@elsikora/nestjs-crud-automator 1.2.0 → 1.2.2

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 (417) hide show
  1. package/dist/class/api/base-service.class.d.ts +5 -5
  2. package/dist/class/api/base-service.class.js +19 -10
  3. package/dist/class/api/base-service.class.js.map +1 -1
  4. package/dist/class/api/index.d.ts +0 -1
  5. package/dist/class/api/index.js +0 -1
  6. package/dist/class/api/index.js.map +1 -1
  7. package/dist/class/index.d.ts +1 -0
  8. package/dist/class/index.js +1 -0
  9. package/dist/class/index.js.map +1 -1
  10. package/dist/class/utility/dto/index.d.ts +2 -0
  11. package/dist/{decorator/api/route → class/utility/dto}/index.js +2 -2
  12. package/dist/class/utility/dto/index.js.map +1 -0
  13. package/dist/class/utility/dto/property/factory/boolean.class.d.ts +5 -0
  14. package/dist/class/utility/dto/property/factory/boolean.class.js +15 -0
  15. package/dist/class/utility/dto/property/factory/boolean.class.js.map +1 -0
  16. package/dist/class/utility/dto/property/factory/date.class.d.ts +5 -0
  17. package/dist/class/utility/dto/property/factory/date.class.js +15 -0
  18. package/dist/class/utility/dto/property/factory/date.class.js.map +1 -0
  19. package/dist/class/utility/dto/property/factory/index.d.ts +6 -0
  20. package/dist/{dto/exception → class/utility/dto/property/factory}/index.js +6 -7
  21. package/dist/class/utility/dto/property/factory/index.js.map +1 -0
  22. package/dist/class/utility/dto/property/factory/number.class.d.ts +5 -0
  23. package/dist/class/utility/dto/property/factory/number.class.js +19 -0
  24. package/dist/class/utility/dto/property/factory/number.class.js.map +1 -0
  25. package/dist/class/utility/dto/property/factory/object.class.d.ts +5 -0
  26. package/dist/class/utility/dto/property/factory/object.class.js +17 -0
  27. package/dist/class/utility/dto/property/factory/object.class.js.map +1 -0
  28. package/dist/class/utility/dto/property/factory/relation.class.d.ts +5 -0
  29. package/dist/class/utility/dto/property/factory/relation.class.js +11 -0
  30. package/dist/class/utility/dto/property/factory/relation.class.js.map +1 -0
  31. package/dist/class/utility/dto/property/factory/string.class.d.ts +5 -0
  32. package/dist/class/utility/dto/property/factory/string.class.js +15 -0
  33. package/dist/class/utility/dto/property/factory/string.class.js.map +1 -0
  34. package/dist/class/utility/dto/property/factory/uuid.class.d.ts +5 -0
  35. package/dist/class/utility/dto/property/factory/uuid.class.js +11 -0
  36. package/dist/class/utility/dto/property/factory/uuid.class.js.map +1 -0
  37. package/dist/class/utility/dto/property/index.d.ts +1 -0
  38. package/dist/{dto → class/utility/dto/property}/index.js +1 -1
  39. package/dist/class/utility/dto/property/index.js.map +1 -0
  40. package/dist/class/utility/dto/strategy/body.class.d.ts +6 -0
  41. package/dist/class/utility/dto/strategy/body.class.js +21 -0
  42. package/dist/class/utility/dto/strategy/body.class.js.map +1 -0
  43. package/dist/class/utility/dto/strategy/index.d.ts +4 -0
  44. package/dist/class/utility/dto/strategy/index.js +21 -0
  45. package/dist/class/utility/dto/strategy/index.js.map +1 -0
  46. package/dist/class/utility/dto/strategy/query.class.d.ts +6 -0
  47. package/dist/class/utility/dto/strategy/query.class.js +18 -0
  48. package/dist/class/utility/dto/strategy/query.class.js.map +1 -0
  49. package/dist/class/utility/dto/strategy/request.class.d.ts +6 -0
  50. package/dist/class/utility/dto/strategy/request.class.js +26 -0
  51. package/dist/class/utility/dto/strategy/request.class.js.map +1 -0
  52. package/dist/class/utility/dto/strategy/response.class.d.ts +6 -0
  53. package/dist/class/utility/dto/strategy/response.class.js +18 -0
  54. package/dist/class/utility/dto/strategy/response.class.js.map +1 -0
  55. package/dist/class/utility/index.d.ts +1 -0
  56. package/dist/class/utility/index.js +18 -0
  57. package/dist/class/utility/index.js.map +1 -0
  58. package/dist/constant/decorator/api/controller.constant.d.ts +1 -1
  59. package/dist/constant/decorator/api/controller.constant.js +2 -2
  60. package/dist/constant/decorator/api/controller.constant.js.map +1 -1
  61. package/dist/constant/decorator/api/function.constant.d.ts +1 -1
  62. package/dist/constant/decorator/api/function.constant.js +2 -2
  63. package/dist/constant/decorator/api/function.constant.js.map +1 -1
  64. package/dist/constant/decorator/api/property-describe.constant.d.ts +1 -1
  65. package/dist/constant/decorator/api/property-describe.constant.js +2 -2
  66. package/dist/constant/decorator/api/property-describe.constant.js.map +1 -1
  67. package/dist/constant/factory/dto/get-list-query.constant.d.ts +1 -2
  68. package/dist/constant/factory/dto/get-list-query.constant.js +2 -2
  69. package/dist/constant/factory/dto/get-list-query.constant.js.map +1 -1
  70. package/dist/constant/interface/api/filter.constant.d.ts +1 -1
  71. package/dist/constant/interface/api/filter.constant.js +2 -2
  72. package/dist/constant/interface/api/filter.constant.js.map +1 -1
  73. package/dist/constant/interface/api/index.d.ts +1 -0
  74. package/dist/constant/interface/api/index.js +1 -0
  75. package/dist/constant/interface/api/index.js.map +1 -1
  76. package/dist/constant/interface/api/property/string.constant.d.ts +1 -1
  77. package/dist/constant/interface/api/property/string.constant.js +2 -2
  78. package/dist/constant/interface/api/property/string.constant.js.map +1 -1
  79. package/dist/constant/interface/api/property/wallet.constant.d.ts +1 -1
  80. package/dist/constant/interface/api/property/wallet.constant.js +2 -2
  81. package/dist/constant/interface/api/property/wallet.constant.js.map +1 -1
  82. package/dist/constant/utility/dto/constant.d.ts +6 -0
  83. package/dist/constant/utility/dto/constant.js +27 -0
  84. package/dist/constant/utility/dto/constant.js.map +1 -0
  85. package/dist/decorator/api/controller.decorator.d.ts +3 -7
  86. package/dist/decorator/api/controller.decorator.js +2 -2
  87. package/dist/decorator/api/controller.decorator.js.map +1 -1
  88. package/dist/decorator/api/function/create.decorator.d.ts +2 -4
  89. package/dist/decorator/api/function/create.decorator.js +25 -17
  90. package/dist/decorator/api/function/create.decorator.js.map +1 -1
  91. package/dist/decorator/api/function/decorator.d.ts +3 -7
  92. package/dist/decorator/api/function/decorator.js +20 -16
  93. package/dist/decorator/api/function/decorator.js.map +1 -1
  94. package/dist/decorator/api/function/delete.decorator.d.ts +3 -3
  95. package/dist/decorator/api/function/delete.decorator.js +6 -6
  96. package/dist/decorator/api/function/delete.decorator.js.map +1 -1
  97. package/dist/decorator/api/function/get-list.decorator.d.ts +3 -3
  98. package/dist/decorator/api/function/get-list.decorator.js +9 -8
  99. package/dist/decorator/api/function/get-list.decorator.js.map +1 -1
  100. package/dist/decorator/api/function/get.decorator.d.ts +3 -3
  101. package/dist/decorator/api/function/get.decorator.js +8 -9
  102. package/dist/decorator/api/function/get.decorator.js.map +1 -1
  103. package/dist/decorator/api/function/update.decorator.d.ts +3 -3
  104. package/dist/decorator/api/function/update.decorator.js +10 -14
  105. package/dist/decorator/api/function/update.decorator.js.map +1 -1
  106. package/dist/decorator/api/index.d.ts +0 -1
  107. package/dist/decorator/api/index.js +0 -1
  108. package/dist/decorator/api/index.js.map +1 -1
  109. package/dist/decorator/api/method.decorator.js +58 -0
  110. package/dist/decorator/api/method.decorator.js.map +1 -1
  111. package/dist/decorator/api/property/date.decorator.js.map +1 -1
  112. package/dist/decorator/api/property/describe.decorator.js +1 -1
  113. package/dist/decorator/api/property/describe.decorator.js.map +1 -1
  114. package/dist/decorator/api/property/string.decorator.js +13 -6
  115. package/dist/decorator/api/property/string.decorator.js.map +1 -1
  116. package/dist/decorator/api/property/wallet.decorator.js +3 -3
  117. package/dist/decorator/api/property/wallet.decorator.js.map +1 -1
  118. package/dist/decorator/api/service.decorator.d.ts +3 -6
  119. package/dist/decorator/api/service.decorator.js +23 -49
  120. package/dist/decorator/api/service.decorator.js.map +1 -1
  121. package/dist/enum/decorator/api/authentication-type.enum.d.ts +1 -0
  122. package/dist/enum/decorator/api/authentication-type.enum.js +1 -0
  123. package/dist/enum/decorator/api/authentication-type.enum.js.map +1 -1
  124. package/dist/enum/decorator/api/dto-type.enum.d.ts +3 -3
  125. package/dist/enum/decorator/api/dto-type.enum.js +2 -2
  126. package/dist/enum/decorator/api/dto-type.enum.js.map +1 -1
  127. package/dist/enum/decorator/api/property/desribe-type.enum.d.ts +2 -1
  128. package/dist/enum/decorator/api/property/desribe-type.enum.js +1 -0
  129. package/dist/enum/decorator/api/property/desribe-type.enum.js.map +1 -1
  130. package/dist/factory/api/controller.factory.d.ts +8 -8
  131. package/dist/factory/api/controller.factory.js +89 -55
  132. package/dist/factory/api/controller.factory.js.map +1 -1
  133. package/dist/index.d.ts +0 -1
  134. package/dist/index.js +0 -1
  135. package/dist/index.js.map +1 -1
  136. package/dist/interceptor/correlation-id-response-body.interceptor.js +0 -8
  137. package/dist/interceptor/correlation-id-response-body.interceptor.js.map +1 -1
  138. package/dist/interface/class/dto/index.d.ts +1 -0
  139. package/dist/interface/class/dto/index.js +18 -0
  140. package/dist/interface/class/dto/index.js.map +1 -0
  141. package/dist/interface/class/dto/strategy.interface.d.ts +5 -0
  142. package/dist/{type/decorator/api/function/get-properties.type.js → interface/class/dto/strategy.interface.js} +1 -1
  143. package/dist/interface/class/dto/strategy.interface.js.map +1 -0
  144. package/dist/interface/class/index.d.ts +1 -0
  145. package/dist/interface/class/index.js +18 -0
  146. package/dist/interface/class/index.js.map +1 -0
  147. package/dist/interface/decorator/api/controller-properties.interface.d.ts +12 -7
  148. package/dist/interface/decorator/api/controller-properties.interface.js.map +1 -1
  149. package/dist/interface/decorator/api/function/create-properties.interface.d.ts +4 -0
  150. package/dist/interface/decorator/api/function/create-properties.interface.js +3 -0
  151. package/dist/interface/decorator/api/function/create-properties.interface.js.map +1 -0
  152. package/dist/interface/decorator/api/index.d.ts +1 -0
  153. package/dist/interface/decorator/api/index.js +1 -0
  154. package/dist/interface/decorator/api/index.js.map +1 -1
  155. package/dist/interface/decorator/api/method/properties.interface.d.ts +3 -2
  156. package/dist/interface/decorator/api/method/properties.interface.js.map +1 -1
  157. package/dist/interface/decorator/api/property/base-properties.interface.d.ts +1 -1
  158. package/dist/interface/decorator/api/property/base-properties.interface.js.map +1 -1
  159. package/dist/interface/dto-generate-factory.interface.d.ts +5 -0
  160. package/dist/interface/dto-generate-factory.interface.js +3 -0
  161. package/dist/interface/dto-generate-factory.interface.js.map +1 -0
  162. package/dist/interface/index.d.ts +2 -0
  163. package/dist/interface/index.js +2 -0
  164. package/dist/interface/index.js.map +1 -1
  165. package/dist/interface/utility/get-entity-columns-properties.interface.d.ts +5 -0
  166. package/dist/interface/utility/get-entity-columns-properties.interface.js +3 -0
  167. package/dist/interface/utility/get-entity-columns-properties.interface.js.map +1 -0
  168. package/dist/tsconfig.build.tsbuildinfo +1 -1
  169. package/dist/type/decorator/api/controller/constructor.type.d.ts +4 -0
  170. package/dist/type/decorator/api/{function/create-properties.type.js → controller/constructor.type.js} +1 -1
  171. package/dist/type/decorator/api/controller/constructor.type.js.map +1 -0
  172. package/dist/type/decorator/api/controller/index.d.ts +1 -0
  173. package/dist/type/decorator/api/controller/index.js +18 -0
  174. package/dist/type/decorator/api/controller/index.js.map +1 -0
  175. package/dist/type/decorator/api/function/create/executor-properties.type.d.ts +8 -0
  176. package/dist/type/decorator/api/function/create/executor-properties.type.js +3 -0
  177. package/dist/type/decorator/api/function/create/executor-properties.type.js.map +1 -0
  178. package/dist/type/decorator/api/function/create/index.d.ts +2 -0
  179. package/dist/type/decorator/api/function/create/index.js +19 -0
  180. package/dist/type/decorator/api/function/create/index.js.map +1 -0
  181. package/dist/type/decorator/api/function/{update-properties.type.js → create/properties.type.js} +1 -1
  182. package/dist/type/decorator/api/function/create/properties.type.js.map +1 -0
  183. package/dist/type/decorator/api/function/delete/executor-properties.type.d.ts +9 -0
  184. package/dist/type/decorator/api/function/delete/executor-properties.type.js +3 -0
  185. package/dist/type/decorator/api/function/delete/executor-properties.type.js.map +1 -0
  186. package/dist/type/decorator/api/function/delete/index.d.ts +1 -0
  187. package/dist/type/decorator/api/function/delete/index.js +18 -0
  188. package/dist/type/decorator/api/function/delete/index.js.map +1 -0
  189. package/dist/type/decorator/api/function/get/executor-properties.type.d.ts +7 -0
  190. package/dist/type/decorator/api/function/get/executor-properties.type.js +3 -0
  191. package/dist/type/decorator/api/function/get/executor-properties.type.js.map +1 -0
  192. package/dist/type/decorator/api/function/get/index.d.ts +2 -0
  193. package/dist/type/decorator/api/function/get/index.js +19 -0
  194. package/dist/type/decorator/api/function/get/index.js.map +1 -0
  195. package/dist/type/decorator/api/function/get/properties.type.js +3 -0
  196. package/dist/type/decorator/api/function/get/properties.type.js.map +1 -0
  197. package/dist/type/decorator/api/function/get-list/base-properties.type.d.ts +16 -0
  198. package/dist/type/decorator/api/function/get-list/base-properties.type.js +3 -0
  199. package/dist/type/decorator/api/function/get-list/base-properties.type.js.map +1 -0
  200. package/dist/type/decorator/api/function/get-list/executor-properties.type.d.ts +9 -0
  201. package/dist/type/decorator/api/function/get-list/executor-properties.type.js +3 -0
  202. package/dist/type/decorator/api/function/get-list/executor-properties.type.js.map +1 -0
  203. package/dist/type/decorator/api/function/get-list/index.d.ts +3 -0
  204. package/dist/type/decorator/api/function/get-list/index.js +20 -0
  205. package/dist/type/decorator/api/function/get-list/index.js.map +1 -0
  206. package/dist/type/decorator/api/function/get-list/properties.type.d.ts +9 -0
  207. package/dist/type/decorator/api/function/get-list/properties.type.js +3 -0
  208. package/dist/type/decorator/api/function/get-list/properties.type.js.map +1 -0
  209. package/dist/type/decorator/api/function/index.d.ts +5 -4
  210. package/dist/type/decorator/api/function/index.js +5 -4
  211. package/dist/type/decorator/api/function/index.js.map +1 -1
  212. package/dist/type/decorator/api/function/properties.type.d.ts +7 -0
  213. package/dist/type/decorator/api/function/properties.type.js +3 -0
  214. package/dist/type/decorator/api/function/properties.type.js.map +1 -0
  215. package/dist/type/decorator/api/function/update/executor-properties.type.d.ts +11 -0
  216. package/dist/type/decorator/api/function/update/executor-properties.type.js +3 -0
  217. package/dist/type/decorator/api/function/update/executor-properties.type.js.map +1 -0
  218. package/dist/type/decorator/api/function/update/index.d.ts +2 -0
  219. package/dist/type/decorator/api/function/update/index.js +19 -0
  220. package/dist/type/decorator/api/function/update/index.js.map +1 -0
  221. package/dist/type/decorator/api/function/update/properties.type.js +3 -0
  222. package/dist/type/decorator/api/function/update/properties.type.js.map +1 -0
  223. package/dist/type/decorator/api/index.d.ts +1 -0
  224. package/dist/type/decorator/api/index.js +1 -0
  225. package/dist/type/decorator/api/index.js.map +1 -1
  226. package/dist/type/decorator/api/property/describe/array/index.d.ts +2 -0
  227. package/dist/type/decorator/api/property/describe/array/index.js +19 -0
  228. package/dist/type/decorator/api/property/describe/array/index.js.map +1 -0
  229. package/dist/type/decorator/api/property/describe/array/optional-properties.type.d.ts +3 -0
  230. package/dist/type/decorator/api/property/describe/array/optional-properties.type.js +3 -0
  231. package/dist/type/decorator/api/property/describe/array/optional-properties.type.js.map +1 -0
  232. package/dist/type/decorator/api/property/describe/array/required-properties.type.d.ts +6 -0
  233. package/dist/type/decorator/api/property/describe/array/required-properties.type.js +3 -0
  234. package/dist/type/decorator/api/property/describe/array/required-properties.type.js.map +1 -0
  235. package/dist/type/decorator/api/property/describe/base-properties.type.d.ts +7 -0
  236. package/dist/type/decorator/api/property/describe/base-properties.type.js +3 -0
  237. package/dist/type/decorator/api/property/describe/base-properties.type.js.map +1 -0
  238. package/dist/type/decorator/api/property/describe/boolean-properties.type.d.ts +7 -0
  239. package/dist/type/decorator/api/property/describe/boolean-properties.type.js +3 -0
  240. package/dist/type/decorator/api/property/describe/boolean-properties.type.js.map +1 -0
  241. package/dist/type/decorator/api/property/describe/date-properties.type.d.ts +7 -0
  242. package/dist/type/decorator/api/property/describe/date-properties.type.js +3 -0
  243. package/dist/type/decorator/api/property/describe/date-properties.type.js.map +1 -0
  244. package/dist/type/decorator/api/property/describe/dto/body-properties.type.d.ts +5 -0
  245. package/dist/type/decorator/api/property/describe/dto/body-properties.type.js +3 -0
  246. package/dist/type/decorator/api/property/describe/dto/body-properties.type.js.map +1 -0
  247. package/dist/type/decorator/api/property/describe/dto/index.d.ts +5 -0
  248. package/dist/type/decorator/api/property/describe/dto/index.js +22 -0
  249. package/dist/type/decorator/api/property/describe/dto/index.js.map +1 -0
  250. package/dist/type/decorator/api/property/describe/dto/properties.type.d.ts +6 -0
  251. package/dist/type/decorator/api/property/describe/dto/properties.type.js +3 -0
  252. package/dist/type/decorator/api/property/describe/dto/properties.type.js.map +1 -0
  253. package/dist/type/decorator/api/property/describe/dto/query/get-list-properties.type.d.ts +3 -0
  254. package/dist/type/decorator/api/property/describe/dto/query/get-list-properties.type.js.map +1 -0
  255. package/dist/type/decorator/api/property/describe/dto/query/index.d.ts +2 -0
  256. package/dist/type/decorator/api/property/describe/dto/query/index.js +19 -0
  257. package/dist/type/decorator/api/property/describe/dto/query/index.js.map +1 -0
  258. package/dist/type/decorator/api/property/describe/dto/query/properties.type.d.ts +6 -0
  259. package/dist/type/decorator/api/property/describe/dto/query/properties.type.js +3 -0
  260. package/dist/type/decorator/api/property/describe/dto/query/properties.type.js.map +1 -0
  261. package/dist/type/decorator/api/property/describe/dto/request-properties.type.d.ts +5 -0
  262. package/dist/type/decorator/api/property/describe/dto/request-properties.type.js +3 -0
  263. package/dist/type/decorator/api/property/describe/dto/request-properties.type.js.map +1 -0
  264. package/dist/type/decorator/api/property/describe/dto/response-properties.type.d.ts +5 -0
  265. package/dist/type/decorator/api/property/describe/dto/response-properties.type.js +3 -0
  266. package/dist/type/decorator/api/property/describe/dto/response-properties.type.js.map +1 -0
  267. package/dist/type/decorator/api/property/describe/example-properties.type.d.ts +7 -0
  268. package/dist/type/decorator/api/property/describe/example-properties.type.js +3 -0
  269. package/dist/type/decorator/api/property/describe/example-properties.type.js.map +1 -0
  270. package/dist/type/decorator/api/property/describe/index.d.ts +12 -0
  271. package/dist/type/decorator/api/property/describe/index.js +29 -0
  272. package/dist/type/decorator/api/property/describe/index.js.map +1 -0
  273. package/dist/type/decorator/api/property/describe/number-properties.type.d.ts +13 -0
  274. package/dist/type/decorator/api/property/describe/number-properties.type.js +3 -0
  275. package/dist/type/decorator/api/property/describe/number-properties.type.js.map +1 -0
  276. package/dist/type/decorator/api/property/describe/object-properties.type.d.ts +10 -0
  277. package/dist/type/decorator/api/property/describe/object-properties.type.js +3 -0
  278. package/dist/type/decorator/api/property/describe/object-properties.type.js.map +1 -0
  279. package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.d.ts +2 -0
  280. package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.js +3 -0
  281. package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.js.map +1 -0
  282. package/dist/type/decorator/api/property/describe/properties/base-properties.type.d.ts +10 -0
  283. package/dist/type/decorator/api/property/describe/properties/base-properties.type.js +3 -0
  284. package/dist/type/decorator/api/property/describe/properties/base-properties.type.js.map +1 -0
  285. package/dist/type/decorator/api/property/describe/properties/index.d.ts +2 -0
  286. package/dist/type/decorator/api/property/describe/properties/index.js +19 -0
  287. package/dist/type/decorator/api/property/describe/properties/index.js.map +1 -0
  288. package/dist/type/decorator/api/property/describe/properties.type.d.ts +8 -0
  289. package/dist/type/decorator/api/property/describe/properties.type.js +3 -0
  290. package/dist/type/decorator/api/property/describe/properties.type.js.map +1 -0
  291. package/dist/type/decorator/api/property/describe/relation-properties.type.d.ts +6 -0
  292. package/dist/type/decorator/api/property/describe/relation-properties.type.js +3 -0
  293. package/dist/type/decorator/api/property/describe/relation-properties.type.js.map +1 -0
  294. package/dist/type/decorator/api/property/describe/string-properties.type.d.ts +13 -0
  295. package/dist/type/decorator/api/property/describe/string-properties.type.js +3 -0
  296. package/dist/type/decorator/api/property/describe/string-properties.type.js.map +1 -0
  297. package/dist/type/decorator/api/property/describe/uuid-properties.type.d.ts +7 -0
  298. package/dist/type/decorator/api/property/describe/uuid-properties.type.js +3 -0
  299. package/dist/type/decorator/api/property/describe/uuid-properties.type.js.map +1 -0
  300. package/dist/type/decorator/api/property/index.d.ts +1 -1
  301. package/dist/type/decorator/api/property/index.js +1 -1
  302. package/dist/type/decorator/api/property/index.js.map +1 -1
  303. package/dist/type/decorator/api/service-properties.type.d.ts +3 -0
  304. package/dist/type/decorator/api/service-properties.type.js +3 -0
  305. package/dist/type/decorator/api/service-properties.type.js.map +1 -0
  306. package/dist/type/index.d.ts +1 -0
  307. package/dist/type/index.js +1 -0
  308. package/dist/type/index.js.map +1 -1
  309. package/dist/type/utility/dto/generate-allowed-combination.type.d.ts +9 -0
  310. package/dist/type/utility/dto/generate-allowed-combination.type.js +3 -0
  311. package/dist/type/utility/dto/generate-allowed-combination.type.js.map +1 -0
  312. package/dist/type/utility/dto/generate-is-allowed-combination.type.d.ts +3 -0
  313. package/dist/type/utility/dto/generate-is-allowed-combination.type.js +3 -0
  314. package/dist/type/utility/dto/generate-is-allowed-combination.type.js.map +1 -0
  315. package/dist/type/utility/dto/index.d.ts +2 -0
  316. package/dist/type/utility/dto/index.js +19 -0
  317. package/dist/type/utility/dto/index.js.map +1 -0
  318. package/dist/type/utility/index.d.ts +1 -0
  319. package/dist/type/utility/index.js +18 -0
  320. package/dist/type/utility/index.js.map +1 -0
  321. package/dist/utility/api/controller/get-method-name.utility.d.ts +1 -1
  322. package/dist/utility/api/controller/get-method-name.utility.js +1 -1
  323. package/dist/utility/api/controller/get-method-name.utility.js.map +1 -1
  324. package/dist/utility/api/controller/write-method.utility.d.ts +3 -3
  325. package/dist/utility/api/controller/write-method.utility.js +2 -2
  326. package/dist/utility/api/controller/write-method.utility.js.map +1 -1
  327. package/dist/utility/api/filter-order-by-from-entity.utility.d.ts +4 -2
  328. package/dist/utility/api/filter-order-by-from-entity.utility.js +17 -14
  329. package/dist/utility/api/filter-order-by-from-entity.utility.js.map +1 -1
  330. package/dist/utility/dto/analize.utility.js.map +1 -1
  331. package/dist/utility/dto/build-decorator.utility.d.ts +4 -0
  332. package/dist/utility/dto/build-decorator.utility.js +31 -0
  333. package/dist/utility/dto/build-decorator.utility.js.map +1 -0
  334. package/dist/utility/dto/generate-decorator.utility.d.ts +3 -0
  335. package/dist/utility/dto/generate-decorator.utility.js +15 -0
  336. package/dist/utility/dto/generate-decorator.utility.js.map +1 -0
  337. package/dist/utility/dto/generate-exception.utility.d.ts +2 -0
  338. package/dist/utility/dto/generate-exception.utility.js +88 -0
  339. package/dist/utility/dto/generate-exception.utility.js.map +1 -0
  340. package/dist/utility/dto/generate.utility.d.ts +2 -2
  341. package/dist/utility/dto/generate.utility.js +51 -308
  342. package/dist/utility/dto/generate.utility.js.map +1 -1
  343. package/dist/utility/dto/get-base-class.utility.d.ts +3 -0
  344. package/dist/utility/dto/get-base-class.utility.js +65 -0
  345. package/dist/utility/dto/get-base-class.utility.js.map +1 -0
  346. package/dist/utility/dto/get-decorator-config.utility.d.ts +3 -0
  347. package/dist/utility/dto/get-decorator-config.utility.js +21 -0
  348. package/dist/utility/dto/get-decorator-config.utility.js.map +1 -0
  349. package/dist/utility/dto/handle-date-property.utility.d.ts +5 -0
  350. package/dist/utility/dto/handle-date-property.utility.js +18 -0
  351. package/dist/utility/dto/handle-date-property.utility.js.map +1 -0
  352. package/dist/utility/dto/index.d.ts +8 -0
  353. package/dist/utility/dto/index.js +8 -0
  354. package/dist/utility/dto/index.js.map +1 -1
  355. package/dist/utility/dto/is-property-should-be-enabled.utility.d.ts +3 -0
  356. package/dist/utility/dto/is-property-should-be-enabled.utility.js +26 -0
  357. package/dist/utility/dto/is-property-should-be-enabled.utility.js.map +1 -0
  358. package/dist/utility/dto/is-should-be-generated.utility.d.ts +2 -0
  359. package/dist/utility/dto/is-should-be-generated.utility.js +25 -0
  360. package/dist/utility/dto/is-should-be-generated.utility.js.map +1 -0
  361. package/dist/utility/dto/validate-property-config.utility.d.ts +2 -0
  362. package/dist/utility/dto/validate-property-config.utility.js +14 -0
  363. package/dist/utility/dto/validate-property-config.utility.js.map +1 -0
  364. package/dist/utility/generate-entity-information.utility.js +15 -6
  365. package/dist/utility/generate-entity-information.utility.js.map +1 -1
  366. package/dist/utility/get-entity-columns.utility.d.ts +3 -2
  367. package/dist/utility/get-entity-columns.utility.js +4 -3
  368. package/dist/utility/get-entity-columns.utility.js.map +1 -1
  369. package/package.json +4 -1
  370. package/dist/class/api/base-controller.class.d.ts +0 -4
  371. package/dist/class/api/base-controller.class.js +0 -10
  372. package/dist/class/api/base-controller.class.js.map +0 -1
  373. package/dist/decorator/api/route/decorator.d.ts +0 -18
  374. package/dist/decorator/api/route/decorator.js +0 -43
  375. package/dist/decorator/api/route/decorator.js.map +0 -1
  376. package/dist/decorator/api/route/get.decorator.d.ts +0 -9
  377. package/dist/decorator/api/route/get.decorator.js +0 -53
  378. package/dist/decorator/api/route/get.decorator.js.map +0 -1
  379. package/dist/decorator/api/route/index.d.ts +0 -2
  380. package/dist/decorator/api/route/index.js.map +0 -1
  381. package/dist/dto/exception/bad-request.dto.d.ts +0 -8
  382. package/dist/dto/exception/bad-request.dto.js +0 -84
  383. package/dist/dto/exception/bad-request.dto.js.map +0 -1
  384. package/dist/dto/exception/conflict.dto.d.ts +0 -8
  385. package/dist/dto/exception/conflict.dto.js +0 -84
  386. package/dist/dto/exception/conflict.dto.js.map +0 -1
  387. package/dist/dto/exception/forbidden.dto.d.ts +0 -8
  388. package/dist/dto/exception/forbidden.dto.js +0 -84
  389. package/dist/dto/exception/forbidden.dto.js.map +0 -1
  390. package/dist/dto/exception/index.d.ts +0 -7
  391. package/dist/dto/exception/index.js.map +0 -1
  392. package/dist/dto/exception/internal-server-error.dto.d.ts +0 -8
  393. package/dist/dto/exception/internal-server-error.dto.js +0 -84
  394. package/dist/dto/exception/internal-server-error.dto.js.map +0 -1
  395. package/dist/dto/exception/not-found.dto.d.ts +0 -8
  396. package/dist/dto/exception/not-found.dto.js +0 -84
  397. package/dist/dto/exception/not-found.dto.js.map +0 -1
  398. package/dist/dto/exception/too-many-requests.dto.d.ts +0 -8
  399. package/dist/dto/exception/too-many-requests.dto.js +0 -84
  400. package/dist/dto/exception/too-many-requests.dto.js.map +0 -1
  401. package/dist/dto/exception/unauthorized.dto.d.ts +0 -8
  402. package/dist/dto/exception/unauthorized.dto.js +0 -84
  403. package/dist/dto/exception/unauthorized.dto.js.map +0 -1
  404. package/dist/dto/index.d.ts +0 -1
  405. package/dist/dto/index.js.map +0 -1
  406. package/dist/type/decorator/api/function/create-properties.type.js.map +0 -1
  407. package/dist/type/decorator/api/function/get-list-properties.type.d.ts +0 -23
  408. package/dist/type/decorator/api/function/get-list-properties.type.js.map +0 -1
  409. package/dist/type/decorator/api/function/get-properties.type.js.map +0 -1
  410. package/dist/type/decorator/api/function/update-properties.type.js.map +0 -1
  411. package/dist/type/decorator/api/property/describe-properties.type.d.ts +0 -64
  412. package/dist/type/decorator/api/property/describe-properties.type.js +0 -3
  413. package/dist/type/decorator/api/property/describe-properties.type.js.map +0 -1
  414. /package/dist/type/decorator/api/function/{create-properties.type.d.ts → create/properties.type.d.ts} +0 -0
  415. /package/dist/type/decorator/api/function/{get-properties.type.d.ts → get/properties.type.d.ts} +0 -0
  416. /package/dist/type/decorator/api/function/{update-properties.type.d.ts → update/properties.type.d.ts} +0 -0
  417. /package/dist/type/decorator/api/{function → property/describe/dto/query}/get-list-properties.type.js +0 -0
@@ -6,12 +6,13 @@ const typeorm_1 = require("typeorm");
6
6
  const constant_1 = require("../../../constant");
7
7
  const enum_1 = require("../../../enum");
8
8
  const utility_1 = require("../../../utility");
9
- async function executor(repository, entityType, properties, filter) {
9
+ async function executor(options) {
10
+ const { entity, filter, properties, repository } = options;
10
11
  try {
11
12
  const [items, totalCount] = await repository.findAndCount(filter);
12
13
  if (items.length === 0) {
13
14
  throw new common_1.NotFoundException((0, utility_1.ErrorString)({
14
- entity: entityType,
15
+ entity: entity,
15
16
  type: enum_1.EErrorStringAction.LIST_PAGE_NOT_FOUND,
16
17
  }));
17
18
  }
@@ -28,7 +29,7 @@ async function executor(repository, entityType, properties, filter) {
28
29
  throw error;
29
30
  }
30
31
  throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
31
- entity: entityType,
32
+ entity: entity,
32
33
  type: enum_1.EErrorStringAction.FETCHING_LIST_ERROR,
33
34
  }));
34
35
  }
@@ -44,17 +45,17 @@ function ApiFunctionGetList(options) {
44
45
  where: {},
45
46
  };
46
47
  const typedEntityProperties = entityProperties;
47
- Object.keys(typedEntityProperties).forEach((key) => {
48
+ for (const key of Object.keys(typedEntityProperties)) {
48
49
  if (typeof typedEntityProperties[key] === "string") {
49
50
  filter.where = {
50
51
  ...filter.where,
51
52
  [key]: (0, typeorm_1.Like)(`%${typedEntityProperties[key]}%`),
52
53
  };
53
54
  }
54
- });
55
+ }
55
56
  if (orderBy) {
56
57
  filter.order = {
57
- [orderBy]: orderDirection || constant_1.API_FUNCTION_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,
58
+ [orderBy]: orderDirection || constant_1.FUNCTION_API_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,
58
59
  };
59
60
  }
60
61
  if ("createdAt" in options.model.prototype) {
@@ -119,9 +120,9 @@ function ApiFunctionGetList(options) {
119
120
  }
120
121
  const repository = this.repository;
121
122
  if (!repository) {
122
- throw new Error("Repository is not available in this context");
123
+ throw (0, utility_1.ErrorException)("Repository is not available in this context");
123
124
  }
124
- return executor(repository, options.model, properties, filter);
125
+ return executor({ entity: options.model, filter, properties, repository });
125
126
  };
126
127
  return descriptor;
127
128
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-list.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get-list.decorator.ts"],"names":[],"mappings":";;AA8CA,gDAuGC;AArJD,2CAAgG;AAChG,qCAA0E;AAE1E,gDAAoE;AACpE,wCAAmD;AAEnD,8CAA+C;AAM/C,KAAK,UAAU,QAAQ,CAAuB,UAAyB,EAAE,UAAuB,EAAE,UAA4C,EAAE,MAA0B;IACzK,IAAI,CAAC;QACJ,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAElE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,0BAAiB,CAC1B,IAAA,qBAAW,EAAC;gBACX,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,yBAAkB,CAAC,mBAAmB;aAC5C,CAAC,CACF,CAAC;QACH,CAAC;QAED,OAAO;YAC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ACf,SAAS,EAAE,IAAA,yBAAe,EAAC,aAAa,CAAC;qBACzC,CAAC;gBACH,CAAC;qBAAM,IAAI,WAAW,EAAE,CAAC;oBACxB,MAAM,CAAC,KAAK,GAAG;wBACd,GAAG,MAAM,CAAC,KAAK;wBACf,SAAS,EAAE,IAAA,yBAAe,EAAC,WAAW,CAAC;qBACvC,CAAC;gBACH,CAAC;YACF,CAAC;YAED,IAAI,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC7C,IAAI,cAAc,IAAI,YAAY,EAAE,CAAC;oBACpC,MAAM,CAAC,KAAK,GAAG;wBACd,GAAG,MAAM,CAAC,KAAK;wBACf,UAAU,EAAE,IAAA,iBAAO,EAAC,cAAc,EAAE,YAAY,CAAC;qBACjD,CAAC;gBACH,CAAC;qBAAM,IAAI,cAAc,EAAE,CAAC;oBAC3B,MAAM,CAAC,KAAK,GAAG;wBACd,GAAG,MAAM,CAAC,KAAK;wBACf,UAAU,EAAE,IAAA,yBAAe,EAAC,cAAc,CAAC;qBAC3C,CAAC;gBACH,CAAC;qBAAM,IAAI,YAAY,EAAE,CAAC;oBACzB,MAAM,CAAC,KAAK,GAAG;wBACd,GAAG,MAAM,CAAC,KAAK;wBACf,UAAU,EAAE,IAAA,yBAAe,EAAC,YAAY,CAAC;qBACzC,CAAC;gBACH,CAAC;YACF,CAAC;YAED,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YAChE,CAAC;YAED,OAAO,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAChE,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Between, LessThanOrEqual, Like, MoreThanOrEqual } from \"typeorm\";\n\nimport { API_FUNCTION_DECORATOR_CONSTANT } from \"../../../constant\";\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorString } from \"../../../utility\";\n\nimport type { IApiGetListResponseResult } from \"../../../interface\";\nimport type { TApiFunctionGetListProperties } from \"../../../type\";\nimport type { BaseEntity, FindManyOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends BaseEntity>(repository: Repository<E>, entityType: new () => E, properties: TApiFunctionGetListProperties<E>, filter: FindManyOptions<E>): Promise<IApiGetListResponseResult<E>> {\n\ttry {\n\t\tconst [items, totalCount] = await repository.findAndCount(filter);\n\n\t\tif (items.length === 0) {\n\t\t\tthrow new NotFoundException(\n\t\t\t\tErrorString({\n\t\t\t\t\tentity: entityType,\n\t\t\t\t\ttype: EErrorStringAction.LIST_PAGE_NOT_FOUND,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tcount: items.length,\n\t\t\tcurrentPage: properties.page,\n\t\t\titems,\n\t\t\ttotalCount,\n\t\t\ttotalPages: Math.ceil(totalCount / properties.limit),\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entityType,\n\t\t\t\ttype: EErrorStringAction.FETCHING_LIST_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGetList<E extends BaseEntity>(options: { model: new () => E }) {\n\treturn function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tproperties: TApiFunctionGetListProperties<InstanceType<typeof options.model>>,\n\t\t\trelations: FindOptionsRelations<E>,\n\t\t) {\n\t\t\tconst { createdAtFrom, createdAtTo, limit, orderBy, orderDirection, page, receivedAtFrom, receivedAtTo, updatedAtFrom, updatedAtTo, ...entityProperties } = properties;\n\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations,\n\t\t\t\tskip: limit * (page - 1),\n\t\t\t\ttake: limit,\n\t\t\t\twhere: {},\n\t\t\t};\n\n\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\tObject.keys(typedEntityProperties).forEach((key: string) => {\n\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key]}%`),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (orderBy) {\n\t\t\t\tfilter.order = {\n\t\t\t\t\t[orderBy as never as string]: orderDirection || API_FUNCTION_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (\"createdAt\" in options.model.prototype) {\n\t\t\t\tif (createdAtFrom && createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: Between(createdAtFrom, createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: MoreThanOrEqual(createdAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: LessThanOrEqual(createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"updatedAt\" in options.model.prototype) {\n\t\t\t\tif (updatedAtFrom && updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: Between(updatedAtFrom, updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: MoreThanOrEqual(updatedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: LessThanOrEqual(updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"receivedAt\" in options.model.prototype) {\n\t\t\t\tif (receivedAtFrom && receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: Between(receivedAtFrom, receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: MoreThanOrEqual(receivedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: LessThanOrEqual(receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow new Error(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor(repository, options.model, properties, filter);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
1
+ {"version":3,"file":"get-list.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get-list.decorator.ts"],"names":[],"mappings":";;AAkDA,gDAwGC;AA1JD,2CAAgG;AAChG,qCAA0E;AAE1E,gDAAoE;AACpE,wCAAmD;AAEnD,8CAA+D;AAQ/D,K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AAe,EAAC,YAAY,CAAC;qBACzC,CAAC;gBACH,CAAC;YACF,CAAC;YAED,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAA,wBAAc,EAAC,6CAA6C,CAAC,CAAC;YACrE,CAAC;YAED,OAAO,QAAQ,CAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC/E,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Between, LessThanOrEqual, Like, MoreThanOrEqual } from \"typeorm\";\n\nimport { FUNCTION_API_DECORATOR_CONSTANT } from \"../../../constant\";\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString } from \"../../../utility\";\n\nimport type { IApiBaseEntity, IApiGetListResponseResult } from \"../../../interface\";\n\nimport type { TApiFunctionGetListProperties } from \"../../../type\";\nimport type { IApiFunctionGetListExecutorProperties } from \"../../../type/decorator/api/function/get-list/executor-properties.type\";\nimport type { FindManyOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionGetListExecutorProperties<E>): Promise<IApiGetListResponseResult<E>> {\n\tconst { entity, filter, properties, repository }: IApiFunctionGetListExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst [items, totalCount]: [Array<E>, number] = await repository.findAndCount(filter);\n\n\t\tif (items.length === 0) {\n\t\t\tthrow new NotFoundException(\n\t\t\t\tErrorString({\n\t\t\t\t\tentity: entity,\n\t\t\t\t\ttype: EErrorStringAction.LIST_PAGE_NOT_FOUND,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tcount: items.length,\n\t\t\tcurrentPage: properties.page,\n\t\t\titems,\n\t\t\ttotalCount,\n\t\t\ttotalPages: Math.ceil(totalCount / properties.limit),\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.FETCHING_LIST_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGetList<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tproperties: TApiFunctionGetListProperties<InstanceType<typeof options.model>>,\n\t\t\trelations: FindOptionsRelations<E>,\n\t\t): Promise<IApiGetListResponseResult<E>> {\n\t\t\tconst { createdAtFrom, createdAtTo, limit, orderBy, orderDirection, page, receivedAtFrom, receivedAtTo, updatedAtFrom, updatedAtTo, ...entityProperties }: TApiFunctionGetListProperties<InstanceType<typeof options.model>> = properties;\n\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations,\n\t\t\t\tskip: limit * (page - 1),\n\t\t\t\ttake: limit,\n\t\t\t\twhere: {},\n\t\t\t};\n\n\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\tfor (const key of Object.keys(typedEntityProperties)) {\n\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key] as string}%`),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (orderBy) {\n\t\t\t\tfilter.order = {\n\t\t\t\t\t[orderBy as never as string]: orderDirection || FUNCTION_API_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (\"createdAt\" in options.model.prototype) {\n\t\t\t\tif (createdAtFrom && createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: Between(createdAtFrom, createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: MoreThanOrEqual(createdAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: LessThanOrEqual(createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"updatedAt\" in options.model.prototype) {\n\t\t\t\tif (updatedAtFrom && updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: Between(updatedAtFrom, updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: MoreThanOrEqual(updatedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: LessThanOrEqual(updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"receivedAt\" in options.model.prototype) {\n\t\t\t\tif (receivedAtFrom && receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: Between(receivedAtFrom, receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: MoreThanOrEqual(receivedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: LessThanOrEqual(receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: options.model, filter, properties, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BaseEntity } from "typeorm";
2
- export declare function ApiFunctionGet<E extends BaseEntity>(options: {
1
+ import type { IApiBaseEntity } from "../../../interface";
2
+ export declare function ApiFunctionGet<E extends IApiBaseEntity>(options: {
3
3
  model: new () => E;
4
- }): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
4
+ }): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -5,22 +5,21 @@ const common_1 = require("@nestjs/common");
5
5
  const typeorm_1 = require("typeorm");
6
6
  const enum_1 = require("../../../enum");
7
7
  const utility_1 = require("../../../utility");
8
- async function executor(repository, model, filter) {
9
- console.log("FILTER", filter);
8
+ async function executor(options) {
9
+ const { entity, filter, repository } = options;
10
10
  try {
11
11
  const item = await repository.findOne(filter);
12
12
  if (!item) {
13
- throw new common_1.NotFoundException((0, utility_1.ErrorString)({ entity: model, type: enum_1.EErrorStringAction.NOT_FOUND }));
13
+ throw new common_1.NotFoundException((0, utility_1.ErrorString)({ entity: entity, type: enum_1.EErrorStringAction.NOT_FOUND }));
14
14
  }
15
15
  return item;
16
16
  }
17
17
  catch (error) {
18
- console.log("FUCKIGH", error);
19
18
  if (error instanceof common_1.HttpException) {
20
19
  throw error;
21
20
  }
22
21
  throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
23
- entity: model,
22
+ entity: entity,
24
23
  type: enum_1.EErrorStringAction.FETCHING_ERROR,
25
24
  }));
26
25
  }
@@ -35,20 +34,20 @@ function ApiFunctionGet(options) {
35
34
  if (properties) {
36
35
  const { ...entityProperties } = properties;
37
36
  const typedEntityProperties = entityProperties;
38
- Object.keys(typedEntityProperties).forEach((key) => {
37
+ for (const key of Object.keys(typedEntityProperties)) {
39
38
  if (typeof typedEntityProperties[key] === "string") {
40
39
  filter.where = {
41
40
  ...filter.where,
42
41
  [key]: (0, typeorm_1.Like)(`%${typedEntityProperties[key]}%`),
43
42
  };
44
43
  }
45
- });
44
+ }
46
45
  }
47
46
  const repository = this.repository;
48
47
  if (!repository) {
49
- throw new Error("Repository is not available in this context");
48
+ throw (0, utility_1.ErrorException)("Repository is not available in this context");
50
49
  }
51
- return executor(repository, options.model, filter);
50
+ return executor({ entity: options.model, filter, repository });
52
51
  };
53
52
  return descriptor;
54
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get.decorator.ts"],"names":[],"mappings":";;AAqCA,wCAyCC;AA9ED,2CAAgG;AAChG,qCAA+B;AAE/B,wCAAmD;AACnD,8CAA+C;AAM/C,KAAK,UAAU,QAAQ,CAAuB,UAAyB,EAAE,KAAkB,EAAE,MAAyB;IACrH,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE9B,IAAI,CAAC;QACJ,MAAM,IAAI,GAAa,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,MAAM,IAAI,0BAAiB,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,yBAAkB,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AI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YAChE,CAAC;YAED,OAAO,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Like } from \"typeorm\";\n\nimport { EErrorStringAction } from \"../../../enum\";\nimport { ErrorString } from \"../../../utility\";\n\nimport type { TApiFunctionGetProperties } from \"../../../type\";\n\nimport type { BaseEntity, FindManyOptions, FindOneOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends BaseEntity>(repository: Repository<E>, model: new () => E, filter: FindOneOptions<E>): Promise<E> {\n\tconsole.log(\"FILTER\", filter);\n\n\ttry {\n\t\tconst item: E | null = await repository.findOne(filter);\n\n\t\tif (!item) {\n\t\t\tthrow new NotFoundException(ErrorString({ entity: model, type: EErrorStringAction.NOT_FOUND }));\n\t\t}\n\n\t\treturn item;\n\t} catch (error) {\n\t\tconsole.log(\"FUCKIGH\", error);\n\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: model,\n\t\t\t\ttype: EErrorStringAction.FETCHING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGet<E extends BaseEntity>(options: { model: new () => E }) {\n\treturn function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: string,\n\t\t\tproperties?: TApiFunctionGetProperties<InstanceType<typeof options.model>>,\n\t\t\trelations?: FindOptionsRelations<E>,\n\t\t) {\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations: relations,\n\t\t\t\twhere: { id },\n\t\t\t};\n\n\t\t\tif (properties) {\n\t\t\t\tconst { ...entityProperties } = properties;\n\n\t\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\t\tObject.keys(typedEntityProperties).forEach((key: string) => {\n\t\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key]}%`),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow new Error(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor(repository, options.model, filter);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
1
+ {"version":3,"file":"get.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get.decorator.ts"],"names":[],"mappings":";;AAqCA,wCA0CC;AA/ED,2CAAgG;AAChG,qCAA+B;AAE/B,wCAAmD;AAEnD,8CAA+D;AAO/D,KAAK,UAAU,QAAQ,CAA2B,OAA6C;IAC9F,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAyC,OAAO,CAAC;IAErF,IAAI,CAAC;QACJ,MAAM,IAAI,GAAa,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,MAAM,IAAI,0BAAiB,CAAC,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAkB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE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AAC,CAAC;QACnE,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Like } from \"typeorm\";\n\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString } from \"../../../utility\";\n\nimport type { IApiBaseEntity } from \"../../../interface\";\nimport type { IApiFunctionGetExecutorProperties, TApiFunctionGetProperties } from \"../../../type\";\n\nimport type { FindManyOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionGetExecutorProperties<E>): Promise<E> {\n\tconst { entity, filter, repository }: IApiFunctionGetExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst item: E | null = await repository.findOne(filter);\n\n\t\tif (!item) {\n\t\t\tthrow new NotFoundException(ErrorString({ entity: entity, type: EErrorStringAction.NOT_FOUND }));\n\t\t}\n\n\t\treturn item;\n\t} catch (error) {\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.FETCHING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGet<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: string,\n\t\t\tproperties?: TApiFunctionGetProperties<InstanceType<typeof options.model>>,\n\t\t\trelations?: FindOptionsRelations<E>,\n\t\t): Promise<E> {\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations: relations,\n\t\t\t\twhere: { id },\n\t\t\t};\n\n\t\t\tif (properties) {\n\t\t\t\tconst { ...entityProperties }: TApiFunctionGetProperties<InstanceType<typeof options.model>> = properties;\n\n\t\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\t\tfor (const key of Object.keys(typedEntityProperties)) {\n\t\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key] as string}%`),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: options.model, filter, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BaseEntity } from "typeorm";
2
- export declare function ApiFunctionUpdate<E extends BaseEntity>(options: {
1
+ import type { IApiBaseEntity } from "../../../interface";
2
+ export declare function ApiFunctionUpdate<E extends IApiBaseEntity>(options: {
3
3
  model: new () => E;
4
- }): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
4
+ }): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -5,17 +5,13 @@ const common_1 = require("@nestjs/common");
5
5
  const enum_1 = require("../../../enum");
6
6
  const utility_1 = require("../../../utility");
7
7
  const get_decorator_1 = require("./get.decorator");
8
- async function executor(repository, entityType, id, properties, getFunction) {
8
+ async function executor(options) {
9
+ const { entity, getFunction, id, properties, repository } = options;
9
10
  try {
10
11
  const entity = await getFunction(id.toString());
11
- const allColumns = (0, utility_1.GetEntityColumns)(entityType);
12
- const autoGeneratedColumns = (0, utility_1.GetEntityColumns)(entityType, true);
13
- const filteredProperties = Object.keys(properties).reduce((accumulator, key) => {
14
- if (allColumns.includes(key) && !autoGeneratedColumns.includes(key)) {
15
- accumulator[key] = properties[key];
16
- }
17
- return accumulator;
18
- }, {});
12
+ const allColumns = (0, utility_1.GetEntityColumns)({ entity: entity, shouldTakeGeneratedOnly: false });
13
+ const autoGeneratedColumns = (0, utility_1.GetEntityColumns)({ entity: entity, shouldTakeGeneratedOnly: true });
14
+ const filteredProperties = Object.fromEntries(Object.entries(properties).filter(([key]) => allColumns.includes(key) && !autoGeneratedColumns.includes(key)));
19
15
  const updatedEntity = repository.merge(entity, filteredProperties);
20
16
  return await repository.save(updatedEntity);
21
17
  }
@@ -25,7 +21,7 @@ async function executor(repository, entityType, id, properties, getFunction) {
25
21
  throw error;
26
22
  }
27
23
  throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
28
- entity: entityType,
24
+ entity: entity,
29
25
  type: enum_1.EErrorStringAction.UPDATING_ERROR,
30
26
  }));
31
27
  }
@@ -37,12 +33,12 @@ function ApiFunctionUpdate(options) {
37
33
  descriptor.value = async function (id, properties) {
38
34
  const repository = this.repository;
39
35
  if (!repository) {
40
- throw new Error("Repository is not available in this context");
36
+ throw (0, utility_1.ErrorException)("Repository is not available in this context");
41
37
  }
42
38
  if (!getFunction) {
43
39
  const getDescriptor = {
44
40
  value: function () {
45
- return Promise.reject(new Error("Not implemented"));
41
+ return Promise.reject((0, utility_1.ErrorException)("Not implemented"));
46
42
  },
47
43
  };
48
44
  getDecorator(this, "get", getDescriptor);
@@ -50,10 +46,10 @@ function ApiFunctionUpdate(options) {
50
46
  getFunction = getDescriptor.value.bind(this);
51
47
  }
52
48
  else {
53
- throw new Error("Get function is not properly decorated");
49
+ throw (0, utility_1.ErrorException)("Get function is not properly decorated");
54
50
  }
55
51
  }
56
- return executor(repository, options.model, id, properties, getFunction);
52
+ return executor({ entity: new options.model(), getFunction, id, properties, repository });
57
53
  };
58
54
  return descriptor;
59
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":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AU;YAClB,IAAI,EAAE,yBAAkB,CAAC,cAAc;SACvC,CAAC,CACF,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAgB,iBAAiB,CAAuB,OAA+B;IACtF,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAClF,MAAM,YAAY,GAAG,IAAA,8BAAc,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9D,IAAI,WAAkF,CAAC;QAEvF,UAAU,CAAC,KAAK,GAAG,KAAK,WAIvB,EAAmB,EACnB,UAA4E;YAE5E,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YAChE,CAAC;YAED,IAAI,CAAC,WAAW,EAAE,CAAC;gBAClB,MAAM,aAAa,GAAmG;oBACrH,KAAK,EAAE;wBACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;oBACrD,CAAC;iBACD,CAAC;gBACF,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;gBAEzC,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;oBACzB,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;gBAC3D,CAAC;YACF,CAAC;YAED,OAAO,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException } from \"@nestjs/common\";\n\nimport { EErrorStringAction } from \"../../../enum\";\nimport { ErrorString, GetEntityColumns } from \"../../../utility\";\n\nimport { ApiFunctionGet } from \"./get.decorator\";\n\nimport type { TApiFunctionGetProperties, TApiFunctionUpdateProperties } from \"../../../type\";\n\nimport type { BaseEntity, DeepPartial, Repository } from \"typeorm\";\n\nasync function executor<E extends BaseEntity>(repository: Repository<E>, entityType: new () => E, id: number | string, properties: TApiFunctionUpdateProperties<E>, getFunction: (id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>): Promise<E> {\n\ttry {\n\t\tconst entity = await getFunction(id.toString());\n\n\t\tconst allColumns = GetEntityColumns(entityType);\n\t\tconst autoGeneratedColumns = GetEntityColumns(entityType, true);\n\n\t\tconst filteredProperties = Object.keys(properties).reduce((accumulator, key) => {\n\t\t\tif (allColumns.includes(key as keyof E) && !autoGeneratedColumns.includes(key as keyof E)) {\n\t\t\t\t(accumulator as any)[key] = (properties as any)[key];\n\t\t\t}\n\n\t\t\treturn accumulator;\n\t\t}, {} as DeepPartial<E>);\n\n\t\tconst updatedEntity = repository.merge(entity, filteredProperties);\n\n\t\treturn await repository.save(updatedEntity);\n\t} catch (error) {\n\t\tconsole.log(error);\n\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entityType,\n\t\t\t\ttype: EErrorStringAction.UPDATING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionUpdate<E extends BaseEntity>(options: { model: new () => E }) {\n\treturn function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tconst getDecorator = ApiFunctionGet({ model: options.model });\n\t\tlet getFunction: (id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>;\n\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: number | string,\n\t\t\tproperties: TApiFunctionUpdateProperties<InstanceType<typeof options.model>>,\n\t\t) {\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow new Error(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\tif (!getFunction) {\n\t\t\t\tconst getDescriptor: TypedPropertyDescriptor<(id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>> = {\n\t\t\t\t\tvalue: function () {\n\t\t\t\t\t\treturn Promise.reject(new Error(\"Not implemented\"));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tgetDecorator(this, \"get\", getDescriptor);\n\n\t\t\t\tif (getDescriptor.value) {\n\t\t\t\t\tgetFunction = getDescriptor.value.bind(this);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"Get function is not properly decorated\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn executor(repository, options.model, id, properties, getFunction);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
1
+ {"version":3,"file":"update.decorator.js","sourceRoot":"/","sources":["decorator/api/function/update.decorator.ts"],"names":[],"mappings":";;AA2CA,8CAuCC;AAlFD,2CAA6E;AAE7E,wCAAmD;AAEnD,8CAAiF;AAEjF,mDAAiD;AAOjD,KAAK,UAAU,QAAQ,CAA2B,OAAgD;IACjG,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,GAA4C,OAAO,CAAC;IAE7G,IAAI,CAAC;QACJ,MAAM,MAAM,GAAM,MAAM,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEnD,MAAM,UAAU,GAAmB,IAAA,0BAAgB,EAAI,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3G,MAAM,oBAAoB,GAAmB,IAAA,0BAAgB,EAAI,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpH,MAAM,kBAAkB,GAAmB,MAAM,CAAC,WAAW,C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BAAc,EAAC,iBAAiB,CAAC,CAAC,CAAC;oBAC1D,CAAC;iBACD,CAAC;gBACF,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;gBAEzC,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;oBACzB,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAA,wBAAc,EAAC,wCAAwC,CAAC,CAAC;gBAChE,CAAC;YACF,CAAC;YAED,OAAO,QAAQ,CAAI,EAAE,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException } from \"@nestjs/common\";\n\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString, GetEntityColumns } from \"../../../utility\";\n\nimport { ApiFunctionGet } from \"./get.decorator\";\n\nimport type { IApiBaseEntity } from \"../../../interface\";\nimport type { IApiFunctionUpdateExecutorProperties, TApiFunctionGetProperties, TApiFunctionUpdateProperties } from \"../../../type\";\n\nimport type { DeepPartial, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionUpdateExecutorProperties<E>): Promise<E> {\n\tconst { entity, getFunction, id, properties, repository }: IApiFunctionUpdateExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst entity: E = await getFunction(id.toString());\n\n\t\tconst allColumns: Array<keyof E> = GetEntityColumns<E>({ entity: entity, shouldTakeGeneratedOnly: false });\n\t\tconst autoGeneratedColumns: Array<keyof E> = GetEntityColumns<E>({ entity: entity, shouldTakeGeneratedOnly: true });\n\n\t\tconst filteredProperties: DeepPartial<E> = Object.fromEntries(Object.entries(properties).filter(([key]: [string, unknown]) => allColumns.includes(key as keyof E) && !autoGeneratedColumns.includes(key as keyof E))) as DeepPartial<E>;\n\n\t\tconst updatedEntity: E = repository.merge(entity, filteredProperties);\n\n\t\treturn await repository.save(updatedEntity);\n\t} catch (error) {\n\t\tconsole.log(error);\n\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.UPDATING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionUpdate<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tconst getDecorator: (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor = ApiFunctionGet({ model: options.model });\n\t\tlet getFunction: (id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>;\n\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: number | string,\n\t\t\tproperties: TApiFunctionUpdateProperties<InstanceType<typeof options.model>>,\n\t\t): Promise<E> {\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\tif (!getFunction) {\n\t\t\t\tconst getDescriptor: TypedPropertyDescriptor<(id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>> = {\n\t\t\t\t\tvalue: function () {\n\t\t\t\t\t\treturn Promise.reject(ErrorException(\"Not implemented\"));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tgetDecorator(this, \"get\", getDescriptor);\n\n\t\t\t\tif (getDescriptor.value) {\n\t\t\t\t\tgetFunction = getDescriptor.value.bind(this);\n\t\t\t\t} else {\n\t\t\t\t\tthrow ErrorException(\"Get function is not properly decorated\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: new options.model(), getFunction, id, properties, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
@@ -2,4 +2,3 @@ export * from "./function";
2
2
  export * from "./property";
3
3
  export * from "./service.decorator";
4
4
  export * from "./controller.decorator";
5
- export * from "./route";
@@ -18,5 +18,4 @@ __exportStar(require("./function"), exports);
18
18
  __exportStar(require("./property"), exports);
19
19
  __exportStar(require("./service.decorator"), exports);
20
20
  __exportStar(require("./controller.decorator"), exports);
21
- __exportStar(require("./route"), exports);
22
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC;AACvC,0CAAwB","sourcesContent":["export * from \"./function\";\nexport * from \"./property\";\nexport * from \"./service.decorator\";\nexport * from \"./controller.decorator\";\nexport * from \"./route\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC","sourcesContent":["export * from \"./function\";\nexport * from \"./property\";\nexport * from \"./service.decorator\";\nexport * from \"./controller.decorator\";\n"]}
@@ -5,6 +5,7 @@ const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
6
  const throttler_1 = require("@nestjs/throttler");
7
7
  const enum_1 = require("../../enum");
8
+ const utility_1 = require("../../utility");
8
9
  function ApiMethod(options) {
9
10
  let summary = "";
10
11
  if (options.action) {
@@ -123,6 +124,50 @@ function ApiMethod(options) {
123
124
  if (options.throttler) {
124
125
  decorators.push((0, throttler_1.Throttle)({ default: options.throttler }));
125
126
  }
127
+ if (options.responses) {
128
+ if (options.responses.unauthorized) {
129
+ decorators.push((0, swagger_1.ApiUnauthorizedResponse)({
130
+ description: "Unauthorized",
131
+ status: common_1.HttpStatus.UNAUTHORIZED,
132
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.UNAUTHORIZED),
133
+ }));
134
+ }
135
+ if (options.responses.forbidden) {
136
+ decorators.push((0, swagger_1.ApiForbiddenResponse)({
137
+ description: "Forbiddeb",
138
+ status: common_1.HttpStatus.FORBIDDEN,
139
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.FORBIDDEN),
140
+ }));
141
+ }
142
+ if (options.responses.internalServerError) {
143
+ decorators.push((0, swagger_1.ApiInternalServerErrorResponse)({
144
+ description: "Internal Server Error",
145
+ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
146
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.INTERNAL_SERVER_ERROR),
147
+ }));
148
+ }
149
+ if (options.responses.notFound) {
150
+ decorators.push((0, swagger_1.ApiNotFoundResponse)({
151
+ description: "Not Found",
152
+ status: common_1.HttpStatus.NOT_FOUND,
153
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.NOT_FOUND),
154
+ }));
155
+ }
156
+ if (options.responses.badRequest) {
157
+ decorators.push((0, swagger_1.ApiBadRequestResponse)({
158
+ description: "Bad Request",
159
+ status: common_1.HttpStatus.BAD_REQUEST,
160
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.BAD_REQUEST),
161
+ }));
162
+ }
163
+ if (options.responses.tooManyRequests) {
164
+ decorators.push((0, swagger_1.ApiTooManyRequestsResponse)({
165
+ description: "Too Many Requests",
166
+ status: common_1.HttpStatus.TOO_MANY_REQUESTS,
167
+ type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.TOO_MANY_REQUESTS),
168
+ }));
169
+ }
170
+ }
126
171
  switch (options.method) {
127
172
  case common_1.RequestMethod.GET: {
128
173
  decorators.push((0, common_1.Get)(options.path));
@@ -148,6 +193,19 @@ function ApiMethod(options) {
148
193
  throw new Error(`ApiMethod error: Method ${options.method} is not supported`);
149
194
  }
150
195
  }
196
+ if (options.authentication) {
197
+ decorators.push((0, common_1.UseGuards)(options.authentication.guard));
198
+ if (options.authentication?.bearerStrategies?.length) {
199
+ for (const strategy of options.authentication?.bearerStrategies) {
200
+ decorators.push((0, swagger_1.ApiBearerAuth)(strategy));
201
+ }
202
+ }
203
+ if (options.authentication?.securityStrategies?.length) {
204
+ for (const strategy of options.authentication.securityStrategies) {
205
+ decorators.push((0, swagger_1.ApiSecurity)(strategy));
206
+ }
207
+ }
208
+ }
151
209
  return (0, common_1.applyDecorators)(...decorators);
152
210
  }
153
211
  //# sourceMappingURL=method.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"method.decorator.js","sourceRoot":"/","sources":["decorator/api/method.decorator.ts"],"names":[],"mappings":";;AAeA,8BAkSC;AAjTD,2CAAyG;AACzG,6CAA4D;AAC5D,iDAA6C;AAE7C,qCAAwC;AAWxC,SAAgB,SAAS,CAA2B,OAAgC;IACnF,IAAI,OAAO,GAAW,EAAE,CAAC;IAEzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,KAAK,iBAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAA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AAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAgED,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,sBAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,UAAU,CAAC,IAAI,CAAC,IAAA,YAAG,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEnC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YACzB,UAAU,CAAC,IAAI,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEpC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1B,UAAU,CAAC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAErC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,UAAU,CAAC,IAAI,CAAC,IAAA,YAAG,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEnC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3B,UAAU,CAAC,IAAI,CAAC,IAAA,eAAM,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEtC,MAAM;QACP,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,MAAM,mBAAmB,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;IAwBD,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { applyDecorators, Delete, Get, HttpCode, Patch, Post, Put, RequestMethod } from \"@nestjs/common\";\nimport { ApiOperation, ApiResponse } from \"@nestjs/swagger\";\nimport { Throttle } from \"@nestjs/throttler\";\n\nimport { EApiAction } from \"../../enum\";\n\nimport type { IApiBaseEntity, IApiMethodProperties } from \"../../interface\";\n// import { ExceptionBadRequestDTO } from \"../../dto/exception/bad-request.dto\";\n\n/* import { ExceptionForbiddenDTO } from \"../../dto/exception/forbidden.dto\";\nimport { ExceptionInternalServerErrorDTO } from \"../../dto/exception/internal-server-error.dto\";\nimport { ExceptionNotFoundDTO } from \"../../dto/exception/not-found.dto\";\nimport { ExceptionTooManyRequestsDTO } from \"../../dto/exception/too-many-requests.dto\";\nimport { ExceptionUnauthorizedDTO } from \"../../dto/exception/unauthorized.dto\";*/\n\nexport function ApiMethod<T extends IApiBaseEntity>(options: IApiMethodProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void {\n\tlet summary: string = \"\";\n\n\tif (options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\tsummary = `Creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\tsummary = `Updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\tsummary = `Deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\tsummary = `Partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\tsummary = `Fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\tsummary = `Registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\tsummary = `Authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\tsummary = `Confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\tsummary = `Refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\tsummary = `Fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!options.description && options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\toptions.description = `This method is used for creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\toptions.description = `This method is used for updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\toptions.description = `This method is used for deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\toptions.description = `This method is used for partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\toptions.description = `This method is used for registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\toptions.description = `This method is used for authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\toptions.description = `This method is used for confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\toptions.description = `This method is used for refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst decorators: Array<MethodDecorator> = [\n\t\tApiOperation({ description: options.description, summary }),\n\t\tApiResponse({\n\t\t\tdescription: \"Success\",\n\t\t\tstatus: options.httpCode,\n\t\t\ttype: options.responseType,\n\t\t}),\n\t\tHttpCode(options.httpCode),\n\t];\n\n\tif (options.throttler) {\n\t\tdecorators.push(Throttle({ default: options.throttler }));\n\t}\n\n\t/* if (options.responses) {\n\t\tif (options.responses.unauthorized) {\n\t\t\tdecorators.push(\n\t\t\t\tApiUnauthorizedResponse({\n\t\t\t\t\tdescription: \"Unauthorized\",\n\t\t\t\t\tstatus: HttpStatus.UNAUTHORIZED,\n\t\t\t\t\ttype: ExceptionUnauthorizedDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.forbidden) {\n\t\t\tdecorators.push(\n\t\t\t\tApiForbiddenResponse({\n\t\t\t\t\tdescription: \"Forbidden\",\n\t\t\t\t\tstatus: HttpStatus.FORBIDDEN,\n\t\t\t\t\ttype: ExceptionForbiddenDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.internalServerError) {\n\t\t\tdecorators.push(\n\t\t\t\tApiInternalServerErrorResponse({\n\t\t\t\t\tdescription: \"Internal Server Error\",\n\t\t\t\t\tstatus: HttpStatus.INTERNAL_SERVER_ERROR,\n\t\t\t\t\ttype: ExceptionInternalServerErrorDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.notFound) {\n\t\t\tdecorators.push(\n\t\t\t\tApiNotFoundResponse({\n\t\t\t\t\tdescription: \"Not Found\",\n\t\t\t\t\tstatus: HttpStatus.NOT_FOUND,\n\t\t\t\t\ttype: ExceptionNotFoundDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.badRequest) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Bad Request\",\n\t\t\t\t\tstatus: HttpStatus.BAD_REQUEST,\n\t\t\t\t\ttype: ExceptionBadRequestDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.tooManyRequests) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Too Many Requests\",\n\t\t\t\t\tstatus: HttpStatus.TOO_MANY_REQUESTS,\n\t\t\t\t\ttype: ExceptionTooManyRequestsDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}*/\n\n\tswitch (options.method) {\n\t\tcase RequestMethod.GET: {\n\t\t\tdecorators.push(Get(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.POST: {\n\t\t\tdecorators.push(Post(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PATCH: {\n\t\t\tdecorators.push(Patch(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PUT: {\n\t\t\tdecorators.push(Put(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.DELETE: {\n\t\t\tdecorators.push(Delete(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`ApiMethod error: Method ${options.method} is not supported`);\n\t\t}\n\t}\n\n\t/* if (options.authentication) {\n switch (options.authentication) {\n case EApiAuthenticationType.USER: {\n decorators.push(ApiBearerAuth(\"userAuthorization\"), isUser());\n\n break;\n }\n\n case EApiAuthenticationType.ADMIN: {\n decorators.push(ApiBearerAuth(\"adminAuthorization\"), isAdminUser());\n\n break;\n }\n\n case EApiAuthenticationType.ACCOUNT: {\n decorators.push(ApiBearerAuth(\"accountAuthorization\"), ApiSecurity(\"accountRequestSignature\"), ApiSecurity(\"accountRequestTimestamp\"), isAccount());\n\n break;\n }\n }\n }*/\n\n\treturn applyDecorators(...decorators);\n}\n"]}
1
+ {"version":3,"file":"method.decorator.js","sourceRoot":"/","sources":["decorator/api/method.decorator.ts"],"names":[],"mappings":";;AAUA,8BA4RC;AAtSD,2CAAgI;AAChI,6CAA+O;AAC/O,iDAA6C;AAE7C,qCAAwC;AAExC,2CAAqD;AAIrD,SAAgB,SAAS,CAA2B,OAAgC;IACnF,IAAI,OAAO,GAAW,EAAE,CAAC;IAEzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,KAAK,iBAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAA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Post, Put, RequestMethod, UseGuards } from \"@nestjs/common\";\nimport { ApiBadRequestResponse, ApiBearerAuth, ApiForbiddenResponse, ApiInternalServerErrorResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiSecurity, ApiTooManyRequestsResponse, ApiUnauthorizedResponse } from \"@nestjs/swagger\";\nimport { Throttle } from \"@nestjs/throttler\";\n\nimport { EApiAction } from \"../../enum\";\n\nimport { DtoGenerateException } from \"../../utility\";\n\nimport type { IApiBaseEntity, IApiMethodProperties } from \"../../interface\";\n\nexport function ApiMethod<T extends IApiBaseEntity>(options: IApiMethodProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void {\n\tlet summary: string = \"\";\n\n\tif (options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\tsummary = `Creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\tsummary = `Updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\tsummary = `Deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\tsummary = `Partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\tsummary = `Fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\tsummary = `Registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\tsummary = `Authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\tsummary = `Confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\tsummary = `Refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\tsummary = `Fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!options.description && options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\toptions.description = `This method is used for creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\toptions.description = `This method is used for updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\toptions.description = `This method is used for deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\toptions.description = `This method is used for partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\toptions.description = `This method is used for registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\toptions.description = `This method is used for authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\toptions.description = `This method is used for confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\toptions.description = `This method is used for refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst decorators: Array<MethodDecorator> = [\n\t\tApiOperation({ description: options.description, summary }),\n\t\tApiResponse({\n\t\t\tdescription: \"Success\",\n\t\t\tstatus: options.httpCode,\n\t\t\ttype: options.responseType,\n\t\t}),\n\t\tHttpCode(options.httpCode),\n\t];\n\n\tif (options.throttler) {\n\t\tdecorators.push(Throttle({ default: options.throttler }));\n\t}\n\n\tif (options.responses) {\n\t\tif (options.responses.unauthorized) {\n\t\t\tdecorators.push(\n\t\t\t\tApiUnauthorizedResponse({\n\t\t\t\t\tdescription: \"Unauthorized\",\n\t\t\t\t\tstatus: HttpStatus.UNAUTHORIZED,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.UNAUTHORIZED),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.forbidden) {\n\t\t\tdecorators.push(\n\t\t\t\tApiForbiddenResponse({\n\t\t\t\t\tdescription: \"Forbiddeb\",\n\t\t\t\t\tstatus: HttpStatus.FORBIDDEN,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.FORBIDDEN),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.internalServerError) {\n\t\t\tdecorators.push(\n\t\t\t\tApiInternalServerErrorResponse({\n\t\t\t\t\tdescription: \"Internal Server Error\",\n\t\t\t\t\tstatus: HttpStatus.INTERNAL_SERVER_ERROR,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.INTERNAL_SERVER_ERROR),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.notFound) {\n\t\t\tdecorators.push(\n\t\t\t\tApiNotFoundResponse({\n\t\t\t\t\tdescription: \"Not Found\",\n\t\t\t\t\tstatus: HttpStatus.NOT_FOUND,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.NOT_FOUND),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.badRequest) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Bad Request\",\n\t\t\t\t\tstatus: HttpStatus.BAD_REQUEST,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.BAD_REQUEST),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.tooManyRequests) {\n\t\t\tdecorators.push(\n\t\t\t\tApiTooManyRequestsResponse({\n\t\t\t\t\tdescription: \"Too Many Requests\",\n\t\t\t\t\tstatus: HttpStatus.TOO_MANY_REQUESTS,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.TOO_MANY_REQUESTS),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tswitch (options.method) {\n\t\tcase RequestMethod.GET: {\n\t\t\tdecorators.push(Get(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.POST: {\n\t\t\tdecorators.push(Post(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PATCH: {\n\t\t\tdecorators.push(Patch(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PUT: {\n\t\t\tdecorators.push(Put(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.DELETE: {\n\t\t\tdecorators.push(Delete(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`ApiMethod error: Method ${options.method} is not supported`);\n\t\t}\n\t}\n\n\tif (options.authentication) {\n\t\tdecorators.push(UseGuards(options.authentication.guard));\n\n\t\tif (options.authentication?.bearerStrategies?.length) {\n\t\t\tfor (const strategy of options.authentication?.bearerStrategies) {\n\t\t\t\tdecorators.push(ApiBearerAuth(strategy));\n\t\t\t}\n\t\t}\n\n\t\tif (options.authentication?.securityStrategies?.length) {\n\t\t\tfor (const strategy of options.authentication.securityStrategies) {\n\t\t\t\tdecorators.push(ApiSecurity(strategy));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn applyDecorators(...decorators);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"date.decorator.js","sourceRoot":"/","sources":["decorator/api/property/date.decorator.ts"],"names":[],"mappings":";;AAmEA,0CA2BC;AA9FD,2CAAiD;AAEjD,yDAAyC;AAEzC,gDAAoD;AACpD,wCAA2E;AAE3E,yDAAuD;AAIvD,SAAS,cAAc,CAAC,IAA0B;IACjD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,2BAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,OAAO,eAAe,CAAC;QACxB,CAAC;QAED,KAAK,2BAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,OAAO,kBAAkB,CAAC;QAC3B,CAAC;QAED,KAAK,2BAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC3C,OAAO,gBAAgB,CAAC;QACzB,CAAC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AM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;AACF,CAAC","sourcesContent":["import { applyDecorators } from \"@nestjs/common\";\n\nimport { Type } from \"class-transformer\";\n\nimport { NUMBER_CONSTANT } from \"../../../constant\";\nimport { EApiPropertyDataType, EApiPropertyDateType } from \"../../../enum\";\n\nimport { ApiPropertyString } from \"./string.decorator\";\n\nimport type { IApiBaseEntity, IApiPropertyDateProperties, IApiPropertyStringProperties } from \"../../../interface\";\n\nfunction getDescription(type: EApiPropertyDateType): string {\n\tswitch (type) {\n\t\tcase EApiPropertyDateType.CREATED: {\n\t\t\treturn \"creation date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED: {\n\t\t\treturn \"last update date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_FROM: {\n\t\t\treturn \"createdAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_TO: {\n\t\t\treturn \"createdAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_TO: {\n\t\t\treturn \"updatedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_FROM: {\n\t\t\treturn \"updatedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.EXPIRES_IN: {\n\t\t\treturn \"expiration date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.REFRESH_IN: {\n\t\t\treturn \"refresh date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.DATE: {\n\t\t\treturn \"date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_FROM: {\n\t\t\treturn \"receivedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_TO: {\n\t\t\treturn \"receivedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT: {\n\t\t\treturn \"receivedAt date\";\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn \"\";\n\t\t}\n\t}\n}\n\nexport function ApiPropertyDate<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void {\n\tvalidateOptions<T>(properties);\n\n\tconst startOfYearUTCDate: string = new Date(Date.UTC(new Date().getUTCFullYear(), 0, 1, 0, 0, 0, 0)).toISOString();\n\n\tconst apiPropertyStringOptions: IApiPropertyStringProperties<T> = {\n\t\tdescription: getDescription(properties.type),\n\t\tentity: properties.entity,\n\t\texample: startOfYearUTCDate,\n\t\texpose: properties.expose,\n\t\tformat: EApiPropertyDataType.DATE_TIME,\n\t\tmaxLength: startOfYearUTCDate.length,\n\t\tminLength: startOfYearUTCDate.length,\n\t\tnullable: properties.nullable,\n\t\tpattern: \"/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/\",\n\t\trequired: !properties.response && properties.required,\n\t\tresponse: properties.response,\n\t\ttype: EApiPropertyDataType.DATE_TIME,\n\t};\n\n\tconst decorators: Array<PropertyDecorator> = [ApiPropertyString({ ...apiPropertyStringOptions })];\n\n\tif (!properties.response) {\n\t\tdecorators.push(Type(() => Date));\n\t}\n\n\treturn applyDecorators(...decorators);\n}\n\nfunction validateOptions<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): void {\n\tconst errors: Array<string> = [];\n\n\tif (!properties.response && typeof properties.required !== \"boolean\") {\n\t\terrors.push(\"Required is not defined\");\n\t}\n\n\tif (properties.response && properties.required) {\n\t\terrors.push(\"Required is defined for response\");\n\t}\n\n\tif (errors.length > NUMBER_CONSTANT.ZERO_LIST_LENGTH) {\n\t\tthrow new Error(`ApiPropertyDate error: ${errors.join(\"\\n\")}`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"date.decorator.js","sourceRoot":"/","sources":["decorator/api/property/date.decorator.ts"],"names":[],"mappings":";;AAmEA,0CA0BC;AA7FD,2CAAiD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AAI,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,0BAAe,CAAC,gBAAgB,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;AACF,CAAC","sourcesContent":["import { applyDecorators } from \"@nestjs/common\";\n\nimport { Type } from \"class-transformer\";\n\nimport { NUMBER_CONSTANT } from \"../../../constant\";\nimport { EApiPropertyDataType, EApiPropertyDateType } from \"../../../enum\";\n\nimport { ApiPropertyString } from \"./string.decorator\";\n\nimport type { IApiBaseEntity, IApiPropertyDateProperties, IApiPropertyStringProperties } from \"../../../interface\";\n\nfunction getDescription(type: EApiPropertyDateType): string {\n\tswitch (type) {\n\t\tcase EApiPropertyDateType.CREATED: {\n\t\t\treturn \"creation date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED: {\n\t\t\treturn \"last update date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_FROM: {\n\t\t\treturn \"createdAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_TO: {\n\t\t\treturn \"createdAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_TO: {\n\t\t\treturn \"updatedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_FROM: {\n\t\t\treturn \"updatedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.EXPIRES_IN: {\n\t\t\treturn \"expiration date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.REFRESH_IN: {\n\t\t\treturn \"refresh date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.DATE: {\n\t\t\treturn \"date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_FROM: {\n\t\t\treturn \"receivedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_TO: {\n\t\t\treturn \"receivedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT: {\n\t\t\treturn \"receivedAt date\";\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn \"\";\n\t\t}\n\t}\n}\n\nexport function ApiPropertyDate<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void {\n\tvalidateOptions<T>(properties);\n\n\tconst startOfYearUTCDate: string = new Date(Date.UTC(new Date().getUTCFullYear(), 0, 1, 0, 0, 0, 0)).toISOString();\n\n\tconst apiPropertyStringOptions: IApiPropertyStringProperties<T> = {\n\t\tdescription: getDescription(properties.type),\n\t\tentity: properties.entity,\n\t\texample: startOfYearUTCDate,\n\t\texpose: properties.expose,\n\t\tformat: EApiPropertyDataType.DATE_TIME,\n\t\tmaxLength: startOfYearUTCDate.length,\n\t\tminLength: startOfYearUTCDate.length,\n\t\tnullable: properties.nullable,\n\t\tpattern: \"/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/\",\n\t\trequired: !properties.response && properties.required,\n\t\tresponse: properties.response,\n\t\ttype: EApiPropertyDataType.DATE_TIME,\n\t};\n\tconst decorators: Array<PropertyDecorator> = [ApiPropertyString({ ...apiPropertyStringOptions })];\n\n\tif (!properties.response) {\n\t\tdecorators.push(Type(() => Date));\n\t}\n\n\treturn applyDecorators(...decorators);\n}\n\nfunction validateOptions<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): void {\n\tconst errors: Array<string> = [];\n\n\tif (!properties.response && typeof properties.required !== \"boolean\") {\n\t\terrors.push(\"Required is not defined\");\n\t}\n\n\tif (properties.response && properties.required) {\n\t\terrors.push(\"Required is defined for response\");\n\t}\n\n\tif (errors.length > NUMBER_CONSTANT.ZERO_LIST_LENGTH) {\n\t\tthrow new Error(`ApiPropertyDate error: ${errors.join(\"\\n\")}`);\n\t}\n}\n"]}
@@ -6,7 +6,7 @@ const constant_1 = require("../../../constant");
6
6
  function ApiPropertyDescribe(properties) {
7
7
  return (target, propertyKey) => {
8
8
  const entityName = target.constructor.name;
9
- class_1.MetadataStorage.getInstance().setMetadata(entityName, propertyKey, constant_1.API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT.METADATA_PROPERTY_NAME, properties);
9
+ class_1.MetadataStorage.getInstance().setMetadata(entityName, propertyKey, constant_1.PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_PROPERTY_NAME, properties);
10
10
  };
11
11
  }
12
12
  //# sourceMappingURL=describe.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.decorator.js","sourceRoot":"/","sources":["decorator/api/property/describe.decorator.ts"],"names":[],"mappings":";;AAKA,kDAKC;AAVD,0CAAiD;AACjD,gDAA6E;AAI7E,SAAgB,mBAAmB,CAAC,UAA0C;IAC7E,OAAO,CAAC,MAAwB,EAAE,WAAmB,EAAQ,EAAE;QAC9D,MAAM,UAAU,GAAW,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACnD,uBAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,mDAAwC,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;IACjJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { MetadataStorage } from \"../../../class\";\nimport { API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT } from \"../../../constant\";\n\nimport type { TApiPropertyDescribeProperties } from \"../../../type\";\n\nexport function ApiPropertyDescribe(properties: TApiPropertyDescribeProperties) {\n\treturn (target: Record<any, any>, propertyKey: string): void => {\n\t\tconst entityName: string = target.constructor.name;\n\t\tMetadataStorage.getInstance().setMetadata(entityName, propertyKey, API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT.METADATA_PROPERTY_NAME, properties);\n\t};\n}\n"]}
1
+ {"version":3,"file":"describe.decorator.js","sourceRoot":"/","sources":["decorator/api/property/describe.decorator.ts"],"names":[],"mappings":";;AAKA,kDAKC;AAVD,0CAAiD;AACjD,gDAA6E;AAI7E,SAAgB,mBAAmB,CAAC,UAA0C;IAC7E,OAAO,CAAC,MAAwB,EAAE,WAAmB,EAAQ,EAAE;QAC9D,MAAM,UAAU,GAAW,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACnD,uBAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,mDAAwC,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;IACjJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { MetadataStorage } from \"../../../class\";\nimport { PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT } from \"../../../constant\";\n\nimport type { TApiPropertyDescribeProperties } from \"../../../type\";\n\nexport function ApiPropertyDescribe(properties: TApiPropertyDescribeProperties) {\n\treturn (target: Record<any, any>, propertyKey: string): void => {\n\t\tconst entityName: string = target.constructor.name;\n\t\tMetadataStorage.getInstance().setMetadata(entityName, propertyKey, PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_PROPERTY_NAME, properties);\n\t};\n}\n"]}
@@ -15,6 +15,9 @@ function ApiPropertyString(properties) {
15
15
  validateOptions(properties);
16
16
  const apiPropertyOptions = buildApiPropertyOptions(properties);
17
17
  const decorators = buildDecorators(properties, apiPropertyOptions);
18
+ if (properties.description === "message amount pattern") {
19
+ console.log("PODSOS", apiPropertyOptions);
20
+ }
18
21
  return (0, common_1.applyDecorators)(...decorators);
19
22
  }
20
23
  function buildOptionsFromEnum(properties) {
@@ -44,8 +47,8 @@ function validateOptions(properties) {
44
47
  if ((!properties.response && (!properties.example || !properties.pattern)) || (properties.example && properties.pattern)) {
45
48
  const matches = properties.pattern.match(/^\/(.*?)\/([gimuy]*)$/);
46
49
  if (matches) {
47
- const pattern = matches[constant_1.API_PROPERTY_STRING_INTERFACE_CONSTANT.REGEX_PATTERN_INDEX];
48
- const flags = matches[constant_1.API_PROPERTY_STRING_INTERFACE_CONSTANT.REGEX_FLAGS_INDEX];
50
+ const pattern = matches[constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_PATTERN_INDEX];
51
+ const flags = matches[constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_FLAGS_INDEX];
49
52
  const regex = new RegExp(pattern, flags);
50
53
  if (Array.isArray(properties.example)) {
51
54
  for (const example of properties.example) {
@@ -119,6 +122,7 @@ function buildApiPropertyOptions(properties) {
119
122
  const apiPropertyOptions = {
120
123
  description: `${properties.entity.name} ${properties.description || ""}`,
121
124
  example: properties.example,
125
+ expose: properties.expose,
122
126
  format: properties.format,
123
127
  maxLength: properties.maxLength,
124
128
  minLength: properties.minLength,
@@ -147,10 +151,13 @@ function buildApiPropertyOptions(properties) {
147
151
  function buildDecorators(properties, apiPropertyOptions) {
148
152
  const decorators = [(0, swagger_1.ApiProperty)(apiPropertyOptions)];
149
153
  if (properties.response) {
150
- decorators.push(swagger_1.ApiResponseProperty);
151
- if (properties.expose) {
154
+ decorators.push((0, swagger_1.ApiResponseProperty)());
155
+ if (properties.expose === undefined || properties.expose) {
152
156
  decorators.push((0, class_transformer_1.Expose)());
153
157
  }
158
+ else {
159
+ decorators.push((0, class_transformer_1.Exclude)());
160
+ }
154
161
  }
155
162
  else if (properties.isArray) {
156
163
  if (!properties.required) {
@@ -204,7 +211,7 @@ function buildDecorators(properties, apiPropertyOptions) {
204
211
  break;
205
212
  }
206
213
  case enum_1.EApiPropertyDataType.IP: {
207
- decorators.push((0, class_validator_1.IsIP)(constant_1.API_PROPERTY_STRING_INTERFACE_CONSTANT.IP_VERSION, { each: true }));
214
+ decorators.push((0, class_validator_1.IsIP)(constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.IP_VERSION, { each: true }));
208
215
  break;
209
216
  }
210
217
  default: {
@@ -257,7 +264,7 @@ function buildDecorators(properties, apiPropertyOptions) {
257
264
  break;
258
265
  }
259
266
  case enum_1.EApiPropertyDataType.IP: {
260
- decorators.push((0, class_validator_1.IsIP)(constant_1.API_PROPERTY_STRING_INTERFACE_CONSTANT.IP_VERSION));
267
+ decorators.push((0, class_validator_1.IsIP)(constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.IP_VERSION));
261
268
  break;
262
269
  }
263
270
  case enum_1.EApiPropertyDataType.DATE_TIME: