@nest-omni/core 1.0.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 (528) hide show
  1. package/dist/boilerplate.polyfill.d.ts +39 -0
  2. package/dist/boilerplate.polyfill.js +66 -0
  3. package/dist/boilerplate.polyfill.js.map +1 -0
  4. package/dist/common/abstract-client.service.d.ts +16 -0
  5. package/dist/common/abstract-client.service.js +26 -0
  6. package/dist/common/abstract-client.service.js.map +1 -0
  7. package/dist/common/abstract.entity.d.ts +17 -0
  8. package/dist/common/abstract.entity.js +71 -0
  9. package/dist/common/abstract.entity.js.map +1 -0
  10. package/dist/common/dto/abstract.dto.d.ts +13 -0
  11. package/dist/common/dto/abstract.dto.js +63 -0
  12. package/dist/common/dto/abstract.dto.js.map +1 -0
  13. package/dist/common/dto/bulk-id.dto.d.ts +3 -0
  14. package/dist/common/dto/bulk-id.dto.js +29 -0
  15. package/dist/common/dto/bulk-id.dto.js.map +1 -0
  16. package/dist/common/dto/create-translation.dto.d.ts +5 -0
  17. package/dist/common/dto/create-translation.dto.js +28 -0
  18. package/dist/common/dto/create-translation.dto.js.map +1 -0
  19. package/dist/common/dto/page-meta.dto.d.ts +15 -0
  20. package/dist/common/dto/page-meta.dto.js +55 -0
  21. package/dist/common/dto/page-meta.dto.js.map +1 -0
  22. package/dist/common/dto/page-options.dto.d.ts +8 -0
  23. package/dist/common/dto/page-options.dto.js +52 -0
  24. package/dist/common/dto/page-options.dto.js.map +1 -0
  25. package/dist/common/dto/page.dto.d.ts +11 -0
  26. package/dist/common/dto/page.dto.js +61 -0
  27. package/dist/common/dto/page.dto.js.map +1 -0
  28. package/dist/common/utils.d.ts +3 -0
  29. package/dist/common/utils.js +26 -0
  30. package/dist/common/utils.js.map +1 -0
  31. package/dist/constants/index.d.ts +4 -0
  32. package/dist/constants/index.js +21 -0
  33. package/dist/constants/index.js.map +1 -0
  34. package/dist/constants/language-code.d.ts +5 -0
  35. package/dist/constants/language-code.js +10 -0
  36. package/dist/constants/language-code.js.map +1 -0
  37. package/dist/constants/order.d.ts +4 -0
  38. package/dist/constants/order.js +9 -0
  39. package/dist/constants/order.js.map +1 -0
  40. package/dist/constants/role-type.d.ts +4 -0
  41. package/dist/constants/role-type.js +9 -0
  42. package/dist/constants/role-type.js.map +1 -0
  43. package/dist/constants/token-type.d.ts +4 -0
  44. package/dist/constants/token-type.js +9 -0
  45. package/dist/constants/token-type.js.map +1 -0
  46. package/dist/decorators/api-page-ok-response.decorator.d.ts +5 -0
  47. package/dist/decorators/api-page-ok-response.decorator.js +26 -0
  48. package/dist/decorators/api-page-ok-response.decorator.js.map +1 -0
  49. package/dist/decorators/auth-user.decorator.d.ts +1 -0
  50. package/dist/decorators/auth-user.decorator.js +16 -0
  51. package/dist/decorators/auth-user.decorator.js.map +1 -0
  52. package/dist/decorators/controller.decorator.d.ts +1 -0
  53. package/dist/decorators/controller.decorator.js +12 -0
  54. package/dist/decorators/controller.decorator.js.map +1 -0
  55. package/dist/decorators/field.decorators.d.ts +71 -0
  56. package/dist/decorators/field.decorators.js +457 -0
  57. package/dist/decorators/field.decorators.js.map +1 -0
  58. package/dist/decorators/http.decorators.d.ts +3 -0
  59. package/dist/decorators/http.decorators.js +9 -0
  60. package/dist/decorators/http.decorators.js.map +1 -0
  61. package/dist/decorators/index.d.ts +12 -0
  62. package/dist/decorators/index.js +29 -0
  63. package/dist/decorators/index.js.map +1 -0
  64. package/dist/decorators/omni-auth.decorator.d.ts +8 -0
  65. package/dist/decorators/omni-auth.decorator.js +36 -0
  66. package/dist/decorators/omni-auth.decorator.js.map +1 -0
  67. package/dist/decorators/operation.decorator.d.ts +1 -0
  68. package/dist/decorators/operation.decorator.js +7 -0
  69. package/dist/decorators/operation.decorator.js.map +1 -0
  70. package/dist/decorators/property.decorators.d.ts +15 -0
  71. package/dist/decorators/property.decorators.js +43 -0
  72. package/dist/decorators/property.decorators.js.map +1 -0
  73. package/dist/decorators/public-route.decorator.d.ts +3 -0
  74. package/dist/decorators/public-route.decorator.js +8 -0
  75. package/dist/decorators/public-route.decorator.js.map +1 -0
  76. package/dist/decorators/swagger.schema.d.ts +5 -0
  77. package/dist/decorators/swagger.schema.js +80 -0
  78. package/dist/decorators/swagger.schema.js.map +1 -0
  79. package/dist/decorators/timestamp-column.decorator.d.ts +1 -0
  80. package/dist/decorators/timestamp-column.decorator.js +29 -0
  81. package/dist/decorators/timestamp-column.decorator.js.map +1 -0
  82. package/dist/decorators/transform.decorators.d.ts +8 -0
  83. package/dist/decorators/transform.decorators.js +96 -0
  84. package/dist/decorators/transform.decorators.js.map +1 -0
  85. package/dist/decorators/translate.decorator.d.ts +5 -0
  86. package/dist/decorators/translate.decorator.js +18 -0
  87. package/dist/decorators/translate.decorator.js.map +1 -0
  88. package/dist/decorators/use-dto.decorator.d.ts +4 -0
  89. package/dist/decorators/use-dto.decorator.js +10 -0
  90. package/dist/decorators/use-dto.decorator.js.map +1 -0
  91. package/dist/decorators/user-check.decorator.d.ts +6 -0
  92. package/dist/decorators/user-check.decorator.js +22 -0
  93. package/dist/decorators/user-check.decorator.js.map +1 -0
  94. package/dist/decorators/user.decorator.d.ts +8 -0
  95. package/dist/decorators/user.decorator.js +39 -0
  96. package/dist/decorators/user.decorator.js.map +1 -0
  97. package/dist/decorators/user_auth.decorator.d.ts +1 -0
  98. package/dist/decorators/user_auth.decorator.js +17 -0
  99. package/dist/decorators/user_auth.decorator.js.map +1 -0
  100. package/dist/decorators/validator.decorators.d.ts +10 -0
  101. package/dist/decorators/validator.decorators.js +63 -0
  102. package/dist/decorators/validator.decorators.js.map +1 -0
  103. package/dist/exceptions/file-not-image.exception.d.ts +4 -0
  104. package/dist/exceptions/file-not-image.exception.js +11 -0
  105. package/dist/exceptions/file-not-image.exception.js.map +1 -0
  106. package/dist/exceptions/index.d.ts +2 -0
  107. package/dist/exceptions/index.js +19 -0
  108. package/dist/exceptions/index.js.map +1 -0
  109. package/dist/exceptions/page-type.exception.d.ts +4 -0
  110. package/dist/exceptions/page-type.exception.js +11 -0
  111. package/dist/exceptions/page-type.exception.js.map +1 -0
  112. package/dist/exceptions/user-not-found.exception.d.ts +4 -0
  113. package/dist/exceptions/user-not-found.exception.js +11 -0
  114. package/dist/exceptions/user-not-found.exception.js.map +1 -0
  115. package/dist/filters/bad-request.filter.d.ts +5 -0
  116. package/dist/filters/bad-request.filter.js +65 -0
  117. package/dist/filters/bad-request.filter.js.map +1 -0
  118. package/dist/filters/constraint-errors.d.ts +1 -0
  119. package/dist/filters/constraint-errors.js +7 -0
  120. package/dist/filters/constraint-errors.js.map +1 -0
  121. package/dist/filters/index.d.ts +3 -0
  122. package/dist/filters/index.js +20 -0
  123. package/dist/filters/index.js.map +1 -0
  124. package/dist/filters/query-failed.filter.d.ts +10 -0
  125. package/dist/filters/query-failed.filter.js +43 -0
  126. package/dist/filters/query-failed.filter.js.map +1 -0
  127. package/dist/guards/auth.guard.d.ts +4 -0
  128. package/dist/guards/auth.guard.js +13 -0
  129. package/dist/guards/auth.guard.js.map +1 -0
  130. package/dist/guards/roles.guard.d.ts +7 -0
  131. package/dist/guards/roles.guard.js +36 -0
  132. package/dist/guards/roles.guard.js.map +1 -0
  133. package/dist/health-checker/health-checker.controller.d.ts +15 -0
  134. package/dist/health-checker/health-checker.controller.js +68 -0
  135. package/dist/health-checker/health-checker.controller.js.map +1 -0
  136. package/dist/health-checker/health-checker.module.d.ts +2 -0
  137. package/dist/health-checker/health-checker.module.js +26 -0
  138. package/dist/health-checker/health-checker.module.js.map +1 -0
  139. package/dist/health-checker/health-indicators/service.indicator.d.ts +8 -0
  140. package/dist/health-checker/health-indicators/service.indicator.js +57 -0
  141. package/dist/health-checker/health-indicators/service.indicator.js.map +1 -0
  142. package/dist/helpers/common.helper.d.ts +3 -0
  143. package/dist/helpers/common.helper.js +37 -0
  144. package/dist/helpers/common.helper.js.map +1 -0
  145. package/dist/helpers/date.helper.d.ts +10 -0
  146. package/dist/helpers/date.helper.js +59 -0
  147. package/dist/helpers/date.helper.js.map +1 -0
  148. package/dist/helpers/excel.helper.d.ts +12 -0
  149. package/dist/helpers/excel.helper.js +250 -0
  150. package/dist/helpers/excel.helper.js.map +1 -0
  151. package/dist/helpers/index.d.ts +3 -0
  152. package/dist/helpers/index.js +20 -0
  153. package/dist/helpers/index.js.map +1 -0
  154. package/dist/index.d.ts +11 -0
  155. package/dist/index.js +28 -0
  156. package/dist/index.js.map +1 -0
  157. package/dist/interceptors/auth-user.interceptor.d.ts +4 -0
  158. package/dist/interceptors/auth-user.interceptor.js +25 -0
  159. package/dist/interceptors/auth-user.interceptor.js.map +1 -0
  160. package/dist/interceptors/index.d.ts +2 -0
  161. package/dist/interceptors/index.js +19 -0
  162. package/dist/interceptors/index.js.map +1 -0
  163. package/dist/interceptors/language-interceptor.service.d.ts +6 -0
  164. package/dist/interceptors/language-interceptor.service.js +31 -0
  165. package/dist/interceptors/language-interceptor.service.js.map +1 -0
  166. package/dist/interceptors/translation-interceptor.service.d.ts +5 -0
  167. package/dist/interceptors/translation-interceptor.service.js +35 -0
  168. package/dist/interceptors/translation-interceptor.service.js.map +1 -0
  169. package/dist/interfaces/IApiFile.d.ts +4 -0
  170. package/dist/interfaces/IApiFile.js +3 -0
  171. package/dist/interfaces/IApiFile.js.map +1 -0
  172. package/dist/interfaces/IFile.d.ts +9 -0
  173. package/dist/interfaces/IFile.js +3 -0
  174. package/dist/interfaces/IFile.js.map +1 -0
  175. package/dist/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
  176. package/dist/interfaces/ITranslationDecoratorInterface.js +3 -0
  177. package/dist/interfaces/ITranslationDecoratorInterface.js.map +1 -0
  178. package/dist/interfaces/index.d.ts +3 -0
  179. package/dist/interfaces/index.js +20 -0
  180. package/dist/interfaces/index.js.map +1 -0
  181. package/dist/interfaces/response.d.ts +25 -0
  182. package/dist/interfaces/response.js +3 -0
  183. package/dist/interfaces/response.js.map +1 -0
  184. package/dist/middlewares/index.d.ts +3 -0
  185. package/dist/middlewares/index.js +20 -0
  186. package/dist/middlewares/index.js.map +1 -0
  187. package/dist/middlewares/omni-auth.middleware.d.ts +1 -0
  188. package/dist/middlewares/omni-auth.middleware.js +14 -0
  189. package/dist/middlewares/omni-auth.middleware.js.map +1 -0
  190. package/dist/middlewares/powerby.middleware.d.ts +1 -0
  191. package/dist/middlewares/powerby.middleware.js +11 -0
  192. package/dist/middlewares/powerby.middleware.js.map +1 -0
  193. package/dist/middlewares/request-id.middleware.d.ts +7 -0
  194. package/dist/middlewares/request-id.middleware.js +23 -0
  195. package/dist/middlewares/request-id.middleware.js.map +1 -0
  196. package/dist/providers/context.provider.d.ts +32 -0
  197. package/dist/providers/context.provider.js +71 -0
  198. package/dist/providers/context.provider.js.map +1 -0
  199. package/dist/providers/generator.provider.d.ts +9 -0
  200. package/dist/providers/generator.provider.js +51 -0
  201. package/dist/providers/generator.provider.js.map +1 -0
  202. package/dist/providers/index.d.ts +2 -0
  203. package/dist/providers/index.js +19 -0
  204. package/dist/providers/index.js.map +1 -0
  205. package/dist/setup/bootstrap.setup.d.ts +5 -0
  206. package/dist/setup/bootstrap.setup.js +102 -0
  207. package/dist/setup/bootstrap.setup.js.map +1 -0
  208. package/dist/setup/index.d.ts +1 -0
  209. package/dist/setup/index.js +18 -0
  210. package/dist/setup/index.js.map +1 -0
  211. package/dist/setup-swagger.d.ts +2 -0
  212. package/dist/setup-swagger.js +63 -0
  213. package/dist/setup-swagger.js.map +1 -0
  214. package/dist/shared/index.d.ts +2 -0
  215. package/dist/shared/index.js +19 -0
  216. package/dist/shared/index.js.map +1 -0
  217. package/dist/shared/serviceRegistryModule.d.ts +2 -0
  218. package/dist/shared/serviceRegistryModule.js +102 -0
  219. package/dist/shared/serviceRegistryModule.js.map +1 -0
  220. package/dist/shared/services/api-config.service.d.ts +70 -0
  221. package/dist/shared/services/api-config.service.js +286 -0
  222. package/dist/shared/services/api-config.service.js.map +1 -0
  223. package/dist/shared/services/aws-s3.service.d.ts +10 -0
  224. package/dist/shared/services/aws-s3.service.js +49 -0
  225. package/dist/shared/services/aws-s3.service.js.map +1 -0
  226. package/dist/shared/services/generator.service.d.ts +4 -0
  227. package/dist/shared/services/generator.service.js +24 -0
  228. package/dist/shared/services/generator.service.js.map +1 -0
  229. package/dist/shared/services/index.d.ts +5 -0
  230. package/dist/shared/services/index.js +22 -0
  231. package/dist/shared/services/index.js.map +1 -0
  232. package/dist/shared/services/translation.service.d.ts +9 -0
  233. package/dist/shared/services/translation.service.js +61 -0
  234. package/dist/shared/services/translation.service.js.map +1 -0
  235. package/dist/shared/services/validator.service.d.ts +3 -0
  236. package/dist/shared/services/validator.service.js +21 -0
  237. package/dist/shared/services/validator.service.js.map +1 -0
  238. package/dist/snake-naming.strategy.d.ts +11 -0
  239. package/dist/snake-naming.strategy.js +38 -0
  240. package/dist/snake-naming.strategy.js.map +1 -0
  241. package/dist/tsconfig.tsbuildinfo +1 -0
  242. package/dist/types.d.ts +9 -0
  243. package/dist/types.js +3 -0
  244. package/dist/types.js.map +1 -0
  245. package/dist/validators/file-mimetype.validator.d.ts +13 -0
  246. package/dist/validators/file-mimetype.validator.js +24 -0
  247. package/dist/validators/file-mimetype.validator.js.map +1 -0
  248. package/dist/validators/index.d.ts +3 -0
  249. package/dist/validators/index.js +20 -0
  250. package/dist/validators/index.js.map +1 -0
  251. package/dist/validators/is-exists.validator.d.ts +18 -0
  252. package/dist/validators/is-exists.validator.js +52 -0
  253. package/dist/validators/is-exists.validator.js.map +1 -0
  254. package/dist/validators/is-unique.validator.d.ts +17 -0
  255. package/dist/validators/is-unique.validator.js +83 -0
  256. package/dist/validators/is-unique.validator.js.map +1 -0
  257. package/dist/validators/phone-country-code.validator.d.ts +2 -0
  258. package/dist/validators/phone-country-code.validator.js +31 -0
  259. package/dist/validators/phone-country-code.validator.js.map +1 -0
  260. package/dist/validators/same-as.validator.d.ts +2 -0
  261. package/dist/validators/same-as.validator.js +26 -0
  262. package/dist/validators/same-as.validator.js.map +1 -0
  263. package/dist/validators/skip-empty.validator.d.ts +1 -0
  264. package/dist/validators/skip-empty.validator.js +19 -0
  265. package/dist/validators/skip-empty.validator.js.map +1 -0
  266. package/package.json +66 -0
  267. package/src/boilerplate.polyfill.d.ts +39 -0
  268. package/src/boilerplate.polyfill.js +78 -0
  269. package/src/boilerplate.polyfill.ts +202 -0
  270. package/src/common/abstract-client.service.d.ts +20 -0
  271. package/src/common/abstract-client.service.js +39 -0
  272. package/src/common/abstract-client.service.ts +56 -0
  273. package/src/common/abstract.entity.d.ts +24 -0
  274. package/src/common/abstract.entity.js +152 -0
  275. package/src/common/abstract.entity.ts +73 -0
  276. package/src/common/dto/abstract.dto.d.ts +13 -0
  277. package/src/common/dto/abstract.dto.js +96 -0
  278. package/src/common/dto/abstract.dto.ts +64 -0
  279. package/src/common/dto/bulk-id.dto.d.ts +3 -0
  280. package/src/common/dto/bulk-id.dto.js +63 -0
  281. package/src/common/dto/bulk-id.dto.ts +13 -0
  282. package/src/common/dto/create-translation.dto.d.ts +5 -0
  283. package/src/common/dto/create-translation.dto.js +63 -0
  284. package/src/common/dto/create-translation.dto.ts +10 -0
  285. package/src/common/dto/page-meta.dto.d.ts +15 -0
  286. package/src/common/dto/page-meta.dto.js +88 -0
  287. package/src/common/dto/page-meta.dto.ts +37 -0
  288. package/src/common/dto/page-options.dto.d.ts +8 -0
  289. package/src/common/dto/page-options.dto.js +87 -0
  290. package/src/common/dto/page-options.dto.ts +35 -0
  291. package/src/common/dto/page.dto.d.ts +11 -0
  292. package/src/common/dto/page.dto.js +94 -0
  293. package/src/common/dto/page.dto.ts +36 -0
  294. package/src/common/utils.d.ts +14 -0
  295. package/src/common/utils.js +39 -0
  296. package/src/common/utils.ts +45 -0
  297. package/src/constants/index.d.ts +4 -0
  298. package/src/constants/index.js +20 -0
  299. package/src/constants/index.ts +4 -0
  300. package/src/constants/language-code.d.ts +5 -0
  301. package/src/constants/language-code.js +10 -0
  302. package/src/constants/language-code.ts +7 -0
  303. package/src/constants/order.d.ts +4 -0
  304. package/src/constants/order.js +8 -0
  305. package/src/constants/order.ts +4 -0
  306. package/src/constants/role-type.d.ts +4 -0
  307. package/src/constants/role-type.js +8 -0
  308. package/src/constants/role-type.ts +4 -0
  309. package/src/constants/token-type.d.ts +4 -0
  310. package/src/constants/token-type.js +8 -0
  311. package/src/constants/token-type.ts +4 -0
  312. package/src/decorators/api-page-ok-response.decorator.d.ts +5 -0
  313. package/src/decorators/api-page-ok-response.decorator.js +25 -0
  314. package/src/decorators/api-page-ok-response.decorator.ts +31 -0
  315. package/src/decorators/auth-user.decorator.d.ts +1 -0
  316. package/src/decorators/auth-user.decorator.js +15 -0
  317. package/src/decorators/auth-user.decorator.ts +16 -0
  318. package/src/decorators/controller.decorator.d.ts +1 -0
  319. package/src/decorators/controller.decorator.js +34 -0
  320. package/src/decorators/controller.decorator.ts +8 -0
  321. package/src/decorators/field.decorators.d.ts +71 -0
  322. package/src/decorators/field.decorators.js +455 -0
  323. package/src/decorators/field.decorators.ts +773 -0
  324. package/src/decorators/http.decorators.d.ts +3 -0
  325. package/src/decorators/http.decorators.js +8 -0
  326. package/src/decorators/http.decorators.ts +10 -0
  327. package/src/decorators/index.d.ts +12 -0
  328. package/src/decorators/index.js +28 -0
  329. package/src/decorators/index.ts +12 -0
  330. package/src/decorators/omni-auth.decorator.d.ts +8 -0
  331. package/src/decorators/omni-auth.decorator.js +60 -0
  332. package/src/decorators/omni-auth.decorator.ts +46 -0
  333. package/src/decorators/operation.decorator.d.ts +1 -0
  334. package/src/decorators/operation.decorator.js +6 -0
  335. package/src/decorators/operation.decorator.ts +4 -0
  336. package/src/decorators/property.decorators.d.ts +15 -0
  337. package/src/decorators/property.decorators.js +36 -0
  338. package/src/decorators/property.decorators.ts +62 -0
  339. package/src/decorators/public-route.decorator.d.ts +3 -0
  340. package/src/decorators/public-route.decorator.js +8 -0
  341. package/src/decorators/public-route.decorator.ts +8 -0
  342. package/src/decorators/swagger.schema.d.ts +5 -0
  343. package/src/decorators/swagger.schema.js +82 -0
  344. package/src/decorators/swagger.schema.ts +117 -0
  345. package/src/decorators/timestamp-column.decorator.d.ts +1 -0
  346. package/src/decorators/timestamp-column.decorator.js +28 -0
  347. package/src/decorators/timestamp-column.decorator.ts +29 -0
  348. package/src/decorators/transform.decorators.d.ts +35 -0
  349. package/src/decorators/transform.decorators.js +122 -0
  350. package/src/decorators/transform.decorators.ts +147 -0
  351. package/src/decorators/translate.decorator.d.ts +5 -0
  352. package/src/decorators/translate.decorator.js +18 -0
  353. package/src/decorators/translate.decorator.ts +19 -0
  354. package/src/decorators/use-dto.decorator.d.ts +4 -0
  355. package/src/decorators/use-dto.decorator.js +9 -0
  356. package/src/decorators/use-dto.decorator.ts +11 -0
  357. package/src/decorators/user-check.decorator.d.ts +6 -0
  358. package/src/decorators/user-check.decorator.js +44 -0
  359. package/src/decorators/user-check.decorator.ts +30 -0
  360. package/src/decorators/user.decorator.d.ts +8 -0
  361. package/src/decorators/user.decorator.js +62 -0
  362. package/src/decorators/user.decorator.ts +48 -0
  363. package/src/decorators/user_auth.decorator.d.ts +1 -0
  364. package/src/decorators/user_auth.decorator.js +16 -0
  365. package/src/decorators/user_auth.decorator.ts +15 -0
  366. package/src/decorators/validator.decorators.d.ts +10 -0
  367. package/src/decorators/validator.decorators.js +59 -0
  368. package/src/decorators/validator.decorators.ts +78 -0
  369. package/src/exceptions/file-not-image.exception.d.ts +4 -0
  370. package/src/exceptions/file-not-image.exception.js +10 -0
  371. package/src/exceptions/file-not-image.exception.ts +7 -0
  372. package/src/exceptions/index.d.ts +2 -0
  373. package/src/exceptions/index.js +18 -0
  374. package/src/exceptions/index.ts +2 -0
  375. package/src/exceptions/page-type.exception.d.ts +4 -0
  376. package/src/exceptions/page-type.exception.js +10 -0
  377. package/src/exceptions/page-type.exception.ts +7 -0
  378. package/src/exceptions/user-not-found.exception.d.ts +4 -0
  379. package/src/exceptions/user-not-found.exception.js +10 -0
  380. package/src/exceptions/user-not-found.exception.ts +7 -0
  381. package/src/filters/bad-request.filter.d.ts +5 -0
  382. package/src/filters/bad-request.filter.js +104 -0
  383. package/src/filters/bad-request.filter.ts +67 -0
  384. package/src/filters/constraint-errors.d.ts +1 -0
  385. package/src/filters/constraint-errors.js +7 -0
  386. package/src/filters/constraint-errors.ts +5 -0
  387. package/src/filters/index.d.ts +3 -0
  388. package/src/filters/index.js +19 -0
  389. package/src/filters/index.ts +3 -0
  390. package/src/filters/query-failed.filter.d.ts +10 -0
  391. package/src/filters/query-failed.filter.js +81 -0
  392. package/src/filters/query-failed.filter.ts +32 -0
  393. package/src/health-checker/health-checker.controller.d.ts +15 -0
  394. package/src/health-checker/health-checker.controller.js +104 -0
  395. package/src/health-checker/health-checker.controller.ts +51 -0
  396. package/src/health-checker/health-checker.module.d.ts +2 -0
  397. package/src/health-checker/health-checker.module.js +69 -0
  398. package/src/health-checker/health-checker.module.ts +13 -0
  399. package/src/health-checker/health-indicators/service.indicator.d.ts +8 -0
  400. package/src/health-checker/health-indicators/service.indicator.js +102 -0
  401. package/src/health-checker/health-indicators/service.indicator.ts +44 -0
  402. package/src/helpers/common.helper.d.ts +16 -0
  403. package/src/helpers/common.helper.js +49 -0
  404. package/src/helpers/common.helper.ts +49 -0
  405. package/src/helpers/date.helper.d.ts +10 -0
  406. package/src/helpers/date.helper.js +81 -0
  407. package/src/helpers/date.helper.ts +64 -0
  408. package/src/helpers/excel.helper.d.ts +27 -0
  409. package/src/helpers/excel.helper.js +338 -0
  410. package/src/helpers/index.d.ts +3 -0
  411. package/src/helpers/index.js +19 -0
  412. package/src/helpers/index.ts +3 -0
  413. package/src/i18n/en_US/validation.json +38 -0
  414. package/src/i18n/zh_CN/validation.json +38 -0
  415. package/src/index.d.ts +11 -0
  416. package/src/index.js +28 -0
  417. package/src/index.ts +12 -0
  418. package/src/interceptors/auth-user.interceptor.d.ts +4 -0
  419. package/src/interceptors/auth-user.interceptor.js +68 -0
  420. package/src/interceptors/auth-user.interceptor.ts +20 -0
  421. package/src/interceptors/index.d.ts +2 -0
  422. package/src/interceptors/index.js +18 -0
  423. package/src/interceptors/index.ts +2 -0
  424. package/src/interceptors/language-interceptor.service.d.ts +6 -0
  425. package/src/interceptors/language-interceptor.service.js +74 -0
  426. package/src/interceptors/language-interceptor.service.ts +31 -0
  427. package/src/interceptors/translation-interceptor.service.d.ts +5 -0
  428. package/src/interceptors/translation-interceptor.service.js +83 -0
  429. package/src/interceptors/translation-interceptor.service.ts +43 -0
  430. package/src/interfaces/IApiFile.d.ts +4 -0
  431. package/src/interfaces/IApiFile.js +2 -0
  432. package/src/interfaces/IApiFile.ts +4 -0
  433. package/src/interfaces/IFile.d.ts +9 -0
  434. package/src/interfaces/IFile.js +2 -0
  435. package/src/interfaces/IFile.ts +8 -0
  436. package/src/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
  437. package/src/interfaces/ITranslationDecoratorInterface.js +2 -0
  438. package/src/interfaces/ITranslationDecoratorInterface.ts +3 -0
  439. package/src/interfaces/index.d.ts +3 -0
  440. package/src/interfaces/index.js +19 -0
  441. package/src/interfaces/index.ts +3 -0
  442. package/src/interfaces/response.d.ts +25 -0
  443. package/src/interfaces/response.js +2 -0
  444. package/src/interfaces/response.ts +37 -0
  445. package/src/middlewares/index.d.ts +3 -0
  446. package/src/middlewares/index.js +19 -0
  447. package/src/middlewares/index.ts +3 -0
  448. package/src/middlewares/omni-auth.middleware.d.ts +1 -0
  449. package/src/middlewares/omni-auth.middleware.js +13 -0
  450. package/src/middlewares/omni-auth.middleware.ts +10 -0
  451. package/src/middlewares/powerby.middleware.d.ts +1 -0
  452. package/src/middlewares/powerby.middleware.js +10 -0
  453. package/src/middlewares/powerby.middleware.ts +6 -0
  454. package/src/middlewares/request-id.middleware.d.ts +7 -0
  455. package/src/middlewares/request-id.middleware.js +22 -0
  456. package/src/middlewares/request-id.middleware.ts +28 -0
  457. package/src/providers/context.provider.d.ts +32 -0
  458. package/src/providers/context.provider.js +73 -0
  459. package/src/providers/context.provider.ts +98 -0
  460. package/src/providers/generator.provider.d.ts +13 -0
  461. package/src/providers/generator.provider.js +54 -0
  462. package/src/providers/generator.provider.ts +66 -0
  463. package/src/providers/index.d.ts +2 -0
  464. package/src/providers/index.js +18 -0
  465. package/src/providers/index.ts +2 -0
  466. package/src/setup/bootstrap.setup.d.ts +5 -0
  467. package/src/setup/bootstrap.setup.js +138 -0
  468. package/src/setup/bootstrap.setup.ts +139 -0
  469. package/src/setup/index.d.ts +1 -0
  470. package/src/setup/index.js +17 -0
  471. package/src/setup/index.ts +1 -0
  472. package/src/setup/microservices.setup.js +55 -0
  473. package/src/setup-swagger.d.ts +2 -0
  474. package/src/setup-swagger.js +62 -0
  475. package/src/setup-swagger.ts +67 -0
  476. package/src/shared/index.d.ts +2 -0
  477. package/src/shared/index.js +18 -0
  478. package/src/shared/index.ts +2 -0
  479. package/src/shared/serviceRegistryModule.d.ts +2 -0
  480. package/src/shared/serviceRegistryModule.js +176 -0
  481. package/src/shared/serviceRegistryModule.ts +110 -0
  482. package/src/shared/services/api-config.service.d.ts +73 -0
  483. package/src/shared/services/api-config.service.js +335 -0
  484. package/src/shared/services/api-config.service.ts +319 -0
  485. package/src/shared/services/aws-s3.service.d.ts +10 -0
  486. package/src/shared/services/aws-s3.service.js +96 -0
  487. package/src/shared/services/aws-s3.service.ts +39 -0
  488. package/src/shared/services/generator.service.d.ts +4 -0
  489. package/src/shared/services/generator.service.js +67 -0
  490. package/src/shared/services/generator.service.ts +13 -0
  491. package/src/shared/services/index.d.ts +5 -0
  492. package/src/shared/services/index.js +21 -0
  493. package/src/shared/services/index.ts +5 -0
  494. package/src/shared/services/translation.service.d.ts +9 -0
  495. package/src/shared/services/translation.service.js +109 -0
  496. package/src/shared/services/translation.service.ts +59 -0
  497. package/src/shared/services/validator.service.d.ts +3 -0
  498. package/src/shared/services/validator.service.js +64 -0
  499. package/src/shared/services/validator.service.ts +10 -0
  500. package/src/snake-naming.strategy.d.ts +11 -0
  501. package/src/snake-naming.strategy.js +37 -0
  502. package/src/snake-naming.strategy.ts +64 -0
  503. package/src/types.d.ts +9 -0
  504. package/src/types.js +2 -0
  505. package/src/types.ts +44 -0
  506. package/src/validators/file-mimetype.validator.d.ts +13 -0
  507. package/src/validators/file-mimetype.validator.js +21 -0
  508. package/src/validators/file-mimetype.validator.ts +34 -0
  509. package/src/validators/index.d.ts +3 -0
  510. package/src/validators/index.js +19 -0
  511. package/src/validators/index.ts +3 -0
  512. package/src/validators/is-exists.validator.d.ts +18 -0
  513. package/src/validators/is-exists.validator.js +99 -0
  514. package/src/validators/is-exists.validator.ts +60 -0
  515. package/src/validators/is-unique.validator.d.ts +17 -0
  516. package/src/validators/is-unique.validator.js +131 -0
  517. package/src/validators/is-unique.validator.ts +93 -0
  518. package/src/validators/phone-country-code.validator.d.ts +2 -0
  519. package/src/validators/phone-country-code.validator.js +30 -0
  520. package/src/validators/phone-country-code.validator.ts +36 -0
  521. package/src/validators/same-as.validator.d.ts +2 -0
  522. package/src/validators/same-as.validator.js +25 -0
  523. package/src/validators/same-as.validator.ts +27 -0
  524. package/src/validators/skip-empty.validator.d.ts +6 -0
  525. package/src/validators/skip-empty.validator.js +23 -0
  526. package/src/validators/skip-empty.validator.ts +25 -0
  527. package/tsconfig.json +21 -0
  528. package/tsconfig.lib.json +16 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
46
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
47
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.AwsS3Service = void 0;
54
+ const client_s3_1 = require("@aws-sdk/client-s3");
55
+ const common_1 = require("@nestjs/common");
56
+ const mime_types_1 = __importDefault(require("mime-types"));
57
+ let AwsS3Service = (() => {
58
+ let _classDecorators = [(0, common_1.Injectable)()];
59
+ let _classDescriptor;
60
+ let _classExtraInitializers = [];
61
+ let _classThis;
62
+ var AwsS3Service = _classThis = class {
63
+ constructor(configService, generatorService) {
64
+ this.configService = configService;
65
+ this.generatorService = generatorService;
66
+ const awsS3Config = configService.awsS3Config;
67
+ this.s3 = new client_s3_1.S3({
68
+ apiVersion: awsS3Config.bucketApiVersion,
69
+ region: awsS3Config.bucketRegion,
70
+ });
71
+ }
72
+ uploadImage(file) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const fileName = this.generatorService.fileName(mime_types_1.default.extension(file.mimetype));
75
+ const key = 'images/' + fileName;
76
+ yield this.s3.putObject({
77
+ Bucket: this.configService.awsS3Config.bucketName,
78
+ Body: file.buffer,
79
+ ACL: 'public-read',
80
+ Key: key,
81
+ });
82
+ return key;
83
+ });
84
+ }
85
+ };
86
+ __setFunctionName(_classThis, "AwsS3Service");
87
+ (() => {
88
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
89
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
90
+ AwsS3Service = _classThis = _classDescriptor.value;
91
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
92
+ __runInitializers(_classThis, _classExtraInitializers);
93
+ })();
94
+ return AwsS3Service = _classThis;
95
+ })();
96
+ exports.AwsS3Service = AwsS3Service;
@@ -0,0 +1,39 @@
1
+ import { S3 } from '@aws-sdk/client-s3';
2
+ import { Injectable } from '@nestjs/common';
3
+ import mime from 'mime-types';
4
+
5
+ import type { IFile } from '../../interfaces';
6
+ import { ApiConfigService } from './api-config.service';
7
+ import { GeneratorService } from './generator.service';
8
+
9
+ @Injectable()
10
+ export class AwsS3Service {
11
+ private readonly s3: S3;
12
+
13
+ constructor(
14
+ public configService: ApiConfigService,
15
+ public generatorService: GeneratorService,
16
+ ) {
17
+ const awsS3Config = configService.awsS3Config;
18
+
19
+ this.s3 = new S3({
20
+ apiVersion: awsS3Config.bucketApiVersion,
21
+ region: awsS3Config.bucketRegion,
22
+ });
23
+ }
24
+
25
+ async uploadImage(file: IFile): Promise<string> {
26
+ const fileName = this.generatorService.fileName(
27
+ <string>mime.extension(file.mimetype),
28
+ );
29
+ const key = 'images/' + fileName;
30
+ await this.s3.putObject({
31
+ Bucket: this.configService.awsS3Config.bucketName,
32
+ Body: file.buffer,
33
+ ACL: 'public-read',
34
+ Key: key,
35
+ });
36
+
37
+ return key;
38
+ }
39
+ }
@@ -0,0 +1,4 @@
1
+ export declare class GeneratorService {
2
+ uuid(): string;
3
+ fileName(ext: string): string;
4
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.GeneratorService = void 0;
42
+ const common_1 = require("@nestjs/common");
43
+ const uuid_1 = require("uuid");
44
+ let GeneratorService = (() => {
45
+ let _classDecorators = [(0, common_1.Injectable)()];
46
+ let _classDescriptor;
47
+ let _classExtraInitializers = [];
48
+ let _classThis;
49
+ var GeneratorService = _classThis = class {
50
+ uuid() {
51
+ return (0, uuid_1.v1)();
52
+ }
53
+ fileName(ext) {
54
+ return this.uuid() + '.' + ext;
55
+ }
56
+ };
57
+ __setFunctionName(_classThis, "GeneratorService");
58
+ (() => {
59
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
60
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
61
+ GeneratorService = _classThis = _classDescriptor.value;
62
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
63
+ __runInitializers(_classThis, _classExtraInitializers);
64
+ })();
65
+ return GeneratorService = _classThis;
66
+ })();
67
+ exports.GeneratorService = GeneratorService;
@@ -0,0 +1,13 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { v1 as uuid } from 'uuid';
3
+
4
+ @Injectable()
5
+ export class GeneratorService {
6
+ public uuid(): string {
7
+ return uuid();
8
+ }
9
+
10
+ public fileName(ext: string): string {
11
+ return this.uuid() + '.' + ext;
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ export * from './api-config.service';
2
+ export * from './aws-s3.service';
3
+ export * from './generator.service';
4
+ export * from './translation.service';
5
+ export * from './validator.service';
@@ -0,0 +1,21 @@
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("./api-config.service"), exports);
18
+ __exportStar(require("./aws-s3.service"), exports);
19
+ __exportStar(require("./generator.service"), exports);
20
+ __exportStar(require("./translation.service"), exports);
21
+ __exportStar(require("./validator.service"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './api-config.service';
2
+ export * from './aws-s3.service';
3
+ export * from './generator.service';
4
+ export * from './translation.service';
5
+ export * from './validator.service';
@@ -0,0 +1,9 @@
1
+ import type { TranslateOptions } from 'nestjs-i18n';
2
+ import { I18nService } from 'nestjs-i18n';
3
+ import { AbstractDto } from '../../common/dto/abstract.dto';
4
+ export declare class TranslationService {
5
+ private readonly i18n;
6
+ constructor(i18n: I18nService);
7
+ translate(key: string, options?: TranslateOptions): Promise<string>;
8
+ translateNecessaryKeys<T extends AbstractDto>(dto: T): Promise<T>;
9
+ }
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
46
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
47
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.TranslationService = void 0;
51
+ const common_1 = require("@nestjs/common");
52
+ const lodash_1 = require("lodash");
53
+ const abstract_dto_1 = require("../../common/dto/abstract.dto");
54
+ const decorators_1 = require("../../decorators");
55
+ const providers_1 = require("../../providers");
56
+ let TranslationService = (() => {
57
+ let _classDecorators = [(0, common_1.Injectable)()];
58
+ let _classDescriptor;
59
+ let _classExtraInitializers = [];
60
+ let _classThis;
61
+ var TranslationService = _classThis = class {
62
+ constructor(i18n) {
63
+ this.i18n = i18n;
64
+ }
65
+ translate(key, options) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ return this.i18n.translate(`${key}`, Object.assign(Object.assign({}, options), { lang: providers_1.ContextProvider.getLanguage() }));
68
+ });
69
+ }
70
+ translateNecessaryKeys(dto) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ if ((0, lodash_1.isString)(dto)) {
73
+ return dto;
74
+ }
75
+ yield Promise.all((0, lodash_1.map)(dto, (value, key) => __awaiter(this, void 0, void 0, function* () {
76
+ var _a;
77
+ if ((0, lodash_1.isString)(value)) {
78
+ const translateDec = Reflect.getMetadata(decorators_1.STATIC_TRANSLATION_DECORATOR_KEY, dto, key);
79
+ if (translateDec) {
80
+ return this.translate(`${(_a = translateDec.translationKey) !== null && _a !== void 0 ? _a : key}.${value}`);
81
+ }
82
+ return;
83
+ }
84
+ if (value instanceof abstract_dto_1.AbstractDto) {
85
+ return this.translateNecessaryKeys(value);
86
+ }
87
+ if ((0, lodash_1.isArray)(value)) {
88
+ return Promise.all((0, lodash_1.map)(value, (v) => {
89
+ if (v instanceof abstract_dto_1.AbstractDto) {
90
+ return this.translateNecessaryKeys(v);
91
+ }
92
+ }));
93
+ }
94
+ })));
95
+ return dto;
96
+ });
97
+ }
98
+ };
99
+ __setFunctionName(_classThis, "TranslationService");
100
+ (() => {
101
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
102
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
103
+ TranslationService = _classThis = _classDescriptor.value;
104
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
105
+ __runInitializers(_classThis, _classExtraInitializers);
106
+ })();
107
+ return TranslationService = _classThis;
108
+ })();
109
+ exports.TranslationService = TranslationService;
@@ -0,0 +1,59 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { isArray, isString, map } from 'lodash';
3
+ import type { TranslateOptions } from 'nestjs-i18n';
4
+ import { I18nService } from 'nestjs-i18n';
5
+
6
+ import { AbstractDto } from '../../common/dto/abstract.dto';
7
+ import { STATIC_TRANSLATION_DECORATOR_KEY } from '../../decorators';
8
+ import type { ITranslationDecoratorInterface } from '../../interfaces';
9
+ import { ContextProvider } from '../../providers';
10
+
11
+ @Injectable()
12
+ export class TranslationService {
13
+ constructor(private readonly i18n: I18nService) {}
14
+
15
+ async translate(key: string, options?: TranslateOptions): Promise<string> {
16
+ return this.i18n.translate(`${key}`, {
17
+ ...options,
18
+ lang: ContextProvider.getLanguage(),
19
+ });
20
+ }
21
+
22
+ async translateNecessaryKeys<T extends AbstractDto>(dto: T): Promise<T> {
23
+ if (isString(dto)) {
24
+ return dto;
25
+ }
26
+ await Promise.all(
27
+ map(dto, async (value, key) => {
28
+ if (isString(value)) {
29
+ const translateDec: ITranslationDecoratorInterface | undefined =
30
+ Reflect.getMetadata(STATIC_TRANSLATION_DECORATOR_KEY, dto, key);
31
+
32
+ if (translateDec) {
33
+ return this.translate(
34
+ `${translateDec.translationKey ?? key}.${value}`,
35
+ );
36
+ }
37
+
38
+ return;
39
+ }
40
+
41
+ if (value instanceof AbstractDto) {
42
+ return this.translateNecessaryKeys(value);
43
+ }
44
+
45
+ if (isArray(value)) {
46
+ return Promise.all(
47
+ map(value, (v) => {
48
+ if (v instanceof AbstractDto) {
49
+ return this.translateNecessaryKeys(v);
50
+ }
51
+ }),
52
+ );
53
+ }
54
+ }),
55
+ );
56
+
57
+ return dto;
58
+ }
59
+ }
@@ -0,0 +1,3 @@
1
+ export declare class ValidatorService {
2
+ isImage(mimeType: string): boolean;
3
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ValidatorService = void 0;
42
+ const common_1 = require("@nestjs/common");
43
+ let ValidatorService = (() => {
44
+ let _classDecorators = [(0, common_1.Injectable)()];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ var ValidatorService = _classThis = class {
49
+ isImage(mimeType) {
50
+ const imageMimeTypes = ['image/jpeg', 'image/png'];
51
+ return imageMimeTypes.includes(mimeType);
52
+ }
53
+ };
54
+ __setFunctionName(_classThis, "ValidatorService");
55
+ (() => {
56
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
57
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
58
+ ValidatorService = _classThis = _classDescriptor.value;
59
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
60
+ __runInitializers(_classThis, _classExtraInitializers);
61
+ })();
62
+ return ValidatorService = _classThis;
63
+ })();
64
+ exports.ValidatorService = ValidatorService;
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ @Injectable()
4
+ export class ValidatorService {
5
+ public isImage(mimeType: string): boolean {
6
+ const imageMimeTypes = ['image/jpeg', 'image/png'];
7
+
8
+ return imageMimeTypes.includes(mimeType);
9
+ }
10
+ }
@@ -0,0 +1,11 @@
1
+ import type { NamingStrategyInterface } from 'typeorm';
2
+ import { DefaultNamingStrategy } from 'typeorm';
3
+ export declare class SnakeNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface {
4
+ tableName(className: string, customName: string | undefined): string;
5
+ columnName(propertyName: string, customName: string | undefined, embeddedPrefixes: string[]): string;
6
+ relationName(propertyName: string): string;
7
+ joinColumnName(relationName: string, referencedColumnName: string): string;
8
+ joinTableName(firstTableName: string, secondTableName: string, firstPropertyName: string, _secondPropertyName: string): string;
9
+ joinTableColumnName(tableName: string, propertyName: string, columnName?: string): string;
10
+ classTableInheritanceParentColumnName(parentTableName: string, parentTableIdPropertyName: string): string;
11
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnakeNamingStrategy = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const StringUtils_1 = require("typeorm/util/StringUtils");
6
+ class SnakeNamingStrategy extends typeorm_1.DefaultNamingStrategy {
7
+ tableName(className, customName) {
8
+ if (className.includes('Entity')) {
9
+ className = className.replace('Entity', '');
10
+ }
11
+ return customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(className);
12
+ }
13
+ columnName(propertyName, customName, embeddedPrefixes) {
14
+ return ((0, StringUtils_1.snakeCase)(embeddedPrefixes.join('_')) +
15
+ (customName !== null && customName !== void 0 ? customName : (0, StringUtils_1.snakeCase)(propertyName)));
16
+ }
17
+ relationName(propertyName) {
18
+ return (0, StringUtils_1.snakeCase)(propertyName);
19
+ }
20
+ joinColumnName(relationName, referencedColumnName) {
21
+ return (0, StringUtils_1.snakeCase)(relationName + '_' + referencedColumnName);
22
+ }
23
+ joinTableName(firstTableName, secondTableName, firstPropertyName, _secondPropertyName) {
24
+ return (0, StringUtils_1.snakeCase)(firstTableName +
25
+ '_' +
26
+ firstPropertyName.replace(/\./gi, '_') +
27
+ '_' +
28
+ secondTableName);
29
+ }
30
+ joinTableColumnName(tableName, propertyName, columnName) {
31
+ return (0, StringUtils_1.snakeCase)(tableName + '_' + (columnName !== null && columnName !== void 0 ? columnName : propertyName));
32
+ }
33
+ classTableInheritanceParentColumnName(parentTableName, parentTableIdPropertyName) {
34
+ return (0, StringUtils_1.snakeCase)(`${parentTableName}_${parentTableIdPropertyName}`);
35
+ }
36
+ }
37
+ exports.SnakeNamingStrategy = SnakeNamingStrategy;
@@ -0,0 +1,64 @@
1
+ import type { NamingStrategyInterface } from 'typeorm';
2
+ import { DefaultNamingStrategy } from 'typeorm';
3
+ import { snakeCase } from 'typeorm/util/StringUtils';
4
+
5
+ export class SnakeNamingStrategy
6
+ extends DefaultNamingStrategy
7
+ implements NamingStrategyInterface
8
+ {
9
+ tableName(className: string, customName: string | undefined): string {
10
+ if (className.includes('Entity')) {
11
+ className = className.replace('Entity', '');
12
+ }
13
+ return customName ?? snakeCase(className);
14
+ }
15
+
16
+ columnName(
17
+ propertyName: string,
18
+ customName: string | undefined,
19
+ embeddedPrefixes: string[],
20
+ ): string {
21
+ return (
22
+ snakeCase(embeddedPrefixes.join('_')) +
23
+ (customName ?? snakeCase(propertyName))
24
+ );
25
+ }
26
+
27
+ relationName(propertyName: string): string {
28
+ return snakeCase(propertyName);
29
+ }
30
+
31
+ joinColumnName(relationName: string, referencedColumnName: string): string {
32
+ return snakeCase(relationName + '_' + referencedColumnName);
33
+ }
34
+
35
+ joinTableName(
36
+ firstTableName: string,
37
+ secondTableName: string,
38
+ firstPropertyName: string,
39
+ _secondPropertyName: string,
40
+ ): string {
41
+ return snakeCase(
42
+ firstTableName +
43
+ '_' +
44
+ firstPropertyName.replace(/\./gi, '_') +
45
+ '_' +
46
+ secondTableName,
47
+ );
48
+ }
49
+
50
+ joinTableColumnName(
51
+ tableName: string,
52
+ propertyName: string,
53
+ columnName?: string,
54
+ ): string {
55
+ return snakeCase(tableName + '_' + (columnName ?? propertyName));
56
+ }
57
+
58
+ classTableInheritanceParentColumnName(
59
+ parentTableName: string,
60
+ parentTableIdPropertyName: string,
61
+ ): string {
62
+ return snakeCase(`${parentTableName}_${parentTableIdPropertyName}`);
63
+ }
64
+ }
package/src/types.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (...arguments_: Arguments) => T;
2
+ export type Plain<T> = T;
3
+ export type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
4
+ export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
5
+ export type Path<T> = keyof T extends string ? PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T : never;
6
+ export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
7
+ export type KeyOfType<Entity, U> = {
8
+ [P in keyof Required<Entity>]: Required<Entity>[P] extends U ? P : Required<Entity>[P] extends U[] ? P : never;
9
+ }[keyof Entity];
package/src/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });