@7365admin1/core 2.21.0 → 2.22.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
@@ -4647,6 +4647,16 @@ function useSiteRepo() {
4647
4647
  throw error;
4648
4648
  }
4649
4649
  }
4650
+ async function getAllSitesUnpaginated() {
4651
+ try {
4652
+ const sites = await collection.find({ deletedAt: "" }).project({
4653
+ _id: 1
4654
+ }).toArray();
4655
+ return sites;
4656
+ } catch (error) {
4657
+ throw error;
4658
+ }
4659
+ }
4650
4660
  return {
4651
4661
  createIndexes,
4652
4662
  createSite,
@@ -4659,7 +4669,8 @@ function useSiteRepo() {
4659
4669
  getByName,
4660
4670
  getByExactName,
4661
4671
  updateSiteIncidentCounter,
4662
- updateSiteById
4672
+ updateSiteById,
4673
+ getAllSitesUnpaginated
4663
4674
  };
4664
4675
  }
4665
4676
 
@@ -7812,6 +7823,11 @@ function useOrgController() {
7812
7823
  import { BadRequestError as BadRequestError34 } from "@7365admin1/node-server-utils";
7813
7824
  import Joi20 from "joi";
7814
7825
  import { ObjectId as ObjectId22 } from "mongodb";
7826
+ var SubscriptionType = /* @__PURE__ */ ((SubscriptionType2) => {
7827
+ SubscriptionType2["ORGANIZATION"] = "organization";
7828
+ SubscriptionType2["AFFILIATE"] = "affiliate";
7829
+ return SubscriptionType2;
7830
+ })(SubscriptionType || {});
7815
7831
  var schema = Joi20.object({
7816
7832
  user: Joi20.string().hex().required(),
7817
7833
  amount: Joi20.number().min(0).required(),
@@ -7845,7 +7861,7 @@ function MSubscription(value) {
7845
7861
  currency: Joi20.string().required(),
7846
7862
  description: Joi20.string().optional().allow("", null),
7847
7863
  promoCode: Joi20.string().optional().allow("", null),
7848
- type: Joi20.string().valid("organization", "affiliate").required(),
7864
+ type: Joi20.string().valid(...Object.values(SubscriptionType)).optional().allow(null, ""),
7849
7865
  paidSeats: Joi20.number().optional().min(0).allow("", null),
7850
7866
  currentSeats: Joi20.number().optional().min(0).allow("", null),
7851
7867
  maxSeats: Joi20.number().optional().min(0).allow("", null),
@@ -7899,7 +7915,6 @@ function MSubscription(value) {
7899
7915
  status: "active",
7900
7916
  billingCycle: value.billingCycle,
7901
7917
  nextBillingDate,
7902
- // Fixed nextBillingDate logic
7903
7918
  lastPaymentStatus: value.lastPaymentStatus ?? "success",
7904
7919
  failedAttempts: value.failedAttempts ?? 0,
7905
7920
  createdAt: createdAt.toISOString(),
@@ -16496,7 +16511,7 @@ var schemaBuildingUnit = Joi43.object({
16496
16511
  buildingName: Joi43.string().optional().allow("", null),
16497
16512
  block: Joi43.number().integer().min(1).required(),
16498
16513
  level: Joi43.string().required(),
16499
- category: Joi43.string().required(),
16514
+ category: Joi43.string().optional().allow(null, ""),
16500
16515
  status: Joi43.string().optional().allow("", null),
16501
16516
  buildingUnitFiles: Joi43.array().items(Joi43.string()).optional().allow("", null),
16502
16517
  companyName: Joi43.string().optional().allow("", null),
@@ -18608,10 +18623,12 @@ var schemaCustomerSite = Joi48.object({
18608
18623
  _id: Joi48.string().hex().optional().allow("", null),
18609
18624
  name: Joi48.string().required(),
18610
18625
  site: Joi48.string().hex().optional().allow("", null),
18611
- siteOrg: Joi48.string().hex().required(),
18612
- siteOrgName: Joi48.string().required(),
18626
+ siteOrg: Joi48.string().hex().optional().allow("", null),
18627
+ siteOrgName: Joi48.string().optional().allow("", null),
18613
18628
  org: Joi48.string().hex().required(),
18614
18629
  status: Joi48.string().optional().allow("", null),
18630
+ address: addressSchema.optional().allow("", null),
18631
+ category: Joi48.string().valid(...Object.values(SiteCategories)).optional().allow(null, ""),
18615
18632
  createdAt: Joi48.string().optional().allow("", null),
18616
18633
  updatedAt: Joi48.string().optional().allow("", null),
18617
18634
  deletedAt: Joi48.string().optional().allow("", null)
@@ -18656,6 +18673,8 @@ function MCustomerSite(value) {
18656
18673
  siteOrg: value.siteOrg,
18657
18674
  siteOrgName: value.siteOrgName,
18658
18675
  org: value.org,
18676
+ address: value.address,
18677
+ category: value.category,
18659
18678
  status: value.status ?? "active",
18660
18679
  createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
18661
18680
  updatedAt: value.updatedAt ?? "",
@@ -18938,7 +18957,12 @@ function useCustomerSiteService() {
18938
18957
  }
18939
18958
  }
18940
18959
  const siteId = await createSite(
18941
- { name: value.name, orgId: value.siteOrg },
18960
+ {
18961
+ name: value.name,
18962
+ orgId: value.siteOrg,
18963
+ address: value.address,
18964
+ category: value.category
18965
+ },
18942
18966
  session
18943
18967
  );
18944
18968
  if (!siteId) {
@@ -19050,25 +19074,15 @@ function useCustomerSiteController() {
19050
19074
  } = useCustomerSiteRepo();
19051
19075
  const { add: _add, addViaInvite: _addViaInvite } = useCustomerSiteService();
19052
19076
  async function add(req, res, next) {
19053
- const validation = Joi50.object({
19054
- name: Joi50.string().required(),
19055
- site: Joi50.string().hex().optional().allow("", null),
19056
- siteOrg: Joi50.string().hex().required(),
19057
- siteOrgName: Joi50.string().required(),
19058
- org: Joi50.string().hex().required()
19059
- });
19060
- const payload = { ...req.body };
19061
- const { error } = validation.validate(payload);
19077
+ const { error, value } = schemaCustomerSite.validate(req.body);
19062
19078
  if (error) {
19063
- logger68.log({
19064
- level: "error",
19065
- message: `${error.message} - controller validation`
19066
- });
19067
- next(new BadRequestError87(error.message));
19079
+ const messages = error.details.map((d) => d.message).join(", ");
19080
+ logger68.log({ level: "error", message: messages });
19081
+ next(new BadRequestError87(messages));
19068
19082
  return;
19069
19083
  }
19070
19084
  try {
19071
- const data = await _add(payload);
19085
+ const data = await _add(value);
19072
19086
  res.status(201).json(data);
19073
19087
  return;
19074
19088
  } catch (error2) {
@@ -24188,7 +24202,7 @@ function useSiteFacilityService() {
24188
24202
  });
24189
24203
  }, generateTimeSlots2 = function(start, end, interval) {
24190
24204
  const slots = [];
24191
- const timeToMinutes = (t) => {
24205
+ const timeToMinutes2 = (t) => {
24192
24206
  const [h, m] = t.split(":").map(Number);
24193
24207
  return h * 60 + m;
24194
24208
  };
@@ -24197,8 +24211,8 @@ function useSiteFacilityService() {
24197
24211
  const mm = m % 60;
24198
24212
  return `${String(h).padStart(2, "0")}:${String(mm).padStart(2, "0")}`;
24199
24213
  };
24200
- const startMin = timeToMinutes(start);
24201
- const endMin = timeToMinutes(end);
24214
+ const startMin = timeToMinutes2(start);
24215
+ const endMin = timeToMinutes2(end);
24202
24216
  const intervalMin = interval * 60;
24203
24217
  for (let t = startMin; t + intervalMin <= endMin; t += intervalMin) {
24204
24218
  const s = minutesToTime(t);
@@ -26625,7 +26639,10 @@ function useBulletinBoardService() {
26625
26639
  const existingBulletinBoard = await _getBulletinBoardById(id);
26626
26640
  if (Array.isArray(existingBulletinBoard.file)) {
26627
26641
  for (const file of existingBulletinBoard.file) {
26628
- await _deleteFileById(file, session);
26642
+ try {
26643
+ await _deleteFileById(file, session);
26644
+ } catch (error) {
26645
+ }
26629
26646
  }
26630
26647
  }
26631
26648
  await _deleteBulletinBoardById(id, session);
@@ -26785,14 +26802,16 @@ function useBulletinBoardController() {
26785
26802
  }
26786
26803
  }
26787
26804
  async function deleteBulletinBoardById(req, res, next) {
26788
- const validation = Joi76.string().hex().required();
26789
- const _id = req.params.id;
26790
- const { error } = validation.validate(_id);
26805
+ const schema2 = Joi76.object({
26806
+ _id: Joi76.string().hex().length(24).required()
26807
+ });
26808
+ const { error, value } = schema2.validate({ _id: req.params.id });
26791
26809
  if (error) {
26792
26810
  logger105.log({ level: "error", message: error.message });
26793
26811
  next(new BadRequestError125(error.message));
26794
26812
  return;
26795
26813
  }
26814
+ const { _id } = value;
26796
26815
  try {
26797
26816
  await _deleteBulletinBoardById(_id);
26798
26817
  res.status(200).json({ message: "Successfully deleted bulletin board." });
@@ -40400,12 +40419,14 @@ var MManpowerMonitoring = class {
40400
40419
  // src/repositories/manpower-monitoring.repo.ts
40401
40420
  import {
40402
40421
  BadRequestError as BadRequestError179,
40403
- paginate as paginate49,
40422
+ paginate as paginate50,
40404
40423
  useAtlas as useAtlas98
40405
40424
  } from "@7365admin1/node-server-utils";
40406
40425
 
40407
40426
  // src/utils/hrmlabs-attendance.util.ts
40408
40427
  import axios2 from "axios";
40428
+ import moment from "moment-timezone";
40429
+ var default_early_checkIn = 4;
40409
40430
  async function hrmLabsAuthentication({
40410
40431
  authUrl,
40411
40432
  username,
@@ -40432,6 +40453,205 @@ async function hrmLabsAuthentication({
40432
40453
  "HRMLabs Authentication failed. Please check your credentials."
40433
40454
  );
40434
40455
  }
40456
+ async function fetchAttendanceData({
40457
+ attendanceUrl,
40458
+ token,
40459
+ startDate,
40460
+ endDate,
40461
+ siteName,
40462
+ search
40463
+ }) {
40464
+ try {
40465
+ const res = await axios2.post(
40466
+ attendanceUrl,
40467
+ {
40468
+ start: startDate,
40469
+ end: endDate,
40470
+ locationName: siteName,
40471
+ search
40472
+ },
40473
+ {
40474
+ headers: { Authorization: `Bearer ${token}` },
40475
+ validateStatus: () => true
40476
+ }
40477
+ );
40478
+ if (res.status >= 200 && res.status < 300 && res.data?.success) {
40479
+ return { success: true, data: res.data.data || [] };
40480
+ }
40481
+ return {
40482
+ success: false,
40483
+ message: `Attendance API failed with status ${res.status}`,
40484
+ data: []
40485
+ };
40486
+ } catch (error) {
40487
+ console.error("fetchAttendanceData error:", error.message || error);
40488
+ return {
40489
+ success: false,
40490
+ message: error?.message || "Unknown error while fetching attendance data",
40491
+ data: []
40492
+ };
40493
+ }
40494
+ }
40495
+ function filterByShiftTime(attendance, shiftData, timezone, format) {
40496
+ return attendance.filter((item) => {
40497
+ if (!item.checkIn)
40498
+ return false;
40499
+ const checkInLocal = moment(item.checkIn, format);
40500
+ if (!checkInLocal.isValid())
40501
+ return false;
40502
+ const [startHour, startMinute] = shiftData.checkIn.split(":").map(Number);
40503
+ const [endHour, endMinute] = shiftData.checkOut.split(":").map(Number);
40504
+ const shiftStart = moment(checkInLocal).set({ hour: startHour, minute: startMinute, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
40505
+ const shiftEnd = moment(checkInLocal).set({
40506
+ hour: endHour,
40507
+ minute: endMinute,
40508
+ second: 0,
40509
+ millisecond: 0
40510
+ }).subtract(default_early_checkIn, "hour");
40511
+ if (shiftEnd.isBefore(shiftStart))
40512
+ shiftEnd.add(1, "day");
40513
+ return checkInLocal.isBetween(shiftStart, shiftEnd, null, "[]");
40514
+ });
40515
+ }
40516
+ function paginate49(data, page, limit) {
40517
+ const length = data.length;
40518
+ const startIndex = (page - 1) * limit;
40519
+ const endIndex = startIndex + limit;
40520
+ return {
40521
+ items: data.slice(startIndex, endIndex),
40522
+ pages: Math.ceil(length / limit),
40523
+ pageRange: `${startIndex + 1}-${Math.min(endIndex, length)} of ${length}`
40524
+ };
40525
+ }
40526
+ function designationCount(attendance, designationConfig, shiftName) {
40527
+ let data = [];
40528
+ const seen = /* @__PURE__ */ new Set();
40529
+ const count = {};
40530
+ const uniqueAttendanceData = attendance.filter((item) => {
40531
+ if (seen.has(item.identificationNumber))
40532
+ return false;
40533
+ seen.add(item.identificationNumber);
40534
+ return true;
40535
+ });
40536
+ for (const record of uniqueAttendanceData) {
40537
+ count[record.jobTitle] = (count[record.jobTitle] || 0) + 1;
40538
+ }
40539
+ let total = 0;
40540
+ const result = [];
40541
+ const addedTitles = /* @__PURE__ */ new Set();
40542
+ const shiftMap = {
40543
+ "Day Shift": "morningShift",
40544
+ "Afternoon Shift": "afternoonShift",
40545
+ "Night Shift": "nightShift"
40546
+ };
40547
+ for (const designation of designationConfig.designations) {
40548
+ const title = designation.title;
40549
+ const shifts = designation.shifts;
40550
+ if (shiftName === "all") {
40551
+ total = (shifts.morningShift || 0) + (shifts.afternoonShift || 0) + (shifts.nightShift || 0);
40552
+ } else {
40553
+ total = shifts[shiftMap[shiftName]] || 0;
40554
+ }
40555
+ const countValue = count[title] ?? 0;
40556
+ result.push({
40557
+ name: title,
40558
+ count: countValue,
40559
+ total
40560
+ });
40561
+ addedTitles.add(title);
40562
+ }
40563
+ for (const title in count) {
40564
+ if (!addedTitles.has(title)) {
40565
+ result.push({
40566
+ name: title,
40567
+ count: count[title],
40568
+ total: 0
40569
+ });
40570
+ }
40571
+ }
40572
+ return result;
40573
+ }
40574
+ function totalCountPerShift(attendance, shiftData, timezone, format) {
40575
+ let totalCountPerShift3 = [];
40576
+ const seen = /* @__PURE__ */ new Set();
40577
+ const uniqueAttendanceData = [];
40578
+ for (const item of attendance) {
40579
+ if (!seen.has(item.identificationNumber)) {
40580
+ const duplicates = attendance.filter(
40581
+ (a) => a.identificationNumber === item.identificationNumber
40582
+ );
40583
+ if (duplicates.length > 1) {
40584
+ const preferred = duplicates.find((a) => a.timeDiff > 0.1) || item;
40585
+ uniqueAttendanceData.push(preferred);
40586
+ } else {
40587
+ uniqueAttendanceData.push(item);
40588
+ }
40589
+ seen.add(item.identificationNumber);
40590
+ }
40591
+ }
40592
+ let data = [];
40593
+ for (const shift of shiftData) {
40594
+ data = uniqueAttendanceData.filter((item) => {
40595
+ if (!item.checkIn)
40596
+ return false;
40597
+ const checkInLocal = moment(item.checkIn, format);
40598
+ if (!checkInLocal.isValid())
40599
+ return false;
40600
+ const [startHour, startMinute] = shift.checkIn.split(":").map(Number);
40601
+ const [endHour, endMinute] = shift.checkOut.split(":").map(Number);
40602
+ const shiftStart = moment(checkInLocal).set({
40603
+ hour: startHour,
40604
+ minute: startMinute,
40605
+ second: 0,
40606
+ millisecond: 0
40607
+ }).subtract(default_early_checkIn, "hour");
40608
+ const shiftEnd = moment(checkInLocal).set({
40609
+ hour: endHour,
40610
+ minute: endMinute,
40611
+ second: 0,
40612
+ millisecond: 0
40613
+ }).subtract(default_early_checkIn, "hour");
40614
+ if (shiftEnd.isBefore(shiftStart))
40615
+ shiftEnd.add(1, "day");
40616
+ return checkInLocal.isBetween(shiftStart, shiftEnd, null, "[]");
40617
+ });
40618
+ totalCountPerShift3.push(data.length);
40619
+ }
40620
+ const shiftInsertMap = {
40621
+ "Day Shift": (data2) => data2.push(0),
40622
+ "Afternoon Shift": (data2) => data2.splice(1, 0, 0),
40623
+ "Night Shift": (data2) => data2.unshift(0)
40624
+ };
40625
+ if (shiftData.length === 1) {
40626
+ const shiftName = shiftData[0]?.name;
40627
+ const insertFn = shiftInsertMap[shiftName];
40628
+ if (insertFn) {
40629
+ insertFn(totalCountPerShift3);
40630
+ }
40631
+ }
40632
+ return totalCountPerShift3;
40633
+ }
40634
+ function filterByStatus(attendance, shiftData, timezone, format, status) {
40635
+ return attendance.filter((item) => {
40636
+ if (!item.checkIn)
40637
+ return false;
40638
+ const checkInLocal = moment(item.checkIn, format);
40639
+ if (!checkInLocal.isValid())
40640
+ return false;
40641
+ const [lateHour, lateMinute] = shiftData.lateCheckInAlert.split(":").map(Number);
40642
+ const lateLoginTime = moment(checkInLocal).set({
40643
+ hour: lateHour,
40644
+ minute: lateMinute,
40645
+ second: 0,
40646
+ millisecond: 0
40647
+ });
40648
+ if (status == "onTime") {
40649
+ return checkInLocal.isBefore(lateLoginTime);
40650
+ } else if (status == "late") {
40651
+ return checkInLocal.isAfter(lateLoginTime);
40652
+ }
40653
+ });
40654
+ }
40435
40655
  function sleep(ms) {
40436
40656
  return new Promise((resolve) => setTimeout(resolve, ms));
40437
40657
  }
@@ -40465,9 +40685,189 @@ async function fetchSites({ siteUrl, token }) {
40465
40685
  } while (attempt < maxRetries);
40466
40686
  throw lastError;
40467
40687
  }
40688
+ async function totalCountPerStatus(attendance, shiftName, shiftData, timezone, format, totalShifts) {
40689
+ const totalCountPerStatus3 = {
40690
+ onTime: 0,
40691
+ late: 0,
40692
+ noShow: 0,
40693
+ earlyOut: 0,
40694
+ totalCount: 0
40695
+ };
40696
+ const seenGlobal = /* @__PURE__ */ new Set();
40697
+ const parseTime = (timeStr) => {
40698
+ const [hour, minute] = timeStr.split(":").map(Number);
40699
+ return { hour, minute };
40700
+ };
40701
+ for (const shift of shiftData) {
40702
+ const shiftStartTime = parseTime(shift.checkIn);
40703
+ const shiftEndTime = parseTime(shift.checkOut);
40704
+ const lateTime = parseTime(shift.lateCheckInAlert);
40705
+ const uniqueAttendanceData = shiftName === "all" ? await filterByShiftTime(attendance, shift, timezone, format) : attendance;
40706
+ for (const item of uniqueAttendanceData) {
40707
+ const {
40708
+ checkIn: checkInStr,
40709
+ checkOut: checkOutStr,
40710
+ identificationNumber
40711
+ } = item;
40712
+ if (!checkInStr || seenGlobal.has(identificationNumber))
40713
+ continue;
40714
+ const checkIn = moment(checkInStr, format);
40715
+ const checkOut = checkOutStr ? moment(checkOutStr, format) : null;
40716
+ const checkOutChecker = checkOut ? moment(checkOutStr, format) : checkIn;
40717
+ if (!checkIn.isValid())
40718
+ continue;
40719
+ const shiftStart = moment(checkIn).set({ ...shiftStartTime, second: 59, millisecond: 59 }).subtract(default_early_checkIn, "hour");
40720
+ const shiftEnd = moment(checkOutChecker).set({ ...shiftEndTime, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
40721
+ const lateCheckIn = moment(checkIn).set({
40722
+ ...lateTime,
40723
+ second: 59,
40724
+ millisecond: 59
40725
+ });
40726
+ if (shiftEnd.isBefore(shiftStart))
40727
+ shiftEnd.add(1, "day");
40728
+ if (checkIn.isBetween(shiftStart, shiftEnd, null, "[]")) {
40729
+ seenGlobal.add(identificationNumber);
40730
+ if (checkIn.isSameOrBefore(lateCheckIn)) {
40731
+ totalCountPerStatus3.onTime++;
40732
+ } else {
40733
+ totalCountPerStatus3.late++;
40734
+ }
40735
+ if (checkOut && item.timeDiff < 12) {
40736
+ totalCountPerStatus3.earlyOut++;
40737
+ }
40738
+ }
40739
+ }
40740
+ }
40741
+ const shiftMap = {
40742
+ "Day Shift": totalShifts.morningShift,
40743
+ "Afternoon Shift": totalShifts.afternoonShift,
40744
+ "Night Shift": totalShifts.nightShift,
40745
+ all: totalShifts.morningShift + totalShifts.afternoonShift + totalShifts.nightShift
40746
+ };
40747
+ const totalPresent = totalCountPerStatus3.onTime + totalCountPerStatus3.late;
40748
+ totalCountPerStatus3.noShow = shiftMap[shiftName] - totalPresent;
40749
+ totalCountPerStatus3.totalCount = shiftMap[shiftName];
40750
+ return totalCountPerStatus3;
40751
+ }
40752
+ async function chartCountData(attendance, shiftData, timezone, format, totalShifts, startDateStr, endDateStr, status = "all") {
40753
+ const categorizedData = [];
40754
+ const seenPerDay = /* @__PURE__ */ new Set();
40755
+ const parseTime = (timeStr) => {
40756
+ const [hour, minute] = timeStr.split(":").map(Number);
40757
+ return { hour, minute };
40758
+ };
40759
+ const startDate = moment(startDateStr, "DD-MM-YYYY");
40760
+ const endDate = moment(endDateStr, "DD-MM-YYYY");
40761
+ const daysInRange = [];
40762
+ for (let day = startDate.clone(); day.isSameOrBefore(endDate); day.add(1, "day")) {
40763
+ daysInRange.push(day.format("DD-MM-YYYY"));
40764
+ }
40765
+ for (const day of daysInRange) {
40766
+ const dailyData = { date: day, late: 0, under: 0, over: 0, normal: 0 };
40767
+ const dailyAttendance = attendance.filter((item) => {
40768
+ const checkInDate = item.checkIn.split(" ")[0];
40769
+ return checkInDate === day;
40770
+ });
40771
+ const [morningCount, nightCount] = totalCountPerShift(
40772
+ dailyAttendance,
40773
+ shiftData,
40774
+ timezone,
40775
+ format
40776
+ );
40777
+ if (status === "all" || status === "under" || status === "over") {
40778
+ const shifts = [
40779
+ {
40780
+ label: "morningShift",
40781
+ expected: totalShifts.morningShift,
40782
+ actual: morningCount
40783
+ },
40784
+ {
40785
+ label: "nightShift",
40786
+ expected: totalShifts.nightShift,
40787
+ actual: nightCount
40788
+ }
40789
+ ];
40790
+ const today = /* @__PURE__ */ new Date();
40791
+ today.setHours(0, 0, 0, 0);
40792
+ for (const { label, expected, actual } of shifts) {
40793
+ const [dayPart, month, year] = day.split("-");
40794
+ const currentDay = /* @__PURE__ */ new Date(`${year}-${month}-${dayPart}`);
40795
+ currentDay.setHours(0, 0, 0, 0);
40796
+ if (currentDay <= today) {
40797
+ if (status === "all") {
40798
+ if (actual < expected)
40799
+ dailyData.under++;
40800
+ else if (actual > expected)
40801
+ dailyData.over++;
40802
+ else
40803
+ dailyData.normal++;
40804
+ } else if (status === "under" && actual < expected) {
40805
+ dailyData.under++;
40806
+ } else if (status === "over" && actual > expected) {
40807
+ dailyData.over++;
40808
+ }
40809
+ }
40810
+ }
40811
+ }
40812
+ if (status === "late" || status === "all") {
40813
+ for (const shift of shiftData) {
40814
+ const shiftStartTime = parseTime(shift.checkIn);
40815
+ const shiftEndTime = parseTime(shift.checkOut);
40816
+ const lateTime = parseTime(shift.lateCheckInAlert);
40817
+ const uniqueAttendanceData = await filterByShiftTime(
40818
+ dailyAttendance,
40819
+ shift,
40820
+ timezone,
40821
+ format
40822
+ );
40823
+ for (const item of uniqueAttendanceData) {
40824
+ const {
40825
+ checkIn: checkInStr,
40826
+ checkOut: checkOutStr,
40827
+ identificationNumber
40828
+ } = item;
40829
+ if (!checkInStr)
40830
+ continue;
40831
+ const checkIn = moment(checkInStr, format);
40832
+ if (!checkIn.isValid())
40833
+ continue;
40834
+ const dayKey = `${identificationNumber}-${checkIn.format(
40835
+ "YYYY-MM-DD"
40836
+ )}`;
40837
+ if (seenPerDay.has(dayKey))
40838
+ continue;
40839
+ seenPerDay.add(dayKey);
40840
+ const checkOut = checkOutStr ? moment(checkOutStr, format) : checkIn;
40841
+ const shiftStart = moment(checkIn).set({ ...shiftStartTime, second: 59, millisecond: 59 }).subtract(default_early_checkIn, "hour");
40842
+ const shiftEnd = moment(checkOut).set({ ...shiftEndTime, second: 0, millisecond: 0 }).subtract(default_early_checkIn, "hour");
40843
+ const lateCheckIn = moment(checkIn).set({
40844
+ ...lateTime,
40845
+ second: 59,
40846
+ millisecond: 59
40847
+ });
40848
+ if (shiftEnd.isBefore(shiftStart))
40849
+ shiftEnd.add(1, "day");
40850
+ if (checkIn.isBetween(shiftStart, shiftEnd, null, "[]") && checkIn.isAfter(lateCheckIn)) {
40851
+ dailyData.late++;
40852
+ }
40853
+ }
40854
+ }
40855
+ }
40856
+ categorizedData.push(dailyData);
40857
+ }
40858
+ return categorizedData;
40859
+ }
40468
40860
  var hrmlabs_attendance_util_default = {
40469
40861
  hrmLabsAuthentication,
40470
- fetchSites
40862
+ fetchAttendanceData,
40863
+ filterByShiftTime,
40864
+ paginate: paginate49,
40865
+ designationCount,
40866
+ totalCountPerShift,
40867
+ filterByStatus,
40868
+ fetchSites,
40869
+ totalCountPerStatus,
40870
+ chartCountData
40471
40871
  };
40472
40872
 
40473
40873
  // src/repositories/manpower-monitoring.repo.ts
@@ -40523,7 +40923,7 @@ function useManpowerMonitoringRepo() {
40523
40923
  ]).toArray();
40524
40924
  const total = result[0].totalCount[0]?.count || 0;
40525
40925
  const items = result[0].items;
40526
- return paginate49(items, page, limit, total);
40926
+ return paginate50(items, page, limit, total);
40527
40927
  } catch (error) {
40528
40928
  throw new Error(error.message || "Server Internal Error");
40529
40929
  }
@@ -40662,21 +41062,210 @@ function useManpowerMonitoringRepo() {
40662
41062
  }
40663
41063
 
40664
41064
  // src/services/manpower-monitoring.service.ts
41065
+ import {
41066
+ BadRequestError as BadRequestError181,
41067
+ logger as logger159,
41068
+ useAtlas as useAtlas100
41069
+ } from "@7365admin1/node-server-utils";
41070
+
41071
+ // src/repositories/manpower-remarks.repo.ts
40665
41072
  import {
40666
41073
  BadRequestError as BadRequestError180,
40667
- logger as logger158,
41074
+ paginate as paginate51,
40668
41075
  useAtlas as useAtlas99
40669
41076
  } from "@7365admin1/node-server-utils";
40670
- import moment from "moment-timezone";
41077
+
41078
+ // src/models/manpower-remarks.model.ts
41079
+ import Joi112 from "joi";
41080
+ import { ObjectId as ObjectId109 } from "mongodb";
41081
+ var remarksSchema = Joi112.object({
41082
+ name: Joi112.string().required(),
41083
+ remark: Joi112.object({
41084
+ isAcknowledged: Joi112.boolean().required(),
41085
+ status: Joi112.string().optional().allow("", null),
41086
+ acknowledgementRemarks: Joi112.string().optional().allow("", null),
41087
+ acknowledgedAt: Joi112.string().optional().allow("", null)
41088
+ }).required()
41089
+ });
41090
+ var manpowerRemarksSchema = Joi112.object({
41091
+ siteId: Joi112.string().hex().optional(),
41092
+ siteName: Joi112.string().optional(),
41093
+ remarks: Joi112.array().items(remarksSchema).required(),
41094
+ createdBy: Joi112.string().hex().optional().allow("", null),
41095
+ createdByName: Joi112.string().optional().allow("", null),
41096
+ morningAlertTime: Joi112.string().optional().allow("", null),
41097
+ afternoonAlertTime: Joi112.string().optional().allow("", null),
41098
+ nightAlertTime: Joi112.string().optional().allow("", null),
41099
+ serviceProviderId: Joi112.string().hex().optional(),
41100
+ status: Joi112.string().required()
41101
+ });
41102
+ var MManpowerRemarks = class {
41103
+ constructor(data) {
41104
+ this._id = new ObjectId109();
41105
+ this.serviceProviderId = data.serviceProviderId || "";
41106
+ this.siteId = data.siteId || "";
41107
+ this.siteName = data.siteName || "";
41108
+ this.remarks = data.remarks || [];
41109
+ this.createdBy = data.createdBy || "";
41110
+ this.createdByName = data.createdByName || "";
41111
+ this.createdAt = /* @__PURE__ */ new Date();
41112
+ this.createdAtSGT = data.createdAtSGT || "";
41113
+ this.updatedAt = data.updatedAt || "";
41114
+ this.morningAlertTime = data.morningAlertTime || "";
41115
+ this.afternoonAlertTime = data.afternoonAlertTime || "";
41116
+ this.nightAlertTime = data.nightAlertTime || "";
41117
+ this.status = data.status || "active";
41118
+ }
41119
+ };
41120
+
41121
+ // src/repositories/manpower-remarks.repo.ts
41122
+ import { ObjectId as ObjectId110 } from "mongodb";
41123
+ import moment2 from "moment-timezone";
41124
+ function useManpowerRemarksRepo() {
41125
+ const db = useAtlas99.getDb();
41126
+ if (!db) {
41127
+ throw new Error("Unable to connect to server.");
41128
+ }
41129
+ const namespace_collection = "manpower-remarks";
41130
+ const collection = db.collection(namespace_collection);
41131
+ async function createManpowerRemarks(value, session) {
41132
+ try {
41133
+ value = new MManpowerRemarks(value);
41134
+ if (value.siteId)
41135
+ value.siteId = new ObjectId110(value.siteId);
41136
+ if (value.serviceProviderId)
41137
+ value.serviceProviderId = new ObjectId110(value.serviceProviderId);
41138
+ const result = await collection.insertOne(value, { session });
41139
+ return result;
41140
+ } catch (error) {
41141
+ throw new Error(error.message || error || "Server Internal Error");
41142
+ }
41143
+ }
41144
+ async function getManpowerRemarksAllSite({
41145
+ page = 1,
41146
+ limit = 10,
41147
+ serviceProviderId = "",
41148
+ search = "",
41149
+ status = "active",
41150
+ date = ""
41151
+ }) {
41152
+ try {
41153
+ page = page ? page - 1 : 0;
41154
+ limit = limit || 10;
41155
+ const searchQuery = {};
41156
+ const nowSGT = moment2().tz("Asia/Singapore");
41157
+ searchQuery.serviceProviderId = new ObjectId110(serviceProviderId);
41158
+ if (search != "") {
41159
+ searchQuery.siteName = { $regex: search, $options: "i" };
41160
+ }
41161
+ if (status) {
41162
+ searchQuery.status = status;
41163
+ }
41164
+ if (date) {
41165
+ searchQuery.createdAtSGT = date;
41166
+ }
41167
+ const result = await collection.aggregate([
41168
+ { $match: searchQuery },
41169
+ {
41170
+ $facet: {
41171
+ totalCount: [{ $count: "count" }],
41172
+ items: [
41173
+ { $sort: { siteName: 1 } },
41174
+ { $skip: page * limit },
41175
+ { $limit: limit }
41176
+ ]
41177
+ }
41178
+ }
41179
+ ]).toArray();
41180
+ const total = result[0].totalCount[0]?.count || 0;
41181
+ const items = result[0].items;
41182
+ return paginate51(items, page, limit, total);
41183
+ } catch (error) {
41184
+ throw new Error(error.message || "Server Internal Error");
41185
+ }
41186
+ }
41187
+ async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
41188
+ try {
41189
+ _id = new ObjectId110(_id);
41190
+ serviceProviderId = new ObjectId110(serviceProviderId);
41191
+ } catch (error) {
41192
+ throw new Error("Invalid Site ID format.");
41193
+ }
41194
+ try {
41195
+ const data = await collection.findOne({
41196
+ siteId: _id,
41197
+ createdAtSGT: date,
41198
+ serviceProviderId
41199
+ });
41200
+ return data;
41201
+ } catch (error) {
41202
+ throw error;
41203
+ }
41204
+ }
41205
+ async function updateManpowerRemarks(_id, value) {
41206
+ try {
41207
+ _id = new ObjectId110(_id);
41208
+ } catch (error) {
41209
+ throw new BadRequestError180("Invalid ID format.");
41210
+ }
41211
+ try {
41212
+ if (value.createdBy) {
41213
+ value.createdBy = new ObjectId110(value.createdBy);
41214
+ }
41215
+ const updateValue = {
41216
+ ...value,
41217
+ updatedAt: /* @__PURE__ */ new Date()
41218
+ };
41219
+ const res = await collection.updateOne({ _id }, { $set: updateValue });
41220
+ if (res.modifiedCount === 0) {
41221
+ throw new Error("Unable to update remarks.");
41222
+ }
41223
+ return res.modifiedCount;
41224
+ } catch (error) {
41225
+ throw error;
41226
+ }
41227
+ }
41228
+ async function updateRemarksStatus(_id, value) {
41229
+ try {
41230
+ _id = new ObjectId110(_id);
41231
+ } catch (error) {
41232
+ throw new BadRequestError180("Invalid ID format.");
41233
+ }
41234
+ try {
41235
+ const updateValue = {
41236
+ ...value,
41237
+ updatedAt: /* @__PURE__ */ new Date()
41238
+ };
41239
+ const res = await collection.updateOne({ _id }, { $set: updateValue });
41240
+ if (res.modifiedCount === 0) {
41241
+ throw new Error("Unable to update remarks status.");
41242
+ }
41243
+ return res.modifiedCount;
41244
+ } catch (error) {
41245
+ throw error;
41246
+ }
41247
+ }
41248
+ return {
41249
+ createManpowerRemarks,
41250
+ getManpowerRemarksAllSite,
41251
+ getManpowerRemarksBySiteId,
41252
+ updateManpowerRemarks,
41253
+ updateRemarksStatus
41254
+ };
41255
+ }
41256
+
41257
+ // src/services/manpower-monitoring.service.ts
41258
+ import moment3 from "moment-timezone";
40671
41259
  function useManpowerMonitoringSrvc() {
40672
41260
  const {
40673
41261
  createManpowerMonitoringSettings: _createManpowerMonitoringSettings
40674
41262
  } = useManpowerMonitoringRepo();
41263
+ const { createManpowerRemarks: _createManpowerRemarks } = useManpowerRemarksRepo();
40675
41264
  async function createManpowerMonitoringSettings(payload) {
40676
41265
  console.log("Im here now at service");
40677
- const session = useAtlas99.getClient()?.startSession();
41266
+ const session = useAtlas100.getClient()?.startSession();
40678
41267
  if (!session) {
40679
- throw new BadRequestError180("Database session not available.");
41268
+ throw new BadRequestError181("Database session not available.");
40680
41269
  }
40681
41270
  await session.startTransaction();
40682
41271
  const morningCheckInTime = payload?.shifts?.[payload.shiftType][0]?.checkIn;
@@ -40685,10 +41274,10 @@ function useManpowerMonitoringSrvc() {
40685
41274
  const morningAlertFrequencyMins = payload?.shifts?.[payload.shiftType][0]?.alertFrequencyMins;
40686
41275
  const afternoonAlertFrequencyMins = payload.shiftType == "3-shifts" ? payload?.shifts?.[payload.shiftType][1]?.alertFrequencyMins : null;
40687
41276
  const nightAlertFrequencyMins = payload.shiftType == "3-shifts" ? payload?.shifts?.[payload.shiftType][2]?.alertFrequencyMins : payload?.shifts?.[payload.shiftType][1]?.alertFrequencyMins;
40688
- const morningAlertTime = moment.tz(morningCheckInTime, "HH:mm", "Asia/Singapore").add(morningAlertFrequencyMins, "minutes").format("HH:mm");
40689
- const afternoonAlertTime = afternoonCheckInTime ? moment.tz(afternoonCheckInTime, "HH:mm", "Asia/Singapore").add(afternoonAlertFrequencyMins, "minutes").format("HH:mm") : "";
40690
- const nightAlertTime = moment.tz(nightCheckInTime, "HH:mm", "Asia/Singapore").add(nightAlertFrequencyMins, "minutes").format("HH:mm");
40691
- const nowSGT = moment().tz("Asia/Singapore");
41277
+ const morningAlertTime = moment3.tz(morningCheckInTime, "HH:mm", "Asia/Singapore").add(morningAlertFrequencyMins, "minutes").format("HH:mm");
41278
+ const afternoonAlertTime = afternoonCheckInTime ? moment3.tz(afternoonCheckInTime, "HH:mm", "Asia/Singapore").add(afternoonAlertFrequencyMins, "minutes").format("HH:mm") : "";
41279
+ const nightAlertTime = moment3.tz(nightCheckInTime, "HH:mm", "Asia/Singapore").add(nightAlertFrequencyMins, "minutes").format("HH:mm");
41280
+ const nowSGT = moment3().tz("Asia/Singapore");
40692
41281
  console.log("im done preparing the payload");
40693
41282
  try {
40694
41283
  const remarksPayload = {
@@ -40734,13 +41323,19 @@ function useManpowerMonitoringSrvc() {
40734
41323
  updatedAt: "",
40735
41324
  status: "active"
40736
41325
  };
40737
- console.log("im here at remarks payload");
41326
+ const manpowerRemark = await _createManpowerRemarks(
41327
+ remarksPayload,
41328
+ session
41329
+ );
41330
+ if (!manpowerRemark) {
41331
+ throw new Error("Failed to create manpower remarks");
41332
+ }
40738
41333
  const result = await _createManpowerMonitoringSettings(payload, session);
40739
41334
  await session.commitTransaction();
40740
41335
  return result;
40741
41336
  } catch (error) {
40742
41337
  await session.abortTransaction();
40743
- logger158.error(error.message || error);
41338
+ logger159.error(error.message || error);
40744
41339
  console.error("Error creating monitoring settings:", error);
40745
41340
  throw new Error(error?.message || "Internal Server Error!");
40746
41341
  } finally {
@@ -40753,8 +41348,8 @@ function useManpowerMonitoringSrvc() {
40753
41348
  }
40754
41349
 
40755
41350
  // src/controllers/manpower-monitoring.controller.ts
40756
- import { BadRequestError as BadRequestError181, logger as logger159 } from "@7365admin1/node-server-utils";
40757
- import Joi112 from "joi";
41351
+ import { BadRequestError as BadRequestError182, logger as logger160 } from "@7365admin1/node-server-utils";
41352
+ import Joi113 from "joi";
40758
41353
  function useManpowerMonitoringCtrl() {
40759
41354
  const {
40760
41355
  getAllManpowerSettings: _getAllManpowerSettings,
@@ -40771,13 +41366,13 @@ function useManpowerMonitoringCtrl() {
40771
41366
  const payload = { ...req.body };
40772
41367
  const { error } = manpowerMonitoringSchema.validate(payload);
40773
41368
  if (error) {
40774
- next(new BadRequestError181(error.message));
41369
+ next(new BadRequestError182(error.message));
40775
41370
  return;
40776
41371
  }
40777
41372
  const result = await _createManpowerMonitoringSettings(payload);
40778
41373
  return res.json(result);
40779
41374
  } catch (error) {
40780
- logger159.log({ level: "error", message: error.message });
41375
+ logger160.log({ level: "error", message: error.message });
40781
41376
  next(error);
40782
41377
  return;
40783
41378
  }
@@ -40785,14 +41380,14 @@ function useManpowerMonitoringCtrl() {
40785
41380
  async function getAllManpowerSettings(req, res, next) {
40786
41381
  try {
40787
41382
  const { page, search, limit } = req.query;
40788
- const schema2 = Joi112.object({
40789
- page: Joi112.number().optional().allow("", null),
40790
- limit: Joi112.number().optional().allow("", null),
40791
- search: Joi112.string().optional().allow("", null)
41383
+ const schema2 = Joi113.object({
41384
+ page: Joi113.number().optional().allow("", null),
41385
+ limit: Joi113.number().optional().allow("", null),
41386
+ search: Joi113.string().optional().allow("", null)
40792
41387
  });
40793
41388
  const { error } = schema2.validate({ page, search, limit });
40794
41389
  if (error) {
40795
- next(new BadRequestError181(error.message));
41390
+ next(new BadRequestError182(error.message));
40796
41391
  return;
40797
41392
  }
40798
41393
  const result = await _getAllManpowerSettings({
@@ -40802,7 +41397,7 @@ function useManpowerMonitoringCtrl() {
40802
41397
  });
40803
41398
  return res.json(result);
40804
41399
  } catch (error) {
40805
- logger159.log({ level: "error", message: error.message });
41400
+ logger160.log({ level: "error", message: error.message });
40806
41401
  next(error);
40807
41402
  return;
40808
41403
  }
@@ -40811,64 +41406,64 @@ function useManpowerMonitoringCtrl() {
40811
41406
  try {
40812
41407
  const _id = req.params.id;
40813
41408
  const serviceProviderId = req.params.serviceProviderId;
40814
- const schema2 = Joi112.object({
40815
- _id: Joi112.string().hex().required(),
40816
- serviceProviderId: Joi112.string().hex().required()
41409
+ const schema2 = Joi113.object({
41410
+ _id: Joi113.string().hex().required(),
41411
+ serviceProviderId: Joi113.string().hex().required()
40817
41412
  });
40818
41413
  const { error } = schema2.validate({ _id, serviceProviderId });
40819
41414
  if (error) {
40820
- next(new BadRequestError181(error.message));
41415
+ next(new BadRequestError182(error.message));
40821
41416
  return;
40822
41417
  }
40823
41418
  const result = await _getManpowerSettingsBySiteId(_id, serviceProviderId);
40824
41419
  return res.json(result);
40825
41420
  } catch (error) {
40826
- logger159.log({ level: "error", message: error.message });
41421
+ logger160.log({ level: "error", message: error.message });
40827
41422
  next(error);
40828
41423
  return;
40829
41424
  }
40830
41425
  }
40831
41426
  async function updateManpowerMonitoringSettings(req, res, next) {
40832
41427
  try {
40833
- const validation = Joi112.object({
40834
- _id: Joi112.string().hex().required(),
40835
- shiftType: Joi112.string().optional().allow("", null),
40836
- enabled: Joi112.boolean().required(),
40837
- shifts: Joi112.object({
40838
- "2-shifts": Joi112.array().items(shiftSchema).optional(),
40839
- "3-shifts": Joi112.array().items(shiftSchema).optional()
41428
+ const validation = Joi113.object({
41429
+ _id: Joi113.string().hex().required(),
41430
+ shiftType: Joi113.string().optional().allow("", null),
41431
+ enabled: Joi113.boolean().required(),
41432
+ shifts: Joi113.object({
41433
+ "2-shifts": Joi113.array().items(shiftSchema).optional(),
41434
+ "3-shifts": Joi113.array().items(shiftSchema).optional()
40840
41435
  }).optional(),
40841
- emails: Joi112.array().items(Joi112.string().email()).optional()
41436
+ emails: Joi113.array().items(Joi113.string().email()).optional()
40842
41437
  });
40843
41438
  const _id = req.params.id;
40844
41439
  const payload = { ...req.body };
40845
41440
  console.log("_id", _id);
40846
41441
  const { error } = validation.validate({ _id, ...payload });
40847
41442
  if (error) {
40848
- next(new BadRequestError181(error.message));
41443
+ next(new BadRequestError182(error.message));
40849
41444
  return;
40850
41445
  }
40851
41446
  const result = await _updateManpowerMonitoringSettings(_id, payload);
40852
41447
  return res.json(result);
40853
41448
  } catch (error) {
40854
- logger159.log({ level: "error", message: error.message });
41449
+ logger160.log({ level: "error", message: error.message });
40855
41450
  next(error);
40856
41451
  return;
40857
41452
  }
40858
41453
  }
40859
41454
  async function multipleManpowerMonitoringSettings(req, res, next) {
40860
41455
  try {
40861
- const validation = Joi112.array().items(manpowerMonitoringSchema);
41456
+ const validation = Joi113.array().items(manpowerMonitoringSchema);
40862
41457
  const payload = req.body;
40863
41458
  const { error } = validation.validate(payload);
40864
41459
  if (error) {
40865
- next(new BadRequestError181(error.message));
41460
+ next(new BadRequestError182(error.message));
40866
41461
  return;
40867
41462
  }
40868
41463
  const result = await _multipleManpowerMonitoringSettings(payload);
40869
41464
  return res.json(result);
40870
41465
  } catch (error) {
40871
- logger159.log({ level: "error", message: error.message });
41466
+ logger160.log({ level: "error", message: error.message });
40872
41467
  next(error);
40873
41468
  return;
40874
41469
  }
@@ -40876,18 +41471,18 @@ function useManpowerMonitoringCtrl() {
40876
41471
  async function getAllSites(req, res, next) {
40877
41472
  try {
40878
41473
  const serviceProviderId = req.query.serviceProviderId;
40879
- const validation = Joi112.object({
40880
- serviceProviderId: Joi112.string().hex().required()
41474
+ const validation = Joi113.object({
41475
+ serviceProviderId: Joi113.string().hex().required()
40881
41476
  });
40882
41477
  const { error } = validation.validate({ serviceProviderId });
40883
41478
  if (error) {
40884
- next(new BadRequestError181(error.message));
41479
+ next(new BadRequestError182(error.message));
40885
41480
  return;
40886
41481
  }
40887
41482
  const result = await _getAllSites(serviceProviderId);
40888
41483
  return res.json(result);
40889
41484
  } catch (error) {
40890
- logger159.log({ level: "error", message: error.message });
41485
+ logger160.log({ level: "error", message: error.message });
40891
41486
  next(error);
40892
41487
  return;
40893
41488
  }
@@ -40903,27 +41498,27 @@ function useManpowerMonitoringCtrl() {
40903
41498
  }
40904
41499
 
40905
41500
  // src/models/manpower-designations.model.ts
40906
- import Joi113 from "joi";
40907
- import { ObjectId as ObjectId109 } from "mongodb";
40908
- var designationsSchema = Joi113.object({
40909
- title: Joi113.string().required(),
40910
- shifts: Joi113.object({
40911
- morningShift: Joi113.number().required(),
40912
- afternoonShift: Joi113.number().optional(),
40913
- nightShift: Joi113.number().required()
41501
+ import Joi114 from "joi";
41502
+ import { ObjectId as ObjectId111 } from "mongodb";
41503
+ var designationsSchema = Joi114.object({
41504
+ title: Joi114.string().required(),
41505
+ shifts: Joi114.object({
41506
+ morningShift: Joi114.number().required(),
41507
+ afternoonShift: Joi114.number().optional(),
41508
+ nightShift: Joi114.number().required()
40914
41509
  }).required()
40915
41510
  });
40916
- var manpowerDesignationsSchema = Joi113.object({
40917
- siteId: Joi113.string().hex().required(),
40918
- siteName: Joi113.string().required(),
40919
- serviceProviderId: Joi113.string().hex().optional(),
40920
- designations: Joi113.array().items(designationsSchema).required(),
40921
- createdBy: Joi113.string().hex().required(),
40922
- createdByName: Joi113.string().optional().allow("", null)
41511
+ var manpowerDesignationsSchema = Joi114.object({
41512
+ siteId: Joi114.string().hex().required(),
41513
+ siteName: Joi114.string().required(),
41514
+ serviceProviderId: Joi114.string().hex().optional(),
41515
+ designations: Joi114.array().items(designationsSchema).required(),
41516
+ createdBy: Joi114.string().hex().required(),
41517
+ createdByName: Joi114.string().optional().allow("", null)
40923
41518
  });
40924
41519
  var MManpowerDesignations = class {
40925
41520
  constructor(data) {
40926
- this._id = new ObjectId109();
41521
+ this._id = new ObjectId111();
40927
41522
  this.siteId = data.siteId || "";
40928
41523
  this.siteName = data.siteName || "";
40929
41524
  this.serviceProviderId = data.serviceProviderId || "";
@@ -40937,11 +41532,11 @@ var MManpowerDesignations = class {
40937
41532
 
40938
41533
  // src/repositories/manpower-designations.repo.ts
40939
41534
  import {
40940
- useAtlas as useAtlas100
41535
+ useAtlas as useAtlas101
40941
41536
  } from "@7365admin1/node-server-utils";
40942
- import { ObjectId as ObjectId110 } from "mongodb";
41537
+ import { ObjectId as ObjectId112 } from "mongodb";
40943
41538
  function useManpowerDesignationRepo() {
40944
- const db = useAtlas100.getDb();
41539
+ const db = useAtlas101.getDb();
40945
41540
  if (!db) {
40946
41541
  throw new Error("Unable to connect to server.");
40947
41542
  }
@@ -40951,11 +41546,11 @@ function useManpowerDesignationRepo() {
40951
41546
  try {
40952
41547
  value = new MManpowerDesignations(value);
40953
41548
  if (value.createdBy)
40954
- value.createdBy = new ObjectId110(value.createdBy);
41549
+ value.createdBy = new ObjectId112(value.createdBy);
40955
41550
  if (value.siteId)
40956
- value.siteId = new ObjectId110(value.siteId);
41551
+ value.siteId = new ObjectId112(value.siteId);
40957
41552
  if (value.serviceProviderId)
40958
- value.serviceProviderId = new ObjectId110(value.serviceProviderId);
41553
+ value.serviceProviderId = new ObjectId112(value.serviceProviderId);
40959
41554
  const result = await collection.insertOne(value);
40960
41555
  return result;
40961
41556
  } catch (error) {
@@ -40964,8 +41559,8 @@ function useManpowerDesignationRepo() {
40964
41559
  }
40965
41560
  async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
40966
41561
  try {
40967
- _id = new ObjectId110(_id);
40968
- serviceProviderId = new ObjectId110(serviceProviderId);
41562
+ _id = new ObjectId112(_id);
41563
+ serviceProviderId = new ObjectId112(serviceProviderId);
40969
41564
  } catch (error) {
40970
41565
  throw new Error("Invalid Site ID format.");
40971
41566
  }
@@ -40981,7 +41576,7 @@ function useManpowerDesignationRepo() {
40981
41576
  }
40982
41577
  async function updateManpowerDesignations(_id, value) {
40983
41578
  try {
40984
- _id = new ObjectId110(_id);
41579
+ _id = new ObjectId112(_id);
40985
41580
  } catch (error) {
40986
41581
  throw new Error("Invalid ID format.");
40987
41582
  }
@@ -41007,8 +41602,8 @@ function useManpowerDesignationRepo() {
41007
41602
  }
41008
41603
 
41009
41604
  // src/controllers/manpower-designations.controller.ts
41010
- import { BadRequestError as BadRequestError183, logger as logger161 } from "@7365admin1/node-server-utils";
41011
- import Joi114 from "joi";
41605
+ import { BadRequestError as BadRequestError184, logger as logger162 } from "@7365admin1/node-server-utils";
41606
+ import Joi115 from "joi";
41012
41607
  function useManpowerDesignationCtrl() {
41013
41608
  const {
41014
41609
  createManpowerDesignations: _createManpowerDesignations,
@@ -41020,13 +41615,13 @@ function useManpowerDesignationCtrl() {
41020
41615
  const payload = { ...req.body };
41021
41616
  const { error } = manpowerDesignationsSchema.validate(payload);
41022
41617
  if (error) {
41023
- next(new BadRequestError183(error.message));
41618
+ next(new BadRequestError184(error.message));
41024
41619
  return;
41025
41620
  }
41026
41621
  const result = await _createManpowerDesignations(payload);
41027
41622
  return res.json(result);
41028
41623
  } catch (error) {
41029
- logger161.log({ level: "error", message: error.message });
41624
+ logger162.log({ level: "error", message: error.message });
41030
41625
  next(error);
41031
41626
  return;
41032
41627
  }
@@ -41034,13 +41629,13 @@ function useManpowerDesignationCtrl() {
41034
41629
  async function getManpowerSettingsBySiteId(req, res, next) {
41035
41630
  try {
41036
41631
  const { id, serviceProviderId } = req.params;
41037
- const schema2 = Joi114.object({
41038
- id: Joi114.string().hex().required(),
41039
- serviceProviderId: Joi114.string().hex().required()
41632
+ const schema2 = Joi115.object({
41633
+ id: Joi115.string().hex().required(),
41634
+ serviceProviderId: Joi115.string().hex().required()
41040
41635
  });
41041
41636
  const { error } = schema2.validate({ id, serviceProviderId });
41042
41637
  if (error) {
41043
- next(new BadRequestError183(error.message));
41638
+ next(new BadRequestError184(error.message));
41044
41639
  return;
41045
41640
  }
41046
41641
  const result = await _getManpowerDesignationsBySiteId(
@@ -41049,28 +41644,28 @@ function useManpowerDesignationCtrl() {
41049
41644
  );
41050
41645
  return res.json(result);
41051
41646
  } catch (error) {
41052
- logger161.log({ level: "error", message: error.message });
41647
+ logger162.log({ level: "error", message: error.message });
41053
41648
  next(error);
41054
41649
  return;
41055
41650
  }
41056
41651
  }
41057
41652
  async function updateManpowerDesignations(req, res, next) {
41058
41653
  try {
41059
- const validation = Joi114.object({
41060
- _id: Joi114.string().hex().required(),
41061
- designations: Joi114.array().items(designationsSchema).required()
41654
+ const validation = Joi115.object({
41655
+ _id: Joi115.string().hex().required(),
41656
+ designations: Joi115.array().items(designationsSchema).required()
41062
41657
  });
41063
41658
  const _id = req.params.id;
41064
41659
  const payload = { ...req.body };
41065
41660
  const { error } = validation.validate({ _id, ...payload });
41066
41661
  if (error) {
41067
- next(new BadRequestError183(error.message));
41662
+ next(new BadRequestError184(error.message));
41068
41663
  return;
41069
41664
  }
41070
41665
  const result = await _updateManpowerDesignations(_id, payload);
41071
41666
  return res.json(result);
41072
41667
  } catch (error) {
41073
- logger161.log({ level: "error", message: error.message });
41668
+ logger162.log({ level: "error", message: error.message });
41074
41669
  next(error);
41075
41670
  return;
41076
41671
  }
@@ -41083,20 +41678,30 @@ function useManpowerDesignationCtrl() {
41083
41678
  }
41084
41679
 
41085
41680
  // src/models/overnight-parking.model.ts
41086
- import Joi115 from "joi";
41087
- import { ObjectId as ObjectId111 } from "mongodb";
41088
- var dayScheduleSchema = Joi115.object({
41089
- isEnabled: Joi115.boolean().required(),
41090
- startTime: Joi115.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).required().messages({
41681
+ import Joi116 from "joi";
41682
+ import { ObjectId as ObjectId113 } from "mongodb";
41683
+ var dayScheduleSchema = Joi116.object({
41684
+ isEnabled: Joi116.boolean().required(),
41685
+ startTime: Joi116.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
41091
41686
  "string.pattern.base": "startTime must be in HH:mm format"
41092
41687
  }),
41093
- endTime: Joi115.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).required().messages({
41688
+ endTime: Joi116.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
41094
41689
  "string.pattern.base": "endTime must be in HH:mm format"
41095
41690
  })
41096
- }).required();
41097
- var schemaOvernightParkingApprovalHours = Joi115.object({
41098
- _id: Joi115.string().hex().length(24).optional(),
41099
- site: Joi115.string().hex().length(24).required(),
41691
+ }).optional().allow(null);
41692
+ var DayOfWeek = /* @__PURE__ */ ((DayOfWeek2) => {
41693
+ DayOfWeek2["SUNDAY"] = "sunday";
41694
+ DayOfWeek2["MONDAY"] = "monday";
41695
+ DayOfWeek2["TUESDAY"] = "tuesday";
41696
+ DayOfWeek2["WEDNESDAY"] = "wednesday";
41697
+ DayOfWeek2["THURSDAY"] = "thursday";
41698
+ DayOfWeek2["FRIDAY"] = "friday";
41699
+ DayOfWeek2["SATURDAY"] = "saturday";
41700
+ return DayOfWeek2;
41701
+ })(DayOfWeek || {});
41702
+ var schemaOvernightParkingApprovalHours = Joi116.object({
41703
+ _id: Joi116.string().hex().length(24).optional(),
41704
+ site: Joi116.string().hex().length(24).required(),
41100
41705
  monday: dayScheduleSchema,
41101
41706
  tuesday: dayScheduleSchema,
41102
41707
  wednesday: dayScheduleSchema,
@@ -41104,9 +41709,10 @@ var schemaOvernightParkingApprovalHours = Joi115.object({
41104
41709
  friday: dayScheduleSchema,
41105
41710
  saturday: dayScheduleSchema,
41106
41711
  sunday: dayScheduleSchema,
41107
- createdAt: Joi115.date().optional(),
41108
- updatedAt: Joi115.date().optional(),
41109
- deletedAt: Joi115.date().optional().allow(null)
41712
+ autoApproveOvernightParking: Joi116.boolean().optional().allow(null).default(false),
41713
+ createdAt: Joi116.date().optional(),
41714
+ updatedAt: Joi116.date().optional(),
41715
+ deletedAt: Joi116.date().optional().allow(null)
41110
41716
  });
41111
41717
  function MOvernightParkingApprovalHours(value) {
41112
41718
  const { error } = schemaOvernightParkingApprovalHours.validate(value);
@@ -41115,14 +41721,22 @@ function MOvernightParkingApprovalHours(value) {
41115
41721
  }
41116
41722
  if (value.site && typeof value.site === "string") {
41117
41723
  try {
41118
- value.site = new ObjectId111(value.site);
41724
+ value.site = new ObjectId113(value.site);
41119
41725
  } catch {
41120
41726
  throw new Error("Invalid site ID.");
41121
41727
  }
41122
41728
  }
41123
41729
  const now = (/* @__PURE__ */ new Date()).toISOString();
41124
41730
  return {
41125
- ...value,
41731
+ site: value.site,
41732
+ monday: value.monday ?? null,
41733
+ tuesday: value.tuesday ?? null,
41734
+ wednesday: value.wednesday ?? null,
41735
+ thursday: value.thursday ?? null,
41736
+ friday: value.friday ?? null,
41737
+ saturday: value.saturday ?? null,
41738
+ sunday: value.sunday ?? null,
41739
+ autoApproveOvernightParking: value.autoApproveOvernightParking ?? false,
41126
41740
  createdAt: value.createdAt ?? now,
41127
41741
  updatedAt: value.updatedAt ?? now
41128
41742
  };
@@ -41130,21 +41744,21 @@ function MOvernightParkingApprovalHours(value) {
41130
41744
 
41131
41745
  // src/repositories/overnight-parking.repo.ts
41132
41746
  import {
41133
- InternalServerError as InternalServerError63,
41134
- logger as logger162,
41135
- makeCacheKey as makeCacheKey60,
41747
+ InternalServerError as InternalServerError64,
41748
+ logger as logger163,
41749
+ makeCacheKey as makeCacheKey61,
41136
41750
  toObjectId as toObjectId9,
41137
- useAtlas as useAtlas101,
41138
- useCache as useCache62
41751
+ useAtlas as useAtlas102,
41752
+ useCache as useCache63
41139
41753
  } from "@7365admin1/node-server-utils";
41140
41754
  var overnight_parking_namespace_collection = "site.overnight-parking";
41141
41755
  function useOvernightParkingRepo() {
41142
- const db = useAtlas101.getDb();
41756
+ const db = useAtlas102.getDb();
41143
41757
  if (!db) {
41144
- throw new InternalServerError63("Unable to connect to server.");
41758
+ throw new InternalServerError64("Unable to connect to server.");
41145
41759
  }
41146
41760
  const collection = db.collection(overnight_parking_namespace_collection);
41147
- const { delNamespace, setCache, getCache } = useCache62(
41761
+ const { delNamespace, setCache, getCache } = useCache63(
41148
41762
  overnight_parking_namespace_collection
41149
41763
  );
41150
41764
  async function createIndexes() {
@@ -41168,7 +41782,7 @@ function useOvernightParkingRepo() {
41168
41782
  await collection.createIndexes(indexesToCreate);
41169
41783
  }
41170
41784
  } catch (error) {
41171
- throw new InternalServerError63("Failed to create collection indexes.");
41785
+ throw new InternalServerError64("Failed to create collection indexes.");
41172
41786
  }
41173
41787
  }
41174
41788
  async function upsert(value, session) {
@@ -41186,6 +41800,7 @@ function useOvernightParkingRepo() {
41186
41800
  friday: value.friday,
41187
41801
  saturday: value.saturday,
41188
41802
  sunday: value.sunday,
41803
+ autoApproveOvernightParking: value.autoApproveOvernightParking,
41189
41804
  updatedAt: now
41190
41805
  },
41191
41806
  $setOnInsert: {
@@ -41196,11 +41811,11 @@ function useOvernightParkingRepo() {
41196
41811
  { upsert: true, session }
41197
41812
  );
41198
41813
  delNamespace().then(() => {
41199
- logger162.info(
41814
+ logger163.info(
41200
41815
  `Cache cleared for namespace: ${overnight_parking_namespace_collection}`
41201
41816
  );
41202
41817
  }).catch((err) => {
41203
- logger162.error(
41818
+ logger163.error(
41204
41819
  `Failed to clear cache for namespace: ${overnight_parking_namespace_collection}`,
41205
41820
  err
41206
41821
  );
@@ -41212,12 +41827,12 @@ function useOvernightParkingRepo() {
41212
41827
  }
41213
41828
  async function getSiteOvernightParking(site) {
41214
41829
  const siteId = toObjectId9(site);
41215
- const cacheKey = makeCacheKey60(overnight_parking_namespace_collection, {
41830
+ const cacheKey = makeCacheKey61(overnight_parking_namespace_collection, {
41216
41831
  site
41217
41832
  });
41218
41833
  const cachedData = await getCache(cacheKey);
41219
41834
  if (cachedData) {
41220
- logger162.info(`Cache hit for key: ${cacheKey}`);
41835
+ logger163.info(`Cache hit for key: ${cacheKey}`);
41221
41836
  return cachedData;
41222
41837
  }
41223
41838
  try {
@@ -41226,9 +41841,9 @@ function useOvernightParkingRepo() {
41226
41841
  deletedAt: null
41227
41842
  });
41228
41843
  setCache(cacheKey, data, 15 * 60).then(() => {
41229
- logger162.info(`Cache set for key: ${cacheKey}`);
41844
+ logger163.info(`Cache set for key: ${cacheKey}`);
41230
41845
  }).catch((err) => {
41231
- logger162.error(`Failed to set cache for key: ${cacheKey}`, err);
41846
+ logger163.error(`Failed to set cache for key: ${cacheKey}`, err);
41232
41847
  });
41233
41848
  return data;
41234
41849
  } catch (error) {
@@ -41243,8 +41858,8 @@ function useOvernightParkingRepo() {
41243
41858
  }
41244
41859
 
41245
41860
  // src/controllers/overnight-parking.controller.ts
41246
- import Joi116 from "joi";
41247
- import { BadRequestError as BadRequestError185, logger as logger163 } from "@7365admin1/node-server-utils";
41861
+ import Joi117 from "joi";
41862
+ import { BadRequestError as BadRequestError186, logger as logger164 } from "@7365admin1/node-server-utils";
41248
41863
  function useOvernightParkingController() {
41249
41864
  const { upsert: _upsert, getSiteOvernightParking: _getSiteOvernightParking } = useOvernightParkingRepo();
41250
41865
  async function upsert(req, res, next) {
@@ -41259,22 +41874,22 @@ function useOvernightParkingController() {
41259
41874
  );
41260
41875
  if (error) {
41261
41876
  const messages = error.details.map((d) => d.message).join(", ");
41262
- logger163.log({ level: "error", message: messages });
41263
- next(new BadRequestError185(messages));
41877
+ logger164.log({ level: "error", message: messages });
41878
+ next(new BadRequestError186(messages));
41264
41879
  return;
41265
41880
  }
41266
41881
  const data = await _upsert(value);
41267
41882
  res.status(201).json(data);
41268
41883
  return;
41269
41884
  } catch (error) {
41270
- logger163.log({ level: "error", message: error.message });
41885
+ logger164.log({ level: "error", message: error.message });
41271
41886
  next(error);
41272
41887
  return;
41273
41888
  }
41274
41889
  }
41275
41890
  async function getSiteOvernightParking(req, res, next) {
41276
- const schema2 = Joi116.object({
41277
- site: Joi116.string().hex().length(24).required()
41891
+ const schema2 = Joi117.object({
41892
+ site: Joi117.string().hex().length(24).required()
41278
41893
  });
41279
41894
  try {
41280
41895
  const { error, value } = schema2.validate(
@@ -41285,8 +41900,8 @@ function useOvernightParkingController() {
41285
41900
  );
41286
41901
  if (error) {
41287
41902
  const messages = error.details.map((d) => d.message).join(", ");
41288
- logger163.log({ level: "error", message: messages });
41289
- next(new BadRequestError185(messages));
41903
+ logger164.log({ level: "error", message: messages });
41904
+ next(new BadRequestError186(messages));
41290
41905
  return;
41291
41906
  }
41292
41907
  const { site } = value;
@@ -41294,7 +41909,7 @@ function useOvernightParkingController() {
41294
41909
  res.status(201).json(data);
41295
41910
  return;
41296
41911
  } catch (error) {
41297
- logger163.log({ level: "error", message: error.message });
41912
+ logger164.log({ level: "error", message: error.message });
41298
41913
  next(error);
41299
41914
  return;
41300
41915
  }
@@ -41304,6 +41919,1404 @@ function useOvernightParkingController() {
41304
41919
  getSiteOvernightParking
41305
41920
  };
41306
41921
  }
41922
+
41923
+ // src/models/overnight-parking-request.model.ts
41924
+ import Joi118 from "joi";
41925
+ import { toObjectId as toObjectId10 } from "@7365admin1/node-server-utils";
41926
+ var OvernightParkingRequestStatus = /* @__PURE__ */ ((OvernightParkingRequestStatus2) => {
41927
+ OvernightParkingRequestStatus2["PENDING"] = "pending";
41928
+ OvernightParkingRequestStatus2["APPROVED"] = "approved";
41929
+ OvernightParkingRequestStatus2["REJECTED"] = "rejected";
41930
+ OvernightParkingRequestStatus2["DELETED"] = "deleted";
41931
+ OvernightParkingRequestStatus2["EXPIRED"] = "expired";
41932
+ return OvernightParkingRequestStatus2;
41933
+ })(OvernightParkingRequestStatus || {});
41934
+ var OvernightParkingRequestSort = /* @__PURE__ */ ((OvernightParkingRequestSort2) => {
41935
+ OvernightParkingRequestSort2["ID"] = "_id";
41936
+ OvernightParkingRequestSort2["CREATED_AT"] = "createdAt";
41937
+ return OvernightParkingRequestSort2;
41938
+ })(OvernightParkingRequestSort || {});
41939
+ var schemaOvernightParkingRequest = Joi118.object({
41940
+ _id: Joi118.string().hex().length(24).optional(),
41941
+ site: Joi118.string().hex().length(24).required(),
41942
+ name: Joi118.string().required(),
41943
+ contact: Joi118.string().required(),
41944
+ email: Joi118.string().email().required(),
41945
+ isOvernightParking: Joi118.boolean().optional(),
41946
+ numberOfPassengers: Joi118.number().integer().min(0).optional().default(0),
41947
+ purposeOfVisit: Joi118.string().optional().allow("", null),
41948
+ status: Joi118.string().valid(...Object.values(OvernightParkingRequestStatus)).optional().allow(null, "").default("pending" /* PENDING */),
41949
+ comment: Joi118.string().optional().allow(null, "")
41950
+ });
41951
+ var schemaUpdateOvernightParkingRequest = Joi118.object({
41952
+ _id: Joi118.string().hex().length(24).required(),
41953
+ status: Joi118.string().valid(...Object.values(OvernightParkingRequestStatus)).required(),
41954
+ comment: Joi118.string().optional().allow(null, "")
41955
+ });
41956
+ function MOvernightParkingRequest(value) {
41957
+ const { error } = schemaOvernightParkingRequest.validate(value);
41958
+ if (error) {
41959
+ throw new Error(error.details[0].message);
41960
+ }
41961
+ if (value.site && typeof value.site === "string")
41962
+ value.site = toObjectId10(value.site);
41963
+ const data = {
41964
+ ...value,
41965
+ createdAt: value.createdAt ? new Date(value.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
41966
+ updatedAt: value.updatedAt,
41967
+ deletedAt: value.deletedAt
41968
+ };
41969
+ return data;
41970
+ }
41971
+
41972
+ // src/repositories/overnight-parking-request.repository.ts
41973
+ import {
41974
+ BadRequestError as BadRequestError187,
41975
+ InternalServerError as InternalServerError65,
41976
+ logger as logger165,
41977
+ makeCacheKey as makeCacheKey62,
41978
+ paginate as paginate54,
41979
+ toObjectId as toObjectId11,
41980
+ useAtlas as useAtlas103,
41981
+ useCache as useCache64
41982
+ } from "@7365admin1/node-server-utils";
41983
+ var overnight_parking_requests_namespace_collection = "site.overnight-parking-requests";
41984
+ function useOvernightParkingRequestRepo() {
41985
+ const db = useAtlas103.getDb();
41986
+ if (!db) {
41987
+ throw new InternalServerError65("Unable to connect to server.");
41988
+ }
41989
+ const collection = db.collection(
41990
+ overnight_parking_requests_namespace_collection
41991
+ );
41992
+ const { delNamespace, getCache, setCache } = useCache64(
41993
+ overnight_parking_requests_namespace_collection
41994
+ );
41995
+ async function add(value, session) {
41996
+ try {
41997
+ value = MOvernightParkingRequest(value);
41998
+ const res = await collection.insertOne(value, { session });
41999
+ delNamespace().then(() => {
42000
+ logger165.info(
42001
+ `Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
42002
+ );
42003
+ }).catch((err) => {
42004
+ logger165.error(
42005
+ `Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
42006
+ err
42007
+ );
42008
+ });
42009
+ return res.insertedId;
42010
+ } catch (error) {
42011
+ throw error;
42012
+ }
42013
+ }
42014
+ async function getAll({
42015
+ site = "",
42016
+ page = 1,
42017
+ limit = 10,
42018
+ sort = {},
42019
+ status = ""
42020
+ }) {
42021
+ page = page ? page - 1 : 0;
42022
+ const skip = page * limit;
42023
+ const siteId = toObjectId11(site);
42024
+ const query = {
42025
+ site: siteId,
42026
+ ...status && { status }
42027
+ };
42028
+ const cacheOptions = {
42029
+ site,
42030
+ page,
42031
+ limit,
42032
+ sort: JSON.stringify(sort),
42033
+ ...status && { status }
42034
+ };
42035
+ const cacheKey = makeCacheKey62(
42036
+ overnight_parking_requests_namespace_collection,
42037
+ cacheOptions
42038
+ );
42039
+ const cachedData = await getCache(cacheKey);
42040
+ if (cachedData) {
42041
+ logger165.info(`Cache hit for key: ${cacheKey}`);
42042
+ return cachedData;
42043
+ }
42044
+ try {
42045
+ const items = await collection.aggregate([
42046
+ { $match: query },
42047
+ { $sort: sort },
42048
+ { $skip: skip },
42049
+ { $limit: limit }
42050
+ ]).toArray();
42051
+ const length = await collection.countDocuments(query);
42052
+ const data = paginate54(items, page, limit, length);
42053
+ setCache(cacheKey, data, 15 * 60).then(() => {
42054
+ logger165.info(`Cache set for key: ${cacheKey}`);
42055
+ }).catch((err) => {
42056
+ logger165.error(`Failed to set cache for key: ${cacheKey}`, err);
42057
+ });
42058
+ return data;
42059
+ } catch (error) {
42060
+ throw error;
42061
+ }
42062
+ }
42063
+ async function getOvernightParkingRequestById(id) {
42064
+ try {
42065
+ const cacheKey = makeCacheKey62(
42066
+ overnight_parking_requests_namespace_collection,
42067
+ { id }
42068
+ );
42069
+ const cachedData = await getCache(cacheKey);
42070
+ if (cachedData) {
42071
+ logger165.info(`Cache hit for key: ${cacheKey}`);
42072
+ return cachedData;
42073
+ }
42074
+ const _id = toObjectId11(id);
42075
+ const data = await collection.findOne({ _id });
42076
+ if (!data)
42077
+ throw new BadRequestError187("Overnight parking request not found.");
42078
+ setCache(cacheKey, data, 15 * 60).then(() => {
42079
+ logger165.info(`Cache set for key: ${cacheKey}`);
42080
+ }).catch((err) => {
42081
+ logger165.error(`Failed to set cache for key: ${cacheKey}`, err);
42082
+ });
42083
+ return data;
42084
+ } catch (error) {
42085
+ throw error;
42086
+ }
42087
+ }
42088
+ async function updateOvernightParkingRequestById(id, value, session) {
42089
+ try {
42090
+ const _id = toObjectId11(id);
42091
+ value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42092
+ const data = await collection.updateOne(
42093
+ { _id },
42094
+ { $set: value },
42095
+ { session }
42096
+ );
42097
+ if (data.matchedCount === 0)
42098
+ throw new BadRequestError187("Overnight parking request not found.");
42099
+ delNamespace().then(() => {
42100
+ logger165.info(
42101
+ `Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
42102
+ );
42103
+ }).catch((err) => {
42104
+ logger165.error(
42105
+ `Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
42106
+ err
42107
+ );
42108
+ });
42109
+ return data;
42110
+ } catch (error) {
42111
+ throw error;
42112
+ }
42113
+ }
42114
+ async function deleteOvernightParkingRequestById(id, session) {
42115
+ try {
42116
+ const _id = toObjectId11(id);
42117
+ const value = {
42118
+ deletedAt: (/* @__PURE__ */ new Date()).toISOString(),
42119
+ status: "deleted" /* DELETED */
42120
+ };
42121
+ const data = await collection.updateOne(
42122
+ { _id },
42123
+ { $set: value },
42124
+ { session }
42125
+ );
42126
+ if (data.matchedCount === 0)
42127
+ throw new BadRequestError187("Overnight parking request not found.");
42128
+ delNamespace().then(() => {
42129
+ logger165.info(
42130
+ `Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
42131
+ );
42132
+ }).catch((err) => {
42133
+ logger165.error(
42134
+ `Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
42135
+ err
42136
+ );
42137
+ });
42138
+ return data;
42139
+ } catch (error) {
42140
+ throw error;
42141
+ }
42142
+ }
42143
+ async function updateExpiredRequests(site, session) {
42144
+ try {
42145
+ const _site = toObjectId11(site);
42146
+ const value = {
42147
+ status: "expired" /* EXPIRED */
42148
+ };
42149
+ const now = (/* @__PURE__ */ new Date()).toISOString();
42150
+ const data = await collection.updateMany(
42151
+ {
42152
+ site: _site,
42153
+ createdAt: { $lte: now },
42154
+ status: "pending" /* PENDING */
42155
+ },
42156
+ { $set: value },
42157
+ { session }
42158
+ );
42159
+ delNamespace().then(() => {
42160
+ logger165.info(
42161
+ `Cache cleared for namespace: ${overnight_parking_requests_namespace_collection}`
42162
+ );
42163
+ }).catch((err) => {
42164
+ logger165.error(
42165
+ `Failed to clear cache for namespace: ${overnight_parking_requests_namespace_collection}`,
42166
+ err
42167
+ );
42168
+ });
42169
+ return data;
42170
+ } catch (error) {
42171
+ throw error;
42172
+ }
42173
+ }
42174
+ return {
42175
+ add,
42176
+ getAll,
42177
+ getOvernightParkingRequestById,
42178
+ updateOvernightParkingRequestById,
42179
+ deleteOvernightParkingRequestById,
42180
+ updateExpiredRequests
42181
+ };
42182
+ }
42183
+
42184
+ // src/services/overnight-parking-request.service.ts
42185
+ import {
42186
+ logger as logger166,
42187
+ useAtlas as useAtlas104
42188
+ } from "@7365admin1/node-server-utils";
42189
+ function getDayKey(date = /* @__PURE__ */ new Date()) {
42190
+ const days = [
42191
+ "sunday" /* SUNDAY */,
42192
+ "monday" /* MONDAY */,
42193
+ "tuesday" /* TUESDAY */,
42194
+ "wednesday" /* WEDNESDAY */,
42195
+ "thursday" /* THURSDAY */,
42196
+ "friday" /* FRIDAY */,
42197
+ "saturday" /* SATURDAY */
42198
+ ];
42199
+ return days[date.getDay()];
42200
+ }
42201
+ function timeToMinutes(time) {
42202
+ const [hours, minutes] = time.split(":").map(Number);
42203
+ return hours * 60 + minutes;
42204
+ }
42205
+ function isCurrentTimeWithinRange(startTime, endTime, now = /* @__PURE__ */ new Date()) {
42206
+ const currentMinutes = now.getHours() * 60 + now.getMinutes();
42207
+ const startMinutes = timeToMinutes(startTime);
42208
+ const endMinutes = timeToMinutes(endTime);
42209
+ if (startMinutes <= endMinutes) {
42210
+ return currentMinutes >= startMinutes && currentMinutes <= endMinutes;
42211
+ }
42212
+ return currentMinutes >= startMinutes || currentMinutes <= endMinutes;
42213
+ }
42214
+ function shouldAutoApprove(overnightParking, now = /* @__PURE__ */ new Date()) {
42215
+ if (!overnightParking)
42216
+ return false;
42217
+ if (overnightParking.autoApproveOvernightParking !== true) {
42218
+ return false;
42219
+ }
42220
+ const dayKey = getDayKey(now);
42221
+ const daySchedule = overnightParking[dayKey];
42222
+ if (!daySchedule)
42223
+ return false;
42224
+ if (daySchedule.isEnabled !== true)
42225
+ return false;
42226
+ if (!daySchedule.startTime || !daySchedule.endTime)
42227
+ return false;
42228
+ return isCurrentTimeWithinRange(
42229
+ daySchedule.startTime,
42230
+ daySchedule.endTime,
42231
+ now
42232
+ );
42233
+ }
42234
+ function useOvernightParkingRequestService() {
42235
+ const {
42236
+ add: _add,
42237
+ updateOvernightParkingRequestById: _updateOvernightParkingRequestById,
42238
+ deleteOvernightParkingRequestById: _deleteOvernightParkingRequestById,
42239
+ updateExpiredRequests: _updateExpiredRequests
42240
+ } = useOvernightParkingRequestRepo();
42241
+ const { getAllSitesUnpaginated: _getAllSitesUnpaginated } = useSiteRepo();
42242
+ const { getSiteOvernightParking: _getSiteOvernightParking } = useOvernightParkingRepo();
42243
+ async function add(value) {
42244
+ const session = useAtlas104.getClient()?.startSession();
42245
+ try {
42246
+ session?.startTransaction();
42247
+ const overnightParking = await _getSiteOvernightParking(value.site);
42248
+ const payload = {
42249
+ ...value,
42250
+ status: shouldAutoApprove(overnightParking) ? "approved" /* APPROVED */ : "pending" /* PENDING */
42251
+ };
42252
+ const result = await _add(payload, session);
42253
+ await session?.commitTransaction();
42254
+ return result;
42255
+ } catch (error) {
42256
+ await session?.abortTransaction();
42257
+ throw error;
42258
+ } finally {
42259
+ session?.endSession();
42260
+ }
42261
+ }
42262
+ async function updateOvernightParkingRequestById(id, value) {
42263
+ const session = useAtlas104.getClient()?.startSession();
42264
+ try {
42265
+ session?.startTransaction();
42266
+ const result = await _updateOvernightParkingRequestById(id, value);
42267
+ await session?.commitTransaction();
42268
+ return result;
42269
+ } catch (error) {
42270
+ await session?.abortTransaction();
42271
+ throw error;
42272
+ } finally {
42273
+ session?.endSession();
42274
+ }
42275
+ }
42276
+ async function deleteOvernightParkingRequestById(id) {
42277
+ const session = useAtlas104.getClient()?.startSession();
42278
+ try {
42279
+ session?.startTransaction();
42280
+ const result = await _deleteOvernightParkingRequestById(id, session);
42281
+ await session?.commitTransaction();
42282
+ return result;
42283
+ } catch (error) {
42284
+ await session?.abortTransaction();
42285
+ throw error;
42286
+ } finally {
42287
+ session?.endSession();
42288
+ }
42289
+ }
42290
+ async function processExpiredRequests() {
42291
+ const sites = await _getAllSitesUnpaginated();
42292
+ for (const site of sites) {
42293
+ const session = useAtlas104.getClient()?.startSession();
42294
+ try {
42295
+ session?.startTransaction();
42296
+ await _updateExpiredRequests(site._id, session);
42297
+ await session?.commitTransaction();
42298
+ } catch (error) {
42299
+ await session?.abortTransaction();
42300
+ logger166.error(`Failed processing site ${site._id}`, error);
42301
+ } finally {
42302
+ session?.endSession();
42303
+ }
42304
+ }
42305
+ }
42306
+ return {
42307
+ add,
42308
+ updateOvernightParkingRequestById,
42309
+ deleteOvernightParkingRequestById,
42310
+ processExpiredRequests
42311
+ };
42312
+ }
42313
+
42314
+ // src/controllers/overnight-parking-request.controller.ts
42315
+ import Joi119 from "joi";
42316
+ import { BadRequestError as BadRequestError189, logger as logger167 } from "@7365admin1/node-server-utils";
42317
+ function useOvernightParkingRequestController() {
42318
+ const {
42319
+ add: _add,
42320
+ updateOvernightParkingRequestById: _updateOvernightParkingRequestById,
42321
+ deleteOvernightParkingRequestById: _deleteOvernightParkingRequestById
42322
+ } = useOvernightParkingRequestService();
42323
+ const {
42324
+ getAll: _getAll,
42325
+ getOvernightParkingRequestById: _getOvernightParkingRequestById
42326
+ } = useOvernightParkingRequestRepo();
42327
+ async function add(req, res, next) {
42328
+ try {
42329
+ const { error, value } = schemaOvernightParkingRequest.validate(
42330
+ req.body,
42331
+ {
42332
+ abortEarly: false
42333
+ }
42334
+ );
42335
+ if (error) {
42336
+ const messages = error.details.map((d) => d.message).join(", ");
42337
+ logger167.log({ level: "error", message: messages });
42338
+ next(new BadRequestError189(messages));
42339
+ return;
42340
+ }
42341
+ const data = await _add(value);
42342
+ res.status(201).json(data);
42343
+ return;
42344
+ } catch (error) {
42345
+ logger167.log({ level: "error", message: error.message });
42346
+ next(error);
42347
+ return;
42348
+ }
42349
+ }
42350
+ async function getAll(req, res, next) {
42351
+ try {
42352
+ const validation = Joi119.object({
42353
+ page: Joi119.number().integer().min(1).optional().default(1),
42354
+ limit: Joi119.number().integer().min(1).max(100).optional().default(10),
42355
+ sort: Joi119.string().valid(...Object.values(OvernightParkingRequestSort)).optional().allow(null, ""),
42356
+ status: Joi119.string().valid(...Object.values(OvernightParkingRequestStatus)).optional().allow(null, ""),
42357
+ site: Joi119.string().hex().length(24).optional().allow(null, ""),
42358
+ order: Joi119.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
42359
+ });
42360
+ const { error, value } = validation.validate(req.query, {
42361
+ abortEarly: false
42362
+ });
42363
+ if (error) {
42364
+ const messages = error.details.map((d) => d.message).join(", ");
42365
+ logger167.log({ level: "error", message: messages });
42366
+ next(new BadRequestError189(messages));
42367
+ return;
42368
+ }
42369
+ const { site, page, limit, status, sort, order } = value;
42370
+ const sortObj = {
42371
+ [sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
42372
+ };
42373
+ const data = await _getAll({
42374
+ site,
42375
+ page,
42376
+ limit,
42377
+ sort: sortObj,
42378
+ status
42379
+ });
42380
+ res.status(200).json(data);
42381
+ return;
42382
+ } catch (error) {
42383
+ logger167.log({ level: "error", message: error.message });
42384
+ next(error);
42385
+ return;
42386
+ }
42387
+ }
42388
+ async function getOvernightParkingRequestById(req, res, next) {
42389
+ try {
42390
+ const validation = Joi119.object({
42391
+ _id: Joi119.string().hex().length(24).required()
42392
+ });
42393
+ const { error, value } = validation.validate(
42394
+ { _id: req.params.id },
42395
+ {
42396
+ abortEarly: false
42397
+ }
42398
+ );
42399
+ if (error) {
42400
+ const messages = error.details.map((d) => d.message).join(", ");
42401
+ logger167.log({ level: "error", message: messages });
42402
+ next(new BadRequestError189(messages));
42403
+ return;
42404
+ }
42405
+ const { _id } = value;
42406
+ const data = await _getOvernightParkingRequestById(_id);
42407
+ res.status(200).json(data);
42408
+ return;
42409
+ } catch (error) {
42410
+ logger167.log({ level: "error", message: error.message });
42411
+ next(error);
42412
+ return;
42413
+ }
42414
+ }
42415
+ async function updateOvernightParkingRequestById(req, res, next) {
42416
+ try {
42417
+ const { error, value } = schemaUpdateOvernightParkingRequest.validate(
42418
+ { _id: req.params.id, ...req.body },
42419
+ {
42420
+ abortEarly: false
42421
+ }
42422
+ );
42423
+ if (error) {
42424
+ const messages = error.details.map((d) => d.message).join(", ");
42425
+ logger167.log({ level: "error", message: messages });
42426
+ next(new BadRequestError189(messages));
42427
+ return;
42428
+ }
42429
+ const { _id, ...rest } = value;
42430
+ await _updateOvernightParkingRequestById(_id, rest);
42431
+ res.status(200).json({ message: "Successfully updated overnight parking request" });
42432
+ return;
42433
+ } catch (error) {
42434
+ logger167.log({ level: "error", message: error.message });
42435
+ next(error);
42436
+ return;
42437
+ }
42438
+ }
42439
+ async function deleteOvernightParkingRequestById(req, res, next) {
42440
+ try {
42441
+ const schema2 = Joi119.object({
42442
+ _id: Joi119.string().hex().length(24).required()
42443
+ });
42444
+ const { error, value } = schema2.validate(
42445
+ { _id: req.params.id },
42446
+ {
42447
+ abortEarly: false
42448
+ }
42449
+ );
42450
+ if (error) {
42451
+ const messages = error.details.map((d) => d.message).join(", ");
42452
+ logger167.log({ level: "error", message: messages });
42453
+ next(new BadRequestError189(messages));
42454
+ return;
42455
+ }
42456
+ const { _id } = value;
42457
+ await _deleteOvernightParkingRequestById(_id);
42458
+ res.status(200).json({ message: "Successfully deleted overnight parking request" });
42459
+ return;
42460
+ } catch (error) {
42461
+ logger167.log({ level: "error", message: error.message });
42462
+ next(error);
42463
+ return;
42464
+ }
42465
+ }
42466
+ return {
42467
+ add,
42468
+ getAll,
42469
+ getOvernightParkingRequestById,
42470
+ updateOvernightParkingRequestById,
42471
+ deleteOvernightParkingRequestById
42472
+ };
42473
+ }
42474
+
42475
+ // src/services/hrmlabs-attendance.service.ts
42476
+ import { logger as logger168 } from "@7365admin1/node-server-utils";
42477
+ var {
42478
+ hrmLabsAuthentication: hrmLabsAuthentication3,
42479
+ fetchAttendanceData: fetchAttendanceData2,
42480
+ filterByShiftTime: filterByShiftTime2,
42481
+ paginate: paginate55,
42482
+ designationCount: designationCount2,
42483
+ totalCountPerShift: totalCountPerShift2,
42484
+ filterByStatus: filterByStatus2,
42485
+ totalCountPerStatus: totalCountPerStatus2,
42486
+ chartCountData: chartCountData2
42487
+ } = hrmlabs_attendance_util_default;
42488
+ function useHrmLabsAttendanceSrvc() {
42489
+ const { getManpowerSettingsBySiteId: _getManpowerSettingsBySiteId } = useManpowerMonitoringRepo();
42490
+ const { getManpowerDesignationsBySiteId: _getManpowerDesignationsBySiteId } = useManpowerDesignationRepo();
42491
+ async function getAttendanceData(payload) {
42492
+ const {
42493
+ startDate,
42494
+ endDate,
42495
+ siteName,
42496
+ siteId,
42497
+ shiftName,
42498
+ search,
42499
+ page = 1,
42500
+ limit = 10,
42501
+ status = "all",
42502
+ serviceProviderId
42503
+ } = payload;
42504
+ const username = process.env.HRMLABS_USERNAME;
42505
+ const domain = process.env.HRMLABS_DOMAIN;
42506
+ const password = process.env.HRMLABS_PASSWORD;
42507
+ const authUrl = process.env.HRMLABS_AUTH_URL;
42508
+ const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
42509
+ const timeZone = "Asia/Singapore";
42510
+ const dateFormat = "DD-MM-YYYY HH:mm:ss";
42511
+ if (!startDate) {
42512
+ return { success: false, message: "Start Date should not be empty" };
42513
+ }
42514
+ try {
42515
+ const config2 = await _getManpowerSettingsBySiteId(
42516
+ siteId,
42517
+ serviceProviderId
42518
+ );
42519
+ if (!config2) {
42520
+ return {
42521
+ success: false,
42522
+ message: "Manpower monitoring settings not found for the provided site ID."
42523
+ };
42524
+ }
42525
+ const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
42526
+ const shiftData = config2.shifts[shiftType].find(
42527
+ (s) => s.name === shiftName
42528
+ );
42529
+ if (!shiftData) {
42530
+ return {
42531
+ success: false,
42532
+ message: "Shift not found in configuration."
42533
+ };
42534
+ }
42535
+ const token = await hrmLabsAuthentication3({
42536
+ authUrl,
42537
+ username,
42538
+ password,
42539
+ domain
42540
+ });
42541
+ const attendanceData = await fetchAttendanceData2({
42542
+ attendanceUrl,
42543
+ token,
42544
+ startDate,
42545
+ endDate,
42546
+ siteName,
42547
+ search
42548
+ });
42549
+ if (!attendanceData?.success) {
42550
+ return {
42551
+ success: false,
42552
+ message: "Failed to fetch attendance data from HRMLabs.",
42553
+ items: [],
42554
+ pages: 0,
42555
+ pageRange: "0-0 of 0",
42556
+ count: {}
42557
+ };
42558
+ }
42559
+ let filteredAttendance;
42560
+ if (status === "all") {
42561
+ filteredAttendance = filterByShiftTime2(
42562
+ attendanceData.data,
42563
+ shiftData,
42564
+ timeZone,
42565
+ dateFormat
42566
+ );
42567
+ } else {
42568
+ const filteredByShift = filterByShiftTime2(
42569
+ attendanceData.data,
42570
+ shiftData,
42571
+ timeZone,
42572
+ dateFormat
42573
+ );
42574
+ filteredAttendance = filterByStatus2(
42575
+ filteredByShift,
42576
+ shiftData,
42577
+ timeZone,
42578
+ dateFormat,
42579
+ status
42580
+ );
42581
+ }
42582
+ const paginatedItems = paginate55(filteredAttendance, page, limit);
42583
+ return {
42584
+ items: paginatedItems.items,
42585
+ pages: paginatedItems.pages,
42586
+ pageRange: paginatedItems.pageRange
42587
+ };
42588
+ } catch (error) {
42589
+ logger168.error(error.message || error);
42590
+ console.log("Error fetching attendance data:", error);
42591
+ throw new Error(error?.message || "Internal Server Error!");
42592
+ }
42593
+ }
42594
+ async function getAttendanceDataCount(payload) {
42595
+ const { startDate, endDate, siteName, siteId, search, serviceProviderId } = payload;
42596
+ const username = process.env.HRMLABS_USERNAME;
42597
+ const domain = process.env.HRMLABS_DOMAIN;
42598
+ const password = process.env.HRMLABS_PASSWORD;
42599
+ const authUrl = process.env.HRMLABS_AUTH_URL;
42600
+ const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
42601
+ const timeZone = "Asia/Singapore";
42602
+ const dateFormat = "DD-MM-YYYY HH:mm:ss";
42603
+ let totalCount;
42604
+ if (!startDate) {
42605
+ return { success: false, message: "Start Date should not be empty" };
42606
+ }
42607
+ try {
42608
+ const config2 = await _getManpowerSettingsBySiteId(
42609
+ siteId,
42610
+ serviceProviderId
42611
+ );
42612
+ if (!config2) {
42613
+ return {
42614
+ success: false,
42615
+ message: "Manpower monitoring settings not found for the provided site ID."
42616
+ };
42617
+ }
42618
+ const shiftType = config2.shiftType;
42619
+ const shiftData = config2.shifts[shiftType];
42620
+ if (!shiftData) {
42621
+ return {
42622
+ success: false,
42623
+ message: "Shift not found in configuration."
42624
+ };
42625
+ }
42626
+ const designationConfig = await _getManpowerDesignationsBySiteId(
42627
+ siteId,
42628
+ serviceProviderId
42629
+ );
42630
+ if (!designationConfig) {
42631
+ return {
42632
+ success: false,
42633
+ message: "Manpower monitoring designations not found for the provided site ID."
42634
+ };
42635
+ }
42636
+ const totalShifts = designationConfig.designations.reduce(
42637
+ (acc, item) => {
42638
+ acc.morningShift += item.shifts.morningShift;
42639
+ acc.afternoonShift += item.shifts.afternoonShift;
42640
+ acc.nightShift += item.shifts.nightShift;
42641
+ return acc;
42642
+ },
42643
+ {
42644
+ morningShift: 0,
42645
+ afternoonShift: 0,
42646
+ nightShift: 0
42647
+ }
42648
+ );
42649
+ const token = await hrmLabsAuthentication3({
42650
+ authUrl,
42651
+ username,
42652
+ password,
42653
+ domain
42654
+ });
42655
+ const attendanceData = await fetchAttendanceData2({
42656
+ attendanceUrl,
42657
+ token,
42658
+ startDate,
42659
+ endDate,
42660
+ siteName,
42661
+ search
42662
+ });
42663
+ if (!attendanceData?.success) {
42664
+ return {
42665
+ totalCount: {
42666
+ dayShift: {
42667
+ actual: 0,
42668
+ expected: totalShifts.morningShift
42669
+ },
42670
+ afternoonShift: {
42671
+ actual: 0,
42672
+ expected: totalShifts.afternoonShift
42673
+ },
42674
+ nightShift: {
42675
+ actual: 0,
42676
+ expected: totalShifts.nightShift
42677
+ }
42678
+ }
42679
+ };
42680
+ }
42681
+ const result = totalCountPerShift2(
42682
+ attendanceData.data,
42683
+ shiftData,
42684
+ timeZone,
42685
+ dateFormat
42686
+ );
42687
+ totalCount = {
42688
+ dayShift: {
42689
+ actual: result[0],
42690
+ expected: totalShifts.morningShift
42691
+ },
42692
+ afternoonShift: {
42693
+ actual: shiftType == "2-shifts" ? 0 : result[1],
42694
+ expected: totalShifts.afternoonShift
42695
+ },
42696
+ nightShift: {
42697
+ actual: shiftType == "2-shifts" ? result[1] : result[2],
42698
+ expected: totalShifts.nightShift
42699
+ }
42700
+ };
42701
+ return { totalCount };
42702
+ } catch (error) {
42703
+ logger168.error(error.message || error);
42704
+ console.log("Error fetching attendance data count:", error);
42705
+ throw new Error(error?.message || "Internal Server Error!");
42706
+ }
42707
+ }
42708
+ async function getAllAttendance(payload) {
42709
+ const { startDate, endDate, siteName, siteId, search, serviceProviderId } = payload;
42710
+ let { shiftName } = payload;
42711
+ const username = process.env.HRMLABS_USERNAME;
42712
+ const domain = process.env.HRMLABS_DOMAIN;
42713
+ const password = process.env.HRMLABS_PASSWORD;
42714
+ const authUrl = process.env.HRMLABS_AUTH_URL;
42715
+ const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
42716
+ const timeZone = "Asia/Singapore";
42717
+ const dateFormat = "DD-MM-YYYY HH:mm:ss";
42718
+ if (!startDate) {
42719
+ return { success: false, message: "Start Date should not be empty" };
42720
+ }
42721
+ try {
42722
+ const config2 = await _getManpowerSettingsBySiteId(
42723
+ siteId,
42724
+ serviceProviderId
42725
+ );
42726
+ if (!config2) {
42727
+ return {
42728
+ success: false,
42729
+ message: "Manpower monitoring settings not found for the provided site ID."
42730
+ };
42731
+ }
42732
+ const designationConfig = await _getManpowerDesignationsBySiteId(
42733
+ siteId,
42734
+ serviceProviderId
42735
+ );
42736
+ if (!designationConfig) {
42737
+ return {
42738
+ success: false,
42739
+ message: "Manpower monitoring designations not found for the provided site ID."
42740
+ };
42741
+ }
42742
+ let shiftData = [];
42743
+ const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
42744
+ if (shiftName == "all") {
42745
+ shiftData = config2.shifts[shiftType];
42746
+ } else {
42747
+ shiftName = shiftName.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
42748
+ const filteredShiftData = config2.shifts[shiftType].find(
42749
+ (s) => s.name === shiftName
42750
+ );
42751
+ shiftData.push(filteredShiftData);
42752
+ }
42753
+ if (!shiftData) {
42754
+ return {
42755
+ success: false,
42756
+ message: "Shift not found in configuration."
42757
+ };
42758
+ }
42759
+ const totalShifts = designationConfig.designations.reduce(
42760
+ (acc, item) => {
42761
+ acc.morningShift += item.shifts.morningShift;
42762
+ acc.afternoonShift += item.shifts.afternoonShift;
42763
+ acc.nightShift += item.shifts.nightShift;
42764
+ return acc;
42765
+ },
42766
+ {
42767
+ morningShift: 0,
42768
+ afternoonShift: 0,
42769
+ nightShift: 0
42770
+ }
42771
+ );
42772
+ const token = await hrmLabsAuthentication3({
42773
+ authUrl,
42774
+ username,
42775
+ password,
42776
+ domain
42777
+ });
42778
+ const attendanceData = await fetchAttendanceData2({
42779
+ attendanceUrl,
42780
+ token,
42781
+ startDate,
42782
+ endDate,
42783
+ siteName,
42784
+ search
42785
+ });
42786
+ if (!attendanceData?.success) {
42787
+ const jobTitleCount2 = designationCount2(
42788
+ attendanceData.data,
42789
+ designationConfig,
42790
+ shiftName
42791
+ );
42792
+ const totalCount2 = {
42793
+ dayShift: {
42794
+ actual: 0,
42795
+ expected: totalShifts.morningShift
42796
+ },
42797
+ afternoonShift: {
42798
+ actual: 0,
42799
+ expected: totalShifts.afternoonShift
42800
+ },
42801
+ nightShift: {
42802
+ actual: 0,
42803
+ expected: totalShifts.nightShift
42804
+ }
42805
+ };
42806
+ const countPerStatus2 = await totalCountPerStatus2(
42807
+ attendanceData.data,
42808
+ shiftName,
42809
+ shiftData,
42810
+ timeZone,
42811
+ dateFormat,
42812
+ totalShifts
42813
+ );
42814
+ return {
42815
+ success: false,
42816
+ message: "Failed to fetch attendance data from HRMLabs.",
42817
+ items: [],
42818
+ count: {},
42819
+ countPerJobTitle: jobTitleCount2,
42820
+ totalCount: totalCount2,
42821
+ countPerStatus: countPerStatus2
42822
+ };
42823
+ }
42824
+ let filteredAttendance;
42825
+ if (shiftName === "all") {
42826
+ filteredAttendance = attendanceData.data;
42827
+ } else {
42828
+ filteredAttendance = filterByShiftTime2(
42829
+ attendanceData.data,
42830
+ shiftData[0],
42831
+ timeZone,
42832
+ dateFormat
42833
+ );
42834
+ }
42835
+ const jobTitleCount = designationCount2(
42836
+ filteredAttendance,
42837
+ designationConfig,
42838
+ shiftName
42839
+ );
42840
+ const result = totalCountPerShift2(
42841
+ attendanceData.data,
42842
+ shiftData,
42843
+ timeZone,
42844
+ dateFormat
42845
+ );
42846
+ const totalCount = {
42847
+ dayShift: {
42848
+ actual: result[0],
42849
+ expected: totalShifts.morningShift
42850
+ },
42851
+ afternoonShift: {
42852
+ actual: shiftType == "2-shifts" ? 0 : result[1],
42853
+ expected: totalShifts.afternoonShift
42854
+ },
42855
+ nightShift: {
42856
+ actual: shiftType == "2-shifts" ? result[1] : result[2],
42857
+ expected: totalShifts.nightShift
42858
+ }
42859
+ };
42860
+ const countPerStatus = await totalCountPerStatus2(
42861
+ filteredAttendance,
42862
+ shiftName,
42863
+ shiftData,
42864
+ timeZone,
42865
+ dateFormat,
42866
+ totalShifts
42867
+ );
42868
+ return {
42869
+ items: filteredAttendance,
42870
+ countPerJobTitle: jobTitleCount,
42871
+ totalCount,
42872
+ countPerStatus
42873
+ };
42874
+ } catch (error) {
42875
+ logger168.error(error.message || error);
42876
+ console.log("Error fetching attendance data:", error);
42877
+ throw new Error(error?.message || "Internal Server Error!");
42878
+ }
42879
+ }
42880
+ async function getChartAttendanceData(payload) {
42881
+ const {
42882
+ startDate,
42883
+ endDate,
42884
+ siteName,
42885
+ siteId,
42886
+ search,
42887
+ serviceProviderId,
42888
+ status
42889
+ } = payload;
42890
+ let { shiftName } = payload;
42891
+ const username = process.env.HRMLABS_USERNAME;
42892
+ const domain = process.env.HRMLABS_DOMAIN;
42893
+ const password = process.env.HRMLABS_PASSWORD;
42894
+ const authUrl = process.env.HRMLABS_AUTH_URL;
42895
+ const attendanceUrl = process.env.HRMLABS_ATTENDANCE_URL;
42896
+ const timeZone = "Asia/Singapore";
42897
+ const dateFormat = "DD-MM-YYYY HH:mm:ss";
42898
+ if (!startDate) {
42899
+ return { success: false, message: "Start Date should not be empty" };
42900
+ }
42901
+ try {
42902
+ const config2 = await _getManpowerSettingsBySiteId(
42903
+ siteId,
42904
+ serviceProviderId
42905
+ );
42906
+ if (!config2) {
42907
+ return {
42908
+ success: false,
42909
+ message: "Manpower monitoring settings not found for the provided site ID."
42910
+ };
42911
+ }
42912
+ const designationConfig = await _getManpowerDesignationsBySiteId(
42913
+ siteId,
42914
+ serviceProviderId
42915
+ );
42916
+ if (!designationConfig) {
42917
+ return {
42918
+ success: false,
42919
+ message: "Manpower monitoring designations not found for the provided site ID."
42920
+ };
42921
+ }
42922
+ const shiftType = config2.shiftType === "2-shifts" ? "2-shifts" : "3-shifts";
42923
+ const shiftData = config2.shifts[shiftType];
42924
+ if (!shiftData) {
42925
+ return {
42926
+ success: false,
42927
+ message: "Shift not found in configuration."
42928
+ };
42929
+ }
42930
+ const token = await hrmLabsAuthentication3({
42931
+ authUrl,
42932
+ username,
42933
+ password,
42934
+ domain
42935
+ });
42936
+ const attendanceData = await fetchAttendanceData2({
42937
+ attendanceUrl,
42938
+ token,
42939
+ startDate,
42940
+ endDate,
42941
+ siteName,
42942
+ search
42943
+ });
42944
+ if (!attendanceData?.success) {
42945
+ return {
42946
+ success: false,
42947
+ message: "Failed to fetch attendance data from HRMLabs.",
42948
+ items: [],
42949
+ pages: 0,
42950
+ pageRange: "0-0 of 0",
42951
+ count: {}
42952
+ };
42953
+ }
42954
+ const filteredAttendance = attendanceData.data;
42955
+ const totalShifts = designationConfig.designations.reduce(
42956
+ (acc, item) => {
42957
+ acc.morningShift += item.shifts.morningShift;
42958
+ acc.afternoonShift += item.shifts.afternoonShift;
42959
+ acc.nightShift += item.shifts.nightShift;
42960
+ return acc;
42961
+ },
42962
+ {
42963
+ morningShift: 0,
42964
+ afternoonShift: 0,
42965
+ nightShift: 0
42966
+ }
42967
+ );
42968
+ const chartCount = await chartCountData2(
42969
+ filteredAttendance,
42970
+ shiftData,
42971
+ timeZone,
42972
+ dateFormat,
42973
+ totalShifts,
42974
+ startDate,
42975
+ endDate,
42976
+ status
42977
+ );
42978
+ return {
42979
+ chartCount
42980
+ };
42981
+ } catch (error) {
42982
+ logger168.error(error.message || error);
42983
+ console.log("Error fetching attendance data:", error);
42984
+ throw new Error(error?.message || "Internal Server Error!");
42985
+ }
42986
+ }
42987
+ return {
42988
+ getAttendanceData,
42989
+ getAttendanceDataCount,
42990
+ getAllAttendance,
42991
+ getChartAttendanceData
42992
+ };
42993
+ }
42994
+
42995
+ // src/controllers/hrmlabs-attendance.controller.ts
42996
+ import { BadRequestError as BadRequestError190, logger as logger169 } from "@7365admin1/node-server-utils";
42997
+ import Joi120 from "joi";
42998
+ function useHrmLabsAttendanceCtrl() {
42999
+ const hrmLabsAttendanceSrvc = useHrmLabsAttendanceSrvc();
43000
+ async function getAttendanceData(req, res, next) {
43001
+ try {
43002
+ const {
43003
+ startDate,
43004
+ endDate,
43005
+ siteName,
43006
+ siteId,
43007
+ shiftName,
43008
+ page,
43009
+ limit,
43010
+ search,
43011
+ status,
43012
+ serviceProviderId
43013
+ } = req.body;
43014
+ const schema2 = Joi120.object({
43015
+ startDate: Joi120.string().optional().allow("", null),
43016
+ endDate: Joi120.string().optional().allow("", null),
43017
+ siteName: Joi120.string().optional().allow("", null),
43018
+ siteId: Joi120.string().required(),
43019
+ shiftName: Joi120.string().optional().allow("", null),
43020
+ page: Joi120.number().optional().allow("", null),
43021
+ limit: Joi120.number().optional().allow("", null),
43022
+ search: Joi120.string().optional().allow("", null),
43023
+ status: Joi120.string().optional().allow("", null),
43024
+ serviceProviderId: Joi120.string().required()
43025
+ });
43026
+ const { error } = schema2.validate({
43027
+ startDate,
43028
+ endDate,
43029
+ siteName,
43030
+ siteId,
43031
+ shiftName,
43032
+ page,
43033
+ limit,
43034
+ search,
43035
+ status,
43036
+ serviceProviderId
43037
+ });
43038
+ if (error) {
43039
+ next(new BadRequestError190(error.message));
43040
+ return;
43041
+ }
43042
+ const result = await hrmLabsAttendanceSrvc.getAttendanceData(req.body);
43043
+ return res.json(result);
43044
+ } catch (error) {
43045
+ logger169.log({ level: "error", message: error.message });
43046
+ next(error);
43047
+ return;
43048
+ }
43049
+ }
43050
+ async function getAttendanceDataCount(req, res, next) {
43051
+ try {
43052
+ const { startDate, endDate, siteName, siteId, serviceProviderId } = req.body;
43053
+ const schema2 = Joi120.object({
43054
+ startDate: Joi120.string().optional().allow("", null),
43055
+ endDate: Joi120.string().optional().allow("", null),
43056
+ siteName: Joi120.string().optional().allow("", null),
43057
+ siteId: Joi120.string().required(),
43058
+ serviceProviderId: Joi120.string().required()
43059
+ });
43060
+ const { error } = schema2.validate({
43061
+ startDate,
43062
+ endDate,
43063
+ siteName,
43064
+ siteId,
43065
+ serviceProviderId
43066
+ });
43067
+ if (error) {
43068
+ next(new BadRequestError190(error.message));
43069
+ return;
43070
+ }
43071
+ const result = await hrmLabsAttendanceSrvc.getAttendanceDataCount(
43072
+ req.body
43073
+ );
43074
+ return res.json(result);
43075
+ } catch (error) {
43076
+ logger169.log({ level: "error", message: error.message });
43077
+ next(error);
43078
+ return;
43079
+ }
43080
+ }
43081
+ async function getAllAttendance(req, res, next) {
43082
+ try {
43083
+ const {
43084
+ startDate,
43085
+ endDate,
43086
+ siteName,
43087
+ siteId,
43088
+ shiftName,
43089
+ search,
43090
+ serviceProviderId
43091
+ } = req.body;
43092
+ const schema2 = Joi120.object({
43093
+ startDate: Joi120.string().optional().allow("", null),
43094
+ endDate: Joi120.string().optional().allow("", null),
43095
+ siteName: Joi120.string().optional().allow("", null),
43096
+ siteId: Joi120.string().required(),
43097
+ shiftName: Joi120.string().optional().allow("", null),
43098
+ search: Joi120.string().optional().allow("", null),
43099
+ serviceProviderId: Joi120.string().required()
43100
+ });
43101
+ const { error } = schema2.validate({
43102
+ startDate,
43103
+ endDate,
43104
+ siteName,
43105
+ siteId,
43106
+ shiftName,
43107
+ search,
43108
+ serviceProviderId
43109
+ });
43110
+ if (error) {
43111
+ next(new BadRequestError190(error.message));
43112
+ return;
43113
+ }
43114
+ const result = await hrmLabsAttendanceSrvc.getAllAttendance(req.body);
43115
+ return res.json(result);
43116
+ } catch (error) {
43117
+ logger169.log({ level: "error", message: error.message });
43118
+ next(error);
43119
+ return;
43120
+ }
43121
+ }
43122
+ async function getChartAttendanceData(req, res, next) {
43123
+ try {
43124
+ const {
43125
+ startDate,
43126
+ endDate,
43127
+ siteName,
43128
+ siteId,
43129
+ search = "",
43130
+ serviceProviderId,
43131
+ status
43132
+ } = req.body;
43133
+ const schema2 = Joi120.object({
43134
+ startDate: Joi120.string().optional().allow("", null),
43135
+ endDate: Joi120.string().optional().allow("", null),
43136
+ siteName: Joi120.string().optional().allow("", null),
43137
+ siteId: Joi120.string().required(),
43138
+ search: Joi120.string().optional().allow("", null),
43139
+ serviceProviderId: Joi120.string().required(),
43140
+ status: Joi120.string().optional().allow("", null)
43141
+ });
43142
+ const { error } = schema2.validate({
43143
+ startDate,
43144
+ endDate,
43145
+ siteName,
43146
+ siteId,
43147
+ search,
43148
+ serviceProviderId,
43149
+ status
43150
+ });
43151
+ if (error) {
43152
+ next(new BadRequestError190(error.message));
43153
+ return;
43154
+ }
43155
+ const result = await hrmLabsAttendanceSrvc.getChartAttendanceData(
43156
+ req.body
43157
+ );
43158
+ return res.json(result);
43159
+ } catch (error) {
43160
+ logger169.log({ level: "error", message: error.message });
43161
+ next(error);
43162
+ return;
43163
+ }
43164
+ }
43165
+ return {
43166
+ getAttendanceData,
43167
+ getAttendanceDataCount,
43168
+ getAllAttendance,
43169
+ getChartAttendanceData
43170
+ };
43171
+ }
43172
+
43173
+ // src/controllers/manpower-remarks.controller.ts
43174
+ import { BadRequestError as BadRequestError191, logger as logger170 } from "@7365admin1/node-server-utils";
43175
+ import Joi121 from "joi";
43176
+ function useManpowerRemarkCtrl() {
43177
+ const {
43178
+ createManpowerRemarks: _createManpowerRemarks,
43179
+ getManpowerRemarksAllSite: _getManpowerRemarksAllSite,
43180
+ updateRemarksStatus: _updateRemarksStatus,
43181
+ getManpowerRemarksBySiteId: _getManpowerRemarksBySiteId,
43182
+ updateManpowerRemarks: _updateManpowerRemarks
43183
+ } = useManpowerRemarksRepo();
43184
+ async function createManpowerRemark(req, res, next) {
43185
+ try {
43186
+ const payload = { ...req.body };
43187
+ const { error } = manpowerRemarksSchema.validate(payload);
43188
+ if (error) {
43189
+ next(new BadRequestError191(error.message));
43190
+ return;
43191
+ }
43192
+ const result = await _createManpowerRemarks(payload);
43193
+ return res.json(result);
43194
+ } catch (error) {
43195
+ logger170.log({ level: "error", message: error.message });
43196
+ next(error);
43197
+ return;
43198
+ }
43199
+ }
43200
+ async function getManpowerRemarksAllSite(req, res, next) {
43201
+ try {
43202
+ const { page, limit, serviceProviderId, search, status, date } = req.query;
43203
+ const schema2 = Joi121.object({
43204
+ page: Joi121.number().optional().allow("", null),
43205
+ limit: Joi121.number().optional().allow("", null),
43206
+ serviceProviderId: Joi121.string().hex().optional().allow("", null),
43207
+ search: Joi121.string().optional().allow("", null),
43208
+ status: Joi121.string().required(),
43209
+ date: Joi121.string().required()
43210
+ });
43211
+ const { error } = schema2.validate({
43212
+ page,
43213
+ limit,
43214
+ serviceProviderId,
43215
+ search,
43216
+ status,
43217
+ date
43218
+ });
43219
+ if (error) {
43220
+ next(new BadRequestError191(error.message));
43221
+ return;
43222
+ }
43223
+ const result = await _getManpowerRemarksAllSite({
43224
+ page: Number(page),
43225
+ limit: Number(limit),
43226
+ serviceProviderId: serviceProviderId?.toString() || "",
43227
+ search: search?.toString() || "",
43228
+ status: status?.toString() || "",
43229
+ date: date?.toString() || ""
43230
+ });
43231
+ return res.json(result);
43232
+ } catch (error) {
43233
+ logger170.log({ level: "error", message: error.message });
43234
+ next(error);
43235
+ return;
43236
+ }
43237
+ }
43238
+ async function getManpowerRemarksBySiteId(req, res, next) {
43239
+ try {
43240
+ const { id, serviceProviderId } = req.params;
43241
+ const date = req.query.date;
43242
+ const schema2 = Joi121.object({
43243
+ id: Joi121.string().hex().required(),
43244
+ date: Joi121.string().required(),
43245
+ serviceProviderId: Joi121.string().hex().required()
43246
+ });
43247
+ const { error } = schema2.validate({
43248
+ id,
43249
+ date,
43250
+ serviceProviderId
43251
+ });
43252
+ if (error) {
43253
+ next(new BadRequestError191(error.message));
43254
+ return;
43255
+ }
43256
+ const result = await _getManpowerRemarksBySiteId(
43257
+ id,
43258
+ date,
43259
+ serviceProviderId
43260
+ );
43261
+ return res.json(result);
43262
+ } catch (error) {
43263
+ logger170.log({ level: "error", message: error.message });
43264
+ next(error);
43265
+ return;
43266
+ }
43267
+ }
43268
+ async function updateManpowerMonitoringSettings(req, res, next) {
43269
+ try {
43270
+ const validation = Joi121.object({
43271
+ _id: Joi121.string().hex().required(),
43272
+ remarks: Joi121.array().items(remarksSchema).required(),
43273
+ createdBy: Joi121.string().hex().optional().allow("", null),
43274
+ createdByName: Joi121.string().optional().allow("", null)
43275
+ });
43276
+ const _id = req.params.id;
43277
+ const payload = { ...req.body };
43278
+ const { error } = validation.validate({ _id, ...payload });
43279
+ if (error) {
43280
+ next(new BadRequestError191(error.message));
43281
+ return;
43282
+ }
43283
+ const result = await _updateManpowerRemarks(_id, payload);
43284
+ return res.json(result);
43285
+ } catch (error) {
43286
+ logger170.log({ level: "error", message: error.message });
43287
+ next(error);
43288
+ return;
43289
+ }
43290
+ }
43291
+ async function updateRemarksStatus(req, res, next) {
43292
+ try {
43293
+ const validation = Joi121.object({
43294
+ _id: Joi121.string().hex().required(),
43295
+ status: Joi121.string().required()
43296
+ });
43297
+ const _id = req.params.id;
43298
+ const payload = { ...req.body };
43299
+ const { error } = validation.validate({ _id, ...payload });
43300
+ if (error) {
43301
+ next(new BadRequestError191(error.message));
43302
+ return;
43303
+ }
43304
+ const result = await _updateRemarksStatus(_id, payload);
43305
+ return res.json(result);
43306
+ } catch (error) {
43307
+ logger170.log({ level: "error", message: error.message });
43308
+ next(error);
43309
+ return;
43310
+ }
43311
+ }
43312
+ return {
43313
+ createManpowerRemark,
43314
+ getManpowerRemarksAllSite,
43315
+ getManpowerRemarksBySiteId,
43316
+ updateManpowerMonitoringSettings,
43317
+ updateRemarksStatus
43318
+ };
43319
+ }
41307
43320
  export {
41308
43321
  ANPRMode,
41309
43322
  AccessTypeProps,
@@ -41313,6 +43326,7 @@ export {
41313
43326
  BulletinStatus,
41314
43327
  CameraType,
41315
43328
  DEVICE_STATUS,
43329
+ DayOfWeek,
41316
43330
  EAccessCardTypes,
41317
43331
  EAccessCardUserTypes,
41318
43332
  FacilitySort,
@@ -41342,6 +43356,7 @@ export {
41342
43356
  MIncidentReport,
41343
43357
  MManpowerDesignations,
41344
43358
  MManpowerMonitoring,
43359
+ MManpowerRemarks,
41345
43360
  MMember,
41346
43361
  MNfcPatrolLog,
41347
43362
  MNfcPatrolRoute,
@@ -41354,6 +43369,7 @@ export {
41354
43369
  MOnlineForm,
41355
43370
  MOrg,
41356
43371
  MOvernightParkingApprovalHours,
43372
+ MOvernightParkingRequest,
41357
43373
  MPatrolLog,
41358
43374
  MPatrolQuestion,
41359
43375
  MPatrolRoute,
@@ -41378,6 +43394,8 @@ export {
41378
43394
  MVisitorTransaction,
41379
43395
  MWorkOrder,
41380
43396
  OrgNature,
43397
+ OvernightParkingRequestSort,
43398
+ OvernightParkingRequestStatus,
41381
43399
  PERSON_TYPES,
41382
43400
  PMDashboardCollection,
41383
43401
  Period,
@@ -41386,6 +43404,7 @@ export {
41386
43404
  SiteStatus,
41387
43405
  SortFields,
41388
43406
  SortOrder,
43407
+ SubscriptionType,
41389
43408
  UseAccessManagementRepo,
41390
43409
  VehicleCategory,
41391
43410
  VehicleOrder,
@@ -41394,6 +43413,7 @@ export {
41394
43413
  VehicleType,
41395
43414
  VisitorSort,
41396
43415
  VisitorStatus,
43416
+ addressSchema,
41397
43417
  allowedFieldsSite,
41398
43418
  allowedNatures,
41399
43419
  attendanceSchema,
@@ -41417,12 +43437,15 @@ export {
41417
43437
  mAndEDashboardCollection,
41418
43438
  manpowerDesignationsSchema,
41419
43439
  manpowerMonitoringSchema,
43440
+ manpowerRemarksSchema,
41420
43441
  nfcPatrolSettingsSchema,
41421
43442
  nfcPatrolSettingsSchemaUpdate,
41422
43443
  orgSchema,
43444
+ overnight_parking_requests_namespace_collection,
41423
43445
  pestDashboardCollection,
41424
43446
  poolDashboardCollection,
41425
43447
  promoCodeSchema,
43448
+ remarksSchema,
41426
43449
  robotSchema,
41427
43450
  schema,
41428
43451
  schemaBilling,
@@ -41449,6 +43472,7 @@ export {
41449
43472
  schemaOccurrenceSubject,
41450
43473
  schemaOnlineForm,
41451
43474
  schemaOvernightParkingApprovalHours,
43475
+ schemaOvernightParkingRequest,
41452
43476
  schemaPatrolLog,
41453
43477
  schemaPatrolQuestion,
41454
43478
  schemaPatrolRoute,
@@ -41473,6 +43497,7 @@ export {
41473
43497
  schemaUpdateOccurrenceSubject,
41474
43498
  schemaUpdateOnlineForm,
41475
43499
  schemaUpdateOptions,
43500
+ schemaUpdateOvernightParkingRequest,
41476
43501
  schemaUpdatePatrolLog,
41477
43502
  schemaUpdatePatrolQuestion,
41478
43503
  schemaUpdatePatrolRoute,
@@ -41546,6 +43571,8 @@ export {
41546
43571
  useGuestManagementController,
41547
43572
  useGuestManagementRepo,
41548
43573
  useGuestManagementService,
43574
+ useHrmLabsAttendanceCtrl,
43575
+ useHrmLabsAttendanceSrvc,
41549
43576
  useIncidentReportController,
41550
43577
  useIncidentReportRepo,
41551
43578
  useIncidentReportService,
@@ -41557,6 +43584,8 @@ export {
41557
43584
  useManpowerMonitoringCtrl,
41558
43585
  useManpowerMonitoringRepo,
41559
43586
  useManpowerMonitoringSrvc,
43587
+ useManpowerRemarkCtrl,
43588
+ useManpowerRemarksRepo,
41560
43589
  useMemberController,
41561
43590
  useMemberRepo,
41562
43591
  useNewDashboardController,
@@ -41588,6 +43617,9 @@ export {
41588
43617
  useOrgRepo,
41589
43618
  useOvernightParkingController,
41590
43619
  useOvernightParkingRepo,
43620
+ useOvernightParkingRequestController,
43621
+ useOvernightParkingRequestRepo,
43622
+ useOvernightParkingRequestService,
41591
43623
  usePatrolLogController,
41592
43624
  usePatrolLogRepo,
41593
43625
  usePatrolQuestionController,