@aurispec/core-backend 1.0.4 → 1.0.5

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.
Files changed (100) hide show
  1. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts +7 -0
  2. package/dist/database/migrations/1772984882048-modified_reviews_table.d.ts.map +1 -0
  3. package/dist/database/migrations/1772984882048-modified_reviews_table.js +61 -0
  4. package/dist/models/BusinessModel.d.ts +2 -0
  5. package/dist/models/BusinessModel.d.ts.map +1 -1
  6. package/dist/models/BusinessModel.js +9 -0
  7. package/dist/models/ReviewModel.d.ts +5 -0
  8. package/dist/models/ReviewModel.d.ts.map +1 -1
  9. package/dist/models/ReviewModel.js +19 -0
  10. package/dist/models/UserModel.d.ts +2 -0
  11. package/dist/models/UserModel.d.ts.map +1 -1
  12. package/dist/models/UserModel.js +9 -0
  13. package/package.json +1 -1
  14. package/dist/app.js +0 -59
  15. package/dist/common/configs/express.js +0 -29
  16. package/dist/common/configs/websocket.js +0 -17
  17. package/dist/common/constants/chat.d.ts +0 -18
  18. package/dist/common/constants/chat.d.ts.map +0 -1
  19. package/dist/common/constants/chat.js +0 -20
  20. package/dist/common/constants/messages/admin.messages.d.ts +0 -33
  21. package/dist/common/constants/messages/admin.messages.d.ts.map +0 -1
  22. package/dist/common/constants/messages/admin.messages.js +0 -35
  23. package/dist/common/constants/messages/user.messages.d.ts +0 -33
  24. package/dist/common/constants/messages/user.messages.d.ts.map +0 -1
  25. package/dist/common/constants/messages/user.messages.js +0 -35
  26. package/dist/common/dtos/AdminDto.d.ts +0 -5
  27. package/dist/common/dtos/AdminDto.d.ts.map +0 -1
  28. package/dist/common/dtos/AdminDto.js +0 -30
  29. package/dist/common/dtos/ArticleDto.d.ts +0 -11
  30. package/dist/common/dtos/ArticleDto.d.ts.map +0 -1
  31. package/dist/common/dtos/ArticleDto.js +0 -61
  32. package/dist/common/dtos/BusinessDto.d.ts +0 -12
  33. package/dist/common/dtos/BusinessDto.d.ts.map +0 -1
  34. package/dist/common/dtos/BusinessDto.js +0 -59
  35. package/dist/common/dtos/ChatDto.d.ts +0 -17
  36. package/dist/common/dtos/ChatDto.d.ts.map +0 -1
  37. package/dist/common/dtos/ChatDto.js +0 -89
  38. package/dist/common/dtos/CommonDto.d.ts +0 -13
  39. package/dist/common/dtos/CommonDto.d.ts.map +0 -1
  40. package/dist/common/dtos/CommonDto.js +0 -59
  41. package/dist/common/dtos/CommunityDto.d.ts +0 -10
  42. package/dist/common/dtos/CommunityDto.d.ts.map +0 -1
  43. package/dist/common/dtos/CommunityDto.js +0 -72
  44. package/dist/common/dtos/EventDto.d.ts +0 -24
  45. package/dist/common/dtos/EventDto.d.ts.map +0 -1
  46. package/dist/common/dtos/EventDto.js +0 -72
  47. package/dist/common/dtos/IPaginator.d.ts +0 -15
  48. package/dist/common/dtos/IPaginator.d.ts.map +0 -1
  49. package/dist/common/dtos/IPaginator.js +0 -40
  50. package/dist/common/dtos/Plan.dto.d.ts +0 -10
  51. package/dist/common/dtos/Plan.dto.d.ts.map +0 -1
  52. package/dist/common/dtos/Plan.dto.js +0 -66
  53. package/dist/common/dtos/PostDto.d.ts +0 -13
  54. package/dist/common/dtos/PostDto.d.ts.map +0 -1
  55. package/dist/common/dtos/PostDto.js +0 -75
  56. package/dist/common/dtos/ProductDto.d.ts +0 -13
  57. package/dist/common/dtos/ProductDto.d.ts.map +0 -1
  58. package/dist/common/dtos/ProductDto.js +0 -66
  59. package/dist/common/dtos/ServiceDto.d.ts +0 -19
  60. package/dist/common/dtos/ServiceDto.d.ts.map +0 -1
  61. package/dist/common/dtos/ServiceDto.js +0 -93
  62. package/dist/common/dtos/UserDto.d.ts +0 -70
  63. package/dist/common/dtos/UserDto.d.ts.map +0 -1
  64. package/dist/common/dtos/UserDto.js +0 -313
  65. package/dist/common/types/IPagination.d.ts +0 -15
  66. package/dist/common/types/IPagination.d.ts.map +0 -1
  67. package/dist/common/types/IPagination.js +0 -2
  68. package/dist/common/utils/axios.js +0 -26
  69. package/dist/common/utils/socket.js +0 -16
  70. package/dist/database/seeds/CommunityDataSeeder.js +0 -48
  71. package/dist/database/seeds/EventDataSeeder.js +0 -54
  72. package/dist/database/seeds/FeatureSeeder.js +0 -131
  73. package/dist/database/seeds/MarketplaceDataSeeder.js +0 -95
  74. package/dist/database/seeds/PlanSeeder.js +0 -78
  75. package/dist/database/seeds/UserProfileDataSeeder.js +0 -215
  76. package/dist/database/seeds/index.js +0 -39
  77. package/dist/services/StripeService.js +0 -288
  78. package/dist/services/mobile/ArticleCommentService.js +0 -479
  79. package/dist/services/mobile/ArticleService.js +0 -507
  80. package/dist/services/mobile/AuthService.js +0 -362
  81. package/dist/services/mobile/BusinessService.js +0 -267
  82. package/dist/services/mobile/BusinessServiceService.js +0 -383
  83. package/dist/services/mobile/CardService.js +0 -249
  84. package/dist/services/mobile/ChatService.js +0 -324
  85. package/dist/services/mobile/CommunityMemberService.js +0 -193
  86. package/dist/services/mobile/CommunityService.js +0 -561
  87. package/dist/services/mobile/CompleteProfileService.js +0 -308
  88. package/dist/services/mobile/ConnectionService.js +0 -338
  89. package/dist/services/mobile/EventAttendanceService.js +0 -343
  90. package/dist/services/mobile/EventService.js +0 -540
  91. package/dist/services/mobile/NotificationService.js +0 -89
  92. package/dist/services/mobile/PasswordResetService.js +0 -168
  93. package/dist/services/mobile/PlanService.js +0 -85
  94. package/dist/services/mobile/PostCommentService.js +0 -611
  95. package/dist/services/mobile/PostService.js +0 -640
  96. package/dist/services/mobile/ProductService.js +0 -360
  97. package/dist/services/mobile/RedisService.js +0 -16
  98. package/dist/services/mobile/TransactionService.js +0 -51
  99. package/dist/services/mobile/UploadService.js +0 -110
  100. package/dist/services/mobile/UserService.js +0 -128
@@ -1,168 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const typedi_1 = require("typedi");
13
- const UserRepository_1 = require("../../repositories/UserRepository");
14
- const AppError_1 = require("../../common/errors/AppError");
15
- const UserEnums_1 = require("../../common/enums/UserEnums");
16
- const utils_1 = require("../../common/utils");
17
- const EmailProducer_1 = require("../../queues/producers/EmailProducer");
18
- const configs_1 = require("../../common/configs");
19
- const messages_1 = require("../../common/constants/messages");
20
- const logger_1 = require("@/common/configs/logger");
21
- let PasswordResetService = class PasswordResetService {
22
- userRepository;
23
- constructor() {
24
- this.userRepository = new UserRepository_1.UserRepository();
25
- }
26
- async requestPasswordReset(req) {
27
- const { email } = req;
28
- let message;
29
- let whereConditions = {
30
- email,
31
- };
32
- const existingUser = await this.userRepository.basicFindOneByConditions(whereConditions);
33
- if (!existingUser) {
34
- throw new AppError_1.AppError(messages_1.USER_MESSAGES.ACCOUNT.NOT_FOUND, 404);
35
- }
36
- if (existingUser.user_status !== UserEnums_1.AccountStatus.ACTIVE) {
37
- message = "You cannot change the password of an inactive account";
38
- throw new AppError_1.AppError(message, 403);
39
- }
40
- else {
41
- const passwordResetToken = (0, utils_1.generateUUID)();
42
- const { expiresAt, uuid } = passwordResetToken;
43
- const { otp, expireAt: verification_expires_at } = (0, utils_1.generateOTP)(30);
44
- await this.userRepository.updateOne({ uuid: existingUser.uuid, email }, {
45
- reset_token: uuid,
46
- reset_token_expires_at: expiresAt,
47
- reset_otp: otp,
48
- });
49
- const { iv: ivHex, encryptedData } = (0, utils_1.encrypt)(email);
50
- const reset_link = `${configs_1.CONFIGS.MAIN_WEBSITE_BASE_URL}/password/reset/${uuid}?hash=${ivHex}&ref=${encryptedData}`;
51
- const messageBody = {
52
- reset_link,
53
- otp,
54
- first_name: (0, utils_1.capitalizeFirst)(existingUser?.full_name),
55
- email,
56
- };
57
- await (0, EmailProducer_1.sendPasswordResetRequestEmail)(messageBody);
58
- return {
59
- successful: true,
60
- message: messages_1.dynamic_messages.PASSWWORD_RESET_SENT(email),
61
- };
62
- }
63
- }
64
- async setNewPasswordWithOtp(setNewPassword) {
65
- const { confirm_password, otp, new_password } = setNewPassword;
66
- let message;
67
- if (confirm_password !== new_password) {
68
- message = "Confirm password does not match the password";
69
- logger_1.logger.error(message);
70
- throw new AppError_1.AppError(message, 422);
71
- }
72
- const user = await this.userRepository.basicFindOneByConditions({
73
- reset_otp: otp,
74
- });
75
- if (!user) {
76
- message = "Invalid OTP";
77
- logger_1.logger.error(message);
78
- throw new AppError_1.AppError(message, 404);
79
- }
80
- if (user.user_status !== UserEnums_1.AccountStatus.ACTIVE) {
81
- message = "You cannot change the password of an inactive account";
82
- throw new AppError_1.AppError(message, 403);
83
- }
84
- // Check if OTP has expired
85
- const expectedTokenExpirationDate = user.reset_token_expires_at;
86
- const tokenHasExpired = (0, utils_1.hasExpired)(expectedTokenExpirationDate);
87
- if (tokenHasExpired) {
88
- message = "OTP has expired!";
89
- throw new AppError_1.AppError(messages_1.USER_MESSAGES.EMAIL_VERIFICATION.EXPIRED, 403);
90
- }
91
- else {
92
- const password = await (0, utils_1.hashString)(new_password);
93
- const { id, email, full_name } = user;
94
- await this.userRepository.updateOne({
95
- email: user.email,
96
- id,
97
- }, {
98
- reset_otp: null,
99
- password_hash: password,
100
- reset_token_expires_at: null,
101
- reset_token: null,
102
- });
103
- const messageBody = {
104
- email,
105
- first_name: (0, utils_1.capitalizeFirst)(full_name),
106
- login_link: `${configs_1.CONFIGS.MAIN_WEBSITE_BASE_URL}/login`,
107
- contact_link: `${configs_1.CONFIGS.MAIN_WEBSITE_BASE_URL}/contact-us`,
108
- };
109
- await (0, EmailProducer_1.sendPasswordResetConfirmationEmail)(messageBody);
110
- return {
111
- successful: true,
112
- message: `Your account password was successfully changed`,
113
- };
114
- }
115
- }
116
- async setNewPassword(req, hash, ref, reset_token) {
117
- const { confirm_password, new_password } = req;
118
- if (!hash || !ref || !reset_token) {
119
- throw new AppError_1.AppError(messages_1.dynamic_messages.NOT_FOUND("Required params"), 404);
120
- }
121
- if (new_password !== confirm_password) {
122
- throw new AppError_1.AppError("Password must match confirm password", 400);
123
- }
124
- const existingUser = await this.userRepository.basicFindOneByConditions({
125
- reset_token,
126
- });
127
- if (!existingUser) {
128
- throw new AppError_1.AppError(messages_1.USER_MESSAGES.ACCOUNT.NOT_FOUND, 404);
129
- }
130
- else if (existingUser.user_status == UserEnums_1.AccountStatus.PENDING) {
131
- await this.userRepository.updateOne({ uuid: existingUser.uuid, email: existingUser.email }, { user_status: UserEnums_1.AccountStatus.ACTIVE, is_verified: true });
132
- // throw new AppError(
133
- // USER_MESSAGES.AUTH.PASSWWORD_RESET.INACTIVE_ACCOUNT
134
- // );
135
- }
136
- const expectedTokenExpirationDate = existingUser.reset_token_expires_at;
137
- const { id, email } = existingUser;
138
- const tokenHasExpired = (0, utils_1.hasExpired)(expectedTokenExpirationDate);
139
- if (tokenHasExpired) {
140
- throw new AppError_1.AppError(messages_1.USER_MESSAGES.AUTH.PASSWWORD_RESET.EXPIRED, 400);
141
- }
142
- else {
143
- const password = await (0, utils_1.hashString)(new_password);
144
- await this.userRepository.updateOne({ id, email }, {
145
- password_hash: password,
146
- reset_otp: null,
147
- reset_token_expires_at: null,
148
- reset_token: null,
149
- });
150
- }
151
- const messageBody = {
152
- email,
153
- first_name: (0, utils_1.capitalizeFirst)(existingUser?.full_name),
154
- login_link: `${configs_1.CONFIGS.MAIN_WEBSITE_BASE_URL}/login`,
155
- contact_link: `${configs_1.CONFIGS.MAIN_WEBSITE_BASE_URL}/contact-us`,
156
- };
157
- await (0, EmailProducer_1.sendPasswordResetConfirmationEmail)(messageBody);
158
- return {
159
- successful: true,
160
- message: `Your account password was successfully changed`,
161
- };
162
- }
163
- };
164
- PasswordResetService = __decorate([
165
- (0, typedi_1.Service)(),
166
- __metadata("design:paramtypes", [])
167
- ], PasswordResetService);
168
- exports.default = PasswordResetService;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlanService = void 0;
4
- const logger_1 = require("@/common/configs/logger");
5
- const messages_1 = require("@/common/constants/messages");
6
- const AppError_1 = require("@/common/errors/AppError");
7
- const CardRepository_1 = require("@/repositories/CardRepository");
8
- const PlanRepository_1 = require("@/repositories/PlanRepository");
9
- const UserRepository_1 = require("@/repositories/UserRepository");
10
- const PlanCollection_1 = require("@/transformers/collections/PlanCollection");
11
- const SubscriptionHistoryRepository_1 = require("@/repositories/SubscriptionHistoryRepository");
12
- class PlanService {
13
- planRepository;
14
- userRepository;
15
- cardRepository;
16
- subscriptionHistoryRepository;
17
- constructor() {
18
- this.planRepository = new PlanRepository_1.PlanRepository();
19
- this.userRepository = new UserRepository_1.UserRepository();
20
- this.cardRepository = new CardRepository_1.CardRepository();
21
- this.subscriptionHistoryRepository = new SubscriptionHistoryRepository_1.SubscriptionHistoryRepository();
22
- }
23
- async fetchPlanFeatures(user_id) {
24
- let message;
25
- const foundUser = await this.userRepository.findOneAndRelations({
26
- where: { id: user_id },
27
- relations: ['plan']
28
- });
29
- if (!foundUser) {
30
- message = messages_1.dynamic_messages.NOT_FOUND("Your account");
31
- logger_1.logger.error(message);
32
- throw new AppError_1.AppError(message, 404);
33
- }
34
- const plans = await this.planRepository
35
- .getRepo().createQueryBuilder("plan")
36
- .leftJoinAndSelect("plan.planFeatures", "planFeature")
37
- .leftJoinAndSelect("planFeature.feature", "feature")
38
- .getMany();
39
- return {
40
- successful: true,
41
- data: PlanCollection_1.PlanCollection.toJSON(plans, foundUser?.plan_id),
42
- message: messages_1.dynamic_messages.FETCHED_SUCCESSFULLY("Plan features"),
43
- };
44
- }
45
- async setNewPlan(user_id, plan_id) {
46
- let message;
47
- const foundPlan = await this.planRepository.basicFindOneByConditions({
48
- uuid: plan_id
49
- });
50
- if (!foundPlan) {
51
- message = messages_1.dynamic_messages.NOT_FOUND("Your plan");
52
- logger_1.logger.error(message);
53
- throw new AppError_1.AppError(message, 404);
54
- }
55
- const foundUser = await this.userRepository.findOneAndRelations({
56
- where: { id: user_id }
57
- });
58
- if (!foundUser) {
59
- message = messages_1.dynamic_messages.NOT_FOUND("Your account");
60
- logger_1.logger.error(message);
61
- throw new AppError_1.AppError(message, 404);
62
- }
63
- const foundDefaultCard = await this.cardRepository.basicFindOneByConditions({
64
- user_id: foundUser.id,
65
- is_default: true
66
- });
67
- if (!foundDefaultCard) {
68
- message = "You don't have any card set for default payment. Please set that to continue";
69
- logger_1.logger.error(message);
70
- throw new AppError_1.AppError(message, 404);
71
- }
72
- if (foundUser.plan_id == foundPlan.id) {
73
- message = `You already have ${foundPlan.name} as your plan`;
74
- logger_1.logger.error(message);
75
- throw new AppError_1.AppError(message, 400);
76
- }
77
- await this.userRepository.updateOne({ uuid: foundUser.uuid }, { plan_id: foundPlan.id });
78
- return {
79
- successful: true,
80
- data: null,
81
- message: "Plan successfully changed",
82
- };
83
- }
84
- }
85
- exports.PlanService = PlanService;