@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 2.59.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2da0ba6: get latest changes 13-05-2026 16:18
|
|
8
|
+
|
|
9
|
+
## 2.58.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 36f6c2d: get latest changes for bulletin board api,etc.
|
|
14
|
+
|
|
3
15
|
## 2.57.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2217,6 +2217,16 @@ declare function useVehicleRepo(): {
|
|
|
2217
2217
|
};
|
|
2218
2218
|
}>;
|
|
2219
2219
|
getSpecificVehicleById: (_id: string | ObjectId) => Promise<mongodb.WithId<bson.Document>>;
|
|
2220
|
+
getBlocklistedVehicles: ({ page, limit, search, site, }: {
|
|
2221
|
+
page?: number | undefined;
|
|
2222
|
+
limit?: number | undefined;
|
|
2223
|
+
search?: string | undefined;
|
|
2224
|
+
site?: string | undefined;
|
|
2225
|
+
}) => Promise<{
|
|
2226
|
+
items: any[];
|
|
2227
|
+
pages: number;
|
|
2228
|
+
pageRange: string;
|
|
2229
|
+
}>;
|
|
2220
2230
|
};
|
|
2221
2231
|
|
|
2222
2232
|
declare function formatDahuaDate(date: Date): string;
|
|
@@ -2264,6 +2274,7 @@ declare function useVehicleController(): {
|
|
|
2264
2274
|
getAllVehiclesByUnitId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2265
2275
|
uploadSpreadsheetVehicles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2266
2276
|
getSpecificVehicleById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2277
|
+
getBlocklistedVehicles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2267
2278
|
};
|
|
2268
2279
|
|
|
2269
2280
|
declare function useSiteCameraRepo(): {
|
|
@@ -3746,6 +3757,7 @@ declare enum BulletinRecipient {
|
|
|
3746
3757
|
}
|
|
3747
3758
|
declare enum BulletinStatus {
|
|
3748
3759
|
ACTIVE = "active",
|
|
3760
|
+
UPCOMING = "upcoming",
|
|
3749
3761
|
EXPIRED = "expired",
|
|
3750
3762
|
DELETED = "deleted"
|
|
3751
3763
|
}
|
|
@@ -3820,6 +3832,7 @@ declare function useBulletinBoardRepo(): {
|
|
|
3820
3832
|
getBulletinBoardById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.WithId<bson.Document> | TBulletinBoard>;
|
|
3821
3833
|
updateBulletinBoardById: (_id: ObjectId | string, value: Partial<TBulletinBoard>, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
3822
3834
|
processExpiredBulletinBoards: (session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
3835
|
+
processUpcomingBulletinBoards: (session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
3823
3836
|
deleteBulletinBoardById: (_id: string | ObjectId, session?: ClientSession) => Promise<number>;
|
|
3824
3837
|
createIndexes: () => Promise<void>;
|
|
3825
3838
|
};
|
|
@@ -3828,6 +3841,7 @@ declare function useBulletinBoardService(): {
|
|
|
3828
3841
|
add: (value: TBulletinBoard) => Promise<string>;
|
|
3829
3842
|
updateBulletinBoardById: (id: string | ObjectId, value: Partial<TBulletinBoard>) => Promise<string>;
|
|
3830
3843
|
processExpiredBulletinBoards: () => Promise<void>;
|
|
3844
|
+
processUpcomingBulletinBoards: () => Promise<void>;
|
|
3831
3845
|
deleteBulletinBoardById: (id: string | ObjectId) => Promise<string>;
|
|
3832
3846
|
};
|
|
3833
3847
|
|
package/dist/index.js
CHANGED
|
@@ -15243,6 +15243,74 @@ function useVehicleRepo() {
|
|
|
15243
15243
|
throw new Error("Failed to bulk upsert vehicles.");
|
|
15244
15244
|
}
|
|
15245
15245
|
}
|
|
15246
|
+
async function getBlocklistedVehicles({
|
|
15247
|
+
page = 1,
|
|
15248
|
+
limit = 10,
|
|
15249
|
+
search = "",
|
|
15250
|
+
site = ""
|
|
15251
|
+
}) {
|
|
15252
|
+
page = page > 0 ? page - 1 : 0;
|
|
15253
|
+
const baseQuery = {
|
|
15254
|
+
type: "blocklist" /* BLOCKLIST */,
|
|
15255
|
+
...site && {
|
|
15256
|
+
site: typeof site === "string" ? new import_mongodb42.ObjectId(site) : site
|
|
15257
|
+
}
|
|
15258
|
+
};
|
|
15259
|
+
let query = {
|
|
15260
|
+
...baseQuery,
|
|
15261
|
+
...search && { $text: { $search: search } }
|
|
15262
|
+
};
|
|
15263
|
+
const escapeRegex = (input) => input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15264
|
+
const buildPipeline = (matchQuery) => [
|
|
15265
|
+
{ $match: matchQuery },
|
|
15266
|
+
{
|
|
15267
|
+
$addFields: {
|
|
15268
|
+
latestDate: { $max: ["$createdAt", "$updatedAt"] }
|
|
15269
|
+
}
|
|
15270
|
+
},
|
|
15271
|
+
{ $sort: { latestDate: -1 } },
|
|
15272
|
+
{ $skip: page * limit },
|
|
15273
|
+
{ $limit: limit },
|
|
15274
|
+
{
|
|
15275
|
+
$project: {
|
|
15276
|
+
latestDate: 0
|
|
15277
|
+
}
|
|
15278
|
+
}
|
|
15279
|
+
];
|
|
15280
|
+
const buildCountPipeline = (matchQuery) => [
|
|
15281
|
+
{ $match: matchQuery },
|
|
15282
|
+
{ $count: "total" }
|
|
15283
|
+
];
|
|
15284
|
+
try {
|
|
15285
|
+
let items = [];
|
|
15286
|
+
let length = 0;
|
|
15287
|
+
items = await collection.aggregate(buildPipeline(query)).toArray();
|
|
15288
|
+
const countResult = await collection.aggregate(buildCountPipeline(query)).toArray();
|
|
15289
|
+
length = countResult[0]?.total || 0;
|
|
15290
|
+
if ((!items || items.length === 0) && search) {
|
|
15291
|
+
const escaped = escapeRegex(search);
|
|
15292
|
+
const regexQuery = {
|
|
15293
|
+
...baseQuery,
|
|
15294
|
+
$or: [
|
|
15295
|
+
{ name: { $regex: escaped, $options: "i" } },
|
|
15296
|
+
{ plateNumber: { $regex: escaped, $options: "i" } },
|
|
15297
|
+
{ company: { $regex: escaped, $options: "i" } },
|
|
15298
|
+
{ level: { $regex: escaped, $options: "i" } },
|
|
15299
|
+
{ unitName: { $regex: escaped, $options: "i" } },
|
|
15300
|
+
{ contact: { $regex: escaped, $options: "i" } },
|
|
15301
|
+
{ nric: { $regex: escaped, $options: "i" } }
|
|
15302
|
+
]
|
|
15303
|
+
};
|
|
15304
|
+
items = await collection.aggregate(buildPipeline(regexQuery)).toArray();
|
|
15305
|
+
const regexCountResult = await collection.aggregate(buildCountPipeline(regexQuery)).toArray();
|
|
15306
|
+
length = regexCountResult[0]?.total || 0;
|
|
15307
|
+
}
|
|
15308
|
+
const data = (0, import_node_server_utils70.paginate)(items, page, limit, length);
|
|
15309
|
+
return data;
|
|
15310
|
+
} catch (error) {
|
|
15311
|
+
throw error;
|
|
15312
|
+
}
|
|
15313
|
+
}
|
|
15246
15314
|
return {
|
|
15247
15315
|
createIndex,
|
|
15248
15316
|
createTextIndex,
|
|
@@ -15259,7 +15327,8 @@ function useVehicleRepo() {
|
|
|
15259
15327
|
getAllVehiclesByUnitId,
|
|
15260
15328
|
getAllExpiredVehicles,
|
|
15261
15329
|
bulkUpsertVehicles,
|
|
15262
|
-
getSpecificVehicleById
|
|
15330
|
+
getSpecificVehicleById,
|
|
15331
|
+
getBlocklistedVehicles
|
|
15263
15332
|
};
|
|
15264
15333
|
}
|
|
15265
15334
|
|
|
@@ -20695,7 +20764,8 @@ function useVehicleController() {
|
|
|
20695
20764
|
getVehicleById: _getVehicleById,
|
|
20696
20765
|
getVehiclesByNRIC: _getVehiclesByNRIC,
|
|
20697
20766
|
getAllVehiclesByUnitId: _getAllVehiclesByUnitId,
|
|
20698
|
-
getSpecificVehicleById: _getSpecificVehicleById
|
|
20767
|
+
getSpecificVehicleById: _getSpecificVehicleById,
|
|
20768
|
+
getBlocklistedVehicles: _getBlocklistedVehicles
|
|
20699
20769
|
} = useVehicleRepo();
|
|
20700
20770
|
function normalizeRow(row) {
|
|
20701
20771
|
return Object.fromEntries(
|
|
@@ -21231,6 +21301,38 @@ function useVehicleController() {
|
|
|
21231
21301
|
return;
|
|
21232
21302
|
}
|
|
21233
21303
|
}
|
|
21304
|
+
async function getBlocklistedVehicles(req, res, next) {
|
|
21305
|
+
const schema2 = import_joi46.default.object({
|
|
21306
|
+
search: import_joi46.default.string().optional().allow("", null),
|
|
21307
|
+
page: import_joi46.default.number().integer().min(1).optional().default(1),
|
|
21308
|
+
limit: import_joi46.default.number().integer().min(1).max(100).optional().default(10),
|
|
21309
|
+
site: import_joi46.default.string().hex().length(24).optional().allow(null, "")
|
|
21310
|
+
});
|
|
21311
|
+
const { error, value } = schema2.validate(req.query, {
|
|
21312
|
+
abortEarly: false
|
|
21313
|
+
});
|
|
21314
|
+
if (error) {
|
|
21315
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
21316
|
+
import_node_server_utils87.logger.log({ level: "error", message: messages });
|
|
21317
|
+
next(new import_node_server_utils87.BadRequestError(messages));
|
|
21318
|
+
return;
|
|
21319
|
+
}
|
|
21320
|
+
const { search, page, limit, site } = value;
|
|
21321
|
+
try {
|
|
21322
|
+
const data = await _getBlocklistedVehicles({
|
|
21323
|
+
search,
|
|
21324
|
+
page,
|
|
21325
|
+
limit,
|
|
21326
|
+
site
|
|
21327
|
+
});
|
|
21328
|
+
res.json(data);
|
|
21329
|
+
return;
|
|
21330
|
+
} catch (error2) {
|
|
21331
|
+
import_node_server_utils87.logger.log({ level: "error", message: error2.message });
|
|
21332
|
+
next(error2);
|
|
21333
|
+
return;
|
|
21334
|
+
}
|
|
21335
|
+
}
|
|
21234
21336
|
return {
|
|
21235
21337
|
add,
|
|
21236
21338
|
getVehicles,
|
|
@@ -21243,7 +21345,8 @@ function useVehicleController() {
|
|
|
21243
21345
|
reactivateVehicleById,
|
|
21244
21346
|
getAllVehiclesByUnitId,
|
|
21245
21347
|
uploadSpreadsheetVehicles,
|
|
21246
|
-
getSpecificVehicleById
|
|
21348
|
+
getSpecificVehicleById,
|
|
21349
|
+
getBlocklistedVehicles
|
|
21247
21350
|
};
|
|
21248
21351
|
}
|
|
21249
21352
|
|
|
@@ -30649,6 +30752,7 @@ var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
|
|
|
30649
30752
|
})(BulletinRecipient || {});
|
|
30650
30753
|
var BulletinStatus = /* @__PURE__ */ ((BulletinStatus2) => {
|
|
30651
30754
|
BulletinStatus2["ACTIVE"] = "active";
|
|
30755
|
+
BulletinStatus2["UPCOMING"] = "upcoming";
|
|
30652
30756
|
BulletinStatus2["EXPIRED"] = "expired";
|
|
30653
30757
|
BulletinStatus2["DELETED"] = "deleted";
|
|
30654
30758
|
return BulletinStatus2;
|
|
@@ -30993,12 +31097,48 @@ function useBulletinBoardRepo() {
|
|
|
30993
31097
|
throw error;
|
|
30994
31098
|
}
|
|
30995
31099
|
}
|
|
31100
|
+
async function processUpcomingBulletinBoards(session) {
|
|
31101
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
31102
|
+
const query = {
|
|
31103
|
+
status: "upcoming" /* UPCOMING */,
|
|
31104
|
+
startDate: { $lte: now }
|
|
31105
|
+
};
|
|
31106
|
+
try {
|
|
31107
|
+
const res = await collection.updateMany(
|
|
31108
|
+
query,
|
|
31109
|
+
{
|
|
31110
|
+
$set: {
|
|
31111
|
+
status: "active" /* ACTIVE */,
|
|
31112
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
31113
|
+
}
|
|
31114
|
+
},
|
|
31115
|
+
{ session }
|
|
31116
|
+
);
|
|
31117
|
+
if (res.matchedCount === 0) {
|
|
31118
|
+
throw new import_node_server_utils135.NotFoundError("No upcoming bulletin boards found to activate.");
|
|
31119
|
+
}
|
|
31120
|
+
delNamespace().then(() => {
|
|
31121
|
+
import_node_server_utils135.logger.info(
|
|
31122
|
+
`Cache cleared for namespace: ${bulletin_boards_namespace_collection}`
|
|
31123
|
+
);
|
|
31124
|
+
}).catch((err) => {
|
|
31125
|
+
import_node_server_utils135.logger.error(
|
|
31126
|
+
`Failed to clear cache for namespace: ${bulletin_boards_namespace_collection}`,
|
|
31127
|
+
err
|
|
31128
|
+
);
|
|
31129
|
+
});
|
|
31130
|
+
return res;
|
|
31131
|
+
} catch (error) {
|
|
31132
|
+
throw error;
|
|
31133
|
+
}
|
|
31134
|
+
}
|
|
30996
31135
|
return {
|
|
30997
31136
|
add,
|
|
30998
31137
|
getAll,
|
|
30999
31138
|
getBulletinBoardById,
|
|
31000
31139
|
updateBulletinBoardById,
|
|
31001
31140
|
processExpiredBulletinBoards,
|
|
31141
|
+
processUpcomingBulletinBoards,
|
|
31002
31142
|
deleteBulletinBoardById,
|
|
31003
31143
|
createIndexes
|
|
31004
31144
|
};
|
|
@@ -31011,6 +31151,7 @@ function useBulletinBoardService() {
|
|
|
31011
31151
|
add: _add,
|
|
31012
31152
|
updateBulletinBoardById: _updateBulletinBoardById,
|
|
31013
31153
|
processExpiredBulletinBoards: _processExpiredBulletinBoards,
|
|
31154
|
+
processUpcomingBulletinBoards: _processUpcomingBulletinBoards,
|
|
31014
31155
|
deleteBulletinBoardById: _deleteBulletinBoardById,
|
|
31015
31156
|
getBulletinBoardById: _getBulletinBoardById
|
|
31016
31157
|
} = useBulletinBoardRepo();
|
|
@@ -31018,6 +31159,9 @@ function useBulletinBoardService() {
|
|
|
31018
31159
|
async function add(value) {
|
|
31019
31160
|
const session = import_node_server_utils136.useAtlas.getClient()?.startSession();
|
|
31020
31161
|
session?.startTransaction();
|
|
31162
|
+
if (value.startDate && new Date(value.startDate) > /* @__PURE__ */ new Date()) {
|
|
31163
|
+
value.status = "upcoming" /* UPCOMING */;
|
|
31164
|
+
}
|
|
31021
31165
|
try {
|
|
31022
31166
|
await _add(value, session);
|
|
31023
31167
|
await session?.commitTransaction();
|
|
@@ -31043,6 +31187,20 @@ function useBulletinBoardService() {
|
|
|
31043
31187
|
session?.endSession();
|
|
31044
31188
|
}
|
|
31045
31189
|
}
|
|
31190
|
+
async function processUpcomingBulletinBoards() {
|
|
31191
|
+
const session = import_node_server_utils136.useAtlas.getClient()?.startSession();
|
|
31192
|
+
session?.startTransaction();
|
|
31193
|
+
try {
|
|
31194
|
+
await _processUpcomingBulletinBoards(session);
|
|
31195
|
+
await session?.commitTransaction();
|
|
31196
|
+
return;
|
|
31197
|
+
} catch (error) {
|
|
31198
|
+
await session?.abortTransaction();
|
|
31199
|
+
throw error;
|
|
31200
|
+
} finally {
|
|
31201
|
+
session?.endSession();
|
|
31202
|
+
}
|
|
31203
|
+
}
|
|
31046
31204
|
async function processExpiredBulletinBoards() {
|
|
31047
31205
|
const session = import_node_server_utils136.useAtlas.getClient()?.startSession();
|
|
31048
31206
|
session?.startTransaction();
|
|
@@ -31084,6 +31242,7 @@ function useBulletinBoardService() {
|
|
|
31084
31242
|
add,
|
|
31085
31243
|
updateBulletinBoardById,
|
|
31086
31244
|
processExpiredBulletinBoards,
|
|
31245
|
+
processUpcomingBulletinBoards,
|
|
31087
31246
|
deleteBulletinBoardById
|
|
31088
31247
|
};
|
|
31089
31248
|
}
|
|
@@ -32676,14 +32835,15 @@ function useEventManagementRepo() {
|
|
|
32676
32835
|
} catch (error) {
|
|
32677
32836
|
throw new import_node_server_utils146.BadRequestError("Invalid site ID format.");
|
|
32678
32837
|
}
|
|
32838
|
+
const datePart = date ? new Date(date).toISOString().split("T")[0] : "";
|
|
32679
32839
|
const baseQuery = {
|
|
32680
32840
|
site,
|
|
32681
32841
|
status: status ? status : { $ne: "deleted" },
|
|
32682
32842
|
...type && { type },
|
|
32683
|
-
...
|
|
32843
|
+
...datePart && {
|
|
32684
32844
|
dateTime: {
|
|
32685
|
-
$gte: `${
|
|
32686
|
-
$
|
|
32845
|
+
$gte: /* @__PURE__ */ new Date(`${datePart}T00:00:00.000Z`),
|
|
32846
|
+
$lte: /* @__PURE__ */ new Date(`${datePart}T23:59:59.999Z`)
|
|
32687
32847
|
}
|
|
32688
32848
|
}
|
|
32689
32849
|
};
|
|
@@ -32696,7 +32856,7 @@ function useEventManagementRepo() {
|
|
|
32696
32856
|
page,
|
|
32697
32857
|
limit,
|
|
32698
32858
|
...type && { type },
|
|
32699
|
-
...
|
|
32859
|
+
...datePart && { dateTime: datePart }
|
|
32700
32860
|
};
|
|
32701
32861
|
if (search) {
|
|
32702
32862
|
query.$or = [{ title: { $regex: search, $options: "i" } }];
|