@7365admin1/core 3.37.0 → 3.39.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 +3 -3
- package/dist/index.js +96 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25060,9 +25060,9 @@ function usePersonRepo() {
|
|
|
25060
25060
|
{ email: { $regex: search, $options: "i" } },
|
|
25061
25061
|
{ nric: { $regex: search, $options: "i" } },
|
|
25062
25062
|
{ "plates.plateNumber": { $regex: search, $options: "i" } },
|
|
25063
|
-
{ contact: { $regex: makeContainsRegex(
|
|
25064
|
-
{ contacts: { $regex: makeContainsRegex(
|
|
25065
|
-
{ plateNumbers: { $regex: makeContainsRegex(
|
|
25063
|
+
{ contact: { $regex: makeContainsRegex(search) } },
|
|
25064
|
+
{ contacts: { $regex: makeContainsRegex(search) } },
|
|
25065
|
+
{ plateNumbers: { $regex: makeContainsRegex(search) } }
|
|
25066
25066
|
]
|
|
25067
25067
|
},
|
|
25068
25068
|
...ObjectId45.isValid(org) && { org: new ObjectId45(org) },
|
|
@@ -25675,7 +25675,7 @@ function usePersonRepo() {
|
|
|
25675
25675
|
const data = await collection.find(query, { session }).limit(10).toArray();
|
|
25676
25676
|
return data;
|
|
25677
25677
|
} catch (error) {
|
|
25678
|
-
throw new InternalServerError26("Failed to find
|
|
25678
|
+
throw new InternalServerError26("Failed to find persons" + error);
|
|
25679
25679
|
}
|
|
25680
25680
|
}
|
|
25681
25681
|
async function addFromVisitor(value, session) {
|
|
@@ -32983,7 +32983,7 @@ function useAttendanceRepository() {
|
|
|
32983
32983
|
localField: "user",
|
|
32984
32984
|
foreignField: "_id",
|
|
32985
32985
|
as: "user",
|
|
32986
|
-
pipeline: [{ $project: { name: 1 } }]
|
|
32986
|
+
pipeline: [{ $project: { name: 1, profile: 1 } }]
|
|
32987
32987
|
}
|
|
32988
32988
|
},
|
|
32989
32989
|
{ $unwind: { path: "$user", preserveNullAndEmptyArrays: true } }
|
|
@@ -32997,6 +32997,7 @@ function useAttendanceRepository() {
|
|
|
32997
32997
|
{
|
|
32998
32998
|
$project: {
|
|
32999
32999
|
userName: "$user.name",
|
|
33000
|
+
userProfile: "$user.profile",
|
|
33000
33001
|
checkInTimestamp: "$checkIn.timestamp",
|
|
33001
33002
|
checkOutTimestamp: "$checkOut.timestamp",
|
|
33002
33003
|
createdAt: 1
|
|
@@ -35487,7 +35488,7 @@ function useVisitorTransactionService() {
|
|
|
35487
35488
|
value.unitName = unit?.name;
|
|
35488
35489
|
}
|
|
35489
35490
|
const { nric = "", name = "", contact = "", plateNumber = "", email = "", site = "", type = "guest", company, createdBy } = value;
|
|
35490
|
-
if (/^(guest|walk-in|contractor|delivery)$/.test(type)) {
|
|
35491
|
+
if (/^(guest|walk-in|contractor|delivery)$/.test(type) && site) {
|
|
35491
35492
|
await addUpdateFromVisitor({
|
|
35492
35493
|
nric,
|
|
35493
35494
|
name,
|
|
@@ -35718,7 +35719,7 @@ function useVisitorTransactionService() {
|
|
|
35718
35719
|
value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
|
|
35719
35720
|
}
|
|
35720
35721
|
const { nric = "", name = "", contact = "", plateNumber = "", email = "", site = "", type = "guest", company, createdBy } = value;
|
|
35721
|
-
if (/^(guest|walk-in|contractor|delivery)$/.test(type)) {
|
|
35722
|
+
if (/^(guest|walk-in|contractor|delivery)$/.test(type) && site) {
|
|
35722
35723
|
await addUpdateFromVisitor({
|
|
35723
35724
|
nric,
|
|
35724
35725
|
name,
|
|
@@ -35902,7 +35903,9 @@ function useVisitorTransactionService() {
|
|
|
35902
35903
|
value.site,
|
|
35903
35904
|
session,
|
|
35904
35905
|
void 0,
|
|
35905
|
-
id
|
|
35906
|
+
id,
|
|
35907
|
+
void 0,
|
|
35908
|
+
true
|
|
35906
35909
|
);
|
|
35907
35910
|
item.receivedDate = /* @__PURE__ */ new Date();
|
|
35908
35911
|
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
@@ -35951,7 +35954,9 @@ function useVisitorTransactionService() {
|
|
|
35951
35954
|
value.site,
|
|
35952
35955
|
session,
|
|
35953
35956
|
void 0,
|
|
35954
|
-
id
|
|
35957
|
+
id,
|
|
35958
|
+
void 0,
|
|
35959
|
+
true
|
|
35955
35960
|
);
|
|
35956
35961
|
item.receivedDate = /* @__PURE__ */ new Date();
|
|
35957
35962
|
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
@@ -55352,8 +55357,11 @@ function useNfcPatrolRouteRepo() {
|
|
|
55352
55357
|
const query = {
|
|
55353
55358
|
site
|
|
55354
55359
|
};
|
|
55355
|
-
if (search) {
|
|
55356
|
-
query
|
|
55360
|
+
if (search?.trim()) {
|
|
55361
|
+
query.name = {
|
|
55362
|
+
$regex: search.trim(),
|
|
55363
|
+
$options: "i"
|
|
55364
|
+
};
|
|
55357
55365
|
}
|
|
55358
55366
|
if (filter === "today" || filter === "notToday") {
|
|
55359
55367
|
const singaporeDateString = (/* @__PURE__ */ new Date()).toLocaleString("en-US", {
|
|
@@ -58775,13 +58783,9 @@ function useNfcPatrolLogRepo() {
|
|
|
58775
58783
|
};
|
|
58776
58784
|
if (date) {
|
|
58777
58785
|
if (type === "month") {
|
|
58778
|
-
const [year, month] = date.split("-").map(Number);
|
|
58779
|
-
const endDay = new Date(year, month, 0).getDate();
|
|
58780
58786
|
query.date = {
|
|
58781
|
-
$gte: `${
|
|
58782
|
-
$lte: `${
|
|
58783
|
-
endDay
|
|
58784
|
-
).padStart(2, "0")}`
|
|
58787
|
+
$gte: `${date}-01-01`,
|
|
58788
|
+
$lte: `${date}-12-31`
|
|
58785
58789
|
};
|
|
58786
58790
|
} else {
|
|
58787
58791
|
query.date = date;
|
|
@@ -59109,47 +59113,52 @@ function useNfcPatrolLogController() {
|
|
|
59109
59113
|
page: Joi111.number().integer().min(1).default(1),
|
|
59110
59114
|
limit: Joi111.number().integer().min(1).max(100).default(10),
|
|
59111
59115
|
site: Joi111.string().length(24).hex().required(),
|
|
59112
|
-
date: Joi111.string().pattern(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
|
|
59113
|
-
"string.pattern.base": "Date must be
|
|
59116
|
+
date: Joi111.string().pattern(/^\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?$/).optional().messages({
|
|
59117
|
+
"string.pattern.base": "Date must be YYYY or YYYY-MM or YYYY-MM-DD"
|
|
59114
59118
|
}),
|
|
59115
59119
|
type: Joi111.string().valid("month").optional(),
|
|
59116
59120
|
route: Joi111.object({
|
|
59117
|
-
_id: Joi111.string().length(24).hex().
|
|
59118
|
-
startTime: Joi111.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).
|
|
59119
|
-
|
|
59121
|
+
_id: Joi111.string().length(24).hex().optional(),
|
|
59122
|
+
startTime: Joi111.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().messages({
|
|
59123
|
+
"string.pattern.base": "startTime must be in HH:mm 24-hour format"
|
|
59124
|
+
})
|
|
59125
|
+
}).min(1).optional()
|
|
59120
59126
|
});
|
|
59121
59127
|
const query = {
|
|
59128
|
+
page: req.query.page,
|
|
59129
|
+
limit: req.query.limit,
|
|
59122
59130
|
site: req.query.site,
|
|
59123
59131
|
date: req.query.date,
|
|
59124
|
-
|
|
59125
|
-
|
|
59126
|
-
|
|
59127
|
-
|
|
59132
|
+
type: req.query.type,
|
|
59133
|
+
route: req.query["route._id"] || req.query["route.startTime"] ? {
|
|
59134
|
+
...req.query["route._id"] ? { _id: req.query["route._id"] } : {},
|
|
59135
|
+
...req.query["route.startTime"] ? { startTime: req.query["route.startTime"] } : {}
|
|
59136
|
+
} : void 0
|
|
59128
59137
|
};
|
|
59129
59138
|
const { error, value } = validation.validate(query, {
|
|
59130
|
-
abortEarly: false
|
|
59139
|
+
abortEarly: false,
|
|
59140
|
+
allowUnknown: true,
|
|
59141
|
+
stripUnknown: true
|
|
59131
59142
|
});
|
|
59132
59143
|
if (error) {
|
|
59133
|
-
|
|
59134
|
-
|
|
59135
|
-
|
|
59136
|
-
|
|
59144
|
+
return next(
|
|
59145
|
+
new BadRequestError181(
|
|
59146
|
+
error.details.map((d) => d.message).join(", ")
|
|
59147
|
+
)
|
|
59148
|
+
);
|
|
59137
59149
|
}
|
|
59138
|
-
const { page, limit, site, date, route } = value;
|
|
59139
59150
|
try {
|
|
59140
59151
|
const data = await _getAllBySite({
|
|
59141
|
-
page,
|
|
59142
|
-
limit,
|
|
59143
|
-
site,
|
|
59144
|
-
date,
|
|
59145
|
-
|
|
59152
|
+
page: value.page,
|
|
59153
|
+
limit: value.limit,
|
|
59154
|
+
site: value.site,
|
|
59155
|
+
date: value.date,
|
|
59156
|
+
type: value.type,
|
|
59157
|
+
route: value.route
|
|
59146
59158
|
});
|
|
59147
|
-
res.status(200).json(data);
|
|
59148
|
-
return;
|
|
59159
|
+
return res.status(200).json(data);
|
|
59149
59160
|
} catch (error2) {
|
|
59150
|
-
|
|
59151
|
-
next(error2);
|
|
59152
|
-
return;
|
|
59161
|
+
return next(error2);
|
|
59153
59162
|
}
|
|
59154
59163
|
}
|
|
59155
59164
|
async function completeCheckpoint(req, res, next) {
|
|
@@ -64737,34 +64746,62 @@ import axios3 from "axios";
|
|
|
64737
64746
|
|
|
64738
64747
|
// src/utils/payment-signature.util.ts
|
|
64739
64748
|
import * as crypto3 from "crypto";
|
|
64749
|
+
function hasOwn(obj, key) {
|
|
64750
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
64751
|
+
}
|
|
64752
|
+
function sha512(input) {
|
|
64753
|
+
return crypto3.createHash("sha512").update(input).digest("hex");
|
|
64754
|
+
}
|
|
64755
|
+
function assertSecret(secretKey) {
|
|
64756
|
+
if (!secretKey) {
|
|
64757
|
+
throw new Error("Payment signature: missing secret key.");
|
|
64758
|
+
}
|
|
64759
|
+
}
|
|
64740
64760
|
function paymentSignature(params, secretKey) {
|
|
64741
|
-
|
|
64761
|
+
assertSecret(secretKey);
|
|
64762
|
+
const fieldOrder = [
|
|
64763
|
+
"mid",
|
|
64764
|
+
"order_id",
|
|
64765
|
+
"payment_type",
|
|
64766
|
+
"amount",
|
|
64767
|
+
"ccy",
|
|
64768
|
+
"card_no",
|
|
64769
|
+
"exp_date",
|
|
64770
|
+
"cvv2"
|
|
64771
|
+
];
|
|
64742
64772
|
let concatenated = "";
|
|
64743
64773
|
fieldOrder.forEach((v) => {
|
|
64744
|
-
if (!params
|
|
64774
|
+
if (!hasOwn(params, v)) {
|
|
64745
64775
|
return;
|
|
64746
|
-
}
|
|
64747
|
-
|
|
64776
|
+
}
|
|
64777
|
+
const raw = String(params[v] ?? "");
|
|
64778
|
+
if (v === "cvv2") {
|
|
64779
|
+
concatenated += raw.slice(-1);
|
|
64748
64780
|
} else if (v === "card_no") {
|
|
64749
|
-
concatenated +=
|
|
64781
|
+
concatenated += raw.substring(0, 6) + raw.slice(-4);
|
|
64750
64782
|
} else {
|
|
64751
|
-
concatenated +=
|
|
64783
|
+
concatenated += raw;
|
|
64752
64784
|
}
|
|
64753
64785
|
});
|
|
64754
64786
|
concatenated += secretKey;
|
|
64755
|
-
|
|
64756
|
-
return signature;
|
|
64787
|
+
return sha512(concatenated);
|
|
64757
64788
|
}
|
|
64758
64789
|
function genericSignature(params, secretKey) {
|
|
64759
|
-
|
|
64790
|
+
assertSecret(secretKey);
|
|
64791
|
+
const paramsCopy = {
|
|
64792
|
+
...params
|
|
64793
|
+
};
|
|
64760
64794
|
delete paramsCopy["signature"];
|
|
64761
|
-
const
|
|
64762
|
-
|
|
64763
|
-
|
|
64764
|
-
|
|
64765
|
-
|
|
64766
|
-
|
|
64767
|
-
|
|
64795
|
+
const concatenated = Object.keys(paramsCopy).sort().map((key) => {
|
|
64796
|
+
const value = paramsCopy[key];
|
|
64797
|
+
if (value !== null && typeof value === "object") {
|
|
64798
|
+
throw new Error(
|
|
64799
|
+
`Payment signature: non-primitive value for field "${key}".`
|
|
64800
|
+
);
|
|
64801
|
+
}
|
|
64802
|
+
return String(value ?? "");
|
|
64803
|
+
}).join("") + secretKey;
|
|
64804
|
+
return sha512(concatenated);
|
|
64768
64805
|
}
|
|
64769
64806
|
|
|
64770
64807
|
// src/repositories/reddot-payment.repository.ts
|
|
@@ -65193,7 +65230,7 @@ var useRedDotPaymentSvc = () => {
|
|
|
65193
65230
|
};
|
|
65194
65231
|
if (!process.env.MERCHANT_ENQUIRY) {
|
|
65195
65232
|
throw new Error(
|
|
65196
|
-
"
|
|
65233
|
+
"MERCHANT_ENQUIRY environment variable is not defined."
|
|
65197
65234
|
);
|
|
65198
65235
|
}
|
|
65199
65236
|
const url = process.env.MERCHANT_ENQUIRY;
|