@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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 2.30.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 296993e: Patch bug fix for updated visitor transaction schema
8
+
3
9
  ## 2.30.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -5214,7 +5214,7 @@ declare function useOccurrenceEntryRepo(): {
5214
5214
  pageRange: string;
5215
5215
  } | TOccurrenceEntry>;
5216
5216
  getOccurrenceEntryById: (_id: string | ObjectId, session?: ClientSession) => Promise<bson.Document>;
5217
- getOccurrenceEntryByBookId: (dailyOccurrenceBookId: string | ObjectId, session?: ClientSession) => Promise<mongodb.WithId<bson.Document> | TOccurrenceEntry | null>;
5217
+ getOccurrenceEntryByBookId: (dailyOccurrenceBookId: string | ObjectId) => Promise<mongodb.WithId<bson.Document> | null>;
5218
5218
  updateOccurrenceEntryById: (_id: ObjectId | string, value: Partial<TOccurrenceEntry>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
5219
5219
  updateUserNameBySignatureId: (_id: string | ObjectId, value: string | ObjectId, session?: ClientSession) => Promise<number>;
5220
5220
  deleteOccurrenceEntryById: (_id: string | ObjectId) => Promise<number>;
package/dist/index.js CHANGED
@@ -1832,7 +1832,7 @@ var schemaUpdateOccurrenceEntry = import_joi5.default.object({
1832
1832
  occurrence: import_joi5.default.string().optional().allow(null, ""),
1833
1833
  signature: import_joi5.default.string().hex().optional().allow(null, ""),
1834
1834
  incidentReportId: import_joi5.default.string().hex().optional().allow(null, ""),
1835
- eSignature: import_joi5.default.string().hex().length(24).required(),
1835
+ eSignature: import_joi5.default.string().hex().length(24).optional().allow(null, ""),
1836
1836
  createdByName: import_joi5.default.string().optional().allow(null, "")
1837
1837
  });
1838
1838
  function MOccurrenceEntry(value) {
@@ -2241,32 +2241,16 @@ function useOccurrenceEntryRepo() {
2241
2241
  throw error;
2242
2242
  }
2243
2243
  }
2244
- async function getOccurrenceEntryByBookId(dailyOccurrenceBookId, session) {
2244
+ async function getOccurrenceEntryByBookId(dailyOccurrenceBookId) {
2245
2245
  try {
2246
2246
  dailyOccurrenceBookId = new import_mongodb7.ObjectId(dailyOccurrenceBookId);
2247
2247
  } catch (error) {
2248
2248
  throw new import_node_server_utils8.BadRequestError("Invalid occurrence entry ID format.");
2249
2249
  }
2250
- const cacheKey = (0, import_node_server_utils8.makeCacheKey)(namespace_collection, {
2251
- dailyOccurrenceBookId
2252
- });
2253
- const cachedData = await getCache(cacheKey);
2254
- if (cachedData) {
2255
- import_node_server_utils8.logger.info(`Cache hit for key: ${cacheKey}`);
2256
- return cachedData;
2257
- }
2250
+ const query = { dailyOccurrenceBookId };
2258
2251
  try {
2259
- const data = await collection.findOne(
2260
- { dailyOccurrenceBookId },
2261
- {
2262
- sort: { _id: -1 },
2263
- session
2264
- }
2265
- );
2266
- setCache(cacheKey, data, 15 * 60).then(() => {
2267
- import_node_server_utils8.logger.info(`Cache set for key: ${cacheKey}`);
2268
- }).catch((err) => {
2269
- import_node_server_utils8.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
2252
+ const data = await collection.findOne(query, {
2253
+ sort: { _id: -1 }
2270
2254
  });
2271
2255
  return data;
2272
2256
  } catch (error) {
@@ -13285,7 +13269,7 @@ var schemaVisitorTransaction = import_joi36.default.object({
13285
13269
  checkIn: import_joi36.default.date().optional().allow(null, ""),
13286
13270
  checkOut: import_joi36.default.date().optional().allow(null, ""),
13287
13271
  deliveryType: import_joi36.default.string().optional().allow(null, ""),
13288
- status: import_joi36.default.string().optional().valid(...Object.values(VisitorStatus)).default("pending" /* PENDING */),
13272
+ status: import_joi36.default.string().optional().valid(...Object.values(VisitorStatus)).default("registered" /* REGISTERED */),
13289
13273
  remarks: import_joi36.default.string().optional().allow(null, ""),
13290
13274
  members: import_joi36.default.array().items(
13291
13275
  import_joi36.default.object({
@@ -15992,11 +15976,7 @@ function useDahuaService() {
15992
15976
  org,
15993
15977
  status: "unregistered" /* UNREGISTERED */
15994
15978
  };
15995
- const typesForAutoRegister = [
15996
- "guest" /* GUEST */,
15997
- "resident" /* RESIDENT */,
15998
- "tenant" /* TENANT */
15999
- ];
15979
+ const typesForAutoRegister = Object.values(PersonTypes);
16000
15980
  let startDate = vehicle?.start ? new Date(vehicle?.start) : /* @__PURE__ */ new Date();
16001
15981
  let endDate = vehicle?.end ? new Date(vehicle?.end) : new Date(startDate.getTime() + 60 * 60 * 1e3);
16002
15982
  if (vehicle && typeof vehicle.category === "string" && typesForAutoRegister.includes(vehicle.category)) {
@@ -16007,7 +15987,7 @@ function useDahuaService() {
16007
15987
  visitorTransaction.level = vehicle.level;
16008
15988
  visitorTransaction.unit = vehicle.unit?.toString();
16009
15989
  visitorTransaction.unitName = vehicle.unitName;
16010
- visitorTransaction.type = "resident" /* RESIDENT */;
15990
+ visitorTransaction.type = vehicle.category;
16011
15991
  visitorTransaction.status = "registered" /* REGISTERED */;
16012
15992
  visitorTransaction.recNo = vehicle.recNo;
16013
15993
  visitorTransaction.expiredAt = vehicle.end;
@@ -38901,8 +38881,7 @@ function useOccurrenceEntryController() {
38901
38881
  getLatestSerialNumber: _getLatestSerialNumber
38902
38882
  } = useOccurrenceEntryRepo();
38903
38883
  async function add(req, res, next) {
38904
- const payload = { ...req.body };
38905
- const { error } = schemaOccurrenceEntry.validate(payload, {
38884
+ const { error, value } = schemaOccurrenceEntry.validate(req.body, {
38906
38885
  abortEarly: false
38907
38886
  });
38908
38887
  if (error) {
@@ -38912,7 +38891,7 @@ function useOccurrenceEntryController() {
38912
38891
  return;
38913
38892
  }
38914
38893
  try {
38915
- const data = await _add(payload);
38894
+ const data = await _add(value);
38916
38895
  res.status(201).json(data);
38917
38896
  return;
38918
38897
  } catch (error2) {
@@ -38994,9 +38973,8 @@ function useOccurrenceEntryController() {
38994
38973
  }
38995
38974
  }
38996
38975
  async function updateOccurrenceEntryById(req, res, next) {
38997
- const _id = req.params.id;
38998
- const payload = { _id, ...req.body };
38999
- const { error } = schemaUpdateOccurrenceEntry.validate(payload, {
38976
+ const payload = { _id: req.params.id, ...req.body };
38977
+ const { error, value } = schemaUpdateOccurrenceEntry.validate(payload, {
39000
38978
  abortEarly: false
39001
38979
  });
39002
38980
  if (error) {
@@ -39005,8 +38983,9 @@ function useOccurrenceEntryController() {
39005
38983
  next(new import_node_server_utils184.BadRequestError(messages));
39006
38984
  return;
39007
38985
  }
38986
+ const { _id, ...rest } = value;
39008
38987
  try {
39009
- const result = await _updateOccurrenceEntryById(_id, req.body);
38988
+ const result = await _updateOccurrenceEntryById(_id, rest);
39010
38989
  res.status(200).json({ message: result });
39011
38990
  return;
39012
38991
  } catch (error2) {