@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/dist/index.mjs
CHANGED
|
@@ -1583,10 +1583,21 @@ function useOccurrenceEntryRepo() {
|
|
|
1583
1583
|
} catch (error) {
|
|
1584
1584
|
throw new BadRequestError7("Invalid site ID format.");
|
|
1585
1585
|
}
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1586
|
+
const escapedSearch = search ? search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : "";
|
|
1587
|
+
const query = {
|
|
1588
|
+
site,
|
|
1589
|
+
...search && {
|
|
1590
|
+
$or: [
|
|
1591
|
+
{ occurrence: { $regex: escapedSearch, $options: "i" } },
|
|
1592
|
+
{ bookEntryCount: { $regex: escapedSearch, $options: "i" } },
|
|
1593
|
+
{ subjectName: { $regex: escapedSearch, $options: "i" } },
|
|
1594
|
+
{ userName: { $regex: escapedSearch, $options: "i" } }
|
|
1595
|
+
]
|
|
1596
|
+
},
|
|
1597
|
+
...dailyOccurrenceBookId && {
|
|
1598
|
+
dailyOccurrenceBookId: typeof dailyOccurrenceBookId === "string" ? new ObjectId7(dailyOccurrenceBookId) : dailyOccurrenceBookId
|
|
1599
|
+
}
|
|
1588
1600
|
};
|
|
1589
|
-
let query = { ...baseQuery };
|
|
1590
1601
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
1591
1602
|
const cacheOptions = {
|
|
1592
1603
|
site: site.toString(),
|
|
@@ -1595,20 +1606,9 @@ function useOccurrenceEntryRepo() {
|
|
|
1595
1606
|
limit,
|
|
1596
1607
|
...dailyOccurrenceBookId && {
|
|
1597
1608
|
dailyOccurrenceBookId
|
|
1598
|
-
}
|
|
1609
|
+
},
|
|
1610
|
+
...search && { search }
|
|
1599
1611
|
};
|
|
1600
|
-
if (search) {
|
|
1601
|
-
query.$text = { $search: search };
|
|
1602
|
-
cacheOptions.search = search;
|
|
1603
|
-
}
|
|
1604
|
-
if (dailyOccurrenceBookId) {
|
|
1605
|
-
try {
|
|
1606
|
-
dailyOccurrenceBookId = new ObjectId7(dailyOccurrenceBookId);
|
|
1607
|
-
query.dailyOccurrenceBookId = dailyOccurrenceBookId;
|
|
1608
|
-
} catch (error) {
|
|
1609
|
-
throw new BadRequestError7("Invalid daily occurrence book ID format.");
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
1612
|
const cacheKey = makeCacheKey4(namespace_collection, cacheOptions);
|
|
1613
1613
|
const cachedData = await getCache(cacheKey);
|
|
1614
1614
|
if (cachedData) {
|
|
@@ -1710,19 +1710,6 @@ function useOccurrenceEntryRepo() {
|
|
|
1710
1710
|
{ session }
|
|
1711
1711
|
).toArray();
|
|
1712
1712
|
length = await collection.countDocuments(query, { session });
|
|
1713
|
-
if ((!items || items.length === 0) && search) {
|
|
1714
|
-
const regexQuery = {
|
|
1715
|
-
...baseQuery,
|
|
1716
|
-
$or: [{ occurrence: { $regex: search, $options: "i" } }]
|
|
1717
|
-
};
|
|
1718
|
-
items = await collection.aggregate([
|
|
1719
|
-
{ $match: regexQuery },
|
|
1720
|
-
{ $sort: sort },
|
|
1721
|
-
{ $skip: page * limit },
|
|
1722
|
-
{ $limit: limit }
|
|
1723
|
-
]).toArray();
|
|
1724
|
-
length = await collection.countDocuments(regexQuery, { session });
|
|
1725
|
-
}
|
|
1726
1713
|
const data = paginate3(items, page, limit, length);
|
|
1727
1714
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
1728
1715
|
logger6.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -13275,21 +13262,21 @@ function MVisitorTransaction(value) {
|
|
|
13275
13262
|
try {
|
|
13276
13263
|
value.org = new ObjectId39(value.org);
|
|
13277
13264
|
} catch (error2) {
|
|
13278
|
-
throw new Error("Invalid ID.");
|
|
13265
|
+
throw new Error("Invalid org ID.");
|
|
13279
13266
|
}
|
|
13280
13267
|
}
|
|
13281
13268
|
if (value.site && typeof value.site === "string") {
|
|
13282
13269
|
try {
|
|
13283
13270
|
value.site = new ObjectId39(value.site);
|
|
13284
13271
|
} catch (error2) {
|
|
13285
|
-
throw new Error("Invalid ID.");
|
|
13272
|
+
throw new Error("Invalid site ID.");
|
|
13286
13273
|
}
|
|
13287
13274
|
}
|
|
13288
13275
|
if (value.unit && typeof value.unit === "string") {
|
|
13289
13276
|
try {
|
|
13290
13277
|
value.unit = new ObjectId39(value.unit);
|
|
13291
13278
|
} catch (error2) {
|
|
13292
|
-
throw new Error("Invalid ID.");
|
|
13279
|
+
throw new Error("Invalid unit ID.");
|
|
13293
13280
|
}
|
|
13294
13281
|
}
|
|
13295
13282
|
if (value.manualCheckout && typeof value.manualCheckout === "string") {
|
|
@@ -13319,6 +13306,13 @@ function MVisitorTransaction(value) {
|
|
|
13319
13306
|
return p;
|
|
13320
13307
|
});
|
|
13321
13308
|
}
|
|
13309
|
+
if (value.invitedId && typeof value.invitedId === "string") {
|
|
13310
|
+
try {
|
|
13311
|
+
value.invitedId = new ObjectId39(value.invitedId);
|
|
13312
|
+
} catch (error2) {
|
|
13313
|
+
throw new Error("Invalid invited ID.");
|
|
13314
|
+
}
|
|
13315
|
+
}
|
|
13322
13316
|
const newDate = (/* @__PURE__ */ new Date()).toISOString();
|
|
13323
13317
|
return {
|
|
13324
13318
|
_id: value._id,
|
|
@@ -13359,11 +13353,11 @@ function MVisitorTransaction(value) {
|
|
|
13359
13353
|
numberOfPassengers: value.numberOfPassengers ?? null,
|
|
13360
13354
|
email: value.email,
|
|
13361
13355
|
isOvernightParking: value.isOvernightParking ?? false,
|
|
13362
|
-
invitedId:
|
|
13356
|
+
invitedId: value.invitedId ?? "",
|
|
13363
13357
|
overnightParking: value.isOvernightParking == true ? {
|
|
13364
13358
|
status: "pending approval",
|
|
13365
13359
|
remarks: "",
|
|
13366
|
-
updatedBy:
|
|
13360
|
+
updatedBy: value.invitedId ?? ""
|
|
13367
13361
|
} : null
|
|
13368
13362
|
};
|
|
13369
13363
|
}
|