@bonifaceebuka/core-backend 1.0.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.
Files changed (488) hide show
  1. package/Readme.md +33 -0
  2. package/dist/app.js +59 -0
  3. package/dist/common/configs/axios.d.ts +7 -0
  4. package/dist/common/configs/axios.d.ts.map +1 -0
  5. package/dist/common/configs/axios.js +26 -0
  6. package/dist/common/configs/cloudinary.d.ts +3 -0
  7. package/dist/common/configs/cloudinary.d.ts.map +1 -0
  8. package/dist/common/configs/cloudinary.js +10 -0
  9. package/dist/common/configs/cors.d.ts +8 -0
  10. package/dist/common/configs/cors.d.ts.map +1 -0
  11. package/dist/common/configs/cors.js +23 -0
  12. package/dist/common/configs/express.js +29 -0
  13. package/dist/common/configs/index.d.ts +111 -0
  14. package/dist/common/configs/index.d.ts.map +1 -0
  15. package/dist/common/configs/index.js +168 -0
  16. package/dist/common/configs/logger.d.ts +3 -0
  17. package/dist/common/configs/logger.d.ts.map +1 -0
  18. package/dist/common/configs/logger.js +66 -0
  19. package/dist/common/configs/mailing.d.ts +4 -0
  20. package/dist/common/configs/mailing.d.ts.map +1 -0
  21. package/dist/common/configs/mailing.js +22 -0
  22. package/dist/common/configs/plans.d.ts +15 -0
  23. package/dist/common/configs/plans.d.ts.map +1 -0
  24. package/dist/common/configs/plans.js +17 -0
  25. package/dist/common/configs/postgres.d.ts +4 -0
  26. package/dist/common/configs/postgres.d.ts.map +1 -0
  27. package/dist/common/configs/postgres.js +25 -0
  28. package/dist/common/configs/redis.d.ts +5 -0
  29. package/dist/common/configs/redis.d.ts.map +1 -0
  30. package/dist/common/configs/redis.js +78 -0
  31. package/dist/common/configs/sendgrid.d.ts +3 -0
  32. package/dist/common/configs/sendgrid.d.ts.map +1 -0
  33. package/dist/common/configs/sendgrid.js +21 -0
  34. package/dist/common/configs/websocket.js +17 -0
  35. package/dist/common/constants/chat.d.ts +18 -0
  36. package/dist/common/constants/chat.d.ts.map +1 -0
  37. package/dist/common/constants/chat.js +20 -0
  38. package/dist/common/constants/messages/admin.messages.d.ts +33 -0
  39. package/dist/common/constants/messages/admin.messages.d.ts.map +1 -0
  40. package/dist/common/constants/messages/admin.messages.js +35 -0
  41. package/dist/common/constants/messages/index.d.ts +19 -0
  42. package/dist/common/constants/messages/index.d.ts.map +1 -0
  43. package/dist/common/constants/messages/index.js +21 -0
  44. package/dist/common/constants/messages/user.messages.d.ts +33 -0
  45. package/dist/common/constants/messages/user.messages.d.ts.map +1 -0
  46. package/dist/common/constants/messages/user.messages.js +35 -0
  47. package/dist/common/dtos/AdminDto.d.ts +5 -0
  48. package/dist/common/dtos/AdminDto.d.ts.map +1 -0
  49. package/dist/common/dtos/AdminDto.js +30 -0
  50. package/dist/common/dtos/ArticleDto.d.ts +11 -0
  51. package/dist/common/dtos/ArticleDto.d.ts.map +1 -0
  52. package/dist/common/dtos/ArticleDto.js +61 -0
  53. package/dist/common/dtos/BusinessDto.d.ts +12 -0
  54. package/dist/common/dtos/BusinessDto.d.ts.map +1 -0
  55. package/dist/common/dtos/BusinessDto.js +59 -0
  56. package/dist/common/dtos/ChatDto.d.ts +17 -0
  57. package/dist/common/dtos/ChatDto.d.ts.map +1 -0
  58. package/dist/common/dtos/ChatDto.js +89 -0
  59. package/dist/common/dtos/CommonDto.d.ts +13 -0
  60. package/dist/common/dtos/CommonDto.d.ts.map +1 -0
  61. package/dist/common/dtos/CommonDto.js +59 -0
  62. package/dist/common/dtos/CommunityDto.d.ts +10 -0
  63. package/dist/common/dtos/CommunityDto.d.ts.map +1 -0
  64. package/dist/common/dtos/CommunityDto.js +72 -0
  65. package/dist/common/dtos/EventDto.d.ts +24 -0
  66. package/dist/common/dtos/EventDto.d.ts.map +1 -0
  67. package/dist/common/dtos/EventDto.js +72 -0
  68. package/dist/common/dtos/IPaginator.d.ts +15 -0
  69. package/dist/common/dtos/IPaginator.d.ts.map +1 -0
  70. package/dist/common/dtos/IPaginator.js +40 -0
  71. package/dist/common/dtos/Paginator.d.ts +15 -0
  72. package/dist/common/dtos/Paginator.d.ts.map +1 -0
  73. package/dist/common/dtos/Paginator.js +40 -0
  74. package/dist/common/dtos/Plan.dto.d.ts +10 -0
  75. package/dist/common/dtos/Plan.dto.d.ts.map +1 -0
  76. package/dist/common/dtos/Plan.dto.js +66 -0
  77. package/dist/common/dtos/PostDto.d.ts +13 -0
  78. package/dist/common/dtos/PostDto.d.ts.map +1 -0
  79. package/dist/common/dtos/PostDto.js +75 -0
  80. package/dist/common/dtos/ProductDto.d.ts +13 -0
  81. package/dist/common/dtos/ProductDto.d.ts.map +1 -0
  82. package/dist/common/dtos/ProductDto.js +66 -0
  83. package/dist/common/dtos/ServiceDto.d.ts +19 -0
  84. package/dist/common/dtos/ServiceDto.d.ts.map +1 -0
  85. package/dist/common/dtos/ServiceDto.js +93 -0
  86. package/dist/common/dtos/UserDto.d.ts +70 -0
  87. package/dist/common/dtos/UserDto.d.ts.map +1 -0
  88. package/dist/common/dtos/UserDto.js +313 -0
  89. package/dist/common/enums/ChatEnum.d.ts +6 -0
  90. package/dist/common/enums/ChatEnum.d.ts.map +1 -0
  91. package/dist/common/enums/ChatEnum.js +9 -0
  92. package/dist/common/enums/CommunityEnum.d.ts +14 -0
  93. package/dist/common/enums/CommunityEnum.d.ts.map +1 -0
  94. package/dist/common/enums/CommunityEnum.js +19 -0
  95. package/dist/common/enums/ConnectionEnum.d.ts +11 -0
  96. package/dist/common/enums/ConnectionEnum.d.ts.map +1 -0
  97. package/dist/common/enums/ConnectionEnum.js +15 -0
  98. package/dist/common/enums/EventEnum.d.ts +7 -0
  99. package/dist/common/enums/EventEnum.d.ts.map +1 -0
  100. package/dist/common/enums/EventEnum.js +10 -0
  101. package/dist/common/enums/IndexEnum.d.ts +56 -0
  102. package/dist/common/enums/IndexEnum.d.ts.map +1 -0
  103. package/dist/common/enums/IndexEnum.js +67 -0
  104. package/dist/common/enums/MarketplaceEnum.d.ts +9 -0
  105. package/dist/common/enums/MarketplaceEnum.d.ts.map +1 -0
  106. package/dist/common/enums/MarketplaceEnum.js +13 -0
  107. package/dist/common/enums/NotificationEnum.d.ts +7 -0
  108. package/dist/common/enums/NotificationEnum.d.ts.map +1 -0
  109. package/dist/common/enums/NotificationEnum.js +10 -0
  110. package/dist/common/enums/TransactionEnum.d.ts +9 -0
  111. package/dist/common/enums/TransactionEnum.d.ts.map +1 -0
  112. package/dist/common/enums/TransactionEnum.js +13 -0
  113. package/dist/common/enums/UploadEnum.d.ts +15 -0
  114. package/dist/common/enums/UploadEnum.d.ts.map +1 -0
  115. package/dist/common/enums/UploadEnum.js +19 -0
  116. package/dist/common/enums/UserEnums.d.ts +36 -0
  117. package/dist/common/enums/UserEnums.d.ts.map +1 -0
  118. package/dist/common/enums/UserEnums.js +44 -0
  119. package/dist/common/enums/index.d.ts +65 -0
  120. package/dist/common/enums/index.d.ts.map +1 -0
  121. package/dist/common/enums/index.js +90 -0
  122. package/dist/common/errors/AppError.d.ts +6 -0
  123. package/dist/common/errors/AppError.d.ts.map +1 -0
  124. package/dist/common/errors/AppError.js +14 -0
  125. package/dist/common/types/HttpType.d.ts +11 -0
  126. package/dist/common/types/HttpType.d.ts.map +1 -0
  127. package/dist/common/types/HttpType.js +47 -0
  128. package/dist/common/types/IPagination.d.ts +15 -0
  129. package/dist/common/types/IPagination.d.ts.map +1 -0
  130. package/dist/common/types/IPagination.js +2 -0
  131. package/dist/common/types/Isocket.d.ts +6 -0
  132. package/dist/common/types/Isocket.d.ts.map +1 -0
  133. package/dist/common/types/Isocket.js +2 -0
  134. package/dist/common/types/chatType.d.ts +36 -0
  135. package/dist/common/types/chatType.d.ts.map +1 -0
  136. package/dist/common/types/chatType.js +2 -0
  137. package/dist/common/types/index.d.ts +6 -0
  138. package/dist/common/types/index.d.ts.map +1 -0
  139. package/dist/common/types/index.js +21 -0
  140. package/dist/common/types/mail.d.ts +7 -0
  141. package/dist/common/types/mail.d.ts.map +1 -0
  142. package/dist/common/types/mail.js +2 -0
  143. package/dist/common/types/uploadsType.d.ts +14 -0
  144. package/dist/common/types/uploadsType.d.ts.map +1 -0
  145. package/dist/common/types/uploadsType.js +45 -0
  146. package/dist/common/utils/axios.js +26 -0
  147. package/dist/common/utils/index.d.ts +28 -0
  148. package/dist/common/utils/index.d.ts.map +1 -0
  149. package/dist/common/utils/index.js +159 -0
  150. package/dist/common/utils/mailing.d.ts +2 -0
  151. package/dist/common/utils/mailing.d.ts.map +1 -0
  152. package/dist/common/utils/mailing.js +76 -0
  153. package/dist/common/utils/number_utils.d.ts +3 -0
  154. package/dist/common/utils/number_utils.d.ts.map +1 -0
  155. package/dist/common/utils/number_utils.js +10 -0
  156. package/dist/common/utils/responseHandlers.d.ts +44 -0
  157. package/dist/common/utils/responseHandlers.d.ts.map +1 -0
  158. package/dist/common/utils/responseHandlers.js +49 -0
  159. package/dist/common/utils/security.d.ts +7 -0
  160. package/dist/common/utils/security.d.ts.map +1 -0
  161. package/dist/common/utils/security.js +44 -0
  162. package/dist/common/utils/socket.js +16 -0
  163. package/dist/common/utils/validator.d.ts +6 -0
  164. package/dist/common/utils/validator.d.ts.map +1 -0
  165. package/dist/common/utils/validator.js +43 -0
  166. package/dist/database/migrations/1765969273227-create-base-migrations.d.ts +7 -0
  167. package/dist/database/migrations/1765969273227-create-base-migrations.d.ts.map +1 -0
  168. package/dist/database/migrations/1765969273227-create-base-migrations.js +53 -0
  169. package/dist/database/migrations/1765981653813-modify-users-table.d.ts +7 -0
  170. package/dist/database/migrations/1765981653813-modify-users-table.d.ts.map +1 -0
  171. package/dist/database/migrations/1765981653813-modify-users-table.js +19 -0
  172. package/dist/database/migrations/1766478443902-create_step_one_form_data_tables.d.ts +7 -0
  173. package/dist/database/migrations/1766478443902-create_step_one_form_data_tables.d.ts.map +1 -0
  174. package/dist/database/migrations/1766478443902-create_step_one_form_data_tables.js +79 -0
  175. package/dist/database/migrations/1766482587930-create_speeches_table.d.ts +7 -0
  176. package/dist/database/migrations/1766482587930-create_speeches_table.d.ts.map +1 -0
  177. package/dist/database/migrations/1766482587930-create_speeches_table.js +91 -0
  178. package/dist/database/migrations/1766486689085-create_challenges_and_education_table.d.ts +7 -0
  179. package/dist/database/migrations/1766486689085-create_challenges_and_education_table.d.ts.map +1 -0
  180. package/dist/database/migrations/1766486689085-create_challenges_and_education_table.js +21 -0
  181. package/dist/database/migrations/1766488441761-create_goals_table.d.ts +7 -0
  182. package/dist/database/migrations/1766488441761-create_goals_table.d.ts.map +1 -0
  183. package/dist/database/migrations/1766488441761-create_goals_table.js +13 -0
  184. package/dist/database/migrations/1766596709454-events_related_tables.d.ts +7 -0
  185. package/dist/database/migrations/1766596709454-events_related_tables.d.ts.map +1 -0
  186. package/dist/database/migrations/1766596709454-events_related_tables.js +27 -0
  187. package/dist/database/migrations/1767290352669-changed_country_to_location_events_table.d.ts +7 -0
  188. package/dist/database/migrations/1767290352669-changed_country_to_location_events_table.d.ts.map +1 -0
  189. package/dist/database/migrations/1767290352669-changed_country_to_location_events_table.js +47 -0
  190. package/dist/database/migrations/1767290877959-indexed_users_table.d.ts +7 -0
  191. package/dist/database/migrations/1767290877959-indexed_users_table.d.ts.map +1 -0
  192. package/dist/database/migrations/1767290877959-indexed_users_table.js +13 -0
  193. package/dist/database/migrations/1767291527448-indexed_tables.d.ts +7 -0
  194. package/dist/database/migrations/1767291527448-indexed_tables.d.ts.map +1 -0
  195. package/dist/database/migrations/1767291527448-indexed_tables.js +71 -0
  196. package/dist/database/migrations/1767292081954-added_event_venue_column_to_events_table.d.ts +7 -0
  197. package/dist/database/migrations/1767292081954-added_event_venue_column_to_events_table.d.ts.map +1 -0
  198. package/dist/database/migrations/1767292081954-added_event_venue_column_to_events_table.js +13 -0
  199. package/dist/database/migrations/1767369618268-create_billings_related_table.d.ts +7 -0
  200. package/dist/database/migrations/1767369618268-create_billings_related_table.d.ts.map +1 -0
  201. package/dist/database/migrations/1767369618268-create_billings_related_table.js +45 -0
  202. package/dist/database/migrations/1767404043438-create_billings_related_tables.d.ts +7 -0
  203. package/dist/database/migrations/1767404043438-create_billings_related_tables.d.ts.map +1 -0
  204. package/dist/database/migrations/1767404043438-create_billings_related_tables.js +19 -0
  205. package/dist/database/migrations/1767617739297-update_tables.d.ts +7 -0
  206. package/dist/database/migrations/1767617739297-update_tables.d.ts.map +1 -0
  207. package/dist/database/migrations/1767617739297-update_tables.js +27 -0
  208. package/dist/database/migrations/1767717097064-create_event_attendance_table.d.ts +7 -0
  209. package/dist/database/migrations/1767717097064-create_event_attendance_table.d.ts.map +1 -0
  210. package/dist/database/migrations/1767717097064-create_event_attendance_table.js +40 -0
  211. package/dist/database/migrations/1767792070012-added_more_fields_to_users_table.d.ts +7 -0
  212. package/dist/database/migrations/1767792070012-added_more_fields_to_users_table.d.ts.map +1 -0
  213. package/dist/database/migrations/1767792070012-added_more_fields_to_users_table.js +17 -0
  214. package/dist/database/migrations/1767878654013-added_more_fields_to_users_table.d.ts +7 -0
  215. package/dist/database/migrations/1767878654013-added_more_fields_to_users_table.d.ts.map +1 -0
  216. package/dist/database/migrations/1767878654013-added_more_fields_to_users_table.js +15 -0
  217. package/dist/database/migrations/1767882191474-added_more_fields_to_events_table.d.ts +7 -0
  218. package/dist/database/migrations/1767882191474-added_more_fields_to_events_table.d.ts.map +1 -0
  219. package/dist/database/migrations/1767882191474-added_more_fields_to_events_table.js +17 -0
  220. package/dist/database/migrations/1767883990258-added_coordinates_field_to_events_table.d.ts +7 -0
  221. package/dist/database/migrations/1767883990258-added_coordinates_field_to_events_table.d.ts.map +1 -0
  222. package/dist/database/migrations/1767883990258-added_coordinates_field_to_events_table.js +19 -0
  223. package/dist/database/migrations/1767890415337-added_coordinates_field_to_user_profiles_table.d.ts +7 -0
  224. package/dist/database/migrations/1767890415337-added_coordinates_field_to_user_profiles_table.d.ts.map +1 -0
  225. package/dist/database/migrations/1767890415337-added_coordinates_field_to_user_profiles_table.js +15 -0
  226. package/dist/database/migrations/1767891781321-create_location_gist_index.d.ts +6 -0
  227. package/dist/database/migrations/1767891781321-create_location_gist_index.d.ts.map +1 -0
  228. package/dist/database/migrations/1767891781321-create_location_gist_index.js +26 -0
  229. package/dist/database/migrations/1768486598835-create_comunity_creation_tables.d.ts +7 -0
  230. package/dist/database/migrations/1768486598835-create_comunity_creation_tables.d.ts.map +1 -0
  231. package/dist/database/migrations/1768486598835-create_comunity_creation_tables.js +47 -0
  232. package/dist/database/migrations/1768489253067-create_comunity_creation_tables.d.ts +7 -0
  233. package/dist/database/migrations/1768489253067-create_comunity_creation_tables.d.ts.map +1 -0
  234. package/dist/database/migrations/1768489253067-create_comunity_creation_tables.js +19 -0
  235. package/dist/database/migrations/1768713527323-create_posts_table.d.ts +7 -0
  236. package/dist/database/migrations/1768713527323-create_posts_table.d.ts.map +1 -0
  237. package/dist/database/migrations/1768713527323-create_posts_table.js +29 -0
  238. package/dist/database/migrations/1768888281914-create_post_comments_table.d.ts +7 -0
  239. package/dist/database/migrations/1768888281914-create_post_comments_table.d.ts.map +1 -0
  240. package/dist/database/migrations/1768888281914-create_post_comments_table.js +45 -0
  241. package/dist/database/migrations/1768897962516-tightened_the_likable_type_field_in_likes_table.d.ts +7 -0
  242. package/dist/database/migrations/1768897962516-tightened_the_likable_type_field_in_likes_table.d.ts.map +1 -0
  243. package/dist/database/migrations/1768897962516-tightened_the_likable_type_field_in_likes_table.js +21 -0
  244. package/dist/database/migrations/1769721210774-create_products_table.d.ts +7 -0
  245. package/dist/database/migrations/1769721210774-create_products_table.d.ts.map +1 -0
  246. package/dist/database/migrations/1769721210774-create_products_table.js +97 -0
  247. package/dist/database/migrations/1769728749602-modified_products_table.d.ts +7 -0
  248. package/dist/database/migrations/1769728749602-modified_products_table.d.ts.map +1 -0
  249. package/dist/database/migrations/1769728749602-modified_products_table.js +13 -0
  250. package/dist/database/migrations/1769852101831-create_businesses_table.d.ts +7 -0
  251. package/dist/database/migrations/1769852101831-create_businesses_table.d.ts.map +1 -0
  252. package/dist/database/migrations/1769852101831-create_businesses_table.js +35 -0
  253. package/dist/database/migrations/1769854726115-modified_businesses_table.d.ts +7 -0
  254. package/dist/database/migrations/1769854726115-modified_businesses_table.d.ts.map +1 -0
  255. package/dist/database/migrations/1769854726115-modified_businesses_table.js +17 -0
  256. package/dist/database/migrations/1770059807138-nullified_title_posts_table.d.ts +7 -0
  257. package/dist/database/migrations/1770059807138-nullified_title_posts_table.d.ts.map +1 -0
  258. package/dist/database/migrations/1770059807138-nullified_title_posts_table.js +25 -0
  259. package/dist/database/migrations/1770108116282-added_business_id_products_table.d.ts +7 -0
  260. package/dist/database/migrations/1770108116282-added_business_id_products_table.d.ts.map +1 -0
  261. package/dist/database/migrations/1770108116282-added_business_id_products_table.js +15 -0
  262. package/dist/database/migrations/1770145991793-create_service_providers_table.d.ts +7 -0
  263. package/dist/database/migrations/1770145991793-create_service_providers_table.d.ts.map +1 -0
  264. package/dist/database/migrations/1770145991793-create_service_providers_table.js +39 -0
  265. package/dist/database/migrations/1770202856432-modified_service_providers_table.d.ts +7 -0
  266. package/dist/database/migrations/1770202856432-modified_service_providers_table.d.ts.map +1 -0
  267. package/dist/database/migrations/1770202856432-modified_service_providers_table.js +23 -0
  268. package/dist/database/migrations/1770203361907-modified_service_providers_table.d.ts +7 -0
  269. package/dist/database/migrations/1770203361907-modified_service_providers_table.d.ts.map +1 -0
  270. package/dist/database/migrations/1770203361907-modified_service_providers_table.js +15 -0
  271. package/dist/database/migrations/1770221489298-modified_service_providers_table.d.ts +7 -0
  272. package/dist/database/migrations/1770221489298-modified_service_providers_table.d.ts.map +1 -0
  273. package/dist/database/migrations/1770221489298-modified_service_providers_table.js +15 -0
  274. package/dist/database/migrations/1770234277025-added_category_id_to_service_providers_table.d.ts +7 -0
  275. package/dist/database/migrations/1770234277025-added_category_id_to_service_providers_table.d.ts.map +1 -0
  276. package/dist/database/migrations/1770234277025-added_category_id_to_service_providers_table.js +15 -0
  277. package/dist/database/migrations/1770235034364-added_category_id_to_service_providers_table.d.ts +7 -0
  278. package/dist/database/migrations/1770235034364-added_category_id_to_service_providers_table.d.ts.map +1 -0
  279. package/dist/database/migrations/1770235034364-added_category_id_to_service_providers_table.js +17 -0
  280. package/dist/database/migrations/1770459229926-create_articles_table.d.ts +7 -0
  281. package/dist/database/migrations/1770459229926-create_articles_table.d.ts.map +1 -0
  282. package/dist/database/migrations/1770459229926-create_articles_table.js +61 -0
  283. package/dist/database/migrations/1770544472943-modified_users_table.d.ts +7 -0
  284. package/dist/database/migrations/1770544472943-modified_users_table.d.ts.map +1 -0
  285. package/dist/database/migrations/1770544472943-modified_users_table.js +15 -0
  286. package/dist/database/migrations/1770556066865-create_chats_table.d.ts +7 -0
  287. package/dist/database/migrations/1770556066865-create_chats_table.d.ts.map +1 -0
  288. package/dist/database/migrations/1770556066865-create_chats_table.js +37 -0
  289. package/dist/database/migrations/1770557237871-modified_chats_table.d.ts +7 -0
  290. package/dist/database/migrations/1770557237871-modified_chats_table.d.ts.map +1 -0
  291. package/dist/database/migrations/1770557237871-modified_chats_table.js +21 -0
  292. package/dist/database/migrations/1770559802657-modified_chats_table.d.ts +7 -0
  293. package/dist/database/migrations/1770559802657-modified_chats_table.d.ts.map +1 -0
  294. package/dist/database/migrations/1770559802657-modified_chats_table.js +27 -0
  295. package/dist/database/migrations/1770570310226-modified_chats_table.d.ts +7 -0
  296. package/dist/database/migrations/1770570310226-modified_chats_table.d.ts.map +1 -0
  297. package/dist/database/migrations/1770570310226-modified_chats_table.js +29 -0
  298. package/dist/database/migrations/1770574652097-modified_chats_table.d.ts +7 -0
  299. package/dist/database/migrations/1770574652097-modified_chats_table.d.ts.map +1 -0
  300. package/dist/database/migrations/1770574652097-modified_chats_table.js +31 -0
  301. package/dist/database/migrations/1770728516930-modified_chats_table.d.ts +7 -0
  302. package/dist/database/migrations/1770728516930-modified_chats_table.d.ts.map +1 -0
  303. package/dist/database/migrations/1770728516930-modified_chats_table.js +23 -0
  304. package/dist/database/seeds/CommunityDataSeeder.js +48 -0
  305. package/dist/database/seeds/EventDataSeeder.js +54 -0
  306. package/dist/database/seeds/FeatureSeeder.js +131 -0
  307. package/dist/database/seeds/MarketplaceDataSeeder.js +95 -0
  308. package/dist/database/seeds/PlanSeeder.js +78 -0
  309. package/dist/database/seeds/UserProfileDataSeeder.js +215 -0
  310. package/dist/database/seeds/index.js +39 -0
  311. package/dist/index.d.ts +11 -0
  312. package/dist/index.d.ts.map +1 -0
  313. package/dist/index.js +26 -0
  314. package/dist/ioc.d.ts +6 -0
  315. package/dist/ioc.d.ts.map +1 -0
  316. package/dist/ioc.js +9 -0
  317. package/dist/models/AdminUserModel.d.ts +18 -0
  318. package/dist/models/AdminUserModel.d.ts.map +1 -0
  319. package/dist/models/AdminUserModel.js +92 -0
  320. package/dist/models/ArticleCommentModel.d.ts +14 -0
  321. package/dist/models/ArticleCommentModel.d.ts.map +1 -0
  322. package/dist/models/ArticleCommentModel.js +69 -0
  323. package/dist/models/ArticleImageModel.d.ts +10 -0
  324. package/dist/models/ArticleImageModel.d.ts.map +1 -0
  325. package/dist/models/ArticleImageModel.js +45 -0
  326. package/dist/models/ArticleModel.d.ts +16 -0
  327. package/dist/models/ArticleModel.d.ts.map +1 -0
  328. package/dist/models/ArticleModel.js +70 -0
  329. package/dist/models/BaseModel.d.ts +8 -0
  330. package/dist/models/BaseModel.d.ts.map +1 -0
  331. package/dist/models/BaseModel.js +43 -0
  332. package/dist/models/BookmarkModel.d.ts +8 -0
  333. package/dist/models/BookmarkModel.d.ts.map +1 -0
  334. package/dist/models/BookmarkModel.js +40 -0
  335. package/dist/models/BusinessCategoryModel.d.ts +5 -0
  336. package/dist/models/BusinessCategoryModel.d.ts.map +1 -0
  337. package/dist/models/BusinessCategoryModel.js +25 -0
  338. package/dist/models/BusinessIdCategoryModel.d.ts +5 -0
  339. package/dist/models/BusinessIdCategoryModel.d.ts.map +1 -0
  340. package/dist/models/BusinessIdCategoryModel.js +25 -0
  341. package/dist/models/BusinessModel.d.ts +22 -0
  342. package/dist/models/BusinessModel.d.ts.map +1 -0
  343. package/dist/models/BusinessModel.js +103 -0
  344. package/dist/models/BusinessServiceModel.d.ts +12 -0
  345. package/dist/models/BusinessServiceModel.d.ts.map +1 -0
  346. package/dist/models/BusinessServiceModel.js +54 -0
  347. package/dist/models/CardModel.d.ts +19 -0
  348. package/dist/models/CardModel.d.ts.map +1 -0
  349. package/dist/models/CardModel.js +91 -0
  350. package/dist/models/CategoryModel.d.ts +5 -0
  351. package/dist/models/CategoryModel.d.ts.map +1 -0
  352. package/dist/models/CategoryModel.js +25 -0
  353. package/dist/models/ChallengeModel.d.ts +6 -0
  354. package/dist/models/ChallengeModel.d.ts.map +1 -0
  355. package/dist/models/ChallengeModel.js +30 -0
  356. package/dist/models/ChatMessageModel.d.ts +16 -0
  357. package/dist/models/ChatMessageModel.d.ts.map +1 -0
  358. package/dist/models/ChatMessageModel.js +75 -0
  359. package/dist/models/CommentModel.d.ts +14 -0
  360. package/dist/models/CommentModel.d.ts.map +1 -0
  361. package/dist/models/CommentModel.js +69 -0
  362. package/dist/models/CommunityMemberModel.d.ts +12 -0
  363. package/dist/models/CommunityMemberModel.d.ts.map +1 -0
  364. package/dist/models/CommunityMemberModel.js +55 -0
  365. package/dist/models/CommunityModel.d.ts +22 -0
  366. package/dist/models/CommunityModel.d.ts.map +1 -0
  367. package/dist/models/CommunityModel.js +97 -0
  368. package/dist/models/CommunityTopicModel.d.ts +10 -0
  369. package/dist/models/CommunityTopicModel.d.ts.map +1 -0
  370. package/dist/models/CommunityTopicModel.js +45 -0
  371. package/dist/models/ConnectionModel.d.ts +11 -0
  372. package/dist/models/ConnectionModel.d.ts.map +1 -0
  373. package/dist/models/ConnectionModel.js +53 -0
  374. package/dist/models/ConversationModel.d.ts +8 -0
  375. package/dist/models/ConversationModel.d.ts.map +1 -0
  376. package/dist/models/ConversationModel.js +43 -0
  377. package/dist/models/DiagnosisLevelModel.d.ts +7 -0
  378. package/dist/models/DiagnosisLevelModel.d.ts.map +1 -0
  379. package/dist/models/DiagnosisLevelModel.js +32 -0
  380. package/dist/models/EducationModel.d.ts +5 -0
  381. package/dist/models/EducationModel.d.ts.map +1 -0
  382. package/dist/models/EducationModel.js +25 -0
  383. package/dist/models/EventAttendanceModel.d.ts +10 -0
  384. package/dist/models/EventAttendanceModel.d.ts.map +1 -0
  385. package/dist/models/EventAttendanceModel.js +45 -0
  386. package/dist/models/EventModel.d.ts +25 -0
  387. package/dist/models/EventModel.d.ts.map +1 -0
  388. package/dist/models/EventModel.js +119 -0
  389. package/dist/models/EventTypeModel.d.ts +7 -0
  390. package/dist/models/EventTypeModel.d.ts.map +1 -0
  391. package/dist/models/EventTypeModel.js +31 -0
  392. package/dist/models/FeatureModel.d.ts +9 -0
  393. package/dist/models/FeatureModel.d.ts.map +1 -0
  394. package/dist/models/FeatureModel.js +50 -0
  395. package/dist/models/GoalModel.d.ts +5 -0
  396. package/dist/models/GoalModel.d.ts.map +1 -0
  397. package/dist/models/GoalModel.js +25 -0
  398. package/dist/models/InterestModel.d.ts +7 -0
  399. package/dist/models/InterestModel.d.ts.map +1 -0
  400. package/dist/models/InterestModel.js +32 -0
  401. package/dist/models/LikeModel.d.ts +10 -0
  402. package/dist/models/LikeModel.d.ts.map +1 -0
  403. package/dist/models/LikeModel.js +48 -0
  404. package/dist/models/NotificationModel.d.ts +14 -0
  405. package/dist/models/NotificationModel.d.ts.map +1 -0
  406. package/dist/models/NotificationModel.js +66 -0
  407. package/dist/models/PaymentGatewayCustomerModel.d.ts +6 -0
  408. package/dist/models/PaymentGatewayCustomerModel.d.ts.map +1 -0
  409. package/dist/models/PaymentGatewayCustomerModel.js +31 -0
  410. package/dist/models/PlanFeatureModel.d.ts +11 -0
  411. package/dist/models/PlanFeatureModel.d.ts.map +1 -0
  412. package/dist/models/PlanFeatureModel.js +50 -0
  413. package/dist/models/PlanModel.d.ts +15 -0
  414. package/dist/models/PlanModel.d.ts.map +1 -0
  415. package/dist/models/PlanModel.js +68 -0
  416. package/dist/models/PostImageModel.d.ts +10 -0
  417. package/dist/models/PostImageModel.d.ts.map +1 -0
  418. package/dist/models/PostImageModel.js +45 -0
  419. package/dist/models/PostModel.d.ts +20 -0
  420. package/dist/models/PostModel.d.ts.map +1 -0
  421. package/dist/models/PostModel.js +87 -0
  422. package/dist/models/ProductImageModel.d.ts +10 -0
  423. package/dist/models/ProductImageModel.d.ts.map +1 -0
  424. package/dist/models/ProductImageModel.js +45 -0
  425. package/dist/models/ProductModel.d.ts +20 -0
  426. package/dist/models/ProductModel.d.ts.map +1 -0
  427. package/dist/models/ProductModel.js +96 -0
  428. package/dist/models/ReviewModel.d.ts +7 -0
  429. package/dist/models/ReviewModel.d.ts.map +1 -0
  430. package/dist/models/ReviewModel.js +36 -0
  431. package/dist/models/ServiceProviderModel.d.ts +23 -0
  432. package/dist/models/ServiceProviderModel.d.ts.map +1 -0
  433. package/dist/models/ServiceProviderModel.js +109 -0
  434. package/dist/models/SessionModel.d.ts +8 -0
  435. package/dist/models/SessionModel.d.ts.map +1 -0
  436. package/dist/models/SessionModel.js +40 -0
  437. package/dist/models/SpeechModel.d.ts +7 -0
  438. package/dist/models/SpeechModel.d.ts.map +1 -0
  439. package/dist/models/SpeechModel.js +32 -0
  440. package/dist/models/SubscriptionHistoryModel.d.ts +12 -0
  441. package/dist/models/SubscriptionHistoryModel.d.ts.map +1 -0
  442. package/dist/models/SubscriptionHistoryModel.js +60 -0
  443. package/dist/models/SubscriptionModel.d.ts +11 -0
  444. package/dist/models/SubscriptionModel.d.ts.map +1 -0
  445. package/dist/models/SubscriptionModel.js +53 -0
  446. package/dist/models/TopicModel.d.ts +7 -0
  447. package/dist/models/TopicModel.d.ts.map +1 -0
  448. package/dist/models/TopicModel.js +31 -0
  449. package/dist/models/TransactionModel.d.ts +15 -0
  450. package/dist/models/TransactionModel.d.ts.map +1 -0
  451. package/dist/models/TransactionModel.js +76 -0
  452. package/dist/models/UploadModel.d.ts +24 -0
  453. package/dist/models/UploadModel.d.ts.map +1 -0
  454. package/dist/models/UploadModel.js +119 -0
  455. package/dist/models/UserModel.d.ts +47 -0
  456. package/dist/models/UserModel.d.ts.map +1 -0
  457. package/dist/models/UserModel.js +237 -0
  458. package/dist/models/UserProfileModel.d.ts +28 -0
  459. package/dist/models/UserProfileModel.d.ts.map +1 -0
  460. package/dist/models/UserProfileModel.js +138 -0
  461. package/dist/models/index.d.ts +49 -0
  462. package/dist/models/index.d.ts.map +1 -0
  463. package/dist/models/index.js +64 -0
  464. package/dist/services/StripeService.js +288 -0
  465. package/dist/services/mobile/ArticleCommentService.js +479 -0
  466. package/dist/services/mobile/ArticleService.js +507 -0
  467. package/dist/services/mobile/AuthService.js +362 -0
  468. package/dist/services/mobile/BusinessService.js +267 -0
  469. package/dist/services/mobile/BusinessServiceService.js +383 -0
  470. package/dist/services/mobile/CardService.js +249 -0
  471. package/dist/services/mobile/ChatService.js +324 -0
  472. package/dist/services/mobile/CommunityMemberService.js +193 -0
  473. package/dist/services/mobile/CommunityService.js +561 -0
  474. package/dist/services/mobile/CompleteProfileService.js +308 -0
  475. package/dist/services/mobile/ConnectionService.js +338 -0
  476. package/dist/services/mobile/EventAttendanceService.js +343 -0
  477. package/dist/services/mobile/EventService.js +540 -0
  478. package/dist/services/mobile/NotificationService.js +89 -0
  479. package/dist/services/mobile/PasswordResetService.js +168 -0
  480. package/dist/services/mobile/PlanService.js +85 -0
  481. package/dist/services/mobile/PostCommentService.js +611 -0
  482. package/dist/services/mobile/PostService.js +640 -0
  483. package/dist/services/mobile/ProductService.js +360 -0
  484. package/dist/services/mobile/RedisService.js +16 -0
  485. package/dist/services/mobile/TransactionService.js +51 -0
  486. package/dist/services/mobile/UploadService.js +110 -0
  487. package/dist/services/mobile/UserService.js +128 -0
  488. package/package.json +73 -0
@@ -0,0 +1,479 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const typedi_1 = require("typedi");
16
+ const logger_1 = require("../../common/configs/logger");
17
+ const AppError_1 = require("../../common/errors/AppError");
18
+ const messages_1 = require("../../common/constants/messages");
19
+ const ArticleRepository_1 = require("@/repositories/ArticleRepository");
20
+ const Paginator_1 = require("@/transformers/Paginator");
21
+ const configs_1 = require("@/common/configs");
22
+ const ArticleCommentRepository_1 = require("@/repositories/ArticleCommentRepository");
23
+ const ArticleCommentResource_1 = require("@/transformers/resources/ArticleCommentResource");
24
+ const IndexEnum_1 = require("@/common/enums/IndexEnum");
25
+ const LikeRepository_1 = require("@/repositories/LikeRepository");
26
+ const ArticleCommentModel_1 = __importDefault(require("@/models/ArticleCommentModel"));
27
+ const LikeModel_1 = __importDefault(require("@/models/LikeModel"));
28
+ let ArticleCommentService = class ArticleCommentService {
29
+ articleRepository;
30
+ articleCommentRepository;
31
+ likeRepository;
32
+ constructor() {
33
+ this.articleRepository = new ArticleRepository_1.ArticleRepository();
34
+ this.likeRepository = new LikeRepository_1.LikeRepository();
35
+ this.articleCommentRepository = new ArticleCommentRepository_1.ArticleCommentRepository();
36
+ }
37
+ async createArticleComment(articleCommentData, user_id, article_id) {
38
+ let message;
39
+ const { content, } = articleCommentData;
40
+ const article = await this.articleRepository.basicFindOneByConditions({
41
+ uuid: article_id
42
+ });
43
+ if (!article) {
44
+ message = messages_1.dynamic_messages.NOT_FOUND("Article");
45
+ logger_1.logger.info(message);
46
+ throw new AppError_1.AppError(message, 404);
47
+ }
48
+ const createdArticleComment = await this.articleCommentRepository.create({
49
+ content,
50
+ article_id: article.id,
51
+ user_id
52
+ });
53
+ const comment = await this.articleCommentRepository.findOneAndRelations({
54
+ where: { uuid: createdArticleComment.uuid },
55
+ relations: ['user']
56
+ });
57
+ logger_1.logger.info("Article comment created successfully");
58
+ return {
59
+ successful: true,
60
+ data: comment ? ArticleCommentResource_1.ArticleCommentResource.toJSON(comment, user_id) : null,
61
+ message: "Article comment created successfully"
62
+ };
63
+ }
64
+ async createReplyComment(articleCommentData, user_id, comment_id) {
65
+ let message;
66
+ const { content, } = articleCommentData;
67
+ const parentComment = await this.articleCommentRepository.basicFindOneByConditions({
68
+ uuid: comment_id
69
+ });
70
+ if (!parentComment) {
71
+ message = "We couldn't find the comment you want to reply";
72
+ logger_1.logger.info(message);
73
+ throw new AppError_1.AppError(message, 404);
74
+ }
75
+ const article = await this.articleRepository.basicFindOneByConditions({
76
+ id: parentComment.article_id
77
+ });
78
+ if (!article) {
79
+ message = "We couldn't find the article that should have owned the comment you want to reply";
80
+ logger_1.logger.info(message);
81
+ throw new AppError_1.AppError(message, 404);
82
+ }
83
+ const createdArticleComment = await this.articleCommentRepository.create({
84
+ content,
85
+ article_id: article.id,
86
+ parent_id: parentComment.id,
87
+ user_id
88
+ });
89
+ const comment = await this.articleCommentRepository.findOneAndRelations({
90
+ where: { uuid: createdArticleComment.uuid },
91
+ relations: ['user']
92
+ });
93
+ logger_1.logger.info("Article's comment's reply created successfully");
94
+ return {
95
+ successful: true,
96
+ data: comment ? ArticleCommentResource_1.ArticleCommentResource.toJSON(comment, user_id) : null,
97
+ message: "Article' comment's reply created successfully"
98
+ };
99
+ }
100
+ async getComment(comment_id, user_id) {
101
+ let message;
102
+ const comment = await this.articleCommentRepository.findOneAndRelations({
103
+ where: {
104
+ uuid: comment_id
105
+ },
106
+ relations: ['user']
107
+ });
108
+ if (!comment) {
109
+ message = messages_1.dynamic_messages.NOT_FOUND("Comment");
110
+ logger_1.logger.info(message);
111
+ throw new AppError_1.AppError(message, 404);
112
+ }
113
+ const article = await this.articleRepository.basicFindOneByConditions({
114
+ id: comment.article_id
115
+ });
116
+ if (!article) {
117
+ message = "We couldn't find the article that should have owned this comment";
118
+ logger_1.logger.info(message);
119
+ throw new AppError_1.AppError(message, 404);
120
+ }
121
+ const qb = this.articleCommentRepository
122
+ .getRepo()
123
+ .createQueryBuilder("comment")
124
+ .leftJoin("comment.user", "user")
125
+ .leftJoin("user.user_profile", "profile")
126
+ .leftJoin("profile.avatar", "avatar")
127
+ .where("comment.deleted_at IS NULL")
128
+ .andWhere("comment.article_id = :articleId", { articleId: article.id })
129
+ .andWhere("comment.uuid = :commentId", {
130
+ commentId: comment_id,
131
+ })
132
+ .take(1)
133
+ .orderBy("comment.created_at", "DESC");
134
+ /* ======================
135
+ SELECT FIELDS
136
+ ====================== */
137
+ qb.select([
138
+ "comment.id",
139
+ "comment.uuid",
140
+ "comment.content",
141
+ "comment.created_at",
142
+ "comment.updated_at",
143
+ "user.id",
144
+ "user.uuid",
145
+ "user.full_name",
146
+ "avatar.url AS profile_image_url",
147
+ ]);
148
+ /* ======================
149
+ REPLIES COUNT
150
+ ====================== */
151
+ qb.addSelect(subQuery => {
152
+ return subQuery
153
+ .select("COUNT(r.id)")
154
+ .from(ArticleCommentModel_1.default, "r")
155
+ .where("r.parent_id = comment.id")
156
+ .andWhere("r.deleted_at IS NULL");
157
+ }, "replies_count");
158
+ // Check if user has liked the comment
159
+ qb.addSelect(`
160
+ EXISTS (
161
+ SELECT 1
162
+ FROM likes l
163
+ WHERE l.likeable_id = comment.id
164
+ AND l.likeable_type = :likeType
165
+ AND l.user_id = :user_id
166
+ AND l.deleted_at IS NULL
167
+ )
168
+ `, "has_liked")
169
+ .setParameter("likeType", IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL)
170
+ .setParameter("user_id", user_id);
171
+ /* ======================
172
+ LIKES COUNT (COMMENT)
173
+ ====================== */
174
+ qb.addSelect(subQuery => {
175
+ return subQuery
176
+ .select("COUNT(l.id)")
177
+ .from(LikeModel_1.default, "l")
178
+ .where("l.likeable_id = comment.id")
179
+ .andWhere("l.likeable_type = :commentType")
180
+ .andWhere("l.deleted_at IS NULL");
181
+ }, "likes_count")
182
+ .setParameter("commentType", IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL);
183
+ const { entities, raw } = await qb.getRawAndEntities();
184
+ const foundComment = entities[0];
185
+ const { uuid, content, created_at, updated_at, user } = foundComment;
186
+ const data = {
187
+ uuid,
188
+ content,
189
+ created_at,
190
+ updated_at,
191
+ creator: {
192
+ uuid: user?.uuid,
193
+ full_name: user?.full_name,
194
+ profile_image_url: raw[0]?.profile_image_url,
195
+ },
196
+ replies_count: raw[0]?.replies_count,
197
+ likes_count: raw[0]?.likes_count,
198
+ has_liked: raw[0]?.has_liked,
199
+ };
200
+ return {
201
+ successful: true,
202
+ data,
203
+ message: "Comment fetched successfully!"
204
+ };
205
+ }
206
+ async likeOrUnlikeComment(comment_id, user_id) {
207
+ let message;
208
+ const comment = await this.articleCommentRepository.basicFindOneByConditions({
209
+ uuid: comment_id
210
+ });
211
+ if (!comment) {
212
+ message = "We couldn't find the comment you want to like/unlike";
213
+ logger_1.logger.info(message);
214
+ throw new AppError_1.AppError(message, 404);
215
+ }
216
+ const article = await this.articleRepository.basicFindOneByConditions({
217
+ id: comment.article_id
218
+ });
219
+ if (!article) {
220
+ message = "We couldn't find the article that should have owned the comment you want to like/unlike";
221
+ logger_1.logger.info(message);
222
+ throw new AppError_1.AppError(message, 404);
223
+ }
224
+ const alreadyLikedComment = await this.likeRepository.basicFindOneByConditions({
225
+ likeable_id: comment.id,
226
+ likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL,
227
+ user_id
228
+ });
229
+ if (alreadyLikedComment) {
230
+ // Unlike the comment
231
+ await this.likeRepository.deleteByCondition({
232
+ user_id,
233
+ likeable_id: comment.id,
234
+ likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL
235
+ });
236
+ message = "Comment unliked successfully";
237
+ }
238
+ else {
239
+ // Like the comment
240
+ await this.likeRepository.create({
241
+ user_id,
242
+ likeable_id: comment.id,
243
+ likeable_type: IndexEnum_1.SYS_MODELS.ARTICLE_COMMENT_MODEL
244
+ });
245
+ message = "Comment liked successfully";
246
+ }
247
+ return {
248
+ successful: true,
249
+ data: null,
250
+ message
251
+ };
252
+ }
253
+ async getArticleComments(user_id, article_id, pageNumber) {
254
+ let message;
255
+ const page_number = pageNumber || 1;
256
+ const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
257
+ const article = await this.articleRepository.basicFindOneByConditions({
258
+ uuid: article_id
259
+ });
260
+ if (!article) {
261
+ message = messages_1.dynamic_messages.NOT_FOUND("Article");
262
+ logger_1.logger.info(message);
263
+ throw new AppError_1.AppError(message, 404);
264
+ }
265
+ const paginationDto = {
266
+ page_number, limit
267
+ };
268
+ const { data, total, perPage, page } = await this.articleCommentRepository.getPagedArticleComments(paginationDto, article.id, user_id);
269
+ const { entities, raw } = data;
270
+ const articleCommentEntities = entities;
271
+ const rawArticleComments = raw;
272
+ const articleComments = articleCommentEntities.map((entity, index) => {
273
+ const { uuid, content, created_at, updated_at, user } = entity;
274
+ return {
275
+ uuid,
276
+ content,
277
+ created_at,
278
+ updated_at,
279
+ creator: {
280
+ uuid: user?.uuid,
281
+ full_name: user?.full_name,
282
+ profile_image_url: rawArticleComments[index]?.profile_image_url,
283
+ },
284
+ replies_count: rawArticleComments[index]?.replies_count,
285
+ likes_count: rawArticleComments[index]?.likes_count,
286
+ has_liked: rawArticleComments[index]?.has_liked,
287
+ };
288
+ });
289
+ const pagedArticleComments = (0, Paginator_1.paginator)({
290
+ total,
291
+ perPage,
292
+ currentPage: page_number,
293
+ data: articleComments,
294
+ });
295
+ return {
296
+ successful: true,
297
+ data: pagedArticleComments,
298
+ message: "Comments fetched successfully!"
299
+ };
300
+ }
301
+ async getCommentReplies(user_id, comment_id, pageNumber) {
302
+ let message;
303
+ const page_number = pageNumber || 1;
304
+ const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
305
+ const parentComment = await this.articleCommentRepository.basicFindOneByConditions({
306
+ uuid: comment_id
307
+ });
308
+ if (!parentComment) {
309
+ message = messages_1.dynamic_messages.NOT_FOUND("Comment");
310
+ logger_1.logger.info(message);
311
+ throw new AppError_1.AppError(message, 404);
312
+ }
313
+ const article = await this.articleRepository.basicFindOneByConditions({
314
+ id: parentComment.article_id
315
+ });
316
+ if (!article) {
317
+ message = messages_1.dynamic_messages.NOT_FOUND("Article");
318
+ logger_1.logger.info(message);
319
+ throw new AppError_1.AppError(message, 404);
320
+ }
321
+ const paginationDto = {
322
+ page_number,
323
+ limit
324
+ };
325
+ const { data, total, perPage, page } = await this.articleCommentRepository.getPagedCommentReplies(paginationDto, parentComment.id, user_id);
326
+ const { entities, raw } = data;
327
+ const articleCommentEntities = entities;
328
+ const rawArticleComments = raw;
329
+ const articleComments = articleCommentEntities.map((entity, index) => {
330
+ const { uuid, content, created_at, updated_at, user } = entity;
331
+ return {
332
+ uuid,
333
+ content,
334
+ created_at,
335
+ updated_at,
336
+ creator: {
337
+ uuid: user?.uuid,
338
+ full_name: user?.full_name,
339
+ profile_image_url: rawArticleComments[index]?.profile_image_url,
340
+ },
341
+ replies_count: rawArticleComments[index]?.replies_count,
342
+ likes_count: rawArticleComments[index]?.likes_count,
343
+ has_liked: rawArticleComments[index]?.has_liked,
344
+ };
345
+ });
346
+ const pagedArticleComments = (0, Paginator_1.paginator)({
347
+ total,
348
+ perPage,
349
+ currentPage: page_number,
350
+ data: articleComments,
351
+ });
352
+ return {
353
+ successful: true,
354
+ data: pagedArticleComments,
355
+ message: "Comments fetched successfully!"
356
+ };
357
+ }
358
+ async getCommentLikes(user_id, comment_id, pageNumber) {
359
+ let message;
360
+ const page_number = pageNumber || 1;
361
+ const limit = configs_1.CONFIGS.DATA_FETCH_LIMIT || 10;
362
+ const comment = await this.articleCommentRepository.basicFindOneByConditions({
363
+ uuid: comment_id
364
+ });
365
+ if (!comment) {
366
+ message = messages_1.dynamic_messages.NOT_FOUND("Comment");
367
+ logger_1.logger.info(message);
368
+ throw new AppError_1.AppError(message, 404);
369
+ }
370
+ const article = await this.articleRepository.basicFindOneByConditions({
371
+ id: comment.article_id
372
+ });
373
+ if (!article) {
374
+ message = messages_1.dynamic_messages.NOT_FOUND("Article");
375
+ logger_1.logger.info(message);
376
+ throw new AppError_1.AppError(message, 404);
377
+ }
378
+ const paginationDto = {
379
+ page_number,
380
+ metadata: {
381
+ comment_id: comment.id
382
+ },
383
+ limit
384
+ };
385
+ const { data, total, perPage, page } = await this.likeRepository.getPagedCommentUserLikes(paginationDto, user_id);
386
+ const { entities, raw } = data;
387
+ const commentUserLikes = raw.map((like) => {
388
+ return {
389
+ user: {
390
+ name: like?.user_full_name,
391
+ uuid: like?.user_uuid,
392
+ avatar_url: like?.avatar_url,
393
+ },
394
+ liked_at: like?.like_created_at
395
+ };
396
+ });
397
+ const pagedCommentLikes = (0, Paginator_1.paginator)({
398
+ total,
399
+ perPage,
400
+ currentPage: page_number,
401
+ data: commentUserLikes,
402
+ });
403
+ return {
404
+ successful: true,
405
+ data: pagedCommentLikes,
406
+ message: "Comment likes fetched successfully!"
407
+ };
408
+ }
409
+ async updateOneComment(articleCommentData, comment_id, user_id) {
410
+ let message;
411
+ const { content } = articleCommentData;
412
+ const comment = await this.articleCommentRepository.findOneAndRelations({
413
+ where: {
414
+ uuid: comment_id,
415
+ user_id
416
+ }
417
+ });
418
+ if (!comment) {
419
+ message = "We couldn't find the comment you want to update";
420
+ logger_1.logger.info(message);
421
+ throw new AppError_1.AppError(message, 404);
422
+ }
423
+ const article = await this.articleRepository.basicFindOneByConditions({
424
+ id: comment.article_id
425
+ });
426
+ if (!article) {
427
+ message = "We couldn't find the article that should have owned the comment you want to update";
428
+ logger_1.logger.info(message);
429
+ throw new AppError_1.AppError(message, 404);
430
+ }
431
+ const updatedComment = await this.articleCommentRepository.updateOne({
432
+ uuid: comment.uuid,
433
+ user_id,
434
+ }, {
435
+ content
436
+ });
437
+ return {
438
+ successful: true,
439
+ data: updatedComment,
440
+ message: "Comment updated successfully!"
441
+ };
442
+ }
443
+ async deleteOneComment(comment_id, user_id) {
444
+ let message;
445
+ const comment = await this.articleCommentRepository.findOneAndRelations({
446
+ where: {
447
+ uuid: comment_id,
448
+ user_id
449
+ }
450
+ });
451
+ if (!comment) {
452
+ message = "We couldn't find the comment you want to delete";
453
+ logger_1.logger.info(message);
454
+ throw new AppError_1.AppError(message, 404);
455
+ }
456
+ const article = await this.articleRepository.basicFindOneByConditions({
457
+ id: comment.article_id
458
+ });
459
+ if (!article) {
460
+ message = "We couldn't find the article that should have owned the comment you want to delete";
461
+ logger_1.logger.info(message);
462
+ throw new AppError_1.AppError(message, 404);
463
+ }
464
+ await this.articleCommentRepository.deleteByCondition({
465
+ uuid: comment.uuid,
466
+ user_id,
467
+ });
468
+ return {
469
+ successful: true,
470
+ data: null,
471
+ message: "Comment deleted successfully!"
472
+ };
473
+ }
474
+ };
475
+ ArticleCommentService = __decorate([
476
+ (0, typedi_1.Service)(),
477
+ __metadata("design:paramtypes", [])
478
+ ], ArticleCommentService);
479
+ exports.default = ArticleCommentService;