@elsikora/nestjs-crud-automator 1.1.1 → 1.2.0

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 (306) hide show
  1. package/dist/class/api/base-controller.class.d.ts +4 -0
  2. package/dist/class/api/base-controller.class.js +10 -0
  3. package/dist/class/api/base-controller.class.js.map +1 -0
  4. package/dist/class/api/base-service.class.d.ts +9 -7
  5. package/dist/class/api/base-service.class.js +11 -2
  6. package/dist/class/api/base-service.class.js.map +1 -1
  7. package/dist/class/api/index.d.ts +1 -0
  8. package/dist/class/api/index.js +1 -0
  9. package/dist/class/api/index.js.map +1 -1
  10. package/dist/class/index.d.ts +1 -0
  11. package/dist/class/index.js +1 -0
  12. package/dist/class/index.js.map +1 -1
  13. package/dist/class/metadata-storage.class.d.ts +8 -0
  14. package/dist/class/metadata-storage.class.js +45 -0
  15. package/dist/class/metadata-storage.class.js.map +1 -0
  16. package/dist/constant/decorator/api/controller.constant.d.ts +3 -0
  17. package/dist/constant/decorator/api/controller.constant.js +8 -0
  18. package/dist/constant/decorator/api/controller.constant.js.map +1 -0
  19. package/dist/constant/decorator/api/index.d.ts +2 -0
  20. package/dist/constant/decorator/api/index.js +2 -0
  21. package/dist/constant/decorator/api/index.js.map +1 -1
  22. package/dist/constant/decorator/api/property-describe.constant.d.ts +3 -0
  23. package/dist/constant/decorator/api/property-describe.constant.js +8 -0
  24. package/dist/constant/decorator/api/property-describe.constant.js.map +1 -0
  25. package/dist/constant/factory/dto/get-list-query.constant.d.ts +7 -0
  26. package/dist/constant/factory/dto/get-list-query.constant.js +14 -0
  27. package/dist/constant/factory/dto/get-list-query.constant.js.map +1 -0
  28. package/dist/constant/factory/dto/index.d.ts +1 -0
  29. package/dist/{type/api/function → constant/factory/dto}/index.js +1 -1
  30. package/dist/constant/factory/dto/index.js.map +1 -0
  31. package/dist/constant/factory/index.d.ts +1 -0
  32. package/dist/constant/factory/index.js +18 -0
  33. package/dist/constant/factory/index.js.map +1 -0
  34. package/dist/constant/index.d.ts +1 -0
  35. package/dist/constant/index.js +1 -0
  36. package/dist/constant/index.js.map +1 -1
  37. package/dist/constant/interface/api/filter.constant.d.ts +1 -1
  38. package/dist/constant/interface/api/filter.constant.js +1 -5
  39. package/dist/constant/interface/api/filter.constant.js.map +1 -1
  40. package/dist/decorator/api/controller.decorator.d.ts +8 -0
  41. package/dist/decorator/api/controller.decorator.js +17 -0
  42. package/dist/decorator/api/controller.decorator.js.map +1 -0
  43. package/dist/decorator/api/function/create.decorator.d.ts +4 -0
  44. package/dist/decorator/api/function/create.decorator.js +44 -0
  45. package/dist/decorator/api/function/create.decorator.js.map +1 -0
  46. package/dist/decorator/api/function/decorator.d.ts +2 -2
  47. package/dist/decorator/api/function/decorator.js +23 -5
  48. package/dist/decorator/api/function/decorator.js.map +1 -1
  49. package/dist/decorator/api/function/delete.decorator.d.ts +4 -0
  50. package/dist/decorator/api/function/delete.decorator.js +52 -0
  51. package/dist/decorator/api/function/delete.decorator.js.map +1 -0
  52. package/dist/decorator/api/function/get-list.decorator.d.ts +1 -2
  53. package/dist/decorator/api/function/get-list.decorator.js +6 -6
  54. package/dist/decorator/api/function/get-list.decorator.js.map +1 -1
  55. package/dist/decorator/api/function/get.decorator.js +5 -7
  56. package/dist/decorator/api/function/get.decorator.js.map +1 -1
  57. package/dist/decorator/api/function/update.decorator.d.ts +4 -0
  58. package/dist/decorator/api/function/update.decorator.js +61 -0
  59. package/dist/decorator/api/function/update.decorator.js.map +1 -0
  60. package/dist/decorator/api/index.d.ts +2 -0
  61. package/dist/decorator/api/index.js +2 -0
  62. package/dist/decorator/api/index.js.map +1 -1
  63. package/dist/decorator/api/method.decorator.js +0 -50
  64. package/dist/decorator/api/method.decorator.js.map +1 -1
  65. package/dist/decorator/api/property/boolean.decorator.js.map +1 -1
  66. package/dist/decorator/api/property/date.decorator.js +1 -1
  67. package/dist/decorator/api/property/date.decorator.js.map +1 -1
  68. package/dist/decorator/api/property/describe.decorator.d.ts +2 -0
  69. package/dist/decorator/api/property/describe.decorator.js +12 -0
  70. package/dist/decorator/api/property/describe.decorator.js.map +1 -0
  71. package/dist/decorator/api/property/index.d.ts +1 -0
  72. package/dist/decorator/api/property/index.js +1 -0
  73. package/dist/decorator/api/property/index.js.map +1 -1
  74. package/dist/decorator/api/property/number.decorator.js +1 -1
  75. package/dist/decorator/api/property/number.decorator.js.map +1 -1
  76. package/dist/decorator/api/property/object.decorator.js.map +1 -1
  77. package/dist/decorator/api/property/string.decorator.js.map +1 -1
  78. package/dist/decorator/api/property/uuid.decorator.js.map +1 -1
  79. package/dist/decorator/api/property/wallet.decorator.js.map +1 -1
  80. package/dist/decorator/api/route/decorator.d.ts +18 -0
  81. package/dist/decorator/api/route/decorator.js +43 -0
  82. package/dist/decorator/api/route/decorator.js.map +1 -0
  83. package/dist/decorator/api/route/get.decorator.d.ts +9 -0
  84. package/dist/decorator/api/route/get.decorator.js +53 -0
  85. package/dist/decorator/api/route/get.decorator.js.map +1 -0
  86. package/dist/decorator/api/route/index.d.ts +2 -0
  87. package/dist/decorator/api/route/index.js +19 -0
  88. package/dist/decorator/api/route/index.js.map +1 -0
  89. package/dist/decorator/api/service.decorator.d.ts +3 -5
  90. package/dist/decorator/api/service.decorator.js +96 -15
  91. package/dist/decorator/api/service.decorator.js.map +1 -1
  92. package/dist/dto/exception/bad-request.dto.js +1 -1
  93. package/dist/dto/exception/bad-request.dto.js.map +1 -1
  94. package/dist/dto/exception/conflict.dto.js +1 -1
  95. package/dist/dto/exception/conflict.dto.js.map +1 -1
  96. package/dist/dto/exception/forbidden.dto.js +1 -1
  97. package/dist/dto/exception/forbidden.dto.js.map +1 -1
  98. package/dist/dto/exception/internal-server-error.dto.js +1 -1
  99. package/dist/dto/exception/internal-server-error.dto.js.map +1 -1
  100. package/dist/dto/exception/not-found.dto.js +1 -1
  101. package/dist/dto/exception/not-found.dto.js.map +1 -1
  102. package/dist/dto/exception/too-many-requests.dto.js +1 -1
  103. package/dist/dto/exception/too-many-requests.dto.js.map +1 -1
  104. package/dist/dto/exception/unauthorized.dto.js +1 -1
  105. package/dist/dto/exception/unauthorized.dto.js.map +1 -1
  106. package/dist/enum/decorator/api/controller/index.d.ts +1 -0
  107. package/dist/enum/decorator/api/controller/index.js +3 -0
  108. package/dist/enum/decorator/api/controller/index.js.map +1 -0
  109. package/dist/enum/decorator/api/dto-type.enum.d.ts +6 -0
  110. package/dist/enum/decorator/api/dto-type.enum.js +11 -0
  111. package/dist/enum/decorator/api/dto-type.enum.js.map +1 -0
  112. package/dist/enum/decorator/api/function/type.enum.d.ts +5 -5
  113. package/dist/enum/decorator/api/function/type.enum.js +4 -4
  114. package/dist/enum/decorator/api/function/type.enum.js.map +1 -1
  115. package/dist/enum/decorator/api/index.d.ts +3 -0
  116. package/dist/enum/decorator/api/index.js +3 -0
  117. package/dist/enum/decorator/api/index.js.map +1 -1
  118. package/dist/enum/decorator/api/property/desribe-type.enum.d.ts +8 -0
  119. package/dist/enum/decorator/api/property/desribe-type.enum.js +13 -0
  120. package/dist/enum/decorator/api/property/desribe-type.enum.js.map +1 -0
  121. package/dist/enum/decorator/api/property/index.d.ts +1 -0
  122. package/dist/enum/decorator/api/property/index.js +1 -0
  123. package/dist/enum/decorator/api/property/index.js.map +1 -1
  124. package/dist/enum/decorator/api/route-type.enum.d.ts +8 -0
  125. package/dist/enum/decorator/api/route-type.enum.js +13 -0
  126. package/dist/enum/decorator/api/route-type.enum.js.map +1 -0
  127. package/dist/factory/api/controller.factory.d.ts +28 -0
  128. package/dist/factory/api/controller.factory.js +203 -0
  129. package/dist/factory/api/controller.factory.js.map +1 -0
  130. package/dist/factory/api/index.d.ts +1 -0
  131. package/dist/factory/api/index.js +18 -0
  132. package/dist/factory/api/index.js.map +1 -0
  133. package/dist/factory/index.d.ts +1 -0
  134. package/dist/factory/index.js +18 -0
  135. package/dist/factory/index.js.map +1 -0
  136. package/dist/helper/index.d.ts +1 -0
  137. package/dist/helper/index.js +3 -0
  138. package/dist/helper/index.js.map +1 -0
  139. package/dist/index.d.ts +2 -0
  140. package/dist/index.js +2 -0
  141. package/dist/index.js.map +1 -1
  142. package/dist/interceptor/correlation-id-response-body.interceptor.js.map +1 -1
  143. package/dist/interface/api-base-entity.interface.d.ts +2 -1
  144. package/dist/interface/api-base-entity.interface.js.map +1 -1
  145. package/dist/interface/decorator/api/base-controller.interface.d.ts +4 -0
  146. package/dist/interface/decorator/api/base-controller.interface.js +3 -0
  147. package/dist/interface/decorator/api/base-controller.interface.js.map +1 -0
  148. package/dist/interface/decorator/api/controller-properties.interface.d.ts +21 -0
  149. package/dist/interface/decorator/api/controller-properties.interface.js +3 -0
  150. package/dist/interface/decorator/api/controller-properties.interface.js.map +1 -0
  151. package/dist/interface/decorator/api/index.d.ts +1 -0
  152. package/dist/interface/decorator/api/index.js +1 -0
  153. package/dist/interface/decorator/api/index.js.map +1 -1
  154. package/dist/interface/decorator/api/method/properties.interface.d.ts +3 -3
  155. package/dist/interface/decorator/api/method/properties.interface.js.map +1 -1
  156. package/dist/interface/decorator/api/property/date-properties.interface.d.ts +1 -1
  157. package/dist/interface/decorator/api/property/date-properties.interface.js.map +1 -1
  158. package/dist/interface/decorator/api/property/object-properties.interface.d.ts +1 -1
  159. package/dist/interface/decorator/api/property/object-properties.interface.js.map +1 -1
  160. package/dist/interface/decorator/api/property/string-properties.interface.d.ts +1 -1
  161. package/dist/interface/decorator/api/property/string-properties.interface.js.map +1 -1
  162. package/dist/interface/entity/column.interface.d.ts +7 -0
  163. package/dist/interface/entity/column.interface.js +3 -0
  164. package/dist/interface/entity/column.interface.js.map +1 -0
  165. package/dist/interface/entity/index.d.ts +2 -0
  166. package/dist/interface/entity/index.js +19 -0
  167. package/dist/interface/entity/index.js.map +1 -0
  168. package/dist/interface/entity/interface.d.ts +7 -0
  169. package/dist/interface/entity/interface.js +3 -0
  170. package/dist/interface/entity/interface.js.map +1 -0
  171. package/dist/interface/index.d.ts +1 -0
  172. package/dist/interface/index.js +1 -0
  173. package/dist/interface/index.js.map +1 -1
  174. package/dist/tsconfig.build.tsbuildinfo +1 -1
  175. package/dist/type/decorator/api/filter/allowed-types.type.d.ts +1 -0
  176. package/dist/type/decorator/api/filter/allowed-types.type.js.map +1 -0
  177. package/dist/type/{api → decorator/api}/filter/extracted-allowed-types.type.d.ts +1 -1
  178. package/dist/type/decorator/api/filter/extracted-allowed-types.type.js.map +1 -0
  179. package/dist/type/decorator/api/filter/field-selector.type.js.map +1 -0
  180. package/dist/type/decorator/api/filter/index.js.map +1 -0
  181. package/dist/type/decorator/api/filter/order-by.type.d.ts +4 -0
  182. package/dist/type/decorator/api/filter/order-by.type.js.map +1 -0
  183. package/dist/type/decorator/api/function/create-properties.type.d.ts +1 -0
  184. package/dist/type/decorator/api/function/create-properties.type.js +3 -0
  185. package/dist/type/decorator/api/function/create-properties.type.js.map +1 -0
  186. package/dist/type/decorator/api/function/get-list-properties.type.d.ts +23 -0
  187. package/dist/type/decorator/api/function/get-list-properties.type.js.map +1 -0
  188. package/dist/type/decorator/api/function/get-properties.type.d.ts +6 -0
  189. package/dist/type/decorator/api/function/get-properties.type.js.map +1 -0
  190. package/dist/type/decorator/api/function/index.d.ts +4 -0
  191. package/dist/type/decorator/api/function/index.js +21 -0
  192. package/dist/type/decorator/api/function/index.js.map +1 -0
  193. package/dist/type/decorator/api/function/update-properties.type.d.ts +1 -0
  194. package/dist/type/decorator/api/function/update-properties.type.js +3 -0
  195. package/dist/type/decorator/api/function/update-properties.type.js.map +1 -0
  196. package/dist/type/{api → decorator/api}/index.d.ts +1 -0
  197. package/dist/type/{api → decorator/api}/index.js +1 -0
  198. package/dist/type/decorator/api/index.js.map +1 -0
  199. package/dist/type/decorator/api/property/describe-properties.type.d.ts +64 -0
  200. package/dist/type/decorator/api/property/describe-properties.type.js +3 -0
  201. package/dist/type/decorator/api/property/describe-properties.type.js.map +1 -0
  202. package/dist/type/decorator/api/property/index.d.ts +1 -0
  203. package/dist/type/decorator/api/property/index.js +18 -0
  204. package/dist/type/decorator/api/property/index.js.map +1 -0
  205. package/dist/type/decorator/index.d.ts +1 -0
  206. package/dist/type/decorator/index.js +18 -0
  207. package/dist/type/decorator/index.js.map +1 -0
  208. package/dist/type/factory/api/controller/index.d.ts +1 -0
  209. package/dist/type/factory/api/controller/index.js +18 -0
  210. package/dist/type/factory/api/controller/index.js.map +1 -0
  211. package/dist/type/factory/api/controller/target-methods.type.d.ts +1 -0
  212. package/dist/type/factory/api/controller/target-methods.type.js +3 -0
  213. package/dist/type/factory/api/controller/target-methods.type.js.map +1 -0
  214. package/dist/type/factory/api/index.d.ts +1 -0
  215. package/dist/type/factory/api/index.js +18 -0
  216. package/dist/type/factory/api/index.js.map +1 -0
  217. package/dist/type/factory/index.d.ts +1 -0
  218. package/dist/type/factory/index.js +18 -0
  219. package/dist/type/factory/index.js.map +1 -0
  220. package/dist/type/index.d.ts +2 -1
  221. package/dist/type/index.js +2 -1
  222. package/dist/type/index.js.map +1 -1
  223. package/dist/utility/api/controller/get-method-name.utility.d.ts +2 -0
  224. package/dist/utility/api/controller/get-method-name.utility.js +9 -0
  225. package/dist/utility/api/controller/get-method-name.utility.js.map +1 -0
  226. package/dist/utility/api/controller/index.d.ts +2 -0
  227. package/dist/utility/api/controller/index.js +19 -0
  228. package/dist/utility/api/controller/index.js.map +1 -0
  229. package/dist/utility/api/controller/write-method.utility.d.ts +3 -0
  230. package/dist/utility/api/controller/write-method.utility.js +13 -0
  231. package/dist/utility/api/controller/write-method.utility.js.map +1 -0
  232. package/dist/utility/api/filter-order-by-from-entity.utility.d.ts +3 -3
  233. package/dist/utility/api/filter-order-by-from-entity.utility.js +15 -12
  234. package/dist/utility/api/filter-order-by-from-entity.utility.js.map +1 -1
  235. package/dist/utility/api/index.d.ts +1 -0
  236. package/dist/utility/api/index.js +1 -0
  237. package/dist/utility/api/index.js.map +1 -1
  238. package/dist/utility/capitalize-string.utility.d.ts +1 -0
  239. package/dist/utility/capitalize-string.utility.js +7 -0
  240. package/dist/utility/capitalize-string.utility.js.map +1 -0
  241. package/dist/utility/dto/analize.utility.d.ts +1 -0
  242. package/dist/utility/dto/analize.utility.js +10 -0
  243. package/dist/utility/dto/analize.utility.js.map +1 -0
  244. package/dist/utility/dto/generate.utility.d.ts +5 -0
  245. package/dist/utility/dto/generate.utility.js +365 -0
  246. package/dist/utility/dto/generate.utility.js.map +1 -0
  247. package/dist/utility/dto/index.d.ts +1 -0
  248. package/dist/utility/dto/index.js +18 -0
  249. package/dist/utility/dto/index.js.map +1 -0
  250. package/dist/utility/error-exception.utility.d.ts +1 -0
  251. package/dist/utility/error-exception.utility.js +7 -0
  252. package/dist/utility/error-exception.utility.js.map +1 -0
  253. package/dist/utility/generate-entity-information.utility.d.ts +2 -0
  254. package/dist/utility/generate-entity-information.utility.js +51 -0
  255. package/dist/utility/generate-entity-information.utility.js.map +1 -0
  256. package/dist/utility/get-entity-columns.utility.d.ts +2 -0
  257. package/dist/utility/get-entity-columns.utility.js +9 -0
  258. package/dist/utility/get-entity-columns.utility.js.map +1 -0
  259. package/dist/utility/index.d.ts +5 -1
  260. package/dist/utility/index.js +5 -1
  261. package/dist/utility/index.js.map +1 -1
  262. package/dist/validator/all-or-none-of-listed-properties.validator.d.ts +5 -0
  263. package/dist/validator/all-or-none-of-listed-properties.validator.js +29 -0
  264. package/dist/validator/all-or-none-of-listed-properties.validator.js.map +1 -0
  265. package/dist/validator/has-at-least-one-and-only-one-of-listed-properties.validator.d.ts +5 -0
  266. package/dist/validator/has-at-least-one-and-only-one-of-listed-properties.validator.js +39 -0
  267. package/dist/validator/has-at-least-one-and-only-one-of-listed-properties.validator.js.map +1 -0
  268. package/dist/validator/has-at-least-one-of-listed-properties.validator.d.ts +5 -0
  269. package/dist/validator/has-at-least-one-of-listed-properties.validator.js +35 -0
  270. package/dist/validator/has-at-least-one-of-listed-properties.validator.js.map +1 -0
  271. package/dist/validator/has-at-least-one-property.validator.d.ts +5 -0
  272. package/dist/validator/has-at-least-one-property.validator.js +23 -0
  273. package/dist/validator/has-at-least-one-property.validator.js.map +1 -0
  274. package/dist/validator/index.d.ts +5 -0
  275. package/dist/validator/index.js +5 -0
  276. package/dist/validator/index.js.map +1 -1
  277. package/dist/validator/only-one-of-listed-properties.validator.d.ts +5 -0
  278. package/dist/validator/only-one-of-listed-properties.validator.js +37 -0
  279. package/dist/validator/only-one-of-listed-properties.validator.js.map +1 -0
  280. package/package.json +5 -3
  281. package/dist/type/api/filter/allowed-types.type.d.ts +0 -1
  282. package/dist/type/api/filter/allowed-types.type.js.map +0 -1
  283. package/dist/type/api/filter/extracted-allowed-types.type.js.map +0 -1
  284. package/dist/type/api/filter/field-selector.type.js.map +0 -1
  285. package/dist/type/api/filter/index.js.map +0 -1
  286. package/dist/type/api/filter/order-by.type.d.ts +0 -5
  287. package/dist/type/api/filter/order-by.type.js.map +0 -1
  288. package/dist/type/api/function/get-list-properties.type.d.ts +0 -23
  289. package/dist/type/api/function/get-list-properties.type.js.map +0 -1
  290. package/dist/type/api/function/get-properties.type.d.ts +0 -6
  291. package/dist/type/api/function/get-properties.type.js.map +0 -1
  292. package/dist/type/api/function/index.d.ts +0 -1
  293. package/dist/type/api/function/index.js.map +0 -1
  294. package/dist/type/api/index.js.map +0 -1
  295. package/dist/utility/create-rest-application.utility.d.ts +0 -3
  296. package/dist/utility/create-rest-application.utility.js +0 -9
  297. package/dist/utility/create-rest-application.utility.js.map +0 -1
  298. /package/dist/type/{api → decorator/api}/filter/allowed-types.type.js +0 -0
  299. /package/dist/type/{api → decorator/api}/filter/extracted-allowed-types.type.js +0 -0
  300. /package/dist/type/{api → decorator/api}/filter/field-selector.type.d.ts +0 -0
  301. /package/dist/type/{api → decorator/api}/filter/field-selector.type.js +0 -0
  302. /package/dist/type/{api → decorator/api}/filter/index.d.ts +0 -0
  303. /package/dist/type/{api → decorator/api}/filter/index.js +0 -0
  304. /package/dist/type/{api → decorator/api}/filter/order-by.type.js +0 -0
  305. /package/dist/type/{api → decorator/api}/function/get-list-properties.type.js +0 -0
  306. /package/dist/type/{api → decorator/api}/function/get-properties.type.js +0 -0
@@ -0,0 +1,4 @@
1
+ import type { BaseEntity } from "typeorm";
2
+ export declare class BaseApiController<E extends BaseEntity> {
3
+ get(_properties?: any): Promise<E>;
4
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseApiController = void 0;
4
+ class BaseApiController {
5
+ get(_properties) {
6
+ return null;
7
+ }
8
+ }
9
+ exports.BaseApiController = BaseApiController;
10
+ //# sourceMappingURL=base-controller.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-controller.class.js","sourceRoot":"/","sources":["class/api/base-controller.class.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAC7B,GAAG,CAAC,WAAiB;QACpB,OAAO,IAAW,CAAC;IACpB,CAAC;CACD;AAJD,8CAIC","sourcesContent":["import type { BaseEntity } from \"typeorm\";\n\nexport class BaseApiController<E extends BaseEntity> {\n\tget(_properties?: any): Promise<E> {\n\t\treturn null as any;\n\t}\n}\n"]}
@@ -1,8 +1,10 @@
1
- import { IApiGetListResponseResult } from "../../interface";
2
- import { BaseEntity } from "typeorm";
3
- import { TApiFunctionGetListProperties } from "../../type";
4
- import { TApiFunctionGetProperties } from "../../type/api/function/get-properties.type";
5
- export declare class BaseApiService<E extends BaseEntity> {
6
- getList(_properties: TApiFunctionGetListProperties<E>): Promise<IApiGetListResponseResult<E>>;
7
- get(_id: string, _properties?: TApiFunctionGetProperties<E>): Promise<E>;
1
+ import type { IApiGetListResponseResult } from "../../interface";
2
+ import type { TApiFunctionCreateProperties, TApiFunctionGetListProperties, TApiFunctionGetProperties, TApiFunctionUpdateProperties } from "../../type";
3
+ import type { FindOptionsRelations } from "typeorm";
4
+ export declare class BaseApiService<E> {
5
+ create(_properties: TApiFunctionCreateProperties<E>): Promise<E>;
6
+ delete(_id: string): Promise<void>;
7
+ get(_id: string, _properties?: TApiFunctionGetProperties<E>, _relations?: FindOptionsRelations<E>): Promise<E>;
8
+ getList(_properties: TApiFunctionGetListProperties<E>, _relations?: FindOptionsRelations<E>): Promise<IApiGetListResponseResult<E>>;
9
+ update(_id: string, _properties: TApiFunctionUpdateProperties<E>): Promise<E>;
8
10
  }
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseApiService = void 0;
4
4
  class BaseApiService {
5
- getList(_properties) {
5
+ create(_properties) {
6
6
  return null;
7
7
  }
8
- get(_id, _properties) {
8
+ delete(_id) {
9
+ return null;
10
+ }
11
+ get(_id, _properties, _relations) {
12
+ return null;
13
+ }
14
+ getList(_properties, _relations) {
15
+ return null;
16
+ }
17
+ update(_id, _properties) {
9
18
  return null;
10
19
  }
11
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-service.class.js","sourceRoot":"/","sources":["class/api/base-service.class.ts"],"names":[],"mappings":";;;AAKA,MAAa,cAAc;IACvB,OAAO,CAAC,WAA6C;QACjD,OAAO,IAAW,CAAC;IACvB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,WAA0C;QACvD,OAAO,IAAW,CAAC;IACvB,CAAC;CACJ;AARD,wCAQC","sourcesContent":["import { IApiGetListResponseResult } from \"../../interface\";\nimport { BaseEntity } from \"typeorm\";\nimport {TApiFunctionGetListProperties} from \"../../type\";\nimport {TApiFunctionGetProperties} from \"../../type/api/function/get-properties.type\";\n\nexport class BaseApiService<E extends BaseEntity> {\n getList(_properties: TApiFunctionGetListProperties<E>): Promise<IApiGetListResponseResult<E>> {\n return null as any;\n }\n\n get(_id: string, _properties?: TApiFunctionGetProperties<E>): Promise<E> {\n return null as any;\n }\n}\n"]}
1
+ {"version":3,"file":"base-service.class.js","sourceRoot":"/","sources":["class/api/base-service.class.ts"],"names":[],"mappings":";;;AAMA,MAAa,cAAc;IAC1B,MAAM,CAAC,WAA4C;QAClD,OAAO,IAAW,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,GAAW;QACjB,OAAO,IAAW,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,WAA0C,EAAE,UAAoC;QAChG,OAAO,IAAW,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,WAA6C,EAAE,UAAoC;QAC1F,OAAO,IAAW,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,WAA4C;QAC/D,OAAO,IAAW,CAAC;IACpB,CAAC;CACD;AApBD,wCAoBC","sourcesContent":["import type { IApiGetListResponseResult } from \"../../interface\";\n\nimport type { TApiFunctionCreateProperties, TApiFunctionGetListProperties, TApiFunctionGetProperties, TApiFunctionUpdateProperties } from \"../../type\";\n\nimport type { FindOptionsRelations } from \"typeorm\";\n\nexport class BaseApiService<E> {\n\tcreate(_properties: TApiFunctionCreateProperties<E>): Promise<E> {\n\t\treturn null as any;\n\t}\n\n\tdelete(_id: string): Promise<void> {\n\t\treturn null as any;\n\t}\n\n\tget(_id: string, _properties?: TApiFunctionGetProperties<E>, _relations?: FindOptionsRelations<E>): Promise<E> {\n\t\treturn null as any;\n\t}\n\n\tgetList(_properties: TApiFunctionGetListProperties<E>, _relations?: FindOptionsRelations<E>): Promise<IApiGetListResponseResult<E>> {\n\t\treturn null as any;\n\t}\n\n\tupdate(_id: string, _properties: TApiFunctionUpdateProperties<E>): Promise<E> {\n\t\treturn null as any;\n\t}\n}\n"]}
@@ -1 +1,2 @@
1
1
  export * from "./base-service.class";
2
+ export * from "./base-controller.class";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-service.class"), exports);
18
+ __exportStar(require("./base-controller.class"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["class/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC","sourcesContent":["export * from \"./base-service.class\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["class/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,0DAAwC","sourcesContent":["export * from \"./base-service.class\";\nexport * from \"./base-controller.class\";\n"]}
@@ -1 +1,2 @@
1
1
  export * from "./api";
2
+ export * from "./metadata-storage.class";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api"), exports);
18
+ __exportStar(require("./metadata-storage.class"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["class/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB","sourcesContent":["export * from \"./api\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["class/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2DAAyC","sourcesContent":["export * from \"./api\";\nexport * from \"./metadata-storage.class\";\n"]}
@@ -0,0 +1,8 @@
1
+ export declare class MetadataStorage {
2
+ private static instance;
3
+ private readonly STORAGE;
4
+ static getInstance(): MetadataStorage;
5
+ getAllEntitiesMetadata(): Record<string, Record<string, any>>;
6
+ getMetadata(entityName: string, propertyName?: string, key?: string): any;
7
+ setMetadata(entityName: string, propertyName: string, key: string, value: unknown): void;
8
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetadataStorage = void 0;
4
+ class MetadataStorage {
5
+ static instance;
6
+ STORAGE = new Map();
7
+ static getInstance() {
8
+ if (!MetadataStorage.instance) {
9
+ MetadataStorage.instance = new MetadataStorage();
10
+ }
11
+ return MetadataStorage.instance;
12
+ }
13
+ getAllEntitiesMetadata() {
14
+ const result = {};
15
+ for (const [entityName, entityMetadata] of this.STORAGE.entries()) {
16
+ result[entityName] = Object.fromEntries(entityMetadata);
17
+ }
18
+ return result;
19
+ }
20
+ getMetadata(entityName, propertyName, key) {
21
+ const entityMetadata = this.STORAGE.get(entityName);
22
+ if (!entityMetadata)
23
+ return undefined;
24
+ if (!propertyName)
25
+ return Object.fromEntries(entityMetadata);
26
+ const propertyMetadata = entityMetadata.get(propertyName);
27
+ if (!propertyMetadata)
28
+ return undefined;
29
+ if (!key)
30
+ return propertyMetadata;
31
+ return propertyMetadata[key];
32
+ }
33
+ setMetadata(entityName, propertyName, key, value) {
34
+ if (!this.STORAGE.has(entityName)) {
35
+ this.STORAGE.set(entityName, new Map());
36
+ }
37
+ const entityMetadata = this.STORAGE.get(entityName);
38
+ if (!entityMetadata.has(propertyName)) {
39
+ entityMetadata.set(propertyName, {});
40
+ }
41
+ entityMetadata.get(propertyName)[key] = value;
42
+ }
43
+ }
44
+ exports.MetadataStorage = MetadataStorage;
45
+ //# sourceMappingURL=metadata-storage.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-storage.class.js","sourceRoot":"/","sources":["class/metadata-storage.class.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;IACnB,MAAM,CAAC,QAAQ,CAAkB;IAExB,OAAO,GAAkC,IAAI,GAAG,EAA4B,CAAC;IAEvF,MAAM,CAAC,WAAW;QACxB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC/B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QAClD,CAAC;QAED,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEM,sBAAsB;QAC5B,MAAM,MAAM,GAAwC,EAAE,CAAC;QAEvD,KAAK,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YACnE,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,WAAW,CAAC,UAAkB,EAAE,YAAqB,EAAE,GAAY;QACzE,MAAM,cAAc,GAAiC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAElF,IAAI,CAAC,cAAc;YAAE,OAAO,SAAS,CAAC;QAEtC,IAAI,CAAC,YAAY;YAAE,OAAO,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAC7D,MAAM,gBAAgB,GAAY,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAEnE,IAAI,CAAC,gBAAgB;YAAE,OAAO,SAAS,CAAC;QAExC,IAAI,CAAC,GAAG;YAAE,OAAO,gBAAgB,CAAC;QAIlC,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAEM,WAAW,CAAC,UAAkB,EAAE,YAAoB,EAAE,GAAW,EAAE,KAAc;QACvF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,cAAc,GAAqB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC;QAEvE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACtC,CAAC;QAED,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/C,CAAC;CACD;AApDD,0CAoDC","sourcesContent":["export class MetadataStorage {\n\tprivate static instance: MetadataStorage;\n\n\tprivate readonly STORAGE: Map<string, Map<string, any>> = new Map<string, Map<string, any>>();\n\n\tpublic static getInstance(): MetadataStorage {\n\t\tif (!MetadataStorage.instance) {\n\t\t\tMetadataStorage.instance = new MetadataStorage();\n\t\t}\n\n\t\treturn MetadataStorage.instance;\n\t}\n\n\tpublic getAllEntitiesMetadata(): Record<string, Record<string, any>> {\n\t\tconst result: Record<string, Record<string, any>> = {};\n\n\t\tfor (const [entityName, entityMetadata] of this.STORAGE.entries()) {\n\t\t\tresult[entityName] = Object.fromEntries(entityMetadata);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic getMetadata(entityName: string, propertyName?: string, key?: string): any {\n\t\tconst entityMetadata: Map<string, any> | undefined = this.STORAGE.get(entityName);\n\n\t\tif (!entityMetadata) return undefined;\n\n\t\tif (!propertyName) return Object.fromEntries(entityMetadata);\n\t\tconst propertyMetadata: unknown = entityMetadata.get(propertyName);\n\n\t\tif (!propertyMetadata) return undefined;\n\n\t\tif (!key) return propertyMetadata;\n\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-expect-error\n\t\treturn propertyMetadata[key];\n\t}\n\n\tpublic setMetadata(entityName: string, propertyName: string, key: string, value: unknown): void {\n\t\tif (!this.STORAGE.has(entityName)) {\n\t\t\tthis.STORAGE.set(entityName, new Map());\n\t\t}\n\t\tconst entityMetadata: Map<string, any> = this.STORAGE.get(entityName)!;\n\n\t\tif (!entityMetadata.has(propertyName)) {\n\t\t\tentityMetadata.set(propertyName, {});\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tentityMetadata.get(propertyName)[key] = value;\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const API_CONTROLLER_DECORATOR_CONSTANT: {
2
+ readonly RESERVED_METHOD_PREFIX: string;
3
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_CONTROLLER_DECORATOR_CONSTANT = void 0;
4
+ const RESERVED_METHOD_PREFIX = "apiController";
5
+ exports.API_CONTROLLER_DECORATOR_CONSTANT = {
6
+ RESERVED_METHOD_PREFIX,
7
+ };
8
+ //# sourceMappingURL=controller.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.constant.js","sourceRoot":"/","sources":["constant/decorator/api/controller.constant.ts"],"names":[],"mappings":";;;AAAA,MAAM,sBAAsB,GAAW,eAAe,CAAC;AAE1C,QAAA,iCAAiC,GAE1C;IACH,sBAAsB;CACb,CAAC","sourcesContent":["const RESERVED_METHOD_PREFIX: string = \"apiController\";\n\nexport const API_CONTROLLER_DECORATOR_CONSTANT: {\n\treadonly RESERVED_METHOD_PREFIX: string;\n} = {\n\tRESERVED_METHOD_PREFIX,\n} as const;\n"]}
@@ -1 +1,3 @@
1
1
  export * from "./function.constant";
2
+ export * from "./controller.constant";
3
+ export * from "./property-describe.constant";
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./function.constant"), exports);
18
+ __exportStar(require("./controller.constant"), exports);
19
+ __exportStar(require("./property-describe.constant"), exports);
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC","sourcesContent":["export * from \"./function.constant\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,wDAAsC;AACtC,+DAA6C","sourcesContent":["export * from \"./function.constant\";\nexport * from \"./controller.constant\";\nexport * from \"./property-describe.constant\";\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT: {
2
+ readonly METADATA_PROPERTY_NAME: string;
3
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT = void 0;
4
+ const METADATA_PROPERTY_NAME = "API_PROPERTY_DESCRIBE";
5
+ exports.API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT = {
6
+ METADATA_PROPERTY_NAME,
7
+ };
8
+ //# sourceMappingURL=property-describe.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-describe.constant.js","sourceRoot":"/","sources":["constant/decorator/api/property-describe.constant.ts"],"names":[],"mappings":";;;AAAA,MAAM,sBAAsB,GAAW,uBAAuB,CAAC;AAElD,QAAA,wCAAwC,GAEjD;IACH,sBAAsB;CACb,CAAC","sourcesContent":["const METADATA_PROPERTY_NAME: string = \"API_PROPERTY_DESCRIBE\";\n\nexport const API_PROPERTY_DESCRIBE_DECORATOR_CONSTANT: {\n\treadonly METADATA_PROPERTY_NAME: string;\n} = {\n\tMETADATA_PROPERTY_NAME,\n} as const;\n"]}
@@ -0,0 +1,7 @@
1
+ declare const GET_LIST_QUERY_DTO_FACTOR_CONSTANT: {
2
+ readonly MAXIMUM_LIST_LENGTH: number;
3
+ readonly MAXIMUM_LIST_PAGES_COUNT: number;
4
+ readonly MINIMUM_LIST_LENGTH: number;
5
+ readonly MINIMUM_LIST_PAGES_COUNT: number;
6
+ };
7
+ export default GET_LIST_QUERY_DTO_FACTOR_CONSTANT;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const MINIMUM_LIST_LENGTH = 1;
4
+ const MAXIMUM_LIST_LENGTH = 100;
5
+ const MINIMUM_LIST_PAGES_COUNT = 1;
6
+ const MAXIMUM_LIST_PAGES_COUNT = 100;
7
+ const GET_LIST_QUERY_DTO_FACTOR_CONSTANT = {
8
+ MAXIMUM_LIST_LENGTH,
9
+ MAXIMUM_LIST_PAGES_COUNT,
10
+ MINIMUM_LIST_LENGTH,
11
+ MINIMUM_LIST_PAGES_COUNT,
12
+ };
13
+ exports.default = GET_LIST_QUERY_DTO_FACTOR_CONSTANT;
14
+ //# sourceMappingURL=get-list-query.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-list-query.constant.js","sourceRoot":"/","sources":["constant/factory/dto/get-list-query.constant.ts"],"names":[],"mappings":";;AAAA,MAAM,mBAAmB,GAAW,CAAC,CAAC;AACtC,MAAM,mBAAmB,GAAW,GAAG,CAAC;AACxC,MAAM,wBAAwB,GAAW,CAAC,CAAC;AAC3C,MAAM,wBAAwB,GAAW,GAAG,CAAC;AAE7C,MAAM,kCAAkC,GAKpC;IACA,mBAAmB;IACnB,wBAAwB;IACxB,mBAAmB;IACnB,wBAAwB;CAClB,CAAC;AAEX,kBAAe,kCAAkC,CAAC","sourcesContent":["const MINIMUM_LIST_LENGTH: number = 1;\nconst MAXIMUM_LIST_LENGTH: number = 100;\nconst MINIMUM_LIST_PAGES_COUNT: number = 1;\nconst MAXIMUM_LIST_PAGES_COUNT: number = 100;\n\nconst GET_LIST_QUERY_DTO_FACTOR_CONSTANT: {\n readonly MAXIMUM_LIST_LENGTH: number;\n readonly MAXIMUM_LIST_PAGES_COUNT: number;\n readonly MINIMUM_LIST_LENGTH: number;\n readonly MINIMUM_LIST_PAGES_COUNT: number;\n} = {\n MAXIMUM_LIST_LENGTH,\n MAXIMUM_LIST_PAGES_COUNT,\n MINIMUM_LIST_LENGTH,\n MINIMUM_LIST_PAGES_COUNT,\n} as const;\n\nexport default GET_LIST_QUERY_DTO_FACTOR_CONSTANT;\n"]}
@@ -0,0 +1 @@
1
+ export * from "./get-list-query.constant";
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./get-list-properties.type"), exports);
17
+ __exportStar(require("./get-list-query.constant"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/factory/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C","sourcesContent":["export * from \"./get-list-query.constant\";\n"]}
@@ -0,0 +1 @@
1
+ export * from "./dto";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dto"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/factory/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB","sourcesContent":["export * from \"./dto\";\n"]}
@@ -3,3 +3,4 @@ export * from "./dto";
3
3
  export * from "./interface";
4
4
  export * from "./date.constant";
5
5
  export * from "./number.constant";
6
+ export * from "./factory";
@@ -19,4 +19,5 @@ __exportStar(require("./dto"), exports);
19
19
  __exportStar(require("./interface"), exports);
20
20
  __exportStar(require("./date.constant"), exports);
21
21
  __exportStar(require("./number.constant"), exports);
22
+ __exportStar(require("./factory"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,wCAAsB;AACtB,8CAA4B;AAC5B,kDAAgC;AAChC,oDAAkC","sourcesContent":["export * from \"./decorator\";\nexport * from \"./dto\";\nexport * from \"./interface\";\nexport * from \"./date.constant\";\nexport * from \"./number.constant\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["constant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,wCAAsB;AACtB,8CAA4B;AAC5B,kDAAgC;AAChC,oDAAkC;AAClC,4CAA0B","sourcesContent":["export * from \"./decorator\";\nexport * from \"./dto\";\nexport * from \"./interface\";\nexport * from \"./date.constant\";\nexport * from \"./number.constant\";\nexport * from \"./factory\";\n"]}
@@ -1,3 +1,3 @@
1
1
  export declare const API_FILTER_INTERFACE_CONSTANT: {
2
- readonly ALLOWED_ENTITY_TO_FILTER_COLUMNS: string[];
2
+ readonly ALLOWED_ENTITY_TO_FILTER_COLUMNS: Array<string>;
3
3
  };
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.API_FILTER_INTERFACE_CONSTANT = void 0;
4
- const ALLOWED_ENTITY_TO_FILTER_COLUMNS = [
5
- 'string', 'text', 'varchar', 'char',
6
- 'number', 'int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float', 'double', 'decimal',
7
- 'date', 'datetime', 'timestamp'
8
- ];
4
+ const ALLOWED_ENTITY_TO_FILTER_COLUMNS = ["string", "text", "varchar", "char", "number", "int", "integer", "tinyint", "smallint", "mediumint", "bigint", "float", "double", "decimal", "date", "datetime", "timestamp"];
9
5
  exports.API_FILTER_INTERFACE_CONSTANT = {
10
6
  ALLOWED_ENTITY_TO_FILTER_COLUMNS,
11
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"filter.constant.js","sourceRoot":"/","sources":["constant/interface/api/filter.constant.ts"],"names":[],"mappings":";;;AACA,MAAM,gCAAgC,GAAa;IAC/C,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IACnC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS;IACtG,MAAM,EAAE,UAAU,EAAE,WAAW;CAClC,CAAC;AAEW,QAAA,6BAA6B,GAEtC;IACA,gCAAgC;CAC1B,CAAC","sourcesContent":["\nconst ALLOWED_ENTITY_TO_FILTER_COLUMNS: string[] = [\n 'string', 'text', 'varchar', 'char',\n 'number', 'int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float', 'double', 'decimal',\n 'date', 'datetime', 'timestamp'\n];\n\nexport const API_FILTER_INTERFACE_CONSTANT: {\n readonly ALLOWED_ENTITY_TO_FILTER_COLUMNS: string[];\n} = {\n ALLOWED_ENTITY_TO_FILTER_COLUMNS,\n} as const;\n"]}
1
+ {"version":3,"file":"filter.constant.js","sourceRoot":"/","sources":["constant/interface/api/filter.constant.ts"],"names":[],"mappings":";;;AAAA,MAAM,gCAAgC,GAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAE1N,QAAA,6BAA6B,GAEtC;IACH,gCAAgC;CACvB,CAAC","sourcesContent":["const ALLOWED_ENTITY_TO_FILTER_COLUMNS: Array<string> = [\"string\", \"text\", \"varchar\", \"char\", \"number\", \"int\", \"integer\", \"tinyint\", \"smallint\", \"mediumint\", \"bigint\", \"float\", \"double\", \"decimal\", \"date\", \"datetime\", \"timestamp\"];\n\nexport const API_FILTER_INTERFACE_CONSTANT: {\n\treadonly ALLOWED_ENTITY_TO_FILTER_COLUMNS: Array<string>;\n} = {\n\tALLOWED_ENTITY_TO_FILTER_COLUMNS,\n} as const;\n"]}
@@ -0,0 +1,8 @@
1
+ import type { BaseApiService } from "../../class";
2
+ import type { IApiControllerProperties } from "../../interface/decorator/api/controller-properties.interface";
3
+ import type { BaseEntity } from "typeorm";
4
+ type TConstructor = new (...arguments_: Array<any>) => {
5
+ service: BaseApiService<any>;
6
+ };
7
+ export declare const ApiController: <E extends BaseEntity>(options: IApiControllerProperties<E>) => <T extends TConstructor>(target: T) => T;
8
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiController = void 0;
4
+ const factory_1 = require("../../factory");
5
+ const ApiController = (options) => (target) => {
6
+ const factory = new factory_1.ApiControllerFactory(target, options);
7
+ factory.init();
8
+ const ValidatedController = class extends target {
9
+ constructor(...properties) {
10
+ super(...properties);
11
+ }
12
+ };
13
+ Object.defineProperty(ValidatedController, "name", { value: target.name });
14
+ return ValidatedController;
15
+ };
16
+ exports.ApiController = ApiController;
17
+ //# sourceMappingURL=controller.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.decorator.js","sourceRoot":"/","sources":["decorator/api/controller.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAS9C,MAAM,aAAa,GACzB,CAAuB,OAAoC,EAAE,EAAE,CAC/D,CAAyB,MAAS,EAAK,EAAE;IACxC,MAAM,OAAO,GAA4B,IAAI,8BAAoB,CAAI,MAAM,EAAE,OAAO,CAAC,CAAC;IACtF,OAAO,CAAC,IAAI,EAAE,CAAC;IAEf,MAAM,mBAAmB,GAA2D,KAAM,SAAQ,MAAM;QACvG,YAAY,GAAG,UAAe;YAE7B,KAAK,CAAC,GAAG,UAAU,CAAC,CAAC;QACtB,CAAC;KACD,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3E,OAAO,mBAAwB,CAAC;AACjC,CAAC,CAAC;AAfU,QAAA,aAAa,iBAevB","sourcesContent":["import { ApiControllerFactory } from \"../../factory\";\n\nimport type { BaseApiService } from \"../../class\";\nimport type { IApiControllerProperties } from \"../../interface/decorator/api/controller-properties.interface\";\n\nimport type { BaseEntity } from \"typeorm\";\n\ntype TConstructor = new (...arguments_: Array<any>) => { service: BaseApiService<any> };\n\nexport const ApiController =\n\t<E extends BaseEntity>(options: IApiControllerProperties<E>) =>\n\t<T extends TConstructor>(target: T): T => {\n\t\tconst factory: ApiControllerFactory<E> = new ApiControllerFactory<E>(target, options);\n\t\tfactory.init();\n\n\t\tconst ValidatedController: { new (...arguments_: Array<any>): {}; prototype: {} } = class extends target {\n\t\t\tconstructor(...properties: any) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\tsuper(...properties);\n\t\t\t}\n\t\t};\n\t\tObject.defineProperty(ValidatedController, \"name\", { value: target.name });\n\n\t\treturn ValidatedController as T;\n\t};\n"]}
@@ -0,0 +1,4 @@
1
+ import type { BaseEntity } from "typeorm";
2
+ export declare function ApiFunctionCreate<E extends BaseEntity>(options: {
3
+ model: new () => E;
4
+ }): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiFunctionCreate = ApiFunctionCreate;
4
+ const common_1 = require("@nestjs/common");
5
+ const enum_1 = require("../../../enum");
6
+ const utility_1 = require("../../../utility");
7
+ const get_entity_columns_utility_1 = require("../../../utility/get-entity-columns.utility");
8
+ async function executor(repository, entityType, properties) {
9
+ try {
10
+ const allColumns = (0, get_entity_columns_utility_1.GetEntityColumns)(entityType);
11
+ const autoGeneratedColumns = (0, get_entity_columns_utility_1.GetEntityColumns)(entityType, true);
12
+ const filteredProperties = Object.keys(properties).reduce((accumulator, key) => {
13
+ if (allColumns.includes(key) && !autoGeneratedColumns.includes(key)) {
14
+ accumulator[key] = properties[key];
15
+ }
16
+ return accumulator;
17
+ }, {});
18
+ const newEntity = repository.create(filteredProperties);
19
+ return await repository.save(newEntity);
20
+ }
21
+ catch (error) {
22
+ console.log(error);
23
+ if (error instanceof common_1.HttpException) {
24
+ throw error;
25
+ }
26
+ throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
27
+ entity: entityType,
28
+ type: enum_1.EErrorStringAction.CREATING_ERROR,
29
+ }));
30
+ }
31
+ }
32
+ function ApiFunctionCreate(options) {
33
+ return function (_target, _propertyKey, descriptor) {
34
+ descriptor.value = async function (properties) {
35
+ const repository = this.repository;
36
+ if (!repository) {
37
+ throw new Error("Repository is not available in this context");
38
+ }
39
+ return executor(repository, options.model, properties);
40
+ };
41
+ return descriptor;
42
+ };
43
+ }
44
+ //# sourceMappingURL=create.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.decorator.js","sourceRoot":"/","sources":["decorator/api/function/create.decorator.ts"],"names":[],"mappings":";;AA2CA,8CAmBC;AA9DD,2CAA6E;AAE7E,wCAAmD;AAEnD,8CAA+C;AAC/C,4FAA+E;AAM/E,KAAK,UAAU,QAAQ,CAAuB,UAAyB,EAAE,UAAuB,EAAE,UAA2C;IAC5I,IAAI,CAAC;QACJ,MAAM,UAAU,GAAG,IAAA,6CAAgB,EAAC,UAAU,CAAC,CAAC;QAChD,MAAM,oBAAoB,GAAG,IAAA,6CAAgB,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAEhE,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE;YAC9E,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAc,CAAC,EAAE,CAAC;gBAC1F,WAAmB,CAAC,GAAG,CAAC,GAAI,UAAkB,CAAC,GAAG,CAAC,CAAC;YACtD,CAAC;YAED,OAAO,WAAW,CAAC;QACpB,CAAC,EAAE,EAAoB,CAAC,CAAC;QAEzB,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAExD,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnB,IAAI,KAAK,YAAY,sBAAa,EAAE,CAAC;YACpC,MAAM,KAAK,CAAC;QACb,CAAC;QAED,MAAM,IAAI,qCAA4B,CACrC,IAAA,qBAAW,EAAC;YACX,MAAM,EAAE,UAAU;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,UAAU,CAAC,KAAK,GAAG,KAAK,WAIvB,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,OAAO,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QACxD,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 { ErrorString } from \"../../../utility\";\nimport { GetEntityColumns } from \"../../../utility/get-entity-columns.utility\";\n\nimport type { TApiFunctionCreateProperties } from \"../../../type\";\n\nimport type { BaseEntity, DeepPartial, Repository } from \"typeorm\";\n\nasync function executor<E extends BaseEntity>(repository: Repository<E>, entityType: new () => E, properties: TApiFunctionCreateProperties<E>): Promise<E> {\n\ttry {\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 newEntity = repository.create(filteredProperties);\n\n\t\treturn await repository.save(newEntity);\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.CREATING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionCreate<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: TApiFunctionCreateProperties<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\treturn executor(repository, options.model, properties);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { BaseEntity, FindOptionsRelations } from "typeorm";
2
1
  import { EApiFunctionType } from "../../../enum";
2
+ import type { BaseEntity, FindOptionsRelations } from "typeorm";
3
3
  export declare function ApiFunction<E extends BaseEntity>(options: {
4
4
  model: new () => E;
5
- type: EApiFunctionType;
6
5
  relations?: FindOptionsRelations<E>;
6
+ type: EApiFunctionType;
7
7
  }): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -1,25 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiFunction = ApiFunction;
4
- const get_list_decorator_1 = require("./get-list.decorator");
5
4
  const enum_1 = require("../../../enum");
5
+ const create_decorator_1 = require("./create.decorator");
6
+ const delete_decorator_1 = require("./delete.decorator");
7
+ const get_list_decorator_1 = require("./get-list.decorator");
6
8
  const get_decorator_1 = require("./get.decorator");
9
+ const update_decorator_1 = require("./update.decorator");
7
10
  function ApiFunction(options) {
8
11
  return function (_target, _propertyKey, descriptor) {
9
12
  const originalMethod = descriptor.value;
10
- descriptor.value = function (...args) {
13
+ descriptor.value = function (...arguments_) {
11
14
  switch (options.type) {
12
15
  case enum_1.EApiFunctionType.GET_LIST: {
13
- return (0, get_list_decorator_1.ApiFunctionGetList)({ model: options.model, relations: options.relations })(this, _propertyKey, { value: originalMethod }).value.apply(this, args);
16
+ return (0, get_list_decorator_1.ApiFunctionGetList)({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, arguments_);
14
17
  }
15
18
  case enum_1.EApiFunctionType.GET: {
16
- return (0, get_decorator_1.ApiFunctionGet)({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, args);
19
+ return (0, get_decorator_1.ApiFunctionGet)({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, arguments_);
20
+ }
21
+ case enum_1.EApiFunctionType.CREATE: {
22
+ return (0, create_decorator_1.ApiFunctionCreate)({ model: options.model })(this, _propertyKey, {
23
+ value: originalMethod,
24
+ }).value.apply(this, arguments_);
25
+ }
26
+ case enum_1.EApiFunctionType.UPDATE: {
27
+ return (0, update_decorator_1.ApiFunctionUpdate)({ model: options.model })(this, _propertyKey, {
28
+ value: originalMethod,
29
+ }).value.apply(this, arguments_);
30
+ }
31
+ case enum_1.EApiFunctionType.DELETE: {
32
+ return (0, delete_decorator_1.ApiFunctionDelete)({ model: options.model })(this, _propertyKey, {
33
+ value: originalMethod,
34
+ }).value.apply(this, arguments_);
17
35
  }
18
36
  default: {
19
37
  throw new Error("Unsupported function");
20
38
  }
21
39
  }
22
- return originalMethod.apply(this, args);
40
+ return originalMethod.apply(this, arguments_);
23
41
  };
24
42
  return descriptor;
25
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.js","sourceRoot":"/","sources":["decorator/api/function/decorator.ts"],"names":[],"mappings":";;AAKA,kCAyBC;AA7BD,6DAAwD;AACxD,wCAA+C;AAC/C,mDAA+C;AAE/C,SAAgB,WAAW,CAAuB,OAA4F;IAC7I,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAClF,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,UAA+C,GAAG,IAAgB;YAEpF,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,uBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAChC,OAAO,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC1J,CAAC;gBAED,KAAK,uBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3B,OAAO,IAAA,8BAAc,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxH,CAAC;gBAED,OAAO,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACzC,CAAC;YACF,CAAC;YAED,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type {BaseEntity, FindOptionsRelations, Repository} from \"typeorm\";\nimport {ApiFunctionGetList} from \"./get-list.decorator\";\nimport {EApiFunctionType} from \"../../../enum\";\nimport {ApiFunctionGet} from \"./get.decorator\";\n\nexport function ApiFunction<E extends BaseEntity>(options: { model: new () => E; type: EApiFunctionType; relations?: FindOptionsRelations<E> }) {\n\treturn function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tconst originalMethod = descriptor.value;\n\n\t\tdescriptor.value = function (this: { repository: Repository<E> }, ...args: Array<any>) {\n\n\t\t\tswitch (options.type) {\n\t\t\t\tcase EApiFunctionType.GET_LIST: {\n\t\t\t\t\treturn ApiFunctionGetList({ model: options.model, relations: options.relations })(this, _propertyKey, { value: originalMethod }).value.apply(this, args);\n\t\t\t\t}\n\n\t\t\t\tcase EApiFunctionType.GET: {\n\t\t\t\t\treturn ApiFunctionGet({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, args);\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unsupported function\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn originalMethod.apply(this, args);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
1
+ {"version":3,"file":"decorator.js","sourceRoot":"/","sources":["decorator/api/function/decorator.ts"],"names":[],"mappings":";;AAUA,kCA0CC;AApDD,wCAAiD;AAEjD,yDAAuD;AACvD,yDAAuD;AACvD,6DAA0D;AAC1D,mDAAiD;AACjD,yDAAuD;AAIvD,SAAgB,WAAW,CAAuB,OAA4F;IAC7I,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAClF,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,UAA+C,GAAG,UAAsB;YAC1F,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,uBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAChC,OAAO,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAClI,CAAC;gBAED,KAAK,uBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3B,OAAO,IAAA,8BAAc,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAC9H,CAAC;gBAED,KAAK,uBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;oBAC9B,OAAO,IAAA,oCAAiB,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE;wBACtE,KAAK,EAAE,cAAc;qBACrB,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAClC,CAAC;gBAED,KAAK,uBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;oBAC9B,OAAO,IAAA,oCAAiB,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE;wBACtE,KAAK,EAAE,cAAc;qBACrB,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAClC,CAAC;gBAED,KAAK,uBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;oBAC9B,OAAO,IAAA,oCAAiB,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE;wBACtE,KAAK,EAAE,cAAc;qBACrB,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBAClC,CAAC;gBAED,OAAO,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACzC,CAAC;YACF,CAAC;YAED,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { EApiFunctionType } from \"../../../enum\";\n\nimport { ApiFunctionCreate } from \"./create.decorator\";\nimport { ApiFunctionDelete } from \"./delete.decorator\";\nimport { ApiFunctionGetList } from \"./get-list.decorator\";\nimport { ApiFunctionGet } from \"./get.decorator\";\nimport { ApiFunctionUpdate } from \"./update.decorator\";\n\nimport type { BaseEntity, FindOptionsRelations, Repository } from \"typeorm\";\n\nexport function ApiFunction<E extends BaseEntity>(options: { model: new () => E; relations?: FindOptionsRelations<E>; type: EApiFunctionType }) {\n\treturn function (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tconst originalMethod = descriptor.value;\n\n\t\tdescriptor.value = function (this: { repository: Repository<E> }, ...arguments_: Array<any>) {\n\t\t\tswitch (options.type) {\n\t\t\t\tcase EApiFunctionType.GET_LIST: {\n\t\t\t\t\treturn ApiFunctionGetList({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, arguments_);\n\t\t\t\t}\n\n\t\t\t\tcase EApiFunctionType.GET: {\n\t\t\t\t\treturn ApiFunctionGet({ model: options.model })(this, _propertyKey, { value: originalMethod }).value.apply(this, arguments_);\n\t\t\t\t}\n\n\t\t\t\tcase EApiFunctionType.CREATE: {\n\t\t\t\t\treturn ApiFunctionCreate({ model: options.model })(this, _propertyKey, {\n\t\t\t\t\t\tvalue: originalMethod,\n\t\t\t\t\t}).value.apply(this, arguments_);\n\t\t\t\t}\n\n\t\t\t\tcase EApiFunctionType.UPDATE: {\n\t\t\t\t\treturn ApiFunctionUpdate({ model: options.model })(this, _propertyKey, {\n\t\t\t\t\t\tvalue: originalMethod,\n\t\t\t\t\t}).value.apply(this, arguments_);\n\t\t\t\t}\n\n\t\t\t\tcase EApiFunctionType.DELETE: {\n\t\t\t\t\treturn ApiFunctionDelete({ model: options.model })(this, _propertyKey, {\n\t\t\t\t\t\tvalue: originalMethod,\n\t\t\t\t\t}).value.apply(this, arguments_);\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unsupported function\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn originalMethod.apply(this, arguments_);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { BaseEntity } from "typeorm";
2
+ export declare function ApiFunctionDelete<E extends BaseEntity>(options: {
3
+ model: new () => E;
4
+ }): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiFunctionDelete = ApiFunctionDelete;
4
+ const common_1 = require("@nestjs/common");
5
+ const enum_1 = require("../../../enum");
6
+ const utility_1 = require("../../../utility");
7
+ const get_decorator_1 = require("./get.decorator");
8
+ async function executor(repository, entityType, id, getFunction) {
9
+ try {
10
+ const entity = await getFunction(id.toString());
11
+ await repository.remove(entity);
12
+ }
13
+ catch (error) {
14
+ console.log(error);
15
+ if (error instanceof common_1.HttpException) {
16
+ throw error;
17
+ }
18
+ throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
19
+ entity: entityType,
20
+ type: enum_1.EErrorStringAction.DELETING_ERROR,
21
+ }));
22
+ }
23
+ }
24
+ function ApiFunctionDelete(options) {
25
+ return function (_target, _propertyKey, descriptor) {
26
+ const getDecorator = (0, get_decorator_1.ApiFunctionGet)({ model: options.model });
27
+ let getFunction;
28
+ descriptor.value = async function (id) {
29
+ const repository = this.repository;
30
+ if (!repository) {
31
+ throw new Error("Repository is not available in this context");
32
+ }
33
+ if (!getFunction) {
34
+ const getDescriptor = {
35
+ value: function () {
36
+ return Promise.reject(new Error("Not implemented"));
37
+ },
38
+ };
39
+ getDecorator(this, "get", getDescriptor);
40
+ if (getDescriptor.value) {
41
+ getFunction = getDescriptor.value.bind(this);
42
+ }
43
+ else {
44
+ throw new Error("Get function is not properly decorated");
45
+ }
46
+ }
47
+ return executor(repository, options.model, id, getFunction);
48
+ };
49
+ return descriptor;
50
+ };
51
+ }
52
+ //# sourceMappingURL=delete.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.decorator.js","sourceRoot":"/","sources":["decorator/api/function/delete.decorator.ts"],"names":[],"mappings":";;AA+BA,8CAqCC;AApED,2CAA6E;AAE7E,wCAAmD;AACnD,8CAA+C;AAE/C,mDAAiD;AAKjD,KAAK,UAAU,QAAQ,CAAuB,UAAyB,EAAE,UAAuB,EAAE,EAAmB,EAAE,WAAkF;IACxM,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnB,IAAI,KAAK,YAAY,sBAAa,EAAE,CAAC;YACpC,MAAM,KAAK,CAAC;QACb,CAAC;QAED,MAAM,IAAI,qCAA4B,CACrC,IAAA,qBAAW,EAAC;YACX,MAAM,EAAE,UAAU;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;YAEnB,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,WAAW,CAAC,CAAC;QAC7D,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 } from \"../../../utility\";\n\nimport { ApiFunctionGet } from \"./get.decorator\";\n\nimport type { TApiFunctionGetProperties } from \"../../../type\";\nimport type { BaseEntity, Repository } from \"typeorm\";\n\nasync function executor<E extends BaseEntity>(repository: Repository<E>, entityType: new () => E, id: number | string, getFunction: (id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>): Promise<void> {\n\ttry {\n\t\tconst entity = await getFunction(id.toString());\n\n\t\tawait repository.remove(entity);\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.DELETING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionDelete<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) {\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, getFunction);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}