@lenne.tech/nest-server 10.2.7 → 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 (323) 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 +3 -3
  48. package/dist/core/common/helpers/table.helper.js +7 -7
  49. package/dist/core/common/helpers/table.helper.js.map +1 -1
  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 +12 -8
  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 +4 -0
  74. package/dist/core/common/services/brevo.service.js +27 -4
  75. package/dist/core/common/services/brevo.service.js.map +1 -1
  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 +58 -32
  81. package/dist/core/common/services/crud.service.js +40 -23
  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 +8 -4
  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/main.js +3 -3
  162. package/dist/main.js.map +1 -1
  163. package/dist/server/common/models/persistence.model.d.ts +24 -0
  164. package/dist/server/common/models/persistence.model.js +4 -4
  165. package/dist/server/common/models/persistence.model.js.map +1 -1
  166. package/dist/server/common/services/cron-jobs.service.js.map +1 -1
  167. package/dist/server/modules/auth/auth.controller.js.map +1 -1
  168. package/dist/server/modules/auth/auth.model.js.map +1 -1
  169. package/dist/server/modules/auth/auth.module.js +2 -2
  170. package/dist/server/modules/auth/auth.module.js.map +1 -1
  171. package/dist/server/modules/auth/auth.resolver.js.map +1 -1
  172. package/dist/server/modules/auth/auth.service.js +1 -1
  173. package/dist/server/modules/auth/auth.service.js.map +1 -1
  174. package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
  175. package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
  176. package/dist/server/modules/file/file-info.model.js.map +1 -1
  177. package/dist/server/modules/file/file.controller.js.map +1 -1
  178. package/dist/server/modules/file/file.module.js +2 -2
  179. package/dist/server/modules/file/file.module.js.map +1 -1
  180. package/dist/server/modules/file/file.resolver.js +5 -5
  181. package/dist/server/modules/file/file.resolver.js.map +1 -1
  182. package/dist/server/modules/file/file.service.d.ts +24 -0
  183. package/dist/server/modules/file/file.service.js.map +1 -1
  184. package/dist/server/modules/file/multer-config.service.js +2 -2
  185. package/dist/server/modules/file/multer-config.service.js.map +1 -1
  186. package/dist/server/modules/user/avatar.controller.js.map +1 -1
  187. package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
  188. package/dist/server/modules/user/inputs/user.input.js.map +1 -1
  189. package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
  190. package/dist/server/modules/user/user.model.js +2 -2
  191. package/dist/server/modules/user/user.model.js.map +1 -1
  192. package/dist/server/modules/user/user.module.js +2 -2
  193. package/dist/server/modules/user/user.module.js.map +1 -1
  194. package/dist/server/modules/user/user.resolver.d.ts +1 -1
  195. package/dist/server/modules/user/user.resolver.js +1 -1
  196. package/dist/server/modules/user/user.resolver.js.map +1 -1
  197. package/dist/server/modules/user/user.service.d.ts +25 -1
  198. package/dist/server/modules/user/user.service.js +2 -2
  199. package/dist/server/modules/user/user.service.js.map +1 -1
  200. package/dist/server/server.controller.js.map +1 -1
  201. package/dist/server/server.module.js +2 -2
  202. package/dist/server/server.module.js.map +1 -1
  203. package/dist/test/test.helper.d.ts +13 -13
  204. package/dist/test/test.helper.js +15 -15
  205. package/dist/test/test.helper.js.map +1 -1
  206. package/dist/tsconfig.build.tsbuildinfo +1 -1
  207. package/package.json +34 -34
  208. package/src/config.env.ts +79 -78
  209. package/src/core/common/args/filter.args.ts +2 -1
  210. package/src/core/common/args/pagination.args.ts +1 -0
  211. package/src/core/common/decorators/current-user.decorator.ts +1 -0
  212. package/src/core/common/decorators/graphql-populate.decorator.ts +1 -0
  213. package/src/core/common/decorators/graphql-service-options.decorator.ts +1 -0
  214. package/src/core/common/decorators/restricted.decorator.ts +7 -5
  215. package/src/core/common/enums/comparison-operator.enum.ts +1 -1
  216. package/src/core/common/enums/logical-operator.enum.ts +1 -1
  217. package/src/core/common/enums/role.enum.ts +6 -6
  218. package/src/core/common/enums/sort-order.emum.ts +1 -1
  219. package/src/core/common/helpers/context.helper.ts +1 -1
  220. package/src/core/common/helpers/db.helper.ts +14 -12
  221. package/src/core/common/helpers/decorator.helper.ts +1 -0
  222. package/src/core/common/helpers/file.helper.ts +1 -1
  223. package/src/core/common/helpers/filter.helper.ts +6 -5
  224. package/src/core/common/helpers/graphql.helper.ts +7 -6
  225. package/src/core/common/helpers/input.helper.ts +10 -8
  226. package/src/core/common/helpers/model.helper.ts +6 -5
  227. package/src/core/common/helpers/service.helper.ts +13 -11
  228. package/src/core/common/helpers/table.helper.ts +12 -10
  229. package/src/core/common/inputs/combined-filter.input.ts +1 -0
  230. package/src/core/common/inputs/filter.input.ts +1 -0
  231. package/src/core/common/inputs/single-filter.input.ts +1 -0
  232. package/src/core/common/inputs/sort.input.ts +1 -0
  233. package/src/core/common/interceptors/check-response.interceptor.ts +1 -0
  234. package/src/core/common/interceptors/check-security.interceptor.ts +1 -0
  235. package/src/core/common/interfaces/core-persistence-model.interface.ts +3 -3
  236. package/src/core/common/interfaces/cron-job-config-with-time-zone.interface.ts +1 -0
  237. package/src/core/common/interfaces/cron-job-config-with-utc-offset.interface.ts +1 -0
  238. package/src/core/common/interfaces/mailjet-options.interface.ts +1 -1
  239. package/src/core/common/interfaces/prepare-input-options.interface.ts +1 -1
  240. package/src/core/common/interfaces/server-options.interface.ts +33 -24
  241. package/src/core/common/interfaces/service-options.interface.ts +31 -16
  242. package/src/core/common/models/core-persistence.model.ts +1 -0
  243. package/src/core/common/pipes/check-input.pipe.ts +1 -0
  244. package/src/core/common/pipes/map-and-validate.pipe.ts +1 -0
  245. package/src/core/common/plugins/complexity.plugin.ts +5 -4
  246. package/src/core/common/scalars/date-timestamp.scalar.ts +1 -0
  247. package/src/core/common/scalars/date.scalar.ts +1 -0
  248. package/src/core/common/services/brevo.service.ts +50 -5
  249. package/src/core/common/services/config.service.ts +3 -1
  250. package/src/core/common/services/core-cron-jobs.service.ts +3 -2
  251. package/src/core/common/services/crud.service.ts +70 -43
  252. package/src/core/common/services/email.service.ts +7 -5
  253. package/src/core/common/services/mailjet.service.ts +14 -13
  254. package/src/core/common/services/model-doc.service.ts +2 -1
  255. package/src/core/common/services/module.service.ts +18 -10
  256. package/src/core/common/services/template.service.ts +5 -3
  257. package/src/core/common/types/core-model-constructor.type.ts +1 -1
  258. package/src/core/common/types/falsy.type.ts +1 -1
  259. package/src/core/common/types/field-selection.type.ts +4 -3
  260. package/src/core/common/types/ids.type.ts +3 -3
  261. package/src/core/common/types/maybe-promise.type.ts +1 -1
  262. package/src/core/common/types/plain-input.type.ts +1 -1
  263. package/src/core/common/types/populate-config.type.ts +1 -1
  264. package/src/core/common/types/string-or-object-id.type.ts +1 -1
  265. package/src/core/modules/auth/core-auth.controller.ts +2 -1
  266. package/src/core/modules/auth/core-auth.model.ts +1 -0
  267. package/src/core/modules/auth/core-auth.module.ts +8 -7
  268. package/src/core/modules/auth/core-auth.resolver.ts +2 -1
  269. package/src/core/modules/auth/guards/auth.guard.ts +4 -2
  270. package/src/core/modules/auth/guards/refresh-token.guard.ts +1 -0
  271. package/src/core/modules/auth/guards/roles.guard.ts +1 -0
  272. package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +1 -0
  273. package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +1 -0
  274. package/src/core/modules/auth/interfaces/core-auth-user.interface.ts +4 -4
  275. package/src/core/modules/auth/interfaces/core-token-data.interface.ts +4 -4
  276. package/src/core/modules/auth/interfaces/jwt-payload.interface.ts +1 -1
  277. package/src/core/modules/auth/services/core-auth.service.ts +13 -11
  278. package/src/core/modules/auth/strategies/jwt-refresh.strategy.ts +3 -2
  279. package/src/core/modules/auth/strategies/jwt.strategy.ts +3 -2
  280. package/src/core/modules/auth/tokens.decorator.ts +4 -3
  281. package/src/core/modules/file/core-file-info.model.ts +6 -5
  282. package/src/core/modules/file/core-file.controller.ts +1 -0
  283. package/src/core/modules/file/core-file.resolver.ts +2 -1
  284. package/src/core/modules/file/core-file.service.ts +9 -8
  285. package/src/core/modules/file/interfaces/file-service-options.interface.ts +1 -1
  286. package/src/core/modules/file/interfaces/file-upload.interface.ts +2 -2
  287. package/src/core/modules/health-check/core-health-check-result.model.ts +1 -0
  288. package/src/core/modules/health-check/core-health-check.controller.ts +1 -0
  289. package/src/core/modules/health-check/core-health-check.module.ts +2 -1
  290. package/src/core/modules/health-check/core-health-check.resolver.ts +3 -2
  291. package/src/core/modules/health-check/core-health-check.service.ts +2 -1
  292. package/src/core/modules/user/core-user.model.ts +2 -1
  293. package/src/core/modules/user/core-user.service.ts +6 -4
  294. package/src/core/modules/user/inputs/core-user-create.input.ts +2 -1
  295. package/src/core/modules/user/inputs/core-user.input.ts +2 -1
  296. package/src/core.module.ts +24 -22
  297. package/src/main.ts +5 -3
  298. package/src/server/common/models/persistence.model.ts +7 -5
  299. package/src/server/common/services/cron-jobs.service.ts +1 -0
  300. package/src/server/modules/auth/auth.controller.ts +1 -0
  301. package/src/server/modules/auth/auth.model.ts +1 -0
  302. package/src/server/modules/auth/auth.module.ts +3 -2
  303. package/src/server/modules/auth/auth.resolver.ts +1 -0
  304. package/src/server/modules/auth/auth.service.ts +2 -1
  305. package/src/server/modules/auth/inputs/auth-sign-in.input.ts +1 -0
  306. package/src/server/modules/auth/inputs/auth-sign-up.input.ts +1 -0
  307. package/src/server/modules/file/file-info.model.ts +1 -0
  308. package/src/server/modules/file/file.controller.ts +1 -0
  309. package/src/server/modules/file/file.module.ts +3 -2
  310. package/src/server/modules/file/file.resolver.ts +7 -5
  311. package/src/server/modules/file/file.service.ts +1 -0
  312. package/src/server/modules/file/multer-config.service.ts +3 -2
  313. package/src/server/modules/user/avatar.controller.ts +1 -0
  314. package/src/server/modules/user/inputs/user-create.input.ts +1 -0
  315. package/src/server/modules/user/inputs/user.input.ts +1 -0
  316. package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +1 -0
  317. package/src/server/modules/user/user.model.ts +3 -2
  318. package/src/server/modules/user/user.module.ts +3 -2
  319. package/src/server/modules/user/user.resolver.ts +2 -1
  320. package/src/server/modules/user/user.service.ts +5 -3
  321. package/src/server/server.controller.ts +1 -0
  322. package/src/server/server.module.ts +7 -6
  323. 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';
@@ -78,13 +79,21 @@ export interface IServerOptions {
78
79
  /**
79
80
  * API key for Brevo
80
81
  */
81
- apiKey?: string;
82
+ apiKey: string;
82
83
 
83
84
  /**
84
85
  * Regular expression for excluding (test) users
85
86
  * e.g. /@testuser.com$/i
86
87
  */
87
88
  exclude?: RegExp;
89
+
90
+ /**
91
+ * Default sender for Brevo
92
+ */
93
+ sender: {
94
+ email: string;
95
+ name: string;
96
+ };
88
97
  };
89
98
 
90
99
  /**
@@ -103,7 +112,7 @@ export interface IServerOptions {
103
112
  * Cron jobs configuration object with the name of the cron job function as key
104
113
  * and the cron expression or config as value
105
114
  */
106
- cronJobs?: Record<string, CronExpression | string | Date | Falsy | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset>;
115
+ cronJobs?: Record<string, CronExpression | CronJobConfigWithTimeZone | CronJobConfigWithUtcOffset | Date | Falsy | string>;
107
116
 
108
117
  /**
109
118
  * SMTP and template configuration for sending emails
@@ -199,11 +208,6 @@ export interface IServerOptions {
199
208
  */
200
209
  healthCheck?: {
201
210
 
202
- /**
203
- * Whether health check is enabled
204
- */
205
- enabled?: boolean;
206
-
207
211
  /**
208
212
  * Configuration of single health checks
209
213
  */
@@ -241,14 +245,14 @@ export interface IServerOptions {
241
245
  enabled?: boolean;
242
246
 
243
247
  /**
244
- * Key in result JSON
248
+ * Memory limit in bytes
245
249
  */
246
- key?: string;
250
+ heapUsedThreshold?: number;
247
251
 
248
252
  /**
249
- * Memory limit in bytes
253
+ * Key in result JSON
250
254
  */
251
- heapUsedThreshold?: number;
255
+ key?: string;
252
256
  };
253
257
 
254
258
  /**
@@ -293,6 +297,11 @@ export interface IServerOptions {
293
297
  options?: DiskHealthIndicatorOptions;
294
298
  };
295
299
  };
300
+
301
+ /**
302
+ * Whether health check is enabled
303
+ */
304
+ enabled?: boolean;
296
305
  };
297
306
 
298
307
  /**
@@ -372,11 +381,6 @@ export interface IServerOptions {
372
381
  */
373
382
  modelDocumentation?: boolean;
374
383
 
375
- /**
376
- * Mongoose connection string
377
- */
378
- uri: string;
379
-
380
384
  /**
381
385
  * Mongoose module options
382
386
  */
@@ -390,6 +394,11 @@ export interface IServerOptions {
390
394
  * default: false
391
395
  */
392
396
  strictQuery?: boolean;
397
+
398
+ /**
399
+ * Mongoose connection string
400
+ */
401
+ uri: string;
393
402
  };
394
403
 
395
404
  /**
@@ -398,6 +407,12 @@ export interface IServerOptions {
398
407
  */
399
408
  port?: number;
400
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
+
401
416
  /**
402
417
  * Configuration for useStaticAssets
403
418
  */
@@ -415,12 +430,6 @@ export interface IServerOptions {
415
430
  path?: string;
416
431
  };
417
432
 
418
- /**
419
- * Whether to enable verification and automatic encryption for received passwords that are not in sha256 format
420
- * default = false, sha256 format check: /^[a-f0-9]{64}$/i
421
- */
422
- sha256?: boolean;
423
-
424
433
  /**
425
434
  * Templates
426
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
  /**
@@ -1,23 +1,29 @@
1
+
1
2
  import { Injectable } from '@nestjs/common';
2
- import brevo = require('@getbrevo/brevo');
3
+
3
4
  import { ConfigService } from './config.service';
4
5
 
6
+ import brevo = require('@getbrevo/brevo');
7
+
8
+
5
9
  @Injectable()
6
10
  export class BrevoService {
11
+ brevoConfig: ConfigService['configFastButReadOnly']['brevo'];
12
+
7
13
  constructor(protected configService: ConfigService) {
8
14
  const defaultClient = brevo.ApiClient.instance;
9
15
  const apiKey = defaultClient.authentications['api-key'];
10
- apiKey.apiKey = configService.configFastButReadOnly.brevo?.apiKey;
11
- if (!apiKey.apiKey) {
12
- console.warn('Brevo API key not set!');
16
+ this.brevoConfig = configService.configFastButReadOnly.brevo;
17
+ if (!this.brevoConfig) {
18
+ throw new Error('Brevo configuration not set!');
13
19
  }
20
+ apiKey.apiKey = this.brevoConfig.apiKey;
14
21
  }
15
22
 
16
23
  /**
17
24
  * Send a transactional email via Brevo
18
25
  */
19
26
  async sendMail(to: string, templateId: number, params?: object): Promise<unknown> {
20
-
21
27
  // Check input
22
28
  if (!to || !templateId) {
23
29
  return false;
@@ -45,4 +51,43 @@ export class BrevoService {
45
51
  // Return null if error
46
52
  return null;
47
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
+ }
48
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