@nest-omni/core 2.0.1-0 → 2.0.1-1

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 (317) hide show
  1. package/package.json +1 -1
  2. package/.history/src/common/boilerplate.polyfill_20250521135408.ts +0 -202
  3. package/.history/src/common/boilerplate.polyfill_20250712165919.ts +0 -254
  4. package/.history/src/common/boilerplate.polyfill_20250712165924.ts +0 -254
  5. package/.history/src/common/boilerplate.polyfill_20250712165927.ts +0 -254
  6. package/.history/src/common/boilerplate.polyfill_20250712170044.ts +0 -265
  7. package/.history/src/common/boilerplate.polyfill_20250712170049.ts +0 -265
  8. package/.history/src/common/boilerplate.polyfill_20250712170053.ts +0 -265
  9. package/.history/src/common/boilerplate.polyfill_20250712170610.ts +0 -280
  10. package/.history/src/common/boilerplate.polyfill_20250712170614.ts +0 -280
  11. package/.history/src/common/boilerplate.polyfill_20250712170739.ts +0 -265
  12. package/.history/src/common/boilerplate.polyfill_20250712170801.ts +0 -291
  13. package/.history/src/common/boilerplate.polyfill_20250712170809.ts +0 -317
  14. package/.history/src/common/boilerplate.polyfill_20250712170816.ts +0 -319
  15. package/.history/src/common/boilerplate.polyfill_20250712170820.ts +0 -318
  16. package/.history/src/common/boilerplate.polyfill_20250712170824.ts +0 -318
  17. package/.history/src/common/boilerplate.polyfill_20250712171040.ts +0 -289
  18. package/README.md +0 -16
  19. package/build.sh +0 -45
  20. package/dist/package.json +0 -71
  21. package/dist/yarn.lock +0 -644
  22. package/src/.hygen.js +0 -116
  23. package/src/common/abstract-client.service.ts +0 -56
  24. package/src/common/abstract.entity.ts +0 -82
  25. package/src/common/boilerplate.polyfill.ts +0 -202
  26. package/src/common/dto/abstract.dto.ts +0 -61
  27. package/src/common/dto/bulk-id.dto.ts +0 -13
  28. package/src/common/dto/create-translation.dto.ts +0 -10
  29. package/src/common/dto/index.ts +0 -6
  30. package/src/common/dto/page-meta.dto.ts +0 -37
  31. package/src/common/dto/page-options.dto.ts +0 -35
  32. package/src/common/dto/page.dto.ts +0 -36
  33. package/src/common/index.ts +0 -7
  34. package/src/common/snake-naming.strategy.ts +0 -64
  35. package/src/common/types.ts +0 -44
  36. package/src/common/utils.ts +0 -45
  37. package/src/constants/index.ts +0 -2
  38. package/src/constants/language-code.ts +0 -7
  39. package/src/constants/order.ts +0 -4
  40. package/src/decorators/api-page-ok-response.decorator.ts +0 -32
  41. package/src/decorators/auth-user.decorator.ts +0 -16
  42. package/src/decorators/controller.decorator.ts +0 -8
  43. package/src/decorators/field.decorators.ts +0 -856
  44. package/src/decorators/http.decorators.ts +0 -10
  45. package/src/decorators/index.ts +0 -12
  46. package/src/decorators/operation.decorator.ts +0 -4
  47. package/src/decorators/property.decorators.ts +0 -62
  48. package/src/decorators/public-route.decorator.ts +0 -8
  49. package/src/decorators/swagger.schema.ts +0 -117
  50. package/src/decorators/timestamp-column.decorator.ts +0 -29
  51. package/src/decorators/transform.decorators.ts +0 -159
  52. package/src/decorators/translate.decorator.ts +0 -19
  53. package/src/decorators/use-dto.decorator.ts +0 -11
  54. package/src/decorators/user-check.decorator.ts +0 -30
  55. package/src/decorators/user.decorator.ts +0 -59
  56. package/src/decorators/user_auth.decorator.ts +0 -15
  57. package/src/decorators/validator.decorators.ts +0 -98
  58. package/src/exceptions/file-not-image.exception.ts +0 -7
  59. package/src/exceptions/index.ts +0 -2
  60. package/src/exceptions/page-type.exception.ts +0 -7
  61. package/src/exceptions/user-not-found.exception.ts +0 -7
  62. package/src/filters/bad-request.filter.ts +0 -77
  63. package/src/filters/constraint-errors.ts +0 -5
  64. package/src/filters/index.ts +0 -3
  65. package/src/filters/query-failed.filter.ts +0 -32
  66. package/src/health-checker/health-checker.controller.ts +0 -51
  67. package/src/health-checker/health-checker.module.ts +0 -13
  68. package/src/health-checker/health-indicators/service.indicator.ts +0 -44
  69. package/src/helpers/common.helper.ts +0 -49
  70. package/src/helpers/date.helper.ts +0 -64
  71. package/src/helpers/index.ts +0 -2
  72. package/src/i18n/en_US/validation.json +0 -41
  73. package/src/i18n/zh_CN/validation.json +0 -41
  74. package/src/index.ts +0 -11
  75. package/src/interceptors/index.ts +0 -2
  76. package/src/interceptors/language-interceptor.service.ts +0 -28
  77. package/src/interceptors/translation-interceptor.service.ts +0 -43
  78. package/src/interfaces/IApiFile.ts +0 -4
  79. package/src/interfaces/IFile.ts +0 -8
  80. package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
  81. package/src/interfaces/index.ts +0 -3
  82. package/src/interfaces/response.ts +0 -37
  83. package/src/middlewares/index.ts +0 -4
  84. package/src/middlewares/omni-auth.middleware.ts +0 -10
  85. package/src/middlewares/powerby.middleware.ts +0 -6
  86. package/src/middlewares/request-id.middleware.ts +0 -28
  87. package/src/middlewares/xml.middleware.ts +0 -14
  88. package/src/providers/context.provider.ts +0 -109
  89. package/src/providers/generator.provider.ts +0 -66
  90. package/src/providers/index.ts +0 -2
  91. package/src/setup/bootstrap.setup.ts +0 -254
  92. package/src/setup/index.ts +0 -1
  93. package/src/shared/index.ts +0 -2
  94. package/src/shared/serviceRegistryModule.ts +0 -135
  95. package/src/shared/services/api-config.service.ts +0 -336
  96. package/src/shared/services/generator.service.ts +0 -13
  97. package/src/shared/services/index.ts +0 -4
  98. package/src/shared/services/translation.service.ts +0 -59
  99. package/src/shared/services/validator.service.ts +0 -10
  100. package/src/validator-json/decorators.ts +0 -63
  101. package/src/validator-json/default.ts +0 -257
  102. package/src/validator-json/defaultConverters.ts +0 -402
  103. package/src/validator-json/index.ts +0 -4
  104. package/src/validator-json/options.ts +0 -50
  105. package/src/validators/file-mimetype.validator.ts +0 -34
  106. package/src/validators/index.ts +0 -6
  107. package/src/validators/is-exists.validator.ts +0 -60
  108. package/src/validators/is-unique.validator.ts +0 -93
  109. package/src/validators/phone-country-code.validator.ts +0 -36
  110. package/src/validators/same-as.validator.ts +0 -27
  111. package/src/validators/skip-empty.validator.ts +0 -25
  112. package/tsconfig.json +0 -31
  113. package/tsconfig.lib.json +0 -16
  114. /package/{dist/.hygen → .hygen}/new/crud/controller.ejs.t +0 -0
  115. /package/{dist/.hygen → .hygen}/new/crud/create.dto.ejs.t +0 -0
  116. /package/{dist/.hygen → .hygen}/new/crud/entity.ejs.t +0 -0
  117. /package/{dist/.hygen → .hygen}/new/crud/get.dto.ejs.t +0 -0
  118. /package/{dist/.hygen → .hygen}/new/crud/index-dto.ejs.t +0 -0
  119. /package/{dist/.hygen → .hygen}/new/crud/index-response.dto.ejs.t +0 -0
  120. /package/{dist/.hygen → .hygen}/new/crud/module.ejs.t +0 -0
  121. /package/{dist/.hygen → .hygen}/new/crud/prompt.js +0 -0
  122. /package/{dist/.hygen → .hygen}/new/crud/service.ejs.t +0 -0
  123. /package/{dist/.hygen → .hygen}/new/crud/update.dto.ejs.t +0 -0
  124. /package/{dist/.hygen → .hygen}/new/module/controller.ejs.t +0 -0
  125. /package/{dist/.hygen → .hygen}/new/module/create-command.ejs.t +0 -0
  126. /package/{dist/.hygen → .hygen}/new/module/create.dto.ejs.t +0 -0
  127. /package/{dist/.hygen → .hygen}/new/module/dto.ejs.t +0 -0
  128. /package/{dist/.hygen → .hygen}/new/module/entity.ejs.t +0 -0
  129. /package/{dist/.hygen → .hygen}/new/module/get-query.ejs.t +0 -0
  130. /package/{dist/.hygen → .hygen}/new/module/module.ejs.t +0 -0
  131. /package/{dist/.hygen → .hygen}/new/module/not-found.exception.ejs.t +0 -0
  132. /package/{dist/.hygen → .hygen}/new/module/page-options.dto.ejs.t +0 -0
  133. /package/{dist/.hygen → .hygen}/new/module/prompt.js +0 -0
  134. /package/{dist/.hygen → .hygen}/new/module/repository.ejs.t +0 -0
  135. /package/{dist/.hygen → .hygen}/new/module/service.ejs.t +0 -0
  136. /package/{dist/.hygen → .hygen}/new/module/translation-dto.ejs.t +0 -0
  137. /package/{dist/.hygen → .hygen}/new/module/translation-entity.ejs.t +0 -0
  138. /package/{dist/.hygen → .hygen}/new/module/translation-repository.ejs.t +0 -0
  139. /package/{dist/.hygen → .hygen}/new/module/update.dto.ejs.t +0 -0
  140. /package/{dist/.hygen.js → .hygen.js} +0 -0
  141. /package/{dist/common → common}/abstract-client.service.d.ts +0 -0
  142. /package/{dist/common → common}/abstract-client.service.js +0 -0
  143. /package/{dist/common → common}/abstract.entity.d.ts +0 -0
  144. /package/{dist/common → common}/abstract.entity.js +0 -0
  145. /package/{dist/common → common}/boilerplate.polyfill.d.ts +0 -0
  146. /package/{dist/common → common}/boilerplate.polyfill.js +0 -0
  147. /package/{dist/common → common}/dto/abstract.dto.d.ts +0 -0
  148. /package/{dist/common → common}/dto/abstract.dto.js +0 -0
  149. /package/{dist/common → common}/dto/bulk-id.dto.d.ts +0 -0
  150. /package/{dist/common → common}/dto/bulk-id.dto.js +0 -0
  151. /package/{dist/common → common}/dto/create-translation.dto.d.ts +0 -0
  152. /package/{dist/common → common}/dto/create-translation.dto.js +0 -0
  153. /package/{dist/common → common}/dto/index.d.ts +0 -0
  154. /package/{dist/common → common}/dto/index.js +0 -0
  155. /package/{dist/common → common}/dto/page-meta.dto.d.ts +0 -0
  156. /package/{dist/common → common}/dto/page-meta.dto.js +0 -0
  157. /package/{dist/common → common}/dto/page-options.dto.d.ts +0 -0
  158. /package/{dist/common → common}/dto/page-options.dto.js +0 -0
  159. /package/{dist/common → common}/dto/page.dto.d.ts +0 -0
  160. /package/{dist/common → common}/dto/page.dto.js +0 -0
  161. /package/{dist/common → common}/index.d.ts +0 -0
  162. /package/{dist/common → common}/index.js +0 -0
  163. /package/{dist/common → common}/snake-naming.strategy.d.ts +0 -0
  164. /package/{dist/common → common}/snake-naming.strategy.js +0 -0
  165. /package/{dist/common → common}/types.d.ts +0 -0
  166. /package/{dist/common → common}/types.js +0 -0
  167. /package/{dist/common → common}/utils.d.ts +0 -0
  168. /package/{dist/common → common}/utils.js +0 -0
  169. /package/{dist/constants → constants}/index.d.ts +0 -0
  170. /package/{dist/constants → constants}/index.js +0 -0
  171. /package/{dist/constants → constants}/language-code.d.ts +0 -0
  172. /package/{dist/constants → constants}/language-code.js +0 -0
  173. /package/{dist/constants → constants}/order.d.ts +0 -0
  174. /package/{dist/constants → constants}/order.js +0 -0
  175. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.d.ts +0 -0
  176. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.js +0 -0
  177. /package/{dist/decorators → decorators}/auth-user.decorator.d.ts +0 -0
  178. /package/{dist/decorators → decorators}/auth-user.decorator.js +0 -0
  179. /package/{dist/decorators → decorators}/controller.decorator.d.ts +0 -0
  180. /package/{dist/decorators → decorators}/controller.decorator.js +0 -0
  181. /package/{dist/decorators → decorators}/field.decorators.d.ts +0 -0
  182. /package/{dist/decorators → decorators}/field.decorators.js +0 -0
  183. /package/{dist/decorators → decorators}/http.decorators.d.ts +0 -0
  184. /package/{dist/decorators → decorators}/http.decorators.js +0 -0
  185. /package/{dist/decorators → decorators}/index.d.ts +0 -0
  186. /package/{dist/decorators → decorators}/index.js +0 -0
  187. /package/{dist/decorators → decorators}/operation.decorator.d.ts +0 -0
  188. /package/{dist/decorators → decorators}/operation.decorator.js +0 -0
  189. /package/{dist/decorators → decorators}/property.decorators.d.ts +0 -0
  190. /package/{dist/decorators → decorators}/property.decorators.js +0 -0
  191. /package/{dist/decorators → decorators}/public-route.decorator.d.ts +0 -0
  192. /package/{dist/decorators → decorators}/public-route.decorator.js +0 -0
  193. /package/{dist/decorators → decorators}/swagger.schema.d.ts +0 -0
  194. /package/{dist/decorators → decorators}/swagger.schema.js +0 -0
  195. /package/{dist/decorators → decorators}/timestamp-column.decorator.d.ts +0 -0
  196. /package/{dist/decorators → decorators}/timestamp-column.decorator.js +0 -0
  197. /package/{dist/decorators → decorators}/transform.decorators.d.ts +0 -0
  198. /package/{dist/decorators → decorators}/transform.decorators.js +0 -0
  199. /package/{dist/decorators → decorators}/translate.decorator.d.ts +0 -0
  200. /package/{dist/decorators → decorators}/translate.decorator.js +0 -0
  201. /package/{dist/decorators → decorators}/use-dto.decorator.d.ts +0 -0
  202. /package/{dist/decorators → decorators}/use-dto.decorator.js +0 -0
  203. /package/{dist/decorators → decorators}/user-check.decorator.d.ts +0 -0
  204. /package/{dist/decorators → decorators}/user-check.decorator.js +0 -0
  205. /package/{dist/decorators → decorators}/user.decorator.d.ts +0 -0
  206. /package/{dist/decorators → decorators}/user.decorator.js +0 -0
  207. /package/{dist/decorators → decorators}/user_auth.decorator.d.ts +0 -0
  208. /package/{dist/decorators → decorators}/user_auth.decorator.js +0 -0
  209. /package/{dist/decorators → decorators}/validator.decorators.d.ts +0 -0
  210. /package/{dist/decorators → decorators}/validator.decorators.js +0 -0
  211. /package/{dist/exceptions → exceptions}/file-not-image.exception.d.ts +0 -0
  212. /package/{dist/exceptions → exceptions}/file-not-image.exception.js +0 -0
  213. /package/{dist/exceptions → exceptions}/index.d.ts +0 -0
  214. /package/{dist/exceptions → exceptions}/index.js +0 -0
  215. /package/{dist/exceptions → exceptions}/page-type.exception.d.ts +0 -0
  216. /package/{dist/exceptions → exceptions}/page-type.exception.js +0 -0
  217. /package/{dist/exceptions → exceptions}/user-not-found.exception.d.ts +0 -0
  218. /package/{dist/exceptions → exceptions}/user-not-found.exception.js +0 -0
  219. /package/{dist/filters → filters}/bad-request.filter.d.ts +0 -0
  220. /package/{dist/filters → filters}/bad-request.filter.js +0 -0
  221. /package/{dist/filters → filters}/constraint-errors.d.ts +0 -0
  222. /package/{dist/filters → filters}/constraint-errors.js +0 -0
  223. /package/{dist/filters → filters}/index.d.ts +0 -0
  224. /package/{dist/filters → filters}/index.js +0 -0
  225. /package/{dist/filters → filters}/query-failed.filter.d.ts +0 -0
  226. /package/{dist/filters → filters}/query-failed.filter.js +0 -0
  227. /package/{dist/health-checker → health-checker}/health-checker.controller.d.ts +0 -0
  228. /package/{dist/health-checker → health-checker}/health-checker.controller.js +0 -0
  229. /package/{dist/health-checker → health-checker}/health-checker.module.d.ts +0 -0
  230. /package/{dist/health-checker → health-checker}/health-checker.module.js +0 -0
  231. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.d.ts +0 -0
  232. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.js +0 -0
  233. /package/{dist/helpers → helpers}/common.helper.d.ts +0 -0
  234. /package/{dist/helpers → helpers}/common.helper.js +0 -0
  235. /package/{dist/helpers → helpers}/date.helper.d.ts +0 -0
  236. /package/{dist/helpers → helpers}/date.helper.js +0 -0
  237. /package/{dist/helpers → helpers}/index.d.ts +0 -0
  238. /package/{dist/helpers → helpers}/index.js +0 -0
  239. /package/{dist/i18n → i18n}/en_US/validation.json +0 -0
  240. /package/{dist/i18n → i18n}/zh_CN/validation.json +0 -0
  241. /package/{dist/index.d.ts → index.d.ts} +0 -0
  242. /package/{dist/index.js → index.js} +0 -0
  243. /package/{dist/interceptors → interceptors}/index.d.ts +0 -0
  244. /package/{dist/interceptors → interceptors}/index.js +0 -0
  245. /package/{dist/interceptors → interceptors}/language-interceptor.service.d.ts +0 -0
  246. /package/{dist/interceptors → interceptors}/language-interceptor.service.js +0 -0
  247. /package/{dist/interceptors → interceptors}/translation-interceptor.service.d.ts +0 -0
  248. /package/{dist/interceptors → interceptors}/translation-interceptor.service.js +0 -0
  249. /package/{dist/interfaces → interfaces}/IApiFile.d.ts +0 -0
  250. /package/{dist/interfaces → interfaces}/IApiFile.js +0 -0
  251. /package/{dist/interfaces → interfaces}/IFile.d.ts +0 -0
  252. /package/{dist/interfaces → interfaces}/IFile.js +0 -0
  253. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
  254. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.js +0 -0
  255. /package/{dist/interfaces → interfaces}/index.d.ts +0 -0
  256. /package/{dist/interfaces → interfaces}/index.js +0 -0
  257. /package/{dist/interfaces → interfaces}/response.d.ts +0 -0
  258. /package/{dist/interfaces → interfaces}/response.js +0 -0
  259. /package/{dist/middlewares → middlewares}/index.d.ts +0 -0
  260. /package/{dist/middlewares → middlewares}/index.js +0 -0
  261. /package/{dist/middlewares → middlewares}/omni-auth.middleware.d.ts +0 -0
  262. /package/{dist/middlewares → middlewares}/omni-auth.middleware.js +0 -0
  263. /package/{dist/middlewares → middlewares}/powerby.middleware.d.ts +0 -0
  264. /package/{dist/middlewares → middlewares}/powerby.middleware.js +0 -0
  265. /package/{dist/middlewares → middlewares}/request-id.middleware.d.ts +0 -0
  266. /package/{dist/middlewares → middlewares}/request-id.middleware.js +0 -0
  267. /package/{dist/middlewares → middlewares}/xml.middleware.d.ts +0 -0
  268. /package/{dist/middlewares → middlewares}/xml.middleware.js +0 -0
  269. /package/{dist/providers → providers}/context.provider.d.ts +0 -0
  270. /package/{dist/providers → providers}/context.provider.js +0 -0
  271. /package/{dist/providers → providers}/generator.provider.d.ts +0 -0
  272. /package/{dist/providers → providers}/generator.provider.js +0 -0
  273. /package/{dist/providers → providers}/index.d.ts +0 -0
  274. /package/{dist/providers → providers}/index.js +0 -0
  275. /package/{dist/setup → setup}/bootstrap.setup.d.ts +0 -0
  276. /package/{dist/setup → setup}/bootstrap.setup.js +0 -0
  277. /package/{dist/setup → setup}/index.d.ts +0 -0
  278. /package/{dist/setup → setup}/index.js +0 -0
  279. /package/{dist/shared → shared}/index.d.ts +0 -0
  280. /package/{dist/shared → shared}/index.js +0 -0
  281. /package/{dist/shared → shared}/serviceRegistryModule.d.ts +0 -0
  282. /package/{dist/shared → shared}/serviceRegistryModule.js +0 -0
  283. /package/{dist/shared → shared}/services/api-config.service.d.ts +0 -0
  284. /package/{dist/shared → shared}/services/api-config.service.js +0 -0
  285. /package/{dist/shared → shared}/services/generator.service.d.ts +0 -0
  286. /package/{dist/shared → shared}/services/generator.service.js +0 -0
  287. /package/{dist/shared → shared}/services/index.d.ts +0 -0
  288. /package/{dist/shared → shared}/services/index.js +0 -0
  289. /package/{dist/shared → shared}/services/translation.service.d.ts +0 -0
  290. /package/{dist/shared → shared}/services/translation.service.js +0 -0
  291. /package/{dist/shared → shared}/services/validator.service.d.ts +0 -0
  292. /package/{dist/shared → shared}/services/validator.service.js +0 -0
  293. /package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +0 -0
  294. /package/{dist/validator-json → validator-json}/decorators.d.ts +0 -0
  295. /package/{dist/validator-json → validator-json}/decorators.js +0 -0
  296. /package/{dist/validator-json → validator-json}/default.d.ts +0 -0
  297. /package/{dist/validator-json → validator-json}/default.js +0 -0
  298. /package/{dist/validator-json → validator-json}/defaultConverters.d.ts +0 -0
  299. /package/{dist/validator-json → validator-json}/defaultConverters.js +0 -0
  300. /package/{dist/validator-json → validator-json}/index.d.ts +0 -0
  301. /package/{dist/validator-json → validator-json}/index.js +0 -0
  302. /package/{dist/validator-json → validator-json}/options.d.ts +0 -0
  303. /package/{dist/validator-json → validator-json}/options.js +0 -0
  304. /package/{dist/validators → validators}/file-mimetype.validator.d.ts +0 -0
  305. /package/{dist/validators → validators}/file-mimetype.validator.js +0 -0
  306. /package/{dist/validators → validators}/index.d.ts +0 -0
  307. /package/{dist/validators → validators}/index.js +0 -0
  308. /package/{dist/validators → validators}/is-exists.validator.d.ts +0 -0
  309. /package/{dist/validators → validators}/is-exists.validator.js +0 -0
  310. /package/{dist/validators → validators}/is-unique.validator.d.ts +0 -0
  311. /package/{dist/validators → validators}/is-unique.validator.js +0 -0
  312. /package/{dist/validators → validators}/phone-country-code.validator.d.ts +0 -0
  313. /package/{dist/validators → validators}/phone-country-code.validator.js +0 -0
  314. /package/{dist/validators → validators}/same-as.validator.d.ts +0 -0
  315. /package/{dist/validators → validators}/same-as.validator.js +0 -0
  316. /package/{dist/validators → validators}/skip-empty.validator.d.ts +0 -0
  317. /package/{dist/validators → validators}/skip-empty.validator.js +0 -0
@@ -1,10 +0,0 @@
1
- import type { PipeTransform } from '@nestjs/common';
2
- import { Param, ParseUUIDPipe } from '@nestjs/common';
3
- import type { Type } from '@nestjs/common/interfaces';
4
-
5
- export function UUIDParam(
6
- property: string,
7
- ...pipes: Array<Type<PipeTransform> | PipeTransform>
8
- ): ParameterDecorator {
9
- return Param(property, new ParseUUIDPipe({ version: '4' }), ...pipes);
10
- }
@@ -1,12 +0,0 @@
1
- export * from './api-page-ok-response.decorator';
2
- export * from './auth-user.decorator';
3
- export * from './field.decorators';
4
- export * from './http.decorators';
5
- export * from './property.decorators';
6
- export * from './public-route.decorator';
7
- export * from './swagger.schema';
8
- export * from './transform.decorators';
9
- export * from './translate.decorator';
10
- export * from './use-dto.decorator';
11
- export * from './validator.decorators';
12
- export * from './controller.decorator';
@@ -1,4 +0,0 @@
1
- import { SetMetadata } from '@nestjs/common';
2
-
3
- export const OperationLog = (operation: string) =>
4
- SetMetadata('operation-log', operation);
@@ -1,62 +0,0 @@
1
- import type { ApiPropertyOptions } from '@nestjs/swagger';
2
- import { ApiProperty } from '@nestjs/swagger';
3
-
4
- import { getVariableName } from '../common/utils';
5
- import { getEnumDescription } from '../decorators/field.decorators';
6
-
7
- export function ApiBooleanProperty(
8
- options: Omit<ApiPropertyOptions, 'type'> = {},
9
- ): PropertyDecorator {
10
- return ApiProperty({ type: Boolean, ...options });
11
- }
12
-
13
- export function ApiBooleanPropertyOptional(
14
- options: Omit<ApiPropertyOptions, 'type' | 'required'> = {},
15
- ): PropertyDecorator {
16
- return ApiBooleanProperty({ required: false, ...options });
17
- }
18
-
19
- export function ApiUUIDProperty(
20
- options: Omit<ApiPropertyOptions, 'type' | 'format'> &
21
- Partial<{ each: boolean }> = {},
22
- ): PropertyDecorator {
23
- return ApiProperty({
24
- type: options.each ? [String] : String,
25
- format: 'uuid',
26
- isArray: options.each,
27
- ...options,
28
- });
29
- }
30
-
31
- export function ApiUUIDPropertyOptional(
32
- options: Omit<ApiPropertyOptions, 'type' | 'format' | 'required'> &
33
- Partial<{ each: boolean }> = {},
34
- ): PropertyDecorator {
35
- return ApiUUIDProperty({ required: false, ...options });
36
- }
37
-
38
- export function ApiEnumProperty<TEnum>(
39
- getEnum: () => TEnum,
40
- options: Omit<ApiPropertyOptions, 'type'> & { each?: boolean } = {},
41
- ): PropertyDecorator {
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
- const enumValue = getEnum() as any;
44
- options.description = getEnumDescription(enumValue);
45
- return ApiProperty({
46
- type: 'enum',
47
- // throw error during the compilation of swagger
48
- // isArray: options.each,
49
- enum: enumValue,
50
- enumName: getVariableName(getEnum),
51
- ...options,
52
- });
53
- }
54
-
55
- export function ApiEnumPropertyOptional<TEnum>(
56
- getEnum: () => TEnum,
57
- options: Omit<ApiPropertyOptions, 'type' | 'required'> & {
58
- each?: boolean;
59
- } = {},
60
- ): PropertyDecorator {
61
- return ApiEnumProperty(getEnum, { required: false, ...options });
62
- }
@@ -1,8 +0,0 @@
1
- import type { CustomDecorator } from '@nestjs/common';
2
- import { SetMetadata } from '@nestjs/common';
3
-
4
- export const PUBLIC_ROUTE_KEY = 'public_route';
5
-
6
- // eslint-disable-next-line @typescript-eslint/naming-convention
7
- export const PublicRoute = (isPublic = false): CustomDecorator =>
8
- SetMetadata(PUBLIC_ROUTE_KEY, isPublic);
@@ -1,117 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-types,@typescript-eslint/no-unsafe-argument */
2
- import type { Type } from '@nestjs/common';
3
- import { applyDecorators, UseInterceptors } from '@nestjs/common';
4
- import { PARAMTYPES_METADATA, ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
5
- import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
6
- import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
7
- import { ApiBody, ApiConsumes, ApiExtraModels, getSchemaPath } from '@nestjs/swagger';
8
- import type { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
9
- import { reverseObjectKeys } from '@nestjs/swagger/dist/utils/reverse-object-keys.util';
10
- import _ from 'lodash';
11
-
12
- import type { IApiFile } from '../interfaces';
13
-
14
- function explore(instance: Object, propertyKey: string | symbol) {
15
- const types: Array<Type<unknown>> = Reflect.getMetadata(
16
- PARAMTYPES_METADATA,
17
- instance,
18
- propertyKey,
19
- );
20
- const routeArgsMetadata =
21
- Reflect.getMetadata(
22
- ROUTE_ARGS_METADATA,
23
- instance.constructor,
24
- propertyKey,
25
- ) || {};
26
-
27
- const parametersWithType = _.mapValues(
28
- reverseObjectKeys(routeArgsMetadata),
29
- (param) => ({
30
- type: types[param.index],
31
- name: param.data,
32
- required: true,
33
- }),
34
- );
35
-
36
- for (const [key, value] of Object.entries(parametersWithType)) {
37
- const keyPair = key.split(':');
38
-
39
- if (Number(keyPair[0]) === RouteParamtypes.BODY) {
40
- return value.type;
41
- }
42
- }
43
- }
44
-
45
- function RegisterModels(): MethodDecorator {
46
- return (target, propertyKey, descriptor: PropertyDescriptor) => {
47
- const body = explore(target, propertyKey);
48
-
49
- return body && ApiExtraModels(body)(target, propertyKey, descriptor);
50
- };
51
- }
52
-
53
- function ApiFileDecorator(
54
- files: IApiFile[] = [],
55
- options: Partial<{ isRequired: boolean }> = {},
56
- ): MethodDecorator {
57
- return (target, propertyKey, descriptor: PropertyDescriptor) => {
58
- const { isRequired = false } = options;
59
- const fileSchema: SchemaObject = {
60
- type: 'string',
61
- format: 'binary',
62
- };
63
- const properties: Record<string, SchemaObject | ReferenceObject> = {};
64
-
65
- for (const file of files) {
66
- if (file.isArray) {
67
- properties[file.name] = {
68
- type: 'array',
69
- items: fileSchema,
70
- };
71
- } else {
72
- properties[file.name] = fileSchema;
73
- }
74
- }
75
-
76
- let schema: SchemaObject = {
77
- properties,
78
- type: 'object',
79
- };
80
- const body = explore(target, propertyKey);
81
-
82
- if (body) {
83
- schema = {
84
- allOf: [
85
- {
86
- $ref: getSchemaPath(body),
87
- },
88
- { properties, type: 'object' },
89
- ],
90
- };
91
- }
92
-
93
- return ApiBody({
94
- schema,
95
- required: isRequired,
96
- })(target, propertyKey, descriptor);
97
- };
98
- }
99
-
100
- export function ApiFile(
101
- files: _.Many<IApiFile>,
102
- options: Partial<{ isRequired: boolean }> = {},
103
- ): MethodDecorator {
104
- const filesArray = _.castArray(files);
105
- const apiFileInterceptors = filesArray.map((file) =>
106
- file.isArray
107
- ? UseInterceptors(FilesInterceptor(file.name))
108
- : UseInterceptors(FileInterceptor(file.name)),
109
- );
110
-
111
- return applyDecorators(
112
- RegisterModels(),
113
- ApiConsumes('multipart/form-data'),
114
- ApiFileDecorator(filesArray, options),
115
- ...apiFileInterceptors,
116
- );
117
- }
@@ -1,29 +0,0 @@
1
- import { applyDecorators } from '@nestjs/common';
2
- import { ApiProperty } from '@nestjs/swagger';
3
- import { Column } from 'typeorm';
4
- import { formatDateTime, strToTimeStamp } from '../helpers';
5
-
6
- export function TimestampColumn(name: string, description?: string) {
7
- return applyDecorators(
8
- ApiProperty({
9
- required: false,
10
- type: 'string',
11
- format: 'date-time',
12
- example: '2018-10-01 12:18:48',
13
- description,
14
- }),
15
- Column({
16
- type: 'int',
17
- name,
18
- nullable: false,
19
- unsigned: true,
20
- default: 0,
21
- comment: description,
22
- transformer: {
23
- to: (value) =>
24
- value === 0 || /\d{10}/.test(value) ? value : strToTimeStamp(value),
25
- from: (value) => formatDateTime(value),
26
- },
27
- }),
28
- );
29
- }
@@ -1,159 +0,0 @@
1
- import { Transform, TransformationType } from 'class-transformer';
2
- import { parsePhoneNumber } from 'libphonenumber-js';
3
- import { castArray, isArray, map, trim } from 'lodash';
4
-
5
- import { GeneratorProvider } from '../providers';
6
-
7
- /**
8
- * @description trim spaces from start and end, replace multiple spaces with one.
9
- * @example
10
- * @ApiProperty()
11
- * @IsString()
12
- * @Trim()
13
- * name: string;
14
- * @returns PropertyDecorator
15
- * @constructor
16
- */
17
- export function Trim(): PropertyDecorator {
18
- return Transform((params) => {
19
- const value = params.value as string[] | string;
20
-
21
- if (isArray(value)) {
22
- // @ts-ignore
23
- return map(value, (v) => trim(v).replaceAll(/\s\s+/g, ' '));
24
- }
25
-
26
- // @ts-ignore
27
- return trim(value).replaceAll(/\s\s+/g, ' ');
28
- });
29
- }
30
-
31
- export function ToBoolean(): PropertyDecorator {
32
- return Transform(
33
- (params) => {
34
- switch (params.value) {
35
- case 'true': {
36
- return true;
37
- }
38
-
39
- case 'false': {
40
- return false;
41
- }
42
-
43
- default: {
44
- return params.value;
45
- }
46
- }
47
- },
48
- { toClassOnly: true },
49
- );
50
- }
51
-
52
- /**
53
- * @description convert string or number to integer
54
- * @example
55
- * @IsNumber()
56
- * @ToInt()
57
- * name: number;
58
- * @returns PropertyDecorator
59
- * @constructor
60
- */
61
- export function ToInt(): PropertyDecorator {
62
- return Transform(
63
- (params) => {
64
- const value = params.value as string;
65
-
66
- return Number.parseInt(value, 10);
67
- },
68
- { toClassOnly: true },
69
- );
70
- }
71
-
72
- /**
73
- * @description transforms to array, specially for query params
74
- * @example
75
- * @IsNumber()
76
- * @ToArray()
77
- * name: number;
78
- * @constructor
79
- */
80
- export function ToArray(): PropertyDecorator {
81
- return Transform(
82
- (params): unknown[] => {
83
- const value = params.value;
84
-
85
- if (!value) {
86
- return value;
87
- }
88
-
89
- return castArray(value);
90
- },
91
- { toClassOnly: true },
92
- );
93
- }
94
-
95
- export function ToLowerCase(): PropertyDecorator {
96
- return Transform(
97
- (params) => {
98
- const value = params.value;
99
-
100
- if (!value) {
101
- return;
102
- }
103
-
104
- if (!Array.isArray(value)) {
105
- return value.toLowerCase();
106
- }
107
-
108
- return value.map((v) => v.toLowerCase());
109
- },
110
- {
111
- toClassOnly: true,
112
- },
113
- );
114
- }
115
-
116
- export function ToUpperCase(): PropertyDecorator {
117
- return Transform(
118
- (params) => {
119
- const value = params.value;
120
-
121
- if (!value) {
122
- return;
123
- }
124
-
125
- if (!Array.isArray(value)) {
126
- return value.toUpperCase();
127
- }
128
-
129
- return value.map((v) => v.toUpperCase());
130
- },
131
- {
132
- toClassOnly: true,
133
- },
134
- );
135
- }
136
-
137
- export function S3UrlParser(): PropertyDecorator {
138
- return Transform((params) => {
139
- const key = params.value as string;
140
-
141
- switch (params.type) {
142
- case TransformationType.CLASS_TO_PLAIN: {
143
- return GeneratorProvider.getS3PublicUrl(key);
144
- }
145
-
146
- case TransformationType.PLAIN_TO_CLASS: {
147
- return GeneratorProvider.getS3Key(key);
148
- }
149
-
150
- default: {
151
- return key;
152
- }
153
- }
154
- });
155
- }
156
-
157
- export function PhoneNumberSerializer(): PropertyDecorator {
158
- return Transform((params) => parsePhoneNumber(params.value as string).number);
159
- }
@@ -1,19 +0,0 @@
1
- import type { ITranslationDecoratorInterface } from '../interfaces';
2
-
3
- export const STATIC_TRANSLATION_DECORATOR_KEY = 'custom:static-translate';
4
- export const DYNAMIC_TRANSLATION_DECORATOR_KEY = 'custom:dynamic-translate';
5
-
6
- // FIXME: This is a temporary solution to get the translation decorator working.
7
- export function StaticTranslate(
8
- data: ITranslationDecoratorInterface = {},
9
- ): PropertyDecorator {
10
- return (target, key) => {
11
- Reflect.defineMetadata(STATIC_TRANSLATION_DECORATOR_KEY, data, target, key);
12
- };
13
- }
14
-
15
- export function DynamicTranslate(): PropertyDecorator {
16
- return (target, key) => {
17
- Reflect.defineMetadata(DYNAMIC_TRANSLATION_DECORATOR_KEY, {}, target, key);
18
- };
19
- }
@@ -1,11 +0,0 @@
1
- import type { AbstractEntity } from '../common/abstract.entity';
2
- import type { AbstractDto } from '../common/dto/abstract.dto';
3
- import type { Constructor } from '../common/types';
4
-
5
- export function UseDto(
6
- dtoClass: Constructor<AbstractDto, [AbstractEntity, unknown]>,
7
- ): ClassDecorator {
8
- return (ctor) => {
9
- ctor.prototype.dtoClass = dtoClass;
10
- };
11
- }
@@ -1,30 +0,0 @@
1
- import { createParamDecorator, ExecutionContext } from '@nestjs/common';
2
- import * as lodash from 'lodash';
3
-
4
- export interface IUser {
5
- uid: number;
6
- username: string;
7
- }
8
-
9
- export const User = createParamDecorator(
10
- (data: string, ctx: ExecutionContext): IUser => {
11
- return getUserData(ctx.switchToHttp().getRequest(), data);
12
- },
13
- );
14
-
15
- export function getUserData(req, data?: string): IUser | null {
16
- const headers = req.headers;
17
- if (
18
- lodash.isEmpty(headers['x-user-id']) ||
19
- lodash.isEmpty(headers['x-username'])
20
- ) {
21
- return null;
22
- }
23
-
24
- const user = {
25
- uid: headers['x-user-id'],
26
- username: headers['x-username'],
27
- };
28
-
29
- return data ? user[data] : user;
30
- }
@@ -1,59 +0,0 @@
1
- import { createParamDecorator } from '@nestjs/common';
2
- import { isEmpty } from 'lodash';
3
- import { ConfigService } from '@nestjs/config';
4
- import { ContextProvider } from '../providers';
5
-
6
- export interface IUser {
7
- uid: string;
8
- username: string;
9
- tenantId: string;
10
- appId: string;
11
- admin: boolean;
12
- role: string;
13
- }
14
-
15
- export const User = createParamDecorator(
16
- (key?: keyof IUser): IUser | IUser[keyof IUser] => {
17
- const authUser = ContextProvider.getAuthUser();
18
- return key ? authUser[key] : authUser;
19
- },
20
- );
21
-
22
- export function getOmniAuthData<T extends keyof IUser>(
23
- request: { headers: Record<string, string> },
24
- key?: T,
25
- ): IUser[T] | IUser {
26
- const headers = request.headers;
27
- let user: IUser;
28
- const configService = new ConfigService(request);
29
-
30
- // 未通过网关透传用户信息且处于local开发环境,则从配置获取用户信息
31
- if (isEmpty(headers['x-user-id']) && isEmpty(headers['x-app-id'])) {
32
- if (process.env.NODE_ENV === 'dev') {
33
- user = {
34
- uid: configService.get('MOCK_UID'),
35
- username: configService.get('MOCK_USERNAME'),
36
- appId: configService.get('MOCK_APP_ID'),
37
- tenantId: configService.get('MOCK_TENANT_ID'),
38
- admin: configService.get('MOCK_ADMIN', false),
39
- role: configService.get('MOCK_ROLE', ''),
40
- };
41
- } else {
42
- console.debug(
43
- 'User information is not transparently transmitted through the gateway: ' +
44
- JSON.stringify(headers),
45
- );
46
- }
47
- } else {
48
- user = {
49
- uid: headers['x-user-id'] || '',
50
- username: headers['x-username'] || '',
51
- appId: headers['x-app-id'] || '',
52
- tenantId: headers['x-tenant-id'] || '',
53
- admin: headers['x-admin'] === '1',
54
- role: headers['x-role'] || '',
55
- };
56
- }
57
-
58
- return key ? user[key] : user;
59
- }
@@ -1,15 +0,0 @@
1
- import { applyDecorators } from '@nestjs/common';
2
- import { CrudAuth } from '@dataui/crud';
3
- import { getOmniAuthData } from './user.decorator';
4
-
5
- export function UserFilter(field: string) {
6
- const obj = {};
7
- return applyDecorators(
8
- CrudAuth({
9
- filter: (req) => {
10
- obj[field] = getOmniAuthData(req, 'uid');
11
- return obj;
12
- },
13
- }),
14
- );
15
- }
@@ -1,98 +0,0 @@
1
- import type { ValidationOptions } from 'class-validator';
2
- import {
3
- IsPhoneNumber as isPhoneNumber,
4
- registerDecorator,
5
- ValidateIf,
6
- } from 'class-validator';
7
- import { isString } from 'lodash';
8
-
9
- export function IsPassword(
10
- validationOptions?: ValidationOptions,
11
- ): PropertyDecorator {
12
- return (object, propertyName: string) => {
13
- registerDecorator({
14
- propertyName,
15
- name: 'isPassword',
16
- target: object.constructor,
17
- constraints: [],
18
- options: validationOptions,
19
- validator: {
20
- validate(value: string) {
21
- return /^[\d!#$%&*@A-Z^a-z]*$/.test(value);
22
- },
23
- },
24
- });
25
- };
26
- }
27
-
28
- export function IsPhoneNumber(
29
- validationOptions?: ValidationOptions & {
30
- region?: Parameters<typeof isPhoneNumber>[0];
31
- },
32
- ): PropertyDecorator {
33
- return isPhoneNumber(validationOptions?.region, {
34
- message: 'error.phoneNumber',
35
- ...validationOptions,
36
- });
37
- }
38
-
39
- export function IsTmpKey(
40
- validationOptions?: ValidationOptions,
41
- ): PropertyDecorator {
42
- return (object, propertyName: string) => {
43
- registerDecorator({
44
- propertyName,
45
- name: 'tmpKey',
46
- target: object.constructor,
47
- options: validationOptions,
48
- validator: {
49
- validate(value: string): boolean {
50
- return isString(value) && /^tmp\//.test(value);
51
- },
52
- defaultMessage(): string {
53
- return 'error.invalidTmpKey';
54
- },
55
- },
56
- });
57
- };
58
- }
59
-
60
- export function IsUndefinable(options?: ValidationOptions): PropertyDecorator {
61
- return ValidateIf((obj, value) => value !== undefined, options);
62
- }
63
-
64
- export function IsEmptyable(options?: ValidationOptions): PropertyDecorator {
65
- return ValidateIf(
66
- (obj, value) =>
67
- !(
68
- value === null ||
69
- value === undefined ||
70
- (isString(value) && value.trim() === '')
71
- ),
72
- options,
73
- );
74
- }
75
-
76
- export function IsNullable(options?: ValidationOptions): PropertyDecorator {
77
- return ValidateIf((obj, value) => value !== null, options);
78
- }
79
-
80
- export function IsHttpUrl(validationOptions?: ValidationOptions) {
81
- return function (object, propertyName: string) {
82
- registerDecorator({
83
- name: 'isHttpUrl',
84
- target: object.constructor,
85
- propertyName: propertyName,
86
- options: validationOptions,
87
- validator: {
88
- validate(value: any) {
89
- const httpUrlPattern = /^(https?:\/\/)/i;
90
- return typeof value === 'string' && httpUrlPattern.test(value);
91
- },
92
- defaultMessage(): string {
93
- return 'URL must start with http:// or https://';
94
- },
95
- },
96
- });
97
- };
98
- }
@@ -1,7 +0,0 @@
1
- import { BadRequestException } from '@nestjs/common';
2
-
3
- export class FileNotImageException extends BadRequestException {
4
- constructor(error?: string) {
5
- super('error.fileNotImage', error);
6
- }
7
- }
@@ -1,2 +0,0 @@
1
- export * from './file-not-image.exception';
2
- export * from './user-not-found.exception';
@@ -1,7 +0,0 @@
1
- import { BadRequestException } from '@nestjs/common';
2
-
3
- export class PageTypeException extends BadRequestException {
4
- constructor() {
5
- super('error.pageType');
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- import { NotFoundException } from '@nestjs/common';
2
-
3
- export class UserNotFoundException extends NotFoundException {
4
- constructor(error?: string) {
5
- super('error.userNotFound', error);
6
- }
7
- }