itlab-internal-services 2.15.7 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/README.md +1 -187
  2. package/dist/classes/document-merger.class.js +3 -5
  3. package/dist/classes/index.d.ts +1 -0
  4. package/dist/classes/index.js +3 -1
  5. package/dist/classes/report-category.class.d.ts +55 -0
  6. package/dist/classes/report-category.class.js +120 -0
  7. package/dist/decorators/{account.decorator.d.ts → authenticated-account.decorator.d.ts} +4 -4
  8. package/dist/decorators/{account.decorator.js → authenticated-account.decorator.js} +8 -10
  9. package/dist/decorators/index.d.ts +1 -1
  10. package/dist/decorators/index.js +1 -1
  11. package/dist/exceptions/authenticated-user-required.exception.d.ts +34 -0
  12. package/dist/exceptions/authenticated-user-required.exception.js +51 -0
  13. package/dist/exceptions/bad-body.exception.d.ts +19 -8
  14. package/dist/exceptions/bad-body.exception.js +26 -10
  15. package/dist/exceptions/bad-parameter.exception.d.ts +23 -8
  16. package/dist/exceptions/bad-parameter.exception.js +41 -19
  17. package/dist/exceptions/duplicate.exception.d.ts +20 -8
  18. package/dist/exceptions/duplicate.exception.js +27 -10
  19. package/dist/exceptions/index.d.ts +1 -0
  20. package/dist/exceptions/index.js +1 -0
  21. package/dist/functions/add-views-likes-virtuals.function.d.ts +15 -0
  22. package/dist/functions/add-views-likes-virtuals.function.js +43 -0
  23. package/dist/functions/create-internal-axios-client.function.js +2 -2
  24. package/dist/functions/index.d.ts +1 -0
  25. package/dist/functions/index.js +3 -1
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +2 -2
  28. package/dist/likeable.interface.d.ts +1 -1
  29. package/dist/likeable.interface.js +2 -2
  30. package/dist/models/account.model.d.ts +23 -0
  31. package/dist/models/account.model.js +59 -0
  32. package/dist/models/index.d.ts +3 -1
  33. package/dist/models/index.js +7 -3
  34. package/dist/{modules/search/models → models}/search-document.model.d.ts +1 -1
  35. package/dist/{modules/search/models → models}/search-document.model.js +1 -1
  36. package/dist/models/{account-entity.model.d.ts → user.model.d.ts} +8 -21
  37. package/dist/models/{account-entity.model.js → user.model.js} +11 -25
  38. package/dist/modules/authentication/authentication-module-options.interface.d.ts +2 -8
  39. package/dist/modules/authentication/authentication-options.parameter.d.ts +4 -0
  40. package/dist/modules/authentication/{inject-auth-options.decorator.js → authentication-options.parameter.js} +5 -2
  41. package/dist/modules/authentication/authentication.module.d.ts +23 -0
  42. package/dist/modules/authentication/authentication.module.js +24 -1
  43. package/dist/modules/authentication/guards/index.d.ts +2 -2
  44. package/dist/modules/authentication/guards/index.js +7 -7
  45. package/dist/modules/authentication/guards/jwt-auth.guard.d.ts +17 -0
  46. package/dist/modules/authentication/guards/jwt-auth.guard.js +73 -0
  47. package/dist/modules/authentication/guards/permissions.guard.d.ts +5 -27
  48. package/dist/modules/authentication/guards/permissions.guard.js +26 -59
  49. package/dist/modules/authentication/guards/public.guard.d.ts +7 -13
  50. package/dist/modules/authentication/guards/public.guard.js +10 -24
  51. package/dist/modules/authentication/guards/service-auth.guard.d.ts +22 -0
  52. package/dist/modules/authentication/guards/service-auth.guard.js +65 -0
  53. package/dist/modules/authentication/index.d.ts +3 -3
  54. package/dist/modules/authentication/index.js +3 -5
  55. package/dist/modules/cache/cache-response.interceptor.d.ts +2 -2
  56. package/dist/modules/cache/cache-response.interceptor.js +2 -2
  57. package/dist/modules/cache/index.d.ts +1 -0
  58. package/dist/modules/cache/index.js +1 -0
  59. package/dist/modules/comment/comment-module-options.interface.d.ts +38 -0
  60. package/dist/modules/comment/comment.controller.d.ts +24 -30
  61. package/dist/modules/comment/comment.controller.js +59 -61
  62. package/dist/modules/comment/comment.module-definition.d.ts +1 -42
  63. package/dist/modules/comment/comment.module-definition.js +1 -2
  64. package/dist/modules/comment/comment.module.d.ts +13 -13
  65. package/dist/modules/comment/comment.module.js +15 -42
  66. package/dist/modules/comment/comment.service.d.ts +27 -37
  67. package/dist/modules/comment/comment.service.js +50 -84
  68. package/dist/modules/comment/index.d.ts +2 -3
  69. package/dist/modules/comment/index.js +16 -7
  70. package/dist/modules/database/database.module.js +2 -5
  71. package/dist/modules/database/index.d.ts +2 -5
  72. package/dist/modules/database/index.js +17 -9
  73. package/dist/modules/index.d.ts +2 -6
  74. package/dist/modules/index.js +2 -6
  75. package/dist/modules/like/index.d.ts +2 -1
  76. package/dist/modules/like/index.js +16 -3
  77. package/dist/modules/like/like-module-options.interface.d.ts +21 -0
  78. package/dist/modules/like/like.controller.d.ts +45 -37
  79. package/dist/modules/like/like.controller.js +117 -102
  80. package/dist/modules/like/like.module-definition.d.ts +1 -17
  81. package/dist/modules/like/like.module-definition.js +1 -2
  82. package/dist/modules/like/like.module.d.ts +12 -12
  83. package/dist/modules/like/like.module.js +14 -37
  84. package/dist/modules/like/like.service.d.ts +31 -27
  85. package/dist/modules/like/like.service.js +42 -35
  86. package/dist/modules/merge/index.d.ts +3 -0
  87. package/dist/modules/merge/index.js +19 -0
  88. package/dist/modules/merge/merge-module-options.interface.d.ts +21 -0
  89. package/dist/modules/merge/merge.controller.d.ts +30 -0
  90. package/dist/modules/merge/merge.controller.js +76 -0
  91. package/dist/modules/merge/merge.module.d.ts +18 -0
  92. package/dist/modules/merge/merge.module.js +41 -0
  93. package/dist/modules/merge/merge.service.interface.d.ts +17 -0
  94. package/dist/modules/services/base-http.service.d.ts +83 -0
  95. package/dist/modules/services/base-http.service.js +124 -0
  96. package/dist/modules/services/base-urls.d.ts +22 -0
  97. package/dist/modules/services/base-urls.js +121 -0
  98. package/dist/modules/services/index.d.ts +4 -0
  99. package/dist/modules/services/index.js +20 -0
  100. package/dist/modules/services/providers/accounts.service.d.ts +52 -0
  101. package/dist/modules/services/providers/accounts.service.js +82 -0
  102. package/dist/modules/services/providers/books.service.d.ts +29 -0
  103. package/dist/modules/services/providers/books.service.js +53 -0
  104. package/dist/modules/services/providers/changelog.service.d.ts +18 -0
  105. package/dist/modules/services/providers/changelog.service.js +41 -0
  106. package/dist/modules/services/providers/comments/comments.service-definition.d.ts +1 -0
  107. package/dist/modules/services/providers/comments/comments.service-definition.js +4 -0
  108. package/dist/modules/services/providers/comments/comments.service.d.ts +60 -0
  109. package/dist/modules/services/providers/comments/comments.service.js +138 -0
  110. package/dist/modules/services/providers/comments/index.d.ts +1 -0
  111. package/dist/{factories → modules/services/providers/comments}/index.js +1 -1
  112. package/dist/modules/services/providers/content/content-types.d.ts +20 -0
  113. package/dist/modules/services/providers/content/content-types.js +7 -0
  114. package/dist/modules/services/providers/content/content.service-definition.d.ts +1 -0
  115. package/dist/modules/services/providers/content/content.service-definition.js +4 -0
  116. package/dist/modules/services/providers/content/content.service.d.ts +94 -0
  117. package/dist/modules/services/providers/content/content.service.js +214 -0
  118. package/dist/modules/services/providers/content/index.d.ts +1 -0
  119. package/dist/modules/{search/models → services/providers/content}/index.js +1 -1
  120. package/dist/modules/services/providers/demo-hive.service.d.ts +29 -0
  121. package/dist/modules/services/providers/demo-hive.service.js +53 -0
  122. package/dist/modules/services/providers/events.service.d.ts +29 -0
  123. package/dist/modules/services/providers/events.service.js +53 -0
  124. package/dist/modules/services/providers/hackschool.service.d.ts +49 -0
  125. package/dist/modules/services/providers/hackschool.service.js +77 -0
  126. package/dist/modules/services/providers/ideas.service.d.ts +18 -0
  127. package/dist/modules/services/providers/ideas.service.js +41 -0
  128. package/dist/modules/services/providers/index.d.ts +19 -0
  129. package/dist/modules/services/providers/index.js +35 -0
  130. package/dist/modules/services/providers/lunch-roulette.service.d.ts +18 -0
  131. package/dist/modules/services/providers/lunch-roulette.service.js +41 -0
  132. package/dist/modules/services/providers/mail/index.d.ts +3 -0
  133. package/dist/modules/services/providers/mail/index.js +19 -0
  134. package/dist/modules/services/providers/mail/mail-types.d.ts +30 -0
  135. package/dist/modules/services/providers/mail/mail-types.js +22 -0
  136. package/dist/modules/services/providers/mail/mail.service.d.ts +99 -0
  137. package/dist/modules/{mail → services/providers/mail}/mail.service.js +54 -91
  138. package/dist/modules/services/providers/newletter.service.d.ts +29 -0
  139. package/dist/modules/services/providers/newletter.service.js +53 -0
  140. package/dist/modules/services/providers/newsroom.service.d.ts +47 -0
  141. package/dist/modules/services/providers/newsroom.service.js +71 -0
  142. package/dist/modules/services/providers/notification/dtos/schedule-notification.dto.js +2 -0
  143. package/dist/modules/services/providers/notification/index.d.ts +2 -0
  144. package/dist/modules/services/providers/notification/index.js +18 -0
  145. package/dist/modules/services/providers/notification/notification.service-definition.d.ts +1 -0
  146. package/dist/modules/services/providers/notification/notification.service-definition.js +4 -0
  147. package/dist/modules/services/providers/notification/notification.service.d.ts +50 -0
  148. package/dist/modules/services/providers/notification/notification.service.js +130 -0
  149. package/dist/modules/services/providers/pass/dtos/create-guild-member-pass.dto.js +2 -0
  150. package/dist/modules/services/providers/pass/dtos/create-team-member-pass.dto.js +2 -0
  151. package/dist/modules/services/providers/pass/index.d.ts +2 -0
  152. package/dist/modules/services/providers/pass/index.js +18 -0
  153. package/dist/modules/services/providers/pass/pass-types.d.ts +18 -0
  154. package/dist/modules/services/providers/pass/pass-types.js +7 -0
  155. package/dist/modules/{pass → services/providers/pass}/pass.service.d.ts +15 -39
  156. package/dist/modules/{pass → services/providers/pass}/pass.service.js +46 -61
  157. package/dist/modules/services/providers/podcasts.service.d.ts +29 -0
  158. package/dist/modules/services/providers/podcasts.service.js +53 -0
  159. package/dist/modules/services/providers/search/dtos/index-search-document.dto.js +2 -0
  160. package/dist/modules/services/providers/search/index.d.ts +2 -0
  161. package/dist/modules/services/providers/search/index.js +18 -0
  162. package/dist/modules/services/providers/search/search.service-definition.d.ts +1 -0
  163. package/dist/modules/services/providers/search/search.service-definition.js +4 -0
  164. package/dist/modules/services/providers/search/search.service.d.ts +66 -0
  165. package/dist/modules/services/providers/search/search.service.js +171 -0
  166. package/dist/modules/services/providers/team.service.d.ts +29 -0
  167. package/dist/modules/services/providers/team.service.js +53 -0
  168. package/dist/modules/services/providers/tech-radar.service.d.ts +39 -0
  169. package/dist/modules/services/providers/tech-radar.service.js +65 -0
  170. package/dist/modules/services/services-module-options.interface.d.ts +4 -0
  171. package/dist/modules/services/services-module-options.interface.js +2 -0
  172. package/dist/modules/services/services-options.parameter.d.ts +1 -0
  173. package/dist/modules/services/services-options.parameter.js +8 -0
  174. package/dist/modules/services/services.module-definition.d.ts +16 -0
  175. package/dist/modules/services/services.module-definition.js +21 -0
  176. package/dist/modules/services/services.module.d.ts +17 -0
  177. package/dist/modules/services/services.module.js +63 -0
  178. package/dist/pipes/index.d.ts +2 -3
  179. package/dist/pipes/index.js +2 -3
  180. package/dist/pipes/params/hub-id.pipe.d.ts +22 -0
  181. package/dist/pipes/{hub-id.pipe.js → params/hub-id.pipe.js} +14 -17
  182. package/dist/pipes/params/hub-resource.pipe.d.ts +22 -0
  183. package/dist/pipes/{hub-resource.pipe.js → params/hub-resource.pipe.js} +19 -20
  184. package/dist/pipes/params/index.d.ts +3 -0
  185. package/dist/pipes/params/index.js +19 -0
  186. package/dist/pipes/params/mongo-id.pipe.d.ts +15 -0
  187. package/dist/pipes/params/mongo-id.pipe.js +52 -0
  188. package/dist/pipes/queries/index.d.ts +3 -0
  189. package/dist/pipes/queries/index.js +19 -0
  190. package/dist/pipes/queries/mongo-ids.pipe.d.ts +22 -0
  191. package/dist/pipes/queries/mongo-ids.pipe.js +60 -0
  192. package/dist/pipes/queries/optional-boolean.pipe.d.ts +29 -0
  193. package/dist/pipes/queries/optional-boolean.pipe.js +72 -0
  194. package/dist/pipes/queries/optional-include-drafts.pipe.d.ts +28 -0
  195. package/dist/pipes/queries/optional-include-drafts.pipe.js +38 -0
  196. package/dist/properties/index.d.ts +1 -0
  197. package/dist/properties/index.js +5 -0
  198. package/dist/swagger/index.d.ts +1 -0
  199. package/dist/swagger/index.js +5 -0
  200. package/dist/swagger/remove-public-route-auth.plugin.d.ts +9 -0
  201. package/dist/swagger/remove-public-route-auth.plugin.js +25 -0
  202. package/dist/swagger/swagger-options.interface.d.ts +14 -0
  203. package/dist/swagger/swagger-options.interface.js +2 -0
  204. package/dist/swagger/swagger.function.d.ts +11 -0
  205. package/dist/swagger/swagger.function.js +47 -0
  206. package/dist/transform/boolean.transform.js +3 -3
  207. package/dist/viewable.interface.js +1 -1
  208. package/package.json +2 -2
  209. package/dist/factories/index.d.ts +0 -1
  210. package/dist/factories/virtuals.factory.d.ts +0 -79
  211. package/dist/factories/virtuals.factory.js +0 -171
  212. package/dist/modules/authentication/guards/auth.guard.d.ts +0 -36
  213. package/dist/modules/authentication/guards/auth.guard.js +0 -107
  214. package/dist/modules/authentication/guards/internal.guard.d.ts +0 -33
  215. package/dist/modules/authentication/guards/internal.guard.js +0 -72
  216. package/dist/modules/authentication/inject-auth-options.decorator.d.ts +0 -1
  217. package/dist/modules/comment/comment.model.d.ts +0 -29
  218. package/dist/modules/comment/comment.model.js +0 -43
  219. package/dist/modules/content/content.module-definition.d.ts +0 -5
  220. package/dist/modules/content/content.module-definition.js +0 -8
  221. package/dist/modules/content/content.module.d.ts +0 -31
  222. package/dist/modules/content/content.module.js +0 -60
  223. package/dist/modules/content/content.service.d.ts +0 -50
  224. package/dist/modules/content/content.service.js +0 -145
  225. package/dist/modules/content/index.d.ts +0 -3
  226. package/dist/modules/content/index.js +0 -9
  227. package/dist/modules/database/model-service/dbs/hub-account.db.d.ts +0 -28
  228. package/dist/modules/database/model-service/dbs/hub-account.db.js +0 -44
  229. package/dist/modules/database/model-service/dbs/hub-books.db.d.ts +0 -23
  230. package/dist/modules/database/model-service/dbs/hub-books.db.js +0 -45
  231. package/dist/modules/database/model-service/dbs/hub-comments.db.d.ts +0 -29
  232. package/dist/modules/database/model-service/dbs/hub-comments.db.js +0 -68
  233. package/dist/modules/database/model-service/dbs/hub-content.db.d.ts +0 -24
  234. package/dist/modules/database/model-service/dbs/hub-content.db.js +0 -49
  235. package/dist/modules/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
  236. package/dist/modules/database/model-service/dbs/hub-demo-hive.db.js +0 -45
  237. package/dist/modules/database/model-service/dbs/hub-events.db.d.ts +0 -24
  238. package/dist/modules/database/model-service/dbs/hub-events.db.js +0 -49
  239. package/dist/modules/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
  240. package/dist/modules/database/model-service/dbs/hub-hackschool.db.js +0 -106
  241. package/dist/modules/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
  242. package/dist/modules/database/model-service/dbs/hub-newsroom.db.js +0 -53
  243. package/dist/modules/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
  244. package/dist/modules/database/model-service/dbs/hub-podcasts.db.js +0 -45
  245. package/dist/modules/database/model-service/dbs/hub-team.db.d.ts +0 -22
  246. package/dist/modules/database/model-service/dbs/hub-team.db.js +0 -41
  247. package/dist/modules/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
  248. package/dist/modules/database/model-service/dbs/hub-tech-radar.db.js +0 -81
  249. package/dist/modules/database/model-service/model.service.d.ts +0 -6407
  250. package/dist/modules/database/model-service/model.service.js +0 -136
  251. package/dist/modules/database/populate-service/populate.service.d.ts +0 -73
  252. package/dist/modules/database/populate-service/populate.service.js +0 -163
  253. package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +0 -32
  254. package/dist/modules/database/service-mapper-service/service-mapper.service.js +0 -73
  255. package/dist/modules/fetch/fetch.module.d.ts +0 -31
  256. package/dist/modules/fetch/fetch.module.js +0 -60
  257. package/dist/modules/fetch/fetch.service.d.ts +0 -153
  258. package/dist/modules/fetch/fetch.service.js +0 -274
  259. package/dist/modules/fetch/index.d.ts +0 -2
  260. package/dist/modules/fetch/index.js +0 -7
  261. package/dist/modules/mail/index.d.ts +0 -4
  262. package/dist/modules/mail/index.js +0 -23
  263. package/dist/modules/mail/mail.module.d.ts +0 -31
  264. package/dist/modules/mail/mail.module.js +0 -60
  265. package/dist/modules/mail/mail.service.d.ts +0 -136
  266. package/dist/modules/notification/index.d.ts +0 -3
  267. package/dist/modules/notification/index.js +0 -22
  268. package/dist/modules/notification/notification.module-definition.d.ts +0 -5
  269. package/dist/modules/notification/notification.module-definition.js +0 -8
  270. package/dist/modules/notification/notification.module.d.ts +0 -34
  271. package/dist/modules/notification/notification.module.js +0 -63
  272. package/dist/modules/notification/notification.service.d.ts +0 -42
  273. package/dist/modules/notification/notification.service.js +0 -100
  274. package/dist/modules/pass/index.d.ts +0 -3
  275. package/dist/modules/pass/index.js +0 -22
  276. package/dist/modules/pass/pass.module.d.ts +0 -32
  277. package/dist/modules/pass/pass.module.js +0 -61
  278. package/dist/modules/search/index.d.ts +0 -4
  279. package/dist/modules/search/index.js +0 -23
  280. package/dist/modules/search/models/index.d.ts +0 -1
  281. package/dist/modules/search/search.module-definition.d.ts +0 -5
  282. package/dist/modules/search/search.module-definition.js +0 -8
  283. package/dist/modules/search/search.module.d.ts +0 -33
  284. package/dist/modules/search/search.module.js +0 -62
  285. package/dist/modules/search/search.service.d.ts +0 -49
  286. package/dist/modules/search/search.service.js +0 -120
  287. package/dist/pipes/hub-id.pipe.d.ts +0 -22
  288. package/dist/pipes/hub-resource.pipe.d.ts +0 -22
  289. package/dist/pipes/mongo-id.pipe.d.ts +0 -14
  290. package/dist/pipes/mongo-id.pipe.js +0 -52
  291. package/dist/swagger.config.d.ts +0 -36
  292. package/dist/swagger.config.js +0 -76
  293. /package/dist/modules/{mail/dtos/auth-login-token-mail.dto.js → comment/comment-module-options.interface.js} +0 -0
  294. /package/dist/modules/{mail/dtos/auth-password-reset-mail.dto.js → like/like-module-options.interface.js} +0 -0
  295. /package/dist/modules/{mail/dtos/event-cancel-mail.dto.js → merge/merge-module-options.interface.js} +0 -0
  296. /package/dist/modules/{mail/dtos/event-invite-mail.dto.js → merge/merge.service.interface.js} +0 -0
  297. /package/dist/modules/{mail → services/providers/mail}/dtos/auth-login-token-mail.dto.d.ts +0 -0
  298. /package/dist/modules/{mail/dtos/idea-status-updated-mail.dto.js → services/providers/mail/dtos/auth-login-token-mail.dto.js} +0 -0
  299. /package/dist/modules/{mail → services/providers/mail}/dtos/auth-password-reset-mail.dto.d.ts +0 -0
  300. /package/dist/modules/{mail/dtos/idea-submitted-mail.dto.js → services/providers/mail/dtos/auth-password-reset-mail.dto.js} +0 -0
  301. /package/dist/modules/{mail → services/providers/mail}/dtos/event-cancel-mail.dto.d.ts +0 -0
  302. /package/dist/modules/{mail/dtos/lunch-roulette-cancel-mail.dto.js → services/providers/mail/dtos/event-cancel-mail.dto.js} +0 -0
  303. /package/dist/modules/{mail → services/providers/mail}/dtos/event-invite-mail.dto.d.ts +0 -0
  304. /package/dist/modules/{mail/dtos/lunch-roulette-matched-mail.dto.js → services/providers/mail/dtos/event-invite-mail.dto.js} +0 -0
  305. /package/dist/modules/{mail → services/providers/mail}/dtos/idea-status-updated-mail.dto.d.ts +0 -0
  306. /package/dist/modules/{mail/dtos/lunch-roulette-submitted-mail.dto.js → services/providers/mail/dtos/idea-status-updated-mail.dto.js} +0 -0
  307. /package/dist/modules/{mail → services/providers/mail}/dtos/idea-submitted-mail.dto.d.ts +0 -0
  308. /package/dist/modules/{mail/dtos/lunch-roulette-unmatched-mail.dto.js → services/providers/mail/dtos/idea-submitted-mail.dto.js} +0 -0
  309. /package/dist/modules/{mail → services/providers/mail}/dtos/index.d.ts +0 -0
  310. /package/dist/modules/{mail → services/providers/mail}/dtos/index.js +0 -0
  311. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-cancel-mail.dto.d.ts +0 -0
  312. /package/dist/modules/{mail/dtos/newsletter-issue-mail.dto.js → services/providers/mail/dtos/lunch-roulette-cancel-mail.dto.js} +0 -0
  313. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-matched-mail.dto.d.ts +0 -0
  314. /package/dist/modules/{mail/dtos/newsletter-subscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-matched-mail.dto.js} +0 -0
  315. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-submitted-mail.dto.d.ts +0 -0
  316. /package/dist/modules/{mail/dtos/newsletter-unsubscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-submitted-mail.dto.js} +0 -0
  317. /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-unmatched-mail.dto.d.ts +0 -0
  318. /package/dist/modules/{mail/dtos/notification-mail.dto.js → services/providers/mail/dtos/lunch-roulette-unmatched-mail.dto.js} +0 -0
  319. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-issue-mail.dto.d.ts +0 -0
  320. /package/dist/modules/{notification/dtos/schedule-notification.dto.js → services/providers/mail/dtos/newsletter-issue-mail.dto.js} +0 -0
  321. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-subscribed-mail.dto.d.ts +0 -0
  322. /package/dist/modules/{pass/dtos/create-guild-member-pass.dto.js → services/providers/mail/dtos/newsletter-subscribed-mail.dto.js} +0 -0
  323. /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-unsubscribed-mail.dto.d.ts +0 -0
  324. /package/dist/modules/{pass/dtos/create-team-member-pass.dto.js → services/providers/mail/dtos/newsletter-unsubscribed-mail.dto.js} +0 -0
  325. /package/dist/modules/{mail → services/providers/mail}/dtos/notification-mail.dto.d.ts +0 -0
  326. /package/dist/modules/{search/dtos/index-search-document.dto.js → services/providers/mail/dtos/notification-mail.dto.js} +0 -0
  327. /package/dist/modules/{mail → services/providers/mail}/models/index.d.ts +0 -0
  328. /package/dist/modules/{mail → services/providers/mail}/models/index.js +0 -0
  329. /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.d.ts +0 -0
  330. /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.js +0 -0
  331. /package/dist/modules/{notification → services/providers/notification}/dtos/index.d.ts +0 -0
  332. /package/dist/modules/{notification → services/providers/notification}/dtos/index.js +0 -0
  333. /package/dist/modules/{notification → services/providers/notification}/dtos/schedule-notification.dto.d.ts +0 -0
  334. /package/dist/modules/{pass → services/providers/pass}/dtos/create-guild-member-pass.dto.d.ts +0 -0
  335. /package/dist/modules/{pass → services/providers/pass}/dtos/create-team-member-pass.dto.d.ts +0 -0
  336. /package/dist/modules/{pass → services/providers/pass}/dtos/index.d.ts +0 -0
  337. /package/dist/modules/{pass → services/providers/pass}/dtos/index.js +0 -0
  338. /package/dist/modules/{search → services/providers/search}/dtos/index-search-document.dto.d.ts +0 -0
  339. /package/dist/modules/{search → services/providers/search}/dtos/index.d.ts +0 -0
  340. /package/dist/modules/{search → services/providers/search}/dtos/index.js +0 -0
  341. /package/dist/{modules/content → properties}/content.property.d.ts +0 -0
  342. /package/dist/{modules/content → properties}/content.property.js +0 -0
@@ -0,0 +1 @@
1
+ export { PropertyContent } from './content.property';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertyContent = void 0;
4
+ var content_property_1 = require("./content.property");
5
+ Object.defineProperty(exports, "PropertyContent", { enumerable: true, get: function () { return content_property_1.PropertyContent; } });
@@ -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;
@@ -26,7 +26,7 @@ function PropertyViewedBy() {
26
26
  function ApiViewedBy() {
27
27
  return (0, swagger_1.ApiProperty)({
28
28
  name: 'viewedBy',
29
- type: [models_1.AccountEntity],
29
+ type: [models_1.Account],
30
30
  default: [],
31
31
  description: 'Accounts that have viewed this entity.',
32
32
  });
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.0",
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.4",
39
39
  "mongoose": "^8.17.1",
40
40
  "rxjs": "^7.8.2"
41
41
  },
@@ -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
- }
@@ -1,171 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VirtualsFactory = void 0;
4
- const class_validator_1 = require("class-validator");
5
- const hub_resource_enum_1 = require("../hub-resource.enum");
6
- /**
7
- * VirtualsFactory
8
- *
9
- * Provides a fluent, composable API for defining reusable Mongoose virtuals on schemas.
10
- * Helps keep schema definitions clean and DRY by centralizing the logic for frequently-used
11
- * virtual references (accounts, comments, likes, etc.), derived values, and hub-based resources.
12
- */
13
- class VirtualsFactory {
14
- /**
15
- * @param {Schema} schema - the schema to create the virtual field on
16
- * @param {HubResource} resource - the resource used for the virtual field
17
- */
18
- constructor(schema, resource) {
19
- this.schema = schema;
20
- this.resource = resource;
21
- }
22
- // ———————————————————————— Core Helper Methods ————————————————————————
23
- /**
24
- * Registers a generic virtual with custom Mongoose options.
25
- *
26
- * @param {string} name - The virtual field name.
27
- * @param {VirtualTypeOptions} [options] - The Mongoose virtual options.
28
- * @returns {VirtualsFactory} - The VirtualsFactory instance for chaining.
29
- */
30
- virtual(name, options) {
31
- this.schema.virtual(name, options);
32
- return this;
33
- }
34
- /**
35
- * Registers a virtual referencing a single Account by ID.
36
- *
37
- * @param {string} name - Virtual field name.
38
- * @param {string} localField - Field containing the Account ID.
39
- */
40
- virtualSingleAccount(name, localField) {
41
- this.schema.virtual(name, {
42
- ref: 'accounts',
43
- foreignField: '_id',
44
- localField,
45
- justOne: true,
46
- });
47
- return this;
48
- }
49
- /**
50
- * Registers a virtual referencing multiple Accounts by ID array.
51
- *
52
- * @param {string} name - Virtual field name.
53
- * @param {string} localField - Field containing array of Account IDs.
54
- */
55
- virtualMultipleAccounts(name, localField) {
56
- this.schema.virtual(name, {
57
- ref: 'accounts',
58
- foreignField: '_id',
59
- localField,
60
- justOne: false,
61
- });
62
- return this;
63
- }
64
- // ———————————————————————— Account-Related Virtuals ————————————————————————
65
- /** Links `accountId` → `account` (single Account) */
66
- get account() {
67
- return this.virtualSingleAccount('account', 'accountId');
68
- }
69
- /** Links `accountIds` → `accounts` (multiple Accounts) */
70
- get accounts() {
71
- return this.virtualMultipleAccounts('accounts', 'accountIds');
72
- }
73
- /** Links `authorId` → `author` (single Account) */
74
- get author() {
75
- return this.virtualSingleAccount('author', 'authorId');
76
- }
77
- /** Links `authorIds` → `authors` (multiple Accounts) */
78
- get authors() {
79
- return this.virtualMultipleAccounts('authors', 'authorIds');
80
- }
81
- /** Links `submitterId` → `submitter` (single Account) */
82
- get submitter() {
83
- return this.virtualSingleAccount('submitter', 'submitterId');
84
- }
85
- /** Links `submitterIds` → `submitters` (multiple Accounts) */
86
- get submitters() {
87
- return this.virtualMultipleAccounts('submitters', 'submitterIds');
88
- }
89
- /** Links `contactId` → `contact` (single Account) */
90
- get contact() {
91
- return this.virtualSingleAccount('contact', 'contactId');
92
- }
93
- /** Links `contactIds` → `contacts` (multiple Accounts) */
94
- get contacts() {
95
- return this.virtualMultipleAccounts('contacts', 'contactIds');
96
- }
97
- /** Links `_viewedBy` → `viewedBy` and creates derived `views` counter */
98
- get views() {
99
- this.virtualMultipleAccounts('viewedBy', '_viewedBy');
100
- this.schema.virtual('views').get(function () {
101
- return (0, class_validator_1.isArray)(this._viewedBy) ? this._viewedBy.length : 0;
102
- });
103
- return this;
104
- }
105
- /** Links `_likedBy` → `likedBy` and creates derived `likes` counter */
106
- get likes() {
107
- this.virtualMultipleAccounts('likedBy', '_likedBy');
108
- this.schema.virtual('likes').get(function () {
109
- return (0, class_validator_1.isArray)(this._likedBy) ? this._likedBy.length : 0;
110
- });
111
- return this;
112
- }
113
- // ———————————————————————— Comment-Related Virtuals ————————————————————————
114
- /**
115
- * Creates `comments` virtual for top-level comments on the resource.
116
- * Filters out replies.
117
- */
118
- get comments() {
119
- this.schema.virtual('comments', {
120
- ref: 'comments',
121
- foreignField: '_resourceId',
122
- localField: '_id',
123
- match: {
124
- _resource: this.resource,
125
- _replyTo: { $exists: false },
126
- },
127
- justOne: false,
128
- });
129
- return this;
130
- }
131
- /**
132
- * Creates `commentsCount` virtual for counting all related comments on this resource.
133
- */
134
- get commentsCount() {
135
- this.schema.virtual('commentsCount', {
136
- ref: 'comments',
137
- foreignField: '_resourceId',
138
- localField: '_id',
139
- match: { _resource: this.resource },
140
- count: true,
141
- });
142
- return this;
143
- }
144
- // ———————————————————————— Content and Utility Virtuals ————————————————————————
145
- /**
146
- * Creates an empty virtual field for general content use.
147
- * Placeholder to support virtual getter/setter extension in custom implementations.
148
- */
149
- get content() {
150
- this.schema.virtual('content');
151
- return this;
152
- }
153
- // ———————————————————————— Hub Resource Virtuals ————————————————————————
154
- /**
155
- * Registers `ref-[resource]` virtuals for each known Hub resource.
156
- * Used for polymorphic document relationships in the platform.
157
- */
158
- get hubResources() {
159
- for (const resource of hub_resource_enum_1.HUB_RESOURCES) {
160
- this.schema.virtual(`ref-${resource}`, {
161
- ref: resource,
162
- foreignField: '_id',
163
- localField: '_resourceId',
164
- match: { _resource: resource },
165
- justOne: true,
166
- });
167
- }
168
- return this;
169
- }
170
- }
171
- exports.VirtualsFactory = VirtualsFactory;
@@ -1,36 +0,0 @@
1
- import { CanActivate, ExecutionContext } from '@nestjs/common';
2
- import { Reflector } from '@nestjs/core';
3
- import { JwtService } from '@nestjs/jwt';
4
- import { AuthenticationModuleOptions } from '../authentication-module-options.interface';
5
- /**
6
- * AuthGuard
7
- *
8
- * @class
9
- * Implements route-level security using JWT authentication.
10
- * Allows bypassing auth for routes marked with the `IS_PUBLIC_METADATA_KEY` metadata.
11
- * If authentication is required, verifies the JWT and attaches the decoded payload to the request object.
12
- */
13
- export declare class AuthGuard implements CanActivate {
14
- private readonly authOptions;
15
- private readonly jwtService;
16
- private readonly reflector;
17
- constructor(authOptions: AuthenticationModuleOptions, jwtService: JwtService, reflector: Reflector);
18
- /**
19
- * Evaluates if the current request is authorized to proceed.
20
- * Skips JWT validation for routes marked as public.
21
- * If the route is protected, validates the JWT and attaches user data to the request.
22
- *
23
- * @param {ExecutionContext} context - The current request execution context.
24
- * @returns {boolean} Whether the request is allowed to proceed.
25
- * @throws {UnauthorizedException} If JWT is missing or invalid.
26
- */
27
- canActivate(context: ExecutionContext): boolean;
28
- }
29
- /**
30
- * Decorator that applies JWT authentication to a route or controller.
31
- * Combines NestJS guards and Swagger decorators to enforce security
32
- * and document the authentication requirement.
33
- *
34
- * @returns {MethodDecorator & ClassDecorator} A decorator that enforces JWT authentication.
35
- */
36
- export declare function RequireJwtAuth(): MethodDecorator & ClassDecorator;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AuthGuard = void 0;
16
- exports.RequireJwtAuth = RequireJwtAuth;
17
- const common_1 = require("@nestjs/common");
18
- const core_1 = require("@nestjs/core");
19
- const jwt_1 = require("@nestjs/jwt");
20
- const swagger_1 = require("@nestjs/swagger");
21
- const inject_auth_options_decorator_1 = require("../inject-auth-options.decorator");
22
- const public_guard_1 = require("./public.guard");
23
- /**
24
- * AuthGuard
25
- *
26
- * @class
27
- * Implements route-level security using JWT authentication.
28
- * Allows bypassing auth for routes marked with the `IS_PUBLIC_METADATA_KEY` metadata.
29
- * If authentication is required, verifies the JWT and attaches the decoded payload to the request object.
30
- */
31
- let AuthGuard = class AuthGuard {
32
- constructor(authOptions, jwtService, reflector) {
33
- this.authOptions = authOptions;
34
- this.jwtService = jwtService;
35
- this.reflector = reflector;
36
- }
37
- /**
38
- * Evaluates if the current request is authorized to proceed.
39
- * Skips JWT validation for routes marked as public.
40
- * If the route is protected, validates the JWT and attaches user data to the request.
41
- *
42
- * @param {ExecutionContext} context - The current request execution context.
43
- * @returns {boolean} Whether the request is allowed to proceed.
44
- * @throws {UnauthorizedException} If JWT is missing or invalid.
45
- */
46
- canActivate(context) {
47
- const isPublicRoute = this.reflector.getAllAndOverride(public_guard_1.IS_PUBLIC_METADATA_KEY, [
48
- context.getHandler(),
49
- context.getClass(),
50
- ]);
51
- if (isPublicRoute)
52
- return true; // Public route; skip auth.
53
- const request = context.switchToHttp().getRequest();
54
- const token = extractBearerToken(request);
55
- if (!token) {
56
- // No token found in request headers.
57
- throw new common_1.UnauthorizedException('Authorization token not found.');
58
- }
59
- try {
60
- // Attempt to verify token using configured JWT secret.
61
- const decodedUser = this.jwtService.verify(token, { secret: this.authOptions.jwtSecret });
62
- // Attach the decoded JWT payload to the request object for later use.
63
- request['user'] = decodedUser;
64
- }
65
- catch (_a) {
66
- // Verification failed: could be malformed, expired, or invalid signature.
67
- throw new common_1.UnauthorizedException('Invalid or expired token.');
68
- }
69
- return true;
70
- }
71
- };
72
- exports.AuthGuard = AuthGuard;
73
- exports.AuthGuard = AuthGuard = __decorate([
74
- (0, common_1.Injectable)(),
75
- __param(0, (0, inject_auth_options_decorator_1.InjectAuthOptions)()),
76
- __metadata("design:paramtypes", [Object, jwt_1.JwtService,
77
- core_1.Reflector])
78
- ], AuthGuard);
79
- /**
80
- * Extracts a JWT from the Authorization header of the HTTP request.
81
- * Accepts only the 'Bearer <token>' format.
82
- *
83
- * @param {Request} request - Incoming HTTP request from the client.
84
- * @returns {string | undefined} The extracted token if present and valid; otherwise, undefined.
85
- */
86
- function extractBearerToken(request) {
87
- const authorizationHeader = request.headers.authorization;
88
- if (!authorizationHeader)
89
- return undefined;
90
- const [scheme, token] = authorizationHeader.split(' ');
91
- // Only accept Bearer token format
92
- if (scheme !== 'Bearer' || !(token === null || token === void 0 ? void 0 : token.trim())) {
93
- return undefined;
94
- }
95
- return token;
96
- }
97
- /**
98
- * Decorator that applies JWT authentication to a route or controller.
99
- * Combines NestJS guards and Swagger decorators to enforce security
100
- * and document the authentication requirement.
101
- *
102
- * @returns {MethodDecorator & ClassDecorator} A decorator that enforces JWT authentication.
103
- */
104
- function RequireJwtAuth() {
105
- return (0, common_1.applyDecorators)((0, common_1.UseGuards)(AuthGuard), (0, swagger_1.ApiBearerAuth)(), // Indicates that the route uses bearer token auth.
106
- (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized: Invalid or missing JWT' }));
107
- }
@@ -1,33 +0,0 @@
1
- import { CanActivate, ExecutionContext } from '@nestjs/common';
2
- import { AuthenticationModuleOptions } from '../authentication-module-options.interface';
3
- /**
4
- * INTERNAL_HEADER_KEY
5
- *
6
- * Custom HTTP header used to validate internal Kubernetes-based requests.
7
- * This header must contain a pre-configured token for access to protected internal routes.
8
- */
9
- export declare const INTERNAL_HEADER_KEY = "X-itlab-k8s-auth";
10
- /**
11
- * Guard that validates incoming requests against a shared internal token,
12
- * typically used for internal service-to-service communication (e.g. from Kubernetes).
13
- * Only requests with a matching token in the `X-itlab-k8s-auth` header are authorized.
14
- */
15
- export declare class InternalGuard implements CanActivate {
16
- private readonly authOptions;
17
- constructor(authOptions: AuthenticationModuleOptions);
18
- /**
19
- * Determines whether the request contains a valid internal auth token.
20
- *
21
- * @param {ExecutionContext} context - The current execution context of the request.
22
- * @returns {boolean} Whether the request is authorized.
23
- * @throws {UnauthorizedException} If the token is missing or invalid.
24
- */
25
- canActivate(context: ExecutionContext): boolean;
26
- }
27
- /**
28
- * Decorator that secures a controller or route to only be accessible by internal services
29
- * using the `InternalGuard`. Adds Swagger docs indicating the required custom header.
30
- *
31
- * @returns {MethodDecorator & ClassDecorator} Decorator to enforce internal-only access.
32
- */
33
- export declare function InternalOnly(): MethodDecorator & ClassDecorator;