@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/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -382,7 +382,7 @@ declare function useVerificationRepo(): {
|
|
|
382
382
|
createTextIndex: () => Promise<void>;
|
|
383
383
|
add: (value: TVerification, session?: ClientSession) => Promise<ObjectId>;
|
|
384
384
|
getById: (_id: string | ObjectId) => Promise<TVerification | null>;
|
|
385
|
-
getVerifications: ({ search, page, limit, sort, status, app, type, email, }: {
|
|
385
|
+
getVerifications: ({ search, page, limit, sort, status, app, type, email, siteId, orgId, }: {
|
|
386
386
|
search?: string | undefined;
|
|
387
387
|
page?: number | undefined;
|
|
388
388
|
limit?: number | undefined;
|
|
@@ -391,6 +391,8 @@ declare function useVerificationRepo(): {
|
|
|
391
391
|
app?: string | undefined;
|
|
392
392
|
type?: Record<string, any> | undefined;
|
|
393
393
|
email?: string | undefined;
|
|
394
|
+
siteId?: string | undefined;
|
|
395
|
+
orgId?: string | undefined;
|
|
394
396
|
}) => Promise<{}>;
|
|
395
397
|
getByIdByType: (type: string) => Promise<TVerification[]>;
|
|
396
398
|
updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
@@ -3861,7 +3863,7 @@ declare function MBulletinBoard(value: TBulletinBoard): {
|
|
|
3861
3863
|
declare const bulletin_boards_namespace_collection = "bulletin-boards";
|
|
3862
3864
|
declare function useBulletinBoardRepo(): {
|
|
3863
3865
|
add: (value: TBulletinBoard, session?: ClientSession) => Promise<ObjectId>;
|
|
3864
|
-
getAll: ({ search, page, limit, sort, site, status, recipients, }: {
|
|
3866
|
+
getAll: ({ search, page, limit, sort, site, status, recipients, expiration, }: {
|
|
3865
3867
|
search?: string | undefined;
|
|
3866
3868
|
page?: number | undefined;
|
|
3867
3869
|
limit?: number | undefined;
|
|
@@ -3869,6 +3871,7 @@ declare function useBulletinBoardRepo(): {
|
|
|
3869
3871
|
site: string | ObjectId;
|
|
3870
3872
|
status: string;
|
|
3871
3873
|
recipients: Array<string>;
|
|
3874
|
+
expiration?: "yes" | "no" | undefined;
|
|
3872
3875
|
}, session?: ClientSession) => Promise<{
|
|
3873
3876
|
items: any[];
|
|
3874
3877
|
pages: number;
|
|
@@ -4986,12 +4989,14 @@ declare function MBulletinVideo(value: TBulletinVideo): {
|
|
|
4986
4989
|
|
|
4987
4990
|
declare function useBulletinVideoRepo(): {
|
|
4988
4991
|
add: (value: TBulletinVideo, session?: ClientSession) => Promise<ObjectId>;
|
|
4989
|
-
getAll: ({ search, page, limit, sort, site, }: {
|
|
4992
|
+
getAll: ({ search, page, limit, sort, site, startDate, endDate, }: {
|
|
4990
4993
|
search?: string | undefined;
|
|
4991
4994
|
page?: number | undefined;
|
|
4992
4995
|
limit?: number | undefined;
|
|
4993
4996
|
sort?: Record<string, any> | undefined;
|
|
4994
4997
|
site: string | ObjectId;
|
|
4998
|
+
startDate?: string | undefined;
|
|
4999
|
+
endDate?: string | undefined;
|
|
4995
5000
|
}, session?: ClientSession) => Promise<{
|
|
4996
5001
|
items: any[];
|
|
4997
5002
|
pages: number;
|
package/dist/index.js
CHANGED
|
@@ -4301,7 +4301,9 @@ function useVerificationRepo() {
|
|
|
4301
4301
|
status = "active",
|
|
4302
4302
|
app = "",
|
|
4303
4303
|
type = {},
|
|
4304
|
-
email = ""
|
|
4304
|
+
email = "",
|
|
4305
|
+
siteId = "",
|
|
4306
|
+
orgId = ""
|
|
4305
4307
|
}) {
|
|
4306
4308
|
page = page > 0 ? page - 1 : 0;
|
|
4307
4309
|
const query = { status };
|
|
@@ -4328,6 +4330,24 @@ function useVerificationRepo() {
|
|
|
4328
4330
|
query.email = email;
|
|
4329
4331
|
cacheOptions.email = email;
|
|
4330
4332
|
}
|
|
4333
|
+
if (siteId) {
|
|
4334
|
+
const siteCandidates = [siteId];
|
|
4335
|
+
try {
|
|
4336
|
+
siteCandidates.push(new import_mongodb13.ObjectId(siteId));
|
|
4337
|
+
} catch {
|
|
4338
|
+
}
|
|
4339
|
+
query["metadata.siteId"] = { $in: siteCandidates };
|
|
4340
|
+
cacheOptions.siteId = siteId;
|
|
4341
|
+
}
|
|
4342
|
+
if (orgId) {
|
|
4343
|
+
const orgCandidates = [orgId];
|
|
4344
|
+
try {
|
|
4345
|
+
orgCandidates.push(new import_mongodb13.ObjectId(orgId));
|
|
4346
|
+
} catch {
|
|
4347
|
+
}
|
|
4348
|
+
query["metadata.org"] = { $in: orgCandidates };
|
|
4349
|
+
cacheOptions.orgId = orgId;
|
|
4350
|
+
}
|
|
4331
4351
|
const cacheKey = (0, import_node_server_utils15.makeCacheKey)(namespace_collection, cacheOptions);
|
|
4332
4352
|
const cachedData = await getCache(cacheKey);
|
|
4333
4353
|
if (cachedData) {
|
|
@@ -8547,7 +8567,10 @@ function useVerificationController() {
|
|
|
8547
8567
|
status: import_joi16.default.string().required(),
|
|
8548
8568
|
app: import_joi16.default.string().optional().allow("", null),
|
|
8549
8569
|
type: import_joi16.default.alternatives().try(import_joi16.default.string(), import_joi16.default.array().items(import_joi16.default.string())).optional().allow("", null),
|
|
8550
|
-
email: import_joi16.default.string().optional().allow("", null)
|
|
8570
|
+
email: import_joi16.default.string().optional().allow("", null),
|
|
8571
|
+
siteId: import_joi16.default.string().hex().optional().allow("", null),
|
|
8572
|
+
orgId: import_joi16.default.string().hex().optional().allow("", null),
|
|
8573
|
+
limit: import_joi16.default.number().integer().min(1).allow("", null).default(10)
|
|
8551
8574
|
});
|
|
8552
8575
|
const query = { ...req.query };
|
|
8553
8576
|
const { error } = validation.validate(query);
|
|
@@ -8561,6 +8584,9 @@ function useVerificationController() {
|
|
|
8561
8584
|
const status = req.query.status ?? "pending";
|
|
8562
8585
|
const app = req.query.app ?? "";
|
|
8563
8586
|
const email = req.query.email ?? "";
|
|
8587
|
+
const siteId = req.query.siteId ?? "";
|
|
8588
|
+
const orgId = req.query.orgId ?? "";
|
|
8589
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
8564
8590
|
const type = req.query.type ? String(req.query.type).split(",") : "";
|
|
8565
8591
|
const typeObj = {};
|
|
8566
8592
|
if (type && Array.isArray(type) && type.length) {
|
|
@@ -8575,7 +8601,10 @@ function useVerificationController() {
|
|
|
8575
8601
|
status,
|
|
8576
8602
|
app,
|
|
8577
8603
|
type: typeObj,
|
|
8578
|
-
email
|
|
8604
|
+
email,
|
|
8605
|
+
siteId,
|
|
8606
|
+
orgId,
|
|
8607
|
+
limit
|
|
8579
8608
|
});
|
|
8580
8609
|
res.json(data);
|
|
8581
8610
|
return;
|
|
@@ -12260,6 +12289,7 @@ function useServiceProviderRepo() {
|
|
|
12260
12289
|
throw new import_node_server_utils56.BadRequestError("Invalid site ID format.");
|
|
12261
12290
|
}
|
|
12262
12291
|
}
|
|
12292
|
+
cacheOptions.membersLookup = "1";
|
|
12263
12293
|
const cacheKey = (0, import_node_server_utils56.makeCacheKey)(namespace_collection, cacheOptions);
|
|
12264
12294
|
const cachedData = await getCache(cacheKey);
|
|
12265
12295
|
if (cachedData) {
|
|
@@ -12275,7 +12305,7 @@ function useServiceProviderRepo() {
|
|
|
12275
12305
|
localField: "serviceProviderOrgId",
|
|
12276
12306
|
foreignField: "_id",
|
|
12277
12307
|
as: "organization",
|
|
12278
|
-
pipeline: [{ $project: { nature: 1 } }]
|
|
12308
|
+
pipeline: [{ $project: { nature: 1, email: 1 } }]
|
|
12279
12309
|
}
|
|
12280
12310
|
},
|
|
12281
12311
|
{
|
|
@@ -12284,17 +12314,50 @@ function useServiceProviderRepo() {
|
|
|
12284
12314
|
preserveNullAndEmptyArrays: true
|
|
12285
12315
|
}
|
|
12286
12316
|
},
|
|
12317
|
+
{
|
|
12318
|
+
$lookup: {
|
|
12319
|
+
from: "members",
|
|
12320
|
+
let: { spOrgId: "$serviceProviderOrgId" },
|
|
12321
|
+
pipeline: [
|
|
12322
|
+
{
|
|
12323
|
+
$match: {
|
|
12324
|
+
$expr: { $eq: ["$org", "$$spOrgId"] },
|
|
12325
|
+
status: "active"
|
|
12326
|
+
}
|
|
12327
|
+
},
|
|
12328
|
+
{ $count: "c" }
|
|
12329
|
+
],
|
|
12330
|
+
as: "_memberCount"
|
|
12331
|
+
}
|
|
12332
|
+
},
|
|
12287
12333
|
{
|
|
12288
12334
|
$project: {
|
|
12289
12335
|
name: 1,
|
|
12290
12336
|
type: 1,
|
|
12337
|
+
email: {
|
|
12338
|
+
$cond: {
|
|
12339
|
+
if: {
|
|
12340
|
+
$gt: [{ $strLenCP: { $ifNull: ["$email", ""] } }, 0]
|
|
12341
|
+
},
|
|
12342
|
+
then: "$email",
|
|
12343
|
+
else: { $ifNull: ["$organization.email", ""] }
|
|
12344
|
+
}
|
|
12345
|
+
},
|
|
12291
12346
|
nature: "$organization.nature",
|
|
12292
12347
|
orgId: 1,
|
|
12293
12348
|
siteId: 1,
|
|
12294
12349
|
siteName: 1,
|
|
12295
12350
|
serviceProviderOrgId: 1,
|
|
12296
12351
|
status: 1,
|
|
12297
|
-
category: 1
|
|
12352
|
+
category: 1,
|
|
12353
|
+
members: {
|
|
12354
|
+
$let: {
|
|
12355
|
+
vars: {
|
|
12356
|
+
mc: { $arrayElemAt: ["$_memberCount", 0] }
|
|
12357
|
+
},
|
|
12358
|
+
in: { $ifNull: ["$$mc.c", 0] }
|
|
12359
|
+
}
|
|
12360
|
+
}
|
|
12298
12361
|
}
|
|
12299
12362
|
},
|
|
12300
12363
|
{ $sort: sort },
|
|
@@ -31979,7 +32042,8 @@ function useBulletinBoardRepo() {
|
|
|
31979
32042
|
sort = {},
|
|
31980
32043
|
site = "",
|
|
31981
32044
|
status = "active",
|
|
31982
|
-
recipients = []
|
|
32045
|
+
recipients = [],
|
|
32046
|
+
expiration
|
|
31983
32047
|
}, session) {
|
|
31984
32048
|
page = page > 0 ? page - 1 : 0;
|
|
31985
32049
|
try {
|
|
@@ -31990,8 +32054,13 @@ function useBulletinBoardRepo() {
|
|
|
31990
32054
|
const query = {
|
|
31991
32055
|
site,
|
|
31992
32056
|
status,
|
|
31993
|
-
...search && {
|
|
31994
|
-
|
|
32057
|
+
...search && {
|
|
32058
|
+
$or: [{ title: { $regex: search, $options: "i" } }]
|
|
32059
|
+
},
|
|
32060
|
+
...recipients?.length && { recipients: { $all: recipients } },
|
|
32061
|
+
...expiration !== void 0 && {
|
|
32062
|
+
noExpiration: expiration === "yes"
|
|
32063
|
+
}
|
|
31995
32064
|
};
|
|
31996
32065
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
31997
32066
|
const cacheOptions = {
|
|
@@ -32001,7 +32070,8 @@ function useBulletinBoardRepo() {
|
|
|
32001
32070
|
page,
|
|
32002
32071
|
limit,
|
|
32003
32072
|
...search && { search },
|
|
32004
|
-
...recipients?.length && { recipients: recipients.sort().join(",") }
|
|
32073
|
+
...recipients?.length && { recipients: recipients.sort().join(",") },
|
|
32074
|
+
...expiration !== void 0 && { expiration }
|
|
32005
32075
|
};
|
|
32006
32076
|
const cacheKey = (0, import_node_server_utils136.makeCacheKey)(
|
|
32007
32077
|
bulletin_boards_namespace_collection,
|
|
@@ -32189,7 +32259,9 @@ function useBulletinBoardRepo() {
|
|
|
32189
32259
|
{ session }
|
|
32190
32260
|
);
|
|
32191
32261
|
if (res.matchedCount === 0) {
|
|
32192
|
-
throw new import_node_server_utils136.NotFoundError(
|
|
32262
|
+
throw new import_node_server_utils136.NotFoundError(
|
|
32263
|
+
"No upcoming bulletin boards found to activate."
|
|
32264
|
+
);
|
|
32193
32265
|
}
|
|
32194
32266
|
delNamespace().then(() => {
|
|
32195
32267
|
import_node_server_utils136.logger.info(
|
|
@@ -32375,32 +32447,35 @@ function useBulletinBoardController() {
|
|
|
32375
32447
|
order: import_joi77.default.string().valid(...Object.values(BulletinOrder)).default("desc" /* DESC */),
|
|
32376
32448
|
site: import_joi77.default.string().hex().length(24).required(),
|
|
32377
32449
|
status: import_joi77.default.string().valid(...Object.values(BulletinStatus)).optional().default("active" /* ACTIVE */),
|
|
32378
|
-
recipients: import_joi77.default.
|
|
32379
|
-
|
|
32380
|
-
import_joi77.default.string().valid(...Object.values(BulletinRecipient))
|
|
32381
|
-
),
|
|
32382
|
-
import_joi77.default.string().allow("")
|
|
32383
|
-
).optional().allow(null).custom((value2, helpers) => {
|
|
32384
|
-
if (!value2 || value2 === "") {
|
|
32450
|
+
recipients: import_joi77.default.any().optional().allow(null, "").custom((value2, helpers) => {
|
|
32451
|
+
if (!value2 || value2 === "")
|
|
32385
32452
|
return [];
|
|
32386
|
-
|
|
32387
|
-
let parsed = [];
|
|
32453
|
+
let parsed;
|
|
32388
32454
|
if (Array.isArray(value2)) {
|
|
32389
32455
|
parsed = value2;
|
|
32390
|
-
} else if (typeof value2 === "string") {
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
return helpers.error("any.
|
|
32456
|
+
} else if (typeof value2 === "string" && value2.trim().startsWith("[")) {
|
|
32457
|
+
try {
|
|
32458
|
+
const result = JSON.parse(value2);
|
|
32459
|
+
parsed = Array.isArray(result) ? result : [value2];
|
|
32460
|
+
} catch {
|
|
32461
|
+
return helpers.error("any.invalid");
|
|
32396
32462
|
}
|
|
32463
|
+
} else {
|
|
32464
|
+
parsed = [value2];
|
|
32397
32465
|
}
|
|
32466
|
+
const validValues = Object.values(BulletinRecipient);
|
|
32467
|
+
const isValid = parsed.every(
|
|
32468
|
+
(r) => validValues.includes(r)
|
|
32469
|
+
);
|
|
32470
|
+
if (!isValid)
|
|
32471
|
+
return helpers.error("any.invalid");
|
|
32398
32472
|
return parsed;
|
|
32399
32473
|
}).messages({
|
|
32400
|
-
"any.
|
|
32474
|
+
"any.invalid": `Recipients must be one of: ${Object.values(
|
|
32401
32475
|
BulletinRecipient
|
|
32402
32476
|
).join(", ")}`
|
|
32403
|
-
})
|
|
32477
|
+
}),
|
|
32478
|
+
expiration: import_joi77.default.string().valid("yes", "no").optional().allow("", null)
|
|
32404
32479
|
});
|
|
32405
32480
|
const { error, value } = validation.validate(req.query, {
|
|
32406
32481
|
abortEarly: false
|
|
@@ -32411,7 +32486,17 @@ function useBulletinBoardController() {
|
|
|
32411
32486
|
next(new import_node_server_utils138.BadRequestError(messages));
|
|
32412
32487
|
return;
|
|
32413
32488
|
}
|
|
32414
|
-
const {
|
|
32489
|
+
const {
|
|
32490
|
+
search,
|
|
32491
|
+
page,
|
|
32492
|
+
limit,
|
|
32493
|
+
site,
|
|
32494
|
+
status,
|
|
32495
|
+
recipients,
|
|
32496
|
+
sort,
|
|
32497
|
+
order,
|
|
32498
|
+
expiration
|
|
32499
|
+
} = value;
|
|
32415
32500
|
const sortObj = {
|
|
32416
32501
|
[sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
|
|
32417
32502
|
};
|
|
@@ -32423,7 +32508,8 @@ function useBulletinBoardController() {
|
|
|
32423
32508
|
sort: sortObj,
|
|
32424
32509
|
site,
|
|
32425
32510
|
status,
|
|
32426
|
-
recipients
|
|
32511
|
+
recipients,
|
|
32512
|
+
expiration
|
|
32427
32513
|
});
|
|
32428
32514
|
res.status(200).json(data);
|
|
32429
32515
|
return;
|
|
@@ -40619,7 +40705,9 @@ function useBulletinVideoRepo() {
|
|
|
40619
40705
|
page = 1,
|
|
40620
40706
|
limit = 10,
|
|
40621
40707
|
sort = {},
|
|
40622
|
-
site = ""
|
|
40708
|
+
site = "",
|
|
40709
|
+
startDate,
|
|
40710
|
+
endDate
|
|
40623
40711
|
}, session) {
|
|
40624
40712
|
page = page > 0 ? page - 1 : 0;
|
|
40625
40713
|
try {
|
|
@@ -40627,10 +40715,33 @@ function useBulletinVideoRepo() {
|
|
|
40627
40715
|
} catch (error) {
|
|
40628
40716
|
throw new import_node_server_utils162.BadRequestError("Invalid site ID format.");
|
|
40629
40717
|
}
|
|
40718
|
+
let dateExpr = {};
|
|
40719
|
+
if (startDate && endDate) {
|
|
40720
|
+
const startingDate = new Date(startDate);
|
|
40721
|
+
startingDate.setUTCHours(0, 0, 0, 0);
|
|
40722
|
+
const endingDate = new Date(endDate);
|
|
40723
|
+
endingDate.setUTCHours(23, 59, 59, 999);
|
|
40724
|
+
const parsedCreatedAt = {
|
|
40725
|
+
$dateFromString: {
|
|
40726
|
+
dateString: "$createdAt",
|
|
40727
|
+
onError: /* @__PURE__ */ new Date(0),
|
|
40728
|
+
onNull: /* @__PURE__ */ new Date(0)
|
|
40729
|
+
}
|
|
40730
|
+
};
|
|
40731
|
+
dateExpr = {
|
|
40732
|
+
$expr: {
|
|
40733
|
+
$and: [
|
|
40734
|
+
{ $gte: [parsedCreatedAt, startingDate] },
|
|
40735
|
+
{ $lte: [parsedCreatedAt, endingDate] }
|
|
40736
|
+
]
|
|
40737
|
+
}
|
|
40738
|
+
};
|
|
40739
|
+
}
|
|
40630
40740
|
const query = {
|
|
40631
40741
|
site,
|
|
40632
40742
|
status: { $ne: "deleted" },
|
|
40633
|
-
...search && { $text: { $search: search } }
|
|
40743
|
+
...search && { $text: { $search: search } },
|
|
40744
|
+
...dateExpr
|
|
40634
40745
|
};
|
|
40635
40746
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
40636
40747
|
const cacheOptions = {
|
|
@@ -40639,7 +40750,9 @@ function useBulletinVideoRepo() {
|
|
|
40639
40750
|
page,
|
|
40640
40751
|
limit,
|
|
40641
40752
|
status: { $ne: "deleted" },
|
|
40642
|
-
...search && { search }
|
|
40753
|
+
...search && { search },
|
|
40754
|
+
...startDate && { startDate },
|
|
40755
|
+
...endDate && { endDate }
|
|
40643
40756
|
};
|
|
40644
40757
|
if (search) {
|
|
40645
40758
|
query.$or = [
|
|
@@ -40898,7 +41011,9 @@ function useBulletinVideoController() {
|
|
|
40898
41011
|
limit: import_joi92.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
40899
41012
|
sort: import_joi92.default.string().valid(...Object.values(BulletinVideoSort)).default("_id" /* ID */),
|
|
40900
41013
|
order: import_joi92.default.string().valid(...Object.values(BulletinVideoOrder)).default("desc" /* DESC */),
|
|
40901
|
-
site: import_joi92.default.string().hex().length(24).required()
|
|
41014
|
+
site: import_joi92.default.string().hex().length(24).required(),
|
|
41015
|
+
startDate: import_joi92.default.string().optional().allow("", null),
|
|
41016
|
+
endDate: import_joi92.default.string().optional().allow("", null)
|
|
40902
41017
|
});
|
|
40903
41018
|
const { error, value } = validation.validate(req.query, {
|
|
40904
41019
|
abortEarly: false
|
|
@@ -40909,7 +41024,7 @@ function useBulletinVideoController() {
|
|
|
40909
41024
|
next(new import_node_server_utils164.BadRequestError(messages));
|
|
40910
41025
|
return;
|
|
40911
41026
|
}
|
|
40912
|
-
const { search, page, limit, site, sort, order } = value;
|
|
41027
|
+
const { search, page, limit, site, sort, order, startDate, endDate } = value;
|
|
40913
41028
|
const sortObj = {
|
|
40914
41029
|
[sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
|
|
40915
41030
|
};
|
|
@@ -40919,7 +41034,9 @@ function useBulletinVideoController() {
|
|
|
40919
41034
|
page,
|
|
40920
41035
|
limit,
|
|
40921
41036
|
sort: sortObj,
|
|
40922
|
-
site
|
|
41037
|
+
site,
|
|
41038
|
+
startDate,
|
|
41039
|
+
endDate
|
|
40923
41040
|
});
|
|
40924
41041
|
res.status(200).json(data);
|
|
40925
41042
|
return;
|