@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,280 +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
- callback?: (item: Entity) => any,
58
- ): Promise<[any[], PageMetaDto]>;
59
-
60
- leftJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
61
- this: SelectQueryBuilder<Entity>,
62
- property: `${A}.${Exclude<
63
- KeyOfType<AliasEntity, AbstractEntity>,
64
- symbol
65
- >}`,
66
- alias: string,
67
- condition?: string,
68
- parameters?: ObjectLiteral,
69
- ): this;
70
-
71
- leftJoin<AliasEntity extends AbstractEntity, A extends string>(
72
- this: SelectQueryBuilder<Entity>,
73
- property: `${A}.${Exclude<
74
- KeyOfType<AliasEntity, AbstractEntity>,
75
- symbol
76
- >}`,
77
- alias: string,
78
- condition?: string,
79
- parameters?: ObjectLiteral,
80
- ): this;
81
-
82
- innerJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
83
- this: SelectQueryBuilder<Entity>,
84
- property: `${A}.${Exclude<
85
- KeyOfType<AliasEntity, AbstractEntity>,
86
- symbol
87
- >}`,
88
- alias: string,
89
- condition?: string,
90
- parameters?: ObjectLiteral,
91
- ): this;
92
-
93
- innerJoin<AliasEntity extends AbstractEntity, A extends string>(
94
- this: SelectQueryBuilder<Entity>,
95
- property: `${A}.${Exclude<
96
- KeyOfType<AliasEntity, AbstractEntity>,
97
- symbol
98
- >}`,
99
- alias: string,
100
- condition?: string,
101
- parameters?: ObjectLiteral,
102
- ): this;
103
-
104
- /**
105
- * 自动分页,返回所有数据(分批查询)
106
- * @param pageSize 每页大小,默认1000
107
- * @returns Promise<Entity[]>
108
- */
109
- autoPaginate(
110
- this: SelectQueryBuilder<Entity>,
111
- pageSize?: number,
112
- ): Promise<Entity[]>;
113
-
114
- /**
115
- * 通过异步生成器迭代QueryBuilder结果
116
- * @param batchSize 每批大小,默认1000
117
- * @returns AsyncGenerator<Entity, void, unknown>
118
- */
119
- iterate(
120
- this: SelectQueryBuilder<Entity>,
121
- batchSize?: number,
122
- ): AsyncGenerator<Entity, void, unknown>;
123
- }
124
- }
125
-
126
- Array.prototype.toDtos = function <
127
- Entity extends AbstractEntity<Dto>,
128
- Dto extends AbstractDto,
129
- >(options?: unknown): Dto[] {
130
- return compact(
131
- map<Entity, Dto>(this as Entity[], (item) => item.toDto(options as never)),
132
- );
133
- };
134
-
135
- Array.prototype.getByLanguage = function (languageCode: LanguageCode): string {
136
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
137
- return this.find((translation) => languageCode === translation.languageCode)!
138
- .text;
139
- };
140
-
141
- Array.prototype.toPageDto = function (
142
- pageMetaDto: PageMetaDto,
143
- options?: unknown,
144
- ) {
145
- return new PageDto(this.toDtos(options), pageMetaDto);
146
- };
147
-
148
- SelectQueryBuilder.prototype.searchByString = function (
149
- q,
150
- columnNames,
151
- options,
152
- ) {
153
- if (!q) {
154
- return this;
155
- }
156
-
157
- this.andWhere(
158
- new Brackets((qb) => {
159
- for (const item of columnNames) {
160
- qb.orWhere(`${item} ILIKE :q`);
161
- }
162
- }),
163
- );
164
-
165
- if (options?.formStart) {
166
- this.setParameter('q', `${q}%`);
167
- } else {
168
- this.setParameter('q', `%${q}%`);
169
- }
170
-
171
- return this;
172
- };
173
-
174
- SelectQueryBuilder.prototype.paginate = async function (
175
- pageOptionsDto,
176
- options,
177
- callback,
178
- ) {
179
- if (options?.takeAll) {
180
- // 自动分页,返回所有数据和总数
181
- let page = 0;
182
- const all: any[] = [];
183
- let batch: any[];
184
- do {
185
- batch = await this.clone()
186
- .skip(page * pageOptionsDto.pageSize)
187
- .take(pageOptionsDto.pageSize)
188
- .getMany();
189
- if (callback) {
190
- for (const item of batch) {
191
- all.push(await callback(item));
192
- }
193
- } else {
194
- all.push(...batch);
195
- }
196
- page++;
197
- } while (batch.length === pageOptionsDto.pageSize);
198
- const itemCount = all.length;
199
- const pageMetaDto = new PageMetaDto({ itemCount, pageOptionsDto });
200
- return [all, pageMetaDto];
201
- } else {
202
- this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
203
- const entities = await this.getMany();
204
- let itemCount = -1;
205
- if (!options?.skipCount) {
206
- itemCount = await this.getCount();
207
- }
208
- const pageMetaDto = new PageMetaDto({
209
- itemCount,
210
- pageOptionsDto,
211
- });
212
- if (callback) {
213
- const processed = [];
214
- for (const item of entities) {
215
- processed.push(await callback(item));
216
- }
217
- return [processed, pageMetaDto];
218
- }
219
- return [entities, pageMetaDto];
220
- }
221
- };
222
-
223
- SelectQueryBuilder.prototype.withTenant = function (
224
- tenantId?: number | string,
225
- tenantFieldName: string = 'tenantId',
226
- ) {
227
- if (!tenantId) {
228
- tenantId = ContextProvider.getTenantId();
229
- }
230
-
231
- if (this.expressionMap.mainAlias.hasMetadata) {
232
- const entityMetadata = this.expressionMap.mainAlias.metadata;
233
- const columnName = entityMetadata.columns.find(
234
- (column: any) => column.propertyName === tenantFieldName,
235
- )?.databaseName;
236
-
237
- if (columnName) {
238
- return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
239
- tenantId,
240
- });
241
- }
242
- }
243
-
244
- return this;
245
- };
246
-
247
- SelectQueryBuilder.prototype.autoPaginate = async function (pageSize = 1000) {
248
- let page = 0;
249
- let hasMore = true;
250
- const all: any[] = [];
251
- while (hasMore) {
252
- const batch = await this.clone().skip(page * pageSize).take(pageSize).getMany();
253
- all.push(...batch);
254
- if (batch.length < pageSize) {
255
- hasMore = false;
256
- } else {
257
- page++;
258
- }
259
- }
260
- return all;
261
- };
262
-
263
- SelectQueryBuilder.prototype.iterate = async function* (batchSize = 1000) {
264
- let page = 0;
265
- let hasMore = true;
266
- while (hasMore) {
267
- const batch = await this.clone()
268
- .skip(page * batchSize)
269
- .take(batchSize)
270
- .getMany();
271
- for (const item of batch) {
272
- yield item;
273
- }
274
- if (batch.length < batchSize) {
275
- hasMore = false;
276
- } else {
277
- page++;
278
- }
279
- }
280
- };
@@ -1,280 +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
- callback?: (item: Entity) => any,
58
- ): Promise<[any[], PageMetaDto]>;
59
-
60
- leftJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
61
- this: SelectQueryBuilder<Entity>,
62
- property: `${A}.${Exclude<
63
- KeyOfType<AliasEntity, AbstractEntity>,
64
- symbol
65
- >}`,
66
- alias: string,
67
- condition?: string,
68
- parameters?: ObjectLiteral,
69
- ): this;
70
-
71
- leftJoin<AliasEntity extends AbstractEntity, A extends string>(
72
- this: SelectQueryBuilder<Entity>,
73
- property: `${A}.${Exclude<
74
- KeyOfType<AliasEntity, AbstractEntity>,
75
- symbol
76
- >}`,
77
- alias: string,
78
- condition?: string,
79
- parameters?: ObjectLiteral,
80
- ): this;
81
-
82
- innerJoinAndSelect<AliasEntity extends AbstractEntity, A extends string>(
83
- this: SelectQueryBuilder<Entity>,
84
- property: `${A}.${Exclude<
85
- KeyOfType<AliasEntity, AbstractEntity>,
86
- symbol
87
- >}`,
88
- alias: string,
89
- condition?: string,
90
- parameters?: ObjectLiteral,
91
- ): this;
92
-
93
- innerJoin<AliasEntity extends AbstractEntity, A extends string>(
94
- this: SelectQueryBuilder<Entity>,
95
- property: `${A}.${Exclude<
96
- KeyOfType<AliasEntity, AbstractEntity>,
97
- symbol
98
- >}`,
99
- alias: string,
100
- condition?: string,
101
- parameters?: ObjectLiteral,
102
- ): this;
103
-
104
- /**
105
- * 自动分页,返回所有数据(分批查询)
106
- * @param pageSize 每页大小,默认1000
107
- * @returns Promise<Entity[]>
108
- */
109
- autoPaginate(
110
- this: SelectQueryBuilder<Entity>,
111
- pageSize?: number,
112
- ): Promise<Entity[]>;
113
-
114
- /**
115
- * 通过异步生成器迭代QueryBuilder结果
116
- * @param batchSize 每批大小,默认1000
117
- * @returns AsyncGenerator<Entity, void, unknown>
118
- */
119
- iterate(
120
- this: SelectQueryBuilder<Entity>,
121
- batchSize?: number,
122
- ): AsyncGenerator<Entity, void, unknown>;
123
- }
124
- }
125
-
126
- Array.prototype.toDtos = function <
127
- Entity extends AbstractEntity<Dto>,
128
- Dto extends AbstractDto,
129
- >(options?: unknown): Dto[] {
130
- return compact(
131
- map<Entity, Dto>(this as Entity[], (item) => item.toDto(options as never)),
132
- );
133
- };
134
-
135
- Array.prototype.getByLanguage = function (languageCode: LanguageCode): string {
136
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
137
- return this.find((translation) => languageCode === translation.languageCode)!
138
- .text;
139
- };
140
-
141
- Array.prototype.toPageDto = function (
142
- pageMetaDto: PageMetaDto,
143
- options?: unknown,
144
- ) {
145
- return new PageDto(this.toDtos(options), pageMetaDto);
146
- };
147
-
148
- SelectQueryBuilder.prototype.searchByString = function (
149
- q,
150
- columnNames,
151
- options,
152
- ) {
153
- if (!q) {
154
- return this;
155
- }
156
-
157
- this.andWhere(
158
- new Brackets((qb) => {
159
- for (const item of columnNames) {
160
- qb.orWhere(`${item} ILIKE :q`);
161
- }
162
- }),
163
- );
164
-
165
- if (options?.formStart) {
166
- this.setParameter('q', `${q}%`);
167
- } else {
168
- this.setParameter('q', `%${q}%`);
169
- }
170
-
171
- return this;
172
- };
173
-
174
- SelectQueryBuilder.prototype.paginate = async function (
175
- pageOptionsDto,
176
- options,
177
- callback,
178
- ) {
179
- if (options?.takeAll) {
180
- // 自动分页,返回所有数据和总数
181
- let page = 0;
182
- const all: any[] = [];
183
- let batch: any[];
184
- do {
185
- batch = await this.clone()
186
- .skip(page * pageOptionsDto.pageSize)
187
- .take(pageOptionsDto.pageSize)
188
- .getMany();
189
- if (callback) {
190
- for (const item of batch) {
191
- all.push(await callback(item));
192
- }
193
- } else {
194
- all.push(...batch);
195
- }
196
- page++;
197
- } while (batch.length === pageOptionsDto.pageSize);
198
- const itemCount = all.length;
199
- const pageMetaDto = new PageMetaDto({ itemCount, pageOptionsDto });
200
- return [all, pageMetaDto];
201
- } else {
202
- this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
203
- const entities = await this.getMany();
204
- let itemCount = -1;
205
- if (!options?.skipCount) {
206
- itemCount = await this.getCount();
207
- }
208
- const pageMetaDto = new PageMetaDto({
209
- itemCount,
210
- pageOptionsDto,
211
- });
212
- if (callback) {
213
- const processed = [];
214
- for (const item of entities) {
215
- processed.push(await callback(item));
216
- }
217
- return [processed, pageMetaDto];
218
- }
219
- return [entities, pageMetaDto];
220
- }
221
- };
222
-
223
- SelectQueryBuilder.prototype.withTenant = function (
224
- tenantId?: number | string,
225
- tenantFieldName: string = 'tenantId',
226
- ) {
227
- if (!tenantId) {
228
- tenantId = ContextProvider.getTenantId();
229
- }
230
-
231
- if (this.expressionMap.mainAlias.hasMetadata) {
232
- const entityMetadata = this.expressionMap.mainAlias.metadata;
233
- const columnName = entityMetadata.columns.find(
234
- (column: any) => column.propertyName === tenantFieldName,
235
- )?.databaseName;
236
-
237
- if (columnName) {
238
- return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
239
- tenantId,
240
- });
241
- }
242
- }
243
-
244
- return this;
245
- };
246
-
247
- SelectQueryBuilder.prototype.autoPaginate = async function (pageSize = 1000) {
248
- let page = 0;
249
- let hasMore = true;
250
- const all: any[] = [];
251
- while (hasMore) {
252
- const batch = await this.clone().skip(page * pageSize).take(pageSize).getMany();
253
- all.push(...batch);
254
- if (batch.length < pageSize) {
255
- hasMore = false;
256
- } else {
257
- page++;
258
- }
259
- }
260
- return all;
261
- };
262
-
263
- SelectQueryBuilder.prototype.iterate = async function* (batchSize = 1000) {
264
- let page = 0;
265
- let hasMore = true;
266
- while (hasMore) {
267
- const batch = await this.clone()
268
- .skip(page * batchSize)
269
- .take(batchSize)
270
- .getMany();
271
- for (const item of batch) {
272
- yield item;
273
- }
274
- if (batch.length < batchSize) {
275
- hasMore = false;
276
- } else {
277
- page++;
278
- }
279
- }
280
- };