@7365admin1/core 3.9.0 → 3.10.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 +9 -4
- package/dist/index.js +119 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -33541,7 +33541,7 @@ async function send(userIds, title, body, data, isForMAMobileApp = false, appSlu
|
|
|
33541
33541
|
if (isForMAMobileApp) {
|
|
33542
33542
|
tokens = await PushTokenRepo.findTokensByUserIds(userIds, appSlug);
|
|
33543
33543
|
} else {
|
|
33544
|
-
tokens = await PushTokenRepo.findTokensByUserIds(userIds);
|
|
33544
|
+
tokens = await PushTokenRepo.findTokensByUserIds(userIds, appSlug);
|
|
33545
33545
|
}
|
|
33546
33546
|
if (!tokens.length)
|
|
33547
33547
|
return;
|
|
@@ -33589,6 +33589,37 @@ var NotificationService = class {
|
|
|
33589
33589
|
"iservice365-resident-mobile-app"
|
|
33590
33590
|
);
|
|
33591
33591
|
}
|
|
33592
|
+
static async onlineFormRequestStatusUpdated(payload) {
|
|
33593
|
+
let screen = "";
|
|
33594
|
+
let params = {};
|
|
33595
|
+
if (payload.status === "pending" || payload.status === "resubmission") {
|
|
33596
|
+
screen = "/(user)/(online-forms)/form-fill";
|
|
33597
|
+
params = {
|
|
33598
|
+
id: payload.onlineFormId.toString(),
|
|
33599
|
+
submissionStatus: payload.status ?? ""
|
|
33600
|
+
};
|
|
33601
|
+
} else {
|
|
33602
|
+
screen = "/(user)/(online-forms)/submission-detail";
|
|
33603
|
+
params = {
|
|
33604
|
+
id: payload.onlineFormId.toString(),
|
|
33605
|
+
status: payload.status ?? ""
|
|
33606
|
+
};
|
|
33607
|
+
}
|
|
33608
|
+
await send(
|
|
33609
|
+
toStringArray(payload.to),
|
|
33610
|
+
"Online Form",
|
|
33611
|
+
`Your online form has been updated to ${payload.status}.`,
|
|
33612
|
+
{
|
|
33613
|
+
onlineFormId: payload.onlineFormId.toString(),
|
|
33614
|
+
status: payload.status,
|
|
33615
|
+
module: "onlineForm",
|
|
33616
|
+
screen,
|
|
33617
|
+
params: JSON.stringify(params)
|
|
33618
|
+
},
|
|
33619
|
+
false,
|
|
33620
|
+
"iservice365-resident-mobile-app"
|
|
33621
|
+
);
|
|
33622
|
+
}
|
|
33592
33623
|
static async bulletinBoardCreatedForMA(payload) {
|
|
33593
33624
|
await send(
|
|
33594
33625
|
toStringArray(payload.to),
|
|
@@ -57911,7 +57942,8 @@ function useNewDashboardRepo() {
|
|
|
57911
57942
|
site,
|
|
57912
57943
|
serviceType,
|
|
57913
57944
|
page = 1,
|
|
57914
|
-
limit = 10
|
|
57945
|
+
limit = 10,
|
|
57946
|
+
period = "today" /* TODAY */
|
|
57915
57947
|
}) {
|
|
57916
57948
|
page = page > 0 ? page - 1 : 0;
|
|
57917
57949
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -57921,9 +57953,7 @@ function useNewDashboardRepo() {
|
|
|
57921
57953
|
} catch {
|
|
57922
57954
|
throw new BadRequestError182("Invalid site ID format.");
|
|
57923
57955
|
}
|
|
57924
|
-
const
|
|
57925
|
-
const todayEnd = moment2.tz("Asia/Singapore").endOf("day").toDate();
|
|
57926
|
-
const todayRange = { $gte: todayStart, $lte: todayEnd };
|
|
57956
|
+
const todayRange = getDateRange(period);
|
|
57927
57957
|
try {
|
|
57928
57958
|
const [items, countResult] = await Promise.all([
|
|
57929
57959
|
areaChecklistCollection.aggregate([
|
|
@@ -57999,7 +58029,8 @@ function useNewDashboardRepo() {
|
|
|
57999
58029
|
site,
|
|
58000
58030
|
serviceType,
|
|
58001
58031
|
page = 1,
|
|
58002
|
-
limit = 10
|
|
58032
|
+
limit = 10,
|
|
58033
|
+
period = "today" /* TODAY */
|
|
58003
58034
|
}) {
|
|
58004
58035
|
page = page > 0 ? page - 1 : 0;
|
|
58005
58036
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -58009,8 +58040,9 @@ function useNewDashboardRepo() {
|
|
|
58009
58040
|
} catch {
|
|
58010
58041
|
throw new BadRequestError182("Invalid site ID format.");
|
|
58011
58042
|
}
|
|
58012
|
-
const
|
|
58013
|
-
const
|
|
58043
|
+
const periodRange = getDateRange(period);
|
|
58044
|
+
const todayStart = periodRange.$gte;
|
|
58045
|
+
const todayEnd = periodRange.$lte;
|
|
58014
58046
|
const todayStartStr = todayStart.toISOString();
|
|
58015
58047
|
const todayEndStr = todayEnd.toISOString();
|
|
58016
58048
|
try {
|
|
@@ -58127,7 +58159,8 @@ function useNewDashboardRepo() {
|
|
|
58127
58159
|
site,
|
|
58128
58160
|
serviceType,
|
|
58129
58161
|
page = 1,
|
|
58130
|
-
limit = 10
|
|
58162
|
+
limit = 10,
|
|
58163
|
+
period = "today" /* TODAY */
|
|
58131
58164
|
}) {
|
|
58132
58165
|
page = page > 0 ? page - 1 : 0;
|
|
58133
58166
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -58138,10 +58171,14 @@ function useNewDashboardRepo() {
|
|
|
58138
58171
|
throw new BadRequestError182("Invalid site ID format.");
|
|
58139
58172
|
}
|
|
58140
58173
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
58174
|
+
const matchQuery = { site, service: workOrderService };
|
|
58175
|
+
if (period) {
|
|
58176
|
+
matchQuery.createdAt = getDateRange(period);
|
|
58177
|
+
}
|
|
58141
58178
|
try {
|
|
58142
58179
|
const [items, length] = await Promise.all([
|
|
58143
58180
|
feedbackCollection.aggregate([
|
|
58144
|
-
{ $match:
|
|
58181
|
+
{ $match: matchQuery },
|
|
58145
58182
|
{ $sort: { createdAt: -1, _id: -1 } },
|
|
58146
58183
|
{
|
|
58147
58184
|
$lookup: {
|
|
@@ -58164,7 +58201,7 @@ function useNewDashboardRepo() {
|
|
|
58164
58201
|
{ $skip: page * limit },
|
|
58165
58202
|
{ $limit: limit }
|
|
58166
58203
|
]).toArray(),
|
|
58167
|
-
feedbackCollection.countDocuments(
|
|
58204
|
+
feedbackCollection.countDocuments(matchQuery)
|
|
58168
58205
|
]);
|
|
58169
58206
|
const data = paginate51(items, page, limit, length);
|
|
58170
58207
|
return data;
|
|
@@ -58324,6 +58361,7 @@ function useNewDashboardController() {
|
|
|
58324
58361
|
const validation = Joi112.object({
|
|
58325
58362
|
site: Joi112.string().hex().required(),
|
|
58326
58363
|
serviceType: Joi112.string().valid(...Object.values(AppServiceType)).required(),
|
|
58364
|
+
period: Joi112.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58327
58365
|
page: Joi112.number().min(1).optional().allow("", null),
|
|
58328
58366
|
limit: Joi112.number().min(1).optional().allow("", null)
|
|
58329
58367
|
});
|
|
@@ -58335,12 +58373,14 @@ function useNewDashboardController() {
|
|
|
58335
58373
|
}
|
|
58336
58374
|
const site = req.params.site;
|
|
58337
58375
|
const serviceType = req.params.serviceType;
|
|
58376
|
+
const period = req.query.period;
|
|
58338
58377
|
const page = parseInt(req.query.page) ?? 1;
|
|
58339
58378
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58340
58379
|
try {
|
|
58341
58380
|
const data = await _getServiceTodayTaskSchedule({
|
|
58342
58381
|
site,
|
|
58343
58382
|
serviceType,
|
|
58383
|
+
period,
|
|
58344
58384
|
page,
|
|
58345
58385
|
limit
|
|
58346
58386
|
});
|
|
@@ -58357,6 +58397,7 @@ function useNewDashboardController() {
|
|
|
58357
58397
|
const validation = Joi112.object({
|
|
58358
58398
|
site: Joi112.string().hex().required(),
|
|
58359
58399
|
serviceType: Joi112.string().valid(...Object.values(AppServiceType)).required(),
|
|
58400
|
+
period: Joi112.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58360
58401
|
page: Joi112.number().min(1).optional().allow("", null),
|
|
58361
58402
|
limit: Joi112.number().min(1).optional().allow("", null)
|
|
58362
58403
|
});
|
|
@@ -58368,12 +58409,14 @@ function useNewDashboardController() {
|
|
|
58368
58409
|
}
|
|
58369
58410
|
const site = req.params.site;
|
|
58370
58411
|
const serviceType = req.params.serviceType;
|
|
58412
|
+
const period = req.query.period;
|
|
58371
58413
|
const page = parseInt(req.query.page) ?? 1;
|
|
58372
58414
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58373
58415
|
try {
|
|
58374
58416
|
const data = await _getServiceStaffAttendance({
|
|
58375
58417
|
site,
|
|
58376
58418
|
serviceType,
|
|
58419
|
+
period,
|
|
58377
58420
|
page,
|
|
58378
58421
|
limit
|
|
58379
58422
|
});
|
|
@@ -58390,6 +58433,7 @@ function useNewDashboardController() {
|
|
|
58390
58433
|
const validation = Joi112.object({
|
|
58391
58434
|
site: Joi112.string().hex().required(),
|
|
58392
58435
|
serviceType: Joi112.string().valid(...Object.values(AppServiceType)).required(),
|
|
58436
|
+
period: Joi112.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58393
58437
|
page: Joi112.number().min(1).optional().allow("", null),
|
|
58394
58438
|
limit: Joi112.number().min(1).optional().allow("", null)
|
|
58395
58439
|
});
|
|
@@ -58401,12 +58445,14 @@ function useNewDashboardController() {
|
|
|
58401
58445
|
}
|
|
58402
58446
|
const site = req.params.site;
|
|
58403
58447
|
const serviceType = req.params.serviceType;
|
|
58448
|
+
const period = req.query.period;
|
|
58404
58449
|
const page = parseInt(req.query.page) ?? 1;
|
|
58405
58450
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58406
58451
|
try {
|
|
58407
58452
|
const data = await _getServiceRecentFeedbacks({
|
|
58408
58453
|
site,
|
|
58409
58454
|
serviceType,
|
|
58455
|
+
period,
|
|
58410
58456
|
page,
|
|
58411
58457
|
limit
|
|
58412
58458
|
});
|
|
@@ -67071,14 +67117,26 @@ function useBidPrelovedRepo() {
|
|
|
67071
67117
|
throw new InternalServerError82("Unable to update bid.");
|
|
67072
67118
|
return "Bid updated successfully.";
|
|
67073
67119
|
}
|
|
67074
|
-
|
|
67120
|
+
async function getById(_id) {
|
|
67121
|
+
if (typeof _id === "string")
|
|
67122
|
+
_id = new ObjectId150(_id);
|
|
67123
|
+
const result = await collection.findOne({ _id });
|
|
67124
|
+
if (!result)
|
|
67125
|
+
throw new NotFoundError61("Bid not found.");
|
|
67126
|
+
return result;
|
|
67127
|
+
}
|
|
67128
|
+
return { add, getById, updateStatus };
|
|
67075
67129
|
}
|
|
67076
67130
|
|
|
67077
67131
|
// src/controllers/bid-preloved.controller.ts
|
|
67078
67132
|
import { BadRequestError as BadRequestError224, logger as logger194 } from "@7365admin1/node-server-utils";
|
|
67079
67133
|
import Joi146 from "joi";
|
|
67080
67134
|
function useBidPrelovedController() {
|
|
67081
|
-
const {
|
|
67135
|
+
const {
|
|
67136
|
+
add: _add,
|
|
67137
|
+
getById: _getById,
|
|
67138
|
+
updateStatus: _updateStatus
|
|
67139
|
+
} = useBidPrelovedRepo();
|
|
67082
67140
|
async function add(req, res, next) {
|
|
67083
67141
|
const { error, value } = schemaBidPreloved.validate(req.body, {
|
|
67084
67142
|
abortEarly: false
|
|
@@ -67125,7 +67183,25 @@ function useBidPrelovedController() {
|
|
|
67125
67183
|
next(error);
|
|
67126
67184
|
}
|
|
67127
67185
|
}
|
|
67128
|
-
|
|
67186
|
+
async function getById(req, res, next) {
|
|
67187
|
+
const paramsSchema = Joi146.object({
|
|
67188
|
+
id: Joi146.string().hex().length(24).required()
|
|
67189
|
+
});
|
|
67190
|
+
const { error, value: params } = paramsSchema.validate(req.params);
|
|
67191
|
+
if (error) {
|
|
67192
|
+
logger194.log({ level: "error", message: error.message });
|
|
67193
|
+
next(new BadRequestError224(error.message));
|
|
67194
|
+
return;
|
|
67195
|
+
}
|
|
67196
|
+
try {
|
|
67197
|
+
const data = await _getById(params.id);
|
|
67198
|
+
res.status(200).json(data);
|
|
67199
|
+
} catch (error2) {
|
|
67200
|
+
logger194.log({ level: "error", message: error2.message });
|
|
67201
|
+
next(error2);
|
|
67202
|
+
}
|
|
67203
|
+
}
|
|
67204
|
+
return { add, getById, updateStatus };
|
|
67129
67205
|
}
|
|
67130
67206
|
|
|
67131
67207
|
// src/models/online-forms-v2.model.ts
|
|
@@ -67278,6 +67354,7 @@ function useFormEntryRepo() {
|
|
|
67278
67354
|
const { delNamespace, getCache, setCache } = useCache69(
|
|
67279
67355
|
online_forms_namespace_collection
|
|
67280
67356
|
);
|
|
67357
|
+
const { getUserById } = useUserRepo();
|
|
67281
67358
|
async function createTextIndex() {
|
|
67282
67359
|
try {
|
|
67283
67360
|
await collection.createIndex({
|
|
@@ -67431,6 +67508,26 @@ function useFormEntryRepo() {
|
|
|
67431
67508
|
if (res.modifiedCount === 0) {
|
|
67432
67509
|
throw new InternalServerError83("Unable to update online form.");
|
|
67433
67510
|
}
|
|
67511
|
+
const onlineFormRequest = await collection.findOne({ _id });
|
|
67512
|
+
if (!onlineFormRequest) {
|
|
67513
|
+
throw new NotFoundError62("Online form not found.");
|
|
67514
|
+
}
|
|
67515
|
+
const user = await getUserById(onlineFormRequest.userId.toString());
|
|
67516
|
+
if (!user || !user._id) {
|
|
67517
|
+
throw new NotFoundError62("User not found.");
|
|
67518
|
+
}
|
|
67519
|
+
const userId = user._id.toString();
|
|
67520
|
+
await NotificationService.onlineFormRequestStatusUpdated({
|
|
67521
|
+
to: userId,
|
|
67522
|
+
onlineFormId: onlineFormRequest._id,
|
|
67523
|
+
// typeOfForm: onlineFormRequest.typeOfForm,
|
|
67524
|
+
// unitNumber: onlineFormRequest.unitNumber,
|
|
67525
|
+
status: onlineFormRequest.status
|
|
67526
|
+
// createdAt: onlineFormRequest.createdAt ?? "",
|
|
67527
|
+
// fields: onlineFormRequest.fields ?? {},
|
|
67528
|
+
// remarks: onlineFormRequest.remarks ?? "",
|
|
67529
|
+
// managementValuesJson: onlineFormRequest.managementValues ?? {},
|
|
67530
|
+
});
|
|
67434
67531
|
delNamespace().then(() => {
|
|
67435
67532
|
logger195.info(
|
|
67436
67533
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
@@ -67467,7 +67564,9 @@ function useFormEntryRepo() {
|
|
|
67467
67564
|
throw new InternalServerError83("Unable to delete online form.");
|
|
67468
67565
|
}
|
|
67469
67566
|
delNamespace().then(() => {
|
|
67470
|
-
logger195.info(
|
|
67567
|
+
logger195.info(
|
|
67568
|
+
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
67569
|
+
);
|
|
67471
67570
|
}).catch((err) => {
|
|
67472
67571
|
logger195.error(
|
|
67473
67572
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
@@ -67504,7 +67603,11 @@ function useFormEntryRepo() {
|
|
|
67504
67603
|
throw error;
|
|
67505
67604
|
}
|
|
67506
67605
|
}
|
|
67507
|
-
async function residentForm({
|
|
67606
|
+
async function residentForm({
|
|
67607
|
+
userId,
|
|
67608
|
+
site,
|
|
67609
|
+
org
|
|
67610
|
+
}) {
|
|
67508
67611
|
try {
|
|
67509
67612
|
const user = new ObjectId152(userId);
|
|
67510
67613
|
const siteId = new ObjectId152(site);
|