@7365admin1/core 2.35.0 → 2.36.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.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5187b6f: get latest changes today
8
+
9
+ ## 2.35.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 9157cc3: Improve dob search entry / fix visitor transaction pick up
14
+
3
15
  ## 2.35.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -2602,11 +2602,11 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
2602
2602
  numberOfPassengers: number | null;
2603
2603
  email: string | undefined;
2604
2604
  isOvernightParking: boolean;
2605
- invitedId: ObjectId;
2605
+ invitedId: string | ObjectId;
2606
2606
  overnightParking: {
2607
2607
  status: string;
2608
2608
  remarks: string;
2609
- updatedBy: ObjectId;
2609
+ updatedBy: string | ObjectId;
2610
2610
  } | null;
2611
2611
  };
2612
2612
 
package/dist/index.js CHANGED
@@ -1977,10 +1977,21 @@ function useOccurrenceEntryRepo() {
1977
1977
  } catch (error) {
1978
1978
  throw new import_node_server_utils8.BadRequestError("Invalid site ID format.");
1979
1979
  }
1980
- const baseQuery = {
1981
- site
1980
+ const escapedSearch = search ? search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : "";
1981
+ const query = {
1982
+ site,
1983
+ ...search && {
1984
+ $or: [
1985
+ { occurrence: { $regex: escapedSearch, $options: "i" } },
1986
+ { bookEntryCount: { $regex: escapedSearch, $options: "i" } },
1987
+ { subjectName: { $regex: escapedSearch, $options: "i" } },
1988
+ { userName: { $regex: escapedSearch, $options: "i" } }
1989
+ ]
1990
+ },
1991
+ ...dailyOccurrenceBookId && {
1992
+ dailyOccurrenceBookId: typeof dailyOccurrenceBookId === "string" ? new import_mongodb7.ObjectId(dailyOccurrenceBookId) : dailyOccurrenceBookId
1993
+ }
1982
1994
  };
1983
- let query = { ...baseQuery };
1984
1995
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
1985
1996
  const cacheOptions = {
1986
1997
  site: site.toString(),
@@ -1989,20 +2000,9 @@ function useOccurrenceEntryRepo() {
1989
2000
  limit,
1990
2001
  ...dailyOccurrenceBookId && {
1991
2002
  dailyOccurrenceBookId
1992
- }
2003
+ },
2004
+ ...search && { search }
1993
2005
  };
1994
- if (search) {
1995
- query.$text = { $search: search };
1996
- cacheOptions.search = search;
1997
- }
1998
- if (dailyOccurrenceBookId) {
1999
- try {
2000
- dailyOccurrenceBookId = new import_mongodb7.ObjectId(dailyOccurrenceBookId);
2001
- query.dailyOccurrenceBookId = dailyOccurrenceBookId;
2002
- } catch (error) {
2003
- throw new import_node_server_utils8.BadRequestError("Invalid daily occurrence book ID format.");
2004
- }
2005
- }
2006
2006
  const cacheKey = (0, import_node_server_utils8.makeCacheKey)(namespace_collection, cacheOptions);
2007
2007
  const cachedData = await getCache(cacheKey);
2008
2008
  if (cachedData) {
@@ -2104,19 +2104,6 @@ function useOccurrenceEntryRepo() {
2104
2104
  { session }
2105
2105
  ).toArray();
2106
2106
  length = await collection.countDocuments(query, { session });
2107
- if ((!items || items.length === 0) && search) {
2108
- const regexQuery = {
2109
- ...baseQuery,
2110
- $or: [{ occurrence: { $regex: search, $options: "i" } }]
2111
- };
2112
- items = await collection.aggregate([
2113
- { $match: regexQuery },
2114
- { $sort: sort },
2115
- { $skip: page * limit },
2116
- { $limit: limit }
2117
- ]).toArray();
2118
- length = await collection.countDocuments(regexQuery, { session });
2119
- }
2120
2107
  const data = (0, import_node_server_utils8.paginate)(items, page, limit, length);
2121
2108
  setCache(cacheKey, data, 15 * 60).then(() => {
2122
2109
  import_node_server_utils8.logger.info(`Cache set for key: ${cacheKey}`);
@@ -13477,21 +13464,21 @@ function MVisitorTransaction(value) {
13477
13464
  try {
13478
13465
  value.org = new import_mongodb39.ObjectId(value.org);
13479
13466
  } catch (error2) {
13480
- throw new Error("Invalid ID.");
13467
+ throw new Error("Invalid org ID.");
13481
13468
  }
13482
13469
  }
13483
13470
  if (value.site && typeof value.site === "string") {
13484
13471
  try {
13485
13472
  value.site = new import_mongodb39.ObjectId(value.site);
13486
13473
  } catch (error2) {
13487
- throw new Error("Invalid ID.");
13474
+ throw new Error("Invalid site ID.");
13488
13475
  }
13489
13476
  }
13490
13477
  if (value.unit && typeof value.unit === "string") {
13491
13478
  try {
13492
13479
  value.unit = new import_mongodb39.ObjectId(value.unit);
13493
13480
  } catch (error2) {
13494
- throw new Error("Invalid ID.");
13481
+ throw new Error("Invalid unit ID.");
13495
13482
  }
13496
13483
  }
13497
13484
  if (value.manualCheckout && typeof value.manualCheckout === "string") {
@@ -13521,6 +13508,13 @@ function MVisitorTransaction(value) {
13521
13508
  return p;
13522
13509
  });
13523
13510
  }
13511
+ if (value.invitedId && typeof value.invitedId === "string") {
13512
+ try {
13513
+ value.invitedId = new import_mongodb39.ObjectId(value.invitedId);
13514
+ } catch (error2) {
13515
+ throw new Error("Invalid invited ID.");
13516
+ }
13517
+ }
13524
13518
  const newDate = (/* @__PURE__ */ new Date()).toISOString();
13525
13519
  return {
13526
13520
  _id: value._id,
@@ -13561,11 +13555,11 @@ function MVisitorTransaction(value) {
13561
13555
  numberOfPassengers: value.numberOfPassengers ?? null,
13562
13556
  email: value.email,
13563
13557
  isOvernightParking: value.isOvernightParking ?? false,
13564
- invitedId: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null,
13558
+ invitedId: value.invitedId ?? "",
13565
13559
  overnightParking: value.isOvernightParking == true ? {
13566
13560
  status: "pending approval",
13567
13561
  remarks: "",
13568
- updatedBy: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null
13562
+ updatedBy: value.invitedId ?? ""
13569
13563
  } : null
13570
13564
  };
13571
13565
  }
@@ -24468,7 +24462,7 @@ function MPatrolRoute(value) {
24468
24462
  try {
24469
24463
  value.assignee = value.assignee.map((id) => new import_mongodb65.ObjectId(id));
24470
24464
  } catch {
24471
- throw new import_node_server_utils115.BadRequestError("Invalid _id format");
24465
+ throw new import_node_server_utils115.BadRequestError("Invalid assignee id format");
24472
24466
  }
24473
24467
  }
24474
24468
  if (value.cameras && Array.isArray(value.cameras)) {
@@ -25177,14 +25171,14 @@ function MPatrolLog(value) {
25177
25171
  try {
25178
25172
  value.route = new import_mongodb67.ObjectId(value.route);
25179
25173
  } catch {
25180
- throw new import_node_server_utils118.BadRequestError("Invalid route format");
25174
+ throw new import_node_server_utils118.BadRequestError("Invalid route id format");
25181
25175
  }
25182
25176
  }
25183
25177
  if (value.site && typeof value.site === "string") {
25184
25178
  try {
25185
25179
  value.site = new import_mongodb67.ObjectId(value.site);
25186
25180
  } catch {
25187
- throw new import_node_server_utils118.BadRequestError("Invalid site format");
25181
+ throw new import_node_server_utils118.BadRequestError("Invalid site id format");
25188
25182
  }
25189
25183
  }
25190
25184
  const assignee = (value.assignee || []).map((id) => {
@@ -25198,7 +25192,7 @@ function MPatrolLog(value) {
25198
25192
  try {
25199
25193
  value.incidentReport.id = new import_mongodb67.ObjectId(value.incidentReport.id);
25200
25194
  } catch {
25201
- throw new import_node_server_utils118.BadRequestError("Invalid incident report format");
25195
+ throw new import_node_server_utils118.BadRequestError("Invalid incident report id format");
25202
25196
  }
25203
25197
  }
25204
25198
  return {
@@ -26629,7 +26623,7 @@ function MServiceProviderBilling(value) {
26629
26623
  try {
26630
26624
  value.orgId = new import_mongodb71.ObjectId(value.orgId);
26631
26625
  } catch {
26632
- throw new Error("Invalid ID.");
26626
+ throw new Error("Invalid org ID.");
26633
26627
  }
26634
26628
  }
26635
26629
  return {
@@ -28993,14 +28987,14 @@ function MBillingItem(value) {
28993
28987
  try {
28994
28988
  value.site = new import_mongodb79.ObjectId(value.site);
28995
28989
  } catch {
28996
- throw new import_node_server_utils137.BadRequestError("Invalid site format");
28990
+ throw new import_node_server_utils137.BadRequestError("Invalid site id format");
28997
28991
  }
28998
28992
  }
28999
28993
  if (value.org && typeof value.org === "string") {
29000
28994
  try {
29001
28995
  value.org = new import_mongodb79.ObjectId(value.org);
29002
28996
  } catch {
29003
- throw new import_node_server_utils137.BadRequestError("Invalid org format");
28997
+ throw new import_node_server_utils137.BadRequestError("Invalid org id format");
29004
28998
  }
29005
28999
  }
29006
29000
  if (value.units && Array.isArray(value.units)) {
@@ -29357,21 +29351,21 @@ function MBillingConfiguration(value) {
29357
29351
  try {
29358
29352
  value.site = new import_mongodb81.ObjectId(value.site);
29359
29353
  } catch {
29360
- throw new import_node_server_utils139.BadRequestError("Invalid site format");
29354
+ throw new import_node_server_utils139.BadRequestError("Invalid site id format");
29361
29355
  }
29362
29356
  }
29363
29357
  if (value.org && typeof value.org === "string") {
29364
29358
  try {
29365
29359
  value.org = new import_mongodb81.ObjectId(value.org);
29366
29360
  } catch {
29367
- throw new import_node_server_utils139.BadRequestError("Invalid org format");
29361
+ throw new import_node_server_utils139.BadRequestError("Invalid org id format");
29368
29362
  }
29369
29363
  }
29370
29364
  if (value.createdBy && typeof value.createdBy === "string") {
29371
29365
  try {
29372
29366
  value.createdBy = new import_mongodb81.ObjectId(value.createdBy);
29373
29367
  } catch {
29374
- throw new import_node_server_utils139.BadRequestError("Invalid createdBy format");
29368
+ throw new import_node_server_utils139.BadRequestError("Invalid createdBy id format");
29375
29369
  }
29376
29370
  }
29377
29371
  return {
@@ -30789,35 +30783,35 @@ function MUnitBilling(value) {
30789
30783
  try {
30790
30784
  value.site = new import_mongodb85.ObjectId(value.site);
30791
30785
  } catch {
30792
- throw new import_node_server_utils148.BadRequestError("Invalid site format");
30786
+ throw new import_node_server_utils148.BadRequestError("Invalid site id format");
30793
30787
  }
30794
30788
  }
30795
30789
  if (value.org && typeof value.org === "string") {
30796
30790
  try {
30797
30791
  value.org = new import_mongodb85.ObjectId(value.org);
30798
30792
  } catch {
30799
- throw new import_node_server_utils148.BadRequestError("Invalid org format");
30793
+ throw new import_node_server_utils148.BadRequestError("Invalid org id format");
30800
30794
  }
30801
30795
  }
30802
30796
  if (value.paidBy && typeof value.paidBy === "string") {
30803
30797
  try {
30804
30798
  value.paidBy = new import_mongodb85.ObjectId(value.paidBy);
30805
30799
  } catch {
30806
- throw new import_node_server_utils148.BadRequestError("Invalid paidBy format");
30800
+ throw new import_node_server_utils148.BadRequestError("Invalid paidBy id format");
30807
30801
  }
30808
30802
  }
30809
30803
  if (value.billItem && typeof value.billItem === "string") {
30810
30804
  try {
30811
30805
  value.billItem = new import_mongodb85.ObjectId(value.billItem);
30812
30806
  } catch {
30813
- throw new import_node_server_utils148.BadRequestError("Invalid billItem format");
30807
+ throw new import_node_server_utils148.BadRequestError("Invalid billItem id format");
30814
30808
  }
30815
30809
  }
30816
30810
  if (value.unitId && typeof value.unitId === "string") {
30817
30811
  try {
30818
30812
  value.unitId = new import_mongodb85.ObjectId(value.unitId);
30819
30813
  } catch {
30820
- throw new import_node_server_utils148.BadRequestError("Invalid unitId format");
30814
+ throw new import_node_server_utils148.BadRequestError("Invalid unitId id format");
30821
30815
  }
30822
30816
  }
30823
30817
  return {