@mondart/nestjs-common-module 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/.eslintrc.js +25 -0
  2. package/.github/workflows/npm-publish.yml +34 -0
  3. package/.prettierrc +4 -0
  4. package/common/caching/caching.module.ts +28 -0
  5. package/common/caching/caching.service.ts +34 -0
  6. package/common/caching/index.ts +2 -0
  7. package/common/constants/index.ts +1 -0
  8. package/common/constants/validation-constraints.const.ts +14 -0
  9. package/common/controllers/core-crud.controller.ts +106 -0
  10. package/common/controllers/index.ts +1 -0
  11. package/common/decorators/entity-order.decorator.ts +19 -0
  12. package/common/decorators/index.ts +2 -0
  13. package/common/decorators/swagger-api-response.decorator.ts +30 -0
  14. package/common/decorators/validations/default/array-max-size.decorator.ts +9 -0
  15. package/common/decorators/validations/default/array-min-size.decorator.ts +9 -0
  16. package/common/decorators/validations/default/array-not-empty.decorator.ts +7 -0
  17. package/common/decorators/validations/default/index.ts +20 -0
  18. package/common/decorators/validations/default/is-array.decorator.ts +7 -0
  19. package/common/decorators/validations/default/is-boolean.decorator.ts +10 -0
  20. package/common/decorators/validations/default/is-date.decorator.ts +10 -0
  21. package/common/decorators/validations/default/is-enum.decorator.ts +9 -0
  22. package/common/decorators/validations/default/is-int.decorator.ts +10 -0
  23. package/common/decorators/validations/default/is-not-empty-object.decorator.ts +15 -0
  24. package/common/decorators/validations/default/is-not-empty.decorator.ts +7 -0
  25. package/common/decorators/validations/default/is-number-string.decorator.ts +12 -0
  26. package/common/decorators/validations/default/is-object.decorator.ts +7 -0
  27. package/common/decorators/validations/default/is-positive.decorator.ts +10 -0
  28. package/common/decorators/validations/default/is-string.decorator.ts +8 -0
  29. package/common/decorators/validations/default/is-uuid.decorator.ts +7 -0
  30. package/common/decorators/validations/default/matches.decorator.ts +13 -0
  31. package/common/decorators/validations/default/max-length.decorator.ts +9 -0
  32. package/common/decorators/validations/default/max.decorator.ts +13 -0
  33. package/common/decorators/validations/default/min-length.decorator.ts +9 -0
  34. package/common/decorators/validations/default/min.decorator.ts +13 -0
  35. package/common/decorators/validations/index.ts +3 -0
  36. package/common/decorators/validations/is-id.decorator.ts +20 -0
  37. package/common/decorators/validations/is-not-empty-string.decorator.ts +14 -0
  38. package/common/dto/index.ts +2 -0
  39. package/common/dto/request/base-request.dto.ts +11 -0
  40. package/common/dto/request/event.dto.ts +25 -0
  41. package/common/dto/request/id.dto.ts +10 -0
  42. package/common/dto/request/ids.dto.ts +13 -0
  43. package/common/dto/request/index.ts +4 -0
  44. package/common/dto/response/base-response-with-action-dates.dto.ts +19 -0
  45. package/common/dto/response/base-response.dto.ts +10 -0
  46. package/common/dto/response/error-response.dto.ts +22 -0
  47. package/common/dto/response/index.ts +5 -0
  48. package/common/dto/response/kafka-success-response.dto.ts +56 -0
  49. package/common/dto/response/success-response.dto.ts +32 -0
  50. package/common/dto/response/validation.dto.ts +80 -0
  51. package/common/entities/action-dates.entity.ts +30 -0
  52. package/common/entities/base.entity.ts +7 -0
  53. package/common/entities/index.ts +2 -0
  54. package/common/entities/parent.entity.ts +35 -0
  55. package/common/enums/environments.enum.ts +6 -0
  56. package/common/enums/index.ts +2 -0
  57. package/common/enums/shared-messages.enum.ts +40 -0
  58. package/common/filters/http-exception.filter.ts +74 -0
  59. package/common/filters/index.ts +1 -0
  60. package/common/filters/rpc-exception.filter.ts +40 -0
  61. package/common/helper/get-env.helper.ts +3 -0
  62. package/common/helper/get-env.ts +3 -0
  63. package/common/helper/index.ts +2 -0
  64. package/common/helper/message-formatter.helper.ts +30 -0
  65. package/common/helper/multi-inheritance.helper.ts +12 -0
  66. package/common/helper/multi-inheritance.util.ts +12 -0
  67. package/common/index.ts +14 -0
  68. package/common/interface/core-crud-service.option.ts +8 -0
  69. package/common/interface/custom-validation-arguments.interface.ts +20 -0
  70. package/common/interface/index.ts +2 -0
  71. package/common/interface/kafka-success-response.interfase.ts +9 -0
  72. package/common/interface/pagination-query.ts +39 -0
  73. package/common/lib/index.ts +1 -0
  74. package/common/lib/kafka/constant/consumer.const.ts +13 -0
  75. package/common/lib/kafka/constant/kafka.const.ts +9 -0
  76. package/common/lib/kafka/index.ts +5 -0
  77. package/common/lib/kafka/kafka-admin.service.ts +51 -0
  78. package/common/lib/kafka/kafka-consumer.service.ts +59 -0
  79. package/common/lib/kafka/kafka-instance.const.ts +9 -0
  80. package/common/lib/kafka/kafka-logger.ts +25 -0
  81. package/common/lib/kafka/kafka-producer.service.ts +97 -0
  82. package/common/lib/kafka/kafka.interface.ts +22 -0
  83. package/common/lib/kafka/kafka.module.ts +80 -0
  84. package/common/lib/kafka/kafka.provider.ts +10 -0
  85. package/common/lib/kafka/kafka.service.ts +224 -0
  86. package/common/services/core-crud.service.ts +457 -0
  87. package/common/services/index.ts +1 -0
  88. package/common/strategy/index.ts +1 -0
  89. package/common/strategy/type-orm-naming.strategy.ts +17 -0
  90. package/common/validators/does-exist.validator.ts +42 -0
  91. package/common/validators/env.validator.ts +28 -0
  92. package/common/validators/index.ts +4 -0
  93. package/common/validators/is-unique.validator.ts +70 -0
  94. package/common/validators/validation-options.ts +38 -0
  95. package/dist/caching/caching.module.d.ts +2 -0
  96. package/dist/caching/caching.module.js +41 -0
  97. package/dist/caching/caching.module.js.map +1 -0
  98. package/dist/caching/caching.service.d.ts +9 -0
  99. package/dist/caching/caching.service.js +45 -0
  100. package/dist/caching/caching.service.js.map +1 -0
  101. package/dist/caching/index.d.ts +2 -0
  102. package/dist/caching/index.js +19 -0
  103. package/dist/caching/index.js.map +1 -0
  104. package/dist/constants/index.d.ts +1 -0
  105. package/dist/constants/index.js +18 -0
  106. package/dist/constants/index.js.map +1 -0
  107. package/dist/constants/validation-constraints.const.d.ts +14 -0
  108. package/dist/constants/validation-constraints.const.js +19 -0
  109. package/dist/constants/validation-constraints.const.js.map +1 -0
  110. package/dist/controllers/core-crud.controller.d.ts +19 -0
  111. package/dist/controllers/core-crud.controller.js +72 -0
  112. package/dist/controllers/core-crud.controller.js.map +1 -0
  113. package/dist/controllers/index.d.ts +1 -0
  114. package/dist/controllers/index.js +18 -0
  115. package/dist/controllers/index.js.map +1 -0
  116. package/dist/decorators/entity-order.decorator.d.ts +2 -0
  117. package/dist/decorators/entity-order.decorator.js +18 -0
  118. package/dist/decorators/entity-order.decorator.js.map +1 -0
  119. package/dist/decorators/index.d.ts +2 -0
  120. package/dist/decorators/index.js +19 -0
  121. package/dist/decorators/index.js.map +1 -0
  122. package/dist/decorators/swagger-api-response.decorator.d.ts +5 -0
  123. package/dist/decorators/swagger-api-response.decorator.js +25 -0
  124. package/dist/decorators/swagger-api-response.decorator.js.map +1 -0
  125. package/dist/decorators/validations/default/array-max-size.decorator.d.ts +1 -0
  126. package/dist/decorators/validations/default/array-max-size.decorator.js +12 -0
  127. package/dist/decorators/validations/default/array-max-size.decorator.js.map +1 -0
  128. package/dist/decorators/validations/default/array-min-size.decorator.d.ts +1 -0
  129. package/dist/decorators/validations/default/array-min-size.decorator.js +12 -0
  130. package/dist/decorators/validations/default/array-min-size.decorator.js.map +1 -0
  131. package/dist/decorators/validations/default/array-not-empty.decorator.d.ts +1 -0
  132. package/dist/decorators/validations/default/array-not-empty.decorator.js +10 -0
  133. package/dist/decorators/validations/default/array-not-empty.decorator.js.map +1 -0
  134. package/dist/decorators/validations/default/index.d.ts +20 -0
  135. package/dist/decorators/validations/default/index.js +37 -0
  136. package/dist/decorators/validations/default/index.js.map +1 -0
  137. package/dist/decorators/validations/default/is-array.decorator.d.ts +1 -0
  138. package/dist/decorators/validations/default/is-array.decorator.js +10 -0
  139. package/dist/decorators/validations/default/is-array.decorator.js.map +1 -0
  140. package/dist/decorators/validations/default/is-boolean.decorator.d.ts +3 -0
  141. package/dist/decorators/validations/default/is-boolean.decorator.js +10 -0
  142. package/dist/decorators/validations/default/is-boolean.decorator.js.map +1 -0
  143. package/dist/decorators/validations/default/is-date.decorator.d.ts +3 -0
  144. package/dist/decorators/validations/default/is-date.decorator.js +10 -0
  145. package/dist/decorators/validations/default/is-date.decorator.js.map +1 -0
  146. package/dist/decorators/validations/default/is-enum.decorator.d.ts +1 -0
  147. package/dist/decorators/validations/default/is-enum.decorator.js +12 -0
  148. package/dist/decorators/validations/default/is-enum.decorator.js.map +1 -0
  149. package/dist/decorators/validations/default/is-int.decorator.d.ts +3 -0
  150. package/dist/decorators/validations/default/is-int.decorator.js +10 -0
  151. package/dist/decorators/validations/default/is-int.decorator.js.map +1 -0
  152. package/dist/decorators/validations/default/is-not-empty-object.decorator.d.ts +5 -0
  153. package/dist/decorators/validations/default/is-not-empty-object.decorator.js +13 -0
  154. package/dist/decorators/validations/default/is-not-empty-object.decorator.js.map +1 -0
  155. package/dist/decorators/validations/default/is-not-empty.decorator.d.ts +1 -0
  156. package/dist/decorators/validations/default/is-not-empty.decorator.js +10 -0
  157. package/dist/decorators/validations/default/is-not-empty.decorator.js.map +1 -0
  158. package/dist/decorators/validations/default/is-number-string.decorator.d.ts +3 -0
  159. package/dist/decorators/validations/default/is-number-string.decorator.js +10 -0
  160. package/dist/decorators/validations/default/is-number-string.decorator.js.map +1 -0
  161. package/dist/decorators/validations/default/is-object.decorator.d.ts +2 -0
  162. package/dist/decorators/validations/default/is-object.decorator.js +10 -0
  163. package/dist/decorators/validations/default/is-object.decorator.js.map +1 -0
  164. package/dist/decorators/validations/default/is-positive.decorator.d.ts +3 -0
  165. package/dist/decorators/validations/default/is-positive.decorator.js +10 -0
  166. package/dist/decorators/validations/default/is-positive.decorator.js.map +1 -0
  167. package/dist/decorators/validations/default/is-string.decorator.d.ts +3 -0
  168. package/dist/decorators/validations/default/is-string.decorator.js +11 -0
  169. package/dist/decorators/validations/default/is-string.decorator.js.map +1 -0
  170. package/dist/decorators/validations/default/is-uuid.decorator.d.ts +3 -0
  171. package/dist/decorators/validations/default/is-uuid.decorator.js +10 -0
  172. package/dist/decorators/validations/default/is-uuid.decorator.js.map +1 -0
  173. package/dist/decorators/validations/default/matches.decorator.d.ts +3 -0
  174. package/dist/decorators/validations/default/matches.decorator.js +10 -0
  175. package/dist/decorators/validations/default/matches.decorator.js.map +1 -0
  176. package/dist/decorators/validations/default/max-length.decorator.d.ts +1 -0
  177. package/dist/decorators/validations/default/max-length.decorator.js +12 -0
  178. package/dist/decorators/validations/default/max-length.decorator.js.map +1 -0
  179. package/dist/decorators/validations/default/max.decorator.d.ts +3 -0
  180. package/dist/decorators/validations/default/max.decorator.js +10 -0
  181. package/dist/decorators/validations/default/max.decorator.js.map +1 -0
  182. package/dist/decorators/validations/default/min-length.decorator.d.ts +1 -0
  183. package/dist/decorators/validations/default/min-length.decorator.js +12 -0
  184. package/dist/decorators/validations/default/min-length.decorator.js.map +1 -0
  185. package/dist/decorators/validations/default/min.decorator.d.ts +3 -0
  186. package/dist/decorators/validations/default/min.decorator.js +10 -0
  187. package/dist/decorators/validations/default/min.decorator.js.map +1 -0
  188. package/dist/decorators/validations/index.d.ts +3 -0
  189. package/dist/decorators/validations/index.js +20 -0
  190. package/dist/decorators/validations/index.js.map +1 -0
  191. package/dist/decorators/validations/is-id.decorator.d.ts +4 -0
  192. package/dist/decorators/validations/is-id.decorator.js +21 -0
  193. package/dist/decorators/validations/is-id.decorator.js.map +1 -0
  194. package/dist/decorators/validations/is-not-empty-string.decorator.d.ts +4 -0
  195. package/dist/decorators/validations/is-not-empty-string.decorator.js +15 -0
  196. package/dist/decorators/validations/is-not-empty-string.decorator.js.map +1 -0
  197. package/dist/dto/index.d.ts +2 -0
  198. package/dist/dto/index.js +19 -0
  199. package/dist/dto/index.js.map +1 -0
  200. package/dist/dto/request/base-request.dto.d.ts +4 -0
  201. package/dist/dto/request/base-request.dto.js +24 -0
  202. package/dist/dto/request/base-request.dto.js.map +1 -0
  203. package/dist/dto/request/event.dto.d.ts +8 -0
  204. package/dist/dto/request/event.dto.js +45 -0
  205. package/dist/dto/request/event.dto.js.map +1 -0
  206. package/dist/dto/request/id.dto.d.ts +3 -0
  207. package/dist/dto/request/id.dto.js +25 -0
  208. package/dist/dto/request/id.dto.js.map +1 -0
  209. package/dist/dto/request/ids.dto.d.ts +3 -0
  210. package/dist/dto/request/ids.dto.js +28 -0
  211. package/dist/dto/request/ids.dto.js.map +1 -0
  212. package/dist/dto/request/index.d.ts +4 -0
  213. package/dist/dto/request/index.js +21 -0
  214. package/dist/dto/request/index.js.map +1 -0
  215. package/dist/dto/response/base-response-with-action-dates.dto.d.ts +7 -0
  216. package/dist/dto/response/base-response-with-action-dates.dto.js +36 -0
  217. package/dist/dto/response/base-response-with-action-dates.dto.js.map +1 -0
  218. package/dist/dto/response/base-response.dto.d.ts +4 -0
  219. package/dist/dto/response/base-response.dto.js +24 -0
  220. package/dist/dto/response/base-response.dto.js.map +1 -0
  221. package/dist/dto/response/error-response.dto.d.ts +8 -0
  222. package/dist/dto/response/error-response.dto.js +38 -0
  223. package/dist/dto/response/error-response.dto.js.map +1 -0
  224. package/dist/dto/response/index.d.ts +5 -0
  225. package/dist/dto/response/index.js +22 -0
  226. package/dist/dto/response/index.js.map +1 -0
  227. package/dist/dto/response/kafka-success-response.dto.d.ts +14 -0
  228. package/dist/dto/response/kafka-success-response.dto.js +66 -0
  229. package/dist/dto/response/kafka-success-response.dto.js.map +1 -0
  230. package/dist/dto/response/success-response.dto.d.ts +9 -0
  231. package/dist/dto/response/success-response.dto.js +44 -0
  232. package/dist/dto/response/success-response.dto.js.map +1 -0
  233. package/dist/dto/response/validation.dto.d.ts +25 -0
  234. package/dist/dto/response/validation.dto.js +84 -0
  235. package/dist/dto/response/validation.dto.js.map +1 -0
  236. package/dist/entities/action-dates.entity.d.ts +8 -0
  237. package/dist/entities/action-dates.entity.js +43 -0
  238. package/dist/entities/action-dates.entity.js.map +1 -0
  239. package/dist/entities/base.entity.d.ts +4 -0
  240. package/dist/entities/base.entity.js +22 -0
  241. package/dist/entities/base.entity.js.map +1 -0
  242. package/dist/entities/index.d.ts +2 -0
  243. package/dist/entities/index.js +19 -0
  244. package/dist/entities/index.js.map +1 -0
  245. package/dist/entities/parent.entity.d.ts +8 -0
  246. package/dist/entities/parent.entity.js +45 -0
  247. package/dist/entities/parent.entity.js.map +1 -0
  248. package/dist/enums/environments.enum.d.ts +6 -0
  249. package/dist/enums/environments.enum.js +11 -0
  250. package/dist/enums/environments.enum.js.map +1 -0
  251. package/dist/enums/index.d.ts +2 -0
  252. package/dist/enums/index.js +19 -0
  253. package/dist/enums/index.js.map +1 -0
  254. package/dist/enums/shared-messages.enum.d.ts +25 -0
  255. package/dist/enums/shared-messages.enum.js +30 -0
  256. package/dist/enums/shared-messages.enum.js.map +1 -0
  257. package/dist/filters/http-exception.filter.d.ts +8 -0
  258. package/dist/filters/http-exception.filter.js +65 -0
  259. package/dist/filters/http-exception.filter.js.map +1 -0
  260. package/dist/filters/index.d.ts +1 -0
  261. package/dist/filters/index.js +18 -0
  262. package/dist/filters/index.js.map +1 -0
  263. package/dist/filters/rpc-exception.filter.d.ts +5 -0
  264. package/dist/filters/rpc-exception.filter.js +21 -0
  265. package/dist/filters/rpc-exception.filter.js.map +1 -0
  266. package/dist/helper/get-env.d.ts +1 -0
  267. package/dist/helper/get-env.helper.d.ts +1 -0
  268. package/dist/helper/get-env.helper.js +7 -0
  269. package/dist/helper/get-env.helper.js.map +1 -0
  270. package/dist/helper/get-env.js +7 -0
  271. package/dist/helper/get-env.js.map +1 -0
  272. package/dist/helper/index.d.ts +2 -0
  273. package/dist/helper/index.js +19 -0
  274. package/dist/helper/index.js.map +1 -0
  275. package/dist/helper/message-formatter.helper.d.ts +3 -0
  276. package/dist/helper/message-formatter.helper.js +27 -0
  277. package/dist/helper/message-formatter.helper.js.map +1 -0
  278. package/dist/helper/multi-inheritance.helper.d.ts +1 -0
  279. package/dist/helper/multi-inheritance.helper.js +13 -0
  280. package/dist/helper/multi-inheritance.helper.js.map +1 -0
  281. package/dist/helper/multi-inheritance.util.d.ts +1 -0
  282. package/dist/helper/multi-inheritance.util.js +13 -0
  283. package/dist/helper/multi-inheritance.util.js.map +1 -0
  284. package/dist/index.d.ts +14 -0
  285. package/dist/index.js +18 -0
  286. package/dist/index.js.map +1 -0
  287. package/dist/interface/core-crud-service.option.d.ts +7 -0
  288. package/dist/interface/core-crud-service.option.js +10 -0
  289. package/dist/interface/core-crud-service.option.js.map +1 -0
  290. package/dist/interface/custom-validation-arguments.interface.d.ts +14 -0
  291. package/dist/interface/custom-validation-arguments.interface.js +3 -0
  292. package/dist/interface/custom-validation-arguments.interface.js.map +1 -0
  293. package/dist/interface/index.d.ts +2 -0
  294. package/dist/interface/index.js +19 -0
  295. package/dist/interface/index.js.map +1 -0
  296. package/dist/interface/kafka-success-response.interfase.d.ts +9 -0
  297. package/dist/interface/kafka-success-response.interfase.js +3 -0
  298. package/dist/interface/kafka-success-response.interfase.js.map +1 -0
  299. package/dist/interface/pagination-query.d.ts +13 -0
  300. package/dist/interface/pagination-query.js +55 -0
  301. package/dist/interface/pagination-query.js.map +1 -0
  302. package/dist/lib/index.d.ts +1 -0
  303. package/dist/lib/index.js +18 -0
  304. package/dist/lib/index.js.map +1 -0
  305. package/dist/lib/kafka/constant/consumer.const.d.ts +12 -0
  306. package/dist/lib/kafka/constant/consumer.const.js +18 -0
  307. package/dist/lib/kafka/constant/consumer.const.js.map +1 -0
  308. package/dist/lib/kafka/constant/kafka.const.d.ts +9 -0
  309. package/dist/lib/kafka/constant/kafka.const.js +14 -0
  310. package/dist/lib/kafka/constant/kafka.const.js.map +1 -0
  311. package/dist/lib/kafka/index.d.ts +4 -0
  312. package/dist/lib/kafka/index.js +8 -0
  313. package/dist/lib/kafka/index.js.map +1 -0
  314. package/dist/lib/kafka/kafka-admin.service.d.ts +7 -0
  315. package/dist/lib/kafka/kafka-admin.service.js +47 -0
  316. package/dist/lib/kafka/kafka-admin.service.js.map +1 -0
  317. package/dist/lib/kafka/kafka-consumer.service.d.ts +9 -0
  318. package/dist/lib/kafka/kafka-consumer.service.js +50 -0
  319. package/dist/lib/kafka/kafka-consumer.service.js.map +1 -0
  320. package/dist/lib/kafka/kafka-instance.const.d.ts +2 -0
  321. package/dist/lib/kafka/kafka-instance.const.js +12 -0
  322. package/dist/lib/kafka/kafka-instance.const.js.map +1 -0
  323. package/dist/lib/kafka/kafka-logger.d.ts +2 -0
  324. package/dist/lib/kafka/kafka-logger.js +22 -0
  325. package/dist/lib/kafka/kafka-logger.js.map +1 -0
  326. package/dist/lib/kafka/kafka-producer.service.d.ts +10 -0
  327. package/dist/lib/kafka/kafka-producer.service.js +76 -0
  328. package/dist/lib/kafka/kafka-producer.service.js.map +1 -0
  329. package/dist/lib/kafka/kafka.interface.d.ts +15 -0
  330. package/dist/lib/kafka/kafka.interface.js +5 -0
  331. package/dist/lib/kafka/kafka.interface.js.map +1 -0
  332. package/dist/lib/kafka/kafka.module.d.ts +10 -0
  333. package/dist/lib/kafka/kafka.module.js +77 -0
  334. package/dist/lib/kafka/kafka.module.js.map +1 -0
  335. package/dist/lib/kafka/kafka.provider.d.ts +7 -0
  336. package/dist/lib/kafka/kafka.provider.js +12 -0
  337. package/dist/lib/kafka/kafka.provider.js.map +1 -0
  338. package/dist/lib/kafka/kafka.service.d.ts +38 -0
  339. package/dist/lib/kafka/kafka.service.js +124 -0
  340. package/dist/lib/kafka/kafka.service.js.map +1 -0
  341. package/dist/services/core-crud.service.d.ts +31 -0
  342. package/dist/services/core-crud.service.js +318 -0
  343. package/dist/services/core-crud.service.js.map +1 -0
  344. package/dist/services/index.d.ts +1 -0
  345. package/dist/services/index.js +18 -0
  346. package/dist/services/index.js.map +1 -0
  347. package/dist/strategy/index.d.ts +1 -0
  348. package/dist/strategy/index.js +18 -0
  349. package/dist/strategy/index.js.map +1 -0
  350. package/dist/strategy/type-orm-naming.strategy.d.ts +4 -0
  351. package/dist/strategy/type-orm-naming.strategy.js +12 -0
  352. package/dist/strategy/type-orm-naming.strategy.js.map +1 -0
  353. package/dist/tsconfig.tsbuildinfo +1 -0
  354. package/dist/validators/does-exist.validator.d.ts +8 -0
  355. package/dist/validators/does-exist.validator.js +48 -0
  356. package/dist/validators/does-exist.validator.js.map +1 -0
  357. package/dist/validators/env.validator.d.ts +2 -0
  358. package/dist/validators/env.validator.js +27 -0
  359. package/dist/validators/env.validator.js.map +1 -0
  360. package/dist/validators/index.d.ts +4 -0
  361. package/dist/validators/index.js +21 -0
  362. package/dist/validators/index.js.map +1 -0
  363. package/dist/validators/is-unique.validator.d.ts +7 -0
  364. package/dist/validators/is-unique.validator.js +58 -0
  365. package/dist/validators/is-unique.validator.js.map +1 -0
  366. package/dist/validators/validation-options.d.ts +3 -0
  367. package/dist/validators/validation-options.js +28 -0
  368. package/dist/validators/validation-options.js.map +1 -0
  369. package/nest-cli.json +8 -0
  370. package/package.json +81 -0
  371. package/tsconfig.build.json +4 -0
@@ -0,0 +1,10 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { Type } from 'class-transformer';
3
+ import { IsId } from '../../decorators/validations/is-id.decorator';
4
+
5
+ export class IdDto {
6
+ @ApiProperty({ default: 1 })
7
+ @Type(() => Number)
8
+ @IsId({ optional: false })
9
+ id: number;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { Transform } from 'class-transformer';
3
+ import { IsId } from '../../decorators/validations/is-id.decorator';
4
+
5
+ export class IdsDto {
6
+ @ApiProperty({ default: [1], isArray: true })
7
+ @Transform((o) => {
8
+ const ids = o.value.split(',');
9
+ return ids.map((value: string) => Number(value));
10
+ })
11
+ @IsId({ optional: false, each: true })
12
+ ids: number[];
13
+ }
@@ -0,0 +1,4 @@
1
+ export * from './base-request.dto';
2
+ export * from './event.dto';
3
+ export * from './id.dto';
4
+ export * from './ids.dto';
@@ -0,0 +1,19 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { BaseResponse } from './base-response.dto';
3
+
4
+ export class BaseResponseWithActionDates extends BaseResponse {
5
+ @ApiProperty({ type: Date })
6
+ public createdAt: Date;
7
+ @ApiProperty({ type: Date })
8
+ public updatedAt: Date;
9
+ @ApiPropertyOptional({ type: Date, default: null })
10
+ public deletedAt?: Date;
11
+
12
+ constructor(init: Partial<BaseResponseWithActionDates>) {
13
+ super(init);
14
+
15
+ this.createdAt = init?.createdAt;
16
+ this.updatedAt = init?.updatedAt;
17
+ this.deletedAt = init?.deletedAt;
18
+ }
19
+ }
@@ -0,0 +1,10 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+
3
+ export class BaseResponse {
4
+ @ApiProperty({ example: 1 })
5
+ public id?: number;
6
+
7
+ constructor(init?: Partial<BaseResponse>) {
8
+ this.id = init?.id;
9
+ }
10
+ }
@@ -0,0 +1,22 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+
3
+ export class BaseErrorResponse {
4
+ @ApiProperty({ type: String })
5
+ message: string;
6
+
7
+ @ApiProperty({ type: Number })
8
+ statusCode: number;
9
+
10
+ @ApiProperty()
11
+ details: Record<string, any>;
12
+ }
13
+
14
+ export class ErrorResponse extends BaseErrorResponse {
15
+ constructor(message: string, statusCode: number, details: any = {}) {
16
+ super();
17
+
18
+ this.message = message;
19
+ this.statusCode = statusCode;
20
+ this.details = details;
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ export * from './base-response-with-action-dates.dto';
2
+ export * from './base-response.dto';
3
+ export * from './error-response.dto';
4
+ export * from './success-response.dto';
5
+ export * from './validation.dto';
@@ -0,0 +1,56 @@
1
+ import { IsNumber, IsOptional, IsString } from 'class-validator';
2
+ import { KafkaSuccessResponseInterface } from '../../interface/kafka-success-response.interfase';
3
+
4
+ export class BaseEventDto<type> {
5
+ @IsString()
6
+ @IsOptional()
7
+ topic?: string;
8
+
9
+ @IsString()
10
+ event_source: string;
11
+
12
+ @IsString()
13
+ @IsOptional()
14
+ model?: string;
15
+
16
+ @IsString()
17
+ @IsOptional()
18
+ event_key?: string;
19
+
20
+ @IsOptional()
21
+ data?: type;
22
+
23
+ @IsNumber()
24
+ @IsOptional()
25
+ partition?: number;
26
+
27
+ @IsNumber()
28
+ @IsOptional()
29
+ status?: number;
30
+ }
31
+
32
+ export class KafkaSuccessResponse<type> extends BaseEventDto<type> {
33
+ constructor({
34
+ data,
35
+ event_source,
36
+ topic,
37
+ model,
38
+ event_key,
39
+ partition,
40
+ status,
41
+ }: KafkaSuccessResponseInterface<type>) {
42
+ super();
43
+
44
+ this.data = data;
45
+ this.topic = topic;
46
+ this.event_source = event_source;
47
+ this.model = model;
48
+ this.event_key = event_key;
49
+ this.partition = partition;
50
+ this.status = status;
51
+ }
52
+
53
+ public stringify() {
54
+ return JSON.stringify(this);
55
+ }
56
+ }
@@ -0,0 +1,32 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { SharedMessages } from '../../enums/shared-messages.enum';
3
+
4
+ export class BaseSuccessResponse<type> {
5
+ @ApiProperty({ type: Object })
6
+ data: type;
7
+
8
+ @ApiProperty({ type: Object })
9
+ metadata: object;
10
+
11
+ @ApiProperty({ type: String, default: SharedMessages.SUCCESSFUL })
12
+ message: string;
13
+
14
+ @ApiProperty({ type: Number, default: 200 })
15
+ statusCode: number;
16
+ }
17
+
18
+ export class SuccessResponse<type> extends BaseSuccessResponse<type> {
19
+ constructor(
20
+ data: type,
21
+ message: string = null,
22
+ statusCode = 200,
23
+ metadata = null,
24
+ ) {
25
+ super();
26
+
27
+ this.data = data;
28
+ this.message = message;
29
+ this.statusCode = statusCode;
30
+ this.metadata = metadata;
31
+ }
32
+ }
@@ -0,0 +1,80 @@
1
+ import { HttpStatus, ValidationError } from '@nestjs/common';
2
+ import { ApiProperty } from '@nestjs/swagger';
3
+
4
+ export class validationErrorMsg {
5
+ @ApiProperty({ type: String })
6
+ field: string;
7
+
8
+ @ApiProperty({ type: String })
9
+ message: string;
10
+ }
11
+
12
+ class ValidationMsg {
13
+ @ApiProperty({ type: String })
14
+ entity: string;
15
+
16
+ @ApiProperty({
17
+ type: validationErrorMsg,
18
+ isArray: true,
19
+ })
20
+ errors: Array<validationErrorMsg>;
21
+ }
22
+
23
+ export class ValidationErrorResponseType {
24
+ @ApiProperty({ type: String })
25
+ message: string;
26
+
27
+ @ApiProperty({ type: String })
28
+ statusCode: string;
29
+
30
+ @ApiProperty({ type: ValidationMsg })
31
+ validationMsg: ValidationMsg;
32
+ }
33
+
34
+ export class ValidationErrorResponseDto {
35
+ public message: string;
36
+ public statusCode: string;
37
+ public validationMsg: object;
38
+
39
+ constructor(
40
+ message: string,
41
+ error: {
42
+ validationErrors?: Array<ValidationError>;
43
+ errors?: validationErrorMsg[];
44
+ },
45
+ ) {
46
+ let validation =
47
+ error.validationErrors &&
48
+ error.validationErrors.map((error) => {
49
+ error = { ...error, ...this.formatValidationError(error) };
50
+
51
+ const field = error.property;
52
+
53
+ const message = Object.values(error.constraints)[0];
54
+
55
+ return {
56
+ field,
57
+ message,
58
+ };
59
+ });
60
+
61
+ validation = validation || error.errors;
62
+
63
+ this.message = message;
64
+ this.statusCode = String(HttpStatus.BAD_REQUEST);
65
+ this.validationMsg = {
66
+ errors: validation,
67
+ };
68
+ }
69
+
70
+ private formatValidationError(err: ValidationError) {
71
+ if (err.children.length === 0)
72
+ return {
73
+ property: err.property,
74
+ constraints: err.constraints,
75
+ children: err.children,
76
+ };
77
+
78
+ return this.formatValidationError(err.children[0]);
79
+ }
80
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Column,
6
+ BaseEntity,
7
+ } from 'typeorm';
8
+ import { Order } from '../decorators/entity-order.decorator';
9
+
10
+ export class ActionDatesEntity extends BaseEntity {
11
+ @Order(9999)
12
+ @CreateDateColumn()
13
+ createdAt: Date;
14
+
15
+ @Order(9999)
16
+ @UpdateDateColumn()
17
+ updatedAt: Date;
18
+
19
+ @Order(9999)
20
+ @DeleteDateColumn()
21
+ deletedAt: Date;
22
+
23
+ @Order(9999)
24
+ @Column({ nullable: true })
25
+ createdBy?: string;
26
+
27
+ @Order(9999)
28
+ @Column({ nullable: true })
29
+ updatedBy?: string;
30
+ }
@@ -0,0 +1,7 @@
1
+ import { Column } from 'typeorm';
2
+ import { ActionDatesEntity } from './action-dates.entity';
3
+
4
+ export class ParentEntity extends ActionDatesEntity {
5
+ @Column({ default: true })
6
+ isActive: boolean;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './action-dates.entity';
2
+ export * from './base.entity';
@@ -0,0 +1,35 @@
1
+ import {
2
+ BaseEntity,
3
+ Column,
4
+ DataSource,
5
+ PrimaryGeneratedColumn,
6
+ } from 'typeorm';
7
+ import { ActionDatesEntity } from './action-dates.entity';
8
+ import { getOrder, Order } from '../decorators/entity-order.decorator';
9
+
10
+ export class ParentEntity extends ActionDatesEntity {
11
+ @Order(-1)
12
+ @PrimaryGeneratedColumn()
13
+ id: number;
14
+
15
+ @Order(9998)
16
+ @Column({ default: true })
17
+ isActive: boolean;
18
+
19
+ @Order(9999)
20
+ @Column({ type: 'json', nullable: true })
21
+ metadata?: any;
22
+
23
+ static useDataSource(dataSource: DataSource) {
24
+ BaseEntity.useDataSource.call(this, dataSource);
25
+ const meta = dataSource.entityMetadatasMap.get(this);
26
+ if (meta != null) {
27
+ // reorder columns here
28
+ meta.columns = [...meta.columns].sort((x, y) => {
29
+ const orderX = getOrder((x.target as any).prototype, x.propertyName);
30
+ const orderY = getOrder((y.target as any).prototype, y.propertyName);
31
+ return orderX - orderY;
32
+ });
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ export enum Environments {
2
+ PRODUCTION = 'production',
3
+ STAGE = 'stage',
4
+ TEST = 'test',
5
+ DEVELOP = 'develop',
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from './environments.enum';
2
+ export * from './environments.enum';
@@ -0,0 +1,40 @@
1
+ export enum SharedMessages {
2
+ // Generic errors
3
+ INTERNAL_SERVER_ERROR = 'Internal Server Error.',
4
+ NOT_IMPLEMENTED = 'This feature has not been implemented yet.',
5
+ RECURSIVE_CHILD = 'Some children IDs are invalid, the parent product can not be used in children, it is recursive.',
6
+ SUCCESSFUL = 'Operation completed successfully.',
7
+ IS_UNiQUE = 'Field must be unique.',
8
+
9
+ // Create (POST) specific errors
10
+ CREATE_FAILED = 'Failed to create: {0}.',
11
+ CREATE_DENIED = 'Permission denied to create: {0}.',
12
+
13
+ // Read (GET) specific errors
14
+ FETCH_FAILED = 'Failed to fetch: {0}.',
15
+ RESOURCE_NOT_FOUND = 'The requested {0} was not found.',
16
+ DUPLICATED_SKU = 'The SKU is reserved.',
17
+ DUPLICATED_CODE = 'The Code is reserved.',
18
+ INVALID_COMPOSITE_SUB_ITEMS = 'Composite sub items are invalid.',
19
+ INVALID_GROUPED_SUB_ITEMS = 'Sub items are invalid.',
20
+
21
+ // Update (PUT/PATCH) specific errors
22
+ UPDATE_FAILED = 'Failed to update: {0}.',
23
+ UPDATE_DENIED = 'Permission denied to update: {0}.',
24
+
25
+ // Upsert (PUT/PATCH) specific errors
26
+ UPSERT_FAILED = 'Failed to upsert: {0}.',
27
+ UPSERT_DENIED = 'Permission denied to upsert: {0}.',
28
+
29
+ // Delete (DELETE) specific errors
30
+ DELETE_FAILED = 'Failed to delete: {0}.',
31
+ DELETE_DENIED = 'Permission denied to delete: {0}.',
32
+
33
+ // Validation errors
34
+ SORT_VALIDATION_FAILED = 'Sort parameter validation failed {0}.',
35
+ PARAMETER_VALIDATION_FAILED = 'Parameter validation failed {0}.',
36
+
37
+ // Authentication and Authorization errors
38
+ UNAUTHORIZED = 'Authorization is required to access this {0}.',
39
+ FORBIDDEN = 'Access to this {0} is forbidden.',
40
+ }
@@ -0,0 +1,74 @@
1
+ import {
2
+ ArgumentsHost,
3
+ Catch,
4
+ ExceptionFilter,
5
+ HttpException,
6
+ HttpStatus,
7
+ Logger,
8
+ } from '@nestjs/common';
9
+ import { Response } from 'express';
10
+ import { ErrorResponse } from '../dto';
11
+ import { ConfigService } from '@nestjs/config';
12
+ import { SharedMessages } from '../enums/shared-messages.enum';
13
+ import { KafkaContext } from '@nestjs/microservices';
14
+
15
+ @Catch(HttpException)
16
+ export class HttpExceptionFilter implements ExceptionFilter {
17
+ constructor(private readonly configService: ConfigService) {}
18
+ catch(exception: HttpException, host: ArgumentsHost) {
19
+ const context = host.switchToHttp();
20
+ const response = context.getResponse<Response>();
21
+ const status = exception.getStatus();
22
+ const result = exception.getResponse() as {
23
+ message: string | string[];
24
+ error: string | string[];
25
+ details: any;
26
+ };
27
+ const logger = new Logger('OrderKafkaController', { timestamp: true });
28
+
29
+ if (response instanceof KafkaContext) {
30
+ logger.error(result);
31
+
32
+ // TODO: add sentry for manage kafka exceptions
33
+ }
34
+ try {
35
+ if (status === HttpStatus.UNPROCESSABLE_ENTITY) {
36
+ return response.status(status).json(result);
37
+ } else if (status === HttpStatus.BAD_REQUEST) {
38
+ // if (result instanceof SharedMessages) {
39
+ //
40
+ // }
41
+ return response
42
+ .status(status)
43
+ .json(
44
+ new ErrorResponse(
45
+ String(result?.error),
46
+ status,
47
+ typeof result?.message === 'string'
48
+ ? result?.message
49
+ : result?.message[0],
50
+ ),
51
+ );
52
+ } else {
53
+ let message: string;
54
+
55
+ if (typeof result.message === 'string') {
56
+ message = result?.message;
57
+ } else {
58
+ message = result?.message[0];
59
+ }
60
+
61
+ return response.status(status).json(new ErrorResponse(message, status));
62
+ }
63
+ } catch (err) {
64
+ response
65
+ .status(HttpStatus.INTERNAL_SERVER_ERROR)
66
+ .json(
67
+ new ErrorResponse(
68
+ SharedMessages.INTERNAL_SERVER_ERROR,
69
+ HttpStatus.INTERNAL_SERVER_ERROR,
70
+ ),
71
+ );
72
+ }
73
+ }
74
+ }
@@ -0,0 +1 @@
1
+ export * from './http-exception.filter';
@@ -0,0 +1,40 @@
1
+ import { Catch, ArgumentsHost } from '@nestjs/common';
2
+ import { BaseRpcExceptionFilter, RpcException } from '@nestjs/microservices';
3
+
4
+ @Catch(RpcException)
5
+ export class KafkaExceptionFilter extends BaseRpcExceptionFilter {
6
+ catch(exception: any, host: ArgumentsHost) {
7
+ return super.catch(exception, host);
8
+ }
9
+ }
10
+
11
+ // @Catch(RpcException)
12
+ // export class CustomRpcExceptionFilter
13
+ // implements RpcExceptionFilter<RpcException>
14
+ // {
15
+ // catch(exception: RpcException, host: ArgumentsHost) {
16
+ // const ctx = host.switchToRpc();
17
+ // const response = ctx.getContext();
18
+ //
19
+ // const status =
20
+ // exception instanceof HttpException
21
+ // ? exception.getStatus()
22
+ // : HttpStatus.INTERNAL_SERVER_ERROR;
23
+ //
24
+ // const message = exception.message || 'Internal server error';
25
+ //
26
+ // return response.send({
27
+ // statusCode: status,
28
+ // message: message,
29
+ // });
30
+ // }
31
+ // // catch(exception: RpcException, host: ArgumentsHost): Observable<any> {
32
+ // // return throwError(() =>
33
+ // // new KafkaSuccessResponse<any>({
34
+ // // data: exception.getError(),
35
+ // // event_source: 'product',
36
+ // // status: 400,
37
+ // // }).stringify(),
38
+ // // );
39
+ // // }
40
+ // }
@@ -0,0 +1,3 @@
1
+ export function env(key, defaultValue: any = null) {
2
+ return process?.env?.[key] ?? defaultValue;
3
+ }
@@ -0,0 +1,3 @@
1
+ export function env(key, defaultValue: any = null) {
2
+ return process?.env?.[key] ?? defaultValue;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './get-env';
2
+ export * from './multi-inheritance.util';
@@ -0,0 +1,30 @@
1
+ export class MessageFormatter {
2
+ /**
3
+ * Function to replace a message from the SharedMessages enum with custom arguments.
4
+ * @param message The message of the SharedMessages enum.
5
+ * @param args Custom arguments to replace placeholders in the message.
6
+ * @returns The formatted message.
7
+ */
8
+ static replace(message: string, ...args: any[]): string {
9
+ // Check if the message exists in the enum
10
+ if (!message) {
11
+ throw new Error(`Message with key ${message} does not exist.`);
12
+ }
13
+
14
+ // Replace placeholders in the message with provided arguments
15
+ if (args.length !== 0) {
16
+ args.forEach((arg, index) => {
17
+ const placeholder = `{${index}}`;
18
+ if (arg !== undefined && arg !== null) {
19
+ message = message.replace(placeholder, String(arg));
20
+ } else {
21
+ message = message.replace(placeholder, '');
22
+ }
23
+ });
24
+ } else {
25
+ message = message.replace(' {0} ', ' ');
26
+ }
27
+
28
+ return message;
29
+ }
30
+ }
@@ -0,0 +1,12 @@
1
+ export const multiInheritance = (baseClass: any, extendedClasses: any[]) => {
2
+ extendedClasses.forEach((extendedClass) => {
3
+ Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
4
+ Object.defineProperty(
5
+ baseClass.prototype,
6
+ name,
7
+ Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
8
+ Object.create(null),
9
+ );
10
+ });
11
+ });
12
+ };
@@ -0,0 +1,12 @@
1
+ export const multiInheritance = (baseClass: any, extendedClasses: any[]) => {
2
+ extendedClasses.forEach((extendedClass) => {
3
+ Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
4
+ Object.defineProperty(
5
+ baseClass.prototype,
6
+ name,
7
+ Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
8
+ Object.create(null),
9
+ );
10
+ });
11
+ });
12
+ };
@@ -0,0 +1,14 @@
1
+ export * as caching from './caching';
2
+ export * as constants from './constants';
3
+ export * as controllers from './controllers';
4
+ export * as decorators from './decorators';
5
+ export * as dto from './dto';
6
+ export * as entities from './entities';
7
+ export * as enums from './enums';
8
+ export * as filters from './filters';
9
+ export * as helper from './helper';
10
+ export * as interfaces from './interface';
11
+ export * as lib from './lib';
12
+ export * as services from './services';
13
+ export * as strategy from './strategy';
14
+ export * as validators from './validators';
@@ -0,0 +1,8 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { FindOptionsRelations } from 'typeorm/find-options/FindOptionsRelations';
3
+
4
+ export class CoreCrudServiceOption<T> {
5
+ entityManager?: EntityManager;
6
+ relations?: FindOptionsRelations<T>;
7
+ existsCheck?: boolean = true;
8
+ }
@@ -0,0 +1,20 @@
1
+ import { ValidationArguments } from 'class-validator/types/validation/ValidationArguments';
2
+ import { ValidatorConstraintInterface } from 'class-validator/types/validation/ValidatorConstraintInterface';
3
+
4
+ export interface CustomValidationArguments extends ValidationArguments {
5
+ constraints: CustomConstraintsInterface[];
6
+ }
7
+
8
+ export interface CustomConstraintsInterface {
9
+ repository: string;
10
+ pathToProperty?: string;
11
+ whereQuery?: object;
12
+ stringPropertyQuery?: string[];
13
+ }
14
+ export interface CustomValidatorConstraintInterface
15
+ extends ValidatorConstraintInterface {
16
+ validate(
17
+ value: any,
18
+ validationArguments?: CustomValidationArguments,
19
+ ): Promise<boolean> | boolean;
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './core-crud-service.option';
2
+ export * from './core-crud-service.option';
@@ -0,0 +1,9 @@
1
+ export interface KafkaSuccessResponseInterface<type> {
2
+ data: type;
3
+ event_source: string;
4
+ topic?: string;
5
+ model?: string;
6
+ event_key?: string;
7
+ partition?: number;
8
+ status?: number;
9
+ }