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
@@ -0,0 +1,7 @@
1
+ import { ContentReturnType } from '../modules';
2
+ type PropertyContentReturnTypeOptions = {
3
+ optional?: boolean;
4
+ default?: ContentReturnType;
5
+ };
6
+ export declare function PropertyContentReturnType(options?: PropertyContentReturnTypeOptions): PropertyDecorator;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertyContentReturnType = PropertyContentReturnType;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const class_transformer_1 = require("class-transformer");
7
+ const class_validator_1 = require("class-validator");
8
+ const content_return_types_1 = require("../modules/services/providers/content/content-return-types");
9
+ function isSupportedContentType(value) {
10
+ return content_return_types_1.supportedContentReturnTypes.some((type) => type === value);
11
+ }
12
+ function PropertyContentReturnType(options = {}) {
13
+ const decorators = [
14
+ (0, swagger_1.ApiProperty)(Object.assign({ description: 'In which format should the content be returned', examples: [...content_return_types_1.supportedContentReturnTypes] }, options)),
15
+ (0, class_transformer_1.Transform)(({ value }) => (isSupportedContentType(value) ? value : options.default)),
16
+ (0, class_validator_1.IsIn)(content_return_types_1.supportedContentReturnTypes, { message: 'Invalid content return type' }),
17
+ ];
18
+ if (options.optional) {
19
+ decorators.push(common_1.Optional);
20
+ }
21
+ return (0, common_1.applyDecorators)(...decorators);
22
+ }
@@ -0,0 +1,4 @@
1
+ export { PropertyContentReturnType } from './content-return-type.property';
2
+ export { PropertyContent } from './content.property';
3
+ export { PropertiesLikeable } from './likeable.properties';
4
+ export { PropertiesViewable } from './viewable.properties';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertiesViewable = exports.PropertiesLikeable = exports.PropertyContent = exports.PropertyContentReturnType = void 0;
4
+ var content_return_type_property_1 = require("./content-return-type.property");
5
+ Object.defineProperty(exports, "PropertyContentReturnType", { enumerable: true, get: function () { return content_return_type_property_1.PropertyContentReturnType; } });
6
+ var content_property_1 = require("./content.property");
7
+ Object.defineProperty(exports, "PropertyContent", { enumerable: true, get: function () { return content_property_1.PropertyContent; } });
8
+ var likeable_properties_1 = require("./likeable.properties");
9
+ Object.defineProperty(exports, "PropertiesLikeable", { enumerable: true, get: function () { return likeable_properties_1.PropertiesLikeable; } });
10
+ var viewable_properties_1 = require("./viewable.properties");
11
+ Object.defineProperty(exports, "PropertiesViewable", { enumerable: true, get: function () { return viewable_properties_1.PropertiesViewable; } });
@@ -0,0 +1 @@
1
+ export declare function PropertiesLikeable(): ClassDecorator;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertiesLikeable = PropertiesLikeable;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const models_1 = require("../models");
7
+ function PropertiesLikeable() {
8
+ return (0, common_1.applyDecorators)((0, swagger_1.ApiPropertyOptional)({
9
+ name: '_likedBy',
10
+ description: 'Array of user IDs that liked this resource.',
11
+ type: [String],
12
+ default: [],
13
+ }), (0, swagger_1.ApiPropertyOptional)({
14
+ name: 'likes',
15
+ description: 'Total number of likes for this resource.',
16
+ type: Number,
17
+ default: 0,
18
+ }), (0, swagger_1.ApiPropertyOptional)({
19
+ name: 'likedBy',
20
+ description: 'Populated list of User objects who liked this resource.',
21
+ type: [models_1.User],
22
+ default: [],
23
+ }));
24
+ }
25
+ // /**
26
+ // * Decorator for the internal array of user IDs who liked the resource.
27
+ // */
28
+ // export function PropertyLikedBy(): PropertyDecorator {
29
+ // return applyDecorators(
30
+ // ApiPropertyOptional({
31
+ // name: '_likedBy',
32
+ // description: 'Array of user IDs that liked this resource.',
33
+ // type: [String],
34
+ // default: [],
35
+ // }),
36
+ // Prop({ required: true, default: () => [] }),
37
+ // );
38
+ // }
39
+ // /**
40
+ // * Decorator for the total number of likes on the resource.
41
+ // */
42
+ // export function PropertyLikes(): PropertyDecorator {
43
+ // return applyDecorators(
44
+ // ApiPropertyOptional({
45
+ // name: 'likes',
46
+ // description: 'Total number of likes for this resource.',
47
+ // type: Number,
48
+ // default: 0,
49
+ // }),
50
+ // Prop({ required: true, default: 0 }),
51
+ // );
52
+ // }
53
+ // /**
54
+ // * Virtual decorator to expose the populated list of users who liked the resource.
55
+ // */
56
+ // export function VirtualLikedBy(): PropertyDecorator {
57
+ // return applyDecorators(
58
+ // ApiPropertyOptional({
59
+ // name: 'likedBy',
60
+ // description: 'Populated list of User objects who liked this resource.',
61
+ // type: [User],
62
+ // default: [],
63
+ // }),
64
+ // Virtual(),
65
+ // );
66
+ // }
@@ -0,0 +1 @@
1
+ export declare function PropertiesViewable(): ClassDecorator;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertiesViewable = PropertiesViewable;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const models_1 = require("../models");
7
+ function PropertiesViewable() {
8
+ return (0, common_1.applyDecorators)((0, swagger_1.ApiPropertyOptional)({
9
+ name: '_viewedBy',
10
+ description: 'Array of user IDs that have viewed this resource.',
11
+ type: [String],
12
+ default: [],
13
+ }), (0, swagger_1.ApiPropertyOptional)({
14
+ name: 'views',
15
+ description: 'Total number of views for this resource.',
16
+ type: Number,
17
+ default: 0,
18
+ }), (0, swagger_1.ApiPropertyOptional)({
19
+ name: 'viewedBy',
20
+ description: 'Populated list of User objects who viewed this resource.',
21
+ type: [models_1.User],
22
+ default: [],
23
+ }));
24
+ }
25
+ // /**
26
+ // * Decorator for the internal array of user IDs who viewed the resource.
27
+ // */
28
+ // export function PropertyViewedBy(): PropertyDecorator {
29
+ // return applyDecorators(
30
+ // ApiPropertyOptional({
31
+ // name: '_viewedBy',
32
+ // description: 'Array of user IDs that have viewed this resource.',
33
+ // type: [String],
34
+ // default: [],
35
+ // }),
36
+ // Prop({ required: true, default: () => [] }),
37
+ // );
38
+ // }
39
+ // /**
40
+ // * Decorator for the total number of views on the resource.
41
+ // */
42
+ // export function PropertyViews(): PropertyDecorator {
43
+ // return applyDecorators(
44
+ // ApiPropertyOptional({
45
+ // name: 'views',
46
+ // description: 'Total number of views for this resource.',
47
+ // type: Number,
48
+ // default: 0,
49
+ // }),
50
+ // Prop({ required: true, default: 0 }),
51
+ // );
52
+ // }
53
+ // /**
54
+ // * Virtual decorator to expose the populated list of users who viewed the resource.
55
+ // */
56
+ // export function VirtualViewedBy(): PropertyDecorator {
57
+ // return applyDecorators(
58
+ // ApiPropertyOptional({
59
+ // name: 'viewedBy',
60
+ // description: 'Populated list of User objects who viewed this resource.',
61
+ // type: [User],
62
+ // default: [],
63
+ // }),
64
+ // Virtual(),
65
+ // );
66
+ // }
@@ -0,0 +1 @@
1
+ export { initializeSwagger } from './swagger.function';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeSwagger = void 0;
4
+ var swagger_function_1 = require("./swagger.function");
5
+ Object.defineProperty(exports, "initializeSwagger", { enumerable: true, get: function () { return swagger_function_1.initializeSwagger; } });
@@ -0,0 +1,9 @@
1
+ import { OpenAPIObject } from '@nestjs/swagger';
2
+ /**
3
+ * Modifies Swagger documentation to remove "Auth Required" lock
4
+ * for routes marked with @Public() decorator.
5
+ *
6
+ * @param {OpenAPIObject} document - The generated Swagger document
7
+ * @returns {OpenAPIObject} - Modified Swagger document
8
+ */
9
+ export declare function removePublicRouteAuth(document: OpenAPIObject): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removePublicRouteAuth = removePublicRouteAuth;
4
+ const service_auth_guard_1 = require("../modules/authentication/guards/service-auth.guard");
5
+ /**
6
+ * Modifies Swagger documentation to remove "Auth Required" lock
7
+ * for routes marked with @Public() decorator.
8
+ *
9
+ * @param {OpenAPIObject} document - The generated Swagger document
10
+ * @returns {OpenAPIObject} - Modified Swagger document
11
+ */
12
+ function removePublicRouteAuth(document) {
13
+ Object.values(document.paths).forEach((path) => {
14
+ Object.values(path).forEach((method) => {
15
+ if (Array.isArray(method.security) && method.security.includes('public')) {
16
+ method.security = [];
17
+ if (method.parameters) {
18
+ method.parameters = method.parameters.filter((parameter) => parameter.name !== service_auth_guard_1.SERVICE_AUTH_HEADER_KEY);
19
+ }
20
+ delete method.responses['401'];
21
+ console.log(method);
22
+ }
23
+ });
24
+ });
25
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Defines configurable options for setting up Swagger API documentation.
3
+ * This includes optional authentication mechanisms like JWT or Kubernetes API keys.
4
+ */
5
+ export type SwaggerOptions = {
6
+ /**
7
+ * Title of the API documentation displayed in Swagger UI
8
+ */
9
+ title: string;
10
+ /**
11
+ * Short description of the API's purpose or scope
12
+ */
13
+ description: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { INestApplication } from '@nestjs/common';
2
+ import { SwaggerOptions } from './swagger-options.interface';
3
+ /**
4
+ * Initializes Swagger documentation for a NestJS application.
5
+ * This function configures Swagger with API metadata, security schemes,
6
+ * and serves the Swagger UI at the `/api` endpoint.
7
+ *
8
+ * @param {INestApplication} app - The NestJS application instance to attach Swagger to.
9
+ * @param {SwaggerOptions} [options] - Configuration for Swagger metadata.
10
+ */
11
+ export declare function initializeSwagger(app: INestApplication, options: SwaggerOptions): void;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeSwagger = initializeSwagger;
4
+ const swagger_1 = require("@nestjs/swagger");
5
+ const service_auth_guard_1 = require("../modules/authentication/guards/service-auth.guard");
6
+ const remove_public_route_auth_plugin_1 = require("./remove-public-route-auth.plugin");
7
+ /**
8
+ * Initializes Swagger documentation for a NestJS application.
9
+ * This function configures Swagger with API metadata, security schemes,
10
+ * and serves the Swagger UI at the `/api` endpoint.
11
+ *
12
+ * @param {INestApplication} app - The NestJS application instance to attach Swagger to.
13
+ * @param {SwaggerOptions} [options] - Configuration for Swagger metadata.
14
+ */
15
+ function initializeSwagger(app, options) {
16
+ var _a;
17
+ // Create a new DocumentBuilder to configure the Swagger documentation
18
+ const documentBuilder = new swagger_1.DocumentBuilder()
19
+ .setTitle(options.title)
20
+ .setDescription(options.description)
21
+ .setContact('Timo Scheuermann', '', 'timo.scheuermann@sv-informatik.de');
22
+ // Add the base server URL. Falls back to localhost if SWAGGER_BASE_PATH is not set
23
+ const baseUrl = (_a = process.env.SWAGGER_BASE_PATH) !== null && _a !== void 0 ? _a : 'http://localhost:3000';
24
+ documentBuilder.addServer(baseUrl);
25
+ // Configure JWT Bearer authentication for user endpoints
26
+ documentBuilder.addBearerAuth({
27
+ type: 'http',
28
+ in: 'header',
29
+ bearerFormat: 'JWT',
30
+ description: 'Gesicherter Login Token',
31
+ }, 'Auth Token');
32
+ // Configure API key authentication for internal service-to-service communication
33
+ documentBuilder.addApiKey({
34
+ type: 'apiKey',
35
+ in: 'header',
36
+ name: service_auth_guard_1.SERVICE_AUTH_HEADER_KEY,
37
+ description: 'Token for service authentication',
38
+ }, 'Service Token');
39
+ // Build the Swagger configuration from the builder
40
+ const swaggerConfig = documentBuilder.build();
41
+ // Generate the Swagger document using the NestJS application instance
42
+ const swaggerDocument = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
43
+ // Remove security from @Public endpoints
44
+ (0, remove_public_route_auth_plugin_1.removePublicRouteAuth)(swaggerDocument);
45
+ // Serve Swagger UI at the '/api' endpoint
46
+ swagger_1.SwaggerModule.setup('api', app, swaggerDocument);
47
+ }
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BooleanTransform = BooleanTransform;
4
4
  const class_transformer_1 = require("class-transformer");
5
+ // Standardize boolean input formats (string, number, or boolean)
6
+ const trueValues = [true, 'true', 1, '1', 'yes', 'on'];
7
+ const falseValues = [false, 'false', 0, '0', 'no', 'off'];
5
8
  /**
6
9
  * Property decorator to normalize boolean-like input values.
7
10
  * It converts various representations of truthy and falsy values (e.g., "true", "1", 1) into actual booleans.
@@ -11,9 +14,6 @@ const class_transformer_1 = require("class-transformer");
11
14
  */
12
15
  function BooleanTransform() {
13
16
  return (0, class_transformer_1.Transform)(({ value }) => {
14
- // Standardize boolean input formats (string, number, or boolean)
15
- const trueValues = [true, 'true', 1, '1', 'yes', 'on'];
16
- const falseValues = [false, 'false', 0, '0', 'no', 'off'];
17
17
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
18
18
  if (trueValues.includes(value))
19
19
  return true;
@@ -0,0 +1,2 @@
1
+ export * from './likeable.type';
2
+ export * from './viewable.type';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./likeable.type"), exports);
18
+ __exportStar(require("./viewable.type"), exports);
@@ -0,0 +1,15 @@
1
+ import { User } from '../models';
2
+ /**
3
+ * Represents an entity that can be liked by users.
4
+ *
5
+ * - `_likedBy`: stores IDs of users who liked the entity.
6
+ * - `likes`: computed total number of likes.
7
+ * - `likedBy`: optional populated list of User objects.
8
+ */
9
+ export type Likeable = {
10
+ _likedBy: string[];
11
+ likes: number;
12
+ likedBy?: User[];
13
+ addLike(accountId: string): Promise<void>;
14
+ removeLike(accountId: string): Promise<void>;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { User } from '../models';
2
+ /**
3
+ * Represents an entity that can be viewed by users.
4
+ *
5
+ * - `_viewedBy`: stores IDs of users who viewed the entity.
6
+ * - `views`: computed total number of views.
7
+ * - `viewedBy`: optional populated list of User objects.
8
+ */
9
+ export type Viewable = {
10
+ _viewedBy: string[];
11
+ views: number;
12
+ viewedBy?: User[];
13
+ addView(accountId: string): Promise<void>;
14
+ removeView(accountId: string): Promise<void>;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Timo Scheuermann",
5
5
  "email": "timo.scheuermann@sv-informatik.de"
6
6
  },
7
- "version": "2.15.7",
7
+ "version": "2.16.1",
8
8
  "type": "commonjs",
9
9
  "files": [
10
10
  "dist"
@@ -35,7 +35,7 @@
35
35
  "cache-manager": "^7.1.1",
36
36
  "class-transformer": "^0.5.1",
37
37
  "class-validator": "^0.14.2",
38
- "itlab-functions": "^1.0.2",
38
+ "itlab-functions": "^1.0.6",
39
39
  "mongoose": "^8.17.1",
40
40
  "rxjs": "^7.8.2"
41
41
  },
@@ -1,39 +0,0 @@
1
- import { Document } from 'mongoose';
2
- import { Viewable } from '../viewable.interface';
3
- /**
4
- * Facilitates asynchronous updates to documents by adding unique account IDs to specified
5
- * array attributes. This prevents duplication of IDs in those arrays, ensuring data integrity.
6
- *
7
- * Designed primarily for adding account references such as views or other related IDs.
8
- */
9
- export declare class DocumentUpdater {
10
- private static readonly logger;
11
- /**
12
- * Adds an account ID uniquely to a specified array attribute of a document.
13
- *
14
- * This method verifies the presence of an accountId before proceeding.
15
- * It then performs an atomic MongoDB `$addToSet` update on the document to
16
- * add the accountId to the given attribute array only if it is not already present,
17
- * preventing duplicates without needing to fetch the document first.
18
- *
19
- * Updates are saved without modifying timestamps to preserve original metadata.
20
- *
21
- * @template I - Interface representing the document’s shape.
22
- * @template T - Mongoose Document type extending `Document`.
23
- * @param document - The Mongoose document to update.
24
- * @param attribute - The document attribute (key) representing the array to update.
25
- * @param accountId - The unique account ID to add.
26
- */
27
- static addUniqueAccountId<I, T extends Document = Document>(document: T, attribute: keyof I, accountId?: string): void;
28
- /**
29
- * Adds a view record to a document by associating an account ID with the '_viewedBy' attribute.
30
- *
31
- * This method leverages `addUniqueAccountId` to add the given accountId to the '_viewedBy' array,
32
- * ensuring each viewer is recorded only once.
33
- *
34
- * @template T - Mongoose Document type that extends Document and implements Viewable interface.
35
- * @param target - The target document to record the view.
36
- * @param accountId - The account ID representing the viewer.
37
- */
38
- static addView<T extends Document & Viewable>(target: T, accountId?: string): void;
39
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocumentUpdater = void 0;
4
- const common_1 = require("@nestjs/common");
5
- /**
6
- * Facilitates asynchronous updates to documents by adding unique account IDs to specified
7
- * array attributes. This prevents duplication of IDs in those arrays, ensuring data integrity.
8
- *
9
- * Designed primarily for adding account references such as views or other related IDs.
10
- */
11
- class DocumentUpdater {
12
- /**
13
- * Adds an account ID uniquely to a specified array attribute of a document.
14
- *
15
- * This method verifies the presence of an accountId before proceeding.
16
- * It then performs an atomic MongoDB `$addToSet` update on the document to
17
- * add the accountId to the given attribute array only if it is not already present,
18
- * preventing duplicates without needing to fetch the document first.
19
- *
20
- * Updates are saved without modifying timestamps to preserve original metadata.
21
- *
22
- * @template I - Interface representing the document’s shape.
23
- * @template T - Mongoose Document type extending `Document`.
24
- * @param document - The Mongoose document to update.
25
- * @param attribute - The document attribute (key) representing the array to update.
26
- * @param accountId - The unique account ID to add.
27
- */
28
- static addUniqueAccountId(document, attribute, accountId) {
29
- if (!accountId)
30
- return; // Exit if no accountId provided, avoiding unnecessary operations.
31
- // Perform atomic update to add accountId uniquely to the attribute array.
32
- document
33
- .updateOne({ $addToSet: { [String(attribute)]: accountId } }, { timestamps: false })
34
- .then(() => {
35
- this.logger.log(`Added unique accountId '${accountId}' to attribute '${String(attribute)}' for document ${document._id.toString()}`);
36
- })
37
- .catch((error) => {
38
- // Log any errors during the update operation for debugging and audit.
39
- this.logger.error(`Failed to add accountId '${accountId}' to attribute '${String(attribute)}' for document ${document._id.toString()}: ${error.stack}`);
40
- });
41
- }
42
- /**
43
- * Adds a view record to a document by associating an account ID with the '_viewedBy' attribute.
44
- *
45
- * This method leverages `addUniqueAccountId` to add the given accountId to the '_viewedBy' array,
46
- * ensuring each viewer is recorded only once.
47
- *
48
- * @template T - Mongoose Document type that extends Document and implements Viewable interface.
49
- * @param target - The target document to record the view.
50
- * @param accountId - The account ID representing the viewer.
51
- */
52
- static addView(target, accountId) {
53
- this.addUniqueAccountId(target, '_viewedBy', accountId);
54
- }
55
- }
56
- exports.DocumentUpdater = DocumentUpdater;
57
- DocumentUpdater.logger = new common_1.Logger('DocumentUpdater');
@@ -1 +0,0 @@
1
- export * from './virtuals.factory';
@@ -1,79 +0,0 @@
1
- import { Schema, VirtualTypeOptions } from 'mongoose';
2
- import { HubResource } from '../hub-resource.enum';
3
- /**
4
- * VirtualsFactory
5
- *
6
- * Provides a fluent, composable API for defining reusable Mongoose virtuals on schemas.
7
- * Helps keep schema definitions clean and DRY by centralizing the logic for frequently-used
8
- * virtual references (accounts, comments, likes, etc.), derived values, and hub-based resources.
9
- */
10
- export declare class VirtualsFactory {
11
- private readonly schema;
12
- private readonly resource;
13
- /**
14
- * @param {Schema} schema - the schema to create the virtual field on
15
- * @param {HubResource} resource - the resource used for the virtual field
16
- */
17
- constructor(schema: Schema, resource: HubResource);
18
- /**
19
- * Registers a generic virtual with custom Mongoose options.
20
- *
21
- * @param {string} name - The virtual field name.
22
- * @param {VirtualTypeOptions} [options] - The Mongoose virtual options.
23
- * @returns {VirtualsFactory} - The VirtualsFactory instance for chaining.
24
- */
25
- virtual(name: string, options?: VirtualTypeOptions): VirtualsFactory;
26
- /**
27
- * Registers a virtual referencing a single Account by ID.
28
- *
29
- * @param {string} name - Virtual field name.
30
- * @param {string} localField - Field containing the Account ID.
31
- */
32
- virtualSingleAccount(name: string, localField: string): VirtualsFactory;
33
- /**
34
- * Registers a virtual referencing multiple Accounts by ID array.
35
- *
36
- * @param {string} name - Virtual field name.
37
- * @param {string} localField - Field containing array of Account IDs.
38
- */
39
- virtualMultipleAccounts(name: string, localField: string): VirtualsFactory;
40
- /** Links `accountId` → `account` (single Account) */
41
- get account(): VirtualsFactory;
42
- /** Links `accountIds` → `accounts` (multiple Accounts) */
43
- get accounts(): VirtualsFactory;
44
- /** Links `authorId` → `author` (single Account) */
45
- get author(): VirtualsFactory;
46
- /** Links `authorIds` → `authors` (multiple Accounts) */
47
- get authors(): VirtualsFactory;
48
- /** Links `submitterId` → `submitter` (single Account) */
49
- get submitter(): VirtualsFactory;
50
- /** Links `submitterIds` → `submitters` (multiple Accounts) */
51
- get submitters(): VirtualsFactory;
52
- /** Links `contactId` → `contact` (single Account) */
53
- get contact(): VirtualsFactory;
54
- /** Links `contactIds` → `contacts` (multiple Accounts) */
55
- get contacts(): VirtualsFactory;
56
- /** Links `_viewedBy` → `viewedBy` and creates derived `views` counter */
57
- get views(): VirtualsFactory;
58
- /** Links `_likedBy` → `likedBy` and creates derived `likes` counter */
59
- get likes(): VirtualsFactory;
60
- /**
61
- * Creates `comments` virtual for top-level comments on the resource.
62
- * Filters out replies.
63
- */
64
- get comments(): VirtualsFactory;
65
- /**
66
- * Creates `commentsCount` virtual for counting all related comments on this resource.
67
- */
68
- get commentsCount(): VirtualsFactory;
69
- /**
70
- * Creates an empty virtual field for general content use.
71
- * Placeholder to support virtual getter/setter extension in custom implementations.
72
- */
73
- get content(): VirtualsFactory;
74
- /**
75
- * Registers `ref-[resource]` virtuals for each known Hub resource.
76
- * Used for polymorphic document relationships in the platform.
77
- */
78
- get hubResources(): VirtualsFactory;
79
- }