@7365admin1/core 3.10.0 → 3.12.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
@@ -20867,14 +20867,20 @@ var schemaUpdateVisTrans = Joi37.object({
20867
20867
  Joi37.object({
20868
20868
  keyId: Joi37.string().hex().length(24).required(),
20869
20869
  status: Joi37.string().optional().allow(null, ""),
20870
- remarks: Joi37.string().optional().allow(null, "")
20870
+ remarks: Joi37.string().optional().allow(null, ""),
20871
+ receivedDate: Joi37.string().optional().allow(null, ""),
20872
+ lastUpdate: Joi37.string().optional().allow(null, ""),
20873
+ add: Joi37.boolean().optional().allow(null, "")
20871
20874
  })
20872
20875
  ).optional().allow(null),
20873
20876
  passKeys: Joi37.array().items(
20874
20877
  Joi37.object({
20875
20878
  keyId: Joi37.string().hex().length(24).required(),
20876
20879
  status: Joi37.string().optional().allow(null, ""),
20877
- remarks: Joi37.string().optional().allow(null, "")
20880
+ remarks: Joi37.string().optional().allow(null, ""),
20881
+ receivedDate: Joi37.string().optional().allow(null, ""),
20882
+ lastUpdate: Joi37.string().optional().allow(null, ""),
20883
+ add: Joi37.boolean().optional().allow(null, "")
20878
20884
  })
20879
20885
  ).optional().allow(null),
20880
20886
  checkInRemarks: Joi37.string().optional().allow("", null),
@@ -20897,7 +20903,8 @@ var schemaUpdateVisTrans = Joi37.object({
20897
20903
  ).optional().allow(null),
20898
20904
  contact: Joi37.string().optional().allow(null, "")
20899
20905
  })
20900
- ).optional().allow(null)
20906
+ ).optional().allow(null),
20907
+ updatedBy: Joi37.string().hex().length(24).optional()
20901
20908
  });
20902
20909
  function MVisitorTransaction(value) {
20903
20910
  const { error } = schemaVisitorTransaction.validate(value, {
@@ -21055,6 +21062,15 @@ async function convertObjectIdUtil2(id, fieldName) {
21055
21062
  throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
21056
21063
  }
21057
21064
  }
21065
+ function convertObjectIdUtilNonAsync(id, fieldName) {
21066
+ try {
21067
+ if (!id)
21068
+ throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
21069
+ return new ObjectId40(id);
21070
+ } catch (_) {
21071
+ throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
21072
+ }
21073
+ }
21058
21074
 
21059
21075
  // src/repositories/visitor-transaction.repo.ts
21060
21076
  import moment from "moment-timezone";
@@ -21248,6 +21264,7 @@ function useVisitorTransactionRepo() {
21248
21264
  preserveNullAndEmptyArrays: true
21249
21265
  }
21250
21266
  },
21267
+ // 1. Lookup visitorPass into a temporary field
21251
21268
  {
21252
21269
  $lookup: {
21253
21270
  from: "keys",
@@ -21259,48 +21276,66 @@ function useVisitorTransactionRepo() {
21259
21276
  from: "qr-code-templates",
21260
21277
  localField: "template",
21261
21278
  foreignField: "_id",
21262
- pipeline: [
21263
- {
21264
- $project: {
21265
- _id: 1,
21266
- prefixPass: 1,
21267
- name: 1,
21268
- remarks: 1
21269
- }
21270
- }
21271
- ],
21279
+ pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
21272
21280
  as: "template"
21273
21281
  }
21274
21282
  },
21275
21283
  {
21276
21284
  $project: {
21277
- _id: 0,
21278
- keyId: "$_id",
21279
- status: 1,
21280
- description: 1,
21281
- remarks: {
21282
- $arrayElemAt: ["$template.remarks", 0]
21283
- },
21284
- templatePrefixPass: {
21285
- $arrayElemAt: ["$template.prefixPass", 0]
21286
- },
21285
+ _id: 1,
21286
+ // Kept only for matching purposes
21287
21287
  prefixAndName: {
21288
21288
  $concat: [
21289
- {
21290
- $ifNull: [
21291
- { $arrayElemAt: ["$template.prefixPass", 0] },
21292
- ""
21293
- ]
21294
- },
21289
+ { $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
21295
21290
  { $ifNull: ["$name", ""] }
21296
21291
  ]
21297
21292
  }
21298
21293
  }
21299
21294
  }
21300
21295
  ],
21301
- as: "visitorPass"
21296
+ as: "visitorPass_lookup"
21302
21297
  }
21303
21298
  },
21299
+ // 2. Map through original array, keep all fields, and inject prefixAndName
21300
+ {
21301
+ $addFields: {
21302
+ visitorPass: {
21303
+ $map: {
21304
+ input: "$visitorPass",
21305
+ as: "original",
21306
+ in: {
21307
+ // Explicitly retain all original fields from your document
21308
+ keyId: "$$original.keyId",
21309
+ receivedDate: "$$original.receivedDate",
21310
+ status: "$$original.status",
21311
+ lastUpdate: "$$original.lastUpdate",
21312
+ remarks: "$$original.remarks",
21313
+ // Find and extract ONLY the prefixAndName string from lookup
21314
+ prefixAndName: {
21315
+ $let: {
21316
+ vars: {
21317
+ matched: {
21318
+ $arrayElemAt: [
21319
+ {
21320
+ $filter: {
21321
+ input: "$visitorPass_lookup",
21322
+ as: "lookup",
21323
+ cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
21324
+ }
21325
+ },
21326
+ 0
21327
+ ]
21328
+ }
21329
+ },
21330
+ in: "$$matched.prefixAndName"
21331
+ }
21332
+ }
21333
+ }
21334
+ }
21335
+ }
21336
+ }
21337
+ },
21338
+ // 3. Lookup passKeys into a temporary field
21304
21339
  {
21305
21340
  $lookup: {
21306
21341
  from: "keys",
@@ -21312,46 +21347,69 @@ function useVisitorTransactionRepo() {
21312
21347
  from: "qr-code-templates",
21313
21348
  localField: "template",
21314
21349
  foreignField: "_id",
21315
- pipeline: [
21316
- {
21317
- $project: {
21318
- _id: 1,
21319
- prefixPass: 1,
21320
- name: 1,
21321
- remarks: 1
21322
- }
21323
- }
21324
- ],
21350
+ pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
21325
21351
  as: "template"
21326
21352
  }
21327
21353
  },
21328
21354
  {
21329
21355
  $project: {
21330
- _id: 0,
21331
- keyId: "$_id",
21332
- status: 1,
21333
- description: 1,
21334
- remarks: {
21335
- $arrayElemAt: ["$template.remarks", 0]
21336
- },
21337
- templatePrefixPass: {
21338
- $arrayElemAt: ["$template.prefixPass", 0]
21339
- },
21356
+ _id: 1,
21340
21357
  prefixAndName: {
21341
21358
  $concat: [
21342
- {
21343
- $ifNull: [
21344
- { $arrayElemAt: ["$template.prefixPass", 0] },
21345
- ""
21346
- ]
21347
- },
21359
+ { $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
21348
21360
  { $ifNull: ["$name", ""] }
21349
21361
  ]
21350
21362
  }
21351
21363
  }
21352
21364
  }
21353
21365
  ],
21354
- as: "passKeys"
21366
+ as: "passKeys_lookup"
21367
+ }
21368
+ },
21369
+ // 4. Map through original passKeys array, keep all fields, inject prefixAndName
21370
+ {
21371
+ $addFields: {
21372
+ passKeys: {
21373
+ $map: {
21374
+ input: "$passKeys",
21375
+ as: "original",
21376
+ in: {
21377
+ // Explicitly retain all original fields from your document
21378
+ keyId: "$$original.keyId",
21379
+ receivedDate: "$$original.receivedDate",
21380
+ status: "$$original.status",
21381
+ lastUpdate: "$$original.lastUpdate",
21382
+ remarks: "$$original.remarks",
21383
+ // Find and extract ONLY the prefixAndName string from lookup
21384
+ prefixAndName: {
21385
+ $let: {
21386
+ vars: {
21387
+ matched: {
21388
+ $arrayElemAt: [
21389
+ {
21390
+ $filter: {
21391
+ input: "$passKeys_lookup",
21392
+ as: "lookup",
21393
+ cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
21394
+ }
21395
+ },
21396
+ 0
21397
+ ]
21398
+ }
21399
+ },
21400
+ in: "$$matched.prefixAndName"
21401
+ }
21402
+ }
21403
+ }
21404
+ }
21405
+ }
21406
+ }
21407
+ },
21408
+ // 5. Cleanup temporary arrays
21409
+ {
21410
+ $project: {
21411
+ visitorPass_lookup: 0,
21412
+ passKeys_lookup: 0
21355
21413
  }
21356
21414
  },
21357
21415
  {
@@ -21547,10 +21605,74 @@ function useVisitorTransactionRepo() {
21547
21605
  value.manualCheckout = true;
21548
21606
  }
21549
21607
  try {
21608
+ const updateFields = {};
21609
+ const pushFields = {};
21610
+ const arrayFilters = [];
21611
+ Object.keys(value).forEach((key) => {
21612
+ if (key !== "visitorPass" && key !== "passKeys") {
21613
+ const typedKey = key;
21614
+ updateFields[key] = value[typedKey];
21615
+ }
21616
+ });
21617
+ if (Array.isArray(value.visitorPass)) {
21618
+ value.visitorPass.forEach((item, index) => {
21619
+ if (item.add === true) {
21620
+ const { add: add2, ...cleanItem } = item;
21621
+ cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Pass Id");
21622
+ if (!pushFields["visitorPass"]) {
21623
+ pushFields["visitorPass"] = { $each: [] };
21624
+ }
21625
+ pushFields["visitorPass"].$each.push(cleanItem);
21626
+ } else {
21627
+ const elementKey = `vElem${index}`;
21628
+ Object.keys(item).forEach((itemKey) => {
21629
+ if (itemKey !== "keyId") {
21630
+ const typedItemKey = itemKey;
21631
+ let itemValue = item[typedItemKey];
21632
+ updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
21633
+ }
21634
+ });
21635
+ arrayFilters.push({ [`${elementKey}.keyId`]: new ObjectId41(item.keyId) });
21636
+ }
21637
+ });
21638
+ }
21639
+ if (Array.isArray(value.passKeys)) {
21640
+ value.passKeys.forEach((item, index) => {
21641
+ if (item.add === true) {
21642
+ const { add: add2, ...cleanItem } = item;
21643
+ cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Key Id");
21644
+ if (!pushFields["passKeys"]) {
21645
+ pushFields["passKeys"] = { $each: [] };
21646
+ }
21647
+ pushFields["passKeys"].$each.push(cleanItem);
21648
+ } else {
21649
+ const elementKey = `pElem${index}`;
21650
+ Object.keys(item).forEach((itemKey) => {
21651
+ if (itemKey !== "keyId") {
21652
+ const typedItemKey = itemKey;
21653
+ let itemValue = item[typedItemKey];
21654
+ updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
21655
+ }
21656
+ });
21657
+ arrayFilters.push({ [`${elementKey}.keyId`]: new ObjectId41(item.keyId) });
21658
+ }
21659
+ });
21660
+ }
21661
+ const updatePayload = {};
21662
+ if (Object.keys(updateFields).length > 0) {
21663
+ updatePayload.$set = updateFields;
21664
+ }
21665
+ if (Object.keys(pushFields).length > 0) {
21666
+ updatePayload.$push = pushFields;
21667
+ }
21550
21668
  const result = await collection.updateOne(
21551
- { _id },
21552
- { $set: value },
21553
- { session }
21669
+ { _id: new ObjectId41(_id) },
21670
+ updatePayload,
21671
+ {
21672
+ ...arrayFilters.length > 0 && { arrayFilters },
21673
+ // Only pass if not empty
21674
+ session
21675
+ }
21554
21676
  );
21555
21677
  return result;
21556
21678
  } catch (error) {
@@ -33351,10 +33473,12 @@ var KeyRepo = class {
33351
33473
  return Promise.reject("Server internal error.");
33352
33474
  }
33353
33475
  }
33354
- static async updateKeyById(keyId, key, site, session, isChild) {
33476
+ static async updateKeyById(keyId, key, site, session, isChild, visitorId) {
33355
33477
  keyId = await convertObjectIdUtil2(keyId, "keyId");
33356
33478
  if (site)
33357
33479
  site = await convertObjectIdUtil2(site, "Site");
33480
+ if (visitorId)
33481
+ visitorId = await convertObjectIdUtil2(visitorId, "visitor Id");
33358
33482
  if (key.updatedBy)
33359
33483
  key.updatedBy = await convertObjectIdUtil2(key.updatedBy, "Updated By");
33360
33484
  if (!key.status)
@@ -33371,7 +33495,6 @@ var KeyRepo = class {
33371
33495
  { session }
33372
33496
  );
33373
33497
  let setKeys = [];
33374
- console.log("updateKeyById result", result);
33375
33498
  if (result.modifiedCount > 0) {
33376
33499
  const updatedDocs = await this.collection().find(find).toArray();
33377
33500
  if (Array.isArray(updatedDocs) && updatedDocs.length > 0) {
@@ -33380,6 +33503,10 @@ var KeyRepo = class {
33380
33503
  keyItem["passOrKeyId"] = item?._id;
33381
33504
  keyItem["_id"] = new ObjectId61();
33382
33505
  keyItem["previousStatus"] = item?.status;
33506
+ if (visitorId) {
33507
+ console.log("visitorId true key.repo");
33508
+ keyItem["visitorId"] = visitorId;
33509
+ }
33383
33510
  setKeys.push(keyItem);
33384
33511
  });
33385
33512
  }
@@ -33614,7 +33741,7 @@ var NotificationService = class {
33614
33741
  status: payload.status,
33615
33742
  module: "onlineForm",
33616
33743
  screen,
33617
- params: JSON.stringify(params)
33744
+ params
33618
33745
  },
33619
33746
  false,
33620
33747
  "iservice365-resident-mobile-app"
@@ -33675,6 +33802,14 @@ var NotificationService = class {
33675
33802
  }
33676
33803
  };
33677
33804
 
33805
+ // src/utils/valid-values.ts
33806
+ var VALID_STATUSES = /* @__PURE__ */ new Set([
33807
+ "In Use",
33808
+ "Available",
33809
+ "Damaged",
33810
+ "Lost"
33811
+ ]);
33812
+
33678
33813
  // src/services/visitor-transaction.service.ts
33679
33814
  function useVisitorTransactionService() {
33680
33815
  const MailerConfig = {
@@ -33863,48 +33998,26 @@ function useVisitorTransactionService() {
33863
33998
  const chunk = value.members.slice(i, i + chunkSize);
33864
33999
  for (const member of chunk) {
33865
34000
  await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
33866
- if (Array.isArray(member.visitorPass)) {
33867
- for (const item of member.visitorPass) {
33868
- console.log("Type of keyId:", typeof item.keyId);
33869
- console.log("item visitorPass", item);
33870
- await KeyRepo.updateKeyById(
33871
- item.keyId,
33872
- {
33873
- status: "In Use" /* IN_USE */,
33874
- updatedBy: value.createdBy
33875
- },
33876
- value.site,
33877
- session
33878
- );
33879
- item.receivedDate = /* @__PURE__ */ new Date();
33880
- item.status = "Not Returned" /* NOT_RETURNED */;
33881
- item.lastUpdate = null;
33882
- item.remarks = "";
33883
- }
33884
- }
33885
- if (Array.isArray(member.passKeys)) {
33886
- for (const item of member.passKeys) {
33887
- await KeyRepo.updateKeyById(
33888
- item.keyId,
33889
- {
33890
- status: "In Use" /* IN_USE */,
33891
- updatedBy: value.createdBy
33892
- },
33893
- value.site,
33894
- session
33895
- );
33896
- item.receivedDate = /* @__PURE__ */ new Date();
33897
- item.status = "Not Returned" /* NOT_RETURNED */;
33898
- item.lastUpdate = null;
33899
- item.remarks = "";
33900
- }
33901
- }
33902
34001
  }
33903
34002
  await Promise.all(
33904
- chunk.map((member) => {
34003
+ chunk.map(async (member) => {
33905
34004
  const clonedMember = structuredClone(member);
33906
34005
  const { visitorPass, passKeys } = clonedMember;
33907
- return _add(
34006
+ const preparedVisitorPass = Array.isArray(visitorPass) ? visitorPass.map((item) => ({
34007
+ ...item,
34008
+ receivedDate: /* @__PURE__ */ new Date(),
34009
+ status: "Not Returned" /* NOT_RETURNED */,
34010
+ lastUpdate: null,
34011
+ remarks: ""
34012
+ })) : [];
34013
+ const preparedPassKeys = Array.isArray(passKeys) ? passKeys.map((item) => ({
34014
+ ...item,
34015
+ receivedDate: /* @__PURE__ */ new Date(),
34016
+ status: "Not Returned" /* NOT_RETURNED */,
34017
+ lastUpdate: null,
34018
+ remarks: ""
34019
+ })) : [];
34020
+ const visitorId = await _add(
33908
34021
  {
33909
34022
  ...clonedMember,
33910
34023
  block,
@@ -33918,13 +34031,38 @@ function useVisitorTransactionService() {
33918
34031
  remarks,
33919
34032
  contractorType,
33920
34033
  checkIn: start,
33921
- // expiredAt: end,
33922
- visitorPass: visitorPass ?? [],
33923
- passKeys: passKeys ?? [],
34034
+ visitorPass: preparedVisitorPass,
34035
+ passKeys: preparedPassKeys,
33924
34036
  status: "registered" /* REGISTERED */
33925
34037
  },
33926
34038
  session
33927
34039
  );
34040
+ console.log("visitorId service", visitorId);
34041
+ for (const item of preparedVisitorPass) {
34042
+ await KeyRepo.updateKeyById(
34043
+ item.keyId,
34044
+ {
34045
+ status: "In Use" /* IN_USE */,
34046
+ updatedBy: value.createdBy
34047
+ },
34048
+ value.site,
34049
+ session,
34050
+ void 0,
34051
+ visitorId
34052
+ );
34053
+ }
34054
+ for (const item of preparedPassKeys) {
34055
+ await KeyRepo.updateKeyById(
34056
+ item.keyId,
34057
+ {
34058
+ status: "In Use" /* IN_USE */,
34059
+ updatedBy: value.createdBy,
34060
+ visitorId
34061
+ },
34062
+ value.site,
34063
+ session
34064
+ );
34065
+ }
33928
34066
  })
33929
34067
  );
33930
34068
  }
@@ -33955,15 +34093,6 @@ function useVisitorTransactionService() {
33955
34093
  await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
33956
34094
  if (Array.isArray(value.visitorPass)) {
33957
34095
  for (const item of value.visitorPass) {
33958
- await KeyRepo.updateKeyById(
33959
- item.keyId,
33960
- {
33961
- status: "In Use" /* IN_USE */,
33962
- updatedBy: value.createdBy
33963
- },
33964
- value.site,
33965
- session
33966
- );
33967
34096
  item.receivedDate = /* @__PURE__ */ new Date();
33968
34097
  item.status = "Not Returned" /* NOT_RETURNED */;
33969
34098
  item.lastUpdate = null;
@@ -33972,15 +34101,6 @@ function useVisitorTransactionService() {
33972
34101
  }
33973
34102
  if (Array.isArray(value.passKeys)) {
33974
34103
  for (const item of value.passKeys) {
33975
- await KeyRepo.updateKeyById(
33976
- item.keyId,
33977
- {
33978
- status: "In Use" /* IN_USE */,
33979
- updatedBy: value.createdBy
33980
- },
33981
- value.site,
33982
- session
33983
- );
33984
34104
  item.receivedDate = /* @__PURE__ */ new Date();
33985
34105
  item.status = "Not Returned" /* NOT_RETURNED */;
33986
34106
  item.lastUpdate = null;
@@ -33988,6 +34108,30 @@ function useVisitorTransactionService() {
33988
34108
  }
33989
34109
  }
33990
34110
  const result = await _add(value, session);
34111
+ if (Array.isArray(value.visitorPass)) {
34112
+ for (const item of value.visitorPass) {
34113
+ await KeyRepo.updateKeyById(
34114
+ item.keyId,
34115
+ { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
34116
+ value.site,
34117
+ session,
34118
+ void 0,
34119
+ result
34120
+ );
34121
+ }
34122
+ }
34123
+ if (Array.isArray(value.passKeys)) {
34124
+ for (const item of value.passKeys) {
34125
+ await KeyRepo.updateKeyById(
34126
+ item.keyId,
34127
+ { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
34128
+ value.site,
34129
+ session,
34130
+ void 0,
34131
+ result
34132
+ );
34133
+ }
34134
+ }
33991
34135
  await session?.commitTransaction();
33992
34136
  let openBarrier = null;
33993
34137
  const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
@@ -34061,52 +34205,6 @@ function useVisitorTransactionService() {
34061
34205
  if (found === 1)
34062
34206
  throw new BadRequestError100("This plate number is blocklisted");
34063
34207
  }
34064
- if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
34065
- const keptVisitorPass = [];
34066
- for (const vp of value.visitorPass) {
34067
- const updatePayload = {
34068
- ...vp.status && { status: vp.status },
34069
- ...vp.remarks && { remarks: vp.remarks }
34070
- };
34071
- const visitorPassId = typeof vp === "string" || vp instanceof ObjectId62 ? vp : vp.keyId;
34072
- await KeyRepo.updateKeyById(
34073
- visitorPassId,
34074
- updatePayload,
34075
- value.site
34076
- );
34077
- if (typeof vp !== "string" && !(vp instanceof ObjectId62)) {
34078
- keptVisitorPass.push({
34079
- keyId: new ObjectId62(visitorPassId)
34080
- });
34081
- }
34082
- }
34083
- value.visitorPass = keptVisitorPass;
34084
- }
34085
- if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
34086
- const keptPassKeys = [];
34087
- for (const pk of value.passKeys) {
34088
- try {
34089
- const updatePayload = {
34090
- ...pk.status && { status: pk.status },
34091
- ...pk.remarks && { remarks: pk.remarks }
34092
- };
34093
- const passKeyId = typeof pk === "string" || pk instanceof ObjectId62 ? pk : pk.keyId;
34094
- await KeyRepo.updateKeyById(
34095
- passKeyId,
34096
- updatePayload,
34097
- value.site
34098
- );
34099
- if (typeof pk !== "string" && !(pk instanceof ObjectId62)) {
34100
- keptPassKeys.push({
34101
- keyId: new ObjectId62(passKeyId)
34102
- });
34103
- }
34104
- } catch (error) {
34105
- throw error;
34106
- }
34107
- }
34108
- value.passKeys = keptPassKeys;
34109
- }
34110
34208
  if (value.checkIn) {
34111
34209
  const parsed = new Date(value.checkIn);
34112
34210
  value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
@@ -34123,6 +34221,103 @@ function useVisitorTransactionService() {
34123
34221
  const unit = await _getUnitById(value.unit);
34124
34222
  value.unitName = unit?.name;
34125
34223
  }
34224
+ if (value.updatedBy) {
34225
+ value.updatedBy = await convertObjectIdUtil2(value.updatedBy, "updatedBy Id");
34226
+ }
34227
+ if (Array.isArray(value.visitorPass)) {
34228
+ for (const item of value.visitorPass) {
34229
+ if (item.add) {
34230
+ await KeyRepo.updateKeyById(
34231
+ item.keyId,
34232
+ {
34233
+ status: "In Use" /* IN_USE */,
34234
+ updatedBy: value.updatedBy
34235
+ },
34236
+ value.site,
34237
+ session,
34238
+ void 0,
34239
+ id
34240
+ );
34241
+ item.receivedDate = /* @__PURE__ */ new Date();
34242
+ item.status = "Not Returned" /* NOT_RETURNED */;
34243
+ item.lastUpdate = null;
34244
+ item.remarks = "";
34245
+ } else {
34246
+ let status = "Invalid";
34247
+ if (item?.status == "Returned" /* RETURNED */) {
34248
+ status = "Available" /* AVAILABLE */;
34249
+ } else if (item?.status == "Removed" /* REMOVED */) {
34250
+ status = "Available" /* AVAILABLE */;
34251
+ } else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
34252
+ status = "In Use" /* IN_USE */;
34253
+ } else if (item?.status && VALID_STATUSES.has(item.status)) {
34254
+ status = item.status;
34255
+ } else {
34256
+ throw new Error("Invalid Visitor Pass Status");
34257
+ }
34258
+ await KeyRepo.updateKeyById(
34259
+ item.keyId,
34260
+ {
34261
+ status,
34262
+ updatedBy: value.updatedBy
34263
+ },
34264
+ value.site,
34265
+ session,
34266
+ void 0,
34267
+ id
34268
+ );
34269
+ delete item.receivedDate;
34270
+ item.lastUpdate = /* @__PURE__ */ new Date();
34271
+ }
34272
+ }
34273
+ }
34274
+ if (Array.isArray(value.passKeys)) {
34275
+ for (const item of value.passKeys) {
34276
+ if (item.add) {
34277
+ await KeyRepo.updateKeyById(
34278
+ item.keyId,
34279
+ {
34280
+ status: "In Use" /* IN_USE */,
34281
+ updatedBy: value.updatedBy
34282
+ },
34283
+ value.site,
34284
+ session,
34285
+ void 0,
34286
+ id
34287
+ );
34288
+ item.receivedDate = /* @__PURE__ */ new Date();
34289
+ item.status = "Not Returned" /* NOT_RETURNED */;
34290
+ item.lastUpdate = null;
34291
+ item.remarks = "";
34292
+ } else {
34293
+ let status = "Invalid";
34294
+ if (item?.status == "Returned" /* RETURNED */) {
34295
+ status = "Available" /* AVAILABLE */;
34296
+ } else if (item?.status == "Removed" /* REMOVED */) {
34297
+ status = "Available" /* AVAILABLE */;
34298
+ } else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
34299
+ status = "In Use" /* IN_USE */;
34300
+ } else if (item?.status && VALID_STATUSES.has(item.status)) {
34301
+ status = item.status;
34302
+ } else {
34303
+ throw new Error("Invalid Visitor Pass Status");
34304
+ }
34305
+ await KeyRepo.updateKeyById(
34306
+ item.keyId,
34307
+ {
34308
+ status,
34309
+ updatedBy: value.updatedBy
34310
+ },
34311
+ value.site,
34312
+ session,
34313
+ void 0,
34314
+ id
34315
+ );
34316
+ delete item.receivedDate;
34317
+ item.lastUpdate = /* @__PURE__ */ new Date();
34318
+ }
34319
+ }
34320
+ }
34126
34321
  await _updateVisitorTansactionById(id, value, session);
34127
34322
  const allowedPersonTypes = [
34128
34323
  "contractor" /* CONTRACTOR */,
@@ -60782,7 +60977,6 @@ function useHrmLabsAttendanceSrvc() {
60782
60977
  };
60783
60978
  } catch (error) {
60784
60979
  logger171.error(error.message || error);
60785
- console.log("Error fetching attendance data:", error);
60786
60980
  return { success: false, message: error?.message || "Internal Server Error!", items: [], pages: 0, pageRange: "0-0 of 0", count: {} };
60787
60981
  }
60788
60982
  }
@@ -60896,7 +61090,6 @@ function useHrmLabsAttendanceSrvc() {
60896
61090
  return { totalCount };
60897
61091
  } catch (error) {
60898
61092
  logger171.error(error.message || error);
60899
- console.log("Error fetching attendance data count:", error);
60900
61093
  return { success: false, message: error?.message || "Internal Server Error!", totalCount: null };
60901
61094
  }
60902
61095
  }
@@ -61068,7 +61261,6 @@ function useHrmLabsAttendanceSrvc() {
61068
61261
  };
61069
61262
  } catch (error) {
61070
61263
  logger171.error(error.message || error);
61071
- console.log("Error fetching attendance data:", error);
61072
61264
  return { success: false, message: error?.message || "Internal Server Error!", items: [], count: {}, countPerJobTitle: {}, totalCount: null, countPerStatus: {} };
61073
61265
  }
61074
61266
  }
@@ -61175,7 +61367,6 @@ function useHrmLabsAttendanceSrvc() {
61175
61367
  };
61176
61368
  } catch (error) {
61177
61369
  logger171.error(error.message || error);
61178
- console.log("Error fetching attendance data:", error);
61179
61370
  return { success: false, message: error?.message || "Internal Server Error!", chartCount: null };
61180
61371
  }
61181
61372
  }
@@ -67050,13 +67241,14 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
67050
67241
  var schemaBidPreloved = Joi145.object({
67051
67242
  type: Joi145.string().valid(...Object.values(BidType)).required(),
67052
67243
  postId: Joi145.string().hex().length(24).required(),
67244
+ receiverId: Joi145.string().hex().length(24).required(),
67245
+ buyerId: Joi145.string().hex().length(24).required(),
67053
67246
  price: Joi145.when("type", {
67054
67247
  is: "bid" /* BID */,
67055
67248
  then: Joi145.number().required(),
67056
67249
  otherwise: Joi145.number().optional().allow(null)
67057
67250
  }),
67058
67251
  message: Joi145.string().optional().allow("", null),
67059
- buyerId: Joi145.string().hex().length(24).optional().allow("", null),
67060
67252
  status: Joi145.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
67061
67253
  });
67062
67254
  var schemaUpdateBidPreloved = Joi145.object({
@@ -67131,12 +67323,74 @@ function useBidPrelovedRepo() {
67131
67323
  // src/controllers/bid-preloved.controller.ts
67132
67324
  import { BadRequestError as BadRequestError224, logger as logger194 } from "@7365admin1/node-server-utils";
67133
67325
  import Joi146 from "joi";
67326
+
67327
+ // src/services/bid-preloved.service.ts
67328
+ import { InternalServerError as InternalServerError83, useAtlas as useAtlas128 } from "@7365admin1/node-server-utils";
67329
+ function useBidPrelovedService() {
67330
+ const { add: _addBid } = useBidPrelovedRepo();
67331
+ const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
67332
+ const { add: _addChat } = useChatPrelovedRepo();
67333
+ async function createBid(value) {
67334
+ const client = useAtlas128.getClient();
67335
+ if (!client)
67336
+ throw new InternalServerError83("Unable to connect to server.");
67337
+ const buyerId = value.buyerId;
67338
+ const receiverId = value.receiverId;
67339
+ const postId = value.postId;
67340
+ const messageText = value.message || "";
67341
+ const session = client.startSession();
67342
+ session.startTransaction();
67343
+ try {
67344
+ const bidId = await _addBid(value, session);
67345
+ const existingChannel = await _getByParticipants(
67346
+ buyerId,
67347
+ receiverId,
67348
+ postId
67349
+ );
67350
+ let channelId;
67351
+ if (existingChannel) {
67352
+ channelId = existingChannel._id.toString();
67353
+ } else {
67354
+ const newChannelId = await _addChannel(
67355
+ {
67356
+ senderId: buyerId,
67357
+ receiverId,
67358
+ postId
67359
+ },
67360
+ session
67361
+ );
67362
+ channelId = newChannelId.toString();
67363
+ }
67364
+ await _addChat(
67365
+ {
67366
+ channelId,
67367
+ senderId: buyerId,
67368
+ postId,
67369
+ bidId: bidId.toString(),
67370
+ message: {
67371
+ text: messageText,
67372
+ date: (/* @__PURE__ */ new Date()).toISOString(),
67373
+ senderId: buyerId
67374
+ }
67375
+ },
67376
+ session
67377
+ );
67378
+ await session.commitTransaction();
67379
+ return { bidId };
67380
+ } catch (error) {
67381
+ await session.abortTransaction();
67382
+ throw error;
67383
+ } finally {
67384
+ session.endSession();
67385
+ }
67386
+ }
67387
+ return { createBid };
67388
+ }
67389
+
67390
+ // src/controllers/bid-preloved.controller.ts
67134
67391
  function useBidPrelovedController() {
67135
- const {
67136
- add: _add,
67137
- getById: _getById,
67138
- updateStatus: _updateStatus
67139
- } = useBidPrelovedRepo();
67392
+ const { createBid: _createBid } = useBidPrelovedService();
67393
+ const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
67140
67394
  async function add(req, res, next) {
67141
67395
  const { error, value } = schemaBidPreloved.validate(req.body, {
67142
67396
  abortEarly: false
@@ -67148,9 +67402,10 @@ function useBidPrelovedController() {
67148
67402
  return;
67149
67403
  }
67150
67404
  try {
67151
- const data = await _add(value);
67405
+ const data = await _createBid(value);
67152
67406
  res.status(201).json(data);
67153
67407
  } catch (error2) {
67408
+ console.log("error", error2);
67154
67409
  logger194.log({ level: "error", message: error2.message });
67155
67410
  next(error2);
67156
67411
  }
@@ -67335,20 +67590,20 @@ var residentFormEntry = Joi147.object({
67335
67590
  // src/repositories/online-forms-v2.repository.ts
67336
67591
  import {
67337
67592
  BadRequestError as BadRequestError225,
67338
- InternalServerError as InternalServerError83,
67593
+ InternalServerError as InternalServerError84,
67339
67594
  logger as logger195,
67340
67595
  makeCacheKey as makeCacheKey65,
67341
67596
  NotFoundError as NotFoundError62,
67342
67597
  paginate as paginate64,
67343
- useAtlas as useAtlas128,
67598
+ useAtlas as useAtlas129,
67344
67599
  useCache as useCache69
67345
67600
  } from "@7365admin1/node-server-utils";
67346
67601
  import { ObjectId as ObjectId152 } from "mongodb";
67347
67602
  var online_forms_namespace_collection = "online-forms";
67348
67603
  function useFormEntryRepo() {
67349
- const db = useAtlas128.getDb();
67604
+ const db = useAtlas129.getDb();
67350
67605
  if (!db) {
67351
- throw new InternalServerError83("Unable to connect to server.");
67606
+ throw new InternalServerError84("Unable to connect to server.");
67352
67607
  }
67353
67608
  const collection = db.collection(online_forms_namespace_collection);
67354
67609
  const { delNamespace, getCache, setCache } = useCache69(
@@ -67361,7 +67616,7 @@ function useFormEntryRepo() {
67361
67616
  name: "text"
67362
67617
  });
67363
67618
  } catch (error) {
67364
- throw new InternalServerError83(
67619
+ throw new InternalServerError84(
67365
67620
  "Failed to create text index on online form."
67366
67621
  );
67367
67622
  }
@@ -67370,16 +67625,6 @@ function useFormEntryRepo() {
67370
67625
  try {
67371
67626
  value = MFormEntry(value);
67372
67627
  const res = await collection.insertOne(value, { session });
67373
- delNamespace().then(() => {
67374
- logger195.info(
67375
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67376
- );
67377
- }).catch((err) => {
67378
- logger195.error(
67379
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67380
- err
67381
- );
67382
- });
67383
67628
  return res.insertedId;
67384
67629
  } catch (error) {
67385
67630
  const isDuplicated = error.message.includes("duplicate");
@@ -67402,18 +67647,10 @@ function useFormEntryRepo() {
67402
67647
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
67403
67648
  site = new ObjectId152(site);
67404
67649
  org = new ObjectId152(org);
67405
- const cacheOptions = {
67406
- page,
67407
- limit,
67408
- status,
67409
- sort: JSON.stringify(sort),
67410
- site,
67411
- ...search && { search }
67412
- };
67413
67650
  const query = {
67414
67651
  site,
67415
- status,
67416
- org
67652
+ status
67653
+ // org,
67417
67654
  };
67418
67655
  if (search && search !== "") {
67419
67656
  query.$or = [
@@ -67421,15 +67658,6 @@ function useFormEntryRepo() {
67421
67658
  { unitNumber: { $regex: search, $options: "i" } }
67422
67659
  ];
67423
67660
  }
67424
- const cacheKey = makeCacheKey65(
67425
- online_forms_namespace_collection,
67426
- cacheOptions
67427
- );
67428
- const cachedData = await getCache(cacheKey);
67429
- if (cachedData) {
67430
- logger195.info(`Cache hit for key: ${cacheKey}`);
67431
- return cachedData;
67432
- }
67433
67661
  try {
67434
67662
  const items = await collection.aggregate([
67435
67663
  { $match: query },
@@ -67455,23 +67683,12 @@ function useFormEntryRepo() {
67455
67683
  ]).toArray();
67456
67684
  const length = await collection.countDocuments(query);
67457
67685
  const data = paginate64(items, page, limit, length);
67458
- setCache(cacheKey, data, 15 * 60).then(() => {
67459
- logger195.info(`Cache set for key: ${cacheKey}`);
67460
- }).catch((err) => {
67461
- logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
67462
- });
67463
67686
  return data;
67464
67687
  } catch (error) {
67465
67688
  throw error;
67466
67689
  }
67467
67690
  }
67468
67691
  async function getFormEntryById(_id) {
67469
- const cacheKey = makeCacheKey65(online_forms_namespace_collection, { _id });
67470
- const cachedData = await getCache(cacheKey);
67471
- if (cachedData) {
67472
- logger195.info(`Cache hit for key: ${cacheKey}`);
67473
- return cachedData;
67474
- }
67475
67692
  try {
67476
67693
  _id = new ObjectId152(_id);
67477
67694
  } catch (error) {
@@ -67483,11 +67700,6 @@ function useFormEntryRepo() {
67483
67700
  if (!data) {
67484
67701
  throw new NotFoundError62("Document not found.");
67485
67702
  }
67486
- setCache(cacheKey, data, 15 * 60).then(() => {
67487
- logger195.info(`Cache set for key: ${cacheKey}`);
67488
- }).catch((err) => {
67489
- logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
67490
- });
67491
67703
  return data;
67492
67704
  } catch (error) {
67493
67705
  throw error;
@@ -67506,7 +67718,7 @@ function useFormEntryRepo() {
67506
67718
  };
67507
67719
  const res = await collection.updateOne({ _id }, { $set: updateValue });
67508
67720
  if (res.modifiedCount === 0) {
67509
- throw new InternalServerError83("Unable to update online form.");
67721
+ throw new InternalServerError84("Unable to update online form.");
67510
67722
  }
67511
67723
  const onlineFormRequest = await collection.findOne({ _id });
67512
67724
  if (!onlineFormRequest) {
@@ -67520,23 +67732,7 @@ function useFormEntryRepo() {
67520
67732
  await NotificationService.onlineFormRequestStatusUpdated({
67521
67733
  to: userId,
67522
67734
  onlineFormId: onlineFormRequest._id,
67523
- // typeOfForm: onlineFormRequest.typeOfForm,
67524
- // unitNumber: onlineFormRequest.unitNumber,
67525
67735
  status: onlineFormRequest.status
67526
- // createdAt: onlineFormRequest.createdAt ?? "",
67527
- // fields: onlineFormRequest.fields ?? {},
67528
- // remarks: onlineFormRequest.remarks ?? "",
67529
- // managementValuesJson: onlineFormRequest.managementValues ?? {},
67530
- });
67531
- delNamespace().then(() => {
67532
- logger195.info(
67533
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67534
- );
67535
- }).catch((err) => {
67536
- logger195.error(
67537
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67538
- err
67539
- );
67540
67736
  });
67541
67737
  return res.modifiedCount;
67542
67738
  } catch (error) {
@@ -67561,18 +67757,8 @@ function useFormEntryRepo() {
67561
67757
  { session }
67562
67758
  );
67563
67759
  if (res.modifiedCount === 0) {
67564
- throw new InternalServerError83("Unable to delete online form.");
67760
+ throw new InternalServerError84("Unable to delete online form.");
67565
67761
  }
67566
- delNamespace().then(() => {
67567
- logger195.info(
67568
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67569
- );
67570
- }).catch((err) => {
67571
- logger195.error(
67572
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67573
- err
67574
- );
67575
- });
67576
67762
  return res.modifiedCount;
67577
67763
  } catch (error) {
67578
67764
  throw new Error(error.message);
@@ -67584,16 +67770,6 @@ function useFormEntryRepo() {
67584
67770
  value.org = new ObjectId152(value.org);
67585
67771
  value.userId = new ObjectId152(value.userId);
67586
67772
  const res = await collection.insertOne(value, { session });
67587
- delNamespace().then(() => {
67588
- logger195.info(
67589
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67590
- );
67591
- }).catch((err) => {
67592
- logger195.error(
67593
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67594
- err
67595
- );
67596
- });
67597
67773
  return res.insertedId;
67598
67774
  } catch (error) {
67599
67775
  const isDuplicated = error.message.includes("duplicate");
@@ -67606,22 +67782,61 @@ function useFormEntryRepo() {
67606
67782
  async function residentForm({
67607
67783
  userId,
67608
67784
  site,
67609
- org
67785
+ org,
67786
+ search = "",
67787
+ page = 1,
67788
+ limit = 10,
67789
+ sort = {}
67610
67790
  }) {
67791
+ page = page > 0 ? page - 1 : 0;
67792
+ sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
67793
+ const user = new ObjectId152(userId);
67794
+ const siteId = new ObjectId152(site);
67795
+ const orgId = new ObjectId152(org);
67796
+ const cacheOptions = {
67797
+ page,
67798
+ limit,
67799
+ sort: JSON.stringify(sort),
67800
+ userId: user,
67801
+ site: siteId,
67802
+ org: orgId,
67803
+ ...search && { search }
67804
+ };
67805
+ const query = {
67806
+ userId: user,
67807
+ site: siteId,
67808
+ org: orgId
67809
+ };
67810
+ if (search && search !== "") {
67811
+ query.$or = [
67812
+ { typeOfForm: { $regex: search, $options: "i" } },
67813
+ { unitNumber: { $regex: search, $options: "i" } }
67814
+ ];
67815
+ }
67816
+ const cacheKey = makeCacheKey65(
67817
+ online_forms_namespace_collection,
67818
+ cacheOptions
67819
+ );
67820
+ const cachedData = await getCache(cacheKey);
67821
+ if (cachedData) {
67822
+ logger195.info(`Cache hit for key: ${cacheKey}`);
67823
+ return cachedData;
67824
+ }
67611
67825
  try {
67612
- const user = new ObjectId152(userId);
67613
- const siteId = new ObjectId152(site);
67614
- const orgId = new ObjectId152(org);
67615
- const res = await collection.aggregate([
67616
- {
67617
- $match: {
67618
- userId: user,
67619
- site: siteId,
67620
- org: orgId
67621
- }
67622
- }
67826
+ const items = await collection.aggregate([
67827
+ { $match: query },
67828
+ { $sort: sort },
67829
+ { $skip: page * limit },
67830
+ { $limit: limit }
67623
67831
  ]).toArray();
67624
- return res;
67832
+ const length = await collection.countDocuments(query);
67833
+ const data = paginate64(items, page, limit, length);
67834
+ setCache(cacheKey, data, 15 * 60).then(() => {
67835
+ logger195.info(`Cache set for key: ${cacheKey}`);
67836
+ }).catch((err) => {
67837
+ logger195.error(`Failed to set cache for key: ${cacheKey}`, err);
67838
+ });
67839
+ return data;
67625
67840
  } catch (error) {
67626
67841
  throw error;
67627
67842
  }
@@ -67853,20 +68068,25 @@ function useFormEntryController() {
67853
68068
  }
67854
68069
  async function residentForm(req, res, next) {
67855
68070
  try {
67856
- const { site, userId, org } = req.query;
67857
68071
  const residentFormPayload = Joi148.object({
67858
68072
  org: Joi148.string().hex().required(),
67859
68073
  site: Joi148.string().hex().required(),
67860
- userId: Joi148.string().hex().required()
68074
+ userId: Joi148.string().hex().required(),
68075
+ search: Joi148.string().optional().allow("", null),
68076
+ page: Joi148.number().integer().min(1).allow("", null).default(1),
68077
+ limit: Joi148.number().integer().min(1).max(100).allow("", null).default(10)
68078
+ });
68079
+ const { error, value } = residentFormPayload.validate(req.query, {
68080
+ abortEarly: true
67861
68081
  });
67862
- const { error } = residentFormPayload.validate({ site, userId, org }, { abortEarly: true });
67863
68082
  if (error) {
67864
68083
  const messages = error.details.map((d) => d.message).join(", ");
67865
68084
  logger196.log({ level: "error", message: messages });
67866
68085
  next(new BadRequestError226(messages));
67867
68086
  return;
67868
68087
  }
67869
- const result = await _residentForm({ userId, site, org });
68088
+ const { site, userId, org, search, page, limit } = value;
68089
+ const result = await _residentForm({ userId, site, org, search, page, limit });
67870
68090
  res.json(result);
67871
68091
  } catch (error) {
67872
68092
  logger196.log({ level: "error", message: error.message });
@@ -67887,11 +68107,11 @@ function useFormEntryController() {
67887
68107
  }
67888
68108
 
67889
68109
  // src/services/building-level.service.ts
67890
- import { useAtlas as useAtlas129 } from "@7365admin1/node-server-utils";
68110
+ import { useAtlas as useAtlas130 } from "@7365admin1/node-server-utils";
67891
68111
  function useBuildingLevelService() {
67892
68112
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
67893
68113
  async function add(value) {
67894
- const session = useAtlas129.getClient()?.startSession();
68114
+ const session = useAtlas130.getClient()?.startSession();
67895
68115
  try {
67896
68116
  session?.startTransaction();
67897
68117
  await _add(value, session);
@@ -67905,7 +68125,7 @@ function useBuildingLevelService() {
67905
68125
  }
67906
68126
  }
67907
68127
  async function updateLevelById(_id, value) {
67908
- const session = useAtlas129.getClient()?.startSession();
68128
+ const session = useAtlas130.getClient()?.startSession();
67909
68129
  try {
67910
68130
  session?.startTransaction();
67911
68131
  await _updateLevelById(_id, value, session);
@@ -68391,17 +68611,17 @@ function MHidAmicoIdentity(value) {
68391
68611
  // src/repositories/hid-amico.repo.ts
68392
68612
  import {
68393
68613
  BadRequestError as BadRequestError229,
68394
- InternalServerError as InternalServerError84,
68614
+ InternalServerError as InternalServerError85,
68395
68615
  logger as logger199,
68396
68616
  paginate as paginate65,
68397
- useAtlas as useAtlas130
68617
+ useAtlas as useAtlas131
68398
68618
  } from "@7365admin1/node-server-utils";
68399
68619
  import { ObjectId as ObjectId154 } from "mongodb";
68400
68620
  function useHidAmicoRepo() {
68401
68621
  function db() {
68402
- const instance = useAtlas130.getDb();
68622
+ const instance = useAtlas131.getDb();
68403
68623
  if (!instance) {
68404
- throw new InternalServerError84("Unable to connect to server.");
68624
+ throw new InternalServerError85("Unable to connect to server.");
68405
68625
  }
68406
68626
  return instance;
68407
68627
  }