@7365admin1/core 3.14.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -537,13 +537,13 @@ var require_logger = __commonJS({
537
537
  "use strict";
538
538
  exports.__esModule = true;
539
539
  var _utils = require_utils();
540
- var logger200 = {
540
+ var logger201 = {
541
541
  methodMap: ["debug", "info", "warn", "error"],
542
542
  level: "info",
543
543
  // Maps a given level value to the `methodMap` indexes above.
544
544
  lookupLevel: function lookupLevel(level) {
545
545
  if (typeof level === "string") {
546
- var levelMap = _utils.indexOf(logger200.methodMap, level.toLowerCase());
546
+ var levelMap = _utils.indexOf(logger201.methodMap, level.toLowerCase());
547
547
  if (levelMap >= 0) {
548
548
  level = levelMap;
549
549
  } else {
@@ -554,9 +554,9 @@ var require_logger = __commonJS({
554
554
  },
555
555
  // Can be overridden in the host environment
556
556
  log: function log(level) {
557
- level = logger200.lookupLevel(level);
558
- if (typeof console !== "undefined" && logger200.lookupLevel(logger200.level) <= level) {
559
- var method = logger200.methodMap[level];
557
+ level = logger201.lookupLevel(level);
558
+ if (typeof console !== "undefined" && logger201.lookupLevel(logger201.level) <= level) {
559
+ var method = logger201.methodMap[level];
560
560
  if (!console[method]) {
561
561
  method = "log";
562
562
  }
@@ -567,7 +567,7 @@ var require_logger = __commonJS({
567
567
  }
568
568
  }
569
569
  };
570
- exports["default"] = logger200;
570
+ exports["default"] = logger201;
571
571
  module.exports = exports["default"];
572
572
  }
573
573
  });
@@ -8280,12 +8280,6 @@ function useUserRepo() {
8280
8280
  throw new BadRequestError9("Invalid user ID format.");
8281
8281
  }
8282
8282
  try {
8283
- const cacheKey = makeCacheKey5(namespace_collection, { _id });
8284
- const cachedData = await getCache(cacheKey);
8285
- if (cachedData) {
8286
- logger7.info(`Cache hit for key: ${cacheKey}`);
8287
- return cachedData;
8288
- }
8289
8283
  const results = await collection.aggregate([
8290
8284
  { $match: { _id } },
8291
8285
  {
@@ -8309,17 +8303,42 @@ function useUserRepo() {
8309
8303
  ],
8310
8304
  as: "serviceProviders"
8311
8305
  }
8312
- }
8306
+ },
8307
+ {
8308
+ $lookup: {
8309
+ from: "buildings",
8310
+ localField: "block",
8311
+ foreignField: "_id",
8312
+ pipeline: [{ $project: { _id: 0, name: 1, block: 1 } }],
8313
+ as: "blockInfo"
8314
+ }
8315
+ },
8316
+ { $unwind: { path: "$blockInfo", preserveNullAndEmptyArrays: true } },
8317
+ {
8318
+ $lookup: {
8319
+ from: "building-levels",
8320
+ localField: "level",
8321
+ foreignField: "_id",
8322
+ pipeline: [{ $project: { _id: 0, name: 1 } }],
8323
+ as: "levelInfo"
8324
+ }
8325
+ },
8326
+ { $unwind: { path: "$levelInfo", preserveNullAndEmptyArrays: true } },
8327
+ {
8328
+ $lookup: {
8329
+ from: "building-units",
8330
+ localField: "unitId",
8331
+ foreignField: "_id",
8332
+ pipeline: [{ $project: { _id: 0, name: 1 } }],
8333
+ as: "unitInfo"
8334
+ }
8335
+ },
8336
+ { $unwind: { path: "$unitInfo", preserveNullAndEmptyArrays: true } }
8313
8337
  ]).toArray();
8314
8338
  const data = results.length > 0 ? results[0] : null;
8315
8339
  if (!data) {
8316
8340
  throw new NotFoundError4("User not found.");
8317
8341
  }
8318
- setCache(cacheKey, data, 15 * 60).then(() => {
8319
- logger7.info(`Cache set for key: ${cacheKey}`);
8320
- }).catch((err) => {
8321
- logger7.error(`Failed to set cache for key: ${cacheKey}`, err);
8322
- });
8323
8342
  return data;
8324
8343
  } catch (error) {
8325
8344
  if (error instanceof AppError) {
@@ -25586,6 +25605,22 @@ function useBuildingUnitRepo() {
25586
25605
  }
25587
25606
  return [level];
25588
25607
  }
25608
+ function escapeRegExp(value) {
25609
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25610
+ }
25611
+ function makeFlexibleRegex(value) {
25612
+ const pattern = value.trim().split(/\s+/).map(escapeRegExp).join("\\s*");
25613
+ return pattern ? new RegExp(pattern, "i") : null;
25614
+ }
25615
+ function getSearchParts(searchText) {
25616
+ const levelMatch = searchText.match(/\b(?:lvl|level)\s*([a-z0-9]+)\b/i);
25617
+ const levelSearch = levelMatch?.[0] ?? "";
25618
+ const unitSearch = levelSearch ? searchText.replace(levelSearch, "").trim() : "";
25619
+ return {
25620
+ levelRegex: makeFlexibleRegex(levelSearch),
25621
+ unitRegex: makeFlexibleRegex(unitSearch)
25622
+ };
25623
+ }
25589
25624
  async function add(value, session) {
25590
25625
  try {
25591
25626
  value = MBuildingUnit(value);
@@ -25711,9 +25746,11 @@ function useBuildingUnitRepo() {
25711
25746
  status = "active"
25712
25747
  } = {}) {
25713
25748
  page = page > 0 ? page - 1 : 0;
25749
+ const searchText = search.trim();
25750
+ const searchRegex = makeFlexibleRegex(searchText);
25751
+ const { levelRegex, unitRegex } = getSearchParts(searchText);
25714
25752
  const query = {
25715
25753
  status,
25716
- ...search && { $text: { $search: search } },
25717
25754
  ...site && { site: toObjectId11(site) },
25718
25755
  ...building && { building: toObjectId11(building) }
25719
25756
  };
@@ -25722,7 +25759,7 @@ function useBuildingUnitRepo() {
25722
25759
  page,
25723
25760
  limit,
25724
25761
  sort: JSON.stringify(sort),
25725
- ...search && { search },
25762
+ ...searchText && { search: searchText },
25726
25763
  ...site && { site },
25727
25764
  ...building && { building },
25728
25765
  ...status && { status }
@@ -25744,8 +25781,45 @@ function useBuildingUnitRepo() {
25744
25781
  });
25745
25782
  return cached;
25746
25783
  }
25747
- const items = await collection.aggregate([
25784
+ const pipeline = [
25748
25785
  { $match: query },
25786
+ {
25787
+ $lookup: {
25788
+ from: "building-levels",
25789
+ localField: "level",
25790
+ foreignField: "_id",
25791
+ pipeline: [{ $project: { name: 1 } }],
25792
+ as: "level"
25793
+ }
25794
+ },
25795
+ { $set: { level: { $first: "$level" } } },
25796
+ ...searchRegex ? [
25797
+ {
25798
+ $match: {
25799
+ $or: [
25800
+ { name: searchRegex },
25801
+ { buildingName: searchRegex },
25802
+ { "level.name": searchRegex },
25803
+ ...levelRegex && unitRegex ? [
25804
+ {
25805
+ $and: [
25806
+ {
25807
+ $or: [
25808
+ { name: unitRegex },
25809
+ { buildingName: unitRegex }
25810
+ ]
25811
+ },
25812
+ { "level.name": levelRegex }
25813
+ ]
25814
+ }
25815
+ ] : []
25816
+ ]
25817
+ }
25818
+ }
25819
+ ] : []
25820
+ ];
25821
+ const items = await collection.aggregate([
25822
+ ...pipeline,
25749
25823
  {
25750
25824
  $lookup: {
25751
25825
  from: "sites",
@@ -25771,22 +25845,13 @@ function useBuildingUnitRepo() {
25771
25845
  as: "site"
25772
25846
  }
25773
25847
  },
25774
- {
25775
- $lookup: {
25776
- from: "building-levels",
25777
- localField: "level",
25778
- foreignField: "_id",
25779
- pipeline: [{ $project: { name: 1 } }],
25780
- as: "level"
25781
- }
25782
- },
25783
- { $set: { level: { $first: "$level" } } },
25784
25848
  { $set: { site: { $first: "$site" } } },
25785
25849
  { $sort: sort },
25786
25850
  { $skip: page * limit },
25787
25851
  { $limit: limit }
25788
25852
  ]).toArray();
25789
- const length = await collection.countDocuments(query);
25853
+ const total = await collection.aggregate([...pipeline, { $count: "length" }]).toArray();
25854
+ const length = total[0]?.length ?? 0;
25790
25855
  const data = paginate21(items, page, limit, length);
25791
25856
  setCache(cacheKey, data, 600).then(() => {
25792
25857
  logger54.log({
@@ -27889,6 +27954,7 @@ function useBuildingRepo() {
27889
27954
  { key: { name: "text" }, name: "text-index" },
27890
27955
  // { key: { name: 1 }, unique: true, name: "unique-name-index" },
27891
27956
  { key: { site: 1 } },
27957
+ { key: { block: 1 }, name: "block-index" },
27892
27958
  { key: { createdAt: 1 } },
27893
27959
  {
27894
27960
  key: { site: 1, block: 1 },
@@ -27991,17 +28057,25 @@ function useBuildingRepo() {
27991
28057
  throw new BadRequestError80("Invalid site ID.");
27992
28058
  }
27993
28059
  }
28060
+ const searchText = search.trim();
28061
+ const blockSearch = Number(searchText);
28062
+ const canSearchBlock = searchText !== "" && Number.isFinite(blockSearch);
27994
28063
  const query = {
27995
28064
  status,
27996
- ...search && { $text: { $search: search } },
27997
- ...siteId && { site: siteId }
28065
+ ...siteId && { site: siteId },
28066
+ ...searchText && {
28067
+ $or: [
28068
+ { $text: { $search: searchText } },
28069
+ ...canSearchBlock ? [{ block: blockSearch }] : []
28070
+ ]
28071
+ }
27998
28072
  };
27999
28073
  sort = Object.keys(sort).length ? sort : { _id: -1 };
28000
28074
  const cacheParams = {
28001
28075
  page,
28002
28076
  limit,
28003
28077
  sort: JSON.stringify(sort),
28004
- ...search && { search },
28078
+ ...searchText && { search: searchText },
28005
28079
  ...site && { site },
28006
28080
  ...status && { status }
28007
28081
  };
@@ -29782,6 +29856,24 @@ function useBuildingUnitController() {
29782
29856
  getAllLevelsWithUnits: _getAllLevelsWithUnits
29783
29857
  } = useBuildingUnitRepo();
29784
29858
  const { add: _add, updateById: _updateById } = useBuildingUnitService();
29859
+ function normalizeQueryString(value) {
29860
+ if (Array.isArray(value)) {
29861
+ for (const item of value) {
29862
+ const normalized = normalizeQueryString(item);
29863
+ if (normalized)
29864
+ return normalized;
29865
+ }
29866
+ return "";
29867
+ }
29868
+ if (value && typeof value === "object") {
29869
+ for (const item of Object.values(value)) {
29870
+ const normalized = normalizeQueryString(item);
29871
+ if (normalized)
29872
+ return normalized;
29873
+ }
29874
+ }
29875
+ return typeof value === "string" ? value : "";
29876
+ }
29785
29877
  async function add(req, res, next) {
29786
29878
  const data = req.body;
29787
29879
  const validation = Joi47.object({
@@ -29855,7 +29947,11 @@ function useBuildingUnitController() {
29855
29947
  sort: Joi47.string().valid(...Object.values(SortFields)).default("_id" /* ID */),
29856
29948
  order: Joi47.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
29857
29949
  });
29858
- const { error, value } = validation.validate(req.query, {
29950
+ const query = {
29951
+ ...req.query,
29952
+ search: normalizeQueryString(req.query.search)
29953
+ };
29954
+ const { error, value } = validation.validate(query, {
29859
29955
  abortEarly: false
29860
29956
  });
29861
29957
  if (error) {
@@ -30016,7 +30112,11 @@ function useBuildingUnitController() {
30016
30112
  order: Joi47.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */),
30017
30113
  level: Joi47.string().hex().length(24).optional().allow(null, "")
30018
30114
  });
30019
- const { error, value } = validation.validate(req.query, {
30115
+ const query = {
30116
+ ...req.query,
30117
+ search: normalizeQueryString(req.query.search)
30118
+ };
30119
+ const { error, value } = validation.validate(query, {
30020
30120
  abortEarly: false
30021
30121
  });
30022
30122
  if (error) {
@@ -45272,6 +45372,31 @@ async function getTransactions(index, url) {
45272
45372
  return Promise.reject(error);
45273
45373
  }
45274
45374
  }
45375
+ function encryptPayload(payloadHex) {
45376
+ const buffer = Buffer.from(payloadHex, "ascii");
45377
+ const encrypted = crypto.publicEncrypt(
45378
+ {
45379
+ key: "testing",
45380
+ padding: crypto.constants.RSA_PKCS1_PADDING
45381
+ },
45382
+ buffer
45383
+ );
45384
+ return encrypted.toString("base64");
45385
+ }
45386
+ function toHex(num, length) {
45387
+ return num.toString(16).padStart(length * 2, "0");
45388
+ }
45389
+ function buildPayload(cardNumber, validityMinutes) {
45390
+ const randomHex = crypto.randomBytes(2).toString("hex");
45391
+ const cardHex = toHex(cardNumber, 4);
45392
+ const epochHex = toHex(Math.floor(Date.now() / 1e3), 4);
45393
+ const validityHex = toHex(validityMinutes, 2);
45394
+ return randomHex + cardHex + epochHex + validityHex;
45395
+ }
45396
+ function generateQrCodeData(cardNumber, validityMinutes) {
45397
+ const payloadHex = buildPayload(cardNumber, validityMinutes);
45398
+ return encryptPayload(payloadHex);
45399
+ }
45275
45400
 
45276
45401
  // src/repositories/access-management.repo.ts
45277
45402
  import { parseStringPromise as parseStringPromise2 } from "xml2js";
@@ -48521,6 +48646,14 @@ function useAccessManagementSvc() {
48521
48646
  throw new Error(err.message);
48522
48647
  }
48523
48648
  };
48649
+ const generateQrCodeWithExpirySvc = async ({ cardNumber, validityMinutes }) => {
48650
+ try {
48651
+ const response = generateQrCodeData(cardNumber, validityMinutes);
48652
+ return response;
48653
+ } catch (error) {
48654
+ throw new Error(error.message);
48655
+ }
48656
+ };
48524
48657
  return {
48525
48658
  addPhysicalCardSvc,
48526
48659
  addNonPhysicalCardSvc,
@@ -48563,7 +48696,8 @@ function useAccessManagementSvc() {
48563
48696
  getResidentsSvc,
48564
48697
  userAccessCardsSvc,
48565
48698
  removeTemplateSvc,
48566
- qrCodeListSvc
48699
+ qrCodeListSvc,
48700
+ generateQrCodeWithExpirySvc
48567
48701
  };
48568
48702
  }
48569
48703
 
@@ -48611,7 +48745,8 @@ function useAccessManagementController() {
48611
48745
  getResidentsSvc,
48612
48746
  userAccessCardsSvc,
48613
48747
  removeTemplateSvc,
48614
- qrCodeListSvc
48748
+ qrCodeListSvc,
48749
+ generateQrCodeWithExpirySvc
48615
48750
  } = useAccessManagementSvc();
48616
48751
  const addPhysicalCard = async (req, res) => {
48617
48752
  try {
@@ -49723,6 +49858,23 @@ function useAccessManagementController() {
49723
49858
  });
49724
49859
  }
49725
49860
  };
49861
+ const generateQrCodeWithExpiry = async (req, res) => {
49862
+ try {
49863
+ const { cardNumber, validityMinutes } = req.body;
49864
+ const result = await generateQrCodeWithExpirySvc({ cardNumber, validityMinutes });
49865
+ return res.status(200).json({
49866
+ message: "successful!",
49867
+ data: {
49868
+ result
49869
+ }
49870
+ });
49871
+ } catch (error) {
49872
+ return res.status(400).json({
49873
+ data: null,
49874
+ message: error.message
49875
+ });
49876
+ }
49877
+ };
49726
49878
  return {
49727
49879
  addPhysicalCard,
49728
49880
  addNonPhysicalCard,
@@ -49763,7 +49915,8 @@ function useAccessManagementController() {
49763
49915
  getResidents,
49764
49916
  userAccessCards,
49765
49917
  removeTemplate,
49766
- qrCodeList
49918
+ qrCodeList,
49919
+ generateQrCodeWithExpiry
49767
49920
  };
49768
49921
  }
49769
49922
 
@@ -57184,14 +57337,14 @@ function useNewDashboardRepo() {
57184
57337
  site: { $in: [siteIdObj, siteId] },
57185
57338
  service: "Security",
57186
57339
  createdAt: periodRange,
57187
- status: { $nin: ["completed"] }
57340
+ status: { $nin: ["Completed", "Deleted"] }
57188
57341
  }
57189
57342
  },
57190
57343
  {
57191
57344
  $facet: {
57192
57345
  total: [{ $count: "count" }],
57193
57346
  inProgress: [
57194
- { $match: { status: "in-progress" } },
57347
+ { $match: { status: "In-Progress" } },
57195
57348
  { $count: "count" }
57196
57349
  ]
57197
57350
  }
@@ -57203,7 +57356,7 @@ function useNewDashboardRepo() {
57203
57356
  site: { $in: [siteIdObj, siteId] },
57204
57357
  service: "Security",
57205
57358
  createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57206
- status: { $nin: ["completed"] }
57359
+ status: { $nin: ["Completed", "Deleted"] }
57207
57360
  }
57208
57361
  },
57209
57362
  { $count: "count" }
@@ -57214,7 +57367,7 @@ function useNewDashboardRepo() {
57214
57367
  site: { $in: [siteIdObj, siteId] },
57215
57368
  service: "Security",
57216
57369
  createdAt: { $gte: today, $lte: todayEnd },
57217
- status: { $nin: ["completed"] }
57370
+ status: { $nin: ["Completed", "Deleted"] }
57218
57371
  }
57219
57372
  },
57220
57373
  { $count: "count" }
@@ -57223,7 +57376,7 @@ function useNewDashboardRepo() {
57223
57376
  {
57224
57377
  $match: {
57225
57378
  site: { $in: [siteIdObj, siteId] },
57226
- status: { $in: ["pending", "Pending"] },
57379
+ status: { $in: ["pending"] },
57227
57380
  createdAt: periodRange
57228
57381
  }
57229
57382
  },
@@ -57233,7 +57386,7 @@ function useNewDashboardRepo() {
57233
57386
  {
57234
57387
  $match: {
57235
57388
  site: { $in: [siteIdObj, siteId] },
57236
- status: { $in: ["pending", "Pending"] },
57389
+ status: { $in: ["pending"] },
57237
57390
  createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57238
57391
  }
57239
57392
  },
@@ -57243,7 +57396,7 @@ function useNewDashboardRepo() {
57243
57396
  {
57244
57397
  $match: {
57245
57398
  site: { $in: [siteIdObj, siteId] },
57246
- status: { $in: ["pending", "Pending"] },
57399
+ status: { $in: ["pending"] },
57247
57400
  createdAt: { $gte: today, $lte: todayEnd }
57248
57401
  }
57249
57402
  },
@@ -57525,11 +57678,11 @@ function useNewDashboardRepo() {
57525
57678
  [
57526
57679
  db.collection(incidents_namespace_collection).find({
57527
57680
  site: { $in: [siteIdObj, siteId] },
57528
- status: { $in: ["pending", "Pending"] }
57681
+ status: { $in: ["pending"] }
57529
57682
  }).sort({ createdAt: -1 }).toArray(),
57530
57683
  db.collection(facility_bookings_namespace_collection2).find({
57531
57684
  site: { $in: [siteIdObj, siteId] },
57532
- status: { $in: ["Pending", "pending", "For Review", "for review"] }
57685
+ status: { $in: ["Pending", "For Review"] }
57533
57686
  }).sort({ createdAt: -1 }).toArray()
57534
57687
  ]
57535
57688
  );
@@ -57538,14 +57691,16 @@ function useNewDashboardRepo() {
57538
57691
  const todayAttentions = [];
57539
57692
  if (pendingIncidentCount > 0) {
57540
57693
  todayAttentions.push({
57541
- id: "incidents-pending",
57694
+ id: pendingIncidentDocs[0]._id.toString(),
57695
+ type: "incident",
57542
57696
  title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"} pending acknowledge`,
57543
57697
  createdAt: pendingIncidentDocs[0].updatedAt || pendingIncidentDocs[0].createdAt || /* @__PURE__ */ new Date()
57544
57698
  });
57545
57699
  }
57546
57700
  if (pendingFacilityBookingCount > 0) {
57547
57701
  todayAttentions.push({
57548
- id: "facility-booking-pending",
57702
+ id: pendingFacilityBookingDocs[0]._id.toString(),
57703
+ type: "facility-booking",
57549
57704
  title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"} need approval`,
57550
57705
  createdAt: pendingFacilityBookingDocs[0].createdAt || /* @__PURE__ */ new Date()
57551
57706
  });
@@ -57600,14 +57755,14 @@ function useNewDashboardRepo() {
57600
57755
  $match: {
57601
57756
  site: { $in: [siteIdObj, siteId] },
57602
57757
  createdAt: periodRange,
57603
- status: { $nin: ["completed"] }
57758
+ status: { $nin: ["Completed", "Deleted"] }
57604
57759
  }
57605
57760
  },
57606
57761
  {
57607
57762
  $facet: {
57608
57763
  total: [{ $count: "count" }],
57609
57764
  inProgress: [
57610
- { $match: { status: "in-progress" } },
57765
+ { $match: { status: "In-Progress" } },
57611
57766
  { $count: "count" }
57612
57767
  ]
57613
57768
  }
@@ -57618,7 +57773,7 @@ function useNewDashboardRepo() {
57618
57773
  $match: {
57619
57774
  site: { $in: [siteIdObj, siteId] },
57620
57775
  createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57621
- status: { $nin: ["completed"] }
57776
+ status: { $nin: ["Completed", "Deleted"] }
57622
57777
  }
57623
57778
  },
57624
57779
  { $count: "count" }
@@ -57628,7 +57783,7 @@ function useNewDashboardRepo() {
57628
57783
  $match: {
57629
57784
  site: { $in: [siteIdObj, siteId] },
57630
57785
  createdAt: { $gte: today, $lte: todayEnd },
57631
- status: { $nin: ["completed"] }
57786
+ status: { $nin: ["Completed", "Deleted"] }
57632
57787
  }
57633
57788
  },
57634
57789
  { $count: "count" }
@@ -57637,7 +57792,7 @@ function useNewDashboardRepo() {
57637
57792
  {
57638
57793
  $match: {
57639
57794
  site: { $in: [siteIdObj, siteId] },
57640
- status: { $in: ["pending", "Pending"] },
57795
+ status: { $in: ["pending"] },
57641
57796
  createdAt: periodRange
57642
57797
  }
57643
57798
  },
@@ -57647,7 +57802,7 @@ function useNewDashboardRepo() {
57647
57802
  {
57648
57803
  $match: {
57649
57804
  site: { $in: [siteIdObj, siteId] },
57650
- status: { $in: ["pending", "Pending"] },
57805
+ status: { $in: ["pending"] },
57651
57806
  createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57652
57807
  }
57653
57808
  },
@@ -57657,7 +57812,7 @@ function useNewDashboardRepo() {
57657
57812
  {
57658
57813
  $match: {
57659
57814
  site: { $in: [siteIdObj, siteId] },
57660
- status: { $in: ["pending", "Pending"] },
57815
+ status: { $in: ["pending"] },
57661
57816
  createdAt: { $gte: today, $lte: todayEnd }
57662
57817
  }
57663
57818
  },
@@ -57907,6 +58062,13 @@ function useNewDashboardRepo() {
57907
58062
  const periodRange = getDateRange(period);
57908
58063
  try {
57909
58064
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
58065
+ const workOrderMatchQuery = {
58066
+ site,
58067
+ status: { $nin: ["Completed", "Deleted"] }
58068
+ };
58069
+ if (serviceType !== "property_management_agency") {
58070
+ workOrderMatchQuery.service = workOrderService;
58071
+ }
57910
58072
  const [
57911
58073
  workOrderReport,
57912
58074
  supplyAlertReport,
@@ -57919,17 +58081,15 @@ function useNewDashboardRepo() {
57919
58081
  workOrderCollection.aggregate([
57920
58082
  {
57921
58083
  $match: {
57922
- site,
57923
- service: workOrderService,
57924
- createdAt: periodRange,
57925
- status: { $nin: ["completed"] }
58084
+ ...workOrderMatchQuery,
58085
+ createdAt: periodRange
57926
58086
  }
57927
58087
  },
57928
58088
  {
57929
58089
  $facet: {
57930
58090
  total: [{ $count: "count" }],
57931
58091
  inProgress: [
57932
- { $match: { status: "in-progress" } },
58092
+ { $match: { status: "In-Progress" } },
57933
58093
  { $count: "count" }
57934
58094
  ]
57935
58095
  }
@@ -57960,10 +58120,8 @@ function useNewDashboardRepo() {
57960
58120
  workOrderCollection.aggregate([
57961
58121
  {
57962
58122
  $match: {
57963
- site,
57964
- service: workOrderService,
57965
- createdAt: { $gte: yesterday, $lte: yesterdayEnd },
57966
- status: { $nin: ["completed"] }
58123
+ ...workOrderMatchQuery,
58124
+ createdAt: { $gte: yesterday, $lte: yesterdayEnd }
57967
58125
  }
57968
58126
  },
57969
58127
  { $count: "count" }
@@ -57971,10 +58129,8 @@ function useNewDashboardRepo() {
57971
58129
  workOrderCollection.aggregate([
57972
58130
  {
57973
58131
  $match: {
57974
- site,
57975
- service: workOrderService,
57976
- createdAt: { $gte: today, $lte: todayEnd },
57977
- status: { $nin: ["completed"] }
58132
+ ...workOrderMatchQuery,
58133
+ createdAt: { $gte: today, $lte: todayEnd }
57978
58134
  }
57979
58135
  },
57980
58136
  { $count: "count" }
@@ -58077,10 +58233,9 @@ function useNewDashboardRepo() {
58077
58233
  throw new BadRequestError182("Invalid period.");
58078
58234
  }
58079
58235
  try {
58080
- const workOrders = await workOrderCollection.find({
58236
+ const workOrderQuery = {
58081
58237
  site,
58082
- service: workOrderService,
58083
- status: { $nin: ["deleted", "Deleted"] },
58238
+ status: { $nin: ["Deleted"] },
58084
58239
  $or: [
58085
58240
  { createdAt: { $gte: rangeStart, $lte: rangeEnd } },
58086
58241
  {
@@ -58090,7 +58245,11 @@ function useNewDashboardRepo() {
58090
58245
  }
58091
58246
  }
58092
58247
  ]
58093
- }).project({ status: 1, createdAt: 1 }).toArray();
58248
+ };
58249
+ if (serviceType !== "property_management_agency") {
58250
+ workOrderQuery.service = workOrderService;
58251
+ }
58252
+ const workOrders = await workOrderCollection.find(workOrderQuery).project({ status: 1, createdAt: 1 }).toArray();
58094
58253
  const chartData = labels.map((label) => ({
58095
58254
  day: label,
58096
58255
  label,
@@ -58187,6 +58346,7 @@ function useNewDashboardRepo() {
58187
58346
  name: 1,
58188
58347
  type: 1,
58189
58348
  status: 1,
58349
+ schedule: 1,
58190
58350
  assigneeName: { $arrayElemAt: ["$_assigneeDoc.name", 0] }
58191
58351
  }
58192
58352
  },
@@ -58351,7 +58511,10 @@ function useNewDashboardRepo() {
58351
58511
  throw new BadRequestError182("Invalid site ID format.");
58352
58512
  }
58353
58513
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
58354
- const matchQuery = { site, service: workOrderService };
58514
+ const matchQuery = { site };
58515
+ if (serviceType !== "property_management_agency") {
58516
+ matchQuery.service = workOrderService;
58517
+ }
58355
58518
  if (period) {
58356
58519
  matchQuery.createdAt = getDateRange(period);
58357
58520
  }
@@ -65677,7 +65840,7 @@ function usePostFavoriteService() {
65677
65840
  });
65678
65841
  }
65679
65842
  await session?.commitTransaction();
65680
- return "Successfully added to favorites.";
65843
+ return "Successfully added to post-preloved.";
65681
65844
  } catch (error) {
65682
65845
  await session?.abortTransaction();
65683
65846
  throw error;
@@ -67089,9 +67252,112 @@ function useChatPrelovedController() {
67089
67252
  return { add, updateById, deleteById };
67090
67253
  }
67091
67254
 
67092
- // src/controllers/channel-preloved.controller.ts
67093
- import { BadRequestError as BadRequestError223, logger as logger193 } from "@7365admin1/node-server-utils";
67255
+ // src/events/chat-preloved.event.ts
67094
67256
  import Joi144 from "joi";
67257
+ import { logger as logger193, useCache as useCache69 } from "@7365admin1/node-server-utils";
67258
+ function parseSid(cookieHeader) {
67259
+ const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
67260
+ return match ? decodeURIComponent(match[1]) : null;
67261
+ }
67262
+ var schemaSendMessage = Joi144.object({
67263
+ receiverId: Joi144.string().hex().length(24).required(),
67264
+ channelId: Joi144.string().hex().length(24).optional().allow("", null),
67265
+ senderId: Joi144.string().hex().length(24).required(),
67266
+ postId: Joi144.string().hex().length(24).optional().allow("", null),
67267
+ message: Joi144.object({
67268
+ text: Joi144.string().required(),
67269
+ date: Joi144.date().optional().allow(null),
67270
+ time: Joi144.string().optional().allow("", null),
67271
+ senderId: Joi144.string().hex().length(24).required()
67272
+ }).required(),
67273
+ readMessage: Joi144.array().items(Joi144.string().hex()).optional().default([]),
67274
+ viewMessage: Joi144.array().items(Joi144.string().hex()).optional().default([]),
67275
+ attachments: Joi144.array().items(Joi144.string().hex()).optional().default([]),
67276
+ reactions: Joi144.string().optional().allow("", null).default(""),
67277
+ bidId: Joi144.string().hex().length(24).optional().allow("", null),
67278
+ edited: Joi144.boolean().optional().default(false)
67279
+ });
67280
+ var schemaTyping = Joi144.object({
67281
+ receiverId: Joi144.string().hex().length(24).required(),
67282
+ fromUserId: Joi144.string().hex().length(24).required(),
67283
+ senderName: Joi144.string().required()
67284
+ });
67285
+ var schemaChatMessageDeleted = Joi144.object({
67286
+ messageId: Joi144.string().hex().length(24).required(),
67287
+ receiverId: Joi144.string().hex().length(24).required()
67288
+ });
67289
+ function chatPrelovedEvents(io) {
67290
+ const namespace = io.of(/^\/chat-channel-[0-9a-fA-F]{24}$/);
67291
+ namespace.use(async (socket, next) => {
67292
+ try {
67293
+ const cookieHeader = socket.handshake.headers.cookie || "";
67294
+ let sid = parseSid(cookieHeader);
67295
+ if (!sid && socket.handshake.auth?.token) {
67296
+ sid = socket.handshake.auth.token;
67297
+ }
67298
+ if (!sid) {
67299
+ return next(new Error("Unauthorized"));
67300
+ }
67301
+ const { getCache } = useCache69("sessions");
67302
+ const sessionData = await getCache(`sid:${sid}`);
67303
+ if (!sessionData) {
67304
+ return next(new Error("Session expired or invalid"));
67305
+ }
67306
+ const session = sessionData;
67307
+ socket.data.userId = (session._id ?? sessionData).toString();
67308
+ next();
67309
+ } catch (error) {
67310
+ logger193.log({ level: "error", message: `Socket auth error: ${error.message}` });
67311
+ next(new Error("Authentication error"));
67312
+ }
67313
+ });
67314
+ namespace.on("connection", (socket) => {
67315
+ const userId = socket.data.userId;
67316
+ socket.join(userId);
67317
+ socket.on("sendMessage", (payload) => {
67318
+ const { error, value } = schemaSendMessage.validate(payload, {
67319
+ abortEarly: false
67320
+ });
67321
+ if (error) {
67322
+ const message = error.details.map((d) => d.message).join(", ");
67323
+ socket.emit("error", { event: "sendMessage", message });
67324
+ return;
67325
+ }
67326
+ namespace.to(value.receiverId).emit("receiveMessage", value);
67327
+ });
67328
+ socket.on("typing", (data) => {
67329
+ const { error, value } = schemaTyping.validate(data, {
67330
+ abortEarly: false
67331
+ });
67332
+ if (error) {
67333
+ const message = error.details.map((d) => d.message).join(", ");
67334
+ socket.emit("error", { event: "typing", message });
67335
+ return;
67336
+ }
67337
+ namespace.to(value.receiverId).emit("TypingNow", value);
67338
+ });
67339
+ socket.on("chatMessageDeleted", (data) => {
67340
+ const { error, value } = schemaChatMessageDeleted.validate(data, {
67341
+ abortEarly: false
67342
+ });
67343
+ if (error) {
67344
+ const message = error.details.map((d) => d.message).join(", ");
67345
+ socket.emit("error", { event: "chatMessageDeleted", message });
67346
+ return;
67347
+ }
67348
+ namespace.to(value.receiverId).emit("chatMessageDeleted", {
67349
+ messageId: value.messageId
67350
+ });
67351
+ });
67352
+ socket.on("disconnect", () => {
67353
+ socket.leave(userId);
67354
+ });
67355
+ });
67356
+ }
67357
+
67358
+ // src/controllers/channel-preloved.controller.ts
67359
+ import { BadRequestError as BadRequestError223, logger as logger194 } from "@7365admin1/node-server-utils";
67360
+ import Joi145 from "joi";
67095
67361
  function useChannelPrelovedController() {
67096
67362
  const {
67097
67363
  add: _add,
@@ -67105,7 +67371,7 @@ function useChannelPrelovedController() {
67105
67371
  });
67106
67372
  if (error) {
67107
67373
  const messages = error.details.map((d) => d.message).join(", ");
67108
- logger193.log({ level: "error", message: messages });
67374
+ logger194.log({ level: "error", message: messages });
67109
67375
  next(new BadRequestError223(messages));
67110
67376
  return;
67111
67377
  }
@@ -67113,31 +67379,31 @@ function useChannelPrelovedController() {
67113
67379
  const data = await _add(value);
67114
67380
  res.status(201).json(data);
67115
67381
  } catch (error2) {
67116
- logger193.log({ level: "error", message: error2.message });
67382
+ logger194.log({ level: "error", message: error2.message });
67117
67383
  next(error2);
67118
67384
  }
67119
67385
  }
67120
67386
  async function getChannelMessages(req, res, next) {
67121
- const paramsSchema = Joi144.object({
67122
- id: Joi144.string().hex().length(24).required()
67387
+ const paramsSchema = Joi145.object({
67388
+ id: Joi145.string().hex().length(24).required()
67123
67389
  });
67124
- const querySchema = Joi144.object({
67125
- page: Joi144.number().integer().min(1).default(1),
67126
- limit: Joi144.number().integer().min(1).max(100).default(10),
67127
- isLoadMore: Joi144.boolean().default(false),
67128
- lastMessageId: Joi144.string().hex().length(24).optional().allow("", null)
67390
+ const querySchema = Joi145.object({
67391
+ page: Joi145.number().integer().min(1).default(1),
67392
+ limit: Joi145.number().integer().min(1).max(100).default(10),
67393
+ isLoadMore: Joi145.boolean().default(false),
67394
+ lastMessageId: Joi145.string().hex().length(24).optional().allow("", null)
67129
67395
  });
67130
67396
  const { error: paramError, value: params } = paramsSchema.validate(
67131
67397
  req.params
67132
67398
  );
67133
67399
  if (paramError) {
67134
- logger193.log({ level: "error", message: paramError.message });
67400
+ logger194.log({ level: "error", message: paramError.message });
67135
67401
  next(new BadRequestError223(paramError.message));
67136
67402
  return;
67137
67403
  }
67138
67404
  const { error: queryError, value: query } = querySchema.validate(req.query);
67139
67405
  if (queryError) {
67140
- logger193.log({ level: "error", message: queryError.message });
67406
+ logger194.log({ level: "error", message: queryError.message });
67141
67407
  next(new BadRequestError223(queryError.message));
67142
67408
  return;
67143
67409
  }
@@ -67151,19 +67417,19 @@ function useChannelPrelovedController() {
67151
67417
  );
67152
67418
  res.status(200).json(data);
67153
67419
  } catch (error) {
67154
- logger193.log({ level: "error", message: error.message });
67420
+ logger194.log({ level: "error", message: error.message });
67155
67421
  next(error);
67156
67422
  }
67157
67423
  }
67158
67424
  async function getChannel(req, res, next) {
67159
- const querySchema = Joi144.object({
67160
- postId: Joi144.string().hex().length(24).required(),
67161
- receiverId: Joi144.string().hex().length(24).required(),
67162
- senderId: Joi144.string().hex().length(24).required()
67425
+ const querySchema = Joi145.object({
67426
+ postId: Joi145.string().hex().length(24).required(),
67427
+ receiverId: Joi145.string().hex().length(24).required(),
67428
+ senderId: Joi145.string().hex().length(24).required()
67163
67429
  });
67164
67430
  const { error, value } = querySchema.validate(req.query);
67165
67431
  if (error) {
67166
- logger193.log({ level: "error", message: error.message });
67432
+ logger194.log({ level: "error", message: error.message });
67167
67433
  next(new BadRequestError223(error.message));
67168
67434
  return;
67169
67435
  }
@@ -67175,20 +67441,20 @@ function useChannelPrelovedController() {
67175
67441
  );
67176
67442
  res.status(200).json(data);
67177
67443
  } catch (error2) {
67178
- logger193.log({ level: "error", message: error2.message });
67444
+ logger194.log({ level: "error", message: error2.message });
67179
67445
  next(error2);
67180
67446
  }
67181
67447
  }
67182
67448
  async function getChatLists(req, res, next) {
67183
- const querySchema = Joi144.object({
67184
- currentUserId: Joi144.string().hex().length(24).required(),
67185
- page: Joi144.number().integer().min(1).default(1),
67186
- limit: Joi144.number().integer().min(1).max(100).default(10),
67187
- search: Joi144.string().optional().allow("", null)
67449
+ const querySchema = Joi145.object({
67450
+ currentUserId: Joi145.string().hex().length(24).required(),
67451
+ page: Joi145.number().integer().min(1).default(1),
67452
+ limit: Joi145.number().integer().min(1).max(100).default(10),
67453
+ search: Joi145.string().optional().allow("", null)
67188
67454
  });
67189
67455
  const { error, value } = querySchema.validate(req.query);
67190
67456
  if (error) {
67191
- logger193.log({ level: "error", message: error.message });
67457
+ logger194.log({ level: "error", message: error.message });
67192
67458
  next(new BadRequestError223(error.message));
67193
67459
  return;
67194
67460
  }
@@ -67201,7 +67467,7 @@ function useChannelPrelovedController() {
67201
67467
  );
67202
67468
  res.status(200).json(data);
67203
67469
  } catch (error2) {
67204
- logger193.log({ level: "error", message: error2.message });
67470
+ logger194.log({ level: "error", message: error2.message });
67205
67471
  next(error2);
67206
67472
  }
67207
67473
  }
@@ -67209,7 +67475,7 @@ function useChannelPrelovedController() {
67209
67475
  }
67210
67476
 
67211
67477
  // src/models/bid-preloved.model.ts
67212
- import Joi145 from "joi";
67478
+ import Joi146 from "joi";
67213
67479
  import { ObjectId as ObjectId149 } from "mongodb";
67214
67480
  var BidType = /* @__PURE__ */ ((BidType2) => {
67215
67481
  BidType2["BID"] = "bid";
@@ -67223,21 +67489,21 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
67223
67489
  BidStatus3["CANCELLED"] = "cancelled";
67224
67490
  return BidStatus3;
67225
67491
  })(BidStatus || {});
67226
- var schemaBidPreloved = Joi145.object({
67227
- type: Joi145.string().valid(...Object.values(BidType)).required(),
67228
- postId: Joi145.string().hex().length(24).required(),
67229
- receiverId: Joi145.string().hex().length(24).required(),
67230
- buyerId: Joi145.string().hex().length(24).required(),
67231
- price: Joi145.when("type", {
67492
+ var schemaBidPreloved = Joi146.object({
67493
+ type: Joi146.string().valid(...Object.values(BidType)).required(),
67494
+ postId: Joi146.string().hex().length(24).required(),
67495
+ receiverId: Joi146.string().hex().length(24).required(),
67496
+ buyerId: Joi146.string().hex().length(24).required(),
67497
+ price: Joi146.when("type", {
67232
67498
  is: "bid" /* BID */,
67233
- then: Joi145.number().required(),
67234
- otherwise: Joi145.number().optional().allow(null)
67499
+ then: Joi146.number().required(),
67500
+ otherwise: Joi146.number().optional().allow(null)
67235
67501
  }),
67236
- message: Joi145.string().optional().allow("", null),
67237
- status: Joi145.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
67502
+ message: Joi146.string().optional().allow("", null),
67503
+ status: Joi146.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
67238
67504
  });
67239
- var schemaUpdateBidPreloved = Joi145.object({
67240
- status: Joi145.string().valid(...Object.values(BidStatus)).required()
67505
+ var schemaUpdateBidPreloved = Joi146.object({
67506
+ status: Joi146.string().valid(...Object.values(BidStatus)).required()
67241
67507
  });
67242
67508
  function MBidPreloved(value) {
67243
67509
  const { error } = schemaBidPreloved.validate(value);
@@ -67305,10 +67571,6 @@ function useBidPrelovedRepo() {
67305
67571
  return { add, getById, updateStatus };
67306
67572
  }
67307
67573
 
67308
- // src/controllers/bid-preloved.controller.ts
67309
- import { BadRequestError as BadRequestError224, logger as logger194 } from "@7365admin1/node-server-utils";
67310
- import Joi146 from "joi";
67311
-
67312
67574
  // src/services/bid-preloved.service.ts
67313
67575
  import { InternalServerError as InternalServerError83, useAtlas as useAtlas128 } from "@7365admin1/node-server-utils";
67314
67576
  function useBidPrelovedService() {
@@ -67373,6 +67635,8 @@ function useBidPrelovedService() {
67373
67635
  }
67374
67636
 
67375
67637
  // src/controllers/bid-preloved.controller.ts
67638
+ import { BadRequestError as BadRequestError224, logger as logger195 } from "@7365admin1/node-server-utils";
67639
+ import Joi147 from "joi";
67376
67640
  function useBidPrelovedController() {
67377
67641
  const { createBid: _createBid } = useBidPrelovedService();
67378
67642
  const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
@@ -67382,7 +67646,7 @@ function useBidPrelovedController() {
67382
67646
  });
67383
67647
  if (error) {
67384
67648
  const messages = error.details.map((d) => d.message).join(", ");
67385
- logger194.log({ level: "error", message: messages });
67649
+ logger195.log({ level: "error", message: messages });
67386
67650
  next(new BadRequestError224(messages));
67387
67651
  return;
67388
67652
  }
@@ -67391,19 +67655,19 @@ function useBidPrelovedController() {
67391
67655
  res.status(201).json(data);
67392
67656
  } catch (error2) {
67393
67657
  console.log("error", error2);
67394
- logger194.log({ level: "error", message: error2.message });
67658
+ logger195.log({ level: "error", message: error2.message });
67395
67659
  next(error2);
67396
67660
  }
67397
67661
  }
67398
67662
  async function updateStatus(req, res, next) {
67399
- const paramsSchema = Joi146.object({
67400
- id: Joi146.string().hex().length(24).required()
67663
+ const paramsSchema = Joi147.object({
67664
+ id: Joi147.string().hex().length(24).required()
67401
67665
  });
67402
67666
  const { error: paramError, value: params } = paramsSchema.validate(
67403
67667
  req.params
67404
67668
  );
67405
67669
  if (paramError) {
67406
- logger194.log({ level: "error", message: paramError.message });
67670
+ logger195.log({ level: "error", message: paramError.message });
67407
67671
  next(new BadRequestError224(paramError.message));
67408
67672
  return;
67409
67673
  }
@@ -67411,7 +67675,7 @@ function useBidPrelovedController() {
67411
67675
  req.body
67412
67676
  );
67413
67677
  if (bodyError) {
67414
- logger194.log({ level: "error", message: bodyError.message });
67678
+ logger195.log({ level: "error", message: bodyError.message });
67415
67679
  next(new BadRequestError224(bodyError.message));
67416
67680
  return;
67417
67681
  }
@@ -67419,17 +67683,17 @@ function useBidPrelovedController() {
67419
67683
  const data = await _updateStatus(params.id, body.status);
67420
67684
  res.status(200).json(data);
67421
67685
  } catch (error) {
67422
- logger194.log({ level: "error", message: error.message });
67686
+ logger195.log({ level: "error", message: error.message });
67423
67687
  next(error);
67424
67688
  }
67425
67689
  }
67426
67690
  async function getById(req, res, next) {
67427
- const paramsSchema = Joi146.object({
67428
- id: Joi146.string().hex().length(24).required()
67691
+ const paramsSchema = Joi147.object({
67692
+ id: Joi147.string().hex().length(24).required()
67429
67693
  });
67430
67694
  const { error, value: params } = paramsSchema.validate(req.params);
67431
67695
  if (error) {
67432
- logger194.log({ level: "error", message: error.message });
67696
+ logger195.log({ level: "error", message: error.message });
67433
67697
  next(new BadRequestError224(error.message));
67434
67698
  return;
67435
67699
  }
@@ -67437,7 +67701,7 @@ function useBidPrelovedController() {
67437
67701
  const data = await _getById(params.id);
67438
67702
  res.status(200).json(data);
67439
67703
  } catch (error2) {
67440
- logger194.log({ level: "error", message: error2.message });
67704
+ logger195.log({ level: "error", message: error2.message });
67441
67705
  next(error2);
67442
67706
  }
67443
67707
  }
@@ -67445,7 +67709,7 @@ function useBidPrelovedController() {
67445
67709
  }
67446
67710
 
67447
67711
  // src/models/online-forms-v2.model.ts
67448
- import Joi147 from "joi";
67712
+ import Joi148 from "joi";
67449
67713
  import { ObjectId as ObjectId151 } from "mongodb";
67450
67714
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
67451
67715
  FormEntryStatus2["ACTIVE"] = "active";
@@ -67453,49 +67717,49 @@ var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
67453
67717
  FormEntryStatus2["DELETED"] = "deleted";
67454
67718
  return FormEntryStatus2;
67455
67719
  })(FormEntryStatus || {});
67456
- var schemaFormEntry = Joi147.object({
67457
- _id: Joi147.string().hex().optional().allow("", null),
67458
- formType: Joi147.string().required(),
67459
- block: Joi147.string().optional().allow(null, ""),
67460
- level: Joi147.string().optional().allow(null, ""),
67461
- unit: Joi147.string().optional().allow(null, ""),
67462
- name: Joi147.string().optional().allow(null, ""),
67463
- phoneNumber: Joi147.string().optional().allow(null, ""),
67464
- createdBy: Joi147.string().required(),
67465
- fields: Joi147.object().pattern(
67466
- Joi147.string(),
67467
- Joi147.alternatives().try(
67468
- Joi147.string(),
67469
- Joi147.number(),
67470
- Joi147.boolean(),
67471
- Joi147.valid(null)
67720
+ var schemaFormEntry = Joi148.object({
67721
+ _id: Joi148.string().hex().optional().allow("", null),
67722
+ formType: Joi148.string().required(),
67723
+ block: Joi148.string().optional().allow(null, ""),
67724
+ level: Joi148.string().optional().allow(null, ""),
67725
+ unit: Joi148.string().optional().allow(null, ""),
67726
+ name: Joi148.string().optional().allow(null, ""),
67727
+ phoneNumber: Joi148.string().optional().allow(null, ""),
67728
+ createdBy: Joi148.string().required(),
67729
+ fields: Joi148.object().pattern(
67730
+ Joi148.string(),
67731
+ Joi148.alternatives().try(
67732
+ Joi148.string(),
67733
+ Joi148.number(),
67734
+ Joi148.boolean(),
67735
+ Joi148.valid(null)
67472
67736
  )
67473
67737
  ).required(),
67474
- status: Joi147.string().optional().allow("", null),
67475
- org: Joi147.string().hex().optional().allow("", null),
67476
- site: Joi147.string().hex().optional().allow("", null),
67477
- createdAt: Joi147.date().optional().allow("", null),
67478
- updatedAt: Joi147.date().optional().allow("", null),
67479
- deletedAt: Joi147.date().optional().allow("", null)
67738
+ status: Joi148.string().optional().allow("", null),
67739
+ org: Joi148.string().hex().optional().allow("", null),
67740
+ site: Joi148.string().hex().optional().allow("", null),
67741
+ createdAt: Joi148.date().optional().allow("", null),
67742
+ updatedAt: Joi148.date().optional().allow("", null),
67743
+ deletedAt: Joi148.date().optional().allow("", null)
67480
67744
  });
67481
- var schemaUpdateFormEntry = Joi147.object({
67482
- _id: Joi147.string().hex().required(),
67483
- formType: Joi147.string().optional().allow("", null),
67484
- block: Joi147.string().optional().allow(null, ""),
67485
- level: Joi147.string().optional().allow(null, ""),
67486
- unit: Joi147.string().optional().allow(null, ""),
67487
- fields: Joi147.object().pattern(
67488
- Joi147.string(),
67489
- Joi147.alternatives().try(
67490
- Joi147.string(),
67491
- Joi147.number(),
67492
- Joi147.boolean(),
67493
- Joi147.valid(null)
67745
+ var schemaUpdateFormEntry = Joi148.object({
67746
+ _id: Joi148.string().hex().required(),
67747
+ formType: Joi148.string().optional().allow("", null),
67748
+ block: Joi148.string().optional().allow(null, ""),
67749
+ level: Joi148.string().optional().allow(null, ""),
67750
+ unit: Joi148.string().optional().allow(null, ""),
67751
+ fields: Joi148.object().pattern(
67752
+ Joi148.string(),
67753
+ Joi148.alternatives().try(
67754
+ Joi148.string(),
67755
+ Joi148.number(),
67756
+ Joi148.boolean(),
67757
+ Joi148.valid(null)
67494
67758
  )
67495
67759
  ).optional(),
67496
- status: Joi147.string().optional().allow("", null),
67497
- updatedAt: Joi147.date().optional().allow("", null),
67498
- deletedAt: Joi147.date().optional().allow("", null)
67760
+ status: Joi148.string().optional().allow("", null),
67761
+ updatedAt: Joi148.date().optional().allow("", null),
67762
+ deletedAt: Joi148.date().optional().allow("", null)
67499
67763
  });
67500
67764
  function MFormEntry(value) {
67501
67765
  const { error } = schemaFormEntry.validate(value);
@@ -67540,34 +67804,34 @@ function MFormEntry(value) {
67540
67804
  deletedAt: value.deletedAt ?? null
67541
67805
  };
67542
67806
  }
67543
- var residentFormEntry = Joi147.object({
67544
- _id: Joi147.string().hex().optional().allow("", null),
67545
- typeOfForm: Joi147.string().optional().allow("", null),
67546
- unitNumber: Joi147.string().optional().allow(null, ""),
67547
- fields: Joi147.object().pattern(
67548
- Joi147.string(),
67549
- Joi147.alternatives().try(
67550
- Joi147.string(),
67551
- Joi147.number(),
67552
- Joi147.boolean(),
67553
- Joi147.valid(null)
67807
+ var residentFormEntry = Joi148.object({
67808
+ _id: Joi148.string().hex().optional().allow("", null),
67809
+ typeOfForm: Joi148.string().optional().allow("", null),
67810
+ unitNumber: Joi148.string().optional().allow(null, ""),
67811
+ fields: Joi148.object().pattern(
67812
+ Joi148.string(),
67813
+ Joi148.alternatives().try(
67814
+ Joi148.string(),
67815
+ Joi148.number(),
67816
+ Joi148.boolean(),
67817
+ Joi148.valid(null)
67554
67818
  )
67555
67819
  ).optional().allow(null, ""),
67556
- status: Joi147.string().optional().allow("", null),
67557
- org: Joi147.string().hex().optional().allow("", null),
67558
- site: Joi147.string().hex().optional().allow("", null),
67559
- userId: Joi147.string().hex().optional().allow("", null),
67560
- createdAt: Joi147.date().optional().allow("", null),
67561
- updatedAt: Joi147.date().optional().allow("", null),
67562
- deletedAt: Joi147.date().optional().allow("", null),
67563
- remarks: Joi147.string().optional().allow("", null),
67564
- managementValues: Joi147.object().pattern(
67565
- Joi147.string(),
67566
- Joi147.alternatives().try(
67567
- Joi147.string(),
67568
- Joi147.number(),
67569
- Joi147.boolean(),
67570
- Joi147.valid(null)
67820
+ status: Joi148.string().optional().allow("", null),
67821
+ org: Joi148.string().hex().optional().allow("", null),
67822
+ site: Joi148.string().hex().optional().allow("", null),
67823
+ userId: Joi148.string().hex().optional().allow("", null),
67824
+ createdAt: Joi148.date().optional().allow("", null),
67825
+ updatedAt: Joi148.date().optional().allow("", null),
67826
+ deletedAt: Joi148.date().optional().allow("", null),
67827
+ remarks: Joi148.string().optional().allow("", null),
67828
+ managementValues: Joi148.object().pattern(
67829
+ Joi148.string(),
67830
+ Joi148.alternatives().try(
67831
+ Joi148.string(),
67832
+ Joi148.number(),
67833
+ Joi148.boolean(),
67834
+ Joi148.valid(null)
67571
67835
  )
67572
67836
  ).optional().allow(null, "")
67573
67837
  });
@@ -67576,12 +67840,12 @@ var residentFormEntry = Joi147.object({
67576
67840
  import {
67577
67841
  BadRequestError as BadRequestError225,
67578
67842
  InternalServerError as InternalServerError84,
67579
- logger as logger195,
67843
+ logger as logger196,
67580
67844
  makeCacheKey as makeCacheKey65,
67581
67845
  NotFoundError as NotFoundError62,
67582
67846
  paginate as paginate64,
67583
67847
  useAtlas as useAtlas129,
67584
- useCache as useCache69
67848
+ useCache as useCache70
67585
67849
  } from "@7365admin1/node-server-utils";
67586
67850
  import { ObjectId as ObjectId152 } from "mongodb";
67587
67851
  var online_forms_namespace_collection = "online-forms";
@@ -67591,7 +67855,7 @@ function useFormEntryRepo() {
67591
67855
  throw new InternalServerError84("Unable to connect to server.");
67592
67856
  }
67593
67857
  const collection = db.collection(online_forms_namespace_collection);
67594
- const { delNamespace, getCache, setCache } = useCache69(
67858
+ const { delNamespace, getCache, setCache } = useCache70(
67595
67859
  online_forms_namespace_collection
67596
67860
  );
67597
67861
  const { getUserById } = useUserRepo();
@@ -67804,7 +68068,7 @@ function useFormEntryRepo() {
67804
68068
  );
67805
68069
  const cachedData = await getCache(cacheKey);
67806
68070
  if (cachedData) {
67807
- logger195.info(`Cache hit for key: ${cacheKey}`);
68071
+ logger196.info(`Cache hit for key: ${cacheKey}`);
67808
68072
  return cachedData;
67809
68073
  }
67810
68074
  try {
@@ -67817,9 +68081,9 @@ function useFormEntryRepo() {
67817
68081
  const length = await collection.countDocuments(query);
67818
68082
  const data = paginate64(items, page, limit, length);
67819
68083
  setCache(cacheKey, data, 15 * 60).then(() => {
67820
- logger195.info(`Cache set for key: ${cacheKey}`);
68084
+ logger196.info(`Cache set for key: ${cacheKey}`);
67821
68085
  }).catch((err) => {
67822
- logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
68086
+ logger196.error(`Failed to set cache for key: ${cacheKey}`, err);
67823
68087
  });
67824
68088
  return data;
67825
68089
  } catch (error) {
@@ -67839,8 +68103,8 @@ function useFormEntryRepo() {
67839
68103
  }
67840
68104
 
67841
68105
  // src/controllers/online-forms-v2.controller.ts
67842
- import { BadRequestError as BadRequestError226, logger as logger196 } from "@7365admin1/node-server-utils";
67843
- import Joi148 from "joi";
68106
+ import { BadRequestError as BadRequestError226, logger as logger197 } from "@7365admin1/node-server-utils";
68107
+ import Joi149 from "joi";
67844
68108
  import ExcelJS3 from "exceljs";
67845
68109
  import fs6 from "fs";
67846
68110
  function useFormEntryController() {
@@ -67901,7 +68165,7 @@ function useFormEntryController() {
67901
68165
  });
67902
68166
  if (error) {
67903
68167
  const messages = error.details.map((d) => d.message).join(", ");
67904
- logger196.log({ level: "error", message: messages });
68168
+ logger197.log({ level: "error", message: messages });
67905
68169
  next(new BadRequestError226(messages));
67906
68170
  return;
67907
68171
  }
@@ -67910,24 +68174,24 @@ function useFormEntryController() {
67910
68174
  fs6.unlink(req.file.path, () => {
67911
68175
  });
67912
68176
  } catch (error) {
67913
- logger196.log({ level: "error", message: error.message });
68177
+ logger197.log({ level: "error", message: error.message });
67914
68178
  next(error);
67915
68179
  }
67916
68180
  }
67917
68181
  async function getAll(req, res, next) {
67918
68182
  try {
67919
- const schema2 = Joi148.object({
67920
- search: Joi148.string().optional().allow("", null),
67921
- page: Joi148.number().integer().min(1).allow("", null).default(1),
67922
- limit: Joi148.number().integer().min(1).max(100).allow("", null).default(10),
67923
- status: Joi148.string().optional().allow(null, ""),
67924
- org: Joi148.string().hex().optional().allow("", null),
67925
- site: Joi148.string().hex().optional().allow("", null)
68183
+ const schema2 = Joi149.object({
68184
+ search: Joi149.string().optional().allow("", null),
68185
+ page: Joi149.number().integer().min(1).allow("", null).default(1),
68186
+ limit: Joi149.number().integer().min(1).max(100).allow("", null).default(10),
68187
+ status: Joi149.string().optional().allow(null, ""),
68188
+ org: Joi149.string().hex().optional().allow("", null),
68189
+ site: Joi149.string().hex().optional().allow("", null)
67926
68190
  });
67927
68191
  const { error, value } = schema2.validate(req.query);
67928
68192
  if (error) {
67929
68193
  const messages = error.details.map((d) => d.message).join(", ");
67930
- logger196.log({ level: "error", message: messages });
68194
+ logger197.log({ level: "error", message: messages });
67931
68195
  next(new BadRequestError226(messages));
67932
68196
  return;
67933
68197
  }
@@ -67936,20 +68200,20 @@ function useFormEntryController() {
67936
68200
  res.json(data);
67937
68201
  return;
67938
68202
  } catch (error) {
67939
- logger196.log({ level: "error", message: error.message });
68203
+ logger197.log({ level: "error", message: error.message });
67940
68204
  next(error);
67941
68205
  return;
67942
68206
  }
67943
68207
  }
67944
68208
  async function getFormEntryById(req, res, next) {
67945
68209
  try {
67946
- const schema2 = Joi148.object({
67947
- _id: Joi148.string().hex().length(24).required()
68210
+ const schema2 = Joi149.object({
68211
+ _id: Joi149.string().hex().length(24).required()
67948
68212
  });
67949
68213
  const { error, value } = schema2.validate({ _id: req.params.id });
67950
68214
  if (error) {
67951
68215
  const messages = error.details.map((d) => d.message).join(", ");
67952
- logger196.log({ level: "error", message: messages });
68216
+ logger197.log({ level: "error", message: messages });
67953
68217
  next(new BadRequestError226(messages));
67954
68218
  return;
67955
68219
  }
@@ -67958,7 +68222,7 @@ function useFormEntryController() {
67958
68222
  res.json(data);
67959
68223
  return;
67960
68224
  } catch (error) {
67961
- logger196.log({ level: "error", message: error.message });
68225
+ logger197.log({ level: "error", message: error.message });
67962
68226
  next(error);
67963
68227
  return;
67964
68228
  }
@@ -67971,7 +68235,7 @@ function useFormEntryController() {
67971
68235
  });
67972
68236
  if (error) {
67973
68237
  const messages = error.details.map((d) => d.message).join(", ");
67974
- logger196.log({ level: "error", message: messages });
68238
+ logger197.log({ level: "error", message: messages });
67975
68239
  next(new BadRequestError226(messages));
67976
68240
  return;
67977
68241
  }
@@ -67980,18 +68244,18 @@ function useFormEntryController() {
67980
68244
  res.json({ message: "Successfully updated online form." });
67981
68245
  return;
67982
68246
  } catch (error) {
67983
- logger196.log({ level: "error", message: error.message });
68247
+ logger197.log({ level: "error", message: error.message });
67984
68248
  next(error);
67985
68249
  return;
67986
68250
  }
67987
68251
  }
67988
68252
  async function deleteFormEntryById(req, res, next) {
67989
68253
  try {
67990
- const validation = Joi148.string().hex().required();
68254
+ const validation = Joi149.string().hex().required();
67991
68255
  const _id = req.params.id;
67992
68256
  const { error } = validation.validate(_id);
67993
68257
  if (error) {
67994
- logger196.log({ level: "error", message: error.message });
68258
+ logger197.log({ level: "error", message: error.message });
67995
68259
  next(new BadRequestError226(error.message));
67996
68260
  return;
67997
68261
  }
@@ -67999,7 +68263,7 @@ function useFormEntryController() {
67999
68263
  res.json({ message: "Successfully deleted online form." });
68000
68264
  return;
68001
68265
  } catch (error) {
68002
- logger196.log({ level: "error", message: error.message });
68266
+ logger197.log({ level: "error", message: error.message });
68003
68267
  next(error);
68004
68268
  return;
68005
68269
  }
@@ -68016,7 +68280,7 @@ function useFormEntryController() {
68016
68280
  });
68017
68281
  if (error) {
68018
68282
  const messages = error.details.map((d) => d.message).join(", ");
68019
- logger196.log({ level: "error", message: messages });
68283
+ logger197.log({ level: "error", message: messages });
68020
68284
  next(new BadRequestError226(messages));
68021
68285
  return;
68022
68286
  }
@@ -68025,7 +68289,7 @@ function useFormEntryController() {
68025
68289
  res.status(201).json({ message: data });
68026
68290
  return;
68027
68291
  } catch (error2) {
68028
- logger196.log({ level: "error", message: error2.message });
68292
+ logger197.log({ level: "error", message: error2.message });
68029
68293
  next(error2);
68030
68294
  return;
68031
68295
  }
@@ -68037,7 +68301,7 @@ function useFormEntryController() {
68037
68301
  });
68038
68302
  if (error) {
68039
68303
  const messages = error.details.map((d) => d.message).join(", ");
68040
- logger196.log({ level: "error", message: messages });
68304
+ logger197.log({ level: "error", message: messages });
68041
68305
  next(new BadRequestError226(messages));
68042
68306
  return;
68043
68307
  }
@@ -68046,27 +68310,27 @@ function useFormEntryController() {
68046
68310
  res.status(201).json({ message: data });
68047
68311
  return;
68048
68312
  } catch (error2) {
68049
- logger196.log({ level: "error", message: error2.message });
68313
+ logger197.log({ level: "error", message: error2.message });
68050
68314
  next(error2);
68051
68315
  return;
68052
68316
  }
68053
68317
  }
68054
68318
  async function residentForm(req, res, next) {
68055
68319
  try {
68056
- const residentFormPayload = Joi148.object({
68057
- org: Joi148.string().hex().required(),
68058
- site: Joi148.string().hex().required(),
68059
- userId: Joi148.string().hex().required(),
68060
- search: Joi148.string().optional().allow("", null),
68061
- page: Joi148.number().integer().min(1).allow("", null).default(1),
68062
- limit: Joi148.number().integer().min(1).max(100).allow("", null).default(10)
68320
+ const residentFormPayload = Joi149.object({
68321
+ org: Joi149.string().hex().required(),
68322
+ site: Joi149.string().hex().required(),
68323
+ userId: Joi149.string().hex().required(),
68324
+ search: Joi149.string().optional().allow("", null),
68325
+ page: Joi149.number().integer().min(1).allow("", null).default(1),
68326
+ limit: Joi149.number().integer().min(1).max(100).allow("", null).default(10)
68063
68327
  });
68064
68328
  const { error, value } = residentFormPayload.validate(req.query, {
68065
68329
  abortEarly: true
68066
68330
  });
68067
68331
  if (error) {
68068
68332
  const messages = error.details.map((d) => d.message).join(", ");
68069
- logger196.log({ level: "error", message: messages });
68333
+ logger197.log({ level: "error", message: messages });
68070
68334
  next(new BadRequestError226(messages));
68071
68335
  return;
68072
68336
  }
@@ -68074,7 +68338,7 @@ function useFormEntryController() {
68074
68338
  const result = await _residentForm({ userId, site, org, search, page, limit });
68075
68339
  res.json(result);
68076
68340
  } catch (error) {
68077
- logger196.log({ level: "error", message: error.message });
68341
+ logger197.log({ level: "error", message: error.message });
68078
68342
  next(error);
68079
68343
  return;
68080
68344
  }
@@ -68130,8 +68394,8 @@ function useBuildingLevelService() {
68130
68394
  }
68131
68395
 
68132
68396
  // src/controllers/building-level.controller.ts
68133
- import { BadRequestError as BadRequestError227, logger as logger197 } from "@7365admin1/node-server-utils";
68134
- import Joi149 from "joi";
68397
+ import { BadRequestError as BadRequestError227, logger as logger198 } from "@7365admin1/node-server-utils";
68398
+ import Joi150 from "joi";
68135
68399
  function useBuildingLevelController() {
68136
68400
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
68137
68401
  const {
@@ -68148,7 +68412,7 @@ function useBuildingLevelController() {
68148
68412
  });
68149
68413
  if (error) {
68150
68414
  const messages = error.details.map((d) => d.message).join(", ");
68151
- logger197.log({ level: "error", message: messages });
68415
+ logger198.log({ level: "error", message: messages });
68152
68416
  next(new BadRequestError227(messages));
68153
68417
  return;
68154
68418
  }
@@ -68160,19 +68424,19 @@ function useBuildingLevelController() {
68160
68424
  }
68161
68425
  async function getAll(req, res, next) {
68162
68426
  try {
68163
- const validation = Joi149.object({
68164
- page: Joi149.number().min(1).optional().default(1),
68165
- limit: Joi149.number().min(1).optional().default(20),
68166
- search: Joi149.string().optional().allow("", null),
68167
- site: Joi149.string().hex().length(24).optional().allow("", null),
68168
- status: Joi149.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
68427
+ const validation = Joi150.object({
68428
+ page: Joi150.number().min(1).optional().default(1),
68429
+ limit: Joi150.number().min(1).optional().default(20),
68430
+ search: Joi150.string().optional().allow("", null),
68431
+ site: Joi150.string().hex().length(24).optional().allow("", null),
68432
+ status: Joi150.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
68169
68433
  });
68170
68434
  const { error, value } = validation.validate(req.query, {
68171
68435
  abortEarly: false
68172
68436
  });
68173
68437
  if (error) {
68174
68438
  const messages = error.details.map((d) => d.message);
68175
- logger197.log({ level: "error", message: messages.join(", ") });
68439
+ logger198.log({ level: "error", message: messages.join(", ") });
68176
68440
  next(new BadRequestError227(messages.join(", ")));
68177
68441
  return;
68178
68442
  }
@@ -68192,13 +68456,13 @@ function useBuildingLevelController() {
68192
68456
  }
68193
68457
  async function getById(req, res, next) {
68194
68458
  try {
68195
- const schema2 = Joi149.object({
68196
- id: Joi149.string().hex().length(24).required()
68459
+ const schema2 = Joi150.object({
68460
+ id: Joi150.string().hex().length(24).required()
68197
68461
  });
68198
68462
  const { error, value } = schema2.validate({ id: req.params.id });
68199
68463
  if (error) {
68200
68464
  const messages = error.details.map((d) => d.message);
68201
- logger197.log({ level: "error", message: messages.join(", ") });
68465
+ logger198.log({ level: "error", message: messages.join(", ") });
68202
68466
  next(new BadRequestError227(messages.join(", ")));
68203
68467
  return;
68204
68468
  }
@@ -68218,7 +68482,7 @@ function useBuildingLevelController() {
68218
68482
  });
68219
68483
  if (error) {
68220
68484
  const messages = error.details.map((d) => d.message);
68221
- logger197.log({ level: "error", message: messages.join(", ") });
68485
+ logger198.log({ level: "error", message: messages.join(", ") });
68222
68486
  next(new BadRequestError227(messages.join(", ")));
68223
68487
  return;
68224
68488
  }
@@ -68231,13 +68495,13 @@ function useBuildingLevelController() {
68231
68495
  }
68232
68496
  async function deleteById(req, res, next) {
68233
68497
  try {
68234
- const schema2 = Joi149.object({
68235
- id: Joi149.string().hex().required()
68498
+ const schema2 = Joi150.object({
68499
+ id: Joi150.string().hex().required()
68236
68500
  });
68237
68501
  const { error, value } = schema2.validate({ id: req.params.id });
68238
68502
  if (error) {
68239
68503
  const messages = error.details.map((d) => d.message);
68240
- logger197.log({ level: "error", message: messages.join(", ") });
68504
+ logger198.log({ level: "error", message: messages.join(", ") });
68241
68505
  next(new BadRequestError227(messages.join(", ")));
68242
68506
  return;
68243
68507
  }
@@ -68251,18 +68515,18 @@ function useBuildingLevelController() {
68251
68515
  }
68252
68516
  async function batchUpdateByIds(req, res, next) {
68253
68517
  try {
68254
- const schema2 = Joi149.array().items(
68255
- Joi149.object({
68256
- _id: Joi149.string().hex().length(24).required(),
68257
- value: Joi149.object({
68258
- name: Joi149.string().optional().allow("", null)
68518
+ const schema2 = Joi150.array().items(
68519
+ Joi150.object({
68520
+ _id: Joi150.string().hex().length(24).required(),
68521
+ value: Joi150.object({
68522
+ name: Joi150.string().optional().allow("", null)
68259
68523
  }).required()
68260
68524
  })
68261
68525
  );
68262
68526
  const { error, value } = schema2.validate(req.body);
68263
68527
  if (error) {
68264
68528
  const messages = error.details.map((d) => d.message);
68265
- logger197.log({ level: "error", message: messages.join(", ") });
68529
+ logger198.log({ level: "error", message: messages.join(", ") });
68266
68530
  next(new BadRequestError227(messages.join(", ")));
68267
68531
  return;
68268
68532
  }
@@ -68278,9 +68542,9 @@ function useBuildingLevelController() {
68278
68542
  }
68279
68543
  async function getBuildingLevelList(req, res, next) {
68280
68544
  try {
68281
- const schema2 = Joi149.object({
68282
- site: Joi149.string().hex().length(24).required(),
68283
- block: Joi149.string().hex().length(24).required()
68545
+ const schema2 = Joi150.object({
68546
+ site: Joi150.string().hex().length(24).required(),
68547
+ block: Joi150.string().hex().length(24).required()
68284
68548
  });
68285
68549
  const { error, value } = schema2.validate({
68286
68550
  site: req.params.siteId,
@@ -68288,7 +68552,7 @@ function useBuildingLevelController() {
68288
68552
  });
68289
68553
  if (error) {
68290
68554
  const messages = error.details.map((d) => d.message).join(", ");
68291
- logger197.log({ level: "error", message: messages });
68555
+ logger198.log({ level: "error", message: messages });
68292
68556
  next(new BadRequestError227(messages));
68293
68557
  return;
68294
68558
  }
@@ -68312,9 +68576,9 @@ function useBuildingLevelController() {
68312
68576
  }
68313
68577
 
68314
68578
  // src/models/hid-amico.model.ts
68315
- import { BadRequestError as BadRequestError228, logger as logger198 } from "@7365admin1/node-server-utils";
68579
+ import { BadRequestError as BadRequestError228, logger as logger199 } from "@7365admin1/node-server-utils";
68316
68580
  import { ObjectId as ObjectId153 } from "mongodb";
68317
- import Joi150 from "joi";
68581
+ import Joi151 from "joi";
68318
68582
  function canReadObjectId(value) {
68319
68583
  if (value instanceof ObjectId153)
68320
68584
  return true;
@@ -68354,159 +68618,159 @@ function toObjectId23(value, label = "ID") {
68354
68618
  }
68355
68619
  throw new BadRequestError228(`Invalid ${label} format`);
68356
68620
  }
68357
- var objectIdSchema2 = Joi150.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
68621
+ var objectIdSchema2 = Joi151.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
68358
68622
  "any.invalid": "{{#label}} must be a valid ObjectId"
68359
68623
  });
68360
- var schemaHidAmicoReader = Joi150.object({
68624
+ var schemaHidAmicoReader = Joi151.object({
68361
68625
  _id: objectIdSchema2.optional(),
68362
68626
  site: objectIdSchema2.required(),
68363
- name: Joi150.string().trim().required(),
68364
- baseUrl: Joi150.string().uri({ scheme: ["http", "https"] }).required(),
68365
- username: Joi150.string().trim().required(),
68366
- password: Joi150.string().required(),
68367
- location: Joi150.string().allow(null, "").optional(),
68368
- deviceId: Joi150.string().allow(null, "").optional(),
68369
- monitorPath: Joi150.string().allow(null, "").optional(),
68370
- enabled: Joi150.boolean().optional(),
68371
- status: Joi150.string().valid("active", "inactive", "deleted", "offline").optional(),
68372
- lastSeenAt: Joi150.date().optional(),
68373
- lastSyncAt: Joi150.date().optional(),
68374
- lastSyncStatus: Joi150.string().valid("idle", "running", "completed", "failed").optional(),
68375
- lastSyncMessage: Joi150.string().allow(null, "").optional(),
68376
- createdAt: Joi150.date().optional(),
68377
- updatedAt: Joi150.date().optional(),
68378
- deletedAt: Joi150.date().optional()
68627
+ name: Joi151.string().trim().required(),
68628
+ baseUrl: Joi151.string().uri({ scheme: ["http", "https"] }).required(),
68629
+ username: Joi151.string().trim().required(),
68630
+ password: Joi151.string().required(),
68631
+ location: Joi151.string().allow(null, "").optional(),
68632
+ deviceId: Joi151.string().allow(null, "").optional(),
68633
+ monitorPath: Joi151.string().allow(null, "").optional(),
68634
+ enabled: Joi151.boolean().optional(),
68635
+ status: Joi151.string().valid("active", "inactive", "deleted", "offline").optional(),
68636
+ lastSeenAt: Joi151.date().optional(),
68637
+ lastSyncAt: Joi151.date().optional(),
68638
+ lastSyncStatus: Joi151.string().valid("idle", "running", "completed", "failed").optional(),
68639
+ lastSyncMessage: Joi151.string().allow(null, "").optional(),
68640
+ createdAt: Joi151.date().optional(),
68641
+ updatedAt: Joi151.date().optional(),
68642
+ deletedAt: Joi151.date().optional()
68379
68643
  });
68380
- var schemaUpdateHidAmicoReader = Joi150.object({
68644
+ var schemaUpdateHidAmicoReader = Joi151.object({
68381
68645
  site: objectIdSchema2.optional(),
68382
- name: Joi150.string().trim().optional(),
68383
- baseUrl: Joi150.string().uri({ scheme: ["http", "https"] }).optional(),
68384
- username: Joi150.string().trim().optional(),
68385
- password: Joi150.string().allow(null, "").optional(),
68386
- location: Joi150.string().allow(null, "").optional(),
68387
- deviceId: Joi150.string().allow(null, "").optional(),
68388
- monitorPath: Joi150.string().allow(null, "").optional(),
68389
- enabled: Joi150.boolean().optional(),
68390
- status: Joi150.string().valid("active", "inactive", "deleted", "offline").optional(),
68391
- lastSeenAt: Joi150.date().optional(),
68392
- lastSyncAt: Joi150.date().optional(),
68393
- lastSyncStatus: Joi150.string().valid("idle", "running", "completed", "failed").optional(),
68394
- lastSyncMessage: Joi150.string().allow(null, "").optional(),
68395
- deletedAt: Joi150.date().optional()
68646
+ name: Joi151.string().trim().optional(),
68647
+ baseUrl: Joi151.string().uri({ scheme: ["http", "https"] }).optional(),
68648
+ username: Joi151.string().trim().optional(),
68649
+ password: Joi151.string().allow(null, "").optional(),
68650
+ location: Joi151.string().allow(null, "").optional(),
68651
+ deviceId: Joi151.string().allow(null, "").optional(),
68652
+ monitorPath: Joi151.string().allow(null, "").optional(),
68653
+ enabled: Joi151.boolean().optional(),
68654
+ status: Joi151.string().valid("active", "inactive", "deleted", "offline").optional(),
68655
+ lastSeenAt: Joi151.date().optional(),
68656
+ lastSyncAt: Joi151.date().optional(),
68657
+ lastSyncStatus: Joi151.string().valid("idle", "running", "completed", "failed").optional(),
68658
+ lastSyncMessage: Joi151.string().allow(null, "").optional(),
68659
+ deletedAt: Joi151.date().optional()
68396
68660
  });
68397
- var schemaHidAmicoEvent = Joi150.object({
68661
+ var schemaHidAmicoEvent = Joi151.object({
68398
68662
  _id: objectIdSchema2.optional(),
68399
68663
  reader: objectIdSchema2.required(),
68400
68664
  site: objectIdSchema2.optional(),
68401
- type: Joi150.string().required(),
68402
- payload: Joi150.object().unknown(true).required(),
68403
- status: Joi150.string().valid("received", "processed", "failed").optional(),
68404
- createdAt: Joi150.date().optional()
68665
+ type: Joi151.string().required(),
68666
+ payload: Joi151.object().unknown(true).required(),
68667
+ status: Joi151.string().valid("received", "processed", "failed").optional(),
68668
+ createdAt: Joi151.date().optional()
68405
68669
  });
68406
- var schemaHidAmicoIdentity = Joi150.object({
68670
+ var schemaHidAmicoIdentity = Joi151.object({
68407
68671
  _id: objectIdSchema2.optional(),
68408
68672
  reader: objectIdSchema2.required(),
68409
68673
  site: objectIdSchema2.required(),
68410
- hidUserId: Joi150.alternatives(Joi150.string(), Joi150.number()).optional().allow(null, ""),
68411
- registration: Joi150.string().optional().allow(null, ""),
68412
- cardNo: Joi150.string().optional().allow(null, ""),
68674
+ hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
68675
+ registration: Joi151.string().optional().allow(null, ""),
68676
+ cardNo: Joi151.string().optional().allow(null, ""),
68413
68677
  person: objectIdSchema2.optional().allow(null, ""),
68414
68678
  user: objectIdSchema2.optional().allow(null, ""),
68415
68679
  member: objectIdSchema2.optional().allow(null, ""),
68416
68680
  visitor: objectIdSchema2.optional().allow(null, ""),
68417
- type: Joi150.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68418
- status: Joi150.string().valid("active", "inactive", "deleted").optional(),
68419
- metadata: Joi150.object().unknown(true).optional(),
68420
- createdAt: Joi150.date().optional(),
68421
- updatedAt: Joi150.date().optional(),
68422
- deletedAt: Joi150.date().optional()
68681
+ type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68682
+ status: Joi151.string().valid("active", "inactive", "deleted").optional(),
68683
+ metadata: Joi151.object().unknown(true).optional(),
68684
+ createdAt: Joi151.date().optional(),
68685
+ updatedAt: Joi151.date().optional(),
68686
+ deletedAt: Joi151.date().optional()
68423
68687
  }).or("hidUserId", "registration", "cardNo");
68424
- var schemaCreateHidAmicoIdentity = Joi150.object({
68688
+ var schemaCreateHidAmicoIdentity = Joi151.object({
68425
68689
  site: objectIdSchema2.optional(),
68426
- hidUserId: Joi150.alternatives(Joi150.string(), Joi150.number()).optional().allow(null, ""),
68427
- registration: Joi150.string().optional().allow(null, ""),
68428
- cardNo: Joi150.string().optional().allow(null, ""),
68690
+ hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
68691
+ registration: Joi151.string().optional().allow(null, ""),
68692
+ cardNo: Joi151.string().optional().allow(null, ""),
68429
68693
  person: objectIdSchema2.optional().allow(null, ""),
68430
68694
  user: objectIdSchema2.optional().allow(null, ""),
68431
68695
  member: objectIdSchema2.optional().allow(null, ""),
68432
68696
  visitor: objectIdSchema2.optional().allow(null, ""),
68433
- type: Joi150.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68434
- status: Joi150.string().valid("active", "inactive", "deleted").optional(),
68435
- metadata: Joi150.object().unknown(true).optional()
68697
+ type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
68698
+ status: Joi151.string().valid("active", "inactive", "deleted").optional(),
68699
+ metadata: Joi151.object().unknown(true).optional()
68436
68700
  }).or("hidUserId", "registration", "cardNo");
68437
- var schemaUpdateHidAmicoIdentity = Joi150.object({
68438
- hidUserId: Joi150.alternatives(Joi150.string(), Joi150.number()).optional().allow(null, ""),
68439
- registration: Joi150.string().optional().allow(null, ""),
68440
- cardNo: Joi150.string().optional().allow(null, ""),
68701
+ var schemaUpdateHidAmicoIdentity = Joi151.object({
68702
+ hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
68703
+ registration: Joi151.string().optional().allow(null, ""),
68704
+ cardNo: Joi151.string().optional().allow(null, ""),
68441
68705
  person: objectIdSchema2.optional().allow(null, ""),
68442
68706
  user: objectIdSchema2.optional().allow(null, ""),
68443
68707
  member: objectIdSchema2.optional().allow(null, ""),
68444
68708
  visitor: objectIdSchema2.optional().allow(null, ""),
68445
- type: Joi150.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68446
- status: Joi150.string().valid("active", "inactive", "deleted").optional(),
68447
- metadata: Joi150.object().unknown(true).optional(),
68448
- deletedAt: Joi150.date().optional()
68709
+ type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68710
+ status: Joi151.string().valid("active", "inactive", "deleted").optional(),
68711
+ metadata: Joi151.object().unknown(true).optional(),
68712
+ deletedAt: Joi151.date().optional()
68449
68713
  });
68450
- var schemaHidAmicoReaderIdParams = Joi150.object({
68451
- readerId: Joi150.string().hex().length(24).required()
68714
+ var schemaHidAmicoReaderIdParams = Joi151.object({
68715
+ readerId: Joi151.string().hex().length(24).required()
68452
68716
  });
68453
- var schemaHidAmicoUserImageParams = Joi150.object({
68454
- readerId: Joi150.string().hex().length(24).required(),
68455
- hidUserId: Joi150.alternatives().try(Joi150.string(), Joi150.number()).required()
68717
+ var schemaHidAmicoUserImageParams = Joi151.object({
68718
+ readerId: Joi151.string().hex().length(24).required(),
68719
+ hidUserId: Joi151.alternatives().try(Joi151.string(), Joi151.number()).required()
68456
68720
  });
68457
- var schemaHidAmicoIdentityIdParams = Joi150.object({
68458
- identityId: Joi150.string().hex().length(24).required()
68721
+ var schemaHidAmicoIdentityIdParams = Joi151.object({
68722
+ identityId: Joi151.string().hex().length(24).required()
68459
68723
  });
68460
- var schemaHidAmicoReaderListQuery = Joi150.object({
68461
- site: Joi150.string().hex().length(24).optional(),
68462
- page: Joi150.number().min(1).optional(),
68463
- limit: Joi150.number().min(1).optional()
68724
+ var schemaHidAmicoReaderListQuery = Joi151.object({
68725
+ site: Joi151.string().hex().length(24).optional(),
68726
+ page: Joi151.number().min(1).optional(),
68727
+ limit: Joi151.number().min(1).optional()
68464
68728
  });
68465
- var schemaHidAmicoLogQuery = Joi150.object({
68466
- page: Joi150.number().min(1).optional(),
68467
- limit: Joi150.number().min(1).optional(),
68468
- type: Joi150.string().optional()
68729
+ var schemaHidAmicoLogQuery = Joi151.object({
68730
+ page: Joi151.number().min(1).optional(),
68731
+ limit: Joi151.number().min(1).optional(),
68732
+ type: Joi151.string().optional()
68469
68733
  });
68470
- var schemaHidAmicoIdentityQuery = Joi150.object({
68471
- page: Joi150.number().min(1).optional(),
68472
- limit: Joi150.number().min(1).optional(),
68473
- type: Joi150.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68474
- status: Joi150.string().valid("active", "inactive", "deleted").optional(),
68475
- search: Joi150.string().allow("").optional()
68734
+ var schemaHidAmicoIdentityQuery = Joi151.object({
68735
+ page: Joi151.number().min(1).optional(),
68736
+ limit: Joi151.number().min(1).optional(),
68737
+ type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
68738
+ status: Joi151.string().valid("active", "inactive", "deleted").optional(),
68739
+ search: Joi151.string().allow("").optional()
68476
68740
  });
68477
- var schemaHidAmicoSync = Joi150.object({
68478
- objects: Joi150.array().items(
68479
- Joi150.object({
68480
- object: Joi150.string().required(),
68481
- values: Joi150.array().items(Joi150.object().unknown(true)).required()
68741
+ var schemaHidAmicoSync = Joi151.object({
68742
+ objects: Joi151.array().items(
68743
+ Joi151.object({
68744
+ object: Joi151.string().required(),
68745
+ values: Joi151.array().items(Joi151.object().unknown(true)).required()
68482
68746
  }).unknown(true)
68483
68747
  ).optional(),
68484
- users: Joi150.array().items(Joi150.object().unknown(true)).optional(),
68485
- cards: Joi150.array().items(Joi150.object().unknown(true)).optional(),
68486
- qrcodes: Joi150.array().items(Joi150.object().unknown(true)).optional(),
68487
- pins: Joi150.array().items(Joi150.object().unknown(true)).optional()
68748
+ users: Joi151.array().items(Joi151.object().unknown(true)).optional(),
68749
+ cards: Joi151.array().items(Joi151.object().unknown(true)).optional(),
68750
+ qrcodes: Joi151.array().items(Joi151.object().unknown(true)).optional(),
68751
+ pins: Joi151.array().items(Joi151.object().unknown(true)).optional()
68488
68752
  }).unknown(true);
68489
- var schemaHidAmicoExecuteActions = Joi150.object({
68490
- actions: Joi150.array().items(Joi150.object().unknown(true)).min(1).required()
68753
+ var schemaHidAmicoExecuteActions = Joi151.object({
68754
+ actions: Joi151.array().items(Joi151.object().unknown(true)).min(1).required()
68491
68755
  }).unknown(true);
68492
- var schemaHidAmicoConfiguration = Joi150.object().pattern(Joi150.string(), Joi150.array().items(Joi150.string())).min(1).unknown(true);
68493
- var schemaHidAmicoSetConfiguration = Joi150.object().unknown(true);
68494
- var schemaHidAmicoObjectOperation = Joi150.object({
68495
- operation: Joi150.string().valid("load", "create", "modify", "destroy").required(),
68496
- object: Joi150.string().required(),
68497
- values: Joi150.alternatives().try(
68498
- Joi150.array().items(Joi150.object().unknown(true)),
68499
- Joi150.object().unknown(true)
68756
+ var schemaHidAmicoConfiguration = Joi151.object().pattern(Joi151.string(), Joi151.array().items(Joi151.string())).min(1).unknown(true);
68757
+ var schemaHidAmicoSetConfiguration = Joi151.object().unknown(true);
68758
+ var schemaHidAmicoObjectOperation = Joi151.object({
68759
+ operation: Joi151.string().valid("load", "create", "modify", "destroy").required(),
68760
+ object: Joi151.string().required(),
68761
+ values: Joi151.alternatives().try(
68762
+ Joi151.array().items(Joi151.object().unknown(true)),
68763
+ Joi151.object().unknown(true)
68500
68764
  ).optional(),
68501
- where: Joi150.object().unknown(true).optional(),
68502
- fields: Joi150.array().items(Joi150.string()).optional(),
68503
- order: Joi150.array().items(Joi150.string()).optional(),
68504
- limit: Joi150.number().integer().min(1).optional(),
68505
- offset: Joi150.number().integer().min(0).optional()
68765
+ where: Joi151.object().unknown(true).optional(),
68766
+ fields: Joi151.array().items(Joi151.string()).optional(),
68767
+ order: Joi151.array().items(Joi151.string()).optional(),
68768
+ limit: Joi151.number().integer().min(1).optional(),
68769
+ offset: Joi151.number().integer().min(0).optional()
68506
68770
  }).unknown(true);
68507
- var schemaHidAmicoNotificationParams = Joi150.object({
68508
- readerId: Joi150.string().hex().length(24).required(),
68509
- type: Joi150.string().valid(
68771
+ var schemaHidAmicoNotificationParams = Joi151.object({
68772
+ readerId: Joi151.string().hex().length(24).required(),
68773
+ type: Joi151.string().valid(
68510
68774
  "dao",
68511
68775
  "template",
68512
68776
  "user_image",
@@ -68524,7 +68788,7 @@ var schemaHidAmicoNotificationParams = Joi150.object({
68524
68788
  function MHidAmicoReader(value) {
68525
68789
  const { error } = schemaHidAmicoReader.validate(value);
68526
68790
  if (error) {
68527
- logger198.info(`HID Amico reader: ${error.message}`);
68791
+ logger199.info(`HID Amico reader: ${error.message}`);
68528
68792
  throw new BadRequestError228(error.message);
68529
68793
  }
68530
68794
  return {
@@ -68551,7 +68815,7 @@ function MHidAmicoReader(value) {
68551
68815
  function MHidAmicoEvent(value) {
68552
68816
  const { error } = schemaHidAmicoEvent.validate(value);
68553
68817
  if (error) {
68554
- logger198.info(`HID Amico event: ${error.message}`);
68818
+ logger199.info(`HID Amico event: ${error.message}`);
68555
68819
  throw new BadRequestError228(error.message);
68556
68820
  }
68557
68821
  return {
@@ -68570,7 +68834,7 @@ function optionalObjectId(value) {
68570
68834
  function MHidAmicoIdentity(value) {
68571
68835
  const { error } = schemaHidAmicoIdentity.validate(value);
68572
68836
  if (error) {
68573
- logger198.info(`HID Amico identity: ${error.message}`);
68837
+ logger199.info(`HID Amico identity: ${error.message}`);
68574
68838
  throw new BadRequestError228(error.message);
68575
68839
  }
68576
68840
  return {
@@ -68597,7 +68861,7 @@ function MHidAmicoIdentity(value) {
68597
68861
  import {
68598
68862
  BadRequestError as BadRequestError229,
68599
68863
  InternalServerError as InternalServerError85,
68600
- logger as logger199,
68864
+ logger as logger200,
68601
68865
  paginate as paginate65,
68602
68866
  useAtlas as useAtlas131
68603
68867
  } from "@7365admin1/node-server-utils";
@@ -68674,7 +68938,7 @@ function useHidAmicoRepo() {
68674
68938
  ]);
68675
68939
  return "HID Amico indexes created.";
68676
68940
  } catch (error) {
68677
- logger199.error(error.message);
68941
+ logger200.error(error.message);
68678
68942
  throw new Error("Failed to create HID Amico indexes.");
68679
68943
  }
68680
68944
  }
@@ -69809,6 +70073,7 @@ export {
69809
70073
  building_units_namespace_collection,
69810
70074
  buildings_namespace_collection,
69811
70075
  bulletin_boards_namespace_collection,
70076
+ chatPrelovedEvents,
69812
70077
  chatSchema,
69813
70078
  createManpowerRemarksDaily,
69814
70079
  customerSchema,
@@ -69964,6 +70229,7 @@ export {
69964
70229
  useAuthServiceV2,
69965
70230
  useBidPrelovedController,
69966
70231
  useBidPrelovedRepo,
70232
+ useBidPrelovedService,
69967
70233
  useBuildingController,
69968
70234
  useBuildingLevelController,
69969
70235
  useBuildingLevelRepo,