@7365admin1/core 2.41.0 → 2.43.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
@@ -423,7 +423,6 @@ function useFeedbackRepo() {
423
423
  cacheOptions.from = from;
424
424
  cacheOptions.to = to;
425
425
  }
426
- console.log("query", JSON.stringify(query));
427
426
  const cacheKey = makeCacheKey2(feedbacks_namespace_collection, cacheOptions);
428
427
  const cachedData = await getCache(cacheKey);
429
428
  if (cachedData) {
@@ -1892,7 +1891,6 @@ function useOccurrenceEntryRepo() {
1892
1891
  throw new Error("Invalid incident report ID.");
1893
1892
  }
1894
1893
  }
1895
- console.log("Updating occurrence entry:", _id, value);
1896
1894
  try {
1897
1895
  const res = await collection.updateOne(
1898
1896
  { _id },
@@ -4815,7 +4813,10 @@ function useSiteRepo() {
4815
4813
  throw error;
4816
4814
  }
4817
4815
  }
4818
- async function siteInformation({ id, payload }) {
4816
+ async function siteInformation({
4817
+ id,
4818
+ payload
4819
+ }) {
4819
4820
  try {
4820
4821
  const siteId = new ObjectId17(id);
4821
4822
  const res = await collection.updateOne(
@@ -4835,6 +4836,48 @@ function useSiteRepo() {
4835
4836
  throw error;
4836
4837
  }
4837
4838
  }
4839
+ async function getAllSitesForResidentCreation({
4840
+ search = "",
4841
+ page = 1,
4842
+ limit = 10
4843
+ }) {
4844
+ page = page > 0 ? page - 1 : 0;
4845
+ const query = {
4846
+ status: { $ne: "deleted" }
4847
+ };
4848
+ const cacheOptions = {
4849
+ status: { $ne: "deleted" },
4850
+ page,
4851
+ limit
4852
+ };
4853
+ if (search) {
4854
+ query.$or = [{ name: { $regex: search, $options: "i" } }];
4855
+ cacheOptions.search = search;
4856
+ }
4857
+ const cacheKey = makeCacheKey9(namespace_collection, cacheOptions);
4858
+ const cachedData = await getCache(cacheKey);
4859
+ if (cachedData) {
4860
+ logger12.info(`Cache hit for key: ${cacheKey}`);
4861
+ return cachedData;
4862
+ }
4863
+ try {
4864
+ const items = await collection.aggregate([
4865
+ { $match: query },
4866
+ { $skip: page * limit },
4867
+ { $limit: limit }
4868
+ ]).toArray();
4869
+ const length = await collection.countDocuments(query);
4870
+ const data = paginate8(items, page, limit, length);
4871
+ setCache(cacheKey, data, 15 * 60).then(() => {
4872
+ logger12.info(`Cache set for key: ${cacheKey}`);
4873
+ }).catch((err) => {
4874
+ logger12.error(`Failed to set cache for key: ${cacheKey}`, err);
4875
+ });
4876
+ return data;
4877
+ } catch (error) {
4878
+ throw error;
4879
+ }
4880
+ }
4838
4881
  return {
4839
4882
  createIndexes,
4840
4883
  createSite,
@@ -4849,7 +4892,8 @@ function useSiteRepo() {
4849
4892
  updateSiteIncidentCounter,
4850
4893
  updateSiteById,
4851
4894
  getAllSitesUnpaginated,
4852
- siteInformation
4895
+ siteInformation,
4896
+ getAllSitesForResidentCreation
4853
4897
  };
4854
4898
  }
4855
4899
 
@@ -10332,7 +10376,6 @@ function useSubscriptionService() {
10332
10376
  subscription.nextBillingDate,
10333
10377
  "pending"
10334
10378
  );
10335
- console.log("dueInvoice", dueInvoice);
10336
10379
  if (value.promoCode) {
10337
10380
  const promoCode = await getByCode(value.promoCode);
10338
10381
  if (!promoCode) {
@@ -11361,11 +11404,8 @@ function useFeedbackController() {
11361
11404
  (acc, [key, value]) => ({ ...acc, [key]: value }),
11362
11405
  {}
11363
11406
  );
11364
- console.log("cookies", cookies);
11365
11407
  const createdBy = cookies?.["user"].toString() ?? "";
11366
- console.log("createdBy", createdBy);
11367
11408
  const payload = { ...req.body, createdBy };
11368
- console.log("payload", payload);
11369
11409
  const { error } = feedbackSchema.validate(payload);
11370
11410
  if (error) {
11371
11411
  logger40.log({ level: "error", message: error.message });
@@ -12069,7 +12109,7 @@ function useServiceProviderController() {
12069
12109
  const validation = Joi30.object({
12070
12110
  search: Joi30.string().optional().allow("", null),
12071
12111
  page: Joi30.number().integer().min(1).allow("", null).default(1),
12072
- limit: Joi30.number().integer().min(1).max(100).allow("", null).default(10),
12112
+ limit: Joi30.number().integer().min(1).max(1e3).allow("", null).default(10),
12073
12113
  orgId: Joi30.string().hex().optional().allow("", null),
12074
12114
  siteId: Joi30.string().hex().optional().allow("", null),
12075
12115
  serviceProviderOrgId: Joi30.string().hex().optional().allow("", null),
@@ -13301,7 +13341,9 @@ var schemaPerson = Joi35.object({
13301
13341
  plates: Joi35.array().items(schemaPlate).optional().allow(null),
13302
13342
  isOwner: Joi35.boolean().required(),
13303
13343
  files: Joi35.array().items(schemaFiles).optional().allow(null),
13304
- password: Joi35.string().optional().allow(null, "")
13344
+ password: Joi35.string().optional().allow(null, ""),
13345
+ plateNumber: Joi35.string().optional().allow(null, ""),
13346
+ platform: Joi35.string().valid("web", "mobile").optional().allow(null, "")
13305
13347
  });
13306
13348
  var schemaUpdatePerson = Joi35.object({
13307
13349
  _id: Joi35.string().hex().required(),
@@ -13321,12 +13363,14 @@ var schemaUpdatePerson = Joi35.object({
13321
13363
  plates: Joi35.array().items(schemaFiles).optional().allow(null, ""),
13322
13364
  isOwner: Joi35.boolean().optional().allow(null, ""),
13323
13365
  files: Joi35.array().items(schemaFiles).optional().allow(null),
13324
- password: Joi35.string().optional().allow(null, "")
13366
+ password: Joi35.string().optional().allow(null, ""),
13367
+ plateNumber: Joi35.string().optional().allow(null, ""),
13368
+ platform: Joi35.string().valid("web", "mobile").optional().allow(null, "")
13325
13369
  });
13326
13370
  function MPerson(value) {
13327
13371
  const { error } = schemaPerson.validate(value);
13328
13372
  if (error) {
13329
- throw new Error(error.details[0].message);
13373
+ throw new BadRequestError66(error.details[0].message);
13330
13374
  }
13331
13375
  if (value._id && typeof value._id === "string") {
13332
13376
  try {
@@ -13391,6 +13435,8 @@ function MPerson(value) {
13391
13435
  plates: value.plates ?? [],
13392
13436
  isOwner: value.isOwner ?? false,
13393
13437
  files: value.files ?? [],
13438
+ plateNumber: value.plateNumber ?? "",
13439
+ platForm: value.platform ?? "",
13394
13440
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
13395
13441
  updatedAt: value.updatedAt,
13396
13442
  deletedAt: value.deletedAt
@@ -13429,8 +13475,8 @@ var schemaVisitorTransaction = Joi36.object({
13429
13475
  contact: Joi36.string().optional().allow(null, ""),
13430
13476
  plateNumber: Joi36.string().optional().allow(null, ""),
13431
13477
  recNo: Joi36.string().optional().allow(null, ""),
13432
- checkIn: Joi36.date().optional().allow(null, ""),
13433
- checkOut: Joi36.date().optional().allow(null, ""),
13478
+ checkIn: Joi36.date().iso().optional().allow(null),
13479
+ checkOut: Joi36.date().iso().optional().allow(null),
13434
13480
  deliveryType: Joi36.string().optional().allow(null, ""),
13435
13481
  status: Joi36.string().optional().valid(...Object.values(VisitorStatus)).default("registered" /* REGISTERED */),
13436
13482
  remarks: Joi36.string().optional().allow(null, ""),
@@ -13494,8 +13540,8 @@ var schemaUpdateVisTrans = Joi36.object({
13494
13540
  contact: Joi36.string().optional().allow(null, ""),
13495
13541
  plateNumber: Joi36.string().optional().allow(null, ""),
13496
13542
  recNo: Joi36.string().optional().allow(null, ""),
13497
- checkIn: Joi36.date().optional().allow(null, ""),
13498
- checkOut: Joi36.date().optional().allow(null, ""),
13543
+ checkIn: Joi36.date().iso().optional().allow(null),
13544
+ checkOut: Joi36.date().iso().optional().allow(null),
13499
13545
  deliveryType: Joi36.string().optional().allow(null, ""),
13500
13546
  status: Joi36.string().optional().allow(null, ""),
13501
13547
  remarks: Joi36.string().optional().allow(null, ""),
@@ -13724,7 +13770,6 @@ function useVisitorTransactionRepo() {
13724
13770
  ...status && { status },
13725
13771
  ...tab == "Overnight Parking" && { isOvernightParking: true }
13726
13772
  };
13727
- console.log(query);
13728
13773
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
13729
13774
  try {
13730
13775
  const basePipeline = [{ $match: query }];
@@ -14197,8 +14242,8 @@ function MVehicle(value) {
14197
14242
  const createdAtDate = value.createdAt ? new Date(value.createdAt) : /* @__PURE__ */ new Date();
14198
14243
  const expiredDate = new Date(createdAtDate);
14199
14244
  expiredDate.setFullYear(expiredDate.getFullYear() + 10);
14200
- const createdAt = createdAtDate.toISOString();
14201
- const expiredAt = value.end ?? expiredDate.toISOString();
14245
+ const createdAt = createdAtDate;
14246
+ const expiredAt = value.end ?? expiredDate;
14202
14247
  return {
14203
14248
  plateNumber: value.plateNumber ?? "",
14204
14249
  type: value.type ?? "",
@@ -14214,8 +14259,8 @@ function MVehicle(value) {
14214
14259
  nric: value.nric ?? "",
14215
14260
  remarks: value.remarks ?? "",
14216
14261
  seasonPassType: value.seasonPassType ?? "",
14217
- start: value.start ?? createdAt,
14218
- end: value.end ?? expiredAt,
14262
+ start: value.start ? new Date(value.start) : createdAt,
14263
+ end: value.end ? new Date(value.end) : expiredAt,
14219
14264
  status: value.status ?? "active" /* ACTIVE */,
14220
14265
  unitName: value.unitName ?? "",
14221
14266
  peopleId: value.peopleId ?? "",
@@ -14353,10 +14398,11 @@ function useVehicleRepo() {
14353
14398
  const baseQuery = {
14354
14399
  ...status && { status },
14355
14400
  ...type && { type },
14356
- ...category && { category },
14357
- ...search && { $text: { search } }
14401
+ ...category && { category }
14358
14402
  };
14359
14403
  let query = { ...baseQuery };
14404
+ if (search)
14405
+ query.$text = { $search: search };
14360
14406
  const escapeRegex = (input) => input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14361
14407
  const buildGroupedPipeline = (matchQuery) => [
14362
14408
  { $match: matchQuery },
@@ -14916,7 +14962,7 @@ function useVehicleRepo() {
14916
14962
  throw error;
14917
14963
  }
14918
14964
  }
14919
- async function bulkUpsertVehicles(values, session) {
14965
+ async function bulkUpsertVehicles(values) {
14920
14966
  try {
14921
14967
  if (!Array.isArray(values) || values.length === 0) {
14922
14968
  return {
@@ -14925,7 +14971,7 @@ function useVehicleRepo() {
14925
14971
  upsertedCount: 0
14926
14972
  };
14927
14973
  }
14928
- const now = (/* @__PURE__ */ new Date()).toISOString();
14974
+ const now = /* @__PURE__ */ new Date();
14929
14975
  const operations = values.map((item) => {
14930
14976
  const vehicle = MVehicle(item);
14931
14977
  const plateNumber = Array.isArray(vehicle.plateNumber) ? vehicle.plateNumber[0] : vehicle.plateNumber;
@@ -14933,7 +14979,7 @@ function useVehicleRepo() {
14933
14979
  return {
14934
14980
  updateOne: {
14935
14981
  filter: {
14936
- site: vehicle.site,
14982
+ site: new ObjectId43(vehicle.site),
14937
14983
  plateNumber,
14938
14984
  $or: [
14939
14985
  { deletedAt: "" },
@@ -14944,6 +14990,9 @@ function useVehicleRepo() {
14944
14990
  update: {
14945
14991
  $set: {
14946
14992
  ...rest,
14993
+ site: new ObjectId43(vehicle.site),
14994
+ unit: vehicle.unit ? new ObjectId43(vehicle.unit) : null,
14995
+ org: vehicle.org ? new ObjectId43(vehicle.org) : null,
14947
14996
  plateNumber,
14948
14997
  updatedAt: now
14949
14998
  },
@@ -14955,10 +15004,7 @@ function useVehicleRepo() {
14955
15004
  }
14956
15005
  };
14957
15006
  });
14958
- const res = await collection.bulkWrite(operations, {
14959
- ordered: false,
14960
- session
14961
- });
15007
+ const res = await collection.bulkWrite(operations);
14962
15008
  return {
14963
15009
  matchedCount: res.matchedCount,
14964
15010
  modifiedCount: res.modifiedCount,
@@ -15007,10 +15053,10 @@ import {
15007
15053
  BadRequestError as BadRequestError70,
15008
15054
  InternalServerError as InternalServerError26,
15009
15055
  logger as logger51,
15010
- makeCacheKey as makeCacheKey25,
15056
+ makeCacheKey as makeCacheKey24,
15011
15057
  paginate as paginate20,
15012
15058
  useAtlas as useAtlas33,
15013
- useCache as useCache26,
15059
+ useCache as useCache25,
15014
15060
  AppError as AppError10,
15015
15061
  toObjectId as toObjectId10
15016
15062
  } from "@7365admin1/node-server-utils";
@@ -15022,7 +15068,7 @@ function usePersonRepo() {
15022
15068
  throw new InternalServerError26("Unable to connect to server.");
15023
15069
  }
15024
15070
  const collection = db.collection(site_people_namespace_collection);
15025
- const { delNamespace, getCache, setCache } = useCache26(
15071
+ const { delNamespace, getCache, setCache } = useCache25(
15026
15072
  site_people_namespace_collection
15027
15073
  );
15028
15074
  async function createIndexes() {
@@ -15095,7 +15141,7 @@ function usePersonRepo() {
15095
15141
  ]
15096
15142
  } : void 0;
15097
15143
  const query = {
15098
- status,
15144
+ ...status && status !== "all" ? { status } : { status: { $nin: ["deleted", "rejected"] } },
15099
15145
  ...start && { start },
15100
15146
  ...end,
15101
15147
  ...search && {
@@ -15123,7 +15169,7 @@ function usePersonRepo() {
15123
15169
  ...query.site && { site: query.site.toString() },
15124
15170
  ...PERSON_TYPES.includes(type) && { type }
15125
15171
  };
15126
- const cacheKey = makeCacheKey25(
15172
+ const cacheKey = makeCacheKey24(
15127
15173
  site_people_namespace_collection,
15128
15174
  cacheOptions
15129
15175
  );
@@ -15133,12 +15179,29 @@ function usePersonRepo() {
15133
15179
  return cachedData;
15134
15180
  }
15135
15181
  try {
15136
- const basePipeline = [
15137
- { $match: query },
15138
- { $sort: sort },
15139
- { $skip: page * limit },
15140
- { $limit: limit }
15141
- ];
15182
+ const basePipeline = [{ $match: query }];
15183
+ if (status && status == "all") {
15184
+ basePipeline.push(
15185
+ {
15186
+ $addFields: {
15187
+ sortPriority: {
15188
+ $cond: [{ $eq: ["$status", "pending"] }, 1, 2]
15189
+ }
15190
+ }
15191
+ },
15192
+ {
15193
+ $sort: {
15194
+ sortPriority: 1,
15195
+ ...sort
15196
+ }
15197
+ }
15198
+ );
15199
+ } else {
15200
+ basePipeline.push({
15201
+ $sort: sort
15202
+ });
15203
+ }
15204
+ basePipeline.push({ $skip: page * limit }, { $limit: limit });
15142
15205
  const [items, countResult] = await Promise.all([
15143
15206
  collection.aggregate(basePipeline, { session }).toArray(),
15144
15207
  collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
@@ -15218,7 +15281,7 @@ function usePersonRepo() {
15218
15281
  } catch (error) {
15219
15282
  throw new BadRequestError70("Invalid person ID.");
15220
15283
  }
15221
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15284
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15222
15285
  _id: String(_id)
15223
15286
  });
15224
15287
  try {
@@ -15254,7 +15317,7 @@ function usePersonRepo() {
15254
15317
  }
15255
15318
  }
15256
15319
  async function getPersonByPlateNumber(plateNumber) {
15257
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15320
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15258
15321
  plateNumber,
15259
15322
  key: "get-person-plate-number"
15260
15323
  });
@@ -15282,7 +15345,7 @@ function usePersonRepo() {
15282
15345
  }
15283
15346
  async function getByNRIC(value) {
15284
15347
  try {
15285
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15348
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15286
15349
  nric: value
15287
15350
  });
15288
15351
  const cachedData = await getCache(cacheKey);
@@ -15303,7 +15366,7 @@ function usePersonRepo() {
15303
15366
  }
15304
15367
  async function getPersonByPhoneNumber(value) {
15305
15368
  try {
15306
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15369
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15307
15370
  contact: value
15308
15371
  });
15309
15372
  const cachedData = await getCache(cacheKey);
@@ -15329,7 +15392,7 @@ function usePersonRepo() {
15329
15392
  type = [],
15330
15393
  unit
15331
15394
  }, session) {
15332
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15395
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15333
15396
  unit: JSON.stringify(unit),
15334
15397
  status,
15335
15398
  type,
@@ -15363,7 +15426,7 @@ function usePersonRepo() {
15363
15426
  }
15364
15427
  async function getCompany(search) {
15365
15428
  try {
15366
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15429
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15367
15430
  company: search
15368
15431
  });
15369
15432
  const cachedData = await getCache(cacheKey);
@@ -15422,7 +15485,7 @@ function usePersonRepo() {
15422
15485
  }
15423
15486
  }
15424
15487
  async function getPeopleByPlateNumber(plateNumber) {
15425
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15488
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15426
15489
  plateNumber,
15427
15490
  key: "get-people-plate-number"
15428
15491
  });
@@ -15468,7 +15531,7 @@ function usePersonRepo() {
15468
15531
  sort: JSON.stringify(sort)
15469
15532
  };
15470
15533
  try {
15471
- const cacheKey = makeCacheKey25(
15534
+ const cacheKey = makeCacheKey24(
15472
15535
  site_people_namespace_collection,
15473
15536
  cacheOptions
15474
15537
  );
@@ -15552,7 +15615,7 @@ function usePersonRepo() {
15552
15615
  }
15553
15616
  async function getByUserId(userId) {
15554
15617
  const user = toObjectId10(userId);
15555
- const cacheKey = makeCacheKey25(site_people_namespace_collection, {
15618
+ const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15556
15619
  user: userId
15557
15620
  });
15558
15621
  try {
@@ -15617,11 +15680,11 @@ import {
15617
15680
  BadRequestError as BadRequestError72,
15618
15681
  InternalServerError as InternalServerError27,
15619
15682
  logger as logger53,
15620
- makeCacheKey as makeCacheKey26,
15683
+ makeCacheKey as makeCacheKey25,
15621
15684
  paginate as paginate21,
15622
15685
  toObjectId as toObjectId11,
15623
15686
  useAtlas as useAtlas34,
15624
- useCache as useCache27
15687
+ useCache as useCache26
15625
15688
  } from "@7365admin1/node-server-utils";
15626
15689
 
15627
15690
  // src/models/building.model.ts
@@ -15821,7 +15884,7 @@ function useBuildingUnitRepo() {
15821
15884
  }
15822
15885
  const namespace_collection = "building-units";
15823
15886
  const collection = db.collection(namespace_collection);
15824
- const { getCache, setCache, delNamespace, delCache } = useCache27(namespace_collection);
15887
+ const { getCache, setCache, delNamespace, delCache } = useCache26(namespace_collection);
15825
15888
  async function createIndexes() {
15826
15889
  try {
15827
15890
  await collection.createIndexes([
@@ -15999,7 +16062,7 @@ function useBuildingUnitRepo() {
15999
16062
  ...building && { building },
16000
16063
  ...status && { status }
16001
16064
  };
16002
- const cacheKey = makeCacheKey26(namespace_collection, cacheParams);
16065
+ const cacheKey = makeCacheKey25(namespace_collection, cacheParams);
16003
16066
  logger53.log({
16004
16067
  level: "info",
16005
16068
  message: `Cache key for getAll building units: ${cacheKey}`
@@ -16070,7 +16133,7 @@ function useBuildingUnitRepo() {
16070
16133
  } catch (error) {
16071
16134
  throw new BadRequestError72("Invalid ID.");
16072
16135
  }
16073
- const cacheKey = makeCacheKey26(namespace_collection, { _id: String(_id) });
16136
+ const cacheKey = makeCacheKey25(namespace_collection, { _id: String(_id) });
16074
16137
  try {
16075
16138
  const cached = await getCache(cacheKey);
16076
16139
  if (cached) {
@@ -16113,7 +16176,7 @@ function useBuildingUnitRepo() {
16113
16176
  } catch (error) {
16114
16177
  throw new BadRequestError72("Invalid building ID.");
16115
16178
  }
16116
- const cacheKey = makeCacheKey26(namespace_collection, {
16179
+ const cacheKey = makeCacheKey25(namespace_collection, {
16117
16180
  building: String(building),
16118
16181
  level
16119
16182
  });
@@ -16187,7 +16250,7 @@ function useBuildingUnitRepo() {
16187
16250
  } catch (error) {
16188
16251
  throw new BadRequestError72("Invalid building ID.");
16189
16252
  }
16190
- const cacheKey = makeCacheKey26(namespace_collection, {
16253
+ const cacheKey = makeCacheKey25(namespace_collection, {
16191
16254
  building: String(building)
16192
16255
  });
16193
16256
  try {
@@ -16261,7 +16324,7 @@ function useBuildingUnitRepo() {
16261
16324
  block,
16262
16325
  level
16263
16326
  };
16264
- const cacheKey = makeCacheKey26(namespace_collection, cacheOptions);
16327
+ const cacheKey = makeCacheKey25(namespace_collection, cacheOptions);
16265
16328
  const cachedData = await getCache(cacheKey);
16266
16329
  if (cachedData) {
16267
16330
  logger53.info(`Cache hit for key: ${cacheKey}`);
@@ -16299,7 +16362,7 @@ function useBuildingUnitRepo() {
16299
16362
  const cacheOptions = {
16300
16363
  site: site.toString()
16301
16364
  };
16302
- const cacheKey = makeCacheKey26(namespace_collection, cacheOptions);
16365
+ const cacheKey = makeCacheKey25(namespace_collection, cacheOptions);
16303
16366
  const cachedData = await getCache(cacheKey);
16304
16367
  if (cachedData) {
16305
16368
  logger53.info(`Cache hit for key: ${cacheKey}`);
@@ -16347,7 +16410,7 @@ function useBuildingUnitRepo() {
16347
16410
  { deletedAt: "" }
16348
16411
  ]
16349
16412
  };
16350
- const cacheKey = makeCacheKey26(namespace_collection, cacheOptions);
16413
+ const cacheKey = makeCacheKey25(namespace_collection, cacheOptions);
16351
16414
  try {
16352
16415
  const cached = await getCache(cacheKey);
16353
16416
  if (cached) {
@@ -17051,15 +17114,11 @@ function useVehicleService() {
17051
17114
  }
17052
17115
  }
17053
17116
  async function bulkUpsertVehicles(values, site, org) {
17054
- const session = useAtlas35.getClient()?.startSession();
17055
- if (!session) {
17056
- throw new Error("Unable to start session for vehicle service.");
17057
- }
17058
17117
  try {
17059
17118
  if (!Array.isArray(values) || values.length === 0) {
17060
17119
  throw new Error("Vehicle list is required.");
17061
17120
  }
17062
- const now = (/* @__PURE__ */ new Date()).toISOString();
17121
+ const now = /* @__PURE__ */ new Date();
17063
17122
  const sanitizedValues = (await Promise.all(
17064
17123
  values.map(async (item) => {
17065
17124
  const plateNumber = Array.isArray(item.plateNumber) ? item.plateNumber[0] : item.plateNumber;
@@ -17074,7 +17133,7 @@ function useVehicleService() {
17074
17133
  ...item,
17075
17134
  org,
17076
17135
  site,
17077
- start: item.start ?? now,
17136
+ start: now.toISOString(),
17078
17137
  unit: unitId,
17079
17138
  plateNumber: typeof plateNumber === "string" ? plateNumber.trim().toUpperCase() : plateNumber
17080
17139
  };
@@ -17104,33 +17163,36 @@ function useVehicleService() {
17104
17163
  if (!siteCameras.length) {
17105
17164
  throw new Error("No site cameras found.");
17106
17165
  }
17107
- for (const vehicleValue of sanitizedValues) {
17108
- const plateNumber = vehicleValue.plateNumber;
17109
- const _mode = vehicleValue.type === "whitelist" /* WHITELIST */ ? "TrafficRedList" /* TRAFFIC_REDLIST */ : "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
17110
- for (const camera of siteCameras) {
17111
- const { host, username, password } = camera;
17112
- const dahuaPayload = {
17113
- host,
17114
- username,
17115
- password,
17116
- plateNumber,
17117
- mode: _mode,
17118
- ...vehicleValue.start ? { start: String(vehicleValue.start) } : {},
17119
- ...vehicleValue.end ? { end: String(vehicleValue.end) } : {},
17120
- ...vehicleValue.name ? { owner: vehicleValue.name } : {},
17121
- ...vehicleValue.vehicleModel ? { vehicleType: vehicleValue.vehicleModel } : {},
17122
- ...vehicleValue.vehicleColor ? { vehicleColor: vehicleValue.vehicleColor } : {}
17123
- };
17124
- const dahuaResponse = await _bulkInsertPlateNumber(dahuaPayload);
17125
- const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
17126
- vehicleValue.recNo = responseData.split("=")[1]?.trim();
17127
- }
17128
- }
17129
- return await _bulkUpsertVehicles(sanitizedValues, session);
17166
+ await Promise.all(
17167
+ sanitizedValues.map(async (vehicleValue) => {
17168
+ const plateNumber = vehicleValue.plateNumber;
17169
+ const _mode = vehicleValue.type === "whitelist" /* WHITELIST */ ? "TrafficRedList" /* TRAFFIC_REDLIST */ : "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
17170
+ const recNos = await Promise.all(
17171
+ siteCameras.map(async (camera) => {
17172
+ const { host, username, password } = camera;
17173
+ const dahuaPayload = {
17174
+ host,
17175
+ username,
17176
+ password,
17177
+ plateNumber,
17178
+ mode: _mode,
17179
+ ...vehicleValue.start ? { start: String(vehicleValue.start) } : {},
17180
+ ...vehicleValue.end ? { end: String(vehicleValue.end) } : {},
17181
+ ...vehicleValue.name ? { owner: vehicleValue.name } : {},
17182
+ ...vehicleValue.vehicleModel ? { vehicleType: vehicleValue.vehicleModel } : {},
17183
+ ...vehicleValue.vehicleColor ? { vehicleColor: vehicleValue.vehicleColor } : {}
17184
+ };
17185
+ const dahuaResponse = await _bulkInsertPlateNumber(dahuaPayload);
17186
+ const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
17187
+ return responseData.split("=")[1]?.trim();
17188
+ })
17189
+ );
17190
+ vehicleValue.recNo = recNos.find((r) => r) ?? void 0;
17191
+ })
17192
+ );
17193
+ return await _bulkUpsertVehicles(sanitizedValues);
17130
17194
  } catch (error) {
17131
17195
  throw error;
17132
- } finally {
17133
- session.endSession();
17134
17196
  }
17135
17197
  }
17136
17198
  return {
@@ -17919,7 +17981,8 @@ function useSiteController() {
17919
17981
  getSites: _getSites,
17920
17982
  getSiteById: _getSiteById,
17921
17983
  updateSiteBlock: _updateSiteBlock,
17922
- deleteSite: _deleteSite
17984
+ deleteSite: _deleteSite,
17985
+ getAllSitesForResidentCreation: _getAllSitesForResidentCreation
17923
17986
  } = useSiteRepo();
17924
17987
  const { updateGuardPostById, siteInformation: _siteInformation } = useSiteService();
17925
17988
  async function createSite(req, res, next) {
@@ -18104,14 +18167,13 @@ function useSiteController() {
18104
18167
  id: Joi42.string().hex().required(),
18105
18168
  bgImage: Joi42.string().optional().allow("", null),
18106
18169
  description: Joi42.string().optional().allow("", null),
18107
- docs: Joi42.array().items(Joi42.object({
18108
- id: Joi42.string().hex().optional().allow("", null),
18109
- name: Joi42.string().optional().allow("", null)
18110
- })).optional().allow("", null)
18111
- }).validate(
18112
- { id, ...payload },
18113
- { abortEarly: false }
18114
- );
18170
+ docs: Joi42.array().items(
18171
+ Joi42.object({
18172
+ id: Joi42.string().hex().optional().allow("", null),
18173
+ name: Joi42.string().optional().allow("", null)
18174
+ })
18175
+ ).optional().allow("", null)
18176
+ }).validate({ id, ...payload }, { abortEarly: false });
18115
18177
  if (error) {
18116
18178
  logger57.log({ level: "error", message: error.message });
18117
18179
  next(new BadRequestError76(error.message));
@@ -18127,6 +18189,36 @@ function useSiteController() {
18127
18189
  return;
18128
18190
  }
18129
18191
  }
18192
+ async function getAllSitesForResidentCreation(req, res, next) {
18193
+ const validation = Joi42.object({
18194
+ search: Joi42.string().optional().allow("", null),
18195
+ page: Joi42.number().integer().min(1).allow("", null).default(1),
18196
+ limit: Joi42.number().integer().min(1).max(100).allow("", null).default(10)
18197
+ });
18198
+ const query = { ...req.query };
18199
+ const { error } = validation.validate(query);
18200
+ if (error) {
18201
+ logger57.log({ level: "error", message: error.message });
18202
+ next(new BadRequestError76(error.message));
18203
+ return;
18204
+ }
18205
+ const search = req.query.search ?? "";
18206
+ const page = parseInt(req.query.page ?? "1");
18207
+ const limit = parseInt(req.query.limit ?? "10");
18208
+ try {
18209
+ const data = await _getAllSitesForResidentCreation({
18210
+ search,
18211
+ page,
18212
+ limit
18213
+ });
18214
+ res.json(data);
18215
+ return;
18216
+ } catch (error2) {
18217
+ logger57.log({ level: "error", message: error2.message });
18218
+ next(error2);
18219
+ return;
18220
+ }
18221
+ }
18130
18222
  return {
18131
18223
  createSite,
18132
18224
  getSites,
@@ -18135,7 +18227,8 @@ function useSiteController() {
18135
18227
  deleteSite,
18136
18228
  updateById,
18137
18229
  updateGuardPostsById,
18138
- siteInformation
18230
+ siteInformation,
18231
+ getAllSitesForResidentCreation
18139
18232
  };
18140
18233
  }
18141
18234
 
@@ -18194,7 +18287,7 @@ function MChat(value) {
18194
18287
  import {
18195
18288
  useAtlas as useAtlas37,
18196
18289
  InternalServerError as InternalServerError28,
18197
- useCache as useCache28,
18290
+ useCache as useCache27,
18198
18291
  logger as logger59
18199
18292
  } from "@7365admin1/node-server-utils";
18200
18293
  function useChatRepo() {
@@ -18204,7 +18297,7 @@ function useChatRepo() {
18204
18297
  }
18205
18298
  const namespace_collection = "chats";
18206
18299
  const collection = db.collection(namespace_collection);
18207
- const { delNamespace } = useCache28(namespace_collection);
18300
+ const { delNamespace } = useCache27(namespace_collection);
18208
18301
  async function createChat(value, session) {
18209
18302
  try {
18210
18303
  value = MChat(value);
@@ -18258,10 +18351,10 @@ import {
18258
18351
  BadRequestError as BadRequestError79,
18259
18352
  InternalServerError as InternalServerError29,
18260
18353
  logger as logger61,
18261
- makeCacheKey as makeCacheKey27,
18354
+ makeCacheKey as makeCacheKey26,
18262
18355
  paginate as paginate22,
18263
18356
  useAtlas as useAtlas38,
18264
- useCache as useCache29
18357
+ useCache as useCache28
18265
18358
  } from "@7365admin1/node-server-utils";
18266
18359
  import { ObjectId as ObjectId49 } from "mongodb";
18267
18360
  var buildings_namespace_collection = "buildings";
@@ -18271,7 +18364,7 @@ function useBuildingRepo() {
18271
18364
  throw new Error("Unable to connect to server.");
18272
18365
  }
18273
18366
  const collection = db.collection(buildings_namespace_collection);
18274
- const { getCache, setCache, delNamespace } = useCache29(
18367
+ const { getCache, setCache, delNamespace } = useCache28(
18275
18368
  buildings_namespace_collection
18276
18369
  );
18277
18370
  async function createIndexes() {
@@ -18382,7 +18475,7 @@ function useBuildingRepo() {
18382
18475
  ...site && { site },
18383
18476
  ...status && { status }
18384
18477
  };
18385
- const cacheKey = makeCacheKey27(buildings_namespace_collection, cacheParams);
18478
+ const cacheKey = makeCacheKey26(buildings_namespace_collection, cacheParams);
18386
18479
  logger61.log({
18387
18480
  level: "info",
18388
18481
  message: `Cache key for getAll buildings: ${cacheKey}`
@@ -18427,7 +18520,7 @@ function useBuildingRepo() {
18427
18520
  } catch (error) {
18428
18521
  throw new BadRequestError79("Invalid ID.");
18429
18522
  }
18430
- const cacheKey = makeCacheKey27(buildings_namespace_collection, {
18523
+ const cacheKey = makeCacheKey26(buildings_namespace_collection, {
18431
18524
  _id: String(_id)
18432
18525
  });
18433
18526
  try {
@@ -18498,7 +18591,7 @@ function useBuildingRepo() {
18498
18591
  block
18499
18592
  };
18500
18593
  const cacheOptions = { ...query };
18501
- const cacheKey = makeCacheKey27(buildings_namespace_collection, cacheOptions);
18594
+ const cacheKey = makeCacheKey26(buildings_namespace_collection, cacheOptions);
18502
18595
  try {
18503
18596
  const cached = await getCache(cacheKey);
18504
18597
  if (cached) {
@@ -19188,6 +19281,7 @@ function useBuildingUnitController() {
19188
19281
  import { BadRequestError as BadRequestError84, logger as logger66 } from "@7365admin1/node-server-utils";
19189
19282
  import Joi46 from "joi";
19190
19283
  import ExcelJS from "exceljs";
19284
+ import csv from "csv-parser";
19191
19285
  import fs from "fs";
19192
19286
  function useVehicleController() {
19193
19287
  const {
@@ -19232,8 +19326,15 @@ function useVehicleController() {
19232
19326
  };
19233
19327
  }
19234
19328
  function parseExpiryDate(value) {
19235
- if (!value)
19236
- return void 0;
19329
+ if (!value) {
19330
+ const today = /* @__PURE__ */ new Date();
19331
+ today.setFullYear(today.getFullYear() + 10);
19332
+ return today.toISOString();
19333
+ }
19334
+ const date = new Date(value);
19335
+ if (!isNaN(date.getTime())) {
19336
+ return date.toISOString();
19337
+ }
19237
19338
  const [day, monthStr, yearShort] = value.split("-");
19238
19339
  const months = {
19239
19340
  Jan: 0,
@@ -19253,19 +19354,17 @@ function useVehicleController() {
19253
19354
  if (month === void 0)
19254
19355
  return void 0;
19255
19356
  const year = 2e3 + Number(yearShort);
19256
- const date = new Date(year, month, Number(day));
19257
- return isNaN(date.getTime()) ? void 0 : date.toISOString();
19357
+ const fallbackDate = new Date(year, month, Number(day));
19358
+ return isNaN(fallbackDate.getTime()) ? void 0 : fallbackDate.toISOString();
19258
19359
  }
19259
- async function uploadExcelVehicles(req, res, next) {
19360
+ async function uploadSpreadsheetVehicles(req, res, next) {
19260
19361
  try {
19261
19362
  if (!req.file) {
19262
- next(new BadRequestError84("Excel file is required."));
19263
- return;
19264
- }
19265
- if (!req.file.originalname.toLowerCase().endsWith(".xlsx")) {
19266
- next(new BadRequestError84("Only .xlsx files are allowed."));
19363
+ next(new BadRequestError84("Spreadsheet file is required."));
19267
19364
  return;
19268
19365
  }
19366
+ const { originalname, path: path4 } = req.file;
19367
+ const lowerName = originalname.toLowerCase();
19269
19368
  const rowSchema = Joi46.object({
19270
19369
  fullName: Joi46.string().trim().required(),
19271
19370
  userType: Joi46.string().trim().required(),
@@ -19277,7 +19376,11 @@ function useVehicleController() {
19277
19376
  plateNumber: Joi46.string().trim().uppercase().required(),
19278
19377
  vehicleModel: Joi46.string().trim().allow("", null).optional(),
19279
19378
  vehicleColor: Joi46.string().trim().allow("", null).optional(),
19280
- subscriptionExpiry: Joi46.string().trim().allow("", null).optional()
19379
+ subscriptionExpiry: Joi46.alternatives().try(
19380
+ Joi46.date().iso(),
19381
+ // ISO format
19382
+ Joi46.string().pattern(/^\d{1,2}-[A-Za-z]{3}-\d{2}$/)
19383
+ ).allow("", null).optional()
19281
19384
  });
19282
19385
  const querySchema = Joi46.object({
19283
19386
  site: Joi46.string().hex().length(24).required(),
@@ -19285,10 +19388,7 @@ function useVehicleController() {
19285
19388
  });
19286
19389
  const { error: queryError, value: queryValue } = querySchema.validate(
19287
19390
  req.query,
19288
- {
19289
- abortEarly: false,
19290
- convert: true
19291
- }
19391
+ { abortEarly: false, convert: true }
19292
19392
  );
19293
19393
  if (queryError) {
19294
19394
  next(
@@ -19299,30 +19399,43 @@ function useVehicleController() {
19299
19399
  return;
19300
19400
  }
19301
19401
  const { site, org } = queryValue;
19302
- const workbook = new ExcelJS.Workbook();
19303
- await workbook.xlsx.readFile(req.file.path);
19304
- const worksheet = workbook.worksheets[0];
19305
- if (!worksheet) {
19306
- next(new BadRequestError84("No worksheet found in uploaded Excel file."));
19307
- return;
19308
- }
19309
- const rows = [];
19310
- const headerRow = worksheet.getRow(1);
19311
- const headers = (headerRow.values || []).slice(1).map((header) => String(header ?? "").trim());
19312
- worksheet.eachRow((row, rowNumber) => {
19313
- if (rowNumber === 1)
19402
+ let rows = [];
19403
+ if (lowerName.endsWith(".xlsx") || lowerName.endsWith(".xls")) {
19404
+ const workbook = new ExcelJS.Workbook();
19405
+ await workbook.xlsx.readFile(path4);
19406
+ const worksheet = workbook.worksheets[0];
19407
+ if (!worksheet) {
19408
+ next(
19409
+ new BadRequestError84("No worksheet found in uploaded Excel file.")
19410
+ );
19314
19411
  return;
19315
- const rowData = {};
19316
- headers.forEach((header, index) => {
19317
- rowData[header] = row.getCell(index + 1).value ?? "";
19412
+ }
19413
+ const headerRow = worksheet.getRow(1);
19414
+ const headers = (headerRow.values || []).slice(1).map((header) => String(header ?? "").trim());
19415
+ worksheet.eachRow((row, rowNumber) => {
19416
+ if (rowNumber === 1)
19417
+ return;
19418
+ const rowData = {};
19419
+ headers.forEach((header, index) => {
19420
+ rowData[header] = row.getCell(index + 1).value ?? "";
19421
+ });
19422
+ if (Object.values(rowData).some(
19423
+ (v) => v !== "" && v !== null && v !== void 0
19424
+ )) {
19425
+ rows.push(rowData);
19426
+ }
19318
19427
  });
19319
- const hasValue = Object.values(rowData).some(
19320
- (value) => value !== null && value !== void 0 && value !== ""
19428
+ } else if (lowerName.endsWith(".csv")) {
19429
+ rows = await new Promise((resolve, reject) => {
19430
+ const parsed = [];
19431
+ fs.createReadStream(path4).pipe(csv()).on("data", (row) => parsed.push(row)).on("end", () => resolve(parsed)).on("error", reject);
19432
+ });
19433
+ } else {
19434
+ next(
19435
+ new BadRequestError84("Only .xlsx, .xls, or .csv files are allowed.")
19321
19436
  );
19322
- if (hasValue) {
19323
- rows.push(rowData);
19324
- }
19325
- });
19437
+ return;
19438
+ }
19326
19439
  const validRows = [];
19327
19440
  const invalidRows = [];
19328
19441
  rows.forEach((row, index) => {
@@ -19336,9 +19449,9 @@ function useVehicleController() {
19336
19449
  data: row,
19337
19450
  errors: error.details.map((d) => d.message)
19338
19451
  });
19339
- return;
19452
+ } else {
19453
+ validRows.push(value);
19340
19454
  }
19341
- validRows.push(value);
19342
19455
  });
19343
19456
  const vehicles = validRows.map((row) => mapRowToVehicle(row, site, org));
19344
19457
  let data = {};
@@ -19346,15 +19459,15 @@ function useVehicleController() {
19346
19459
  data = await _bulkUpsertVehicles(vehicles, site, org);
19347
19460
  }
19348
19461
  res.status(200).json({
19349
- message: "Excel import completed.",
19350
- sheetName: worksheet.name,
19462
+ message: "Spreadsheet import completed.",
19463
+ fileName: originalname,
19351
19464
  totalRows: rows.length,
19352
19465
  validRows: validRows.length,
19353
19466
  invalidRows: invalidRows.length,
19354
19467
  validationErrors: invalidRows,
19355
19468
  data
19356
19469
  });
19357
- fs.unlink(req.file.path, () => {
19470
+ fs.unlink(path4, () => {
19358
19471
  });
19359
19472
  } catch (error) {
19360
19473
  logger66.log({ level: "error", message: error.message });
@@ -19696,8 +19809,7 @@ function useVehicleController() {
19696
19809
  getVehiclesByNRIC,
19697
19810
  reactivateVehicleById,
19698
19811
  getAllVehiclesByUnitId,
19699
- // uploadCsvVehicles,
19700
- uploadExcelVehicles
19812
+ uploadSpreadsheetVehicles
19701
19813
  };
19702
19814
  }
19703
19815
 
@@ -19942,10 +20054,10 @@ import {
19942
20054
  BadRequestError as BadRequestError87,
19943
20055
  InternalServerError as InternalServerError30,
19944
20056
  logger as logger68,
19945
- makeCacheKey as makeCacheKey28,
20057
+ makeCacheKey as makeCacheKey27,
19946
20058
  paginate as paginate23,
19947
20059
  useAtlas as useAtlas42,
19948
- useCache as useCache30
20060
+ useCache as useCache29
19949
20061
  } from "@7365admin1/node-server-utils";
19950
20062
  import { ObjectId as ObjectId51 } from "mongodb";
19951
20063
  import Joi49 from "joi";
@@ -19956,7 +20068,7 @@ function useCustomerSiteRepo() {
19956
20068
  }
19957
20069
  const namespace_collection = "customer.sites";
19958
20070
  const collection = db.collection(namespace_collection);
19959
- const { delNamespace, getCache, setCache } = useCache30(namespace_collection);
20071
+ const { delNamespace, getCache, setCache } = useCache29(namespace_collection);
19960
20072
  async function createIndexes() {
19961
20073
  try {
19962
20074
  await collection.createIndexes([
@@ -20016,7 +20128,7 @@ function useCustomerSiteRepo() {
20016
20128
  throw new BadRequestError87("Invalid org ID.");
20017
20129
  }
20018
20130
  }
20019
- const cacheKey = makeCacheKey28(namespace_collection, cacheKeyOptions);
20131
+ const cacheKey = makeCacheKey27(namespace_collection, cacheKeyOptions);
20020
20132
  try {
20021
20133
  const cachedData = await getCache(cacheKey);
20022
20134
  if (cachedData) {
@@ -20068,7 +20180,7 @@ function useCustomerSiteRepo() {
20068
20180
  query.$or = [{ name: { $regex: search, $options: "i" } }];
20069
20181
  cacheOptions.search = search;
20070
20182
  }
20071
- const cacheKey = makeCacheKey28(namespace_collection, cacheOptions);
20183
+ const cacheKey = makeCacheKey27(namespace_collection, cacheOptions);
20072
20184
  const cachedData = await getCache(cacheKey);
20073
20185
  if (cachedData) {
20074
20186
  logger68.info(`Cache hit for key: ${cacheKey}`);
@@ -20118,7 +20230,7 @@ function useCustomerSiteRepo() {
20118
20230
  }
20119
20231
  try {
20120
20232
  const query = { site, status: "active" };
20121
- const cacheKey = makeCacheKey28(namespace_collection, {
20233
+ const cacheKey = makeCacheKey27(namespace_collection, {
20122
20234
  site: site.toString(),
20123
20235
  status: "active",
20124
20236
  tag: "get-by-site-as-sp"
@@ -20533,9 +20645,9 @@ import {
20533
20645
  useAtlas as useAtlas44,
20534
20646
  InternalServerError as InternalServerError31,
20535
20647
  BadRequestError as BadRequestError91,
20536
- useCache as useCache31,
20648
+ useCache as useCache30,
20537
20649
  logger as logger71,
20538
- makeCacheKey as makeCacheKey29,
20650
+ makeCacheKey as makeCacheKey28,
20539
20651
  NotFoundError as NotFoundError21
20540
20652
  } from "@7365admin1/node-server-utils";
20541
20653
  function useAttendanceSettingsRepository() {
@@ -20545,7 +20657,7 @@ function useAttendanceSettingsRepository() {
20545
20657
  }
20546
20658
  const namespace_collection = "site.attendance-settings";
20547
20659
  const collection = db.collection(namespace_collection);
20548
- const { delNamespace, setCache, getCache } = useCache31(namespace_collection);
20660
+ const { delNamespace, setCache, getCache } = useCache30(namespace_collection);
20549
20661
  async function createIndex() {
20550
20662
  try {
20551
20663
  await collection.createIndexes([
@@ -20582,7 +20694,7 @@ function useAttendanceSettingsRepository() {
20582
20694
  throw new BadRequestError91("Invalid attendance settings site ID format.");
20583
20695
  }
20584
20696
  const query = { site, serviceType };
20585
- const cacheKey = makeCacheKey29(namespace_collection, {
20697
+ const cacheKey = makeCacheKey28(namespace_collection, {
20586
20698
  site: site.toString(),
20587
20699
  serviceType
20588
20700
  });
@@ -20814,9 +20926,9 @@ import {
20814
20926
  InternalServerError as InternalServerError32,
20815
20927
  paginate as paginate24,
20816
20928
  BadRequestError as BadRequestError94,
20817
- useCache as useCache32,
20929
+ useCache as useCache31,
20818
20930
  logger as logger75,
20819
- makeCacheKey as makeCacheKey30,
20931
+ makeCacheKey as makeCacheKey29,
20820
20932
  NotFoundError as NotFoundError22
20821
20933
  } from "@7365admin1/node-server-utils";
20822
20934
  function useAttendanceRepository() {
@@ -20826,7 +20938,7 @@ function useAttendanceRepository() {
20826
20938
  }
20827
20939
  const namespace_collection = "site.attendances";
20828
20940
  const collection = db.collection(namespace_collection);
20829
- const { delNamespace, setCache, getCache, delCache } = useCache32(namespace_collection);
20941
+ const { delNamespace, setCache, getCache, delCache } = useCache31(namespace_collection);
20830
20942
  async function createIndex() {
20831
20943
  try {
20832
20944
  await collection.createIndexes([
@@ -20879,7 +20991,7 @@ function useAttendanceRepository() {
20879
20991
  if (search) {
20880
20992
  cacheOptions.search = search;
20881
20993
  }
20882
- const cacheKey = makeCacheKey30(namespace_collection, cacheOptions);
20994
+ const cacheKey = makeCacheKey29(namespace_collection, cacheOptions);
20883
20995
  const cachedData = await getCache(cacheKey);
20884
20996
  if (cachedData) {
20885
20997
  logger75.info(`Cache hit for key: ${cacheKey}`);
@@ -20983,7 +21095,7 @@ function useAttendanceRepository() {
20983
21095
  if (search) {
20984
21096
  cacheOptions.search = search;
20985
21097
  }
20986
- const cacheKey = makeCacheKey30(namespace_collection, cacheOptions);
21098
+ const cacheKey = makeCacheKey29(namespace_collection, cacheOptions);
20987
21099
  const cachedData = await getCache(cacheKey);
20988
21100
  if (cachedData) {
20989
21101
  logger75.info(`Cache hit for key: ${cacheKey}`);
@@ -21061,7 +21173,7 @@ function useAttendanceRepository() {
21061
21173
  throw new BadRequestError94("Invalid attendance ID format.");
21062
21174
  }
21063
21175
  const query = { _id };
21064
- const cacheKey = makeCacheKey30(namespace_collection, {
21176
+ const cacheKey = makeCacheKey29(namespace_collection, {
21065
21177
  _id: _id.toString()
21066
21178
  });
21067
21179
  if (!session) {
@@ -21114,7 +21226,7 @@ function useAttendanceRepository() {
21114
21226
  throw new BadRequestError94("Invalid attendance ID format.");
21115
21227
  }
21116
21228
  const query = { _id };
21117
- const cacheKey = makeCacheKey30(namespace_collection, {
21229
+ const cacheKey = makeCacheKey29(namespace_collection, {
21118
21230
  _id: _id.toString()
21119
21231
  });
21120
21232
  if (!session) {
@@ -21194,7 +21306,7 @@ function useAttendanceRepository() {
21194
21306
  );
21195
21307
  if (res.modifiedCount === 0)
21196
21308
  throw new InternalServerError32("Unable to delete attendance.");
21197
- const cacheKey = makeCacheKey30(namespace_collection, { _id });
21309
+ const cacheKey = makeCacheKey29(namespace_collection, { _id });
21198
21310
  delCache(cacheKey).then(() => {
21199
21311
  logger75.info(`Cache deleted for key: ${cacheKey}`);
21200
21312
  }).catch((err) => {
@@ -22149,11 +22261,6 @@ var KeyRepo = class {
22149
22261
  } else if (organization) {
22150
22262
  defaultQuery = { organization };
22151
22263
  }
22152
- console.log("key-query: ", {
22153
- ...defaultQuery,
22154
- ...searchQuery,
22155
- ...dateFilter
22156
- });
22157
22264
  try {
22158
22265
  const result = await this.collection().aggregate([
22159
22266
  {
@@ -22666,14 +22773,28 @@ function useVisitorTransactionService() {
22666
22773
  const host = camera.host;
22667
22774
  const username = camera.username;
22668
22775
  const password = camera.password;
22669
- const mode = "TrafficRedList" /* TRAFFIC_REDLIST */;
22776
+ const redlist = "TrafficRedList" /* TRAFFIC_REDLIST */;
22777
+ const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
22670
22778
  const _plateNumber = value.plateNumber;
22779
+ const dahuaBlocklistQuery = {
22780
+ host,
22781
+ username,
22782
+ password,
22783
+ plateNumber: _plateNumber,
22784
+ mode: blacklist
22785
+ };
22786
+ const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
22787
+ const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
22788
+ const foundMatch = rawString.match(/found=(\d+)/);
22789
+ const found = foundMatch ? Number(foundMatch[1]) : 0;
22790
+ if (found === 1)
22791
+ throw new BadRequestError97("This plate number is blocklisted");
22671
22792
  const dahuaQuery = {
22672
22793
  host,
22673
22794
  username,
22674
22795
  password,
22675
22796
  plateNumber: _plateNumber,
22676
- mode
22797
+ mode: redlist
22677
22798
  };
22678
22799
  const raw = await _getPlateNumber(dahuaQuery);
22679
22800
  const parsed = parseDahuaFind(raw);
@@ -22683,7 +22804,7 @@ function useVisitorTransactionService() {
22683
22804
  username,
22684
22805
  password,
22685
22806
  plateNumber: _plateNumber,
22686
- mode,
22807
+ mode: redlist,
22687
22808
  start: startDahuaDate,
22688
22809
  end: endDahuaDate,
22689
22810
  owner: value.name ?? "",
@@ -22719,7 +22840,7 @@ function useVisitorTransactionService() {
22719
22840
  password,
22720
22841
  plateNumber: _plateNumber,
22721
22842
  recno: parsed.recNo,
22722
- mode,
22843
+ mode: redlist,
22723
22844
  start: startDahuaDate,
22724
22845
  end: endDahuaDate,
22725
22846
  owner: value.name ?? "",
@@ -22828,6 +22949,14 @@ function useVisitorTransactionService() {
22828
22949
  }
22829
22950
  value.passKeys = keptPassKeys;
22830
22951
  }
22952
+ if (value.checkIn) {
22953
+ const parsed = new Date(value.checkIn);
22954
+ value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
22955
+ }
22956
+ if (value.checkOut) {
22957
+ const parsed = new Date(value.checkOut);
22958
+ value.checkOut = isNaN(parsed.getTime()) ? null : parsed;
22959
+ }
22831
22960
  await _updateVisitorTansactionById(id, value, session);
22832
22961
  await session?.commitTransaction();
22833
22962
  return "Successfully updated visitor transaction.";
@@ -23416,10 +23545,10 @@ import {
23416
23545
  BadRequestError as BadRequestError99,
23417
23546
  InternalServerError as InternalServerError33,
23418
23547
  logger as logger80,
23419
- makeCacheKey as makeCacheKey31,
23548
+ makeCacheKey as makeCacheKey30,
23420
23549
  paginate as paginate25,
23421
23550
  useAtlas as useAtlas50,
23422
- useCache as useCache33
23551
+ useCache as useCache32
23423
23552
  } from "@7365admin1/node-server-utils";
23424
23553
  import { ObjectId as ObjectId61 } from "mongodb";
23425
23554
  var guests_namespace_collection = "visitor.guests";
@@ -23429,7 +23558,7 @@ function useGuestManagementRepo() {
23429
23558
  throw new InternalServerError33("Unable to connect to server.");
23430
23559
  }
23431
23560
  const collection = db.collection(guests_namespace_collection);
23432
- const { delNamespace, getCache, setCache } = useCache33(
23561
+ const { delNamespace, getCache, setCache } = useCache32(
23433
23562
  guests_namespace_collection
23434
23563
  );
23435
23564
  async function createTextIndex() {
@@ -23508,7 +23637,7 @@ function useGuestManagementRepo() {
23508
23637
  ...query.org && { org: query.org.toString() },
23509
23638
  ...query.site && { site: query.site.toString() }
23510
23639
  };
23511
- const cacheKey = makeCacheKey31(guests_namespace_collection, cacheOptions);
23640
+ const cacheKey = makeCacheKey30(guests_namespace_collection, cacheOptions);
23512
23641
  const cachedData = await getCache(cacheKey);
23513
23642
  if (cachedData) {
23514
23643
  logger80.info(`Cache hit for key: ${cacheKey}`);
@@ -23841,10 +23970,11 @@ function usePersonService() {
23841
23970
  email: value.email,
23842
23971
  password: hashedPassword,
23843
23972
  name: value.name,
23973
+ status: value.platform == "mobile" ? "deleted" : "active",
23844
23974
  defaultOrg: value.org?.toString() || ""
23845
23975
  };
23846
23976
  const userId = await addUser(user, session);
23847
- value.user = userId;
23977
+ value.user = userId.toString();
23848
23978
  let org = null;
23849
23979
  if (userId) {
23850
23980
  if (value?.org) {
@@ -24145,7 +24275,6 @@ function usePersonController() {
24145
24275
  }
24146
24276
  async function getPeopleByUnit(req, res, next) {
24147
24277
  const PERSON_TYPES3 = Object.values(PersonTypes);
24148
- console.log(req.query);
24149
24278
  try {
24150
24279
  const schema2 = Joi58.object({
24151
24280
  unit: Joi58.string().required(),
@@ -24389,8 +24518,8 @@ import {
24389
24518
  InternalServerError as InternalServerError34,
24390
24519
  paginate as paginate26,
24391
24520
  BadRequestError as BadRequestError104,
24392
- useCache as useCache34,
24393
- makeCacheKey as makeCacheKey32,
24521
+ useCache as useCache33,
24522
+ makeCacheKey as makeCacheKey31,
24394
24523
  logger as logger85
24395
24524
  } from "@7365admin1/node-server-utils";
24396
24525
  function useRobotRepo() {
@@ -24400,7 +24529,7 @@ function useRobotRepo() {
24400
24529
  }
24401
24530
  const namespace_collection = "robots";
24402
24531
  const collection = db.collection(namespace_collection);
24403
- const { delNamespace, getCache, setCache } = useCache34(namespace_collection);
24532
+ const { delNamespace, getCache, setCache } = useCache33(namespace_collection);
24404
24533
  async function createIndex() {
24405
24534
  try {
24406
24535
  await collection.createIndexes([
@@ -24500,7 +24629,7 @@ function useRobotRepo() {
24500
24629
  cacheOptions.from = from;
24501
24630
  cacheOptions.to = to;
24502
24631
  }
24503
- const cacheKey = makeCacheKey32(namespace_collection, cacheOptions);
24632
+ const cacheKey = makeCacheKey31(namespace_collection, cacheOptions);
24504
24633
  const cachedData = await getCache(cacheKey);
24505
24634
  if (cachedData) {
24506
24635
  logger85.info(`Cache hit for key: ${cacheKey}`);
@@ -24729,10 +24858,10 @@ import {
24729
24858
  BadRequestError as BadRequestError108,
24730
24859
  InternalServerError as InternalServerError35,
24731
24860
  logger as logger88,
24732
- makeCacheKey as makeCacheKey33,
24861
+ makeCacheKey as makeCacheKey32,
24733
24862
  paginate as paginate27,
24734
24863
  useAtlas as useAtlas54,
24735
- useCache as useCache35
24864
+ useCache as useCache34
24736
24865
  } from "@7365admin1/node-server-utils";
24737
24866
  import { ObjectId as ObjectId65 } from "mongodb";
24738
24867
  function usePatrolQuestionRepo() {
@@ -24742,7 +24871,7 @@ function usePatrolQuestionRepo() {
24742
24871
  }
24743
24872
  const namespace_collection = "patrol.questions";
24744
24873
  const collection = db.collection(namespace_collection);
24745
- const { delNamespace, getCache, setCache } = useCache35(namespace_collection);
24874
+ const { delNamespace, getCache, setCache } = useCache34(namespace_collection);
24746
24875
  async function createIndexes() {
24747
24876
  try {
24748
24877
  await collection.createIndexes([
@@ -24828,7 +24957,7 @@ function usePatrolQuestionRepo() {
24828
24957
  ...search && { search },
24829
24958
  ...query.site && { site: query.site.toString() }
24830
24959
  };
24831
- const cacheKey = makeCacheKey33(namespace_collection, cacheOptions);
24960
+ const cacheKey = makeCacheKey32(namespace_collection, cacheOptions);
24832
24961
  const cachedData = await getCache(cacheKey);
24833
24962
  if (cachedData) {
24834
24963
  logger88.info(`Cache hit for key: ${cacheKey}`);
@@ -24904,7 +25033,7 @@ function usePatrolQuestionRepo() {
24904
25033
  } catch (error) {
24905
25034
  throw new BadRequestError108("Invalid patrol question ID format.");
24906
25035
  }
24907
- const cacheKey = makeCacheKey33(namespace_collection, { _id });
25036
+ const cacheKey = makeCacheKey32(namespace_collection, { _id });
24908
25037
  const cachedData = await getCache(cacheKey);
24909
25038
  if (cachedData) {
24910
25039
  logger88.info(`Cache hit for key: ${cacheKey}`);
@@ -25180,10 +25309,10 @@ import {
25180
25309
  BadRequestError as BadRequestError111,
25181
25310
  InternalServerError as InternalServerError36,
25182
25311
  logger as logger91,
25183
- makeCacheKey as makeCacheKey34,
25312
+ makeCacheKey as makeCacheKey33,
25184
25313
  paginate as paginate28,
25185
25314
  useAtlas as useAtlas55,
25186
- useCache as useCache36
25315
+ useCache as useCache35
25187
25316
  } from "@7365admin1/node-server-utils";
25188
25317
  import { ObjectId as ObjectId67 } from "mongodb";
25189
25318
  function usePatrolRouteRepo() {
@@ -25193,7 +25322,7 @@ function usePatrolRouteRepo() {
25193
25322
  }
25194
25323
  const namespace_collection = "patrol.route";
25195
25324
  const collection = db.collection(namespace_collection);
25196
- const { delNamespace, getCache, setCache } = useCache36(namespace_collection);
25325
+ const { delNamespace, getCache, setCache } = useCache35(namespace_collection);
25197
25326
  async function createTextIndex() {
25198
25327
  try {
25199
25328
  await collection.createIndex({
@@ -25254,7 +25383,7 @@ function usePatrolRouteRepo() {
25254
25383
  ...search && { search },
25255
25384
  ...query.site && { site: query.site.toString() }
25256
25385
  };
25257
- const cacheKey = makeCacheKey34(namespace_collection, cacheOptions);
25386
+ const cacheKey = makeCacheKey33(namespace_collection, cacheOptions);
25258
25387
  const cachedData = await getCache(cacheKey);
25259
25388
  if (cachedData) {
25260
25389
  logger91.info(`Cache hit for key: ${cacheKey}`);
@@ -25475,7 +25604,7 @@ function usePatrolRouteRepo() {
25475
25604
  ...day && { day },
25476
25605
  ...start && { start }
25477
25606
  };
25478
- const cacheKey = makeCacheKey34(namespace_collection, cacheOptions);
25607
+ const cacheKey = makeCacheKey33(namespace_collection, cacheOptions);
25479
25608
  const cachedData = await getCache(cacheKey);
25480
25609
  if (cachedData) {
25481
25610
  logger91.info(`Cache hit for key: ${cacheKey}`);
@@ -25542,7 +25671,7 @@ function usePatrolRouteRepo() {
25542
25671
  } catch (error) {
25543
25672
  throw new BadRequestError111("Invalid patrol log ID format.");
25544
25673
  }
25545
- const cacheKey = makeCacheKey34(namespace_collection, { _id });
25674
+ const cacheKey = makeCacheKey33(namespace_collection, { _id });
25546
25675
  const cachedData = await getCache(cacheKey);
25547
25676
  if (cachedData) {
25548
25677
  logger91.info(`Cache hit for key: ${cacheKey}`);
@@ -25897,10 +26026,10 @@ import {
25897
26026
  BadRequestError as BadRequestError114,
25898
26027
  InternalServerError as InternalServerError37,
25899
26028
  logger as logger94,
25900
- makeCacheKey as makeCacheKey35,
26029
+ makeCacheKey as makeCacheKey34,
25901
26030
  paginate as paginate29,
25902
26031
  useAtlas as useAtlas56,
25903
- useCache as useCache37
26032
+ useCache as useCache36
25904
26033
  } from "@7365admin1/node-server-utils";
25905
26034
  import { ObjectId as ObjectId69 } from "mongodb";
25906
26035
  function usePatrolLogRepo() {
@@ -25910,7 +26039,7 @@ function usePatrolLogRepo() {
25910
26039
  }
25911
26040
  const namespace_collection = "patrol.logs";
25912
26041
  const collection = db.collection(namespace_collection);
25913
- const { delNamespace, getCache, setCache } = useCache37(namespace_collection);
26042
+ const { delNamespace, getCache, setCache } = useCache36(namespace_collection);
25914
26043
  async function createIndexes() {
25915
26044
  try {
25916
26045
  await collection.createIndexes([
@@ -26007,7 +26136,7 @@ function usePatrolLogRepo() {
26007
26136
  ...query.site && { site: query.site.toString() },
26008
26137
  ...dateFrom && { dateFrom: dateFrom.toString() }
26009
26138
  };
26010
- const cacheKey = makeCacheKey35(namespace_collection, cacheOptions);
26139
+ const cacheKey = makeCacheKey34(namespace_collection, cacheOptions);
26011
26140
  const cachedData = await getCache(cacheKey);
26012
26141
  if (cachedData) {
26013
26142
  logger94.info(`Cache hit for key: ${cacheKey}`);
@@ -26171,7 +26300,7 @@ function usePatrolLogRepo() {
26171
26300
  } catch (error) {
26172
26301
  throw new BadRequestError114("Invalid patrol log ID format.");
26173
26302
  }
26174
- const cacheKey = makeCacheKey35(namespace_collection, { _id });
26303
+ const cacheKey = makeCacheKey34(namespace_collection, { _id });
26175
26304
  const cachedData = await getCache(cacheKey);
26176
26305
  if (cachedData) {
26177
26306
  logger94.info(`Cache hit for key: ${cacheKey}`);
@@ -26687,11 +26816,11 @@ import {
26687
26816
  BadRequestError as BadRequestError117,
26688
26817
  InternalServerError as InternalServerError38,
26689
26818
  logger as logger97,
26690
- makeCacheKey as makeCacheKey36,
26819
+ makeCacheKey as makeCacheKey35,
26691
26820
  NotFoundError as NotFoundError25,
26692
26821
  paginate as paginate30,
26693
26822
  useAtlas as useAtlas58,
26694
- useCache as useCache38
26823
+ useCache as useCache37
26695
26824
  } from "@7365admin1/node-server-utils";
26696
26825
  import { ObjectId as ObjectId71 } from "mongodb";
26697
26826
  function useSiteFacilityRepo() {
@@ -26701,7 +26830,7 @@ function useSiteFacilityRepo() {
26701
26830
  }
26702
26831
  const namespace_collection = "site.facilities";
26703
26832
  const collection = db.collection(namespace_collection);
26704
- const { delNamespace, getCache, setCache } = useCache38(namespace_collection);
26833
+ const { delNamespace, getCache, setCache } = useCache37(namespace_collection);
26705
26834
  async function createTextIndex() {
26706
26835
  try {
26707
26836
  await collection.createIndex({
@@ -26776,7 +26905,7 @@ function useSiteFacilityRepo() {
26776
26905
  query.$text = { $search: search };
26777
26906
  cacheOptions.search = search;
26778
26907
  }
26779
- const cacheKey = makeCacheKey36(namespace_collection, cacheOptions);
26908
+ const cacheKey = makeCacheKey35(namespace_collection, cacheOptions);
26780
26909
  const cachedData = await getCache(cacheKey);
26781
26910
  if (cachedData) {
26782
26911
  logger97.info(`Cache hit for key: ${cacheKey}`);
@@ -26810,7 +26939,7 @@ function useSiteFacilityRepo() {
26810
26939
  } catch (error) {
26811
26940
  throw new BadRequestError117("Invalid site facility ID format.");
26812
26941
  }
26813
- const cacheKey = makeCacheKey36(namespace_collection, { _id });
26942
+ const cacheKey = makeCacheKey35(namespace_collection, { _id });
26814
26943
  const cachedData = await getCache(cacheKey);
26815
26944
  if (cachedData) {
26816
26945
  logger97.info(`Cache hit for key: ${cacheKey}`);
@@ -26935,7 +27064,7 @@ function useSiteFacilityRepo() {
26935
27064
  _id,
26936
27065
  site
26937
27066
  };
26938
- const cacheKey = makeCacheKey36(namespace_collection, query);
27067
+ const cacheKey = makeCacheKey35(namespace_collection, query);
26939
27068
  const cachedData = await getCache(cacheKey);
26940
27069
  if (cachedData) {
26941
27070
  logger97.info(`Cache hit for key: ${cacheKey}`);
@@ -27345,11 +27474,11 @@ import {
27345
27474
  BadRequestError as BadRequestError119,
27346
27475
  InternalServerError as InternalServerError39,
27347
27476
  logger as logger99,
27348
- makeCacheKey as makeCacheKey37,
27477
+ makeCacheKey as makeCacheKey36,
27349
27478
  NotFoundError as NotFoundError26,
27350
27479
  paginate as paginate31,
27351
27480
  useAtlas as useAtlas60,
27352
- useCache as useCache39
27481
+ useCache as useCache38
27353
27482
  } from "@7365admin1/node-server-utils";
27354
27483
  import { ObjectId as ObjectId73 } from "mongodb";
27355
27484
  function useServiceProviderBillingRepo() {
@@ -27359,7 +27488,7 @@ function useServiceProviderBillingRepo() {
27359
27488
  }
27360
27489
  const namespace_collection = "site.service-provider.billing";
27361
27490
  const collection = db.collection(namespace_collection);
27362
- const { delNamespace, getCache, setCache } = useCache39(namespace_collection);
27491
+ const { delNamespace, getCache, setCache } = useCache38(namespace_collection);
27363
27492
  async function createIndexes() {
27364
27493
  try {
27365
27494
  await collection.createIndexes([{ key: { orgId: 1, status: 1 } }]);
@@ -27418,7 +27547,7 @@ function useServiceProviderBillingRepo() {
27418
27547
  query.$text = { $search: search };
27419
27548
  cacheOptions.search = search;
27420
27549
  }
27421
- const cacheKey = makeCacheKey37(namespace_collection, cacheOptions);
27550
+ const cacheKey = makeCacheKey36(namespace_collection, cacheOptions);
27422
27551
  const cachedData = await getCache(cacheKey);
27423
27552
  if (cachedData) {
27424
27553
  logger99.info(`Cache hit for key: ${cacheKey}`);
@@ -27452,7 +27581,7 @@ function useServiceProviderBillingRepo() {
27452
27581
  } catch (error) {
27453
27582
  throw new BadRequestError119("Invalid service provider billing ID format.");
27454
27583
  }
27455
- const cacheKey = makeCacheKey37(namespace_collection, { _id });
27584
+ const cacheKey = makeCacheKey36(namespace_collection, { _id });
27456
27585
  const cachedData = await getCache(cacheKey);
27457
27586
  if (cachedData) {
27458
27587
  logger99.info(`Cache hit for key: ${cacheKey}`);
@@ -27996,12 +28125,12 @@ import {
27996
28125
  BadRequestError as BadRequestError121,
27997
28126
  InternalServerError as InternalServerError40,
27998
28127
  logger as logger101,
27999
- makeCacheKey as makeCacheKey38,
28128
+ makeCacheKey as makeCacheKey37,
28000
28129
  NotFoundError as NotFoundError27,
28001
28130
  paginate as paginate32,
28002
28131
  toObjectId as toObjectId13,
28003
28132
  useAtlas as useAtlas62,
28004
- useCache as useCache40
28133
+ useCache as useCache39
28005
28134
  } from "@7365admin1/node-server-utils";
28006
28135
  import { ObjectId as ObjectId75 } from "mongodb";
28007
28136
  var facility_bookings_namespace_collection = "site.facilty-booking";
@@ -28011,7 +28140,7 @@ function useSiteFacilityBookingRepo() {
28011
28140
  throw new InternalServerError40("Unable to connect to server.");
28012
28141
  }
28013
28142
  const collection = db.collection(facility_bookings_namespace_collection);
28014
- const { delNamespace, getCache, setCache } = useCache40(
28143
+ const { delNamespace, getCache, setCache } = useCache39(
28015
28144
  facility_bookings_namespace_collection
28016
28145
  );
28017
28146
  async function createIndexes() {
@@ -28069,7 +28198,7 @@ function useSiteFacilityBookingRepo() {
28069
28198
  limit,
28070
28199
  ...search && { search }
28071
28200
  };
28072
- const cacheKey = makeCacheKey38(
28201
+ const cacheKey = makeCacheKey37(
28073
28202
  facility_bookings_namespace_collection,
28074
28203
  cacheOptions
28075
28204
  );
@@ -28102,7 +28231,7 @@ function useSiteFacilityBookingRepo() {
28102
28231
  }
28103
28232
  async function getSiteFacilityBookingById(id, session) {
28104
28233
  const _id = toObjectId13(id);
28105
- const cacheKey = makeCacheKey38(facility_bookings_namespace_collection, {
28234
+ const cacheKey = makeCacheKey37(facility_bookings_namespace_collection, {
28106
28235
  id
28107
28236
  });
28108
28237
  const cachedData = await getCache(cacheKey);
@@ -28475,11 +28604,11 @@ import {
28475
28604
  BadRequestError as BadRequestError123,
28476
28605
  InternalServerError as InternalServerError41,
28477
28606
  logger as logger103,
28478
- makeCacheKey as makeCacheKey39,
28607
+ makeCacheKey as makeCacheKey38,
28479
28608
  NotFoundError as NotFoundError28,
28480
28609
  paginate as paginate33,
28481
28610
  useAtlas as useAtlas64,
28482
- useCache as useCache41
28611
+ useCache as useCache40
28483
28612
  } from "@7365admin1/node-server-utils";
28484
28613
  import { ObjectId as ObjectId77 } from "mongodb";
28485
28614
  function useDocumentManagementRepo() {
@@ -28489,7 +28618,7 @@ function useDocumentManagementRepo() {
28489
28618
  }
28490
28619
  const namespace_collection = "documents";
28491
28620
  const collection = db.collection(namespace_collection);
28492
- const { delNamespace, getCache, setCache } = useCache41(namespace_collection);
28621
+ const { delNamespace, getCache, setCache } = useCache40(namespace_collection);
28493
28622
  async function createTextIndex() {
28494
28623
  try {
28495
28624
  await collection.createIndex({
@@ -28558,7 +28687,7 @@ function useDocumentManagementRepo() {
28558
28687
  ];
28559
28688
  cacheOptions.search = search;
28560
28689
  }
28561
- const cacheKey = makeCacheKey39(namespace_collection, cacheOptions);
28690
+ const cacheKey = makeCacheKey38(namespace_collection, cacheOptions);
28562
28691
  const cachedData = await getCache(cacheKey);
28563
28692
  if (cachedData) {
28564
28693
  logger103.info(`Cache hit for key: ${cacheKey}`);
@@ -28599,7 +28728,7 @@ function useDocumentManagementRepo() {
28599
28728
  } catch (error) {
28600
28729
  throw new BadRequestError123("Invalid document ID format.");
28601
28730
  }
28602
- const cacheKey = makeCacheKey39(namespace_collection, { _id });
28731
+ const cacheKey = makeCacheKey38(namespace_collection, { _id });
28603
28732
  const cachedData = await getCache(cacheKey);
28604
28733
  if (cachedData) {
28605
28734
  logger103.info(`Cache hit for key: ${cacheKey}`);
@@ -28716,7 +28845,7 @@ function useDocumentManagementRepo() {
28716
28845
  } catch (error) {
28717
28846
  throw new BadRequestError123("Invalid document management site ID format.");
28718
28847
  }
28719
- const cacheKey = makeCacheKey39(namespace_collection, { site });
28848
+ const cacheKey = makeCacheKey38(namespace_collection, { site });
28720
28849
  const cachedData = await getCache(cacheKey);
28721
28850
  if (cachedData) {
28722
28851
  logger103.info(`Cache hit for key: ${cacheKey}`);
@@ -29140,11 +29269,11 @@ import {
29140
29269
  BadRequestError as BadRequestError126,
29141
29270
  InternalServerError as InternalServerError42,
29142
29271
  logger as logger105,
29143
- makeCacheKey as makeCacheKey40,
29272
+ makeCacheKey as makeCacheKey39,
29144
29273
  NotFoundError as NotFoundError30,
29145
29274
  paginate as paginate34,
29146
29275
  useAtlas as useAtlas66,
29147
- useCache as useCache42
29276
+ useCache as useCache41
29148
29277
  } from "@7365admin1/node-server-utils";
29149
29278
  import { ObjectId as ObjectId79 } from "mongodb";
29150
29279
  var bulletin_boards_namespace_collection = "bulletin-boards";
@@ -29154,7 +29283,7 @@ function useBulletinBoardRepo() {
29154
29283
  throw new InternalServerError42("Unable to connect to server.");
29155
29284
  }
29156
29285
  const collection = db.collection(bulletin_boards_namespace_collection);
29157
- const { delNamespace, getCache, setCache } = useCache42(
29286
+ const { delNamespace, getCache, setCache } = useCache41(
29158
29287
  bulletin_boards_namespace_collection
29159
29288
  );
29160
29289
  async function createIndexes() {
@@ -29218,7 +29347,7 @@ function useBulletinBoardRepo() {
29218
29347
  ...search && { search },
29219
29348
  ...recipients?.length && { recipients: recipients.sort().join(",") }
29220
29349
  };
29221
- const cacheKey = makeCacheKey40(
29350
+ const cacheKey = makeCacheKey39(
29222
29351
  bulletin_boards_namespace_collection,
29223
29352
  cacheOptions
29224
29353
  );
@@ -29255,7 +29384,7 @@ function useBulletinBoardRepo() {
29255
29384
  } catch (error) {
29256
29385
  throw new BadRequestError126("Invalid bulletin board ID format.");
29257
29386
  }
29258
- const cacheKey = makeCacheKey40(bulletin_boards_namespace_collection, {
29387
+ const cacheKey = makeCacheKey39(bulletin_boards_namespace_collection, {
29259
29388
  _id
29260
29389
  });
29261
29390
  const cachedData = await getCache(cacheKey);
@@ -29516,7 +29645,7 @@ function useBulletinBoardController() {
29516
29645
  page: Joi76.number().integer().min(1).allow("", null).default(1),
29517
29646
  limit: Joi76.number().integer().min(1).max(100).allow("", null).default(10),
29518
29647
  sort: Joi76.string().valid(...Object.values(BulletinSort)).default("_id" /* ID */),
29519
- order: Joi76.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */),
29648
+ order: Joi76.string().valid(...Object.values(SortOrder)).default("desc" /* DESC */),
29520
29649
  site: Joi76.string().hex().length(24).required(),
29521
29650
  status: Joi76.string().valid(...Object.values(BuildingStatus)).optional().default("active" /* ACTIVE */),
29522
29651
  recipients: Joi76.alternatives().try(
@@ -29786,9 +29915,9 @@ import {
29786
29915
  InternalServerError as InternalServerError43,
29787
29916
  logger as logger108,
29788
29917
  useAtlas as useAtlas68,
29789
- useCache as useCache43,
29918
+ useCache as useCache42,
29790
29919
  paginate as paginate35,
29791
- makeCacheKey as makeCacheKey41
29920
+ makeCacheKey as makeCacheKey40
29792
29921
  } from "@7365admin1/node-server-utils";
29793
29922
  import { ObjectId as ObjectId81 } from "mongodb";
29794
29923
  function useSiteBillingItemRepo() {
@@ -29798,7 +29927,7 @@ function useSiteBillingItemRepo() {
29798
29927
  }
29799
29928
  const namespace_collection = "site.billing.items";
29800
29929
  const collection = db.collection(namespace_collection);
29801
- const { delNamespace, setCache, getCache } = useCache43(namespace_collection);
29930
+ const { delNamespace, setCache, getCache } = useCache42(namespace_collection);
29802
29931
  async function createTextIndex() {
29803
29932
  try {
29804
29933
  await collection.createIndex({
@@ -29874,7 +30003,7 @@ function useSiteBillingItemRepo() {
29874
30003
  ...search && { search },
29875
30004
  ...query.site && { site: query.site.toString() }
29876
30005
  };
29877
- const cacheKey = makeCacheKey41(namespace_collection, cacheOptions);
30006
+ const cacheKey = makeCacheKey40(namespace_collection, cacheOptions);
29878
30007
  const cachedData = await getCache(cacheKey);
29879
30008
  if (cachedData) {
29880
30009
  logger108.info(`Cache hit for key: ${cacheKey}`);
@@ -29907,7 +30036,7 @@ function useSiteBillingItemRepo() {
29907
30036
  } catch (error) {
29908
30037
  throw new BadRequestError129("Invalid ID.");
29909
30038
  }
29910
- const cacheKey = makeCacheKey41(namespace_collection, { _id: String(_id) });
30039
+ const cacheKey = makeCacheKey40(namespace_collection, { _id: String(_id) });
29911
30040
  try {
29912
30041
  const cached = await getCache(cacheKey);
29913
30042
  if (cached) {
@@ -30039,9 +30168,9 @@ import {
30039
30168
  InternalServerError as InternalServerError44,
30040
30169
  logger as logger110,
30041
30170
  useAtlas as useAtlas69,
30042
- useCache as useCache44,
30171
+ useCache as useCache43,
30043
30172
  paginate as paginate36,
30044
- makeCacheKey as makeCacheKey42
30173
+ makeCacheKey as makeCacheKey41
30045
30174
  } from "@7365admin1/node-server-utils";
30046
30175
 
30047
30176
  // src/models/site-billing-configuration.model.ts
@@ -30171,7 +30300,7 @@ function useSiteBillingConfigurationRepo() {
30171
30300
  }
30172
30301
  const namespace_collection = "site.billing.configuration";
30173
30302
  const collection = db.collection(namespace_collection);
30174
- const { delNamespace, setCache, getCache } = useCache44(namespace_collection);
30303
+ const { delNamespace, setCache, getCache } = useCache43(namespace_collection);
30175
30304
  async function createTextIndex() {
30176
30305
  try {
30177
30306
  await collection.createIndex({
@@ -30233,7 +30362,7 @@ function useSiteBillingConfigurationRepo() {
30233
30362
  ...search && { search },
30234
30363
  ...query.site && { site: query.site.toString() }
30235
30364
  };
30236
- const cacheKey = makeCacheKey42(namespace_collection, cacheOptions);
30365
+ const cacheKey = makeCacheKey41(namespace_collection, cacheOptions);
30237
30366
  const cachedData = await getCache(cacheKey);
30238
30367
  if (cachedData) {
30239
30368
  logger110.info(`Cache hit for key: ${cacheKey}`);
@@ -30266,7 +30395,7 @@ function useSiteBillingConfigurationRepo() {
30266
30395
  } catch (error) {
30267
30396
  throw new BadRequestError131("Invalid ID.");
30268
30397
  }
30269
- const cacheKey = makeCacheKey42(namespace_collection, { _id: String(_id) });
30398
+ const cacheKey = makeCacheKey41(namespace_collection, { _id: String(_id) });
30270
30399
  try {
30271
30400
  const cached = await getCache(cacheKey);
30272
30401
  if (cached) {
@@ -30972,11 +31101,11 @@ import {
30972
31101
  BadRequestError as BadRequestError136,
30973
31102
  InternalServerError as InternalServerError45,
30974
31103
  logger as logger115,
30975
- makeCacheKey as makeCacheKey43,
31104
+ makeCacheKey as makeCacheKey42,
30976
31105
  NotFoundError as NotFoundError33,
30977
31106
  paginate as paginate37,
30978
31107
  useAtlas as useAtlas72,
30979
- useCache as useCache45
31108
+ useCache as useCache44
30980
31109
  } from "@7365admin1/node-server-utils";
30981
31110
  import { ObjectId as ObjectId85 } from "mongodb";
30982
31111
  var events_namespace_collection = "event-management";
@@ -30986,7 +31115,7 @@ function useEventManagementRepo() {
30986
31115
  throw new InternalServerError45("Unable to connect to server.");
30987
31116
  }
30988
31117
  const collection = db.collection(events_namespace_collection);
30989
- const { delNamespace, getCache, setCache } = useCache45(
31118
+ const { delNamespace, getCache, setCache } = useCache44(
30990
31119
  events_namespace_collection
30991
31120
  );
30992
31121
  async function createIndexes() {
@@ -31074,7 +31203,7 @@ function useEventManagementRepo() {
31074
31203
  query.$text = { $search: search };
31075
31204
  cacheOptions.search = search;
31076
31205
  }
31077
- const cacheKey = makeCacheKey43(events_namespace_collection, cacheOptions);
31206
+ const cacheKey = makeCacheKey42(events_namespace_collection, cacheOptions);
31078
31207
  const cachedData = await getCache(cacheKey);
31079
31208
  if (cachedData) {
31080
31209
  logger115.info(`Cache hit for key: ${cacheKey}`);
@@ -31126,7 +31255,7 @@ function useEventManagementRepo() {
31126
31255
  } catch (error) {
31127
31256
  throw new BadRequestError136("Invalid event ID format.");
31128
31257
  }
31129
- const cacheKey = makeCacheKey43(events_namespace_collection, { _id });
31258
+ const cacheKey = makeCacheKey42(events_namespace_collection, { _id });
31130
31259
  const cachedData = await getCache(cacheKey);
31131
31260
  if (cachedData) {
31132
31261
  logger115.info(`Cache hit for key: ${cacheKey}`);
@@ -31658,9 +31787,9 @@ import {
31658
31787
  InternalServerError as InternalServerError46,
31659
31788
  logger as logger118,
31660
31789
  useAtlas as useAtlas74,
31661
- useCache as useCache46,
31790
+ useCache as useCache45,
31662
31791
  paginate as paginate38,
31663
- makeCacheKey as makeCacheKey44
31792
+ makeCacheKey as makeCacheKey43
31664
31793
  } from "@7365admin1/node-server-utils";
31665
31794
  import { ObjectId as ObjectId87 } from "mongodb";
31666
31795
  function useSiteUnitBillingRepo() {
@@ -31670,7 +31799,7 @@ function useSiteUnitBillingRepo() {
31670
31799
  }
31671
31800
  const namespace_collection = "site.unit.billing";
31672
31801
  const collection = db.collection(namespace_collection);
31673
- const { delNamespace, setCache, getCache } = useCache46(namespace_collection);
31802
+ const { delNamespace, setCache, getCache } = useCache45(namespace_collection);
31674
31803
  async function createTextIndex() {
31675
31804
  try {
31676
31805
  await collection.createIndex({
@@ -31786,7 +31915,7 @@ function useSiteUnitBillingRepo() {
31786
31915
  ...dateFrom && { dateFrom },
31787
31916
  ...dateTo && { dateTo }
31788
31917
  };
31789
- const cacheKey = makeCacheKey44(namespace_collection, cacheOptions);
31918
+ const cacheKey = makeCacheKey43(namespace_collection, cacheOptions);
31790
31919
  const cachedData = await getCache(cacheKey);
31791
31920
  if (cachedData) {
31792
31921
  logger118.info(`Cache hit for key: ${cacheKey}`);
@@ -31841,7 +31970,7 @@ function useSiteUnitBillingRepo() {
31841
31970
  } catch (error) {
31842
31971
  throw new BadRequestError139("Invalid ID.");
31843
31972
  }
31844
- const cacheKey = makeCacheKey44(namespace_collection, { _id: String(_id) });
31973
+ const cacheKey = makeCacheKey43(namespace_collection, { _id: String(_id) });
31845
31974
  try {
31846
31975
  const cached = await getCache(cacheKey);
31847
31976
  if (cached) {
@@ -32890,7 +33019,11 @@ var formatEntryPassDate = (date) => {
32890
33019
  const day = String(newDate.getDate()).padStart(2, "0");
32891
33020
  return `${year}${month}${day}`;
32892
33021
  };
32893
- async function removeAccessGroup({ cardNo, staffNo, url }) {
33022
+ async function removeAccessGroup({
33023
+ cardNo,
33024
+ staffNo,
33025
+ url
33026
+ }) {
32894
33027
  try {
32895
33028
  const commands = readTemplate("delete-qr-card", {
32896
33029
  staffNo,
@@ -32911,8 +33044,6 @@ async function removeAccessGroup({ cardNo, staffNo, url }) {
32911
33044
  });
32912
33045
  const response = await sendCommand(commands, url);
32913
33046
  const result = await parseStringPromise(response, { explicitArray: false });
32914
- console.log(result.RESULT.$.STCODE);
32915
- console.log(commands);
32916
33047
  if (result && result.RESULT.$.STCODE !== "0") {
32917
33048
  throw new Error("Command failed, server error.");
32918
33049
  }
@@ -36203,10 +36334,10 @@ import {
36203
36334
  BadRequestError as BadRequestError144,
36204
36335
  InternalServerError as InternalServerError48,
36205
36336
  logger as logger122,
36206
- makeCacheKey as makeCacheKey46,
36337
+ makeCacheKey as makeCacheKey45,
36207
36338
  paginate as paginate40,
36208
36339
  useAtlas as useAtlas77,
36209
- useCache as useCache48
36340
+ useCache as useCache47
36210
36341
  } from "@7365admin1/node-server-utils";
36211
36342
  import { ObjectId as ObjectId92 } from "mongodb";
36212
36343
  function useNfcPatrolTagRepo() {
@@ -36217,8 +36348,8 @@ function useNfcPatrolTagRepo() {
36217
36348
  const namespace_collection = "nfc-patrol-tags";
36218
36349
  const namespace_collection_nfc_patrol_routes = "nfc-patrol-routes";
36219
36350
  const collection = db.collection(namespace_collection);
36220
- const { delNamespace, getCache, setCache } = useCache48(namespace_collection);
36221
- const { delNamespace: delNamespaceNfcPatrolRoutes } = useCache48(
36351
+ const { delNamespace, getCache, setCache } = useCache47(namespace_collection);
36352
+ const { delNamespace: delNamespaceNfcPatrolRoutes } = useCache47(
36222
36353
  namespace_collection_nfc_patrol_routes
36223
36354
  );
36224
36355
  async function createIndexes() {
@@ -36274,7 +36405,7 @@ function useNfcPatrolTagRepo() {
36274
36405
  page,
36275
36406
  limit
36276
36407
  };
36277
- const cacheKey = makeCacheKey46(namespace_collection, cacheOptions);
36408
+ const cacheKey = makeCacheKey45(namespace_collection, cacheOptions);
36278
36409
  const cachedData = await getCache(cacheKey);
36279
36410
  if (cachedData) {
36280
36411
  logger122.info(`Cache hit for key: ${cacheKey}`);
@@ -36666,12 +36797,12 @@ import {
36666
36797
  BadRequestError as BadRequestError147,
36667
36798
  InternalServerError as InternalServerError49,
36668
36799
  logger as logger124,
36669
- makeCacheKey as makeCacheKey47,
36800
+ makeCacheKey as makeCacheKey46,
36670
36801
  NotFoundError as NotFoundError37,
36671
36802
  paginate as paginate41,
36672
36803
  toObjectId as toObjectId14,
36673
36804
  useAtlas as useAtlas79,
36674
- useCache as useCache49
36805
+ useCache as useCache48
36675
36806
  } from "@7365admin1/node-server-utils";
36676
36807
  import { ObjectId as ObjectId94 } from "mongodb";
36677
36808
  var occurrence_book_namespace_collection = "occurrence-books";
@@ -36708,7 +36839,7 @@ function useOccurrenceBookRepo() {
36708
36839
  }
36709
36840
  }
36710
36841
  const collection = db.collection(occurrence_book_namespace_collection);
36711
- const { delNamespace, getCache, setCache } = useCache49(
36842
+ const { delNamespace, getCache, setCache } = useCache48(
36712
36843
  occurrence_book_namespace_collection
36713
36844
  );
36714
36845
  async function add(value, session) {
@@ -36784,7 +36915,7 @@ function useOccurrenceBookRepo() {
36784
36915
  $lt: endDateISO
36785
36916
  };
36786
36917
  }
36787
- const cacheKey = makeCacheKey47(
36918
+ const cacheKey = makeCacheKey46(
36788
36919
  occurrence_book_namespace_collection,
36789
36920
  cacheOptions
36790
36921
  );
@@ -36821,7 +36952,7 @@ function useOccurrenceBookRepo() {
36821
36952
  } catch (error) {
36822
36953
  throw new BadRequestError147("Invalid occurrence book ID format.");
36823
36954
  }
36824
- const cacheKey = makeCacheKey47(occurrence_book_namespace_collection, {
36955
+ const cacheKey = makeCacheKey46(occurrence_book_namespace_collection, {
36825
36956
  _id
36826
36957
  });
36827
36958
  const cachedData = await getCache(cacheKey);
@@ -37317,11 +37448,11 @@ import {
37317
37448
  BadRequestError as BadRequestError149,
37318
37449
  InternalServerError as InternalServerError50,
37319
37450
  logger as logger126,
37320
- makeCacheKey as makeCacheKey48,
37451
+ makeCacheKey as makeCacheKey47,
37321
37452
  NotFoundError as NotFoundError38,
37322
37453
  paginate as paginate42,
37323
37454
  useAtlas as useAtlas81,
37324
- useCache as useCache50
37455
+ useCache as useCache49
37325
37456
  } from "@7365admin1/node-server-utils";
37326
37457
  import { ObjectId as ObjectId96 } from "mongodb";
37327
37458
  function useBulletinVideoRepo() {
@@ -37340,7 +37471,7 @@ function useBulletinVideoRepo() {
37340
37471
  }
37341
37472
  const namespace_collection = "bulletin-videos";
37342
37473
  const collection = db.collection(namespace_collection);
37343
- const { delNamespace, getCache, setCache } = useCache50(namespace_collection);
37474
+ const { delNamespace, getCache, setCache } = useCache49(namespace_collection);
37344
37475
  async function add(value, session) {
37345
37476
  try {
37346
37477
  value = MBulletinVideo(value);
@@ -37391,7 +37522,7 @@ function useBulletinVideoRepo() {
37391
37522
  query.$text = { $search: search };
37392
37523
  cacheOptions.search = search;
37393
37524
  }
37394
- const cacheKey = makeCacheKey48(namespace_collection, cacheOptions);
37525
+ const cacheKey = makeCacheKey47(namespace_collection, cacheOptions);
37395
37526
  const cachedData = await getCache(cacheKey);
37396
37527
  if (cachedData) {
37397
37528
  logger126.info(`Cache hit for key: ${cacheKey}`);
@@ -37425,7 +37556,7 @@ function useBulletinVideoRepo() {
37425
37556
  } catch (error) {
37426
37557
  throw new BadRequestError149("Invalid bulletin video ID format.");
37427
37558
  }
37428
- const cacheKey = makeCacheKey48(namespace_collection, { _id });
37559
+ const cacheKey = makeCacheKey47(namespace_collection, { _id });
37429
37560
  const cachedData = await getCache(cacheKey);
37430
37561
  if (cachedData) {
37431
37562
  logger126.info(`Cache hit for key: ${cacheKey}`);
@@ -37879,9 +38010,9 @@ import {
37879
38010
  InternalServerError as InternalServerError51,
37880
38011
  logger as logger129,
37881
38012
  useAtlas as useAtlas83,
37882
- useCache as useCache51,
38013
+ useCache as useCache50,
37883
38014
  paginate as paginate43,
37884
- makeCacheKey as makeCacheKey49
38015
+ makeCacheKey as makeCacheKey48
37885
38016
  } from "@7365admin1/node-server-utils";
37886
38017
  import { ObjectId as ObjectId98 } from "mongodb";
37887
38018
  function useStatementOfAccountRepo() {
@@ -37891,7 +38022,7 @@ function useStatementOfAccountRepo() {
37891
38022
  }
37892
38023
  const namespace_collection = "site.statement-of-accounts";
37893
38024
  const collection = db.collection(namespace_collection);
37894
- const { delNamespace, getCache, setCache } = useCache51(namespace_collection);
38025
+ const { delNamespace, getCache, setCache } = useCache50(namespace_collection);
37895
38026
  async function createTextIndex() {
37896
38027
  try {
37897
38028
  await collection.createIndex({
@@ -37979,7 +38110,7 @@ function useStatementOfAccountRepo() {
37979
38110
  ...dateFrom && { dateFrom: dateFrom.toString() },
37980
38111
  ...dateTo && { dateTo: dateTo.toString() }
37981
38112
  };
37982
- const cacheKey = makeCacheKey49(namespace_collection, cacheOptions);
38113
+ const cacheKey = makeCacheKey48(namespace_collection, cacheOptions);
37983
38114
  const cachedData = await getCache(cacheKey);
37984
38115
  if (cachedData) {
37985
38116
  logger129.info(`Cache hit for key: ${cacheKey}`);
@@ -38024,7 +38155,7 @@ function useStatementOfAccountRepo() {
38024
38155
  } catch (error) {
38025
38156
  throw new BadRequestError152("Invalid ID.");
38026
38157
  }
38027
- const cacheKey = makeCacheKey49(namespace_collection, { _id: String(_id) });
38158
+ const cacheKey = makeCacheKey48(namespace_collection, { _id: String(_id) });
38028
38159
  try {
38029
38160
  const cached = await getCache(cacheKey);
38030
38161
  if (cached) {
@@ -38665,7 +38796,6 @@ function useStatementOfAccountController() {
38665
38796
  try {
38666
38797
  const _id = req.params.id;
38667
38798
  const status = req.params.status;
38668
- console.log(_id, status);
38669
38799
  const result = await _updateStatusById(_id, { status });
38670
38800
  res.status(200).json({ message: result });
38671
38801
  return;
@@ -38870,11 +39000,11 @@ import {
38870
39000
  BadRequestError as BadRequestError156,
38871
39001
  InternalServerError as InternalServerError52,
38872
39002
  logger as logger133,
38873
- makeCacheKey as makeCacheKey50,
39003
+ makeCacheKey as makeCacheKey49,
38874
39004
  NotFoundError as NotFoundError40,
38875
39005
  paginate as paginate44,
38876
39006
  useAtlas as useAtlas85,
38877
- useCache as useCache52
39007
+ useCache as useCache51
38878
39008
  } from "@7365admin1/node-server-utils";
38879
39009
  import { ObjectId as ObjectId101 } from "mongodb";
38880
39010
  function useEntryPassSettingsRepo() {
@@ -38884,7 +39014,7 @@ function useEntryPassSettingsRepo() {
38884
39014
  }
38885
39015
  const namespace_collection = "site.entrypass-settings";
38886
39016
  const collection = db.collection(namespace_collection);
38887
- const { delNamespace, getCache, setCache } = useCache52(namespace_collection);
39017
+ const { delNamespace, getCache, setCache } = useCache51(namespace_collection);
38888
39018
  async function createTextIndex() {
38889
39019
  try {
38890
39020
  await collection.createIndex({
@@ -38937,7 +39067,7 @@ function useEntryPassSettingsRepo() {
38937
39067
  const query = {
38938
39068
  ...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } }
38939
39069
  };
38940
- const cacheKey = makeCacheKey50(namespace_collection, cacheOptions);
39070
+ const cacheKey = makeCacheKey49(namespace_collection, cacheOptions);
38941
39071
  const cachedData = await getCache(cacheKey);
38942
39072
  if (cachedData) {
38943
39073
  logger133.info(`Cache hit for key: ${cacheKey}`);
@@ -38990,7 +39120,7 @@ function useEntryPassSettingsRepo() {
38990
39120
  } catch (error) {
38991
39121
  throw new BadRequestError156("Invalid entry pass settings ID format.");
38992
39122
  }
38993
- const cacheKey = makeCacheKey50(namespace_collection, { _id });
39123
+ const cacheKey = makeCacheKey49(namespace_collection, { _id });
38994
39124
  const cachedData = await getCache(cacheKey);
38995
39125
  if (cachedData) {
38996
39126
  logger133.info(`Cache hit for key: ${cacheKey}`);
@@ -39118,7 +39248,7 @@ function useEntryPassSettingsRepo() {
39118
39248
  } catch (error) {
39119
39249
  throw new BadRequestError156("Invalid entry pass settings ID format.");
39120
39250
  }
39121
- const cacheKey = makeCacheKey50(namespace_collection, { site });
39251
+ const cacheKey = makeCacheKey49(namespace_collection, { site });
39122
39252
  const cachedData = await getCache(cacheKey);
39123
39253
  if (cachedData) {
39124
39254
  logger133.info(`Cache hit for key: ${cacheKey}`);
@@ -39444,9 +39574,9 @@ function useEntryPassSettingsController() {
39444
39574
  import {
39445
39575
  InternalServerError as InternalServerError53,
39446
39576
  logger as logger135,
39447
- makeCacheKey as makeCacheKey51,
39577
+ makeCacheKey as makeCacheKey50,
39448
39578
  useAtlas as useAtlas86,
39449
- useCache as useCache53
39579
+ useCache as useCache52
39450
39580
  } from "@7365admin1/node-server-utils";
39451
39581
  function useDashboardRepo() {
39452
39582
  const db = useAtlas86.getDb();
@@ -39457,7 +39587,7 @@ function useDashboardRepo() {
39457
39587
  const work_order_collection = db.collection("work-orders");
39458
39588
  const visitor_collection = db.collection("visitor.transactions");
39459
39589
  const namespace_collection = "dashboard";
39460
- const { delNamespace, getCache, setCache } = useCache53(namespace_collection);
39590
+ const { delNamespace, getCache, setCache } = useCache52(namespace_collection);
39461
39591
  async function getAll({
39462
39592
  site = ""
39463
39593
  }, session) {
@@ -39468,7 +39598,7 @@ function useDashboardRepo() {
39468
39598
  const cacheOptions = {
39469
39599
  site: site.toString()
39470
39600
  };
39471
- const cacheKey = makeCacheKey51(namespace_collection, cacheOptions);
39601
+ const cacheKey = makeCacheKey50(namespace_collection, cacheOptions);
39472
39602
  const cachedData = await getCache(cacheKey);
39473
39603
  if (cachedData) {
39474
39604
  logger135.info(`Cache hit for key: ${cacheKey}`);
@@ -39618,10 +39748,10 @@ import {
39618
39748
  BadRequestError as BadRequestError160,
39619
39749
  InternalServerError as InternalServerError54,
39620
39750
  logger as logger138,
39621
- makeCacheKey as makeCacheKey52,
39751
+ makeCacheKey as makeCacheKey51,
39622
39752
  paginate as paginate45,
39623
39753
  useAtlas as useAtlas87,
39624
- useCache as useCache54
39754
+ useCache as useCache53
39625
39755
  } from "@7365admin1/node-server-utils";
39626
39756
  import { ObjectId as ObjectId103 } from "mongodb";
39627
39757
  function useNfcPatrolRouteRepo() {
@@ -39631,7 +39761,7 @@ function useNfcPatrolRouteRepo() {
39631
39761
  }
39632
39762
  const namespace_collection = "nfc-patrol-routes";
39633
39763
  const collection = db.collection(namespace_collection);
39634
- const { delNamespace, getCache, setCache } = useCache54(namespace_collection);
39764
+ const { delNamespace, getCache, setCache } = useCache53(namespace_collection);
39635
39765
  async function createIndexes() {
39636
39766
  try {
39637
39767
  await collection.createIndexes([
@@ -39697,7 +39827,7 @@ function useNfcPatrolRouteRepo() {
39697
39827
  cacheOptions.search = search;
39698
39828
  if (filter)
39699
39829
  cacheOptions.filter = filter;
39700
- const cacheKey = makeCacheKey52(namespace_collection, cacheOptions);
39830
+ const cacheKey = makeCacheKey51(namespace_collection, cacheOptions);
39701
39831
  const cachedData = await getCache(cacheKey);
39702
39832
  if (cachedData) {
39703
39833
  logger138.info(`Cache hit for key: ${cacheKey}`);
@@ -39748,7 +39878,7 @@ function useNfcPatrolRouteRepo() {
39748
39878
  if (isStart === true) {
39749
39879
  cacheParams.isStart = true;
39750
39880
  }
39751
- const cacheKey = makeCacheKey52(namespace_collection, cacheParams);
39881
+ const cacheKey = makeCacheKey51(namespace_collection, cacheParams);
39752
39882
  try {
39753
39883
  const cached = await getCache(cacheKey);
39754
39884
  if (cached) {
@@ -40370,11 +40500,11 @@ import {
40370
40500
  BadRequestError as BadRequestError163,
40371
40501
  InternalServerError as InternalServerError55,
40372
40502
  logger as logger141,
40373
- makeCacheKey as makeCacheKey53,
40503
+ makeCacheKey as makeCacheKey52,
40374
40504
  NotFoundError as NotFoundError43,
40375
40505
  paginate as paginate46,
40376
40506
  useAtlas as useAtlas89,
40377
- useCache as useCache55
40507
+ useCache as useCache54
40378
40508
  } from "@7365admin1/node-server-utils";
40379
40509
  import { ObjectId as ObjectId105 } from "mongodb";
40380
40510
  var incidents_namespace_collection = "incident-reports";
@@ -40405,7 +40535,7 @@ function useIncidentReportRepo() {
40405
40535
  }
40406
40536
  }
40407
40537
  const collection = db.collection(incidents_namespace_collection);
40408
- const { delNamespace, getCache, setCache } = useCache55(
40538
+ const { delNamespace, getCache, setCache } = useCache54(
40409
40539
  incidents_namespace_collection
40410
40540
  );
40411
40541
  async function add(value, session) {
@@ -40504,7 +40634,7 @@ function useIncidentReportRepo() {
40504
40634
  if (search) {
40505
40635
  cacheOptions.search = search;
40506
40636
  }
40507
- const cacheKey = makeCacheKey53(incidents_namespace_collection, cacheOptions);
40637
+ const cacheKey = makeCacheKey52(incidents_namespace_collection, cacheOptions);
40508
40638
  const cachedData = await getCache(cacheKey);
40509
40639
  if (cachedData) {
40510
40640
  logger141.info(`Cache hit for key: ${cacheKey}`);
@@ -40617,7 +40747,7 @@ function useIncidentReportRepo() {
40617
40747
  } catch (error) {
40618
40748
  throw new BadRequestError163("Invalid incident report ID format.");
40619
40749
  }
40620
- const cacheKey = makeCacheKey53(incidents_namespace_collection, { _id });
40750
+ const cacheKey = makeCacheKey52(incidents_namespace_collection, { _id });
40621
40751
  const cachedData = await getCache(cacheKey);
40622
40752
  if (cachedData) {
40623
40753
  logger141.info(`Cache hit for key: ${cacheKey}`);
@@ -41294,10 +41424,10 @@ import {
41294
41424
  BadRequestError as BadRequestError167,
41295
41425
  InternalServerError as InternalServerError56,
41296
41426
  logger as logger144,
41297
- makeCacheKey as makeCacheKey54,
41427
+ makeCacheKey as makeCacheKey53,
41298
41428
  NotFoundError as NotFoundError45,
41299
41429
  useAtlas as useAtlas91,
41300
- useCache as useCache56
41430
+ useCache as useCache55
41301
41431
  } from "@7365admin1/node-server-utils";
41302
41432
  import { ObjectId as ObjectId107 } from "mongodb";
41303
41433
  function useNfcPatrolSettingsRepository() {
@@ -41307,7 +41437,7 @@ function useNfcPatrolSettingsRepository() {
41307
41437
  }
41308
41438
  const namespace_collection = "site.nfc-patrol-settings";
41309
41439
  const collection = db.collection(namespace_collection);
41310
- const { delNamespace, setCache, getCache } = useCache56(namespace_collection);
41440
+ const { delNamespace, setCache, getCache } = useCache55(namespace_collection);
41311
41441
  async function createIndexes() {
41312
41442
  try {
41313
41443
  await collection.createIndexes([{ key: { site: 1 }, unique: true }]);
@@ -41334,7 +41464,7 @@ function useNfcPatrolSettingsRepository() {
41334
41464
  throw new BadRequestError167("Invalid nfc patrol settings site ID format.");
41335
41465
  }
41336
41466
  const query = { site };
41337
- const cacheKey = makeCacheKey54(namespace_collection, {
41467
+ const cacheKey = makeCacheKey53(namespace_collection, {
41338
41468
  site: site.toString()
41339
41469
  });
41340
41470
  if (!session) {
@@ -41549,11 +41679,11 @@ import {
41549
41679
  BadRequestError as BadRequestError170,
41550
41680
  InternalServerError as InternalServerError57,
41551
41681
  logger as logger147,
41552
- makeCacheKey as makeCacheKey55,
41682
+ makeCacheKey as makeCacheKey54,
41553
41683
  NotFoundError as NotFoundError46,
41554
41684
  paginate as paginate47,
41555
41685
  useAtlas as useAtlas93,
41556
- useCache as useCache57
41686
+ useCache as useCache56
41557
41687
  } from "@7365admin1/node-server-utils";
41558
41688
 
41559
41689
  // src/models/occurrence-subject.model.ts
@@ -41630,7 +41760,7 @@ function useOccurrenceSubjectRepo() {
41630
41760
  }
41631
41761
  const namespace_collection = "occurrence-subjects";
41632
41762
  const collection = db.collection(namespace_collection);
41633
- const { delNamespace, getCache, setCache } = useCache57(namespace_collection);
41763
+ const { delNamespace, getCache, setCache } = useCache56(namespace_collection);
41634
41764
  async function add(value, session) {
41635
41765
  try {
41636
41766
  value = MOccurrenceSubject(value);
@@ -41682,7 +41812,7 @@ function useOccurrenceSubjectRepo() {
41682
41812
  query.$text = { $search: search };
41683
41813
  cacheOptions.search = search;
41684
41814
  }
41685
- const cacheKey = makeCacheKey55(namespace_collection, cacheOptions);
41815
+ const cacheKey = makeCacheKey54(namespace_collection, cacheOptions);
41686
41816
  const cachedData = await getCache(cacheKey);
41687
41817
  if (cachedData) {
41688
41818
  logger147.info(`Cache hit for key: ${cacheKey}`);
@@ -42202,11 +42332,11 @@ import {
42202
42332
  BadRequestError as BadRequestError172,
42203
42333
  InternalServerError as InternalServerError58,
42204
42334
  logger as logger149,
42205
- makeCacheKey as makeCacheKey56,
42335
+ makeCacheKey as makeCacheKey55,
42206
42336
  NotFoundError as NotFoundError47,
42207
42337
  paginate as paginate48,
42208
42338
  useAtlas as useAtlas95,
42209
- useCache as useCache58
42339
+ useCache as useCache57
42210
42340
  } from "@7365admin1/node-server-utils";
42211
42341
  import { ObjectId as ObjectId112 } from "mongodb";
42212
42342
  function useOnlineFormRepo() {
@@ -42216,7 +42346,7 @@ function useOnlineFormRepo() {
42216
42346
  }
42217
42347
  const namespace_collection = "online-forms";
42218
42348
  const collection = db.collection(namespace_collection);
42219
- const { delNamespace, getCache, setCache } = useCache58(namespace_collection);
42349
+ const { delNamespace, getCache, setCache } = useCache57(namespace_collection);
42220
42350
  async function createTextIndex() {
42221
42351
  try {
42222
42352
  await collection.createIndex({
@@ -42283,7 +42413,7 @@ function useOnlineFormRepo() {
42283
42413
  query.$or = [{ name: { $regex: search, $options: "i" } }];
42284
42414
  cacheOptions.search = search;
42285
42415
  }
42286
- const cacheKey = makeCacheKey56(namespace_collection, cacheOptions);
42416
+ const cacheKey = makeCacheKey55(namespace_collection, cacheOptions);
42287
42417
  const cachedData = await getCache(cacheKey);
42288
42418
  if (cachedData) {
42289
42419
  logger149.info(`Cache hit for key: ${cacheKey}`);
@@ -42324,7 +42454,7 @@ function useOnlineFormRepo() {
42324
42454
  } catch (error) {
42325
42455
  throw new BadRequestError172("Invalid online form ID format.");
42326
42456
  }
42327
- const cacheKey = makeCacheKey56(namespace_collection, { _id });
42457
+ const cacheKey = makeCacheKey55(namespace_collection, { _id });
42328
42458
  const cachedData = await getCache(cacheKey);
42329
42459
  if (cachedData) {
42330
42460
  logger149.info(`Cache hit for key: ${cacheKey}`);
@@ -42445,7 +42575,7 @@ function useOnlineFormRepo() {
42445
42575
  cacheOptions.search = search;
42446
42576
  }
42447
42577
  cacheOptions.site = site;
42448
- const cacheKey = makeCacheKey56(namespace_collection, { site });
42578
+ const cacheKey = makeCacheKey55(namespace_collection, { site });
42449
42579
  const cachedData = await getCache(cacheKey);
42450
42580
  if (cachedData) {
42451
42581
  logger149.info(`Cache hit for key: ${cacheKey}`);
@@ -42959,10 +43089,10 @@ import {
42959
43089
  BadRequestError as BadRequestError176,
42960
43090
  InternalServerError as InternalServerError59,
42961
43091
  logger as logger153,
42962
- makeCacheKey as makeCacheKey57,
43092
+ makeCacheKey as makeCacheKey56,
42963
43093
  paginate as paginate49,
42964
43094
  useAtlas as useAtlas97,
42965
- useCache as useCache59
43095
+ useCache as useCache58
42966
43096
  } from "@7365admin1/node-server-utils";
42967
43097
  import { ObjectId as ObjectId114 } from "mongodb";
42968
43098
  function useNfcPatrolLogRepo() {
@@ -42972,7 +43102,7 @@ function useNfcPatrolLogRepo() {
42972
43102
  }
42973
43103
  const namespace_collection = "nfc-patrol-logs";
42974
43104
  const collection = db.collection(namespace_collection);
42975
- const { delNamespace, getCache, setCache } = useCache59(namespace_collection);
43105
+ const { delNamespace, getCache, setCache } = useCache58(namespace_collection);
42976
43106
  async function createIndexes() {
42977
43107
  try {
42978
43108
  await collection.createIndexes([
@@ -43046,7 +43176,7 @@ function useNfcPatrolLogRepo() {
43046
43176
  if (route?.startTime) {
43047
43177
  cacheOptions.routeStartTime = route?.startTime;
43048
43178
  }
43049
- const cacheKey = makeCacheKey57(namespace_collection, cacheOptions);
43179
+ const cacheKey = makeCacheKey56(namespace_collection, cacheOptions);
43050
43180
  const cachedData = await getCache(cacheKey);
43051
43181
  if (cachedData) {
43052
43182
  logger153.info(`Cache hit for key: ${cacheKey}`);
@@ -43200,10 +43330,10 @@ import {
43200
43330
  BadRequestError as BadRequestError179,
43201
43331
  InternalServerError as InternalServerError60,
43202
43332
  logger as logger156,
43203
- makeCacheKey as makeCacheKey58,
43333
+ makeCacheKey as makeCacheKey57,
43204
43334
  toObjectId as toObjectId15,
43205
43335
  useAtlas as useAtlas99,
43206
- useCache as useCache60
43336
+ useCache as useCache59
43207
43337
  } from "@7365admin1/node-server-utils";
43208
43338
  var Period = /* @__PURE__ */ ((Period2) => {
43209
43339
  Period2["TODAY"] = "today";
@@ -43289,7 +43419,7 @@ function useNewDashboardRepo() {
43289
43419
  if (!db) {
43290
43420
  throw new InternalServerError60("Unable to connect to server.");
43291
43421
  }
43292
- const { delNamespace, getCache, setCache } = useCache60(
43422
+ const { delNamespace, getCache, setCache } = useCache59(
43293
43423
  securityDashboardCollection
43294
43424
  );
43295
43425
  async function getMetric(collectionString, siteId, period) {
@@ -43334,7 +43464,7 @@ function useNewDashboardRepo() {
43334
43464
  visitor,
43335
43465
  incident
43336
43466
  };
43337
- const cacheKey = makeCacheKey58(securityDashboardCollection, cacheOptions);
43467
+ const cacheKey = makeCacheKey57(securityDashboardCollection, cacheOptions);
43338
43468
  const cachedData = await getCache(cacheKey);
43339
43469
  if (cachedData) {
43340
43470
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43413,7 +43543,7 @@ function useNewDashboardRepo() {
43413
43543
  visitor,
43414
43544
  incident
43415
43545
  };
43416
- const cacheKey = makeCacheKey58(PMDashboardCollection, cacheOptions);
43546
+ const cacheKey = makeCacheKey57(PMDashboardCollection, cacheOptions);
43417
43547
  const cachedData = await getCache(cacheKey);
43418
43548
  if (cachedData) {
43419
43549
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43494,7 +43624,7 @@ function useNewDashboardRepo() {
43494
43624
  feedback,
43495
43625
  workOrder
43496
43626
  };
43497
- const cacheKey = makeCacheKey58(pestDashboardCollection, cacheOptions);
43627
+ const cacheKey = makeCacheKey57(pestDashboardCollection, cacheOptions);
43498
43628
  const cachedData = await getCache(cacheKey);
43499
43629
  if (cachedData) {
43500
43630
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43531,7 +43661,7 @@ function useNewDashboardRepo() {
43531
43661
  feedback,
43532
43662
  workOrder
43533
43663
  };
43534
- const cacheKey = makeCacheKey58(poolDashboardCollection, cacheOptions);
43664
+ const cacheKey = makeCacheKey57(poolDashboardCollection, cacheOptions);
43535
43665
  const cachedData = await getCache(cacheKey);
43536
43666
  if (cachedData) {
43537
43667
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43568,7 +43698,7 @@ function useNewDashboardRepo() {
43568
43698
  feedback,
43569
43699
  workOrder
43570
43700
  };
43571
- const cacheKey = makeCacheKey58(mAndEDashboardCollection, cacheOptions);
43701
+ const cacheKey = makeCacheKey57(mAndEDashboardCollection, cacheOptions);
43572
43702
  const cachedData = await getCache(cacheKey);
43573
43703
  if (cachedData) {
43574
43704
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43605,7 +43735,7 @@ function useNewDashboardRepo() {
43605
43735
  feedback,
43606
43736
  workOrder
43607
43737
  };
43608
- const cacheKey = makeCacheKey58(landscapeDashboardCollection, cacheOptions);
43738
+ const cacheKey = makeCacheKey57(landscapeDashboardCollection, cacheOptions);
43609
43739
  const cachedData = await getCache(cacheKey);
43610
43740
  if (cachedData) {
43611
43741
  logger156.info(`Cache hit for key: ${cacheKey}`);
@@ -43943,6 +44073,8 @@ var MManpowerMonitoring = class {
43943
44073
  // src/repositories/manpower-monitoring.repo.ts
43944
44074
  import {
43945
44075
  BadRequestError as BadRequestError181,
44076
+ InternalServerError as InternalServerError61,
44077
+ logger as logger158,
43946
44078
  paginate as paginate51,
43947
44079
  useAtlas as useAtlas100
43948
44080
  } from "@7365admin1/node-server-utils";
@@ -44405,6 +44537,25 @@ function useManpowerMonitoringRepo() {
44405
44537
  const namespace_collection = "manpower-settings";
44406
44538
  const collection = db.collection(namespace_collection);
44407
44539
  const serviceProviderCollection = db.collection("site.service-providers");
44540
+ async function createIndexes() {
44541
+ try {
44542
+ await collection.createIndexes([
44543
+ {
44544
+ key: { siteId: 1 }
44545
+ },
44546
+ { key: { createdAt: 1 } }
44547
+ ]);
44548
+ return `Successfully created indexes for ${namespace_collection}.`;
44549
+ } catch (error) {
44550
+ logger158.log({
44551
+ level: "error",
44552
+ message: error.message
44553
+ });
44554
+ throw new InternalServerError61(
44555
+ "Failed to create general indexes on manpower monitoring."
44556
+ );
44557
+ }
44558
+ }
44408
44559
  async function createManpowerMonitoringSettings(value, session) {
44409
44560
  try {
44410
44561
  value = new MManpowerMonitoring(value);
@@ -44581,7 +44732,8 @@ function useManpowerMonitoringRepo() {
44581
44732
  getManpowerSettingsBySiteId,
44582
44733
  updateManpowerMonitoringSettings,
44583
44734
  multipleManpowerMonitoringSettings,
44584
- getAllSites
44735
+ getAllSites,
44736
+ createIndexes
44585
44737
  };
44586
44738
  }
44587
44739
 
@@ -44595,6 +44747,8 @@ import {
44595
44747
  // src/repositories/manpower-remarks.repo.ts
44596
44748
  import {
44597
44749
  BadRequestError as BadRequestError182,
44750
+ InternalServerError as InternalServerError62,
44751
+ logger as logger159,
44598
44752
  paginate as paginate52,
44599
44753
  useAtlas as useAtlas101
44600
44754
  } from "@7365admin1/node-server-utils";
@@ -44652,6 +44806,25 @@ function useManpowerRemarksRepo() {
44652
44806
  }
44653
44807
  const namespace_collection = "manpower-remarks";
44654
44808
  const collection = db.collection(namespace_collection);
44809
+ async function createIndexes() {
44810
+ try {
44811
+ await collection.createIndexes([
44812
+ {
44813
+ key: { siteId: 1 }
44814
+ },
44815
+ { key: { createdAt: 1 } }
44816
+ ]);
44817
+ return `Successfully created indexes for ${namespace_collection}.`;
44818
+ } catch (error) {
44819
+ logger159.log({
44820
+ level: "error",
44821
+ message: error.message
44822
+ });
44823
+ throw new InternalServerError62(
44824
+ "Failed to create general indexes on manpower remarks."
44825
+ );
44826
+ }
44827
+ }
44655
44828
  async function createManpowerRemarks(value, session) {
44656
44829
  try {
44657
44830
  value = new MManpowerRemarks(value);
@@ -44774,7 +44947,8 @@ function useManpowerRemarksRepo() {
44774
44947
  getManpowerRemarksAllSite,
44775
44948
  getManpowerRemarksBySiteId,
44776
44949
  updateManpowerRemarks,
44777
- updateRemarksStatus
44950
+ updateRemarksStatus,
44951
+ createIndexes
44778
44952
  };
44779
44953
  }
44780
44954
 
@@ -44786,7 +44960,6 @@ function useManpowerMonitoringSrvc() {
44786
44960
  } = useManpowerMonitoringRepo();
44787
44961
  const { createManpowerRemarks: _createManpowerRemarks } = useManpowerRemarksRepo();
44788
44962
  async function createManpowerMonitoringSettings(payload) {
44789
- console.log("Im here now at service");
44790
44963
  const session = useAtlas102.getClient()?.startSession();
44791
44964
  if (!session) {
44792
44965
  throw new BadRequestError183("Database session not available.");
@@ -44802,7 +44975,6 @@ function useManpowerMonitoringSrvc() {
44802
44975
  const afternoonAlertTime = afternoonCheckInTime ? moment3.tz(afternoonCheckInTime, "HH:mm", "Asia/Singapore").add(afternoonAlertFrequencyMins, "minutes").format("HH:mm") : "";
44803
44976
  const nightAlertTime = moment3.tz(nightCheckInTime, "HH:mm", "Asia/Singapore").add(nightAlertFrequencyMins, "minutes").format("HH:mm");
44804
44977
  const nowSGT = moment3().tz("Asia/Singapore");
44805
- console.log("im done preparing the payload");
44806
44978
  try {
44807
44979
  const remarksPayload = {
44808
44980
  siteId: payload.siteId,
@@ -44961,7 +45133,6 @@ function useManpowerMonitoringCtrl() {
44961
45133
  });
44962
45134
  const _id = req.params.id;
44963
45135
  const payload = { ...req.body };
44964
- console.log("_id", _id);
44965
45136
  const { error } = validation.validate({ _id, ...payload });
44966
45137
  if (error) {
44967
45138
  next(new BadRequestError184(error.message));
@@ -45056,6 +45227,8 @@ var MManpowerDesignations = class {
45056
45227
 
45057
45228
  // src/repositories/manpower-designations.repo.ts
45058
45229
  import {
45230
+ InternalServerError as InternalServerError63,
45231
+ logger as logger162,
45059
45232
  useAtlas as useAtlas103
45060
45233
  } from "@7365admin1/node-server-utils";
45061
45234
  import { ObjectId as ObjectId120 } from "mongodb";
@@ -45066,6 +45239,25 @@ function useManpowerDesignationRepo() {
45066
45239
  }
45067
45240
  const namespace_collection = "manpower-designations";
45068
45241
  const collection = db.collection(namespace_collection);
45242
+ async function createIndexes() {
45243
+ try {
45244
+ await collection.createIndexes([
45245
+ {
45246
+ key: { siteId: 1 }
45247
+ },
45248
+ { key: { createdAt: 1 } }
45249
+ ]);
45250
+ return `Successfully created indexes for ${namespace_collection}.`;
45251
+ } catch (error) {
45252
+ logger162.log({
45253
+ level: "error",
45254
+ message: error.message
45255
+ });
45256
+ throw new InternalServerError63(
45257
+ "Failed to create general indexes on manpower designations."
45258
+ );
45259
+ }
45260
+ }
45069
45261
  async function createManpowerDesignations(value) {
45070
45262
  try {
45071
45263
  value = new MManpowerDesignations(value);
@@ -45121,7 +45313,8 @@ function useManpowerDesignationRepo() {
45121
45313
  return {
45122
45314
  createManpowerDesignations,
45123
45315
  getManpowerDesignationsBySiteId,
45124
- updateManpowerDesignations
45316
+ updateManpowerDesignations,
45317
+ createIndexes
45125
45318
  };
45126
45319
  }
45127
45320
 
@@ -45270,10 +45463,10 @@ function MOvernightParkingApprovalHours(value) {
45270
45463
  import {
45271
45464
  InternalServerError as InternalServerError64,
45272
45465
  logger as logger164,
45273
- makeCacheKey as makeCacheKey62,
45466
+ makeCacheKey as makeCacheKey61,
45274
45467
  toObjectId as toObjectId16,
45275
45468
  useAtlas as useAtlas104,
45276
- useCache as useCache64
45469
+ useCache as useCache63
45277
45470
  } from "@7365admin1/node-server-utils";
45278
45471
  var overnight_parking_namespace_collection = "site.overnight-parking";
45279
45472
  function useOvernightParkingRepo() {
@@ -45282,7 +45475,7 @@ function useOvernightParkingRepo() {
45282
45475
  throw new InternalServerError64("Unable to connect to server.");
45283
45476
  }
45284
45477
  const collection = db.collection(overnight_parking_namespace_collection);
45285
- const { delNamespace, setCache, getCache } = useCache64(
45478
+ const { delNamespace, setCache, getCache } = useCache63(
45286
45479
  overnight_parking_namespace_collection
45287
45480
  );
45288
45481
  async function createIndexes() {
@@ -45351,7 +45544,7 @@ function useOvernightParkingRepo() {
45351
45544
  }
45352
45545
  async function getSiteOvernightParking(site) {
45353
45546
  const siteId = toObjectId16(site);
45354
- const cacheKey = makeCacheKey62(overnight_parking_namespace_collection, {
45547
+ const cacheKey = makeCacheKey61(overnight_parking_namespace_collection, {
45355
45548
  site
45356
45549
  });
45357
45550
  const cachedData = await getCache(cacheKey);
@@ -45498,11 +45691,11 @@ import {
45498
45691
  BadRequestError as BadRequestError189,
45499
45692
  InternalServerError as InternalServerError65,
45500
45693
  logger as logger166,
45501
- makeCacheKey as makeCacheKey63,
45694
+ makeCacheKey as makeCacheKey62,
45502
45695
  paginate as paginate55,
45503
45696
  toObjectId as toObjectId18,
45504
45697
  useAtlas as useAtlas105,
45505
- useCache as useCache65
45698
+ useCache as useCache64
45506
45699
  } from "@7365admin1/node-server-utils";
45507
45700
  var overnight_parking_requests_namespace_collection = "site.overnight-parking-requests";
45508
45701
  function useOvernightParkingRequestRepo() {
@@ -45513,7 +45706,7 @@ function useOvernightParkingRequestRepo() {
45513
45706
  const collection = db.collection(
45514
45707
  overnight_parking_requests_namespace_collection
45515
45708
  );
45516
- const { delNamespace, getCache, setCache } = useCache65(
45709
+ const { delNamespace, getCache, setCache } = useCache64(
45517
45710
  overnight_parking_requests_namespace_collection
45518
45711
  );
45519
45712
  async function createIndexes() {
@@ -45580,7 +45773,7 @@ function useOvernightParkingRequestRepo() {
45580
45773
  sort: JSON.stringify(sort),
45581
45774
  ...status && { status }
45582
45775
  };
45583
- const cacheKey = makeCacheKey63(
45776
+ const cacheKey = makeCacheKey62(
45584
45777
  overnight_parking_requests_namespace_collection,
45585
45778
  cacheOptions
45586
45779
  );
@@ -45610,7 +45803,7 @@ function useOvernightParkingRequestRepo() {
45610
45803
  }
45611
45804
  async function getOvernightParkingRequestById(id) {
45612
45805
  try {
45613
- const cacheKey = makeCacheKey63(
45806
+ const cacheKey = makeCacheKey62(
45614
45807
  overnight_parking_requests_namespace_collection,
45615
45808
  { id }
45616
45809
  );
@@ -48720,7 +48913,7 @@ import {
48720
48913
  comparePassword as comparePassword3,
48721
48914
  InternalServerError as InternalServerError71,
48722
48915
  NotFoundError as NotFoundError53,
48723
- useCache as useCache68
48916
+ useCache as useCache67
48724
48917
  } from "@7365admin1/node-server-utils";
48725
48918
  import { v4 as uuidv42 } from "uuid";
48726
48919
 
@@ -48734,8 +48927,8 @@ import {
48734
48927
  paginate as paginate58,
48735
48928
  NotFoundError as NotFoundError52,
48736
48929
  AppError as AppError28,
48737
- useCache as useCache67,
48738
- makeCacheKey as makeCacheKey65,
48930
+ useCache as useCache66,
48931
+ makeCacheKey as makeCacheKey64,
48739
48932
  toObjectId as toObjectId19
48740
48933
  } from "@7365admin1/node-server-utils";
48741
48934
  function useUserRepoV2() {
@@ -48748,7 +48941,7 @@ function useUserRepoV2() {
48748
48941
  }
48749
48942
  const namespace_collection = "users";
48750
48943
  const collection = db.collection(namespace_collection);
48751
- const { delNamespace, setCache, getCache, delCache } = useCache67(namespace_collection);
48944
+ const { delNamespace, setCache, getCache, delCache } = useCache66(namespace_collection);
48752
48945
  async function createIndex() {
48753
48946
  try {
48754
48947
  await collection.createIndexes([{ key: { email: 1 } }]);
@@ -48796,7 +48989,7 @@ function useUserRepoV2() {
48796
48989
  }
48797
48990
  async function getUserByEmail(email) {
48798
48991
  try {
48799
- const cacheKey = makeCacheKey65(namespace_collection, { email });
48992
+ const cacheKey = makeCacheKey64(namespace_collection, { email });
48800
48993
  const cachedData = await getCache(cacheKey);
48801
48994
  if (cachedData) {
48802
48995
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -48815,7 +49008,7 @@ function useUserRepoV2() {
48815
49008
  }
48816
49009
  async function getUserByEmailStatus(email) {
48817
49010
  try {
48818
- const cacheKey = makeCacheKey65(namespace_collection, {
49011
+ const cacheKey = makeCacheKey64(namespace_collection, {
48819
49012
  email,
48820
49013
  status: "complete" /* COMPLETE */
48821
49014
  });
@@ -48839,7 +49032,7 @@ function useUserRepoV2() {
48839
49032
  async function getUserById(id) {
48840
49033
  const _id = toObjectId19(id);
48841
49034
  try {
48842
- const cacheKey = makeCacheKey65(namespace_collection, { id });
49035
+ const cacheKey = makeCacheKey64(namespace_collection, { id });
48843
49036
  const cachedData = await getCache(cacheKey);
48844
49037
  if (cachedData) {
48845
49038
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -48878,7 +49071,7 @@ function useUserRepoV2() {
48878
49071
  }
48879
49072
  async function getUserByReferralCode(referralCode) {
48880
49073
  try {
48881
- const cacheKey = makeCacheKey65(namespace_collection, { referralCode });
49074
+ const cacheKey = makeCacheKey64(namespace_collection, { referralCode });
48882
49075
  const cachedData = await getCache(cacheKey);
48883
49076
  if (cachedData) {
48884
49077
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -48895,7 +49088,7 @@ function useUserRepoV2() {
48895
49088
  }
48896
49089
  async function getByEmailApp(email, app) {
48897
49090
  try {
48898
- const cacheKey = makeCacheKey65(namespace_collection, { email, app });
49091
+ const cacheKey = makeCacheKey64(namespace_collection, { email, app });
48899
49092
  const cachedData = await getCache(cacheKey);
48900
49093
  if (cachedData) {
48901
49094
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -48951,7 +49144,7 @@ function useUserRepoV2() {
48951
49144
  err
48952
49145
  );
48953
49146
  });
48954
- const cacheKey = makeCacheKey65(namespace_collection, cacheOptions);
49147
+ const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
48955
49148
  const cachedData = await getCache(cacheKey);
48956
49149
  if (cachedData) {
48957
49150
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -49015,7 +49208,7 @@ function useUserRepoV2() {
49015
49208
  err
49016
49209
  )
49017
49210
  );
49018
- const cacheKey = makeCacheKey65(namespace_collection, cacheOptions);
49211
+ const cacheKey = makeCacheKey64(namespace_collection, cacheOptions);
49019
49212
  const cachedData = await getCache(cacheKey);
49020
49213
  if (cachedData) {
49021
49214
  logger180.info(`Cache hit for key: ${cacheKey}`);
@@ -49041,7 +49234,7 @@ function useUserRepoV2() {
49041
49234
  }
49042
49235
  }
49043
49236
  async function updatePasswordById({ _id, password }, session) {
49044
- const cacheKey = makeCacheKey65(namespace_collection, { _id });
49237
+ const cacheKey = makeCacheKey64(namespace_collection, { _id });
49045
49238
  _id = toObjectId19(_id);
49046
49239
  try {
49047
49240
  const result = await collection.updateOne(
@@ -49105,7 +49298,7 @@ function useUserRepoV2() {
49105
49298
  // Dynamically set the field
49106
49299
  { session }
49107
49300
  );
49108
- const cacheKey = makeCacheKey65(namespace_collection, { _id });
49301
+ const cacheKey = makeCacheKey64(namespace_collection, { _id });
49109
49302
  delCache(cacheKey).then(() => {
49110
49303
  logger180.info(`Cache deleted for key: ${cacheKey}`);
49111
49304
  }).catch((err) => {
@@ -49140,7 +49333,7 @@ function useUserRepoV2() {
49140
49333
  },
49141
49334
  { session }
49142
49335
  );
49143
- const cacheKey = makeCacheKey65(namespace_collection, { _id });
49336
+ const cacheKey = makeCacheKey64(namespace_collection, { _id });
49144
49337
  delCache(cacheKey).then(() => {
49145
49338
  logger180.info(`Cache deleted for key: ${cacheKey}`);
49146
49339
  }).catch((err) => {
@@ -49163,7 +49356,7 @@ function useUserRepoV2() {
49163
49356
  { $set: { password, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
49164
49357
  { session }
49165
49358
  );
49166
- const cacheKey = makeCacheKey65(namespace_collection, { _id });
49359
+ const cacheKey = makeCacheKey64(namespace_collection, { _id });
49167
49360
  delCache(cacheKey).then(() => {
49168
49361
  logger180.info(`Cache deleted for key: ${cacheKey}`);
49169
49362
  }).catch((err) => {
@@ -49195,7 +49388,7 @@ function useUserRepoV2() {
49195
49388
  function useAuthServiceV2() {
49196
49389
  const { getUserByEmail, getUserById: _getUserById } = useUserRepoV2();
49197
49390
  const expiresIn = "15m";
49198
- const { setCache, delCache } = useCache68("sessions");
49391
+ const { setCache, delCache } = useCache67("sessions");
49199
49392
  const { getByUserIdType } = useMemberRepo();
49200
49393
  async function login({
49201
49394
  email,
@@ -49963,7 +50156,7 @@ import {
49963
50156
  InternalServerError as InternalServerError73,
49964
50157
  useAtlas as useAtlas116,
49965
50158
  logger as logger184,
49966
- useCache as useCache69
50159
+ useCache as useCache68
49967
50160
  } from "@7365admin1/node-server-utils";
49968
50161
  function useRoleRepoV2() {
49969
50162
  const db = useAtlas116.getDb();
@@ -50000,7 +50193,7 @@ function useRoleRepoV2() {
50000
50193
  throw new InternalServerError73("Failed to create unique index on role.");
50001
50194
  }
50002
50195
  }
50003
- const { delNamespace } = useCache69(namespace_collection);
50196
+ const { delNamespace } = useCache68(namespace_collection);
50004
50197
  async function addRole(value, session) {
50005
50198
  value = new MRoleV2(value);
50006
50199
  try {