@7365admin1/core 2.57.0 → 2.59.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 +14 -0
- package/dist/index.js +167 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15037,6 +15037,74 @@ function useVehicleRepo() {
|
|
|
15037
15037
|
throw new Error("Failed to bulk upsert vehicles.");
|
|
15038
15038
|
}
|
|
15039
15039
|
}
|
|
15040
|
+
async function getBlocklistedVehicles({
|
|
15041
|
+
page = 1,
|
|
15042
|
+
limit = 10,
|
|
15043
|
+
search = "",
|
|
15044
|
+
site = ""
|
|
15045
|
+
}) {
|
|
15046
|
+
page = page > 0 ? page - 1 : 0;
|
|
15047
|
+
const baseQuery = {
|
|
15048
|
+
type: "blocklist" /* BLOCKLIST */,
|
|
15049
|
+
...site && {
|
|
15050
|
+
site: typeof site === "string" ? new ObjectId42(site) : site
|
|
15051
|
+
}
|
|
15052
|
+
};
|
|
15053
|
+
let query = {
|
|
15054
|
+
...baseQuery,
|
|
15055
|
+
...search && { $text: { $search: search } }
|
|
15056
|
+
};
|
|
15057
|
+
const escapeRegex = (input) => input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15058
|
+
const buildPipeline = (matchQuery) => [
|
|
15059
|
+
{ $match: matchQuery },
|
|
15060
|
+
{
|
|
15061
|
+
$addFields: {
|
|
15062
|
+
latestDate: { $max: ["$createdAt", "$updatedAt"] }
|
|
15063
|
+
}
|
|
15064
|
+
},
|
|
15065
|
+
{ $sort: { latestDate: -1 } },
|
|
15066
|
+
{ $skip: page * limit },
|
|
15067
|
+
{ $limit: limit },
|
|
15068
|
+
{
|
|
15069
|
+
$project: {
|
|
15070
|
+
latestDate: 0
|
|
15071
|
+
}
|
|
15072
|
+
}
|
|
15073
|
+
];
|
|
15074
|
+
const buildCountPipeline = (matchQuery) => [
|
|
15075
|
+
{ $match: matchQuery },
|
|
15076
|
+
{ $count: "total" }
|
|
15077
|
+
];
|
|
15078
|
+
try {
|
|
15079
|
+
let items = [];
|
|
15080
|
+
let length = 0;
|
|
15081
|
+
items = await collection.aggregate(buildPipeline(query)).toArray();
|
|
15082
|
+
const countResult = await collection.aggregate(buildCountPipeline(query)).toArray();
|
|
15083
|
+
length = countResult[0]?.total || 0;
|
|
15084
|
+
if ((!items || items.length === 0) && search) {
|
|
15085
|
+
const escaped = escapeRegex(search);
|
|
15086
|
+
const regexQuery = {
|
|
15087
|
+
...baseQuery,
|
|
15088
|
+
$or: [
|
|
15089
|
+
{ name: { $regex: escaped, $options: "i" } },
|
|
15090
|
+
{ plateNumber: { $regex: escaped, $options: "i" } },
|
|
15091
|
+
{ company: { $regex: escaped, $options: "i" } },
|
|
15092
|
+
{ level: { $regex: escaped, $options: "i" } },
|
|
15093
|
+
{ unitName: { $regex: escaped, $options: "i" } },
|
|
15094
|
+
{ contact: { $regex: escaped, $options: "i" } },
|
|
15095
|
+
{ nric: { $regex: escaped, $options: "i" } }
|
|
15096
|
+
]
|
|
15097
|
+
};
|
|
15098
|
+
items = await collection.aggregate(buildPipeline(regexQuery)).toArray();
|
|
15099
|
+
const regexCountResult = await collection.aggregate(buildCountPipeline(regexQuery)).toArray();
|
|
15100
|
+
length = regexCountResult[0]?.total || 0;
|
|
15101
|
+
}
|
|
15102
|
+
const data = paginate18(items, page, limit, length);
|
|
15103
|
+
return data;
|
|
15104
|
+
} catch (error) {
|
|
15105
|
+
throw error;
|
|
15106
|
+
}
|
|
15107
|
+
}
|
|
15040
15108
|
return {
|
|
15041
15109
|
createIndex,
|
|
15042
15110
|
createTextIndex,
|
|
@@ -15053,7 +15121,8 @@ function useVehicleRepo() {
|
|
|
15053
15121
|
getAllVehiclesByUnitId,
|
|
15054
15122
|
getAllExpiredVehicles,
|
|
15055
15123
|
bulkUpsertVehicles,
|
|
15056
|
-
getSpecificVehicleById
|
|
15124
|
+
getSpecificVehicleById,
|
|
15125
|
+
getBlocklistedVehicles
|
|
15057
15126
|
};
|
|
15058
15127
|
}
|
|
15059
15128
|
|
|
@@ -20537,7 +20606,8 @@ function useVehicleController() {
|
|
|
20537
20606
|
getVehicleById: _getVehicleById,
|
|
20538
20607
|
getVehiclesByNRIC: _getVehiclesByNRIC,
|
|
20539
20608
|
getAllVehiclesByUnitId: _getAllVehiclesByUnitId,
|
|
20540
|
-
getSpecificVehicleById: _getSpecificVehicleById
|
|
20609
|
+
getSpecificVehicleById: _getSpecificVehicleById,
|
|
20610
|
+
getBlocklistedVehicles: _getBlocklistedVehicles
|
|
20541
20611
|
} = useVehicleRepo();
|
|
20542
20612
|
function normalizeRow(row) {
|
|
20543
20613
|
return Object.fromEntries(
|
|
@@ -21073,6 +21143,38 @@ function useVehicleController() {
|
|
|
21073
21143
|
return;
|
|
21074
21144
|
}
|
|
21075
21145
|
}
|
|
21146
|
+
async function getBlocklistedVehicles(req, res, next) {
|
|
21147
|
+
const schema2 = Joi46.object({
|
|
21148
|
+
search: Joi46.string().optional().allow("", null),
|
|
21149
|
+
page: Joi46.number().integer().min(1).optional().default(1),
|
|
21150
|
+
limit: Joi46.number().integer().min(1).max(100).optional().default(10),
|
|
21151
|
+
site: Joi46.string().hex().length(24).optional().allow(null, "")
|
|
21152
|
+
});
|
|
21153
|
+
const { error, value } = schema2.validate(req.query, {
|
|
21154
|
+
abortEarly: false
|
|
21155
|
+
});
|
|
21156
|
+
if (error) {
|
|
21157
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
21158
|
+
logger65.log({ level: "error", message: messages });
|
|
21159
|
+
next(new BadRequestError84(messages));
|
|
21160
|
+
return;
|
|
21161
|
+
}
|
|
21162
|
+
const { search, page, limit, site } = value;
|
|
21163
|
+
try {
|
|
21164
|
+
const data = await _getBlocklistedVehicles({
|
|
21165
|
+
search,
|
|
21166
|
+
page,
|
|
21167
|
+
limit,
|
|
21168
|
+
site
|
|
21169
|
+
});
|
|
21170
|
+
res.json(data);
|
|
21171
|
+
return;
|
|
21172
|
+
} catch (error2) {
|
|
21173
|
+
logger65.log({ level: "error", message: error2.message });
|
|
21174
|
+
next(error2);
|
|
21175
|
+
return;
|
|
21176
|
+
}
|
|
21177
|
+
}
|
|
21076
21178
|
return {
|
|
21077
21179
|
add,
|
|
21078
21180
|
getVehicles,
|
|
@@ -21085,7 +21187,8 @@ function useVehicleController() {
|
|
|
21085
21187
|
reactivateVehicleById,
|
|
21086
21188
|
getAllVehiclesByUnitId,
|
|
21087
21189
|
uploadSpreadsheetVehicles,
|
|
21088
|
-
getSpecificVehicleById
|
|
21190
|
+
getSpecificVehicleById,
|
|
21191
|
+
getBlocklistedVehicles
|
|
21089
21192
|
};
|
|
21090
21193
|
}
|
|
21091
21194
|
|
|
@@ -30632,6 +30735,7 @@ var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
|
|
|
30632
30735
|
})(BulletinRecipient || {});
|
|
30633
30736
|
var BulletinStatus = /* @__PURE__ */ ((BulletinStatus2) => {
|
|
30634
30737
|
BulletinStatus2["ACTIVE"] = "active";
|
|
30738
|
+
BulletinStatus2["UPCOMING"] = "upcoming";
|
|
30635
30739
|
BulletinStatus2["EXPIRED"] = "expired";
|
|
30636
30740
|
BulletinStatus2["DELETED"] = "deleted";
|
|
30637
30741
|
return BulletinStatus2;
|
|
@@ -30985,12 +31089,48 @@ function useBulletinBoardRepo() {
|
|
|
30985
31089
|
throw error;
|
|
30986
31090
|
}
|
|
30987
31091
|
}
|
|
31092
|
+
async function processUpcomingBulletinBoards(session) {
|
|
31093
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
31094
|
+
const query = {
|
|
31095
|
+
status: "upcoming" /* UPCOMING */,
|
|
31096
|
+
startDate: { $lte: now }
|
|
31097
|
+
};
|
|
31098
|
+
try {
|
|
31099
|
+
const res = await collection.updateMany(
|
|
31100
|
+
query,
|
|
31101
|
+
{
|
|
31102
|
+
$set: {
|
|
31103
|
+
status: "active" /* ACTIVE */,
|
|
31104
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
31105
|
+
}
|
|
31106
|
+
},
|
|
31107
|
+
{ session }
|
|
31108
|
+
);
|
|
31109
|
+
if (res.matchedCount === 0) {
|
|
31110
|
+
throw new NotFoundError30("No upcoming bulletin boards found to activate.");
|
|
31111
|
+
}
|
|
31112
|
+
delNamespace().then(() => {
|
|
31113
|
+
logger104.info(
|
|
31114
|
+
`Cache cleared for namespace: ${bulletin_boards_namespace_collection}`
|
|
31115
|
+
);
|
|
31116
|
+
}).catch((err) => {
|
|
31117
|
+
logger104.error(
|
|
31118
|
+
`Failed to clear cache for namespace: ${bulletin_boards_namespace_collection}`,
|
|
31119
|
+
err
|
|
31120
|
+
);
|
|
31121
|
+
});
|
|
31122
|
+
return res;
|
|
31123
|
+
} catch (error) {
|
|
31124
|
+
throw error;
|
|
31125
|
+
}
|
|
31126
|
+
}
|
|
30988
31127
|
return {
|
|
30989
31128
|
add,
|
|
30990
31129
|
getAll,
|
|
30991
31130
|
getBulletinBoardById,
|
|
30992
31131
|
updateBulletinBoardById,
|
|
30993
31132
|
processExpiredBulletinBoards,
|
|
31133
|
+
processUpcomingBulletinBoards,
|
|
30994
31134
|
deleteBulletinBoardById,
|
|
30995
31135
|
createIndexes
|
|
30996
31136
|
};
|
|
@@ -31003,6 +31143,7 @@ function useBulletinBoardService() {
|
|
|
31003
31143
|
add: _add,
|
|
31004
31144
|
updateBulletinBoardById: _updateBulletinBoardById,
|
|
31005
31145
|
processExpiredBulletinBoards: _processExpiredBulletinBoards,
|
|
31146
|
+
processUpcomingBulletinBoards: _processUpcomingBulletinBoards,
|
|
31006
31147
|
deleteBulletinBoardById: _deleteBulletinBoardById,
|
|
31007
31148
|
getBulletinBoardById: _getBulletinBoardById
|
|
31008
31149
|
} = useBulletinBoardRepo();
|
|
@@ -31010,6 +31151,9 @@ function useBulletinBoardService() {
|
|
|
31010
31151
|
async function add(value) {
|
|
31011
31152
|
const session = useAtlas67.getClient()?.startSession();
|
|
31012
31153
|
session?.startTransaction();
|
|
31154
|
+
if (value.startDate && new Date(value.startDate) > /* @__PURE__ */ new Date()) {
|
|
31155
|
+
value.status = "upcoming" /* UPCOMING */;
|
|
31156
|
+
}
|
|
31013
31157
|
try {
|
|
31014
31158
|
await _add(value, session);
|
|
31015
31159
|
await session?.commitTransaction();
|
|
@@ -31035,6 +31179,20 @@ function useBulletinBoardService() {
|
|
|
31035
31179
|
session?.endSession();
|
|
31036
31180
|
}
|
|
31037
31181
|
}
|
|
31182
|
+
async function processUpcomingBulletinBoards() {
|
|
31183
|
+
const session = useAtlas67.getClient()?.startSession();
|
|
31184
|
+
session?.startTransaction();
|
|
31185
|
+
try {
|
|
31186
|
+
await _processUpcomingBulletinBoards(session);
|
|
31187
|
+
await session?.commitTransaction();
|
|
31188
|
+
return;
|
|
31189
|
+
} catch (error) {
|
|
31190
|
+
await session?.abortTransaction();
|
|
31191
|
+
throw error;
|
|
31192
|
+
} finally {
|
|
31193
|
+
session?.endSession();
|
|
31194
|
+
}
|
|
31195
|
+
}
|
|
31038
31196
|
async function processExpiredBulletinBoards() {
|
|
31039
31197
|
const session = useAtlas67.getClient()?.startSession();
|
|
31040
31198
|
session?.startTransaction();
|
|
@@ -31076,6 +31234,7 @@ function useBulletinBoardService() {
|
|
|
31076
31234
|
add,
|
|
31077
31235
|
updateBulletinBoardById,
|
|
31078
31236
|
processExpiredBulletinBoards,
|
|
31237
|
+
processUpcomingBulletinBoards,
|
|
31079
31238
|
deleteBulletinBoardById
|
|
31080
31239
|
};
|
|
31081
31240
|
}
|
|
@@ -32703,14 +32862,15 @@ function useEventManagementRepo() {
|
|
|
32703
32862
|
} catch (error) {
|
|
32704
32863
|
throw new BadRequestError136("Invalid site ID format.");
|
|
32705
32864
|
}
|
|
32865
|
+
const datePart = date ? new Date(date).toISOString().split("T")[0] : "";
|
|
32706
32866
|
const baseQuery = {
|
|
32707
32867
|
site,
|
|
32708
32868
|
status: status ? status : { $ne: "deleted" },
|
|
32709
32869
|
...type && { type },
|
|
32710
|
-
...
|
|
32870
|
+
...datePart && {
|
|
32711
32871
|
dateTime: {
|
|
32712
|
-
$gte: `${
|
|
32713
|
-
$
|
|
32872
|
+
$gte: /* @__PURE__ */ new Date(`${datePart}T00:00:00.000Z`),
|
|
32873
|
+
$lte: /* @__PURE__ */ new Date(`${datePart}T23:59:59.999Z`)
|
|
32714
32874
|
}
|
|
32715
32875
|
}
|
|
32716
32876
|
};
|
|
@@ -32723,7 +32883,7 @@ function useEventManagementRepo() {
|
|
|
32723
32883
|
page,
|
|
32724
32884
|
limit,
|
|
32725
32885
|
...type && { type },
|
|
32726
|
-
...
|
|
32886
|
+
...datePart && { dateTime: datePart }
|
|
32727
32887
|
};
|
|
32728
32888
|
if (search) {
|
|
32729
32889
|
query.$or = [{ title: { $regex: search, $options: "i" } }];
|