@lenne.tech/nest-server 10.2.6 → 10.2.8

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 (327) hide show
  1. package/dist/config.env.js +75 -75
  2. package/dist/config.env.js.map +1 -1
  3. package/dist/core/common/args/filter.args.js +1 -1
  4. package/dist/core/common/args/filter.args.js.map +1 -1
  5. package/dist/core/common/args/pagination.args.js.map +1 -1
  6. package/dist/core/common/decorators/current-user.decorator.js.map +1 -1
  7. package/dist/core/common/decorators/graphql-populate.decorator.js.map +1 -1
  8. package/dist/core/common/decorators/graphql-service-options.decorator.js.map +1 -1
  9. package/dist/core/common/decorators/restricted.decorator.d.ts +4 -4
  10. package/dist/core/common/decorators/restricted.decorator.js +2 -2
  11. package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
  12. package/dist/core/common/enums/comparison-operator.enum.js +1 -1
  13. package/dist/core/common/enums/comparison-operator.enum.js.map +1 -1
  14. package/dist/core/common/enums/logical-operator.enum.js +1 -1
  15. package/dist/core/common/enums/logical-operator.enum.js.map +1 -1
  16. package/dist/core/common/enums/role.enum.d.ts +3 -3
  17. package/dist/core/common/enums/role.enum.js +2 -2
  18. package/dist/core/common/enums/role.enum.js.map +1 -1
  19. package/dist/core/common/enums/sort-order.emum.js +1 -1
  20. package/dist/core/common/enums/sort-order.emum.js.map +1 -1
  21. package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
  22. package/dist/core/common/helpers/config.helper.js.map +1 -1
  23. package/dist/core/common/helpers/context.helper.js +1 -1
  24. package/dist/core/common/helpers/context.helper.js.map +1 -1
  25. package/dist/core/common/helpers/db.helper.d.ts +28 -4
  26. package/dist/core/common/helpers/db.helper.js +4 -4
  27. package/dist/core/common/helpers/db.helper.js.map +1 -1
  28. package/dist/core/common/helpers/decorator.helper.d.ts +24 -0
  29. package/dist/core/common/helpers/decorator.helper.js.map +1 -1
  30. package/dist/core/common/helpers/file.helper.js +1 -1
  31. package/dist/core/common/helpers/file.helper.js.map +1 -1
  32. package/dist/core/common/helpers/filter.helper.d.ts +26 -2
  33. package/dist/core/common/helpers/filter.helper.js +3 -3
  34. package/dist/core/common/helpers/filter.helper.js.map +1 -1
  35. package/dist/core/common/helpers/graphql.helper.d.ts +2 -2
  36. package/dist/core/common/helpers/graphql.helper.js +1 -1
  37. package/dist/core/common/helpers/graphql.helper.js.map +1 -1
  38. package/dist/core/common/helpers/input.helper.d.ts +3 -3
  39. package/dist/core/common/helpers/input.helper.js +5 -5
  40. package/dist/core/common/helpers/input.helper.js.map +1 -1
  41. package/dist/core/common/helpers/model.helper.d.ts +2 -2
  42. package/dist/core/common/helpers/model.helper.js +3 -3
  43. package/dist/core/common/helpers/model.helper.js.map +1 -1
  44. package/dist/core/common/helpers/service.helper.d.ts +6 -6
  45. package/dist/core/common/helpers/service.helper.js +5 -5
  46. package/dist/core/common/helpers/service.helper.js.map +1 -1
  47. package/dist/core/common/helpers/table.helper.d.ts +9 -0
  48. package/dist/core/common/helpers/table.helper.js +28 -0
  49. package/dist/core/common/helpers/table.helper.js.map +1 -0
  50. package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
  51. package/dist/core/common/inputs/filter.input.js.map +1 -1
  52. package/dist/core/common/inputs/single-filter.input.js.map +1 -1
  53. package/dist/core/common/inputs/sort.input.js.map +1 -1
  54. package/dist/core/common/interceptors/check-response.interceptor.js.map +1 -1
  55. package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
  56. package/dist/core/common/interfaces/core-persistence-model.interface.d.ts +3 -3
  57. package/dist/core/common/interfaces/mailjet-options.interface.d.ts +1 -1
  58. package/dist/core/common/interfaces/prepare-input-options.interface.d.ts +1 -1
  59. package/dist/core/common/interfaces/server-options.interface.d.ts +15 -7
  60. package/dist/core/common/interfaces/service-options.interface.d.ts +31 -5
  61. package/dist/core/common/models/core-model.model.js.map +1 -1
  62. package/dist/core/common/models/core-persistence.model.d.ts +24 -0
  63. package/dist/core/common/models/core-persistence.model.js.map +1 -1
  64. package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
  65. package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
  66. package/dist/core/common/plugins/complexity.plugin.js +4 -4
  67. package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
  68. package/dist/core/common/plugins/mongoose-id.plugin.js.map +1 -1
  69. package/dist/core/common/scalars/any.scalar.js.map +1 -1
  70. package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
  71. package/dist/core/common/scalars/date.scalar.js.map +1 -1
  72. package/dist/core/common/scalars/json.scalar.js.map +1 -1
  73. package/dist/core/common/services/brevo.service.d.ts +10 -0
  74. package/dist/core/common/services/brevo.service.js +75 -0
  75. package/dist/core/common/services/brevo.service.js.map +1 -0
  76. package/dist/core/common/services/config.service.js +1 -1
  77. package/dist/core/common/services/config.service.js.map +1 -1
  78. package/dist/core/common/services/core-cron-jobs.service.d.ts +2 -2
  79. package/dist/core/common/services/core-cron-jobs.service.js.map +1 -1
  80. package/dist/core/common/services/crud.service.d.ts +63 -32
  81. package/dist/core/common/services/crud.service.js +59 -21
  82. package/dist/core/common/services/crud.service.js.map +1 -1
  83. package/dist/core/common/services/email.service.js +5 -5
  84. package/dist/core/common/services/email.service.js.map +1 -1
  85. package/dist/core/common/services/mailjet.service.d.ts +4 -4
  86. package/dist/core/common/services/mailjet.service.js +8 -8
  87. package/dist/core/common/services/mailjet.service.js.map +1 -1
  88. package/dist/core/common/services/model-doc.service.d.ts +24 -0
  89. package/dist/core/common/services/model-doc.service.js +1 -1
  90. package/dist/core/common/services/model-doc.service.js.map +1 -1
  91. package/dist/core/common/services/module.service.d.ts +28 -4
  92. package/dist/core/common/services/module.service.js +23 -7
  93. package/dist/core/common/services/module.service.js.map +1 -1
  94. package/dist/core/common/services/template.service.js +3 -3
  95. package/dist/core/common/services/template.service.js.map +1 -1
  96. package/dist/core/common/types/core-model-constructor.type.d.ts +1 -1
  97. package/dist/core/common/types/falsy.type.d.ts +1 -1
  98. package/dist/core/common/types/field-selection.type.d.ts +25 -1
  99. package/dist/core/common/types/ids.type.d.ts +31 -7
  100. package/dist/core/common/types/maybe-promise.type.d.ts +1 -1
  101. package/dist/core/common/types/plain-input.type.d.ts +1 -1
  102. package/dist/core/common/types/populate-config.type.d.ts +25 -1
  103. package/dist/core/common/types/string-or-object-id.type.d.ts +25 -1
  104. package/dist/core/modules/auth/core-auth.controller.js +1 -1
  105. package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
  106. package/dist/core/modules/auth/core-auth.model.js.map +1 -1
  107. package/dist/core/modules/auth/core-auth.module.d.ts +5 -5
  108. package/dist/core/modules/auth/core-auth.module.js +5 -5
  109. package/dist/core/modules/auth/core-auth.module.js.map +1 -1
  110. package/dist/core/modules/auth/core-auth.resolver.js +1 -1
  111. package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
  112. package/dist/core/modules/auth/guards/auth.guard.d.ts +1 -1
  113. package/dist/core/modules/auth/guards/auth.guard.js +1 -1
  114. package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
  115. package/dist/core/modules/auth/guards/refresh-token.guard.js.map +1 -1
  116. package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
  117. package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
  118. package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
  119. package/dist/core/modules/auth/interfaces/core-auth-user.interface.d.ts +1 -1
  120. package/dist/core/modules/auth/interfaces/core-token-data.interface.d.ts +1 -1
  121. package/dist/core/modules/auth/interfaces/jwt-payload.interface.d.ts +1 -1
  122. package/dist/core/modules/auth/services/core-auth.service.d.ts +1 -1
  123. package/dist/core/modules/auth/services/core-auth.service.js +10 -10
  124. package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
  125. package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js +1 -1
  126. package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js.map +1 -1
  127. package/dist/core/modules/auth/strategies/jwt.strategy.js.map +1 -1
  128. package/dist/core/modules/auth/tokens.decorator.js +1 -1
  129. package/dist/core/modules/auth/tokens.decorator.js.map +1 -1
  130. package/dist/core/modules/file/core-file-info.model.d.ts +24 -0
  131. package/dist/core/modules/file/core-file-info.model.js +5 -5
  132. package/dist/core/modules/file/core-file-info.model.js.map +1 -1
  133. package/dist/core/modules/file/core-file.controller.js.map +1 -1
  134. package/dist/core/modules/file/core-file.resolver.js +1 -1
  135. package/dist/core/modules/file/core-file.resolver.js.map +1 -1
  136. package/dist/core/modules/file/core-file.service.d.ts +30 -6
  137. package/dist/core/modules/file/core-file.service.js +3 -3
  138. package/dist/core/modules/file/core-file.service.js.map +1 -1
  139. package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +1 -1
  140. package/dist/core/modules/file/interfaces/file-upload.interface.d.ts +2 -2
  141. package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
  142. package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
  143. package/dist/core/modules/health-check/core-health-check.module.js +1 -1
  144. package/dist/core/modules/health-check/core-health-check.module.js.map +1 -1
  145. package/dist/core/modules/health-check/core-health-check.resolver.js +2 -2
  146. package/dist/core/modules/health-check/core-health-check.resolver.js.map +1 -1
  147. package/dist/core/modules/health-check/core-health-check.service.js +1 -1
  148. package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
  149. package/dist/core/modules/user/core-user.model.d.ts +24 -0
  150. package/dist/core/modules/user/core-user.model.js +1 -1
  151. package/dist/core/modules/user/core-user.model.js.map +1 -1
  152. package/dist/core/modules/user/core-user.service.d.ts +25 -1
  153. package/dist/core/modules/user/core-user.service.js +3 -3
  154. package/dist/core/modules/user/core-user.service.js.map +1 -1
  155. package/dist/core/modules/user/inputs/core-user-create.input.js +1 -1
  156. package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
  157. package/dist/core/modules/user/inputs/core-user.input.js +1 -1
  158. package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
  159. package/dist/core.module.js +20 -20
  160. package/dist/core.module.js.map +1 -1
  161. package/dist/index.d.ts +2 -0
  162. package/dist/index.js +2 -0
  163. package/dist/index.js.map +1 -1
  164. package/dist/main.js +3 -3
  165. package/dist/main.js.map +1 -1
  166. package/dist/server/common/models/persistence.model.d.ts +24 -0
  167. package/dist/server/common/models/persistence.model.js +4 -4
  168. package/dist/server/common/models/persistence.model.js.map +1 -1
  169. package/dist/server/common/services/cron-jobs.service.js.map +1 -1
  170. package/dist/server/modules/auth/auth.controller.js.map +1 -1
  171. package/dist/server/modules/auth/auth.model.js.map +1 -1
  172. package/dist/server/modules/auth/auth.module.js +2 -2
  173. package/dist/server/modules/auth/auth.module.js.map +1 -1
  174. package/dist/server/modules/auth/auth.resolver.js.map +1 -1
  175. package/dist/server/modules/auth/auth.service.js +1 -1
  176. package/dist/server/modules/auth/auth.service.js.map +1 -1
  177. package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
  178. package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
  179. package/dist/server/modules/file/file-info.model.js.map +1 -1
  180. package/dist/server/modules/file/file.controller.js.map +1 -1
  181. package/dist/server/modules/file/file.module.js +2 -2
  182. package/dist/server/modules/file/file.module.js.map +1 -1
  183. package/dist/server/modules/file/file.resolver.js +5 -5
  184. package/dist/server/modules/file/file.resolver.js.map +1 -1
  185. package/dist/server/modules/file/file.service.d.ts +24 -0
  186. package/dist/server/modules/file/file.service.js.map +1 -1
  187. package/dist/server/modules/file/multer-config.service.js +2 -2
  188. package/dist/server/modules/file/multer-config.service.js.map +1 -1
  189. package/dist/server/modules/user/avatar.controller.js.map +1 -1
  190. package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
  191. package/dist/server/modules/user/inputs/user.input.js.map +1 -1
  192. package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
  193. package/dist/server/modules/user/user.model.js +2 -2
  194. package/dist/server/modules/user/user.model.js.map +1 -1
  195. package/dist/server/modules/user/user.module.js +2 -2
  196. package/dist/server/modules/user/user.module.js.map +1 -1
  197. package/dist/server/modules/user/user.resolver.d.ts +1 -1
  198. package/dist/server/modules/user/user.resolver.js +1 -1
  199. package/dist/server/modules/user/user.resolver.js.map +1 -1
  200. package/dist/server/modules/user/user.service.d.ts +25 -1
  201. package/dist/server/modules/user/user.service.js +2 -2
  202. package/dist/server/modules/user/user.service.js.map +1 -1
  203. package/dist/server/server.controller.js.map +1 -1
  204. package/dist/server/server.module.js +2 -2
  205. package/dist/server/server.module.js.map +1 -1
  206. package/dist/test/test.helper.d.ts +13 -13
  207. package/dist/test/test.helper.js +15 -15
  208. package/dist/test/test.helper.js.map +1 -1
  209. package/dist/tsconfig.build.tsbuildinfo +1 -1
  210. package/package.json +35 -34
  211. package/src/config.env.ts +79 -78
  212. package/src/core/common/args/filter.args.ts +2 -1
  213. package/src/core/common/args/pagination.args.ts +1 -0
  214. package/src/core/common/decorators/current-user.decorator.ts +1 -0
  215. package/src/core/common/decorators/graphql-populate.decorator.ts +1 -0
  216. package/src/core/common/decorators/graphql-service-options.decorator.ts +1 -0
  217. package/src/core/common/decorators/restricted.decorator.ts +7 -5
  218. package/src/core/common/enums/comparison-operator.enum.ts +1 -1
  219. package/src/core/common/enums/logical-operator.enum.ts +1 -1
  220. package/src/core/common/enums/role.enum.ts +6 -6
  221. package/src/core/common/enums/sort-order.emum.ts +1 -1
  222. package/src/core/common/helpers/context.helper.ts +1 -1
  223. package/src/core/common/helpers/db.helper.ts +14 -12
  224. package/src/core/common/helpers/decorator.helper.ts +1 -0
  225. package/src/core/common/helpers/file.helper.ts +1 -1
  226. package/src/core/common/helpers/filter.helper.ts +6 -5
  227. package/src/core/common/helpers/graphql.helper.ts +7 -6
  228. package/src/core/common/helpers/input.helper.ts +10 -8
  229. package/src/core/common/helpers/model.helper.ts +6 -5
  230. package/src/core/common/helpers/service.helper.ts +13 -11
  231. package/src/core/common/helpers/table.helper.ts +37 -0
  232. package/src/core/common/inputs/combined-filter.input.ts +1 -0
  233. package/src/core/common/inputs/filter.input.ts +1 -0
  234. package/src/core/common/inputs/single-filter.input.ts +1 -0
  235. package/src/core/common/inputs/sort.input.ts +1 -0
  236. package/src/core/common/interceptors/check-response.interceptor.ts +1 -0
  237. package/src/core/common/interceptors/check-security.interceptor.ts +1 -0
  238. package/src/core/common/interfaces/core-persistence-model.interface.ts +3 -3
  239. package/src/core/common/interfaces/cron-job-config-with-time-zone.interface.ts +1 -0
  240. package/src/core/common/interfaces/cron-job-config-with-utc-offset.interface.ts +1 -0
  241. package/src/core/common/interfaces/mailjet-options.interface.ts +1 -1
  242. package/src/core/common/interfaces/prepare-input-options.interface.ts +1 -1
  243. package/src/core/common/interfaces/server-options.interface.ts +49 -23
  244. package/src/core/common/interfaces/service-options.interface.ts +31 -16
  245. package/src/core/common/models/core-persistence.model.ts +1 -0
  246. package/src/core/common/pipes/check-input.pipe.ts +1 -0
  247. package/src/core/common/pipes/map-and-validate.pipe.ts +1 -0
  248. package/src/core/common/plugins/complexity.plugin.ts +5 -4
  249. package/src/core/common/scalars/date-timestamp.scalar.ts +1 -0
  250. package/src/core/common/scalars/date.scalar.ts +1 -0
  251. package/src/core/common/services/brevo.service.ts +93 -0
  252. package/src/core/common/services/config.service.ts +3 -1
  253. package/src/core/common/services/core-cron-jobs.service.ts +3 -2
  254. package/src/core/common/services/crud.service.ts +113 -41
  255. package/src/core/common/services/email.service.ts +7 -5
  256. package/src/core/common/services/mailjet.service.ts +14 -13
  257. package/src/core/common/services/model-doc.service.ts +2 -1
  258. package/src/core/common/services/module.service.ts +33 -13
  259. package/src/core/common/services/template.service.ts +5 -3
  260. package/src/core/common/types/core-model-constructor.type.ts +1 -1
  261. package/src/core/common/types/falsy.type.ts +1 -1
  262. package/src/core/common/types/field-selection.type.ts +4 -3
  263. package/src/core/common/types/ids.type.ts +3 -3
  264. package/src/core/common/types/maybe-promise.type.ts +1 -1
  265. package/src/core/common/types/plain-input.type.ts +1 -1
  266. package/src/core/common/types/populate-config.type.ts +1 -1
  267. package/src/core/common/types/string-or-object-id.type.ts +1 -1
  268. package/src/core/modules/auth/core-auth.controller.ts +2 -1
  269. package/src/core/modules/auth/core-auth.model.ts +1 -0
  270. package/src/core/modules/auth/core-auth.module.ts +8 -7
  271. package/src/core/modules/auth/core-auth.resolver.ts +2 -1
  272. package/src/core/modules/auth/guards/auth.guard.ts +4 -2
  273. package/src/core/modules/auth/guards/refresh-token.guard.ts +1 -0
  274. package/src/core/modules/auth/guards/roles.guard.ts +1 -0
  275. package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +1 -0
  276. package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +1 -0
  277. package/src/core/modules/auth/interfaces/core-auth-user.interface.ts +4 -4
  278. package/src/core/modules/auth/interfaces/core-token-data.interface.ts +4 -4
  279. package/src/core/modules/auth/interfaces/jwt-payload.interface.ts +1 -1
  280. package/src/core/modules/auth/services/core-auth.service.ts +13 -11
  281. package/src/core/modules/auth/strategies/jwt-refresh.strategy.ts +3 -2
  282. package/src/core/modules/auth/strategies/jwt.strategy.ts +3 -2
  283. package/src/core/modules/auth/tokens.decorator.ts +4 -3
  284. package/src/core/modules/file/core-file-info.model.ts +6 -5
  285. package/src/core/modules/file/core-file.controller.ts +1 -0
  286. package/src/core/modules/file/core-file.resolver.ts +2 -1
  287. package/src/core/modules/file/core-file.service.ts +9 -8
  288. package/src/core/modules/file/interfaces/file-service-options.interface.ts +1 -1
  289. package/src/core/modules/file/interfaces/file-upload.interface.ts +2 -2
  290. package/src/core/modules/health-check/core-health-check-result.model.ts +1 -0
  291. package/src/core/modules/health-check/core-health-check.controller.ts +1 -0
  292. package/src/core/modules/health-check/core-health-check.module.ts +2 -1
  293. package/src/core/modules/health-check/core-health-check.resolver.ts +3 -2
  294. package/src/core/modules/health-check/core-health-check.service.ts +2 -1
  295. package/src/core/modules/user/core-user.model.ts +2 -1
  296. package/src/core/modules/user/core-user.service.ts +6 -4
  297. package/src/core/modules/user/inputs/core-user-create.input.ts +2 -1
  298. package/src/core/modules/user/inputs/core-user.input.ts +2 -1
  299. package/src/core.module.ts +24 -22
  300. package/src/index.ts +2 -0
  301. package/src/main.ts +5 -3
  302. package/src/server/common/models/persistence.model.ts +7 -5
  303. package/src/server/common/services/cron-jobs.service.ts +1 -0
  304. package/src/server/modules/auth/auth.controller.ts +1 -0
  305. package/src/server/modules/auth/auth.model.ts +1 -0
  306. package/src/server/modules/auth/auth.module.ts +3 -2
  307. package/src/server/modules/auth/auth.resolver.ts +1 -0
  308. package/src/server/modules/auth/auth.service.ts +2 -1
  309. package/src/server/modules/auth/inputs/auth-sign-in.input.ts +1 -0
  310. package/src/server/modules/auth/inputs/auth-sign-up.input.ts +1 -0
  311. package/src/server/modules/file/file-info.model.ts +1 -0
  312. package/src/server/modules/file/file.controller.ts +1 -0
  313. package/src/server/modules/file/file.module.ts +3 -2
  314. package/src/server/modules/file/file.resolver.ts +7 -5
  315. package/src/server/modules/file/file.service.ts +1 -0
  316. package/src/server/modules/file/multer-config.service.ts +3 -2
  317. package/src/server/modules/user/avatar.controller.ts +1 -0
  318. package/src/server/modules/user/inputs/user-create.input.ts +1 -0
  319. package/src/server/modules/user/inputs/user.input.ts +1 -0
  320. package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +1 -0
  321. package/src/server/modules/user/user.model.ts +3 -2
  322. package/src/server/modules/user/user.module.ts +3 -2
  323. package/src/server/modules/user/user.resolver.ts +2 -1
  324. package/src/server/modules/user/user.service.ts +5 -3
  325. package/src/server/server.controller.ts +1 -0
  326. package/src/server/server.module.ts +7 -6
  327. package/src/test/test.helper.ts +28 -26
@@ -5,11 +5,12 @@ import { JwtSignOptions } from '@nestjs/jwt/dist/interfaces';
5
5
  import { MongooseModuleOptions } from '@nestjs/mongoose';
6
6
  import { ServeStaticOptions } from '@nestjs/platform-express/interfaces/serve-static-options.interface';
7
7
  import { CronExpression } from '@nestjs/schedule';
8
+ import { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health';
9
+ import { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type';
8
10
  import compression from 'compression';
9
11
  import { CollationOptions } from 'mongodb';
10
12
  import * as SMTPTransport from 'nodemailer/lib/smtp-transport';
11
- import { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health';
12
- import { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type';
13
+
13
14
  import { Falsy } from '../types/falsy.type';
14
15
  import { CronJobConfigWithTimeZone } from './cron-job-config-with-time-zone.interface';
15
16
  import { CronJobConfigWithUtcOffset } from './cron-job-config-with-utc-offset.interface';
@@ -70,6 +71,31 @@ export interface IServerOptions {
70
71
  */
71
72
  automaticObjectIdFiltering?: boolean;
72
73
 
74
+ /**
75
+ * Configuration for Brevo
76
+ * See: https://developers.brevo.com/
77
+ */
78
+ brevo?: {
79
+ /**
80
+ * API key for Brevo
81
+ */
82
+ apiKey: string;
83
+
84
+ /**
85
+ * Regular expression for excluding (test) users
86
+ * e.g. /@testuser.com$/i
87
+ */
88
+ exclude?: RegExp;
89
+
90
+ /**
91
+ * Default sender for Brevo
92
+ */
93
+ sender: {
94
+ email: string;
95
+ name: string;
96
+ };
97
+ };
98
+
73
99
  /**
74
100
  * Whether to use the compression middleware package to enable gzip compression.
75
101
  * See: https://docs.nestjs.com/techniques/compression
@@ -86,7 +112,7 @@ export interface IServerOptions {
86
112
  * Cron jobs configuration object with the name of the cron job function as key
87
113
  * and the cron expression or config as value
88
114
  */
89
- cronJobs?: Record<string, CronExpression | string | Date | Falsy | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset>;
115
+ cronJobs?: Record<string, CronExpression | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset | Date | Falsy | string>;
90
116
 
91
117
  /**
92
118
  * SMTP and template configuration for sending emails
@@ -182,11 +208,6 @@ export interface IServerOptions {
182
208
  */
183
209
  healthCheck?: {
184
210
 
185
- /**
186
- * Whether health check is enabled
187
- */
188
- enabled?: boolean;
189
-
190
211
  /**
191
212
  * Configuration of single health checks
192
213
  */
@@ -224,14 +245,14 @@ export interface IServerOptions {
224
245
  enabled?: boolean;
225
246
 
226
247
  /**
227
- * Key in result JSON
248
+ * Memory limit in bytes
228
249
  */
229
- key?: string;
250
+ heapUsedThreshold?: number;
230
251
 
231
252
  /**
232
- * Memory limit in bytes
253
+ * Key in result JSON
233
254
  */
234
- heapUsedThreshold?: number;
255
+ key?: string;
235
256
  };
236
257
 
237
258
  /**
@@ -276,6 +297,11 @@ export interface IServerOptions {
276
297
  options?: DiskHealthIndicatorOptions;
277
298
  };
278
299
  };
300
+
301
+ /**
302
+ * Whether health check is enabled
303
+ */
304
+ enabled?: boolean;
279
305
  };
280
306
 
281
307
  /**
@@ -355,11 +381,6 @@ export interface IServerOptions {
355
381
  */
356
382
  modelDocumentation?: boolean;
357
383
 
358
- /**
359
- * Mongoose connection string
360
- */
361
- uri: string;
362
-
363
384
  /**
364
385
  * Mongoose module options
365
386
  */
@@ -373,6 +394,11 @@ export interface IServerOptions {
373
394
  * default: false
374
395
  */
375
396
  strictQuery?: boolean;
397
+
398
+ /**
399
+ * Mongoose connection string
400
+ */
401
+ uri: string;
376
402
  };
377
403
 
378
404
  /**
@@ -381,6 +407,12 @@ export interface IServerOptions {
381
407
  */
382
408
  port?: number;
383
409
 
410
+ /**
411
+ * Whether to enable verification and automatic encryption for received passwords that are not in sha256 format
412
+ * default = false, sha256 format check: /^[a-f0-9]{64}$/i
413
+ */
414
+ sha256?: boolean;
415
+
384
416
  /**
385
417
  * Configuration for useStaticAssets
386
418
  */
@@ -398,12 +430,6 @@ export interface IServerOptions {
398
430
  path?: string;
399
431
  };
400
432
 
401
- /**
402
- * Whether to enable verification and automatic encryption for received passwords that are not in sha256 format
403
- * default = false, sha256 format check: /^[a-f0-9]{64}$/i
404
- */
405
- sha256?: boolean;
406
-
407
433
  /**
408
434
  * Templates
409
435
  */
@@ -1,11 +1,18 @@
1
1
  import { CollationOptions } from 'mongodb';
2
2
  import { Model, PopulateOptions } from 'mongoose';
3
+
3
4
  import { FieldSelection } from '../types/field-selection.type';
4
5
  import { PrepareInputOptions } from './prepare-input-options.interface';
5
6
  import { PrepareOutputOptions } from './prepare-output-options.interface';
6
7
 
7
8
  /**
8
9
  * General service options
10
+ *
11
+ * HINT:
12
+ * If this interface is extended (ServiceOptions & { ... }), then only properties that are not present in
13
+ * ServiceOptions may be added in order to avoid unwanted side effects. To ensure this (also for future changes to
14
+ * ServiceOptions), the properties of the extension should be provided with a prefix, e.g. with an underscore
15
+ * (ServiceOptions & {_myProperty: any}).
9
16
  */
10
17
  export interface ServiceOptions {
11
18
  // All fields are allowed to be compatible as far as possible
@@ -45,38 +52,46 @@ export interface ServiceOptions {
45
52
  outputType?: new (...params: any[]) => any;
46
53
 
47
54
  // Alias for fieldSelection (if both are set fieldSelection is overwritten by populate)
48
- populate?: string | PopulateOptions | (PopulateOptions | string)[];
55
+ populate?: (PopulateOptions | string)[] | PopulateOptions | string;
49
56
 
50
57
  // Process field selection
51
58
  // If {} or not set, then the field selection runs with defaults
52
- // If falsy, then the field selection will not be automatically executed
53
- processFieldSelection?: {
54
- model?: new (...args: any[]) => any;
55
- dbModel?: Model<any>;
56
- // Ignore selections in fieldSelection and populate
57
- // If falsy (default, if not set in env.config): select and populate information in fieldSelection and populate will be respected
58
- // If truly: select fields will be ignored and only populate fields in fieldSelection and populate will be respected
59
- ignoreSelections?: boolean;
60
- };
59
+ // If falsy, then the prepareInput function is not executed
60
+ prepareInput?: PrepareInputOptions;
61
61
 
62
62
  // Prepare input configuration:
63
63
  // If {} or not set, then the prepareInput function will run with defaults
64
64
  // If falsy, then the prepareInput function is not executed
65
- prepareInput?: PrepareInputOptions;
65
+ prepareOutput?: PrepareOutputOptions;
66
66
 
67
67
  // Prepare output configuration:
68
68
  // If {} or not set, then the prepareInput function will run with defaults
69
- // If falsy, then the prepareInput function is not executed
70
- prepareOutput?: PrepareOutputOptions;
69
+ // If falsy, then the field selection will not be automatically executed
70
+ processFieldSelection?: {
71
+ dbModel?: Model<any>;
72
+ // If truly: select fields will be ignored and only populate fields in fieldSelection and populate will be respected
73
+ ignoreSelections?: boolean;
74
+ // Ignore selections in fieldSelection and populate
75
+ // If falsy (default, if not set in env.config): select and populate information in fieldSelection and populate will be respected
76
+ model?: new (...args: any[]) => any;
77
+ };
71
78
 
72
79
  // Whether to publish action via GraphQL subscription
73
80
  pubSub?: boolean;
74
81
 
82
+ // Whether to return raw data without preparation via prepareInput or prepareOutput (prepareInput and prepareOutput will be ignored)
83
+ // Compare raw functions in CrudService
84
+ raw?: boolean;
85
+
86
+ // Roles (as string) to check
87
+ roles?: string | string[];
88
+
89
+ // Select fields via mongoose select
90
+ // See https://mongoosejs.com/docs/api.html#query_Query-select
91
+ select?: Record<string, boolean | number | object> | string | string[];
92
+
75
93
  // Add updateBy and/or createBy user ID into input after check
76
94
  // If falsy: input data will not be changed
77
95
  // If truly (default): updatedBy and/or createdBy (when create mode is activated) will be set if current user is available
78
96
  setCreateOrUpdateUserId?: boolean;
79
-
80
- // Roles (as string) to check
81
- roles?: string | string[];
82
97
  }
@@ -1,6 +1,7 @@
1
1
  import { Field, ID, ObjectType } from '@nestjs/graphql';
2
2
  import { Prop, Schema } from '@nestjs/mongoose';
3
3
  import { Types } from 'mongoose';
4
+
4
5
  import { CoreModel } from './core-model.model';
5
6
 
6
7
  /**
@@ -1,5 +1,6 @@
1
1
  import { ArgumentMetadata, Inject, Injectable, PipeTransform } from '@nestjs/common';
2
2
  import { CONTEXT } from '@nestjs/graphql';
3
+
3
4
  import { getContextData } from '../helpers/context.helper';
4
5
  import { check } from '../helpers/input.helper';
5
6
 
@@ -1,6 +1,7 @@
1
1
  import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
2
2
  import { plainToInstance } from 'class-transformer';
3
3
  import { validate } from 'class-validator';
4
+
4
5
  import { isBasicType } from '../helpers/input.helper';
5
6
 
6
7
  @Injectable()
@@ -1,8 +1,9 @@
1
- import { GraphQLSchemaHost } from '@nestjs/graphql';
2
1
  import { Plugin } from '@nestjs/apollo';
2
+ import { GraphQLSchemaHost } from '@nestjs/graphql';
3
3
  import { ApolloServerPlugin, GraphQLRequestListener } from 'apollo-server-plugin-base';
4
4
  import { GraphQLError } from 'graphql';
5
5
  import { fieldExtensionsEstimator, getComplexity, simpleEstimator } from 'graphql-query-complexity';
6
+
6
7
  import { ConfigService } from '../services/config.service';
7
8
 
8
9
  @Plugin()
@@ -14,13 +15,13 @@ export class ComplexityPlugin implements ApolloServerPlugin {
14
15
  const { schema } = this.gqlSchemaHost;
15
16
 
16
17
  return {
17
- async didResolveOperation({ request, document }) {
18
+ async didResolveOperation({ document, request }) {
18
19
  const complexity = getComplexity({
19
- schema,
20
+ estimators: [fieldExtensionsEstimator(), simpleEstimator({ defaultComplexity: 1 })],
20
21
  operationName: request.operationName,
21
22
  query: document,
23
+ schema,
22
24
  variables: request.variables,
23
- estimators: [fieldExtensionsEstimator(), simpleEstimator({ defaultComplexity: 1 })],
24
25
  });
25
26
  if (maxComplexity !== undefined && complexity > maxComplexity) {
26
27
  throw new GraphQLError(`Query is too complex: ${complexity}. Maximum allowed complexity: ${maxComplexity}`);
@@ -1,4 +1,5 @@
1
1
  import { CustomScalar, Scalar } from '@nestjs/graphql';
2
+
2
3
  import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
3
4
 
4
5
  /**
@@ -1,4 +1,5 @@
1
1
  import { CustomScalar, Scalar } from '@nestjs/graphql';
2
+
2
3
  import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
3
4
 
4
5
  /**
@@ -0,0 +1,93 @@
1
+
2
+ import { Injectable } from '@nestjs/common';
3
+
4
+ import { ConfigService } from './config.service';
5
+
6
+ import brevo = require('@getbrevo/brevo');
7
+
8
+
9
+ @Injectable()
10
+ export class BrevoService {
11
+ brevoConfig: ConfigService['configFastButReadOnly']['brevo'];
12
+
13
+ constructor(protected configService: ConfigService) {
14
+ const defaultClient = brevo.ApiClient.instance;
15
+ const apiKey = defaultClient.authentications['api-key'];
16
+ this.brevoConfig = configService.configFastButReadOnly.brevo;
17
+ if (!this.brevoConfig) {
18
+ throw new Error('Brevo configuration not set!');
19
+ }
20
+ apiKey.apiKey = this.brevoConfig.apiKey;
21
+ }
22
+
23
+ /**
24
+ * Send a transactional email via Brevo
25
+ */
26
+ async sendMail(to: string, templateId: number, params?: object): Promise<unknown> {
27
+ // Check input
28
+ if (!to || !templateId) {
29
+ return false;
30
+ }
31
+
32
+ // Exclude (test) users
33
+ if (this.configService.configFastButReadOnly.brevo?.exclude?.test?.(to)) {
34
+ return 'TEST_USER!';
35
+ }
36
+
37
+ // Prepare data
38
+ const apiInstance = new brevo.TransactionalEmailsApi();
39
+ const sendSmtpEmail = new brevo.SendSmtpEmail();
40
+ sendSmtpEmail.templateId = templateId;
41
+ sendSmtpEmail.to = [{ email: to }];
42
+ sendSmtpEmail.params = params;
43
+
44
+ // Send email
45
+ try {
46
+ return await apiInstance.sendTransacEmail(sendSmtpEmail);
47
+ } catch (error) {
48
+ console.error(error);
49
+ }
50
+
51
+ // Return null if error
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * Send HTML mail
57
+ */
58
+ async sendHtmlMail(
59
+ to: string,
60
+ subject: string,
61
+ html: string,
62
+ options?: { params?: Record<string, string> },
63
+ ): Promise<unknown> {
64
+ // Check input
65
+ if (!to || !subject || !html) {
66
+ return false;
67
+ }
68
+
69
+ // Exclude (test) users
70
+ if (this.brevoConfig.exclude?.test?.(to)) {
71
+ return 'TEST_USER!';
72
+ }
73
+
74
+ // Prepare data
75
+ const apiInstance = new brevo.TransactionalEmailsApi();
76
+ const sendSmtpEmail = new brevo.SendSmtpEmail();
77
+ sendSmtpEmail.htmlContent = html;
78
+ sendSmtpEmail.params = options?.params;
79
+ sendSmtpEmail.sender = this.brevoConfig.sender;
80
+ sendSmtpEmail.subject = subject;
81
+ sendSmtpEmail.to = [{ email: to }];
82
+
83
+ // Send email
84
+ try {
85
+ return await apiInstance.sendTransacEmail(sendSmtpEmail);
86
+ } catch (error) {
87
+ console.error(error);
88
+ }
89
+
90
+ // Return null if error
91
+ return null;
92
+ }
93
+ }
@@ -1,11 +1,13 @@
1
- import _ = require('lodash');
2
1
  import { cloneDeep } from 'lodash';
3
2
  import { BehaviorSubject, firstValueFrom } from 'rxjs';
4
3
  import { filter, map } from 'rxjs/operators';
4
+
5
5
  import { merge } from '../helpers/config.helper';
6
6
  import { clone, deepFreeze } from '../helpers/input.helper';
7
7
  import { IServerOptions } from '../interfaces/server-options.interface';
8
8
 
9
+ import _ = require('lodash');
10
+
9
11
  /**
10
12
  * Config service can be used as provider (after initialization in CoreModule.forRoot)
11
13
  *
@@ -1,6 +1,7 @@
1
1
  import { OnApplicationBootstrap } from '@nestjs/common';
2
2
  import { CronExpression, SchedulerRegistry } from '@nestjs/schedule';
3
3
  import { CronJob } from 'cron';
4
+
4
5
  import { CronJobConfigWithTimeZone } from '../interfaces/cron-job-config-with-time-zone.interface';
5
6
  import { CronJobConfigWithUtcOffset } from '../interfaces/cron-job-config-with-utc-offset.interface';
6
7
  import { Falsy } from '../types/falsy.type';
@@ -31,7 +32,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
31
32
  */
32
33
  protected constructor(
33
34
  protected schedulerRegistry: SchedulerRegistry,
34
- protected cronJobs: Record<string, CronExpression | string | Date | Falsy | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset>,
35
+ protected cronJobs: Record<string, CronExpression | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset | Date | Falsy | string>,
35
36
  options?: { log?: boolean },
36
37
  ) {
37
38
  this.config = {
@@ -75,7 +76,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
75
76
  = CronExpressionOrConfig as CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset;
76
77
  if (typeof CronExpressionOrConfig === 'string' || CronExpressionOrConfig instanceof Date) {
77
78
  conf = {
78
- cronTime: CronExpressionOrConfig as string | Date,
79
+ cronTime: CronExpressionOrConfig as Date | string,
79
80
  };
80
81
  }
81
82