@7365admin1/core 2.68.0 → 2.69.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 +44 -17
- package/dist/index.js +467 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +467 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3705,6 +3705,11 @@ function useAuthService() {
|
|
|
3705
3705
|
"Your account is currently suspended. Please contact support for assistance."
|
|
3706
3706
|
);
|
|
3707
3707
|
}
|
|
3708
|
+
if (user.status === "pending") {
|
|
3709
|
+
throw new BadRequestError12(
|
|
3710
|
+
"Your account is currently pending. Please contact support for assistance."
|
|
3711
|
+
);
|
|
3712
|
+
}
|
|
3708
3713
|
const isPasswordValid = await comparePassword(password, user.password);
|
|
3709
3714
|
if (!isPasswordValid) {
|
|
3710
3715
|
throw new BadRequestError12("Invalid password.");
|
|
@@ -4514,6 +4519,155 @@ function useOrgRepo() {
|
|
|
4514
4519
|
throw new InternalServerError9("Failed to update organization status.");
|
|
4515
4520
|
}
|
|
4516
4521
|
}
|
|
4522
|
+
async function getOrganizationsWithSubscription({
|
|
4523
|
+
search = "",
|
|
4524
|
+
page = 1,
|
|
4525
|
+
limit = 10,
|
|
4526
|
+
status = "active",
|
|
4527
|
+
type = "",
|
|
4528
|
+
billingCycle = ""
|
|
4529
|
+
}) {
|
|
4530
|
+
const normalizedPage = page > 0 ? page - 1 : 0;
|
|
4531
|
+
const query = {
|
|
4532
|
+
status
|
|
4533
|
+
};
|
|
4534
|
+
if (search) {
|
|
4535
|
+
query.$or = [
|
|
4536
|
+
{
|
|
4537
|
+
name: {
|
|
4538
|
+
$regex: search,
|
|
4539
|
+
$options: "i"
|
|
4540
|
+
}
|
|
4541
|
+
},
|
|
4542
|
+
{
|
|
4543
|
+
email: {
|
|
4544
|
+
$regex: search,
|
|
4545
|
+
$options: "i"
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
];
|
|
4549
|
+
}
|
|
4550
|
+
const subscriptionMatch = {};
|
|
4551
|
+
if (type) {
|
|
4552
|
+
subscriptionMatch["subscription.type"] = type;
|
|
4553
|
+
}
|
|
4554
|
+
if (billingCycle) {
|
|
4555
|
+
subscriptionMatch["subscription.billingCycle"] = billingCycle;
|
|
4556
|
+
}
|
|
4557
|
+
const lookupStage = {
|
|
4558
|
+
$lookup: {
|
|
4559
|
+
from: "subscriptions",
|
|
4560
|
+
let: {
|
|
4561
|
+
orgId: "$_id"
|
|
4562
|
+
},
|
|
4563
|
+
pipeline: [
|
|
4564
|
+
{
|
|
4565
|
+
$match: {
|
|
4566
|
+
$expr: {
|
|
4567
|
+
$eq: [
|
|
4568
|
+
"$org",
|
|
4569
|
+
"$$orgId"
|
|
4570
|
+
]
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
},
|
|
4574
|
+
{
|
|
4575
|
+
$sort: {
|
|
4576
|
+
createdAt: -1
|
|
4577
|
+
}
|
|
4578
|
+
},
|
|
4579
|
+
{
|
|
4580
|
+
$limit: 1
|
|
4581
|
+
}
|
|
4582
|
+
],
|
|
4583
|
+
as: "subscription"
|
|
4584
|
+
}
|
|
4585
|
+
};
|
|
4586
|
+
const unwindStage = {
|
|
4587
|
+
$unwind: {
|
|
4588
|
+
path: "$subscription",
|
|
4589
|
+
preserveNullAndEmptyArrays: true
|
|
4590
|
+
}
|
|
4591
|
+
};
|
|
4592
|
+
try {
|
|
4593
|
+
const pipeline = [
|
|
4594
|
+
{
|
|
4595
|
+
$match: query
|
|
4596
|
+
},
|
|
4597
|
+
lookupStage,
|
|
4598
|
+
unwindStage,
|
|
4599
|
+
...Object.keys(subscriptionMatch).length ? [
|
|
4600
|
+
{
|
|
4601
|
+
$match: subscriptionMatch
|
|
4602
|
+
}
|
|
4603
|
+
] : [],
|
|
4604
|
+
{
|
|
4605
|
+
$project: {
|
|
4606
|
+
_id: 1,
|
|
4607
|
+
name: 1,
|
|
4608
|
+
email: 1,
|
|
4609
|
+
nature: 1,
|
|
4610
|
+
description: 1,
|
|
4611
|
+
status: 1,
|
|
4612
|
+
createdAt: 1,
|
|
4613
|
+
subscription: {
|
|
4614
|
+
_id: "$subscription._id",
|
|
4615
|
+
org: "$subscription.org",
|
|
4616
|
+
type: "$subscription.type",
|
|
4617
|
+
paidSeats: "$subscription.paidSeats",
|
|
4618
|
+
currentSeats: "$subscription.currentSeats",
|
|
4619
|
+
maxSeats: "$subscription.maxSeats",
|
|
4620
|
+
billingCycle: "$subscription.billingCycle",
|
|
4621
|
+
nextBillingDate: "$subscription.nextBillingDate",
|
|
4622
|
+
createdAt: "$subscription.createdAt",
|
|
4623
|
+
status: "$subscription.status"
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
},
|
|
4627
|
+
{
|
|
4628
|
+
$sort: {
|
|
4629
|
+
_id: -1
|
|
4630
|
+
}
|
|
4631
|
+
},
|
|
4632
|
+
{
|
|
4633
|
+
$skip: normalizedPage * limit
|
|
4634
|
+
},
|
|
4635
|
+
{
|
|
4636
|
+
$limit: limit
|
|
4637
|
+
}
|
|
4638
|
+
];
|
|
4639
|
+
const items = await collection.aggregate(pipeline).toArray();
|
|
4640
|
+
const countPipeline = [
|
|
4641
|
+
{
|
|
4642
|
+
$match: query
|
|
4643
|
+
},
|
|
4644
|
+
lookupStage,
|
|
4645
|
+
unwindStage,
|
|
4646
|
+
...Object.keys(subscriptionMatch).length ? [
|
|
4647
|
+
{
|
|
4648
|
+
$match: subscriptionMatch
|
|
4649
|
+
}
|
|
4650
|
+
] : [],
|
|
4651
|
+
{
|
|
4652
|
+
$count: "total"
|
|
4653
|
+
}
|
|
4654
|
+
];
|
|
4655
|
+
const countResult = await collection.aggregate(countPipeline).toArray();
|
|
4656
|
+
const totalItems = countResult?.[0]?.total ?? 0;
|
|
4657
|
+
return paginate7(
|
|
4658
|
+
items,
|
|
4659
|
+
normalizedPage,
|
|
4660
|
+
limit,
|
|
4661
|
+
totalItems
|
|
4662
|
+
);
|
|
4663
|
+
} catch (error) {
|
|
4664
|
+
logger10.log({
|
|
4665
|
+
level: "error",
|
|
4666
|
+
message: `${error}`
|
|
4667
|
+
});
|
|
4668
|
+
throw error;
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4517
4671
|
return {
|
|
4518
4672
|
createIndex,
|
|
4519
4673
|
createTextIndex,
|
|
@@ -4527,7 +4681,8 @@ function useOrgRepo() {
|
|
|
4527
4681
|
updateFieldById,
|
|
4528
4682
|
updateStatusById,
|
|
4529
4683
|
deleteById,
|
|
4530
|
-
getOrgsByEmail
|
|
4684
|
+
getOrgsByEmail,
|
|
4685
|
+
getOrganizationsWithSubscription
|
|
4531
4686
|
};
|
|
4532
4687
|
}
|
|
4533
4688
|
|
|
@@ -5449,6 +5604,44 @@ function useVerificationRepoV2() {
|
|
|
5449
5604
|
throw new InternalServerError11("Failed to count pending invitations.");
|
|
5450
5605
|
}
|
|
5451
5606
|
}
|
|
5607
|
+
async function getPendingVerificationByEmail(email) {
|
|
5608
|
+
try {
|
|
5609
|
+
return await collection.findOne(
|
|
5610
|
+
{
|
|
5611
|
+
email,
|
|
5612
|
+
status: "pending" /* PENDING */,
|
|
5613
|
+
type: "user-sign-up" /* USER_SIGN_UP */
|
|
5614
|
+
},
|
|
5615
|
+
{
|
|
5616
|
+
sort: { createdAt: -1 }
|
|
5617
|
+
}
|
|
5618
|
+
);
|
|
5619
|
+
} catch (error) {
|
|
5620
|
+
throw new InternalServerError11(
|
|
5621
|
+
"Failed to retrieve verification."
|
|
5622
|
+
);
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
async function updateVerificationCodeById(_id, verificationCode, expireAt, session) {
|
|
5626
|
+
try {
|
|
5627
|
+
_id = new ObjectId18(_id);
|
|
5628
|
+
return await collection.updateOne(
|
|
5629
|
+
{ _id },
|
|
5630
|
+
{
|
|
5631
|
+
$set: {
|
|
5632
|
+
"metadata.verificationCode": verificationCode,
|
|
5633
|
+
expireAt,
|
|
5634
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5635
|
+
}
|
|
5636
|
+
},
|
|
5637
|
+
{ session }
|
|
5638
|
+
);
|
|
5639
|
+
} catch (error) {
|
|
5640
|
+
throw new InternalServerError11(
|
|
5641
|
+
"Failed to update verification code."
|
|
5642
|
+
);
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5452
5645
|
return {
|
|
5453
5646
|
createIndex,
|
|
5454
5647
|
createTextIndex,
|
|
@@ -5458,7 +5651,9 @@ function useVerificationRepoV2() {
|
|
|
5458
5651
|
getVerificationById,
|
|
5459
5652
|
getVerifications,
|
|
5460
5653
|
updateStatusById,
|
|
5461
|
-
countPendingOrgInvites
|
|
5654
|
+
countPendingOrgInvites,
|
|
5655
|
+
getPendingVerificationByEmail,
|
|
5656
|
+
updateVerificationCodeById
|
|
5462
5657
|
};
|
|
5463
5658
|
}
|
|
5464
5659
|
|
|
@@ -8836,7 +9031,7 @@ function useOrgController() {
|
|
|
8836
9031
|
import Joi19 from "joi";
|
|
8837
9032
|
import { BadRequestError as BadRequestError34, logger as logger26 } from "@7365admin1/node-server-utils";
|
|
8838
9033
|
function useOrgControllerV2() {
|
|
8839
|
-
const { getAll: _getAll } = useOrgRepo();
|
|
9034
|
+
const { getAll: _getAll, getOrganizationsWithSubscription: _getOrganizationsWithSubscription } = useOrgRepo();
|
|
8840
9035
|
async function getAll(req, res, next) {
|
|
8841
9036
|
const validation = Joi19.object({
|
|
8842
9037
|
search: Joi19.string().optional().allow("", null),
|
|
@@ -8876,8 +9071,43 @@ function useOrgControllerV2() {
|
|
|
8876
9071
|
return;
|
|
8877
9072
|
}
|
|
8878
9073
|
}
|
|
9074
|
+
async function getOrganizationsWithSubscription(req, res, next) {
|
|
9075
|
+
const validation = Joi19.object({
|
|
9076
|
+
search: Joi19.string().optional().allow("", null),
|
|
9077
|
+
page: Joi19.number().integer().min(1).default(1),
|
|
9078
|
+
limit: Joi19.number().integer().min(1).max(100).default(10),
|
|
9079
|
+
status: Joi19.string().trim().valid("active", "suspended", "deleted").default("active"),
|
|
9080
|
+
type: Joi19.string().optional().allow("", null),
|
|
9081
|
+
billingCycle: Joi19.string().optional().allow("", null)
|
|
9082
|
+
});
|
|
9083
|
+
const { error, value } = validation.validate(
|
|
9084
|
+
req.query,
|
|
9085
|
+
{
|
|
9086
|
+
convert: true,
|
|
9087
|
+
stripUnknown: true
|
|
9088
|
+
}
|
|
9089
|
+
);
|
|
9090
|
+
if (error) {
|
|
9091
|
+
next(new BadRequestError34(error.message));
|
|
9092
|
+
return;
|
|
9093
|
+
}
|
|
9094
|
+
try {
|
|
9095
|
+
const data = await _getOrganizationsWithSubscription({
|
|
9096
|
+
search: value.search ?? "",
|
|
9097
|
+
page: value.page ?? 1,
|
|
9098
|
+
limit: value.limit ?? 10,
|
|
9099
|
+
status: value.status ?? "active",
|
|
9100
|
+
type: value.type ?? "",
|
|
9101
|
+
billingCycle: value.billingCycle ?? ""
|
|
9102
|
+
});
|
|
9103
|
+
res.json(data);
|
|
9104
|
+
} catch (error2) {
|
|
9105
|
+
next(error2);
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
8879
9108
|
return {
|
|
8880
|
-
getAll
|
|
9109
|
+
getAll,
|
|
9110
|
+
getOrganizationsWithSubscription
|
|
8881
9111
|
};
|
|
8882
9112
|
}
|
|
8883
9113
|
|
|
@@ -31832,6 +32062,7 @@ function useDocumentManagementRepo() {
|
|
|
31832
32062
|
async function createIndex() {
|
|
31833
32063
|
try {
|
|
31834
32064
|
await collection.createIndexes([
|
|
32065
|
+
{ key: { type: 1 } },
|
|
31835
32066
|
{ key: { site: 1 } },
|
|
31836
32067
|
{ key: { parentId: 1 } }
|
|
31837
32068
|
]);
|
|
@@ -31874,8 +32105,7 @@ function useDocumentManagementRepo() {
|
|
|
31874
32105
|
search = "",
|
|
31875
32106
|
page = 1,
|
|
31876
32107
|
limit = 10,
|
|
31877
|
-
|
|
31878
|
-
status = "active",
|
|
32108
|
+
type = "all",
|
|
31879
32109
|
org = "",
|
|
31880
32110
|
site = "",
|
|
31881
32111
|
parentId = ""
|
|
@@ -31886,17 +32116,18 @@ function useDocumentManagementRepo() {
|
|
|
31886
32116
|
} catch (error) {
|
|
31887
32117
|
throw new BadRequestError126("Invalid site ID format.");
|
|
31888
32118
|
}
|
|
31889
|
-
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
31890
32119
|
const cacheOptions = {
|
|
31891
32120
|
page,
|
|
31892
32121
|
limit,
|
|
31893
|
-
|
|
31894
|
-
site: site?.toString(),
|
|
31895
|
-
sort: JSON.stringify(sort)
|
|
32122
|
+
site: site?.toString()
|
|
31896
32123
|
};
|
|
31897
32124
|
const query = {
|
|
31898
|
-
|
|
32125
|
+
status: { $ne: "deleted" }
|
|
31899
32126
|
};
|
|
32127
|
+
if (type && type !== "all") {
|
|
32128
|
+
query.type = type;
|
|
32129
|
+
cacheOptions.type = type;
|
|
32130
|
+
}
|
|
31900
32131
|
if (org) {
|
|
31901
32132
|
query.org = new ObjectId79(org);
|
|
31902
32133
|
cacheOptions.org = org.toString();
|
|
@@ -31927,19 +32158,17 @@ function useDocumentManagementRepo() {
|
|
|
31927
32158
|
try {
|
|
31928
32159
|
const items = await collection.aggregate([
|
|
31929
32160
|
{ $match: query },
|
|
31930
|
-
{ $sort:
|
|
31931
|
-
{ $skip: page * limit },
|
|
31932
|
-
{ $limit: limit },
|
|
32161
|
+
{ $sort: { _id: -1 } },
|
|
31933
32162
|
{
|
|
31934
32163
|
$project: {
|
|
32164
|
+
parentId: 1,
|
|
31935
32165
|
name: 1,
|
|
31936
32166
|
type: 1,
|
|
31937
|
-
|
|
31938
|
-
attachment: 1,
|
|
31939
|
-
parentId: 1,
|
|
31940
|
-
remarks: 1,
|
|
32167
|
+
size: 1,
|
|
31941
32168
|
createdAt: 1,
|
|
31942
|
-
updatedAt: 1
|
|
32169
|
+
updatedAt: 1,
|
|
32170
|
+
remarks: 1,
|
|
32171
|
+
attachment: 1
|
|
31943
32172
|
}
|
|
31944
32173
|
}
|
|
31945
32174
|
]).toArray();
|
|
@@ -32219,13 +32448,12 @@ function useDocumentManagementController() {
|
|
|
32219
32448
|
search: Joi76.string().optional().allow("", null),
|
|
32220
32449
|
page: Joi76.number().integer().min(1).allow("", null).default(1),
|
|
32221
32450
|
limit: Joi76.number().integer().min(1).max(100).allow("", null).default(10),
|
|
32222
|
-
|
|
32451
|
+
type: Joi76.string().valid("all", "pdf", "csv", "doc").optional().default("all"),
|
|
32223
32452
|
org: Joi76.string().hex().optional().allow("", null),
|
|
32224
32453
|
site: Joi76.string().hex().optional().allow("", null),
|
|
32225
32454
|
parentId: Joi76.string().hex().optional().allow("", null)
|
|
32226
32455
|
});
|
|
32227
32456
|
const query = { ...req.query };
|
|
32228
|
-
query.status = req.query.status;
|
|
32229
32457
|
const { error } = validation.validate(query);
|
|
32230
32458
|
if (error) {
|
|
32231
32459
|
logger106.log({ level: "error", message: error.message });
|
|
@@ -32235,7 +32463,7 @@ function useDocumentManagementController() {
|
|
|
32235
32463
|
const search = req.query.search ?? "";
|
|
32236
32464
|
const page = parseInt(req.query.page ?? "1");
|
|
32237
32465
|
const limit = parseInt(req.query.limit ?? "10");
|
|
32238
|
-
const
|
|
32466
|
+
const type = req.query.type ?? "all";
|
|
32239
32467
|
const org = req.query.org ?? "";
|
|
32240
32468
|
const site = req.query.site ?? "";
|
|
32241
32469
|
const parentId = req.query.parentId ?? "";
|
|
@@ -32244,7 +32472,7 @@ function useDocumentManagementController() {
|
|
|
32244
32472
|
search,
|
|
32245
32473
|
page,
|
|
32246
32474
|
limit,
|
|
32247
|
-
|
|
32475
|
+
type,
|
|
32248
32476
|
org,
|
|
32249
32477
|
site,
|
|
32250
32478
|
parentId
|
|
@@ -32830,8 +33058,12 @@ function useBulletinBoardService() {
|
|
|
32830
33058
|
async function add(value) {
|
|
32831
33059
|
const session = useAtlas68.getClient()?.startSession();
|
|
32832
33060
|
session?.startTransaction();
|
|
32833
|
-
if (value.startDate
|
|
32834
|
-
|
|
33061
|
+
if (value.startDate) {
|
|
33062
|
+
const today = /* @__PURE__ */ new Date();
|
|
33063
|
+
today.setHours(23, 59, 0, 0);
|
|
33064
|
+
if (new Date(value.startDate) > today) {
|
|
33065
|
+
value.status = "upcoming" /* UPCOMING */;
|
|
33066
|
+
}
|
|
32835
33067
|
}
|
|
32836
33068
|
try {
|
|
32837
33069
|
const bulletinFiles = value?.file ?? [];
|
|
@@ -32862,6 +33094,15 @@ function useBulletinBoardService() {
|
|
|
32862
33094
|
async function updateBulletinBoardById(id, value) {
|
|
32863
33095
|
const session = useAtlas68.getClient()?.startSession();
|
|
32864
33096
|
session?.startTransaction();
|
|
33097
|
+
if (value.startDate) {
|
|
33098
|
+
const today = /* @__PURE__ */ new Date();
|
|
33099
|
+
today.setHours(23, 59, 0, 0);
|
|
33100
|
+
if (new Date(value.startDate) > today) {
|
|
33101
|
+
value.status = "upcoming" /* UPCOMING */;
|
|
33102
|
+
} else {
|
|
33103
|
+
value.status = "active" /* ACTIVE */;
|
|
33104
|
+
}
|
|
33105
|
+
}
|
|
32865
33106
|
try {
|
|
32866
33107
|
await _updateBulletinBoardById(id, value, session);
|
|
32867
33108
|
await session?.commitTransaction();
|
|
@@ -39174,6 +39415,33 @@ function UseAccessManagementRepo() {
|
|
|
39174
39415
|
throw new Error(error.message);
|
|
39175
39416
|
}
|
|
39176
39417
|
}
|
|
39418
|
+
async function userAccessCardsRepo({
|
|
39419
|
+
userId,
|
|
39420
|
+
siteId,
|
|
39421
|
+
isLiftCard
|
|
39422
|
+
}) {
|
|
39423
|
+
try {
|
|
39424
|
+
siteId = new ObjectId92(siteId);
|
|
39425
|
+
userId = new ObjectId92(userId);
|
|
39426
|
+
const query = {
|
|
39427
|
+
site: siteId,
|
|
39428
|
+
userId,
|
|
39429
|
+
isLiftCard,
|
|
39430
|
+
userType: "Visitor/Resident" /* DEFAULT */
|
|
39431
|
+
};
|
|
39432
|
+
console.log(query);
|
|
39433
|
+
const res = await collection().aggregate([
|
|
39434
|
+
{
|
|
39435
|
+
$match: {
|
|
39436
|
+
...query
|
|
39437
|
+
}
|
|
39438
|
+
}
|
|
39439
|
+
]).toArray();
|
|
39440
|
+
return res;
|
|
39441
|
+
} catch (error) {
|
|
39442
|
+
throw new Error(error.message);
|
|
39443
|
+
}
|
|
39444
|
+
}
|
|
39177
39445
|
return {
|
|
39178
39446
|
createIndexes,
|
|
39179
39447
|
createIndexForEntrypass,
|
|
@@ -39210,7 +39478,8 @@ function UseAccessManagementRepo() {
|
|
|
39210
39478
|
assignMultipleCardsRepo,
|
|
39211
39479
|
visitorCheckoutRepo,
|
|
39212
39480
|
uploadTemplateRepo,
|
|
39213
|
-
getResidentsRepo
|
|
39481
|
+
getResidentsRepo,
|
|
39482
|
+
userAccessCardsRepo
|
|
39214
39483
|
};
|
|
39215
39484
|
}
|
|
39216
39485
|
|
|
@@ -39255,7 +39524,8 @@ function useAccessManagementSvc() {
|
|
|
39255
39524
|
assignMultipleCardsRepo,
|
|
39256
39525
|
visitorCheckoutRepo,
|
|
39257
39526
|
uploadTemplateRepo,
|
|
39258
|
-
getResidentsRepo
|
|
39527
|
+
getResidentsRepo,
|
|
39528
|
+
userAccessCardsRepo
|
|
39259
39529
|
} = UseAccessManagementRepo();
|
|
39260
39530
|
const addPhysicalCardSvc = async (payload) => {
|
|
39261
39531
|
try {
|
|
@@ -39617,6 +39887,22 @@ function useAccessManagementSvc() {
|
|
|
39617
39887
|
throw new Error(err.message);
|
|
39618
39888
|
}
|
|
39619
39889
|
};
|
|
39890
|
+
const userAccessCardsSvc = async ({
|
|
39891
|
+
userId,
|
|
39892
|
+
siteId,
|
|
39893
|
+
isLiftCard
|
|
39894
|
+
}) => {
|
|
39895
|
+
try {
|
|
39896
|
+
const response = await userAccessCardsRepo({
|
|
39897
|
+
userId,
|
|
39898
|
+
siteId,
|
|
39899
|
+
isLiftCard
|
|
39900
|
+
});
|
|
39901
|
+
return response;
|
|
39902
|
+
} catch (err) {
|
|
39903
|
+
throw new Error(err.message);
|
|
39904
|
+
}
|
|
39905
|
+
};
|
|
39620
39906
|
return {
|
|
39621
39907
|
addPhysicalCardSvc,
|
|
39622
39908
|
addNonPhysicalCardSvc,
|
|
@@ -39656,7 +39942,8 @@ function useAccessManagementSvc() {
|
|
|
39656
39942
|
assignMultipleCardsSvc,
|
|
39657
39943
|
visitorCheckoutSvc,
|
|
39658
39944
|
uploadTemplateSvc,
|
|
39659
|
-
getResidentsSvc
|
|
39945
|
+
getResidentsSvc,
|
|
39946
|
+
userAccessCardsSvc
|
|
39660
39947
|
};
|
|
39661
39948
|
}
|
|
39662
39949
|
|
|
@@ -39701,7 +39988,8 @@ function useAccessManagementController() {
|
|
|
39701
39988
|
assignMultipleCardsSvc,
|
|
39702
39989
|
visitorCheckoutSvc,
|
|
39703
39990
|
uploadTemplateSvc,
|
|
39704
|
-
getResidentsSvc
|
|
39991
|
+
getResidentsSvc,
|
|
39992
|
+
userAccessCardsSvc
|
|
39705
39993
|
} = useAccessManagementSvc();
|
|
39706
39994
|
const addPhysicalCard = async (req, res) => {
|
|
39707
39995
|
try {
|
|
@@ -40725,6 +41013,32 @@ function useAccessManagementController() {
|
|
|
40725
41013
|
});
|
|
40726
41014
|
}
|
|
40727
41015
|
};
|
|
41016
|
+
const userAccessCards = async (req, res) => {
|
|
41017
|
+
try {
|
|
41018
|
+
const { userId, siteId, isLiftCard } = req.query;
|
|
41019
|
+
const schema2 = Joi87.object({
|
|
41020
|
+
isLiftCard: Joi87.string().valid("true", "false").required(),
|
|
41021
|
+
siteId: Joi87.string().hex().required(),
|
|
41022
|
+
userId: Joi87.string().hex().required()
|
|
41023
|
+
});
|
|
41024
|
+
const { error } = schema2.validate({ userId, siteId, isLiftCard });
|
|
41025
|
+
if (error) {
|
|
41026
|
+
return res.status(400).json({ message: error.message });
|
|
41027
|
+
}
|
|
41028
|
+
const isLiftCardBool = isLiftCard === "true";
|
|
41029
|
+
const result = await userAccessCardsSvc({
|
|
41030
|
+
userId,
|
|
41031
|
+
siteId,
|
|
41032
|
+
isLiftCard: isLiftCardBool
|
|
41033
|
+
});
|
|
41034
|
+
return res.status(200).json({ data: result });
|
|
41035
|
+
} catch (error) {
|
|
41036
|
+
return res.status(400).json({
|
|
41037
|
+
data: null,
|
|
41038
|
+
message: error.message
|
|
41039
|
+
});
|
|
41040
|
+
}
|
|
41041
|
+
};
|
|
40728
41042
|
return {
|
|
40729
41043
|
addPhysicalCard,
|
|
40730
41044
|
addNonPhysicalCard,
|
|
@@ -40762,7 +41076,8 @@ function useAccessManagementController() {
|
|
|
40762
41076
|
assignMultipleCards,
|
|
40763
41077
|
visitorCheckout,
|
|
40764
41078
|
uploadTemplate,
|
|
40765
|
-
getResidents
|
|
41079
|
+
getResidents,
|
|
41080
|
+
userAccessCards
|
|
40766
41081
|
};
|
|
40767
41082
|
}
|
|
40768
41083
|
|
|
@@ -52990,7 +53305,9 @@ function useVerificationServiceV2() {
|
|
|
52990
53305
|
updateVerificationStatusById: _updateVerificationStatusById,
|
|
52991
53306
|
getByVerificationCode: _getByVerificationCode,
|
|
52992
53307
|
updateStatusById: _updateStatusById,
|
|
52993
|
-
countPendingOrgInvites: _countPendingOrgInvites
|
|
53308
|
+
countPendingOrgInvites: _countPendingOrgInvites,
|
|
53309
|
+
getPendingVerificationByEmail: _getPendingVerificationByEmail,
|
|
53310
|
+
updateVerificationCodeById: _updateVerificationCodeById
|
|
52994
53311
|
} = useVerificationRepoV2();
|
|
52995
53312
|
const {
|
|
52996
53313
|
getUserByEmailStatus: _getUserByEmailStatus,
|
|
@@ -53333,6 +53650,50 @@ function useVerificationServiceV2() {
|
|
|
53333
53650
|
);
|
|
53334
53651
|
}
|
|
53335
53652
|
}
|
|
53653
|
+
async function resendSignUpVerification(email) {
|
|
53654
|
+
const item = await _getPendingVerificationByEmail(email);
|
|
53655
|
+
if (!item) {
|
|
53656
|
+
throw new NotFoundError53(
|
|
53657
|
+
"Pending verification not found."
|
|
53658
|
+
);
|
|
53659
|
+
}
|
|
53660
|
+
if (item.status !== "pending" /* PENDING */) {
|
|
53661
|
+
throw new BadRequestError202(
|
|
53662
|
+
"Verification is no longer active."
|
|
53663
|
+
);
|
|
53664
|
+
}
|
|
53665
|
+
const verificationCode = generateVerificationCode(6);
|
|
53666
|
+
const expireAt = new Date(
|
|
53667
|
+
(/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3
|
|
53668
|
+
).toISOString();
|
|
53669
|
+
await _updateVerificationCodeById(
|
|
53670
|
+
String(item._id),
|
|
53671
|
+
verificationCode,
|
|
53672
|
+
expireAt
|
|
53673
|
+
);
|
|
53674
|
+
const dir = __dirname;
|
|
53675
|
+
const filePath = getDirectory5(
|
|
53676
|
+
dir,
|
|
53677
|
+
"./public/handlebars/sign-up-v2"
|
|
53678
|
+
);
|
|
53679
|
+
const emailContent = compileHandlebar5({
|
|
53680
|
+
context: {
|
|
53681
|
+
email,
|
|
53682
|
+
validity: "15 minutes",
|
|
53683
|
+
code: verificationCode
|
|
53684
|
+
},
|
|
53685
|
+
filePath
|
|
53686
|
+
});
|
|
53687
|
+
await mailer.sendMail({
|
|
53688
|
+
to: email,
|
|
53689
|
+
subject: "Sign Up Verification",
|
|
53690
|
+
html: emailContent,
|
|
53691
|
+
sender: "iService365" /* ISERVICE365 */
|
|
53692
|
+
});
|
|
53693
|
+
return {
|
|
53694
|
+
message: "Verification code resent successfully."
|
|
53695
|
+
};
|
|
53696
|
+
}
|
|
53336
53697
|
return {
|
|
53337
53698
|
signUp,
|
|
53338
53699
|
verify,
|
|
@@ -53340,7 +53701,8 @@ function useVerificationServiceV2() {
|
|
|
53340
53701
|
createOrganizationInvite,
|
|
53341
53702
|
createServiceProviderInvite,
|
|
53342
53703
|
createForgetPassword,
|
|
53343
|
-
cancelUserInvitation
|
|
53704
|
+
cancelUserInvitation,
|
|
53705
|
+
resendSignUpVerification
|
|
53344
53706
|
};
|
|
53345
53707
|
}
|
|
53346
53708
|
|
|
@@ -53354,7 +53716,8 @@ function useVerificationControllerV2() {
|
|
|
53354
53716
|
createOrganizationInvite: _createOrganizationInvite,
|
|
53355
53717
|
createServiceProviderInvite: _createServiceProviderInvite,
|
|
53356
53718
|
createForgetPassword: _createForgetPassword,
|
|
53357
|
-
cancelUserInvitation: _cancelUserInvitation
|
|
53719
|
+
cancelUserInvitation: _cancelUserInvitation,
|
|
53720
|
+
resendSignUpVerification: _resendSignUpVerification
|
|
53358
53721
|
} = useVerificationServiceV2();
|
|
53359
53722
|
const { getVerifications: _getVerifications } = useVerificationRepoV2();
|
|
53360
53723
|
async function verify(req, res, next) {
|
|
@@ -53568,6 +53931,27 @@ function useVerificationControllerV2() {
|
|
|
53568
53931
|
return;
|
|
53569
53932
|
}
|
|
53570
53933
|
}
|
|
53934
|
+
async function resendSignUpVerification(req, res, next) {
|
|
53935
|
+
const schema2 = Joi129.object({
|
|
53936
|
+
email: Joi129.string().email().lowercase().required()
|
|
53937
|
+
});
|
|
53938
|
+
const { error, value } = schema2.validate(req.body);
|
|
53939
|
+
if (error) {
|
|
53940
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
53941
|
+
next(new BadRequestError203(messages));
|
|
53942
|
+
return;
|
|
53943
|
+
}
|
|
53944
|
+
try {
|
|
53945
|
+
const data = await _resendSignUpVerification(
|
|
53946
|
+
value.email
|
|
53947
|
+
);
|
|
53948
|
+
res.json(data);
|
|
53949
|
+
return;
|
|
53950
|
+
} catch (error2) {
|
|
53951
|
+
next(error2);
|
|
53952
|
+
return;
|
|
53953
|
+
}
|
|
53954
|
+
}
|
|
53571
53955
|
return {
|
|
53572
53956
|
verify,
|
|
53573
53957
|
createUserInvite,
|
|
@@ -53575,7 +53959,8 @@ function useVerificationControllerV2() {
|
|
|
53575
53959
|
createServiceProviderInvite,
|
|
53576
53960
|
createForgetPassword,
|
|
53577
53961
|
getVerifications,
|
|
53578
|
-
cancelUserInvitation
|
|
53962
|
+
cancelUserInvitation,
|
|
53963
|
+
resendSignUpVerification
|
|
53579
53964
|
};
|
|
53580
53965
|
}
|
|
53581
53966
|
|
|
@@ -54087,6 +54472,11 @@ function useAuthServiceV2() {
|
|
|
54087
54472
|
"Your account is currently suspended. Please contact support for assistance."
|
|
54088
54473
|
);
|
|
54089
54474
|
}
|
|
54475
|
+
if (user.status === "pending") {
|
|
54476
|
+
throw new BadRequestError205(
|
|
54477
|
+
"Your account is currently pending. Please contact support for assistance."
|
|
54478
|
+
);
|
|
54479
|
+
}
|
|
54090
54480
|
const isPasswordValid = await comparePassword3(password, user.password);
|
|
54091
54481
|
if (!isPasswordValid) {
|
|
54092
54482
|
throw new BadRequestError205("Invalid password.");
|
|
@@ -54977,7 +55367,8 @@ var schemaPost = Joi133.object({
|
|
|
54977
55367
|
title: Joi133.string().required(),
|
|
54978
55368
|
description: Joi133.string().optional().allow("", null),
|
|
54979
55369
|
attachments: Joi133.array().items(Joi133.string().hex().optional()).optional().allow(null),
|
|
54980
|
-
category: Joi133.
|
|
55370
|
+
category: Joi133.string().optional().allow(null),
|
|
55371
|
+
subcategory: Joi133.string().optional().allow(null),
|
|
54981
55372
|
currency: Joi133.string().optional().allow("", null),
|
|
54982
55373
|
price: Joi133.number().required(),
|
|
54983
55374
|
status: Joi133.string().valid(...Object.values(PostStatus)).optional().default("published" /* PUBLISHED */),
|
|
@@ -54993,7 +55384,8 @@ var schemaUpdatePost = Joi133.object({
|
|
|
54993
55384
|
title: Joi133.string().optional().allow("", null),
|
|
54994
55385
|
description: Joi133.string().optional().allow("", null),
|
|
54995
55386
|
attachments: Joi133.array().items(Joi133.string().hex().optional()).optional().allow(null),
|
|
54996
|
-
category: Joi133.
|
|
55387
|
+
category: Joi133.string().optional().allow(null),
|
|
55388
|
+
subcategory: Joi133.string().optional().allow(null),
|
|
54997
55389
|
currency: Joi133.string().optional().allow("", null),
|
|
54998
55390
|
price: Joi133.number().optional(),
|
|
54999
55391
|
status: Joi133.string().valid(...Object.values(PostStatus)).optional().allow(null),
|
|
@@ -55044,24 +55436,27 @@ function MPost(value) {
|
|
|
55044
55436
|
return id;
|
|
55045
55437
|
});
|
|
55046
55438
|
}
|
|
55047
|
-
if (value.category &&
|
|
55048
|
-
|
|
55049
|
-
|
|
55050
|
-
|
|
55051
|
-
|
|
55052
|
-
|
|
55053
|
-
|
|
55054
|
-
|
|
55055
|
-
|
|
55056
|
-
|
|
55057
|
-
}
|
|
55439
|
+
if (value.category && typeof value.category === "string") {
|
|
55440
|
+
try {
|
|
55441
|
+
value.category = new ObjectId131(value.category);
|
|
55442
|
+
} catch {
|
|
55443
|
+
throw new Error("Invalid category ID.");
|
|
55444
|
+
}
|
|
55445
|
+
}
|
|
55446
|
+
if (value.subcategory && typeof value.subcategory === "string") {
|
|
55447
|
+
try {
|
|
55448
|
+
value.subcategory = new ObjectId131(value.subcategory);
|
|
55449
|
+
} catch {
|
|
55450
|
+
throw new Error("Invalid subcategory ID.");
|
|
55451
|
+
}
|
|
55058
55452
|
}
|
|
55059
55453
|
return {
|
|
55060
55454
|
_id: value._id ?? new ObjectId131(),
|
|
55061
55455
|
title: value.title ?? "",
|
|
55062
55456
|
description: value.description ?? "",
|
|
55063
55457
|
attachments: value.attachments ?? [],
|
|
55064
|
-
category: value.category ??
|
|
55458
|
+
category: value.category ?? "",
|
|
55459
|
+
subcategory: value.subcategory ?? "",
|
|
55065
55460
|
currency: value.currency ?? "",
|
|
55066
55461
|
price: value.price ?? 0,
|
|
55067
55462
|
status: value.status ?? "published" /* PUBLISHED */,
|
|
@@ -55127,6 +55522,7 @@ function usePostPrelovedRepo() {
|
|
|
55127
55522
|
case "price-high-low":
|
|
55128
55523
|
return { price: -1 };
|
|
55129
55524
|
case "recent":
|
|
55525
|
+
return { createdAt: -1 };
|
|
55130
55526
|
default:
|
|
55131
55527
|
return { createdAt: -1 };
|
|
55132
55528
|
}
|
|
@@ -55171,7 +55567,8 @@ function usePostPrelovedRepo() {
|
|
|
55171
55567
|
filter,
|
|
55172
55568
|
site,
|
|
55173
55569
|
status,
|
|
55174
|
-
category
|
|
55570
|
+
category,
|
|
55571
|
+
subcategory
|
|
55175
55572
|
}, session) {
|
|
55176
55573
|
page = page > 0 ? page - 1 : 0;
|
|
55177
55574
|
if (site) {
|
|
@@ -55181,13 +55578,24 @@ function usePostPrelovedRepo() {
|
|
|
55181
55578
|
throw new BadRequestError212("Invalid site ID format.");
|
|
55182
55579
|
}
|
|
55183
55580
|
}
|
|
55184
|
-
|
|
55581
|
+
let categoryId = null;
|
|
55582
|
+
let subcategoryIds = null;
|
|
55583
|
+
if (category && subcategory) {
|
|
55185
55584
|
try {
|
|
55186
|
-
|
|
55585
|
+
categoryId = new ObjectId132(category);
|
|
55187
55586
|
} catch {
|
|
55188
55587
|
throw new BadRequestError212("Invalid category ID format.");
|
|
55189
55588
|
}
|
|
55190
|
-
|
|
55589
|
+
if (subcategory.length > 0) {
|
|
55590
|
+
subcategoryIds = subcategory.map((id) => {
|
|
55591
|
+
try {
|
|
55592
|
+
return new ObjectId132(id);
|
|
55593
|
+
} catch {
|
|
55594
|
+
throw new BadRequestError212("Invalid subcategory ID format.");
|
|
55595
|
+
}
|
|
55596
|
+
});
|
|
55597
|
+
}
|
|
55598
|
+
}
|
|
55191
55599
|
const query = {
|
|
55192
55600
|
status: { $ne: "deleted" /* DELETED */ },
|
|
55193
55601
|
...site && { site },
|
|
@@ -55200,7 +55608,8 @@ function usePostPrelovedRepo() {
|
|
|
55200
55608
|
...status && {
|
|
55201
55609
|
status: { $in: Array.isArray(status) ? status : [status] }
|
|
55202
55610
|
},
|
|
55203
|
-
...
|
|
55611
|
+
...categoryId && { category: categoryId },
|
|
55612
|
+
...subcategoryIds && { subcategory: { $in: subcategoryIds } }
|
|
55204
55613
|
};
|
|
55205
55614
|
const sortObj = buildSortObj(filter);
|
|
55206
55615
|
try {
|
|
@@ -55361,7 +55770,8 @@ function usePostPrelovedController() {
|
|
|
55361
55770
|
Joi134.array().items(Joi134.string().valid(...Object.values(PostStatus))),
|
|
55362
55771
|
Joi134.string().valid(...Object.values(PostStatus))
|
|
55363
55772
|
).optional().allow(null),
|
|
55364
|
-
category: Joi134.
|
|
55773
|
+
category: Joi134.string().hex().length(24).optional().allow("", null),
|
|
55774
|
+
subcategory: Joi134.alternatives().try(Joi134.array().items(Joi134.string())).optional().allow(null, "")
|
|
55365
55775
|
});
|
|
55366
55776
|
const { error, value } = validation.validate(req.query, {
|
|
55367
55777
|
abortEarly: false
|
|
@@ -55372,7 +55782,7 @@ function usePostPrelovedController() {
|
|
|
55372
55782
|
next(new BadRequestError213(messages));
|
|
55373
55783
|
return;
|
|
55374
55784
|
}
|
|
55375
|
-
const { page, limit, search, filter, site, status, category } = value;
|
|
55785
|
+
const { page, limit, search, filter, site, status, category, subcategory } = value;
|
|
55376
55786
|
try {
|
|
55377
55787
|
const data = await _getAll({
|
|
55378
55788
|
page,
|
|
@@ -55381,7 +55791,8 @@ function usePostPrelovedController() {
|
|
|
55381
55791
|
filter,
|
|
55382
55792
|
site,
|
|
55383
55793
|
status: status ? Array.isArray(status) ? status : [status] : void 0,
|
|
55384
|
-
category: category
|
|
55794
|
+
category: category ?? void 0,
|
|
55795
|
+
subcategory: subcategory ? Array.isArray(subcategory) ? subcategory : [subcategory] : void 0
|
|
55385
55796
|
});
|
|
55386
55797
|
res.status(200).json(data);
|
|
55387
55798
|
return;
|