@7365admin1/core 2.62.0 → 2.63.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 +8 -3
- package/dist/index.js +152 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3918,7 +3918,9 @@ function useVerificationRepo() {
|
|
|
3918
3918
|
status = "active",
|
|
3919
3919
|
app = "",
|
|
3920
3920
|
type = {},
|
|
3921
|
-
email = ""
|
|
3921
|
+
email = "",
|
|
3922
|
+
siteId = "",
|
|
3923
|
+
orgId = ""
|
|
3922
3924
|
}) {
|
|
3923
3925
|
page = page > 0 ? page - 1 : 0;
|
|
3924
3926
|
const query = { status };
|
|
@@ -3945,6 +3947,24 @@ function useVerificationRepo() {
|
|
|
3945
3947
|
query.email = email;
|
|
3946
3948
|
cacheOptions.email = email;
|
|
3947
3949
|
}
|
|
3950
|
+
if (siteId) {
|
|
3951
|
+
const siteCandidates = [siteId];
|
|
3952
|
+
try {
|
|
3953
|
+
siteCandidates.push(new ObjectId13(siteId));
|
|
3954
|
+
} catch {
|
|
3955
|
+
}
|
|
3956
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
3957
|
+
cacheOptions.siteId = siteId;
|
|
3958
|
+
}
|
|
3959
|
+
if (orgId) {
|
|
3960
|
+
const orgCandidates = [orgId];
|
|
3961
|
+
try {
|
|
3962
|
+
orgCandidates.push(new ObjectId13(orgId));
|
|
3963
|
+
} catch {
|
|
3964
|
+
}
|
|
3965
|
+
query["metadata.org"] = { $in: orgCandidates };
|
|
3966
|
+
cacheOptions.orgId = orgId;
|
|
3967
|
+
}
|
|
3948
3968
|
const cacheKey = makeCacheKey7(namespace_collection, cacheOptions);
|
|
3949
3969
|
const cachedData = await getCache(cacheKey);
|
|
3950
3970
|
if (cachedData) {
|
|
@@ -8222,7 +8242,10 @@ function useVerificationController() {
|
|
|
8222
8242
|
status: Joi16.string().required(),
|
|
8223
8243
|
app: Joi16.string().optional().allow("", null),
|
|
8224
8244
|
type: Joi16.alternatives().try(Joi16.string(), Joi16.array().items(Joi16.string())).optional().allow("", null),
|
|
8225
|
-
email: Joi16.string().optional().allow("", null)
|
|
8245
|
+
email: Joi16.string().optional().allow("", null),
|
|
8246
|
+
siteId: Joi16.string().hex().optional().allow("", null),
|
|
8247
|
+
orgId: Joi16.string().hex().optional().allow("", null),
|
|
8248
|
+
limit: Joi16.number().integer().min(1).allow("", null).default(10)
|
|
8226
8249
|
});
|
|
8227
8250
|
const query = { ...req.query };
|
|
8228
8251
|
const { error } = validation.validate(query);
|
|
@@ -8236,6 +8259,9 @@ function useVerificationController() {
|
|
|
8236
8259
|
const status = req.query.status ?? "pending";
|
|
8237
8260
|
const app = req.query.app ?? "";
|
|
8238
8261
|
const email = req.query.email ?? "";
|
|
8262
|
+
const siteId = req.query.siteId ?? "";
|
|
8263
|
+
const orgId = req.query.orgId ?? "";
|
|
8264
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
8239
8265
|
const type = req.query.type ? String(req.query.type).split(",") : "";
|
|
8240
8266
|
const typeObj = {};
|
|
8241
8267
|
if (type && Array.isArray(type) && type.length) {
|
|
@@ -8250,7 +8276,10 @@ function useVerificationController() {
|
|
|
8250
8276
|
status,
|
|
8251
8277
|
app,
|
|
8252
8278
|
type: typeObj,
|
|
8253
|
-
email
|
|
8279
|
+
email,
|
|
8280
|
+
siteId,
|
|
8281
|
+
orgId,
|
|
8282
|
+
limit
|
|
8254
8283
|
});
|
|
8255
8284
|
res.json(data);
|
|
8256
8285
|
return;
|
|
@@ -12008,6 +12037,7 @@ function useServiceProviderRepo() {
|
|
|
12008
12037
|
throw new BadRequestError54("Invalid site ID format.");
|
|
12009
12038
|
}
|
|
12010
12039
|
}
|
|
12040
|
+
cacheOptions.membersLookup = "1";
|
|
12011
12041
|
const cacheKey = makeCacheKey20(namespace_collection, cacheOptions);
|
|
12012
12042
|
const cachedData = await getCache(cacheKey);
|
|
12013
12043
|
if (cachedData) {
|
|
@@ -12023,7 +12053,7 @@ function useServiceProviderRepo() {
|
|
|
12023
12053
|
localField: "serviceProviderOrgId",
|
|
12024
12054
|
foreignField: "_id",
|
|
12025
12055
|
as: "organization",
|
|
12026
|
-
pipeline: [{ $project: { nature: 1 } }]
|
|
12056
|
+
pipeline: [{ $project: { nature: 1, email: 1 } }]
|
|
12027
12057
|
}
|
|
12028
12058
|
},
|
|
12029
12059
|
{
|
|
@@ -12032,17 +12062,50 @@ function useServiceProviderRepo() {
|
|
|
12032
12062
|
preserveNullAndEmptyArrays: true
|
|
12033
12063
|
}
|
|
12034
12064
|
},
|
|
12065
|
+
{
|
|
12066
|
+
$lookup: {
|
|
12067
|
+
from: "members",
|
|
12068
|
+
let: { spOrgId: "$serviceProviderOrgId" },
|
|
12069
|
+
pipeline: [
|
|
12070
|
+
{
|
|
12071
|
+
$match: {
|
|
12072
|
+
$expr: { $eq: ["$org", "$$spOrgId"] },
|
|
12073
|
+
status: "active"
|
|
12074
|
+
}
|
|
12075
|
+
},
|
|
12076
|
+
{ $count: "c" }
|
|
12077
|
+
],
|
|
12078
|
+
as: "_memberCount"
|
|
12079
|
+
}
|
|
12080
|
+
},
|
|
12035
12081
|
{
|
|
12036
12082
|
$project: {
|
|
12037
12083
|
name: 1,
|
|
12038
12084
|
type: 1,
|
|
12085
|
+
email: {
|
|
12086
|
+
$cond: {
|
|
12087
|
+
if: {
|
|
12088
|
+
$gt: [{ $strLenCP: { $ifNull: ["$email", ""] } }, 0]
|
|
12089
|
+
},
|
|
12090
|
+
then: "$email",
|
|
12091
|
+
else: { $ifNull: ["$organization.email", ""] }
|
|
12092
|
+
}
|
|
12093
|
+
},
|
|
12039
12094
|
nature: "$organization.nature",
|
|
12040
12095
|
orgId: 1,
|
|
12041
12096
|
siteId: 1,
|
|
12042
12097
|
siteName: 1,
|
|
12043
12098
|
serviceProviderOrgId: 1,
|
|
12044
12099
|
status: 1,
|
|
12045
|
-
category: 1
|
|
12100
|
+
category: 1,
|
|
12101
|
+
members: {
|
|
12102
|
+
$let: {
|
|
12103
|
+
vars: {
|
|
12104
|
+
mc: { $arrayElemAt: ["$_memberCount", 0] }
|
|
12105
|
+
},
|
|
12106
|
+
in: { $ifNull: ["$$mc.c", 0] }
|
|
12107
|
+
}
|
|
12108
|
+
}
|
|
12046
12109
|
}
|
|
12047
12110
|
},
|
|
12048
12111
|
{ $sort: sort },
|
|
@@ -31970,7 +32033,8 @@ function useBulletinBoardRepo() {
|
|
|
31970
32033
|
sort = {},
|
|
31971
32034
|
site = "",
|
|
31972
32035
|
status = "active",
|
|
31973
|
-
recipients = []
|
|
32036
|
+
recipients = [],
|
|
32037
|
+
expiration
|
|
31974
32038
|
}, session) {
|
|
31975
32039
|
page = page > 0 ? page - 1 : 0;
|
|
31976
32040
|
try {
|
|
@@ -31981,8 +32045,13 @@ function useBulletinBoardRepo() {
|
|
|
31981
32045
|
const query = {
|
|
31982
32046
|
site,
|
|
31983
32047
|
status,
|
|
31984
|
-
...search && {
|
|
31985
|
-
|
|
32048
|
+
...search && {
|
|
32049
|
+
$or: [{ title: { $regex: search, $options: "i" } }]
|
|
32050
|
+
},
|
|
32051
|
+
...recipients?.length && { recipients: { $all: recipients } },
|
|
32052
|
+
...expiration !== void 0 && {
|
|
32053
|
+
noExpiration: expiration === "yes"
|
|
32054
|
+
}
|
|
31986
32055
|
};
|
|
31987
32056
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
31988
32057
|
const cacheOptions = {
|
|
@@ -31992,7 +32061,8 @@ function useBulletinBoardRepo() {
|
|
|
31992
32061
|
page,
|
|
31993
32062
|
limit,
|
|
31994
32063
|
...search && { search },
|
|
31995
|
-
...recipients?.length && { recipients: recipients.sort().join(",") }
|
|
32064
|
+
...recipients?.length && { recipients: recipients.sort().join(",") },
|
|
32065
|
+
...expiration !== void 0 && { expiration }
|
|
31996
32066
|
};
|
|
31997
32067
|
const cacheKey = makeCacheKey39(
|
|
31998
32068
|
bulletin_boards_namespace_collection,
|
|
@@ -32180,7 +32250,9 @@ function useBulletinBoardRepo() {
|
|
|
32180
32250
|
{ session }
|
|
32181
32251
|
);
|
|
32182
32252
|
if (res.matchedCount === 0) {
|
|
32183
|
-
throw new NotFoundError30(
|
|
32253
|
+
throw new NotFoundError30(
|
|
32254
|
+
"No upcoming bulletin boards found to activate."
|
|
32255
|
+
);
|
|
32184
32256
|
}
|
|
32185
32257
|
delNamespace().then(() => {
|
|
32186
32258
|
logger105.info(
|
|
@@ -32366,32 +32438,35 @@ function useBulletinBoardController() {
|
|
|
32366
32438
|
order: Joi77.string().valid(...Object.values(BulletinOrder)).default("desc" /* DESC */),
|
|
32367
32439
|
site: Joi77.string().hex().length(24).required(),
|
|
32368
32440
|
status: Joi77.string().valid(...Object.values(BulletinStatus)).optional().default("active" /* ACTIVE */),
|
|
32369
|
-
recipients: Joi77.
|
|
32370
|
-
|
|
32371
|
-
Joi77.string().valid(...Object.values(BulletinRecipient))
|
|
32372
|
-
),
|
|
32373
|
-
Joi77.string().allow("")
|
|
32374
|
-
).optional().allow(null).custom((value2, helpers) => {
|
|
32375
|
-
if (!value2 || value2 === "") {
|
|
32441
|
+
recipients: Joi77.any().optional().allow(null, "").custom((value2, helpers) => {
|
|
32442
|
+
if (!value2 || value2 === "")
|
|
32376
32443
|
return [];
|
|
32377
|
-
|
|
32378
|
-
let parsed = [];
|
|
32444
|
+
let parsed;
|
|
32379
32445
|
if (Array.isArray(value2)) {
|
|
32380
32446
|
parsed = value2;
|
|
32381
|
-
} else if (typeof value2 === "string") {
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
32386
|
-
return helpers.error("any.
|
|
32447
|
+
} else if (typeof value2 === "string" && value2.trim().startsWith("[")) {
|
|
32448
|
+
try {
|
|
32449
|
+
const result = JSON.parse(value2);
|
|
32450
|
+
parsed = Array.isArray(result) ? result : [value2];
|
|
32451
|
+
} catch {
|
|
32452
|
+
return helpers.error("any.invalid");
|
|
32387
32453
|
}
|
|
32454
|
+
} else {
|
|
32455
|
+
parsed = [value2];
|
|
32388
32456
|
}
|
|
32457
|
+
const validValues = Object.values(BulletinRecipient);
|
|
32458
|
+
const isValid = parsed.every(
|
|
32459
|
+
(r) => validValues.includes(r)
|
|
32460
|
+
);
|
|
32461
|
+
if (!isValid)
|
|
32462
|
+
return helpers.error("any.invalid");
|
|
32389
32463
|
return parsed;
|
|
32390
32464
|
}).messages({
|
|
32391
|
-
"any.
|
|
32465
|
+
"any.invalid": `Recipients must be one of: ${Object.values(
|
|
32392
32466
|
BulletinRecipient
|
|
32393
32467
|
).join(", ")}`
|
|
32394
|
-
})
|
|
32468
|
+
}),
|
|
32469
|
+
expiration: Joi77.string().valid("yes", "no").optional().allow("", null)
|
|
32395
32470
|
});
|
|
32396
32471
|
const { error, value } = validation.validate(req.query, {
|
|
32397
32472
|
abortEarly: false
|
|
@@ -32402,7 +32477,17 @@ function useBulletinBoardController() {
|
|
|
32402
32477
|
next(new BadRequestError128(messages));
|
|
32403
32478
|
return;
|
|
32404
32479
|
}
|
|
32405
|
-
const {
|
|
32480
|
+
const {
|
|
32481
|
+
search,
|
|
32482
|
+
page,
|
|
32483
|
+
limit,
|
|
32484
|
+
site,
|
|
32485
|
+
status,
|
|
32486
|
+
recipients,
|
|
32487
|
+
sort,
|
|
32488
|
+
order,
|
|
32489
|
+
expiration
|
|
32490
|
+
} = value;
|
|
32406
32491
|
const sortObj = {
|
|
32407
32492
|
[sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
|
|
32408
32493
|
};
|
|
@@ -32414,7 +32499,8 @@ function useBulletinBoardController() {
|
|
|
32414
32499
|
sort: sortObj,
|
|
32415
32500
|
site,
|
|
32416
32501
|
status,
|
|
32417
|
-
recipients
|
|
32502
|
+
recipients,
|
|
32503
|
+
expiration
|
|
32418
32504
|
});
|
|
32419
32505
|
res.status(200).json(data);
|
|
32420
32506
|
return;
|
|
@@ -40689,7 +40775,9 @@ function useBulletinVideoRepo() {
|
|
|
40689
40775
|
page = 1,
|
|
40690
40776
|
limit = 10,
|
|
40691
40777
|
sort = {},
|
|
40692
|
-
site = ""
|
|
40778
|
+
site = "",
|
|
40779
|
+
startDate,
|
|
40780
|
+
endDate
|
|
40693
40781
|
}, session) {
|
|
40694
40782
|
page = page > 0 ? page - 1 : 0;
|
|
40695
40783
|
try {
|
|
@@ -40697,10 +40785,33 @@ function useBulletinVideoRepo() {
|
|
|
40697
40785
|
} catch (error) {
|
|
40698
40786
|
throw new BadRequestError150("Invalid site ID format.");
|
|
40699
40787
|
}
|
|
40788
|
+
let dateExpr = {};
|
|
40789
|
+
if (startDate && endDate) {
|
|
40790
|
+
const startingDate = new Date(startDate);
|
|
40791
|
+
startingDate.setUTCHours(0, 0, 0, 0);
|
|
40792
|
+
const endingDate = new Date(endDate);
|
|
40793
|
+
endingDate.setUTCHours(23, 59, 59, 999);
|
|
40794
|
+
const parsedCreatedAt = {
|
|
40795
|
+
$dateFromString: {
|
|
40796
|
+
dateString: "$createdAt",
|
|
40797
|
+
onError: /* @__PURE__ */ new Date(0),
|
|
40798
|
+
onNull: /* @__PURE__ */ new Date(0)
|
|
40799
|
+
}
|
|
40800
|
+
};
|
|
40801
|
+
dateExpr = {
|
|
40802
|
+
$expr: {
|
|
40803
|
+
$and: [
|
|
40804
|
+
{ $gte: [parsedCreatedAt, startingDate] },
|
|
40805
|
+
{ $lte: [parsedCreatedAt, endingDate] }
|
|
40806
|
+
]
|
|
40807
|
+
}
|
|
40808
|
+
};
|
|
40809
|
+
}
|
|
40700
40810
|
const query = {
|
|
40701
40811
|
site,
|
|
40702
40812
|
status: { $ne: "deleted" },
|
|
40703
|
-
...search && { $text: { $search: search } }
|
|
40813
|
+
...search && { $text: { $search: search } },
|
|
40814
|
+
...dateExpr
|
|
40704
40815
|
};
|
|
40705
40816
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
40706
40817
|
const cacheOptions = {
|
|
@@ -40709,7 +40820,9 @@ function useBulletinVideoRepo() {
|
|
|
40709
40820
|
page,
|
|
40710
40821
|
limit,
|
|
40711
40822
|
status: { $ne: "deleted" },
|
|
40712
|
-
...search && { search }
|
|
40823
|
+
...search && { search },
|
|
40824
|
+
...startDate && { startDate },
|
|
40825
|
+
...endDate && { endDate }
|
|
40713
40826
|
};
|
|
40714
40827
|
if (search) {
|
|
40715
40828
|
query.$or = [
|
|
@@ -40968,7 +41081,9 @@ function useBulletinVideoController() {
|
|
|
40968
41081
|
limit: Joi92.number().integer().min(1).max(100).allow("", null).default(10),
|
|
40969
41082
|
sort: Joi92.string().valid(...Object.values(BulletinVideoSort)).default("_id" /* ID */),
|
|
40970
41083
|
order: Joi92.string().valid(...Object.values(BulletinVideoOrder)).default("desc" /* DESC */),
|
|
40971
|
-
site: Joi92.string().hex().length(24).required()
|
|
41084
|
+
site: Joi92.string().hex().length(24).required(),
|
|
41085
|
+
startDate: Joi92.string().optional().allow("", null),
|
|
41086
|
+
endDate: Joi92.string().optional().allow("", null)
|
|
40972
41087
|
});
|
|
40973
41088
|
const { error, value } = validation.validate(req.query, {
|
|
40974
41089
|
abortEarly: false
|
|
@@ -40979,7 +41094,7 @@ function useBulletinVideoController() {
|
|
|
40979
41094
|
next(new BadRequestError151(messages));
|
|
40980
41095
|
return;
|
|
40981
41096
|
}
|
|
40982
|
-
const { search, page, limit, site, sort, order } = value;
|
|
41097
|
+
const { search, page, limit, site, sort, order, startDate, endDate } = value;
|
|
40983
41098
|
const sortObj = {
|
|
40984
41099
|
[sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
|
|
40985
41100
|
};
|
|
@@ -40989,7 +41104,9 @@ function useBulletinVideoController() {
|
|
|
40989
41104
|
page,
|
|
40990
41105
|
limit,
|
|
40991
41106
|
sort: sortObj,
|
|
40992
|
-
site
|
|
41107
|
+
site,
|
|
41108
|
+
startDate,
|
|
41109
|
+
endDate
|
|
40993
41110
|
});
|
|
40994
41111
|
res.status(200).json(data);
|
|
40995
41112
|
return;
|