@7365admin1/core 2.75.0 → 2.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2725,6 +2725,20 @@ function useUserRepo() {
2725
2725
  throw new InternalServerError5("Failed to update user.");
2726
2726
  }
2727
2727
  }
2728
+ async function updateUserOrgById(id, org, session) {
2729
+ const _id = toObjectId(id);
2730
+ const orgId = toObjectId(org);
2731
+ try {
2732
+ await collection.updateOne(
2733
+ { _id },
2734
+ { $set: { defaultOrg: orgId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
2735
+ { session }
2736
+ );
2737
+ return "Successfully updated user organization.";
2738
+ } catch (error) {
2739
+ throw new InternalServerError5("Failed to update user organization.");
2740
+ }
2741
+ }
2728
2742
  return {
2729
2743
  createIndex,
2730
2744
  createTextIndex,
@@ -2742,7 +2756,8 @@ function useUserRepo() {
2742
2756
  updateDefaultOrgByEmail,
2743
2757
  getUserByEmailStatus,
2744
2758
  updateUserSIDById,
2745
- resetPassword
2759
+ resetPassword,
2760
+ updateUserOrgById
2746
2761
  };
2747
2762
  }
2748
2763
 
@@ -3283,6 +3298,20 @@ function useMemberRepo() {
3283
3298
  { $sort: { _id: -1 } },
3284
3299
  { $skip: page * limit },
3285
3300
  { $limit: limit },
3301
+ {
3302
+ $lookup: {
3303
+ from: "organizations",
3304
+ localField: "org",
3305
+ foreignField: "_id",
3306
+ as: "orgData"
3307
+ }
3308
+ },
3309
+ {
3310
+ $unwind: {
3311
+ path: "$orgData",
3312
+ preserveNullAndEmptyArrays: true
3313
+ }
3314
+ },
3286
3315
  {
3287
3316
  $lookup: {
3288
3317
  from: "organizations",
@@ -3302,7 +3331,16 @@ function useMemberRepo() {
3302
3331
  _id: "$org",
3303
3332
  text: { $first: "$orgName" },
3304
3333
  value: { $first: "$org" },
3305
- defaultSite: { $first: "$defaultSite.defaultSite" }
3334
+ defaultSite: { $first: "$defaultSite.defaultSite" },
3335
+ onboardingRequired: {
3336
+ $first: "$orgData.onboardingRequired"
3337
+ },
3338
+ onboardingCompleted: {
3339
+ $first: "$orgData.onboardingCompleted"
3340
+ },
3341
+ onboardingCompletedAt: {
3342
+ $first: "$orgData.onboardingCompletedAt"
3343
+ }
3306
3344
  }
3307
3345
  },
3308
3346
  {
@@ -3310,15 +3348,16 @@ function useMemberRepo() {
3310
3348
  _id: 0,
3311
3349
  text: 1,
3312
3350
  value: 1,
3313
- defaultSite: 1
3351
+ defaultSite: 1,
3352
+ onboardingRequired: 1,
3353
+ onboardingCompleted: 1,
3354
+ onboardingCompletedAt: 1
3314
3355
  }
3315
3356
  }
3316
3357
  ]).toArray();
3317
3358
  const length = await collection.distinct("org", query).then((orgs) => orgs.length);
3318
3359
  const data = paginate5(items, page, limit, length);
3319
- setCache(cacheKey, data, 15 * 60).then(() => {
3320
- logger8.info(`Cache set for key: ${cacheKey}`);
3321
- }).catch((err) => {
3360
+ setCache(cacheKey, data, 15 * 60).catch((err) => {
3322
3361
  logger8.error(`Failed to set cache for key: ${cacheKey}`, err);
3323
3362
  });
3324
3363
  return data;
@@ -4193,6 +4232,9 @@ var orgSchema = Joi8.object({
4193
4232
  busInst: Joi8.string().optional().allow("", null),
4194
4233
  status: Joi8.string().optional().allow("", null),
4195
4234
  defaultSite: Joi8.string().hex().optional().allow("", null),
4235
+ onboardingRequired: Joi8.boolean().optional(),
4236
+ onboardingCompleted: Joi8.boolean().optional(),
4237
+ onboardingCompletedAt: Joi8.date().optional().allow(null),
4196
4238
  terms: Joi8.string().optional().allow("", null),
4197
4239
  policies: Joi8.string().optional().allow("", null),
4198
4240
  createdAt: Joi8.string().optional().allow("", null),
@@ -4222,6 +4264,9 @@ function MOrg(value) {
4222
4264
  busInst: value.busInst,
4223
4265
  status: value.status || "active",
4224
4266
  defaultSite: value.defaultSite,
4267
+ onboardingRequired: value.onboardingRequired || false,
4268
+ onboardingCompleted: value.onboardingCompleted || false,
4269
+ onboardingCompletedAt: value.onboardingCompletedAt || null,
4225
4270
  terms: value.terms ?? "",
4226
4271
  policies: value.policies ?? "",
4227
4272
  createdAt: value.createdAt || /* @__PURE__ */ new Date(),
@@ -7533,7 +7578,8 @@ function useUserController() {
7533
7578
  "dateOfBirth",
7534
7579
  "profile",
7535
7580
  "gender",
7536
- "defaultOrg"
7581
+ "defaultOrg",
7582
+ "status"
7537
7583
  ).required(),
7538
7584
  value: Joi13.when("field", {
7539
7585
  switch: [
@@ -8974,7 +9020,7 @@ function useOrgController() {
8974
9020
  return;
8975
9021
  }
8976
9022
  try {
8977
- const _id = await _add(req.body);
9023
+ const _id = await _add({ ...req.body, onboardingRequired: true, onboardingCompleted: false, onboardingCompletedAt: null });
8978
9024
  const data = await _getById(_id);
8979
9025
  res.status(201).json({
8980
9026
  message: "Successfully created organization.",
@@ -15377,10 +15423,10 @@ import {
15377
15423
  import { BadRequestError as BadRequestError68, logger as logger49 } from "@7365admin1/node-server-utils";
15378
15424
  import Joi38 from "joi";
15379
15425
  import { ObjectId as ObjectId41 } from "mongodb";
15380
- var VehicleType = /* @__PURE__ */ ((VehicleType2) => {
15381
- VehicleType2["WHITELIST"] = "whitelist";
15382
- VehicleType2["BLOCKLIST"] = "blocklist";
15383
- return VehicleType2;
15426
+ var VehicleType = /* @__PURE__ */ ((VehicleType3) => {
15427
+ VehicleType3["WHITELIST"] = "whitelist";
15428
+ VehicleType3["BLOCKLIST"] = "blocklist";
15429
+ return VehicleType3;
15384
15430
  })(VehicleType || {});
15385
15431
  var VehicleCategory = /* @__PURE__ */ ((VehicleCategory2) => {
15386
15432
  VehicleCategory2["RESIDENT"] = "resident";
@@ -16440,6 +16486,77 @@ function useDahuaDigest({
16440
16486
  streaming
16441
16487
  });
16442
16488
  }
16489
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
16490
+ function isDahuaInvalidAuthority(value) {
16491
+ const text = String(value || "").toLowerCase();
16492
+ return text.includes("invalid authority");
16493
+ }
16494
+ function getDahuaResponseText(response) {
16495
+ return response?.data?.toString?.("utf-8") ?? "";
16496
+ }
16497
+ function getDahuaStatusCode(response) {
16498
+ return response?.statusCode || response?.status || response?.res?.status;
16499
+ }
16500
+ async function useDahuaDigestWithRetry({
16501
+ host,
16502
+ username,
16503
+ password,
16504
+ endpoint,
16505
+ method = "GET",
16506
+ headers = {},
16507
+ timeout = 1e4,
16508
+ streaming = false,
16509
+ retries = 3,
16510
+ retryDelayMs = 0
16511
+ }) {
16512
+ let lastError;
16513
+ for (let attempt = 1; attempt <= retries; attempt++) {
16514
+ try {
16515
+ const response = await useDahuaDigest({
16516
+ host,
16517
+ username,
16518
+ password,
16519
+ endpoint,
16520
+ method,
16521
+ headers,
16522
+ timeout,
16523
+ streaming
16524
+ });
16525
+ const text = getDahuaResponseText(response);
16526
+ const statusCode = getDahuaStatusCode(response);
16527
+ const isOk = statusCode === 200 && text.includes("OK");
16528
+ if (isOk) {
16529
+ return response;
16530
+ }
16531
+ const shouldRetry = isDahuaInvalidAuthority(text);
16532
+ if (shouldRetry && attempt < retries) {
16533
+ loggerDahua.warn(
16534
+ `[${host}] Dahua Invalid Authority. Retrying ${attempt}/${retries}`
16535
+ );
16536
+ if (retryDelayMs > 0) {
16537
+ await sleep(retryDelayMs);
16538
+ }
16539
+ continue;
16540
+ }
16541
+ throw new Error(`Dahua response: ${text || `HTTP ${statusCode}`}`);
16542
+ } catch (error) {
16543
+ lastError = error;
16544
+ const message = error?.message || String(error);
16545
+ const shouldRetry = isDahuaInvalidAuthority(message);
16546
+ if (shouldRetry && attempt < retries) {
16547
+ loggerDahua.warn(
16548
+ `[${host}] Dahua Invalid Authority error. Retrying ${attempt}/${retries}`
16549
+ );
16550
+ if (retryDelayMs > 0) {
16551
+ await sleep(retryDelayMs);
16552
+ }
16553
+ continue;
16554
+ }
16555
+ throw error;
16556
+ }
16557
+ }
16558
+ throw lastError;
16559
+ }
16443
16560
  function createFileNameFromEvent(utcSeconds, utcMilliseconds) {
16444
16561
  const date = new Date(utcSeconds * 1e3 + utcMilliseconds);
16445
16562
  const year = date.getUTCFullYear();
@@ -17090,6 +17207,50 @@ function useDahuaService() {
17090
17207
  );
17091
17208
  }
17092
17209
  }
17210
+ async function openBarrier(value) {
17211
+ const validation = Joi40.object({
17212
+ host: Joi40.string().required(),
17213
+ username: Joi40.string().required(),
17214
+ password: Joi40.string().required(),
17215
+ plateNumber: Joi40.string().required(),
17216
+ channel: Joi40.number().integer().min(1).default(1)
17217
+ });
17218
+ const { error, value: payload } = validation.validate(value, {
17219
+ stripUnknown: true
17220
+ });
17221
+ if (error) {
17222
+ throw new BadRequestError70(`Validation error: ${error.message}`);
17223
+ }
17224
+ try {
17225
+ const query = new URLSearchParams({
17226
+ action: "openStrobe",
17227
+ channel: String(payload.channel),
17228
+ "info.openType": "Normal",
17229
+ "info.plateNumber": payload.plateNumber || "VISITOR"
17230
+ });
17231
+ const endpoint = `/cgi-bin/trafficSnap.cgi?${query.toString()}`;
17232
+ const response = await useDahuaDigestWithRetry({
17233
+ host: payload.host,
17234
+ username: payload.username,
17235
+ password: payload.password,
17236
+ endpoint,
17237
+ retries: 10,
17238
+ retryDelayMs: 0
17239
+ });
17240
+ const text = response?.data?.toString?.("utf-8") ?? "";
17241
+ if (!text.includes("OK")) {
17242
+ throw new Error(`Failed to open barrier. Dahua response: ${text}`);
17243
+ }
17244
+ return {
17245
+ success: true,
17246
+ message: "Barrier opened successfully",
17247
+ raw: text
17248
+ };
17249
+ } catch (error2) {
17250
+ loggerDahua.error(`[${value.host}] Error opening barrier:`, error2);
17251
+ throw error2;
17252
+ }
17253
+ }
17093
17254
  return {
17094
17255
  getSnapshot,
17095
17256
  listenToCamera,
@@ -17097,7 +17258,8 @@ function useDahuaService() {
17097
17258
  removePlateNumber,
17098
17259
  updatePlateNumber,
17099
17260
  getPlateNumber,
17100
- bulkInsertPlateNumber
17261
+ bulkInsertPlateNumber,
17262
+ openBarrier
17101
17263
  };
17102
17264
  }
17103
17265
 
@@ -17304,6 +17466,43 @@ function useSiteCameraRepo() {
17304
17466
  throw new BadRequestError71("Failed to retrieve site cameras.");
17305
17467
  }
17306
17468
  }
17469
+ async function getVisitorsInBySite(site) {
17470
+ try {
17471
+ const pipeline = [
17472
+ { $match: { site: toObjectId9(site), type: "anpr", status: "active", direction: { $in: ["visitors", "entry", "both"] } } },
17473
+ { $limit: 1 },
17474
+ {
17475
+ $lookup: {
17476
+ from: "anpr-settings",
17477
+ localField: "site",
17478
+ foreignField: "site",
17479
+ as: "anprSettingsDetails"
17480
+ }
17481
+ },
17482
+ {
17483
+ $unwind: {
17484
+ path: "$anprSettingsDetails",
17485
+ preserveNullAndEmptyArrays: true
17486
+ }
17487
+ },
17488
+ {
17489
+ $addFields: {
17490
+ ANPRSwitches: "$anprSettingsDetails.ANPRSwitches"
17491
+ }
17492
+ },
17493
+ {
17494
+ $project: { anprSettingsDetails: 0 }
17495
+ }
17496
+ ];
17497
+ const cameras = await collection.aggregate(pipeline).toArray();
17498
+ return cameras?.find((cam) => cam.direction === "visitors" || cam.direction === "entry" || cam.direction === "both");
17499
+ } catch (error) {
17500
+ if (error instanceof BadRequestError71) {
17501
+ throw error;
17502
+ }
17503
+ throw new BadRequestError71("Failed to retrieve site cameras.");
17504
+ }
17505
+ }
17307
17506
  async function getBySiteGuardPost(site, guardPost) {
17308
17507
  try {
17309
17508
  site = new ObjectId43(site);
@@ -17658,6 +17857,7 @@ function useSiteCameraRepo() {
17658
17857
  getAll,
17659
17858
  findSiteCameras,
17660
17859
  getBySite,
17860
+ getVisitorsInBySite,
17661
17861
  getBySites,
17662
17862
  delCachedData,
17663
17863
  getBySiteGuardPost,
@@ -25953,13 +26153,14 @@ function useVisitorTransactionService() {
25953
26153
  getByNRIC,
25954
26154
  updateById: _updateById
25955
26155
  } = usePersonRepo();
25956
- const { getBySite: _getBySite } = useSiteCameraRepo();
26156
+ const { getBySite: _getBySite, getVisitorsInBySite: _getVisitorsInBySite } = useSiteCameraRepo();
25957
26157
  const { getSiteById: _getSiteById } = useSiteRepo();
25958
26158
  const {
25959
26159
  addPlateNumber: _addPlateNumber,
25960
26160
  removePlateNumber: _removePlateNumber,
25961
26161
  getPlateNumber: _getPlateNumber,
25962
- updatePlateNumber: _updatePlateNumber
26162
+ updatePlateNumber: _updatePlateNumber,
26163
+ openBarrier: _openBarrier
25963
26164
  } = useDahuaService();
25964
26165
  const { getAllSites: _getAllSites } = useSiteRepo();
25965
26166
  const { getByUserId: _getByUserId } = usePersonRepo();
@@ -26035,28 +26236,30 @@ function useVisitorTransactionService() {
26035
26236
  "contractor" /* CONTRACTOR */,
26036
26237
  "walk-in" /* WALK_IN */,
26037
26238
  "guest" /* GUEST */,
26038
- "delivery" /* DELIVERY */,
26039
- "pick-up" /* PICK_UP */
26239
+ "delivery" /* DELIVERY */
26240
+ // PersonTypes.PICK_UP,
26040
26241
  ];
26041
26242
  const start = value.checkIn ? new Date(value.checkIn) : /* @__PURE__ */ new Date();
26042
26243
  try {
26043
26244
  session?.startTransaction();
26044
26245
  let camera;
26045
- let site;
26046
- if (value.site) {
26047
- [camera, site] = await Promise.all([
26048
- _getBySite(value.site, { type: "anpr" /* ANPR */ }),
26049
- _getSiteById(value.site)
26050
- ]);
26246
+ if (value.site && value.plateNumber) {
26247
+ try {
26248
+ camera = await _getVisitorsInBySite(value.site);
26249
+ if (!camera) {
26250
+ logger80.warn(`No camera document found for site: ${value.site}`);
26251
+ }
26252
+ } catch (error) {
26253
+ logger80.error(
26254
+ `Error _getVisitorsInBySite camera for site ${value.site}:`,
26255
+ error
26256
+ );
26257
+ }
26051
26258
  }
26052
26259
  if (!value.unitName && value.unit) {
26053
26260
  const unit = await _getUnitById(value.unit);
26054
26261
  value.unitName = unit?.name;
26055
26262
  }
26056
- const hourExpiration = site?.dahuaTimeExpiration ? site?.dahuaTimeExpiration : 24 * 60;
26057
- const end = value.checkOut ? new Date(value.checkOut) : new Date(start.getTime() + hourExpiration * 60 * 1e3);
26058
- const startDahuaDate = formatDahuaDate(start);
26059
- const endDahuaDate = formatDahuaDate(end);
26060
26263
  if (allowedPersonTypes.includes(value?.type)) {
26061
26264
  const nric = value?.nric || "";
26062
26265
  const person = await getByNRIC(nric);
@@ -26093,7 +26296,7 @@ function useVisitorTransactionService() {
26093
26296
  block,
26094
26297
  level,
26095
26298
  unit,
26096
- site: site2,
26299
+ site,
26097
26300
  org,
26098
26301
  type,
26099
26302
  company,
@@ -26149,14 +26352,14 @@ function useVisitorTransactionService() {
26149
26352
  level,
26150
26353
  unit,
26151
26354
  unitName,
26152
- site: site2,
26355
+ site,
26153
26356
  org,
26154
26357
  type,
26155
26358
  company,
26156
26359
  remarks,
26157
26360
  contractorType,
26158
26361
  checkIn: start,
26159
- expiredAt: end,
26362
+ // expiredAt: end,
26160
26363
  visitorPass: visitorPass ?? [],
26161
26364
  passKeys: passKeys ?? [],
26162
26365
  status: "registered" /* REGISTERED */
@@ -26167,11 +26370,13 @@ function useVisitorTransactionService() {
26167
26370
  );
26168
26371
  }
26169
26372
  }
26373
+ let host;
26374
+ let username;
26375
+ let password;
26170
26376
  if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
26171
- const host = camera.host;
26172
- const username = camera.username;
26173
- const password = camera.password;
26174
- const redlist = "TrafficRedList" /* TRAFFIC_REDLIST */;
26377
+ host = camera.host;
26378
+ username = camera.username;
26379
+ password = camera.password;
26175
26380
  const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
26176
26381
  const _plateNumber = value.plateNumber;
26177
26382
  const dahuaBlocklistQuery = {
@@ -26187,74 +26392,6 @@ function useVisitorTransactionService() {
26187
26392
  const found = foundMatch ? Number(foundMatch[1]) : 0;
26188
26393
  if (found === 1)
26189
26394
  throw new BadRequestError100("This plate number is blocklisted");
26190
- const dahuaQuery = {
26191
- host,
26192
- username,
26193
- password,
26194
- plateNumber: _plateNumber,
26195
- mode: redlist
26196
- };
26197
- const raw = await _getPlateNumber(dahuaQuery);
26198
- const parsed = parseDahuaFind(raw);
26199
- if (!parsed.exists) {
26200
- const dahuaPayload = {
26201
- host,
26202
- username,
26203
- password,
26204
- plateNumber: _plateNumber,
26205
- mode: redlist,
26206
- start: startDahuaDate,
26207
- end: endDahuaDate,
26208
- owner: value.name ?? "",
26209
- isOpenGate: site?.isOpenGate ?? true
26210
- };
26211
- const dahuaResponse = await _addPlateNumber(dahuaPayload);
26212
- if (dahuaResponse?.statusCode !== 200) {
26213
- throw new BadRequestError100(
26214
- `Failed to add plate number to ANPR whitelist`
26215
- );
26216
- }
26217
- const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
26218
- value.recNo = responseData.split("=")[1]?.trim();
26219
- value.checkIn = start;
26220
- value.expiredAt = end;
26221
- const vehiclePayload = {
26222
- name: value.name ?? "",
26223
- category: value.type,
26224
- org: value.org,
26225
- site: value.site,
26226
- plateNumber: value.plateNumber,
26227
- type: "whitelist" /* WHITELIST */,
26228
- nric: value.nric,
26229
- start,
26230
- end,
26231
- recNo: value.recNo,
26232
- ...value.block && { block: value.block },
26233
- ...value.level && { level: value.level },
26234
- ...value.unit && { unit: value.unit }
26235
- };
26236
- await addVehicle(vehiclePayload);
26237
- } else {
26238
- const dahuaPayload = {
26239
- host,
26240
- username,
26241
- password,
26242
- plateNumber: _plateNumber,
26243
- recno: parsed.recNo,
26244
- mode: redlist,
26245
- start: startDahuaDate,
26246
- end: endDahuaDate,
26247
- owner: value.name ?? "",
26248
- isOpenGate: site?.isOpenGate ?? true
26249
- };
26250
- const dahuaResponse = await _updatePlateNumber(dahuaPayload);
26251
- if (dahuaResponse?.statusCode !== 200) {
26252
- throw new BadRequestError100(
26253
- `Failed to update plate number to ANPR ${"whitelist" /* WHITELIST */}`
26254
- );
26255
- }
26256
- value.recNo = parsed.recNo;
26257
- }
26258
26395
  }
26259
26396
  if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
26260
26397
  for (const vp of value.visitorPass) {
@@ -26292,6 +26429,27 @@ function useVisitorTransactionService() {
26292
26429
  }
26293
26430
  const result = await _add(value, session);
26294
26431
  await session?.commitTransaction();
26432
+ let openBarrier = null;
26433
+ const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
26434
+ if (isOpenBarrier && value.plateNumber && host && username && password) {
26435
+ try {
26436
+ logger80.info(`Attempting to open barrier at host: ${host}`);
26437
+ openBarrier = await _openBarrier({
26438
+ host,
26439
+ username,
26440
+ password,
26441
+ plateNumber: value?.plateNumber
26442
+ });
26443
+ logger80.info(`Barrier command sent successfully to ${host}`, { response: openBarrier });
26444
+ } catch (error) {
26445
+ logger80.error(
26446
+ `Failed to open barrier at host ${host}. Critical system error:`,
26447
+ error
26448
+ );
26449
+ openBarrier = { success: false, error: error?.message };
26450
+ }
26451
+ }
26452
+ console.log("Open barrier response:", openBarrier);
26295
26453
  return result;
26296
26454
  } catch (error) {
26297
26455
  await session?.abortTransaction();
@@ -26304,6 +26462,43 @@ function useVisitorTransactionService() {
26304
26462
  const session = useAtlas50.getClient()?.startSession();
26305
26463
  session?.startTransaction();
26306
26464
  try {
26465
+ let camera;
26466
+ let host;
26467
+ let username;
26468
+ let password;
26469
+ if (value.site && value.plateNumber) {
26470
+ try {
26471
+ camera = await _getVisitorsInBySite(value.site);
26472
+ if (!camera) {
26473
+ logger80.warn(`No camera document found for site: ${value.site}`);
26474
+ }
26475
+ } catch (error) {
26476
+ logger80.error(
26477
+ `Error _getVisitorsInBySite camera for site ${value.site}:`,
26478
+ error
26479
+ );
26480
+ }
26481
+ }
26482
+ if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
26483
+ host = camera.host;
26484
+ username = camera.username;
26485
+ password = camera.password;
26486
+ const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
26487
+ const _plateNumber = value.plateNumber;
26488
+ const dahuaBlocklistQuery = {
26489
+ host,
26490
+ username,
26491
+ password,
26492
+ plateNumber: _plateNumber,
26493
+ mode: blacklist
26494
+ };
26495
+ const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
26496
+ const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
26497
+ const foundMatch = rawString.match(/found=(\d+)/);
26498
+ const found = foundMatch ? Number(foundMatch[1]) : 0;
26499
+ if (found === 1)
26500
+ throw new BadRequestError100("This plate number is blocklisted");
26501
+ }
26307
26502
  if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
26308
26503
  const keptVisitorPass = [];
26309
26504
  for (const vp of value.visitorPass) {
@@ -26367,6 +26562,34 @@ function useVisitorTransactionService() {
26367
26562
  value.unitName = unit?.name;
26368
26563
  }
26369
26564
  await _updateVisitorTansactionById(id, value, session);
26565
+ const allowedPersonTypes = [
26566
+ "contractor" /* CONTRACTOR */,
26567
+ "walk-in" /* WALK_IN */,
26568
+ "guest" /* GUEST */,
26569
+ "delivery" /* DELIVERY */
26570
+ // PersonTypes.PICK_UP,
26571
+ ];
26572
+ let openBarrier = null;
26573
+ const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
26574
+ if (isOpenBarrier && value.plateNumber && host && username && password) {
26575
+ try {
26576
+ logger80.info(`Attempting to open barrier at host: ${host}`);
26577
+ openBarrier = await _openBarrier({
26578
+ host,
26579
+ username,
26580
+ password,
26581
+ plateNumber: value?.plateNumber
26582
+ });
26583
+ logger80.info(`Barrier command sent successfully to ${host}`, { response: openBarrier });
26584
+ } catch (error) {
26585
+ logger80.error(
26586
+ `Failed to open barrier at host ${host}. Critical system error:`,
26587
+ error
26588
+ );
26589
+ openBarrier = { success: false, error: error?.message };
26590
+ }
26591
+ }
26592
+ console.log("Open barrier response:", openBarrier);
26370
26593
  await session?.commitTransaction();
26371
26594
  return "Successfully updated visitor transaction.";
26372
26595
  } catch (error) {
@@ -27330,6 +27553,7 @@ import {
27330
27553
  compileHandlebar as compileHandlebar3,
27331
27554
  getDirectory as getDirectory3
27332
27555
  } from "@7365admin1/node-server-utils";
27556
+ import { ObjectId as ObjectId64 } from "mongodb";
27333
27557
  function usePersonService() {
27334
27558
  const MailerConfig = {
27335
27559
  host: MAILER_TRANSPORT_HOST,
@@ -27351,7 +27575,8 @@ function usePersonService() {
27351
27575
  createUser: addUser,
27352
27576
  getUserByEmail,
27353
27577
  updateUserFieldById: _updateUserFieldById,
27354
- getUserById
27578
+ getUserById,
27579
+ updateUserOrgById: _updateUserOrgById
27355
27580
  } = useUserRepo();
27356
27581
  const { add: addMember } = useMemberRepo();
27357
27582
  const { getById: _getUnitById, updateById: updateUnitById } = useBuildingUnitRepo();
@@ -27442,8 +27667,27 @@ function usePersonService() {
27442
27667
  }
27443
27668
  await _add(value, session);
27444
27669
  await session.commitTransaction();
27670
+ if (value.email && isValidType && value.platform === "mobile") {
27671
+ const emailContent = compileHandlebar3({
27672
+ context: { name: value.name },
27673
+ filePath: getDirectory3(
27674
+ __dirname,
27675
+ "./public/handlebars/registration-pending"
27676
+ )
27677
+ });
27678
+ mailer.sendMail({
27679
+ to: value.email,
27680
+ subject: "Registration Received \u2013 Pending Review",
27681
+ html: emailContent,
27682
+ sender: "iService365"
27683
+ }).catch((error) => {
27684
+ logger84.error(`Failed to send registration pending email: ${error}`);
27685
+ });
27686
+ }
27445
27687
  return "People added successfully.";
27446
27688
  } catch (error) {
27689
+ console.log("error message service", error);
27690
+ console.log("error message service", error.message);
27447
27691
  logger84.error("Error in people service add:", error);
27448
27692
  await session.abortTransaction();
27449
27693
  throw error;
@@ -27464,7 +27708,21 @@ function usePersonService() {
27464
27708
  }
27465
27709
  const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
27466
27710
  const isOwnerChanged = value.isOwner !== person.isOwner;
27711
+ if (value.org && typeof value.org === "string") {
27712
+ value.org = new ObjectId64(value.org);
27713
+ }
27714
+ if (value.site && typeof value.site === "string") {
27715
+ value.site = new ObjectId64(value.site);
27716
+ }
27717
+ const isOrgChanged = value.org && person.org?.toString() !== value.org.toString();
27467
27718
  await _updateById(_id, value, session);
27719
+ if (isOrgChanged && person.user) {
27720
+ await _updateUserOrgById(
27721
+ person.user.toString(),
27722
+ value.org,
27723
+ session
27724
+ );
27725
+ }
27468
27726
  if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
27469
27727
  const unit = await _getUnitById(value.unit.toString());
27470
27728
  if (unit) {
@@ -27486,7 +27744,11 @@ function usePersonService() {
27486
27744
  updatePayload.ownerName = value.name || "";
27487
27745
  }
27488
27746
  if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
27489
- await updateUnitById(unit._id.toString(), updatePayload, session);
27747
+ await updateUnitById(
27748
+ unit._id.toString(),
27749
+ updatePayload,
27750
+ session
27751
+ );
27490
27752
  }
27491
27753
  }
27492
27754
  }
@@ -27576,13 +27838,13 @@ function usePersonService() {
27576
27838
  title = "We request resubmission for your application";
27577
27839
  hideLogin = false;
27578
27840
  statusLogo = `${statusIconPath}/resubmission-icon.png`;
27579
- message2 = `Hi ${person.name}, please resubmit your application with the required updates.`;
27841
+ message2 = `Hi ${person.name}, please resubmit your application with the required updates.${value.remarks ? ` Remarks: ${value.remarks}` : ""}`;
27580
27842
  break;
27581
27843
  case "rejected":
27582
27844
  userStatus = "rejected";
27583
- title = "Your account request for deletion has been rejected.";
27845
+ title = "Your account request for application has been rejected.";
27584
27846
  statusLogo = `${statusIconPath}/deleted-icon.png`;
27585
- message2 = `Hi ${person.name}, unfortunately your application has been rejected. Please contact support for more information.`;
27847
+ message2 = `Hi ${person.name}, unfortunately your application has been rejected.${value.remarks ? ` Remarks: ${value.remarks}` : " Please contact support for more information."}`;
27586
27848
  break;
27587
27849
  default:
27588
27850
  throw new Error("Invalid review status");
@@ -28019,7 +28281,7 @@ function usePersonController() {
28019
28281
  // src/models/robot.model.ts
28020
28282
  import { BadRequestError as BadRequestError106, logger as logger86 } from "@7365admin1/node-server-utils";
28021
28283
  import Joi61 from "joi";
28022
- import { ObjectId as ObjectId64 } from "mongodb";
28284
+ import { ObjectId as ObjectId65 } from "mongodb";
28023
28285
  var metadataSchema4 = {
28024
28286
  orgId: Joi61.string().hex().optional().allow("", null),
28025
28287
  siteId: Joi61.string().hex().optional().allow("", null),
@@ -28044,21 +28306,21 @@ function MRobot(value) {
28044
28306
  }
28045
28307
  if (value.metadata?.orgId) {
28046
28308
  try {
28047
- value.metadata.orgId = new ObjectId64(value.metadata.orgId);
28309
+ value.metadata.orgId = new ObjectId65(value.metadata.orgId);
28048
28310
  } catch (error2) {
28049
28311
  throw new BadRequestError106("Invalid organization ID format.");
28050
28312
  }
28051
28313
  }
28052
28314
  if (value.metadata?.siteId) {
28053
28315
  try {
28054
- value.metadata.siteId = new ObjectId64(value.metadata.siteId);
28316
+ value.metadata.siteId = new ObjectId65(value.metadata.siteId);
28055
28317
  } catch (error2) {
28056
28318
  throw new BadRequestError106("Invalid site ID format.");
28057
28319
  }
28058
28320
  }
28059
28321
  if (value.metadata?.administratorId) {
28060
28322
  try {
28061
- value.metadata.administratorId = new ObjectId64(
28323
+ value.metadata.administratorId = new ObjectId65(
28062
28324
  value.metadata.administratorId
28063
28325
  );
28064
28326
  } catch (error2) {
@@ -28067,7 +28329,7 @@ function MRobot(value) {
28067
28329
  }
28068
28330
  if (value.createdBy) {
28069
28331
  try {
28070
- value.createdBy = new ObjectId64(value.createdBy);
28332
+ value.createdBy = new ObjectId65(value.createdBy);
28071
28333
  } catch (error2) {
28072
28334
  throw new BadRequestError106("Invalid created by ID format.");
28073
28335
  }
@@ -28092,7 +28354,7 @@ function MRobot(value) {
28092
28354
  }
28093
28355
 
28094
28356
  // src/repositories/robot.repo.ts
28095
- import { ObjectId as ObjectId65 } from "mongodb";
28357
+ import { ObjectId as ObjectId66 } from "mongodb";
28096
28358
  import {
28097
28359
  useAtlas as useAtlas54,
28098
28360
  InternalServerError as InternalServerError35,
@@ -28161,12 +28423,12 @@ function useRobotRepo() {
28161
28423
  }) {
28162
28424
  page = page > 0 ? page - 1 : 0;
28163
28425
  try {
28164
- organization = new ObjectId65(organization);
28426
+ organization = new ObjectId66(organization);
28165
28427
  } catch (error) {
28166
28428
  throw new BadRequestError107("Invalid organization ID format.");
28167
28429
  }
28168
28430
  try {
28169
- site = new ObjectId65(site);
28431
+ site = new ObjectId66(site);
28170
28432
  } catch (error) {
28171
28433
  throw new BadRequestError107("Invalid site ID format.");
28172
28434
  }
@@ -28389,7 +28651,7 @@ function useRobotController() {
28389
28651
 
28390
28652
  // src/models/patrol-question.model.ts
28391
28653
  import { BadRequestError as BadRequestError110, logger as logger89 } from "@7365admin1/node-server-utils";
28392
- import { ObjectId as ObjectId66 } from "mongodb";
28654
+ import { ObjectId as ObjectId67 } from "mongodb";
28393
28655
  import Joi63 from "joi";
28394
28656
  var schemaPatrolQuestion = Joi63.object({
28395
28657
  _id: Joi63.string().hex().optional(),
@@ -28415,14 +28677,14 @@ function MPatrolQuestion(value) {
28415
28677
  }
28416
28678
  if (value._id && typeof value._id === "string") {
28417
28679
  try {
28418
- value._id = new ObjectId66(value._id);
28680
+ value._id = new ObjectId67(value._id);
28419
28681
  } catch {
28420
28682
  throw new BadRequestError110("Invalid _id format");
28421
28683
  }
28422
28684
  }
28423
28685
  return {
28424
- _id: value._id ?? new ObjectId66(),
28425
- site: new ObjectId66(value.site),
28686
+ _id: value._id ?? new ObjectId67(),
28687
+ site: new ObjectId67(value.site),
28426
28688
  question: value.question,
28427
28689
  answers: value.answers,
28428
28690
  status: value.status ?? "active",
@@ -28443,7 +28705,7 @@ import {
28443
28705
  useAtlas as useAtlas55,
28444
28706
  useCache as useCache35
28445
28707
  } from "@7365admin1/node-server-utils";
28446
- import { ObjectId as ObjectId67 } from "mongodb";
28708
+ import { ObjectId as ObjectId68 } from "mongodb";
28447
28709
  function usePatrolQuestionRepo() {
28448
28710
  const db = useAtlas55.getDb();
28449
28711
  if (!db) {
@@ -28522,7 +28784,7 @@ function usePatrolQuestionRepo() {
28522
28784
  { answers: { $regex: search, $options: "i" } }
28523
28785
  ]
28524
28786
  },
28525
- ...ObjectId67.isValid(site) && { site: new ObjectId67(site) }
28787
+ ...ObjectId68.isValid(site) && { site: new ObjectId68(site) }
28526
28788
  };
28527
28789
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
28528
28790
  const cacheOptions = {
@@ -28562,7 +28824,7 @@ function usePatrolQuestionRepo() {
28562
28824
  }
28563
28825
  async function updateById(_id, value, session) {
28564
28826
  try {
28565
- _id = new ObjectId67(_id);
28827
+ _id = new ObjectId68(_id);
28566
28828
  } catch (error) {
28567
28829
  throw new BadRequestError111(
28568
28830
  "Invalid patrol question transaction ID format."
@@ -28583,7 +28845,7 @@ function usePatrolQuestionRepo() {
28583
28845
  }
28584
28846
  async function deleteById(_id) {
28585
28847
  try {
28586
- _id = new ObjectId67(_id);
28848
+ _id = new ObjectId68(_id);
28587
28849
  } catch (error) {
28588
28850
  throw new BadRequestError111("Invalid customer ID format.");
28589
28851
  }
@@ -28605,7 +28867,7 @@ function usePatrolQuestionRepo() {
28605
28867
  }
28606
28868
  async function getById(_id, session) {
28607
28869
  try {
28608
- _id = new ObjectId67(_id);
28870
+ _id = new ObjectId68(_id);
28609
28871
  } catch (error) {
28610
28872
  throw new BadRequestError111("Invalid patrol question ID format.");
28611
28873
  }
@@ -28780,7 +29042,7 @@ function usePatrolQuestionController() {
28780
29042
 
28781
29043
  // src/models/patrol-route.model.ts
28782
29044
  import { BadRequestError as BadRequestError113, logger as logger92 } from "@7365admin1/node-server-utils";
28783
- import { ObjectId as ObjectId68 } from "mongodb";
29045
+ import { ObjectId as ObjectId69 } from "mongodb";
28784
29046
  import Joi65 from "joi";
28785
29047
  var schemeCamera = Joi65.object({
28786
29048
  camera: Joi65.string().hex().required(),
@@ -28828,14 +29090,14 @@ function MPatrolRoute(value) {
28828
29090
  }
28829
29091
  if (value._id && typeof value._id === "string") {
28830
29092
  try {
28831
- value._id = new ObjectId68(value._id);
29093
+ value._id = new ObjectId69(value._id);
28832
29094
  } catch {
28833
29095
  throw new BadRequestError113("Invalid _id format");
28834
29096
  }
28835
29097
  }
28836
29098
  if (value.assignee && Array.isArray(value.assignee)) {
28837
29099
  try {
28838
- value.assignee = value.assignee.map((id) => new ObjectId68(id));
29100
+ value.assignee = value.assignee.map((id) => new ObjectId69(id));
28839
29101
  } catch {
28840
29102
  throw new BadRequestError113("Invalid assignee id format");
28841
29103
  }
@@ -28844,7 +29106,7 @@ function MPatrolRoute(value) {
28844
29106
  value.cameras = value.cameras.map((camera) => {
28845
29107
  if (typeof camera.camera === "string") {
28846
29108
  try {
28847
- camera.camera = new ObjectId68(camera.camera);
29109
+ camera.camera = new ObjectId69(camera.camera);
28848
29110
  } catch {
28849
29111
  throw new BadRequestError113("Invalid camera id format");
28850
29112
  }
@@ -28852,7 +29114,7 @@ function MPatrolRoute(value) {
28852
29114
  camera.questions = camera.questions.map((question) => {
28853
29115
  if (typeof question.questionId === "string") {
28854
29116
  try {
28855
- question.questionId = new ObjectId68(question.questionId);
29117
+ question.questionId = new ObjectId69(question.questionId);
28856
29118
  } catch {
28857
29119
  throw new BadRequestError113("Invalid question id format");
28858
29120
  }
@@ -28863,8 +29125,8 @@ function MPatrolRoute(value) {
28863
29125
  });
28864
29126
  }
28865
29127
  return {
28866
- _id: value._id ?? new ObjectId68(),
28867
- site: new ObjectId68(value.site),
29128
+ _id: value._id ?? new ObjectId69(),
29129
+ site: new ObjectId69(value.site),
28868
29130
  name: value.name,
28869
29131
  assignee: value.assignee,
28870
29132
  start: value.start,
@@ -28890,7 +29152,7 @@ import {
28890
29152
  useAtlas as useAtlas56,
28891
29153
  useCache as useCache36
28892
29154
  } from "@7365admin1/node-server-utils";
28893
- import { ObjectId as ObjectId69 } from "mongodb";
29155
+ import { ObjectId as ObjectId70 } from "mongodb";
28894
29156
  function usePatrolRouteRepo() {
28895
29157
  const db = useAtlas56.getDb();
28896
29158
  if (!db) {
@@ -28966,7 +29228,7 @@ function usePatrolRouteRepo() {
28966
29228
  page = page > 0 ? page - 1 : 0;
28967
29229
  const query = {
28968
29230
  status,
28969
- ...ObjectId69.isValid(site) && { site: new ObjectId69(site) }
29231
+ ...ObjectId70.isValid(site) && { site: new ObjectId70(site) }
28970
29232
  };
28971
29233
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
28972
29234
  const cacheOptions = {
@@ -29049,20 +29311,20 @@ function usePatrolRouteRepo() {
29049
29311
  }
29050
29312
  async function updateById(_id, value, session) {
29051
29313
  try {
29052
- _id = new ObjectId69(_id);
29314
+ _id = new ObjectId70(_id);
29053
29315
  } catch (error) {
29054
29316
  throw new BadRequestError114("Invalid patrol route transaction ID format.");
29055
29317
  }
29056
- if (value.site && ObjectId69.isValid(value.site.toString())) {
29318
+ if (value.site && ObjectId70.isValid(value.site.toString())) {
29057
29319
  try {
29058
- value.site = new ObjectId69(value.site.toString());
29320
+ value.site = new ObjectId70(value.site.toString());
29059
29321
  } catch {
29060
29322
  throw new BadRequestError114("Invalid _id format");
29061
29323
  }
29062
29324
  }
29063
29325
  if (value.assignee && Array.isArray(value.assignee)) {
29064
29326
  try {
29065
- value.assignee = value.assignee.map((id) => new ObjectId69(id));
29327
+ value.assignee = value.assignee.map((id) => new ObjectId70(id));
29066
29328
  } catch {
29067
29329
  throw new BadRequestError114("Invalid _id format");
29068
29330
  }
@@ -29082,7 +29344,7 @@ function usePatrolRouteRepo() {
29082
29344
  }
29083
29345
  async function deleteById(_id) {
29084
29346
  try {
29085
- _id = new ObjectId69(_id);
29347
+ _id = new ObjectId70(_id);
29086
29348
  } catch (error) {
29087
29349
  throw new BadRequestError114("Invalid patrol route transaction ID format.");
29088
29350
  }
@@ -29131,7 +29393,7 @@ function usePatrolRouteRepo() {
29131
29393
  const query = {
29132
29394
  status,
29133
29395
  ...search && { $text: { $search: search } },
29134
- ...ObjectId69.isValid(site) && { site: new ObjectId69(site) }
29396
+ ...ObjectId70.isValid(site) && { site: new ObjectId70(site) }
29135
29397
  };
29136
29398
  if (day && start) {
29137
29399
  const [hour, minute] = start?.split(":") ?? ["0", "0"];
@@ -29214,7 +29476,7 @@ function usePatrolRouteRepo() {
29214
29476
  id: "$_id",
29215
29477
  start: startOfDay,
29216
29478
  end: endOfDay,
29217
- site: ObjectId69.isValid(site) ? new ObjectId69(site) : null
29479
+ site: ObjectId70.isValid(site) ? new ObjectId70(site) : null
29218
29480
  },
29219
29481
  pipeline: [
29220
29482
  {
@@ -29260,7 +29522,7 @@ function usePatrolRouteRepo() {
29260
29522
  }
29261
29523
  async function getById(_id, session) {
29262
29524
  try {
29263
- _id = new ObjectId69(_id);
29525
+ _id = new ObjectId70(_id);
29264
29526
  } catch (error) {
29265
29527
  throw new BadRequestError114("Invalid patrol log ID format.");
29266
29528
  }
@@ -29505,7 +29767,7 @@ function usePatrolRouteController() {
29505
29767
 
29506
29768
  // src/models/patrol-log.model.ts
29507
29769
  import { BadRequestError as BadRequestError116, logger as logger95 } from "@7365admin1/node-server-utils";
29508
- import { ObjectId as ObjectId70 } from "mongodb";
29770
+ import { ObjectId as ObjectId71 } from "mongodb";
29509
29771
  import Joi67 from "joi";
29510
29772
  var schemeLogCamera = Joi67.object({
29511
29773
  camera: Joi67.string().hex().required(),
@@ -29566,41 +29828,41 @@ function MPatrolLog(value) {
29566
29828
  }
29567
29829
  if (value._id && typeof value._id === "string") {
29568
29830
  try {
29569
- value._id = new ObjectId70(value._id);
29831
+ value._id = new ObjectId71(value._id);
29570
29832
  } catch {
29571
29833
  throw new BadRequestError116("Invalid _id format");
29572
29834
  }
29573
29835
  }
29574
29836
  if (value.route && typeof value.route === "string") {
29575
29837
  try {
29576
- value.route = new ObjectId70(value.route);
29838
+ value.route = new ObjectId71(value.route);
29577
29839
  } catch {
29578
29840
  throw new BadRequestError116("Invalid route id format");
29579
29841
  }
29580
29842
  }
29581
29843
  if (value.site && typeof value.site === "string") {
29582
29844
  try {
29583
- value.site = new ObjectId70(value.site);
29845
+ value.site = new ObjectId71(value.site);
29584
29846
  } catch {
29585
29847
  throw new BadRequestError116("Invalid site id format");
29586
29848
  }
29587
29849
  }
29588
29850
  const assignee = (value.assignee || []).map((id) => {
29589
29851
  try {
29590
- return new ObjectId70(id);
29852
+ return new ObjectId71(id);
29591
29853
  } catch {
29592
29854
  throw new BadRequestError116("Invalid assignee id format");
29593
29855
  }
29594
29856
  });
29595
29857
  if (value.incidentReport && typeof value.incidentReport.id === "string") {
29596
29858
  try {
29597
- value.incidentReport.id = new ObjectId70(value.incidentReport.id);
29859
+ value.incidentReport.id = new ObjectId71(value.incidentReport.id);
29598
29860
  } catch {
29599
29861
  throw new BadRequestError116("Invalid incident report id format");
29600
29862
  }
29601
29863
  }
29602
29864
  return {
29603
- _id: value._id ?? new ObjectId70(),
29865
+ _id: value._id ?? new ObjectId71(),
29604
29866
  site: value.site,
29605
29867
  name: value.name,
29606
29868
  assignee,
@@ -29628,7 +29890,7 @@ import {
29628
29890
  useAtlas as useAtlas57,
29629
29891
  useCache as useCache37
29630
29892
  } from "@7365admin1/node-server-utils";
29631
- import { ObjectId as ObjectId71 } from "mongodb";
29893
+ import { ObjectId as ObjectId72 } from "mongodb";
29632
29894
  function usePatrolLogRepo() {
29633
29895
  const db = useAtlas57.getDb();
29634
29896
  if (!db) {
@@ -29719,7 +29981,7 @@ function usePatrolLogRepo() {
29719
29981
  };
29720
29982
  }
29721
29983
  const query = {
29722
- ...ObjectId71.isValid(site) && { site: new ObjectId71(site) },
29984
+ ...ObjectId72.isValid(site) && { site: new ObjectId72(site) },
29723
29985
  ...dateExpr
29724
29986
  };
29725
29987
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -29859,7 +30121,7 @@ function usePatrolLogRepo() {
29859
30121
  }
29860
30122
  async function updateById(_id, value, session) {
29861
30123
  try {
29862
- _id = new ObjectId71(_id);
30124
+ _id = new ObjectId72(_id);
29863
30125
  } catch (error) {
29864
30126
  throw new BadRequestError117("Invalid patrol log transaction ID format.");
29865
30127
  }
@@ -29878,7 +30140,7 @@ function usePatrolLogRepo() {
29878
30140
  }
29879
30141
  async function deleteById(_id, session) {
29880
30142
  try {
29881
- _id = new ObjectId71(_id);
30143
+ _id = new ObjectId72(_id);
29882
30144
  } catch (error) {
29883
30145
  throw new BadRequestError117("Invalid patrol log ID format.");
29884
30146
  }
@@ -29892,7 +30154,7 @@ function usePatrolLogRepo() {
29892
30154
  }
29893
30155
  async function getById(_id, session) {
29894
30156
  try {
29895
- _id = new ObjectId71(_id);
30157
+ _id = new ObjectId72(_id);
29896
30158
  } catch (error) {
29897
30159
  throw new BadRequestError117("Invalid patrol log ID format.");
29898
30160
  }
@@ -30145,7 +30407,7 @@ function usePatrolLogController() {
30145
30407
 
30146
30408
  // src/models/site-facility.model.ts
30147
30409
  import Joi69 from "joi";
30148
- import { ObjectId as ObjectId72 } from "mongodb";
30410
+ import { ObjectId as ObjectId73 } from "mongodb";
30149
30411
  var timeSlotSchema = Joi69.array().items(
30150
30412
  Joi69.object({
30151
30413
  start: Joi69.string().optional().allow("", null),
@@ -30305,28 +30567,28 @@ function MSiteFacility(value) {
30305
30567
  throw new Error(error.details[0].message);
30306
30568
  if (value._id && typeof value._id === "string") {
30307
30569
  try {
30308
- value._id = new ObjectId72(value._id);
30570
+ value._id = new ObjectId73(value._id);
30309
30571
  } catch {
30310
30572
  throw new Error("Invalid _id.");
30311
30573
  }
30312
30574
  }
30313
30575
  if (value.site && typeof value.site === "string") {
30314
30576
  try {
30315
- value.site = new ObjectId72(value.site);
30577
+ value.site = new ObjectId73(value.site);
30316
30578
  } catch {
30317
30579
  throw new Error("Invalid _id.");
30318
30580
  }
30319
30581
  }
30320
30582
  if (value.featuredImage && typeof value.featuredImage === "string") {
30321
30583
  try {
30322
- value.featuredImage = new ObjectId72(value.featuredImage);
30584
+ value.featuredImage = new ObjectId73(value.featuredImage);
30323
30585
  } catch {
30324
30586
  throw new Error("Invalid featuredImage ID.");
30325
30587
  }
30326
30588
  }
30327
30589
  if (Array.isArray(value.gallery)) {
30328
30590
  try {
30329
- value.gallery = value.gallery.map((id) => new ObjectId72(id));
30591
+ value.gallery = value.gallery.map((id) => new ObjectId73(id));
30330
30592
  } catch {
30331
30593
  throw new Error("Invalid ID in gallery array.");
30332
30594
  }
@@ -30419,7 +30681,7 @@ import {
30419
30681
  useAtlas as useAtlas59,
30420
30682
  useCache as useCache38
30421
30683
  } from "@7365admin1/node-server-utils";
30422
- import { ObjectId as ObjectId73 } from "mongodb";
30684
+ import { ObjectId as ObjectId74 } from "mongodb";
30423
30685
  function useSiteFacilityRepo() {
30424
30686
  const db = useAtlas59.getDb();
30425
30687
  if (!db) {
@@ -30487,7 +30749,7 @@ function useSiteFacilityRepo() {
30487
30749
  };
30488
30750
  if (site) {
30489
30751
  try {
30490
- site = new ObjectId73(site);
30752
+ site = new ObjectId74(site);
30491
30753
  query.site = site;
30492
30754
  cacheOptions.site = site.toString();
30493
30755
  } catch (error) {
@@ -30532,7 +30794,7 @@ function useSiteFacilityRepo() {
30532
30794
  }
30533
30795
  async function getSiteFacilityById(_id, session) {
30534
30796
  try {
30535
- _id = new ObjectId73(_id);
30797
+ _id = new ObjectId74(_id);
30536
30798
  } catch (error) {
30537
30799
  throw new BadRequestError120("Invalid site facility ID format.");
30538
30800
  }
@@ -30560,20 +30822,20 @@ function useSiteFacilityRepo() {
30560
30822
  async function updateSiteFacilityById(_id, value, session) {
30561
30823
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
30562
30824
  try {
30563
- _id = new ObjectId73(_id);
30825
+ _id = new ObjectId74(_id);
30564
30826
  } catch (error) {
30565
30827
  throw new BadRequestError120("Invalid ID format.");
30566
30828
  }
30567
30829
  if (value.featuredImage) {
30568
30830
  try {
30569
- value.featuredImage = new ObjectId73(value.featuredImage);
30831
+ value.featuredImage = new ObjectId74(value.featuredImage);
30570
30832
  } catch (error) {
30571
30833
  throw new BadRequestError120("Invalid ID format for featured image.");
30572
30834
  }
30573
30835
  }
30574
30836
  if (Array.isArray(value.gallery)) {
30575
30837
  try {
30576
- value.gallery = value.gallery.map((id) => new ObjectId73(id));
30838
+ value.gallery = value.gallery.map((id) => new ObjectId74(id));
30577
30839
  } catch {
30578
30840
  throw new Error("Invalid ID in gallery array.");
30579
30841
  }
@@ -30619,7 +30881,7 @@ function useSiteFacilityRepo() {
30619
30881
  }
30620
30882
  async function deleteSiteFacilityById(_id) {
30621
30883
  try {
30622
- _id = new ObjectId73(_id);
30884
+ _id = new ObjectId74(_id);
30623
30885
  } catch (error) {
30624
30886
  throw new BadRequestError120("Invalid site facility ID format.");
30625
30887
  }
@@ -30648,12 +30910,12 @@ function useSiteFacilityRepo() {
30648
30910
  }
30649
30911
  async function getSiteFacilityTimeSlotById(_id, site, session) {
30650
30912
  try {
30651
- _id = new ObjectId73(_id);
30913
+ _id = new ObjectId74(_id);
30652
30914
  } catch (error) {
30653
30915
  throw new BadRequestError120("Invalid facility ID format.");
30654
30916
  }
30655
30917
  try {
30656
- site = new ObjectId73(site);
30918
+ site = new ObjectId74(site);
30657
30919
  } catch (error) {
30658
30920
  throw new BadRequestError120("Invalid site ID format.");
30659
30921
  }
@@ -30996,7 +31258,7 @@ function useSiteFacilityController() {
30996
31258
 
30997
31259
  // src/models/service-provider-billing.model.ts
30998
31260
  import Joi71 from "joi";
30999
- import { ObjectId as ObjectId74 } from "mongodb";
31261
+ import { ObjectId as ObjectId75 } from "mongodb";
31000
31262
  var schemaServiceProviderBilling = Joi71.object({
31001
31263
  _id: Joi71.string().hex().optional().allow("", null),
31002
31264
  attachments: Joi71.array().items(Joi71.string().hex()).required(),
@@ -31030,7 +31292,7 @@ function MServiceProviderBilling(value) {
31030
31292
  }
31031
31293
  if (value._id && typeof value._id === "string") {
31032
31294
  try {
31033
- value._id = new ObjectId74(value._id);
31295
+ value._id = new ObjectId75(value._id);
31034
31296
  } catch {
31035
31297
  throw new Error("Invalid ID.");
31036
31298
  }
@@ -31039,7 +31301,7 @@ function MServiceProviderBilling(value) {
31039
31301
  value.acknowledgedBy = value.acknowledgedBy.map((item) => {
31040
31302
  if (item.user && typeof item.user === "string") {
31041
31303
  try {
31042
- item.user = new ObjectId74(item.user);
31304
+ item.user = new ObjectId75(item.user);
31043
31305
  } catch (error2) {
31044
31306
  throw new Error("Invalid ID format for acknowledgedBy.user.");
31045
31307
  }
@@ -31049,13 +31311,13 @@ function MServiceProviderBilling(value) {
31049
31311
  }
31050
31312
  if (value.orgId && typeof value.orgId === "string") {
31051
31313
  try {
31052
- value.orgId = new ObjectId74(value.orgId);
31314
+ value.orgId = new ObjectId75(value.orgId);
31053
31315
  } catch {
31054
31316
  throw new Error("Invalid org ID.");
31055
31317
  }
31056
31318
  }
31057
31319
  return {
31058
- _id: value._id ?? new ObjectId74(),
31320
+ _id: value._id ?? new ObjectId75(),
31059
31321
  attachments: value.attachments,
31060
31322
  acknowledgedBy: value.acknowledgedBy || [],
31061
31323
  status: value.status,
@@ -31077,7 +31339,7 @@ import {
31077
31339
  useAtlas as useAtlas61,
31078
31340
  useCache as useCache39
31079
31341
  } from "@7365admin1/node-server-utils";
31080
- import { ObjectId as ObjectId75 } from "mongodb";
31342
+ import { ObjectId as ObjectId76 } from "mongodb";
31081
31343
  function useServiceProviderBillingRepo() {
31082
31344
  const db = useAtlas61.getDb();
31083
31345
  if (!db) {
@@ -31124,7 +31386,7 @@ function useServiceProviderBillingRepo() {
31124
31386
  }, session) {
31125
31387
  page = page > 0 ? page - 1 : 0;
31126
31388
  try {
31127
- org = new ObjectId75(org);
31389
+ org = new ObjectId76(org);
31128
31390
  } catch (error) {
31129
31391
  throw new BadRequestError122("Invalid org ID format.");
31130
31392
  }
@@ -31174,7 +31436,7 @@ function useServiceProviderBillingRepo() {
31174
31436
  }
31175
31437
  async function getSiteServiceProviderBillingById(_id, session) {
31176
31438
  try {
31177
- _id = new ObjectId75(_id);
31439
+ _id = new ObjectId76(_id);
31178
31440
  } catch (error) {
31179
31441
  throw new BadRequestError122("Invalid service provider billing ID format.");
31180
31442
  }
@@ -31202,7 +31464,7 @@ function useServiceProviderBillingRepo() {
31202
31464
  async function updateServiceProviderBillingById(_id, value, session) {
31203
31465
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
31204
31466
  try {
31205
- _id = new ObjectId75(_id);
31467
+ _id = new ObjectId76(_id);
31206
31468
  } catch (error) {
31207
31469
  throw new BadRequestError122("Invalid ID format.");
31208
31470
  }
@@ -31210,7 +31472,7 @@ function useServiceProviderBillingRepo() {
31210
31472
  value.acknowledgedBy = value.acknowledgedBy.map((item) => {
31211
31473
  if (item.user && typeof item.user === "string") {
31212
31474
  try {
31213
- item.user = new ObjectId75(item.user);
31475
+ item.user = new ObjectId76(item.user);
31214
31476
  } catch (error) {
31215
31477
  throw new Error("Invalid ID format for acknowledgedBy.user.");
31216
31478
  }
@@ -31244,7 +31506,7 @@ function useServiceProviderBillingRepo() {
31244
31506
  }
31245
31507
  async function deleteServiceProviderBillingById(_id) {
31246
31508
  try {
31247
- _id = new ObjectId75(_id);
31509
+ _id = new ObjectId76(_id);
31248
31510
  } catch (error) {
31249
31511
  throw new BadRequestError122("Invalid service provider billing ID format.");
31250
31512
  }
@@ -31482,7 +31744,7 @@ function useServiceProviderBillingController() {
31482
31744
 
31483
31745
  // src/models/site-facility-booking.model.ts
31484
31746
  import Joi73 from "joi";
31485
- import { ObjectId as ObjectId76 } from "mongodb";
31747
+ import { ObjectId as ObjectId77 } from "mongodb";
31486
31748
  var FacilitySort = /* @__PURE__ */ ((FacilitySort2) => {
31487
31749
  FacilitySort2["CREATED_AT"] = "createdAt";
31488
31750
  FacilitySort2["NAME"] = "name";
@@ -31592,48 +31854,48 @@ function MSiteFacilityBooking(value) {
31592
31854
  }
31593
31855
  if (value._id && typeof value._id === "string") {
31594
31856
  try {
31595
- value._id = new ObjectId76(value._id);
31857
+ value._id = new ObjectId77(value._id);
31596
31858
  } catch {
31597
31859
  throw new Error("Invalid ID.");
31598
31860
  }
31599
31861
  }
31600
31862
  if (value.site && typeof value.site === "string") {
31601
31863
  try {
31602
- value.site = new ObjectId76(value.site);
31864
+ value.site = new ObjectId77(value.site);
31603
31865
  } catch {
31604
31866
  throw new Error("Invalid site ID.");
31605
31867
  }
31606
31868
  }
31607
31869
  if (value.user && typeof value.user === "string") {
31608
31870
  try {
31609
- value.user = new ObjectId76(value.user);
31871
+ value.user = new ObjectId77(value.user);
31610
31872
  } catch {
31611
31873
  throw new Error("Invalid user ID.");
31612
31874
  }
31613
31875
  }
31614
31876
  if (value.approvedBy && typeof value.approvedBy === "string") {
31615
31877
  try {
31616
- value.approvedBy = new ObjectId76(value.approvedBy);
31878
+ value.approvedBy = new ObjectId77(value.approvedBy);
31617
31879
  } catch {
31618
31880
  throw new Error("Invalid approved by ID.");
31619
31881
  }
31620
31882
  }
31621
31883
  if (value.createdBy && typeof value.createdBy === "string") {
31622
31884
  try {
31623
- value.createdBy = new ObjectId76(value.createdBy);
31885
+ value.createdBy = new ObjectId77(value.createdBy);
31624
31886
  } catch {
31625
31887
  throw new Error("Invalid created by ID.");
31626
31888
  }
31627
31889
  }
31628
31890
  if (value.updatedBy && typeof value.updatedBy === "string") {
31629
31891
  try {
31630
- value.updatedBy = new ObjectId76(value.updatedBy);
31892
+ value.updatedBy = new ObjectId77(value.updatedBy);
31631
31893
  } catch {
31632
31894
  throw new Error("Invalid updated by ID.");
31633
31895
  }
31634
31896
  }
31635
31897
  return {
31636
- _id: value._id ?? new ObjectId76(),
31898
+ _id: value._id ?? new ObjectId77(),
31637
31899
  facility: value.facility ?? "",
31638
31900
  slot: value.slot ?? "",
31639
31901
  slotName: value.slotName ?? "",
@@ -31729,7 +31991,7 @@ import {
31729
31991
  useAtlas as useAtlas63,
31730
31992
  useCache as useCache40
31731
31993
  } from "@7365admin1/node-server-utils";
31732
- import { ObjectId as ObjectId77 } from "mongodb";
31994
+ import { ObjectId as ObjectId78 } from "mongodb";
31733
31995
  var facility_bookings_namespace_collection = "site.facilty-booking";
31734
31996
  function useSiteFacilityBookingRepo() {
31735
31997
  const db = useAtlas63.getDb();
@@ -31892,7 +32154,7 @@ function useSiteFacilityBookingRepo() {
31892
32154
  }
31893
32155
  async function deleteSiteFacilityBookingById(_id) {
31894
32156
  try {
31895
- _id = new ObjectId77(_id);
32157
+ _id = new ObjectId78(_id);
31896
32158
  } catch (error) {
31897
32159
  throw new BadRequestError124("Invalid site facility booking ID format.");
31898
32160
  }
@@ -32129,7 +32391,7 @@ function useSiteFacilityBookingController() {
32129
32391
 
32130
32392
  // src/models/document-management.model.ts
32131
32393
  import Joi75 from "joi";
32132
- import { ObjectId as ObjectId78 } from "mongodb";
32394
+ import { ObjectId as ObjectId79 } from "mongodb";
32133
32395
  var schemaDocumentManagement = Joi75.object({
32134
32396
  _id: Joi75.string().hex().optional().allow("", null),
32135
32397
  name: Joi75.string().required(),
@@ -32167,28 +32429,28 @@ function MDocumentManagement(value) {
32167
32429
  }
32168
32430
  if (value._id && typeof value._id === "string") {
32169
32431
  try {
32170
- value._id = new ObjectId78(value._id);
32432
+ value._id = new ObjectId79(value._id);
32171
32433
  } catch (error2) {
32172
32434
  throw new Error("Invalid ID.");
32173
32435
  }
32174
32436
  }
32175
32437
  if (value.org && typeof value.org === "string") {
32176
32438
  try {
32177
- value.org = new ObjectId78(value.org);
32439
+ value.org = new ObjectId79(value.org);
32178
32440
  } catch (error2) {
32179
32441
  throw new Error("Invalid org ID.");
32180
32442
  }
32181
32443
  }
32182
32444
  if (value.site && typeof value.site === "string") {
32183
32445
  try {
32184
- value.site = new ObjectId78(value.site);
32446
+ value.site = new ObjectId79(value.site);
32185
32447
  } catch (error2) {
32186
32448
  throw new Error("Invalid site ID.");
32187
32449
  }
32188
32450
  }
32189
32451
  if (value.parentId && typeof value.parentId === "string") {
32190
32452
  try {
32191
- value.parentId = new ObjectId78(value.parentId);
32453
+ value.parentId = new ObjectId79(value.parentId);
32192
32454
  } catch (error2) {
32193
32455
  throw new Error("Invalid parentId.");
32194
32456
  }
@@ -32222,7 +32484,7 @@ import {
32222
32484
  useAtlas as useAtlas65,
32223
32485
  useCache as useCache41
32224
32486
  } from "@7365admin1/node-server-utils";
32225
- import { ObjectId as ObjectId79 } from "mongodb";
32487
+ import { ObjectId as ObjectId80 } from "mongodb";
32226
32488
  function useDocumentManagementRepo() {
32227
32489
  const db = useAtlas65.getDb();
32228
32490
  if (!db) {
@@ -32284,7 +32546,7 @@ function useDocumentManagementRepo() {
32284
32546
  }) {
32285
32547
  page = page > 0 ? page - 1 : 0;
32286
32548
  try {
32287
- site = new ObjectId79(site);
32549
+ site = new ObjectId80(site);
32288
32550
  } catch (error) {
32289
32551
  throw new BadRequestError126("Invalid site ID format.");
32290
32552
  }
@@ -32301,12 +32563,12 @@ function useDocumentManagementRepo() {
32301
32563
  cacheOptions.type = type;
32302
32564
  }
32303
32565
  if (org) {
32304
- query.org = new ObjectId79(org);
32566
+ query.org = new ObjectId80(org);
32305
32567
  cacheOptions.org = org.toString();
32306
32568
  }
32307
32569
  if (parentId) {
32308
32570
  try {
32309
- query.parentId = new ObjectId79(parentId);
32571
+ query.parentId = new ObjectId80(parentId);
32310
32572
  cacheOptions.parentId = parentId.toString();
32311
32573
  } catch (error) {
32312
32574
  throw new BadRequestError126("Invalid parentId format.");
@@ -32360,7 +32622,7 @@ function useDocumentManagementRepo() {
32360
32622
  }
32361
32623
  async function getDocumentById(_id) {
32362
32624
  try {
32363
- _id = new ObjectId79(_id);
32625
+ _id = new ObjectId80(_id);
32364
32626
  } catch (error) {
32365
32627
  throw new BadRequestError126("Invalid document ID format.");
32366
32628
  }
@@ -32405,7 +32667,7 @@ function useDocumentManagementRepo() {
32405
32667
  }
32406
32668
  async function updateDocumentById(_id, value) {
32407
32669
  try {
32408
- _id = new ObjectId79(_id);
32670
+ _id = new ObjectId80(_id);
32409
32671
  } catch (error) {
32410
32672
  throw new BadRequestError126("Invalid document ID format.");
32411
32673
  }
@@ -32433,7 +32695,7 @@ function useDocumentManagementRepo() {
32433
32695
  }
32434
32696
  async function deleteDocumentById(_id, session) {
32435
32697
  try {
32436
- _id = new ObjectId79(_id);
32698
+ _id = new ObjectId80(_id);
32437
32699
  } catch (error) {
32438
32700
  throw new BadRequestError126("Invalid document ID format.");
32439
32701
  }
@@ -32466,7 +32728,7 @@ function useDocumentManagementRepo() {
32466
32728
  }
32467
32729
  async function getDocumentManagementBySiteId(site, type) {
32468
32730
  try {
32469
- site = new ObjectId79(site);
32731
+ site = new ObjectId80(site);
32470
32732
  } catch (error) {
32471
32733
  throw new BadRequestError126("Invalid document management site ID format.");
32472
32734
  }
@@ -32796,7 +33058,7 @@ function useDocumentManagementController() {
32796
33058
 
32797
33059
  // src/models/bulletin-board.model.ts
32798
33060
  import Joi77 from "joi";
32799
- import { ObjectId as ObjectId80 } from "mongodb";
33061
+ import { ObjectId as ObjectId81 } from "mongodb";
32800
33062
  var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
32801
33063
  BulletinRecipient2["RESIDENT"] = "resident";
32802
33064
  BulletinRecipient2["SECURITY_AGENCY"] = "security_agency";
@@ -32876,21 +33138,21 @@ function MBulletinBoard(value) {
32876
33138
  }
32877
33139
  if (value._id && typeof value._id === "string") {
32878
33140
  try {
32879
- value._id = new ObjectId80(value._id);
33141
+ value._id = new ObjectId81(value._id);
32880
33142
  } catch {
32881
33143
  throw new Error("Invalid ID.");
32882
33144
  }
32883
33145
  }
32884
33146
  if (value.site && typeof value.site === "string") {
32885
33147
  try {
32886
- value.site = new ObjectId80(value.site);
33148
+ value.site = new ObjectId81(value.site);
32887
33149
  } catch {
32888
33150
  throw new Error("Invalid site ID.");
32889
33151
  }
32890
33152
  }
32891
33153
  if (value.orgId && typeof value.orgId === "string") {
32892
33154
  try {
32893
- value.orgId = new ObjectId80(value.orgId);
33155
+ value.orgId = new ObjectId81(value.orgId);
32894
33156
  } catch {
32895
33157
  throw new Error("Invalid org ID.");
32896
33158
  }
@@ -32899,7 +33161,7 @@ function MBulletinBoard(value) {
32899
33161
  value.file = value.file.map((f) => {
32900
33162
  if (f._id && typeof f._id === "string") {
32901
33163
  try {
32902
- return { ...f, _id: new ObjectId80(f._id) };
33164
+ return { ...f, _id: new ObjectId81(f._id) };
32903
33165
  } catch {
32904
33166
  throw new Error("Invalid file ID.");
32905
33167
  }
@@ -32908,7 +33170,7 @@ function MBulletinBoard(value) {
32908
33170
  });
32909
33171
  }
32910
33172
  return {
32911
- _id: value._id ?? new ObjectId80(),
33173
+ _id: value._id ?? new ObjectId81(),
32912
33174
  site: value.site ?? "",
32913
33175
  orgId: value.orgId ?? "",
32914
33176
  recipients: value.recipients ?? [],
@@ -32936,7 +33198,7 @@ import {
32936
33198
  useAtlas as useAtlas67,
32937
33199
  useCache as useCache42
32938
33200
  } from "@7365admin1/node-server-utils";
32939
- import { ObjectId as ObjectId81 } from "mongodb";
33201
+ import { ObjectId as ObjectId82 } from "mongodb";
32940
33202
  var bulletin_boards_namespace_collection = "bulletin-boards";
32941
33203
  function useBulletinBoardRepo() {
32942
33204
  const db = useAtlas67.getDb();
@@ -32989,7 +33251,7 @@ function useBulletinBoardRepo() {
32989
33251
  }, session) {
32990
33252
  page = page > 0 ? page - 1 : 0;
32991
33253
  try {
32992
- site = new ObjectId81(site);
33254
+ site = new ObjectId82(site);
32993
33255
  } catch (error) {
32994
33256
  throw new BadRequestError129("Invalid site ID format.");
32995
33257
  }
@@ -33048,7 +33310,7 @@ function useBulletinBoardRepo() {
33048
33310
  }
33049
33311
  async function getBulletinBoardById(_id, session) {
33050
33312
  try {
33051
- _id = new ObjectId81(_id);
33313
+ _id = new ObjectId82(_id);
33052
33314
  } catch (error) {
33053
33315
  throw new BadRequestError129("Invalid bulletin board ID format.");
33054
33316
  }
@@ -33078,13 +33340,13 @@ function useBulletinBoardRepo() {
33078
33340
  async function updateBulletinBoardById(_id, value, session) {
33079
33341
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
33080
33342
  try {
33081
- _id = new ObjectId81(_id);
33343
+ _id = new ObjectId82(_id);
33082
33344
  } catch (error) {
33083
33345
  throw new BadRequestError129("Invalid ID format.");
33084
33346
  }
33085
33347
  if (value.site && typeof value.site === "string") {
33086
33348
  try {
33087
- value.site = new ObjectId81(value.site);
33349
+ value.site = new ObjectId82(value.site);
33088
33350
  } catch {
33089
33351
  throw new Error("Invalid site ID.");
33090
33352
  }
@@ -33115,7 +33377,7 @@ function useBulletinBoardRepo() {
33115
33377
  }
33116
33378
  async function deleteBulletinBoardById(_id, session) {
33117
33379
  try {
33118
- _id = new ObjectId81(_id);
33380
+ _id = new ObjectId82(_id);
33119
33381
  } catch (error) {
33120
33382
  throw new BadRequestError129("Invalid bulletin board ID format.");
33121
33383
  }
@@ -33549,7 +33811,7 @@ function useBulletinBoardController() {
33549
33811
 
33550
33812
  // src/models/site-billing-item.model.ts
33551
33813
  import { BadRequestError as BadRequestError131, logger as logger109 } from "@7365admin1/node-server-utils";
33552
- import { ObjectId as ObjectId82 } from "mongodb";
33814
+ import { ObjectId as ObjectId83 } from "mongodb";
33553
33815
  import Joi79 from "joi";
33554
33816
 
33555
33817
  // src/types/enums/billing-frequency.enum.ts
@@ -33620,21 +33882,21 @@ function MBillingItem(value) {
33620
33882
  }
33621
33883
  if (value._id && typeof value._id === "string") {
33622
33884
  try {
33623
- value._id = new ObjectId82(value._id);
33885
+ value._id = new ObjectId83(value._id);
33624
33886
  } catch {
33625
33887
  throw new BadRequestError131("Invalid _id format");
33626
33888
  }
33627
33889
  }
33628
33890
  if (value.site && typeof value.site === "string") {
33629
33891
  try {
33630
- value.site = new ObjectId82(value.site);
33892
+ value.site = new ObjectId83(value.site);
33631
33893
  } catch {
33632
33894
  throw new BadRequestError131("Invalid site id format");
33633
33895
  }
33634
33896
  }
33635
33897
  if (value.org && typeof value.org === "string") {
33636
33898
  try {
33637
- value.org = new ObjectId82(value.org);
33899
+ value.org = new ObjectId83(value.org);
33638
33900
  } catch {
33639
33901
  throw new BadRequestError131("Invalid org id format");
33640
33902
  }
@@ -33643,7 +33905,7 @@ function MBillingItem(value) {
33643
33905
  value.units = value.units.map((unit) => {
33644
33906
  if (unit._id && typeof unit._id === "string") {
33645
33907
  try {
33646
- unit._id = new ObjectId82(unit._id);
33908
+ unit._id = new ObjectId83(unit._id);
33647
33909
  } catch {
33648
33910
  throw new BadRequestError131("Invalid unit id format");
33649
33911
  }
@@ -33652,7 +33914,7 @@ function MBillingItem(value) {
33652
33914
  });
33653
33915
  }
33654
33916
  return {
33655
- _id: value._id ?? new ObjectId82(),
33917
+ _id: value._id ?? new ObjectId83(),
33656
33918
  site: value.site,
33657
33919
  org: value.org,
33658
33920
  name: value.name,
@@ -33689,7 +33951,7 @@ import {
33689
33951
  paginate as paginate36,
33690
33952
  makeCacheKey as makeCacheKey41
33691
33953
  } from "@7365admin1/node-server-utils";
33692
- import { ObjectId as ObjectId83 } from "mongodb";
33954
+ import { ObjectId as ObjectId84 } from "mongodb";
33693
33955
  function useSiteBillingItemRepo() {
33694
33956
  const db = useAtlas69.getDb();
33695
33957
  if (!db) {
@@ -33776,7 +34038,7 @@ function useSiteBillingItemRepo() {
33776
34038
  }
33777
34039
  ]
33778
34040
  },
33779
- ...ObjectId83.isValid(site) && { site: new ObjectId83(site) }
34041
+ ...ObjectId84.isValid(site) && { site: new ObjectId84(site) }
33780
34042
  };
33781
34043
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
33782
34044
  const cacheOptions = {
@@ -33816,7 +34078,7 @@ function useSiteBillingItemRepo() {
33816
34078
  }
33817
34079
  async function getById(_id, session) {
33818
34080
  try {
33819
- _id = new ObjectId83(_id);
34081
+ _id = new ObjectId84(_id);
33820
34082
  } catch (error) {
33821
34083
  throw new BadRequestError132("Invalid ID.");
33822
34084
  }
@@ -33855,22 +34117,22 @@ function useSiteBillingItemRepo() {
33855
34117
  }
33856
34118
  async function updateById(_id, value, session) {
33857
34119
  try {
33858
- _id = new ObjectId83(_id);
34120
+ _id = new ObjectId84(_id);
33859
34121
  } catch (error) {
33860
34122
  throw new BadRequestError132(
33861
34123
  "Invalid site billing item transaction ID format."
33862
34124
  );
33863
34125
  }
33864
- if (value.site && ObjectId83.isValid(value.site.toString())) {
34126
+ if (value.site && ObjectId84.isValid(value.site.toString())) {
33865
34127
  try {
33866
- value.site = new ObjectId83(value.site.toString());
34128
+ value.site = new ObjectId84(value.site.toString());
33867
34129
  } catch {
33868
34130
  throw new BadRequestError132("Invalid _id format");
33869
34131
  }
33870
34132
  }
33871
- if (value.org && ObjectId83.isValid(value.org.toString())) {
34133
+ if (value.org && ObjectId84.isValid(value.org.toString())) {
33872
34134
  try {
33873
- value.org = new ObjectId83(value.org.toString());
34135
+ value.org = new ObjectId84(value.org.toString());
33874
34136
  } catch {
33875
34137
  throw new BadRequestError132("Invalid _id format");
33876
34138
  }
@@ -33890,7 +34152,7 @@ function useSiteBillingItemRepo() {
33890
34152
  }
33891
34153
  async function deleteById(_id) {
33892
34154
  try {
33893
- _id = new ObjectId83(_id);
34155
+ _id = new ObjectId84(_id);
33894
34156
  } catch (error) {
33895
34157
  throw new BadRequestError132(
33896
34158
  "Invalid site billing item transaction ID format."
@@ -33960,7 +34222,7 @@ import {
33960
34222
 
33961
34223
  // src/models/site-billing-configuration.model.ts
33962
34224
  import { BadRequestError as BadRequestError133, logger as logger111 } from "@7365admin1/node-server-utils";
33963
- import { ObjectId as ObjectId84 } from "mongodb";
34225
+ import { ObjectId as ObjectId85 } from "mongodb";
33964
34226
  import Joi80 from "joi";
33965
34227
  var schemaBillingConfiguration = Joi80.object({
33966
34228
  _id: Joi80.string().hex().optional(),
@@ -34021,34 +34283,34 @@ function MBillingConfiguration(value) {
34021
34283
  }
34022
34284
  if (value._id && typeof value._id === "string") {
34023
34285
  try {
34024
- value._id = new ObjectId84(value._id);
34286
+ value._id = new ObjectId85(value._id);
34025
34287
  } catch {
34026
34288
  throw new BadRequestError133("Invalid _id format");
34027
34289
  }
34028
34290
  }
34029
34291
  if (value.site && typeof value.site === "string") {
34030
34292
  try {
34031
- value.site = new ObjectId84(value.site);
34293
+ value.site = new ObjectId85(value.site);
34032
34294
  } catch {
34033
34295
  throw new BadRequestError133("Invalid site id format");
34034
34296
  }
34035
34297
  }
34036
34298
  if (value.org && typeof value.org === "string") {
34037
34299
  try {
34038
- value.org = new ObjectId84(value.org);
34300
+ value.org = new ObjectId85(value.org);
34039
34301
  } catch {
34040
34302
  throw new BadRequestError133("Invalid org id format");
34041
34303
  }
34042
34304
  }
34043
34305
  if (value.createdBy && typeof value.createdBy === "string") {
34044
34306
  try {
34045
- value.createdBy = new ObjectId84(value.createdBy);
34307
+ value.createdBy = new ObjectId85(value.createdBy);
34046
34308
  } catch {
34047
34309
  throw new BadRequestError133("Invalid createdBy id format");
34048
34310
  }
34049
34311
  }
34050
34312
  return {
34051
- _id: value._id ?? new ObjectId84(),
34313
+ _id: value._id ?? new ObjectId85(),
34052
34314
  site: value.site,
34053
34315
  org: value.org,
34054
34316
  siteName: value.siteName,
@@ -34077,7 +34339,7 @@ function MBillingConfiguration(value) {
34077
34339
  }
34078
34340
 
34079
34341
  // src/repositories/site-billing-configuration.repo.ts
34080
- import { ObjectId as ObjectId85 } from "mongodb";
34342
+ import { ObjectId as ObjectId86 } from "mongodb";
34081
34343
  function useSiteBillingConfigurationRepo() {
34082
34344
  const db = useAtlas70.getDb();
34083
34345
  if (!db) {
@@ -34150,7 +34412,7 @@ function useSiteBillingConfigurationRepo() {
34150
34412
  const query = {
34151
34413
  status,
34152
34414
  ...search && { $text: { $search: search } },
34153
- ...ObjectId85.isValid(site) && { site: new ObjectId85(site) }
34415
+ ...ObjectId86.isValid(site) && { site: new ObjectId86(site) }
34154
34416
  };
34155
34417
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
34156
34418
  const cacheOptions = {
@@ -34190,7 +34452,7 @@ function useSiteBillingConfigurationRepo() {
34190
34452
  }
34191
34453
  async function getById(_id) {
34192
34454
  try {
34193
- _id = new ObjectId85(_id);
34455
+ _id = new ObjectId86(_id);
34194
34456
  } catch (error) {
34195
34457
  throw new BadRequestError134("Invalid ID.");
34196
34458
  }
@@ -34231,22 +34493,22 @@ function useSiteBillingConfigurationRepo() {
34231
34493
  }
34232
34494
  async function updateById(_id, value, session) {
34233
34495
  try {
34234
- _id = new ObjectId85(_id);
34496
+ _id = new ObjectId86(_id);
34235
34497
  } catch (error) {
34236
34498
  throw new BadRequestError134(
34237
34499
  "Invalid site billing configuration transaction ID format."
34238
34500
  );
34239
34501
  }
34240
- if (value.site && ObjectId85.isValid(value.site.toString())) {
34502
+ if (value.site && ObjectId86.isValid(value.site.toString())) {
34241
34503
  try {
34242
- value.site = new ObjectId85(value.site.toString());
34504
+ value.site = new ObjectId86(value.site.toString());
34243
34505
  } catch {
34244
34506
  throw new BadRequestError134("Invalid _id format");
34245
34507
  }
34246
34508
  }
34247
- if (value.org && ObjectId85.isValid(value.org.toString())) {
34509
+ if (value.org && ObjectId86.isValid(value.org.toString())) {
34248
34510
  try {
34249
- value.org = new ObjectId85(value.org.toString());
34511
+ value.org = new ObjectId86(value.org.toString());
34250
34512
  } catch {
34251
34513
  throw new BadRequestError134("Invalid _id format");
34252
34514
  }
@@ -34266,7 +34528,7 @@ function useSiteBillingConfigurationRepo() {
34266
34528
  }
34267
34529
  async function deleteById(_id) {
34268
34530
  try {
34269
- _id = new ObjectId85(_id);
34531
+ _id = new ObjectId86(_id);
34270
34532
  } catch (error) {
34271
34533
  throw new BadRequestError134(
34272
34534
  "Invalid site billing configuration transaction ID format."
@@ -34848,7 +35110,7 @@ function useSiteBillingConfigurationController() {
34848
35110
  }
34849
35111
 
34850
35112
  // src/models/event-management.model.ts
34851
- import { ObjectId as ObjectId86 } from "mongodb";
35113
+ import { ObjectId as ObjectId87 } from "mongodb";
34852
35114
  import Joi83 from "joi";
34853
35115
  var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
34854
35116
  EventStatus2["PLANNED"] = "planned";
@@ -34892,20 +35154,20 @@ var schemaUpdateEventManagement = Joi83.object({
34892
35154
  function MEventManagement(value) {
34893
35155
  if (value._id && typeof value._id === "string") {
34894
35156
  try {
34895
- value._id = new ObjectId86(value._id);
35157
+ value._id = new ObjectId87(value._id);
34896
35158
  } catch {
34897
35159
  throw new Error("Invalid ID.");
34898
35160
  }
34899
35161
  }
34900
35162
  if (value.site && typeof value.site === "string") {
34901
35163
  try {
34902
- value.site = new ObjectId86(value.site);
35164
+ value.site = new ObjectId87(value.site);
34903
35165
  } catch {
34904
35166
  throw new Error("Invalid site ID.");
34905
35167
  }
34906
35168
  }
34907
35169
  return {
34908
- _id: value._id ?? new ObjectId86(),
35170
+ _id: value._id ?? new ObjectId87(),
34909
35171
  site: value.site,
34910
35172
  title: value.title,
34911
35173
  description: value.description ?? "",
@@ -34929,7 +35191,7 @@ import {
34929
35191
  useAtlas as useAtlas73,
34930
35192
  useCache as useCache45
34931
35193
  } from "@7365admin1/node-server-utils";
34932
- import { ObjectId as ObjectId87 } from "mongodb";
35194
+ import { ObjectId as ObjectId88 } from "mongodb";
34933
35195
  var events_namespace_collection = "event-management";
34934
35196
  function useEventManagementRepo() {
34935
35197
  const db = useAtlas73.getDb();
@@ -34997,7 +35259,7 @@ function useEventManagementRepo() {
34997
35259
  }, session) {
34998
35260
  page = page > 0 ? page - 1 : 0;
34999
35261
  try {
35000
- site = new ObjectId87(site);
35262
+ site = new ObjectId88(site);
35001
35263
  } catch (error) {
35002
35264
  throw new BadRequestError139("Invalid site ID format.");
35003
35265
  }
@@ -35085,7 +35347,7 @@ function useEventManagementRepo() {
35085
35347
  }
35086
35348
  async function getEventManagementById(_id, session) {
35087
35349
  try {
35088
- _id = new ObjectId87(_id);
35350
+ _id = new ObjectId88(_id);
35089
35351
  } catch (error) {
35090
35352
  throw new BadRequestError139("Invalid event ID format.");
35091
35353
  }
@@ -35113,13 +35375,13 @@ function useEventManagementRepo() {
35113
35375
  async function updateEventManagementById(_id, value, session) {
35114
35376
  value.updatedAt = /* @__PURE__ */ new Date();
35115
35377
  try {
35116
- _id = new ObjectId87(_id);
35378
+ _id = new ObjectId88(_id);
35117
35379
  } catch (error) {
35118
35380
  throw new BadRequestError139("Invalid ID format.");
35119
35381
  }
35120
35382
  if (value.site && typeof value.site === "string") {
35121
35383
  try {
35122
- value.site = new ObjectId87(value.site);
35384
+ value.site = new ObjectId88(value.site);
35123
35385
  } catch {
35124
35386
  throw new Error("Invalid site ID.");
35125
35387
  }
@@ -35150,7 +35412,7 @@ function useEventManagementRepo() {
35150
35412
  }
35151
35413
  async function deleteEventManagementById(_id) {
35152
35414
  try {
35153
- _id = new ObjectId87(_id);
35415
+ _id = new ObjectId88(_id);
35154
35416
  } catch (error) {
35155
35417
  throw new BadRequestError139("Invalid event ID format.");
35156
35418
  }
@@ -35438,7 +35700,7 @@ function useEventManagementController() {
35438
35700
 
35439
35701
  // src/models/site-unit-billing.model.ts
35440
35702
  import { BadRequestError as BadRequestError141, logger as logger119 } from "@7365admin1/node-server-utils";
35441
- import { ObjectId as ObjectId88 } from "mongodb";
35703
+ import { ObjectId as ObjectId89 } from "mongodb";
35442
35704
  import Joi85 from "joi";
35443
35705
  var Status = /* @__PURE__ */ ((Status2) => {
35444
35706
  Status2["PENDING"] = "pending";
@@ -35533,48 +35795,48 @@ function MUnitBilling(value) {
35533
35795
  }
35534
35796
  if (value._id && typeof value._id === "string") {
35535
35797
  try {
35536
- value._id = new ObjectId88(value._id);
35798
+ value._id = new ObjectId89(value._id);
35537
35799
  } catch {
35538
35800
  throw new BadRequestError141("Invalid _id format");
35539
35801
  }
35540
35802
  }
35541
35803
  if (value.site && typeof value.site === "string") {
35542
35804
  try {
35543
- value.site = new ObjectId88(value.site);
35805
+ value.site = new ObjectId89(value.site);
35544
35806
  } catch {
35545
35807
  throw new BadRequestError141("Invalid site id format");
35546
35808
  }
35547
35809
  }
35548
35810
  if (value.org && typeof value.org === "string") {
35549
35811
  try {
35550
- value.org = new ObjectId88(value.org);
35812
+ value.org = new ObjectId89(value.org);
35551
35813
  } catch {
35552
35814
  throw new BadRequestError141("Invalid org id format");
35553
35815
  }
35554
35816
  }
35555
35817
  if (value.paidBy && typeof value.paidBy === "string") {
35556
35818
  try {
35557
- value.paidBy = new ObjectId88(value.paidBy);
35819
+ value.paidBy = new ObjectId89(value.paidBy);
35558
35820
  } catch {
35559
35821
  throw new BadRequestError141("Invalid paidBy id format");
35560
35822
  }
35561
35823
  }
35562
35824
  if (value.billItem && typeof value.billItem === "string") {
35563
35825
  try {
35564
- value.billItem = new ObjectId88(value.billItem);
35826
+ value.billItem = new ObjectId89(value.billItem);
35565
35827
  } catch {
35566
35828
  throw new BadRequestError141("Invalid billItem id format");
35567
35829
  }
35568
35830
  }
35569
35831
  if (value.unitId && typeof value.unitId === "string") {
35570
35832
  try {
35571
- value.unitId = new ObjectId88(value.unitId);
35833
+ value.unitId = new ObjectId89(value.unitId);
35572
35834
  } catch {
35573
35835
  throw new BadRequestError141("Invalid unitId id format");
35574
35836
  }
35575
35837
  }
35576
35838
  return {
35577
- _id: value._id ?? new ObjectId88(),
35839
+ _id: value._id ?? new ObjectId89(),
35578
35840
  site: value.site ?? "",
35579
35841
  org: value.org ?? "",
35580
35842
  billItem: value.billItem ?? "",
@@ -35619,7 +35881,7 @@ import {
35619
35881
  paginate as paginate39,
35620
35882
  makeCacheKey as makeCacheKey44
35621
35883
  } from "@7365admin1/node-server-utils";
35622
- import { ObjectId as ObjectId89 } from "mongodb";
35884
+ import { ObjectId as ObjectId90 } from "mongodb";
35623
35885
  function useSiteUnitBillingRepo() {
35624
35886
  const db = useAtlas75.getDb();
35625
35887
  if (!db) {
@@ -35669,7 +35931,7 @@ function useSiteUnitBillingRepo() {
35669
35931
  const res = await collection.insertOne(value, { session });
35670
35932
  const acronym = createAcronym(value.billName || "NA");
35671
35933
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
35672
- const newId = new ObjectId89(res.insertedId).toString().slice(-6);
35934
+ const newId = new ObjectId90(res.insertedId).toString().slice(-6);
35673
35935
  const referenceNumber = `${acronym}${newId}${dateFormatted}`;
35674
35936
  await collection.updateOne(
35675
35937
  { _id: res.insertedId },
@@ -35747,7 +36009,7 @@ function useSiteUnitBillingRepo() {
35747
36009
  }
35748
36010
  ]
35749
36011
  },
35750
- ...ObjectId89.isValid(site) && { site: new ObjectId89(site) },
36012
+ ...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
35751
36013
  ...dateExpr
35752
36014
  };
35753
36015
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -35813,7 +36075,7 @@ function useSiteUnitBillingRepo() {
35813
36075
  }
35814
36076
  async function getById(_id) {
35815
36077
  try {
35816
- _id = new ObjectId89(_id);
36078
+ _id = new ObjectId90(_id);
35817
36079
  } catch (error) {
35818
36080
  throw new BadRequestError142("Invalid ID.");
35819
36081
  }
@@ -35872,8 +36134,8 @@ function useSiteUnitBillingRepo() {
35872
36134
  }
35873
36135
  const query = {
35874
36136
  status,
35875
- ...unitId && ObjectId89.isValid(unitId) && { unitId: new ObjectId89(unitId) },
35876
- ...site && ObjectId89.isValid(site) && { site: new ObjectId89(site) },
36137
+ ...unitId && ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) },
36138
+ ...site && ObjectId90.isValid(site) && { site: new ObjectId90(site) },
35877
36139
  ...dateExpr
35878
36140
  };
35879
36141
  try {
@@ -35911,43 +36173,43 @@ function useSiteUnitBillingRepo() {
35911
36173
  }
35912
36174
  async function updateById(_id, value, session) {
35913
36175
  try {
35914
- _id = new ObjectId89(_id);
36176
+ _id = new ObjectId90(_id);
35915
36177
  } catch (error) {
35916
36178
  throw new BadRequestError142(
35917
36179
  "Invalid site unit billing transaction ID format."
35918
36180
  );
35919
36181
  }
35920
- if (value.site && ObjectId89.isValid(value.site.toString())) {
36182
+ if (value.site && ObjectId90.isValid(value.site.toString())) {
35921
36183
  try {
35922
- value.site = new ObjectId89(value.site.toString());
36184
+ value.site = new ObjectId90(value.site.toString());
35923
36185
  } catch {
35924
36186
  throw new BadRequestError142("Invalid _id format");
35925
36187
  }
35926
36188
  }
35927
- if (value.org && ObjectId89.isValid(value.org.toString())) {
36189
+ if (value.org && ObjectId90.isValid(value.org.toString())) {
35928
36190
  try {
35929
- value.org = new ObjectId89(value.org.toString());
36191
+ value.org = new ObjectId90(value.org.toString());
35930
36192
  } catch {
35931
36193
  throw new BadRequestError142("Invalid _id format");
35932
36194
  }
35933
36195
  }
35934
- if (value.paidBy && ObjectId89.isValid(value.paidBy.toString())) {
36196
+ if (value.paidBy && ObjectId90.isValid(value.paidBy.toString())) {
35935
36197
  try {
35936
- value.org = new ObjectId89(value.paidBy.toString());
36198
+ value.org = new ObjectId90(value.paidBy.toString());
35937
36199
  } catch {
35938
36200
  throw new BadRequestError142("Invalid _id format");
35939
36201
  }
35940
36202
  }
35941
- if (value.billItem && ObjectId89.isValid(value.billItem.toString())) {
36203
+ if (value.billItem && ObjectId90.isValid(value.billItem.toString())) {
35942
36204
  try {
35943
- value.billItem = new ObjectId89(value.billItem.toString());
36205
+ value.billItem = new ObjectId90(value.billItem.toString());
35944
36206
  } catch {
35945
36207
  throw new BadRequestError142("Invalid _id format");
35946
36208
  }
35947
36209
  }
35948
- if (value.unitId && ObjectId89.isValid(value.unitId.toString())) {
36210
+ if (value.unitId && ObjectId90.isValid(value.unitId.toString())) {
35949
36211
  try {
35950
- value.unitId = new ObjectId89(value.unitId.toString());
36212
+ value.unitId = new ObjectId90(value.unitId.toString());
35951
36213
  } catch {
35952
36214
  throw new BadRequestError142("Invalid _id format");
35953
36215
  }
@@ -35967,7 +36229,7 @@ function useSiteUnitBillingRepo() {
35967
36229
  }
35968
36230
  async function deleteById(_id) {
35969
36231
  try {
35970
- _id = new ObjectId89(_id);
36232
+ _id = new ObjectId90(_id);
35971
36233
  } catch (error) {
35972
36234
  throw new BadRequestError142(
35973
36235
  "Invalid site unit billing transaction ID format."
@@ -36033,9 +36295,9 @@ function useSiteUnitBillingRepo() {
36033
36295
  }
36034
36296
  ]
36035
36297
  },
36036
- ...ObjectId89.isValid(site) && { site: new ObjectId89(site) },
36298
+ ...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
36037
36299
  ...dateExpr,
36038
- ...ObjectId89.isValid(unitId) && { unitId: new ObjectId89(unitId) }
36300
+ ...ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) }
36039
36301
  };
36040
36302
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
36041
36303
  try {
@@ -36122,9 +36384,9 @@ function useSiteUnitBillingRepo() {
36122
36384
  }
36123
36385
  ]
36124
36386
  },
36125
- ...ObjectId89.isValid(site) && { site: new ObjectId89(site) },
36387
+ ...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
36126
36388
  ...dateExpr,
36127
- ...ObjectId89.isValid(unitId) && { unitId: new ObjectId89(unitId) }
36389
+ ...ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) }
36128
36390
  };
36129
36391
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
36130
36392
  try {
@@ -36211,7 +36473,7 @@ import {
36211
36473
  logger as logger121,
36212
36474
  useAtlas as useAtlas76
36213
36475
  } from "@7365admin1/node-server-utils";
36214
- import { ObjectId as ObjectId90 } from "mongodb";
36476
+ import { ObjectId as ObjectId91 } from "mongodb";
36215
36477
  function useSiteUnitBillingService() {
36216
36478
  const {
36217
36479
  add: _add,
@@ -36368,7 +36630,7 @@ function useSiteUnitBillingService() {
36368
36630
  return unitsWithOwner || [];
36369
36631
  } else {
36370
36632
  if (units && units.length > 0) {
36371
- const unitIds = units.map((unit) => new ObjectId90(unit._id));
36633
+ const unitIds = units.map((unit) => new ObjectId91(unit._id));
36372
36634
  const specificUnitsWithOwner = await _getBuildingUnitsWithOwner(
36373
36635
  site || "",
36374
36636
  unitIds
@@ -36649,7 +36911,7 @@ function useSiteUnitBillingController() {
36649
36911
  }
36650
36912
 
36651
36913
  // src/models/access-management.model.ts
36652
- import { ObjectId as ObjectId91 } from "mongodb";
36914
+ import { ObjectId as ObjectId92 } from "mongodb";
36653
36915
  var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
36654
36916
  EAccessCardTypes2["NFC"] = "NFC";
36655
36917
  EAccessCardTypes2["QR"] = "QRCODE";
@@ -36671,7 +36933,7 @@ var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
36671
36933
  })(AccessTypeProps || {});
36672
36934
  var MAccessCardTransaction = class {
36673
36935
  constructor({
36674
- _id = new ObjectId91(),
36936
+ _id = new ObjectId92(),
36675
36937
  index,
36676
36938
  site,
36677
36939
  cardNo,
@@ -36698,7 +36960,7 @@ var MAccessCardTransaction = class {
36698
36960
  };
36699
36961
  var MAccessCard = class {
36700
36962
  constructor({
36701
- _id = new ObjectId91(),
36963
+ _id = new ObjectId92(),
36702
36964
  userId,
36703
36965
  site,
36704
36966
  staffNo = null,
@@ -36760,7 +37022,7 @@ import {
36760
37022
  paginate as paginate40,
36761
37023
  useAtlas as useAtlas77
36762
37024
  } from "@7365admin1/node-server-utils";
36763
- import { ObjectId as ObjectId92 } from "mongodb";
37025
+ import { ObjectId as ObjectId93 } from "mongodb";
36764
37026
 
36765
37027
  // src/utils/access-management.ts
36766
37028
  import fs3 from "fs";
@@ -37070,12 +37332,12 @@ function UseAccessManagementRepo() {
37070
37332
  payload
37071
37333
  }) {
37072
37334
  try {
37073
- payload.site = new ObjectId92(payload.site);
37335
+ payload.site = new ObjectId93(payload.site);
37074
37336
  payload.startDate = new Date(payload.startDate);
37075
37337
  payload.endDate = new Date(payload.endDate);
37076
37338
  payload.createdAt = new Date(payload.createdAt);
37077
37339
  payload.updatedAt = new Date(payload.updatedAt);
37078
- payload.assignedUnit = payload.unit?.map((id) => new ObjectId92(id));
37340
+ payload.assignedUnit = payload.unit?.map((id) => new ObjectId93(id));
37079
37341
  delete payload.unit;
37080
37342
  const accessCardObj = new MAccessCard(payload);
37081
37343
  const result = await collection().insertOne(accessCardObj);
@@ -37114,7 +37376,7 @@ function UseAccessManagementRepo() {
37114
37376
  async function addNonPhysicalCardRepo(params) {
37115
37377
  try {
37116
37378
  const MAX_RETRIES = 3;
37117
- const site = new ObjectId92(params.site);
37379
+ const site = new ObjectId93(params.site);
37118
37380
  const date = /* @__PURE__ */ new Date();
37119
37381
  const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
37120
37382
  const countPerUnit = params.quantity;
@@ -37146,7 +37408,7 @@ function UseAccessManagementRepo() {
37146
37408
  userType: params.userType,
37147
37409
  doorName: params.doorName,
37148
37410
  liftName: params.liftName,
37149
- assignedUnit: new ObjectId92(units[i]),
37411
+ assignedUnit: new ObjectId93(units[i]),
37150
37412
  createdAt: new Date(params.createdAt),
37151
37413
  updatedAt: new Date(params.updatedAt),
37152
37414
  isWinsland: params.isWinsland
@@ -37232,7 +37494,7 @@ function UseAccessManagementRepo() {
37232
37494
  }
37233
37495
  async function accessManagementSettingsRepo(params) {
37234
37496
  try {
37235
- params.site = new ObjectId92(params.site);
37497
+ params.site = new ObjectId93(params.site);
37236
37498
  const result = collectionName("entrypass-settings").updateOne(
37237
37499
  { site: params.site },
37238
37500
  {
@@ -37254,7 +37516,7 @@ function UseAccessManagementRepo() {
37254
37516
  }
37255
37517
  async function allAccessCardsCountsRepo(params) {
37256
37518
  try {
37257
- const site = new ObjectId92(params.site);
37519
+ const site = new ObjectId93(params.site);
37258
37520
  const userType = params.userType;
37259
37521
  const result = await collection().aggregate([
37260
37522
  {
@@ -37314,7 +37576,7 @@ function UseAccessManagementRepo() {
37314
37576
  }
37315
37577
  async function availableAccessCardsRepo(params) {
37316
37578
  try {
37317
- const site = new ObjectId92(params.site);
37579
+ const site = new ObjectId93(params.site);
37318
37580
  const userType = params.userType;
37319
37581
  const type = params.type;
37320
37582
  const query = {
@@ -37429,7 +37691,7 @@ function UseAccessManagementRepo() {
37429
37691
  }
37430
37692
  async function userTypeAccessCardsRepo(params) {
37431
37693
  try {
37432
- const site = new ObjectId92(params.site);
37694
+ const site = new ObjectId93(params.site);
37433
37695
  const userType = params.userType;
37434
37696
  const page = params.page ? Number(params.page) - 1 : 0;
37435
37697
  const limit = Number(params.limit) || 10;
@@ -37828,7 +38090,7 @@ function UseAccessManagementRepo() {
37828
38090
  }
37829
38091
  async function assignedAccessCardsRepo(params) {
37830
38092
  try {
37831
- const site = new ObjectId92(params.site);
38093
+ const site = new ObjectId93(params.site);
37832
38094
  const userType = params.userType;
37833
38095
  const type = params.type;
37834
38096
  const search = params.search;
@@ -38003,12 +38265,12 @@ function UseAccessManagementRepo() {
38003
38265
  session?.startTransaction();
38004
38266
  const { userId, cardId, site } = params;
38005
38267
  const allUserId = await Promise.all(
38006
- userId.map(async (id) => new ObjectId92(id))
38268
+ userId.map(async (id) => new ObjectId93(id))
38007
38269
  );
38008
38270
  const allCardId = await Promise.all(
38009
- cardId.map(async (id) => new ObjectId92(id))
38271
+ cardId.map(async (id) => new ObjectId93(id))
38010
38272
  );
38011
- const siteId = new ObjectId92(site);
38273
+ const siteId = new ObjectId93(site);
38012
38274
  const result = await collection().updateMany(
38013
38275
  {
38014
38276
  $or: [
@@ -38039,7 +38301,7 @@ function UseAccessManagementRepo() {
38039
38301
  async function accessandLiftCardsRepo(params) {
38040
38302
  try {
38041
38303
  const { accessLevel, liftAccessLevel, site, userType, type } = params;
38042
- const siteId = new ObjectId92(site);
38304
+ const siteId = new ObjectId93(site);
38043
38305
  const query = {
38044
38306
  site: { $in: [siteId] },
38045
38307
  userType,
@@ -38072,9 +38334,9 @@ function UseAccessManagementRepo() {
38072
38334
  const session = useAtlas77.getClient()?.startSession();
38073
38335
  try {
38074
38336
  session?.startTransaction();
38075
- const siteId = new ObjectId92(params.site);
38076
- const userId = new ObjectId92(params.userId);
38077
- const cardId = new ObjectId92(params.cardId);
38337
+ const siteId = new ObjectId93(params.site);
38338
+ const userId = new ObjectId93(params.userId);
38339
+ const cardId = new ObjectId93(params.cardId);
38078
38340
  const quantity = 1;
38079
38341
  const cardCredentials = await collection().findOneAndUpdate(
38080
38342
  { _id: cardId },
@@ -38100,7 +38362,7 @@ function UseAccessManagementRepo() {
38100
38362
  (no) => no.toString().padStart(10, "0")
38101
38363
  );
38102
38364
  const accessCards = [];
38103
- const convertedUnits = unit.map((obj) => new ObjectId92(obj));
38365
+ const convertedUnits = unit.map((obj) => new ObjectId93(obj));
38104
38366
  for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
38105
38367
  accessCards.push(
38106
38368
  new MAccessCard({
@@ -38189,7 +38451,7 @@ function UseAccessManagementRepo() {
38189
38451
  session?.startTransaction();
38190
38452
  const results = [];
38191
38453
  for (let nfc of params.nfcList) {
38192
- nfc._id = new ObjectId92(nfc._id);
38454
+ nfc._id = new ObjectId93(nfc._id);
38193
38455
  const card = await collection().findOne({ _id: nfc._id }, { session });
38194
38456
  if (card) {
38195
38457
  const updateFields = {
@@ -38223,7 +38485,7 @@ function UseAccessManagementRepo() {
38223
38485
  async function doorAndLiftDropdownRepo(params) {
38224
38486
  try {
38225
38487
  const { site, type, userType } = params;
38226
- const id = new ObjectId92(site);
38488
+ const id = new ObjectId93(site);
38227
38489
  const res = collection().aggregate([
38228
38490
  {
38229
38491
  $match: {
@@ -38310,10 +38572,10 @@ function UseAccessManagementRepo() {
38310
38572
  const session = useAtlas77.getClient()?.startSession();
38311
38573
  try {
38312
38574
  const { cardId, remarks, issuedCardId, unitId, userId } = params;
38313
- const id = new ObjectId92(cardId);
38314
- const newCardId = new ObjectId92(issuedCardId);
38315
- const unit = new ObjectId92(unitId);
38316
- const user = new ObjectId92(userId);
38575
+ const id = new ObjectId93(cardId);
38576
+ const newCardId = new ObjectId93(issuedCardId);
38577
+ const unit = new ObjectId93(unitId);
38578
+ const user = new ObjectId93(userId);
38317
38579
  session?.startTransaction();
38318
38580
  const sessionResult = await Promise.all([
38319
38581
  await collection().findOneAndUpdate(
@@ -38346,7 +38608,7 @@ function UseAccessManagementRepo() {
38346
38608
  async function visitorAccessCardsRepo(params) {
38347
38609
  try {
38348
38610
  const page = params.page ? params.page - 1 : 0;
38349
- const siteId = new ObjectId92(params.site);
38611
+ const siteId = new ObjectId93(params.site);
38350
38612
  const search = params.search;
38351
38613
  const type = params.type;
38352
38614
  const limit = Number(params.limit);
@@ -38414,7 +38676,7 @@ function UseAccessManagementRepo() {
38414
38676
  }
38415
38677
  async function getCardReplacementRepo(params) {
38416
38678
  try {
38417
- const site = new ObjectId92(params.site);
38679
+ const site = new ObjectId93(params.site);
38418
38680
  const search = params.search;
38419
38681
  const statusFilter = params.statusFilter;
38420
38682
  const dateFrom = params.dateFrom;
@@ -38586,7 +38848,7 @@ function UseAccessManagementRepo() {
38586
38848
  async function getAccessManagementSettingsRepo(params) {
38587
38849
  try {
38588
38850
  const { site } = params;
38589
- const siteId = new ObjectId92(site);
38851
+ const siteId = new ObjectId93(site);
38590
38852
  const res = await collectionName("entrypass-settings").findOne(
38591
38853
  { site: siteId },
38592
38854
  { allowDiskUse: true }
@@ -38620,7 +38882,7 @@ function UseAccessManagementRepo() {
38620
38882
  const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
38621
38883
  const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
38622
38884
  return new MAccessCard({
38623
- site: new ObjectId92(site),
38885
+ site: new ObjectId93(site),
38624
38886
  type: "NFC" /* NFC */,
38625
38887
  staffNo: null,
38626
38888
  accessLevel,
@@ -38671,8 +38933,8 @@ function UseAccessManagementRepo() {
38671
38933
  liftAccessLevel
38672
38934
  } = params;
38673
38935
  const [convertedUnits, convertedSite] = await Promise.all([
38674
- Promise.all(units.map((id) => new ObjectId92(id))),
38675
- new ObjectId92(site)
38936
+ Promise.all(units.map((id) => new ObjectId93(id))),
38937
+ new ObjectId93(site)
38676
38938
  ]);
38677
38939
  const totalRequired = quantity * convertedUnits.length;
38678
38940
  const availableCards = await collection().find({
@@ -38724,7 +38986,7 @@ function UseAccessManagementRepo() {
38724
38986
  async function deleteCardRepo(params) {
38725
38987
  try {
38726
38988
  const { cardId, remarks } = params;
38727
- const id = new ObjectId92(cardId);
38989
+ const id = new ObjectId93(cardId);
38728
38990
  const result = await collection().findOneAndUpdate(
38729
38991
  { _id: id },
38730
38992
  {
@@ -38745,8 +39007,8 @@ function UseAccessManagementRepo() {
38745
39007
  async function getCardDetailsRepo(params) {
38746
39008
  try {
38747
39009
  const { siteId, cardId } = params;
38748
- const convertedSiteId = new ObjectId92(siteId);
38749
- const convertedCardId = new ObjectId92(cardId);
39010
+ const convertedSiteId = new ObjectId93(siteId);
39011
+ const convertedCardId = new ObjectId93(cardId);
38750
39012
  const card = await collection().findOne(
38751
39013
  {
38752
39014
  _id: convertedCardId,
@@ -38795,7 +39057,7 @@ function UseAccessManagementRepo() {
38795
39057
  async function addQrTagRepo(params) {
38796
39058
  try {
38797
39059
  const { site, payload } = params;
38798
- const id = new ObjectId92(site);
39060
+ const id = new ObjectId93(site);
38799
39061
  const highestCardNo = await collection().aggregate([
38800
39062
  {
38801
39063
  $match: {
@@ -38829,7 +39091,7 @@ function UseAccessManagementRepo() {
38829
39091
  );
38830
39092
  const bulkOps = await Promise.all(
38831
39093
  payload.map(async (doc, index) => {
38832
- const id2 = new ObjectId92(doc._id);
39094
+ const id2 = new ObjectId93(doc._id);
38833
39095
  return {
38834
39096
  updateOne: {
38835
39097
  filter: { _id: id2 },
@@ -38852,7 +39114,7 @@ function UseAccessManagementRepo() {
38852
39114
  async function allQrTagRepo(params) {
38853
39115
  try {
38854
39116
  const { site } = params;
38855
- const siteId = new ObjectId92(site);
39117
+ const siteId = new ObjectId93(site);
38856
39118
  const query = {
38857
39119
  site: siteId,
38858
39120
  assignedUnit: { $ne: null },
@@ -38901,8 +39163,8 @@ function UseAccessManagementRepo() {
38901
39163
  }
38902
39164
  async function availableCardContractorsRepo(params) {
38903
39165
  try {
38904
- const siteId = new ObjectId92(params.siteId);
38905
- const unitId = new ObjectId92(params.unitId);
39166
+ const siteId = new ObjectId93(params.siteId);
39167
+ const unitId = new ObjectId93(params.unitId);
38906
39168
  const page = Number(params.page) - 1;
38907
39169
  const limit = Number(params.limit) || 10;
38908
39170
  const type = params.type;
@@ -39003,8 +39265,8 @@ function UseAccessManagementRepo() {
39003
39265
  }
39004
39266
  async function vmsgenerateQrCodesRepo(params) {
39005
39267
  try {
39006
- const site = new ObjectId92(params.site);
39007
- const unitId = new ObjectId92(params.unitId);
39268
+ const site = new ObjectId93(params.site);
39269
+ const unitId = new ObjectId93(params.unitId);
39008
39270
  const quantity = Number(params.quantity);
39009
39271
  const normalizedUnitId = params.normalizedUnitId;
39010
39272
  const date = /* @__PURE__ */ new Date();
@@ -39059,11 +39321,11 @@ function UseAccessManagementRepo() {
39059
39321
  let isAborted = false;
39060
39322
  try {
39061
39323
  await session?.startTransaction();
39062
- const siteId = new ObjectId92(params.site);
39063
- const unitId = new ObjectId92(params.unitId);
39324
+ const siteId = new ObjectId93(params.site);
39325
+ const unitId = new ObjectId93(params.unitId);
39064
39326
  const quantity = params.quantity;
39065
39327
  const type = params.type;
39066
- const visitorId = new ObjectId92(params.visitorId);
39328
+ const visitorId = new ObjectId93(params.visitorId);
39067
39329
  const nfcCards = params.nfcCards;
39068
39330
  const acm_url = params.acm_url;
39069
39331
  let cards = [];
@@ -39085,7 +39347,7 @@ function UseAccessManagementRepo() {
39085
39347
  } else if (type === "NFC" /* NFC */) {
39086
39348
  if (nfcCards && nfcCards.length > 0) {
39087
39349
  const objectIds = nfcCards.map(
39088
- (card) => new ObjectId92(card._id)
39350
+ (card) => new ObjectId93(card._id)
39089
39351
  );
39090
39352
  cards = await collection().find({ _id: { $in: objectIds } }).toArray();
39091
39353
  const nfcList = objectIds.map((card) => ({
@@ -39192,7 +39454,7 @@ function UseAccessManagementRepo() {
39192
39454
  }
39193
39455
  async function signQrCodeRepo(params) {
39194
39456
  try {
39195
- const cardId = new ObjectId92(params.cardId);
39457
+ const cardId = new ObjectId93(params.cardId);
39196
39458
  const purpose = params.purpose;
39197
39459
  let validity = 5;
39198
39460
  const card = await collection().findOne({ _id: cardId });
@@ -39217,7 +39479,7 @@ function UseAccessManagementRepo() {
39217
39479
  const session = useAtlas77.getClient()?.startSession();
39218
39480
  try {
39219
39481
  await session?.startTransaction();
39220
- const userId = new ObjectId92(params.userId);
39482
+ const userId = new ObjectId93(params.userId);
39221
39483
  const result = await collection().updateMany(
39222
39484
  { userId },
39223
39485
  { $set: { userId: null, status: "Available", updatedAt: /* @__PURE__ */ new Date() } }
@@ -39232,7 +39494,7 @@ function UseAccessManagementRepo() {
39232
39494
  }
39233
39495
  }
39234
39496
  async function getBlockLevelAndUnitListRepo(params) {
39235
- const site = new ObjectId92(params.site);
39497
+ const site = new ObjectId93(params.site);
39236
39498
  try {
39237
39499
  const blocks = await collectionName("buildings").aggregate([
39238
39500
  {
@@ -39302,7 +39564,7 @@ function UseAccessManagementRepo() {
39302
39564
  url
39303
39565
  }) {
39304
39566
  page = page ? page - 1 : 0;
39305
- site = new ObjectId92(site);
39567
+ site = new ObjectId93(site);
39306
39568
  try {
39307
39569
  let index = await collectionName("access-card-transactions").findOne(
39308
39570
  {},
@@ -39437,9 +39699,9 @@ function UseAccessManagementRepo() {
39437
39699
  throw new Error("No user to Assign.");
39438
39700
  }
39439
39701
  assignees = assignees.map(
39440
- (data) => new ObjectId92(data)
39702
+ (data) => new ObjectId93(data)
39441
39703
  );
39442
- unit = new ObjectId92(unit);
39704
+ unit = new ObjectId93(unit);
39443
39705
  let availableCards = [];
39444
39706
  let update = [];
39445
39707
  let cards = [];
@@ -39472,13 +39734,13 @@ function UseAccessManagementRepo() {
39472
39734
  throw new Error(`Not enough ${type} cards available.`);
39473
39735
  }
39474
39736
  cards = availableCards?.slice(0, assignees.length).map((card, index) => {
39475
- const userId = new ObjectId92(assignees[index].toString());
39737
+ const userId = new ObjectId93(assignees[index].toString());
39476
39738
  card.staffNo = userId.toString().slice(-10);
39477
39739
  return card;
39478
39740
  });
39479
39741
  update = availableCards.slice(0, assignees.length).map((card, index) => ({
39480
39742
  _id: card._id,
39481
- userId: new ObjectId92(assignees[index])
39743
+ userId: new ObjectId93(assignees[index])
39482
39744
  }));
39483
39745
  const commands = cards.map((item, index) => {
39484
39746
  let ag = null;
@@ -39544,7 +39806,7 @@ function UseAccessManagementRepo() {
39544
39806
  const session = useAtlas77.getClient()?.startSession();
39545
39807
  try {
39546
39808
  session?.startTransaction();
39547
- const id = new ObjectId92(userId);
39809
+ const id = new ObjectId93(userId);
39548
39810
  await collection().updateMany(
39549
39811
  { userId: id },
39550
39812
  { $set: { userId: null, status: "Available" } },
@@ -39564,8 +39826,8 @@ function UseAccessManagementRepo() {
39564
39826
  id,
39565
39827
  name
39566
39828
  }) {
39567
- site = new ObjectId92(site);
39568
- id = new ObjectId92(id);
39829
+ site = new ObjectId93(site);
39830
+ id = new ObjectId93(id);
39569
39831
  try {
39570
39832
  const result = await collectionName("sites").updateOne(
39571
39833
  { _id: site },
@@ -39582,9 +39844,9 @@ function UseAccessManagementRepo() {
39582
39844
  unitId
39583
39845
  }) {
39584
39846
  try {
39585
- orgId = new ObjectId92(orgId);
39586
- siteId = new ObjectId92(siteId);
39587
- unitId = new ObjectId92(unitId);
39847
+ orgId = new ObjectId93(orgId);
39848
+ siteId = new ObjectId93(siteId);
39849
+ unitId = new ObjectId93(unitId);
39588
39850
  const result = await collectionName("users").aggregate([
39589
39851
  {
39590
39852
  $match: {
@@ -39622,8 +39884,8 @@ function UseAccessManagementRepo() {
39622
39884
  isLiftCard
39623
39885
  }) {
39624
39886
  try {
39625
- siteId = new ObjectId92(siteId);
39626
- userId = new ObjectId92(userId);
39887
+ siteId = new ObjectId93(siteId);
39888
+ userId = new ObjectId93(userId);
39627
39889
  const query = {
39628
39890
  site: siteId,
39629
39891
  userId,
@@ -39644,7 +39906,7 @@ function UseAccessManagementRepo() {
39644
39906
  }
39645
39907
  }
39646
39908
  async function removeTemplateRepo({ site }) {
39647
- site = new ObjectId92(site);
39909
+ site = new ObjectId93(site);
39648
39910
  try {
39649
39911
  const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
39650
39912
  return result;
@@ -39657,8 +39919,8 @@ function UseAccessManagementRepo() {
39657
39919
  page = page ? page - 1 : 0;
39658
39920
  let defaultQuery = {};
39659
39921
  let searchQuery = {};
39660
- site = new ObjectId92(site);
39661
- userId = new ObjectId92(userId);
39922
+ site = new ObjectId93(site);
39923
+ userId = new ObjectId93(userId);
39662
39924
  if (search) {
39663
39925
  searchQuery = {
39664
39926
  $or: [{ fullName: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }]
@@ -41404,7 +41666,7 @@ function useAccessManagementController() {
41404
41666
  }
41405
41667
 
41406
41668
  // src/models/nfc-patrol-tag.model.ts
41407
- import { ObjectId as ObjectId93 } from "mongodb";
41669
+ import { ObjectId as ObjectId94 } from "mongodb";
41408
41670
  import Joi88 from "joi";
41409
41671
  import { BadRequestError as BadRequestError146 } from "@7365admin1/node-server-utils";
41410
41672
  var DEVICE_STATUS = {
@@ -41431,27 +41693,27 @@ var schemaNfcPatrolTag = Joi88.object({
41431
41693
  function MNfcPatrolTag(value) {
41432
41694
  if (value._id && typeof value._id === "string") {
41433
41695
  try {
41434
- value._id = new ObjectId93(value._id);
41696
+ value._id = new ObjectId94(value._id);
41435
41697
  } catch {
41436
41698
  throw new BadRequestError146("Invalid ID.");
41437
41699
  }
41438
41700
  }
41439
41701
  if (value.site && typeof value.site === "string") {
41440
41702
  try {
41441
- value.site = new ObjectId93(value.site);
41703
+ value.site = new ObjectId94(value.site);
41442
41704
  } catch {
41443
41705
  throw new BadRequestError146("Invalid site ID.");
41444
41706
  }
41445
41707
  }
41446
41708
  if (value.createdBy && typeof value.createdBy === "string") {
41447
41709
  try {
41448
- value.createdBy = new ObjectId93(value.createdBy);
41710
+ value.createdBy = new ObjectId94(value.createdBy);
41449
41711
  } catch {
41450
41712
  throw new BadRequestError146("Invalid Created By ID.");
41451
41713
  }
41452
41714
  }
41453
41715
  return {
41454
- _id: value._id ?? new ObjectId93(),
41716
+ _id: value._id ?? new ObjectId94(),
41455
41717
  site: value.site,
41456
41718
  tagID: value.tagID,
41457
41719
  name: value.name,
@@ -41471,7 +41733,7 @@ import {
41471
41733
  useAtlas as useAtlas78,
41472
41734
  useCache as useCache48
41473
41735
  } from "@7365admin1/node-server-utils";
41474
- import { ObjectId as ObjectId94 } from "mongodb";
41736
+ import { ObjectId as ObjectId95 } from "mongodb";
41475
41737
  function useNfcPatrolTagRepo() {
41476
41738
  const db = useAtlas78.getDb();
41477
41739
  if (!db) {
@@ -41525,7 +41787,7 @@ function useNfcPatrolTagRepo() {
41525
41787
  }, session) {
41526
41788
  page = page > 0 ? page - 1 : 0;
41527
41789
  try {
41528
- site = new ObjectId94(site);
41790
+ site = new ObjectId95(site);
41529
41791
  } catch (error) {
41530
41792
  throw new BadRequestError147("Invalid site ID format.");
41531
41793
  }
@@ -41569,19 +41831,19 @@ function useNfcPatrolTagRepo() {
41569
41831
  const [updateType, findObject, setData, session] = args;
41570
41832
  if (findObject?.site && typeof findObject.site === "string") {
41571
41833
  try {
41572
- findObject.site = new ObjectId94(findObject.site);
41834
+ findObject.site = new ObjectId95(findObject.site);
41573
41835
  } catch {
41574
41836
  throw new BadRequestError147("Invalid site ID.");
41575
41837
  }
41576
41838
  }
41577
41839
  if (updateType == "Edit" && findObject?._id && typeof findObject._id === "string") {
41578
41840
  try {
41579
- findObject._id = new ObjectId94(findObject._id);
41841
+ findObject._id = new ObjectId95(findObject._id);
41580
41842
  } catch {
41581
41843
  throw new BadRequestError147("Invalid nfc patrol tag document ID.");
41582
41844
  }
41583
41845
  try {
41584
- setData.updatedBy = new ObjectId94(setData.updatedBy);
41846
+ setData.updatedBy = new ObjectId95(setData.updatedBy);
41585
41847
  } catch {
41586
41848
  throw new BadRequestError147("Invalid updatedBy ID.");
41587
41849
  }
@@ -41872,7 +42134,7 @@ function useNfcPatrolTagController() {
41872
42134
  }
41873
42135
 
41874
42136
  // src/models/occurrence-book.model.ts
41875
- import { ObjectId as ObjectId95 } from "mongodb";
42137
+ import { ObjectId as ObjectId96 } from "mongodb";
41876
42138
  import Joi90 from "joi";
41877
42139
  var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
41878
42140
  DOBStatus3["OPEN"] = "open";
@@ -41898,20 +42160,20 @@ var schemaUpdateOccurrenceBook = Joi90.object({
41898
42160
  function MOccurrenceBook(value) {
41899
42161
  if (value._id && typeof value._id === "string") {
41900
42162
  try {
41901
- value._id = new ObjectId95(value._id);
42163
+ value._id = new ObjectId96(value._id);
41902
42164
  } catch {
41903
42165
  throw new Error("Invalid ID.");
41904
42166
  }
41905
42167
  }
41906
42168
  if (value.site && typeof value.site === "string") {
41907
42169
  try {
41908
- value.site = new ObjectId95(value.site);
42170
+ value.site = new ObjectId96(value.site);
41909
42171
  } catch {
41910
42172
  throw new Error("Invalid site ID.");
41911
42173
  }
41912
42174
  }
41913
42175
  return {
41914
- _id: value._id ?? new ObjectId95(),
42176
+ _id: value._id ?? new ObjectId96(),
41915
42177
  site: value.site,
41916
42178
  date: value.date ?? "",
41917
42179
  totalInput: value.totalInput ?? 0,
@@ -41936,7 +42198,7 @@ import {
41936
42198
  useAtlas as useAtlas80,
41937
42199
  useCache as useCache49
41938
42200
  } from "@7365admin1/node-server-utils";
41939
- import { ObjectId as ObjectId96 } from "mongodb";
42201
+ import { ObjectId as ObjectId97 } from "mongodb";
41940
42202
  var occurrence_book_namespace_collection = "occurrence-books";
41941
42203
  function useOccurrenceBookRepo() {
41942
42204
  const db = useAtlas80.getDb();
@@ -42080,7 +42342,7 @@ function useOccurrenceBookRepo() {
42080
42342
  }
42081
42343
  async function getOccurrenceBookById(_id, session) {
42082
42344
  try {
42083
- _id = new ObjectId96(_id);
42345
+ _id = new ObjectId97(_id);
42084
42346
  } catch (error) {
42085
42347
  throw new BadRequestError150("Invalid occurrence book ID format.");
42086
42348
  }
@@ -42110,7 +42372,7 @@ function useOccurrenceBookRepo() {
42110
42372
  async function updateOccurrenceBookById(_id, value, session) {
42111
42373
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42112
42374
  try {
42113
- _id = new ObjectId96(_id);
42375
+ _id = new ObjectId97(_id);
42114
42376
  } catch (error) {
42115
42377
  throw new BadRequestError150("Invalid ID format.");
42116
42378
  }
@@ -42142,7 +42404,7 @@ function useOccurrenceBookRepo() {
42142
42404
  }
42143
42405
  async function deleteOccurrenceBookById(_id) {
42144
42406
  try {
42145
- _id = new ObjectId96(_id);
42407
+ _id = new ObjectId97(_id);
42146
42408
  } catch (error) {
42147
42409
  throw new BadRequestError150("Invalid occurrence book ID format.");
42148
42410
  }
@@ -42527,7 +42789,7 @@ function useOccurrenceBookController() {
42527
42789
  }
42528
42790
 
42529
42791
  // src/models/bulletin-video.model.ts
42530
- import { ObjectId as ObjectId97 } from "mongodb";
42792
+ import { ObjectId as ObjectId98 } from "mongodb";
42531
42793
  import Joi92 from "joi";
42532
42794
  var BulletinVideoSort = /* @__PURE__ */ ((BulletinVideoSort2) => {
42533
42795
  BulletinVideoSort2["CREATED_AT"] = "createdAt";
@@ -42555,27 +42817,27 @@ var schemaUpdateBulletinVideo = Joi92.object({
42555
42817
  function MBulletinVideo(value) {
42556
42818
  if (value._id && typeof value._id === "string") {
42557
42819
  try {
42558
- value._id = new ObjectId97(value._id);
42820
+ value._id = new ObjectId98(value._id);
42559
42821
  } catch {
42560
42822
  throw new Error("Invalid ID.");
42561
42823
  }
42562
42824
  }
42563
42825
  if (value.site && typeof value.site === "string") {
42564
42826
  try {
42565
- value.site = new ObjectId97(value.site);
42827
+ value.site = new ObjectId98(value.site);
42566
42828
  } catch {
42567
42829
  throw new Error("Invalid site ID.");
42568
42830
  }
42569
42831
  }
42570
42832
  if (value.file && typeof value.file === "string") {
42571
42833
  try {
42572
- value.file = new ObjectId97(value.file);
42834
+ value.file = new ObjectId98(value.file);
42573
42835
  } catch {
42574
42836
  throw new Error("Invalid file ID.");
42575
42837
  }
42576
42838
  }
42577
42839
  return {
42578
- _id: value._id ?? new ObjectId97(),
42840
+ _id: value._id ?? new ObjectId98(),
42579
42841
  site: value.site,
42580
42842
  title: value.title ?? "",
42581
42843
  description: value.description ?? "",
@@ -42597,7 +42859,7 @@ import {
42597
42859
  useAtlas as useAtlas82,
42598
42860
  useCache as useCache50
42599
42861
  } from "@7365admin1/node-server-utils";
42600
- import { ObjectId as ObjectId98 } from "mongodb";
42862
+ import { ObjectId as ObjectId99 } from "mongodb";
42601
42863
  function useBulletinVideoRepo() {
42602
42864
  const db = useAtlas82.getDb();
42603
42865
  if (!db) {
@@ -42659,7 +42921,7 @@ function useBulletinVideoRepo() {
42659
42921
  }, session) {
42660
42922
  page = page > 0 ? page - 1 : 0;
42661
42923
  try {
42662
- site = new ObjectId98(site);
42924
+ site = new ObjectId99(site);
42663
42925
  } catch (error) {
42664
42926
  throw new BadRequestError152("Invalid site ID format.");
42665
42927
  }
@@ -42739,7 +43001,7 @@ function useBulletinVideoRepo() {
42739
43001
  }
42740
43002
  async function getBulletinVideoById(_id, session) {
42741
43003
  try {
42742
- _id = new ObjectId98(_id);
43004
+ _id = new ObjectId99(_id);
42743
43005
  } catch (error) {
42744
43006
  throw new BadRequestError152("Invalid bulletin video ID format.");
42745
43007
  }
@@ -42770,13 +43032,13 @@ function useBulletinVideoRepo() {
42770
43032
  async function updateBulletinVideoById(_id, value, session) {
42771
43033
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42772
43034
  try {
42773
- _id = new ObjectId98(_id);
43035
+ _id = new ObjectId99(_id);
42774
43036
  } catch (error) {
42775
43037
  throw new BadRequestError152("Invalid ID format.");
42776
43038
  }
42777
43039
  if (value.file && typeof value.file === "string") {
42778
43040
  try {
42779
- value.file = new ObjectId98(value.file);
43041
+ value.file = new ObjectId99(value.file);
42780
43042
  } catch {
42781
43043
  throw new Error("Invalid file ID.");
42782
43044
  }
@@ -42805,7 +43067,7 @@ function useBulletinVideoRepo() {
42805
43067
  }
42806
43068
  async function deleteBulletinVideoById(_id, session) {
42807
43069
  try {
42808
- _id = new ObjectId98(_id);
43070
+ _id = new ObjectId99(_id);
42809
43071
  } catch (error) {
42810
43072
  throw new BadRequestError152("Invalid bulletin video ID format.");
42811
43073
  }
@@ -43069,7 +43331,7 @@ function useBulletinVideoController() {
43069
43331
 
43070
43332
  // src/models/site-soa.model.ts
43071
43333
  import { BadRequestError as BadRequestError154, logger as logger130 } from "@7365admin1/node-server-utils";
43072
- import { ObjectId as ObjectId99 } from "mongodb";
43334
+ import { ObjectId as ObjectId100 } from "mongodb";
43073
43335
  import Joi94 from "joi";
43074
43336
  var schemaSOABillingItem = Joi94.object({
43075
43337
  _id: Joi94.string().required(),
@@ -43137,28 +43399,28 @@ function MStatementOfAccount(value) {
43137
43399
  }
43138
43400
  if (value._id && typeof value._id === "string") {
43139
43401
  try {
43140
- value._id = new ObjectId99(value._id);
43402
+ value._id = new ObjectId100(value._id);
43141
43403
  } catch {
43142
43404
  throw new BadRequestError154("Invalid _id format");
43143
43405
  }
43144
43406
  }
43145
43407
  if (value.site && typeof value.site === "string") {
43146
43408
  try {
43147
- value.site = new ObjectId99(value.site);
43409
+ value.site = new ObjectId100(value.site);
43148
43410
  } catch {
43149
43411
  throw new BadRequestError154("Invalid site format");
43150
43412
  }
43151
43413
  }
43152
43414
  if (value.createdBy && typeof value.createdBy === "string") {
43153
43415
  try {
43154
- value.createdBy = new ObjectId99(value.createdBy);
43416
+ value.createdBy = new ObjectId100(value.createdBy);
43155
43417
  } catch {
43156
43418
  throw new BadRequestError154("Invalid createBy format");
43157
43419
  }
43158
43420
  }
43159
43421
  if (value.unitId && typeof value.unitId === "string") {
43160
43422
  try {
43161
- value.unitId = new ObjectId99(value.unitId);
43423
+ value.unitId = new ObjectId100(value.unitId);
43162
43424
  } catch {
43163
43425
  throw new BadRequestError154("Invalid unitId format");
43164
43426
  }
@@ -43167,7 +43429,7 @@ function MStatementOfAccount(value) {
43167
43429
  value.billing = value.billing.map((bill) => {
43168
43430
  if (bill._id && typeof bill._id === "string") {
43169
43431
  try {
43170
- bill._id = new ObjectId99(bill._id);
43432
+ bill._id = new ObjectId100(bill._id);
43171
43433
  } catch {
43172
43434
  throw new BadRequestError154("Invalid billing id format");
43173
43435
  }
@@ -43176,7 +43438,7 @@ function MStatementOfAccount(value) {
43176
43438
  });
43177
43439
  }
43178
43440
  return {
43179
- _id: value._id ?? new ObjectId99(),
43441
+ _id: value._id ?? new ObjectId100(),
43180
43442
  site: value.site,
43181
43443
  unitId: value.unitId ?? "",
43182
43444
  unit: value.unit ?? "",
@@ -43208,7 +43470,7 @@ import {
43208
43470
  paginate as paginate44,
43209
43471
  makeCacheKey as makeCacheKey49
43210
43472
  } from "@7365admin1/node-server-utils";
43211
- import { ObjectId as ObjectId100 } from "mongodb";
43473
+ import { ObjectId as ObjectId101 } from "mongodb";
43212
43474
  function useStatementOfAccountRepo() {
43213
43475
  const db = useAtlas84.getDb();
43214
43476
  if (!db) {
@@ -43306,7 +43568,7 @@ function useStatementOfAccountRepo() {
43306
43568
  { category: { $regex: search, $options: "i" } }
43307
43569
  ]
43308
43570
  },
43309
- ...ObjectId100.isValid(site) && { site: new ObjectId100(site) },
43571
+ ...ObjectId101.isValid(site) && { site: new ObjectId101(site) },
43310
43572
  ...dateExpr
43311
43573
  };
43312
43574
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -43361,7 +43623,7 @@ function useStatementOfAccountRepo() {
43361
43623
  }
43362
43624
  async function getById(_id) {
43363
43625
  try {
43364
- _id = new ObjectId100(_id);
43626
+ _id = new ObjectId101(_id);
43365
43627
  } catch (error) {
43366
43628
  throw new BadRequestError155("Invalid ID.");
43367
43629
  }
@@ -43400,7 +43662,7 @@ function useStatementOfAccountRepo() {
43400
43662
  }
43401
43663
  async function updateById(_id, value, session) {
43402
43664
  try {
43403
- _id = new ObjectId100(_id);
43665
+ _id = new ObjectId101(_id);
43404
43666
  } catch (error) {
43405
43667
  throw new BadRequestError155("Invalid site SOA transaction ID format.");
43406
43668
  }
@@ -43419,7 +43681,7 @@ function useStatementOfAccountRepo() {
43419
43681
  }
43420
43682
  async function deleteById(_id) {
43421
43683
  try {
43422
- _id = new ObjectId100(_id);
43684
+ _id = new ObjectId101(_id);
43423
43685
  } catch (error) {
43424
43686
  throw new BadRequestError155("Invalid site SOA transaction ID format.");
43425
43687
  }
@@ -43441,7 +43703,7 @@ function useStatementOfAccountRepo() {
43441
43703
  }
43442
43704
  async function updateStatusById(_id, value, session) {
43443
43705
  try {
43444
- _id = new ObjectId100(_id);
43706
+ _id = new ObjectId101(_id);
43445
43707
  } catch (error) {
43446
43708
  throw new BadRequestError155("Invalid file ID format.");
43447
43709
  }
@@ -43496,9 +43758,9 @@ function useStatementOfAccountRepo() {
43496
43758
  { category: { $regex: search, $options: "i" } }
43497
43759
  ]
43498
43760
  },
43499
- ...ObjectId100.isValid(site) && { site: new ObjectId100(site) },
43761
+ ...ObjectId101.isValid(site) && { site: new ObjectId101(site) },
43500
43762
  ...dateExpr,
43501
- ...ObjectId100.isValid(unitId) && { unitId: new ObjectId100(unitId) },
43763
+ ...ObjectId101.isValid(unitId) && { unitId: new ObjectId101(unitId) },
43502
43764
  ...category && { category }
43503
43765
  };
43504
43766
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -43548,7 +43810,7 @@ function useStatementOfAccountRepo() {
43548
43810
  async function reviewSOA(_id, value, session) {
43549
43811
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
43550
43812
  try {
43551
- _id = new ObjectId100(_id);
43813
+ _id = new ObjectId101(_id);
43552
43814
  } catch (error) {
43553
43815
  throw new BadRequestError155("Invalid ID format.");
43554
43816
  }
@@ -43597,7 +43859,7 @@ import {
43597
43859
  logger as logger132,
43598
43860
  useAtlas as useAtlas85
43599
43861
  } from "@7365admin1/node-server-utils";
43600
- import { ObjectId as ObjectId101 } from "mongodb";
43862
+ import { ObjectId as ObjectId102 } from "mongodb";
43601
43863
  import { launch } from "puppeteer";
43602
43864
  function useStatementOfAccountService() {
43603
43865
  const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
@@ -43734,7 +43996,7 @@ function useStatementOfAccountService() {
43734
43996
  if (!approvedBy || !approvedBy.name)
43735
43997
  throw new BadRequestError156("Created by not found.");
43736
43998
  value.approvedBy.name = approvedBy.name;
43737
- value.approvedBy._id = new ObjectId101(approvedBy._id);
43999
+ value.approvedBy._id = new ObjectId102(approvedBy._id);
43738
44000
  }
43739
44001
  await _reviewSOA(id, value, session);
43740
44002
  await session?.commitTransaction();
@@ -44116,7 +44378,7 @@ function useStatementOfAccountController() {
44116
44378
 
44117
44379
  // src/models/site-entrypass-settings.model.ts
44118
44380
  import { BadRequestError as BadRequestError158, logger as logger134 } from "@7365admin1/node-server-utils";
44119
- import { ObjectId as ObjectId102 } from "mongodb";
44381
+ import { ObjectId as ObjectId103 } from "mongodb";
44120
44382
  import Joi96 from "joi";
44121
44383
  var schemaEntryPassSettings = Joi96.object({
44122
44384
  _id: Joi96.string().hex().optional().allow("", null),
@@ -44164,21 +44426,21 @@ function MEntryPassSettings(value) {
44164
44426
  }
44165
44427
  if (value._id && typeof value._id === "string") {
44166
44428
  try {
44167
- value._id = new ObjectId102(value._id);
44429
+ value._id = new ObjectId103(value._id);
44168
44430
  } catch {
44169
44431
  throw new BadRequestError158("Invalid _id format");
44170
44432
  }
44171
44433
  }
44172
44434
  if (value.site && typeof value.site === "string") {
44173
44435
  try {
44174
- value.site = new ObjectId102(value.site);
44436
+ value.site = new ObjectId103(value.site);
44175
44437
  } catch {
44176
44438
  throw new BadRequestError158("Invalid site format");
44177
44439
  }
44178
44440
  }
44179
44441
  if (value.org && typeof value.org === "string") {
44180
44442
  try {
44181
- value.org = new ObjectId102(value.org);
44443
+ value.org = new ObjectId103(value.org);
44182
44444
  } catch {
44183
44445
  throw new BadRequestError158("Invalid org format");
44184
44446
  }
@@ -44217,7 +44479,7 @@ import {
44217
44479
  useAtlas as useAtlas86,
44218
44480
  useCache as useCache52
44219
44481
  } from "@7365admin1/node-server-utils";
44220
- import { ObjectId as ObjectId103 } from "mongodb";
44482
+ import { ObjectId as ObjectId104 } from "mongodb";
44221
44483
  function useEntryPassSettingsRepo() {
44222
44484
  const db = useAtlas86.getDb();
44223
44485
  if (!db) {
@@ -44327,7 +44589,7 @@ function useEntryPassSettingsRepo() {
44327
44589
  }
44328
44590
  async function getEntryPassSettingsById(_id) {
44329
44591
  try {
44330
- _id = new ObjectId103(_id);
44592
+ _id = new ObjectId104(_id);
44331
44593
  } catch (error) {
44332
44594
  throw new BadRequestError159("Invalid entry pass settings ID format.");
44333
44595
  }
@@ -44394,7 +44656,7 @@ function useEntryPassSettingsRepo() {
44394
44656
  }
44395
44657
  async function updateEntryPassSettingsById(_id, value) {
44396
44658
  try {
44397
- _id = new ObjectId103(_id);
44659
+ _id = new ObjectId104(_id);
44398
44660
  } catch (error) {
44399
44661
  throw new BadRequestError159("Invalid entry pass settings ID format.");
44400
44662
  }
@@ -44422,7 +44684,7 @@ function useEntryPassSettingsRepo() {
44422
44684
  }
44423
44685
  async function deleteEntryPassSettingsById(_id, session) {
44424
44686
  try {
44425
- _id = new ObjectId103(_id);
44687
+ _id = new ObjectId104(_id);
44426
44688
  } catch (error) {
44427
44689
  throw new BadRequestError159("Invalid card ID format.");
44428
44690
  }
@@ -44455,7 +44717,7 @@ function useEntryPassSettingsRepo() {
44455
44717
  }
44456
44718
  async function getEntryPassSettingsBySiteId(site) {
44457
44719
  try {
44458
- site = new ObjectId103(site);
44720
+ site = new ObjectId104(site);
44459
44721
  } catch (error) {
44460
44722
  throw new BadRequestError159("Invalid entry pass settings ID format.");
44461
44723
  }
@@ -44522,7 +44784,7 @@ function useEntryPassSettingsRepo() {
44522
44784
  }
44523
44785
  async function updateEntryPassSettingsBySiteId(site, value) {
44524
44786
  try {
44525
- site = new ObjectId103(site);
44787
+ site = new ObjectId104(site);
44526
44788
  } catch (error) {
44527
44789
  throw new BadRequestError159("Invalid entry pass settings ID format.");
44528
44790
  }
@@ -44887,7 +45149,7 @@ function useDashboardController() {
44887
45149
  }
44888
45150
 
44889
45151
  // src/models/nfc-patrol-route.model.ts
44890
- import { ObjectId as ObjectId104 } from "mongodb";
45152
+ import { ObjectId as ObjectId105 } from "mongodb";
44891
45153
  import Joi99 from "joi";
44892
45154
  import { BadRequestError as BadRequestError162, logger as logger139 } from "@7365admin1/node-server-utils";
44893
45155
  var schemaNfcPatrolRoute = Joi99.object({
@@ -44923,23 +45185,23 @@ function MNfcPatrolRoute(value) {
44923
45185
  }
44924
45186
  if (value._id && typeof value._id === "string") {
44925
45187
  try {
44926
- value._id = new ObjectId104(value._id);
45188
+ value._id = new ObjectId105(value._id);
44927
45189
  } catch (error2) {
44928
45190
  throw new BadRequestError162("Invalid _id format");
44929
45191
  }
44930
45192
  }
44931
45193
  try {
44932
- value.site = new ObjectId104(value.site);
45194
+ value.site = new ObjectId105(value.site);
44933
45195
  } catch (error2) {
44934
45196
  throw new BadRequestError162("Invalid site format");
44935
45197
  }
44936
45198
  try {
44937
- value.createdBy = new ObjectId104(value.createdBy);
45199
+ value.createdBy = new ObjectId105(value.createdBy);
44938
45200
  } catch (error2) {
44939
45201
  throw new BadRequestError162("Invalid createdBy format");
44940
45202
  }
44941
45203
  return {
44942
- _id: value._id ?? new ObjectId104(),
45204
+ _id: value._id ?? new ObjectId105(),
44943
45205
  site: value.site,
44944
45206
  name: value.name,
44945
45207
  checkPointNumber: value.checkPointNumber,
@@ -44964,7 +45226,7 @@ import {
44964
45226
  useAtlas as useAtlas88,
44965
45227
  useCache as useCache54
44966
45228
  } from "@7365admin1/node-server-utils";
44967
- import { ObjectId as ObjectId105 } from "mongodb";
45229
+ import { ObjectId as ObjectId106 } from "mongodb";
44968
45230
  function useNfcPatrolRouteRepo() {
44969
45231
  const db = useAtlas88.getDb();
44970
45232
  if (!db) {
@@ -45008,7 +45270,7 @@ function useNfcPatrolRouteRepo() {
45008
45270
  }, session) {
45009
45271
  page = page > 0 ? page - 1 : 0;
45010
45272
  try {
45011
- site = new ObjectId105(site);
45273
+ site = new ObjectId106(site);
45012
45274
  } catch (error) {
45013
45275
  throw new BadRequestError163("Invalid site ID format.");
45014
45276
  }
@@ -45079,7 +45341,7 @@ function useNfcPatrolRouteRepo() {
45079
45341
  }
45080
45342
  async function getById(_id, isStart) {
45081
45343
  try {
45082
- _id = new ObjectId105(_id);
45344
+ _id = new ObjectId106(_id);
45083
45345
  } catch (error) {
45084
45346
  throw new BadRequestError163("Invalid ID.");
45085
45347
  }
@@ -45189,18 +45451,18 @@ function useNfcPatrolRouteRepo() {
45189
45451
  throw new BadRequestError163(error.message);
45190
45452
  }
45191
45453
  try {
45192
- _id = new ObjectId105(_id);
45454
+ _id = new ObjectId106(_id);
45193
45455
  } catch (error2) {
45194
45456
  throw new BadRequestError163("Invalid ID.");
45195
45457
  }
45196
45458
  try {
45197
- value.site = new ObjectId105(value.site);
45459
+ value.site = new ObjectId106(value.site);
45198
45460
  } catch (error2) {
45199
45461
  throw new BadRequestError163("Invalid site format");
45200
45462
  }
45201
45463
  if (value.updatedBy) {
45202
45464
  try {
45203
- value.updatedBy = new ObjectId105(value.updatedBy);
45465
+ value.updatedBy = new ObjectId106(value.updatedBy);
45204
45466
  } catch (error2) {
45205
45467
  throw new BadRequestError163("Invalid createdBy format");
45206
45468
  }
@@ -45433,7 +45695,7 @@ function useNfcPatrolRouteController() {
45433
45695
  }
45434
45696
 
45435
45697
  // src/models/incident-report.model.ts
45436
- import { ObjectId as ObjectId106 } from "mongodb";
45698
+ import { ObjectId as ObjectId107 } from "mongodb";
45437
45699
  import Joi101 from "joi";
45438
45700
  var residentSchema = Joi101.object({
45439
45701
  _id: Joi101.string().hex().optional().allow(null, ""),
@@ -45639,28 +45901,28 @@ var schemaUpdateIncidentReport = Joi101.object({
45639
45901
  function MIncidentReport(value) {
45640
45902
  if (value._id && typeof value._id === "string") {
45641
45903
  try {
45642
- value._id = new ObjectId106(value._id);
45904
+ value._id = new ObjectId107(value._id);
45643
45905
  } catch {
45644
45906
  throw new Error("Invalid incident report ID.");
45645
45907
  }
45646
45908
  }
45647
45909
  if (value.organization && typeof value.organization === "string") {
45648
45910
  try {
45649
- value.organization = new ObjectId106(value.organization);
45911
+ value.organization = new ObjectId107(value.organization);
45650
45912
  } catch {
45651
45913
  throw new Error("Invalid organization ID.");
45652
45914
  }
45653
45915
  }
45654
45916
  if (value.site && typeof value.site === "string") {
45655
45917
  try {
45656
- value.site = new ObjectId106(value.site);
45918
+ value.site = new ObjectId107(value.site);
45657
45919
  } catch {
45658
45920
  throw new Error("Invalid site ID.");
45659
45921
  }
45660
45922
  }
45661
45923
  if (value.approvedBy && typeof value.approvedBy === "string") {
45662
45924
  try {
45663
- value.approvedBy = new ObjectId106(value.approvedBy);
45925
+ value.approvedBy = new ObjectId107(value.approvedBy);
45664
45926
  } catch {
45665
45927
  throw new Error("Invalid approvedBy ID.");
45666
45928
  }
@@ -45668,7 +45930,7 @@ function MIncidentReport(value) {
45668
45930
  const { incidentInformation } = value;
45669
45931
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
45670
45932
  try {
45671
- incidentInformation.siteInfo.site = new ObjectId106(
45933
+ incidentInformation.siteInfo.site = new ObjectId107(
45672
45934
  incidentInformation.siteInfo.site
45673
45935
  );
45674
45936
  } catch {
@@ -45682,7 +45944,7 @@ function MIncidentReport(value) {
45682
45944
  incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
45683
45945
  }
45684
45946
  return {
45685
- _id: value._id ?? new ObjectId106(),
45947
+ _id: value._id ?? new ObjectId107(),
45686
45948
  reportId: value.reportId,
45687
45949
  incidentInformation: value.incidentInformation,
45688
45950
  affectedEntities: value.affectedEntities,
@@ -45720,7 +45982,7 @@ import {
45720
45982
  useAtlas as useAtlas90,
45721
45983
  useCache as useCache55
45722
45984
  } from "@7365admin1/node-server-utils";
45723
- import { ObjectId as ObjectId107 } from "mongodb";
45985
+ import { ObjectId as ObjectId108 } from "mongodb";
45724
45986
  var incidents_namespace_collection = "incident-reports";
45725
45987
  function useIncidentReportRepo() {
45726
45988
  const db = useAtlas90.getDb();
@@ -45787,7 +46049,7 @@ function useIncidentReportRepo() {
45787
46049
  page = page > 0 ? page - 1 : 0;
45788
46050
  let dateExpr = {};
45789
46051
  try {
45790
- site = new ObjectId107(site);
46052
+ site = new ObjectId108(site);
45791
46053
  } catch (error) {
45792
46054
  throw new BadRequestError166("Invalid site ID format.");
45793
46055
  }
@@ -45888,7 +46150,7 @@ function useIncidentReportRepo() {
45888
46150
  page = page > 0 ? page - 1 : 0;
45889
46151
  let dateExpr = {};
45890
46152
  try {
45891
- site = new ObjectId107(site);
46153
+ site = new ObjectId108(site);
45892
46154
  } catch (error) {
45893
46155
  throw new BadRequestError166("Invalid site ID format.");
45894
46156
  }
@@ -45957,7 +46219,7 @@ function useIncidentReportRepo() {
45957
46219
  }
45958
46220
  async function getIncidentReportById(_id, session) {
45959
46221
  try {
45960
- _id = new ObjectId107(_id);
46222
+ _id = new ObjectId108(_id);
45961
46223
  } catch (error) {
45962
46224
  throw new BadRequestError166("Invalid incident report ID format.");
45963
46225
  }
@@ -45988,27 +46250,27 @@ function useIncidentReportRepo() {
45988
46250
  async function updateIncidentReportById(_id, value, session) {
45989
46251
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
45990
46252
  try {
45991
- _id = new ObjectId107(_id);
46253
+ _id = new ObjectId108(_id);
45992
46254
  } catch (error) {
45993
46255
  throw new BadRequestError166("Invalid ID format.");
45994
46256
  }
45995
46257
  if (value.organization && typeof value.organization === "string") {
45996
46258
  try {
45997
- value.organization = new ObjectId107(value.organization);
46259
+ value.organization = new ObjectId108(value.organization);
45998
46260
  } catch {
45999
46261
  throw new Error("Invalid organization ID.");
46000
46262
  }
46001
46263
  }
46002
46264
  if (value.site && typeof value.site === "string") {
46003
46265
  try {
46004
- value.site = new ObjectId107(value.site);
46266
+ value.site = new ObjectId108(value.site);
46005
46267
  } catch {
46006
46268
  throw new Error("Invalid site ID.");
46007
46269
  }
46008
46270
  }
46009
46271
  if (value.approvedBy && typeof value.approvedBy === "string") {
46010
46272
  try {
46011
- value.approvedBy = new ObjectId107(value.approvedBy);
46273
+ value.approvedBy = new ObjectId108(value.approvedBy);
46012
46274
  } catch {
46013
46275
  throw new Error("Invalid approvedBy ID.");
46014
46276
  }
@@ -46016,7 +46278,7 @@ function useIncidentReportRepo() {
46016
46278
  const { incidentInformation } = value;
46017
46279
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
46018
46280
  try {
46019
- incidentInformation.siteInfo.site = new ObjectId107(
46281
+ incidentInformation.siteInfo.site = new ObjectId108(
46020
46282
  incidentInformation.siteInfo.site
46021
46283
  );
46022
46284
  } catch {
@@ -46051,7 +46313,7 @@ function useIncidentReportRepo() {
46051
46313
  }
46052
46314
  async function deleteIncidentReportById(_id) {
46053
46315
  try {
46054
- _id = new ObjectId107(_id);
46316
+ _id = new ObjectId108(_id);
46055
46317
  } catch (error) {
46056
46318
  throw new BadRequestError166("Invalid occurrence subject ID format.");
46057
46319
  }
@@ -46083,7 +46345,7 @@ function useIncidentReportRepo() {
46083
46345
  async function reviewIncidentReport(_id, value, session) {
46084
46346
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
46085
46347
  try {
46086
- _id = new ObjectId107(_id);
46348
+ _id = new ObjectId108(_id);
46087
46349
  } catch (error) {
46088
46350
  throw new BadRequestError166("Invalid ID format.");
46089
46351
  }
@@ -46576,7 +46838,7 @@ function useIncidentReportController() {
46576
46838
  }
46577
46839
 
46578
46840
  // src/models/nfc-patrol-settings.model.ts
46579
- import { ObjectId as ObjectId108 } from "mongodb";
46841
+ import { ObjectId as ObjectId109 } from "mongodb";
46580
46842
  import Joi103 from "joi";
46581
46843
  import { BadRequestError as BadRequestError169, logger as logger145 } from "@7365admin1/node-server-utils";
46582
46844
  var objectId = Joi103.string().hex().length(24);
@@ -46602,7 +46864,7 @@ function MNfcPatrolSettings(value) {
46602
46864
  }
46603
46865
  if (value.site) {
46604
46866
  try {
46605
- value.site = new ObjectId108(value.site);
46867
+ value.site = new ObjectId109(value.site);
46606
46868
  } catch (error2) {
46607
46869
  throw new BadRequestError169("Invalid site ID format.");
46608
46870
  }
@@ -46622,7 +46884,7 @@ function MNfcPatrolSettingsUpdate(value) {
46622
46884
  }
46623
46885
  if (value.updatedBy) {
46624
46886
  try {
46625
- value.updatedBy = new ObjectId108(value.updatedBy);
46887
+ value.updatedBy = new ObjectId109(value.updatedBy);
46626
46888
  } catch (error2) {
46627
46889
  throw new BadRequestError169("Invalid updatedBy ID format.");
46628
46890
  }
@@ -46644,7 +46906,7 @@ import {
46644
46906
  useAtlas as useAtlas92,
46645
46907
  useCache as useCache56
46646
46908
  } from "@7365admin1/node-server-utils";
46647
- import { ObjectId as ObjectId109 } from "mongodb";
46909
+ import { ObjectId as ObjectId110 } from "mongodb";
46648
46910
  function useNfcPatrolSettingsRepository() {
46649
46911
  const db = useAtlas92.getDb();
46650
46912
  if (!db) {
@@ -46674,7 +46936,7 @@ function useNfcPatrolSettingsRepository() {
46674
46936
  }
46675
46937
  async function getNfcPatrolSettingsBySite(site, session) {
46676
46938
  try {
46677
- site = new ObjectId109(site);
46939
+ site = new ObjectId110(site);
46678
46940
  } catch (error) {
46679
46941
  throw new BadRequestError170("Invalid nfc patrol settings site ID format.");
46680
46942
  }
@@ -46718,7 +46980,7 @@ function useNfcPatrolSettingsRepository() {
46718
46980
  }
46719
46981
  async function updateNfcPatrolSettings(site, value, session) {
46720
46982
  try {
46721
- site = new ObjectId109(site);
46983
+ site = new ObjectId110(site);
46722
46984
  } catch (error) {
46723
46985
  throw new BadRequestError170("Invalid attendance settings ID format.");
46724
46986
  }
@@ -46887,7 +47149,7 @@ function useNfcPatrolSettingsController() {
46887
47149
 
46888
47150
  // src/services/occurrence-entry.service.ts
46889
47151
  import { useAtlas as useAtlas95 } from "@7365admin1/node-server-utils";
46890
- import { ObjectId as ObjectId112 } from "mongodb";
47152
+ import { ObjectId as ObjectId113 } from "mongodb";
46891
47153
 
46892
47154
  // src/repositories/occurrence-subject.repo.ts
46893
47155
  import {
@@ -46902,7 +47164,7 @@ import {
46902
47164
  } from "@7365admin1/node-server-utils";
46903
47165
 
46904
47166
  // src/models/occurrence-subject.model.ts
46905
- import { ObjectId as ObjectId110 } from "mongodb";
47167
+ import { ObjectId as ObjectId111 } from "mongodb";
46906
47168
  import Joi105 from "joi";
46907
47169
  var SubjectSort = /* @__PURE__ */ ((SubjectSort2) => {
46908
47170
  SubjectSort2["CREATED_AT"] = "createdAt";
@@ -46927,27 +47189,27 @@ var schemaUpdateOccurrenceSubject = Joi105.object({
46927
47189
  function MOccurrenceSubject(value) {
46928
47190
  if (value._id && typeof value._id === "string") {
46929
47191
  try {
46930
- value._id = new ObjectId110(value._id);
47192
+ value._id = new ObjectId111(value._id);
46931
47193
  } catch {
46932
47194
  throw new Error("Invalid ID.");
46933
47195
  }
46934
47196
  }
46935
47197
  if (value.site && typeof value.site === "string") {
46936
47198
  try {
46937
- value.site = new ObjectId110(value.site);
47199
+ value.site = new ObjectId111(value.site);
46938
47200
  } catch {
46939
47201
  throw new Error("Invalid site ID.");
46940
47202
  }
46941
47203
  }
46942
47204
  if (value.addedBy && typeof value.addedBy === "string") {
46943
47205
  try {
46944
- value.addedBy = new ObjectId110(value.addedBy);
47206
+ value.addedBy = new ObjectId111(value.addedBy);
46945
47207
  } catch {
46946
47208
  throw new Error("Invalid addedBy ID.");
46947
47209
  }
46948
47210
  }
46949
47211
  return {
46950
- _id: value._id ?? new ObjectId110(),
47212
+ _id: value._id ?? new ObjectId111(),
46951
47213
  site: value.site,
46952
47214
  subject: value.subject,
46953
47215
  addedBy: value.addedBy ?? "",
@@ -46958,7 +47220,7 @@ function MOccurrenceSubject(value) {
46958
47220
  }
46959
47221
 
46960
47222
  // src/repositories/occurrence-subject.repo.ts
46961
- import { ObjectId as ObjectId111 } from "mongodb";
47223
+ import { ObjectId as ObjectId112 } from "mongodb";
46962
47224
  function useOccurrenceSubjectRepo() {
46963
47225
  const db = useAtlas94.getDb();
46964
47226
  if (!db) {
@@ -47017,7 +47279,7 @@ function useOccurrenceSubjectRepo() {
47017
47279
  }, session) {
47018
47280
  page = page > 0 ? page - 1 : 0;
47019
47281
  try {
47020
- site = new ObjectId111(site);
47282
+ site = new ObjectId112(site);
47021
47283
  } catch (error) {
47022
47284
  throw new BadRequestError173("Invalid site ID format.");
47023
47285
  }
@@ -47110,7 +47372,7 @@ function useOccurrenceSubjectRepo() {
47110
47372
  }
47111
47373
  async function getOccurrenceSubjectById(_id, session) {
47112
47374
  try {
47113
- _id = new ObjectId111(_id);
47375
+ _id = new ObjectId112(_id);
47114
47376
  } catch (error) {
47115
47377
  throw new BadRequestError173("Invalid occurrence subject ID format.");
47116
47378
  }
@@ -47138,7 +47400,7 @@ function useOccurrenceSubjectRepo() {
47138
47400
  async function updateOccurrenceSubjectById(_id, value, session) {
47139
47401
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
47140
47402
  try {
47141
- _id = new ObjectId111(_id);
47403
+ _id = new ObjectId112(_id);
47142
47404
  } catch (error) {
47143
47405
  throw new BadRequestError173("Invalid ID format.");
47144
47406
  }
@@ -47168,7 +47430,7 @@ function useOccurrenceSubjectRepo() {
47168
47430
  }
47169
47431
  async function deleteOccurrenceSubjectById(_id) {
47170
47432
  try {
47171
- _id = new ObjectId111(_id);
47433
+ _id = new ObjectId112(_id);
47172
47434
  } catch (error) {
47173
47435
  throw new BadRequestError173("Invalid occurrence subject ID format.");
47174
47436
  }
@@ -47299,8 +47561,8 @@ function useOccurrenceEntryService() {
47299
47561
  value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
47300
47562
  value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
47301
47563
  value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
47302
- value.signature = value.signature ? new ObjectId112(value.signature) : occurrenceEntry.signature._id;
47303
- value.eSignature = value.eSignature ? new ObjectId112(value.eSignature) : occurrenceEntry.eSignature;
47564
+ value.signature = value.signature ? new ObjectId113(value.signature) : occurrenceEntry.signature._id;
47565
+ value.eSignature = value.eSignature ? new ObjectId113(value.eSignature) : occurrenceEntry.eSignature;
47304
47566
  value.createdAt = /* @__PURE__ */ new Date();
47305
47567
  value.date = value.date ? value.date : occurrenceEntry.date;
47306
47568
  value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
@@ -47492,7 +47754,7 @@ function useOccurrenceEntryController() {
47492
47754
 
47493
47755
  // src/models/online-form.model.ts
47494
47756
  import Joi107 from "joi";
47495
- import { ObjectId as ObjectId113 } from "mongodb";
47757
+ import { ObjectId as ObjectId114 } from "mongodb";
47496
47758
  var schemaOnlineForm = Joi107.object({
47497
47759
  _id: Joi107.string().hex().optional().allow("", null),
47498
47760
  name: Joi107.string().required(),
@@ -47540,21 +47802,21 @@ function MOnlineForm(value) {
47540
47802
  }
47541
47803
  if (value._id && typeof value._id === "string") {
47542
47804
  try {
47543
- value._id = new ObjectId113(value._id);
47805
+ value._id = new ObjectId114(value._id);
47544
47806
  } catch (error2) {
47545
47807
  throw new Error("Invalid ID.");
47546
47808
  }
47547
47809
  }
47548
47810
  if (value.org && typeof value.org === "string") {
47549
47811
  try {
47550
- value.org = new ObjectId113(value.org);
47812
+ value.org = new ObjectId114(value.org);
47551
47813
  } catch (error2) {
47552
47814
  throw new Error("Invalid org ID.");
47553
47815
  }
47554
47816
  }
47555
47817
  if (value.site && typeof value.site === "string") {
47556
47818
  try {
47557
- value.site = new ObjectId113(value.site);
47819
+ value.site = new ObjectId114(value.site);
47558
47820
  } catch (error2) {
47559
47821
  throw new Error("Invalid site ID.");
47560
47822
  }
@@ -47586,7 +47848,7 @@ import {
47586
47848
  useAtlas as useAtlas96,
47587
47849
  useCache as useCache58
47588
47850
  } from "@7365admin1/node-server-utils";
47589
- import { ObjectId as ObjectId114 } from "mongodb";
47851
+ import { ObjectId as ObjectId115 } from "mongodb";
47590
47852
  function useOnlineFormRepo() {
47591
47853
  const db = useAtlas96.getDb();
47592
47854
  if (!db) {
@@ -47638,7 +47900,7 @@ function useOnlineFormRepo() {
47638
47900
  }) {
47639
47901
  page = page > 0 ? page - 1 : 0;
47640
47902
  try {
47641
- site = new ObjectId114(site);
47903
+ site = new ObjectId115(site);
47642
47904
  } catch (error) {
47643
47905
  throw new BadRequestError175("Invalid site ID format.");
47644
47906
  }
@@ -47698,7 +47960,7 @@ function useOnlineFormRepo() {
47698
47960
  }
47699
47961
  async function getOnlineFormById(_id) {
47700
47962
  try {
47701
- _id = new ObjectId114(_id);
47963
+ _id = new ObjectId115(_id);
47702
47964
  } catch (error) {
47703
47965
  throw new BadRequestError175("Invalid online form ID format.");
47704
47966
  }
@@ -47741,7 +48003,7 @@ function useOnlineFormRepo() {
47741
48003
  }
47742
48004
  async function updateOnlineFormById(_id, value) {
47743
48005
  try {
47744
- _id = new ObjectId114(_id);
48006
+ _id = new ObjectId115(_id);
47745
48007
  } catch (error) {
47746
48008
  throw new BadRequestError175("Invalid online form ID format.");
47747
48009
  }
@@ -47769,7 +48031,7 @@ function useOnlineFormRepo() {
47769
48031
  }
47770
48032
  async function deleteOnlineFormById(_id, session) {
47771
48033
  try {
47772
- _id = new ObjectId114(_id);
48034
+ _id = new ObjectId115(_id);
47773
48035
  } catch (error) {
47774
48036
  throw new BadRequestError175("Invalid online form ID format.");
47775
48037
  }
@@ -47802,7 +48064,7 @@ function useOnlineFormRepo() {
47802
48064
  }
47803
48065
  async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
47804
48066
  try {
47805
- site = new ObjectId114(site);
48067
+ site = new ObjectId115(site);
47806
48068
  } catch (error) {
47807
48069
  throw new BadRequestError175(
47808
48070
  "Invalid online form configuration site ID format."
@@ -48234,7 +48496,7 @@ function useOccurrenceSubjectController() {
48234
48496
  }
48235
48497
 
48236
48498
  // src/models/nfc-patrol-log.model.ts
48237
- import { ObjectId as ObjectId115 } from "mongodb";
48499
+ import { ObjectId as ObjectId116 } from "mongodb";
48238
48500
  import Joi110 from "joi";
48239
48501
  import { BadRequestError as BadRequestError178, logger as logger154 } from "@7365admin1/node-server-utils";
48240
48502
  var schemaNfcPatrolLog = Joi110.object({
@@ -48286,32 +48548,32 @@ function MNfcPatrolLog(valueArg) {
48286
48548
  }
48287
48549
  if (value._id && typeof value._id === "string") {
48288
48550
  try {
48289
- value._id = new ObjectId115(value._id);
48551
+ value._id = new ObjectId116(value._id);
48290
48552
  } catch (error2) {
48291
48553
  throw new BadRequestError178("Invalid _id format");
48292
48554
  }
48293
48555
  }
48294
48556
  try {
48295
- value.site = new ObjectId115(value.site);
48557
+ value.site = new ObjectId116(value.site);
48296
48558
  } catch (error2) {
48297
48559
  throw new BadRequestError178("Invalid site format");
48298
48560
  }
48299
48561
  if (value?.createdBy) {
48300
48562
  try {
48301
- value.createdBy = new ObjectId115(value.createdBy);
48563
+ value.createdBy = new ObjectId116(value.createdBy);
48302
48564
  } catch (error2) {
48303
48565
  throw new BadRequestError178("Invalid createdBy format");
48304
48566
  }
48305
48567
  }
48306
48568
  if (value?.route?._id) {
48307
48569
  try {
48308
- value.route._id = new ObjectId115(value.route._id);
48570
+ value.route._id = new ObjectId116(value.route._id);
48309
48571
  } catch (error2) {
48310
48572
  throw new BadRequestError178("Invalid route _id format");
48311
48573
  }
48312
48574
  }
48313
48575
  return {
48314
- _id: value._id ?? new ObjectId115(),
48576
+ _id: value._id ?? new ObjectId116(),
48315
48577
  site: value.site,
48316
48578
  route: value.route,
48317
48579
  date: value.date,
@@ -48333,7 +48595,7 @@ import {
48333
48595
  useAtlas as useAtlas98,
48334
48596
  useCache as useCache59
48335
48597
  } from "@7365admin1/node-server-utils";
48336
- import { ObjectId as ObjectId116 } from "mongodb";
48598
+ import { ObjectId as ObjectId117 } from "mongodb";
48337
48599
  function useNfcPatrolLogRepo() {
48338
48600
  const db = useAtlas98.getDb();
48339
48601
  if (!db) {
@@ -48386,7 +48648,7 @@ function useNfcPatrolLogRepo() {
48386
48648
  const pageIndex = page > 0 ? page - 1 : 0;
48387
48649
  let siteId;
48388
48650
  try {
48389
- siteId = typeof site === "string" ? new ObjectId116(site) : site;
48651
+ siteId = typeof site === "string" ? new ObjectId117(site) : site;
48390
48652
  } catch {
48391
48653
  throw new BadRequestError179("Invalid site ID format.");
48392
48654
  }
@@ -48397,7 +48659,7 @@ function useNfcPatrolLogRepo() {
48397
48659
  query.date = date;
48398
48660
  }
48399
48661
  if (route?._id) {
48400
- query["route._id"] = typeof route._id === "string" ? new ObjectId116(route._id) : route._id;
48662
+ query["route._id"] = typeof route._id === "string" ? new ObjectId117(route._id) : route._id;
48401
48663
  }
48402
48664
  if (route?.startTime) {
48403
48665
  query["route.startTime"] = route.startTime;
@@ -49269,7 +49531,7 @@ function useNewDashboardController() {
49269
49531
 
49270
49532
  // src/models/manpower-monitoring.model.ts
49271
49533
  import Joi113 from "joi";
49272
- import { ObjectId as ObjectId117 } from "mongodb";
49534
+ import { ObjectId as ObjectId118 } from "mongodb";
49273
49535
  var shiftSchema = Joi113.object({
49274
49536
  name: Joi113.string().required(),
49275
49537
  checkIn: Joi113.string().optional().allow("", null),
@@ -49294,7 +49556,7 @@ var manpowerMonitoringSchema = Joi113.object({
49294
49556
  });
49295
49557
  var MManpowerMonitoring = class {
49296
49558
  constructor(data) {
49297
- this._id = new ObjectId117();
49559
+ this._id = new ObjectId118();
49298
49560
  this.serviceProviderId = data.serviceProviderId || "";
49299
49561
  this.siteId = data.siteId || "";
49300
49562
  this.siteName = data.siteName;
@@ -49548,7 +49810,7 @@ function filterByStatus(attendance, shiftData, timezone, format2, status) {
49548
49810
  }
49549
49811
  });
49550
49812
  }
49551
- function sleep(ms) {
49813
+ function sleep2(ms) {
49552
49814
  return new Promise((resolve) => setTimeout(resolve, ms));
49553
49815
  }
49554
49816
  async function fetchSites({ siteUrl, token }) {
@@ -49575,7 +49837,7 @@ async function fetchSites({ siteUrl, token }) {
49575
49837
  }
49576
49838
  if (attempt < maxRetries) {
49577
49839
  const delay = 1e3 * attempt;
49578
- await sleep(delay);
49840
+ await sleep2(delay);
49579
49841
  }
49580
49842
  }
49581
49843
  } while (attempt < maxRetries);
@@ -49767,7 +50029,7 @@ var hrmlabs_attendance_util_default = {
49767
50029
  };
49768
50030
 
49769
50031
  // src/repositories/manpower-monitoring.repo.ts
49770
- import { ObjectId as ObjectId118 } from "mongodb";
50032
+ import { ObjectId as ObjectId119 } from "mongodb";
49771
50033
  var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
49772
50034
  function useManpowerMonitoringRepo() {
49773
50035
  const db = useAtlas101.getDb();
@@ -49802,11 +50064,11 @@ function useManpowerMonitoringRepo() {
49802
50064
  try {
49803
50065
  value = new MManpowerMonitoring(value);
49804
50066
  if (value.createdBy)
49805
- value.createdBy = new ObjectId118(value.createdBy);
50067
+ value.createdBy = new ObjectId119(value.createdBy);
49806
50068
  if (value.siteId)
49807
- value.siteId = new ObjectId118(value.siteId);
50069
+ value.siteId = new ObjectId119(value.siteId);
49808
50070
  if (value.serviceProviderId)
49809
- value.serviceProviderId = new ObjectId118(value.serviceProviderId);
50071
+ value.serviceProviderId = new ObjectId119(value.serviceProviderId);
49810
50072
  const result = await collection.insertOne(value, { session });
49811
50073
  return result;
49812
50074
  } catch (error) {
@@ -49847,8 +50109,8 @@ function useManpowerMonitoringRepo() {
49847
50109
  }
49848
50110
  async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
49849
50111
  try {
49850
- _id = new ObjectId118(_id);
49851
- serviceProviderId = new ObjectId118(serviceProviderId);
50112
+ _id = new ObjectId119(_id);
50113
+ serviceProviderId = new ObjectId119(serviceProviderId);
49852
50114
  } catch (error) {
49853
50115
  throw new Error("Invalid Site ID format.");
49854
50116
  }
@@ -49864,7 +50126,7 @@ function useManpowerMonitoringRepo() {
49864
50126
  }
49865
50127
  async function updateManpowerMonitoringSettings(_id, value) {
49866
50128
  try {
49867
- _id = new ObjectId118(_id);
50129
+ _id = new ObjectId119(_id);
49868
50130
  } catch (error) {
49869
50131
  throw new BadRequestError184("Invalid ID format.");
49870
50132
  }
@@ -49891,7 +50153,7 @@ function useManpowerMonitoringRepo() {
49891
50153
  for (let item of value) {
49892
50154
  item = new MManpowerMonitoring(item);
49893
50155
  const data = await collection.findOne({
49894
- siteId: new ObjectId118(item.siteId)
50156
+ siteId: new ObjectId119(item.siteId)
49895
50157
  });
49896
50158
  if (data) {
49897
50159
  let updateValue;
@@ -49916,11 +50178,11 @@ function useManpowerMonitoringRepo() {
49916
50178
  }
49917
50179
  } else {
49918
50180
  if (item.createdBy)
49919
- item.createdBy = new ObjectId118(item.createdBy);
50181
+ item.createdBy = new ObjectId119(item.createdBy);
49920
50182
  if (item.siteId)
49921
- item.siteId = new ObjectId118(item.siteId);
50183
+ item.siteId = new ObjectId119(item.siteId);
49922
50184
  if (item.serviceProviderId)
49923
- item.serviceProviderId = new ObjectId118(item.serviceProviderId);
50185
+ item.serviceProviderId = new ObjectId119(item.serviceProviderId);
49924
50186
  const result = await collection.insertOne(item);
49925
50187
  if (result.insertedId) {
49926
50188
  results.inserted++;
@@ -49944,7 +50206,7 @@ function useManpowerMonitoringRepo() {
49944
50206
  const siteUrl = process.env.HRMLABS_SITE_URL;
49945
50207
  try {
49946
50208
  const serviceProvider = await serviceProviderCollection.findOne({
49947
- _id: new ObjectId118(serviceProviderId)
50209
+ _id: new ObjectId119(serviceProviderId)
49948
50210
  });
49949
50211
  if (!serviceProvider) {
49950
50212
  throw new Error("Service Provider not found.");
@@ -49997,7 +50259,7 @@ import {
49997
50259
 
49998
50260
  // src/models/manpower-remarks.model.ts
49999
50261
  import Joi114 from "joi";
50000
- import { ObjectId as ObjectId119 } from "mongodb";
50262
+ import { ObjectId as ObjectId120 } from "mongodb";
50001
50263
  var remarksSchema = Joi114.object({
50002
50264
  name: Joi114.string().required(),
50003
50265
  remark: Joi114.object({
@@ -50021,7 +50283,7 @@ var manpowerRemarksSchema = Joi114.object({
50021
50283
  });
50022
50284
  var MManpowerRemarks = class {
50023
50285
  constructor(data) {
50024
- this._id = new ObjectId119();
50286
+ this._id = new ObjectId120();
50025
50287
  this.serviceProviderId = data.serviceProviderId || "";
50026
50288
  this.siteId = data.siteId || "";
50027
50289
  this.siteName = data.siteName || "";
@@ -50039,7 +50301,7 @@ var MManpowerRemarks = class {
50039
50301
  };
50040
50302
 
50041
50303
  // src/repositories/manpower-remarks.repo.ts
50042
- import { ObjectId as ObjectId120 } from "mongodb";
50304
+ import { ObjectId as ObjectId121 } from "mongodb";
50043
50305
  import moment2 from "moment-timezone";
50044
50306
  function useManpowerRemarksRepo() {
50045
50307
  const db = useAtlas102.getDb();
@@ -50073,9 +50335,9 @@ function useManpowerRemarksRepo() {
50073
50335
  try {
50074
50336
  value = new MManpowerRemarks(value);
50075
50337
  if (value.siteId)
50076
- value.siteId = new ObjectId120(value.siteId);
50338
+ value.siteId = new ObjectId121(value.siteId);
50077
50339
  if (value.serviceProviderId)
50078
- value.serviceProviderId = new ObjectId120(value.serviceProviderId);
50340
+ value.serviceProviderId = new ObjectId121(value.serviceProviderId);
50079
50341
  const result = await collection.insertOne(value, { session });
50080
50342
  return result;
50081
50343
  } catch (error) {
@@ -50095,7 +50357,7 @@ function useManpowerRemarksRepo() {
50095
50357
  limit = limit || 10;
50096
50358
  const searchQuery = {};
50097
50359
  const nowSGT = moment2().tz("Asia/Singapore");
50098
- searchQuery.serviceProviderId = new ObjectId120(serviceProviderId);
50360
+ searchQuery.serviceProviderId = new ObjectId121(serviceProviderId);
50099
50361
  if (search != "") {
50100
50362
  searchQuery.siteName = { $regex: search, $options: "i" };
50101
50363
  }
@@ -50127,8 +50389,8 @@ function useManpowerRemarksRepo() {
50127
50389
  }
50128
50390
  async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
50129
50391
  try {
50130
- _id = new ObjectId120(_id);
50131
- serviceProviderId = new ObjectId120(serviceProviderId);
50392
+ _id = new ObjectId121(_id);
50393
+ serviceProviderId = new ObjectId121(serviceProviderId);
50132
50394
  } catch (error) {
50133
50395
  throw new Error("Invalid Site ID format.");
50134
50396
  }
@@ -50145,13 +50407,13 @@ function useManpowerRemarksRepo() {
50145
50407
  }
50146
50408
  async function updateManpowerRemarks(_id, value) {
50147
50409
  try {
50148
- _id = new ObjectId120(_id);
50410
+ _id = new ObjectId121(_id);
50149
50411
  } catch (error) {
50150
50412
  throw new BadRequestError185("Invalid ID format.");
50151
50413
  }
50152
50414
  try {
50153
50415
  if (value.createdBy) {
50154
- value.createdBy = new ObjectId120(value.createdBy);
50416
+ value.createdBy = new ObjectId121(value.createdBy);
50155
50417
  }
50156
50418
  const updateValue = {
50157
50419
  ...value,
@@ -50168,7 +50430,7 @@ function useManpowerRemarksRepo() {
50168
50430
  }
50169
50431
  async function updateRemarksStatus(_id, value) {
50170
50432
  try {
50171
- _id = new ObjectId120(_id);
50433
+ _id = new ObjectId121(_id);
50172
50434
  } catch (error) {
50173
50435
  throw new BadRequestError185("Invalid ID format.");
50174
50436
  }
@@ -50438,7 +50700,7 @@ function useManpowerMonitoringCtrl() {
50438
50700
 
50439
50701
  // src/models/manpower-designations.model.ts
50440
50702
  import Joi116 from "joi";
50441
- import { ObjectId as ObjectId121 } from "mongodb";
50703
+ import { ObjectId as ObjectId122 } from "mongodb";
50442
50704
  var designationsSchema = Joi116.object({
50443
50705
  title: Joi116.string().required(),
50444
50706
  shifts: Joi116.object({
@@ -50457,7 +50719,7 @@ var manpowerDesignationsSchema = Joi116.object({
50457
50719
  });
50458
50720
  var MManpowerDesignations = class {
50459
50721
  constructor(data) {
50460
- this._id = new ObjectId121();
50722
+ this._id = new ObjectId122();
50461
50723
  this.siteId = data.siteId || "";
50462
50724
  this.siteName = data.siteName || "";
50463
50725
  this.serviceProviderId = data.serviceProviderId || "";
@@ -50475,7 +50737,7 @@ import {
50475
50737
  logger as logger164,
50476
50738
  useAtlas as useAtlas104
50477
50739
  } from "@7365admin1/node-server-utils";
50478
- import { ObjectId as ObjectId122 } from "mongodb";
50740
+ import { ObjectId as ObjectId123 } from "mongodb";
50479
50741
  function useManpowerDesignationRepo() {
50480
50742
  const db = useAtlas104.getDb();
50481
50743
  if (!db) {
@@ -50507,11 +50769,11 @@ function useManpowerDesignationRepo() {
50507
50769
  try {
50508
50770
  value = new MManpowerDesignations(value);
50509
50771
  if (value.createdBy)
50510
- value.createdBy = new ObjectId122(value.createdBy);
50772
+ value.createdBy = new ObjectId123(value.createdBy);
50511
50773
  if (value.siteId)
50512
- value.siteId = new ObjectId122(value.siteId);
50774
+ value.siteId = new ObjectId123(value.siteId);
50513
50775
  if (value.serviceProviderId)
50514
- value.serviceProviderId = new ObjectId122(value.serviceProviderId);
50776
+ value.serviceProviderId = new ObjectId123(value.serviceProviderId);
50515
50777
  const result = await collection.insertOne(value);
50516
50778
  return result;
50517
50779
  } catch (error) {
@@ -50520,8 +50782,8 @@ function useManpowerDesignationRepo() {
50520
50782
  }
50521
50783
  async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
50522
50784
  try {
50523
- _id = new ObjectId122(_id);
50524
- serviceProviderId = new ObjectId122(serviceProviderId);
50785
+ _id = new ObjectId123(_id);
50786
+ serviceProviderId = new ObjectId123(serviceProviderId);
50525
50787
  } catch (error) {
50526
50788
  throw new Error("Invalid Site ID format.");
50527
50789
  }
@@ -50537,7 +50799,7 @@ function useManpowerDesignationRepo() {
50537
50799
  }
50538
50800
  async function updateManpowerDesignations(_id, value) {
50539
50801
  try {
50540
- _id = new ObjectId122(_id);
50802
+ _id = new ObjectId123(_id);
50541
50803
  } catch (error) {
50542
50804
  throw new Error("Invalid ID format.");
50543
50805
  }
@@ -50641,7 +50903,7 @@ function useManpowerDesignationCtrl() {
50641
50903
 
50642
50904
  // src/models/overnight-parking.model.ts
50643
50905
  import Joi118 from "joi";
50644
- import { ObjectId as ObjectId123 } from "mongodb";
50906
+ import { ObjectId as ObjectId124 } from "mongodb";
50645
50907
  var dayScheduleSchema = Joi118.object({
50646
50908
  isEnabled: Joi118.boolean().required(),
50647
50909
  startTime: Joi118.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
@@ -50683,7 +50945,7 @@ function MOvernightParkingApprovalHours(value) {
50683
50945
  }
50684
50946
  if (value.site && typeof value.site === "string") {
50685
50947
  try {
50686
- value.site = new ObjectId123(value.site);
50948
+ value.site = new ObjectId124(value.site);
50687
50949
  } catch {
50688
50950
  throw new Error("Invalid site ID.");
50689
50951
  }
@@ -52307,7 +52569,7 @@ function useManpowerRemarkCtrl() {
52307
52569
 
52308
52570
  // src/models/manpower-sites.model.ts
52309
52571
  import Joi124 from "joi";
52310
- import { ObjectId as ObjectId124 } from "mongodb";
52572
+ import { ObjectId as ObjectId125 } from "mongodb";
52311
52573
  var manpowerSitesSchema = Joi124.object({
52312
52574
  id: Joi124.string().hex().required(),
52313
52575
  text: Joi124.string().hex().optional().allow("", null),
@@ -52318,7 +52580,7 @@ var manpowerSitesSchema = Joi124.object({
52318
52580
  });
52319
52581
  var MManpowerSites = class {
52320
52582
  constructor(data) {
52321
- this._id = new ObjectId124();
52583
+ this._id = new ObjectId125();
52322
52584
  this.id = data.id || "";
52323
52585
  this.text = data.text || "";
52324
52586
  this.contractID = data.contractID || "";
@@ -52540,7 +52802,7 @@ import {
52540
52802
  getDirectory as getDirectory4,
52541
52803
  logger as logger177
52542
52804
  } from "@7365admin1/node-server-utils";
52543
- import { ObjectId as ObjectId125 } from "mongodb";
52805
+ import { ObjectId as ObjectId126 } from "mongodb";
52544
52806
  import moment4 from "moment-timezone";
52545
52807
  var createManpowerRemarksDaily = async () => {
52546
52808
  const db = useAtlas110.getDb();
@@ -52700,7 +52962,7 @@ var updateRemarksisAcknowledged = async () => {
52700
52962
  for (const id of updatedIds) {
52701
52963
  const doc = await remarks.findOne({ _id: id });
52702
52964
  const setting = await settings.findOne(
52703
- { siteId: new ObjectId125(doc?.siteId) },
52965
+ { siteId: new ObjectId126(doc?.siteId) },
52704
52966
  { projection: { emails: 1 } }
52705
52967
  );
52706
52968
  const payload = {
@@ -52786,7 +53048,7 @@ var updateRemarksStatusEod = async () => {
52786
53048
  for (const doc of docs) {
52787
53049
  let shiftsToCheck = [];
52788
53050
  const endShiftTime = await settings.findOne(
52789
- { siteId: new ObjectId125(doc.siteId) },
53051
+ { siteId: new ObjectId126(doc.siteId) },
52790
53052
  { projection: { shifts: 1, shiftType: 1 } }
52791
53053
  );
52792
53054
  if (doc.createdAtSGT === nowSGT) {
@@ -52892,7 +53154,7 @@ var isWithinHour = (alertTime, timeNow) => {
52892
53154
 
52893
53155
  // src/events/manpower.event.ts
52894
53156
  import { useAtlas as useAtlas111 } from "@7365admin1/node-server-utils";
52895
- import { ObjectId as ObjectId126 } from "mongodb";
53157
+ import { ObjectId as ObjectId127 } from "mongodb";
52896
53158
  import moment5 from "moment-timezone";
52897
53159
  async function manpowerEvents(io) {
52898
53160
  let intervalId = null;
@@ -52918,7 +53180,7 @@ async function manpowerEvents(io) {
52918
53180
  }).toArray();
52919
53181
  for (const doc of docs) {
52920
53182
  const siteSettings = await settings.findOne(
52921
- { siteId: new ObjectId126(doc.siteId), enabled: true },
53183
+ { siteId: new ObjectId127(doc.siteId), enabled: true },
52922
53184
  { projection: { shifts: 1, shiftType: 1 } }
52923
53185
  );
52924
53186
  const shiftType = siteSettings?.shiftType || "2-shifts";
@@ -53037,11 +53299,11 @@ function genericSignature(params, secretKey) {
53037
53299
  }
53038
53300
 
53039
53301
  // src/repositories/reddot-payment.repository.ts
53040
- import { ObjectId as ObjectId128 } from "mongodb";
53302
+ import { ObjectId as ObjectId129 } from "mongodb";
53041
53303
 
53042
53304
  // src/models/billing-payments.model.ts
53043
53305
  import { BadRequestError as BadRequestError199, logger as logger178 } from "@7365admin1/node-server-utils";
53044
- import { ObjectId as ObjectId127 } from "mongodb";
53306
+ import { ObjectId as ObjectId128 } from "mongodb";
53045
53307
  import Joi126 from "joi";
53046
53308
  var schemaBillingItems = Joi126.object({
53047
53309
  _id: Joi126.string().hex().optional(),
@@ -53075,21 +53337,21 @@ function MBillingItems(value) {
53075
53337
  }
53076
53338
  if (value._id && typeof value._id === "string") {
53077
53339
  try {
53078
- value._id = new ObjectId127(value._id);
53340
+ value._id = new ObjectId128(value._id);
53079
53341
  } catch {
53080
53342
  throw new BadRequestError199("Invalid _id format");
53081
53343
  }
53082
53344
  }
53083
53345
  if (value.unitId && typeof value.unitId === "string") {
53084
53346
  try {
53085
- value.unitId = new ObjectId127(value.unitId);
53347
+ value.unitId = new ObjectId128(value.unitId);
53086
53348
  } catch {
53087
53349
  throw new BadRequestError199("Invalid unitId id format");
53088
53350
  }
53089
53351
  }
53090
53352
  if (value.paidBy && typeof value.paidBy === "string") {
53091
53353
  try {
53092
- value.paidBy = new ObjectId127(value.paidBy);
53354
+ value.paidBy = new ObjectId128(value.paidBy);
53093
53355
  } catch {
53094
53356
  throw new BadRequestError199("Invalid paidBy id format");
53095
53357
  }
@@ -53099,7 +53361,7 @@ function MBillingItems(value) {
53099
53361
  value.unitBillingItems = value.unitBillingItems.map((unitBillingItem) => {
53100
53362
  if (typeof unitBillingItem._id === "string") {
53101
53363
  try {
53102
- unitBillingItem._id = new ObjectId127(unitBillingItem._id);
53364
+ unitBillingItem._id = new ObjectId128(unitBillingItem._id);
53103
53365
  } catch {
53104
53366
  throw new BadRequestError199("Invalid unit billing id format");
53105
53367
  }
@@ -53111,7 +53373,7 @@ function MBillingItems(value) {
53111
53373
  }
53112
53374
  }
53113
53375
  return {
53114
- _id: value._id ?? new ObjectId127(),
53376
+ _id: value._id ?? new ObjectId128(),
53115
53377
  unitBillingItems: value.unitBillingItems ?? [],
53116
53378
  unitId: value.unitId ?? "",
53117
53379
  unitOwner: value.unitOwner ?? "",
@@ -53185,7 +53447,7 @@ var useRedDotPaymentRepo = () => {
53185
53447
  const res = await paymentCollection().insertOne(payload, { session });
53186
53448
  const unit = payload.unitId?.toString().slice(-4);
53187
53449
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
53188
- const newId = new ObjectId128(res.insertedId).toString().slice(-6);
53450
+ const newId = new ObjectId129(res.insertedId).toString().slice(-6);
53189
53451
  const referenceNumber = `${unit}${newId}${dateFormatted}`;
53190
53452
  await paymentCollection().updateOne(
53191
53453
  { _id: res.insertedId },
@@ -54301,7 +54563,7 @@ import {
54301
54563
  import { v4 as uuidv42 } from "uuid";
54302
54564
 
54303
54565
  // src/repositories/user-v2.repo.ts
54304
- import { ObjectId as ObjectId129 } from "mongodb";
54566
+ import { ObjectId as ObjectId130 } from "mongodb";
54305
54567
  import {
54306
54568
  useAtlas as useAtlas115,
54307
54569
  InternalServerError as InternalServerError71,
@@ -54513,7 +54775,7 @@ function useUserRepoV2() {
54513
54775
  }
54514
54776
  if (organization) {
54515
54777
  try {
54516
- query.defaultOrg = new ObjectId129(organization);
54778
+ query.defaultOrg = new ObjectId130(organization);
54517
54779
  cacheOptions.organization = organization.toString();
54518
54780
  } catch (error) {
54519
54781
  throw new BadRequestError204("Invalid organization ID format.");
@@ -54652,13 +54914,13 @@ function useUserRepoV2() {
54652
54914
  );
54653
54915
  }
54654
54916
  try {
54655
- _id = new ObjectId129(_id);
54917
+ _id = new ObjectId130(_id);
54656
54918
  } catch (error) {
54657
54919
  throw new BadRequestError204("Invalid ID.");
54658
54920
  }
54659
54921
  if (field === "defaultOrg") {
54660
54922
  try {
54661
- value = new ObjectId129(value);
54923
+ value = new ObjectId130(value);
54662
54924
  } catch (error) {
54663
54925
  throw new BadRequestError204("Invalid organization ID.");
54664
54926
  }
@@ -54699,7 +54961,7 @@ function useUserRepoV2() {
54699
54961
  year
54700
54962
  }, session) {
54701
54963
  try {
54702
- _id = new ObjectId129(_id);
54964
+ _id = new ObjectId130(_id);
54703
54965
  } catch (error) {
54704
54966
  throw new BadRequestError204("Invalid user ID format.");
54705
54967
  }
@@ -54729,7 +54991,7 @@ function useUserRepoV2() {
54729
54991
  }
54730
54992
  async function updatePassword({ _id, password }, session) {
54731
54993
  try {
54732
- _id = new ObjectId129(_id);
54994
+ _id = new ObjectId130(_id);
54733
54995
  } catch (error) {
54734
54996
  throw new BadRequestError204("Invalid user ID format.");
54735
54997
  }
@@ -55492,38 +55754,38 @@ function useUserControllerV2() {
55492
55754
 
55493
55755
  // src/models/role-v2.model.ts
55494
55756
  import { BadRequestError as BadRequestError209 } from "@7365admin1/node-server-utils";
55495
- import { ObjectId as ObjectId130 } from "mongodb";
55757
+ import { ObjectId as ObjectId131 } from "mongodb";
55496
55758
  var MRoleV2 = class {
55497
55759
  constructor(value) {
55498
55760
  if (typeof value._id === "string") {
55499
55761
  try {
55500
- value._id = new ObjectId130(value._id);
55762
+ value._id = new ObjectId131(value._id);
55501
55763
  } catch (error) {
55502
55764
  throw new BadRequestError209("Invalid role-v2 ID format.");
55503
55765
  }
55504
55766
  }
55505
55767
  if (typeof value.site === "string" && value.site.length === 24) {
55506
55768
  try {
55507
- value.site = new ObjectId130(value.site);
55769
+ value.site = new ObjectId131(value.site);
55508
55770
  } catch (error) {
55509
55771
  throw new BadRequestError209("Invalid site ID format.");
55510
55772
  }
55511
55773
  }
55512
55774
  if (typeof value.org === "string" && value.org.length === 24) {
55513
55775
  try {
55514
- value.org = new ObjectId130(value.org);
55776
+ value.org = new ObjectId131(value.org);
55515
55777
  } catch (error) {
55516
55778
  throw new BadRequestError209("Invalid org ID format.");
55517
55779
  }
55518
55780
  }
55519
55781
  if (value.createdBy) {
55520
55782
  try {
55521
- value.createdBy = new ObjectId130(value.createdBy);
55783
+ value.createdBy = new ObjectId131(value.createdBy);
55522
55784
  } catch (error) {
55523
55785
  throw new BadRequestError209("Invalid created by ID format.");
55524
55786
  }
55525
55787
  }
55526
- this._id = value._id ?? new ObjectId130();
55788
+ this._id = value._id ?? new ObjectId131();
55527
55789
  this.name = value.name ?? "";
55528
55790
  this.permissions = value.permissions ?? [];
55529
55791
  this.site = value.site ?? "";
@@ -55664,7 +55926,7 @@ function useRoleControllerV2() {
55664
55926
 
55665
55927
  // src/models/post-preloved.model.ts
55666
55928
  import Joi133 from "joi";
55667
- import { ObjectId as ObjectId131 } from "mongodb";
55929
+ import { ObjectId as ObjectId132 } from "mongodb";
55668
55930
  var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
55669
55931
  PostStatus2["PUBLISHED"] = "published";
55670
55932
  PostStatus2["RESERVED"] = "reserved";
@@ -55720,28 +55982,28 @@ function MPost(value) {
55720
55982
  }
55721
55983
  if (value._id && typeof value._id === "string") {
55722
55984
  try {
55723
- value._id = new ObjectId131(value._id);
55985
+ value._id = new ObjectId132(value._id);
55724
55986
  } catch {
55725
55987
  throw new Error("Invalid ID.");
55726
55988
  }
55727
55989
  }
55728
55990
  if (value.site && typeof value.site === "string") {
55729
55991
  try {
55730
- value.site = new ObjectId131(value.site);
55992
+ value.site = new ObjectId132(value.site);
55731
55993
  } catch {
55732
55994
  throw new Error("Invalid site ID.");
55733
55995
  }
55734
55996
  }
55735
55997
  if (value.createdBy && typeof value.createdBy === "string") {
55736
55998
  try {
55737
- value.createdBy = new ObjectId131(value.createdBy);
55999
+ value.createdBy = new ObjectId132(value.createdBy);
55738
56000
  } catch {
55739
56001
  throw new Error("Invalid createdBy ID.");
55740
56002
  }
55741
56003
  }
55742
56004
  if (value.reserverId && typeof value.reserverId === "string") {
55743
56005
  try {
55744
- value.reserverId = new ObjectId131(value.reserverId);
56006
+ value.reserverId = new ObjectId132(value.reserverId);
55745
56007
  } catch {
55746
56008
  throw new Error("Invalid reserver ID.");
55747
56009
  }
@@ -55750,7 +56012,7 @@ function MPost(value) {
55750
56012
  value.attachments = value.attachments.map((id) => {
55751
56013
  if (typeof id === "string") {
55752
56014
  try {
55753
- return new ObjectId131(id);
56015
+ return new ObjectId132(id);
55754
56016
  } catch {
55755
56017
  throw new Error("Invalid attachment ID.");
55756
56018
  }
@@ -55760,20 +56022,20 @@ function MPost(value) {
55760
56022
  }
55761
56023
  if (value.category && typeof value.category === "string") {
55762
56024
  try {
55763
- value.category = new ObjectId131(value.category);
56025
+ value.category = new ObjectId132(value.category);
55764
56026
  } catch {
55765
56027
  throw new Error("Invalid category ID.");
55766
56028
  }
55767
56029
  }
55768
56030
  if (value.subcategory && typeof value.subcategory === "string") {
55769
56031
  try {
55770
- value.subcategory = new ObjectId131(value.subcategory);
56032
+ value.subcategory = new ObjectId132(value.subcategory);
55771
56033
  } catch {
55772
56034
  throw new Error("Invalid subcategory ID.");
55773
56035
  }
55774
56036
  }
55775
56037
  return {
55776
- _id: value._id ?? new ObjectId131(),
56038
+ _id: value._id ?? new ObjectId132(),
55777
56039
  title: value.title ?? "",
55778
56040
  description: value.description ?? "",
55779
56041
  attachments: value.attachments ?? [],
@@ -55799,7 +56061,7 @@ import {
55799
56061
  paginate as paginate60,
55800
56062
  useAtlas as useAtlas118
55801
56063
  } from "@7365admin1/node-server-utils";
55802
- import { ObjectId as ObjectId132 } from "mongodb";
56064
+ import { ObjectId as ObjectId133 } from "mongodb";
55803
56065
  function usePostPrelovedRepo() {
55804
56066
  const db = useAtlas118.getDb();
55805
56067
  if (!db) {
@@ -55863,7 +56125,7 @@ function usePostPrelovedRepo() {
55863
56125
  }
55864
56126
  async function getById(_id) {
55865
56127
  try {
55866
- _id = new ObjectId132(_id);
56128
+ _id = new ObjectId133(_id);
55867
56129
  } catch {
55868
56130
  throw new BadRequestError212("Invalid post ID format.");
55869
56131
  }
@@ -55896,7 +56158,7 @@ function usePostPrelovedRepo() {
55896
56158
  page = page > 0 ? page - 1 : 0;
55897
56159
  if (site) {
55898
56160
  try {
55899
- site = new ObjectId132(site);
56161
+ site = new ObjectId133(site);
55900
56162
  } catch {
55901
56163
  throw new BadRequestError212("Invalid site ID format.");
55902
56164
  }
@@ -55905,14 +56167,14 @@ function usePostPrelovedRepo() {
55905
56167
  let subcategoryIds = null;
55906
56168
  if (category && subcategory) {
55907
56169
  try {
55908
- categoryId = new ObjectId132(category);
56170
+ categoryId = new ObjectId133(category);
55909
56171
  } catch {
55910
56172
  throw new BadRequestError212("Invalid category ID format.");
55911
56173
  }
55912
56174
  if (subcategory.length > 0) {
55913
56175
  subcategoryIds = subcategory.map((id) => {
55914
56176
  try {
55915
- return new ObjectId132(id);
56177
+ return new ObjectId133(id);
55916
56178
  } catch {
55917
56179
  throw new BadRequestError212("Invalid subcategory ID format.");
55918
56180
  }
@@ -55937,7 +56199,7 @@ function usePostPrelovedRepo() {
55937
56199
  let userObjectId = null;
55938
56200
  if (userId) {
55939
56201
  try {
55940
- userObjectId = new ObjectId132(userId);
56202
+ userObjectId = new ObjectId133(userId);
55941
56203
  } catch {
55942
56204
  throw new BadRequestError212("Invalid user ID format.");
55943
56205
  }
@@ -55986,7 +56248,7 @@ function usePostPrelovedRepo() {
55986
56248
  }
55987
56249
  async function updateById(_id, value, session) {
55988
56250
  try {
55989
- _id = new ObjectId132(_id);
56251
+ _id = new ObjectId133(_id);
55990
56252
  } catch {
55991
56253
  throw new BadRequestError212("Invalid post ID format.");
55992
56254
  }
@@ -56007,7 +56269,7 @@ function usePostPrelovedRepo() {
56007
56269
  }
56008
56270
  async function deleteById(_id, session) {
56009
56271
  try {
56010
- _id = new ObjectId132(_id);
56272
+ _id = new ObjectId133(_id);
56011
56273
  } catch {
56012
56274
  throw new BadRequestError212("Invalid post ID format.");
56013
56275
  }
@@ -56033,7 +56295,7 @@ function usePostPrelovedRepo() {
56033
56295
  }
56034
56296
  async function updateStatus(_id, status, session) {
56035
56297
  try {
56036
- _id = new ObjectId132(_id);
56298
+ _id = new ObjectId133(_id);
56037
56299
  } catch {
56038
56300
  throw new BadRequestError212("Invalid post ID format.");
56039
56301
  }
@@ -56124,7 +56386,7 @@ function usePostPrelovedController() {
56124
56386
  Joi134.string().valid(...Object.values(PostStatus))
56125
56387
  ).optional().allow(null),
56126
56388
  category: Joi134.string().hex().length(24).optional().allow("", null),
56127
- subcategory: Joi134.alternatives().try(Joi134.array().items(Joi134.string())).optional().allow(null, ""),
56389
+ subcategory: Joi134.array().items(Joi134.string()).single().optional().allow(null),
56128
56390
  userId: Joi134.string().optional().allow("", null)
56129
56391
  });
56130
56392
  const { error, value } = validation.validate(req.query, {
@@ -56245,7 +56507,7 @@ function usePostPrelovedController() {
56245
56507
 
56246
56508
  // src/models/post-favorite.model.ts
56247
56509
  import Joi135 from "joi";
56248
- import { ObjectId as ObjectId133 } from "mongodb";
56510
+ import { ObjectId as ObjectId134 } from "mongodb";
56249
56511
  var schemaUpdatePostFavorite = Joi135.object({
56250
56512
  userId: Joi135.string().hex().length(24).required()
56251
56513
  });
@@ -56263,14 +56525,14 @@ function MPostFavorite(value) {
56263
56525
  }
56264
56526
  if (value._id && typeof value._id === "string") {
56265
56527
  try {
56266
- value._id = new ObjectId133(value._id);
56528
+ value._id = new ObjectId134(value._id);
56267
56529
  } catch {
56268
56530
  throw new Error("Invalid ID.");
56269
56531
  }
56270
56532
  }
56271
56533
  if (value.postId && typeof value.postId === "string") {
56272
56534
  try {
56273
- value.postId = new ObjectId133(value.postId);
56535
+ value.postId = new ObjectId134(value.postId);
56274
56536
  } catch {
56275
56537
  throw new Error("Invalid post ID.");
56276
56538
  }
@@ -56279,7 +56541,7 @@ function MPostFavorite(value) {
56279
56541
  value.userIds = value.userIds.map((id) => {
56280
56542
  if (typeof id === "string") {
56281
56543
  try {
56282
- return new ObjectId133(id);
56544
+ return new ObjectId134(id);
56283
56545
  } catch {
56284
56546
  throw new Error("Invalid user ID.");
56285
56547
  }
@@ -56288,7 +56550,7 @@ function MPostFavorite(value) {
56288
56550
  });
56289
56551
  }
56290
56552
  return {
56291
- _id: value._id ?? new ObjectId133(),
56553
+ _id: value._id ?? new ObjectId134(),
56292
56554
  postId: value.postId ?? "",
56293
56555
  userIds: value.userIds ?? [],
56294
56556
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
@@ -56303,7 +56565,7 @@ import {
56303
56565
  NotFoundError as NotFoundError58,
56304
56566
  useAtlas as useAtlas119
56305
56567
  } from "@7365admin1/node-server-utils";
56306
- import { ObjectId as ObjectId134 } from "mongodb";
56568
+ import { ObjectId as ObjectId135 } from "mongodb";
56307
56569
  function usePostFavoriteRepo() {
56308
56570
  const db = useAtlas119.getDb();
56309
56571
  if (!db) {
@@ -56325,7 +56587,7 @@ function usePostFavoriteRepo() {
56325
56587
  }
56326
56588
  async function getById(_id) {
56327
56589
  try {
56328
- _id = new ObjectId134(_id);
56590
+ _id = new ObjectId135(_id);
56329
56591
  } catch {
56330
56592
  throw new BadRequestError214("Invalid favorite ID format.");
56331
56593
  }
@@ -56334,15 +56596,26 @@ function usePostFavoriteRepo() {
56334
56596
  throw new NotFoundError58("Favorite not found.");
56335
56597
  return result;
56336
56598
  }
56599
+ async function getByPostId(postId) {
56600
+ try {
56601
+ postId = new ObjectId135(postId);
56602
+ } catch {
56603
+ throw new BadRequestError214("Invalid post ID format.");
56604
+ }
56605
+ const result = await collection.findOne({ postId });
56606
+ if (!result)
56607
+ throw new NotFoundError58("Favorite not found.");
56608
+ return result;
56609
+ }
56337
56610
  async function updateById(_id, userId, session) {
56338
56611
  try {
56339
- _id = new ObjectId134(_id);
56612
+ _id = new ObjectId135(_id);
56340
56613
  } catch {
56341
56614
  throw new BadRequestError214("Invalid favorite ID format.");
56342
56615
  }
56343
56616
  let userObjectId;
56344
56617
  try {
56345
- userObjectId = new ObjectId134(userId);
56618
+ userObjectId = new ObjectId135(userId);
56346
56619
  } catch {
56347
56620
  throw new BadRequestError214("Invalid user ID format.");
56348
56621
  }
@@ -56359,6 +56632,7 @@ function usePostFavoriteRepo() {
56359
56632
  return {
56360
56633
  addFavorite,
56361
56634
  getById,
56635
+ getByPostId,
56362
56636
  updateById
56363
56637
  };
56364
56638
  }
@@ -56406,7 +56680,7 @@ import { BadRequestError as BadRequestError215, logger as logger189 } from "@736
56406
56680
  import Joi136 from "joi";
56407
56681
  function usePostFavoriteController() {
56408
56682
  const { addFavorite: _addFavorite, toggleFavorite: _toggleFavorite } = usePostFavoriteService();
56409
- const { getById: _getById } = usePostFavoriteRepo();
56683
+ const { getById: _getById, getByPostId: _getByPostId } = usePostFavoriteRepo();
56410
56684
  async function addFavorite(req, res, next) {
56411
56685
  const { error, value } = schemaPostFavorite.validate(req.body, {
56412
56686
  abortEarly: false
@@ -56447,6 +56721,26 @@ function usePostFavoriteController() {
56447
56721
  return;
56448
56722
  }
56449
56723
  }
56724
+ async function getByPostId(req, res, next) {
56725
+ const schema2 = Joi136.object({
56726
+ postId: Joi136.string().hex().length(24).required()
56727
+ });
56728
+ const { error, value } = schema2.validate({ postId: req.params.postId });
56729
+ if (error) {
56730
+ logger189.log({ level: "error", message: error.message });
56731
+ next(new BadRequestError215(error.message));
56732
+ return;
56733
+ }
56734
+ try {
56735
+ const data = await _getByPostId(value.postId);
56736
+ res.status(200).json(data);
56737
+ return;
56738
+ } catch (error2) {
56739
+ logger189.log({ level: "error", message: error2.message });
56740
+ next(error2);
56741
+ return;
56742
+ }
56743
+ }
56450
56744
  async function updateById(req, res, next) {
56451
56745
  const paramsSchema = Joi136.object({
56452
56746
  _id: Joi136.string().hex().length(24).required()
@@ -56476,13 +56770,14 @@ function usePostFavoriteController() {
56476
56770
  return {
56477
56771
  addFavorite,
56478
56772
  getById,
56773
+ getByPostId,
56479
56774
  updateById
56480
56775
  };
56481
56776
  }
56482
56777
 
56483
56778
  // src/models/category-preloved.model.ts
56484
56779
  import Joi137 from "joi";
56485
- import { ObjectId as ObjectId135 } from "mongodb";
56780
+ import { ObjectId as ObjectId136 } from "mongodb";
56486
56781
  var schemaCategoryPreloved = Joi137.object({
56487
56782
  name: Joi137.string().required(),
56488
56783
  createdBy: Joi137.string().hex().optional().allow("", null),
@@ -56499,14 +56794,14 @@ function MCategoryPreloved(value) {
56499
56794
  }
56500
56795
  if (value.createdBy && typeof value.createdBy === "string") {
56501
56796
  try {
56502
- value.createdBy = new ObjectId135(value.createdBy);
56797
+ value.createdBy = new ObjectId136(value.createdBy);
56503
56798
  } catch {
56504
56799
  throw new Error("Invalid createdBy ID.");
56505
56800
  }
56506
56801
  }
56507
56802
  if (value.site && typeof value.site === "string") {
56508
56803
  try {
56509
- value.site = new ObjectId135(value.site);
56804
+ value.site = new ObjectId136(value.site);
56510
56805
  } catch {
56511
56806
  throw new Error("Invalid site ID.");
56512
56807
  }
@@ -56527,7 +56822,7 @@ import {
56527
56822
  NotFoundError as NotFoundError59,
56528
56823
  useAtlas as useAtlas121
56529
56824
  } from "@7365admin1/node-server-utils";
56530
- import { ObjectId as ObjectId136 } from "mongodb";
56825
+ import { ObjectId as ObjectId137 } from "mongodb";
56531
56826
  function useCategoryPrelovedRepo() {
56532
56827
  const db = useAtlas121.getDb();
56533
56828
  if (!db) {
@@ -56541,7 +56836,7 @@ function useCategoryPrelovedRepo() {
56541
56836
  } = {}) {
56542
56837
  if (site) {
56543
56838
  try {
56544
- site = new ObjectId136(site);
56839
+ site = new ObjectId137(site);
56545
56840
  } catch {
56546
56841
  throw new BadRequestError216("Invalid site ID format.");
56547
56842
  }
@@ -56560,7 +56855,7 @@ function useCategoryPrelovedRepo() {
56560
56855
  async function getById(_id) {
56561
56856
  let objectId2;
56562
56857
  try {
56563
- objectId2 = new ObjectId136(_id);
56858
+ objectId2 = new ObjectId137(_id);
56564
56859
  } catch {
56565
56860
  throw new BadRequestError216("Invalid category-preloved ID format.");
56566
56861
  }
@@ -56660,7 +56955,7 @@ function useCategoryPrelovedController() {
56660
56955
 
56661
56956
  // src/models/subcategory-preloved.model.ts
56662
56957
  import Joi139 from "joi";
56663
- import { ObjectId as ObjectId137 } from "mongodb";
56958
+ import { ObjectId as ObjectId138 } from "mongodb";
56664
56959
  var schemaSubcategoryPreloved = Joi139.object({
56665
56960
  name: Joi139.string().required(),
56666
56961
  createdBy: Joi139.string().hex().optional().allow("", null),
@@ -56679,21 +56974,21 @@ function MSubcategoryPreloved(value) {
56679
56974
  }
56680
56975
  if (value.createdBy && typeof value.createdBy === "string") {
56681
56976
  try {
56682
- value.createdBy = new ObjectId137(value.createdBy);
56977
+ value.createdBy = new ObjectId138(value.createdBy);
56683
56978
  } catch {
56684
56979
  throw new Error("Invalid createdBy ID.");
56685
56980
  }
56686
56981
  }
56687
56982
  if (value.site && typeof value.site === "string") {
56688
56983
  try {
56689
- value.site = new ObjectId137(value.site);
56984
+ value.site = new ObjectId138(value.site);
56690
56985
  } catch {
56691
56986
  throw new Error("Invalid site ID.");
56692
56987
  }
56693
56988
  }
56694
56989
  if (value.category_id && typeof value.category_id === "string") {
56695
56990
  try {
56696
- value.category_id = new ObjectId137(value.category_id);
56991
+ value.category_id = new ObjectId138(value.category_id);
56697
56992
  } catch {
56698
56993
  throw new Error("Invalid category ID.");
56699
56994
  }
@@ -56715,7 +57010,7 @@ import {
56715
57010
  NotFoundError as NotFoundError60,
56716
57011
  useAtlas as useAtlas122
56717
57012
  } from "@7365admin1/node-server-utils";
56718
- import { ObjectId as ObjectId138 } from "mongodb";
57013
+ import { ObjectId as ObjectId139 } from "mongodb";
56719
57014
  function useSubcategoryPrelovedRepo() {
56720
57015
  const db = useAtlas122.getDb();
56721
57016
  if (!db) {
@@ -56730,14 +57025,14 @@ function useSubcategoryPrelovedRepo() {
56730
57025
  } = {}) {
56731
57026
  if (site) {
56732
57027
  try {
56733
- site = new ObjectId138(site);
57028
+ site = new ObjectId139(site);
56734
57029
  } catch {
56735
57030
  throw new BadRequestError218("Invalid site ID format.");
56736
57031
  }
56737
57032
  }
56738
57033
  if (category_id) {
56739
57034
  try {
56740
- category_id = new ObjectId138(category_id);
57035
+ category_id = new ObjectId139(category_id);
56741
57036
  } catch {
56742
57037
  throw new BadRequestError218("Invalid category ID format.");
56743
57038
  }
@@ -56756,7 +57051,7 @@ function useSubcategoryPrelovedRepo() {
56756
57051
  async function getById(_id) {
56757
57052
  let objectId2;
56758
57053
  try {
56759
- objectId2 = new ObjectId138(_id);
57054
+ objectId2 = new ObjectId139(_id);
56760
57055
  } catch {
56761
57056
  throw new BadRequestError218("Invalid subcategory-preloved ID format.");
56762
57057
  }
@@ -56770,14 +57065,75 @@ function useSubcategoryPrelovedRepo() {
56770
57065
  throw error;
56771
57066
  }
56772
57067
  }
56773
- return { getAll, getById };
57068
+ async function addSubcategory(item, session) {
57069
+ const doc = MSubcategoryPreloved(item);
57070
+ try {
57071
+ const res = await collection.insertOne(doc, { session });
57072
+ return res.insertedId;
57073
+ } catch (error) {
57074
+ const isDuplicated = error.message?.includes("duplicate");
57075
+ if (isDuplicated)
57076
+ throw new BadRequestError218("Subcategory already exists.");
57077
+ throw error;
57078
+ }
57079
+ }
57080
+ async function updateById(_id, value, session) {
57081
+ let objectId2;
57082
+ try {
57083
+ objectId2 = new ObjectId139(_id);
57084
+ } catch {
57085
+ throw new BadRequestError218("Invalid subcategory ID format.");
57086
+ }
57087
+ if (value.category_id && typeof value.category_id === "string") {
57088
+ try {
57089
+ value.category_id = new ObjectId139(value.category_id);
57090
+ } catch {
57091
+ throw new BadRequestError218("Invalid category ID format.");
57092
+ }
57093
+ }
57094
+ if (value.site && typeof value.site === "string") {
57095
+ try {
57096
+ value.site = new ObjectId139(value.site);
57097
+ } catch {
57098
+ throw new BadRequestError218("Invalid site ID format.");
57099
+ }
57100
+ }
57101
+ value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
57102
+ const res = await collection.updateOne(
57103
+ { _id: objectId2 },
57104
+ { $set: value },
57105
+ { session }
57106
+ );
57107
+ if (res.modifiedCount === 0)
57108
+ throw new InternalServerError78("Unable to update subcategory.");
57109
+ return res;
57110
+ }
57111
+ async function deleteById(_id, session) {
57112
+ let objectId2;
57113
+ try {
57114
+ objectId2 = new ObjectId139(_id);
57115
+ } catch {
57116
+ throw new BadRequestError218("Invalid subcategory ID format.");
57117
+ }
57118
+ const res = await collection.deleteOne({ _id: objectId2 }, { session });
57119
+ if (res.deletedCount === 0)
57120
+ throw new InternalServerError78("Unable to delete subcategory.");
57121
+ return res.deletedCount;
57122
+ }
57123
+ return { getAll, getById, addSubcategory, updateById, deleteById };
56774
57124
  }
56775
57125
 
56776
57126
  // src/controllers/subcategory-preloved.controller.ts
56777
57127
  import { BadRequestError as BadRequestError219, logger as logger191 } from "@7365admin1/node-server-utils";
56778
57128
  import Joi140 from "joi";
56779
57129
  function useSubcategoryPrelovedController() {
56780
- const { getAll: _getAll, getById: _getById } = useSubcategoryPrelovedRepo();
57130
+ const {
57131
+ getAll: _getAll,
57132
+ getById: _getById,
57133
+ addSubcategory: _addSubcategory,
57134
+ updateById: _updateById,
57135
+ deleteById: _deleteById
57136
+ } = useSubcategoryPrelovedRepo();
56781
57137
  async function getAll(req, res, next) {
56782
57138
  const schema2 = Joi140.object({
56783
57139
  search: Joi140.string().optional().allow("", null),
@@ -56821,12 +57177,73 @@ function useSubcategoryPrelovedController() {
56821
57177
  return;
56822
57178
  }
56823
57179
  }
56824
- return { getAll, getById };
57180
+ async function addSubcategory(req, res, next) {
57181
+ const { error, value } = schemaSubcategoryPreloved.validate(req.body, {
57182
+ abortEarly: false
57183
+ });
57184
+ if (error) {
57185
+ const messages = error.details.map((d) => d.message).join(", ");
57186
+ logger191.log({ level: "error", message: messages });
57187
+ next(new BadRequestError219(messages));
57188
+ return;
57189
+ }
57190
+ try {
57191
+ const data = await _addSubcategory(value);
57192
+ res.status(201).json(data);
57193
+ } catch (error2) {
57194
+ logger191.log({ level: "error", message: error2.message });
57195
+ next(error2);
57196
+ }
57197
+ }
57198
+ async function updateById(req, res, next) {
57199
+ const paramsSchema = Joi140.object({
57200
+ _id: Joi140.string().hex().length(24).required()
57201
+ });
57202
+ const { error: paramsError, value: paramsValue } = paramsSchema.validate({
57203
+ _id: req.params.id
57204
+ });
57205
+ if (paramsError) {
57206
+ next(new BadRequestError219(paramsError.message));
57207
+ return;
57208
+ }
57209
+ const { error: bodyError, value: bodyValue } = schemaUpdateSubcategoryPreloved.validate(req.body, { abortEarly: false });
57210
+ if (bodyError) {
57211
+ const messages = bodyError.details.map((d) => d.message).join(", ");
57212
+ logger191.log({ level: "error", message: messages });
57213
+ next(new BadRequestError219(messages));
57214
+ return;
57215
+ }
57216
+ try {
57217
+ const data = await _updateById(paramsValue._id, bodyValue);
57218
+ res.status(200).json(data);
57219
+ } catch (error) {
57220
+ logger191.log({ level: "error", message: error.message });
57221
+ next(error);
57222
+ }
57223
+ }
57224
+ async function deleteById(req, res, next) {
57225
+ const schema2 = Joi140.object({
57226
+ _id: Joi140.string().hex().length(24).required()
57227
+ });
57228
+ const { error, value } = schema2.validate({ _id: req.params.id });
57229
+ if (error) {
57230
+ next(new BadRequestError219(error.message));
57231
+ return;
57232
+ }
57233
+ try {
57234
+ const data = await _deleteById(value._id);
57235
+ res.status(200).json(data);
57236
+ } catch (error2) {
57237
+ logger191.log({ level: "error", message: error2.message });
57238
+ next(error2);
57239
+ }
57240
+ }
57241
+ return { getAll, getById, addSubcategory, updateById, deleteById };
56825
57242
  }
56826
57243
 
56827
57244
  // src/models/online-forms-v2.model.ts
56828
57245
  import Joi141 from "joi";
56829
- import { ObjectId as ObjectId139 } from "mongodb";
57246
+ import { ObjectId as ObjectId140 } from "mongodb";
56830
57247
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
56831
57248
  FormEntryStatus2["ACTIVE"] = "active";
56832
57249
  FormEntryStatus2["INACTIVE"] = "inactive";
@@ -56881,21 +57298,21 @@ function MFormEntry(value) {
56881
57298
  }
56882
57299
  if (value._id && typeof value._id === "string") {
56883
57300
  try {
56884
- value._id = new ObjectId139(value._id);
57301
+ value._id = new ObjectId140(value._id);
56885
57302
  } catch {
56886
57303
  throw new Error("Invalid ID.");
56887
57304
  }
56888
57305
  }
56889
57306
  if (value.org && typeof value.org === "string") {
56890
57307
  try {
56891
- value.org = new ObjectId139(value.org);
57308
+ value.org = new ObjectId140(value.org);
56892
57309
  } catch {
56893
57310
  throw new Error("Invalid org ID.");
56894
57311
  }
56895
57312
  }
56896
57313
  if (value.site && typeof value.site === "string") {
56897
57314
  try {
56898
- value.site = new ObjectId139(value.site);
57315
+ value.site = new ObjectId140(value.site);
56899
57316
  } catch {
56900
57317
  throw new Error("Invalid site ID.");
56901
57318
  }
@@ -56918,9 +57335,13 @@ import {
56918
57335
  BadRequestError as BadRequestError220,
56919
57336
  InternalServerError as InternalServerError79,
56920
57337
  logger as logger192,
57338
+ makeCacheKey as makeCacheKey66,
57339
+ NotFoundError as NotFoundError61,
57340
+ paginate as paginate62,
56921
57341
  useAtlas as useAtlas123,
56922
57342
  useCache as useCache70
56923
57343
  } from "@7365admin1/node-server-utils";
57344
+ import { ObjectId as ObjectId141 } from "mongodb";
56924
57345
  var online_forms_namespace_collection = "online-forms";
56925
57346
  function useFormEntryRepo() {
56926
57347
  const db = useAtlas123.getDb();
@@ -56965,18 +57386,105 @@ function useFormEntryRepo() {
56965
57386
  throw error;
56966
57387
  }
56967
57388
  }
57389
+ async function getAll({
57390
+ search = "",
57391
+ page = 1,
57392
+ limit = 10,
57393
+ sort = {},
57394
+ status = "active",
57395
+ org = "",
57396
+ site = ""
57397
+ }) {
57398
+ page = page > 0 ? page - 1 : 0;
57399
+ sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
57400
+ const cacheOptions = {
57401
+ page,
57402
+ limit,
57403
+ status,
57404
+ sort: JSON.stringify(sort),
57405
+ ...site && { site },
57406
+ ...search && { search }
57407
+ };
57408
+ const query = {
57409
+ ...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } },
57410
+ ...site && { site: new ObjectId141(site) },
57411
+ ...search && { search: [{ name: { $regex: search, $options: "i" } }] }
57412
+ };
57413
+ const cacheKey = makeCacheKey66(
57414
+ online_forms_namespace_collection,
57415
+ cacheOptions
57416
+ );
57417
+ const cachedData = await getCache(cacheKey);
57418
+ if (cachedData) {
57419
+ logger192.info(`Cache hit for key: ${cacheKey}`);
57420
+ return cachedData;
57421
+ }
57422
+ try {
57423
+ const items = await collection.aggregate([
57424
+ { $match: query },
57425
+ { $sort: sort },
57426
+ { $skip: page * limit },
57427
+ { $limit: limit }
57428
+ ]).toArray();
57429
+ const length = await collection.countDocuments(query);
57430
+ const data = paginate62(items, page, limit, length);
57431
+ setCache(cacheKey, data, 15 * 60).then(() => {
57432
+ logger192.info(`Cache set for key: ${cacheKey}`);
57433
+ }).catch((err) => {
57434
+ logger192.error(`Failed to set cache for key: ${cacheKey}`, err);
57435
+ });
57436
+ return data;
57437
+ } catch (error) {
57438
+ throw error;
57439
+ }
57440
+ }
57441
+ async function getFormEntryById(_id) {
57442
+ const cacheKey = makeCacheKey66(online_forms_namespace_collection, { _id });
57443
+ const cachedData = await getCache(cacheKey);
57444
+ if (cachedData) {
57445
+ logger192.info(`Cache hit for key: ${cacheKey}`);
57446
+ return cachedData;
57447
+ }
57448
+ try {
57449
+ _id = new ObjectId141(_id);
57450
+ } catch (error) {
57451
+ throw new BadRequestError220("Invalid online form ID format.");
57452
+ }
57453
+ const query = { _id, status: { $ne: "deleted" } };
57454
+ try {
57455
+ const [data] = await collection.aggregate([{ $match: query }]).toArray();
57456
+ if (!data) {
57457
+ throw new NotFoundError61("Document not found.");
57458
+ }
57459
+ setCache(cacheKey, data, 15 * 60).then(() => {
57460
+ logger192.info(`Cache set for key: ${cacheKey}`);
57461
+ }).catch((err) => {
57462
+ logger192.error(`Failed to set cache for key: ${cacheKey}`, err);
57463
+ });
57464
+ return data;
57465
+ } catch (error) {
57466
+ throw error;
57467
+ }
57468
+ }
56968
57469
  return {
56969
57470
  add,
57471
+ getAll,
57472
+ getFormEntryById,
56970
57473
  createTextIndex
56971
57474
  };
56972
57475
  }
56973
57476
 
56974
57477
  // src/controllers/online-forms-v2.controller.ts
56975
57478
  import { BadRequestError as BadRequestError221, logger as logger193 } from "@7365admin1/node-server-utils";
57479
+ import Joi142 from "joi";
56976
57480
  import ExcelJS3 from "exceljs";
56977
57481
  import fs5 from "fs";
56978
57482
  function useFormEntryController() {
56979
- const { add: _add } = useFormEntryRepo();
57483
+ const {
57484
+ add: _add,
57485
+ getAll: _getAll,
57486
+ getFormEntryById: _getFormEntryById
57487
+ } = useFormEntryRepo();
56980
57488
  function toCamelCase(str) {
56981
57489
  return str.replace(/\s(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
56982
57490
  }
@@ -57038,8 +57546,59 @@ function useFormEntryController() {
57038
57546
  next(error);
57039
57547
  }
57040
57548
  }
57549
+ async function getAll(req, res, next) {
57550
+ try {
57551
+ const schema2 = Joi142.object({
57552
+ search: Joi142.string().optional().allow("", null),
57553
+ page: Joi142.number().integer().min(1).allow("", null).default(1),
57554
+ limit: Joi142.number().integer().min(1).max(100).allow("", null).default(10),
57555
+ status: Joi142.string().optional().allow(null, ""),
57556
+ org: Joi142.string().hex().optional().allow("", null),
57557
+ site: Joi142.string().hex().optional().allow("", null)
57558
+ });
57559
+ const { error, value } = schema2.validate(req.query);
57560
+ if (error) {
57561
+ const messages = error.details.map((d) => d.message).join(", ");
57562
+ logger193.log({ level: "error", message: messages });
57563
+ next(new BadRequestError221(messages));
57564
+ return;
57565
+ }
57566
+ const { search, page, limit, status, org, site } = value;
57567
+ const data = await _getAll({ search, page, limit, status, org, site });
57568
+ res.json(data);
57569
+ return;
57570
+ } catch (error) {
57571
+ logger193.log({ level: "error", message: error.message });
57572
+ next(error);
57573
+ return;
57574
+ }
57575
+ }
57576
+ async function getFormEntryById(req, res, next) {
57577
+ try {
57578
+ const schema2 = Joi142.object({
57579
+ _id: Joi142.string().hex().length(24).required()
57580
+ });
57581
+ const { error, value } = schema2.validate({ _id: req.params.id });
57582
+ if (error) {
57583
+ const messages = error.details.map((d) => d.message).join(", ");
57584
+ logger193.log({ level: "error", message: messages });
57585
+ next(new BadRequestError221(messages));
57586
+ return;
57587
+ }
57588
+ const { _id } = value;
57589
+ const data = await _getFormEntryById(_id);
57590
+ res.json(data);
57591
+ return;
57592
+ } catch (error) {
57593
+ logger193.log({ level: "error", message: error.message });
57594
+ next(error);
57595
+ return;
57596
+ }
57597
+ }
57041
57598
  return {
57042
- uploadFormEntrys
57599
+ uploadFormEntrys,
57600
+ getAll,
57601
+ getFormEntryById
57043
57602
  };
57044
57603
  }
57045
57604
 
@@ -57083,7 +57642,7 @@ function useBuildingLevelService() {
57083
57642
 
57084
57643
  // src/controllers/building-level.controller.ts
57085
57644
  import { BadRequestError as BadRequestError222, logger as logger194 } from "@7365admin1/node-server-utils";
57086
- import Joi142 from "joi";
57645
+ import Joi143 from "joi";
57087
57646
  function useBuildingLevelController() {
57088
57647
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
57089
57648
  const {
@@ -57110,12 +57669,12 @@ function useBuildingLevelController() {
57110
57669
  }
57111
57670
  async function getAll(req, res, next) {
57112
57671
  try {
57113
- const validation = Joi142.object({
57114
- page: Joi142.number().min(1).optional().default(1),
57115
- limit: Joi142.number().min(1).optional().default(20),
57116
- search: Joi142.string().optional().allow("", null),
57117
- site: Joi142.string().hex().length(24).optional().allow("", null),
57118
- status: Joi142.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
57672
+ const validation = Joi143.object({
57673
+ page: Joi143.number().min(1).optional().default(1),
57674
+ limit: Joi143.number().min(1).optional().default(20),
57675
+ search: Joi143.string().optional().allow("", null),
57676
+ site: Joi143.string().hex().length(24).optional().allow("", null),
57677
+ status: Joi143.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
57119
57678
  });
57120
57679
  const { error, value } = validation.validate(req.query, {
57121
57680
  abortEarly: false
@@ -57142,8 +57701,8 @@ function useBuildingLevelController() {
57142
57701
  }
57143
57702
  async function getById(req, res, next) {
57144
57703
  try {
57145
- const schema2 = Joi142.object({
57146
- id: Joi142.string().hex().length(24).required()
57704
+ const schema2 = Joi143.object({
57705
+ id: Joi143.string().hex().length(24).required()
57147
57706
  });
57148
57707
  const { error, value } = schema2.validate({ id: req.params.id });
57149
57708
  if (error) {
@@ -57181,8 +57740,8 @@ function useBuildingLevelController() {
57181
57740
  }
57182
57741
  async function deleteById(req, res, next) {
57183
57742
  try {
57184
- const schema2 = Joi142.object({
57185
- id: Joi142.string().hex().required()
57743
+ const schema2 = Joi143.object({
57744
+ id: Joi143.string().hex().required()
57186
57745
  });
57187
57746
  const { error, value } = schema2.validate({ id: req.params.id });
57188
57747
  if (error) {