@7365admin1/core 3.10.0 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21156,7 +21156,8 @@ var schemaUpdateVisTrans = import_joi37.default.object({
21156
21156
  ).optional().allow(null),
21157
21157
  contact: import_joi37.default.string().optional().allow(null, "")
21158
21158
  })
21159
- ).optional().allow(null)
21159
+ ).optional().allow(null),
21160
+ updatedBy: import_joi37.default.string().hex().length(24).optional()
21160
21161
  });
21161
21162
  function MVisitorTransaction(value) {
21162
21163
  const { error } = schemaVisitorTransaction.validate(value, {
@@ -21806,10 +21807,44 @@ function useVisitorTransactionRepo() {
21806
21807
  value.manualCheckout = true;
21807
21808
  }
21808
21809
  try {
21810
+ const updateFields = {};
21811
+ const arrayFilters = [];
21812
+ Object.keys(value).forEach((key) => {
21813
+ if (key !== "visitorPass" && key !== "passKeys") {
21814
+ const typedKey = key;
21815
+ updateFields[key] = value[typedKey];
21816
+ }
21817
+ });
21818
+ if (Array.isArray(value.visitorPass)) {
21819
+ value.visitorPass.forEach((item, index) => {
21820
+ const elementKey = `vElem${index}`;
21821
+ Object.keys(item).forEach((itemKey) => {
21822
+ if (itemKey !== "keyId") {
21823
+ const typedItemKey = itemKey;
21824
+ let itemValue = item[typedItemKey];
21825
+ updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
21826
+ }
21827
+ });
21828
+ arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
21829
+ });
21830
+ }
21831
+ if (Array.isArray(value.passKeys)) {
21832
+ value.passKeys.forEach((item, index) => {
21833
+ const elementKey = `pElem${index}`;
21834
+ Object.keys(item).forEach((itemKey) => {
21835
+ if (itemKey !== "keyId") {
21836
+ const typedItemKey = itemKey;
21837
+ let itemValue = item[typedItemKey];
21838
+ updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
21839
+ }
21840
+ });
21841
+ arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
21842
+ });
21843
+ }
21809
21844
  const result = await collection.updateOne(
21810
- { _id },
21811
- { $set: value },
21812
- { session }
21845
+ { _id: new import_mongodb41.ObjectId(_id) },
21846
+ { $set: updateFields },
21847
+ { arrayFilters, session }
21813
21848
  );
21814
21849
  return result;
21815
21850
  } catch (error) {
@@ -33502,10 +33537,12 @@ var KeyRepo = class {
33502
33537
  return Promise.reject("Server internal error.");
33503
33538
  }
33504
33539
  }
33505
- static async updateKeyById(keyId, key, site, session, isChild) {
33540
+ static async updateKeyById(keyId, key, site, session, isChild, visitorId) {
33506
33541
  keyId = await convertObjectIdUtil2(keyId, "keyId");
33507
33542
  if (site)
33508
33543
  site = await convertObjectIdUtil2(site, "Site");
33544
+ if (visitorId)
33545
+ visitorId = await convertObjectIdUtil2(visitorId, "visitor Id");
33509
33546
  if (key.updatedBy)
33510
33547
  key.updatedBy = await convertObjectIdUtil2(key.updatedBy, "Updated By");
33511
33548
  if (!key.status)
@@ -33522,7 +33559,6 @@ var KeyRepo = class {
33522
33559
  { session }
33523
33560
  );
33524
33561
  let setKeys = [];
33525
- console.log("updateKeyById result", result);
33526
33562
  if (result.modifiedCount > 0) {
33527
33563
  const updatedDocs = await this.collection().find(find).toArray();
33528
33564
  if (Array.isArray(updatedDocs) && updatedDocs.length > 0) {
@@ -33531,6 +33567,10 @@ var KeyRepo = class {
33531
33567
  keyItem["passOrKeyId"] = item?._id;
33532
33568
  keyItem["_id"] = new import_mongodb61.ObjectId();
33533
33569
  keyItem["previousStatus"] = item?.status;
33570
+ if (visitorId) {
33571
+ console.log("visitorId true key.repo");
33572
+ keyItem["visitorId"] = visitorId;
33573
+ }
33534
33574
  setKeys.push(keyItem);
33535
33575
  });
33536
33576
  }
@@ -33765,7 +33805,7 @@ var NotificationService = class {
33765
33805
  status: payload.status,
33766
33806
  module: "onlineForm",
33767
33807
  screen,
33768
- params: JSON.stringify(params)
33808
+ params
33769
33809
  },
33770
33810
  false,
33771
33811
  "iservice365-resident-mobile-app"
@@ -33826,6 +33866,14 @@ var NotificationService = class {
33826
33866
  }
33827
33867
  };
33828
33868
 
33869
+ // src/utils/valid-values.ts
33870
+ var VALID_STATUSES = /* @__PURE__ */ new Set([
33871
+ "In Use",
33872
+ "Available",
33873
+ "Damaged",
33874
+ "Lost"
33875
+ ]);
33876
+
33829
33877
  // src/services/visitor-transaction.service.ts
33830
33878
  function useVisitorTransactionService() {
33831
33879
  const MailerConfig = {
@@ -34014,48 +34062,26 @@ function useVisitorTransactionService() {
34014
34062
  const chunk = value.members.slice(i, i + chunkSize);
34015
34063
  for (const member of chunk) {
34016
34064
  await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
34017
- if (Array.isArray(member.visitorPass)) {
34018
- for (const item of member.visitorPass) {
34019
- console.log("Type of keyId:", typeof item.keyId);
34020
- console.log("item visitorPass", item);
34021
- await KeyRepo.updateKeyById(
34022
- item.keyId,
34023
- {
34024
- status: "In Use" /* IN_USE */,
34025
- updatedBy: value.createdBy
34026
- },
34027
- value.site,
34028
- session
34029
- );
34030
- item.receivedDate = /* @__PURE__ */ new Date();
34031
- item.status = "Not Returned" /* NOT_RETURNED */;
34032
- item.lastUpdate = null;
34033
- item.remarks = "";
34034
- }
34035
- }
34036
- if (Array.isArray(member.passKeys)) {
34037
- for (const item of member.passKeys) {
34038
- await KeyRepo.updateKeyById(
34039
- item.keyId,
34040
- {
34041
- status: "In Use" /* IN_USE */,
34042
- updatedBy: value.createdBy
34043
- },
34044
- value.site,
34045
- session
34046
- );
34047
- item.receivedDate = /* @__PURE__ */ new Date();
34048
- item.status = "Not Returned" /* NOT_RETURNED */;
34049
- item.lastUpdate = null;
34050
- item.remarks = "";
34051
- }
34052
- }
34053
34065
  }
34054
34066
  await Promise.all(
34055
- chunk.map((member) => {
34067
+ chunk.map(async (member) => {
34056
34068
  const clonedMember = structuredClone(member);
34057
34069
  const { visitorPass, passKeys } = clonedMember;
34058
- return _add(
34070
+ const preparedVisitorPass = Array.isArray(visitorPass) ? visitorPass.map((item) => ({
34071
+ ...item,
34072
+ receivedDate: /* @__PURE__ */ new Date(),
34073
+ status: "Not Returned" /* NOT_RETURNED */,
34074
+ lastUpdate: null,
34075
+ remarks: ""
34076
+ })) : [];
34077
+ const preparedPassKeys = Array.isArray(passKeys) ? passKeys.map((item) => ({
34078
+ ...item,
34079
+ receivedDate: /* @__PURE__ */ new Date(),
34080
+ status: "Not Returned" /* NOT_RETURNED */,
34081
+ lastUpdate: null,
34082
+ remarks: ""
34083
+ })) : [];
34084
+ const visitorId = await _add(
34059
34085
  {
34060
34086
  ...clonedMember,
34061
34087
  block,
@@ -34069,13 +34095,38 @@ function useVisitorTransactionService() {
34069
34095
  remarks,
34070
34096
  contractorType,
34071
34097
  checkIn: start,
34072
- // expiredAt: end,
34073
- visitorPass: visitorPass ?? [],
34074
- passKeys: passKeys ?? [],
34098
+ visitorPass: preparedVisitorPass,
34099
+ passKeys: preparedPassKeys,
34075
34100
  status: "registered" /* REGISTERED */
34076
34101
  },
34077
34102
  session
34078
34103
  );
34104
+ console.log("visitorId service", visitorId);
34105
+ for (const item of preparedVisitorPass) {
34106
+ await KeyRepo.updateKeyById(
34107
+ item.keyId,
34108
+ {
34109
+ status: "In Use" /* IN_USE */,
34110
+ updatedBy: value.createdBy
34111
+ },
34112
+ value.site,
34113
+ session,
34114
+ void 0,
34115
+ visitorId
34116
+ );
34117
+ }
34118
+ for (const item of preparedPassKeys) {
34119
+ await KeyRepo.updateKeyById(
34120
+ item.keyId,
34121
+ {
34122
+ status: "In Use" /* IN_USE */,
34123
+ updatedBy: value.createdBy,
34124
+ visitorId
34125
+ },
34126
+ value.site,
34127
+ session
34128
+ );
34129
+ }
34079
34130
  })
34080
34131
  );
34081
34132
  }
@@ -34104,6 +34155,7 @@ function useVisitorTransactionService() {
34104
34155
  throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
34105
34156
  }
34106
34157
  await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
34158
+ const result = await _add(value, session);
34107
34159
  if (Array.isArray(value.visitorPass)) {
34108
34160
  for (const item of value.visitorPass) {
34109
34161
  await KeyRepo.updateKeyById(
@@ -34113,7 +34165,9 @@ function useVisitorTransactionService() {
34113
34165
  updatedBy: value.createdBy
34114
34166
  },
34115
34167
  value.site,
34116
- session
34168
+ session,
34169
+ void 0,
34170
+ result
34117
34171
  );
34118
34172
  item.receivedDate = /* @__PURE__ */ new Date();
34119
34173
  item.status = "Not Returned" /* NOT_RETURNED */;
@@ -34130,7 +34184,9 @@ function useVisitorTransactionService() {
34130
34184
  updatedBy: value.createdBy
34131
34185
  },
34132
34186
  value.site,
34133
- session
34187
+ session,
34188
+ void 0,
34189
+ result
34134
34190
  );
34135
34191
  item.receivedDate = /* @__PURE__ */ new Date();
34136
34192
  item.status = "Not Returned" /* NOT_RETURNED */;
@@ -34138,7 +34194,6 @@ function useVisitorTransactionService() {
34138
34194
  item.remarks = "";
34139
34195
  }
34140
34196
  }
34141
- const result = await _add(value, session);
34142
34197
  await session?.commitTransaction();
34143
34198
  let openBarrier = null;
34144
34199
  const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
@@ -34212,52 +34267,6 @@ function useVisitorTransactionService() {
34212
34267
  if (found === 1)
34213
34268
  throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
34214
34269
  }
34215
- if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
34216
- const keptVisitorPass = [];
34217
- for (const vp of value.visitorPass) {
34218
- const updatePayload = {
34219
- ...vp.status && { status: vp.status },
34220
- ...vp.remarks && { remarks: vp.remarks }
34221
- };
34222
- const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb62.ObjectId ? vp : vp.keyId;
34223
- await KeyRepo.updateKeyById(
34224
- visitorPassId,
34225
- updatePayload,
34226
- value.site
34227
- );
34228
- if (typeof vp !== "string" && !(vp instanceof import_mongodb62.ObjectId)) {
34229
- keptVisitorPass.push({
34230
- keyId: new import_mongodb62.ObjectId(visitorPassId)
34231
- });
34232
- }
34233
- }
34234
- value.visitorPass = keptVisitorPass;
34235
- }
34236
- if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
34237
- const keptPassKeys = [];
34238
- for (const pk of value.passKeys) {
34239
- try {
34240
- const updatePayload = {
34241
- ...pk.status && { status: pk.status },
34242
- ...pk.remarks && { remarks: pk.remarks }
34243
- };
34244
- const passKeyId = typeof pk === "string" || pk instanceof import_mongodb62.ObjectId ? pk : pk.keyId;
34245
- await KeyRepo.updateKeyById(
34246
- passKeyId,
34247
- updatePayload,
34248
- value.site
34249
- );
34250
- if (typeof pk !== "string" && !(pk instanceof import_mongodb62.ObjectId)) {
34251
- keptPassKeys.push({
34252
- keyId: new import_mongodb62.ObjectId(passKeyId)
34253
- });
34254
- }
34255
- } catch (error) {
34256
- throw error;
34257
- }
34258
- }
34259
- value.passKeys = keptPassKeys;
34260
- }
34261
34270
  if (value.checkIn) {
34262
34271
  const parsed = new Date(value.checkIn);
34263
34272
  value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
@@ -34274,6 +34283,61 @@ function useVisitorTransactionService() {
34274
34283
  const unit = await _getUnitById(value.unit);
34275
34284
  value.unitName = unit?.name;
34276
34285
  }
34286
+ if (value.updatedBy) {
34287
+ value.updatedBy = await convertObjectIdUtil2(value.updatedBy, "updatedBy Id");
34288
+ }
34289
+ if (Array.isArray(value.visitorPass)) {
34290
+ for (const item of value.visitorPass) {
34291
+ let status = "Invalid";
34292
+ if (item?.status == "Returned" /* RETURNED */) {
34293
+ status = "Available" /* AVAILABLE */;
34294
+ } else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
34295
+ status = "In Use" /* IN_USE */;
34296
+ } else if (item?.status && VALID_STATUSES.has(item.status)) {
34297
+ status = item.status;
34298
+ } else {
34299
+ throw new Error("Invalid Visitor Pass Status");
34300
+ }
34301
+ await KeyRepo.updateKeyById(
34302
+ item.keyId,
34303
+ {
34304
+ status,
34305
+ updatedBy: value.updatedBy
34306
+ },
34307
+ value.site,
34308
+ session,
34309
+ void 0,
34310
+ id
34311
+ );
34312
+ item.lastUpdate = /* @__PURE__ */ new Date();
34313
+ }
34314
+ }
34315
+ if (Array.isArray(value.passKeys)) {
34316
+ for (const item of value.passKeys) {
34317
+ let status = "Invalid";
34318
+ if (item?.status == "Returned" /* RETURNED */) {
34319
+ status = "Available" /* AVAILABLE */;
34320
+ } else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
34321
+ status = "In Use" /* IN_USE */;
34322
+ } else if (item?.status && VALID_STATUSES.has(item.status)) {
34323
+ status = item.status;
34324
+ } else {
34325
+ throw new Error("Invalid Visitor Pass Status");
34326
+ }
34327
+ await KeyRepo.updateKeyById(
34328
+ item.keyId,
34329
+ {
34330
+ status,
34331
+ updatedBy: value.updatedBy
34332
+ },
34333
+ value.site,
34334
+ session,
34335
+ void 0,
34336
+ id
34337
+ );
34338
+ item.lastUpdate = /* @__PURE__ */ new Date();
34339
+ }
34340
+ }
34277
34341
  await _updateVisitorTansactionById(id, value, session);
34278
34342
  const allowedPersonTypes = [
34279
34343
  "contractor" /* CONTRACTOR */,
@@ -60602,7 +60666,6 @@ function useHrmLabsAttendanceSrvc() {
60602
60666
  };
60603
60667
  } catch (error) {
60604
60668
  import_node_server_utils213.logger.error(error.message || error);
60605
- console.log("Error fetching attendance data:", error);
60606
60669
  return { success: false, message: error?.message || "Internal Server Error!", items: [], pages: 0, pageRange: "0-0 of 0", count: {} };
60607
60670
  }
60608
60671
  }
@@ -60716,7 +60779,6 @@ function useHrmLabsAttendanceSrvc() {
60716
60779
  return { totalCount };
60717
60780
  } catch (error) {
60718
60781
  import_node_server_utils213.logger.error(error.message || error);
60719
- console.log("Error fetching attendance data count:", error);
60720
60782
  return { success: false, message: error?.message || "Internal Server Error!", totalCount: null };
60721
60783
  }
60722
60784
  }
@@ -60888,7 +60950,6 @@ function useHrmLabsAttendanceSrvc() {
60888
60950
  };
60889
60951
  } catch (error) {
60890
60952
  import_node_server_utils213.logger.error(error.message || error);
60891
- console.log("Error fetching attendance data:", error);
60892
60953
  return { success: false, message: error?.message || "Internal Server Error!", items: [], count: {}, countPerJobTitle: {}, totalCount: null, countPerStatus: {} };
60893
60954
  }
60894
60955
  }
@@ -60995,7 +61056,6 @@ function useHrmLabsAttendanceSrvc() {
60995
61056
  };
60996
61057
  } catch (error) {
60997
61058
  import_node_server_utils213.logger.error(error.message || error);
60998
- console.log("Error fetching attendance data:", error);
60999
61059
  return { success: false, message: error?.message || "Internal Server Error!", chartCount: null };
61000
61060
  }
61001
61061
  }
@@ -66781,13 +66841,14 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
66781
66841
  var schemaBidPreloved = import_joi145.default.object({
66782
66842
  type: import_joi145.default.string().valid(...Object.values(BidType)).required(),
66783
66843
  postId: import_joi145.default.string().hex().length(24).required(),
66844
+ receiverId: import_joi145.default.string().hex().length(24).required(),
66845
+ buyerId: import_joi145.default.string().hex().length(24).required(),
66784
66846
  price: import_joi145.default.when("type", {
66785
66847
  is: "bid" /* BID */,
66786
66848
  then: import_joi145.default.number().required(),
66787
66849
  otherwise: import_joi145.default.number().optional().allow(null)
66788
66850
  }),
66789
66851
  message: import_joi145.default.string().optional().allow("", null),
66790
- buyerId: import_joi145.default.string().hex().length(24).optional().allow("", null),
66791
66852
  status: import_joi145.default.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
66792
66853
  });
66793
66854
  var schemaUpdateBidPreloved = import_joi145.default.object({
@@ -66856,29 +66917,92 @@ function useBidPrelovedRepo() {
66856
66917
  }
66857
66918
 
66858
66919
  // src/controllers/bid-preloved.controller.ts
66859
- var import_node_server_utils251 = require("@7365admin1/node-server-utils");
66920
+ var import_node_server_utils252 = require("@7365admin1/node-server-utils");
66860
66921
  var import_joi146 = __toESM(require("joi"));
66922
+
66923
+ // src/services/bid-preloved.service.ts
66924
+ var import_node_server_utils251 = require("@7365admin1/node-server-utils");
66925
+ function useBidPrelovedService() {
66926
+ const { add: _addBid } = useBidPrelovedRepo();
66927
+ const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
66928
+ const { add: _addChat } = useChatPrelovedRepo();
66929
+ async function createBid(value) {
66930
+ const client = import_node_server_utils251.useAtlas.getClient();
66931
+ if (!client)
66932
+ throw new import_node_server_utils251.InternalServerError("Unable to connect to server.");
66933
+ const buyerId = value.buyerId;
66934
+ const receiverId = value.receiverId;
66935
+ const postId = value.postId;
66936
+ const messageText = value.message || "";
66937
+ const session = client.startSession();
66938
+ session.startTransaction();
66939
+ try {
66940
+ const bidId = await _addBid(value, session);
66941
+ const existingChannel = await _getByParticipants(
66942
+ buyerId,
66943
+ receiverId,
66944
+ postId
66945
+ );
66946
+ let channelId;
66947
+ if (existingChannel) {
66948
+ channelId = existingChannel._id.toString();
66949
+ } else {
66950
+ const newChannelId = await _addChannel(
66951
+ {
66952
+ senderId: buyerId,
66953
+ receiverId,
66954
+ postId
66955
+ },
66956
+ session
66957
+ );
66958
+ channelId = newChannelId.toString();
66959
+ }
66960
+ await _addChat(
66961
+ {
66962
+ channelId,
66963
+ senderId: buyerId,
66964
+ postId,
66965
+ bidId: bidId.toString(),
66966
+ message: {
66967
+ text: messageText,
66968
+ date: (/* @__PURE__ */ new Date()).toISOString(),
66969
+ senderId: buyerId
66970
+ }
66971
+ },
66972
+ session
66973
+ );
66974
+ await session.commitTransaction();
66975
+ return { bidId };
66976
+ } catch (error) {
66977
+ await session.abortTransaction();
66978
+ throw error;
66979
+ } finally {
66980
+ session.endSession();
66981
+ }
66982
+ }
66983
+ return { createBid };
66984
+ }
66985
+
66986
+ // src/controllers/bid-preloved.controller.ts
66861
66987
  function useBidPrelovedController() {
66862
- const {
66863
- add: _add,
66864
- getById: _getById,
66865
- updateStatus: _updateStatus
66866
- } = useBidPrelovedRepo();
66988
+ const { createBid: _createBid } = useBidPrelovedService();
66989
+ const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
66867
66990
  async function add(req, res, next) {
66868
66991
  const { error, value } = schemaBidPreloved.validate(req.body, {
66869
66992
  abortEarly: false
66870
66993
  });
66871
66994
  if (error) {
66872
66995
  const messages = error.details.map((d) => d.message).join(", ");
66873
- import_node_server_utils251.logger.log({ level: "error", message: messages });
66874
- next(new import_node_server_utils251.BadRequestError(messages));
66996
+ import_node_server_utils252.logger.log({ level: "error", message: messages });
66997
+ next(new import_node_server_utils252.BadRequestError(messages));
66875
66998
  return;
66876
66999
  }
66877
67000
  try {
66878
- const data = await _add(value);
67001
+ const data = await _createBid(value);
66879
67002
  res.status(201).json(data);
66880
67003
  } catch (error2) {
66881
- import_node_server_utils251.logger.log({ level: "error", message: error2.message });
67004
+ console.log("error", error2);
67005
+ import_node_server_utils252.logger.log({ level: "error", message: error2.message });
66882
67006
  next(error2);
66883
67007
  }
66884
67008
  }
@@ -66890,23 +67014,23 @@ function useBidPrelovedController() {
66890
67014
  req.params
66891
67015
  );
66892
67016
  if (paramError) {
66893
- import_node_server_utils251.logger.log({ level: "error", message: paramError.message });
66894
- next(new import_node_server_utils251.BadRequestError(paramError.message));
67017
+ import_node_server_utils252.logger.log({ level: "error", message: paramError.message });
67018
+ next(new import_node_server_utils252.BadRequestError(paramError.message));
66895
67019
  return;
66896
67020
  }
66897
67021
  const { error: bodyError, value: body } = schemaUpdateBidPreloved.validate(
66898
67022
  req.body
66899
67023
  );
66900
67024
  if (bodyError) {
66901
- import_node_server_utils251.logger.log({ level: "error", message: bodyError.message });
66902
- next(new import_node_server_utils251.BadRequestError(bodyError.message));
67025
+ import_node_server_utils252.logger.log({ level: "error", message: bodyError.message });
67026
+ next(new import_node_server_utils252.BadRequestError(bodyError.message));
66903
67027
  return;
66904
67028
  }
66905
67029
  try {
66906
67030
  const data = await _updateStatus(params.id, body.status);
66907
67031
  res.status(200).json(data);
66908
67032
  } catch (error) {
66909
- import_node_server_utils251.logger.log({ level: "error", message: error.message });
67033
+ import_node_server_utils252.logger.log({ level: "error", message: error.message });
66910
67034
  next(error);
66911
67035
  }
66912
67036
  }
@@ -66916,15 +67040,15 @@ function useBidPrelovedController() {
66916
67040
  });
66917
67041
  const { error, value: params } = paramsSchema.validate(req.params);
66918
67042
  if (error) {
66919
- import_node_server_utils251.logger.log({ level: "error", message: error.message });
66920
- next(new import_node_server_utils251.BadRequestError(error.message));
67043
+ import_node_server_utils252.logger.log({ level: "error", message: error.message });
67044
+ next(new import_node_server_utils252.BadRequestError(error.message));
66921
67045
  return;
66922
67046
  }
66923
67047
  try {
66924
67048
  const data = await _getById(params.id);
66925
67049
  res.status(200).json(data);
66926
67050
  } catch (error2) {
66927
- import_node_server_utils251.logger.log({ level: "error", message: error2.message });
67051
+ import_node_server_utils252.logger.log({ level: "error", message: error2.message });
66928
67052
  next(error2);
66929
67053
  }
66930
67054
  }
@@ -67060,16 +67184,16 @@ var residentFormEntry = import_joi147.default.object({
67060
67184
  });
67061
67185
 
67062
67186
  // src/repositories/online-forms-v2.repository.ts
67063
- var import_node_server_utils252 = require("@7365admin1/node-server-utils");
67187
+ var import_node_server_utils253 = require("@7365admin1/node-server-utils");
67064
67188
  var import_mongodb152 = require("mongodb");
67065
67189
  var online_forms_namespace_collection = "online-forms";
67066
67190
  function useFormEntryRepo() {
67067
- const db = import_node_server_utils252.useAtlas.getDb();
67191
+ const db = import_node_server_utils253.useAtlas.getDb();
67068
67192
  if (!db) {
67069
- throw new import_node_server_utils252.InternalServerError("Unable to connect to server.");
67193
+ throw new import_node_server_utils253.InternalServerError("Unable to connect to server.");
67070
67194
  }
67071
67195
  const collection = db.collection(online_forms_namespace_collection);
67072
- const { delNamespace, getCache, setCache } = (0, import_node_server_utils252.useCache)(
67196
+ const { delNamespace, getCache, setCache } = (0, import_node_server_utils253.useCache)(
67073
67197
  online_forms_namespace_collection
67074
67198
  );
67075
67199
  const { getUserById } = useUserRepo();
@@ -67079,7 +67203,7 @@ function useFormEntryRepo() {
67079
67203
  name: "text"
67080
67204
  });
67081
67205
  } catch (error) {
67082
- throw new import_node_server_utils252.InternalServerError(
67206
+ throw new import_node_server_utils253.InternalServerError(
67083
67207
  "Failed to create text index on online form."
67084
67208
  );
67085
67209
  }
@@ -67088,21 +67212,11 @@ function useFormEntryRepo() {
67088
67212
  try {
67089
67213
  value = MFormEntry(value);
67090
67214
  const res = await collection.insertOne(value, { session });
67091
- delNamespace().then(() => {
67092
- import_node_server_utils252.logger.info(
67093
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67094
- );
67095
- }).catch((err) => {
67096
- import_node_server_utils252.logger.error(
67097
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67098
- err
67099
- );
67100
- });
67101
67215
  return res.insertedId;
67102
67216
  } catch (error) {
67103
67217
  const isDuplicated = error.message.includes("duplicate");
67104
67218
  if (isDuplicated) {
67105
- throw new import_node_server_utils252.BadRequestError("Online Form already exists.");
67219
+ throw new import_node_server_utils253.BadRequestError("Online Form already exists.");
67106
67220
  }
67107
67221
  throw error;
67108
67222
  }
@@ -67120,18 +67234,10 @@ function useFormEntryRepo() {
67120
67234
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
67121
67235
  site = new import_mongodb152.ObjectId(site);
67122
67236
  org = new import_mongodb152.ObjectId(org);
67123
- const cacheOptions = {
67124
- page,
67125
- limit,
67126
- status,
67127
- sort: JSON.stringify(sort),
67128
- site,
67129
- ...search && { search }
67130
- };
67131
67237
  const query = {
67132
67238
  site,
67133
- status,
67134
- org
67239
+ status
67240
+ // org,
67135
67241
  };
67136
67242
  if (search && search !== "") {
67137
67243
  query.$or = [
@@ -67139,15 +67245,6 @@ function useFormEntryRepo() {
67139
67245
  { unitNumber: { $regex: search, $options: "i" } }
67140
67246
  ];
67141
67247
  }
67142
- const cacheKey = (0, import_node_server_utils252.makeCacheKey)(
67143
- online_forms_namespace_collection,
67144
- cacheOptions
67145
- );
67146
- const cachedData = await getCache(cacheKey);
67147
- if (cachedData) {
67148
- import_node_server_utils252.logger.info(`Cache hit for key: ${cacheKey}`);
67149
- return cachedData;
67150
- }
67151
67248
  try {
67152
67249
  const items = await collection.aggregate([
67153
67250
  { $match: query },
@@ -67172,40 +67269,24 @@ function useFormEntryRepo() {
67172
67269
  { $project: { user: 0 } }
67173
67270
  ]).toArray();
67174
67271
  const length = await collection.countDocuments(query);
67175
- const data = (0, import_node_server_utils252.paginate)(items, page, limit, length);
67176
- setCache(cacheKey, data, 15 * 60).then(() => {
67177
- import_node_server_utils252.logger.info(`Cache set for key: ${cacheKey}`);
67178
- }).catch((err) => {
67179
- import_node_server_utils252.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
67180
- });
67272
+ const data = (0, import_node_server_utils253.paginate)(items, page, limit, length);
67181
67273
  return data;
67182
67274
  } catch (error) {
67183
67275
  throw error;
67184
67276
  }
67185
67277
  }
67186
67278
  async function getFormEntryById(_id) {
67187
- const cacheKey = (0, import_node_server_utils252.makeCacheKey)(online_forms_namespace_collection, { _id });
67188
- const cachedData = await getCache(cacheKey);
67189
- if (cachedData) {
67190
- import_node_server_utils252.logger.info(`Cache hit for key: ${cacheKey}`);
67191
- return cachedData;
67192
- }
67193
67279
  try {
67194
67280
  _id = new import_mongodb152.ObjectId(_id);
67195
67281
  } catch (error) {
67196
- throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
67282
+ throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67197
67283
  }
67198
67284
  const query = { _id, status: { $ne: "deleted" } };
67199
67285
  try {
67200
67286
  const [data] = await collection.aggregate([{ $match: query }]).toArray();
67201
67287
  if (!data) {
67202
- throw new import_node_server_utils252.NotFoundError("Document not found.");
67288
+ throw new import_node_server_utils253.NotFoundError("Document not found.");
67203
67289
  }
67204
- setCache(cacheKey, data, 15 * 60).then(() => {
67205
- import_node_server_utils252.logger.info(`Cache set for key: ${cacheKey}`);
67206
- }).catch((err) => {
67207
- import_node_server_utils252.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
67208
- });
67209
67290
  return data;
67210
67291
  } catch (error) {
67211
67292
  throw error;
@@ -67215,7 +67296,7 @@ function useFormEntryRepo() {
67215
67296
  try {
67216
67297
  _id = new import_mongodb152.ObjectId(_id);
67217
67298
  } catch (error) {
67218
- throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
67299
+ throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67219
67300
  }
67220
67301
  try {
67221
67302
  const updateValue = {
@@ -67224,37 +67305,21 @@ function useFormEntryRepo() {
67224
67305
  };
67225
67306
  const res = await collection.updateOne({ _id }, { $set: updateValue });
67226
67307
  if (res.modifiedCount === 0) {
67227
- throw new import_node_server_utils252.InternalServerError("Unable to update online form.");
67308
+ throw new import_node_server_utils253.InternalServerError("Unable to update online form.");
67228
67309
  }
67229
67310
  const onlineFormRequest = await collection.findOne({ _id });
67230
67311
  if (!onlineFormRequest) {
67231
- throw new import_node_server_utils252.NotFoundError("Online form not found.");
67312
+ throw new import_node_server_utils253.NotFoundError("Online form not found.");
67232
67313
  }
67233
67314
  const user = await getUserById(onlineFormRequest.userId.toString());
67234
67315
  if (!user || !user._id) {
67235
- throw new import_node_server_utils252.NotFoundError("User not found.");
67316
+ throw new import_node_server_utils253.NotFoundError("User not found.");
67236
67317
  }
67237
67318
  const userId = user._id.toString();
67238
67319
  await NotificationService.onlineFormRequestStatusUpdated({
67239
67320
  to: userId,
67240
67321
  onlineFormId: onlineFormRequest._id,
67241
- // typeOfForm: onlineFormRequest.typeOfForm,
67242
- // unitNumber: onlineFormRequest.unitNumber,
67243
67322
  status: onlineFormRequest.status
67244
- // createdAt: onlineFormRequest.createdAt ?? "",
67245
- // fields: onlineFormRequest.fields ?? {},
67246
- // remarks: onlineFormRequest.remarks ?? "",
67247
- // managementValuesJson: onlineFormRequest.managementValues ?? {},
67248
- });
67249
- delNamespace().then(() => {
67250
- import_node_server_utils252.logger.info(
67251
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67252
- );
67253
- }).catch((err) => {
67254
- import_node_server_utils252.logger.error(
67255
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67256
- err
67257
- );
67258
67323
  });
67259
67324
  return res.modifiedCount;
67260
67325
  } catch (error) {
@@ -67265,7 +67330,7 @@ function useFormEntryRepo() {
67265
67330
  try {
67266
67331
  _id = new import_mongodb152.ObjectId(_id);
67267
67332
  } catch (error) {
67268
- throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
67333
+ throw new import_node_server_utils253.BadRequestError("Invalid online form ID format.");
67269
67334
  }
67270
67335
  try {
67271
67336
  const updateValue = {
@@ -67279,18 +67344,8 @@ function useFormEntryRepo() {
67279
67344
  { session }
67280
67345
  );
67281
67346
  if (res.modifiedCount === 0) {
67282
- throw new import_node_server_utils252.InternalServerError("Unable to delete online form.");
67347
+ throw new import_node_server_utils253.InternalServerError("Unable to delete online form.");
67283
67348
  }
67284
- delNamespace().then(() => {
67285
- import_node_server_utils252.logger.info(
67286
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67287
- );
67288
- }).catch((err) => {
67289
- import_node_server_utils252.logger.error(
67290
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67291
- err
67292
- );
67293
- });
67294
67349
  return res.modifiedCount;
67295
67350
  } catch (error) {
67296
67351
  throw new Error(error.message);
@@ -67302,21 +67357,11 @@ function useFormEntryRepo() {
67302
67357
  value.org = new import_mongodb152.ObjectId(value.org);
67303
67358
  value.userId = new import_mongodb152.ObjectId(value.userId);
67304
67359
  const res = await collection.insertOne(value, { session });
67305
- delNamespace().then(() => {
67306
- import_node_server_utils252.logger.info(
67307
- `Cache cleared for namespace: ${online_forms_namespace_collection}`
67308
- );
67309
- }).catch((err) => {
67310
- import_node_server_utils252.logger.error(
67311
- `Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
67312
- err
67313
- );
67314
- });
67315
67360
  return res.insertedId;
67316
67361
  } catch (error) {
67317
67362
  const isDuplicated = error.message.includes("duplicate");
67318
67363
  if (isDuplicated) {
67319
- throw new import_node_server_utils252.BadRequestError("Online Form already exists.");
67364
+ throw new import_node_server_utils253.BadRequestError("Online Form already exists.");
67320
67365
  }
67321
67366
  throw error;
67322
67367
  }
@@ -67324,22 +67369,61 @@ function useFormEntryRepo() {
67324
67369
  async function residentForm({
67325
67370
  userId,
67326
67371
  site,
67327
- org
67372
+ org,
67373
+ search = "",
67374
+ page = 1,
67375
+ limit = 10,
67376
+ sort = {}
67328
67377
  }) {
67378
+ page = page > 0 ? page - 1 : 0;
67379
+ sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
67380
+ const user = new import_mongodb152.ObjectId(userId);
67381
+ const siteId = new import_mongodb152.ObjectId(site);
67382
+ const orgId = new import_mongodb152.ObjectId(org);
67383
+ const cacheOptions = {
67384
+ page,
67385
+ limit,
67386
+ sort: JSON.stringify(sort),
67387
+ userId: user,
67388
+ site: siteId,
67389
+ org: orgId,
67390
+ ...search && { search }
67391
+ };
67392
+ const query = {
67393
+ userId: user,
67394
+ site: siteId,
67395
+ org: orgId
67396
+ };
67397
+ if (search && search !== "") {
67398
+ query.$or = [
67399
+ { typeOfForm: { $regex: search, $options: "i" } },
67400
+ { unitNumber: { $regex: search, $options: "i" } }
67401
+ ];
67402
+ }
67403
+ const cacheKey = (0, import_node_server_utils253.makeCacheKey)(
67404
+ online_forms_namespace_collection,
67405
+ cacheOptions
67406
+ );
67407
+ const cachedData = await getCache(cacheKey);
67408
+ if (cachedData) {
67409
+ import_node_server_utils253.logger.info(`Cache hit for key: ${cacheKey}`);
67410
+ return cachedData;
67411
+ }
67329
67412
  try {
67330
- const user = new import_mongodb152.ObjectId(userId);
67331
- const siteId = new import_mongodb152.ObjectId(site);
67332
- const orgId = new import_mongodb152.ObjectId(org);
67333
- const res = await collection.aggregate([
67334
- {
67335
- $match: {
67336
- userId: user,
67337
- site: siteId,
67338
- org: orgId
67339
- }
67340
- }
67413
+ const items = await collection.aggregate([
67414
+ { $match: query },
67415
+ { $sort: sort },
67416
+ { $skip: page * limit },
67417
+ { $limit: limit }
67341
67418
  ]).toArray();
67342
- return res;
67419
+ const length = await collection.countDocuments(query);
67420
+ const data = (0, import_node_server_utils253.paginate)(items, page, limit, length);
67421
+ setCache(cacheKey, data, 15 * 60).then(() => {
67422
+ import_node_server_utils253.logger.info(`Cache set for key: ${cacheKey}`);
67423
+ }).catch((err) => {
67424
+ import_node_server_utils253.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
67425
+ });
67426
+ return data;
67343
67427
  } catch (error) {
67344
67428
  throw error;
67345
67429
  }
@@ -67357,7 +67441,7 @@ function useFormEntryRepo() {
67357
67441
  }
67358
67442
 
67359
67443
  // src/controllers/online-forms-v2.controller.ts
67360
- var import_node_server_utils253 = require("@7365admin1/node-server-utils");
67444
+ var import_node_server_utils254 = require("@7365admin1/node-server-utils");
67361
67445
  var import_joi148 = __toESM(require("joi"));
67362
67446
  var import_exceljs3 = __toESM(require("exceljs"));
67363
67447
  var import_fs7 = __toESM(require("fs"));
@@ -67384,14 +67468,14 @@ function useFormEntryController() {
67384
67468
  async function uploadFormEntrys(req, res, next) {
67385
67469
  try {
67386
67470
  if (!req.file) {
67387
- next(new import_node_server_utils253.BadRequestError("Excel file is required."));
67471
+ next(new import_node_server_utils254.BadRequestError("Excel file is required."));
67388
67472
  return;
67389
67473
  }
67390
67474
  const workbook = new import_exceljs3.default.Workbook();
67391
67475
  await workbook.xlsx.readFile(req.file.path);
67392
67476
  const worksheet = workbook.worksheets[0];
67393
67477
  if (!worksheet) {
67394
- next(new import_node_server_utils253.BadRequestError("No worksheet found in uploaded Excel file."));
67478
+ next(new import_node_server_utils254.BadRequestError("No worksheet found in uploaded Excel file."));
67395
67479
  return;
67396
67480
  }
67397
67481
  const headerRow = worksheet.getRow(1);
@@ -67419,8 +67503,8 @@ function useFormEntryController() {
67419
67503
  });
67420
67504
  if (error) {
67421
67505
  const messages = error.details.map((d) => d.message).join(", ");
67422
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67423
- next(new import_node_server_utils253.BadRequestError(messages));
67506
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67507
+ next(new import_node_server_utils254.BadRequestError(messages));
67424
67508
  return;
67425
67509
  }
67426
67510
  const result = await _add(value);
@@ -67428,7 +67512,7 @@ function useFormEntryController() {
67428
67512
  import_fs7.default.unlink(req.file.path, () => {
67429
67513
  });
67430
67514
  } catch (error) {
67431
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67515
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67432
67516
  next(error);
67433
67517
  }
67434
67518
  }
@@ -67445,8 +67529,8 @@ function useFormEntryController() {
67445
67529
  const { error, value } = schema2.validate(req.query);
67446
67530
  if (error) {
67447
67531
  const messages = error.details.map((d) => d.message).join(", ");
67448
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67449
- next(new import_node_server_utils253.BadRequestError(messages));
67532
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67533
+ next(new import_node_server_utils254.BadRequestError(messages));
67450
67534
  return;
67451
67535
  }
67452
67536
  const { search, page, limit, status, org, site } = value;
@@ -67454,7 +67538,7 @@ function useFormEntryController() {
67454
67538
  res.json(data);
67455
67539
  return;
67456
67540
  } catch (error) {
67457
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67541
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67458
67542
  next(error);
67459
67543
  return;
67460
67544
  }
@@ -67467,8 +67551,8 @@ function useFormEntryController() {
67467
67551
  const { error, value } = schema2.validate({ _id: req.params.id });
67468
67552
  if (error) {
67469
67553
  const messages = error.details.map((d) => d.message).join(", ");
67470
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67471
- next(new import_node_server_utils253.BadRequestError(messages));
67554
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67555
+ next(new import_node_server_utils254.BadRequestError(messages));
67472
67556
  return;
67473
67557
  }
67474
67558
  const { _id } = value;
@@ -67476,7 +67560,7 @@ function useFormEntryController() {
67476
67560
  res.json(data);
67477
67561
  return;
67478
67562
  } catch (error) {
67479
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67563
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67480
67564
  next(error);
67481
67565
  return;
67482
67566
  }
@@ -67489,8 +67573,8 @@ function useFormEntryController() {
67489
67573
  });
67490
67574
  if (error) {
67491
67575
  const messages = error.details.map((d) => d.message).join(", ");
67492
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67493
- next(new import_node_server_utils253.BadRequestError(messages));
67576
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67577
+ next(new import_node_server_utils254.BadRequestError(messages));
67494
67578
  return;
67495
67579
  }
67496
67580
  const { _id, ...rest } = value;
@@ -67498,7 +67582,7 @@ function useFormEntryController() {
67498
67582
  res.json({ message: "Successfully updated online form." });
67499
67583
  return;
67500
67584
  } catch (error) {
67501
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67585
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67502
67586
  next(error);
67503
67587
  return;
67504
67588
  }
@@ -67509,15 +67593,15 @@ function useFormEntryController() {
67509
67593
  const _id = req.params.id;
67510
67594
  const { error } = validation.validate(_id);
67511
67595
  if (error) {
67512
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67513
- next(new import_node_server_utils253.BadRequestError(error.message));
67596
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67597
+ next(new import_node_server_utils254.BadRequestError(error.message));
67514
67598
  return;
67515
67599
  }
67516
67600
  await _deleteOnlineFormById(_id);
67517
67601
  res.json({ message: "Successfully deleted online form." });
67518
67602
  return;
67519
67603
  } catch (error) {
67520
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67604
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67521
67605
  next(error);
67522
67606
  return;
67523
67607
  }
@@ -67534,8 +67618,8 @@ function useFormEntryController() {
67534
67618
  });
67535
67619
  if (error) {
67536
67620
  const messages = error.details.map((d) => d.message).join(", ");
67537
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67538
- next(new import_node_server_utils253.BadRequestError(messages));
67621
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67622
+ next(new import_node_server_utils254.BadRequestError(messages));
67539
67623
  return;
67540
67624
  }
67541
67625
  try {
@@ -67543,7 +67627,7 @@ function useFormEntryController() {
67543
67627
  res.status(201).json({ message: data });
67544
67628
  return;
67545
67629
  } catch (error2) {
67546
- import_node_server_utils253.logger.log({ level: "error", message: error2.message });
67630
+ import_node_server_utils254.logger.log({ level: "error", message: error2.message });
67547
67631
  next(error2);
67548
67632
  return;
67549
67633
  }
@@ -67555,8 +67639,8 @@ function useFormEntryController() {
67555
67639
  });
67556
67640
  if (error) {
67557
67641
  const messages = error.details.map((d) => d.message).join(", ");
67558
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67559
- next(new import_node_server_utils253.BadRequestError(messages));
67642
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67643
+ next(new import_node_server_utils254.BadRequestError(messages));
67560
67644
  return;
67561
67645
  }
67562
67646
  try {
@@ -67564,30 +67648,35 @@ function useFormEntryController() {
67564
67648
  res.status(201).json({ message: data });
67565
67649
  return;
67566
67650
  } catch (error2) {
67567
- import_node_server_utils253.logger.log({ level: "error", message: error2.message });
67651
+ import_node_server_utils254.logger.log({ level: "error", message: error2.message });
67568
67652
  next(error2);
67569
67653
  return;
67570
67654
  }
67571
67655
  }
67572
67656
  async function residentForm(req, res, next) {
67573
67657
  try {
67574
- const { site, userId, org } = req.query;
67575
67658
  const residentFormPayload = import_joi148.default.object({
67576
67659
  org: import_joi148.default.string().hex().required(),
67577
67660
  site: import_joi148.default.string().hex().required(),
67578
- userId: import_joi148.default.string().hex().required()
67661
+ userId: import_joi148.default.string().hex().required(),
67662
+ search: import_joi148.default.string().optional().allow("", null),
67663
+ page: import_joi148.default.number().integer().min(1).allow("", null).default(1),
67664
+ limit: import_joi148.default.number().integer().min(1).max(100).allow("", null).default(10)
67665
+ });
67666
+ const { error, value } = residentFormPayload.validate(req.query, {
67667
+ abortEarly: true
67579
67668
  });
67580
- const { error } = residentFormPayload.validate({ site, userId, org }, { abortEarly: true });
67581
67669
  if (error) {
67582
67670
  const messages = error.details.map((d) => d.message).join(", ");
67583
- import_node_server_utils253.logger.log({ level: "error", message: messages });
67584
- next(new import_node_server_utils253.BadRequestError(messages));
67671
+ import_node_server_utils254.logger.log({ level: "error", message: messages });
67672
+ next(new import_node_server_utils254.BadRequestError(messages));
67585
67673
  return;
67586
67674
  }
67587
- const result = await _residentForm({ userId, site, org });
67675
+ const { site, userId, org, search, page, limit } = value;
67676
+ const result = await _residentForm({ userId, site, org, search, page, limit });
67588
67677
  res.json(result);
67589
67678
  } catch (error) {
67590
- import_node_server_utils253.logger.log({ level: "error", message: error.message });
67679
+ import_node_server_utils254.logger.log({ level: "error", message: error.message });
67591
67680
  next(error);
67592
67681
  return;
67593
67682
  }
@@ -67605,11 +67694,11 @@ function useFormEntryController() {
67605
67694
  }
67606
67695
 
67607
67696
  // src/services/building-level.service.ts
67608
- var import_node_server_utils254 = require("@7365admin1/node-server-utils");
67697
+ var import_node_server_utils255 = require("@7365admin1/node-server-utils");
67609
67698
  function useBuildingLevelService() {
67610
67699
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
67611
67700
  async function add(value) {
67612
- const session = import_node_server_utils254.useAtlas.getClient()?.startSession();
67701
+ const session = import_node_server_utils255.useAtlas.getClient()?.startSession();
67613
67702
  try {
67614
67703
  session?.startTransaction();
67615
67704
  await _add(value, session);
@@ -67623,7 +67712,7 @@ function useBuildingLevelService() {
67623
67712
  }
67624
67713
  }
67625
67714
  async function updateLevelById(_id, value) {
67626
- const session = import_node_server_utils254.useAtlas.getClient()?.startSession();
67715
+ const session = import_node_server_utils255.useAtlas.getClient()?.startSession();
67627
67716
  try {
67628
67717
  session?.startTransaction();
67629
67718
  await _updateLevelById(_id, value, session);
@@ -67643,7 +67732,7 @@ function useBuildingLevelService() {
67643
67732
  }
67644
67733
 
67645
67734
  // src/controllers/building-level.controller.ts
67646
- var import_node_server_utils255 = require("@7365admin1/node-server-utils");
67735
+ var import_node_server_utils256 = require("@7365admin1/node-server-utils");
67647
67736
  var import_joi149 = __toESM(require("joi"));
67648
67737
  function useBuildingLevelController() {
67649
67738
  const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
@@ -67661,8 +67750,8 @@ function useBuildingLevelController() {
67661
67750
  });
67662
67751
  if (error) {
67663
67752
  const messages = error.details.map((d) => d.message).join(", ");
67664
- import_node_server_utils255.logger.log({ level: "error", message: messages });
67665
- next(new import_node_server_utils255.BadRequestError(messages));
67753
+ import_node_server_utils256.logger.log({ level: "error", message: messages });
67754
+ next(new import_node_server_utils256.BadRequestError(messages));
67666
67755
  return;
67667
67756
  }
67668
67757
  const result = await _add(value);
@@ -67685,8 +67774,8 @@ function useBuildingLevelController() {
67685
67774
  });
67686
67775
  if (error) {
67687
67776
  const messages = error.details.map((d) => d.message);
67688
- import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
67689
- next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
67777
+ import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67778
+ next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
67690
67779
  return;
67691
67780
  }
67692
67781
  const { page, limit, status, site, search } = value;
@@ -67711,8 +67800,8 @@ function useBuildingLevelController() {
67711
67800
  const { error, value } = schema2.validate({ id: req.params.id });
67712
67801
  if (error) {
67713
67802
  const messages = error.details.map((d) => d.message);
67714
- import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
67715
- next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
67803
+ import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67804
+ next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
67716
67805
  return;
67717
67806
  }
67718
67807
  const { id } = value;
@@ -67731,8 +67820,8 @@ function useBuildingLevelController() {
67731
67820
  });
67732
67821
  if (error) {
67733
67822
  const messages = error.details.map((d) => d.message);
67734
- import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
67735
- next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
67823
+ import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67824
+ next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
67736
67825
  return;
67737
67826
  }
67738
67827
  const { _id, ...rest } = value;
@@ -67750,8 +67839,8 @@ function useBuildingLevelController() {
67750
67839
  const { error, value } = schema2.validate({ id: req.params.id });
67751
67840
  if (error) {
67752
67841
  const messages = error.details.map((d) => d.message);
67753
- import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
67754
- next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
67842
+ import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67843
+ next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
67755
67844
  return;
67756
67845
  }
67757
67846
  const { id } = value;
@@ -67775,8 +67864,8 @@ function useBuildingLevelController() {
67775
67864
  const { error, value } = schema2.validate(req.body);
67776
67865
  if (error) {
67777
67866
  const messages = error.details.map((d) => d.message);
67778
- import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
67779
- next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
67867
+ import_node_server_utils256.logger.log({ level: "error", message: messages.join(", ") });
67868
+ next(new import_node_server_utils256.BadRequestError(messages.join(", ")));
67780
67869
  return;
67781
67870
  }
67782
67871
  const updates = value.map((item) => ({
@@ -67801,8 +67890,8 @@ function useBuildingLevelController() {
67801
67890
  });
67802
67891
  if (error) {
67803
67892
  const messages = error.details.map((d) => d.message).join(", ");
67804
- import_node_server_utils255.logger.log({ level: "error", message: messages });
67805
- next(new import_node_server_utils255.BadRequestError(messages));
67893
+ import_node_server_utils256.logger.log({ level: "error", message: messages });
67894
+ next(new import_node_server_utils256.BadRequestError(messages));
67806
67895
  return;
67807
67896
  }
67808
67897
  const { site, block } = value;
@@ -67825,7 +67914,7 @@ function useBuildingLevelController() {
67825
67914
  }
67826
67915
 
67827
67916
  // src/models/hid-amico.model.ts
67828
- var import_node_server_utils256 = require("@7365admin1/node-server-utils");
67917
+ var import_node_server_utils257 = require("@7365admin1/node-server-utils");
67829
67918
  var import_mongodb153 = require("mongodb");
67830
67919
  var import_joi150 = __toESM(require("joi"));
67831
67920
  function canReadObjectId(value) {
@@ -67865,7 +67954,7 @@ function toObjectId23(value, label = "ID") {
67865
67954
  return toObjectId23(text, label);
67866
67955
  }
67867
67956
  }
67868
- throw new import_node_server_utils256.BadRequestError(`Invalid ${label} format`);
67957
+ throw new import_node_server_utils257.BadRequestError(`Invalid ${label} format`);
67869
67958
  }
67870
67959
  var objectIdSchema2 = import_joi150.default.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
67871
67960
  "any.invalid": "{{#label}} must be a valid ObjectId"
@@ -68037,8 +68126,8 @@ var schemaHidAmicoNotificationParams = import_joi150.default.object({
68037
68126
  function MHidAmicoReader(value) {
68038
68127
  const { error } = schemaHidAmicoReader.validate(value);
68039
68128
  if (error) {
68040
- import_node_server_utils256.logger.info(`HID Amico reader: ${error.message}`);
68041
- throw new import_node_server_utils256.BadRequestError(error.message);
68129
+ import_node_server_utils257.logger.info(`HID Amico reader: ${error.message}`);
68130
+ throw new import_node_server_utils257.BadRequestError(error.message);
68042
68131
  }
68043
68132
  return {
68044
68133
  _id: value._id ? toObjectId23(value._id, "reader ID") : new import_mongodb153.ObjectId(),
@@ -68064,8 +68153,8 @@ function MHidAmicoReader(value) {
68064
68153
  function MHidAmicoEvent(value) {
68065
68154
  const { error } = schemaHidAmicoEvent.validate(value);
68066
68155
  if (error) {
68067
- import_node_server_utils256.logger.info(`HID Amico event: ${error.message}`);
68068
- throw new import_node_server_utils256.BadRequestError(error.message);
68156
+ import_node_server_utils257.logger.info(`HID Amico event: ${error.message}`);
68157
+ throw new import_node_server_utils257.BadRequestError(error.message);
68069
68158
  }
68070
68159
  return {
68071
68160
  _id: value._id ? toObjectId23(value._id, "event ID") : new import_mongodb153.ObjectId(),
@@ -68083,8 +68172,8 @@ function optionalObjectId(value) {
68083
68172
  function MHidAmicoIdentity(value) {
68084
68173
  const { error } = schemaHidAmicoIdentity.validate(value);
68085
68174
  if (error) {
68086
- import_node_server_utils256.logger.info(`HID Amico identity: ${error.message}`);
68087
- throw new import_node_server_utils256.BadRequestError(error.message);
68175
+ import_node_server_utils257.logger.info(`HID Amico identity: ${error.message}`);
68176
+ throw new import_node_server_utils257.BadRequestError(error.message);
68088
68177
  }
68089
68178
  return {
68090
68179
  _id: value._id ? toObjectId23(value._id, "identity ID") : new import_mongodb153.ObjectId(),
@@ -68107,13 +68196,13 @@ function MHidAmicoIdentity(value) {
68107
68196
  }
68108
68197
 
68109
68198
  // src/repositories/hid-amico.repo.ts
68110
- var import_node_server_utils257 = require("@7365admin1/node-server-utils");
68199
+ var import_node_server_utils258 = require("@7365admin1/node-server-utils");
68111
68200
  var import_mongodb154 = require("mongodb");
68112
68201
  function useHidAmicoRepo() {
68113
68202
  function db() {
68114
- const instance = import_node_server_utils257.useAtlas.getDb();
68203
+ const instance = import_node_server_utils258.useAtlas.getDb();
68115
68204
  if (!instance) {
68116
- throw new import_node_server_utils257.InternalServerError("Unable to connect to server.");
68205
+ throw new import_node_server_utils258.InternalServerError("Unable to connect to server.");
68117
68206
  }
68118
68207
  return instance;
68119
68208
  }
@@ -68130,7 +68219,7 @@ function useHidAmicoRepo() {
68130
68219
  try {
68131
68220
  return new import_mongodb154.ObjectId(id);
68132
68221
  } catch {
68133
- throw new import_node_server_utils257.BadRequestError(`Invalid ${label} format`);
68222
+ throw new import_node_server_utils258.BadRequestError(`Invalid ${label} format`);
68134
68223
  }
68135
68224
  }
68136
68225
  function hideSecret(reader) {
@@ -68181,7 +68270,7 @@ function useHidAmicoRepo() {
68181
68270
  ]);
68182
68271
  return "HID Amico indexes created.";
68183
68272
  } catch (error) {
68184
- import_node_server_utils257.logger.error(error.message);
68273
+ import_node_server_utils258.logger.error(error.message);
68185
68274
  throw new Error("Failed to create HID Amico indexes.");
68186
68275
  }
68187
68276
  }
@@ -68192,7 +68281,7 @@ function useHidAmicoRepo() {
68192
68281
  return hideSecret(doc);
68193
68282
  } catch (error) {
68194
68283
  if (error.message?.includes("duplicate")) {
68195
- throw new import_node_server_utils257.BadRequestError("HID Amico reader already exists for this site and URL.");
68284
+ throw new import_node_server_utils258.BadRequestError("HID Amico reader already exists for this site and URL.");
68196
68285
  }
68197
68286
  throw error;
68198
68287
  }
@@ -68206,7 +68295,7 @@ function useHidAmicoRepo() {
68206
68295
  }
68207
68296
  const items = await readers().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68208
68297
  const total = await readers().countDocuments(query);
68209
- return (0, import_node_server_utils257.paginate)(items.map(hideSecret), page, limit, total);
68298
+ return (0, import_node_server_utils258.paginate)(items.map(hideSecret), page, limit, total);
68210
68299
  }
68211
68300
  async function getById(id, options = {}) {
68212
68301
  const _id = toId(id, "reader ID");
@@ -68214,14 +68303,14 @@ function useHidAmicoRepo() {
68214
68303
  { _id, status: { $ne: "deleted" } }
68215
68304
  );
68216
68305
  if (!reader) {
68217
- throw new import_node_server_utils257.BadRequestError("HID Amico reader not found.");
68306
+ throw new import_node_server_utils258.BadRequestError("HID Amico reader not found.");
68218
68307
  }
68219
68308
  return options.includePassword ? reader : hideSecret(reader);
68220
68309
  }
68221
68310
  async function updateById(id, value, session) {
68222
68311
  const { error } = schemaUpdateHidAmicoReader.validate(value);
68223
68312
  if (error) {
68224
- throw new import_node_server_utils257.BadRequestError(error.message);
68313
+ throw new import_node_server_utils258.BadRequestError(error.message);
68225
68314
  }
68226
68315
  const _id = toId(id, "reader ID");
68227
68316
  const payload = {
@@ -68240,7 +68329,7 @@ function useHidAmicoRepo() {
68240
68329
  { returnDocument: "after", session }
68241
68330
  );
68242
68331
  if (!updated) {
68243
- throw new import_node_server_utils257.BadRequestError("HID Amico reader not found.");
68332
+ throw new import_node_server_utils258.BadRequestError("HID Amico reader not found.");
68244
68333
  }
68245
68334
  return hideSecret(updated);
68246
68335
  }
@@ -68269,7 +68358,7 @@ function useHidAmicoRepo() {
68269
68358
  }
68270
68359
  const items = await events().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68271
68360
  const total = await events().countDocuments(query);
68272
- return (0, import_node_server_utils257.paginate)(items, page, limit, total);
68361
+ return (0, import_node_server_utils258.paginate)(items, page, limit, total);
68273
68362
  }
68274
68363
  async function addIdentity(value, session) {
68275
68364
  try {
@@ -68281,16 +68370,16 @@ function useHidAmicoRepo() {
68281
68370
  cardNo: identity.cardNo
68282
68371
  });
68283
68372
  if (existing) {
68284
- throw new import_node_server_utils257.BadRequestError("HID Amico identity already exists for this reader.");
68373
+ throw new import_node_server_utils258.BadRequestError("HID Amico identity already exists for this reader.");
68285
68374
  }
68286
68375
  await identities().insertOne(identity, { session });
68287
68376
  return identity;
68288
68377
  } catch (error) {
68289
- if (error instanceof import_node_server_utils257.BadRequestError) {
68378
+ if (error instanceof import_node_server_utils258.BadRequestError) {
68290
68379
  throw error;
68291
68380
  }
68292
68381
  if (error.message?.includes("duplicate")) {
68293
- throw new import_node_server_utils257.BadRequestError("HID Amico identity already exists for this reader.");
68382
+ throw new import_node_server_utils258.BadRequestError("HID Amico identity already exists for this reader.");
68294
68383
  }
68295
68384
  throw error;
68296
68385
  }
@@ -68315,12 +68404,12 @@ function useHidAmicoRepo() {
68315
68404
  }
68316
68405
  const items = await identities().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
68317
68406
  const total = await identities().countDocuments(query);
68318
- return (0, import_node_server_utils257.paginate)(items, page, limit, total);
68407
+ return (0, import_node_server_utils258.paginate)(items, page, limit, total);
68319
68408
  }
68320
68409
  async function updateIdentity(id, value, session) {
68321
68410
  const { error } = schemaUpdateHidAmicoIdentity.validate(value);
68322
68411
  if (error) {
68323
- throw new import_node_server_utils257.BadRequestError(error.message);
68412
+ throw new import_node_server_utils258.BadRequestError(error.message);
68324
68413
  }
68325
68414
  const payload = {
68326
68415
  ...value,
@@ -68348,7 +68437,7 @@ function useHidAmicoRepo() {
68348
68437
  { returnDocument: "after", session }
68349
68438
  );
68350
68439
  if (!updated) {
68351
- throw new import_node_server_utils257.BadRequestError("HID Amico identity not found.");
68440
+ throw new import_node_server_utils258.BadRequestError("HID Amico identity not found.");
68352
68441
  }
68353
68442
  return updated;
68354
68443
  }
@@ -68405,7 +68494,7 @@ function useHidAmicoRepo() {
68405
68494
  // src/services/hid-amico.service.ts
68406
68495
  var import_crypto3 = __toESM(require("crypto"));
68407
68496
  var import_axios4 = __toESM(require("axios"));
68408
- var import_node_server_utils258 = require("@7365admin1/node-server-utils");
68497
+ var import_node_server_utils259 = require("@7365admin1/node-server-utils");
68409
68498
  var PASSWORD_PREFIX = "v1";
68410
68499
  function getSecretKey() {
68411
68500
  const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
@@ -68449,7 +68538,7 @@ function toHidRequestError(error, path5) {
68449
68538
  status ? `status ${status}` : "",
68450
68539
  payload ? `response ${payload}` : error.message
68451
68540
  ].filter(Boolean).join(" - ");
68452
- return new import_node_server_utils258.BadRequestError(detail);
68541
+ return new import_node_server_utils259.BadRequestError(detail);
68453
68542
  }
68454
68543
  return error;
68455
68544
  }
@@ -68491,7 +68580,7 @@ var HidAmicoClient = class {
68491
68580
  password: decryptSecret(this.reader.password)
68492
68581
  });
68493
68582
  if (!res.data?.session) {
68494
- throw new import_node_server_utils258.BadRequestError("HID Amico login failed: missing session.");
68583
+ throw new import_node_server_utils259.BadRequestError("HID Amico login failed: missing session.");
68495
68584
  }
68496
68585
  this.session = res.data.session;
68497
68586
  return this.session;
@@ -68515,7 +68604,7 @@ var HidAmicoClient = class {
68515
68604
  const payload = JSON.parse(buffer.toString("utf8"));
68516
68605
  const image = payload.image || payload.photo || payload.data?.image || payload.data?.photo;
68517
68606
  if (!image) {
68518
- throw new import_node_server_utils258.BadRequestError("HID Amico user image response did not include an image.");
68607
+ throw new import_node_server_utils259.BadRequestError("HID Amico user image response did not include an image.");
68519
68608
  }
68520
68609
  return {
68521
68610
  contentType: payload.contentType || payload.mimeType || "image/jpeg",
@@ -68640,7 +68729,7 @@ function useHidAmicoService() {
68640
68729
  async function getActiveReader(id) {
68641
68730
  const reader = await repo.getById(id, { includePassword: true });
68642
68731
  if (reader.enabled === false || reader.status === "inactive" || reader.status === "deleted") {
68643
- throw new import_node_server_utils258.BadRequestError("HID Amico reader is not active.");
68732
+ throw new import_node_server_utils259.BadRequestError("HID Amico reader is not active.");
68644
68733
  }
68645
68734
  return reader;
68646
68735
  }
@@ -68895,13 +68984,13 @@ function useHidAmicoService() {
68895
68984
  }
68896
68985
 
68897
68986
  // src/controllers/hid-amico.controller.ts
68898
- var import_node_server_utils259 = require("@7365admin1/node-server-utils");
68987
+ var import_node_server_utils260 = require("@7365admin1/node-server-utils");
68899
68988
  function useHidAmicoController() {
68900
68989
  const service = useHidAmicoService();
68901
68990
  async function listReaders(req, res, next) {
68902
68991
  const { error, value } = schemaHidAmicoReaderListQuery.validate(req.query);
68903
68992
  if (error) {
68904
- next(new import_node_server_utils259.BadRequestError(error.message));
68993
+ next(new import_node_server_utils260.BadRequestError(error.message));
68905
68994
  return;
68906
68995
  }
68907
68996
  try {
@@ -68913,7 +69002,7 @@ function useHidAmicoController() {
68913
69002
  async function createReader(req, res, next) {
68914
69003
  const { error, value } = schemaHidAmicoReader.validate(req.body);
68915
69004
  if (error) {
68916
- next(new import_node_server_utils259.BadRequestError(error.message));
69005
+ next(new import_node_server_utils260.BadRequestError(error.message));
68917
69006
  return;
68918
69007
  }
68919
69008
  try {
@@ -68926,7 +69015,7 @@ function useHidAmicoController() {
68926
69015
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
68927
69016
  const body = schemaUpdateHidAmicoReader.validate(req.body);
68928
69017
  if (params.error || body.error) {
68929
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69018
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
68930
69019
  return;
68931
69020
  }
68932
69021
  try {
@@ -68938,7 +69027,7 @@ function useHidAmicoController() {
68938
69027
  async function deleteReader(req, res, next) {
68939
69028
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
68940
69029
  if (error) {
68941
- next(new import_node_server_utils259.BadRequestError(error.message));
69030
+ next(new import_node_server_utils260.BadRequestError(error.message));
68942
69031
  return;
68943
69032
  }
68944
69033
  try {
@@ -68950,7 +69039,7 @@ function useHidAmicoController() {
68950
69039
  async function testReader(req, res, next) {
68951
69040
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
68952
69041
  if (error) {
68953
- next(new import_node_server_utils259.BadRequestError(error.message));
69042
+ next(new import_node_server_utils260.BadRequestError(error.message));
68954
69043
  return;
68955
69044
  }
68956
69045
  try {
@@ -68963,7 +69052,7 @@ function useHidAmicoController() {
68963
69052
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
68964
69053
  const body = schemaHidAmicoSync.validate(req.body ?? {});
68965
69054
  if (params.error || body.error) {
68966
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69055
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
68967
69056
  return;
68968
69057
  }
68969
69058
  try {
@@ -68976,7 +69065,7 @@ function useHidAmicoController() {
68976
69065
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
68977
69066
  const query = schemaHidAmicoLogQuery.validate(req.query);
68978
69067
  if (params.error || query.error) {
68979
- next(new import_node_server_utils259.BadRequestError(params.error?.message || query.error?.message));
69068
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || query.error?.message));
68980
69069
  return;
68981
69070
  }
68982
69071
  try {
@@ -68989,7 +69078,7 @@ function useHidAmicoController() {
68989
69078
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
68990
69079
  const query = schemaHidAmicoIdentityQuery.validate(req.query);
68991
69080
  if (params.error || query.error) {
68992
- next(new import_node_server_utils259.BadRequestError(params.error?.message || query.error?.message));
69081
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || query.error?.message));
68993
69082
  return;
68994
69083
  }
68995
69084
  try {
@@ -69001,13 +69090,13 @@ function useHidAmicoController() {
69001
69090
  async function createIdentity(req, res, next) {
69002
69091
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69003
69092
  if (params.error) {
69004
- next(new import_node_server_utils259.BadRequestError(params.error.message));
69093
+ next(new import_node_server_utils260.BadRequestError(params.error.message));
69005
69094
  return;
69006
69095
  }
69007
69096
  try {
69008
69097
  const body = schemaCreateHidAmicoIdentity.validate(req.body);
69009
69098
  if (body.error) {
69010
- next(new import_node_server_utils259.BadRequestError(body.error.message));
69099
+ next(new import_node_server_utils260.BadRequestError(body.error.message));
69011
69100
  return;
69012
69101
  }
69013
69102
  res.status(201).json({ data: await service.createIdentity(params.value.readerId, body.value) });
@@ -69019,7 +69108,7 @@ function useHidAmicoController() {
69019
69108
  const params = schemaHidAmicoIdentityIdParams.validate(req.params);
69020
69109
  const body = schemaUpdateHidAmicoIdentity.validate(req.body ?? {});
69021
69110
  if (params.error || body.error) {
69022
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69111
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69023
69112
  return;
69024
69113
  }
69025
69114
  try {
@@ -69031,7 +69120,7 @@ function useHidAmicoController() {
69031
69120
  async function deleteIdentity(req, res, next) {
69032
69121
  const { error, value } = schemaHidAmicoIdentityIdParams.validate(req.params);
69033
69122
  if (error) {
69034
- next(new import_node_server_utils259.BadRequestError(error.message));
69123
+ next(new import_node_server_utils260.BadRequestError(error.message));
69035
69124
  return;
69036
69125
  }
69037
69126
  try {
@@ -69043,7 +69132,7 @@ function useHidAmicoController() {
69043
69132
  async function receiveNotification(req, res, next) {
69044
69133
  const validation = schemaHidAmicoNotificationParams.validate(req.params);
69045
69134
  if (validation.error) {
69046
- next(new import_node_server_utils259.BadRequestError(validation.error.message));
69135
+ next(new import_node_server_utils260.BadRequestError(validation.error.message));
69047
69136
  return;
69048
69137
  }
69049
69138
  try {
@@ -69060,7 +69149,7 @@ function useHidAmicoController() {
69060
69149
  async function getDoorState(req, res, next) {
69061
69150
  const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
69062
69151
  if (error) {
69063
- next(new import_node_server_utils259.BadRequestError(error.message));
69152
+ next(new import_node_server_utils260.BadRequestError(error.message));
69064
69153
  return;
69065
69154
  }
69066
69155
  try {
@@ -69072,7 +69161,7 @@ function useHidAmicoController() {
69072
69161
  async function getUserImage(req, res, next) {
69073
69162
  const { error, value } = schemaHidAmicoUserImageParams.validate(req.params);
69074
69163
  if (error) {
69075
- next(new import_node_server_utils259.BadRequestError(error.message));
69164
+ next(new import_node_server_utils260.BadRequestError(error.message));
69076
69165
  return;
69077
69166
  }
69078
69167
  try {
@@ -69086,7 +69175,7 @@ function useHidAmicoController() {
69086
69175
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69087
69176
  const body = schemaHidAmicoExecuteActions.validate(req.body ?? {});
69088
69177
  if (params.error || body.error) {
69089
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69178
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69090
69179
  return;
69091
69180
  }
69092
69181
  try {
@@ -69099,7 +69188,7 @@ function useHidAmicoController() {
69099
69188
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69100
69189
  const body = schemaHidAmicoConfiguration.validate(req.body ?? {});
69101
69190
  if (params.error || body.error) {
69102
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69191
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69103
69192
  return;
69104
69193
  }
69105
69194
  try {
@@ -69112,7 +69201,7 @@ function useHidAmicoController() {
69112
69201
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69113
69202
  const body = schemaHidAmicoSetConfiguration.validate(req.body ?? {});
69114
69203
  if (params.error || body.error) {
69115
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69204
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69116
69205
  return;
69117
69206
  }
69118
69207
  try {
@@ -69125,20 +69214,20 @@ function useHidAmicoController() {
69125
69214
  const params = schemaHidAmicoReaderIdParams.validate(req.params);
69126
69215
  const body = schemaHidAmicoObjectOperation.validate(req.body ?? {});
69127
69216
  if (params.error || body.error) {
69128
- next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
69217
+ next(new import_node_server_utils260.BadRequestError(params.error?.message || body.error?.message));
69129
69218
  return;
69130
69219
  }
69131
69220
  const { operation, ...payload } = body.value;
69132
69221
  if (operation === "create" && !Array.isArray(payload.values)) {
69133
- next(new import_node_server_utils259.BadRequestError("values array is required for HID object create operations."));
69222
+ next(new import_node_server_utils260.BadRequestError("values array is required for HID object create operations."));
69134
69223
  return;
69135
69224
  }
69136
69225
  if (operation === "modify" && (!payload.values || Array.isArray(payload.values) || !payload.where)) {
69137
- next(new import_node_server_utils259.BadRequestError("values object and where are required for HID object modify operations."));
69226
+ next(new import_node_server_utils260.BadRequestError("values object and where are required for HID object modify operations."));
69138
69227
  return;
69139
69228
  }
69140
69229
  if (operation === "destroy" && !payload.where) {
69141
- next(new import_node_server_utils259.BadRequestError("where is required for HID object destroy operations."));
69230
+ next(new import_node_server_utils260.BadRequestError("where is required for HID object destroy operations."));
69142
69231
  return;
69143
69232
  }
69144
69233
  try {