@7365admin1/core 2.30.0 → 2.30.1

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
@@ -1438,7 +1438,7 @@ var schemaUpdateOccurrenceEntry = Joi5.object({
1438
1438
  occurrence: Joi5.string().optional().allow(null, ""),
1439
1439
  signature: Joi5.string().hex().optional().allow(null, ""),
1440
1440
  incidentReportId: Joi5.string().hex().optional().allow(null, ""),
1441
- eSignature: Joi5.string().hex().length(24).required(),
1441
+ eSignature: Joi5.string().hex().length(24).optional().allow(null, ""),
1442
1442
  createdByName: Joi5.string().optional().allow(null, "")
1443
1443
  });
1444
1444
  function MOccurrenceEntry(value) {
@@ -1847,32 +1847,16 @@ function useOccurrenceEntryRepo() {
1847
1847
  throw error;
1848
1848
  }
1849
1849
  }
1850
- async function getOccurrenceEntryByBookId(dailyOccurrenceBookId, session) {
1850
+ async function getOccurrenceEntryByBookId(dailyOccurrenceBookId) {
1851
1851
  try {
1852
1852
  dailyOccurrenceBookId = new ObjectId7(dailyOccurrenceBookId);
1853
1853
  } catch (error) {
1854
1854
  throw new BadRequestError7("Invalid occurrence entry ID format.");
1855
1855
  }
1856
- const cacheKey = makeCacheKey4(namespace_collection, {
1857
- dailyOccurrenceBookId
1858
- });
1859
- const cachedData = await getCache(cacheKey);
1860
- if (cachedData) {
1861
- logger6.info(`Cache hit for key: ${cacheKey}`);
1862
- return cachedData;
1863
- }
1856
+ const query = { dailyOccurrenceBookId };
1864
1857
  try {
1865
- const data = await collection.findOne(
1866
- { dailyOccurrenceBookId },
1867
- {
1868
- sort: { _id: -1 },
1869
- session
1870
- }
1871
- );
1872
- setCache(cacheKey, data, 15 * 60).then(() => {
1873
- logger6.info(`Cache set for key: ${cacheKey}`);
1874
- }).catch((err) => {
1875
- logger6.error(`Failed to set cache for key: ${cacheKey}`, err);
1858
+ const data = await collection.findOne(query, {
1859
+ sort: { _id: -1 }
1876
1860
  });
1877
1861
  return data;
1878
1862
  } catch (error) {
@@ -13083,7 +13067,7 @@ var schemaVisitorTransaction = Joi36.object({
13083
13067
  checkIn: Joi36.date().optional().allow(null, ""),
13084
13068
  checkOut: Joi36.date().optional().allow(null, ""),
13085
13069
  deliveryType: Joi36.string().optional().allow(null, ""),
13086
- status: Joi36.string().optional().valid(...Object.values(VisitorStatus)).default("pending" /* PENDING */),
13070
+ status: Joi36.string().optional().valid(...Object.values(VisitorStatus)).default("registered" /* REGISTERED */),
13087
13071
  remarks: Joi36.string().optional().allow(null, ""),
13088
13072
  members: Joi36.array().items(
13089
13073
  Joi36.object({
@@ -15813,11 +15797,7 @@ function useDahuaService() {
15813
15797
  org,
15814
15798
  status: "unregistered" /* UNREGISTERED */
15815
15799
  };
15816
- const typesForAutoRegister = [
15817
- "guest" /* GUEST */,
15818
- "resident" /* RESIDENT */,
15819
- "tenant" /* TENANT */
15820
- ];
15800
+ const typesForAutoRegister = Object.values(PersonTypes);
15821
15801
  let startDate = vehicle?.start ? new Date(vehicle?.start) : /* @__PURE__ */ new Date();
15822
15802
  let endDate = vehicle?.end ? new Date(vehicle?.end) : new Date(startDate.getTime() + 60 * 60 * 1e3);
15823
15803
  if (vehicle && typeof vehicle.category === "string" && typesForAutoRegister.includes(vehicle.category)) {
@@ -15828,7 +15808,7 @@ function useDahuaService() {
15828
15808
  visitorTransaction.level = vehicle.level;
15829
15809
  visitorTransaction.unit = vehicle.unit?.toString();
15830
15810
  visitorTransaction.unitName = vehicle.unitName;
15831
- visitorTransaction.type = "resident" /* RESIDENT */;
15811
+ visitorTransaction.type = vehicle.category;
15832
15812
  visitorTransaction.status = "registered" /* REGISTERED */;
15833
15813
  visitorTransaction.recNo = vehicle.recNo;
15834
15814
  visitorTransaction.expiredAt = vehicle.end;
@@ -39061,8 +39041,7 @@ function useOccurrenceEntryController() {
39061
39041
  getLatestSerialNumber: _getLatestSerialNumber
39062
39042
  } = useOccurrenceEntryRepo();
39063
39043
  async function add(req, res, next) {
39064
- const payload = { ...req.body };
39065
- const { error } = schemaOccurrenceEntry.validate(payload, {
39044
+ const { error, value } = schemaOccurrenceEntry.validate(req.body, {
39066
39045
  abortEarly: false
39067
39046
  });
39068
39047
  if (error) {
@@ -39072,7 +39051,7 @@ function useOccurrenceEntryController() {
39072
39051
  return;
39073
39052
  }
39074
39053
  try {
39075
- const data = await _add(payload);
39054
+ const data = await _add(value);
39076
39055
  res.status(201).json(data);
39077
39056
  return;
39078
39057
  } catch (error2) {
@@ -39154,9 +39133,8 @@ function useOccurrenceEntryController() {
39154
39133
  }
39155
39134
  }
39156
39135
  async function updateOccurrenceEntryById(req, res, next) {
39157
- const _id = req.params.id;
39158
- const payload = { _id, ...req.body };
39159
- const { error } = schemaUpdateOccurrenceEntry.validate(payload, {
39136
+ const payload = { _id: req.params.id, ...req.body };
39137
+ const { error, value } = schemaUpdateOccurrenceEntry.validate(payload, {
39160
39138
  abortEarly: false
39161
39139
  });
39162
39140
  if (error) {
@@ -39165,8 +39143,9 @@ function useOccurrenceEntryController() {
39165
39143
  next(new BadRequestError170(messages));
39166
39144
  return;
39167
39145
  }
39146
+ const { _id, ...rest } = value;
39168
39147
  try {
39169
- const result = await _updateOccurrenceEntryById(_id, req.body);
39148
+ const result = await _updateOccurrenceEntryById(_id, rest);
39170
39149
  res.status(200).json({ message: result });
39171
39150
  return;
39172
39151
  } catch (error2) {