@7365admin1/core 3.24.0 → 3.25.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 3.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f1dfe6f: release changes in preloved api, soa api, access-management api, etc.
8
+
3
9
  ## 3.24.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -417,6 +417,7 @@ type TVerification = {
417
417
  type: string;
418
418
  email: string;
419
419
  metadata?: TVerificationMetadata;
420
+ roleName?: string;
420
421
  status?: string;
421
422
  createdAt: string;
422
423
  updatedAt?: string | null;
@@ -427,6 +428,7 @@ declare class MVerification implements TVerification {
427
428
  type: string;
428
429
  email: string;
429
430
  metadata?: TVerificationMetadata;
431
+ roleName?: string;
430
432
  status?: string;
431
433
  createdAt: string;
432
434
  updatedAt?: string | null;
package/dist/index.js CHANGED
@@ -10378,6 +10378,7 @@ var MVerification = class {
10378
10378
  }
10379
10379
  }
10380
10380
  this.metadata = { ...value.metadata };
10381
+ this.roleName = value.roleName;
10381
10382
  this.status = value.status ?? "pending";
10382
10383
  this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
10383
10384
  this.updatedAt = value.updatedAt ?? null;
@@ -10530,6 +10531,16 @@ function useVerificationRepo() {
10530
10531
  { $sort: sort },
10531
10532
  { $skip: page * limit },
10532
10533
  { $limit: limit },
10534
+ {
10535
+ $lookup: {
10536
+ from: "roles",
10537
+ localField: "metadata.role",
10538
+ foreignField: "_id",
10539
+ as: "roles",
10540
+ pipeline: [{ $project: { name: 1 } }]
10541
+ }
10542
+ },
10543
+ { $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
10533
10544
  {
10534
10545
  $project: {
10535
10546
  _id: 1,
@@ -10537,6 +10548,7 @@ function useVerificationRepo() {
10537
10548
  email: 1,
10538
10549
  type: 1,
10539
10550
  metadata: 1,
10551
+ roleName: "$roles.name",
10540
10552
  status: 1
10541
10553
  }
10542
10554
  }
@@ -22162,7 +22174,7 @@ function useVisitorTransactionRepo() {
22162
22174
  session,
22163
22175
  sort: { checkIn: -1 },
22164
22176
  returnDocument: "after",
22165
- projection: { _id: 1, site: 1 }
22177
+ projection: { _id: 1, site: 1, type: 1 }
22166
22178
  }
22167
22179
  );
22168
22180
  return result;
@@ -23761,7 +23773,7 @@ function useDahuaService() {
23761
23773
  try {
23762
23774
  const result = await _checkOutBySiteAndPlate(site, plateNumber2);
23763
23775
  console.log("checkOutBySiteAndPlate result", result);
23764
- if (onDetected2 && result?._id && result?.site) {
23776
+ if (onDetected2 && result?.type != "resident" && result?.site) {
23765
23777
  onDetected2({ reload: true, site: result?.site?.toString(), siteName: camera?.siteName, cameraDirection: camera?.direction, direction });
23766
23778
  }
23767
23779
  return result;
@@ -23835,7 +23847,7 @@ function useDahuaService() {
23835
23847
  loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Unregistered vehicle with plate ${plateNumber2} and transaction ID ${insert?._id}`);
23836
23848
  }
23837
23849
  }
23838
- if (insert?._id && insert?.site && onDetected2) {
23850
+ if (insert?.status == "unregistered" /* UNREGISTERED */ && insert?.site && onDetected2) {
23839
23851
  onDetected2({ _id: insert?._id, site: insert?.site?.toString(), plateNumber: insert?.plateNumber, cameraDirection: camera?.direction, direction });
23840
23852
  }
23841
23853
  return insert;
@@ -48916,22 +48928,52 @@ function useAccessManagementSvc() {
48916
48928
  }
48917
48929
  };
48918
48930
  const liftAccessLevelsSvc = async (params) => {
48931
+ const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
48932
+ const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
48933
+ user: params.user,
48934
+ resource: "lift-levels"
48935
+ });
48936
+ const cachedData = await getCache2(cacheKey);
48937
+ if (cachedData) {
48938
+ import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
48939
+ return cachedData;
48940
+ }
48919
48941
  try {
48920
48942
  const command = readTemplate("lift-levels");
48921
48943
  const response = await sendCommand(command, params.acm_url);
48922
48944
  const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
48923
48945
  const format2 = await formatLiftAccessLevels(res);
48946
+ setCache2(cacheKey, format2, 60).then(() => {
48947
+ import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
48948
+ }).catch((err) => {
48949
+ import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
48950
+ });
48924
48951
  return format2;
48925
48952
  } catch (error) {
48926
48953
  throw new Error(error.message);
48927
48954
  }
48928
48955
  };
48929
48956
  const accessGroupsSvc = async (params) => {
48957
+ const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
48958
+ const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
48959
+ user: params.user,
48960
+ resource: "access-groups"
48961
+ });
48962
+ const cachedData = await getCache2(cacheKey);
48963
+ if (cachedData) {
48964
+ import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
48965
+ return cachedData;
48966
+ }
48930
48967
  try {
48931
48968
  const command = readTemplate("access-group");
48932
48969
  const response = await sendCommand(command, params.acm_url);
48933
48970
  const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
48934
48971
  const format2 = await formatAccessGroup(res);
48972
+ setCache2(cacheKey, format2, 60).then(() => {
48973
+ import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
48974
+ }).catch((err) => {
48975
+ import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
48976
+ });
48935
48977
  return format2;
48936
48978
  } catch (err) {
48937
48979
  throw new Error(err.message);
@@ -52731,6 +52773,7 @@ function useStatementOfAccountService() {
52731
52773
  unit_billings = unit_billings.map((unit) => {
52732
52774
  try {
52733
52775
  unit._id = unit._id.toString();
52776
+ unit.paidBy = unit.paidBy.toString();
52734
52777
  } catch {
52735
52778
  throw new import_node_server_utils172.BadRequestError("Invalid unit id format/type");
52736
52779
  }
@@ -68164,6 +68207,7 @@ function useBidPrelovedService() {
68164
68207
  const { add: _addBid } = useBidPrelovedRepo();
68165
68208
  const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
68166
68209
  const { add: _addChat } = useChatPrelovedRepo();
68210
+ const { updateStatus } = usePostPrelovedRepo();
68167
68211
  async function createBid(value) {
68168
68212
  const client = import_node_server_utils254.useAtlas.getClient();
68169
68213
  if (!client)
@@ -68209,6 +68253,9 @@ function useBidPrelovedService() {
68209
68253
  },
68210
68254
  session
68211
68255
  );
68256
+ if (value.type === "reserve") {
68257
+ await updateStatus(postId, "reserved" /* RESERVED */, session);
68258
+ }
68212
68259
  await session.commitTransaction();
68213
68260
  return { bidId };
68214
68261
  } catch (error) {