@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,318 +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
- * @param pageSize 每页大小,默认1000
106
- * @returns Promise<Entity[]>
107
- */
108
- autoPaginate(
109
- this: SelectQueryBuilder<Entity>,
110
- pageSize?: number,
111
- ): Promise<Entity[]>;
112
-
113
- /**
114
- * 通过异步生成器迭代QueryBuilder结果
115
- * @param batchSize 每批大小,默认1000
116
- * @returns AsyncGenerator<Entity, void, unknown>
117
- */
118
- iterate(
119
- this: SelectQueryBuilder<Entity>,
120
- batchSize?: number,
121
- ): AsyncGenerator<Entity, void, unknown>;
122
-
123
- /**
124
- * 通过callback处理每个item,无需外部循环
125
- * @param callback 处理函数
126
- * @param batchSize 每批大小,默认1000
127
- * @returns Promise<void>
128
- */
129
- iterate(
130
- this: SelectQueryBuilder<Entity>,
131
- callback: (item: Entity) => Promise<void> | void,
132
- batchSize?: number,
133
- ): Promise<void>;
134
- }
135
- }
136
-
137
- Array.prototype.toDtos = function <
138
- Entity extends AbstractEntity<Dto>,
139
- Dto extends AbstractDto,
140
- >(options?: unknown): Dto[] {
141
- return compact(
142
- map<Entity, Dto>(this as Entity[], (item) => item.toDto(options as never)),
143
- );
144
- };
145
-
146
- Array.prototype.getByLanguage = function (languageCode: LanguageCode): string {
147
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
148
- return this.find((translation) => languageCode === translation.languageCode)!
149
- .text;
150
- };
151
-
152
- Array.prototype.toPageDto = function (
153
- pageMetaDto: PageMetaDto,
154
- options?: unknown,
155
- ) {
156
- return new PageDto(this.toDtos(options), pageMetaDto);
157
- };
158
-
159
- SelectQueryBuilder.prototype.searchByString = function (
160
- q,
161
- columnNames,
162
- options,
163
- ) {
164
- if (!q) {
165
- return this;
166
- }
167
-
168
- this.andWhere(
169
- new Brackets((qb) => {
170
- for (const item of columnNames) {
171
- qb.orWhere(`${item} ILIKE :q`);
172
- }
173
- }),
174
- );
175
-
176
- if (options?.formStart) {
177
- this.setParameter('q', `${q}%`);
178
- } else {
179
- this.setParameter('q', `%${q}%`);
180
- }
181
-
182
- return this;
183
- };
184
-
185
- SelectQueryBuilder.prototype.paginate = async function (
186
- pageOptionsDto,
187
- options,
188
- ) {
189
- if (options?.takeAll) {
190
- // 自动分页,返回所有数据和总数
191
- let page = 0;
192
- const all: any[] = [];
193
- let batch: any[];
194
- do {
195
- batch = await this.clone()
196
- .skip(page * pageOptionsDto.pageSize)
197
- .take(pageOptionsDto.pageSize)
198
- .getMany();
199
- all.push(...batch);
200
- page++;
201
- } while (batch.length === pageOptionsDto.pageSize);
202
- const itemCount = all.length;
203
- const pageMetaDto = new PageMetaDto({ itemCount, pageOptionsDto });
204
- return [all, pageMetaDto];
205
- } else {
206
- this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
207
- const entities = await this.getMany();
208
- let itemCount = -1;
209
- if (!options?.skipCount) {
210
- itemCount = await this.getCount();
211
- }
212
- const pageMetaDto = new PageMetaDto({
213
- itemCount,
214
- pageOptionsDto,
215
- });
216
- return [entities, pageMetaDto];
217
- }
218
- };
219
-
220
- SelectQueryBuilder.prototype.withTenant = function (
221
- tenantId?: number | string,
222
- tenantFieldName: string = 'tenantId',
223
- ) {
224
- if (!tenantId) {
225
- tenantId = ContextProvider.getTenantId();
226
- }
227
-
228
- if (this.expressionMap.mainAlias.hasMetadata) {
229
- const entityMetadata = this.expressionMap.mainAlias.metadata;
230
- const columnName = entityMetadata.columns.find(
231
- (column: any) => column.propertyName === tenantFieldName,
232
- )?.databaseName;
233
-
234
- if (columnName) {
235
- return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
236
- tenantId,
237
- });
238
- }
239
- }
240
-
241
- return this;
242
- };
243
-
244
- SelectQueryBuilder.prototype.autoPaginate = async function (pageSize = 1000) {
245
- let page = 0;
246
- let hasMore = true;
247
- const all: any[] = [];
248
- while (hasMore) {
249
- const batch = await this.clone()
250
- .skip(page * pageSize)
251
- .take(pageSize)
252
- .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 = function (
264
- callbackOrBatchSize?: any,
265
- batchSize?: number,
266
- ): any {
267
- // 支持 iterate(batchSize) 或 iterate(callback, batchSize)
268
- let callback: ((item: any) => Promise<void> | void) | undefined;
269
- let realBatchSize = 1000;
270
- if (typeof callbackOrBatchSize === 'function') {
271
- callback = callbackOrBatchSize;
272
- if (typeof batchSize === 'number') realBatchSize = batchSize;
273
- } else if (typeof callbackOrBatchSize === 'number') {
274
- realBatchSize = callbackOrBatchSize;
275
- }
276
-
277
- if (callback) {
278
- // callback模式,返回Promise<void>
279
- return (async () => {
280
- let page = 0;
281
- let hasMore = true;
282
- while (hasMore) {
283
- const batch = await this.clone()
284
- .skip(page * realBatchSize)
285
- .take(realBatchSize)
286
- .getMany();
287
- for (const item of batch) {
288
- await callback(item);
289
- }
290
- if (batch.length < realBatchSize) {
291
- hasMore = false;
292
- } else {
293
- page++;
294
- }
295
- }
296
- })();
297
- } else {
298
- // generator模式
299
- return (async function* (that) {
300
- let page = 0;
301
- let hasMore = true;
302
- while (hasMore) {
303
- const batch = await that.clone()
304
- .skip(page * realBatchSize)
305
- .take(realBatchSize)
306
- .getMany();
307
- for (const item of batch) {
308
- yield item;
309
- }
310
- if (batch.length < realBatchSize) {
311
- hasMore = false;
312
- } else {
313
- page++;
314
- }
315
- }
316
- })(this);
317
- }
318
- };
@@ -1,318 +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
- * @param pageSize 每页大小,默认1000
106
- * @returns Promise<Entity[]>
107
- */
108
- autoPaginate(
109
- this: SelectQueryBuilder<Entity>,
110
- pageSize?: number,
111
- ): Promise<Entity[]>;
112
-
113
- /**
114
- * 通过异步生成器迭代QueryBuilder结果
115
- * @param batchSize 每批大小,默认1000
116
- * @returns AsyncGenerator<Entity, void, unknown>
117
- */
118
- iterate(
119
- this: SelectQueryBuilder<Entity>,
120
- batchSize?: number,
121
- ): AsyncGenerator<Entity, void, unknown>;
122
-
123
- /**
124
- * 通过callback处理每个item,无需外部循环
125
- * @param callback 处理函数
126
- * @param batchSize 每批大小,默认1000
127
- * @returns Promise<void>
128
- */
129
- iterate(
130
- this: SelectQueryBuilder<Entity>,
131
- callback: (item: Entity) => Promise<void> | void,
132
- batchSize?: number,
133
- ): Promise<void>;
134
- }
135
- }
136
-
137
- Array.prototype.toDtos = function <
138
- Entity extends AbstractEntity<Dto>,
139
- Dto extends AbstractDto,
140
- >(options?: unknown): Dto[] {
141
- return compact(
142
- map<Entity, Dto>(this as Entity[], (item) => item.toDto(options as never)),
143
- );
144
- };
145
-
146
- Array.prototype.getByLanguage = function (languageCode: LanguageCode): string {
147
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
148
- return this.find((translation) => languageCode === translation.languageCode)!
149
- .text;
150
- };
151
-
152
- Array.prototype.toPageDto = function (
153
- pageMetaDto: PageMetaDto,
154
- options?: unknown,
155
- ) {
156
- return new PageDto(this.toDtos(options), pageMetaDto);
157
- };
158
-
159
- SelectQueryBuilder.prototype.searchByString = function (
160
- q,
161
- columnNames,
162
- options,
163
- ) {
164
- if (!q) {
165
- return this;
166
- }
167
-
168
- this.andWhere(
169
- new Brackets((qb) => {
170
- for (const item of columnNames) {
171
- qb.orWhere(`${item} ILIKE :q`);
172
- }
173
- }),
174
- );
175
-
176
- if (options?.formStart) {
177
- this.setParameter('q', `${q}%`);
178
- } else {
179
- this.setParameter('q', `%${q}%`);
180
- }
181
-
182
- return this;
183
- };
184
-
185
- SelectQueryBuilder.prototype.paginate = async function (
186
- pageOptionsDto,
187
- options,
188
- ) {
189
- if (options?.takeAll) {
190
- // 自动分页,返回所有数据和总数
191
- let page = 0;
192
- const all: any[] = [];
193
- let batch: any[];
194
- do {
195
- batch = await this.clone()
196
- .skip(page * pageOptionsDto.pageSize)
197
- .take(pageOptionsDto.pageSize)
198
- .getMany();
199
- all.push(...batch);
200
- page++;
201
- } while (batch.length === pageOptionsDto.pageSize);
202
- const itemCount = all.length;
203
- const pageMetaDto = new PageMetaDto({ itemCount, pageOptionsDto });
204
- return [all, pageMetaDto];
205
- } else {
206
- this.skip(pageOptionsDto.skip).take(pageOptionsDto.pageSize);
207
- const entities = await this.getMany();
208
- let itemCount = -1;
209
- if (!options?.skipCount) {
210
- itemCount = await this.getCount();
211
- }
212
- const pageMetaDto = new PageMetaDto({
213
- itemCount,
214
- pageOptionsDto,
215
- });
216
- return [entities, pageMetaDto];
217
- }
218
- };
219
-
220
- SelectQueryBuilder.prototype.withTenant = function (
221
- tenantId?: number | string,
222
- tenantFieldName: string = 'tenantId',
223
- ) {
224
- if (!tenantId) {
225
- tenantId = ContextProvider.getTenantId();
226
- }
227
-
228
- if (this.expressionMap.mainAlias.hasMetadata) {
229
- const entityMetadata = this.expressionMap.mainAlias.metadata;
230
- const columnName = entityMetadata.columns.find(
231
- (column: any) => column.propertyName === tenantFieldName,
232
- )?.databaseName;
233
-
234
- if (columnName) {
235
- return this.andWhere(`${this.alias}.${columnName} = :tenantId`, {
236
- tenantId,
237
- });
238
- }
239
- }
240
-
241
- return this;
242
- };
243
-
244
- SelectQueryBuilder.prototype.autoPaginate = async function (pageSize = 1000) {
245
- let page = 0;
246
- let hasMore = true;
247
- const all: any[] = [];
248
- while (hasMore) {
249
- const batch = await this.clone()
250
- .skip(page * pageSize)
251
- .take(pageSize)
252
- .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 = function (
264
- callbackOrBatchSize?: any,
265
- batchSize?: number,
266
- ): any {
267
- // 支持 iterate(batchSize) 或 iterate(callback, batchSize)
268
- let callback: ((item: any) => Promise<void> | void) | undefined;
269
- let realBatchSize = 1000;
270
- if (typeof callbackOrBatchSize === 'function') {
271
- callback = callbackOrBatchSize;
272
- if (typeof batchSize === 'number') realBatchSize = batchSize;
273
- } else if (typeof callbackOrBatchSize === 'number') {
274
- realBatchSize = callbackOrBatchSize;
275
- }
276
-
277
- if (callback) {
278
- // callback模式,返回Promise<void>
279
- return (async () => {
280
- let page = 0;
281
- let hasMore = true;
282
- while (hasMore) {
283
- const batch = await this.clone()
284
- .skip(page * realBatchSize)
285
- .take(realBatchSize)
286
- .getMany();
287
- for (const item of batch) {
288
- await callback(item);
289
- }
290
- if (batch.length < realBatchSize) {
291
- hasMore = false;
292
- } else {
293
- page++;
294
- }
295
- }
296
- })();
297
- } else {
298
- // generator模式
299
- return (async function* (that) {
300
- let page = 0;
301
- let hasMore = true;
302
- while (hasMore) {
303
- const batch = await that.clone()
304
- .skip(page * realBatchSize)
305
- .take(realBatchSize)
306
- .getMany();
307
- for (const item of batch) {
308
- yield item;
309
- }
310
- if (batch.length < realBatchSize) {
311
- hasMore = false;
312
- } else {
313
- page++;
314
- }
315
- }
316
- })(this);
317
- }
318
- };