@7365admin1/core 2.35.0 → 2.35.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 +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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
|
|
1981
|
-
|
|
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:
|
|
13558
|
+
invitedId: value.invitedId ?? "",
|
|
13565
13559
|
overnightParking: value.isOvernightParking == true ? {
|
|
13566
13560
|
status: "pending approval",
|
|
13567
13561
|
remarks: "",
|
|
13568
|
-
updatedBy:
|
|
13562
|
+
updatedBy: value.invitedId ?? ""
|
|
13569
13563
|
} : null
|
|
13570
13564
|
};
|
|
13571
13565
|
}
|