@7365admin1/core 2.42.0 → 2.43.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 +6 -0
- package/dist/index.d.ts +18 -3
- package/dist/index.js +135 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1640,10 +1640,22 @@ declare function useSiteRepo(): {
|
|
|
1640
1640
|
updateSiteIncidentCounter: (_id: string | ObjectId, incidentCounter: number, session?: ClientSession) => Promise<number>;
|
|
1641
1641
|
updateSiteById: (id: string | ObjectId, payload: TSite, session?: ClientSession) => Promise<number>;
|
|
1642
1642
|
getAllSitesUnpaginated: () => Promise<bson.Document[]>;
|
|
1643
|
-
siteInformation: ({ id, payload }: {
|
|
1643
|
+
siteInformation: ({ id, payload, }: {
|
|
1644
1644
|
id: string;
|
|
1645
1645
|
payload: TSiteInformation;
|
|
1646
1646
|
}) => Promise<number>;
|
|
1647
|
+
getAllSitesForResidentCreation: ({ search, page, limit, }: {
|
|
1648
|
+
search: string;
|
|
1649
|
+
page: number;
|
|
1650
|
+
limit: number;
|
|
1651
|
+
}) => Promise<{
|
|
1652
|
+
items: {
|
|
1653
|
+
_id: ObjectId;
|
|
1654
|
+
name: string;
|
|
1655
|
+
}[];
|
|
1656
|
+
pages: number;
|
|
1657
|
+
pageRange: string;
|
|
1658
|
+
}>;
|
|
1647
1659
|
};
|
|
1648
1660
|
|
|
1649
1661
|
declare function useSiteService(): {
|
|
@@ -1681,6 +1693,7 @@ declare function useSiteController(): {
|
|
|
1681
1693
|
updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1682
1694
|
updateGuardPostsById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1683
1695
|
siteInformation: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1696
|
+
getAllSitesForResidentCreation: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1684
1697
|
};
|
|
1685
1698
|
|
|
1686
1699
|
type TChat = {
|
|
@@ -2481,6 +2494,7 @@ type TPerson = {
|
|
|
2481
2494
|
isOwner?: boolean;
|
|
2482
2495
|
files?: TFiles[];
|
|
2483
2496
|
plateNumber?: string;
|
|
2497
|
+
platform?: string;
|
|
2484
2498
|
createdAt?: string | Date;
|
|
2485
2499
|
updatedAt?: string | Date;
|
|
2486
2500
|
deletedAt?: string | Date;
|
|
@@ -2515,6 +2529,7 @@ declare function MPerson(value: TPerson): {
|
|
|
2515
2529
|
isOwner: boolean;
|
|
2516
2530
|
files: TFiles[];
|
|
2517
2531
|
plateNumber: string;
|
|
2532
|
+
platForm: string;
|
|
2518
2533
|
createdAt: string | Date;
|
|
2519
2534
|
updatedAt: string | Date | undefined;
|
|
2520
2535
|
deletedAt: string | Date | undefined;
|
|
@@ -2554,7 +2569,7 @@ type TVisitorTransaction = {
|
|
|
2554
2569
|
unit?: string | ObjectId;
|
|
2555
2570
|
checkIn?: string | Date | null;
|
|
2556
2571
|
expectedCheckIn?: string | Date;
|
|
2557
|
-
checkOut?: string | Date;
|
|
2572
|
+
checkOut?: string | Date | null;
|
|
2558
2573
|
status?: VisitorStatus;
|
|
2559
2574
|
nric?: string;
|
|
2560
2575
|
remarks?: string;
|
|
@@ -2611,7 +2626,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
2611
2626
|
recNo: string | undefined;
|
|
2612
2627
|
checkIn: string | Date | null;
|
|
2613
2628
|
expectedCheckIn: Date | undefined;
|
|
2614
|
-
checkOut: string | Date | undefined;
|
|
2629
|
+
checkOut: string | Date | null | undefined;
|
|
2615
2630
|
status: VisitorStatus | undefined;
|
|
2616
2631
|
remarks: string | undefined;
|
|
2617
2632
|
deliveryType: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -5156,7 +5156,10 @@ function useSiteRepo() {
|
|
|
5156
5156
|
throw error;
|
|
5157
5157
|
}
|
|
5158
5158
|
}
|
|
5159
|
-
async function siteInformation({
|
|
5159
|
+
async function siteInformation({
|
|
5160
|
+
id,
|
|
5161
|
+
payload
|
|
5162
|
+
}) {
|
|
5160
5163
|
try {
|
|
5161
5164
|
const siteId = new import_mongodb17.ObjectId(id);
|
|
5162
5165
|
const res = await collection.updateOne(
|
|
@@ -5176,6 +5179,48 @@ function useSiteRepo() {
|
|
|
5176
5179
|
throw error;
|
|
5177
5180
|
}
|
|
5178
5181
|
}
|
|
5182
|
+
async function getAllSitesForResidentCreation({
|
|
5183
|
+
search = "",
|
|
5184
|
+
page = 1,
|
|
5185
|
+
limit = 10
|
|
5186
|
+
}) {
|
|
5187
|
+
page = page > 0 ? page - 1 : 0;
|
|
5188
|
+
const query = {
|
|
5189
|
+
status: { $ne: "deleted" }
|
|
5190
|
+
};
|
|
5191
|
+
const cacheOptions = {
|
|
5192
|
+
status: { $ne: "deleted" },
|
|
5193
|
+
page,
|
|
5194
|
+
limit
|
|
5195
|
+
};
|
|
5196
|
+
if (search) {
|
|
5197
|
+
query.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
5198
|
+
cacheOptions.search = search;
|
|
5199
|
+
}
|
|
5200
|
+
const cacheKey = (0, import_node_server_utils19.makeCacheKey)(namespace_collection, cacheOptions);
|
|
5201
|
+
const cachedData = await getCache(cacheKey);
|
|
5202
|
+
if (cachedData) {
|
|
5203
|
+
import_node_server_utils19.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
5204
|
+
return cachedData;
|
|
5205
|
+
}
|
|
5206
|
+
try {
|
|
5207
|
+
const items = await collection.aggregate([
|
|
5208
|
+
{ $match: query },
|
|
5209
|
+
{ $skip: page * limit },
|
|
5210
|
+
{ $limit: limit }
|
|
5211
|
+
]).toArray();
|
|
5212
|
+
const length = await collection.countDocuments(query);
|
|
5213
|
+
const data = (0, import_node_server_utils19.paginate)(items, page, limit, length);
|
|
5214
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
5215
|
+
import_node_server_utils19.logger.info(`Cache set for key: ${cacheKey}`);
|
|
5216
|
+
}).catch((err) => {
|
|
5217
|
+
import_node_server_utils19.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
5218
|
+
});
|
|
5219
|
+
return data;
|
|
5220
|
+
} catch (error) {
|
|
5221
|
+
throw error;
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5179
5224
|
return {
|
|
5180
5225
|
createIndexes,
|
|
5181
5226
|
createSite,
|
|
@@ -5190,7 +5235,8 @@ function useSiteRepo() {
|
|
|
5190
5235
|
updateSiteIncidentCounter,
|
|
5191
5236
|
updateSiteById,
|
|
5192
5237
|
getAllSitesUnpaginated,
|
|
5193
|
-
siteInformation
|
|
5238
|
+
siteInformation,
|
|
5239
|
+
getAllSitesForResidentCreation
|
|
5194
5240
|
};
|
|
5195
5241
|
}
|
|
5196
5242
|
|
|
@@ -12296,7 +12342,7 @@ function useServiceProviderController() {
|
|
|
12296
12342
|
const validation = import_joi30.default.object({
|
|
12297
12343
|
search: import_joi30.default.string().optional().allow("", null),
|
|
12298
12344
|
page: import_joi30.default.number().integer().min(1).allow("", null).default(1),
|
|
12299
|
-
limit: import_joi30.default.number().integer().min(1).max(
|
|
12345
|
+
limit: import_joi30.default.number().integer().min(1).max(1e3).allow("", null).default(10),
|
|
12300
12346
|
orgId: import_joi30.default.string().hex().optional().allow("", null),
|
|
12301
12347
|
siteId: import_joi30.default.string().hex().optional().allow("", null),
|
|
12302
12348
|
serviceProviderOrgId: import_joi30.default.string().hex().optional().allow("", null),
|
|
@@ -13496,7 +13542,8 @@ var schemaPerson = import_joi35.default.object({
|
|
|
13496
13542
|
isOwner: import_joi35.default.boolean().required(),
|
|
13497
13543
|
files: import_joi35.default.array().items(schemaFiles).optional().allow(null),
|
|
13498
13544
|
password: import_joi35.default.string().optional().allow(null, ""),
|
|
13499
|
-
plateNumber: import_joi35.default.string().optional().allow(null, "")
|
|
13545
|
+
plateNumber: import_joi35.default.string().optional().allow(null, ""),
|
|
13546
|
+
platform: import_joi35.default.string().valid("web", "mobile").optional().allow(null, "")
|
|
13500
13547
|
});
|
|
13501
13548
|
var schemaUpdatePerson = import_joi35.default.object({
|
|
13502
13549
|
_id: import_joi35.default.string().hex().required(),
|
|
@@ -13517,12 +13564,13 @@ var schemaUpdatePerson = import_joi35.default.object({
|
|
|
13517
13564
|
isOwner: import_joi35.default.boolean().optional().allow(null, ""),
|
|
13518
13565
|
files: import_joi35.default.array().items(schemaFiles).optional().allow(null),
|
|
13519
13566
|
password: import_joi35.default.string().optional().allow(null, ""),
|
|
13520
|
-
plateNumber: import_joi35.default.string().optional().allow(null, "")
|
|
13567
|
+
plateNumber: import_joi35.default.string().optional().allow(null, ""),
|
|
13568
|
+
platform: import_joi35.default.string().valid("web", "mobile").optional().allow(null, "")
|
|
13521
13569
|
});
|
|
13522
13570
|
function MPerson(value) {
|
|
13523
13571
|
const { error } = schemaPerson.validate(value);
|
|
13524
13572
|
if (error) {
|
|
13525
|
-
throw new
|
|
13573
|
+
throw new import_node_server_utils68.BadRequestError(error.details[0].message);
|
|
13526
13574
|
}
|
|
13527
13575
|
if (value._id && typeof value._id === "string") {
|
|
13528
13576
|
try {
|
|
@@ -13588,6 +13636,7 @@ function MPerson(value) {
|
|
|
13588
13636
|
isOwner: value.isOwner ?? false,
|
|
13589
13637
|
files: value.files ?? [],
|
|
13590
13638
|
plateNumber: value.plateNumber ?? "",
|
|
13639
|
+
platForm: value.platform ?? "",
|
|
13591
13640
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
13592
13641
|
updatedAt: value.updatedAt,
|
|
13593
13642
|
deletedAt: value.deletedAt
|
|
@@ -13626,8 +13675,8 @@ var schemaVisitorTransaction = import_joi36.default.object({
|
|
|
13626
13675
|
contact: import_joi36.default.string().optional().allow(null, ""),
|
|
13627
13676
|
plateNumber: import_joi36.default.string().optional().allow(null, ""),
|
|
13628
13677
|
recNo: import_joi36.default.string().optional().allow(null, ""),
|
|
13629
|
-
checkIn: import_joi36.default.date().optional().allow(null
|
|
13630
|
-
checkOut: import_joi36.default.date().optional().allow(null
|
|
13678
|
+
checkIn: import_joi36.default.date().iso().optional().allow(null),
|
|
13679
|
+
checkOut: import_joi36.default.date().iso().optional().allow(null),
|
|
13631
13680
|
deliveryType: import_joi36.default.string().optional().allow(null, ""),
|
|
13632
13681
|
status: import_joi36.default.string().optional().valid(...Object.values(VisitorStatus)).default("registered" /* REGISTERED */),
|
|
13633
13682
|
remarks: import_joi36.default.string().optional().allow(null, ""),
|
|
@@ -13691,8 +13740,8 @@ var schemaUpdateVisTrans = import_joi36.default.object({
|
|
|
13691
13740
|
contact: import_joi36.default.string().optional().allow(null, ""),
|
|
13692
13741
|
plateNumber: import_joi36.default.string().optional().allow(null, ""),
|
|
13693
13742
|
recNo: import_joi36.default.string().optional().allow(null, ""),
|
|
13694
|
-
checkIn: import_joi36.default.date().optional().allow(null
|
|
13695
|
-
checkOut: import_joi36.default.date().optional().allow(null
|
|
13743
|
+
checkIn: import_joi36.default.date().iso().optional().allow(null),
|
|
13744
|
+
checkOut: import_joi36.default.date().iso().optional().allow(null),
|
|
13696
13745
|
deliveryType: import_joi36.default.string().optional().allow(null, ""),
|
|
13697
13746
|
status: import_joi36.default.string().optional().allow(null, ""),
|
|
13698
13747
|
remarks: import_joi36.default.string().optional().allow(null, ""),
|
|
@@ -15269,7 +15318,7 @@ function usePersonRepo() {
|
|
|
15269
15318
|
]
|
|
15270
15319
|
} : void 0;
|
|
15271
15320
|
const query = {
|
|
15272
|
-
status,
|
|
15321
|
+
...status && status !== "all" ? { status } : { status: { $nin: ["deleted", "rejected"] } },
|
|
15273
15322
|
...start && { start },
|
|
15274
15323
|
...end,
|
|
15275
15324
|
...search && {
|
|
@@ -15307,12 +15356,29 @@ function usePersonRepo() {
|
|
|
15307
15356
|
return cachedData;
|
|
15308
15357
|
}
|
|
15309
15358
|
try {
|
|
15310
|
-
const basePipeline = [
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15359
|
+
const basePipeline = [{ $match: query }];
|
|
15360
|
+
if (status && status == "all") {
|
|
15361
|
+
basePipeline.push(
|
|
15362
|
+
{
|
|
15363
|
+
$addFields: {
|
|
15364
|
+
sortPriority: {
|
|
15365
|
+
$cond: [{ $eq: ["$status", "pending"] }, 1, 2]
|
|
15366
|
+
}
|
|
15367
|
+
}
|
|
15368
|
+
},
|
|
15369
|
+
{
|
|
15370
|
+
$sort: {
|
|
15371
|
+
sortPriority: 1,
|
|
15372
|
+
...sort
|
|
15373
|
+
}
|
|
15374
|
+
}
|
|
15375
|
+
);
|
|
15376
|
+
} else {
|
|
15377
|
+
basePipeline.push({
|
|
15378
|
+
$sort: sort
|
|
15379
|
+
});
|
|
15380
|
+
}
|
|
15381
|
+
basePipeline.push({ $skip: page * limit }, { $limit: limit });
|
|
15316
15382
|
const [items, countResult] = await Promise.all([
|
|
15317
15383
|
collection.aggregate(basePipeline, { session }).toArray(),
|
|
15318
15384
|
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
@@ -18082,7 +18148,8 @@ function useSiteController() {
|
|
|
18082
18148
|
getSites: _getSites,
|
|
18083
18149
|
getSiteById: _getSiteById,
|
|
18084
18150
|
updateSiteBlock: _updateSiteBlock,
|
|
18085
|
-
deleteSite: _deleteSite
|
|
18151
|
+
deleteSite: _deleteSite,
|
|
18152
|
+
getAllSitesForResidentCreation: _getAllSitesForResidentCreation
|
|
18086
18153
|
} = useSiteRepo();
|
|
18087
18154
|
const { updateGuardPostById, siteInformation: _siteInformation } = useSiteService();
|
|
18088
18155
|
async function createSite(req, res, next) {
|
|
@@ -18267,14 +18334,13 @@ function useSiteController() {
|
|
|
18267
18334
|
id: import_joi42.default.string().hex().required(),
|
|
18268
18335
|
bgImage: import_joi42.default.string().optional().allow("", null),
|
|
18269
18336
|
description: import_joi42.default.string().optional().allow("", null),
|
|
18270
|
-
docs: import_joi42.default.array().items(
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
);
|
|
18337
|
+
docs: import_joi42.default.array().items(
|
|
18338
|
+
import_joi42.default.object({
|
|
18339
|
+
id: import_joi42.default.string().hex().optional().allow("", null),
|
|
18340
|
+
name: import_joi42.default.string().optional().allow("", null)
|
|
18341
|
+
})
|
|
18342
|
+
).optional().allow("", null)
|
|
18343
|
+
}).validate({ id, ...payload }, { abortEarly: false });
|
|
18278
18344
|
if (error) {
|
|
18279
18345
|
import_node_server_utils78.logger.log({ level: "error", message: error.message });
|
|
18280
18346
|
next(new import_node_server_utils78.BadRequestError(error.message));
|
|
@@ -18290,6 +18356,36 @@ function useSiteController() {
|
|
|
18290
18356
|
return;
|
|
18291
18357
|
}
|
|
18292
18358
|
}
|
|
18359
|
+
async function getAllSitesForResidentCreation(req, res, next) {
|
|
18360
|
+
const validation = import_joi42.default.object({
|
|
18361
|
+
search: import_joi42.default.string().optional().allow("", null),
|
|
18362
|
+
page: import_joi42.default.number().integer().min(1).allow("", null).default(1),
|
|
18363
|
+
limit: import_joi42.default.number().integer().min(1).max(100).allow("", null).default(10)
|
|
18364
|
+
});
|
|
18365
|
+
const query = { ...req.query };
|
|
18366
|
+
const { error } = validation.validate(query);
|
|
18367
|
+
if (error) {
|
|
18368
|
+
import_node_server_utils78.logger.log({ level: "error", message: error.message });
|
|
18369
|
+
next(new import_node_server_utils78.BadRequestError(error.message));
|
|
18370
|
+
return;
|
|
18371
|
+
}
|
|
18372
|
+
const search = req.query.search ?? "";
|
|
18373
|
+
const page = parseInt(req.query.page ?? "1");
|
|
18374
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
18375
|
+
try {
|
|
18376
|
+
const data = await _getAllSitesForResidentCreation({
|
|
18377
|
+
search,
|
|
18378
|
+
page,
|
|
18379
|
+
limit
|
|
18380
|
+
});
|
|
18381
|
+
res.json(data);
|
|
18382
|
+
return;
|
|
18383
|
+
} catch (error2) {
|
|
18384
|
+
import_node_server_utils78.logger.log({ level: "error", message: error2.message });
|
|
18385
|
+
next(error2);
|
|
18386
|
+
return;
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18293
18389
|
return {
|
|
18294
18390
|
createSite,
|
|
18295
18391
|
getSites,
|
|
@@ -18298,7 +18394,8 @@ function useSiteController() {
|
|
|
18298
18394
|
deleteSite,
|
|
18299
18395
|
updateById,
|
|
18300
18396
|
updateGuardPostsById,
|
|
18301
|
-
siteInformation
|
|
18397
|
+
siteInformation,
|
|
18398
|
+
getAllSitesForResidentCreation
|
|
18302
18399
|
};
|
|
18303
18400
|
}
|
|
18304
18401
|
|
|
@@ -22952,6 +23049,14 @@ function useVisitorTransactionService() {
|
|
|
22952
23049
|
}
|
|
22953
23050
|
value.passKeys = keptPassKeys;
|
|
22954
23051
|
}
|
|
23052
|
+
if (value.checkIn) {
|
|
23053
|
+
const parsed = new Date(value.checkIn);
|
|
23054
|
+
value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
|
|
23055
|
+
}
|
|
23056
|
+
if (value.checkOut) {
|
|
23057
|
+
const parsed = new Date(value.checkOut);
|
|
23058
|
+
value.checkOut = isNaN(parsed.getTime()) ? null : parsed;
|
|
23059
|
+
}
|
|
22955
23060
|
await _updateVisitorTansactionById(id, value, session);
|
|
22956
23061
|
await session?.commitTransaction();
|
|
22957
23062
|
return "Successfully updated visitor transaction.";
|
|
@@ -23951,10 +24056,11 @@ function usePersonService() {
|
|
|
23951
24056
|
email: value.email,
|
|
23952
24057
|
password: hashedPassword,
|
|
23953
24058
|
name: value.name,
|
|
24059
|
+
status: value.platform == "mobile" ? "deleted" : "active",
|
|
23954
24060
|
defaultOrg: value.org?.toString() || ""
|
|
23955
24061
|
};
|
|
23956
24062
|
const userId = await addUser(user, session);
|
|
23957
|
-
value.user = userId;
|
|
24063
|
+
value.user = userId.toString();
|
|
23958
24064
|
let org = null;
|
|
23959
24065
|
if (userId) {
|
|
23960
24066
|
if (value?.org) {
|
|
@@ -29535,7 +29641,7 @@ function useBulletinBoardController() {
|
|
|
29535
29641
|
page: import_joi76.default.number().integer().min(1).allow("", null).default(1),
|
|
29536
29642
|
limit: import_joi76.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
29537
29643
|
sort: import_joi76.default.string().valid(...Object.values(BulletinSort)).default("_id" /* ID */),
|
|
29538
|
-
order: import_joi76.default.string().valid(...Object.values(SortOrder)).default("
|
|
29644
|
+
order: import_joi76.default.string().valid(...Object.values(SortOrder)).default("desc" /* DESC */),
|
|
29539
29645
|
site: import_joi76.default.string().hex().length(24).required(),
|
|
29540
29646
|
status: import_joi76.default.string().valid(...Object.values(BuildingStatus)).optional().default("active" /* ACTIVE */),
|
|
29541
29647
|
recipients: import_joi76.default.alternatives().try(
|