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

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 (318) hide show
  1. package/{dist/decorators → decorators}/user.decorator.js +1 -1
  2. package/package.json +11 -4
  3. package/{dist/setup → setup}/bootstrap.setup.js +57 -22
  4. package/{dist/shared → shared}/serviceRegistryModule.js +11 -34
  5. package/tsconfig.tsbuildinfo +1 -0
  6. package/.history/src/common/boilerplate.polyfill_20250521135408.ts +0 -202
  7. package/.history/src/common/boilerplate.polyfill_20250712165919.ts +0 -254
  8. package/.history/src/common/boilerplate.polyfill_20250712165924.ts +0 -254
  9. package/.history/src/common/boilerplate.polyfill_20250712165927.ts +0 -254
  10. package/.history/src/common/boilerplate.polyfill_20250712170044.ts +0 -265
  11. package/.history/src/common/boilerplate.polyfill_20250712170049.ts +0 -265
  12. package/.history/src/common/boilerplate.polyfill_20250712170053.ts +0 -265
  13. package/.history/src/common/boilerplate.polyfill_20250712170610.ts +0 -280
  14. package/.history/src/common/boilerplate.polyfill_20250712170614.ts +0 -280
  15. package/.history/src/common/boilerplate.polyfill_20250712170739.ts +0 -265
  16. package/.history/src/common/boilerplate.polyfill_20250712170801.ts +0 -291
  17. package/.history/src/common/boilerplate.polyfill_20250712170809.ts +0 -317
  18. package/.history/src/common/boilerplate.polyfill_20250712170816.ts +0 -319
  19. package/.history/src/common/boilerplate.polyfill_20250712170820.ts +0 -318
  20. package/.history/src/common/boilerplate.polyfill_20250712170824.ts +0 -318
  21. package/.history/src/common/boilerplate.polyfill_20250712171040.ts +0 -289
  22. package/README.md +0 -16
  23. package/build.sh +0 -45
  24. package/dist/package.json +0 -71
  25. package/dist/tsconfig.tsbuildinfo +0 -1
  26. package/dist/yarn.lock +0 -644
  27. package/src/.hygen.js +0 -116
  28. package/src/common/abstract-client.service.ts +0 -56
  29. package/src/common/abstract.entity.ts +0 -82
  30. package/src/common/boilerplate.polyfill.ts +0 -202
  31. package/src/common/dto/abstract.dto.ts +0 -61
  32. package/src/common/dto/bulk-id.dto.ts +0 -13
  33. package/src/common/dto/create-translation.dto.ts +0 -10
  34. package/src/common/dto/index.ts +0 -6
  35. package/src/common/dto/page-meta.dto.ts +0 -37
  36. package/src/common/dto/page-options.dto.ts +0 -35
  37. package/src/common/dto/page.dto.ts +0 -36
  38. package/src/common/index.ts +0 -7
  39. package/src/common/snake-naming.strategy.ts +0 -64
  40. package/src/common/types.ts +0 -44
  41. package/src/common/utils.ts +0 -45
  42. package/src/constants/index.ts +0 -2
  43. package/src/constants/language-code.ts +0 -7
  44. package/src/constants/order.ts +0 -4
  45. package/src/decorators/api-page-ok-response.decorator.ts +0 -32
  46. package/src/decorators/auth-user.decorator.ts +0 -16
  47. package/src/decorators/controller.decorator.ts +0 -8
  48. package/src/decorators/field.decorators.ts +0 -856
  49. package/src/decorators/http.decorators.ts +0 -10
  50. package/src/decorators/index.ts +0 -12
  51. package/src/decorators/operation.decorator.ts +0 -4
  52. package/src/decorators/property.decorators.ts +0 -62
  53. package/src/decorators/public-route.decorator.ts +0 -8
  54. package/src/decorators/swagger.schema.ts +0 -117
  55. package/src/decorators/timestamp-column.decorator.ts +0 -29
  56. package/src/decorators/transform.decorators.ts +0 -159
  57. package/src/decorators/translate.decorator.ts +0 -19
  58. package/src/decorators/use-dto.decorator.ts +0 -11
  59. package/src/decorators/user-check.decorator.ts +0 -30
  60. package/src/decorators/user.decorator.ts +0 -59
  61. package/src/decorators/user_auth.decorator.ts +0 -15
  62. package/src/decorators/validator.decorators.ts +0 -98
  63. package/src/exceptions/file-not-image.exception.ts +0 -7
  64. package/src/exceptions/index.ts +0 -2
  65. package/src/exceptions/page-type.exception.ts +0 -7
  66. package/src/exceptions/user-not-found.exception.ts +0 -7
  67. package/src/filters/bad-request.filter.ts +0 -77
  68. package/src/filters/constraint-errors.ts +0 -5
  69. package/src/filters/index.ts +0 -3
  70. package/src/filters/query-failed.filter.ts +0 -32
  71. package/src/health-checker/health-checker.controller.ts +0 -51
  72. package/src/health-checker/health-checker.module.ts +0 -13
  73. package/src/health-checker/health-indicators/service.indicator.ts +0 -44
  74. package/src/helpers/common.helper.ts +0 -49
  75. package/src/helpers/date.helper.ts +0 -64
  76. package/src/helpers/index.ts +0 -2
  77. package/src/i18n/en_US/validation.json +0 -41
  78. package/src/i18n/zh_CN/validation.json +0 -41
  79. package/src/index.ts +0 -11
  80. package/src/interceptors/index.ts +0 -2
  81. package/src/interceptors/language-interceptor.service.ts +0 -28
  82. package/src/interceptors/translation-interceptor.service.ts +0 -43
  83. package/src/interfaces/IApiFile.ts +0 -4
  84. package/src/interfaces/IFile.ts +0 -8
  85. package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
  86. package/src/interfaces/index.ts +0 -3
  87. package/src/interfaces/response.ts +0 -37
  88. package/src/middlewares/index.ts +0 -4
  89. package/src/middlewares/omni-auth.middleware.ts +0 -10
  90. package/src/middlewares/powerby.middleware.ts +0 -6
  91. package/src/middlewares/request-id.middleware.ts +0 -28
  92. package/src/middlewares/xml.middleware.ts +0 -14
  93. package/src/providers/context.provider.ts +0 -109
  94. package/src/providers/generator.provider.ts +0 -66
  95. package/src/providers/index.ts +0 -2
  96. package/src/setup/bootstrap.setup.ts +0 -254
  97. package/src/setup/index.ts +0 -1
  98. package/src/shared/index.ts +0 -2
  99. package/src/shared/serviceRegistryModule.ts +0 -135
  100. package/src/shared/services/api-config.service.ts +0 -336
  101. package/src/shared/services/generator.service.ts +0 -13
  102. package/src/shared/services/index.ts +0 -4
  103. package/src/shared/services/translation.service.ts +0 -59
  104. package/src/shared/services/validator.service.ts +0 -10
  105. package/src/validator-json/decorators.ts +0 -63
  106. package/src/validator-json/default.ts +0 -257
  107. package/src/validator-json/defaultConverters.ts +0 -402
  108. package/src/validator-json/index.ts +0 -4
  109. package/src/validator-json/options.ts +0 -50
  110. package/src/validators/file-mimetype.validator.ts +0 -34
  111. package/src/validators/index.ts +0 -6
  112. package/src/validators/is-exists.validator.ts +0 -60
  113. package/src/validators/is-unique.validator.ts +0 -93
  114. package/src/validators/phone-country-code.validator.ts +0 -36
  115. package/src/validators/same-as.validator.ts +0 -27
  116. package/src/validators/skip-empty.validator.ts +0 -25
  117. package/tsconfig.json +0 -31
  118. package/tsconfig.lib.json +0 -16
  119. /package/{dist/.hygen → .hygen}/new/crud/controller.ejs.t +0 -0
  120. /package/{dist/.hygen → .hygen}/new/crud/create.dto.ejs.t +0 -0
  121. /package/{dist/.hygen → .hygen}/new/crud/entity.ejs.t +0 -0
  122. /package/{dist/.hygen → .hygen}/new/crud/get.dto.ejs.t +0 -0
  123. /package/{dist/.hygen → .hygen}/new/crud/index-dto.ejs.t +0 -0
  124. /package/{dist/.hygen → .hygen}/new/crud/index-response.dto.ejs.t +0 -0
  125. /package/{dist/.hygen → .hygen}/new/crud/module.ejs.t +0 -0
  126. /package/{dist/.hygen → .hygen}/new/crud/prompt.js +0 -0
  127. /package/{dist/.hygen → .hygen}/new/crud/service.ejs.t +0 -0
  128. /package/{dist/.hygen → .hygen}/new/crud/update.dto.ejs.t +0 -0
  129. /package/{dist/.hygen → .hygen}/new/module/controller.ejs.t +0 -0
  130. /package/{dist/.hygen → .hygen}/new/module/create-command.ejs.t +0 -0
  131. /package/{dist/.hygen → .hygen}/new/module/create.dto.ejs.t +0 -0
  132. /package/{dist/.hygen → .hygen}/new/module/dto.ejs.t +0 -0
  133. /package/{dist/.hygen → .hygen}/new/module/entity.ejs.t +0 -0
  134. /package/{dist/.hygen → .hygen}/new/module/get-query.ejs.t +0 -0
  135. /package/{dist/.hygen → .hygen}/new/module/module.ejs.t +0 -0
  136. /package/{dist/.hygen → .hygen}/new/module/not-found.exception.ejs.t +0 -0
  137. /package/{dist/.hygen → .hygen}/new/module/page-options.dto.ejs.t +0 -0
  138. /package/{dist/.hygen → .hygen}/new/module/prompt.js +0 -0
  139. /package/{dist/.hygen → .hygen}/new/module/repository.ejs.t +0 -0
  140. /package/{dist/.hygen → .hygen}/new/module/service.ejs.t +0 -0
  141. /package/{dist/.hygen → .hygen}/new/module/translation-dto.ejs.t +0 -0
  142. /package/{dist/.hygen → .hygen}/new/module/translation-entity.ejs.t +0 -0
  143. /package/{dist/.hygen → .hygen}/new/module/translation-repository.ejs.t +0 -0
  144. /package/{dist/.hygen → .hygen}/new/module/update.dto.ejs.t +0 -0
  145. /package/{dist/.hygen.js → .hygen.js} +0 -0
  146. /package/{dist/common → common}/abstract-client.service.d.ts +0 -0
  147. /package/{dist/common → common}/abstract-client.service.js +0 -0
  148. /package/{dist/common → common}/abstract.entity.d.ts +0 -0
  149. /package/{dist/common → common}/abstract.entity.js +0 -0
  150. /package/{dist/common → common}/boilerplate.polyfill.d.ts +0 -0
  151. /package/{dist/common → common}/boilerplate.polyfill.js +0 -0
  152. /package/{dist/common → common}/dto/abstract.dto.d.ts +0 -0
  153. /package/{dist/common → common}/dto/abstract.dto.js +0 -0
  154. /package/{dist/common → common}/dto/bulk-id.dto.d.ts +0 -0
  155. /package/{dist/common → common}/dto/bulk-id.dto.js +0 -0
  156. /package/{dist/common → common}/dto/create-translation.dto.d.ts +0 -0
  157. /package/{dist/common → common}/dto/create-translation.dto.js +0 -0
  158. /package/{dist/common → common}/dto/index.d.ts +0 -0
  159. /package/{dist/common → common}/dto/index.js +0 -0
  160. /package/{dist/common → common}/dto/page-meta.dto.d.ts +0 -0
  161. /package/{dist/common → common}/dto/page-meta.dto.js +0 -0
  162. /package/{dist/common → common}/dto/page-options.dto.d.ts +0 -0
  163. /package/{dist/common → common}/dto/page-options.dto.js +0 -0
  164. /package/{dist/common → common}/dto/page.dto.d.ts +0 -0
  165. /package/{dist/common → common}/dto/page.dto.js +0 -0
  166. /package/{dist/common → common}/index.d.ts +0 -0
  167. /package/{dist/common → common}/index.js +0 -0
  168. /package/{dist/common → common}/snake-naming.strategy.d.ts +0 -0
  169. /package/{dist/common → common}/snake-naming.strategy.js +0 -0
  170. /package/{dist/common → common}/types.d.ts +0 -0
  171. /package/{dist/common → common}/types.js +0 -0
  172. /package/{dist/common → common}/utils.d.ts +0 -0
  173. /package/{dist/common → common}/utils.js +0 -0
  174. /package/{dist/constants → constants}/index.d.ts +0 -0
  175. /package/{dist/constants → constants}/index.js +0 -0
  176. /package/{dist/constants → constants}/language-code.d.ts +0 -0
  177. /package/{dist/constants → constants}/language-code.js +0 -0
  178. /package/{dist/constants → constants}/order.d.ts +0 -0
  179. /package/{dist/constants → constants}/order.js +0 -0
  180. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.d.ts +0 -0
  181. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.js +0 -0
  182. /package/{dist/decorators → decorators}/auth-user.decorator.d.ts +0 -0
  183. /package/{dist/decorators → decorators}/auth-user.decorator.js +0 -0
  184. /package/{dist/decorators → decorators}/controller.decorator.d.ts +0 -0
  185. /package/{dist/decorators → decorators}/controller.decorator.js +0 -0
  186. /package/{dist/decorators → decorators}/field.decorators.d.ts +0 -0
  187. /package/{dist/decorators → decorators}/field.decorators.js +0 -0
  188. /package/{dist/decorators → decorators}/http.decorators.d.ts +0 -0
  189. /package/{dist/decorators → decorators}/http.decorators.js +0 -0
  190. /package/{dist/decorators → decorators}/index.d.ts +0 -0
  191. /package/{dist/decorators → decorators}/index.js +0 -0
  192. /package/{dist/decorators → decorators}/operation.decorator.d.ts +0 -0
  193. /package/{dist/decorators → decorators}/operation.decorator.js +0 -0
  194. /package/{dist/decorators → decorators}/property.decorators.d.ts +0 -0
  195. /package/{dist/decorators → decorators}/property.decorators.js +0 -0
  196. /package/{dist/decorators → decorators}/public-route.decorator.d.ts +0 -0
  197. /package/{dist/decorators → decorators}/public-route.decorator.js +0 -0
  198. /package/{dist/decorators → decorators}/swagger.schema.d.ts +0 -0
  199. /package/{dist/decorators → decorators}/swagger.schema.js +0 -0
  200. /package/{dist/decorators → decorators}/timestamp-column.decorator.d.ts +0 -0
  201. /package/{dist/decorators → decorators}/timestamp-column.decorator.js +0 -0
  202. /package/{dist/decorators → decorators}/transform.decorators.d.ts +0 -0
  203. /package/{dist/decorators → decorators}/transform.decorators.js +0 -0
  204. /package/{dist/decorators → decorators}/translate.decorator.d.ts +0 -0
  205. /package/{dist/decorators → decorators}/translate.decorator.js +0 -0
  206. /package/{dist/decorators → decorators}/use-dto.decorator.d.ts +0 -0
  207. /package/{dist/decorators → decorators}/use-dto.decorator.js +0 -0
  208. /package/{dist/decorators → decorators}/user-check.decorator.d.ts +0 -0
  209. /package/{dist/decorators → decorators}/user-check.decorator.js +0 -0
  210. /package/{dist/decorators → decorators}/user.decorator.d.ts +0 -0
  211. /package/{dist/decorators → decorators}/user_auth.decorator.d.ts +0 -0
  212. /package/{dist/decorators → decorators}/user_auth.decorator.js +0 -0
  213. /package/{dist/decorators → decorators}/validator.decorators.d.ts +0 -0
  214. /package/{dist/decorators → decorators}/validator.decorators.js +0 -0
  215. /package/{dist/exceptions → exceptions}/file-not-image.exception.d.ts +0 -0
  216. /package/{dist/exceptions → exceptions}/file-not-image.exception.js +0 -0
  217. /package/{dist/exceptions → exceptions}/index.d.ts +0 -0
  218. /package/{dist/exceptions → exceptions}/index.js +0 -0
  219. /package/{dist/exceptions → exceptions}/page-type.exception.d.ts +0 -0
  220. /package/{dist/exceptions → exceptions}/page-type.exception.js +0 -0
  221. /package/{dist/exceptions → exceptions}/user-not-found.exception.d.ts +0 -0
  222. /package/{dist/exceptions → exceptions}/user-not-found.exception.js +0 -0
  223. /package/{dist/filters → filters}/bad-request.filter.d.ts +0 -0
  224. /package/{dist/filters → filters}/bad-request.filter.js +0 -0
  225. /package/{dist/filters → filters}/constraint-errors.d.ts +0 -0
  226. /package/{dist/filters → filters}/constraint-errors.js +0 -0
  227. /package/{dist/filters → filters}/index.d.ts +0 -0
  228. /package/{dist/filters → filters}/index.js +0 -0
  229. /package/{dist/filters → filters}/query-failed.filter.d.ts +0 -0
  230. /package/{dist/filters → filters}/query-failed.filter.js +0 -0
  231. /package/{dist/health-checker → health-checker}/health-checker.controller.d.ts +0 -0
  232. /package/{dist/health-checker → health-checker}/health-checker.controller.js +0 -0
  233. /package/{dist/health-checker → health-checker}/health-checker.module.d.ts +0 -0
  234. /package/{dist/health-checker → health-checker}/health-checker.module.js +0 -0
  235. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.d.ts +0 -0
  236. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.js +0 -0
  237. /package/{dist/helpers → helpers}/common.helper.d.ts +0 -0
  238. /package/{dist/helpers → helpers}/common.helper.js +0 -0
  239. /package/{dist/helpers → helpers}/date.helper.d.ts +0 -0
  240. /package/{dist/helpers → helpers}/date.helper.js +0 -0
  241. /package/{dist/helpers → helpers}/index.d.ts +0 -0
  242. /package/{dist/helpers → helpers}/index.js +0 -0
  243. /package/{dist/i18n → i18n}/en_US/validation.json +0 -0
  244. /package/{dist/i18n → i18n}/zh_CN/validation.json +0 -0
  245. /package/{dist/index.d.ts → index.d.ts} +0 -0
  246. /package/{dist/index.js → index.js} +0 -0
  247. /package/{dist/interceptors → interceptors}/index.d.ts +0 -0
  248. /package/{dist/interceptors → interceptors}/index.js +0 -0
  249. /package/{dist/interceptors → interceptors}/language-interceptor.service.d.ts +0 -0
  250. /package/{dist/interceptors → interceptors}/language-interceptor.service.js +0 -0
  251. /package/{dist/interceptors → interceptors}/translation-interceptor.service.d.ts +0 -0
  252. /package/{dist/interceptors → interceptors}/translation-interceptor.service.js +0 -0
  253. /package/{dist/interfaces → interfaces}/IApiFile.d.ts +0 -0
  254. /package/{dist/interfaces → interfaces}/IApiFile.js +0 -0
  255. /package/{dist/interfaces → interfaces}/IFile.d.ts +0 -0
  256. /package/{dist/interfaces → interfaces}/IFile.js +0 -0
  257. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
  258. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.js +0 -0
  259. /package/{dist/interfaces → interfaces}/index.d.ts +0 -0
  260. /package/{dist/interfaces → interfaces}/index.js +0 -0
  261. /package/{dist/interfaces → interfaces}/response.d.ts +0 -0
  262. /package/{dist/interfaces → interfaces}/response.js +0 -0
  263. /package/{dist/middlewares → middlewares}/index.d.ts +0 -0
  264. /package/{dist/middlewares → middlewares}/index.js +0 -0
  265. /package/{dist/middlewares → middlewares}/omni-auth.middleware.d.ts +0 -0
  266. /package/{dist/middlewares → middlewares}/omni-auth.middleware.js +0 -0
  267. /package/{dist/middlewares → middlewares}/powerby.middleware.d.ts +0 -0
  268. /package/{dist/middlewares → middlewares}/powerby.middleware.js +0 -0
  269. /package/{dist/middlewares → middlewares}/request-id.middleware.d.ts +0 -0
  270. /package/{dist/middlewares → middlewares}/request-id.middleware.js +0 -0
  271. /package/{dist/middlewares → middlewares}/xml.middleware.d.ts +0 -0
  272. /package/{dist/middlewares → middlewares}/xml.middleware.js +0 -0
  273. /package/{dist/providers → providers}/context.provider.d.ts +0 -0
  274. /package/{dist/providers → providers}/context.provider.js +0 -0
  275. /package/{dist/providers → providers}/generator.provider.d.ts +0 -0
  276. /package/{dist/providers → providers}/generator.provider.js +0 -0
  277. /package/{dist/providers → providers}/index.d.ts +0 -0
  278. /package/{dist/providers → providers}/index.js +0 -0
  279. /package/{dist/setup → setup}/bootstrap.setup.d.ts +0 -0
  280. /package/{dist/setup → setup}/index.d.ts +0 -0
  281. /package/{dist/setup → setup}/index.js +0 -0
  282. /package/{dist/shared → shared}/index.d.ts +0 -0
  283. /package/{dist/shared → shared}/index.js +0 -0
  284. /package/{dist/shared → shared}/serviceRegistryModule.d.ts +0 -0
  285. /package/{dist/shared → shared}/services/api-config.service.d.ts +0 -0
  286. /package/{dist/shared → shared}/services/api-config.service.js +0 -0
  287. /package/{dist/shared → shared}/services/generator.service.d.ts +0 -0
  288. /package/{dist/shared → shared}/services/generator.service.js +0 -0
  289. /package/{dist/shared → shared}/services/index.d.ts +0 -0
  290. /package/{dist/shared → shared}/services/index.js +0 -0
  291. /package/{dist/shared → shared}/services/translation.service.d.ts +0 -0
  292. /package/{dist/shared → shared}/services/translation.service.js +0 -0
  293. /package/{dist/shared → shared}/services/validator.service.d.ts +0 -0
  294. /package/{dist/shared → shared}/services/validator.service.js +0 -0
  295. /package/{dist/validator-json → validator-json}/decorators.d.ts +0 -0
  296. /package/{dist/validator-json → validator-json}/decorators.js +0 -0
  297. /package/{dist/validator-json → validator-json}/default.d.ts +0 -0
  298. /package/{dist/validator-json → validator-json}/default.js +0 -0
  299. /package/{dist/validator-json → validator-json}/defaultConverters.d.ts +0 -0
  300. /package/{dist/validator-json → validator-json}/defaultConverters.js +0 -0
  301. /package/{dist/validator-json → validator-json}/index.d.ts +0 -0
  302. /package/{dist/validator-json → validator-json}/index.js +0 -0
  303. /package/{dist/validator-json → validator-json}/options.d.ts +0 -0
  304. /package/{dist/validator-json → validator-json}/options.js +0 -0
  305. /package/{dist/validators → validators}/file-mimetype.validator.d.ts +0 -0
  306. /package/{dist/validators → validators}/file-mimetype.validator.js +0 -0
  307. /package/{dist/validators → validators}/index.d.ts +0 -0
  308. /package/{dist/validators → validators}/index.js +0 -0
  309. /package/{dist/validators → validators}/is-exists.validator.d.ts +0 -0
  310. /package/{dist/validators → validators}/is-exists.validator.js +0 -0
  311. /package/{dist/validators → validators}/is-unique.validator.d.ts +0 -0
  312. /package/{dist/validators → validators}/is-unique.validator.js +0 -0
  313. /package/{dist/validators → validators}/phone-country-code.validator.d.ts +0 -0
  314. /package/{dist/validators → validators}/phone-country-code.validator.js +0 -0
  315. /package/{dist/validators → validators}/same-as.validator.d.ts +0 -0
  316. /package/{dist/validators → validators}/same-as.validator.js +0 -0
  317. /package/{dist/validators → validators}/skip-empty.validator.d.ts +0 -0
  318. /package/{dist/validators → validators}/skip-empty.validator.js +0 -0
package/src/.hygen.js DELETED
@@ -1,116 +0,0 @@
1
- module.exports = {
2
- templates: `${__dirname}/.hygen`,
3
- helpers: {
4
- ControllerName(name) {
5
- return `${this.ClassName(name)}Controller`;
6
- },
7
- ServiceName(name) {
8
- return `${this.ClassName(name)}Service`;
9
- },
10
- ModuleName(name) {
11
- return `${this.ClassName(name)}Module`;
12
- },
13
- DtoName(name) {
14
- return `${this.ClassName(name)}Dto`;
15
- },
16
- TranslationDtoName(name) {
17
- return `${this.ClassName(name)}TranslationDto`;
18
- },
19
- UpdateDtoName(name) {
20
- return `Update${this.DtoName(name)}`;
21
- },
22
- DtoOptionName(name) {
23
- return `I${this.DtoName(name)}Options`;
24
- },
25
- CreateDtoName(name) {
26
- return `Create${this.DtoName(name)}`;
27
- },
28
- EntityName(name) {
29
- return `${this.ClassName(name)}Entity`;
30
- },
31
- TranslationEntityName(name) {
32
- return `${this.ClassName(name)}TranslationEntity`;
33
- },
34
- CreateCommandName(name) {
35
- return `Create${this.ClassName(name)}Command`;
36
- },
37
- CreateHandlerName(name) {
38
- return `Create${this.ClassName(name)}Handler`;
39
- },
40
- GetHandlerName(name) {
41
- return `Get${this.ClassName(name)}Handler`;
42
- },
43
- GetQueryName(name) {
44
- return `Get${this.ClassName(name)}Query`;
45
- },
46
- PageOptionsDtoName(name) {
47
- return this.ClassName(name) + 'PageOptionsDto';
48
- },
49
- NotFoundExceptionName(name) {
50
- return this.ClassName(name) + 'NotFoundException';
51
- },
52
- entityFileName(name) {
53
- return `${this.fileName(name)}.entity`;
54
- },
55
- translationEntityFileName(name) {
56
- return `${this.fileName(name)}-translation.entity`;
57
- },
58
- translationDtoFileName(name) {
59
- return `${this.fileName(name)}-translation.dto`;
60
- },
61
- repositoryFileName(name) {
62
- return `${this.fileName(name)}.repository`;
63
- },
64
- translationRepositoryFileName(name) {
65
- return `${this.fileName(name)}-translation.repository`;
66
- },
67
- createCommandFileName(name) {
68
- return `create-${this.fileName(name)}.command`;
69
- },
70
- getQueryFileName(name) {
71
- return `get-${this.fileName(name)}.query`;
72
- },
73
- controllerFileName(name) {
74
- return `${this.fileName(name)}.controller`;
75
- },
76
- dtoFileName(name) {
77
- return `${this.fileName(name)}.dto`;
78
- },
79
- notFoundExceptionFileName(name) {
80
- return `${this.fileName(name)}-not-found.exception`;
81
- },
82
- createDtoFileName(name) {
83
- return `create-${this.fileName(name)}.dto`;
84
- },
85
- updateDtoFileName(name) {
86
- return `update-${this.fileName(name)}.dto`;
87
- },
88
- pageOptionsDtoFileName(name) {
89
- return `${this.fileName(name)}-page-options.dto`;
90
- },
91
- serviceFileName(name) {
92
- return `${this.fileName(name)}.service`;
93
- },
94
- moduleFileName(name) {
95
- return `${this.fileName(name)}.module`;
96
- },
97
- ClassName(name) {
98
- return this.changeCase.pascal(name);
99
- },
100
- TableName(name) {
101
- return this.inflection.underscore(this.ClassName(name));
102
- },
103
- RepositoryName(name) {
104
- return `${this.ClassName(name)}Repository`;
105
- },
106
- TranslationRepositoryName(name) {
107
- return `${this.ClassName(name)}TranslationRepository`;
108
- },
109
- moduleName(name) {
110
- return this.changeCase.camel(name);
111
- },
112
- fileName(name) {
113
- return this.inflection.dasherize(name).toLowerCase();
114
- },
115
- },
116
- }
@@ -1,56 +0,0 @@
1
- import type { ClientProxy } from '@nestjs/microservices';
2
- import { plainToInstance } from 'class-transformer';
3
- import { firstValueFrom } from 'rxjs';
4
-
5
- import { PageTypeException } from '../exceptions/page-type.exception';
6
- import type { Constructor } from './types';
7
- import type { PageDto } from './dto/page.dto';
8
- import type { PageMetaDto } from './dto/page-meta.dto';
9
-
10
- /**
11
- * Fixme: This class designed to use with @nestjs/microservices by extending and creating a new class.
12
- * TODO: Create Implementation and usage of it
13
- */
14
- export class AbstractClientService<ActionType> {
15
- constructor(private client: ClientProxy) {}
16
-
17
- public async send(pattern: ActionType, data: unknown): Promise<void>;
18
-
19
- public async send<R>(
20
- pattern: ActionType,
21
- data: unknown,
22
- returnDataOptions: { class: Constructor<R>; isPage: true },
23
- ): Promise<PageDto<R>>;
24
-
25
- public async send<R>(
26
- pattern: ActionType,
27
- data: unknown,
28
- returnDataOptions?: { class: Constructor<R>; isPage?: false },
29
- ): Promise<R>;
30
-
31
- public async send<R, I>(
32
- pattern: ActionType,
33
- data: I,
34
- returnDataOptions?: Partial<{
35
- class?: Constructor<R>;
36
- isPage?: boolean;
37
- }>,
38
- ): Promise<R | PageDto<R> | void> {
39
- const returnData = await firstValueFrom(
40
- this.client.send<{ data?: R; meta?: PageMetaDto }>(pattern, data),
41
- {
42
- defaultValue: undefined,
43
- },
44
- );
45
-
46
- if (returnDataOptions?.isPage && (!returnData?.data || !returnData.meta)) {
47
- throw new PageTypeException();
48
- }
49
-
50
- if (!returnDataOptions?.class || returnDataOptions.isPage) {
51
- return returnData as R;
52
- }
53
-
54
- return plainToInstance(returnDataOptions.class, returnData);
55
- }
56
- }
@@ -1,82 +0,0 @@
1
- import {
2
- BeforeInsert,
3
- Column,
4
- CreateDateColumn,
5
- PrimaryGeneratedColumn,
6
- UpdateDateColumn,
7
- } from 'typeorm';
8
-
9
- import type { AbstractDto, AbstractTranslationDto } from './dto/abstract.dto';
10
- import { NumberFieldOptional, StringFieldOptional } from '../decorators';
11
- import { LanguageCode } from '../constants';
12
- import { v4 as uuidv4 } from 'uuid';
13
- /**
14
- * Abstract Entity
15
- *
16
- * @description This class is an abstract class for all entities.
17
- * It's experimental and recommended using it only in microservice architecture,
18
- * otherwise just delete and use your own entity.
19
- */
20
- export abstract class AbstractBaseEntity<DTO, O> {
21
- @CreateDateColumn({
22
- type: 'timestamp',
23
- })
24
- createdAt: Date;
25
-
26
- @UpdateDateColumn({
27
- type: 'timestamp',
28
- })
29
- updatedAt: Date;
30
-
31
- translations?: AbstractTranslationEntity[];
32
-
33
- toDto(options?: O): DTO {
34
- const dtoClass = Object.getPrototypeOf(this).dtoClass;
35
-
36
- if (!dtoClass) {
37
- throw new Error(
38
- `You need to use @UseDto on class (${this.constructor.name}) be able to call toDto function`,
39
- );
40
- }
41
-
42
- return new dtoClass(this, options);
43
- }
44
- }
45
-
46
- export class AbstractEntity<
47
- DTO extends AbstractDto = AbstractDto,
48
- O = never,
49
- > extends AbstractBaseEntity<DTO, O> {
50
- @PrimaryGeneratedColumn('increment')
51
- @NumberFieldOptional({ swagger: false })
52
- id: number;
53
- }
54
-
55
- export class AbstractTranslationEntity<
56
- DTO extends AbstractTranslationDto = AbstractTranslationDto,
57
- O = never,
58
- > extends AbstractEntity<DTO, O> {
59
- @Column({ type: 'enum', enum: LanguageCode })
60
- languageCode: LanguageCode;
61
- }
62
-
63
- export class AbstractUuidPrimaryEntity<
64
- DTO extends AbstractDto = AbstractDto,
65
- O = never,
66
- > extends AbstractBaseEntity<DTO, O> {
67
- @PrimaryGeneratedColumn('uuid')
68
- @StringFieldOptional({
69
- maxLength: 36,
70
- minLength: 2,
71
- example: '23247899-c237-4ab1-9639-3322029d2e1c',
72
- swagger: false,
73
- })
74
- id: string;
75
-
76
- @BeforeInsert()
77
- generateId() {
78
- if (!this.id || this.id?.length < 2) {
79
- this.id = uuidv4();
80
- }
81
- }
82
- }
@@ -1,202 +0,0 @@
1
- import 'source-map-support/register';
2
-
3
- import { compact, map } from 'lodash';
4
- import type { ObjectLiteral } from 'typeorm';
5
- import { Brackets, SelectQueryBuilder } from 'typeorm';
6
-
7
- import type { AbstractEntity } from './abstract.entity';
8
- import type { AbstractDto } from './dto/abstract.dto';
9
- import type { CreateTranslationDto } from './dto/create-translation.dto';
10
- import { PageDto } from './dto/page.dto';
11
- import { PageMetaDto } from './dto/page-meta.dto';
12
- import type { PageOptionsDto } from './dto/page-options.dto';
13
- import type { LanguageCode } from '../constants/language-code';
14
- import type { KeyOfType } from './types';
15
- import { ContextProvider } from '../providers';
16
-
17
- declare global {
18
- export type Uuid = string & { _uuidBrand: undefined };
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-redundant-type-constituents
20
- export type Todo = any & { _todoBrand: undefined };
21
-
22
- // eslint-disable-next-line @typescript-eslint/naming-convention
23
- interface Array<T> {
24
- toDtos<Dto extends AbstractDto>(this: T[], options?: unknown): Dto[];
25
-
26
- getByLanguage(
27
- this: CreateTranslationDto[],
28
- languageCode: LanguageCode,
29
- ): string;
30
-
31
- toPageDto<Dto extends AbstractDto>(
32
- this: T[],
33
- pageMetaDto: PageMetaDto,
34
- // FIXME make option type visible from entity
35
- options?: unknown,
36
- ): PageDto<Dto>;
37
- }
38
- }
39
-
40
- declare module 'typeorm' {
41
- // eslint-disable-next-line @typescript-eslint/naming-convention
42
- interface SelectQueryBuilder<Entity> {
43
- searchByString(
44
- q: string,
45
- columnNames: string[],
46
- options?: {
47
- formStart: boolean;
48
- },
49
- ): this;
50
-
51
- withTenant(tenantId?: string | number, tenantFieldName?: string): this;
52
-
53
- paginate(
54
- this: SelectQueryBuilder<Entity>,
55
- pageOptionsDto: PageOptionsDto,
56
- options?: Partial<{ takeAll: boolean; skipCount: boolean }>,
57
- ): Promise<[Entity[], PageMetaDto]>;
58
-
59
- leftJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
60
- this: SelectQueryBuilder<Entity>,
61
- property: `${A}.${Exclude<
62
- KeyOfType<AliasEntity, AbstractEntity>,
63
- symbol
64
- >}`,
65
- alias: string,
66
- condition?: string,
67
- parameters?: ObjectLiteral,
68
- ): this;
69
-
70
- leftJoin<AliasEntity extends AbstractEntity, A extends string>(
71
- this: SelectQueryBuilder<Entity>,
72
- property: `${A}.${Exclude<
73
- KeyOfType<AliasEntity, AbstractEntity>,
74
- symbol
75
- >}`,
76
- alias: string,
77
- condition?: string,
78
- parameters?: ObjectLiteral,
79
- ): this;
80
-
81
- innerJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
82
- this: SelectQueryBuilder<Entity>,
83
- property: `${A}.${Exclude<
84
- KeyOfType<AliasEntity, AbstractEntity>,
85
- symbol
86
- >}`,
87
- alias: string,
88
- condition?: string,
89
- parameters?: ObjectLiteral,
90
- ): this;
91
-
92
- innerJoin<AliasEntity extends AbstractEntity, A extends string>(
93
- this: SelectQueryBuilder<Entity>,
94
- property: `${A}.${Exclude<
95
- KeyOfType<AliasEntity, AbstractEntity>,
96
- symbol
97
- >}`,
98
- alias: string,
99
- condition?: string,
100
- parameters?: ObjectLiteral,
101
- ): this;
102
- }
103
- }
104
-
105
- Array.prototype.toDtos = function <
106
- Entity extends AbstractEntity<Dto>,
107
- Dto extends AbstractDto,
108
- >(options?: unknown): Dto[] {
109
- return compact(
110
- map<Entity, Dto>(this as Entity[], (item) => item.toDto(options as never)),
111
- );
112
- };
113
-
114
- Array.prototype.getByLanguage = function (languageCode: LanguageCode): string {
115
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
116
- return this.find((translation) => languageCode === translation.languageCode)!
117
- .text;
118
- };
119
-
120
- Array.prototype.toPageDto = function (
121
- pageMetaDto: PageMetaDto,
122
- options?: unknown,
123
- ) {
124
- return new PageDto(this.toDtos(options), pageMetaDto);
125
- };
126
-
127
- SelectQueryBuilder.prototype.searchByString = function (
128
- q,
129
- columnNames,
130
- options,
131
- ) {
132
- if (!q) {
133
- return this;
134
- }
135
-
136
- this.andWhere(
137
- new Brackets((qb) => {
138
- for (const item of columnNames) {
139
- qb.orWhere(`${item} ILIKE :q`);
140
- }
141
- }),
142
- );
143
-
144
- if (options?.formStart) {
145
- this.setParameter('q', `${q}%`);
146
- } else {
147
- this.setParameter('q', `%${q}%`);
148
- }
149
-
150
- return this;
151
- };
152
-
153
- SelectQueryBuilder.prototype.paginate = async function (
154
- pageOptionsDto: PageOptionsDto,
155
- options?: Partial<{
156
- skipCount: boolean;
157
- takeAll: boolean;
158
- }>,
159
- ) {
160
- if (!options?.takeAll) {
161
- this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
162
- }
163
-
164
- const entities = await this.getMany();
165
-
166
- let itemCount = -1;
167
-
168
- if (!options?.skipCount) {
169
- itemCount = await this.getCount();
170
- }
171
-
172
- const pageMetaDto = new PageMetaDto({
173
- itemCount,
174
- pageOptionsDto,
175
- });
176
-
177
- return [entities, pageMetaDto];
178
- };
179
-
180
- SelectQueryBuilder.prototype.withTenant = function (
181
- tenantId?: number | string,
182
- tenantFieldName: string = 'tenantId',
183
- ) {
184
- if (!tenantId) {
185
- tenantId = ContextProvider.getTenantId();
186
- }
187
-
188
- if (this.expressionMap.mainAlias.hasMetadata) {
189
- const entityMetadata = this.expressionMap.mainAlias.metadata;
190
- const columnName = entityMetadata.columns.find(
191
- (column: any) => column.propertyName === tenantFieldName,
192
- )?.databaseName;
193
-
194
- if (columnName) {
195
- return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
196
- tenantId,
197
- });
198
- }
199
- }
200
-
201
- return this;
202
- };
@@ -1,61 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
-
3
- import { DYNAMIC_TRANSLATION_DECORATOR_KEY } from '../../decorators';
4
- import { ContextProvider } from '../../providers';
5
- import { AbstractEntity, AbstractUuidPrimaryEntity } from '../abstract.entity';
6
-
7
- export class AbstractDto {
8
- @ApiProperty()
9
- id: number | string;
10
-
11
- @ApiProperty()
12
- createdAt: Date;
13
-
14
- @ApiProperty()
15
- updatedAt: Date;
16
-
17
- translations?: AbstractTranslationDto[];
18
-
19
- constructor(
20
- entity: AbstractEntity | AbstractUuidPrimaryEntity,
21
- options?: { excludeFields?: boolean },
22
- ) {
23
- if (!options?.excludeFields) {
24
- this.id = entity.id;
25
- this.createdAt = entity.createdAt;
26
- this.updatedAt = entity.updatedAt;
27
- }
28
-
29
- const languageCode = ContextProvider.getLanguage();
30
-
31
- if (languageCode && entity.translations) {
32
- const translationEntity = entity.translations.find(
33
- (titleTranslation) => titleTranslation.languageCode === languageCode,
34
- )!;
35
-
36
- const fields: Record<string, string> = {};
37
-
38
- for (const key of Object.keys(translationEntity)) {
39
- const metadata = Reflect.getMetadata(
40
- DYNAMIC_TRANSLATION_DECORATOR_KEY,
41
- this,
42
- key,
43
- );
44
-
45
- if (metadata) {
46
- fields[key] = translationEntity[key];
47
- }
48
- }
49
-
50
- Object.assign(this, fields);
51
- } else {
52
- this.translations = entity.translations?.toDtos();
53
- }
54
- }
55
- }
56
-
57
- export class AbstractTranslationDto extends AbstractDto {
58
- constructor(entity: AbstractEntity | AbstractUuidPrimaryEntity) {
59
- super(entity, { excludeFields: true });
60
- }
61
- }
@@ -1,13 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { IsArray } from 'class-validator';
3
-
4
- export class BulkIdDto {
5
- @ApiProperty({
6
- type: 'string',
7
- description: 'ID',
8
- isArray: true,
9
- required: true,
10
- })
11
- @IsArray()
12
- id: number[] | string[];
13
- }
@@ -1,10 +0,0 @@
1
- import { LanguageCode } from '../../constants';
2
- import { EnumField, StringField } from '../../decorators';
3
-
4
- export class CreateTranslationDto {
5
- @EnumField(() => LanguageCode)
6
- languageCode: LanguageCode;
7
-
8
- @StringField()
9
- text: string;
10
- }
@@ -1,6 +0,0 @@
1
- export * from './abstract.dto';
2
- export * from './bulk-id.dto';
3
- export * from './create-translation.dto';
4
- export * from './page.dto';
5
- export * from './page-meta.dto';
6
- export * from './page-options.dto';
@@ -1,37 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
-
3
- import type { PageOptionsDto } from './page-options.dto';
4
-
5
- interface IPageMetaDtoParameters {
6
- pageOptionsDto: PageOptionsDto;
7
- itemCount: number;
8
- }
9
-
10
- export class PageMetaDto {
11
- @ApiProperty()
12
- readonly page: number;
13
-
14
- @ApiProperty()
15
- readonly pageSize: number;
16
-
17
- @ApiProperty()
18
- readonly itemCount: number;
19
-
20
- @ApiProperty()
21
- readonly pageCount: number;
22
-
23
- @ApiProperty()
24
- readonly hasPreviousPage: boolean;
25
-
26
- @ApiProperty()
27
- readonly hasNextPage: boolean;
28
-
29
- constructor({ pageOptionsDto, itemCount }: IPageMetaDtoParameters) {
30
- this.page = pageOptionsDto.page;
31
- this.pageSize = pageOptionsDto.pageSize;
32
- this.itemCount = itemCount;
33
- this.pageCount = Math.ceil(this.itemCount / this.pageSize);
34
- this.hasPreviousPage = this.page > 1;
35
- this.hasNextPage = this.page < this.pageCount;
36
- }
37
- }
@@ -1,35 +0,0 @@
1
- import { Order } from '../../constants';
2
- import {
3
- EnumFieldOptional,
4
- NumberFieldOptional,
5
- StringFieldOptional,
6
- } from '../../decorators';
7
-
8
- export class PageOptionsDto {
9
- @EnumFieldOptional(() => Order, {
10
- default: Order.ASC,
11
- })
12
- readonly order: Order = Order.ASC;
13
-
14
- @NumberFieldOptional({
15
- minimum: 1,
16
- default: 1,
17
- int: true,
18
- })
19
- readonly page: number = 1;
20
-
21
- @NumberFieldOptional({
22
- minimum: 1,
23
- maximum: 50,
24
- default: 10,
25
- int: true,
26
- })
27
- readonly pageSize: number = 10;
28
-
29
- get skip(): number {
30
- return (this.page - 1) * this.pageSize;
31
- }
32
-
33
- @StringFieldOptional()
34
- readonly q?: string;
35
- }
@@ -1,36 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
-
3
- import { PageMetaDto } from './page-meta.dto';
4
-
5
- export class PageDto<T> {
6
- @ApiProperty({ isArray: true })
7
- readonly data: T[];
8
-
9
- @ApiProperty()
10
- count: number;
11
-
12
- @ApiProperty()
13
- total: number;
14
-
15
- @ApiProperty()
16
- page: number;
17
-
18
- @ApiProperty()
19
- pageCount: number;
20
-
21
- @ApiProperty()
22
- hasPreviousPage: boolean;
23
-
24
- @ApiProperty()
25
- hasNextPage: boolean;
26
-
27
- constructor(data: T[], meta: PageMetaDto) {
28
- this.data = data;
29
- this.count = meta.pageSize;
30
- this.pageCount = meta.pageCount;
31
- this.page = meta.page;
32
- this.total = meta.itemCount;
33
- this.hasPreviousPage = meta.hasPreviousPage;
34
- this.hasNextPage = meta.hasNextPage;
35
- }
36
- }
@@ -1,7 +0,0 @@
1
- export * from './abstract.entity';
2
- export * from './abstract-client.service';
3
- export * from './utils';
4
- export * from './dto';
5
- export * from './types';
6
- export * from './snake-naming.strategy';
7
- export * from './boilerplate.polyfill';