@7365admin1/core 2.36.0 → 2.37.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,17 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 2.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 933b3da: get latest changes
8
+
9
+ ## 2.36.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 4314116: remove dob entry deprecation upon update
14
+
3
15
  ## 2.36.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1709,7 +1709,10 @@ type TBuilding = {
1709
1709
  updatedAt?: Date | string;
1710
1710
  deletedAt?: Date | string;
1711
1711
  status?: string;
1712
- buildingFloorPlan?: string[];
1712
+ buildingFiles?: Array<{
1713
+ id: string;
1714
+ name: string;
1715
+ }>;
1713
1716
  };
1714
1717
  declare const schemaBuilding: Joi.ObjectSchema<any>;
1715
1718
  declare const schemaBuildingUpdateOptions: Joi.ObjectSchema<any>;
@@ -1749,7 +1752,10 @@ declare function MBuilding(value: TBuilding): {
1749
1752
  block: number;
1750
1753
  levels: string[];
1751
1754
  status: string;
1752
- buildingFloorPlan: string[];
1755
+ buildingFiles: {
1756
+ id: string;
1757
+ name: string;
1758
+ }[];
1753
1759
  createdAt: string | Date;
1754
1760
  updatedAt: string | Date;
1755
1761
  deletedAt: string | Date;
@@ -1790,14 +1796,14 @@ declare function useBuildingRepo(): {
1790
1796
  status?: BuildingStatus | undefined;
1791
1797
  }) => Promise<Record<string, any>>;
1792
1798
  getById: (_id: string | ObjectId) => Promise<TBuilding | null>;
1793
- updateById: (_id: ObjectId | string, value: Pick<TBuilding, "name" | "block" | "levels" | "buildingFloorPlan">, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
1799
+ updateById: (_id: ObjectId | string, value: Pick<TBuilding, "name" | "block" | "levels" | "buildingFiles">, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
1794
1800
  deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
1795
1801
  getBuildingLevel: (site: string | ObjectId, block: number) => Promise<mongodb.WithId<bson.Document> | TBuilding | null>;
1796
1802
  };
1797
1803
 
1798
1804
  declare function useBuildingService(): {
1799
1805
  add: (value: TBuilding) => Promise<bson.ObjectId>;
1800
- updateById: (id: string, data: Pick<TBuilding, "name" | "block" | "levels" | "buildingFloorPlan">) => Promise<mongodb.UpdateResult<bson.Document>>;
1806
+ updateById: (id: string, data: Pick<TBuilding, "name" | "block" | "levels" | "buildingFiles">) => Promise<mongodb.UpdateResult<bson.Document>>;
1801
1807
  deleteById: (id: string) => Promise<string>;
1802
1808
  };
1803
1809
 
@@ -2577,7 +2583,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
2577
2583
  plateNumber: string | undefined;
2578
2584
  recNo: string | undefined;
2579
2585
  checkIn: string | Date | null;
2580
- expectedCheckIn: string | Date | undefined;
2586
+ expectedCheckIn: Date | undefined;
2581
2587
  checkOut: string | Date | undefined;
2582
2588
  status: VisitorStatus | undefined;
2583
2589
  remarks: string | undefined;
@@ -2608,6 +2614,8 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
2608
2614
  remarks: string;
2609
2615
  updatedBy: string | ObjectId;
2610
2616
  } | null;
2617
+ arrivalTime: string | null | undefined;
2618
+ duration: number | null | undefined;
2611
2619
  };
2612
2620
 
2613
2621
  declare const visitors_namespace_collection = "visitor.transactions";
package/dist/index.js CHANGED
@@ -13387,12 +13387,12 @@ var schemaVisitorTransaction = import_joi36.default.object({
13387
13387
  numberOfPassengers: import_joi36.default.number().integer().optional().allow(null, ""),
13388
13388
  visitorPass: import_joi36.default.array().items(
13389
13389
  import_joi36.default.object({
13390
- keyId: import_joi36.default.string().hex().length(24).required()
13390
+ keyId: import_joi36.default.string().hex().length(24).allow(null, "")
13391
13391
  })
13392
13392
  ).optional().allow(null),
13393
13393
  passKeys: import_joi36.default.array().items(
13394
13394
  import_joi36.default.object({
13395
- keyId: import_joi36.default.string().hex().length(24).required()
13395
+ keyId: import_joi36.default.string().hex().length(24).allow(null, "")
13396
13396
  })
13397
13397
  ).optional().allow(null),
13398
13398
  checkInRemarks: import_joi36.default.string().optional().allow("", null),
@@ -13515,7 +13515,7 @@ function MVisitorTransaction(value) {
13515
13515
  throw new Error("Invalid invited ID.");
13516
13516
  }
13517
13517
  }
13518
- const newDate = (/* @__PURE__ */ new Date()).toISOString();
13518
+ const newDate = /* @__PURE__ */ new Date();
13519
13519
  return {
13520
13520
  _id: value._id,
13521
13521
  name: value.name,
@@ -13530,7 +13530,7 @@ function MVisitorTransaction(value) {
13530
13530
  plateNumber: value.plateNumber,
13531
13531
  recNo: value.recNo,
13532
13532
  checkIn: value.checkIn === void 0 ? newDate : value.checkIn,
13533
- expectedCheckIn: value.expectedCheckIn,
13533
+ expectedCheckIn: value.expectedCheckIn ? new Date(value.expectedCheckIn) : void 0,
13534
13534
  checkOut: value.checkOut,
13535
13535
  status: value.status,
13536
13536
  remarks: value.remarks,
@@ -13560,7 +13560,9 @@ function MVisitorTransaction(value) {
13560
13560
  status: "pending approval",
13561
13561
  remarks: "",
13562
13562
  updatedBy: value.invitedId ?? ""
13563
- } : null
13563
+ } : null,
13564
+ arrivalTime: value.arrivalTime,
13565
+ duration: value.duration
13564
13566
  };
13565
13567
  }
13566
13568
 
@@ -13619,34 +13621,27 @@ function useVisitorTransactionRepo() {
13619
13621
  }) {
13620
13622
  page = page > 0 ? page - 1 : 0;
13621
13623
  const skip = page * limit;
13622
- let checkOutFilter;
13623
- const checkIn = dateFrom ? { $gte: new Date(dateFrom).toISOString() } : void 0;
13624
- if (checkedOut === false) {
13625
- checkOutFilter = { checkOut: null };
13626
- } else if (checkedOut === true) {
13627
- checkOutFilter = dateTo ? {
13628
- checkOut: {
13629
- $ne: null,
13630
- $lte: new Date(dateTo).toISOString()
13631
- }
13632
- } : {
13633
- checkOut: { $ne: null }
13634
- };
13635
- } else if (dateTo) {
13636
- checkOutFilter = {
13637
- $or: [
13638
- { checkOut: { $lte: new Date(dateTo).toISOString() } },
13639
- { checkOut: null }
13640
- ]
13641
- };
13624
+ const checkInFilter = {};
13625
+ const expectedCheckInFilter = {};
13626
+ if (status != "approved") {
13627
+ if (dateFrom)
13628
+ checkInFilter.$gte = new Date(dateFrom);
13629
+ if (dateTo)
13630
+ checkInFilter.$lte = new Date(dateTo);
13631
+ } else {
13632
+ if (dateFrom)
13633
+ expectedCheckInFilter.$gte = new Date(dateFrom);
13634
+ if (dateTo)
13635
+ expectedCheckInFilter.$lte = new Date(dateTo);
13642
13636
  }
13643
13637
  const query = {
13644
13638
  status,
13645
13639
  ...import_mongodb40.ObjectId.isValid(org) && { org: new import_mongodb40.ObjectId(org) },
13646
13640
  ...import_mongodb40.ObjectId.isValid(site) && { site: new import_mongodb40.ObjectId(site) },
13647
- ...checkIn && { checkIn },
13641
+ ...Object.keys(checkInFilter).length > 0 && { checkIn: checkInFilter },
13642
+ ...Object.keys(expectedCheckInFilter).length > 0 && { expectedCheckIn: expectedCheckInFilter },
13648
13643
  ...Array.isArray(type) ? { type: { $in: type } } : type ? { type } : {},
13649
- ...checkOutFilter ?? {},
13644
+ ...checkedOut == false && { checkOut: { $eq: null } },
13650
13645
  ...search && { $text: { $search: search } },
13651
13646
  ...plateNumber && { plateNumber }
13652
13647
  };
@@ -13869,7 +13864,7 @@ function useVisitorTransactionRepo() {
13869
13864
  } catch (error) {
13870
13865
  throw new import_node_server_utils68.BadRequestError("Invalid visitor transaction ID format.");
13871
13866
  }
13872
- value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
13867
+ value.updatedAt = /* @__PURE__ */ new Date();
13873
13868
  if (value.checkOut) {
13874
13869
  value.manualCheckout = true;
13875
13870
  }
@@ -13893,8 +13888,8 @@ function useVisitorTransactionRepo() {
13893
13888
  try {
13894
13889
  const updateValue = {
13895
13890
  status: "deleted",
13896
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
13897
- deletedAt: (/* @__PURE__ */ new Date()).toISOString()
13891
+ updatedAt: /* @__PURE__ */ new Date(),
13892
+ deletedAt: /* @__PURE__ */ new Date()
13898
13893
  };
13899
13894
  const res = await collection.updateOne({ _id }, { $set: updateValue });
13900
13895
  if (res.modifiedCount === 0) {
@@ -13907,7 +13902,7 @@ function useVisitorTransactionRepo() {
13907
13902
  }
13908
13903
  async function getDeliveryPickupTransactions() {
13909
13904
  try {
13910
- const now = (/* @__PURE__ */ new Date()).toISOString();
13905
+ const now = /* @__PURE__ */ new Date();
13911
13906
  const result = await collection.find(
13912
13907
  {
13913
13908
  type: {
@@ -13934,7 +13929,7 @@ function useVisitorTransactionRepo() {
13934
13929
  async function getExpiredCheckedOutTransactionsBySite(siteId) {
13935
13930
  const site = (0, import_node_server_utils68.toObjectId)(siteId);
13936
13931
  try {
13937
- const now = (/* @__PURE__ */ new Date()).toISOString();
13932
+ const now = /* @__PURE__ */ new Date();
13938
13933
  const expiredTransactions = await collection.find({
13939
13934
  $or: [
13940
13935
  { expiredAt: { $lte: now } },
@@ -13960,7 +13955,7 @@ function useVisitorTransactionRepo() {
13960
13955
  {
13961
13956
  $set: {
13962
13957
  dahuaSyncStatus,
13963
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
13958
+ updatedAt: /* @__PURE__ */ new Date()
13964
13959
  }
13965
13960
  },
13966
13961
  { session }
@@ -17171,13 +17166,15 @@ var schemaBuilding = import_joi43.default.object({
17171
17166
  updatedAt: import_joi43.default.date().optional().allow("", null),
17172
17167
  deletedAt: import_joi43.default.date().optional().allow("", null),
17173
17168
  status: import_joi43.default.string().optional().allow("", null),
17174
- buildingFloorPlan: import_joi43.default.array().items(import_joi43.default.string()).optional()
17169
+ // buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
17170
+ buildingFiles: import_joi43.default.array().items({ id: import_joi43.default.string().hex().optional().allow("", null), name: import_joi43.default.string().optional().allow("", null) }).optional().allow("", null)
17175
17171
  });
17176
17172
  var schemaBuildingUpdateOptions = import_joi43.default.object({
17177
17173
  name: import_joi43.default.string().optional().allow("", null),
17178
17174
  levels: import_joi43.default.array().items(import_joi43.default.string().required()).min(1).required(),
17179
17175
  block: import_joi43.default.number().integer().min(1).required(),
17180
- buildingFloorPlan: import_joi43.default.array().items(import_joi43.default.string()).optional()
17176
+ // buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
17177
+ buildingFiles: import_joi43.default.array().items({ id: import_joi43.default.string().hex().optional().allow("", null), name: import_joi43.default.string().optional().allow("", null) }).optional().allow("", null)
17181
17178
  });
17182
17179
  var schemaBilling = import_joi43.default.object({
17183
17180
  _id: import_joi43.default.string().hex().optional(),
@@ -17243,7 +17240,8 @@ function MBuilding(value) {
17243
17240
  block: value.block ?? 0,
17244
17241
  levels: value.levels ?? "",
17245
17242
  status: value.status ?? "active",
17246
- buildingFloorPlan: value.buildingFloorPlan ?? [],
17243
+ // buildingFloorPlan: value.buildingFloorPlan ?? [],
17244
+ buildingFiles: value.buildingFiles ?? [],
17247
17245
  createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
17248
17246
  updatedAt: value.updatedAt ?? "",
17249
17247
  deletedAt: value.deletedAt ?? ""
@@ -18149,11 +18147,11 @@ function useBuildingService() {
18149
18147
  }
18150
18148
  try {
18151
18149
  await session.startTransaction();
18152
- const buildingFloorPlans = value?.buildingFloorPlan ?? [];
18153
- if (buildingFloorPlans.length > 0) {
18154
- for (const buildingFloorPlan of buildingFloorPlans) {
18150
+ const buildingFiles = value?.buildingFiles ?? [];
18151
+ if (buildingFiles.length > 0) {
18152
+ for (const buildingFile of buildingFiles) {
18155
18153
  const file = await updateStatusById(
18156
- buildingFloorPlan,
18154
+ buildingFile.id,
18157
18155
  { status: "active" },
18158
18156
  session
18159
18157
  );
@@ -18187,12 +18185,12 @@ function useBuildingService() {
18187
18185
  if (!building) {
18188
18186
  throw new import_node_server_utils82.NotFoundError("Building not found.");
18189
18187
  }
18190
- const dataFloorPlans = data?.buildingFloorPlan || [];
18191
- const buildingFloorPlans = building?.buildingFloorPlan || [];
18188
+ const dataFiles = data?.buildingFiles || [];
18189
+ const buildingFiles = building?.buildingFiles || [];
18192
18190
  const deletedFiles = [];
18193
- buildingFloorPlans.forEach((id2) => {
18194
- if (!dataFloorPlans.includes(id2)) {
18195
- deletedFiles.push(id2);
18191
+ buildingFiles.forEach((file) => {
18192
+ if (!dataFiles.find((f) => f.id === file.id)) {
18193
+ deletedFiles.push(file.id);
18196
18194
  }
18197
18195
  });
18198
18196
  if (deletedFiles.length > 0) {
@@ -18288,7 +18286,8 @@ function useBuildingController() {
18288
18286
  levels: import_joi44.default.array().items(import_joi44.default.string().required()).min(1).required(),
18289
18287
  serial: import_joi44.default.string().optional().allow("", null),
18290
18288
  status: import_joi44.default.string().optional().allow("", null),
18291
- buildingFloorPlan: import_joi44.default.array().items(import_joi44.default.string()).optional()
18289
+ // buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
18290
+ buildingFiles: import_joi44.default.array().items({ id: import_joi44.default.string().hex().optional().allow("", null), name: import_joi44.default.string().optional().allow("", null) }).optional().allow("", null)
18292
18291
  });
18293
18292
  const { error } = validation.validate(value);
18294
18293
  if (error) {
@@ -21976,6 +21975,8 @@ function useVisitorTransactionService() {
21976
21975
  try {
21977
21976
  const updatePayload = { status: "In Use" /* IN_USE */ };
21978
21977
  const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
21978
+ if (!visitorPassId)
21979
+ value.visitorPass = [];
21979
21980
  await KeyRepo.updateKeyById(
21980
21981
  visitorPassId,
21981
21982
  updatePayload,
@@ -21991,6 +21992,8 @@ function useVisitorTransactionService() {
21991
21992
  try {
21992
21993
  const updatePayload = { status: "In Use" /* IN_USE */ };
21993
21994
  const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
21995
+ if (!passKeyId)
21996
+ value.passKeys = [];
21994
21997
  await KeyRepo.updateKeyById(
21995
21998
  passKeyId,
21996
21999
  updatePayload,
@@ -22102,11 +22105,13 @@ function useVisitorTransactionService() {
22102
22105
  value.recNo = parsed.recNo;
22103
22106
  }
22104
22107
  }
22105
- if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
22108
+ if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
22106
22109
  for (const vp of value.visitorPass) {
22107
22110
  try {
22108
22111
  const updatePayload = { status: "In Use" /* IN_USE */ };
22109
22112
  const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
22113
+ if (!visitorPassId)
22114
+ value.visitorPass = [];
22110
22115
  await KeyRepo.updateKeyById(
22111
22116
  visitorPassId,
22112
22117
  updatePayload,
@@ -22122,6 +22127,8 @@ function useVisitorTransactionService() {
22122
22127
  try {
22123
22128
  const updatePayload = { status: "In Use" /* IN_USE */ };
22124
22129
  const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
22130
+ if (!passKeyId)
22131
+ value.passKeys = [];
22125
22132
  await KeyRepo.updateKeyById(
22126
22133
  passKeyId,
22127
22134
  updatePayload,
@@ -31076,18 +31083,16 @@ function useSiteUnitBillingRepo() {
31076
31083
  const endDate = new Date(dateTo);
31077
31084
  endDate.setHours(23, 59, 59, 999);
31078
31085
  dateExpr = {
31079
- $expr: {
31080
- $and: [
31081
- { $gte: ["$issueDate", startDate] },
31082
- { $lte: ["$issueDate", endDate] }
31083
- ]
31086
+ issueDate: {
31087
+ $gte: startDate,
31088
+ $lte: endDate
31084
31089
  }
31085
31090
  };
31086
31091
  }
31087
31092
  const query = {
31088
31093
  status,
31089
- ...import_mongodb86.ObjectId.isValid(unitId) && { unitId: new import_mongodb86.ObjectId(unitId) },
31090
- ...import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) },
31094
+ ...unitId && import_mongodb86.ObjectId.isValid(unitId) && { unitId: new import_mongodb86.ObjectId(unitId) },
31095
+ ...site && import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) },
31091
31096
  ...dateExpr
31092
31097
  };
31093
31098
  try {
@@ -37188,16 +37193,13 @@ function useStatementOfAccountService() {
37188
37193
  if (user) {
37189
37194
  value.createdByName = user.name;
37190
37195
  }
37191
- let unit_billings = await getUnitBillingBySite(
37192
- {
37193
- status: "active",
37194
- site: value.site.toString() ?? "",
37195
- dateFrom,
37196
- dateTo,
37197
- unitId: value.unitId?.toString() ?? ""
37198
- },
37199
- session
37200
- );
37196
+ let unit_billings = await getUnitBillingBySite({
37197
+ status: "active",
37198
+ site: value.site.toString() ?? "",
37199
+ dateFrom,
37200
+ dateTo,
37201
+ unitId: value.unitId?.toString() ?? ""
37202
+ });
37201
37203
  if (!unit_billings || unit_billings.length === 0) {
37202
37204
  return unit_billings;
37203
37205
  }
@@ -40701,8 +40703,7 @@ function useOccurrenceEntryService() {
40701
40703
  updateOccurrenceEntryById: _updateOccurrenceEntryById,
40702
40704
  getOccurrenceEntryById: _getOccurrenceEntryById,
40703
40705
  getOccurrenceEntryByBookId: _getOccurrenceEntryByBookId,
40704
- updateOccurrenceEntryByBookId: _updateOccurrenceEntryByBookId,
40705
- deleteOccurrenceEntryById: _deleteOccurrenceEntryById
40706
+ updateOccurrenceEntryByBookId: _updateOccurrenceEntryByBookId
40706
40707
  } = useOccurrenceEntryRepo();
40707
40708
  const {
40708
40709
  getOccurrenceBookById: _getOccurrenceBookById,
@@ -40778,7 +40779,6 @@ function useOccurrenceEntryService() {
40778
40779
  totalInput: book.totalInput + 1
40779
40780
  });
40780
40781
  await _add(value);
40781
- await _deleteOccurrenceEntryById(id);
40782
40782
  await session?.commitTransaction();
40783
40783
  return "Successfully updated daily occurrence entry.";
40784
40784
  } catch (error) {