itlab-internal-services 2.15.7 → 2.16.1

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 (371) hide show
  1. package/README.md +1 -187
  2. package/dist/classes/document-merger.class.js +2 -3
  3. package/dist/classes/index.d.ts +4 -1
  4. package/dist/classes/index.js +7 -3
  5. package/dist/classes/report-category.class.d.ts +55 -0
  6. package/dist/classes/report-category.class.js +120 -0
  7. package/dist/classes/schema-builder.class.d.ts +75 -0
  8. package/dist/classes/schema-builder.class.js +109 -0
  9. package/dist/classes/task-manager.class.d.ts +71 -0
  10. package/dist/classes/task-manager.class.js +99 -0
  11. package/dist/decorators/{account.decorator.d.ts → authenticated-account.decorator.d.ts} +4 -4
  12. package/dist/decorators/{account.decorator.js → authenticated-account.decorator.js} +8 -10
  13. package/dist/decorators/index.d.ts +1 -1
  14. package/dist/decorators/index.js +1 -1
  15. package/dist/exceptions/authenticated-user-required.exception.d.ts +34 -0
  16. package/dist/exceptions/authenticated-user-required.exception.js +51 -0
  17. package/dist/exceptions/bad-body.exception.d.ts +19 -8
  18. package/dist/exceptions/bad-body.exception.js +26 -10
  19. package/dist/exceptions/bad-parameter.exception.d.ts +23 -8
  20. package/dist/exceptions/bad-parameter.exception.js +41 -18
  21. package/dist/exceptions/duplicate.exception.d.ts +20 -8
  22. package/dist/exceptions/duplicate.exception.js +27 -10
  23. package/dist/exceptions/index.d.ts +1 -0
  24. package/dist/exceptions/index.js +1 -0
  25. package/dist/functions/add-views-likes-virtuals.function.d.ts +15 -0
  26. package/dist/functions/add-views-likes-virtuals.function.js +43 -0
  27. package/dist/functions/create-internal-axios-client.function.js +2 -2
  28. package/dist/functions/index.d.ts +1 -0
  29. package/dist/functions/index.js +3 -1
  30. package/dist/index.d.ts +5 -5
  31. package/dist/index.js +5 -5
  32. package/dist/interceptors/attribute-sanitizer.interceptor.d.ts +68 -0
  33. package/dist/interceptors/attribute-sanitizer.interceptor.js +154 -0
  34. package/dist/interceptors/index.d.ts +1 -0
  35. package/dist/interceptors/index.js +17 -0
  36. package/dist/middleware/http-logging.middleware.d.ts +19 -0
  37. package/dist/middleware/http-logging.middleware.js +50 -0
  38. package/dist/middleware/index.d.ts +1 -0
  39. package/dist/middleware/index.js +17 -0
  40. package/dist/models/account.model.d.ts +23 -0
  41. package/dist/models/account.model.js +59 -0
  42. package/dist/models/index.d.ts +3 -1
  43. package/dist/models/index.js +7 -3
  44. package/dist/{modules/search/models → models}/search-document.model.d.ts +1 -1
  45. package/dist/{modules/search/models → models}/search-document.model.js +1 -1
  46. package/dist/models/{account-entity.model.d.ts → user.model.d.ts} +8 -21
  47. package/dist/models/{account-entity.model.js → user.model.js} +11 -25
  48. package/dist/modules/authentication/authentication-module-options.interface.d.ts +2 -8
  49. package/dist/modules/authentication/authentication-options.parameter.d.ts +4 -0
  50. package/dist/modules/authentication/{inject-auth-options.decorator.js → authentication-options.parameter.js} +5 -2
  51. package/dist/modules/authentication/authentication.module.d.ts +23 -0
  52. package/dist/modules/authentication/authentication.module.js +24 -1
  53. package/dist/modules/authentication/guards/index.d.ts +2 -2
  54. package/dist/modules/authentication/guards/index.js +7 -7
  55. package/dist/modules/authentication/guards/jwt-auth.guard.d.ts +17 -0
  56. package/dist/modules/authentication/guards/jwt-auth.guard.js +67 -0
  57. package/dist/modules/authentication/guards/permissions.guard.d.ts +5 -27
  58. package/dist/modules/authentication/guards/permissions.guard.js +27 -59
  59. package/dist/modules/authentication/guards/public.guard.d.ts +7 -13
  60. package/dist/modules/authentication/guards/public.guard.js +10 -24
  61. package/dist/modules/authentication/guards/service-auth.guard.d.ts +22 -0
  62. package/dist/modules/authentication/guards/service-auth.guard.js +65 -0
  63. package/dist/modules/authentication/index.d.ts +3 -3
  64. package/dist/modules/authentication/index.js +3 -5
  65. package/dist/modules/cache/cache-response.interceptor.d.ts +2 -2
  66. package/dist/modules/cache/cache-response.interceptor.js +2 -2
  67. package/dist/modules/cache/index.d.ts +1 -0
  68. package/dist/modules/cache/index.js +1 -0
  69. package/dist/modules/comment/comment-module-options.interface.d.ts +38 -0
  70. package/dist/modules/comment/comment.controller.d.ts +24 -30
  71. package/dist/modules/comment/comment.controller.js +59 -61
  72. package/dist/modules/comment/comment.module-definition.d.ts +1 -42
  73. package/dist/modules/comment/comment.module-definition.js +1 -2
  74. package/dist/modules/comment/comment.module.d.ts +13 -13
  75. package/dist/modules/comment/comment.module.js +15 -42
  76. package/dist/modules/comment/comment.service.d.ts +27 -37
  77. package/dist/modules/comment/comment.service.js +50 -84
  78. package/dist/modules/comment/index.d.ts +2 -3
  79. package/dist/modules/comment/index.js +16 -7
  80. package/dist/modules/database/database.module.js +2 -5
  81. package/dist/modules/database/index.d.ts +2 -5
  82. package/dist/modules/database/index.js +17 -9
  83. package/dist/modules/index.d.ts +2 -6
  84. package/dist/modules/index.js +2 -6
  85. package/dist/modules/like/index.d.ts +2 -1
  86. package/dist/modules/like/index.js +16 -3
  87. package/dist/modules/like/like-module-options.interface.d.ts +21 -0
  88. package/dist/modules/like/like.controller.d.ts +45 -37
  89. package/dist/modules/like/like.controller.js +117 -102
  90. package/dist/modules/like/like.module-definition.d.ts +1 -17
  91. package/dist/modules/like/like.module-definition.js +1 -2
  92. package/dist/modules/like/like.module.d.ts +12 -12
  93. package/dist/modules/like/like.module.js +14 -37
  94. package/dist/modules/like/like.service.d.ts +31 -27
  95. package/dist/modules/like/like.service.js +42 -35
  96. package/dist/modules/merge/index.d.ts +3 -0
  97. package/dist/modules/merge/index.js +19 -0
  98. package/dist/modules/merge/merge-module-options.interface.d.ts +21 -0
  99. package/dist/modules/merge/merge.controller.d.ts +30 -0
  100. package/dist/modules/merge/merge.controller.js +76 -0
  101. package/dist/modules/merge/merge.module.d.ts +18 -0
  102. package/dist/modules/merge/merge.module.js +41 -0
  103. package/dist/modules/merge/merge.service.interface.d.ts +17 -0
  104. package/dist/modules/services/base-http.service.d.ts +83 -0
  105. package/dist/modules/services/base-http.service.js +124 -0
  106. package/dist/modules/services/base-urls.d.ts +22 -0
  107. package/dist/modules/services/base-urls.js +121 -0
  108. package/dist/modules/services/index.d.ts +4 -0
  109. package/dist/modules/services/index.js +20 -0
  110. package/dist/modules/services/providers/accounts.service.d.ts +52 -0
  111. package/dist/modules/services/providers/accounts.service.js +84 -0
  112. package/dist/modules/services/providers/books.service.d.ts +29 -0
  113. package/dist/modules/services/providers/books.service.js +55 -0
  114. package/dist/modules/services/providers/changelog.service.d.ts +18 -0
  115. package/dist/modules/services/providers/changelog.service.js +43 -0
  116. package/dist/modules/services/providers/comments/comments.service-definition.d.ts +1 -0
  117. package/dist/modules/services/providers/comments/comments.service-definition.js +4 -0
  118. package/dist/modules/services/providers/comments/comments.service.d.ts +60 -0
  119. package/dist/modules/services/providers/comments/comments.service.js +139 -0
  120. package/dist/modules/services/providers/comments/index.d.ts +1 -0
  121. package/dist/{factories → modules/services/providers/comments}/index.js +1 -1
  122. package/dist/modules/services/providers/content/content-return-types.d.ts +19 -0
  123. package/dist/modules/services/providers/content/content-return-types.js +7 -0
  124. package/dist/modules/services/providers/content/content.service-definition.d.ts +1 -0
  125. package/dist/modules/services/providers/content/content.service-definition.js +4 -0
  126. package/dist/modules/services/providers/content/content.service.d.ts +96 -0
  127. package/dist/modules/services/providers/content/content.service.js +231 -0
  128. package/dist/modules/services/providers/content/index.d.ts +2 -0
  129. package/dist/modules/{search/models → services/providers/content}/index.js +1 -1
  130. package/dist/modules/services/providers/demo-hive.service.d.ts +29 -0
  131. package/dist/modules/services/providers/demo-hive.service.js +55 -0
  132. package/dist/modules/services/providers/events.service.d.ts +29 -0
  133. package/dist/modules/services/providers/events.service.js +55 -0
  134. package/dist/modules/services/providers/hackschool.service.d.ts +49 -0
  135. package/dist/modules/services/providers/hackschool.service.js +79 -0
  136. package/dist/modules/services/providers/ideas.service.d.ts +18 -0
  137. package/dist/modules/services/providers/ideas.service.js +43 -0
  138. package/dist/modules/services/providers/index.d.ts +19 -0
  139. package/dist/modules/services/providers/index.js +35 -0
  140. package/dist/modules/services/providers/lunch-roulette.service.d.ts +18 -0
  141. package/dist/modules/services/providers/lunch-roulette.service.js +43 -0
  142. package/dist/modules/services/providers/mail/index.d.ts +3 -0
  143. package/dist/modules/services/providers/mail/index.js +19 -0
  144. package/dist/modules/services/providers/mail/mail-types.d.ts +30 -0
  145. package/dist/modules/services/providers/mail/mail-types.js +22 -0
  146. package/dist/modules/services/providers/mail/mail.service.d.ts +99 -0
  147. package/dist/modules/{mail → services/providers/mail}/mail.service.js +55 -92
  148. package/dist/modules/services/providers/newletter.service.d.ts +29 -0
  149. package/dist/modules/services/providers/newletter.service.js +55 -0
  150. package/dist/modules/services/providers/newsroom.service.d.ts +47 -0
  151. package/dist/modules/services/providers/newsroom.service.js +73 -0
  152. package/dist/modules/services/providers/notification/dtos/schedule-notification.dto.js +2 -0
  153. package/dist/modules/services/providers/notification/index.d.ts +2 -0
  154. package/dist/modules/services/providers/notification/index.js +18 -0
  155. package/dist/modules/services/providers/notification/notification.service-definition.d.ts +1 -0
  156. package/dist/modules/services/providers/notification/notification.service-definition.js +4 -0
  157. package/dist/modules/services/providers/notification/notification.service.d.ts +50 -0
  158. package/dist/modules/services/providers/notification/notification.service.js +130 -0
  159. package/dist/modules/services/providers/pass/dtos/create-guild-member-pass.dto.js +2 -0
  160. package/dist/modules/services/providers/pass/dtos/create-team-member-pass.dto.js +2 -0
  161. package/dist/modules/services/providers/pass/index.d.ts +2 -0
  162. package/dist/modules/services/providers/pass/index.js +18 -0
  163. package/dist/modules/services/providers/pass/pass-types.d.ts +18 -0
  164. package/dist/modules/services/providers/pass/pass-types.js +7 -0
  165. package/dist/modules/{pass → services/providers/pass}/pass.service.d.ts +15 -39
  166. package/dist/modules/{pass → services/providers/pass}/pass.service.js +46 -61
  167. package/dist/modules/services/providers/podcasts.service.d.ts +29 -0
  168. package/dist/modules/services/providers/podcasts.service.js +55 -0
  169. package/dist/modules/services/providers/search/dtos/index-search-document.dto.js +2 -0
  170. package/dist/modules/services/providers/search/index.d.ts +2 -0
  171. package/dist/modules/services/providers/search/index.js +18 -0
  172. package/dist/modules/services/providers/search/search.service-definition.d.ts +1 -0
  173. package/dist/modules/services/providers/search/search.service-definition.js +4 -0
  174. package/dist/modules/services/providers/search/search.service.d.ts +66 -0
  175. package/dist/modules/services/providers/search/search.service.js +171 -0
  176. package/dist/modules/services/providers/team.service.d.ts +29 -0
  177. package/dist/modules/services/providers/team.service.js +55 -0
  178. package/dist/modules/services/providers/tech-radar.service.d.ts +39 -0
  179. package/dist/modules/services/providers/tech-radar.service.js +67 -0
  180. package/dist/modules/services/services-module-options.interface.d.ts +4 -0
  181. package/dist/modules/services/services-module-options.interface.js +2 -0
  182. package/dist/modules/services/services-options.parameter.d.ts +1 -0
  183. package/dist/modules/services/services-options.parameter.js +8 -0
  184. package/dist/modules/services/services.module-definition.d.ts +16 -0
  185. package/dist/modules/services/services.module-definition.js +21 -0
  186. package/dist/modules/services/services.module.d.ts +17 -0
  187. package/dist/modules/services/services.module.js +63 -0
  188. package/dist/pipes/index.d.ts +2 -3
  189. package/dist/pipes/index.js +2 -3
  190. package/dist/pipes/params/hub-id.pipe.d.ts +22 -0
  191. package/dist/pipes/{hub-id.pipe.js → params/hub-id.pipe.js} +14 -17
  192. package/dist/pipes/params/hub-resource.pipe.d.ts +22 -0
  193. package/dist/pipes/{hub-resource.pipe.js → params/hub-resource.pipe.js} +19 -20
  194. package/dist/pipes/params/index.d.ts +3 -0
  195. package/dist/pipes/params/index.js +19 -0
  196. package/dist/pipes/params/mongo-id.pipe.d.ts +15 -0
  197. package/dist/pipes/params/mongo-id.pipe.js +52 -0
  198. package/dist/pipes/queries/index.d.ts +3 -0
  199. package/dist/pipes/queries/index.js +19 -0
  200. package/dist/pipes/queries/mongo-ids.pipe.d.ts +22 -0
  201. package/dist/pipes/queries/mongo-ids.pipe.js +60 -0
  202. package/dist/pipes/queries/optional-boolean.pipe.d.ts +29 -0
  203. package/dist/pipes/queries/optional-boolean.pipe.js +72 -0
  204. package/dist/pipes/queries/optional-include-drafts.pipe.d.ts +28 -0
  205. package/dist/pipes/queries/optional-include-drafts.pipe.js +38 -0
  206. package/dist/properties/content-return-type.property.d.ts +7 -0
  207. package/dist/properties/content-return-type.property.js +22 -0
  208. package/dist/properties/index.d.ts +4 -0
  209. package/dist/properties/index.js +11 -0
  210. package/dist/properties/likeable.properties.d.ts +1 -0
  211. package/dist/properties/likeable.properties.js +66 -0
  212. package/dist/properties/viewable.properties.d.ts +1 -0
  213. package/dist/properties/viewable.properties.js +66 -0
  214. package/dist/swagger/index.d.ts +1 -0
  215. package/dist/swagger/index.js +5 -0
  216. package/dist/swagger/remove-public-route-auth.plugin.d.ts +9 -0
  217. package/dist/swagger/remove-public-route-auth.plugin.js +25 -0
  218. package/dist/swagger/swagger-options.interface.d.ts +14 -0
  219. package/dist/swagger/swagger-options.interface.js +2 -0
  220. package/dist/swagger/swagger.function.d.ts +11 -0
  221. package/dist/swagger/swagger.function.js +47 -0
  222. package/dist/transform/boolean.transform.js +3 -3
  223. package/dist/types/index.d.ts +2 -0
  224. package/dist/types/index.js +18 -0
  225. package/dist/types/likeable.type.d.ts +15 -0
  226. package/dist/types/likeable.type.js +2 -0
  227. package/dist/types/viewable.type.d.ts +15 -0
  228. package/dist/types/viewable.type.js +2 -0
  229. package/package.json +2 -2
  230. package/dist/classes/document-updater.class.d.ts +0 -39
  231. package/dist/classes/document-updater.class.js +0 -57
  232. package/dist/factories/index.d.ts +0 -1
  233. package/dist/factories/virtuals.factory.d.ts +0 -79
  234. package/dist/factories/virtuals.factory.js +0 -171
  235. package/dist/http-logger.middleware.d.ts +0 -12
  236. package/dist/http-logger.middleware.js +0 -43
  237. package/dist/likeable.interface.d.ts +0 -41
  238. package/dist/likeable.interface.js +0 -48
  239. package/dist/modules/authentication/guards/auth.guard.d.ts +0 -36
  240. package/dist/modules/authentication/guards/auth.guard.js +0 -107
  241. package/dist/modules/authentication/guards/internal.guard.d.ts +0 -33
  242. package/dist/modules/authentication/guards/internal.guard.js +0 -72
  243. package/dist/modules/authentication/inject-auth-options.decorator.d.ts +0 -1
  244. package/dist/modules/comment/comment.model.d.ts +0 -29
  245. package/dist/modules/comment/comment.model.js +0 -43
  246. package/dist/modules/content/content.module-definition.d.ts +0 -5
  247. package/dist/modules/content/content.module-definition.js +0 -8
  248. package/dist/modules/content/content.module.d.ts +0 -31
  249. package/dist/modules/content/content.module.js +0 -60
  250. package/dist/modules/content/content.service.d.ts +0 -50
  251. package/dist/modules/content/content.service.js +0 -145
  252. package/dist/modules/content/index.d.ts +0 -3
  253. package/dist/modules/content/index.js +0 -9
  254. package/dist/modules/database/model-service/dbs/hub-account.db.d.ts +0 -28
  255. package/dist/modules/database/model-service/dbs/hub-account.db.js +0 -44
  256. package/dist/modules/database/model-service/dbs/hub-books.db.d.ts +0 -23
  257. package/dist/modules/database/model-service/dbs/hub-books.db.js +0 -45
  258. package/dist/modules/database/model-service/dbs/hub-comments.db.d.ts +0 -29
  259. package/dist/modules/database/model-service/dbs/hub-comments.db.js +0 -68
  260. package/dist/modules/database/model-service/dbs/hub-content.db.d.ts +0 -24
  261. package/dist/modules/database/model-service/dbs/hub-content.db.js +0 -49
  262. package/dist/modules/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
  263. package/dist/modules/database/model-service/dbs/hub-demo-hive.db.js +0 -45
  264. package/dist/modules/database/model-service/dbs/hub-events.db.d.ts +0 -24
  265. package/dist/modules/database/model-service/dbs/hub-events.db.js +0 -49
  266. package/dist/modules/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
  267. package/dist/modules/database/model-service/dbs/hub-hackschool.db.js +0 -106
  268. package/dist/modules/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
  269. package/dist/modules/database/model-service/dbs/hub-newsroom.db.js +0 -53
  270. package/dist/modules/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
  271. package/dist/modules/database/model-service/dbs/hub-podcasts.db.js +0 -45
  272. package/dist/modules/database/model-service/dbs/hub-team.db.d.ts +0 -22
  273. package/dist/modules/database/model-service/dbs/hub-team.db.js +0 -41
  274. package/dist/modules/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
  275. package/dist/modules/database/model-service/dbs/hub-tech-radar.db.js +0 -81
  276. package/dist/modules/database/model-service/model.service.d.ts +0 -6407
  277. package/dist/modules/database/model-service/model.service.js +0 -136
  278. package/dist/modules/database/populate-service/populate.service.d.ts +0 -73
  279. package/dist/modules/database/populate-service/populate.service.js +0 -163
  280. package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +0 -32
  281. package/dist/modules/database/service-mapper-service/service-mapper.service.js +0 -73
  282. package/dist/modules/fetch/fetch.module.d.ts +0 -31
  283. package/dist/modules/fetch/fetch.module.js +0 -60
  284. package/dist/modules/fetch/fetch.service.d.ts +0 -153
  285. package/dist/modules/fetch/fetch.service.js +0 -274
  286. package/dist/modules/fetch/index.d.ts +0 -2
  287. package/dist/modules/fetch/index.js +0 -7
  288. package/dist/modules/mail/index.d.ts +0 -4
  289. package/dist/modules/mail/index.js +0 -23
  290. package/dist/modules/mail/mail.module.d.ts +0 -31
  291. package/dist/modules/mail/mail.module.js +0 -60
  292. package/dist/modules/mail/mail.service.d.ts +0 -136
  293. package/dist/modules/notification/index.d.ts +0 -3
  294. package/dist/modules/notification/index.js +0 -22
  295. package/dist/modules/notification/notification.module-definition.d.ts +0 -5
  296. package/dist/modules/notification/notification.module-definition.js +0 -8
  297. package/dist/modules/notification/notification.module.d.ts +0 -34
  298. package/dist/modules/notification/notification.module.js +0 -63
  299. package/dist/modules/notification/notification.service.d.ts +0 -42
  300. package/dist/modules/notification/notification.service.js +0 -100
  301. package/dist/modules/pass/index.d.ts +0 -3
  302. package/dist/modules/pass/index.js +0 -22
  303. package/dist/modules/pass/pass.module.d.ts +0 -32
  304. package/dist/modules/pass/pass.module.js +0 -61
  305. package/dist/modules/search/index.d.ts +0 -4
  306. package/dist/modules/search/index.js +0 -23
  307. package/dist/modules/search/models/index.d.ts +0 -1
  308. package/dist/modules/search/search.module-definition.d.ts +0 -5
  309. package/dist/modules/search/search.module-definition.js +0 -8
  310. package/dist/modules/search/search.module.d.ts +0 -33
  311. package/dist/modules/search/search.module.js +0 -62
  312. package/dist/modules/search/search.service.d.ts +0 -49
  313. package/dist/modules/search/search.service.js +0 -120
  314. package/dist/pipes/hub-id.pipe.d.ts +0 -22
  315. package/dist/pipes/hub-resource.pipe.d.ts +0 -22
  316. package/dist/pipes/mongo-id.pipe.d.ts +0 -14
  317. package/dist/pipes/mongo-id.pipe.js +0 -52
  318. package/dist/swagger.config.d.ts +0 -36
  319. package/dist/swagger.config.js +0 -76
  320. package/dist/viewable.interface.d.ts +0 -41
  321. package/dist/viewable.interface.js +0 -48
  322. /package/dist/modules/{mail/dtos/auth-login-token-mail.dto.js → comment/comment-module-options.interface.js} +0 -0
  323. /package/dist/modules/{mail/dtos/auth-password-reset-mail.dto.js → like/like-module-options.interface.js} +0 -0
  324. /package/dist/modules/{mail/dtos/event-cancel-mail.dto.js → merge/merge-module-options.interface.js} +0 -0
  325. /package/dist/modules/{mail/dtos/event-invite-mail.dto.js → merge/merge.service.interface.js} +0 -0
  326. /package/dist/modules/{mail → services/providers/mail}/dtos/auth-login-token-mail.dto.d.ts +0 -0
  327. /package/dist/modules/{mail/dtos/idea-status-updated-mail.dto.js → services/providers/mail/dtos/auth-login-token-mail.dto.js} +0 -0
  328. /package/dist/modules/{mail → services/providers/mail}/dtos/auth-password-reset-mail.dto.d.ts +0 -0
  329. /package/dist/modules/{mail/dtos/idea-submitted-mail.dto.js → services/providers/mail/dtos/auth-password-reset-mail.dto.js} +0 -0
  330. /package/dist/modules/{mail → services/providers/mail}/dtos/event-cancel-mail.dto.d.ts +0 -0
  331. /package/dist/modules/{mail/dtos/lunch-roulette-cancel-mail.dto.js → services/providers/mail/dtos/event-cancel-mail.dto.js} +0 -0
  332. /package/dist/modules/{mail → services/providers/mail}/dtos/event-invite-mail.dto.d.ts +0 -0
  333. /package/dist/modules/{mail/dtos/lunch-roulette-matched-mail.dto.js → services/providers/mail/dtos/event-invite-mail.dto.js} +0 -0
  334. /package/dist/modules/{mail → services/providers/mail}/dtos/idea-status-updated-mail.dto.d.ts +0 -0
  335. /package/dist/modules/{mail/dtos/lunch-roulette-submitted-mail.dto.js → services/providers/mail/dtos/idea-status-updated-mail.dto.js} +0 -0
  336. /package/dist/modules/{mail → services/providers/mail}/dtos/idea-submitted-mail.dto.d.ts +0 -0
  337. /package/dist/modules/{mail/dtos/lunch-roulette-unmatched-mail.dto.js → services/providers/mail/dtos/idea-submitted-mail.dto.js} +0 -0
  338. /package/dist/modules/{mail → services/providers/mail}/dtos/index.d.ts +0 -0
  339. /package/dist/modules/{mail → services/providers/mail}/dtos/index.js +0 -0
  340. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-cancel-mail.dto.d.ts +0 -0
  341. /package/dist/modules/{mail/dtos/newsletter-issue-mail.dto.js → services/providers/mail/dtos/lunch-roulette-cancel-mail.dto.js} +0 -0
  342. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-matched-mail.dto.d.ts +0 -0
  343. /package/dist/modules/{mail/dtos/newsletter-subscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-matched-mail.dto.js} +0 -0
  344. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-submitted-mail.dto.d.ts +0 -0
  345. /package/dist/modules/{mail/dtos/newsletter-unsubscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-submitted-mail.dto.js} +0 -0
  346. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-unmatched-mail.dto.d.ts +0 -0
  347. /package/dist/modules/{mail/dtos/notification-mail.dto.js → services/providers/mail/dtos/lunch-roulette-unmatched-mail.dto.js} +0 -0
  348. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-issue-mail.dto.d.ts +0 -0
  349. /package/dist/modules/{notification/dtos/schedule-notification.dto.js → services/providers/mail/dtos/newsletter-issue-mail.dto.js} +0 -0
  350. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-subscribed-mail.dto.d.ts +0 -0
  351. /package/dist/modules/{pass/dtos/create-guild-member-pass.dto.js → services/providers/mail/dtos/newsletter-subscribed-mail.dto.js} +0 -0
  352. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-unsubscribed-mail.dto.d.ts +0 -0
  353. /package/dist/modules/{pass/dtos/create-team-member-pass.dto.js → services/providers/mail/dtos/newsletter-unsubscribed-mail.dto.js} +0 -0
  354. /package/dist/modules/{mail → services/providers/mail}/dtos/notification-mail.dto.d.ts +0 -0
  355. /package/dist/modules/{search/dtos/index-search-document.dto.js → services/providers/mail/dtos/notification-mail.dto.js} +0 -0
  356. /package/dist/modules/{mail → services/providers/mail}/models/index.d.ts +0 -0
  357. /package/dist/modules/{mail → services/providers/mail}/models/index.js +0 -0
  358. /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.d.ts +0 -0
  359. /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.js +0 -0
  360. /package/dist/modules/{notification → services/providers/notification}/dtos/index.d.ts +0 -0
  361. /package/dist/modules/{notification → services/providers/notification}/dtos/index.js +0 -0
  362. /package/dist/modules/{notification → services/providers/notification}/dtos/schedule-notification.dto.d.ts +0 -0
  363. /package/dist/modules/{pass → services/providers/pass}/dtos/create-guild-member-pass.dto.d.ts +0 -0
  364. /package/dist/modules/{pass → services/providers/pass}/dtos/create-team-member-pass.dto.d.ts +0 -0
  365. /package/dist/modules/{pass → services/providers/pass}/dtos/index.d.ts +0 -0
  366. /package/dist/modules/{pass → services/providers/pass}/dtos/index.js +0 -0
  367. /package/dist/modules/{search → services/providers/search}/dtos/index-search-document.dto.d.ts +0 -0
  368. /package/dist/modules/{search → services/providers/search}/dtos/index.d.ts +0 -0
  369. /package/dist/modules/{search → services/providers/search}/dtos/index.js +0 -0
  370. /package/dist/{modules/content → properties}/content.property.d.ts +0 -0
  371. /package/dist/{modules/content → properties}/content.property.js +0 -0
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.LikeController = void 0;
15
+ exports.createLikeController = createLikeController;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const swagger_1 = require("@nestjs/swagger");
18
18
  const decorators_1 = require("../../decorators");
@@ -20,106 +20,121 @@ const pipes_1 = require("../../pipes");
20
20
  const authentication_1 = require("../authentication");
21
21
  const like_service_1 = require("./like.service");
22
22
  /**
23
- * LikeController handles all HTTP requests related to "like" interactions on resources.
23
+ * Factory function for creating a LikeController bound to a specific route suffix.
24
24
  *
25
- * It provides endpoints for users to add a like, remove a like, and check if they have liked a resource.
26
- * Authentication is enforced via JWT to ensure only authorized users can interact with these endpoints.
27
- * Resource IDs are validated as MongoDB ObjectIds to maintain data integrity.
25
+ * Why: Instead of writing separate controllers for each resource type,
26
+ * we generate one dynamically. This ensures DRY principles while still
27
+ * supporting custom routes (e.g. `/like/news` or `/like/event`).
28
+ *
29
+ * @param {string} [routeSuffix] - Suffix appended to the "like" route.
30
+ * @returns A dynamically generated controller class.
28
31
  */
29
- let LikeController = class LikeController {
30
- /**
31
- * Initializes LikeController with LikeService dependency.
32
- *
33
- * @param {LikeService} likeService - Service handling like operations.
34
- */
35
- constructor(likeService) {
36
- this.likeService = likeService;
37
- }
38
- /**
39
- * Adds the authenticated user's like to the specified resource.
40
- *
41
- * @param {string} resourceId - MongoDB ObjectId of the resource to be liked.
42
- * @param {string} accountId - The ID of the authenticated account performing the like.
43
- * @returns {Promise<number>} The updated total number of likes after addition.
44
- */
45
- async addLikeToResource(resourceId, accountId) {
46
- return this.likeService.addLike(resourceId, accountId);
47
- }
48
- /**
49
- * Removes the authenticated user's like from the specified resource.
50
- *
51
- * @param {string} resourceId - MongoDB ObjectId of the resource to unlike.
52
- * @param {string} accountId - The ID of the authenticated account removing the like.
53
- * @returns {Promise<number>} The updated total number of likes after removal.
54
- */
55
- async removeLikeFromResource(resourceId, accountId) {
56
- return this.likeService.removeLike(resourceId, accountId);
57
- }
58
- /**
59
- * Checks if the authenticated user has liked the given resource.
60
- *
61
- * @param {string} resourceId - MongoDB ObjectId of the resource.
62
- * @param {string} accountId - The ID of the authenticated account to check.
63
- * @returns {Promise<boolean>} True if the user has liked the resource, false otherwise.
64
- */
65
- async isResourceLikedByUser(resourceId, accountId) {
66
- return this.likeService.hasLiked(resourceId, accountId);
67
- }
68
- };
69
- exports.LikeController = LikeController;
70
- __decorate([
71
- (0, swagger_1.ApiOperation)({
72
- summary: 'Add a like to a resource',
73
- description: 'Adds a like from the authenticated user to the specified resource.',
74
- }),
75
- (0, swagger_1.ApiOkResponse)({
76
- description: "Returns the updated number of likes after adding the user's like.",
77
- schema: { type: 'number', example: 42 },
78
- }),
79
- (0, pipes_1.ApiMongoId)('resourceId'),
80
- (0, common_1.Put)(':resourceId'),
81
- __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
82
- __param(1, (0, decorators_1.Account)('id')),
83
- __metadata("design:type", Function),
84
- __metadata("design:paramtypes", [String, String]),
85
- __metadata("design:returntype", Promise)
86
- ], LikeController.prototype, "addLikeToResource", null);
87
- __decorate([
88
- (0, swagger_1.ApiOperation)({
89
- summary: 'Remove a like from a resource',
90
- description: "Removes the authenticated user's like from the specified resource.",
91
- }),
92
- (0, swagger_1.ApiNoContentResponse)({
93
- description: 'Successfully removed like. Returns the updated number of likes.',
94
- schema: { type: 'number', example: 41 },
95
- }),
96
- (0, pipes_1.ApiMongoId)('resourceId'),
97
- (0, common_1.Delete)(':resourceId'),
98
- __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
99
- __param(1, (0, decorators_1.Account)('id')),
100
- __metadata("design:type", Function),
101
- __metadata("design:paramtypes", [String, String]),
102
- __metadata("design:returntype", Promise)
103
- ], LikeController.prototype, "removeLikeFromResource", null);
104
- __decorate([
105
- (0, swagger_1.ApiOperation)({
106
- summary: 'Check if resource is liked by user',
107
- description: 'Returns true if the authenticated user has liked the specified resource, otherwise false.',
108
- }),
109
- (0, swagger_1.ApiOkResponse)({
110
- description: 'Boolean value indicating like status by the user.',
111
- schema: { type: 'boolean', example: true },
112
- }),
113
- (0, pipes_1.ApiMongoId)('resourceId'),
114
- (0, common_1.Get)(':resourceId'),
115
- __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
116
- __param(1, (0, decorators_1.Account)('id')),
117
- __metadata("design:type", Function),
118
- __metadata("design:paramtypes", [String, String]),
119
- __metadata("design:returntype", Promise)
120
- ], LikeController.prototype, "isResourceLikedByUser", null);
121
- exports.LikeController = LikeController = __decorate([
122
- (0, authentication_1.RequireJwtAuth)(),
123
- (0, common_1.Controller)(),
124
- __metadata("design:paramtypes", [like_service_1.LikeService])
125
- ], LikeController);
32
+ function createLikeController(routeSuffix) {
33
+ // Normalize route path, removing duplicate/trailing slashes
34
+ const normalizedRoute = `like/${routeSuffix}`.replace(/\/{2,}/g, '/').replace(/\/$/, '');
35
+ let LikeController = class LikeController {
36
+ constructor(likeService) {
37
+ this.likeService = likeService;
38
+ }
39
+ /**
40
+ * Adds the authenticated user's like to a given resource.
41
+ *
42
+ * Why: Prevents duplicate likes using `$addToSet`,
43
+ * ensuring idempotency of repeated requests.
44
+ *
45
+ * @param {string} resourceId - The MongoDB ObjectId of the resource.
46
+ * @param {string} accountId - The authenticated account performing the like.
47
+ * @returns {Promise<number>} The updated like count.
48
+ */
49
+ async addLikeToResource(resourceId, accountId) {
50
+ return this.likeService.addLike(resourceId, accountId);
51
+ }
52
+ /**
53
+ * Removes the authenticated user's like from a given resource.
54
+ *
55
+ * Why: Uses `$pull` to ensure the user’s ID is removed only if present,
56
+ * maintaining database consistency without errors.
57
+ *
58
+ * @param {string} resourceId - The MongoDB ObjectId of the resource.
59
+ * @param {string} accountId - The authenticated account removing the like.
60
+ * @returns {Promise<number>} The updated like count.
61
+ */
62
+ async removeLikeFromResource(resourceId, accountId) {
63
+ return this.likeService.removeLike(resourceId, accountId);
64
+ }
65
+ /**
66
+ * Determines whether the authenticated user has liked a given resource.
67
+ *
68
+ * Why: Useful for rendering UI states (e.g. "Like" vs. "Unlike" buttons)
69
+ * without fetching all likes.
70
+ *
71
+ * @param {string} resourceId - The MongoDB ObjectId of the resource.
72
+ * @param {string} accountId - The authenticated account to check.
73
+ * @returns {Promise<boolean>} True if the resource is liked by the user.
74
+ */
75
+ async isResourceLikedByUser(resourceId, accountId) {
76
+ return this.likeService.hasLiked(resourceId, accountId);
77
+ }
78
+ };
79
+ __decorate([
80
+ (0, swagger_1.ApiOperation)({
81
+ summary: 'Like a resource',
82
+ description: 'Registers a like from the authenticated user on the specified resource. ' +
83
+ 'If the user has already liked it, the response still succeeds without creating a duplicate.',
84
+ }),
85
+ (0, swagger_1.ApiOkResponse)({
86
+ description: 'The total number of likes on the resource after this operation.',
87
+ schema: { type: 'number', example: 42 },
88
+ }),
89
+ (0, pipes_1.ApiMongoIdParam)('resourceId'),
90
+ (0, common_1.Put)(':resourceId'),
91
+ __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
92
+ __param(1, (0, decorators_1.AuthenticatedAccount)('id')),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", [String, String]),
95
+ __metadata("design:returntype", Promise)
96
+ ], LikeController.prototype, "addLikeToResource", null);
97
+ __decorate([
98
+ (0, swagger_1.ApiOperation)({
99
+ summary: 'Unlike a resource',
100
+ description: 'Removes the like from the authenticated user on the specified resource. ' +
101
+ 'If the user has not liked it before, the resource remains unchanged.',
102
+ }),
103
+ (0, swagger_1.ApiNoContentResponse)({
104
+ description: 'The total number of likes on the resource after this operation.',
105
+ schema: { type: 'number', example: 41 },
106
+ }),
107
+ (0, pipes_1.ApiMongoIdParam)('resourceId'),
108
+ (0, common_1.Delete)(':resourceId'),
109
+ __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
110
+ __param(1, (0, decorators_1.AuthenticatedAccount)('id')),
111
+ __metadata("design:type", Function),
112
+ __metadata("design:paramtypes", [String, String]),
113
+ __metadata("design:returntype", Promise)
114
+ ], LikeController.prototype, "removeLikeFromResource", null);
115
+ __decorate([
116
+ (0, swagger_1.ApiOperation)({
117
+ summary: 'Check like status',
118
+ description: 'Determines whether the authenticated user has previously liked the specified resource. ' +
119
+ 'Returns a boolean flag indicating the current like state.',
120
+ }),
121
+ (0, swagger_1.ApiOkResponse)({
122
+ description: 'True if the resource is liked by the authenticated user, false otherwise.',
123
+ schema: { type: 'boolean', example: true },
124
+ }),
125
+ (0, pipes_1.ApiMongoIdParam)('resourceId'),
126
+ (0, common_1.Get)(':resourceId'),
127
+ __param(0, (0, pipes_1.MongoIdParam)('resourceId')),
128
+ __param(1, (0, decorators_1.AuthenticatedAccount)('id')),
129
+ __metadata("design:type", Function),
130
+ __metadata("design:paramtypes", [String, String]),
131
+ __metadata("design:returntype", Promise)
132
+ ], LikeController.prototype, "isResourceLikedByUser", null);
133
+ LikeController = __decorate([
134
+ (0, authentication_1.RequireJwtAuth)(),
135
+ (0, swagger_1.ApiTags)('Like'),
136
+ (0, common_1.Controller)(normalizedRoute),
137
+ __metadata("design:paramtypes", [like_service_1.LikeService])
138
+ ], LikeController);
139
+ return LikeController;
140
+ }
@@ -1,20 +1,4 @@
1
- import { ModelDefinition } from '@nestjs/mongoose';
2
1
  /**
3
- * Configuration options for dynamically registering the LikeModule.
4
- */
5
- export type LikeModuleOptions = {
6
- /**
7
- * The Mongoose model definition representing the resource type to be liked.
8
- */
9
- model: ModelDefinition;
10
- /**
11
- * Optional array of strings used to define the route path and API tag suffixes.
12
- * Useful for scoping like functionality to different resource contexts (e.g., 'posts', 'comments').
13
- */
14
- routeScope?: string[];
15
- };
16
- /**
17
- * Token used to inject LikeModule options into services or controllers if needed.
18
- * Symbol is used to avoid accidental naming collisions across modules.
2
+ * Dependency injection token for LikeModule options.
19
3
  */
20
4
  export declare const LIKE_MODULE_OPTIONS_TOKEN: unique symbol;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIKE_MODULE_OPTIONS_TOKEN = void 0;
4
4
  /**
5
- * Token used to inject LikeModule options into services or controllers if needed.
6
- * Symbol is used to avoid accidental naming collisions across modules.
5
+ * Dependency injection token for LikeModule options.
7
6
  */
8
7
  exports.LIKE_MODULE_OPTIONS_TOKEN = Symbol('LIKE_MODULE_OPTIONS_TOKEN');
@@ -1,21 +1,21 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { LikeModuleOptions } from './like.module-definition';
2
+ import { LikeModuleOptions } from './like-module-options.interface';
3
3
  /**
4
- * LikeModule dynamically registers controllers and services to handle "like" functionality
5
- * for different resources based on the provided model and optional suffix.
4
+ * LikeModule dynamically registers controllers and services
5
+ * to handle "like" functionality for a given resource model.
6
6
  *
7
- * This design enables modularity and reuse of like-related logic across various resource types.
7
+ * Why: Many resources (e.g. blogposts, events, demos) can be liked,
8
+ * but duplicating controller/service logic for each would be error-prone.
9
+ * Instead, this module centralizes the like-related logic, keeping it
10
+ * consistent while still allowing customization via options.
8
11
  */
9
12
  export declare class LikeModule {
10
13
  /**
11
- * Registers and configures the LikeModule dynamically.
14
+ * Dynamically registers a LikeController bound to the provided model
15
+ * and optional route suffix.
12
16
  *
13
- * - Automatically generates an endpoint path based on provided suffix.
14
- * - Tags the controller in Swagger docs for better discoverability.
15
- * - Inherits all business logic from the base LikeController.
16
- *
17
- * @param options - Configuration options including the model and route suffix.
18
- * @returns A fully configured dynamic NestJS module.
17
+ * @param {LikeModuleOptions} options - Configuration for the resource model and route.
18
+ * @returns {DynamicModule} The dynamically created module definition.
19
19
  */
20
- static register(options: LikeModuleOptions): DynamicModule;
20
+ static forFeature(options: LikeModuleOptions): DynamicModule;
21
21
  }
@@ -9,59 +9,36 @@ var LikeModule_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.LikeModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
- const swagger_1 = require("@nestjs/swagger");
13
- const itlab_functions_1 = require("itlab-functions");
14
12
  const like_controller_1 = require("./like.controller");
15
13
  const like_module_definition_1 = require("./like.module-definition");
16
14
  const like_service_1 = require("./like.service");
17
15
  /**
18
- * LikeModule dynamically registers controllers and services to handle "like" functionality
19
- * for different resources based on the provided model and optional suffix.
16
+ * LikeModule dynamically registers controllers and services
17
+ * to handle "like" functionality for a given resource model.
20
18
  *
21
- * This design enables modularity and reuse of like-related logic across various resource types.
19
+ * Why: Many resources (e.g. blogposts, events, demos) can be liked,
20
+ * but duplicating controller/service logic for each would be error-prone.
21
+ * Instead, this module centralizes the like-related logic, keeping it
22
+ * consistent while still allowing customization via options.
22
23
  */
23
24
  let LikeModule = LikeModule_1 = class LikeModule {
24
25
  /**
25
- * Registers and configures the LikeModule dynamically.
26
+ * Dynamically registers a LikeController bound to the provided model
27
+ * and optional route suffix.
26
28
  *
27
- * - Automatically generates an endpoint path based on provided suffix.
28
- * - Tags the controller in Swagger docs for better discoverability.
29
- * - Inherits all business logic from the base LikeController.
30
- *
31
- * @param options - Configuration options including the model and route suffix.
32
- * @returns A fully configured dynamic NestJS module.
29
+ * @param {LikeModuleOptions} options - Configuration for the resource model and route.
30
+ * @returns {DynamicModule} The dynamically created module definition.
33
31
  */
34
- static register(options) {
35
- const { routeScope = [] } = options;
36
- // Transform suffixes into a readable Swagger tag (e.g., "Like Module - Posts")
37
- const swaggerTag = ['Like Module', ...routeScope.map((scope) => (0, itlab_functions_1.capitalize)(scope))].join(' -');
38
- // Build the controller route path (e.g., "/like/posts")
39
- const controllerRoutePath = ['like', ...routeScope].join('/');
40
- /**
41
- * A dynamically scoped LikeController for a specific resource.
42
- *
43
- * This controller uses a generated route path and custom Swagger tag,
44
- * but otherwise inherits all base LikeController behavior.
45
- */
46
- let LikeController = class LikeController extends like_controller_1.LikeController {
47
- };
48
- LikeController = __decorate([
49
- (0, swagger_1.ApiTags)(swaggerTag),
50
- (0, common_1.Controller)(controllerRoutePath)
51
- ], LikeController);
32
+ static forFeature(options) {
33
+ const LikeController = (0, like_controller_1.createLikeController)(options.routeSuffix);
52
34
  return {
53
35
  module: LikeModule_1,
54
- controllers: [LikeController],
55
36
  providers: [like_service_1.LikeService, { provide: like_module_definition_1.LIKE_MODULE_OPTIONS_TOKEN, useValue: options }],
56
- exports: [like_service_1.LikeService],
37
+ controllers: [LikeController],
57
38
  };
58
39
  }
59
40
  };
60
41
  exports.LikeModule = LikeModule;
61
42
  exports.LikeModule = LikeModule = LikeModule_1 = __decorate([
62
- (0, common_1.Module)({
63
- controllers: [like_controller_1.LikeController],
64
- providers: [like_service_1.LikeService],
65
- exports: [like_service_1.LikeService],
66
- })
43
+ (0, common_1.Module)({})
67
44
  ], LikeModule);
@@ -1,10 +1,11 @@
1
1
  import { Connection } from 'mongoose';
2
- import { LikeModuleOptions } from './like.module-definition';
2
+ import { LikeModuleOptions } from './like-module-options.interface';
3
3
  /**
4
- * LikeService manages the "like" functionality for resources.
4
+ * LikeService manages persistence and business logic
5
+ * for adding, removing, and verifying likes on resource entities.
5
6
  *
6
- * It provides methods to add, remove, and verify likes on resource entities,
7
- * interacting with the underlying MongoDB collection configured by the module options.
7
+ * Why: Encapsulates MongoDB operations and ensures consistent handling
8
+ * of like-related behavior across all resources that support likes.
8
9
  */
9
10
  export declare class LikeService {
10
11
  private readonly moduleOptions;
@@ -12,50 +13,53 @@ export declare class LikeService {
12
13
  private readonly logger;
13
14
  private readonly likeModel;
14
15
  /**
15
- * Initializes LikeService with database connection and module configuration.
16
+ * Constructs the LikeService with a configured model instance.
16
17
  *
17
- * @param {LikeModuleOptions} moduleOptions - The module options containing model info.
18
- * @param {Connection} connection - The active MongoDB connection injected by Mongoose.
18
+ * Why: Using the provided Mongoose connection and model options ensures
19
+ * that likes are tied to the correct resource collection dynamically.
20
+ *
21
+ * @param {LikeModuleOptions} moduleOptions - Config for the likeable resource model.
22
+ * @param {Connection} connection - Mongoose database connection.
19
23
  */
20
24
  constructor(moduleOptions: LikeModuleOptions, connection: Connection);
21
25
  /**
22
- * Computes the number of likes for a given resource document.
26
+ * Safely retrieves the number of likes from a resource document.
23
27
  *
24
- * @param {Document & Likeable} [resource] - The resource document which contains _likedBy array.
25
- * @returns {number} The count of likes, or zero if none exist.
28
+ * @param {Document & Likeable} [resource] - The resource document.
29
+ * @returns {number} Count of likes, or zero if not available.
26
30
  */
27
- private getLikeCount;
31
+ private countLikes;
28
32
  /**
29
- * Adds a like to the specified resource by the given account.
33
+ * Adds a like from the specified account to a resource.
30
34
  *
31
- * Uses MongoDB's `$addToSet` to avoid duplicate entries efficiently.
32
- * Returns the updated count of likes after addition.
35
+ * Why: `$addToSet` prevents duplicates, ensuring data integrity
36
+ * when users attempt to like a resource multiple times.
33
37
  *
34
- * @param {string} resourceId - The identifier of the resource to like.
35
- * @param {string} accountId - The account identifier that likes the resource.
38
+ * @param {string} resourceId - The resource’s ID.
39
+ * @param {string} accountId - The account ID adding the like.
36
40
  * @returns {Promise<number>} The updated like count.
37
41
  */
38
42
  addLike(resourceId: string, accountId: string): Promise<number>;
39
43
  /**
40
- * Removes a like from the specified resource by the given account.
44
+ * Removes a like from the specified account on a resource.
41
45
  *
42
- * Uses MongoDB's `$pull` operator to remove the account ID from the liked list.
43
- * Returns the updated count of likes after removal.
46
+ * Why: `$pull` ensures the account is removed cleanly
47
+ * without affecting other users’ likes.
44
48
  *
45
- * @param {string} resourceId - The identifier of the resource to unlike.
46
- * @param {string} accountId - The account identifier that removes the like.
49
+ * @param {string} resourceId - The resource’s ID.
50
+ * @param {string} accountId - The account ID removing the like.
47
51
  * @returns {Promise<number>} The updated like count.
48
52
  */
49
53
  removeLike(resourceId: string, accountId: string): Promise<number>;
50
54
  /**
51
- * Checks whether the specified account has liked the resource.
55
+ * Verifies whether a given account has liked a resource.
52
56
  *
53
- * This method fetches the resource document and checks if the account ID
54
- * exists in the `_likedBy` array.
57
+ * Why: Checking directly with MongoDB avoids fetching the full document,
58
+ * making it efficient for large `_likedBy` arrays.
55
59
  *
56
- * @param {string} resourceId - The resource to check.
57
- * @param {string} accountId - The account to verify.
58
- * @returns {Promise<boolean>} True if the account has liked the resource; false otherwise.
60
+ * @param {string} resourceId - The resource ID.
61
+ * @param {string} accountId - The account ID to check.
62
+ * @returns {Promise<boolean>} True if the account has liked the resource.
59
63
  */
60
64
  hasLiked(resourceId: string, accountId: string): Promise<boolean>;
61
65
  }
@@ -19,79 +19,86 @@ const mongoose_1 = require("@nestjs/mongoose");
19
19
  const mongoose_2 = require("mongoose");
20
20
  const like_module_definition_1 = require("./like.module-definition");
21
21
  /**
22
- * LikeService manages the "like" functionality for resources.
22
+ * LikeService manages persistence and business logic
23
+ * for adding, removing, and verifying likes on resource entities.
23
24
  *
24
- * It provides methods to add, remove, and verify likes on resource entities,
25
- * interacting with the underlying MongoDB collection configured by the module options.
25
+ * Why: Encapsulates MongoDB operations and ensures consistent handling
26
+ * of like-related behavior across all resources that support likes.
26
27
  */
27
28
  let LikeService = LikeService_1 = class LikeService {
28
29
  /**
29
- * Initializes LikeService with database connection and module configuration.
30
+ * Constructs the LikeService with a configured model instance.
30
31
  *
31
- * @param {LikeModuleOptions} moduleOptions - The module options containing model info.
32
- * @param {Connection} connection - The active MongoDB connection injected by Mongoose.
32
+ * Why: Using the provided Mongoose connection and model options ensures
33
+ * that likes are tied to the correct resource collection dynamically.
34
+ *
35
+ * @param {LikeModuleOptions} moduleOptions - Config for the likeable resource model.
36
+ * @param {Connection} connection - Mongoose database connection.
33
37
  */
34
38
  constructor(moduleOptions, connection) {
35
39
  this.moduleOptions = moduleOptions;
36
40
  this.connection = connection;
37
41
  this.logger = new common_1.Logger(LikeService_1.name);
38
- this.likeModel = this.connection.model(this.moduleOptions.model.name, this.moduleOptions.model.schema);
42
+ const { name, schema } = this.moduleOptions.model;
43
+ this.likeModel = this.connection.model(name, schema);
39
44
  }
40
45
  /**
41
- * Computes the number of likes for a given resource document.
46
+ * Safely retrieves the number of likes from a resource document.
42
47
  *
43
- * @param {Document & Likeable} [resource] - The resource document which contains _likedBy array.
44
- * @returns {number} The count of likes, or zero if none exist.
48
+ * @param {Document & Likeable} [resource] - The resource document.
49
+ * @returns {number} Count of likes, or zero if not available.
45
50
  */
46
- getLikeCount(resource) {
51
+ countLikes(resource) {
47
52
  var _a, _b;
48
53
  return (_b = (_a = resource === null || resource === void 0 ? void 0 : resource._likedBy) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
49
54
  }
50
55
  /**
51
- * Adds a like to the specified resource by the given account.
56
+ * Adds a like from the specified account to a resource.
52
57
  *
53
- * Uses MongoDB's `$addToSet` to avoid duplicate entries efficiently.
54
- * Returns the updated count of likes after addition.
58
+ * Why: `$addToSet` prevents duplicates, ensuring data integrity
59
+ * when users attempt to like a resource multiple times.
55
60
  *
56
- * @param {string} resourceId - The identifier of the resource to like.
57
- * @param {string} accountId - The account identifier that likes the resource.
61
+ * @param {string} resourceId - The resource’s ID.
62
+ * @param {string} accountId - The account ID adding the like.
58
63
  * @returns {Promise<number>} The updated like count.
59
64
  */
60
65
  async addLike(resourceId, accountId) {
61
- this.logger.log(`Adding like to resource ${resourceId} by account ${accountId}`);
66
+ this.logger.debug(`Account ${accountId} liked ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
62
67
  const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $addToSet: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
63
- return this.getLikeCount(updatedResource);
68
+ return this.countLikes(updatedResource);
64
69
  }
65
70
  /**
66
- * Removes a like from the specified resource by the given account.
71
+ * Removes a like from the specified account on a resource.
67
72
  *
68
- * Uses MongoDB's `$pull` operator to remove the account ID from the liked list.
69
- * Returns the updated count of likes after removal.
73
+ * Why: `$pull` ensures the account is removed cleanly
74
+ * without affecting other users’ likes.
70
75
  *
71
- * @param {string} resourceId - The identifier of the resource to unlike.
72
- * @param {string} accountId - The account identifier that removes the like.
76
+ * @param {string} resourceId - The resource’s ID.
77
+ * @param {string} accountId - The account ID removing the like.
73
78
  * @returns {Promise<number>} The updated like count.
74
79
  */
75
80
  async removeLike(resourceId, accountId) {
76
- this.logger.log(`Removing like from resource ${resourceId} by account ${accountId}`);
81
+ this.logger.debug(`Account ${accountId} unliked ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
77
82
  const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $pull: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
78
- return this.getLikeCount(updatedResource);
83
+ return this.countLikes(updatedResource);
79
84
  }
80
85
  /**
81
- * Checks whether the specified account has liked the resource.
86
+ * Verifies whether a given account has liked a resource.
82
87
  *
83
- * This method fetches the resource document and checks if the account ID
84
- * exists in the `_likedBy` array.
88
+ * Why: Checking directly with MongoDB avoids fetching the full document,
89
+ * making it efficient for large `_likedBy` arrays.
85
90
  *
86
- * @param {string} resourceId - The resource to check.
87
- * @param {string} accountId - The account to verify.
88
- * @returns {Promise<boolean>} True if the account has liked the resource; false otherwise.
91
+ * @param {string} resourceId - The resource ID.
92
+ * @param {string} accountId - The account ID to check.
93
+ * @returns {Promise<boolean>} True if the account has liked the resource.
89
94
  */
90
95
  async hasLiked(resourceId, accountId) {
91
- var _a;
92
- this.logger.log(`Checking if account ${accountId} has liked resource ${resourceId}`);
93
- const resource = await this.likeModel.findOne({ _id: resourceId });
94
- return !!((_a = resource === null || resource === void 0 ? void 0 : resource._likedBy) === null || _a === void 0 ? void 0 : _a.includes(accountId));
96
+ this.logger.log(`Checking like status for account ${accountId} on ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
97
+ const resource = await this.likeModel.findOne({
98
+ _id: resourceId,
99
+ _likedBy: { $in: [accountId] },
100
+ });
101
+ return !!resource;
95
102
  }
96
103
  };
97
104
  exports.LikeService = LikeService;
@@ -0,0 +1,3 @@
1
+ export * from './merge-module-options.interface';
2
+ export * from './merge.module';
3
+ export * from './merge.service.interface';