@7365admin1/core 3.32.2-staging.9 → 3.33.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 +1 -3
- package/dist/index.js +42 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -184
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/.changeset/invite-payload-logging.md +0 -5
- package/.github/workflows/publish-staging.yml +0 -36
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2622,8 +2622,6 @@ type TGetAttendancesQuery = {
|
|
|
2622
2622
|
page?: number;
|
|
2623
2623
|
limit?: number;
|
|
2624
2624
|
search?: string;
|
|
2625
|
-
startDate?: string | Date;
|
|
2626
|
-
endDate?: string | Date;
|
|
2627
2625
|
} & Pick<TAttendance, "site" | "serviceType">;
|
|
2628
2626
|
type TGetAttendancesByUserQuery = Pick<TGetAttendancesQuery, "page" | "limit" | "search" | "site" | "serviceType"> & Pick<TAttendance, "user">;
|
|
2629
2627
|
declare const attendanceSchema: Joi.ObjectSchema<any>;
|
|
@@ -2684,7 +2682,7 @@ declare function useAttendanceSettingsController(): {
|
|
|
2684
2682
|
declare function useAttendanceRepository(): {
|
|
2685
2683
|
createIndex: () => Promise<void>;
|
|
2686
2684
|
checkInAttendance: (value: TAttendanceCheckIn, session?: ClientSession) => Promise<ObjectId>;
|
|
2687
|
-
getAllAttendances: ({ page, limit, search, site,
|
|
2685
|
+
getAllAttendances: ({ page, limit, search, site, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2688
2686
|
getAttendanceByUser: ({ page, limit, search, site, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2689
2687
|
getAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<{}>;
|
|
2690
2688
|
getRawAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<TAttendance>;
|
package/dist/index.js
CHANGED
|
@@ -9207,7 +9207,6 @@ var MAILER_TRANSPORT_PORT = Number(process.env.MAILER_TRANSPORT_PORT) ?? 465;
|
|
|
9207
9207
|
var MAILER_TRANSPORT_SECURE = process.env.MAILER_TRANSPORT_SECURE === "true";
|
|
9208
9208
|
var MAILER_EMAIL = process.env.MAILER_EMAIL ?? "default@gmail.com";
|
|
9209
9209
|
var MAILER_PASSWORD = process.env.MAILER_PASSWORD ?? "password";
|
|
9210
|
-
var MAILER_FROM_EMAIL = process.env.MAILER_FROM_EMAIL || void 0;
|
|
9211
9210
|
var ACCESS_TOKEN_SECRET = process.env.ACCESS_TOKEN_SECRET ?? "access_token_secret";
|
|
9212
9211
|
var REFRESH_TOKEN_SECRET = process.env.REFRESH_TOKEN_SECRET ?? "refresh_token_secret";
|
|
9213
9212
|
var ACCESS_TOKEN_EXPIRY = process.env.ACCESS_TOKEN_EXPIRY ?? "15s";
|
|
@@ -12361,7 +12360,6 @@ function useVerificationService() {
|
|
|
12361
12360
|
port: MAILER_TRANSPORT_PORT,
|
|
12362
12361
|
secure: MAILER_TRANSPORT_SECURE,
|
|
12363
12362
|
email: MAILER_EMAIL,
|
|
12364
|
-
from: MAILER_FROM_EMAIL,
|
|
12365
12363
|
password: MAILER_PASSWORD
|
|
12366
12364
|
};
|
|
12367
12365
|
const mailer = new import_node_server_utils21.useMailer(MailerConfig);
|
|
@@ -15062,10 +15060,6 @@ function useVerificationController() {
|
|
|
15062
15060
|
}
|
|
15063
15061
|
async function createSimpleUserInvite(req, res, next) {
|
|
15064
15062
|
const payload = { ...req.body };
|
|
15065
|
-
import_node_server_utils32.logger.log({
|
|
15066
|
-
level: "info",
|
|
15067
|
-
message: `[invite/user] payload: ${JSON.stringify(payload)}`
|
|
15068
|
-
});
|
|
15069
15063
|
const validation = import_joi16.default.object({
|
|
15070
15064
|
email: import_joi16.default.string().email().required(),
|
|
15071
15065
|
app: import_joi16.default.array().items(import_joi16.default.string()).min(1).required(),
|
|
@@ -15105,21 +15099,16 @@ function useVerificationController() {
|
|
|
15105
15099
|
siteName
|
|
15106
15100
|
}
|
|
15107
15101
|
});
|
|
15108
|
-
|
|
15102
|
+
res.status(201).json({
|
|
15109
15103
|
message: "Successfully invited user.",
|
|
15110
15104
|
totalInvites: verificationIds.length,
|
|
15111
15105
|
verificationIds
|
|
15112
|
-
};
|
|
15113
|
-
import_node_server_utils32.logger.log({
|
|
15114
|
-
level: "info",
|
|
15115
|
-
message: `[invite/user] response: ${JSON.stringify(responseBody)}`
|
|
15116
15106
|
});
|
|
15117
|
-
res.status(201).json(responseBody);
|
|
15118
15107
|
return;
|
|
15119
15108
|
} catch (error2) {
|
|
15120
15109
|
import_node_server_utils32.logger.log({
|
|
15121
15110
|
level: "error",
|
|
15122
|
-
message:
|
|
15111
|
+
message: `${error2.message}`
|
|
15123
15112
|
});
|
|
15124
15113
|
next(error2);
|
|
15125
15114
|
return;
|
|
@@ -15127,10 +15116,6 @@ function useVerificationController() {
|
|
|
15127
15116
|
}
|
|
15128
15117
|
async function createSimpleMemberInvite(req, res, next) {
|
|
15129
15118
|
const payload = { ...req.body };
|
|
15130
|
-
import_node_server_utils32.logger.log({
|
|
15131
|
-
level: "info",
|
|
15132
|
-
message: `[invite/member] payload: ${JSON.stringify(payload)}`
|
|
15133
|
-
});
|
|
15134
15119
|
const validation = import_joi16.default.object({
|
|
15135
15120
|
email: import_joi16.default.string().email().required(),
|
|
15136
15121
|
app: import_joi16.default.string().optional().allow("", null),
|
|
@@ -15168,19 +15153,14 @@ function useVerificationController() {
|
|
|
15168
15153
|
siteName
|
|
15169
15154
|
}
|
|
15170
15155
|
});
|
|
15171
|
-
|
|
15156
|
+
res.status(201).json({
|
|
15172
15157
|
message: "Successfully invited member."
|
|
15173
|
-
};
|
|
15174
|
-
import_node_server_utils32.logger.log({
|
|
15175
|
-
level: "info",
|
|
15176
|
-
message: `[invite/member] response: ${JSON.stringify(responseBody)}`
|
|
15177
15158
|
});
|
|
15178
|
-
res.status(201).json(responseBody);
|
|
15179
15159
|
return;
|
|
15180
15160
|
} catch (error2) {
|
|
15181
15161
|
import_node_server_utils32.logger.log({
|
|
15182
15162
|
level: "error",
|
|
15183
|
-
message:
|
|
15163
|
+
message: `${error2.message}`
|
|
15184
15164
|
});
|
|
15185
15165
|
next(error2);
|
|
15186
15166
|
return;
|
|
@@ -15188,10 +15168,6 @@ function useVerificationController() {
|
|
|
15188
15168
|
}
|
|
15189
15169
|
async function createServiceProviderInvite(req, res, next) {
|
|
15190
15170
|
const payload = req.body;
|
|
15191
|
-
import_node_server_utils32.logger.log({
|
|
15192
|
-
level: "info",
|
|
15193
|
-
message: `[service-providers/invite] payload: ${JSON.stringify(payload)}`
|
|
15194
|
-
});
|
|
15195
15171
|
const validation = import_joi16.default.object({
|
|
15196
15172
|
email: import_joi16.default.string().email().required(),
|
|
15197
15173
|
orgId: import_joi16.default.string().hex().required(),
|
|
@@ -15231,19 +15207,14 @@ function useVerificationController() {
|
|
|
15231
15207
|
secure: true,
|
|
15232
15208
|
maxAge: 4 * 60 * 60 * 1e3
|
|
15233
15209
|
};
|
|
15234
|
-
|
|
15210
|
+
res.cookie("service-provider-email", email, cookieOptions).json({
|
|
15235
15211
|
message: "Successfully invited service provider."
|
|
15236
|
-
};
|
|
15237
|
-
import_node_server_utils32.logger.log({
|
|
15238
|
-
level: "info",
|
|
15239
|
-
message: `[service-providers/invite] response: ${JSON.stringify(responseBody)}`
|
|
15240
15212
|
});
|
|
15241
|
-
res.cookie("service-provider-email", email, cookieOptions).json(responseBody);
|
|
15242
15213
|
return;
|
|
15243
15214
|
} catch (error2) {
|
|
15244
15215
|
import_node_server_utils32.logger.log({
|
|
15245
15216
|
level: "error",
|
|
15246
|
-
message: `
|
|
15217
|
+
message: `controller - ${error2.message}`
|
|
15247
15218
|
});
|
|
15248
15219
|
next(error2);
|
|
15249
15220
|
return;
|
|
@@ -27030,8 +27001,7 @@ function useVehicleService() {
|
|
|
27030
27001
|
throw new Error("Unable to start session for vehicle service.");
|
|
27031
27002
|
}
|
|
27032
27003
|
}
|
|
27033
|
-
const
|
|
27034
|
-
const [_vehiclePlateNumber] = plateNumbers;
|
|
27004
|
+
const [_vehiclePlateNumber] = value.plateNumber;
|
|
27035
27005
|
const [existingPlateNumber, org] = await Promise.all([
|
|
27036
27006
|
_getVehicleByPlateNumber(_vehiclePlateNumber),
|
|
27037
27007
|
_getById(value.org)
|
|
@@ -27096,6 +27066,7 @@ function useVehicleService() {
|
|
|
27096
27066
|
}
|
|
27097
27067
|
}
|
|
27098
27068
|
const owner = value.name;
|
|
27069
|
+
const plateNumbers = value.plateNumber;
|
|
27099
27070
|
try {
|
|
27100
27071
|
if (!isExternalSession) {
|
|
27101
27072
|
session.startTransaction();
|
|
@@ -27312,10 +27283,7 @@ function useVehicleService() {
|
|
|
27312
27283
|
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27313
27284
|
if (dahuaResponse?.statusCode != 200) {
|
|
27314
27285
|
console.log("dahuaResponse", dahuaResponse);
|
|
27315
|
-
console.log(
|
|
27316
|
-
"approveVehicleById dahuaResponse dahuaResponse?.statusCode != 200",
|
|
27317
|
-
dahuaResponse?.statusCode
|
|
27318
|
-
);
|
|
27286
|
+
console.log("approveVehicleById dahuaResponse dahuaResponse?.statusCode != 200", dahuaResponse?.statusCode);
|
|
27319
27287
|
throw new import_node_server_utils78.BadRequestError("Failed to add plate number to ANPR");
|
|
27320
27288
|
}
|
|
27321
27289
|
const responseData = dahuaResponse?.data.toString("utf-8");
|
|
@@ -27522,19 +27490,7 @@ function useVehicleService() {
|
|
|
27522
27490
|
if (value.peopleId) {
|
|
27523
27491
|
value.peopleId = new import_mongodb49.ObjectId(value.peopleId);
|
|
27524
27492
|
}
|
|
27525
|
-
const {
|
|
27526
|
-
name,
|
|
27527
|
-
plateNumber,
|
|
27528
|
-
start,
|
|
27529
|
-
end,
|
|
27530
|
-
recNo,
|
|
27531
|
-
type,
|
|
27532
|
-
unit,
|
|
27533
|
-
site,
|
|
27534
|
-
block,
|
|
27535
|
-
level,
|
|
27536
|
-
...rest
|
|
27537
|
-
} = value;
|
|
27493
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27538
27494
|
if (_name != name || _plateNumber != plateNumber) {
|
|
27539
27495
|
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27540
27496
|
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
@@ -27561,11 +27517,7 @@ function useVehicleService() {
|
|
|
27561
27517
|
for (const camera of siteCameras) {
|
|
27562
27518
|
const { host, username, password } = camera;
|
|
27563
27519
|
if (_plateNumber != plateNumber) {
|
|
27564
|
-
console.log(
|
|
27565
|
-
"updateVehicleById _plateNumber != plateNumber",
|
|
27566
|
-
_plateNumber,
|
|
27567
|
-
plateNumber
|
|
27568
|
-
);
|
|
27520
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27569
27521
|
const removePlateNumber = {
|
|
27570
27522
|
host,
|
|
27571
27523
|
username,
|
|
@@ -27612,11 +27564,7 @@ function useVehicleService() {
|
|
|
27612
27564
|
);
|
|
27613
27565
|
}
|
|
27614
27566
|
} else {
|
|
27615
|
-
console.log(
|
|
27616
|
-
"updateVehicleById _plateNumber == plateNumber",
|
|
27617
|
-
_plateNumber,
|
|
27618
|
-
plateNumber
|
|
27619
|
-
);
|
|
27567
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27620
27568
|
const dahuaPayload = {
|
|
27621
27569
|
host,
|
|
27622
27570
|
username,
|
|
@@ -33006,7 +32954,6 @@ function MAttendance(value) {
|
|
|
33006
32954
|
// src/repositories/attendance.repository.ts
|
|
33007
32955
|
var import_mongodb60 = require("mongodb");
|
|
33008
32956
|
var import_node_server_utils103 = require("@7365admin1/node-server-utils");
|
|
33009
|
-
var import_moment = __toESM(require("moment"));
|
|
33010
32957
|
function useAttendanceRepository() {
|
|
33011
32958
|
const db = import_node_server_utils103.useAtlas.getDb();
|
|
33012
32959
|
if (!db) {
|
|
@@ -33048,8 +32995,6 @@ function useAttendanceRepository() {
|
|
|
33048
32995
|
limit = 10,
|
|
33049
32996
|
search = "",
|
|
33050
32997
|
site,
|
|
33051
|
-
startDate = "",
|
|
33052
|
-
endDate = "",
|
|
33053
32998
|
serviceType
|
|
33054
32999
|
}) {
|
|
33055
33000
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -33069,37 +33014,6 @@ function useAttendanceRepository() {
|
|
|
33069
33014
|
if (search) {
|
|
33070
33015
|
cacheOptions.search = search;
|
|
33071
33016
|
}
|
|
33072
|
-
const singaporeTz = "Asia/Singapore";
|
|
33073
|
-
const normalizedStartDate = typeof startDate === "string" ? startDate : (0, import_moment.default)(startDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33074
|
-
const normalizedEndDate = typeof endDate === "string" ? endDate : (0, import_moment.default)(endDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33075
|
-
if (startDate && endDate) {
|
|
33076
|
-
const startOfDay = import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate();
|
|
33077
|
-
const endOfDay = import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate();
|
|
33078
|
-
query.$expr = {
|
|
33079
|
-
$and: [
|
|
33080
|
-
{ $gte: [{ $toDate: "$checkIn.timestamp" }, startOfDay] },
|
|
33081
|
-
{ $lte: [{ $toDate: "$checkIn.timestamp" }, endOfDay] }
|
|
33082
|
-
]
|
|
33083
|
-
};
|
|
33084
|
-
cacheOptions.startDate = normalizedStartDate;
|
|
33085
|
-
cacheOptions.endDate = normalizedEndDate;
|
|
33086
|
-
} else if (startDate) {
|
|
33087
|
-
query.$expr = {
|
|
33088
|
-
$gte: [
|
|
33089
|
-
{ $toDate: "$checkIn.timestamp" },
|
|
33090
|
-
import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate()
|
|
33091
|
-
]
|
|
33092
|
-
};
|
|
33093
|
-
cacheOptions.startDate = normalizedStartDate;
|
|
33094
|
-
} else if (endDate) {
|
|
33095
|
-
query.$expr = {
|
|
33096
|
-
$lte: [
|
|
33097
|
-
{ $toDate: "$checkIn.timestamp" },
|
|
33098
|
-
import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate()
|
|
33099
|
-
]
|
|
33100
|
-
};
|
|
33101
|
-
cacheOptions.endDate = normalizedEndDate;
|
|
33102
|
-
}
|
|
33103
33017
|
const cacheKey = (0, import_node_server_utils103.makeCacheKey)(namespace_collection, cacheOptions);
|
|
33104
33018
|
const cachedData = await getCache(cacheKey);
|
|
33105
33019
|
if (cachedData) {
|
|
@@ -33601,9 +33515,7 @@ function useAttendanceController() {
|
|
|
33601
33515
|
limit: import_joi56.default.number().min(1).optional().allow("", null),
|
|
33602
33516
|
search: import_joi56.default.string().optional().allow("", null),
|
|
33603
33517
|
site: import_joi56.default.string().hex().required(),
|
|
33604
|
-
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33605
|
-
dateFrom: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33606
|
-
dateTo: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null)
|
|
33518
|
+
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33607
33519
|
});
|
|
33608
33520
|
const { error } = validation.validate(query);
|
|
33609
33521
|
if (error) {
|
|
@@ -33616,17 +33528,13 @@ function useAttendanceController() {
|
|
|
33616
33528
|
const search = req.query.search ?? "";
|
|
33617
33529
|
const site = req.params.site ?? "";
|
|
33618
33530
|
const serviceType = req.query.serviceType ?? "";
|
|
33619
|
-
const startDate = req.query.dateFrom ?? "";
|
|
33620
|
-
const endDate = req.query.dateTo ?? "";
|
|
33621
33531
|
try {
|
|
33622
33532
|
const data = await _getAllAttendances({
|
|
33623
33533
|
page,
|
|
33624
33534
|
limit,
|
|
33625
33535
|
search,
|
|
33626
33536
|
site,
|
|
33627
|
-
serviceType
|
|
33628
|
-
startDate,
|
|
33629
|
-
endDate
|
|
33537
|
+
serviceType
|
|
33630
33538
|
});
|
|
33631
33539
|
res.json(data);
|
|
33632
33540
|
return;
|
|
@@ -34952,7 +34860,6 @@ function useVisitorTransactionService() {
|
|
|
34952
34860
|
port: MAILER_TRANSPORT_PORT,
|
|
34953
34861
|
secure: MAILER_TRANSPORT_SECURE,
|
|
34954
34862
|
email: MAILER_EMAIL,
|
|
34955
|
-
from: MAILER_FROM_EMAIL,
|
|
34956
34863
|
password: MAILER_PASSWORD
|
|
34957
34864
|
};
|
|
34958
34865
|
const mailer = new import_node_server_utils107.useMailer(MailerConfig);
|
|
@@ -36441,7 +36348,6 @@ function usePersonService() {
|
|
|
36441
36348
|
port: MAILER_TRANSPORT_PORT,
|
|
36442
36349
|
secure: MAILER_TRANSPORT_SECURE,
|
|
36443
36350
|
email: MAILER_EMAIL,
|
|
36444
|
-
from: MAILER_FROM_EMAIL,
|
|
36445
36351
|
password: MAILER_PASSWORD
|
|
36446
36352
|
};
|
|
36447
36353
|
const mailer = new import_node_server_utils112.useMailer(MailerConfig);
|
|
@@ -58794,7 +58700,6 @@ function useNfcPatrolLogController() {
|
|
|
58794
58700
|
const query = {
|
|
58795
58701
|
site: req.query.site,
|
|
58796
58702
|
date: req.query.date,
|
|
58797
|
-
type: req.query.type,
|
|
58798
58703
|
route: {
|
|
58799
58704
|
_id: req.query["route._id"],
|
|
58800
58705
|
startTime: req.query["route.startTime"]
|
|
@@ -58809,14 +58714,13 @@ function useNfcPatrolLogController() {
|
|
|
58809
58714
|
next(new import_node_server_utils200.BadRequestError(messages));
|
|
58810
58715
|
return;
|
|
58811
58716
|
}
|
|
58812
|
-
const { page, limit, site, date,
|
|
58717
|
+
const { page, limit, site, date, route } = value;
|
|
58813
58718
|
try {
|
|
58814
58719
|
const data = await _getAllBySite({
|
|
58815
58720
|
page,
|
|
58816
58721
|
limit,
|
|
58817
58722
|
site,
|
|
58818
58723
|
date,
|
|
58819
|
-
type,
|
|
58820
58724
|
route
|
|
58821
58725
|
});
|
|
58822
58726
|
res.status(200).json(data);
|
|
@@ -58878,7 +58782,7 @@ function useNfcPatrolLogController() {
|
|
|
58878
58782
|
// src/repositories/new-dashboard.repo.ts
|
|
58879
58783
|
var import_node_server_utils201 = require("@7365admin1/node-server-utils");
|
|
58880
58784
|
var import_mongodb122 = require("mongodb");
|
|
58881
|
-
var
|
|
58785
|
+
var import_moment = __toESM(require("moment"));
|
|
58882
58786
|
var Period = /* @__PURE__ */ ((Period2) => {
|
|
58883
58787
|
Period2["TODAY"] = "today";
|
|
58884
58788
|
Period2["THIS_WEEK"] = "thisWeek";
|
|
@@ -58915,7 +58819,7 @@ function useNewDashboardRepo() {
|
|
|
58915
58819
|
const dateWithoutTimezone = date.replace(/\s*\+\d{2}:\d{2}$/, "");
|
|
58916
58820
|
date = new Date(dateWithoutTimezone);
|
|
58917
58821
|
}
|
|
58918
|
-
const singaporeMoment =
|
|
58822
|
+
const singaporeMoment = import_moment.default.tz(date, "Asia/Singapore");
|
|
58919
58823
|
singaporeMoment.set({
|
|
58920
58824
|
hour: 23,
|
|
58921
58825
|
minute: 59,
|
|
@@ -58925,7 +58829,7 @@ function useNewDashboardRepo() {
|
|
|
58925
58829
|
return singaporeMoment.toDate();
|
|
58926
58830
|
}
|
|
58927
58831
|
function getDateRange(p) {
|
|
58928
|
-
const now = (0,
|
|
58832
|
+
const now = (0, import_moment.default)().tz("Asia/Singapore");
|
|
58929
58833
|
if (p === "thisWeek" /* THIS_WEEK */) {
|
|
58930
58834
|
return {
|
|
58931
58835
|
$gte: now.clone().startOf("isoWeek").toDate(),
|
|
@@ -58943,7 +58847,7 @@ function useNewDashboardRepo() {
|
|
|
58943
58847
|
$lte: now.clone().endOf("day").toDate()
|
|
58944
58848
|
};
|
|
58945
58849
|
}
|
|
58946
|
-
function getSiteDayRange(date =
|
|
58850
|
+
function getSiteDayRange(date = import_moment.default.tz("Asia/Singapore")) {
|
|
58947
58851
|
return {
|
|
58948
58852
|
$gte: date.clone().startOf("day").toDate(),
|
|
58949
58853
|
$lte: date.clone().endOf("day").toDate()
|
|
@@ -59214,8 +59118,8 @@ function useNewDashboardRepo() {
|
|
|
59214
59118
|
const todayCompliance = tTotal > 0 ? tCompleted / tTotal * 100 : 0;
|
|
59215
59119
|
let activePatrolItems = [];
|
|
59216
59120
|
if (period === "today" /* TODAY */) {
|
|
59217
|
-
const todayString =
|
|
59218
|
-
const dayIndex =
|
|
59121
|
+
const todayString = import_moment.default.tz("Asia/Singapore").format("YYYY-MM-DD");
|
|
59122
|
+
const dayIndex = import_moment.default.tz("Asia/Singapore").day();
|
|
59219
59123
|
const repeatDay = dayIndex === 0 ? 7 : dayIndex;
|
|
59220
59124
|
const routes = await db.collection("patrol.route").find({
|
|
59221
59125
|
site: { $in: [siteIdObj, siteId] },
|
|
@@ -59267,12 +59171,12 @@ function useNewDashboardRepo() {
|
|
|
59267
59171
|
status = "completed";
|
|
59268
59172
|
}
|
|
59269
59173
|
} else {
|
|
59270
|
-
const routeTime =
|
|
59174
|
+
const routeTime = import_moment.default.tz(
|
|
59271
59175
|
`${todayString} ${startTime}`,
|
|
59272
59176
|
"YYYY-MM-DD HH:mm",
|
|
59273
59177
|
"Asia/Singapore"
|
|
59274
59178
|
);
|
|
59275
|
-
const nowSg =
|
|
59179
|
+
const nowSg = import_moment.default.tz("Asia/Singapore");
|
|
59276
59180
|
const diffMinutes = nowSg.diff(routeTime, "minutes");
|
|
59277
59181
|
if (diffMinutes >= 0) {
|
|
59278
59182
|
if (diffMinutes <= 120) {
|
|
@@ -59320,8 +59224,8 @@ function useNewDashboardRepo() {
|
|
|
59320
59224
|
if (log.status) {
|
|
59321
59225
|
status = Array.isArray(log.status) ? log.status.join(", ") : log.status;
|
|
59322
59226
|
}
|
|
59323
|
-
const logTime = (0,
|
|
59324
|
-
const logDate = (0,
|
|
59227
|
+
const logTime = (0, import_moment.default)(log.createdAt).tz("Asia/Singapore").format("HH:mm");
|
|
59228
|
+
const logDate = (0, import_moment.default)(log.createdAt).tz("Asia/Singapore").format("DD/MM/YYYY");
|
|
59325
59229
|
return {
|
|
59326
59230
|
id: log._id.toString(),
|
|
59327
59231
|
title: log.name,
|
|
@@ -59373,11 +59277,11 @@ function useNewDashboardRepo() {
|
|
|
59373
59277
|
}
|
|
59374
59278
|
async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
|
|
59375
59279
|
const siteIdObj = (0, import_node_server_utils201.toObjectId)(siteId);
|
|
59376
|
-
const startOfToday =
|
|
59377
|
-
const endOfToday =
|
|
59280
|
+
const startOfToday = import_moment.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59281
|
+
const endOfToday = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
59378
59282
|
const facilityTodayRange = getSiteDayRange();
|
|
59379
59283
|
const facilityYesterdayRange = getSiteDayRange(
|
|
59380
|
-
|
|
59284
|
+
import_moment.default.tz("Asia/Singapore").subtract(1, "day")
|
|
59381
59285
|
);
|
|
59382
59286
|
const facilityTodayStart = facilityTodayRange.$gte;
|
|
59383
59287
|
const facilityTodayEnd = facilityTodayRange.$lte;
|
|
@@ -59389,13 +59293,13 @@ function useNewDashboardRepo() {
|
|
|
59389
59293
|
};
|
|
59390
59294
|
if (period === "thisWeek" /* THIS_WEEK */) {
|
|
59391
59295
|
facilityPeriodRange = {
|
|
59392
|
-
$gte:
|
|
59393
|
-
$lte:
|
|
59296
|
+
$gte: import_moment.default.tz("Asia/Singapore").startOf("isoWeek").toDate(),
|
|
59297
|
+
$lte: import_moment.default.tz("Asia/Singapore").endOf("isoWeek").toDate()
|
|
59394
59298
|
};
|
|
59395
59299
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
59396
59300
|
facilityPeriodRange = {
|
|
59397
|
-
$gte:
|
|
59398
|
-
$lte:
|
|
59301
|
+
$gte: import_moment.default.tz("Asia/Singapore").startOf("month").toDate(),
|
|
59302
|
+
$lte: import_moment.default.tz("Asia/Singapore").endOf("month").toDate()
|
|
59399
59303
|
};
|
|
59400
59304
|
}
|
|
59401
59305
|
const upcomingEvents = await db.collection(events_namespace_collection).find({
|
|
@@ -60027,28 +59931,28 @@ function useNewDashboardRepo() {
|
|
|
60027
59931
|
let labels = [];
|
|
60028
59932
|
let getIntervalIndex;
|
|
60029
59933
|
if (period === "today" /* TODAY */) {
|
|
60030
|
-
rangeStart =
|
|
60031
|
-
rangeEnd =
|
|
59934
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59935
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
60032
59936
|
labels = ["12 AM", "4 AM", "8 AM", "12 PM", "4 PM", "8 PM"];
|
|
60033
59937
|
getIntervalIndex = (date) => {
|
|
60034
|
-
const hour = (0,
|
|
59938
|
+
const hour = (0, import_moment.default)(date).tz("Asia/Singapore").hour();
|
|
60035
59939
|
return Math.floor(hour / 4);
|
|
60036
59940
|
};
|
|
60037
59941
|
} else if (period === "thisWeek" /* THIS_WEEK */) {
|
|
60038
|
-
rangeStart =
|
|
60039
|
-
rangeEnd =
|
|
59942
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("isoWeek").toDate();
|
|
59943
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("isoWeek").toDate();
|
|
60040
59944
|
labels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
60041
59945
|
getIntervalIndex = (date) => {
|
|
60042
|
-
const day = (0,
|
|
59946
|
+
const day = (0, import_moment.default)(date).tz("Asia/Singapore").isoWeekday();
|
|
60043
59947
|
return day - 1;
|
|
60044
59948
|
};
|
|
60045
59949
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
60046
|
-
rangeStart =
|
|
60047
|
-
rangeEnd =
|
|
60048
|
-
const daysInMonth =
|
|
59950
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("month").toDate();
|
|
59951
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("month").toDate();
|
|
59952
|
+
const daysInMonth = import_moment.default.tz("Asia/Singapore").daysInMonth();
|
|
60049
59953
|
labels = Array.from({ length: daysInMonth }, (_, i) => String(i + 1));
|
|
60050
59954
|
getIntervalIndex = (date) => {
|
|
60051
|
-
return (0,
|
|
59955
|
+
return (0, import_moment.default)(date).tz("Asia/Singapore").date() - 1;
|
|
60052
59956
|
};
|
|
60053
59957
|
} else {
|
|
60054
59958
|
throw new import_node_server_utils201.BadRequestError("Invalid period.");
|
|
@@ -64170,7 +64074,6 @@ function sendEmailWithAttachmentsTo({
|
|
|
64170
64074
|
port: MAILER_TRANSPORT_PORT,
|
|
64171
64075
|
secure: MAILER_TRANSPORT_SECURE,
|
|
64172
64076
|
email: MAILER_EMAIL,
|
|
64173
|
-
from: MAILER_FROM_EMAIL,
|
|
64174
64077
|
password: MAILER_PASSWORD
|
|
64175
64078
|
};
|
|
64176
64079
|
const mailer = new import_node_server_utils221.useMailer(MailerConfig);
|
|
@@ -64924,7 +64827,6 @@ function useVerificationServiceV2() {
|
|
|
64924
64827
|
port: MAILER_TRANSPORT_PORT,
|
|
64925
64828
|
secure: MAILER_TRANSPORT_SECURE,
|
|
64926
64829
|
email: MAILER_EMAIL,
|
|
64927
|
-
from: MAILER_FROM_EMAIL,
|
|
64928
64830
|
password: MAILER_PASSWORD
|
|
64929
64831
|
};
|
|
64930
64832
|
const mailer = new import_node_server_utils227.useMailer(MailerConfig);
|