@7365admin1/core 3.14.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -536,13 +536,13 @@ var require_logger = __commonJS({
536
536
  "use strict";
537
537
  exports.__esModule = true;
538
538
  var _utils = require_utils();
539
- var logger200 = {
539
+ var logger201 = {
540
540
  methodMap: ["debug", "info", "warn", "error"],
541
541
  level: "info",
542
542
  // Maps a given level value to the `methodMap` indexes above.
543
543
  lookupLevel: function lookupLevel(level) {
544
544
  if (typeof level === "string") {
545
- var levelMap = _utils.indexOf(logger200.methodMap, level.toLowerCase());
545
+ var levelMap = _utils.indexOf(logger201.methodMap, level.toLowerCase());
546
546
  if (levelMap >= 0) {
547
547
  level = levelMap;
548
548
  } else {
@@ -553,9 +553,9 @@ var require_logger = __commonJS({
553
553
  },
554
554
  // Can be overridden in the host environment
555
555
  log: function log(level) {
556
- level = logger200.lookupLevel(level);
557
- if (typeof console !== "undefined" && logger200.lookupLevel(logger200.level) <= level) {
558
- var method = logger200.methodMap[level];
556
+ level = logger201.lookupLevel(level);
557
+ if (typeof console !== "undefined" && logger201.lookupLevel(logger201.level) <= level) {
558
+ var method = logger201.methodMap[level];
559
559
  if (!console[method]) {
560
560
  method = "log";
561
561
  }
@@ -566,7 +566,7 @@ var require_logger = __commonJS({
566
566
  }
567
567
  }
568
568
  };
569
- exports["default"] = logger200;
569
+ exports["default"] = logger201;
570
570
  module2.exports = exports["default"];
571
571
  }
572
572
  });
@@ -6036,6 +6036,7 @@ __export(src_exports, {
6036
6036
  building_units_namespace_collection: () => building_units_namespace_collection,
6037
6037
  buildings_namespace_collection: () => buildings_namespace_collection,
6038
6038
  bulletin_boards_namespace_collection: () => bulletin_boards_namespace_collection,
6039
+ chatPrelovedEvents: () => chatPrelovedEvents,
6039
6040
  chatSchema: () => chatSchema,
6040
6041
  createManpowerRemarksDaily: () => createManpowerRemarksDaily,
6041
6042
  customerSchema: () => customerSchema,
@@ -6191,6 +6192,7 @@ __export(src_exports, {
6191
6192
  useAuthServiceV2: () => useAuthServiceV2,
6192
6193
  useBidPrelovedController: () => useBidPrelovedController,
6193
6194
  useBidPrelovedRepo: () => useBidPrelovedRepo,
6195
+ useBidPrelovedService: () => useBidPrelovedService,
6194
6196
  useBuildingController: () => useBuildingController,
6195
6197
  useBuildingLevelController: () => useBuildingLevelController,
6196
6198
  useBuildingLevelRepo: () => useBuildingLevelRepo,
@@ -8742,12 +8744,6 @@ function useUserRepo() {
8742
8744
  throw new import_node_server_utils10.BadRequestError("Invalid user ID format.");
8743
8745
  }
8744
8746
  try {
8745
- const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection, { _id });
8746
- const cachedData = await getCache(cacheKey);
8747
- if (cachedData) {
8748
- import_node_server_utils10.logger.info(`Cache hit for key: ${cacheKey}`);
8749
- return cachedData;
8750
- }
8751
8747
  const results = await collection.aggregate([
8752
8748
  { $match: { _id } },
8753
8749
  {
@@ -8771,17 +8767,42 @@ function useUserRepo() {
8771
8767
  ],
8772
8768
  as: "serviceProviders"
8773
8769
  }
8774
- }
8770
+ },
8771
+ {
8772
+ $lookup: {
8773
+ from: "buildings",
8774
+ localField: "block",
8775
+ foreignField: "_id",
8776
+ pipeline: [{ $project: { _id: 0, name: 1, block: 1 } }],
8777
+ as: "blockInfo"
8778
+ }
8779
+ },
8780
+ { $unwind: { path: "$blockInfo", preserveNullAndEmptyArrays: true } },
8781
+ {
8782
+ $lookup: {
8783
+ from: "building-levels",
8784
+ localField: "level",
8785
+ foreignField: "_id",
8786
+ pipeline: [{ $project: { _id: 0, name: 1 } }],
8787
+ as: "levelInfo"
8788
+ }
8789
+ },
8790
+ { $unwind: { path: "$levelInfo", preserveNullAndEmptyArrays: true } },
8791
+ {
8792
+ $lookup: {
8793
+ from: "building-units",
8794
+ localField: "unitId",
8795
+ foreignField: "_id",
8796
+ pipeline: [{ $project: { _id: 0, name: 1 } }],
8797
+ as: "unitInfo"
8798
+ }
8799
+ },
8800
+ { $unwind: { path: "$unitInfo", preserveNullAndEmptyArrays: true } }
8775
8801
  ]).toArray();
8776
8802
  const data = results.length > 0 ? results[0] : null;
8777
8803
  if (!data) {
8778
8804
  throw new import_node_server_utils10.NotFoundError("User not found.");
8779
8805
  }
8780
- setCache(cacheKey, data, 15 * 60).then(() => {
8781
- import_node_server_utils10.logger.info(`Cache set for key: ${cacheKey}`);
8782
- }).catch((err) => {
8783
- import_node_server_utils10.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
8784
- });
8785
8806
  return data;
8786
8807
  } catch (error) {
8787
8808
  if (error instanceof import_node_server_utils10.AppError) {
@@ -23661,8 +23682,8 @@ function useDahuaService() {
23661
23682
  name: resident?.name,
23662
23683
  nric: resident?.nric,
23663
23684
  contact: resident?.phoneNumber,
23664
- block: resident?.block,
23665
- level: resident?.level,
23685
+ block: resident?.block?.toString(),
23686
+ level: resident?.level?.toString(),
23666
23687
  unit: resident?.unit?.toString(),
23667
23688
  unitName: resident?.unitName,
23668
23689
  type: resident?.category,
@@ -23683,20 +23704,21 @@ function useDahuaService() {
23683
23704
  await checkOutBySiteAndPlate(camera.site, plateNumber2);
23684
23705
  const resident = await getVehicleBySiteAndPlateNumber(plateNumber2, camera?.site, "resident", "active");
23685
23706
  if (resident?._id) {
23686
- insert = await add({
23707
+ const data = {
23687
23708
  site,
23688
23709
  plateNumber: plateNumber2,
23689
23710
  name: resident?.name,
23690
23711
  nric: resident?.nric,
23691
23712
  contact: resident?.phoneNumber,
23692
- block: resident?.block,
23693
- level: resident?.level,
23713
+ block: resident?.block?.toString(),
23714
+ level: resident?.level?.toString(),
23694
23715
  unit: resident?.unit?.toString(),
23695
23716
  unitName: resident?.unitName,
23696
23717
  type: resident?.category,
23697
23718
  status: "registered" /* REGISTERED */
23698
23719
  // expiredAt: resident?.end,
23699
- }, void 0, true);
23720
+ };
23721
+ insert = await add(data, void 0, true);
23700
23722
  loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Resident with plate ${plateNumber2} and transaction ID ${insert?._id}`);
23701
23723
  }
23702
23724
  } else if (cameraType == "visitors" && ANPRSwitches?.enableUnregistered) {
@@ -25813,6 +25835,22 @@ function useBuildingUnitRepo() {
25813
25835
  }
25814
25836
  return [level];
25815
25837
  }
25838
+ function escapeRegExp(value) {
25839
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25840
+ }
25841
+ function makeFlexibleRegex(value) {
25842
+ const pattern = value.trim().split(/\s+/).map(escapeRegExp).join("\\s*");
25843
+ return pattern ? new RegExp(pattern, "i") : null;
25844
+ }
25845
+ function getSearchParts(searchText) {
25846
+ const levelMatch = searchText.match(/\b(?:lvl|level)\s*([a-z0-9]+)\b/i);
25847
+ const levelSearch = levelMatch?.[0] ?? "";
25848
+ const unitSearch = levelSearch ? searchText.replace(levelSearch, "").trim() : "";
25849
+ return {
25850
+ levelRegex: makeFlexibleRegex(levelSearch),
25851
+ unitRegex: makeFlexibleRegex(unitSearch)
25852
+ };
25853
+ }
25816
25854
  async function add(value, session) {
25817
25855
  try {
25818
25856
  value = MBuildingUnit(value);
@@ -25938,9 +25976,11 @@ function useBuildingUnitRepo() {
25938
25976
  status = "active"
25939
25977
  } = {}) {
25940
25978
  page = page > 0 ? page - 1 : 0;
25979
+ const searchText = search.trim();
25980
+ const searchRegex = makeFlexibleRegex(searchText);
25981
+ const { levelRegex, unitRegex } = getSearchParts(searchText);
25941
25982
  const query = {
25942
25983
  status,
25943
- ...search && { $text: { $search: search } },
25944
25984
  ...site && { site: (0, import_node_server_utils76.toObjectId)(site) },
25945
25985
  ...building && { building: (0, import_node_server_utils76.toObjectId)(building) }
25946
25986
  };
@@ -25949,7 +25989,7 @@ function useBuildingUnitRepo() {
25949
25989
  page,
25950
25990
  limit,
25951
25991
  sort: JSON.stringify(sort),
25952
- ...search && { search },
25992
+ ...searchText && { search: searchText },
25953
25993
  ...site && { site },
25954
25994
  ...building && { building },
25955
25995
  ...status && { status }
@@ -25971,8 +26011,45 @@ function useBuildingUnitRepo() {
25971
26011
  });
25972
26012
  return cached;
25973
26013
  }
25974
- const items = await collection.aggregate([
26014
+ const pipeline = [
25975
26015
  { $match: query },
26016
+ {
26017
+ $lookup: {
26018
+ from: "building-levels",
26019
+ localField: "level",
26020
+ foreignField: "_id",
26021
+ pipeline: [{ $project: { name: 1 } }],
26022
+ as: "level"
26023
+ }
26024
+ },
26025
+ { $set: { level: { $first: "$level" } } },
26026
+ ...searchRegex ? [
26027
+ {
26028
+ $match: {
26029
+ $or: [
26030
+ { name: searchRegex },
26031
+ { buildingName: searchRegex },
26032
+ { "level.name": searchRegex },
26033
+ ...levelRegex && unitRegex ? [
26034
+ {
26035
+ $and: [
26036
+ {
26037
+ $or: [
26038
+ { name: unitRegex },
26039
+ { buildingName: unitRegex }
26040
+ ]
26041
+ },
26042
+ { "level.name": levelRegex }
26043
+ ]
26044
+ }
26045
+ ] : []
26046
+ ]
26047
+ }
26048
+ }
26049
+ ] : []
26050
+ ];
26051
+ const items = await collection.aggregate([
26052
+ ...pipeline,
25976
26053
  {
25977
26054
  $lookup: {
25978
26055
  from: "sites",
@@ -25998,22 +26075,13 @@ function useBuildingUnitRepo() {
25998
26075
  as: "site"
25999
26076
  }
26000
26077
  },
26001
- {
26002
- $lookup: {
26003
- from: "building-levels",
26004
- localField: "level",
26005
- foreignField: "_id",
26006
- pipeline: [{ $project: { name: 1 } }],
26007
- as: "level"
26008
- }
26009
- },
26010
- { $set: { level: { $first: "$level" } } },
26011
26078
  { $set: { site: { $first: "$site" } } },
26012
26079
  { $sort: sort },
26013
26080
  { $skip: page * limit },
26014
26081
  { $limit: limit }
26015
26082
  ]).toArray();
26016
- const length = await collection.countDocuments(query);
26083
+ const total = await collection.aggregate([...pipeline, { $count: "length" }]).toArray();
26084
+ const length = total[0]?.length ?? 0;
26017
26085
  const data = (0, import_node_server_utils76.paginate)(items, page, limit, length);
26018
26086
  setCache(cacheKey, data, 600).then(() => {
26019
26087
  import_node_server_utils76.logger.log({
@@ -28102,6 +28170,7 @@ function useBuildingRepo() {
28102
28170
  { key: { name: "text" }, name: "text-index" },
28103
28171
  // { key: { name: 1 }, unique: true, name: "unique-name-index" },
28104
28172
  { key: { site: 1 } },
28173
+ { key: { block: 1 }, name: "block-index" },
28105
28174
  { key: { createdAt: 1 } },
28106
28175
  {
28107
28176
  key: { site: 1, block: 1 },
@@ -28204,17 +28273,25 @@ function useBuildingRepo() {
28204
28273
  throw new import_node_server_utils83.BadRequestError("Invalid site ID.");
28205
28274
  }
28206
28275
  }
28276
+ const searchText = search.trim();
28277
+ const blockSearch = Number(searchText);
28278
+ const canSearchBlock = searchText !== "" && Number.isFinite(blockSearch);
28207
28279
  const query = {
28208
28280
  status,
28209
- ...search && { $text: { $search: search } },
28210
- ...siteId && { site: siteId }
28281
+ ...siteId && { site: siteId },
28282
+ ...searchText && {
28283
+ $or: [
28284
+ { $text: { $search: searchText } },
28285
+ ...canSearchBlock ? [{ block: blockSearch }] : []
28286
+ ]
28287
+ }
28211
28288
  };
28212
28289
  sort = Object.keys(sort).length ? sort : { _id: -1 };
28213
28290
  const cacheParams = {
28214
28291
  page,
28215
28292
  limit,
28216
28293
  sort: JSON.stringify(sort),
28217
- ...search && { search },
28294
+ ...searchText && { search: searchText },
28218
28295
  ...site && { site },
28219
28296
  ...status && { status }
28220
28297
  };
@@ -29975,6 +30052,24 @@ function useBuildingUnitController() {
29975
30052
  getAllLevelsWithUnits: _getAllLevelsWithUnits
29976
30053
  } = useBuildingUnitRepo();
29977
30054
  const { add: _add, updateById: _updateById } = useBuildingUnitService();
30055
+ function normalizeQueryString(value) {
30056
+ if (Array.isArray(value)) {
30057
+ for (const item of value) {
30058
+ const normalized = normalizeQueryString(item);
30059
+ if (normalized)
30060
+ return normalized;
30061
+ }
30062
+ return "";
30063
+ }
30064
+ if (value && typeof value === "object") {
30065
+ for (const item of Object.values(value)) {
30066
+ const normalized = normalizeQueryString(item);
30067
+ if (normalized)
30068
+ return normalized;
30069
+ }
30070
+ }
30071
+ return typeof value === "string" ? value : "";
30072
+ }
29978
30073
  async function add(req, res, next) {
29979
30074
  const data = req.body;
29980
30075
  const validation = import_joi47.default.object({
@@ -30048,7 +30143,11 @@ function useBuildingUnitController() {
30048
30143
  sort: import_joi47.default.string().valid(...Object.values(SortFields)).default("_id" /* ID */),
30049
30144
  order: import_joi47.default.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
30050
30145
  });
30051
- const { error, value } = validation.validate(req.query, {
30146
+ const query = {
30147
+ ...req.query,
30148
+ search: normalizeQueryString(req.query.search)
30149
+ };
30150
+ const { error, value } = validation.validate(query, {
30052
30151
  abortEarly: false
30053
30152
  });
30054
30153
  if (error) {
@@ -30209,7 +30308,11 @@ function useBuildingUnitController() {
30209
30308
  order: import_joi47.default.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */),
30210
30309
  level: import_joi47.default.string().hex().length(24).optional().allow(null, "")
30211
30310
  });
30212
- const { error, value } = validation.validate(req.query, {
30311
+ const query = {
30312
+ ...req.query,
30313
+ search: normalizeQueryString(req.query.search)
30314
+ };
30315
+ const { error, value } = validation.validate(query, {
30213
30316
  abortEarly: false
30214
30317
  });
30215
30318
  if (error) {
@@ -45266,6 +45369,31 @@ async function getTransactions(index, url) {
45266
45369
  return Promise.reject(error);
45267
45370
  }
45268
45371
  }
45372
+ function encryptPayload(payloadHex) {
45373
+ const buffer = Buffer.from(payloadHex, "ascii");
45374
+ const encrypted = import_crypto.default.publicEncrypt(
45375
+ {
45376
+ key: "testing",
45377
+ padding: import_crypto.default.constants.RSA_PKCS1_PADDING
45378
+ },
45379
+ buffer
45380
+ );
45381
+ return encrypted.toString("base64");
45382
+ }
45383
+ function toHex(num, length) {
45384
+ return num.toString(16).padStart(length * 2, "0");
45385
+ }
45386
+ function buildPayload(cardNumber, validityMinutes) {
45387
+ const randomHex = import_crypto.default.randomBytes(2).toString("hex");
45388
+ const cardHex = toHex(cardNumber, 4);
45389
+ const epochHex = toHex(Math.floor(Date.now() / 1e3), 4);
45390
+ const validityHex = toHex(validityMinutes, 2);
45391
+ return randomHex + cardHex + epochHex + validityHex;
45392
+ }
45393
+ function generateQrCodeData(cardNumber, validityMinutes) {
45394
+ const payloadHex = buildPayload(cardNumber, validityMinutes);
45395
+ return encryptPayload(payloadHex);
45396
+ }
45269
45397
 
45270
45398
  // src/repositories/access-management.repo.ts
45271
45399
  var import_xml2js2 = require("xml2js");
@@ -48515,6 +48643,14 @@ function useAccessManagementSvc() {
48515
48643
  throw new Error(err.message);
48516
48644
  }
48517
48645
  };
48646
+ const generateQrCodeWithExpirySvc = async ({ cardNumber, validityMinutes }) => {
48647
+ try {
48648
+ const response = generateQrCodeData(cardNumber, validityMinutes);
48649
+ return response;
48650
+ } catch (error) {
48651
+ throw new Error(error.message);
48652
+ }
48653
+ };
48518
48654
  return {
48519
48655
  addPhysicalCardSvc,
48520
48656
  addNonPhysicalCardSvc,
@@ -48557,7 +48693,8 @@ function useAccessManagementSvc() {
48557
48693
  getResidentsSvc,
48558
48694
  userAccessCardsSvc,
48559
48695
  removeTemplateSvc,
48560
- qrCodeListSvc
48696
+ qrCodeListSvc,
48697
+ generateQrCodeWithExpirySvc
48561
48698
  };
48562
48699
  }
48563
48700
 
@@ -48605,7 +48742,8 @@ function useAccessManagementController() {
48605
48742
  getResidentsSvc,
48606
48743
  userAccessCardsSvc,
48607
48744
  removeTemplateSvc,
48608
- qrCodeListSvc
48745
+ qrCodeListSvc,
48746
+ generateQrCodeWithExpirySvc
48609
48747
  } = useAccessManagementSvc();
48610
48748
  const addPhysicalCard = async (req, res) => {
48611
48749
  try {
@@ -49717,6 +49855,23 @@ function useAccessManagementController() {
49717
49855
  });
49718
49856
  }
49719
49857
  };
49858
+ const generateQrCodeWithExpiry = async (req, res) => {
49859
+ try {
49860
+ const { cardNumber, validityMinutes } = req.body;
49861
+ const result = await generateQrCodeWithExpirySvc({ cardNumber, validityMinutes });
49862
+ return res.status(200).json({
49863
+ message: "successful!",
49864
+ data: {
49865
+ result
49866
+ }
49867
+ });
49868
+ } catch (error) {
49869
+ return res.status(400).json({
49870
+ data: null,
49871
+ message: error.message
49872
+ });
49873
+ }
49874
+ };
49720
49875
  return {
49721
49876
  addPhysicalCard,
49722
49877
  addNonPhysicalCard,
@@ -49757,7 +49912,8 @@ function useAccessManagementController() {
49757
49912
  getResidents,
49758
49913
  userAccessCards,
49759
49914
  removeTemplate,
49760
- qrCodeList
49915
+ qrCodeList,
49916
+ generateQrCodeWithExpiry
49761
49917
  };
49762
49918
  }
49763
49919
 
@@ -57044,14 +57200,14 @@ function useNewDashboardRepo() {
57044
57200
  site: { $in: [siteIdObj, siteId] },
57045
57201
  service: "Security",
57046
57202
  createdAt: periodRange,
57047
- status: { $nin: ["completed"] }
57203
+ status: { $nin: ["Completed", "Deleted"] }
57048
57204
  }
57049
57205
  },
57050
57206
  {
57051
57207
  $facet: {
57052
57208
  total: [{ $count: "count" }],
57053
57209
  inProgress: [
57054
- { $match: { status: "in-progress" } },
57210
+ { $match: { status: "In-Progress" } },
57055
57211
  { $count: "count" }
57056
57212
  ]
57057
57213
  }
@@ -57063,7 +57219,7 @@ function useNewDashboardRepo() {
57063
57219
  site: { $in: [siteIdObj, siteId] },
57064
57220
  service: "Security",
57065
57221
  createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57066
- status: { $nin: ["completed"] }
57222
+ status: { $nin: ["Completed", "Deleted"] }
57067
57223
  }
57068
57224
  },
57069
57225
  { $count: "count" }
@@ -57074,7 +57230,7 @@ function useNewDashboardRepo() {
57074
57230
  site: { $in: [siteIdObj, siteId] },
57075
57231
  service: "Security",
57076
57232
  createdAt: { $gte: today, $lte: todayEnd },
57077
- status: { $nin: ["completed"] }
57233
+ status: { $nin: ["Completed", "Deleted"] }
57078
57234
  }
57079
57235
  },
57080
57236
  { $count: "count" }
@@ -57083,7 +57239,7 @@ function useNewDashboardRepo() {
57083
57239
  {
57084
57240
  $match: {
57085
57241
  site: { $in: [siteIdObj, siteId] },
57086
- status: { $in: ["pending", "Pending"] },
57242
+ status: { $in: ["pending"] },
57087
57243
  createdAt: periodRange
57088
57244
  }
57089
57245
  },
@@ -57093,7 +57249,7 @@ function useNewDashboardRepo() {
57093
57249
  {
57094
57250
  $match: {
57095
57251
  site: { $in: [siteIdObj, siteId] },
57096
- status: { $in: ["pending", "Pending"] },
57252
+ status: { $in: ["pending"] },
57097
57253
  createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57098
57254
  }
57099
57255
  },
@@ -57103,7 +57259,7 @@ function useNewDashboardRepo() {
57103
57259
  {
57104
57260
  $match: {
57105
57261
  site: { $in: [siteIdObj, siteId] },
57106
- status: { $in: ["pending", "Pending"] },
57262
+ status: { $in: ["pending"] },
57107
57263
  createdAt: { $gte: today, $lte: todayEnd }
57108
57264
  }
57109
57265
  },
@@ -57385,11 +57541,11 @@ function useNewDashboardRepo() {
57385
57541
  [
57386
57542
  db.collection(incidents_namespace_collection).find({
57387
57543
  site: { $in: [siteIdObj, siteId] },
57388
- status: { $in: ["pending", "Pending"] }
57544
+ status: { $in: ["pending"] }
57389
57545
  }).sort({ createdAt: -1 }).toArray(),
57390
57546
  db.collection(facility_bookings_namespace_collection2).find({
57391
57547
  site: { $in: [siteIdObj, siteId] },
57392
- status: { $in: ["Pending", "pending", "For Review", "for review"] }
57548
+ status: { $in: ["Pending", "For Review"] }
57393
57549
  }).sort({ createdAt: -1 }).toArray()
57394
57550
  ]
57395
57551
  );
@@ -57398,14 +57554,16 @@ function useNewDashboardRepo() {
57398
57554
  const todayAttentions = [];
57399
57555
  if (pendingIncidentCount > 0) {
57400
57556
  todayAttentions.push({
57401
- id: "incidents-pending",
57557
+ id: pendingIncidentDocs[0]._id.toString(),
57558
+ type: "incident",
57402
57559
  title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"} pending acknowledge`,
57403
57560
  createdAt: pendingIncidentDocs[0].updatedAt || pendingIncidentDocs[0].createdAt || /* @__PURE__ */ new Date()
57404
57561
  });
57405
57562
  }
57406
57563
  if (pendingFacilityBookingCount > 0) {
57407
57564
  todayAttentions.push({
57408
- id: "facility-booking-pending",
57565
+ id: pendingFacilityBookingDocs[0]._id.toString(),
57566
+ type: "facility-booking",
57409
57567
  title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"} need approval`,
57410
57568
  createdAt: pendingFacilityBookingDocs[0].createdAt || /* @__PURE__ */ new Date()
57411
57569
  });
@@ -57460,14 +57618,14 @@ function useNewDashboardRepo() {
57460
57618
  $match: {
57461
57619
  site: { $in: [siteIdObj, siteId] },
57462
57620
  createdAt: periodRange,
57463
- status: { $nin: ["completed"] }
57621
+ status: { $nin: ["Completed", "Deleted"] }
57464
57622
  }
57465
57623
  },
57466
57624
  {
57467
57625
  $facet: {
57468
57626
  total: [{ $count: "count" }],
57469
57627
  inProgress: [
57470
- { $match: { status: "in-progress" } },
57628
+ { $match: { status: "In-Progress" } },
57471
57629
  { $count: "count" }
57472
57630
  ]
57473
57631
  }
@@ -57478,7 +57636,7 @@ function useNewDashboardRepo() {
57478
57636
  $match: {
57479
57637
  site: { $in: [siteIdObj, siteId] },
57480
57638
  createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57481
- status: { $nin: ["completed"] }
57639
+ status: { $nin: ["Completed", "Deleted"] }
57482
57640
  }
57483
57641
  },
57484
57642
  { $count: "count" }
@@ -57488,7 +57646,7 @@ function useNewDashboardRepo() {
57488
57646
  $match: {
57489
57647
  site: { $in: [siteIdObj, siteId] },
57490
57648
  createdAt: { $gte: today, $lte: todayEnd },
57491
- status: { $nin: ["completed"] }
57649
+ status: { $nin: ["Completed", "Deleted"] }
57492
57650
  }
57493
57651
  },
57494
57652
  { $count: "count" }
@@ -57497,7 +57655,7 @@ function useNewDashboardRepo() {
57497
57655
  {
57498
57656
  $match: {
57499
57657
  site: { $in: [siteIdObj, siteId] },
57500
- status: { $in: ["pending", "Pending"] },
57658
+ status: { $in: ["pending"] },
57501
57659
  createdAt: periodRange
57502
57660
  }
57503
57661
  },
@@ -57507,7 +57665,7 @@ function useNewDashboardRepo() {
57507
57665
  {
57508
57666
  $match: {
57509
57667
  site: { $in: [siteIdObj, siteId] },
57510
- status: { $in: ["pending", "Pending"] },
57668
+ status: { $in: ["pending"] },
57511
57669
  createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57512
57670
  }
57513
57671
  },
@@ -57517,7 +57675,7 @@ function useNewDashboardRepo() {
57517
57675
  {
57518
57676
  $match: {
57519
57677
  site: { $in: [siteIdObj, siteId] },
57520
- status: { $in: ["pending", "Pending"] },
57678
+ status: { $in: ["pending"] },
57521
57679
  createdAt: { $gte: today, $lte: todayEnd }
57522
57680
  }
57523
57681
  },
@@ -57767,6 +57925,13 @@ function useNewDashboardRepo() {
57767
57925
  const periodRange = getDateRange(period);
57768
57926
  try {
57769
57927
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
57928
+ const workOrderMatchQuery = {
57929
+ site,
57930
+ status: { $nin: ["Completed", "Deleted"] }
57931
+ };
57932
+ if (serviceType !== "property_management_agency") {
57933
+ workOrderMatchQuery.service = workOrderService;
57934
+ }
57770
57935
  const [
57771
57936
  workOrderReport,
57772
57937
  supplyAlertReport,
@@ -57779,17 +57944,15 @@ function useNewDashboardRepo() {
57779
57944
  workOrderCollection.aggregate([
57780
57945
  {
57781
57946
  $match: {
57782
- site,
57783
- service: workOrderService,
57784
- createdAt: periodRange,
57785
- status: { $nin: ["completed"] }
57947
+ ...workOrderMatchQuery,
57948
+ createdAt: periodRange
57786
57949
  }
57787
57950
  },
57788
57951
  {
57789
57952
  $facet: {
57790
57953
  total: [{ $count: "count" }],
57791
57954
  inProgress: [
57792
- { $match: { status: "in-progress" } },
57955
+ { $match: { status: "In-Progress" } },
57793
57956
  { $count: "count" }
57794
57957
  ]
57795
57958
  }
@@ -57820,10 +57983,8 @@ function useNewDashboardRepo() {
57820
57983
  workOrderCollection.aggregate([
57821
57984
  {
57822
57985
  $match: {
57823
- site,
57824
- service: workOrderService,
57825
- createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57826
- status: { $nin: ["completed"] }
57986
+ ...workOrderMatchQuery,
57987
+ createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57827
57988
  }
57828
57989
  },
57829
57990
  { $count: "count" }
@@ -57831,10 +57992,8 @@ function useNewDashboardRepo() {
57831
57992
  workOrderCollection.aggregate([
57832
57993
  {
57833
57994
  $match: {
57834
- site,
57835
- service: workOrderService,
57836
- createdAt: { $gte: today, $lte: todayEnd },
57837
- status: { $nin: ["completed"] }
57995
+ ...workOrderMatchQuery,
57996
+ createdAt: { $gte: today, $lte: todayEnd }
57838
57997
  }
57839
57998
  },
57840
57999
  { $count: "count" }
@@ -57937,10 +58096,9 @@ function useNewDashboardRepo() {
57937
58096
  throw new import_node_server_utils199.BadRequestError("Invalid period.");
57938
58097
  }
57939
58098
  try {
57940
- const workOrders = await workOrderCollection.find({
58099
+ const workOrderQuery = {
57941
58100
  site,
57942
- service: workOrderService,
57943
- status: { $nin: ["deleted", "Deleted"] },
58101
+ status: { $nin: ["Deleted"] },
57944
58102
  $or: [
57945
58103
  { createdAt: { $gte: rangeStart, $lte: rangeEnd } },
57946
58104
  {
@@ -57950,7 +58108,11 @@ function useNewDashboardRepo() {
57950
58108
  }
57951
58109
  }
57952
58110
  ]
57953
- }).project({ status: 1, createdAt: 1 }).toArray();
58111
+ };
58112
+ if (serviceType !== "property_management_agency") {
58113
+ workOrderQuery.service = workOrderService;
58114
+ }
58115
+ const workOrders = await workOrderCollection.find(workOrderQuery).project({ status: 1, createdAt: 1 }).toArray();
57954
58116
  const chartData = labels.map((label) => ({
57955
58117
  day: label,
57956
58118
  label,
@@ -58047,6 +58209,7 @@ function useNewDashboardRepo() {
58047
58209
  name: 1,
58048
58210
  type: 1,
58049
58211
  status: 1,
58212
+ schedule: 1,
58050
58213
  assigneeName: { $arrayElemAt: ["$_assigneeDoc.name", 0] }
58051
58214
  }
58052
58215
  },
@@ -58211,7 +58374,10 @@ function useNewDashboardRepo() {
58211
58374
  throw new import_node_server_utils199.BadRequestError("Invalid site ID format.");
58212
58375
  }
58213
58376
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
58214
- const matchQuery = { site, service: workOrderService };
58377
+ const matchQuery = { site };
58378
+ if (serviceType !== "property_management_agency") {
58379
+ matchQuery.service = workOrderService;
58380
+ }
58215
58381
  if (period) {
58216
58382
  matchQuery.createdAt = getDateRange(period);
58217
58383
  }
@@ -65428,7 +65594,7 @@ function usePostFavoriteService() {
65428
65594
  });
65429
65595
  }
65430
65596
  await session?.commitTransaction();
65431
- return "Successfully added to favorites.";
65597
+ return "Successfully added to post-preloved.";
65432
65598
  } catch (error) {
65433
65599
  await session?.abortTransaction();
65434
65600
  throw error;
@@ -66821,9 +66987,112 @@ function useChatPrelovedController() {
66821
66987
  return { add, updateById, deleteById };
66822
66988
  }
66823
66989
 
66824
- // src/controllers/channel-preloved.controller.ts
66825
- var import_node_server_utils249 = require("@7365admin1/node-server-utils");
66990
+ // src/events/chat-preloved.event.ts
66826
66991
  var import_joi144 = __toESM(require("joi"));
66992
+ var import_node_server_utils249 = require("@7365admin1/node-server-utils");
66993
+ function parseSid(cookieHeader) {
66994
+ const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
66995
+ return match ? decodeURIComponent(match[1]) : null;
66996
+ }
66997
+ var schemaSendMessage = import_joi144.default.object({
66998
+ receiverId: import_joi144.default.string().hex().length(24).required(),
66999
+ channelId: import_joi144.default.string().hex().length(24).optional().allow("", null),
67000
+ senderId: import_joi144.default.string().hex().length(24).required(),
67001
+ postId: import_joi144.default.string().hex().length(24).optional().allow("", null),
67002
+ message: import_joi144.default.object({
67003
+ text: import_joi144.default.string().required(),
67004
+ date: import_joi144.default.date().optional().allow(null),
67005
+ time: import_joi144.default.string().optional().allow("", null),
67006
+ senderId: import_joi144.default.string().hex().length(24).required()
67007
+ }).required(),
67008
+ readMessage: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
67009
+ viewMessage: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
67010
+ attachments: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
67011
+ reactions: import_joi144.default.string().optional().allow("", null).default(""),
67012
+ bidId: import_joi144.default.string().hex().length(24).optional().allow("", null),
67013
+ edited: import_joi144.default.boolean().optional().default(false)
67014
+ });
67015
+ var schemaTyping = import_joi144.default.object({
67016
+ receiverId: import_joi144.default.string().hex().length(24).required(),
67017
+ fromUserId: import_joi144.default.string().hex().length(24).required(),
67018
+ senderName: import_joi144.default.string().required()
67019
+ });
67020
+ var schemaChatMessageDeleted = import_joi144.default.object({
67021
+ messageId: import_joi144.default.string().hex().length(24).required(),
67022
+ receiverId: import_joi144.default.string().hex().length(24).required()
67023
+ });
67024
+ function chatPrelovedEvents(io) {
67025
+ const namespace = io.of(/^\/chat-channel-[0-9a-fA-F]{24}$/);
67026
+ namespace.use(async (socket, next) => {
67027
+ try {
67028
+ const cookieHeader = socket.handshake.headers.cookie || "";
67029
+ let sid = parseSid(cookieHeader);
67030
+ if (!sid && socket.handshake.auth?.token) {
67031
+ sid = socket.handshake.auth.token;
67032
+ }
67033
+ if (!sid) {
67034
+ return next(new Error("Unauthorized"));
67035
+ }
67036
+ const { getCache } = (0, import_node_server_utils249.useCache)("sessions");
67037
+ const sessionData = await getCache(`sid:${sid}`);
67038
+ if (!sessionData) {
67039
+ return next(new Error("Session expired or invalid"));
67040
+ }
67041
+ const session = sessionData;
67042
+ socket.data.userId = (session._id ?? sessionData).toString();
67043
+ next();
67044
+ } catch (error) {
67045
+ import_node_server_utils249.logger.log({ level: "error", message: `Socket auth error: ${error.message}` });
67046
+ next(new Error("Authentication error"));
67047
+ }
67048
+ });
67049
+ namespace.on("connection", (socket) => {
67050
+ const userId = socket.data.userId;
67051
+ socket.join(userId);
67052
+ socket.on("sendMessage", (payload) => {
67053
+ const { error, value } = schemaSendMessage.validate(payload, {
67054
+ abortEarly: false
67055
+ });
67056
+ if (error) {
67057
+ const message = error.details.map((d) => d.message).join(", ");
67058
+ socket.emit("error", { event: "sendMessage", message });
67059
+ return;
67060
+ }
67061
+ namespace.to(value.receiverId).emit("receiveMessage", value);
67062
+ });
67063
+ socket.on("typing", (data) => {
67064
+ const { error, value } = schemaTyping.validate(data, {
67065
+ abortEarly: false
67066
+ });
67067
+ if (error) {
67068
+ const message = error.details.map((d) => d.message).join(", ");
67069
+ socket.emit("error", { event: "typing", message });
67070
+ return;
67071
+ }
67072
+ namespace.to(value.receiverId).emit("TypingNow", value);
67073
+ });
67074
+ socket.on("chatMessageDeleted", (data) => {
67075
+ const { error, value } = schemaChatMessageDeleted.validate(data, {
67076
+ abortEarly: false
67077
+ });
67078
+ if (error) {
67079
+ const message = error.details.map((d) => d.message).join(", ");
67080
+ socket.emit("error", { event: "chatMessageDeleted", message });
67081
+ return;
67082
+ }
67083
+ namespace.to(value.receiverId).emit("chatMessageDeleted", {
67084
+ messageId: value.messageId
67085
+ });
67086
+ });
67087
+ socket.on("disconnect", () => {
67088
+ socket.leave(userId);
67089
+ });
67090
+ });
67091
+ }
67092
+
67093
+ // src/controllers/channel-preloved.controller.ts
67094
+ var import_node_server_utils250 = require("@7365admin1/node-server-utils");
67095
+ var import_joi145 = __toESM(require("joi"));
66827
67096
  function useChannelPrelovedController() {
66828
67097
  const {
66829
67098
  add: _add,
@@ -66837,40 +67106,40 @@ function useChannelPrelovedController() {
66837
67106
  });
66838
67107
  if (error) {
66839
67108
  const messages = error.details.map((d) => d.message).join(", ");
66840
- import_node_server_utils249.logger.log({ level: "error", message: messages });
66841
- next(new import_node_server_utils249.BadRequestError(messages));
67109
+ import_node_server_utils250.logger.log({ level: "error", message: messages });
67110
+ next(new import_node_server_utils250.BadRequestError(messages));
66842
67111
  return;
66843
67112
  }
66844
67113
  try {
66845
67114
  const data = await _add(value);
66846
67115
  res.status(201).json(data);
66847
67116
  } catch (error2) {
66848
- import_node_server_utils249.logger.log({ level: "error", message: error2.message });
67117
+ import_node_server_utils250.logger.log({ level: "error", message: error2.message });
66849
67118
  next(error2);
66850
67119
  }
66851
67120
  }
66852
67121
  async function getChannelMessages(req, res, next) {
66853
- const paramsSchema = import_joi144.default.object({
66854
- id: import_joi144.default.string().hex().length(24).required()
67122
+ const paramsSchema = import_joi145.default.object({
67123
+ id: import_joi145.default.string().hex().length(24).required()
66855
67124
  });
66856
- const querySchema = import_joi144.default.object({
66857
- page: import_joi144.default.number().integer().min(1).default(1),
66858
- limit: import_joi144.default.number().integer().min(1).max(100).default(10),
66859
- isLoadMore: import_joi144.default.boolean().default(false),
66860
- lastMessageId: import_joi144.default.string().hex().length(24).optional().allow("", null)
67125
+ const querySchema = import_joi145.default.object({
67126
+ page: import_joi145.default.number().integer().min(1).default(1),
67127
+ limit: import_joi145.default.number().integer().min(1).max(100).default(10),
67128
+ isLoadMore: import_joi145.default.boolean().default(false),
67129
+ lastMessageId: import_joi145.default.string().hex().length(24).optional().allow("", null)
66861
67130
  });
66862
67131
  const { error: paramError, value: params } = paramsSchema.validate(
66863
67132
  req.params
66864
67133
  );
66865
67134
  if (paramError) {
66866
- import_node_server_utils249.logger.log({ level: "error", message: paramError.message });
66867
- next(new import_node_server_utils249.BadRequestError(paramError.message));
67135
+ import_node_server_utils250.logger.log({ level: "error", message: paramError.message });
67136
+ next(new import_node_server_utils250.BadRequestError(paramError.message));
66868
67137
  return;
66869
67138
  }
66870
67139
  const { error: queryError, value: query } = querySchema.validate(req.query);
66871
67140
  if (queryError) {
66872
- import_node_server_utils249.logger.log({ level: "error", message: queryError.message });
66873
- next(new import_node_server_utils249.BadRequestError(queryError.message));
67141
+ import_node_server_utils250.logger.log({ level: "error", message: queryError.message });
67142
+ next(new import_node_server_utils250.BadRequestError(queryError.message));
66874
67143
  return;
66875
67144
  }
66876
67145
  try {
@@ -66883,20 +67152,20 @@ function useChannelPrelovedController() {
66883
67152
  );
66884
67153
  res.status(200).json(data);
66885
67154
  } catch (error) {
66886
- import_node_server_utils249.logger.log({ level: "error", message: error.message });
67155
+ import_node_server_utils250.logger.log({ level: "error", message: error.message });
66887
67156
  next(error);
66888
67157
  }
66889
67158
  }
66890
67159
  async function getChannel(req, res, next) {
66891
- const querySchema = import_joi144.default.object({
66892
- postId: import_joi144.default.string().hex().length(24).required(),
66893
- receiverId: import_joi144.default.string().hex().length(24).required(),
66894
- senderId: import_joi144.default.string().hex().length(24).required()
67160
+ const querySchema = import_joi145.default.object({
67161
+ postId: import_joi145.default.string().hex().length(24).required(),
67162
+ receiverId: import_joi145.default.string().hex().length(24).required(),
67163
+ senderId: import_joi145.default.string().hex().length(24).required()
66895
67164
  });
66896
67165
  const { error, value } = querySchema.validate(req.query);
66897
67166
  if (error) {
66898
- import_node_server_utils249.logger.log({ level: "error", message: error.message });
66899
- next(new import_node_server_utils249.BadRequestError(error.message));
67167
+ import_node_server_utils250.logger.log({ level: "error", message: error.message });
67168
+ next(new import_node_server_utils250.BadRequestError(error.message));
66900
67169
  return;
66901
67170
  }
66902
67171
  try {
@@ -66907,21 +67176,21 @@ function useChannelPrelovedController() {
66907
67176
  );
66908
67177
  res.status(200).json(data);
66909
67178
  } catch (error2) {
66910
- import_node_server_utils249.logger.log({ level: "error", message: error2.message });
67179
+ import_node_server_utils250.logger.log({ level: "error", message: error2.message });
66911
67180
  next(error2);
66912
67181
  }
66913
67182
  }
66914
67183
  async function getChatLists(req, res, next) {
66915
- const querySchema = import_joi144.default.object({
66916
- currentUserId: import_joi144.default.string().hex().length(24).required(),
66917
- page: import_joi144.default.number().integer().min(1).default(1),
66918
- limit: import_joi144.default.number().integer().min(1).max(100).default(10),
66919
- search: import_joi144.default.string().optional().allow("", null)
67184
+ const querySchema = import_joi145.default.object({
67185
+ currentUserId: import_joi145.default.string().hex().length(24).required(),
67186
+ page: import_joi145.default.number().integer().min(1).default(1),
67187
+ limit: import_joi145.default.number().integer().min(1).max(100).default(10),
67188
+ search: import_joi145.default.string().optional().allow("", null)
66920
67189
  });
66921
67190
  const { error, value } = querySchema.validate(req.query);
66922
67191
  if (error) {
66923
- import_node_server_utils249.logger.log({ level: "error", message: error.message });
66924
- next(new import_node_server_utils249.BadRequestError(error.message));
67192
+ import_node_server_utils250.logger.log({ level: "error", message: error.message });
67193
+ next(new import_node_server_utils250.BadRequestError(error.message));
66925
67194
  return;
66926
67195
  }
66927
67196
  try {
@@ -66933,7 +67202,7 @@ function useChannelPrelovedController() {
66933
67202
  );
66934
67203
  res.status(200).json(data);
66935
67204
  } catch (error2) {
66936
- import_node_server_utils249.logger.log({ level: "error", message: error2.message });
67205
+ import_node_server_utils250.logger.log({ level: "error", message: error2.message });
66937
67206
  next(error2);
66938
67207
  }
66939
67208
  }
@@ -66941,7 +67210,7 @@ function useChannelPrelovedController() {
66941
67210
  }
66942
67211
 
66943
67212
  // src/models/bid-preloved.model.ts
66944
- var import_joi145 = __toESM(require("joi"));
67213
+ var import_joi146 = __toESM(require("joi"));
66945
67214
  var import_mongodb149 = require("mongodb");
66946
67215
  var BidType = /* @__PURE__ */ ((BidType2) => {
66947
67216
  BidType2["BID"] = "bid";
@@ -66955,21 +67224,21 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
66955
67224
  BidStatus3["CANCELLED"] = "cancelled";
66956
67225
  return BidStatus3;
66957
67226
  })(BidStatus || {});
66958
- var schemaBidPreloved = import_joi145.default.object({
66959
- type: import_joi145.default.string().valid(...Object.values(BidType)).required(),
66960
- postId: import_joi145.default.string().hex().length(24).required(),
66961
- receiverId: import_joi145.default.string().hex().length(24).required(),
66962
- buyerId: import_joi145.default.string().hex().length(24).required(),
66963
- price: import_joi145.default.when("type", {
67227
+ var schemaBidPreloved = import_joi146.default.object({
67228
+ type: import_joi146.default.string().valid(...Object.values(BidType)).required(),
67229
+ postId: import_joi146.default.string().hex().length(24).required(),
67230
+ receiverId: import_joi146.default.string().hex().length(24).required(),
67231
+ buyerId: import_joi146.default.string().hex().length(24).required(),
67232
+ price: import_joi146.default.when("type", {
66964
67233
  is: "bid" /* BID */,
66965
- then: import_joi145.default.number().required(),
66966
- otherwise: import_joi145.default.number().optional().allow(null)
67234
+ then: import_joi146.default.number().required(),
67235
+ otherwise: import_joi146.default.number().optional().allow(null)
66967
67236
  }),
66968
- message: import_joi145.default.string().optional().allow("", null),
66969
- status: import_joi145.default.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
67237
+ message: import_joi146.default.string().optional().allow("", null),
67238
+ status: import_joi146.default.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
66970
67239
  });
66971
- var schemaUpdateBidPreloved = import_joi145.default.object({
66972
- status: import_joi145.default.string().valid(...Object.values(BidStatus)).required()
67240
+ var schemaUpdateBidPreloved = import_joi146.default.object({
67241
+ status: import_joi146.default.string().valid(...Object.values(BidStatus)).required()
66973
67242
  });
66974
67243
  function MBidPreloved(value) {
66975
67244
  const { error } = schemaBidPreloved.validate(value);
@@ -66993,12 +67262,12 @@ function MBidPreloved(value) {
66993
67262
  }
66994
67263
 
66995
67264
  // src/repositories/bid-preloved.repo.ts
66996
- var import_node_server_utils250 = require("@7365admin1/node-server-utils");
67265
+ var import_node_server_utils251 = require("@7365admin1/node-server-utils");
66997
67266
  var import_mongodb150 = require("mongodb");
66998
67267
  function useBidPrelovedRepo() {
66999
- const db = import_node_server_utils250.useAtlas.getDb();
67268
+ const db = import_node_server_utils251.useAtlas.getDb();
67000
67269
  if (!db)
67001
- throw new import_node_server_utils250.InternalServerError("Unable to connect to server.");
67270
+ throw new import_node_server_utils251.InternalServerError("Unable to connect to server.");
67002
67271
  const collection = db.collection("bid-preloved");
67003
67272
  async function add(value, session) {
67004
67273
  try {
@@ -67013,13 +67282,13 @@ function useBidPrelovedRepo() {
67013
67282
  const objectId2 = typeof _id === "string" ? new import_mongodb150.ObjectId(_id) : _id;
67014
67283
  const existing = await collection.findOne({ _id: objectId2 });
67015
67284
  if (!existing)
67016
- throw new import_node_server_utils250.NotFoundError("Bid not found.");
67285
+ throw new import_node_server_utils251.NotFoundError("Bid not found.");
67017
67286
  const res = await collection.updateOne(
67018
67287
  { _id: objectId2 },
67019
67288
  { $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
67020
67289
  );
67021
67290
  if (res.modifiedCount === 0)
67022
- throw new import_node_server_utils250.InternalServerError("Unable to update bid.");
67291
+ throw new import_node_server_utils251.InternalServerError("Unable to update bid.");
67023
67292
  return "Bid updated successfully.";
67024
67293
  }
67025
67294
  async function getById(_id) {
@@ -67027,26 +67296,22 @@ function useBidPrelovedRepo() {
67027
67296
  _id = new import_mongodb150.ObjectId(_id);
67028
67297
  const result = await collection.findOne({ _id });
67029
67298
  if (!result)
67030
- throw new import_node_server_utils250.NotFoundError("Bid not found.");
67299
+ throw new import_node_server_utils251.NotFoundError("Bid not found.");
67031
67300
  return result;
67032
67301
  }
67033
67302
  return { add, getById, updateStatus };
67034
67303
  }
67035
67304
 
67036
- // src/controllers/bid-preloved.controller.ts
67037
- var import_node_server_utils252 = require("@7365admin1/node-server-utils");
67038
- var import_joi146 = __toESM(require("joi"));
67039
-
67040
67305
  // src/services/bid-preloved.service.ts
67041
- var import_node_server_utils251 = require("@7365admin1/node-server-utils");
67306
+ var import_node_server_utils252 = require("@7365admin1/node-server-utils");
67042
67307
  function useBidPrelovedService() {
67043
67308
  const { add: _addBid } = useBidPrelovedRepo();
67044
67309
  const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
67045
67310
  const { add: _addChat } = useChatPrelovedRepo();
67046
67311
  async function createBid(value) {
67047
- const client = import_node_server_utils251.useAtlas.getClient();
67312
+ const client = import_node_server_utils252.useAtlas.getClient();
67048
67313
  if (!client)
67049
- throw new import_node_server_utils251.InternalServerError("Unable to connect to server.");
67314
+ throw new import_node_server_utils252.InternalServerError("Unable to connect to server.");
67050
67315
  const buyerId = value.buyerId;
67051
67316
  const receiverId = value.receiverId;
67052
67317
  const postId = value.postId;
@@ -67101,6 +67366,8 @@ function useBidPrelovedService() {
67101
67366
  }
67102
67367
 
67103
67368
  // src/controllers/bid-preloved.controller.ts
67369
+ var import_node_server_utils253 = require("@7365admin1/node-server-utils");
67370
+ var import_joi147 = __toESM(require("joi"));
67104
67371
  function useBidPrelovedController() {
67105
67372
  const { createBid: _createBid } = useBidPrelovedService();
67106
67373
  const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
@@ -67110,8 +67377,8 @@ function useBidPrelovedController() {
67110
67377
  });
67111
67378
  if (error) {
67112
67379
  const messages = error.details.map((d) => d.message).join(", ");
67113
- import_node_server_utils252.logger.log({ level: "error", message: messages });
67114
- next(new import_node_server_utils252.BadRequestError(messages));
67380
+ import_node_server_utils253.logger.log({ level: "error", message: messages });
67381
+ next(new import_node_server_utils253.BadRequestError(messages));
67115
67382
  return;
67116
67383
  }
67117
67384
  try {
@@ -67119,53 +67386,53 @@ function useBidPrelovedController() {
67119
67386
  res.status(201).json(data);
67120
67387
  } catch (error2) {
67121
67388
  console.log("error", error2);
67122
- import_node_server_utils252.logger.log({ level: "error", message: error2.message });
67389
+ import_node_server_utils253.logger.log({ level: "error", message: error2.message });
67123
67390
  next(error2);
67124
67391
  }
67125
67392
  }
67126
67393
  async function updateStatus(req, res, next) {
67127
- const paramsSchema = import_joi146.default.object({
67128
- id: import_joi146.default.string().hex().length(24).required()
67394
+ const paramsSchema = import_joi147.default.object({
67395
+ id: import_joi147.default.string().hex().length(24).required()
67129
67396
  });
67130
67397
  const { error: paramError, value: params } = paramsSchema.validate(
67131
67398
  req.params
67132
67399
  );
67133
67400
  if (paramError) {
67134
- import_node_server_utils252.logger.log({ level: "error", message: paramError.message });
67135
- next(new import_node_server_utils252.BadRequestError(paramError.message));
67401
+ import_node_server_utils253.logger.log({ level: "error", message: paramError.message });
67402
+ next(new import_node_server_utils253.BadRequestError(paramError.message));
67136
67403
  return;
67137
67404
  }
67138
67405
  const { error: bodyError, value: body } = schemaUpdateBidPreloved.validate(
67139
67406
  req.body
67140
67407
  );
67141
67408
  if (bodyError) {
67142
- import_node_server_utils252.logger.log({ level: "error", message: bodyError.message });
67143
- next(new import_node_server_utils252.BadRequestError(bodyError.message));
67409
+ import_node_server_utils253.logger.log({ level: "error", message: bodyError.message });
67410
+ next(new import_node_server_utils253.BadRequestError(bodyError.message));
67144
67411
  return;
67145
67412
  }
67146
67413
  try {
67147
67414
  const data = await _updateStatus(params.id, body.status);
67148
67415
  res.status(200).json(data);
67149
67416
  } catch (error) {
67150
- import_node_server_utils252.logger.log({ level: "error", message: error.message });
67417
+ import_node_server_utils253.logger.log({ level: "error", message: error.message });
67151
67418
  next(error);
67152
67419
  }
67153
67420
  }
67154
67421
  async function getById(req, res, next) {
67155
- const paramsSchema = import_joi146.default.object({
67156
- id: import_joi146.default.string().hex().length(24).required()
67422
+ const paramsSchema = import_joi147.default.object({
67423
+ id: import_joi147.default.string().hex().length(24).required()
67157
67424
  });
67158
67425
  const { error, value: params } = paramsSchema.validate(req.params);
67159
67426
  if (error) {
67160
- import_node_server_utils252.logger.log({ level: "error", message: error.message });
67161
- next(new import_node_server_utils252.BadRequestError(error.message));
67427
+ import_node_server_utils253.logger.log({ level: "error", message: error.message });
67428
+ next(new import_node_server_utils253.BadRequestError(error.message));
67162
67429
  return;
67163
67430
  }
67164
67431
  try {
67165
67432
  const data = await _getById(params.id);
67166
67433
  res.status(200).json(data);
67167
67434
  } catch (error2) {
67168
- import_node_server_utils252.logger.log({ level: "error", message: error2.message });
67435
+ import_node_server_utils253.logger.log({ level: "error", message: error2.message });
67169
67436
  next(error2);
67170
67437
  }
67171
67438
  }
@@ -67173,7 +67440,7 @@ function useBidPrelovedController() {
67173
67440
  }
67174
67441
 
67175
67442
  // src/models/online-forms-v2.model.ts
67176
- var import_joi147 = __toESM(require("joi"));
67443
+ var import_joi148 = __toESM(require("joi"));
67177
67444
  var import_mongodb151 = require("mongodb");
67178
67445
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
67179
67446
  FormEntryStatus2["ACTIVE"] = "active";
@@ -67181,49 +67448,49 @@ var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
67181
67448
  FormEntryStatus2["DELETED"] = "deleted";
67182
67449
  return FormEntryStatus2;
67183
67450
  })(FormEntryStatus || {});
67184
- var schemaFormEntry = import_joi147.default.object({
67185
- _id: import_joi147.default.string().hex().optional().allow("", null),
67186
- formType: import_joi147.default.string().required(),
67187
- block: import_joi147.default.string().optional().allow(null, ""),
67188
- level: import_joi147.default.string().optional().allow(null, ""),
67189
- unit: import_joi147.default.string().optional().allow(null, ""),
67190
- name: import_joi147.default.string().optional().allow(null, ""),
67191
- phoneNumber: import_joi147.default.string().optional().allow(null, ""),
67192
- createdBy: import_joi147.default.string().required(),
67193
- fields: import_joi147.default.object().pattern(
67194
- import_joi147.default.string(),
67195
- import_joi147.default.alternatives().try(
67196
- import_joi147.default.string(),
67197
- import_joi147.default.number(),
67198
- import_joi147.default.boolean(),
67199
- import_joi147.default.valid(null)
67451
+ var schemaFormEntry = import_joi148.default.object({
67452
+ _id: import_joi148.default.string().hex().optional().allow("", null),
67453
+ formType: import_joi148.default.string().required(),
67454
+ block: import_joi148.default.string().optional().allow(null, ""),
67455
+ level: import_joi148.default.string().optional().allow(null, ""),
67456
+ unit: import_joi148.default.string().optional().allow(null, ""),
67457
+ name: import_joi148.default.string().optional().allow(null, ""),
67458
+ phoneNumber: import_joi148.default.string().optional().allow(null, ""),
67459
+ createdBy: import_joi148.default.string().required(),
67460
+ fields: import_joi148.default.object().pattern(
67461
+ import_joi148.default.string(),
67462
+ import_joi148.default.alternatives().try(
67463
+ import_joi148.default.string(),
67464
+ import_joi148.default.number(),
67465
+ import_joi148.default.boolean(),
67466
+ import_joi148.default.valid(null)
67200
67467
  )
67201
67468
  ).required(),
67202
- status: import_joi147.default.string().optional().allow("", null),
67203
- org: import_joi147.default.string().hex().optional().allow("", null),
67204
- site: import_joi147.default.string().hex().optional().allow("", null),
67205
- createdAt: import_joi147.default.date().optional().allow("", null),
67206
- updatedAt: import_joi147.default.date().optional().allow("", null),
67207
- deletedAt: import_joi147.default.date().optional().allow("", null)
67469
+ status: import_joi148.default.string().optional().allow("", null),
67470
+ org: import_joi148.default.string().hex().optional().allow("", null),
67471
+ site: import_joi148.default.string().hex().optional().allow("", null),
67472
+ createdAt: import_joi148.default.date().optional().allow("", null),
67473
+ updatedAt: import_joi148.default.date().optional().allow("", null),
67474
+ deletedAt: import_joi148.default.date().optional().allow("", null)
67208
67475
  });
67209
- var schemaUpdateFormEntry = import_joi147.default.object({
67210
- _id: import_joi147.default.string().hex().required(),
67211
- formType: import_joi147.default.string().optional().allow("", null),
67212
- block: import_joi147.default.string().optional().allow(null, ""),
67213
- level: import_joi147.default.string().optional().allow(null, ""),
67214
- unit: import_joi147.default.string().optional().allow(null, ""),
67215
- fields: import_joi147.default.object().pattern(
67216
- import_joi147.default.string(),
67217
- import_joi147.default.alternatives().try(
67218
- import_joi147.default.string(),
67219
- import_joi147.default.number(),
67220
- import_joi147.default.boolean(),
67221
- import_joi147.default.valid(null)
67476
+ var schemaUpdateFormEntry = import_joi148.default.object({
67477
+ _id: import_joi148.default.string().hex().required(),
67478
+ formType: import_joi148.default.string().optional().allow("", null),
67479
+ block: import_joi148.default.string().optional().allow(null, ""),
67480
+ level: import_joi148.default.string().optional().allow(null, ""),
67481
+ unit: import_joi148.default.string().optional().allow(null, ""),
67482
+ fields: import_joi148.default.object().pattern(
67483
+ import_joi148.default.string(),
67484
+ import_joi148.default.alternatives().try(
67485
+ import_joi148.default.string(),
67486
+ import_joi148.default.number(),
67487
+ import_joi148.default.boolean(),
67488
+ import_joi148.default.valid(null)
67222
67489
  )
67223
67490
  ).optional(),
67224
- status: import_joi147.default.string().optional().allow("", null),
67225
- updatedAt: import_joi147.default.date().optional().allow("", null),
67226
- deletedAt: import_joi147.default.date().optional().allow("", null)
67491
+ status: import_joi148.default.string().optional().allow("", null),
67492
+ updatedAt: import_joi148.default.date().optional().allow("", null),
67493
+ deletedAt: import_joi148.default.date().optional().allow("", null)
67227
67494
  });
67228
67495
  function MFormEntry(value) {
67229
67496
  const { error } = schemaFormEntry.validate(value);
@@ -67268,49 +67535,49 @@ function MFormEntry(value) {
67268
67535
  deletedAt: value.deletedAt ?? null
67269
67536
  };
67270
67537
  }
67271
- var residentFormEntry = import_joi147.default.object({
67272
- _id: import_joi147.default.string().hex().optional().allow("", null),
67273
- typeOfForm: import_joi147.default.string().optional().allow("", null),
67274
- unitNumber: import_joi147.default.string().optional().allow(null, ""),
67275
- fields: import_joi147.default.object().pattern(
67276
- import_joi147.default.string(),
67277
- import_joi147.default.alternatives().try(
67278
- import_joi147.default.string(),
67279
- import_joi147.default.number(),
67280
- import_joi147.default.boolean(),
67281
- import_joi147.default.valid(null)
67538
+ var residentFormEntry = import_joi148.default.object({
67539
+ _id: import_joi148.default.string().hex().optional().allow("", null),
67540
+ typeOfForm: import_joi148.default.string().optional().allow("", null),
67541
+ unitNumber: import_joi148.default.string().optional().allow(null, ""),
67542
+ fields: import_joi148.default.object().pattern(
67543
+ import_joi148.default.string(),
67544
+ import_joi148.default.alternatives().try(
67545
+ import_joi148.default.string(),
67546
+ import_joi148.default.number(),
67547
+ import_joi148.default.boolean(),
67548
+ import_joi148.default.valid(null)
67282
67549
  )
67283
67550
  ).optional().allow(null, ""),
67284
- status: import_joi147.default.string().optional().allow("", null),
67285
- org: import_joi147.default.string().hex().optional().allow("", null),
67286
- site: import_joi147.default.string().hex().optional().allow("", null),
67287
- userId: import_joi147.default.string().hex().optional().allow("", null),
67288
- createdAt: import_joi147.default.date().optional().allow("", null),
67289
- updatedAt: import_joi147.default.date().optional().allow("", null),
67290
- deletedAt: import_joi147.default.date().optional().allow("", null),
67291
- remarks: import_joi147.default.string().optional().allow("", null),
67292
- managementValues: import_joi147.default.object().pattern(
67293
- import_joi147.default.string(),
67294
- import_joi147.default.alternatives().try(
67295
- import_joi147.default.string(),
67296
- import_joi147.default.number(),
67297
- import_joi147.default.boolean(),
67298
- import_joi147.default.valid(null)
67551
+ status: import_joi148.default.string().optional().allow("", null),
67552
+ org: import_joi148.default.string().hex().optional().allow("", null),
67553
+ site: import_joi148.default.string().hex().optional().allow("", null),
67554
+ userId: import_joi148.default.string().hex().optional().allow("", null),
67555
+ createdAt: import_joi148.default.date().optional().allow("", null),
67556
+ updatedAt: import_joi148.default.date().optional().allow("", null),
67557
+ deletedAt: import_joi148.default.date().optional().allow("", null),
67558
+ remarks: import_joi148.default.string().optional().allow("", null),
67559
+ managementValues: import_joi148.default.object().pattern(
67560
+ import_joi148.default.string(),
67561
+ import_joi148.default.alternatives().try(
67562
+ import_joi148.default.string(),
67563
+ import_joi148.default.number(),
67564
+ import_joi148.default.boolean(),
67565
+ import_joi148.default.valid(null)
67299
67566
  )
67300
67567
  ).optional().allow(null, "")
67301
67568
  });
67302
67569
 
67303
67570
  // src/repositories/online-forms-v2.repository.ts
67304
- var import_node_server_utils253 = require("@7365admin1/node-server-utils");
67571
+ var import_node_server_utils254 = require("@7365admin1/node-server-utils");
67305
67572
  var import_mongodb152 = require("mongodb");
67306
67573
  var online_forms_namespace_collection = "online-forms";
67307
67574
  function useFormEntryRepo() {
67308
- const db = import_node_server_utils253.useAtlas.getDb();
67575
+ const db = import_node_server_utils254.useAtlas.getDb();
67309
67576
  if (!db) {
67310
- throw new import_node_server_utils253.InternalServerError("Unable to connect to server.");
67577
+ throw new import_node_server_utils254.InternalServerError("Unable to connect to server.");
67311
67578
  }
67312
67579
  const collection = db.collection(online_forms_namespace_collection);
67313
- const { delNamespace, getCache, setCache } = (0, import_node_server_utils253.useCache)(
67580
+ const { delNamespace, getCache, setCache } = (0, import_node_server_utils254.useCache)(
67314
67581
  online_forms_namespace_collection
67315
67582
  );
67316
67583
  const { getUserById } = useUserRepo();
@@ -67320,7 +67587,7 @@ function useFormEntryRepo() {
67320
67587
  name: "text"
67321
67588
  });
67322
67589
  } catch (error) {
67323
- throw new import_node_server_utils253.InternalServerError(
67590
+ throw new import_node_server_utils254.InternalServerError(
67324
67591
  "Failed to create text index on online form."
67325
67592
  );
67326
67593
  }
@@ -67333,7 +67600,7 @@ function useFormEntryRepo() {
67333
67600
  } catch (error) {
67334
67601
  const isDuplicated = error.message.includes("duplicate");
67335
67602
  if (isDuplicated) {
67336
- throw new import_node_server_utils253.BadRequestError("Online Form already exists.");
67603
+ throw new import_node_server_utils254.BadRequestError("Online Form already exists.");
67337
67604
  }
67338
67605
  throw error;
67339
67606
  }
@@ -67386,7 +67653,7 @@ function useFormEntryRepo() {
67386
67653
  { $project: { user: 0 } }
67387
67654
  ]).toArray();
67388
67655
  const length = await collection.countDocuments(query);
67389
- const data = (0, import_node_server_utils253.paginate)(items, page, limit, length);
67656
+ const data = (0, import_node_server_utils254.paginate)(items, page, limit, length);
67390
67657
  return data;
67391
67658
  } catch (error) {
67392
67659
  throw error;
@@ -67396,13 +67663,13 @@ function useFormEntryRepo() {
67396
67663
  try {
67397
67664
  _id = new import_mongodb152.ObjectId(_id);
67398
67665
  } catch (error) {
67399
- throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67666
+ throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
67400
67667
  }
67401
67668
  const query = { _id, status: { $ne: "deleted" } };
67402
67669
  try {
67403
67670
  const [data] = await collection.aggregate([{ $match: query }]).toArray();
67404
67671
  if (!data) {
67405
- throw new import_node_server_utils253.NotFoundError("Document not found.");
67672
+ throw new import_node_server_utils254.NotFoundError("Document not found.");
67406
67673
  }
67407
67674
  return data;
67408
67675
  } catch (error) {
@@ -67413,7 +67680,7 @@ function useFormEntryRepo() {
67413
67680
  try {
67414
67681
  _id = new import_mongodb152.ObjectId(_id);
67415
67682
  } catch (error) {
67416
- throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67683
+ throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
67417
67684
  }
67418
67685
  try {
67419
67686
  const updateValue = {
@@ -67422,15 +67689,15 @@ function useFormEntryRepo() {
67422
67689
  };
67423
67690
  const res = await collection.updateOne({ _id }, { $set: updateValue });
67424
67691
  if (res.modifiedCount === 0) {
67425
- throw new import_node_server_utils253.InternalServerError("Unable to update online form.");
67692
+ throw new import_node_server_utils254.InternalServerError("Unable to update online form.");
67426
67693
  }
67427
67694
  const onlineFormRequest = await collection.findOne({ _id });
67428
67695
  if (!onlineFormRequest) {
67429
- throw new import_node_server_utils253.NotFoundError("Online form not found.");
67696
+ throw new import_node_server_utils254.NotFoundError("Online form not found.");
67430
67697
  }
67431
67698
  const user = await getUserById(onlineFormRequest.userId.toString());
67432
67699
  if (!user || !user._id) {
67433
- throw new import_node_server_utils253.NotFoundError("User not found.");
67700
+ throw new import_node_server_utils254.NotFoundError("User not found.");
67434
67701
  }
67435
67702
  const userId = user._id.toString();
67436
67703
  await NotificationService.onlineFormRequestStatusUpdated({
@@ -67447,7 +67714,7 @@ function useFormEntryRepo() {
67447
67714
  try {
67448
67715
  _id = new import_mongodb152.ObjectId(_id);
67449
67716
  } catch (error) {
67450
- throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67717
+ throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
67451
67718
  }
67452
67719
  try {
67453
67720
  const updateValue = {
@@ -67461,7 +67728,7 @@ function useFormEntryRepo() {
67461
67728
  { session }
67462
67729
  );
67463
67730
  if (res.modifiedCount === 0) {
67464
- throw new import_node_server_utils253.InternalServerError("Unable to delete online form.");
67731
+ throw new import_node_server_utils254.InternalServerError("Unable to delete online form.");
67465
67732
  }
67466
67733
  return res.modifiedCount;
67467
67734
  } catch (error) {
@@ -67478,7 +67745,7 @@ function useFormEntryRepo() {
67478
67745
  } catch (error) {
67479
67746
  const isDuplicated = error.message.includes("duplicate");
67480
67747
  if (isDuplicated) {
67481
- throw new import_node_server_utils253.BadRequestError("Online Form already exists.");
67748
+ throw new import_node_server_utils254.BadRequestError("Online Form already exists.");
67482
67749
  }
67483
67750
  throw error;
67484
67751
  }
@@ -67517,13 +67784,13 @@ function useFormEntryRepo() {
67517
67784
  { unitNumber: { $regex: search, $options: "i" } }
67518
67785
  ];
67519
67786
  }
67520
- const cacheKey = (0, import_node_server_utils253.makeCacheKey)(
67787
+ const cacheKey = (0, import_node_server_utils254.makeCacheKey)(
67521
67788
  online_forms_namespace_collection,
67522
67789
  cacheOptions
67523
67790
  );
67524
67791
  const cachedData = await getCache(cacheKey);
67525
67792
  if (cachedData) {
67526
- import_node_server_utils253.logger.info(`Cache hit for key: ${cacheKey}`);
67793
+ import_node_server_utils254.logger.info(`Cache hit for key: ${cacheKey}`);
67527
67794
  return cachedData;
67528
67795
  }
67529
67796
  try {
@@ -67534,11 +67801,11 @@ function useFormEntryRepo() {
67534
67801
  { $limit: limit }
67535
67802
  ]).toArray();
67536
67803
  const length = await collection.countDocuments(query);
67537
- const data = (0, import_node_server_utils253.paginate)(items, page, limit, length);
67804
+ const data = (0, import_node_server_utils254.paginate)(items, page, limit, length);
67538
67805
  setCache(cacheKey, data, 15 * 60).then(() => {
67539
- import_node_server_utils253.logger.info(`Cache set for key: ${cacheKey}`);
67806
+ import_node_server_utils254.logger.info(`Cache set for key: ${cacheKey}`);
67540
67807
  }).catch((err) => {
67541
- import_node_server_utils253.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
67808
+ import_node_server_utils254.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
67542
67809
  });
67543
67810
  return data;
67544
67811
  } catch (error) {
@@ -67558,8 +67825,8 @@ function useFormEntryRepo() {
67558
67825
  }
67559
67826
 
67560
67827
  // src/controllers/online-forms-v2.controller.ts
67561
- var import_node_server_utils254 = require("@7365admin1/node-server-utils");
67562
- var import_joi148 = __toESM(require("joi"));
67828
+ var import_node_server_utils255 = require("@7365admin1/node-server-utils");
67829
+ var import_joi149 = __toESM(require("joi"));
67563
67830
  var import_exceljs3 = __toESM(require("exceljs"));
67564
67831
  var import_fs7 = __toESM(require("fs"));
67565
67832
  function useFormEntryController() {
@@ -67585,14 +67852,14 @@ function useFormEntryController() {
67585
67852
  async function uploadFormEntrys(req, res, next) {
67586
67853
  try {
67587
67854
  if (!req.file) {
67588
- next(new import_node_server_utils254.BadRequestError("Excel file is required."));
67855
+ next(new import_node_server_utils255.BadRequestError("Excel file is required."));
67589
67856
  return;
67590
67857
  }
67591
67858
  const workbook = new import_exceljs3.default.Workbook();
67592
67859
  await workbook.xlsx.readFile(req.file.path);
67593
67860
  const worksheet = workbook.worksheets[0];
67594
67861
  if (!worksheet) {
67595
- next(new import_node_server_utils254.BadRequestError("No worksheet found in uploaded Excel file."));
67862
+ next(new import_node_server_utils255.BadRequestError("No worksheet found in uploaded Excel file."));
67596
67863
  return;
67597
67864
  }
67598
67865
  const headerRow = worksheet.getRow(1);
@@ -67620,8 +67887,8 @@ function useFormEntryController() {
67620
67887
  });
67621
67888
  if (error) {
67622
67889
  const messages = error.details.map((d) => d.message).join(", ");
67623
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67624
- next(new import_node_server_utils254.BadRequestError(messages));
67890
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
67891
+ next(new import_node_server_utils255.BadRequestError(messages));
67625
67892
  return;
67626
67893
  }
67627
67894
  const result = await _add(value);
@@ -67629,25 +67896,25 @@ function useFormEntryController() {
67629
67896
  import_fs7.default.unlink(req.file.path, () => {
67630
67897
  });
67631
67898
  } catch (error) {
67632
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67899
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67633
67900
  next(error);
67634
67901
  }
67635
67902
  }
67636
67903
  async function getAll(req, res, next) {
67637
67904
  try {
67638
- const schema2 = import_joi148.default.object({
67639
- search: import_joi148.default.string().optional().allow("", null),
67640
- page: import_joi148.default.number().integer().min(1).allow("", null).default(1),
67641
- limit: import_joi148.default.number().integer().min(1).max(100).allow("", null).default(10),
67642
- status: import_joi148.default.string().optional().allow(null, ""),
67643
- org: import_joi148.default.string().hex().optional().allow("", null),
67644
- site: import_joi148.default.string().hex().optional().allow("", null)
67905
+ const schema2 = import_joi149.default.object({
67906
+ search: import_joi149.default.string().optional().allow("", null),
67907
+ page: import_joi149.default.number().integer().min(1).allow("", null).default(1),
67908
+ limit: import_joi149.default.number().integer().min(1).max(100).allow("", null).default(10),
67909
+ status: import_joi149.default.string().optional().allow(null, ""),
67910
+ org: import_joi149.default.string().hex().optional().allow("", null),
67911
+ site: import_joi149.default.string().hex().optional().allow("", null)
67645
67912
  });
67646
67913
  const { error, value } = schema2.validate(req.query);
67647
67914
  if (error) {
67648
67915
  const messages = error.details.map((d) => d.message).join(", ");
67649
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67650
- next(new import_node_server_utils254.BadRequestError(messages));
67916
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
67917
+ next(new import_node_server_utils255.BadRequestError(messages));
67651
67918
  return;
67652
67919
  }
67653
67920
  const { search, page, limit, status, org, site } = value;
@@ -67655,21 +67922,21 @@ function useFormEntryController() {
67655
67922
  res.json(data);
67656
67923
  return;
67657
67924
  } catch (error) {
67658
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67925
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67659
67926
  next(error);
67660
67927
  return;
67661
67928
  }
67662
67929
  }
67663
67930
  async function getFormEntryById(req, res, next) {
67664
67931
  try {
67665
- const schema2 = import_joi148.default.object({
67666
- _id: import_joi148.default.string().hex().length(24).required()
67932
+ const schema2 = import_joi149.default.object({
67933
+ _id: import_joi149.default.string().hex().length(24).required()
67667
67934
  });
67668
67935
  const { error, value } = schema2.validate({ _id: req.params.id });
67669
67936
  if (error) {
67670
67937
  const messages = error.details.map((d) => d.message).join(", ");
67671
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67672
- next(new import_node_server_utils254.BadRequestError(messages));
67938
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
67939
+ next(new import_node_server_utils255.BadRequestError(messages));
67673
67940
  return;
67674
67941
  }
67675
67942
  const { _id } = value;
@@ -67677,7 +67944,7 @@ function useFormEntryController() {
67677
67944
  res.json(data);
67678
67945
  return;
67679
67946
  } catch (error) {
67680
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67947
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67681
67948
  next(error);
67682
67949
  return;
67683
67950
  }
@@ -67690,8 +67957,8 @@ function useFormEntryController() {
67690
67957
  });
67691
67958
  if (error) {
67692
67959
  const messages = error.details.map((d) => d.message).join(", ");
67693
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67694
- next(new import_node_server_utils254.BadRequestError(messages));
67960
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
67961
+ next(new import_node_server_utils255.BadRequestError(messages));
67695
67962
  return;
67696
67963
  }
67697
67964
  const { _id, ...rest } = value;
@@ -67699,26 +67966,26 @@ function useFormEntryController() {
67699
67966
  res.json({ message: "Successfully updated online form." });
67700
67967
  return;
67701
67968
  } catch (error) {
67702
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67969
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67703
67970
  next(error);
67704
67971
  return;
67705
67972
  }
67706
67973
  }
67707
67974
  async function deleteFormEntryById(req, res, next) {
67708
67975
  try {
67709
- const validation = import_joi148.default.string().hex().required();
67976
+ const validation = import_joi149.default.string().hex().required();
67710
67977
  const _id = req.params.id;
67711
67978
  const { error } = validation.validate(_id);
67712
67979
  if (error) {
67713
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67714
- next(new import_node_server_utils254.BadRequestError(error.message));
67980
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67981
+ next(new import_node_server_utils255.BadRequestError(error.message));
67715
67982
  return;
67716
67983
  }
67717
67984
  await _deleteOnlineFormById(_id);
67718
67985
  res.json({ message: "Successfully deleted online form." });
67719
67986
  return;
67720
67987
  } catch (error) {
67721
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
67988
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67722
67989
  next(error);
67723
67990
  return;
67724
67991
  }
@@ -67735,8 +68002,8 @@ function useFormEntryController() {
67735
68002
  });
67736
68003
  if (error) {
67737
68004
  const messages = error.details.map((d) => d.message).join(", ");
67738
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67739
- next(new import_node_server_utils254.BadRequestError(messages));
68005
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
68006
+ next(new import_node_server_utils255.BadRequestError(messages));
67740
68007
  return;
67741
68008
  }
67742
68009
  try {
@@ -67744,7 +68011,7 @@ function useFormEntryController() {
67744
68011
  res.status(201).json({ message: data });
67745
68012
  return;
67746
68013
  } catch (error2) {
67747
- import_node_server_utils254.logger.log({ level: "error", message: error2.message });
68014
+ import_node_server_utils255.logger.log({ level: "error", message: error2.message });
67748
68015
  next(error2);
67749
68016
  return;
67750
68017
  }
@@ -67756,8 +68023,8 @@ function useFormEntryController() {
67756
68023
  });
67757
68024
  if (error) {
67758
68025
  const messages = error.details.map((d) => d.message).join(", ");
67759
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67760
- next(new import_node_server_utils254.BadRequestError(messages));
68026
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
68027
+ next(new import_node_server_utils255.BadRequestError(messages));
67761
68028
  return;
67762
68029
  }
67763
68030
  try {
@@ -67765,35 +68032,35 @@ function useFormEntryController() {
67765
68032
  res.status(201).json({ message: data });
67766
68033
  return;
67767
68034
  } catch (error2) {
67768
- import_node_server_utils254.logger.log({ level: "error", message: error2.message });
68035
+ import_node_server_utils255.logger.log({ level: "error", message: error2.message });
67769
68036
  next(error2);
67770
68037
  return;
67771
68038
  }
67772
68039
  }
67773
68040
  async function residentForm(req, res, next) {
67774
68041
  try {
67775
- const residentFormPayload = import_joi148.default.object({
67776
- org: import_joi148.default.string().hex().required(),
67777
- site: import_joi148.default.string().hex().required(),
67778
- userId: import_joi148.default.string().hex().required(),
67779
- search: import_joi148.default.string().optional().allow("", null),
67780
- page: import_joi148.default.number().integer().min(1).allow("", null).default(1),
67781
- limit: import_joi148.default.number().integer().min(1).max(100).allow("", null).default(10)
68042
+ const residentFormPayload = import_joi149.default.object({
68043
+ org: import_joi149.default.string().hex().required(),
68044
+ site: import_joi149.default.string().hex().required(),
68045
+ userId: import_joi149.default.string().hex().required(),
68046
+ search: import_joi149.default.string().optional().allow("", null),
68047
+ page: import_joi149.default.number().integer().min(1).allow("", null).default(1),
68048
+ limit: import_joi149.default.number().integer().min(1).max(100).allow("", null).default(10)
67782
68049
  });
67783
68050
  const { error, value } = residentFormPayload.validate(req.query, {
67784
68051
  abortEarly: true
67785
68052
  });
67786
68053
  if (error) {
67787
68054
  const messages = error.details.map((d) => d.message).join(", ");
67788
- import_node_server_utils254.logger.log({ level: "error", message: messages });
67789
- next(new import_node_server_utils254.BadRequestError(messages));
68055
+ import_node_server_utils255.logger.log({ level: "error", message: messages });
68056
+ next(new import_node_server_utils255.BadRequestError(messages));
67790
68057
  return;
67791
68058
  }
67792
68059
  const { site, userId, org, search, page, limit } = value;
67793
68060
  const result = await _residentForm({ userId, site, org, search, page, limit });
67794
68061
  res.json(result);
67795
68062
  } catch (error) {
67796
- import_node_server_utils254.logger.log({ level: "error", message: error.message });
68063
+ import_node_server_utils255.logger.log({ level: "error", message: error.message });
67797
68064
  next(error);
67798
68065
  return;
67799
68066
  }
@@ -67811,11 +68078,11 @@ function useFormEntryController() {
67811
68078
  }
67812
68079
 
67813
68080
  // src/services/building-level.service.ts
67814
- var import_node_server_utils255 = require("@7365admin1/node-server-utils");
68081
+ var import_node_server_utils256 = require("@7365admin1/node-server-utils");
67815
68082
  function useBuildingLevelService() {
67816
68083
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
67817
68084
  async function add(value) {
67818
- const session = import_node_server_utils255.useAtlas.getClient()?.startSession();
68085
+ const session = import_node_server_utils256.useAtlas.getClient()?.startSession();
67819
68086
  try {
67820
68087
  session?.startTransaction();
67821
68088
  await _add(value, session);
@@ -67829,7 +68096,7 @@ function useBuildingLevelService() {
67829
68096
  }
67830
68097
  }
67831
68098
  async function updateLevelById(_id, value) {
67832
- const session = import_node_server_utils255.useAtlas.getClient()?.startSession();
68099
+ const session = import_node_server_utils256.useAtlas.getClient()?.startSession();
67833
68100
  try {
67834
68101
  session?.startTransaction();
67835
68102
  await _updateLevelById(_id, value, session);
@@ -67849,8 +68116,8 @@ function useBuildingLevelService() {
67849
68116
  }
67850
68117
 
67851
68118
  // src/controllers/building-level.controller.ts
67852
- var import_node_server_utils256 = require("@7365admin1/node-server-utils");
67853
- var import_joi149 = __toESM(require("joi"));
68119
+ var import_node_server_utils257 = require("@7365admin1/node-server-utils");
68120
+ var import_joi150 = __toESM(require("joi"));
67854
68121
  function useBuildingLevelController() {
67855
68122
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
67856
68123
  const {
@@ -67867,8 +68134,8 @@ function useBuildingLevelController() {
67867
68134
  });
67868
68135
  if (error) {
67869
68136
  const messages = error.details.map((d) => d.message).join(", ");
67870
- import_node_server_utils256.logger.log({ level: "error", message: messages });
67871
- next(new import_node_server_utils256.BadRequestError(messages));
68137
+ import_node_server_utils257.logger.log({ level: "error", message: messages });
68138
+ next(new import_node_server_utils257.BadRequestError(messages));
67872
68139
  return;
67873
68140
  }
67874
68141
  const result = await _add(value);
@@ -67879,20 +68146,20 @@ function useBuildingLevelController() {
67879
68146
  }
67880
68147
  async function getAll(req, res, next) {
67881
68148
  try {
67882
- const validation = import_joi149.default.object({
67883
- page: import_joi149.default.number().min(1).optional().default(1),
67884
- limit: import_joi149.default.number().min(1).optional().default(20),
67885
- search: import_joi149.default.string().optional().allow("", null),
67886
- site: import_joi149.default.string().hex().length(24).optional().allow("", null),
67887
- status: import_joi149.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
68149
+ const validation = import_joi150.default.object({
68150
+ page: import_joi150.default.number().min(1).optional().default(1),
68151
+ limit: import_joi150.default.number().min(1).optional().default(20),
68152
+ search: import_joi150.default.string().optional().allow("", null),
68153
+ site: import_joi150.default.string().hex().length(24).optional().allow("", null),
68154
+ status: import_joi150.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
67888
68155
  });
67889
68156
  const { error, value } = validation.validate(req.query, {
67890
68157
  abortEarly: false
67891
68158
  });
67892
68159
  if (error) {
67893
68160
  const messages = error.details.map((d) => d.message);
67894
- import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67895
- next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
68161
+ import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
68162
+ next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
67896
68163
  return;
67897
68164
  }
67898
68165
  const { page, limit, status, site, search } = value;
@@ -67911,14 +68178,14 @@ function useBuildingLevelController() {
67911
68178
  }
67912
68179
  async function getById(req, res, next) {
67913
68180
  try {
67914
- const schema2 = import_joi149.default.object({
67915
- id: import_joi149.default.string().hex().length(24).required()
68181
+ const schema2 = import_joi150.default.object({
68182
+ id: import_joi150.default.string().hex().length(24).required()
67916
68183
  });
67917
68184
  const { error, value } = schema2.validate({ id: req.params.id });
67918
68185
  if (error) {
67919
68186
  const messages = error.details.map((d) => d.message);
67920
- import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67921
- next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
68187
+ import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
68188
+ next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
67922
68189
  return;
67923
68190
  }
67924
68191
  const { id } = value;
@@ -67937,8 +68204,8 @@ function useBuildingLevelController() {
67937
68204
  });
67938
68205
  if (error) {
67939
68206
  const messages = error.details.map((d) => d.message);
67940
- import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67941
- next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
68207
+ import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
68208
+ next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
67942
68209
  return;
67943
68210
  }
67944
68211
  const { _id, ...rest } = value;
@@ -67950,14 +68217,14 @@ function useBuildingLevelController() {
67950
68217
  }
67951
68218
  async function deleteById(req, res, next) {
67952
68219
  try {
67953
- const schema2 = import_joi149.default.object({
67954
- id: import_joi149.default.string().hex().required()
68220
+ const schema2 = import_joi150.default.object({
68221
+ id: import_joi150.default.string().hex().required()
67955
68222
  });
67956
68223
  const { error, value } = schema2.validate({ id: req.params.id });
67957
68224
  if (error) {
67958
68225
  const messages = error.details.map((d) => d.message);
67959
- import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67960
- next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
68226
+ import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
68227
+ next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
67961
68228
  return;
67962
68229
  }
67963
68230
  const { id } = value;
@@ -67970,19 +68237,19 @@ function useBuildingLevelController() {
67970
68237
  }
67971
68238
  async function batchUpdateByIds(req, res, next) {
67972
68239
  try {
67973
- const schema2 = import_joi149.default.array().items(
67974
- import_joi149.default.object({
67975
- _id: import_joi149.default.string().hex().length(24).required(),
67976
- value: import_joi149.default.object({
67977
- name: import_joi149.default.string().optional().allow("", null)
68240
+ const schema2 = import_joi150.default.array().items(
68241
+ import_joi150.default.object({
68242
+ _id: import_joi150.default.string().hex().length(24).required(),
68243
+ value: import_joi150.default.object({
68244
+ name: import_joi150.default.string().optional().allow("", null)
67978
68245
  }).required()
67979
68246
  })
67980
68247
  );
67981
68248
  const { error, value } = schema2.validate(req.body);
67982
68249
  if (error) {
67983
68250
  const messages = error.details.map((d) => d.message);
67984
- import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67985
- next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
68251
+ import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
68252
+ next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
67986
68253
  return;
67987
68254
  }
67988
68255
  const updates = value.map((item) => ({
@@ -67997,9 +68264,9 @@ function useBuildingLevelController() {
67997
68264
  }
67998
68265
  async function getBuildingLevelList(req, res, next) {
67999
68266
  try {
68000
- const schema2 = import_joi149.default.object({
68001
- site: import_joi149.default.string().hex().length(24).required(),
68002
- block: import_joi149.default.string().hex().length(24).required()
68267
+ const schema2 = import_joi150.default.object({
68268
+ site: import_joi150.default.string().hex().length(24).required(),
68269
+ block: import_joi150.default.string().hex().length(24).required()
68003
68270
  });
68004
68271
  const { error, value } = schema2.validate({
68005
68272
  site: req.params.siteId,
@@ -68007,8 +68274,8 @@ function useBuildingLevelController() {
68007
68274
  });
68008
68275
  if (error) {
68009
68276
  const messages = error.details.map((d) => d.message).join(", ");
68010
- import_node_server_utils256.logger.log({ level: "error", message: messages });
68011
- next(new import_node_server_utils256.BadRequestError(messages));
68277
+ import_node_server_utils257.logger.log({ level: "error", message: messages });
68278
+ next(new import_node_server_utils257.BadRequestError(messages));
68012
68279
  return;
68013
68280
  }
68014
68281
  const { site, block } = value;
@@ -68031,9 +68298,9 @@ function useBuildingLevelController() {
68031
68298
  }
68032
68299
 
68033
68300
  // src/models/hid-amico.model.ts
68034
- var import_node_server_utils257 = require("@7365admin1/node-server-utils");
68301
+ var import_node_server_utils258 = require("@7365admin1/node-server-utils");
68035
68302
  var import_mongodb153 = require("mongodb");
68036
- var import_joi150 = __toESM(require("joi"));
68303
+ var import_joi151 = __toESM(require("joi"));
68037
68304
  function canReadObjectId(value) {
68038
68305
  if (value instanceof import_mongodb153.ObjectId)
68039
68306
  return true;
@@ -68071,161 +68338,161 @@ function toObjectId23(value, label = "ID") {
68071
68338
  return toObjectId23(text, label);
68072
68339
  }
68073
68340
  }
68074
- throw new import_node_server_utils257.BadRequestError(`Invalid ${label} format`);
68341
+ throw new import_node_server_utils258.BadRequestError(`Invalid ${label} format`);
68075
68342
  }
68076
- var objectIdSchema2 = import_joi150.default.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
68343
+ var objectIdSchema2 = import_joi151.default.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
68077
68344
  "any.invalid": "{{#label}} must be a valid ObjectId"
68078
68345
  });
68079
- var schemaHidAmicoReader = import_joi150.default.object({
68346
+ var schemaHidAmicoReader = import_joi151.default.object({
68080
68347
  _id: objectIdSchema2.optional(),
68081
68348
  site: objectIdSchema2.required(),
68082
- name: import_joi150.default.string().trim().required(),
68083
- baseUrl: import_joi150.default.string().uri({ scheme: ["http", "https"] }).required(),
68084
- username: import_joi150.default.string().trim().required(),
68085
- password: import_joi150.default.string().required(),
68086
- location: import_joi150.default.string().allow(null, "").optional(),
68087
- deviceId: import_joi150.default.string().allow(null, "").optional(),
68088
- monitorPath: import_joi150.default.string().allow(null, "").optional(),
68089
- enabled: import_joi150.default.boolean().optional(),
68090
- status: import_joi150.default.string().valid("active", "inactive", "deleted", "offline").optional(),
68091
- lastSeenAt: import_joi150.default.date().optional(),
68092
- lastSyncAt: import_joi150.default.date().optional(),
68093
- lastSyncStatus: import_joi150.default.string().valid("idle", "running", "completed", "failed").optional(),
68094
- lastSyncMessage: import_joi150.default.string().allow(null, "").optional(),
68095
- createdAt: import_joi150.default.date().optional(),
68096
- updatedAt: import_joi150.default.date().optional(),
68097
- deletedAt: import_joi150.default.date().optional()
68349
+ name: import_joi151.default.string().trim().required(),
68350
+ baseUrl: import_joi151.default.string().uri({ scheme: ["http", "https"] }).required(),
68351
+ username: import_joi151.default.string().trim().required(),
68352
+ password: import_joi151.default.string().required(),
68353
+ location: import_joi151.default.string().allow(null, "").optional(),
68354
+ deviceId: import_joi151.default.string().allow(null, "").optional(),
68355
+ monitorPath: import_joi151.default.string().allow(null, "").optional(),
68356
+ enabled: import_joi151.default.boolean().optional(),
68357
+ status: import_joi151.default.string().valid("active", "inactive", "deleted", "offline").optional(),
68358
+ lastSeenAt: import_joi151.default.date().optional(),
68359
+ lastSyncAt: import_joi151.default.date().optional(),
68360
+ lastSyncStatus: import_joi151.default.string().valid("idle", "running", "completed", "failed").optional(),
68361
+ lastSyncMessage: import_joi151.default.string().allow(null, "").optional(),
68362
+ createdAt: import_joi151.default.date().optional(),
68363
+ updatedAt: import_joi151.default.date().optional(),
68364
+ deletedAt: import_joi151.default.date().optional()
68098
68365
  });
68099
- var schemaUpdateHidAmicoReader = import_joi150.default.object({
68366
+ var schemaUpdateHidAmicoReader = import_joi151.default.object({
68100
68367
  site: objectIdSchema2.optional(),
68101
- name: import_joi150.default.string().trim().optional(),
68102
- baseUrl: import_joi150.default.string().uri({ scheme: ["http", "https"] }).optional(),
68103
- username: import_joi150.default.string().trim().optional(),
68104
- password: import_joi150.default.string().allow(null, "").optional(),
68105
- location: import_joi150.default.string().allow(null, "").optional(),
68106
- deviceId: import_joi150.default.string().allow(null, "").optional(),
68107
- monitorPath: import_joi150.default.string().allow(null, "").optional(),
68108
- enabled: import_joi150.default.boolean().optional(),
68109
- status: import_joi150.default.string().valid("active", "inactive", "deleted", "offline").optional(),
68110
- lastSeenAt: import_joi150.default.date().optional(),
68111
- lastSyncAt: import_joi150.default.date().optional(),
68112
- lastSyncStatus: import_joi150.default.string().valid("idle", "running", "completed", "failed").optional(),
68113
- lastSyncMessage: import_joi150.default.string().allow(null, "").optional(),
68114
- deletedAt: import_joi150.default.date().optional()
68368
+ name: import_joi151.default.string().trim().optional(),
68369
+ baseUrl: import_joi151.default.string().uri({ scheme: ["http", "https"] }).optional(),
68370
+ username: import_joi151.default.string().trim().optional(),
68371
+ password: import_joi151.default.string().allow(null, "").optional(),
68372
+ location: import_joi151.default.string().allow(null, "").optional(),
68373
+ deviceId: import_joi151.default.string().allow(null, "").optional(),
68374
+ monitorPath: import_joi151.default.string().allow(null, "").optional(),
68375
+ enabled: import_joi151.default.boolean().optional(),
68376
+ status: import_joi151.default.string().valid("active", "inactive", "deleted", "offline").optional(),
68377
+ lastSeenAt: import_joi151.default.date().optional(),
68378
+ lastSyncAt: import_joi151.default.date().optional(),
68379
+ lastSyncStatus: import_joi151.default.string().valid("idle", "running", "completed", "failed").optional(),
68380
+ lastSyncMessage: import_joi151.default.string().allow(null, "").optional(),
68381
+ deletedAt: import_joi151.default.date().optional()
68115
68382
  });
68116
- var schemaHidAmicoEvent = import_joi150.default.object({
68383
+ var schemaHidAmicoEvent = import_joi151.default.object({
68117
68384
  _id: objectIdSchema2.optional(),
68118
68385
  reader: objectIdSchema2.required(),
68119
68386
  site: objectIdSchema2.optional(),
68120
- type: import_joi150.default.string().required(),
68121
- payload: import_joi150.default.object().unknown(true).required(),
68122
- status: import_joi150.default.string().valid("received", "processed", "failed").optional(),
68123
- createdAt: import_joi150.default.date().optional()
68387
+ type: import_joi151.default.string().required(),
68388
+ payload: import_joi151.default.object().unknown(true).required(),
68389
+ status: import_joi151.default.string().valid("received", "processed", "failed").optional(),
68390
+ createdAt: import_joi151.default.date().optional()
68124
68391
  });
68125
- var schemaHidAmicoIdentity = import_joi150.default.object({
68392
+ var schemaHidAmicoIdentity = import_joi151.default.object({
68126
68393
  _id: objectIdSchema2.optional(),
68127
68394
  reader: objectIdSchema2.required(),
68128
68395
  site: objectIdSchema2.required(),
68129
- hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
68130
- registration: import_joi150.default.string().optional().allow(null, ""),
68131
- cardNo: import_joi150.default.string().optional().allow(null, ""),
68396
+ hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
68397
+ registration: import_joi151.default.string().optional().allow(null, ""),
68398
+ cardNo: import_joi151.default.string().optional().allow(null, ""),
68132
68399
  person: objectIdSchema2.optional().allow(null, ""),
68133
68400
  user: objectIdSchema2.optional().allow(null, ""),
68134
68401
  member: objectIdSchema2.optional().allow(null, ""),
68135
68402
  visitor: objectIdSchema2.optional().allow(null, ""),
68136
- type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68137
- status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
68138
- metadata: import_joi150.default.object().unknown(true).optional(),
68139
- createdAt: import_joi150.default.date().optional(),
68140
- updatedAt: import_joi150.default.date().optional(),
68141
- deletedAt: import_joi150.default.date().optional()
68403
+ type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68404
+ status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
68405
+ metadata: import_joi151.default.object().unknown(true).optional(),
68406
+ createdAt: import_joi151.default.date().optional(),
68407
+ updatedAt: import_joi151.default.date().optional(),
68408
+ deletedAt: import_joi151.default.date().optional()
68142
68409
  }).or("hidUserId", "registration", "cardNo");
68143
- var schemaCreateHidAmicoIdentity = import_joi150.default.object({
68410
+ var schemaCreateHidAmicoIdentity = import_joi151.default.object({
68144
68411
  site: objectIdSchema2.optional(),
68145
- hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
68146
- registration: import_joi150.default.string().optional().allow(null, ""),
68147
- cardNo: import_joi150.default.string().optional().allow(null, ""),
68412
+ hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
68413
+ registration: import_joi151.default.string().optional().allow(null, ""),
68414
+ cardNo: import_joi151.default.string().optional().allow(null, ""),
68148
68415
  person: objectIdSchema2.optional().allow(null, ""),
68149
68416
  user: objectIdSchema2.optional().allow(null, ""),
68150
68417
  member: objectIdSchema2.optional().allow(null, ""),
68151
68418
  visitor: objectIdSchema2.optional().allow(null, ""),
68152
- type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68153
- status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
68154
- metadata: import_joi150.default.object().unknown(true).optional()
68419
+ type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68420
+ status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
68421
+ metadata: import_joi151.default.object().unknown(true).optional()
68155
68422
  }).or("hidUserId", "registration", "cardNo");
68156
- var schemaUpdateHidAmicoIdentity = import_joi150.default.object({
68157
- hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
68158
- registration: import_joi150.default.string().optional().allow(null, ""),
68159
- cardNo: import_joi150.default.string().optional().allow(null, ""),
68423
+ var schemaUpdateHidAmicoIdentity = import_joi151.default.object({
68424
+ hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
68425
+ registration: import_joi151.default.string().optional().allow(null, ""),
68426
+ cardNo: import_joi151.default.string().optional().allow(null, ""),
68160
68427
  person: objectIdSchema2.optional().allow(null, ""),
68161
68428
  user: objectIdSchema2.optional().allow(null, ""),
68162
68429
  member: objectIdSchema2.optional().allow(null, ""),
68163
68430
  visitor: objectIdSchema2.optional().allow(null, ""),
68164
- type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68165
- status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
68166
- metadata: import_joi150.default.object().unknown(true).optional(),
68167
- deletedAt: import_joi150.default.date().optional()
68431
+ type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68432
+ status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
68433
+ metadata: import_joi151.default.object().unknown(true).optional(),
68434
+ deletedAt: import_joi151.default.date().optional()
68168
68435
  });
68169
- var schemaHidAmicoReaderIdParams = import_joi150.default.object({
68170
- readerId: import_joi150.default.string().hex().length(24).required()
68436
+ var schemaHidAmicoReaderIdParams = import_joi151.default.object({
68437
+ readerId: import_joi151.default.string().hex().length(24).required()
68171
68438
  });
68172
- var schemaHidAmicoUserImageParams = import_joi150.default.object({
68173
- readerId: import_joi150.default.string().hex().length(24).required(),
68174
- hidUserId: import_joi150.default.alternatives().try(import_joi150.default.string(), import_joi150.default.number()).required()
68439
+ var schemaHidAmicoUserImageParams = import_joi151.default.object({
68440
+ readerId: import_joi151.default.string().hex().length(24).required(),
68441
+ hidUserId: import_joi151.default.alternatives().try(import_joi151.default.string(), import_joi151.default.number()).required()
68175
68442
  });
68176
- var schemaHidAmicoIdentityIdParams = import_joi150.default.object({
68177
- identityId: import_joi150.default.string().hex().length(24).required()
68443
+ var schemaHidAmicoIdentityIdParams = import_joi151.default.object({
68444
+ identityId: import_joi151.default.string().hex().length(24).required()
68178
68445
  });
68179
- var schemaHidAmicoReaderListQuery = import_joi150.default.object({
68180
- site: import_joi150.default.string().hex().length(24).optional(),
68181
- page: import_joi150.default.number().min(1).optional(),
68182
- limit: import_joi150.default.number().min(1).optional()
68446
+ var schemaHidAmicoReaderListQuery = import_joi151.default.object({
68447
+ site: import_joi151.default.string().hex().length(24).optional(),
68448
+ page: import_joi151.default.number().min(1).optional(),
68449
+ limit: import_joi151.default.number().min(1).optional()
68183
68450
  });
68184
- var schemaHidAmicoLogQuery = import_joi150.default.object({
68185
- page: import_joi150.default.number().min(1).optional(),
68186
- limit: import_joi150.default.number().min(1).optional(),
68187
- type: import_joi150.default.string().optional()
68451
+ var schemaHidAmicoLogQuery = import_joi151.default.object({
68452
+ page: import_joi151.default.number().min(1).optional(),
68453
+ limit: import_joi151.default.number().min(1).optional(),
68454
+ type: import_joi151.default.string().optional()
68188
68455
  });
68189
- var schemaHidAmicoIdentityQuery = import_joi150.default.object({
68190
- page: import_joi150.default.number().min(1).optional(),
68191
- limit: import_joi150.default.number().min(1).optional(),
68192
- type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68193
- status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
68194
- search: import_joi150.default.string().allow("").optional()
68456
+ var schemaHidAmicoIdentityQuery = import_joi151.default.object({
68457
+ page: import_joi151.default.number().min(1).optional(),
68458
+ limit: import_joi151.default.number().min(1).optional(),
68459
+ type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68460
+ status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
68461
+ search: import_joi151.default.string().allow("").optional()
68195
68462
  });
68196
- var schemaHidAmicoSync = import_joi150.default.object({
68197
- objects: import_joi150.default.array().items(
68198
- import_joi150.default.object({
68199
- object: import_joi150.default.string().required(),
68200
- values: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).required()
68463
+ var schemaHidAmicoSync = import_joi151.default.object({
68464
+ objects: import_joi151.default.array().items(
68465
+ import_joi151.default.object({
68466
+ object: import_joi151.default.string().required(),
68467
+ values: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).required()
68201
68468
  }).unknown(true)
68202
68469
  ).optional(),
68203
- users: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
68204
- cards: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
68205
- qrcodes: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
68206
- pins: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional()
68470
+ users: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
68471
+ cards: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
68472
+ qrcodes: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
68473
+ pins: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional()
68207
68474
  }).unknown(true);
68208
- var schemaHidAmicoExecuteActions = import_joi150.default.object({
68209
- actions: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).min(1).required()
68475
+ var schemaHidAmicoExecuteActions = import_joi151.default.object({
68476
+ actions: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).min(1).required()
68210
68477
  }).unknown(true);
68211
- var schemaHidAmicoConfiguration = import_joi150.default.object().pattern(import_joi150.default.string(), import_joi150.default.array().items(import_joi150.default.string())).min(1).unknown(true);
68212
- var schemaHidAmicoSetConfiguration = import_joi150.default.object().unknown(true);
68213
- var schemaHidAmicoObjectOperation = import_joi150.default.object({
68214
- operation: import_joi150.default.string().valid("load", "create", "modify", "destroy").required(),
68215
- object: import_joi150.default.string().required(),
68216
- values: import_joi150.default.alternatives().try(
68217
- import_joi150.default.array().items(import_joi150.default.object().unknown(true)),
68218
- import_joi150.default.object().unknown(true)
68478
+ var schemaHidAmicoConfiguration = import_joi151.default.object().pattern(import_joi151.default.string(), import_joi151.default.array().items(import_joi151.default.string())).min(1).unknown(true);
68479
+ var schemaHidAmicoSetConfiguration = import_joi151.default.object().unknown(true);
68480
+ var schemaHidAmicoObjectOperation = import_joi151.default.object({
68481
+ operation: import_joi151.default.string().valid("load", "create", "modify", "destroy").required(),
68482
+ object: import_joi151.default.string().required(),
68483
+ values: import_joi151.default.alternatives().try(
68484
+ import_joi151.default.array().items(import_joi151.default.object().unknown(true)),
68485
+ import_joi151.default.object().unknown(true)
68219
68486
  ).optional(),
68220
- where: import_joi150.default.object().unknown(true).optional(),
68221
- fields: import_joi150.default.array().items(import_joi150.default.string()).optional(),
68222
- order: import_joi150.default.array().items(import_joi150.default.string()).optional(),
68223
- limit: import_joi150.default.number().integer().min(1).optional(),
68224
- offset: import_joi150.default.number().integer().min(0).optional()
68487
+ where: import_joi151.default.object().unknown(true).optional(),
68488
+ fields: import_joi151.default.array().items(import_joi151.default.string()).optional(),
68489
+ order: import_joi151.default.array().items(import_joi151.default.string()).optional(),
68490
+ limit: import_joi151.default.number().integer().min(1).optional(),
68491
+ offset: import_joi151.default.number().integer().min(0).optional()
68225
68492
  }).unknown(true);
68226
- var schemaHidAmicoNotificationParams = import_joi150.default.object({
68227
- readerId: import_joi150.default.string().hex().length(24).required(),
68228
- type: import_joi150.default.string().valid(
68493
+ var schemaHidAmicoNotificationParams = import_joi151.default.object({
68494
+ readerId: import_joi151.default.string().hex().length(24).required(),
68495
+ type: import_joi151.default.string().valid(
68229
68496
  "dao",
68230
68497
  "template",
68231
68498
  "user_image",
@@ -68243,8 +68510,8 @@ var schemaHidAmicoNotificationParams = import_joi150.default.object({
68243
68510
  function MHidAmicoReader(value) {
68244
68511
  const { error } = schemaHidAmicoReader.validate(value);
68245
68512
  if (error) {
68246
- import_node_server_utils257.logger.info(`HID Amico reader: ${error.message}`);
68247
- throw new import_node_server_utils257.BadRequestError(error.message);
68513
+ import_node_server_utils258.logger.info(`HID Amico reader: ${error.message}`);
68514
+ throw new import_node_server_utils258.BadRequestError(error.message);
68248
68515
  }
68249
68516
  return {
68250
68517
  _id: value._id ? toObjectId23(value._id, "reader ID") : new import_mongodb153.ObjectId(),
@@ -68270,8 +68537,8 @@ function MHidAmicoReader(value) {
68270
68537
  function MHidAmicoEvent(value) {
68271
68538
  const { error } = schemaHidAmicoEvent.validate(value);
68272
68539
  if (error) {
68273
- import_node_server_utils257.logger.info(`HID Amico event: ${error.message}`);
68274
- throw new import_node_server_utils257.BadRequestError(error.message);
68540
+ import_node_server_utils258.logger.info(`HID Amico event: ${error.message}`);
68541
+ throw new import_node_server_utils258.BadRequestError(error.message);
68275
68542
  }
68276
68543
  return {
68277
68544
  _id: value._id ? toObjectId23(value._id, "event ID") : new import_mongodb153.ObjectId(),
@@ -68289,8 +68556,8 @@ function optionalObjectId(value) {
68289
68556
  function MHidAmicoIdentity(value) {
68290
68557
  const { error } = schemaHidAmicoIdentity.validate(value);
68291
68558
  if (error) {
68292
- import_node_server_utils257.logger.info(`HID Amico identity: ${error.message}`);
68293
- throw new import_node_server_utils257.BadRequestError(error.message);
68559
+ import_node_server_utils258.logger.info(`HID Amico identity: ${error.message}`);
68560
+ throw new import_node_server_utils258.BadRequestError(error.message);
68294
68561
  }
68295
68562
  return {
68296
68563
  _id: value._id ? toObjectId23(value._id, "identity ID") : new import_mongodb153.ObjectId(),
@@ -68313,13 +68580,13 @@ function MHidAmicoIdentity(value) {
68313
68580
  }
68314
68581
 
68315
68582
  // src/repositories/hid-amico.repo.ts
68316
- var import_node_server_utils258 = require("@7365admin1/node-server-utils");
68583
+ var import_node_server_utils259 = require("@7365admin1/node-server-utils");
68317
68584
  var import_mongodb154 = require("mongodb");
68318
68585
  function useHidAmicoRepo() {
68319
68586
  function db() {
68320
- const instance = import_node_server_utils258.useAtlas.getDb();
68587
+ const instance = import_node_server_utils259.useAtlas.getDb();
68321
68588
  if (!instance) {
68322
- throw new import_node_server_utils258.InternalServerError("Unable to connect to server.");
68589
+ throw new import_node_server_utils259.InternalServerError("Unable to connect to server.");
68323
68590
  }
68324
68591
  return instance;
68325
68592
  }
@@ -68336,7 +68603,7 @@ function useHidAmicoRepo() {
68336
68603
  try {
68337
68604
  return new import_mongodb154.ObjectId(id);
68338
68605
  } catch {
68339
- throw new import_node_server_utils258.BadRequestError(`Invalid ${label} format`);
68606
+ throw new import_node_server_utils259.BadRequestError(`Invalid ${label} format`);
68340
68607
  }
68341
68608
  }
68342
68609
  function hideSecret(reader) {
@@ -68387,7 +68654,7 @@ function useHidAmicoRepo() {
68387
68654
  ]);
68388
68655
  return "HID Amico indexes created.";
68389
68656
  } catch (error) {
68390
- import_node_server_utils258.logger.error(error.message);
68657
+ import_node_server_utils259.logger.error(error.message);
68391
68658
  throw new Error("Failed to create HID Amico indexes.");
68392
68659
  }
68393
68660
  }
@@ -68398,7 +68665,7 @@ function useHidAmicoRepo() {
68398
68665
  return hideSecret(doc);
68399
68666
  } catch (error) {
68400
68667
  if (error.message?.includes("duplicate")) {
68401
- throw new import_node_server_utils258.BadRequestError("HID Amico reader already exists for this site and URL.");
68668
+ throw new import_node_server_utils259.BadRequestError("HID Amico reader already exists for this site and URL.");
68402
68669
  }
68403
68670
  throw error;
68404
68671
  }
@@ -68412,7 +68679,7 @@ function useHidAmicoRepo() {
68412
68679
  }
68413
68680
  const items = await readers().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68414
68681
  const total = await readers().countDocuments(query);
68415
- return (0, import_node_server_utils258.paginate)(items.map(hideSecret), page, limit, total);
68682
+ return (0, import_node_server_utils259.paginate)(items.map(hideSecret), page, limit, total);
68416
68683
  }
68417
68684
  async function getById(id, options = {}) {
68418
68685
  const _id = toId(id, "reader ID");
@@ -68420,14 +68687,14 @@ function useHidAmicoRepo() {
68420
68687
  { _id, status: { $ne: "deleted" } }
68421
68688
  );
68422
68689
  if (!reader) {
68423
- throw new import_node_server_utils258.BadRequestError("HID Amico reader not found.");
68690
+ throw new import_node_server_utils259.BadRequestError("HID Amico reader not found.");
68424
68691
  }
68425
68692
  return options.includePassword ? reader : hideSecret(reader);
68426
68693
  }
68427
68694
  async function updateById(id, value, session) {
68428
68695
  const { error } = schemaUpdateHidAmicoReader.validate(value);
68429
68696
  if (error) {
68430
- throw new import_node_server_utils258.BadRequestError(error.message);
68697
+ throw new import_node_server_utils259.BadRequestError(error.message);
68431
68698
  }
68432
68699
  const _id = toId(id, "reader ID");
68433
68700
  const payload = {
@@ -68446,7 +68713,7 @@ function useHidAmicoRepo() {
68446
68713
  { returnDocument: "after", session }
68447
68714
  );
68448
68715
  if (!updated) {
68449
- throw new import_node_server_utils258.BadRequestError("HID Amico reader not found.");
68716
+ throw new import_node_server_utils259.BadRequestError("HID Amico reader not found.");
68450
68717
  }
68451
68718
  return hideSecret(updated);
68452
68719
  }
@@ -68475,7 +68742,7 @@ function useHidAmicoRepo() {
68475
68742
  }
68476
68743
  const items = await events().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68477
68744
  const total = await events().countDocuments(query);
68478
- return (0, import_node_server_utils258.paginate)(items, page, limit, total);
68745
+ return (0, import_node_server_utils259.paginate)(items, page, limit, total);
68479
68746
  }
68480
68747
  async function addIdentity(value, session) {
68481
68748
  try {
@@ -68487,16 +68754,16 @@ function useHidAmicoRepo() {
68487
68754
  cardNo: identity.cardNo
68488
68755
  });
68489
68756
  if (existing) {
68490
- throw new import_node_server_utils258.BadRequestError("HID Amico identity already exists for this reader.");
68757
+ throw new import_node_server_utils259.BadRequestError("HID Amico identity already exists for this reader.");
68491
68758
  }
68492
68759
  await identities().insertOne(identity, { session });
68493
68760
  return identity;
68494
68761
  } catch (error) {
68495
- if (error instanceof import_node_server_utils258.BadRequestError) {
68762
+ if (error instanceof import_node_server_utils259.BadRequestError) {
68496
68763
  throw error;
68497
68764
  }
68498
68765
  if (error.message?.includes("duplicate")) {
68499
- throw new import_node_server_utils258.BadRequestError("HID Amico identity already exists for this reader.");
68766
+ throw new import_node_server_utils259.BadRequestError("HID Amico identity already exists for this reader.");
68500
68767
  }
68501
68768
  throw error;
68502
68769
  }
@@ -68521,12 +68788,12 @@ function useHidAmicoRepo() {
68521
68788
  }
68522
68789
  const items = await identities().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68523
68790
  const total = await identities().countDocuments(query);
68524
- return (0, import_node_server_utils258.paginate)(items, page, limit, total);
68791
+ return (0, import_node_server_utils259.paginate)(items, page, limit, total);
68525
68792
  }
68526
68793
  async function updateIdentity(id, value, session) {
68527
68794
  const { error } = schemaUpdateHidAmicoIdentity.validate(value);
68528
68795
  if (error) {
68529
- throw new import_node_server_utils258.BadRequestError(error.message);
68796
+ throw new import_node_server_utils259.BadRequestError(error.message);
68530
68797
  }
68531
68798
  const payload = {
68532
68799
  ...value,
@@ -68554,7 +68821,7 @@ function useHidAmicoRepo() {
68554
68821
  { returnDocument: "after", session }
68555
68822
  );
68556
68823
  if (!updated) {
68557
- throw new import_node_server_utils258.BadRequestError("HID Amico identity not found.");
68824
+ throw new import_node_server_utils259.BadRequestError("HID Amico identity not found.");
68558
68825
  }
68559
68826
  return updated;
68560
68827
  }
@@ -68611,7 +68878,7 @@ function useHidAmicoRepo() {
68611
68878
  // src/services/hid-amico.service.ts
68612
68879
  var import_crypto3 = __toESM(require("crypto"));
68613
68880
  var import_axios4 = __toESM(require("axios"));
68614
- var import_node_server_utils259 = require("@7365admin1/node-server-utils");
68881
+ var import_node_server_utils260 = require("@7365admin1/node-server-utils");
68615
68882
  var PASSWORD_PREFIX = "v1";
68616
68883
  function getSecretKey() {
68617
68884
  const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
@@ -68655,7 +68922,7 @@ function toHidRequestError(error, path5) {
68655
68922
  status ? `status ${status}` : "",
68656
68923
  payload ? `response ${payload}` : error.message
68657
68924
  ].filter(Boolean).join(" - ");
68658
- return new import_node_server_utils259.BadRequestError(detail);
68925
+ return new import_node_server_utils260.BadRequestError(detail);
68659
68926
  }
68660
68927
  return error;
68661
68928
  }
@@ -68697,7 +68964,7 @@ var HidAmicoClient = class {
68697
68964
  password: decryptSecret(this.reader.password)
68698
68965
  });
68699
68966
  if (!res.data?.session) {
68700
- throw new import_node_server_utils259.BadRequestError("HID Amico login failed: missing session.");
68967
+ throw new import_node_server_utils260.BadRequestError("HID Amico login failed: missing session.");
68701
68968
  }
68702
68969
  this.session = res.data.session;
68703
68970
  return this.session;
@@ -68721,7 +68988,7 @@ var HidAmicoClient = class {
68721
68988
  const payload = JSON.parse(buffer.toString("utf8"));
68722
68989
  const image = payload.image || payload.photo || payload.data?.image || payload.data?.photo;
68723
68990
  if (!image) {
68724
- throw new import_node_server_utils259.BadRequestError("HID Amico user image response did not include an image.");
68991
+ throw new import_node_server_utils260.BadRequestError("HID Amico user image response did not include an image.");
68725
68992
  }
68726
68993
  return {
68727
68994
  contentType: payload.contentType || payload.mimeType || "image/jpeg",
@@ -68846,7 +69113,7 @@ function useHidAmicoService() {
68846
69113
  async function getActiveReader(id) {
68847
69114
  const reader = await repo.getById(id, { includePassword: true });
68848
69115
  if (reader.enabled === false || reader.status === "inactive" || reader.status === "deleted") {
68849
- throw new import_node_server_utils259.BadRequestError("HID Amico reader is not active.");
69116
+ throw new import_node_server_utils260.BadRequestError("HID Amico reader is not active.");
68850
69117
  }
68851
69118
  return reader;
68852
69119
  }
@@ -69101,13 +69368,13 @@ function useHidAmicoService() {
69101
69368
  }
69102
69369
 
69103
69370
  // src/controllers/hid-amico.controller.ts
69104
- var import_node_server_utils260 = require("@7365admin1/node-server-utils");
69371
+ var import_node_server_utils261 = require("@7365admin1/node-server-utils");
69105
69372
  function useHidAmicoController() {
69106
69373
  const service = useHidAmicoService();
69107
69374
  async function listReaders(req, res, next) {
69108
69375
  const { error, value } = schemaHidAmicoReaderListQuery.validate(req.query);
69109
69376
  if (error) {
69110
- next(new import_node_server_utils260.BadRequestError(error.message));
69377
+ next(new import_node_server_utils261.BadRequestError(error.message));
69111
69378
  return;
69112
69379
  }
69113
69380
  try {
@@ -69119,7 +69386,7 @@ function useHidAmicoController() {
69119
69386
  async function createReader(req, res, next) {
69120
69387
  const { error, value } = schemaHidAmicoReader.validate(req.body);
69121
69388
  if (error) {
69122
- next(new import_node_server_utils260.BadRequestError(error.message));
69389
+ next(new import_node_server_utils261.BadRequestError(error.message));
69123
69390
  return;
69124
69391
  }
69125
69392
  try {
@@ -69132,7 +69399,7 @@ function useHidAmicoController() {
69132
69399
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69133
69400
  const body = schemaUpdateHidAmicoReader.validate(req.body);
69134
69401
  if (params.error || body.error) {
69135
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69402
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69136
69403
  return;
69137
69404
  }
69138
69405
  try {
@@ -69144,7 +69411,7 @@ function useHidAmicoController() {
69144
69411
  async function deleteReader(req, res, next) {
69145
69412
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
69146
69413
  if (error) {
69147
- next(new import_node_server_utils260.BadRequestError(error.message));
69414
+ next(new import_node_server_utils261.BadRequestError(error.message));
69148
69415
  return;
69149
69416
  }
69150
69417
  try {
@@ -69156,7 +69423,7 @@ function useHidAmicoController() {
69156
69423
  async function testReader(req, res, next) {
69157
69424
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
69158
69425
  if (error) {
69159
- next(new import_node_server_utils260.BadRequestError(error.message));
69426
+ next(new import_node_server_utils261.BadRequestError(error.message));
69160
69427
  return;
69161
69428
  }
69162
69429
  try {
@@ -69169,7 +69436,7 @@ function useHidAmicoController() {
69169
69436
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69170
69437
  const body = schemaHidAmicoSync.validate(req.body ?? {});
69171
69438
  if (params.error || body.error) {
69172
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69439
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69173
69440
  return;
69174
69441
  }
69175
69442
  try {
@@ -69182,7 +69449,7 @@ function useHidAmicoController() {
69182
69449
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69183
69450
  const query = schemaHidAmicoLogQuery.validate(req.query);
69184
69451
  if (params.error || query.error) {
69185
- next(new import_node_server_utils260.BadRequestError(params.error?.message || query.error?.message));
69452
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || query.error?.message));
69186
69453
  return;
69187
69454
  }
69188
69455
  try {
@@ -69195,7 +69462,7 @@ function useHidAmicoController() {
69195
69462
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69196
69463
  const query = schemaHidAmicoIdentityQuery.validate(req.query);
69197
69464
  if (params.error || query.error) {
69198
- next(new import_node_server_utils260.BadRequestError(params.error?.message || query.error?.message));
69465
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || query.error?.message));
69199
69466
  return;
69200
69467
  }
69201
69468
  try {
@@ -69207,13 +69474,13 @@ function useHidAmicoController() {
69207
69474
  async function createIdentity(req, res, next) {
69208
69475
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69209
69476
  if (params.error) {
69210
- next(new import_node_server_utils260.BadRequestError(params.error.message));
69477
+ next(new import_node_server_utils261.BadRequestError(params.error.message));
69211
69478
  return;
69212
69479
  }
69213
69480
  try {
69214
69481
  const body = schemaCreateHidAmicoIdentity.validate(req.body);
69215
69482
  if (body.error) {
69216
- next(new import_node_server_utils260.BadRequestError(body.error.message));
69483
+ next(new import_node_server_utils261.BadRequestError(body.error.message));
69217
69484
  return;
69218
69485
  }
69219
69486
  res.status(201).json({ data: await service.createIdentity(params.value.readerId, body.value) });
@@ -69225,7 +69492,7 @@ function useHidAmicoController() {
69225
69492
  const params = schemaHidAmicoIdentityIdParams.validate(req.params);
69226
69493
  const body = schemaUpdateHidAmicoIdentity.validate(req.body ?? {});
69227
69494
  if (params.error || body.error) {
69228
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69495
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69229
69496
  return;
69230
69497
  }
69231
69498
  try {
@@ -69237,7 +69504,7 @@ function useHidAmicoController() {
69237
69504
  async function deleteIdentity(req, res, next) {
69238
69505
  const { error, value } = schemaHidAmicoIdentityIdParams.validate(req.params);
69239
69506
  if (error) {
69240
- next(new import_node_server_utils260.BadRequestError(error.message));
69507
+ next(new import_node_server_utils261.BadRequestError(error.message));
69241
69508
  return;
69242
69509
  }
69243
69510
  try {
@@ -69249,7 +69516,7 @@ function useHidAmicoController() {
69249
69516
  async function receiveNotification(req, res, next) {
69250
69517
  const validation = schemaHidAmicoNotificationParams.validate(req.params);
69251
69518
  if (validation.error) {
69252
- next(new import_node_server_utils260.BadRequestError(validation.error.message));
69519
+ next(new import_node_server_utils261.BadRequestError(validation.error.message));
69253
69520
  return;
69254
69521
  }
69255
69522
  try {
@@ -69266,7 +69533,7 @@ function useHidAmicoController() {
69266
69533
  async function getDoorState(req, res, next) {
69267
69534
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
69268
69535
  if (error) {
69269
- next(new import_node_server_utils260.BadRequestError(error.message));
69536
+ next(new import_node_server_utils261.BadRequestError(error.message));
69270
69537
  return;
69271
69538
  }
69272
69539
  try {
@@ -69278,7 +69545,7 @@ function useHidAmicoController() {
69278
69545
  async function getUserImage(req, res, next) {
69279
69546
  const { error, value } = schemaHidAmicoUserImageParams.validate(req.params);
69280
69547
  if (error) {
69281
- next(new import_node_server_utils260.BadRequestError(error.message));
69548
+ next(new import_node_server_utils261.BadRequestError(error.message));
69282
69549
  return;
69283
69550
  }
69284
69551
  try {
@@ -69292,7 +69559,7 @@ function useHidAmicoController() {
69292
69559
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69293
69560
  const body = schemaHidAmicoExecuteActions.validate(req.body ?? {});
69294
69561
  if (params.error || body.error) {
69295
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69562
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69296
69563
  return;
69297
69564
  }
69298
69565
  try {
@@ -69305,7 +69572,7 @@ function useHidAmicoController() {
69305
69572
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69306
69573
  const body = schemaHidAmicoConfiguration.validate(req.body ?? {});
69307
69574
  if (params.error || body.error) {
69308
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69575
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69309
69576
  return;
69310
69577
  }
69311
69578
  try {
@@ -69318,7 +69585,7 @@ function useHidAmicoController() {
69318
69585
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69319
69586
  const body = schemaHidAmicoSetConfiguration.validate(req.body ?? {});
69320
69587
  if (params.error || body.error) {
69321
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69588
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69322
69589
  return;
69323
69590
  }
69324
69591
  try {
@@ -69331,20 +69598,20 @@ function useHidAmicoController() {
69331
69598
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69332
69599
  const body = schemaHidAmicoObjectOperation.validate(req.body ?? {});
69333
69600
  if (params.error || body.error) {
69334
- next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69601
+ next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
69335
69602
  return;
69336
69603
  }
69337
69604
  const { operation, ...payload } = body.value;
69338
69605
  if (operation === "create" && !Array.isArray(payload.values)) {
69339
- next(new import_node_server_utils260.BadRequestError("values array is required for HID object create operations."));
69606
+ next(new import_node_server_utils261.BadRequestError("values array is required for HID object create operations."));
69340
69607
  return;
69341
69608
  }
69342
69609
  if (operation === "modify" && (!payload.values || Array.isArray(payload.values) || !payload.where)) {
69343
- next(new import_node_server_utils260.BadRequestError("values object and where are required for HID object modify operations."));
69610
+ next(new import_node_server_utils261.BadRequestError("values object and where are required for HID object modify operations."));
69344
69611
  return;
69345
69612
  }
69346
69613
  if (operation === "destroy" && !payload.where) {
69347
- next(new import_node_server_utils260.BadRequestError("where is required for HID object destroy operations."));
69614
+ next(new import_node_server_utils261.BadRequestError("where is required for HID object destroy operations."));
69348
69615
  return;
69349
69616
  }
69350
69617
  try {
@@ -69523,6 +69790,7 @@ function useHidAmicoController() {
69523
69790
  building_units_namespace_collection,
69524
69791
  buildings_namespace_collection,
69525
69792
  bulletin_boards_namespace_collection,
69793
+ chatPrelovedEvents,
69526
69794
  chatSchema,
69527
69795
  createManpowerRemarksDaily,
69528
69796
  customerSchema,
@@ -69678,6 +69946,7 @@ function useHidAmicoController() {
69678
69946
  useAuthServiceV2,
69679
69947
  useBidPrelovedController,
69680
69948
  useBidPrelovedRepo,
69949
+ useBidPrelovedService,
69681
69950
  useBuildingController,
69682
69951
  useBuildingLevelController,
69683
69952
  useBuildingLevelRepo,