@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 +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -49
- 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
|
}
|
|
@@ -24397,7 +24391,7 @@ function MPatrolRoute(value) {
|
|
|
24397
24391
|
try {
|
|
24398
24392
|
value.assignee = value.assignee.map((id) => new ObjectId65(id));
|
|
24399
24393
|
} catch {
|
|
24400
|
-
throw new BadRequestError109("Invalid
|
|
24394
|
+
throw new BadRequestError109("Invalid assignee id format");
|
|
24401
24395
|
}
|
|
24402
24396
|
}
|
|
24403
24397
|
if (value.cameras && Array.isArray(value.cameras)) {
|
|
@@ -25115,14 +25109,14 @@ function MPatrolLog(value) {
|
|
|
25115
25109
|
try {
|
|
25116
25110
|
value.route = new ObjectId67(value.route);
|
|
25117
25111
|
} catch {
|
|
25118
|
-
throw new BadRequestError112("Invalid route format");
|
|
25112
|
+
throw new BadRequestError112("Invalid route id format");
|
|
25119
25113
|
}
|
|
25120
25114
|
}
|
|
25121
25115
|
if (value.site && typeof value.site === "string") {
|
|
25122
25116
|
try {
|
|
25123
25117
|
value.site = new ObjectId67(value.site);
|
|
25124
25118
|
} catch {
|
|
25125
|
-
throw new BadRequestError112("Invalid site format");
|
|
25119
|
+
throw new BadRequestError112("Invalid site id format");
|
|
25126
25120
|
}
|
|
25127
25121
|
}
|
|
25128
25122
|
const assignee = (value.assignee || []).map((id) => {
|
|
@@ -25136,7 +25130,7 @@ function MPatrolLog(value) {
|
|
|
25136
25130
|
try {
|
|
25137
25131
|
value.incidentReport.id = new ObjectId67(value.incidentReport.id);
|
|
25138
25132
|
} catch {
|
|
25139
|
-
throw new BadRequestError112("Invalid incident report format");
|
|
25133
|
+
throw new BadRequestError112("Invalid incident report id format");
|
|
25140
25134
|
}
|
|
25141
25135
|
}
|
|
25142
25136
|
return {
|
|
@@ -26590,7 +26584,7 @@ function MServiceProviderBilling(value) {
|
|
|
26590
26584
|
try {
|
|
26591
26585
|
value.orgId = new ObjectId71(value.orgId);
|
|
26592
26586
|
} catch {
|
|
26593
|
-
throw new Error("Invalid ID.");
|
|
26587
|
+
throw new Error("Invalid org ID.");
|
|
26594
26588
|
}
|
|
26595
26589
|
}
|
|
26596
26590
|
return {
|
|
@@ -28995,14 +28989,14 @@ function MBillingItem(value) {
|
|
|
28995
28989
|
try {
|
|
28996
28990
|
value.site = new ObjectId79(value.site);
|
|
28997
28991
|
} catch {
|
|
28998
|
-
throw new BadRequestError127("Invalid site format");
|
|
28992
|
+
throw new BadRequestError127("Invalid site id format");
|
|
28999
28993
|
}
|
|
29000
28994
|
}
|
|
29001
28995
|
if (value.org && typeof value.org === "string") {
|
|
29002
28996
|
try {
|
|
29003
28997
|
value.org = new ObjectId79(value.org);
|
|
29004
28998
|
} catch {
|
|
29005
|
-
throw new BadRequestError127("Invalid org format");
|
|
28999
|
+
throw new BadRequestError127("Invalid org id format");
|
|
29006
29000
|
}
|
|
29007
29001
|
}
|
|
29008
29002
|
if (value.units && Array.isArray(value.units)) {
|
|
@@ -29381,21 +29375,21 @@ function MBillingConfiguration(value) {
|
|
|
29381
29375
|
try {
|
|
29382
29376
|
value.site = new ObjectId81(value.site);
|
|
29383
29377
|
} catch {
|
|
29384
|
-
throw new BadRequestError129("Invalid site format");
|
|
29378
|
+
throw new BadRequestError129("Invalid site id format");
|
|
29385
29379
|
}
|
|
29386
29380
|
}
|
|
29387
29381
|
if (value.org && typeof value.org === "string") {
|
|
29388
29382
|
try {
|
|
29389
29383
|
value.org = new ObjectId81(value.org);
|
|
29390
29384
|
} catch {
|
|
29391
|
-
throw new BadRequestError129("Invalid org format");
|
|
29385
|
+
throw new BadRequestError129("Invalid org id format");
|
|
29392
29386
|
}
|
|
29393
29387
|
}
|
|
29394
29388
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
29395
29389
|
try {
|
|
29396
29390
|
value.createdBy = new ObjectId81(value.createdBy);
|
|
29397
29391
|
} catch {
|
|
29398
|
-
throw new BadRequestError129("Invalid createdBy format");
|
|
29392
|
+
throw new BadRequestError129("Invalid createdBy id format");
|
|
29399
29393
|
}
|
|
29400
29394
|
}
|
|
29401
29395
|
return {
|
|
@@ -30826,35 +30820,35 @@ function MUnitBilling(value) {
|
|
|
30826
30820
|
try {
|
|
30827
30821
|
value.site = new ObjectId85(value.site);
|
|
30828
30822
|
} catch {
|
|
30829
|
-
throw new BadRequestError137("Invalid site format");
|
|
30823
|
+
throw new BadRequestError137("Invalid site id format");
|
|
30830
30824
|
}
|
|
30831
30825
|
}
|
|
30832
30826
|
if (value.org && typeof value.org === "string") {
|
|
30833
30827
|
try {
|
|
30834
30828
|
value.org = new ObjectId85(value.org);
|
|
30835
30829
|
} catch {
|
|
30836
|
-
throw new BadRequestError137("Invalid org format");
|
|
30830
|
+
throw new BadRequestError137("Invalid org id format");
|
|
30837
30831
|
}
|
|
30838
30832
|
}
|
|
30839
30833
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
30840
30834
|
try {
|
|
30841
30835
|
value.paidBy = new ObjectId85(value.paidBy);
|
|
30842
30836
|
} catch {
|
|
30843
|
-
throw new BadRequestError137("Invalid paidBy format");
|
|
30837
|
+
throw new BadRequestError137("Invalid paidBy id format");
|
|
30844
30838
|
}
|
|
30845
30839
|
}
|
|
30846
30840
|
if (value.billItem && typeof value.billItem === "string") {
|
|
30847
30841
|
try {
|
|
30848
30842
|
value.billItem = new ObjectId85(value.billItem);
|
|
30849
30843
|
} catch {
|
|
30850
|
-
throw new BadRequestError137("Invalid billItem format");
|
|
30844
|
+
throw new BadRequestError137("Invalid billItem id format");
|
|
30851
30845
|
}
|
|
30852
30846
|
}
|
|
30853
30847
|
if (value.unitId && typeof value.unitId === "string") {
|
|
30854
30848
|
try {
|
|
30855
30849
|
value.unitId = new ObjectId85(value.unitId);
|
|
30856
30850
|
} catch {
|
|
30857
|
-
throw new BadRequestError137("Invalid unitId format");
|
|
30851
|
+
throw new BadRequestError137("Invalid unitId id format");
|
|
30858
30852
|
}
|
|
30859
30853
|
}
|
|
30860
30854
|
return {
|