@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
package/.eslintrc.js ADDED
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.json',
5
+ tsconfigRootDir: __dirname,
6
+ sourceType: 'module',
7
+ },
8
+ plugins: ['@typescript-eslint/eslint-plugin'],
9
+ extends: [
10
+ 'plugin:@typescript-eslint/recommended',
11
+ 'plugin:prettier/recommended',
12
+ ],
13
+ root: true,
14
+ env: {
15
+ node: true,
16
+ jest: true,
17
+ },
18
+ ignorePatterns: ['.eslintrc.js'],
19
+ rules: {
20
+ '@typescript-eslint/interface-name-prefix': 'off',
21
+ '@typescript-eslint/explicit-function-return-type': 'off',
22
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
23
+ '@typescript-eslint/no-explicit-any': 'off',
24
+ },
25
+ };
@@ -0,0 +1,34 @@
1
+ name: Build and Publish
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ build-and-publish:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v3
14
+
15
+ - name: Set up Node.js
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: '16' # Use the Node.js version your project requires
19
+
20
+ - name: Install dependencies
21
+ run: npm install
22
+
23
+ - name: Build project
24
+ run: npm run build # Adjust this if your build command is different
25
+
26
+ - name: Set NPM Token
27
+ run: npm config set _authToken=${{ secrets.NPM_TOKEN }}
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30
+
31
+ - name: Publish to npm
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34
+ run: npm publish --access public
package/.prettierrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all"
4
+ }
@@ -0,0 +1,28 @@
1
+ import { Global, Module } from '@nestjs/common';
2
+ import { CachingService } from './caching.service';
3
+ import { CacheModule } from '@nestjs/cache-manager';
4
+ import { ConfigModule, ConfigService } from '@nestjs/config';
5
+ import * as redisStore from 'cache-manager-redis-store';
6
+
7
+ @Global()
8
+ @Module({
9
+ imports: [
10
+ CacheModule.register({
11
+ isGlobal: true,
12
+ imports: [ConfigModule],
13
+ useFactory: async (configService: ConfigService) => ({
14
+ ttl: configService.get('CACHE_TTL', 86400000),
15
+ store: redisStore,
16
+ host: configService.get('redis.host'),
17
+ port: configService.get('redis.port'),
18
+ password: configService.get('redis.password'),
19
+ max: 10000,
20
+ isGlobal: true,
21
+ }),
22
+ inject: [ConfigService],
23
+ }),
24
+ ],
25
+ providers: [CachingService],
26
+ exports: [CachingService],
27
+ })
28
+ export class CachingModule {}
@@ -0,0 +1,34 @@
1
+ import { Inject, Injectable } from '@nestjs/common';
2
+ import { CACHE_MANAGER } from '@nestjs/cache-manager';
3
+ import { Cache } from 'cache-manager';
4
+
5
+ @Injectable()
6
+ export class CachingService {
7
+ constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}
8
+
9
+ getRedisClient() {
10
+ return this.cacheManager.store;
11
+ }
12
+
13
+ async get<T>(key: string) {
14
+ const result: string = await this.cacheManager.get<undefined | string>(key);
15
+ // JSON parse result
16
+ if (result) {
17
+ return JSON.parse(result) as T;
18
+ }
19
+ return result as T;
20
+ }
21
+
22
+ async set<T>(key: string, value: T, ttlSeconds: number): Promise<void> {
23
+ // stringify value
24
+ return await this.cacheManager.set(
25
+ key,
26
+ JSON.stringify(value),
27
+ ttlSeconds * 1000,
28
+ );
29
+ }
30
+
31
+ async del(key: string): Promise<void> {
32
+ return await this.cacheManager.del(key);
33
+ }
34
+ }
@@ -0,0 +1,2 @@
1
+ export * from './caching.module';
2
+ export * from './caching.service';
@@ -0,0 +1 @@
1
+ export * from './validation-constraints.const';
@@ -0,0 +1,14 @@
1
+ export class ValidationConstraints {
2
+ static readonly maxIntegerValue = 2147483646;
3
+ static readonly pageLimit = 50;
4
+ static readonly otpCodeLength = 6;
5
+ static readonly minSortFieldLength = 2;
6
+ static readonly maxSortFieldLength = 32;
7
+ static readonly shebaNumberLength = 26;
8
+ static readonly ticketMessageMinLength = 50;
9
+ static readonly ticketMessageMaxLength = 500;
10
+ static readonly trackingCodeLength = 8;
11
+ static readonly phonePattern = /^(?![1-9]).{11}$/;
12
+ static readonly faxPattern = /^\+?[0-9]{6,}$/;
13
+ static readonly postalCodeLength = 10;
14
+ }
@@ -0,0 +1,106 @@
1
+ import {
2
+ Get,
3
+ Post,
4
+ Body,
5
+ Put,
6
+ Param,
7
+ Delete,
8
+ NotFoundException,
9
+ HttpStatus,
10
+ BadRequestException,
11
+ } from '@nestjs/common';
12
+ import { Paginate, Paginated } from 'nestjs-paginate';
13
+ import { PaginateConfig } from 'nestjs-paginate/lib/paginate';
14
+ import { PaginationQueryCustom } from '../interface/pagination-query';
15
+ import { SharedMessages } from '../enums/shared-messages.enum';
16
+ import { SuccessResponse } from '../dto/response/success-response.dto';
17
+ import { BaseResponseWithActionDates } from '../dto/response/base-response-with-action-dates.dto';
18
+ import { IdDto } from '../dto/request/id.dto';
19
+ import { CoreCrudService } from '../services/core-crud.service';
20
+ import { ParentEntity } from '../entities/parent.entity';
21
+
22
+ export class CoreCrudController<
23
+ T extends ParentEntity,
24
+ CreateDto,
25
+ UpdateDto,
26
+ ResponseDto extends BaseResponseWithActionDates,
27
+ > {
28
+ protected constructor(
29
+ protected readonly coreService: CoreCrudService<T, CreateDto, UpdateDto>,
30
+ protected readonly responseDto: any,
31
+ ) {}
32
+
33
+ async findAll(
34
+ @Paginate() query: PaginationQueryCustom,
35
+ paginateConfig: PaginateConfig<T>,
36
+ ): Promise<Paginated<T>> {
37
+ const response = await this.coreService.findAllWithPagination(
38
+ query,
39
+ paginateConfig,
40
+ );
41
+ if (!response) throw new NotFoundException(SharedMessages.FETCH_FAILED);
42
+
43
+ response.data = response.data.map((item) => new this.responseDto(item));
44
+ return response;
45
+ }
46
+
47
+ async findOneById(id: number): Promise<SuccessResponse<ResponseDto>> {
48
+ const response = await this.coreService.findOneById(id);
49
+ if (!response)
50
+ throw new NotFoundException(SharedMessages.RESOURCE_NOT_FOUND);
51
+
52
+ return new SuccessResponse<ResponseDto>(
53
+ new this.responseDto(response),
54
+ SharedMessages.SUCCESSFUL,
55
+ HttpStatus.OK,
56
+ );
57
+ }
58
+
59
+ async create(createDto: CreateDto): Promise<SuccessResponse<ResponseDto>> {
60
+ const response = await this.coreService.create(createDto);
61
+ if (!response) throw new BadRequestException(SharedMessages.CREATE_FAILED);
62
+
63
+ return new SuccessResponse<ResponseDto>(
64
+ new this.responseDto(response),
65
+ SharedMessages.SUCCESSFUL,
66
+ HttpStatus.CREATED,
67
+ );
68
+ }
69
+
70
+ async update(
71
+ { id }: IdDto,
72
+ updateDto: UpdateDto,
73
+ ): Promise<SuccessResponse<ResponseDto>> {
74
+ const response = await this.coreService.update(id, updateDto);
75
+ if (!response) throw new BadRequestException(SharedMessages.UPDATE_FAILED);
76
+
77
+ const foundItem = await this.coreService.findOneById(id);
78
+ return new SuccessResponse<ResponseDto>(
79
+ new this.responseDto(foundItem),
80
+ SharedMessages.SUCCESSFUL,
81
+ HttpStatus.OK,
82
+ );
83
+ }
84
+
85
+ async delete({ id }: IdDto): Promise<SuccessResponse<void>> {
86
+ const result = await this.coreService.deleteById(id);
87
+ if (!result) throw new BadRequestException(SharedMessages.DELETE_FAILED);
88
+
89
+ return new SuccessResponse<void>(
90
+ undefined,
91
+ SharedMessages.SUCCESSFUL,
92
+ HttpStatus.OK,
93
+ );
94
+ }
95
+
96
+ async softDelete({ id }: IdDto): Promise<SuccessResponse<void>> {
97
+ const result = await this.coreService.softDeleteById(id);
98
+ if (!result) throw new BadRequestException(SharedMessages.DELETE_FAILED);
99
+
100
+ return new SuccessResponse<void>(
101
+ undefined,
102
+ SharedMessages.SUCCESSFUL,
103
+ HttpStatus.OK,
104
+ );
105
+ }
106
+ }
@@ -0,0 +1 @@
1
+ export * from './core-crud.controller';
@@ -0,0 +1,19 @@
1
+ const ORDER_KEY = Symbol.for('order_key');
2
+ export function Order(value: number): PropertyDecorator {
3
+ return (target, propertyKey) => {
4
+ Reflect.defineMetadata(ORDER_KEY, value, target, propertyKey);
5
+ };
6
+ }
7
+
8
+ export function getOrder(
9
+ target: unknown,
10
+ propertyKey: string | symbol,
11
+ defaultVal = 0,
12
+ ) {
13
+ const result = Reflect.getMetadata(ORDER_KEY, target, propertyKey);
14
+ if (typeof result === 'number') {
15
+ return result;
16
+ }
17
+
18
+ return defaultVal;
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './validations';
2
+ export * from './swagger-api-response.decorator';
@@ -0,0 +1,30 @@
1
+ import { applyDecorators } from '@nestjs/common';
2
+ import { getSchemaPath } from '@nestjs/swagger';
3
+ import { SuccessResponse } from '../dto/response/success-response.dto';
4
+ import { ApiResponse } from '@nestjs/swagger';
5
+
6
+ export function CustomApiResponse(options: {
7
+ status: number;
8
+ description: string;
9
+ responseDto: any;
10
+ }) {
11
+ // Return a function that NestJS will call to apply the decorator
12
+ return function (target: any, key?: string, descriptor?: PropertyDescriptor) {
13
+ // Use applyDecorators to handle combining with other potential decorators
14
+ return applyDecorators(
15
+ ApiResponse({
16
+ status: options.status, // Typically CREATED status
17
+ description: options.description,
18
+ schema: {
19
+ $ref: getSchemaPath(SuccessResponse),
20
+ type: 'object',
21
+ properties: {
22
+ data: {
23
+ $ref: getSchemaPath(options.responseDto),
24
+ },
25
+ },
26
+ },
27
+ }),
28
+ )(target, key, descriptor);
29
+ };
30
+ }
@@ -0,0 +1,9 @@
1
+ import { ArrayMaxSize as arrayMaxSize } from 'class-validator';
2
+
3
+ export function ArrayMaxSize(length: number): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ arrayMaxSize(length, {
6
+ message: 'validation.ARRAY_MAX_SIZE',
7
+ })(target, propertyKey);
8
+ };
9
+ }
@@ -0,0 +1,9 @@
1
+ import { ArrayMinSize as arrayMinSize } from 'class-validator';
2
+
3
+ export function ArrayMinSize(length: number): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ arrayMinSize(length, {
6
+ message: 'validation.ARRAY_MIN_SIZE',
7
+ })(target, propertyKey);
8
+ };
9
+ }
@@ -0,0 +1,7 @@
1
+ import { ArrayNotEmpty as arrayNotEmpty } from 'class-validator';
2
+
3
+ export function ArrayNotEmpty(): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ arrayNotEmpty({ message: 'validation.NOT_EMPTY' })(target, propertyKey);
6
+ };
7
+ }
@@ -0,0 +1,20 @@
1
+ export * from './is-string.decorator';
2
+ export * from './is-not-empty.decorator';
3
+ export * from './min-length.decorator';
4
+ export * from './max-length.decorator';
5
+ export * from './is-enum.decorator';
6
+ export * from './is-int.decorator';
7
+ export * from './is-positive.decorator';
8
+ export * from './min.decorator';
9
+ export * from './max.decorator';
10
+ export * from './is-array.decorator';
11
+ export * from './matches.decorator';
12
+ export * from './is-number-string.decorator';
13
+ export * from './is-boolean.decorator';
14
+ export * from './is-uuid.decorator';
15
+ export * from './is-object.decorator';
16
+ export * from './is-date.decorator';
17
+ export * from './array-not-empty.decorator';
18
+ export * from './array-min-size.decorator';
19
+ export * from './array-max-size.decorator';
20
+ export * from './is-not-empty-object.decorator';
@@ -0,0 +1,7 @@
1
+ import { IsArray as isArray } from 'class-validator';
2
+
3
+ export function IsArray(): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isArray({ message: 'validation.ARRAY' })(target, propertyKey);
6
+ };
7
+ }
@@ -0,0 +1,10 @@
1
+ import { IsBoolean as isBoolean } from 'class-validator';
2
+
3
+ export function IsBoolean(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isBoolean(Object.assign({ message: 'validation.BOOLEAN' }, options))(
6
+ target,
7
+ propertyKey,
8
+ );
9
+ };
10
+ }
@@ -0,0 +1,10 @@
1
+ import { IsDate as isDate } from 'class-validator';
2
+
3
+ export function IsDate(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isDate(Object.assign({ message: 'validation.DATE' }, options))(
6
+ target,
7
+ propertyKey,
8
+ );
9
+ };
10
+ }
@@ -0,0 +1,9 @@
1
+ import { IsEnum as isEnum } from 'class-validator';
2
+
3
+ export function IsEnum(value: any): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isEnum(value, {
6
+ message: 'validation.ENUM',
7
+ })(target, propertyKey);
8
+ };
9
+ }
@@ -0,0 +1,10 @@
1
+ import { IsInt as isInt } from 'class-validator';
2
+
3
+ export function IsInt(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isInt(Object.assign({ message: 'validation.INT' }, options))(
6
+ target,
7
+ propertyKey,
8
+ );
9
+ };
10
+ }
@@ -0,0 +1,15 @@
1
+ import { IsNotEmptyObject as isNotEmptyObject } from 'class-validator';
2
+
3
+ export function IsNotEmptyObject(
4
+ params: {
5
+ nullable?: boolean;
6
+ },
7
+ options?: { each?: boolean },
8
+ ): PropertyDecorator {
9
+ return function (target: any, propertyKey: string | symbol): void {
10
+ isNotEmptyObject(params, {
11
+ ...options,
12
+ message: 'validation.IS_NOT_EMPTY_OBJECT',
13
+ })(target, propertyKey);
14
+ };
15
+ }
@@ -0,0 +1,7 @@
1
+ import { IsNotEmpty as isNotEmpty } from 'class-validator';
2
+
3
+ export function IsNotEmpty(): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isNotEmpty({ message: 'validation.NOT_EMPTY' })(target, propertyKey);
6
+ };
7
+ }
@@ -0,0 +1,12 @@
1
+ import { IsNumberString as isNumberString } from 'class-validator';
2
+
3
+ export function IsNumberString(options?: {
4
+ each?: boolean;
5
+ }): PropertyDecorator {
6
+ return function (target: any, propertyKey: string | symbol): void {
7
+ isNumberString(
8
+ {},
9
+ Object.assign({ message: 'validation.NUMBER_STRING' }, options),
10
+ )(target, propertyKey);
11
+ };
12
+ }
@@ -0,0 +1,7 @@
1
+ import { ValidationOptions, IsObject as isObject } from 'class-validator';
2
+
3
+ export function IsObject(options?: ValidationOptions): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isObject({ ...options, message: 'validation.OBJECT' })(target, propertyKey);
6
+ };
7
+ }
@@ -0,0 +1,10 @@
1
+ import { IsPositive as isPositive } from 'class-validator';
2
+
3
+ export function IsPositive(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isPositive(Object.assign({ message: 'validation.POSITIVE' }, options))(
6
+ target,
7
+ propertyKey,
8
+ );
9
+ };
10
+ }
@@ -0,0 +1,8 @@
1
+ import { IsString as isString } from 'class-validator';
2
+
3
+ export function IsString(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ const each = (options && options.each) || false;
6
+ isString({ each, message: 'validation.STRING' })(target, propertyKey);
7
+ };
8
+ }
@@ -0,0 +1,7 @@
1
+ import { IsUUID as isUUID } from 'class-validator';
2
+
3
+ export function IsUUID(options?: { each?: boolean }): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ isUUID(4, options)(target, propertyKey);
6
+ };
7
+ }
@@ -0,0 +1,13 @@
1
+ import { Matches as matches } from 'class-validator';
2
+
3
+ export function Matches(
4
+ pattern,
5
+ options?: { each?: boolean },
6
+ ): PropertyDecorator {
7
+ return function (target: any, propertyKey: string | symbol): void {
8
+ matches(pattern, Object.assign({ message: 'validation.PATTERN' }, options))(
9
+ target,
10
+ propertyKey,
11
+ );
12
+ };
13
+ }
@@ -0,0 +1,9 @@
1
+ import { MaxLength as maxLength } from 'class-validator';
2
+
3
+ export function MaxLength(length: number): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ maxLength(length, {
6
+ message: 'validation.MAX_LENGTH',
7
+ })(target, propertyKey);
8
+ };
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Max as max } from 'class-validator';
2
+
3
+ export function Max(
4
+ value: number,
5
+ options?: { each?: boolean },
6
+ ): PropertyDecorator {
7
+ return function (target: any, propertyKey: string | symbol): void {
8
+ max(value, Object.assign({ message: 'validation.MAX' }, options))(
9
+ target,
10
+ propertyKey,
11
+ );
12
+ };
13
+ }
@@ -0,0 +1,9 @@
1
+ import { MinLength as minLength } from 'class-validator';
2
+
3
+ export function MinLength(length: number): PropertyDecorator {
4
+ return function (target: any, propertyKey: string | symbol): void {
5
+ minLength(length, {
6
+ message: 'validation.MIN_LENGTH',
7
+ })(target, propertyKey);
8
+ };
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Min as min } from 'class-validator';
2
+
3
+ export function Min(
4
+ value: number,
5
+ options?: { each?: boolean },
6
+ ): PropertyDecorator {
7
+ return function (target: any, propertyKey: string | symbol): void {
8
+ min(value, Object.assign({ message: 'validation.MIN' }, options))(
9
+ target,
10
+ propertyKey,
11
+ );
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ export * from './default';
2
+ export * from './is-id.decorator';
3
+ export * from './is-not-empty-string.decorator';
@@ -0,0 +1,20 @@
1
+ import { IsOptional } from 'class-validator';
2
+ import { IsInt, IsNotEmpty, IsPositive, Max } from './default';
3
+ import { ValidationConstraints } from '../../constants/validation-constraints.const';
4
+
5
+ export function IsId(options?: {
6
+ optional?: boolean;
7
+ each?: boolean;
8
+ }): PropertyDecorator {
9
+ return function (target: any, propertyKey: string | symbol): void {
10
+ const each = (options && options.each) || false;
11
+ IsInt({ each })(target, propertyKey);
12
+ IsPositive({ each })(target, propertyKey);
13
+ Max(ValidationConstraints.maxIntegerValue, {
14
+ each,
15
+ })(target, propertyKey);
16
+
17
+ if (options && options.optional) IsOptional()(target, propertyKey);
18
+ else IsNotEmpty()(target, propertyKey);
19
+ };
20
+ }
@@ -0,0 +1,14 @@
1
+ import { IsOptional } from 'class-validator';
2
+ import { IsNotEmpty, IsString } from './default';
3
+
4
+ export function CustomIsString(options?: {
5
+ each?: boolean;
6
+ optional: boolean;
7
+ }): PropertyDecorator {
8
+ return function (target: any, propertyKey: string | symbol): void {
9
+ IsString({ each: options ? options.each : false })(target, propertyKey);
10
+
11
+ if (options && options.optional) IsOptional()(target, propertyKey);
12
+ else IsNotEmpty()(target, propertyKey);
13
+ };
14
+ }
@@ -0,0 +1,2 @@
1
+ export * from './request';
2
+ export * from './response';
@@ -0,0 +1,11 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { IsBoolean, IsOptional } from 'class-validator';
3
+
4
+ export class BaseRequest {
5
+ @ApiProperty({ example: false })
6
+ @IsBoolean()
7
+ @IsOptional()
8
+ isActive?: boolean;
9
+
10
+ metadata?: any;
11
+ }
@@ -0,0 +1,25 @@
1
+ import { IsNumber, IsOptional, IsString } from 'class-validator';
2
+
3
+ export class EventDto<T> {
4
+ @IsString()
5
+ @IsOptional()
6
+ topic?: string;
7
+
8
+ @IsString()
9
+ event_source: string;
10
+
11
+ @IsString()
12
+ @IsOptional()
13
+ model?: string;
14
+
15
+ @IsString()
16
+ @IsOptional()
17
+ event_key?: string;
18
+
19
+ @IsOptional()
20
+ data?: T;
21
+
22
+ @IsNumber()
23
+ @IsOptional()
24
+ partition?: number;
25
+ }