@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/dist/index.js CHANGED
@@ -4138,6 +4138,11 @@ function useAuthService() {
4138
4138
  "Your account is currently suspended. Please contact support for assistance."
4139
4139
  );
4140
4140
  }
4141
+ if (user.status === "pending") {
4142
+ throw new import_node_server_utils13.BadRequestError(
4143
+ "Your account is currently pending. Please contact support for assistance."
4144
+ );
4145
+ }
4141
4146
  const isPasswordValid = await (0, import_node_server_utils13.comparePassword)(password, user.password);
4142
4147
  if (!isPasswordValid) {
4143
4148
  throw new import_node_server_utils13.BadRequestError("Invalid password.");
@@ -4920,6 +4925,155 @@ function useOrgRepo() {
4920
4925
  throw new import_node_server_utils17.InternalServerError("Failed to update organization status.");
4921
4926
  }
4922
4927
  }
4928
+ async function getOrganizationsWithSubscription({
4929
+ search = "",
4930
+ page = 1,
4931
+ limit = 10,
4932
+ status = "active",
4933
+ type = "",
4934
+ billingCycle = ""
4935
+ }) {
4936
+ const normalizedPage = page > 0 ? page - 1 : 0;
4937
+ const query = {
4938
+ status
4939
+ };
4940
+ if (search) {
4941
+ query.$or = [
4942
+ {
4943
+ name: {
4944
+ $regex: search,
4945
+ $options: "i"
4946
+ }
4947
+ },
4948
+ {
4949
+ email: {
4950
+ $regex: search,
4951
+ $options: "i"
4952
+ }
4953
+ }
4954
+ ];
4955
+ }
4956
+ const subscriptionMatch = {};
4957
+ if (type) {
4958
+ subscriptionMatch["subscription.type"] = type;
4959
+ }
4960
+ if (billingCycle) {
4961
+ subscriptionMatch["subscription.billingCycle"] = billingCycle;
4962
+ }
4963
+ const lookupStage = {
4964
+ $lookup: {
4965
+ from: "subscriptions",
4966
+ let: {
4967
+ orgId: "$_id"
4968
+ },
4969
+ pipeline: [
4970
+ {
4971
+ $match: {
4972
+ $expr: {
4973
+ $eq: [
4974
+ "$org",
4975
+ "$$orgId"
4976
+ ]
4977
+ }
4978
+ }
4979
+ },
4980
+ {
4981
+ $sort: {
4982
+ createdAt: -1
4983
+ }
4984
+ },
4985
+ {
4986
+ $limit: 1
4987
+ }
4988
+ ],
4989
+ as: "subscription"
4990
+ }
4991
+ };
4992
+ const unwindStage = {
4993
+ $unwind: {
4994
+ path: "$subscription",
4995
+ preserveNullAndEmptyArrays: true
4996
+ }
4997
+ };
4998
+ try {
4999
+ const pipeline = [
5000
+ {
5001
+ $match: query
5002
+ },
5003
+ lookupStage,
5004
+ unwindStage,
5005
+ ...Object.keys(subscriptionMatch).length ? [
5006
+ {
5007
+ $match: subscriptionMatch
5008
+ }
5009
+ ] : [],
5010
+ {
5011
+ $project: {
5012
+ _id: 1,
5013
+ name: 1,
5014
+ email: 1,
5015
+ nature: 1,
5016
+ description: 1,
5017
+ status: 1,
5018
+ createdAt: 1,
5019
+ subscription: {
5020
+ _id: "$subscription._id",
5021
+ org: "$subscription.org",
5022
+ type: "$subscription.type",
5023
+ paidSeats: "$subscription.paidSeats",
5024
+ currentSeats: "$subscription.currentSeats",
5025
+ maxSeats: "$subscription.maxSeats",
5026
+ billingCycle: "$subscription.billingCycle",
5027
+ nextBillingDate: "$subscription.nextBillingDate",
5028
+ createdAt: "$subscription.createdAt",
5029
+ status: "$subscription.status"
5030
+ }
5031
+ }
5032
+ },
5033
+ {
5034
+ $sort: {
5035
+ _id: -1
5036
+ }
5037
+ },
5038
+ {
5039
+ $skip: normalizedPage * limit
5040
+ },
5041
+ {
5042
+ $limit: limit
5043
+ }
5044
+ ];
5045
+ const items = await collection.aggregate(pipeline).toArray();
5046
+ const countPipeline = [
5047
+ {
5048
+ $match: query
5049
+ },
5050
+ lookupStage,
5051
+ unwindStage,
5052
+ ...Object.keys(subscriptionMatch).length ? [
5053
+ {
5054
+ $match: subscriptionMatch
5055
+ }
5056
+ ] : [],
5057
+ {
5058
+ $count: "total"
5059
+ }
5060
+ ];
5061
+ const countResult = await collection.aggregate(countPipeline).toArray();
5062
+ const totalItems = countResult?.[0]?.total ?? 0;
5063
+ return (0, import_node_server_utils17.paginate)(
5064
+ items,
5065
+ normalizedPage,
5066
+ limit,
5067
+ totalItems
5068
+ );
5069
+ } catch (error) {
5070
+ import_node_server_utils17.logger.log({
5071
+ level: "error",
5072
+ message: `${error}`
5073
+ });
5074
+ throw error;
5075
+ }
5076
+ }
4923
5077
  return {
4924
5078
  createIndex,
4925
5079
  createTextIndex,
@@ -4933,7 +5087,8 @@ function useOrgRepo() {
4933
5087
  updateFieldById,
4934
5088
  updateStatusById,
4935
5089
  deleteById,
4936
- getOrgsByEmail
5090
+ getOrgsByEmail,
5091
+ getOrganizationsWithSubscription
4937
5092
  };
4938
5093
  }
4939
5094
 
@@ -5832,6 +5987,44 @@ function useVerificationRepoV2() {
5832
5987
  throw new import_node_server_utils20.InternalServerError("Failed to count pending invitations.");
5833
5988
  }
5834
5989
  }
5990
+ async function getPendingVerificationByEmail(email) {
5991
+ try {
5992
+ return await collection.findOne(
5993
+ {
5994
+ email,
5995
+ status: "pending" /* PENDING */,
5996
+ type: "user-sign-up" /* USER_SIGN_UP */
5997
+ },
5998
+ {
5999
+ sort: { createdAt: -1 }
6000
+ }
6001
+ );
6002
+ } catch (error) {
6003
+ throw new import_node_server_utils20.InternalServerError(
6004
+ "Failed to retrieve verification."
6005
+ );
6006
+ }
6007
+ }
6008
+ async function updateVerificationCodeById(_id, verificationCode, expireAt, session) {
6009
+ try {
6010
+ _id = new import_mongodb18.ObjectId(_id);
6011
+ return await collection.updateOne(
6012
+ { _id },
6013
+ {
6014
+ $set: {
6015
+ "metadata.verificationCode": verificationCode,
6016
+ expireAt,
6017
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
6018
+ }
6019
+ },
6020
+ { session }
6021
+ );
6022
+ } catch (error) {
6023
+ throw new import_node_server_utils20.InternalServerError(
6024
+ "Failed to update verification code."
6025
+ );
6026
+ }
6027
+ }
5835
6028
  return {
5836
6029
  createIndex,
5837
6030
  createTextIndex,
@@ -5841,7 +6034,9 @@ function useVerificationRepoV2() {
5841
6034
  getVerificationById,
5842
6035
  getVerifications,
5843
6036
  updateStatusById,
5844
- countPendingOrgInvites
6037
+ countPendingOrgInvites,
6038
+ getPendingVerificationByEmail,
6039
+ updateVerificationCodeById
5845
6040
  };
5846
6041
  }
5847
6042
 
@@ -9190,7 +9385,7 @@ function useOrgController() {
9190
9385
  var import_joi19 = __toESM(require("joi"));
9191
9386
  var import_node_server_utils36 = require("@7365admin1/node-server-utils");
9192
9387
  function useOrgControllerV2() {
9193
- const { getAll: _getAll } = useOrgRepo();
9388
+ const { getAll: _getAll, getOrganizationsWithSubscription: _getOrganizationsWithSubscription } = useOrgRepo();
9194
9389
  async function getAll(req, res, next) {
9195
9390
  const validation = import_joi19.default.object({
9196
9391
  search: import_joi19.default.string().optional().allow("", null),
@@ -9230,8 +9425,43 @@ function useOrgControllerV2() {
9230
9425
  return;
9231
9426
  }
9232
9427
  }
9428
+ async function getOrganizationsWithSubscription(req, res, next) {
9429
+ const validation = import_joi19.default.object({
9430
+ search: import_joi19.default.string().optional().allow("", null),
9431
+ page: import_joi19.default.number().integer().min(1).default(1),
9432
+ limit: import_joi19.default.number().integer().min(1).max(100).default(10),
9433
+ status: import_joi19.default.string().trim().valid("active", "suspended", "deleted").default("active"),
9434
+ type: import_joi19.default.string().optional().allow("", null),
9435
+ billingCycle: import_joi19.default.string().optional().allow("", null)
9436
+ });
9437
+ const { error, value } = validation.validate(
9438
+ req.query,
9439
+ {
9440
+ convert: true,
9441
+ stripUnknown: true
9442
+ }
9443
+ );
9444
+ if (error) {
9445
+ next(new import_node_server_utils36.BadRequestError(error.message));
9446
+ return;
9447
+ }
9448
+ try {
9449
+ const data = await _getOrganizationsWithSubscription({
9450
+ search: value.search ?? "",
9451
+ page: value.page ?? 1,
9452
+ limit: value.limit ?? 10,
9453
+ status: value.status ?? "active",
9454
+ type: value.type ?? "",
9455
+ billingCycle: value.billingCycle ?? ""
9456
+ });
9457
+ res.json(data);
9458
+ } catch (error2) {
9459
+ next(error2);
9460
+ }
9461
+ }
9233
9462
  return {
9234
- getAll
9463
+ getAll,
9464
+ getOrganizationsWithSubscription
9235
9465
  };
9236
9466
  }
9237
9467
 
@@ -31877,6 +32107,7 @@ function useDocumentManagementRepo() {
31877
32107
  async function createIndex() {
31878
32108
  try {
31879
32109
  await collection.createIndexes([
32110
+ { key: { type: 1 } },
31880
32111
  { key: { site: 1 } },
31881
32112
  { key: { parentId: 1 } }
31882
32113
  ]);
@@ -31919,8 +32150,7 @@ function useDocumentManagementRepo() {
31919
32150
  search = "",
31920
32151
  page = 1,
31921
32152
  limit = 10,
31922
- sort = {},
31923
- status = "active",
32153
+ type = "all",
31924
32154
  org = "",
31925
32155
  site = "",
31926
32156
  parentId = ""
@@ -31931,17 +32161,18 @@ function useDocumentManagementRepo() {
31931
32161
  } catch (error) {
31932
32162
  throw new import_node_server_utils136.BadRequestError("Invalid site ID format.");
31933
32163
  }
31934
- sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
31935
32164
  const cacheOptions = {
31936
32165
  page,
31937
32166
  limit,
31938
- status,
31939
- site: site?.toString(),
31940
- sort: JSON.stringify(sort)
32167
+ site: site?.toString()
31941
32168
  };
31942
32169
  const query = {
31943
- ...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } }
32170
+ status: { $ne: "deleted" }
31944
32171
  };
32172
+ if (type && type !== "all") {
32173
+ query.type = type;
32174
+ cacheOptions.type = type;
32175
+ }
31945
32176
  if (org) {
31946
32177
  query.org = new import_mongodb79.ObjectId(org);
31947
32178
  cacheOptions.org = org.toString();
@@ -31972,19 +32203,17 @@ function useDocumentManagementRepo() {
31972
32203
  try {
31973
32204
  const items = await collection.aggregate([
31974
32205
  { $match: query },
31975
- { $sort: sort },
31976
- { $skip: page * limit },
31977
- { $limit: limit },
32206
+ { $sort: { _id: -1 } },
31978
32207
  {
31979
32208
  $project: {
32209
+ parentId: 1,
31980
32210
  name: 1,
31981
32211
  type: 1,
31982
- status: 1,
31983
- attachment: 1,
31984
- parentId: 1,
31985
- remarks: 1,
32212
+ size: 1,
31986
32213
  createdAt: 1,
31987
- updatedAt: 1
32214
+ updatedAt: 1,
32215
+ remarks: 1,
32216
+ attachment: 1
31988
32217
  }
31989
32218
  }
31990
32219
  ]).toArray();
@@ -32260,13 +32489,12 @@ function useDocumentManagementController() {
32260
32489
  search: import_joi76.default.string().optional().allow("", null),
32261
32490
  page: import_joi76.default.number().integer().min(1).allow("", null).default(1),
32262
32491
  limit: import_joi76.default.number().integer().min(1).max(100).allow("", null).default(10),
32263
- status: import_joi76.default.string().required(),
32492
+ type: import_joi76.default.string().valid("all", "pdf", "csv", "doc").optional().default("all"),
32264
32493
  org: import_joi76.default.string().hex().optional().allow("", null),
32265
32494
  site: import_joi76.default.string().hex().optional().allow("", null),
32266
32495
  parentId: import_joi76.default.string().hex().optional().allow("", null)
32267
32496
  });
32268
32497
  const query = { ...req.query };
32269
- query.status = req.query.status;
32270
32498
  const { error } = validation.validate(query);
32271
32499
  if (error) {
32272
32500
  import_node_server_utils138.logger.log({ level: "error", message: error.message });
@@ -32276,7 +32504,7 @@ function useDocumentManagementController() {
32276
32504
  const search = req.query.search ?? "";
32277
32505
  const page = parseInt(req.query.page ?? "1");
32278
32506
  const limit = parseInt(req.query.limit ?? "10");
32279
- const status = req.query.status ?? "active";
32507
+ const type = req.query.type ?? "all";
32280
32508
  const org = req.query.org ?? "";
32281
32509
  const site = req.query.site ?? "";
32282
32510
  const parentId = req.query.parentId ?? "";
@@ -32285,7 +32513,7 @@ function useDocumentManagementController() {
32285
32513
  search,
32286
32514
  page,
32287
32515
  limit,
32288
- status,
32516
+ type,
32289
32517
  org,
32290
32518
  site,
32291
32519
  parentId
@@ -32862,8 +33090,12 @@ function useBulletinBoardService() {
32862
33090
  async function add(value) {
32863
33091
  const session = import_node_server_utils140.useAtlas.getClient()?.startSession();
32864
33092
  session?.startTransaction();
32865
- if (value.startDate && new Date(value.startDate) > /* @__PURE__ */ new Date()) {
32866
- value.status = "upcoming" /* UPCOMING */;
33093
+ if (value.startDate) {
33094
+ const today = /* @__PURE__ */ new Date();
33095
+ today.setHours(23, 59, 0, 0);
33096
+ if (new Date(value.startDate) > today) {
33097
+ value.status = "upcoming" /* UPCOMING */;
33098
+ }
32867
33099
  }
32868
33100
  try {
32869
33101
  const bulletinFiles = value?.file ?? [];
@@ -32894,6 +33126,15 @@ function useBulletinBoardService() {
32894
33126
  async function updateBulletinBoardById(id, value) {
32895
33127
  const session = import_node_server_utils140.useAtlas.getClient()?.startSession();
32896
33128
  session?.startTransaction();
33129
+ if (value.startDate) {
33130
+ const today = /* @__PURE__ */ new Date();
33131
+ today.setHours(23, 59, 0, 0);
33132
+ if (new Date(value.startDate) > today) {
33133
+ value.status = "upcoming" /* UPCOMING */;
33134
+ } else {
33135
+ value.status = "active" /* ACTIVE */;
33136
+ }
33137
+ }
32897
33138
  try {
32898
33139
  await _updateBulletinBoardById(id, value, session);
32899
33140
  await session?.commitTransaction();
@@ -39154,6 +39395,33 @@ function UseAccessManagementRepo() {
39154
39395
  throw new Error(error.message);
39155
39396
  }
39156
39397
  }
39398
+ async function userAccessCardsRepo({
39399
+ userId,
39400
+ siteId,
39401
+ isLiftCard
39402
+ }) {
39403
+ try {
39404
+ siteId = new import_mongodb92.ObjectId(siteId);
39405
+ userId = new import_mongodb92.ObjectId(userId);
39406
+ const query = {
39407
+ site: siteId,
39408
+ userId,
39409
+ isLiftCard,
39410
+ userType: "Visitor/Resident" /* DEFAULT */
39411
+ };
39412
+ console.log(query);
39413
+ const res = await collection().aggregate([
39414
+ {
39415
+ $match: {
39416
+ ...query
39417
+ }
39418
+ }
39419
+ ]).toArray();
39420
+ return res;
39421
+ } catch (error) {
39422
+ throw new Error(error.message);
39423
+ }
39424
+ }
39157
39425
  return {
39158
39426
  createIndexes,
39159
39427
  createIndexForEntrypass,
@@ -39190,7 +39458,8 @@ function UseAccessManagementRepo() {
39190
39458
  assignMultipleCardsRepo,
39191
39459
  visitorCheckoutRepo,
39192
39460
  uploadTemplateRepo,
39193
- getResidentsRepo
39461
+ getResidentsRepo,
39462
+ userAccessCardsRepo
39194
39463
  };
39195
39464
  }
39196
39465
 
@@ -39235,7 +39504,8 @@ function useAccessManagementSvc() {
39235
39504
  assignMultipleCardsRepo,
39236
39505
  visitorCheckoutRepo,
39237
39506
  uploadTemplateRepo,
39238
- getResidentsRepo
39507
+ getResidentsRepo,
39508
+ userAccessCardsRepo
39239
39509
  } = UseAccessManagementRepo();
39240
39510
  const addPhysicalCardSvc = async (payload) => {
39241
39511
  try {
@@ -39597,6 +39867,22 @@ function useAccessManagementSvc() {
39597
39867
  throw new Error(err.message);
39598
39868
  }
39599
39869
  };
39870
+ const userAccessCardsSvc = async ({
39871
+ userId,
39872
+ siteId,
39873
+ isLiftCard
39874
+ }) => {
39875
+ try {
39876
+ const response = await userAccessCardsRepo({
39877
+ userId,
39878
+ siteId,
39879
+ isLiftCard
39880
+ });
39881
+ return response;
39882
+ } catch (err) {
39883
+ throw new Error(err.message);
39884
+ }
39885
+ };
39600
39886
  return {
39601
39887
  addPhysicalCardSvc,
39602
39888
  addNonPhysicalCardSvc,
@@ -39636,7 +39922,8 @@ function useAccessManagementSvc() {
39636
39922
  assignMultipleCardsSvc,
39637
39923
  visitorCheckoutSvc,
39638
39924
  uploadTemplateSvc,
39639
- getResidentsSvc
39925
+ getResidentsSvc,
39926
+ userAccessCardsSvc
39640
39927
  };
39641
39928
  }
39642
39929
 
@@ -39681,7 +39968,8 @@ function useAccessManagementController() {
39681
39968
  assignMultipleCardsSvc,
39682
39969
  visitorCheckoutSvc,
39683
39970
  uploadTemplateSvc,
39684
- getResidentsSvc
39971
+ getResidentsSvc,
39972
+ userAccessCardsSvc
39685
39973
  } = useAccessManagementSvc();
39686
39974
  const addPhysicalCard = async (req, res) => {
39687
39975
  try {
@@ -40705,6 +40993,32 @@ function useAccessManagementController() {
40705
40993
  });
40706
40994
  }
40707
40995
  };
40996
+ const userAccessCards = async (req, res) => {
40997
+ try {
40998
+ const { userId, siteId, isLiftCard } = req.query;
40999
+ const schema2 = import_joi87.default.object({
41000
+ isLiftCard: import_joi87.default.string().valid("true", "false").required(),
41001
+ siteId: import_joi87.default.string().hex().required(),
41002
+ userId: import_joi87.default.string().hex().required()
41003
+ });
41004
+ const { error } = schema2.validate({ userId, siteId, isLiftCard });
41005
+ if (error) {
41006
+ return res.status(400).json({ message: error.message });
41007
+ }
41008
+ const isLiftCardBool = isLiftCard === "true";
41009
+ const result = await userAccessCardsSvc({
41010
+ userId,
41011
+ siteId,
41012
+ isLiftCard: isLiftCardBool
41013
+ });
41014
+ return res.status(200).json({ data: result });
41015
+ } catch (error) {
41016
+ return res.status(400).json({
41017
+ data: null,
41018
+ message: error.message
41019
+ });
41020
+ }
41021
+ };
40708
41022
  return {
40709
41023
  addPhysicalCard,
40710
41024
  addNonPhysicalCard,
@@ -40742,7 +41056,8 @@ function useAccessManagementController() {
40742
41056
  assignMultipleCards,
40743
41057
  visitorCheckout,
40744
41058
  uploadTemplate,
40745
- getResidents
41059
+ getResidents,
41060
+ userAccessCards
40746
41061
  };
40747
41062
  }
40748
41063
 
@@ -52767,7 +53082,9 @@ function useVerificationServiceV2() {
52767
53082
  updateVerificationStatusById: _updateVerificationStatusById,
52768
53083
  getByVerificationCode: _getByVerificationCode,
52769
53084
  updateStatusById: _updateStatusById,
52770
- countPendingOrgInvites: _countPendingOrgInvites
53085
+ countPendingOrgInvites: _countPendingOrgInvites,
53086
+ getPendingVerificationByEmail: _getPendingVerificationByEmail,
53087
+ updateVerificationCodeById: _updateVerificationCodeById
52771
53088
  } = useVerificationRepoV2();
52772
53089
  const {
52773
53090
  getUserByEmailStatus: _getUserByEmailStatus,
@@ -53110,6 +53427,50 @@ function useVerificationServiceV2() {
53110
53427
  );
53111
53428
  }
53112
53429
  }
53430
+ async function resendSignUpVerification(email) {
53431
+ const item = await _getPendingVerificationByEmail(email);
53432
+ if (!item) {
53433
+ throw new import_node_server_utils225.NotFoundError(
53434
+ "Pending verification not found."
53435
+ );
53436
+ }
53437
+ if (item.status !== "pending" /* PENDING */) {
53438
+ throw new import_node_server_utils225.BadRequestError(
53439
+ "Verification is no longer active."
53440
+ );
53441
+ }
53442
+ const verificationCode = generateVerificationCode(6);
53443
+ const expireAt = new Date(
53444
+ (/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3
53445
+ ).toISOString();
53446
+ await _updateVerificationCodeById(
53447
+ String(item._id),
53448
+ verificationCode,
53449
+ expireAt
53450
+ );
53451
+ const dir = __dirname;
53452
+ const filePath = (0, import_node_server_utils225.getDirectory)(
53453
+ dir,
53454
+ "./public/handlebars/sign-up-v2"
53455
+ );
53456
+ const emailContent = (0, import_node_server_utils225.compileHandlebar)({
53457
+ context: {
53458
+ email,
53459
+ validity: "15 minutes",
53460
+ code: verificationCode
53461
+ },
53462
+ filePath
53463
+ });
53464
+ await mailer.sendMail({
53465
+ to: email,
53466
+ subject: "Sign Up Verification",
53467
+ html: emailContent,
53468
+ sender: "iService365" /* ISERVICE365 */
53469
+ });
53470
+ return {
53471
+ message: "Verification code resent successfully."
53472
+ };
53473
+ }
53113
53474
  return {
53114
53475
  signUp,
53115
53476
  verify,
@@ -53117,7 +53478,8 @@ function useVerificationServiceV2() {
53117
53478
  createOrganizationInvite,
53118
53479
  createServiceProviderInvite,
53119
53480
  createForgetPassword,
53120
- cancelUserInvitation
53481
+ cancelUserInvitation,
53482
+ resendSignUpVerification
53121
53483
  };
53122
53484
  }
53123
53485
 
@@ -53131,7 +53493,8 @@ function useVerificationControllerV2() {
53131
53493
  createOrganizationInvite: _createOrganizationInvite,
53132
53494
  createServiceProviderInvite: _createServiceProviderInvite,
53133
53495
  createForgetPassword: _createForgetPassword,
53134
- cancelUserInvitation: _cancelUserInvitation
53496
+ cancelUserInvitation: _cancelUserInvitation,
53497
+ resendSignUpVerification: _resendSignUpVerification
53135
53498
  } = useVerificationServiceV2();
53136
53499
  const { getVerifications: _getVerifications } = useVerificationRepoV2();
53137
53500
  async function verify(req, res, next) {
@@ -53345,6 +53708,27 @@ function useVerificationControllerV2() {
53345
53708
  return;
53346
53709
  }
53347
53710
  }
53711
+ async function resendSignUpVerification(req, res, next) {
53712
+ const schema2 = import_joi129.default.object({
53713
+ email: import_joi129.default.string().email().lowercase().required()
53714
+ });
53715
+ const { error, value } = schema2.validate(req.body);
53716
+ if (error) {
53717
+ const messages = error.details.map((d) => d.message).join(", ");
53718
+ next(new import_node_server_utils226.BadRequestError(messages));
53719
+ return;
53720
+ }
53721
+ try {
53722
+ const data = await _resendSignUpVerification(
53723
+ value.email
53724
+ );
53725
+ res.json(data);
53726
+ return;
53727
+ } catch (error2) {
53728
+ next(error2);
53729
+ return;
53730
+ }
53731
+ }
53348
53732
  return {
53349
53733
  verify,
53350
53734
  createUserInvite,
@@ -53352,7 +53736,8 @@ function useVerificationControllerV2() {
53352
53736
  createServiceProviderInvite,
53353
53737
  createForgetPassword,
53354
53738
  getVerifications,
53355
- cancelUserInvitation
53739
+ cancelUserInvitation,
53740
+ resendSignUpVerification
53356
53741
  };
53357
53742
  }
53358
53743
 
@@ -53847,6 +54232,11 @@ function useAuthServiceV2() {
53847
54232
  "Your account is currently suspended. Please contact support for assistance."
53848
54233
  );
53849
54234
  }
54235
+ if (user.status === "pending") {
54236
+ throw new import_node_server_utils228.BadRequestError(
54237
+ "Your account is currently pending. Please contact support for assistance."
54238
+ );
54239
+ }
53850
54240
  const isPasswordValid = await (0, import_node_server_utils228.comparePassword)(password, user.password);
53851
54241
  if (!isPasswordValid) {
53852
54242
  throw new import_node_server_utils228.BadRequestError("Invalid password.");
@@ -54723,7 +55113,8 @@ var schemaPost = import_joi133.default.object({
54723
55113
  title: import_joi133.default.string().required(),
54724
55114
  description: import_joi133.default.string().optional().allow("", null),
54725
55115
  attachments: import_joi133.default.array().items(import_joi133.default.string().hex().optional()).optional().allow(null),
54726
- category: import_joi133.default.array().items(import_joi133.default.string().hex().optional()).optional().allow(null),
55116
+ category: import_joi133.default.string().optional().allow(null),
55117
+ subcategory: import_joi133.default.string().optional().allow(null),
54727
55118
  currency: import_joi133.default.string().optional().allow("", null),
54728
55119
  price: import_joi133.default.number().required(),
54729
55120
  status: import_joi133.default.string().valid(...Object.values(PostStatus)).optional().default("published" /* PUBLISHED */),
@@ -54739,7 +55130,8 @@ var schemaUpdatePost = import_joi133.default.object({
54739
55130
  title: import_joi133.default.string().optional().allow("", null),
54740
55131
  description: import_joi133.default.string().optional().allow("", null),
54741
55132
  attachments: import_joi133.default.array().items(import_joi133.default.string().hex().optional()).optional().allow(null),
54742
- category: import_joi133.default.array().items(import_joi133.default.string().hex().optional()).optional().allow(null),
55133
+ category: import_joi133.default.string().optional().allow(null),
55134
+ subcategory: import_joi133.default.string().optional().allow(null),
54743
55135
  currency: import_joi133.default.string().optional().allow("", null),
54744
55136
  price: import_joi133.default.number().optional(),
54745
55137
  status: import_joi133.default.string().valid(...Object.values(PostStatus)).optional().allow(null),
@@ -54790,24 +55182,27 @@ function MPost(value) {
54790
55182
  return id;
54791
55183
  });
54792
55184
  }
54793
- if (value.category && Array.isArray(value.category)) {
54794
- value.category = value.category.map((id) => {
54795
- if (typeof id === "string") {
54796
- try {
54797
- return new import_mongodb131.ObjectId(id);
54798
- } catch {
54799
- throw new Error("Invalid category ID.");
54800
- }
54801
- }
54802
- return id;
54803
- });
55185
+ if (value.category && typeof value.category === "string") {
55186
+ try {
55187
+ value.category = new import_mongodb131.ObjectId(value.category);
55188
+ } catch {
55189
+ throw new Error("Invalid category ID.");
55190
+ }
55191
+ }
55192
+ if (value.subcategory && typeof value.subcategory === "string") {
55193
+ try {
55194
+ value.subcategory = new import_mongodb131.ObjectId(value.subcategory);
55195
+ } catch {
55196
+ throw new Error("Invalid subcategory ID.");
55197
+ }
54804
55198
  }
54805
55199
  return {
54806
55200
  _id: value._id ?? new import_mongodb131.ObjectId(),
54807
55201
  title: value.title ?? "",
54808
55202
  description: value.description ?? "",
54809
55203
  attachments: value.attachments ?? [],
54810
- category: value.category ?? [],
55204
+ category: value.category ?? "",
55205
+ subcategory: value.subcategory ?? "",
54811
55206
  currency: value.currency ?? "",
54812
55207
  price: value.price ?? 0,
54813
55208
  status: value.status ?? "published" /* PUBLISHED */,
@@ -54867,6 +55262,7 @@ function usePostPrelovedRepo() {
54867
55262
  case "price-high-low":
54868
55263
  return { price: -1 };
54869
55264
  case "recent":
55265
+ return { createdAt: -1 };
54870
55266
  default:
54871
55267
  return { createdAt: -1 };
54872
55268
  }
@@ -54911,7 +55307,8 @@ function usePostPrelovedRepo() {
54911
55307
  filter,
54912
55308
  site,
54913
55309
  status,
54914
- category
55310
+ category,
55311
+ subcategory
54915
55312
  }, session) {
54916
55313
  page = page > 0 ? page - 1 : 0;
54917
55314
  if (site) {
@@ -54921,13 +55318,24 @@ function usePostPrelovedRepo() {
54921
55318
  throw new import_node_server_utils235.BadRequestError("Invalid site ID format.");
54922
55319
  }
54923
55320
  }
54924
- const categoryIds = category && Array.isArray(category) && category.length > 0 ? category.map((id) => {
55321
+ let categoryId = null;
55322
+ let subcategoryIds = null;
55323
+ if (category && subcategory) {
54925
55324
  try {
54926
- return new import_mongodb132.ObjectId(id);
55325
+ categoryId = new import_mongodb132.ObjectId(category);
54927
55326
  } catch {
54928
55327
  throw new import_node_server_utils235.BadRequestError("Invalid category ID format.");
54929
55328
  }
54930
- }) : null;
55329
+ if (subcategory.length > 0) {
55330
+ subcategoryIds = subcategory.map((id) => {
55331
+ try {
55332
+ return new import_mongodb132.ObjectId(id);
55333
+ } catch {
55334
+ throw new import_node_server_utils235.BadRequestError("Invalid subcategory ID format.");
55335
+ }
55336
+ });
55337
+ }
55338
+ }
54931
55339
  const query = {
54932
55340
  status: { $ne: "deleted" /* DELETED */ },
54933
55341
  ...site && { site },
@@ -54940,7 +55348,8 @@ function usePostPrelovedRepo() {
54940
55348
  ...status && {
54941
55349
  status: { $in: Array.isArray(status) ? status : [status] }
54942
55350
  },
54943
- ...categoryIds && { category: { $in: categoryIds } }
55351
+ ...categoryId && { category: categoryId },
55352
+ ...subcategoryIds && { subcategory: { $in: subcategoryIds } }
54944
55353
  };
54945
55354
  const sortObj = buildSortObj(filter);
54946
55355
  try {
@@ -55101,7 +55510,8 @@ function usePostPrelovedController() {
55101
55510
  import_joi134.default.array().items(import_joi134.default.string().valid(...Object.values(PostStatus))),
55102
55511
  import_joi134.default.string().valid(...Object.values(PostStatus))
55103
55512
  ).optional().allow(null),
55104
- category: import_joi134.default.alternatives().try(import_joi134.default.array().items(import_joi134.default.string().hex()), import_joi134.default.string().hex()).optional().allow(null)
55513
+ category: import_joi134.default.string().hex().length(24).optional().allow("", null),
55514
+ subcategory: import_joi134.default.alternatives().try(import_joi134.default.array().items(import_joi134.default.string())).optional().allow(null, "")
55105
55515
  });
55106
55516
  const { error, value } = validation.validate(req.query, {
55107
55517
  abortEarly: false
@@ -55112,7 +55522,7 @@ function usePostPrelovedController() {
55112
55522
  next(new import_node_server_utils236.BadRequestError(messages));
55113
55523
  return;
55114
55524
  }
55115
- const { page, limit, search, filter, site, status, category } = value;
55525
+ const { page, limit, search, filter, site, status, category, subcategory } = value;
55116
55526
  try {
55117
55527
  const data = await _getAll({
55118
55528
  page,
@@ -55121,7 +55531,8 @@ function usePostPrelovedController() {
55121
55531
  filter,
55122
55532
  site,
55123
55533
  status: status ? Array.isArray(status) ? status : [status] : void 0,
55124
- category: category ? Array.isArray(category) ? category : [category] : void 0
55534
+ category: category ?? void 0,
55535
+ subcategory: subcategory ? Array.isArray(subcategory) ? subcategory : [subcategory] : void 0
55125
55536
  });
55126
55537
  res.status(200).json(data);
55127
55538
  return;