taon 21.0.18 → 21.0.28

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 (412) hide show
  1. package/README.md +11 -2
  2. package/browser/fesm2022/taon-browser.mjs +1167 -1011
  3. package/browser/fesm2022/taon-browser.mjs.map +1 -1
  4. package/browser/package.json +1 -1
  5. package/browser/types/taon-browser.d.ts +7 -3
  6. package/browser-prod/README.md +24 -0
  7. package/browser-prod/fesm2022/taon-browser.mjs +8367 -0
  8. package/browser-prod/fesm2022/taon-browser.mjs.map +1 -0
  9. package/browser-prod/types/taon-browser.d.ts +2178 -0
  10. package/lib/base-classes/base-context.js +4 -0
  11. package/lib/base-classes/base-context.js.map +1 -1
  12. package/lib/build-info._auto-generated_.d.ts +5 -1
  13. package/lib/build-info._auto-generated_.js +6 -2
  14. package/lib/build-info._auto-generated_.js.map +1 -1
  15. package/lib/decorators/classes/middleware-decorator.d.ts +1 -0
  16. package/lib/decorators/classes/middleware-decorator.js +1 -0
  17. package/lib/decorators/classes/middleware-decorator.js.map +1 -1
  18. package/lib/decorators/classes/subscriber-decorator.d.ts +1 -1
  19. package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
  20. package/lib/env/env.angular-node-app.d.ts +30 -28
  21. package/lib/env/env.angular-node-app.js +32 -30
  22. package/lib/env/env.angular-node-app.js.map +1 -1
  23. package/lib/env/env.docs-webapp.d.ts +30 -28
  24. package/lib/env/env.docs-webapp.js +32 -30
  25. package/lib/env/env.docs-webapp.js.map +1 -1
  26. package/lib/env/env.electron-app.d.ts +30 -28
  27. package/lib/env/env.electron-app.js +32 -30
  28. package/lib/env/env.electron-app.js.map +1 -1
  29. package/lib/env/env.mobile-app.d.ts +30 -28
  30. package/lib/env/env.mobile-app.js +32 -30
  31. package/lib/env/env.mobile-app.js.map +1 -1
  32. package/lib/env/env.npm-lib-and-cli-tool.d.ts +30 -28
  33. package/lib/env/env.npm-lib-and-cli-tool.js +32 -30
  34. package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
  35. package/lib/env/env.vscode-plugin.d.ts +30 -28
  36. package/lib/env/env.vscode-plugin.js +32 -30
  37. package/lib/env/env.vscode-plugin.js.map +1 -1
  38. package/lib/formly/type-from-entity.js +9 -9
  39. package/lib/formly/type-from-entity.js.map +1 -1
  40. package/lib/global-state/taon-global-state/index.d.ts +6 -0
  41. package/lib/global-state/taon-global-state/index.js +23 -0
  42. package/lib/global-state/taon-global-state/index.js.map +1 -0
  43. package/lib/global-state/taon-global-state/taon-global-state-api.service.d.ts +7 -0
  44. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +19 -0
  45. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.js +23 -0
  46. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.js.map +1 -0
  47. package/lib/global-state/taon-global-state/taon-global-state.constants.d.ts +2 -0
  48. package/lib/global-state/taon-global-state/taon-global-state.constants.js +11 -0
  49. package/lib/global-state/taon-global-state/taon-global-state.constants.js.map +1 -0
  50. package/lib/global-state/taon-global-state/taon-global-state.controller.d.ts +11 -0
  51. package/lib/global-state/taon-global-state/taon-global-state.controller.js +62 -0
  52. package/lib/global-state/taon-global-state/taon-global-state.controller.js.map +1 -0
  53. package/lib/global-state/taon-global-state/taon-global-state.entity.d.ts +7 -0
  54. package/lib/global-state/taon-global-state/taon-global-state.entity.js +64 -0
  55. package/lib/global-state/taon-global-state/taon-global-state.entity.js.map +1 -0
  56. package/lib/global-state/taon-global-state/taon-global-state.middleware.d.ts +3 -0
  57. package/lib/global-state/taon-global-state/taon-global-state.middleware.js +22 -0
  58. package/lib/global-state/taon-global-state/taon-global-state.middleware.js.map +1 -0
  59. package/lib/global-state/taon-global-state/taon-global-state.models.d.ts +28 -0
  60. package/lib/global-state/taon-global-state/taon-global-state.models.js +48 -0
  61. package/lib/global-state/taon-global-state/taon-global-state.models.js.map +1 -0
  62. package/lib/global-state/taon-global-state/taon-global-state.provider.d.ts +3 -0
  63. package/lib/global-state/taon-global-state/taon-global-state.provider.js +22 -0
  64. package/lib/global-state/taon-global-state/taon-global-state.provider.js.map +1 -0
  65. package/lib/global-state/taon-global-state/taon-global-state.repository.d.ts +9 -0
  66. package/lib/global-state/taon-global-state/taon-global-state.repository.js +53 -0
  67. package/lib/global-state/taon-global-state/taon-global-state.repository.js.map +1 -0
  68. package/lib/global-state/taon-global-state/taon-global-state.subscriber.d.ts +7 -0
  69. package/lib/global-state/taon-global-state/taon-global-state.subscriber.js +29 -0
  70. package/lib/global-state/taon-global-state/taon-global-state.subscriber.js.map +1 -0
  71. package/lib/global-state/taon-global-state/taon-global-state.utils.d.ts +4 -0
  72. package/lib/global-state/taon-global-state/taon-global-state.utils.js +16 -0
  73. package/lib/global-state/taon-global-state/taon-global-state.utils.js.map +1 -0
  74. package/lib/global-state/taon-transaction-registry/index.d.ts +11 -0
  75. package/lib/global-state/taon-transaction-registry/index.js +28 -0
  76. package/lib/global-state/taon-transaction-registry/index.js.map +1 -0
  77. package/lib/global-state/taon-transaction-registry/taon-transaction-registry-api.service.d.ts +7 -0
  78. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +19 -0
  79. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +25 -0
  80. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +1 -0
  81. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.d.ts +2 -0
  82. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +9 -0
  83. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +1 -0
  84. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +9 -0
  85. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +52 -0
  86. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -0
  87. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.d.ts +12 -0
  88. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +77 -0
  89. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +1 -0
  90. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.d.ts +3 -0
  91. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +22 -0
  92. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +1 -0
  93. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.d.ts +6 -0
  94. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.js +11 -0
  95. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +1 -0
  96. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.d.ts +3 -0
  97. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +22 -0
  98. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +1 -0
  99. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.d.ts +9 -0
  100. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +38 -0
  101. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +1 -0
  102. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.d.ts +7 -0
  103. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +29 -0
  104. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +1 -0
  105. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +4 -0
  106. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +11 -0
  107. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -0
  108. package/lib/orm/columns.d.ts +5 -1
  109. package/lib/orm/columns.js +12 -2
  110. package/lib/orm/columns.js.map +1 -1
  111. package/lib/ui/index.js +2 -2
  112. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  113. package/lib-prod/base-classes/base-abstract-entity.d.ts +7 -0
  114. package/lib-prod/base-classes/base-abstract-entity.js +42 -0
  115. package/lib-prod/base-classes/base-abstract-entity.js.map +1 -0
  116. package/lib-prod/base-classes/base-angular-service.d.ts +27 -0
  117. package/lib-prod/base-classes/base-angular-service.js +89 -0
  118. package/lib-prod/base-classes/base-angular-service.js.map +1 -0
  119. package/lib-prod/base-classes/base-class.d.ts +15 -0
  120. package/lib-prod/base-classes/base-class.js +40 -0
  121. package/lib-prod/base-classes/base-class.js.map +1 -0
  122. package/lib-prod/base-classes/base-context.d.ts +20 -0
  123. package/lib-prod/base-classes/base-context.js +23 -0
  124. package/lib-prod/base-classes/base-context.js.map +1 -0
  125. package/lib-prod/base-classes/base-controller.d.ts +83 -0
  126. package/lib-prod/base-classes/base-controller.js +173 -0
  127. package/lib-prod/base-classes/base-controller.js.map +1 -0
  128. package/lib-prod/base-classes/base-crud-controller.d.ts +28 -0
  129. package/lib-prod/base-classes/base-crud-controller.js +319 -0
  130. package/lib-prod/base-classes/base-crud-controller.js.map +1 -0
  131. package/lib-prod/base-classes/base-custom-repository.d.ts +3 -0
  132. package/lib-prod/base-classes/base-custom-repository.js +19 -0
  133. package/lib-prod/base-classes/base-custom-repository.js.map +1 -0
  134. package/lib-prod/base-classes/base-electron-service.d.ts +0 -0
  135. package/lib-prod/base-classes/base-electron-service.js +50 -0
  136. package/lib-prod/base-classes/base-electron-service.js.map +1 -0
  137. package/lib-prod/base-classes/base-entity.d.ts +16 -0
  138. package/lib-prod/base-classes/base-entity.js +32 -0
  139. package/lib-prod/base-classes/base-entity.js.map +1 -0
  140. package/lib-prod/base-classes/base-file-upload.middleware.d.ts +14 -0
  141. package/lib-prod/base-classes/base-file-upload.middleware.js +85 -0
  142. package/lib-prod/base-classes/base-file-upload.middleware.js.map +1 -0
  143. package/lib-prod/base-classes/base-injector.d.ts +67 -0
  144. package/lib-prod/base-classes/base-injector.js +198 -0
  145. package/lib-prod/base-classes/base-injector.js.map +1 -0
  146. package/lib-prod/base-classes/base-middleware.d.ts +38 -0
  147. package/lib-prod/base-classes/base-middleware.js +14 -0
  148. package/lib-prod/base-classes/base-middleware.js.map +1 -0
  149. package/lib-prod/base-classes/base-migration.d.ts +11 -0
  150. package/lib-prod/base-classes/base-migration.js +25 -0
  151. package/lib-prod/base-classes/base-migration.js.map +1 -0
  152. package/lib-prod/base-classes/base-provider.d.ts +8 -0
  153. package/lib-prod/base-classes/base-provider.js +13 -0
  154. package/lib-prod/base-classes/base-provider.js.map +1 -0
  155. package/lib-prod/base-classes/base-repository.d.ts +272 -0
  156. package/lib-prod/base-classes/base-repository.js +634 -0
  157. package/lib-prod/base-classes/base-repository.js.map +1 -0
  158. package/lib-prod/base-classes/base-subscriber-for-entity.d.ts +81 -0
  159. package/lib-prod/base-classes/base-subscriber-for-entity.js +155 -0
  160. package/lib-prod/base-classes/base-subscriber-for-entity.js.map +1 -0
  161. package/lib-prod/base-classes/base.d.ts +1 -0
  162. package/lib-prod/base-classes/base.js +20 -0
  163. package/lib-prod/base-classes/base.js.map +1 -0
  164. package/lib-prod/build-info._auto-generated_.d.ts +24 -0
  165. package/lib-prod/build-info._auto-generated_.js +30 -0
  166. package/lib-prod/build-info._auto-generated_.js.map +1 -0
  167. package/lib-prod/config/controller-config.d.ts +21 -0
  168. package/lib-prod/config/controller-config.js +34 -0
  169. package/lib-prod/config/controller-config.js.map +1 -0
  170. package/lib-prod/config/controller-options.d.ts +16 -0
  171. package/lib-prod/config/controller-options.js +8 -0
  172. package/lib-prod/config/controller-options.js.map +1 -0
  173. package/lib-prod/config/method-config.d.ts +39 -0
  174. package/lib-prod/config/method-config.js +12 -0
  175. package/lib-prod/config/method-config.js.map +1 -0
  176. package/lib-prod/config/param-config.d.ts +8 -0
  177. package/lib-prod/config/param-config.js +8 -0
  178. package/lib-prod/config/param-config.js.map +1 -0
  179. package/lib-prod/constants.d.ts +9 -0
  180. package/lib-prod/constants.js +32 -0
  181. package/lib-prod/constants.js.map +1 -0
  182. package/lib-prod/context-db-migrations.d.ts +17 -0
  183. package/lib-prod/context-db-migrations.js +349 -0
  184. package/lib-prod/context-db-migrations.js.map +1 -0
  185. package/lib-prod/create-context.d.ts +78 -0
  186. package/lib-prod/create-context.js +223 -0
  187. package/lib-prod/create-context.js.map +1 -0
  188. package/lib-prod/decorators/classes/controller-decorator.d.ts +5 -0
  189. package/lib-prod/decorators/classes/controller-decorator.js +21 -0
  190. package/lib-prod/decorators/classes/controller-decorator.js.map +1 -0
  191. package/lib-prod/decorators/classes/entity-decorator.d.ts +19 -0
  192. package/lib-prod/decorators/classes/entity-decorator.js +43 -0
  193. package/lib-prod/decorators/classes/entity-decorator.js.map +1 -0
  194. package/lib-prod/decorators/classes/middleware-decorator.d.ts +8 -0
  195. package/lib-prod/decorators/classes/middleware-decorator.js +22 -0
  196. package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -0
  197. package/lib-prod/decorators/classes/migration-decorator.d.ts +7 -0
  198. package/lib-prod/decorators/classes/migration-decorator.js +21 -0
  199. package/lib-prod/decorators/classes/migration-decorator.js.map +1 -0
  200. package/lib-prod/decorators/classes/provider-decorator.d.ts +7 -0
  201. package/lib-prod/decorators/classes/provider-decorator.js +21 -0
  202. package/lib-prod/decorators/classes/provider-decorator.js.map +1 -0
  203. package/lib-prod/decorators/classes/repository-decorator.d.ts +7 -0
  204. package/lib-prod/decorators/classes/repository-decorator.js +21 -0
  205. package/lib-prod/decorators/classes/repository-decorator.js.map +1 -0
  206. package/lib-prod/decorators/classes/subscriber-decorator.d.ts +8 -0
  207. package/lib-prod/decorators/classes/subscriber-decorator.js +22 -0
  208. package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -0
  209. package/lib-prod/decorators/decorator-abstract-opt.d.ts +3 -0
  210. package/lib-prod/decorators/decorator-abstract-opt.js +7 -0
  211. package/lib-prod/decorators/decorator-abstract-opt.js.map +1 -0
  212. package/lib-prod/decorators/http/http-decorators.d.ts +2 -0
  213. package/lib-prod/decorators/http/http-decorators.js +24 -0
  214. package/lib-prod/decorators/http/http-decorators.js.map +1 -0
  215. package/lib-prod/decorators/http/http-methods-decorators.d.ts +70 -0
  216. package/lib-prod/decorators/http/http-methods-decorators.js +112 -0
  217. package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -0
  218. package/lib-prod/decorators/http/http-params-decorators.d.ts +8 -0
  219. package/lib-prod/decorators/http/http-params-decorators.js +50 -0
  220. package/lib-prod/decorators/http/http-params-decorators.js.map +1 -0
  221. package/lib-prod/dependency-injection/di-container.d.ts +5 -0
  222. package/lib-prod/dependency-injection/di-container.js +35 -0
  223. package/lib-prod/dependency-injection/di-container.js.map +1 -0
  224. package/lib-prod/endpoint-context-storage.d.ts +11 -0
  225. package/lib-prod/endpoint-context-storage.js +38 -0
  226. package/lib-prod/endpoint-context-storage.js.map +1 -0
  227. package/lib-prod/endpoint-context.d.ts +196 -0
  228. package/lib-prod/endpoint-context.js +2416 -0
  229. package/lib-prod/endpoint-context.js.map +1 -0
  230. package/lib-prod/entity-process.d.ts +39 -0
  231. package/lib-prod/entity-process.js +242 -0
  232. package/lib-prod/entity-process.js.map +1 -0
  233. package/lib-prod/env/env.angular-node-app.d.ts +64 -0
  234. package/lib-prod/env/env.angular-node-app.js +71 -0
  235. package/lib-prod/env/env.angular-node-app.js.map +1 -0
  236. package/lib-prod/env/env.docs-webapp.d.ts +64 -0
  237. package/lib-prod/env/env.docs-webapp.js +71 -0
  238. package/lib-prod/env/env.docs-webapp.js.map +1 -0
  239. package/lib-prod/env/env.electron-app.d.ts +64 -0
  240. package/lib-prod/env/env.electron-app.js +71 -0
  241. package/lib-prod/env/env.electron-app.js.map +1 -0
  242. package/lib-prod/env/env.mobile-app.d.ts +64 -0
  243. package/lib-prod/env/env.mobile-app.js +71 -0
  244. package/lib-prod/env/env.mobile-app.js.map +1 -0
  245. package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +64 -0
  246. package/lib-prod/env/env.npm-lib-and-cli-tool.js +71 -0
  247. package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
  248. package/lib-prod/env/env.vscode-plugin.d.ts +64 -0
  249. package/lib-prod/env/env.vscode-plugin.js +71 -0
  250. package/lib-prod/env/env.vscode-plugin.js.map +1 -0
  251. package/lib-prod/env/index.d.ts +6 -0
  252. package/lib-prod/env/index.js +23 -0
  253. package/lib-prod/env/index.js.map +1 -0
  254. package/lib-prod/express-types.d.ts +1 -0
  255. package/lib-prod/express-types.js +3 -0
  256. package/lib-prod/express-types.js.map +1 -0
  257. package/lib-prod/formly/formly.models.d.ts +1 -0
  258. package/lib-prod/formly/formly.models.js +3 -0
  259. package/lib-prod/formly/formly.models.js.map +1 -0
  260. package/lib-prod/formly/fromly.d.ts +16 -0
  261. package/lib-prod/formly/fromly.js +209 -0
  262. package/lib-prod/formly/fromly.js.map +1 -0
  263. package/lib-prod/formly/type-from-entity.d.ts +20 -0
  264. package/lib-prod/formly/type-from-entity.js +60 -0
  265. package/lib-prod/formly/type-from-entity.js.map +1 -0
  266. package/lib-prod/get-response-value.d.ts +6 -0
  267. package/lib-prod/get-response-value.js +27 -0
  268. package/lib-prod/get-response-value.js.map +1 -0
  269. package/lib-prod/global-state/taon-global-state/index.d.ts +5 -0
  270. package/lib-prod/global-state/taon-global-state/index.js +23 -0
  271. package/lib-prod/global-state/taon-global-state/index.js.map +1 -0
  272. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +19 -0
  273. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +23 -0
  274. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js.map +1 -0
  275. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.d.ts +2 -0
  276. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +11 -0
  277. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js.map +1 -0
  278. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.d.ts +11 -0
  279. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +62 -0
  280. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +1 -0
  281. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.d.ts +7 -0
  282. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +64 -0
  283. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js.map +1 -0
  284. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.d.ts +3 -0
  285. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +22 -0
  286. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js.map +1 -0
  287. package/lib-prod/global-state/taon-global-state/taon-global-state.models.d.ts +28 -0
  288. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +48 -0
  289. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js.map +1 -0
  290. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.d.ts +3 -0
  291. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +22 -0
  292. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js.map +1 -0
  293. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.d.ts +9 -0
  294. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +53 -0
  295. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +1 -0
  296. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.d.ts +7 -0
  297. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +29 -0
  298. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js.map +1 -0
  299. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.d.ts +4 -0
  300. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +16 -0
  301. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +1 -0
  302. package/lib-prod/global-state/taon-transaction-registry/index.d.ts +10 -0
  303. package/lib-prod/global-state/taon-transaction-registry/index.js +28 -0
  304. package/lib-prod/global-state/taon-transaction-registry/index.js.map +1 -0
  305. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +19 -0
  306. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +25 -0
  307. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +1 -0
  308. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.d.ts +2 -0
  309. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +9 -0
  310. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +1 -0
  311. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +9 -0
  312. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +52 -0
  313. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -0
  314. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.d.ts +12 -0
  315. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +77 -0
  316. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +1 -0
  317. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.d.ts +3 -0
  318. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +22 -0
  319. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +1 -0
  320. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.d.ts +6 -0
  321. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +11 -0
  322. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +1 -0
  323. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.d.ts +3 -0
  324. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +22 -0
  325. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +1 -0
  326. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.d.ts +9 -0
  327. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +38 -0
  328. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +1 -0
  329. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.d.ts +7 -0
  330. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +29 -0
  331. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +1 -0
  332. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +4 -0
  333. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +11 -0
  334. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -0
  335. package/lib-prod/helpers/class-helpers.d.ts +24 -0
  336. package/lib-prod/helpers/class-helpers.js +233 -0
  337. package/lib-prod/helpers/class-helpers.js.map +1 -0
  338. package/lib-prod/helpers/clone-obj.d.ts +1 -0
  339. package/lib-prod/helpers/clone-obj.js +22 -0
  340. package/lib-prod/helpers/clone-obj.js.map +1 -0
  341. package/lib-prod/helpers/taon-helpers.d.ts +18 -0
  342. package/lib-prod/helpers/taon-helpers.js +152 -0
  343. package/lib-prod/helpers/taon-helpers.js.map +1 -0
  344. package/lib-prod/index._auto-generated_.d.ts +0 -0
  345. package/lib-prod/index._auto-generated_.js +6 -0
  346. package/lib-prod/index._auto-generated_.js.map +1 -0
  347. package/lib-prod/index.d.ts +234 -0
  348. package/lib-prod/index.js +272 -0
  349. package/lib-prod/index.js.map +1 -0
  350. package/lib-prod/inject.d.ts +4 -0
  351. package/lib-prod/inject.js +94 -0
  352. package/lib-prod/inject.js.map +1 -0
  353. package/lib-prod/models.d.ts +260 -0
  354. package/lib-prod/models.js +125 -0
  355. package/lib-prod/models.js.map +1 -0
  356. package/lib-prod/orm/columns.d.ts +32 -0
  357. package/lib-prod/orm/columns.js +112 -0
  358. package/lib-prod/orm/columns.js.map +1 -0
  359. package/lib-prod/orm/index.d.ts +1 -0
  360. package/lib-prod/orm/index.js +73 -0
  361. package/lib-prod/orm/index.js.map +1 -0
  362. package/lib-prod/realtime/realtime-client.d.ts +41 -0
  363. package/lib-prod/realtime/realtime-client.js +204 -0
  364. package/lib-prod/realtime/realtime-client.js.map +1 -0
  365. package/lib-prod/realtime/realtime-core.d.ts +40 -0
  366. package/lib-prod/realtime/realtime-core.js +106 -0
  367. package/lib-prod/realtime/realtime-core.js.map +1 -0
  368. package/lib-prod/realtime/realtime-server.d.ts +43 -0
  369. package/lib-prod/realtime/realtime-server.js +243 -0
  370. package/lib-prod/realtime/realtime-server.js.map +1 -0
  371. package/lib-prod/realtime/realtime-strategy/index.d.ts +4 -0
  372. package/lib-prod/realtime/realtime-strategy/index.js +21 -0
  373. package/lib-prod/realtime/realtime-strategy/index.js.map +1 -0
  374. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +80 -0
  375. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +297 -0
  376. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -0
  377. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.d.ts +14 -0
  378. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +303 -0
  379. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -0
  380. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +16 -0
  381. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +33 -0
  382. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -0
  383. package/lib-prod/realtime/realtime-strategy/realtime-strategy.d.ts +11 -0
  384. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +17 -0
  385. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js.map +1 -0
  386. package/lib-prod/realtime/realtime-subs-manager.d.ts +14 -0
  387. package/lib-prod/realtime/realtime-subs-manager.js +94 -0
  388. package/lib-prod/realtime/realtime-subs-manager.js.map +1 -0
  389. package/lib-prod/realtime/realtime.models.d.ts +27 -0
  390. package/lib-prod/realtime/realtime.models.js +3 -0
  391. package/lib-prod/realtime/realtime.models.js.map +1 -0
  392. package/lib-prod/symbols.d.ts +65 -0
  393. package/lib-prod/symbols.js +110 -0
  394. package/lib-prod/symbols.js.map +1 -0
  395. package/lib-prod/ui/index.d.ts +1 -0
  396. package/lib-prod/ui/index.js +5 -0
  397. package/lib-prod/ui/index.js.map +1 -0
  398. package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -0
  399. package/lib-prod/ui/taon-admin-mode-configuration/index.js +5 -0
  400. package/lib-prod/ui/taon-admin-mode-configuration/index.js.map +1 -0
  401. package/lib-prod/validators.d.ts +7 -0
  402. package/lib-prod/validators.js +85 -0
  403. package/lib-prod/validators.js.map +1 -0
  404. package/package.json +22 -6
  405. package/websql/fesm2022/taon-websql.mjs +1387 -1141
  406. package/websql/fesm2022/taon-websql.mjs.map +1 -1
  407. package/websql/package.json +1 -1
  408. package/websql/types/taon-websql.d.ts +7 -3
  409. package/websql-prod/README.md +24 -0
  410. package/websql-prod/fesm2022/taon-websql.mjs +8198 -0
  411. package/websql-prod/fesm2022/taon-websql.mjs.map +1 -0
  412. package/websql-prod/types/taon-websql.d.ts +2187 -0
@@ -6,7 +6,7 @@ import { JSON10 } from 'json10/websql';
6
6
  import { walk } from 'lodash-walk-object/websql';
7
7
  import { RestResponseWrapper, Models as Models$1, Resource, RestHeaders, Mapping, HttpResponseError } from 'ng2-rest/websql';
8
8
  import { Observable, Subject, from } from 'rxjs';
9
- import { OrignalClassKey, Table, TableIndex, EventSubscriber, Entity, DataSource, Column, PrimaryGeneratedColumn, VersionColumn } from 'taon-typeorm/websql';
9
+ import { OrignalClassKey, Table, TableIndex, EventSubscriber, Entity, DataSource, Column, PrimaryGeneratedColumn, VersionColumn, CreateDateColumn } from 'taon-typeorm/websql';
10
10
  export { AfterInsert, AfterLoad, AfterRecover, AfterRemove, AfterSoftRemove, AfterUpdate, BeforeInsert, BeforeRecover, BeforeRemove, BeforeSoftRemove, BeforeUpdate, Column, Connection, CreateDateColumn, Column as CustomColumn, DeleteDateColumn, Generated, Generated as GeneratedColumn, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Repository, TreeChildren, TreeParent, UpdateDateColumn, VersionColumn, VirtualColumn } from 'taon-typeorm/websql';
11
11
  import * as i0 from '@angular/core';
12
12
  import { InjectionToken, inject as inject$1, PLATFORM_ID, Injectable, ViewContainerRef, ViewChild, Component } from '@angular/core';
@@ -5350,7 +5350,16 @@ const String100Column = (defaultValue = null) => Column({
5350
5350
  default: defaultValue,
5351
5351
  });
5352
5352
  /**
5353
- * 100 characters varchar
5353
+ * 20 characters varchar
5354
+ */
5355
+ const String20Column = (defaultValue = null) => Column({
5356
+ type: 'varchar',
5357
+ length: 20,
5358
+ nullable: _.isNil(defaultValue),
5359
+ default: defaultValue,
5360
+ });
5361
+ /**
5362
+ * 45 characters varchar
5354
5363
  */
5355
5364
  const String45Column = (defaultValue = null) => Column({
5356
5365
  type: 'varchar',
@@ -5598,13 +5607,283 @@ class TaonBaseAngularService {
5598
5607
  return currentContext ? currentContext.getClass(ctor) : void 0;
5599
5608
  });
5600
5609
  }
5601
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TaonBaseAngularService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5602
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TaonBaseAngularService }); }
5610
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TaonBaseAngularService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5611
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TaonBaseAngularService }); }
5603
5612
  }
5604
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TaonBaseAngularService, decorators: [{
5613
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TaonBaseAngularService, decorators: [{
5605
5614
  type: Injectable
5606
5615
  }], ctorParameters: () => [] });
5607
5616
 
5617
+ var TaonGlobalStateStatus;
5618
+ (function (TaonGlobalStateStatus) {
5619
+ TaonGlobalStateStatus["NORMAL"] = "normal";
5620
+ /**
5621
+ * no new transactions allowed
5622
+ * existing ones may finish
5623
+ */
5624
+ TaonGlobalStateStatus["DRAINING"] = "draining";
5625
+ /**
5626
+ * DB is readonly
5627
+ * app is readonly (no writes, no side effects)
5628
+ */
5629
+ TaonGlobalStateStatus["READONLY"] = "readonly";
5630
+ /**
5631
+ * Db and app still readonly - migration in progress
5632
+ */
5633
+ TaonGlobalStateStatus["MIGRATING"] = "migrating";
5634
+ /**
5635
+ * emergency stop / maintenance mode
5636
+ */
5637
+ TaonGlobalStateStatus["FROZEN"] = "frozen";
5638
+ })(TaonGlobalStateStatus || (TaonGlobalStateStatus = {}));
5639
+ const allowedTaonGlobalStatusOrders = {
5640
+ [TaonGlobalStateStatus.NORMAL]: [
5641
+ TaonGlobalStateStatus.DRAINING,
5642
+ TaonGlobalStateStatus.FROZEN,
5643
+ ],
5644
+ [TaonGlobalStateStatus.DRAINING]: [
5645
+ TaonGlobalStateStatus.READONLY,
5646
+ TaonGlobalStateStatus.FROZEN,
5647
+ ],
5648
+ [TaonGlobalStateStatus.READONLY]: [
5649
+ TaonGlobalStateStatus.MIGRATING,
5650
+ TaonGlobalStateStatus.NORMAL,
5651
+ TaonGlobalStateStatus.FROZEN,
5652
+ ],
5653
+ [TaonGlobalStateStatus.MIGRATING]: [
5654
+ TaonGlobalStateStatus.READONLY
5655
+ ],
5656
+ [TaonGlobalStateStatus.FROZEN]: [
5657
+ TaonGlobalStateStatus.READONLY,
5658
+ TaonGlobalStateStatus.NORMAL,
5659
+ ],
5660
+ };
5661
+
5662
+ const TaonGlobalStateDefaultsValues = {
5663
+ description: '',
5664
+ version: 0,
5665
+ id: void 0,
5666
+ status: TaonGlobalStateStatus.NORMAL,
5667
+ };
5668
+
5669
+ /**
5670
+ * Entity decorator
5671
+ */
5672
+ function TaonEntity(options) {
5673
+ return function (constructor) {
5674
+ options = options || {};
5675
+ options.uniqueKeyProp = options.uniqueKeyProp || 'id';
5676
+ ClassHelpers.setName(constructor, options?.className);
5677
+ Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
5678
+ // TODO when entit metadata generator read use this
5679
+ Mapping.DefaultModelWithMapping(void 0, {})(constructor);
5680
+ Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
5681
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
5682
+ //#region @websql
5683
+ Entity(options?.className)(constructor);
5684
+ //#endregion
5685
+ CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
5686
+ };
5687
+ }
5688
+ class TaonEntityOptions extends DecoratorAbstractOpt {
5689
+ }
5690
+
5691
+ //#region imports
5692
+ //#endregion
5693
+ let TAON_GLOBAL_STATE = class TAON_GLOBAL_STATE extends TaonBaseAbstractEntity {
5694
+ };
5695
+ __decorate([
5696
+ Column({
5697
+ type: 'varchar',
5698
+ length: 20,
5699
+ nullable: false,
5700
+ default: TaonGlobalStateDefaultsValues.status,
5701
+ })
5702
+ //#endregion
5703
+ ,
5704
+ __metadata("design:type", String)
5705
+ ], TAON_GLOBAL_STATE.prototype, "status", void 0);
5706
+ __decorate([
5707
+ CreateDateColumn()
5708
+ //#endregion
5709
+ ,
5710
+ __metadata("design:type", Date)
5711
+ ], TAON_GLOBAL_STATE.prototype, "createdAt", void 0);
5712
+ __decorate([
5713
+ Column({
5714
+ type: 'int',
5715
+ nullable: true,
5716
+ })
5717
+ //#endregion
5718
+ ,
5719
+ __metadata("design:type", Date)
5720
+ ], TAON_GLOBAL_STATE.prototype, "secondsBeforeReadonly", void 0);
5721
+ TAON_GLOBAL_STATE = __decorate([
5722
+ TaonEntity({
5723
+ className: 'TAON_GLOBAL_STATE',
5724
+ createTable: true,
5725
+ })
5726
+ ], TAON_GLOBAL_STATE);
5727
+
5728
+ /**
5729
+ * Controller decorator
5730
+ */
5731
+ function TaonController(options) {
5732
+ return function (constructor) {
5733
+ ClassHelpers.setName(constructor, options?.className);
5734
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
5735
+ const cfg = ClassHelpers.ensureClassConfig(constructor);
5736
+ options = options || {};
5737
+ cfg.className = options.className || constructor.name;
5738
+ cfg.path = options.path || '';
5739
+ cfg.realtime = options.realtime;
5740
+ cfg.middlewares = options.middlewares;
5741
+ };
5742
+ }
5743
+
5744
+ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
5745
+ const methodConfig = ClassHelpers.ensureMethodConfig(target, propertyKey);
5746
+ let options;
5747
+ if (typeof pathOrOptions === 'object') {
5748
+ options = pathOrOptions;
5749
+ pathOrOptions = options.path;
5750
+ pathIsGlobal = !!options.pathIsGlobal;
5751
+ path = options.path;
5752
+ }
5753
+ else {
5754
+ options = { pathOrOptions, pathIsGlobal };
5755
+ }
5756
+ const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
5757
+ methodConfig.methodName = propertyKey;
5758
+ methodConfig.middlewares = middlewares;
5759
+ methodConfig.type = method;
5760
+ if (!path) {
5761
+ let paramsPathConcatedPath = '';
5762
+ for (const key in methodConfig.parameters) {
5763
+ if (methodConfig.parameters.hasOwnProperty(key)) {
5764
+ const element = methodConfig.parameters[key];
5765
+ if (element.paramType === 'Path' &&
5766
+ _.isString(element.paramName) &&
5767
+ element.paramName.trim().length > 0) {
5768
+ paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
5769
+ }
5770
+ }
5771
+ }
5772
+ methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
5773
+ }
5774
+ else {
5775
+ methodConfig.path = path;
5776
+ }
5777
+ methodConfig.descriptor = descriptor;
5778
+ methodConfig.global = pathIsGlobal;
5779
+ methodConfig.contentType = overrideContentType;
5780
+ methodConfig.responseType = overrideResponseType;
5781
+ methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
5782
+ };
5783
+ function GET(pathOrOptions, pathIsGlobal = false) {
5784
+ return function (target, propertyKey, descriptor) {
5785
+ metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5786
+ };
5787
+ }
5788
+ /**
5789
+ * Method for sending html website from text
5790
+ * Example
5791
+ *
5792
+ * ```ts
5793
+ * ...
5794
+ * // in your taon controller
5795
+ * ..Taon.Http.HTML()
5796
+ * sendHtmlDummyWebsite(): Taon.ResponseHtml {
5797
+ * return `
5798
+ <html>
5799
+ <head>
5800
+ <title>Dummy website</title>
5801
+ </head>
5802
+ <body>
5803
+ <h1>This is dummy website</h1>
5804
+ <p>Served as HTML string from Taon controller method</p>
5805
+ </body>
5806
+ </html>
5807
+ * `; *
5808
+ * }
5809
+ * ...
5810
+ * ```
5811
+ */
5812
+ function HTML(pathOrOptions) {
5813
+ return function (target, propertyKey, descriptor) {
5814
+ const opt = pathOrOptions;
5815
+ opt.overrideExpressSendAsHtml = true;
5816
+ metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
5817
+ };
5818
+ }
5819
+ function HEAD(pathOrOptions, pathIsGlobal = false) {
5820
+ return function (target, propertyKey, descriptor) {
5821
+ metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5822
+ };
5823
+ }
5824
+ function POST(pathOrOptions, pathIsGlobal = false) {
5825
+ return function (target, propertyKey, descriptor) {
5826
+ metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5827
+ };
5828
+ }
5829
+ function PUT(pathOrOptions, pathIsGlobal = false) {
5830
+ return function (target, propertyKey, descriptor) {
5831
+ metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5832
+ };
5833
+ }
5834
+ function PATCH(pathOrOptions, pathIsGlobal = false) {
5835
+ return function (target, propertyKey, descriptor) {
5836
+ metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5837
+ };
5838
+ }
5839
+ function DELETE(pathOrOptions, pathIsGlobal = false) {
5840
+ return function (target, propertyKey, descriptor) {
5841
+ metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
5842
+ };
5843
+ }
5844
+
5845
+ function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
5846
+ const methodCfg = ClassHelpers.ensureMethodConfig(target, propertyKey);
5847
+ const nameKey = name ? name : param;
5848
+ // const key = name || `${param}_${parameterIndex}`;
5849
+ methodCfg.parameters[nameKey] = {
5850
+ index: parameterIndex,
5851
+ paramName: name,
5852
+ paramType: param,
5853
+ defaultType: defaultValue,
5854
+ expireInSeconds: expire,
5855
+ };
5856
+ // console.log('params updated', methodConfig);
5857
+ }
5858
+ /**
5859
+ * @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
5860
+ */
5861
+ function Path(name) {
5862
+ return function (target, propertyKey, parameterIndex) {
5863
+ metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
5864
+ };
5865
+ }
5866
+ function Query(name) {
5867
+ return function (target, propertyKey, parameterIndex) {
5868
+ metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
5869
+ };
5870
+ }
5871
+ function Cookie(name, expireInSecond = 3600) {
5872
+ return function (target, propertyKey, parameterIndex) {
5873
+ metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
5874
+ };
5875
+ }
5876
+ function Header(name) {
5877
+ return function (target, propertyKey, parameterIndex) {
5878
+ metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
5879
+ };
5880
+ }
5881
+ function Body(name) {
5882
+ return function (target, propertyKey, parameterIndex) {
5883
+ metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
5884
+ };
5885
+ }
5886
+
5608
5887
  /**
5609
5888
  * Provider decorator
5610
5889
  */
@@ -5879,1274 +6158,1174 @@ TaonBaseFileUploadMiddleware = __decorate([
5879
6158
  })
5880
6159
  ], TaonBaseFileUploadMiddleware);
5881
6160
 
5882
- /**
5883
- * Repository decorator
5884
- */
5885
- function TaonRepository(options) {
5886
- return function (constructor) {
5887
- Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
5888
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
5889
- ClassHelpers.setName(constructor, options?.className);
5890
- };
5891
- }
5892
- class TaonRepositoryOptions extends DecoratorAbstractOpt {
5893
- }
5894
-
5895
- //#endregion
5896
- let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
5897
- };
5898
- TaonBaseCustomRepository = __decorate([
5899
- TaonRepository({ className: 'TaonBaseCustomRepository' })
5900
- ], TaonBaseCustomRepository);
5901
-
5902
- //#endregion
5903
- const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
5904
- let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
5905
- constructor(
5906
- // Injected through TaonBaseCrudController
5907
- __entityClassResolveFn) {
5908
- super();
5909
- this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
5910
- this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
5911
- // @ts-ignore
5912
- this.entityClassResolveFn = __entityClassResolveFn;
5913
- }
5914
- get dbQuery() {
5915
- //#region @websqlFunc
5916
- if (!this.__dbQuery) {
5917
- if (!this.ctx) {
5918
- return; // TODO
5919
- throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers.getName(this)}`);
5920
- }
5921
- const connection = this.ctx?.connection;
5922
- if (!connection) {
5923
- throw new Error(`[TaonBaseRepository] Database not inited for context ${this.ctx?.contextName}`);
5924
- }
5925
- this.__dbQuery = new MySqlQuerySource(connection);
5926
- }
5927
- return this.__dbQuery;
5928
- //#endregion
5929
- }
5930
- //#endregion
5931
- //#region connection
5932
- get connection() {
5933
- //#region @websqlFunc
5934
- return this.ctx?.connection;
5935
- //#endregion
5936
- }
5937
- //#endregion
5938
- //#region repository
5939
- get repository() {
5940
- //#region @websqlFunc
5941
- if (this[this.REPOS_CACHE_KEY]) {
5942
- return this[this.REPOS_CACHE_KEY];
5943
- }
5944
- const resolvedRepoClass = this.entityClassResolveFn();
5945
- const resolvedRepoName = ClassHelpers.getName(resolvedRepoClass);
5946
- const repo = this.ctx.repos.get(resolvedRepoName);
5947
- // TODO better recognize what is class in context
5948
- if (!repo) {
5949
- throw `[TaonBaseRepository] Repository for entity "${resolvedRepoName}"
5950
- not found in context "${this.ctx?.contextName}".
5951
-
5952
- Is ${resolvedRepoName} a Taon entity class ?
5953
-
5954
- OR
5955
-
5956
- If ${resolvedRepoName} is a Taon Custom Repository, then use this:
5957
-
5958
- ...
5959
- ${_.lowerFirst(resolvedRepoName)} = injectCustomRepository(${resolvedRepoName});
5960
- ...
5961
-
5962
- `;
5963
- }
5964
- this[this.REPOS_CACHE_KEY] = repo;
5965
- return this[this.REPOS_CACHE_KEY];
5966
- //#endregion
5967
- }
6161
+ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
5968
6162
  /**
5969
- * target for repository
6163
+ * Hook that is called when taon app is inited
6164
+ * (all contexts are created and inited)
5970
6165
  */
5971
- get target() {
5972
- //#region @websqlFunc
5973
- return this?.repository?.target;
5974
- //#endregion
6166
+ async afterAllCtxInited(options) { }
6167
+ //#region upload form data to server
6168
+ uploadFormDataToServer(formData, queryParams) {
6169
+ /* */
6170
+ /* */
6171
+ /* */
6172
+ /* */
6173
+ /* */
6174
+ /* */
6175
+ /* */
6176
+ /* */
6177
+ /* */
6178
+ /* */
6179
+ /* */
6180
+ /* */
6181
+ /* */
6182
+ /* */
6183
+ /* */
6184
+ /* */
6185
+ /* */
6186
+ /* */
6187
+ /* */
6188
+ /* */
6189
+ /* */
6190
+ /* */
6191
+ /* */
6192
+ /* */
6193
+ /* */
6194
+ /* */
6195
+ return (void 0);
5975
6196
  }
6197
+ //#endregion
6198
+ //#region after file upload hook
5976
6199
  /**
5977
- * alias to repository
6200
+ * Hook after file is uploaded
6201
+ * through `uploadFormDataToServer` or `uploadLocalFileToServer`
5978
6202
  */
5979
- get repo() {
5980
- //#region @websqlFunc
5981
- return this.repository;
5982
- //#endregion
6203
+ afterFileUploadAction(file, queryParams) {
6204
+ // empty
5983
6205
  }
5984
- get repositoryExists() {
5985
- //#region @websqlFunc
5986
- return !!this.repository;
5987
- //#endregion
6206
+ //#region upload local file to server
6207
+ async uploadLocalFileToServer(absFilePath, options, queryParams) {
6208
+ /* */
6209
+ /* */
6210
+ /* */
6211
+ /* */
6212
+ /* */
6213
+ /* */
6214
+ /* */
6215
+ /* */
6216
+ /* */
6217
+ /* */
6218
+ /* */
6219
+ /* */
6220
+ /* */
6221
+ /* */
6222
+ return (void 0);
5988
6223
  }
5989
6224
  //#endregion
5990
- //#region crud operations / typeorm / has id
6225
+ // async check() {
6226
+ // await this._waitForProperStatusChange({
6227
+ // request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6228
+ // statusCheck: resp => resp.body.json[0].ok,
6229
+ // });
6230
+ // }
5991
6231
  /**
5992
- * Checks if entity has an id.
5993
- * If entity composite compose ids, it will check them all.
6232
+ * Easy way to wait for status change with http (1s default) pooling.
6233
+ *
6234
+ * example (in sub class):
6235
+ * ```ts
6236
+ async check() {
6237
+ await this.waitForProperStatusChange({
6238
+ request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6239
+ statusCheck: resp => resp.body.json[0].ok,
6240
+ });
6241
+ }
6242
+ * ```
5994
6243
  */
5995
- hasId(entity) {
5996
- return this.repo.hasId(entity);
6244
+ async _waitForProperStatusChange(options) {
6245
+ const poolingInterval = options.poolingInterval || 1000;
6246
+ const taonRequest = options.request;
6247
+ let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
6248
+ let i = 0;
6249
+ let httpErrorsCount = 0;
6250
+ while (true) {
6251
+ await UtilsTerminal.waitMilliseconds(poolingInterval);
6252
+ try {
6253
+ const resp = await taonRequest({
6254
+ reqIndexNum: i,
6255
+ httpErrorsCount,
6256
+ });
6257
+ if (options.statusCheck && options.statusCheck(resp)) {
6258
+ return;
6259
+ }
6260
+ }
6261
+ catch (error) {
6262
+ httpErrorsCount++;
6263
+ if (options.loopRequestsOnBackendError) {
6264
+ const isProperTaonError = error instanceof HttpResponseError &&
6265
+ error.body.json[CoreModels.TaonHttpErrorCustomProp];
6266
+ const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
6267
+ const isUnknownError = !(error instanceof HttpResponseError);
6268
+ const resBool = await options.loopRequestsOnBackendError({
6269
+ taonError: isProperTaonError ? error : void 0,
6270
+ unknownHttpError: isHttpError ? error : void 0,
6271
+ unknownError: isUnknownError ? error : void 0,
6272
+ reqIndexNum: i,
6273
+ httpErrorsCount,
6274
+ });
6275
+ if (resBool) {
6276
+ i++;
6277
+ continue;
6278
+ }
6279
+ else {
6280
+ return;
6281
+ }
6282
+ }
6283
+ if (httpErrorsCount >
6284
+ (options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
6285
+ throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
6286
+ }
6287
+ }
6288
+ if (i++ > maxTries) {
6289
+ throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
6290
+ }
6291
+ }
5997
6292
  }
6293
+ };
6294
+ __decorate([
6295
+ POST({
6296
+ overrideContentType: 'multipart/form-data',
6297
+ middlewares: ({ parentMiddlewares }) => ({
6298
+ ...parentMiddlewares,
6299
+ TaonBaseFileUploadMiddleware,
6300
+ }),
6301
+ }),
6302
+ __param(0, Body()),
6303
+ __param(1, Query()),
6304
+ __metadata("design:type", Function),
6305
+ __metadata("design:paramtypes", [FormData, Object]),
6306
+ __metadata("design:returntype", Object)
6307
+ ], TaonBaseController.prototype, "uploadFormDataToServer", null);
6308
+ TaonBaseController = __decorate([
6309
+ TaonController({
6310
+ className: 'TaonBaseController',
6311
+ })
6312
+ ], TaonBaseController);
6313
+
6314
+ //#endregion
6315
+ /**
6316
+ * Please override property entityClassFn with entity class.
6317
+ */
6318
+ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
5998
6319
  //#endregion
5999
- //#region crud operations / typeorm / get id
6000
- /**
6001
- * Gets entity mixed id.
6002
- */
6003
- getId(entity) {
6004
- return this.repo.getId(entity);
6320
+ //#region init
6321
+ async _() {
6322
+ if (!_.isFunction(this.entityClassResolveFn)) {
6323
+ Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
6324
+ return;
6325
+ }
6326
+ let entityClassFn = this.entityClassResolveFn();
6327
+ this.db = this.injectRepo(entityClassFn);
6328
+ if (entityClassFn) {
6329
+ const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
6330
+ if (configEntity?.createTable === false) {
6331
+ Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
6332
+ }
6333
+ }
6334
+ else {
6335
+ Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
6336
+
6337
+ Please provide entity as class property entityClassFn:
6338
+
6339
+ class ${ClassHelpers.getName(this)} extends TaonBaseCrudController<Entity> {
6340
+ // ...
6341
+ entityClassResolveFn = ()=> MyEntityClass;
6342
+ // ...
6343
+ }
6344
+
6345
+ `);
6346
+ }
6347
+ await super._();
6005
6348
  }
6006
6349
  //#endregion
6007
- //#region crud operations / typeorm / create & bulk create
6008
- /**
6009
- Saves a given entity in the database.
6010
- * If entity does not exist in the database then inserts, otherwise updates.
6011
- */
6012
- async save(item, options) {
6350
+ //#region bufferd changes
6351
+ bufforedChanges(id, property, alreadyLength) {
6013
6352
  //#region @websqlFunc
6014
- // if (!this.repo) {
6015
- // debugger;
6016
- // }
6017
- let model = await this.repo.create(item);
6018
- model = await this.repo.save(model, options);
6019
- const { id } = model;
6020
- model = await this.repo.findOne({
6021
- where: { id },
6022
- });
6023
- return model;
6353
+ return async (request, response) => {
6354
+ const model = await this.db.getBy(id);
6355
+ if (model === void 0) {
6356
+ return;
6357
+ }
6358
+ Validators.preventUndefinedModel(model, id);
6359
+ let value = model[property];
6360
+ let result;
6361
+ if (_.isString(value) || _.isArray(value)) {
6362
+ result = value.slice(alreadyLength);
6363
+ }
6364
+ return result;
6365
+ };
6024
6366
  //#endregion
6025
6367
  }
6026
- /**
6027
- * Creates a new entity instance or instances.
6028
- * Can copy properties from the given object into new entities.
6029
- */
6030
- create(plainEntityLikeOrPlainEntityLikes) {
6031
- return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6032
- }
6033
- async bulkSave(items, options) {
6368
+ //#endregion
6369
+ //#region pagintation
6370
+ pagination(pageNumber = 1, pageSize = 10, search = '') {
6034
6371
  //#region @websqlFunc
6035
- const models = [];
6036
- for (let index = 0; index < items.length; index++) {
6037
- const item = items[index];
6038
- // TODO FIX THIS / REFACTOR
6039
- const model = await this.save(item, options);
6040
- models.push(model);
6041
- }
6042
- return models;
6372
+ return async (request, response) => {
6373
+ if (this.db.repositoryExists) {
6374
+ const query = {
6375
+ page: pageNumber,
6376
+ take: pageSize,
6377
+ keyword: search,
6378
+ };
6379
+ // console.log({
6380
+ // query
6381
+ // })
6382
+ const take = query.take || 10;
6383
+ const page = query.page || 1;
6384
+ const skip = (page - 1) * take;
6385
+ const keyword = query.keyword || '';
6386
+ const [result, total] = await this.db.findAndCount({
6387
+ // where: { name: Like('%' + keyword + '%') },
6388
+ // order: { name: "DESC" },
6389
+ take: take,
6390
+ skip: skip,
6391
+ });
6392
+ response?.setHeader(Symbols.old.X_TOTAL_COUNT, total);
6393
+ // const lastPage = Math.ceil(total / take);
6394
+ // const nextPage = page + 1 > lastPage ? null : page + 1;
6395
+ // const prevPage = page - 1 < 1 ? null : page - 1;
6396
+ // console.log({
6397
+ // result,
6398
+ // total
6399
+ // })
6400
+ return result;
6401
+ }
6402
+ return [];
6403
+ };
6043
6404
  //#endregion
6044
6405
  }
6045
- /**
6046
- * @deprecated use bulkSave instead
6047
- */
6048
- async bulkCreate(items, options) {
6049
- return this.bulkSave(items, options);
6050
- }
6051
- //#region old typeorm version
6052
- /**
6053
- * Saves all given entities in the database.
6054
- * If entities do not exist in the database then inserts, otherwise updates.
6055
- */
6056
- // save<T extends DeepPartial<Entity>>(
6057
- // entities: T[],
6058
- // options: SaveOptions & {
6059
- // reload: false;
6060
- // },
6061
- // ): Promise<T[]>;
6062
- // /**
6063
- // * Saves all given entities in the database.
6064
- // * If entities do not exist in the database then inserts, otherwise updates.
6065
- // */
6066
- // save<T extends DeepPartial<Entity>>(
6067
- // entities: T[],
6068
- // options?: SaveOptions,
6069
- // ): Promise<(T & Entity)[]>;
6070
- // /**
6071
- // * Saves a given entity in the database.
6072
- // * If entity does not exist in the database then inserts, otherwise updates.
6073
- // */
6074
- // save<T extends DeepPartial<Entity>>(
6075
- // entity: T,
6076
- // options: SaveOptions & {
6077
- // reload: false;
6078
- // },
6079
- // ): Promise<T>;
6080
- // /**
6081
- // * Saves a given entity in the database.
6082
- // * If entity does not exist in the database then inserts, otherwise updates.
6083
- // */
6084
- // save<T extends DeepPartial<Entity>>(
6085
- // entity: T,
6086
- // options?: SaveOptions,
6087
- // ): Promise<T & Entity> {
6088
- // return this.repo.save(entity, options);
6089
- // }
6090
- //#endregion
6091
- //#endregion
6092
- //#region crud operations / typeorm / merge
6093
- /**
6094
- * Merges multiple entities (or entity-like objects) into a given entity.
6095
- */
6096
- merge(mergeIntoEntity, ...entityLikes) {
6097
- return this.repo.merge(mergeIntoEntity, ...entityLikes);
6098
- }
6099
6406
  //#endregion
6100
- //#region crud operations / typeorm / preload
6101
- /**
6102
- * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
6103
- * it loads it (and everything related to it), replaces all values with the new ones from the given object
6104
- * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
6105
- * replaced from the new object.
6106
- *
6107
- * Note that given entity-like object must have an entity id / primary key to find entity by.
6108
- * Returns undefined if entity with given id was not found.
6109
- */
6110
- preload(entityLike) {
6111
- return this.repo.preload(entityLike);
6407
+ //#region get all
6408
+ getAll() {
6409
+ //#region @websqlFunc
6410
+ return async (request, response) => {
6411
+ if (this.db.repositoryExists) {
6412
+ const { models, totalCount } = await this.db.getAll();
6413
+ response?.setHeader(Symbols.old.X_TOTAL_COUNT, totalCount);
6414
+ return models;
6415
+ }
6416
+ return [];
6417
+ };
6418
+ //#endregion
6112
6419
  }
6113
6420
  //#endregion
6114
- //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6115
- /**
6116
- * Removes a given entities from the database.
6117
- */
6118
- async remove(idOrEntity) {
6421
+ //#region get by id
6422
+ getBy(id) {
6119
6423
  //#region @websqlFunc
6120
- if (_.isObject(idOrEntity)) {
6121
- idOrEntity = idOrEntity.id;
6122
- }
6123
- const deletedEntity = await this.repo.findOne({
6124
- where: { id: idOrEntity },
6125
- });
6126
- if (!deletedEntity) {
6127
- Helpers.warn(`[TaonBaseRepository] Entity "${ClassHelpers.getName(this.repo.target)}" ` + `with id ${idOrEntity} not found, cannot remove`);
6128
- return;
6129
- }
6130
- const idCopy = deletedEntity.id;
6131
- await this.repo.remove(deletedEntity);
6132
- deletedEntity.id = idCopy;
6133
- return deletedEntity;
6424
+ return async () => {
6425
+ const model = await this.db.getBy(id);
6426
+ return model;
6427
+ };
6134
6428
  //#endregion
6135
6429
  }
6136
- /**
6137
- * alias to remove
6138
- */
6139
- async delete(idOrEntity) {
6140
- return this.remove(idOrEntity);
6141
- }
6142
- /**
6143
- * alias to removeById
6144
- */
6145
- async deleteById(id) {
6146
- return this.remove(id);
6147
- }
6148
- async bulkRemove(idsOrEntities) {
6430
+ //#endregion
6431
+ //#region update by id
6432
+ updateById(id, item) {
6149
6433
  //#region @websqlFunc
6150
- idsOrEntities = idsOrEntities.map(id => {
6151
- return _.isObject(id) ? id.id : id;
6152
- });
6153
- const models = [];
6154
- for (let index = 0; index < idsOrEntities.length; index++) {
6155
- const id = idsOrEntities[index];
6156
- const model = await this.remove(id);
6157
- models.push(model);
6158
- }
6159
- return models;
6434
+ return async () => {
6435
+ const model = await this.db.updateById(id, item);
6436
+ return model;
6437
+ };
6160
6438
  //#endregion
6161
6439
  }
6162
- async bulkDelete(ids) {
6163
- return this.bulkRemove(ids);
6164
- }
6165
- /**
6166
- * Records the delete date of a given entity.
6167
- */
6168
- softRemove(entity, options) {
6169
- return this.repo.softRemove(entity, options);
6170
- }
6171
- /**
6172
- * Recovers a given entity in the database.
6173
- */
6174
- recover(entity, options) {
6175
- return this.repo.recover(entity, options);
6176
- }
6177
6440
  //#endregion
6178
- //#region crud operations / typeorm / insert
6179
- /**
6180
- * Inserts a given entity into the database.
6181
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6182
- * Executes fast and efficient INSERT query.
6183
- * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
6184
- */
6185
- insert(entity) {
6186
- // debugger;
6187
- return this.repo.insert(entity);
6441
+ //#region patch by id
6442
+ patchById(id, item) {
6443
+ //#region @websqlFunc
6444
+ return async () => {
6445
+ const model = await this.db.updateById(id, item);
6446
+ return model;
6447
+ };
6448
+ //#endregion
6188
6449
  }
6189
6450
  //#endregion
6190
- //#region crud operations / typeorm / update & build update
6191
- async update(item) {
6451
+ //#region bulk update
6452
+ bulkUpdate(items) {
6192
6453
  //#region @websqlFunc
6193
- const { id } = item;
6194
- return await this.updateById(id, item);
6454
+ return async () => {
6455
+ if (!Array.isArray(items) || items?.length === 0) {
6456
+ return [];
6457
+ }
6458
+ const { models } = await this.db.bulkUpdate(items);
6459
+ return models;
6460
+ };
6195
6461
  //#endregion
6196
6462
  }
6197
- async updateById(id, item) {
6463
+ //#endregion
6464
+ //#region delete by id
6465
+ deleteById(id) {
6198
6466
  //#region @websqlFunc
6199
- const allowedPropsToUpdate = [];
6200
- for (const key in item) {
6201
- const metadataColumn = this.repo.metadata.ownColumns.find(c => c.propertyName === key);
6202
- if (_.isObject(item) &&
6203
- item.hasOwnProperty(key) &&
6204
- (typeof item[key] !== 'object' ||
6205
- this.allowedTypesToUpdate.includes(metadataColumn?.type)) &&
6206
- !_.isUndefined(metadataColumn)) {
6207
- allowedPropsToUpdate.push(key);
6208
- }
6209
- }
6210
- for (let i = 0; i < allowedPropsToUpdate.length; i++) {
6211
- const key = allowedPropsToUpdate[i];
6212
- if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
6213
- // const raw = _.isBoolean(item[key]) || _.isNumber(item[key]) || _.isNull(item[key]); // TODO does this make any sense ?
6214
- const toSet = item[key];
6215
- // const tableName = tableNameFrom(this.entity as any);
6216
- await this.repo.update({
6217
- id,
6218
- }, {
6219
- [key]: toSet,
6220
- });
6221
- // await this.repo.query(
6222
- // `UPDATE '${tableName}' as ${table}
6223
- // SET ${key}=${toSet}
6224
- // WHERE ${table}.id='${id}'
6225
- // `);
6226
- }
6227
- }
6228
- let model = await this.repo.findOne({
6229
- where: { id },
6230
- });
6231
- return model;
6467
+ return async () => {
6468
+ const model = await this.db.deleteById(id);
6469
+ return model;
6470
+ };
6232
6471
  //#endregion
6233
6472
  }
6234
- async bulkUpdate(items) {
6473
+ //#endregion
6474
+ //#region bulk delete
6475
+ bulkDelete(ids) {
6235
6476
  //#region @websqlFunc
6236
- const models = [];
6237
- for (let index = 0; index < items.length; index++) {
6238
- const item = items[index];
6239
- const { id } = item; // TOOD
6240
- const model = await this.updateById(id, item);
6241
- models.push(model);
6242
- }
6243
- return { models };
6477
+ return async () => {
6478
+ const models = await this.db.bulkDelete(ids);
6479
+ return models;
6480
+ };
6244
6481
  //#endregion
6245
6482
  }
6246
- //#region tpeorm update version
6247
- // this version suck and will not return update entity
6248
- // /**
6249
- // * Updates entity partially. Entity can be found by a given conditions.
6250
- // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6251
- // * Executes fast and efficient UPDATE query.
6252
- // * Does not check if entity exist in the database.
6253
- // */
6254
- // update(
6255
- // criteria:
6256
- // | string
6257
- // | string[]
6258
- // | number
6259
- // | number[]
6260
- // | Date
6261
- // | Date[]
6262
- // | ObjectID
6263
- // | ObjectID[]
6264
- // | FindOptionsWhere<Entity>,
6265
- // partialEntity: QueryDeepPartialEntity<Entity>,
6266
- // ): Promise<UpdateResult> {
6267
- // return this.repo.update(criteria, partialEntity);
6268
- // }
6269
6483
  //#endregion
6484
+ //#region bulk delete
6485
+ clearTable() {
6486
+ //#region @websqlFunc
6487
+ return async () => {
6488
+ await this.db.clear();
6489
+ };
6490
+ //#endregion
6491
+ }
6270
6492
  //#endregion
6271
- //#region crud operations / typeorm / upsert
6272
- /**
6273
- * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
6274
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6275
- * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
6276
- */
6277
- upsert(entityOrEntities, conflictPathsOrOptions) {
6278
- return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
6493
+ //#region create
6494
+ save(item) {
6495
+ //#region @websqlFunc
6496
+ return async () => {
6497
+ const model = await this.db.save(item);
6498
+ return model;
6499
+ };
6500
+ //#endregion
6279
6501
  }
6280
6502
  //#endregion
6281
- //#region crud operations / typeorm / soft delete
6282
- /**
6283
- * Records the delete date of entities by a given criteria.
6284
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6285
- * Executes fast and efficient SOFT-DELETE query.
6286
- * Does not check if entity exist in the database.
6287
- */
6288
- softDelete(criteria) {
6289
- return this.repo.softDelete(criteria);
6503
+ //#region bulk create
6504
+ bulkCreate(items) {
6505
+ //#region @websqlFunc
6506
+ return async () => {
6507
+ const models = await this.db.bulkCreate(items);
6508
+ return models;
6509
+ };
6510
+ //#endregion
6511
+ }
6512
+ };
6513
+ __decorate([
6514
+ GET(),
6515
+ __param(0, Query(`id`)),
6516
+ __param(1, Query(`property`)),
6517
+ __param(2, Query('alreadyLength')),
6518
+ __metadata("design:type", Function),
6519
+ __metadata("design:paramtypes", [Object, String, Number]),
6520
+ __metadata("design:returntype", Object)
6521
+ ], TaonBaseCrudController.prototype, "bufforedChanges", null);
6522
+ __decorate([
6523
+ GET(),
6524
+ __param(0, Query('pageNumber')),
6525
+ __param(1, Query('pageSize')),
6526
+ __param(2, Query('search')),
6527
+ __metadata("design:type", Function),
6528
+ __metadata("design:paramtypes", [Number, Number, String]),
6529
+ __metadata("design:returntype", Object)
6530
+ ], TaonBaseCrudController.prototype, "pagination", null);
6531
+ __decorate([
6532
+ GET(),
6533
+ __metadata("design:type", Function),
6534
+ __metadata("design:paramtypes", []),
6535
+ __metadata("design:returntype", Object)
6536
+ ], TaonBaseCrudController.prototype, "getAll", null);
6537
+ __decorate([
6538
+ GET(),
6539
+ __param(0, Query(`id`)),
6540
+ __metadata("design:type", Function),
6541
+ __metadata("design:paramtypes", [Object]),
6542
+ __metadata("design:returntype", Object)
6543
+ ], TaonBaseCrudController.prototype, "getBy", null);
6544
+ __decorate([
6545
+ PUT(),
6546
+ __param(0, Query(`id`)),
6547
+ __param(1, Body()),
6548
+ __metadata("design:type", Function),
6549
+ __metadata("design:paramtypes", [Object, Object]),
6550
+ __metadata("design:returntype", Object)
6551
+ ], TaonBaseCrudController.prototype, "updateById", null);
6552
+ __decorate([
6553
+ PATCH(),
6554
+ __param(0, Query(`id`)),
6555
+ __param(1, Body()),
6556
+ __metadata("design:type", Function),
6557
+ __metadata("design:paramtypes", [Object, Object]),
6558
+ __metadata("design:returntype", Object)
6559
+ ], TaonBaseCrudController.prototype, "patchById", null);
6560
+ __decorate([
6561
+ PUT(),
6562
+ __param(0, Body()),
6563
+ __metadata("design:type", Function),
6564
+ __metadata("design:paramtypes", [Array]),
6565
+ __metadata("design:returntype", Object)
6566
+ ], TaonBaseCrudController.prototype, "bulkUpdate", null);
6567
+ __decorate([
6568
+ DELETE(),
6569
+ __param(0, Query(`id`)),
6570
+ __metadata("design:type", Function),
6571
+ __metadata("design:paramtypes", [Object]),
6572
+ __metadata("design:returntype", Object)
6573
+ ], TaonBaseCrudController.prototype, "deleteById", null);
6574
+ __decorate([
6575
+ DELETE(),
6576
+ __param(0, Query(`ids`)),
6577
+ __metadata("design:type", Function),
6578
+ __metadata("design:paramtypes", [Array]),
6579
+ __metadata("design:returntype", Object)
6580
+ ], TaonBaseCrudController.prototype, "bulkDelete", null);
6581
+ __decorate([
6582
+ DELETE(),
6583
+ __metadata("design:type", Function),
6584
+ __metadata("design:paramtypes", []),
6585
+ __metadata("design:returntype", Object)
6586
+ ], TaonBaseCrudController.prototype, "clearTable", null);
6587
+ __decorate([
6588
+ POST(),
6589
+ __param(0, Body()),
6590
+ __metadata("design:type", Function),
6591
+ __metadata("design:paramtypes", [Object]),
6592
+ __metadata("design:returntype", Object)
6593
+ ], TaonBaseCrudController.prototype, "save", null);
6594
+ __decorate([
6595
+ POST(),
6596
+ __param(0, Body()),
6597
+ __metadata("design:type", Function),
6598
+ __metadata("design:paramtypes", [Object]),
6599
+ __metadata("design:returntype", Object)
6600
+ ], TaonBaseCrudController.prototype, "bulkCreate", null);
6601
+ TaonBaseCrudController = __decorate([
6602
+ TaonController({ className: 'TaonBaseCrudController' })
6603
+ ], TaonBaseCrudController);
6604
+
6605
+ /**
6606
+ * Repository decorator
6607
+ */
6608
+ function TaonRepository(options) {
6609
+ return function (constructor) {
6610
+ Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
6611
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
6612
+ ClassHelpers.setName(constructor, options?.className);
6613
+ };
6614
+ }
6615
+ class TaonRepositoryOptions extends DecoratorAbstractOpt {
6616
+ }
6617
+
6618
+ //#endregion
6619
+ let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
6620
+ };
6621
+ TaonBaseCustomRepository = __decorate([
6622
+ TaonRepository({ className: 'TaonBaseCustomRepository' })
6623
+ ], TaonBaseCustomRepository);
6624
+
6625
+ //#endregion
6626
+ const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
6627
+ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
6628
+ constructor(
6629
+ // Injected through TaonBaseCrudController
6630
+ __entityClassResolveFn) {
6631
+ super();
6632
+ this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
6633
+ this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
6634
+ // @ts-ignore
6635
+ this.entityClassResolveFn = __entityClassResolveFn;
6636
+ }
6637
+ get dbQuery() {
6638
+ //#region @websqlFunc
6639
+ if (!this.__dbQuery) {
6640
+ if (!this.ctx) {
6641
+ return; // TODO
6642
+ throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers.getName(this)}`);
6643
+ }
6644
+ const connection = this.ctx?.connection;
6645
+ if (!connection) {
6646
+ throw new Error(`[TaonBaseRepository] Database not inited for context ${this.ctx?.contextName}`);
6647
+ }
6648
+ this.__dbQuery = new MySqlQuerySource(connection);
6649
+ }
6650
+ return this.__dbQuery;
6651
+ //#endregion
6290
6652
  }
6291
6653
  //#endregion
6292
- //#region crud operations / typeorm / restore
6654
+ //#region connection
6655
+ get connection() {
6656
+ //#region @websqlFunc
6657
+ return this.ctx?.connection;
6658
+ //#endregion
6659
+ }
6660
+ //#endregion
6661
+ //#region repository
6662
+ get repository() {
6663
+ //#region @websqlFunc
6664
+ if (this[this.REPOS_CACHE_KEY]) {
6665
+ return this[this.REPOS_CACHE_KEY];
6666
+ }
6667
+ const resolvedRepoClass = this.entityClassResolveFn();
6668
+ const resolvedRepoName = ClassHelpers.getName(resolvedRepoClass);
6669
+ const repo = this.ctx.repos.get(resolvedRepoName);
6670
+ // TODO better recognize what is class in context
6671
+ if (!repo) {
6672
+ throw `[TaonBaseRepository] Repository for entity "${resolvedRepoName}"
6673
+ not found in context "${this.ctx?.contextName}".
6674
+
6675
+ Is ${resolvedRepoName} a Taon entity class ?
6676
+
6677
+ OR
6678
+
6679
+ If ${resolvedRepoName} is a Taon Custom Repository, then use this:
6680
+
6681
+ ...
6682
+ ${_.lowerFirst(resolvedRepoName)} = injectCustomRepository(${resolvedRepoName});
6683
+ ...
6684
+
6685
+ `;
6686
+ }
6687
+ this[this.REPOS_CACHE_KEY] = repo;
6688
+ return this[this.REPOS_CACHE_KEY];
6689
+ //#endregion
6690
+ }
6293
6691
  /**
6294
- * Restores entities by a given criteria.
6295
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6296
- * Executes fast and efficient SOFT-DELETE query.
6297
- * Does not check if entity exist in the database.
6692
+ * target for repository
6298
6693
  */
6299
- restore(criteria) {
6300
- return this.repo.restore(criteria);
6694
+ get target() {
6695
+ //#region @websqlFunc
6696
+ return this?.repository?.target;
6697
+ //#endregion
6301
6698
  }
6302
- //#endregion
6303
- //#region crud operations / typeorm / count
6304
6699
  /**
6305
- * Counts entities that match given options.
6306
- * Useful for pagination.
6700
+ * alias to repository
6307
6701
  */
6308
- count(options) {
6309
- return this.repo.count(options);
6702
+ get repo() {
6703
+ //#region @websqlFunc
6704
+ return this.repository;
6705
+ //#endregion
6706
+ }
6707
+ get repositoryExists() {
6708
+ //#region @websqlFunc
6709
+ return !!this.repository;
6710
+ //#endregion
6310
6711
  }
6311
6712
  //#endregion
6312
- //#region crud operations / typeorm / count by
6713
+ //#region crud operations / typeorm / has id
6313
6714
  /**
6314
- * Counts entities that match given conditions.
6315
- * Useful for pagination.
6715
+ * Checks if entity has an id.
6716
+ * If entity composite compose ids, it will check them all.
6316
6717
  */
6317
- countBy(where) {
6318
- return this.repo.countBy(where);
6718
+ hasId(entity) {
6719
+ return this.repo.hasId(entity);
6319
6720
  }
6320
6721
  //#endregion
6321
- //#region crud operations / typeorm / find
6722
+ //#region crud operations / typeorm / get id
6322
6723
  /**
6323
- * Finds entities that match given find options.
6724
+ * Gets entity mixed id.
6324
6725
  */
6325
- find(options) {
6326
- return this.repo.find(options);
6726
+ getId(entity) {
6727
+ return this.repo.getId(entity);
6327
6728
  }
6328
6729
  //#endregion
6329
- //#region crud operations / typeorm / find by
6730
+ //#region crud operations / typeorm / create & bulk create
6330
6731
  /**
6331
- * Finds entities that match given find options.
6732
+ Saves a given entity in the database.
6733
+ * If entity does not exist in the database then inserts, otherwise updates.
6332
6734
  */
6333
- findBy(where) {
6334
- return this.repo.findBy(where);
6735
+ async save(item, options) {
6736
+ //#region @websqlFunc
6737
+ // if (!this.repo) {
6738
+ // debugger;
6739
+ // }
6740
+ let model = await this.repo.create(item);
6741
+ model = await this.repo.save(model, options);
6742
+ const { id } = model;
6743
+ model = await this.repo.findOne({
6744
+ where: { id },
6745
+ });
6746
+ return model;
6747
+ //#endregion
6335
6748
  }
6336
- //#endregion
6337
- //#region crud operations / typeorm / find and count
6338
- // async findAndCount(options: { take: number; skip: number }) {
6339
- // const { take, skip } = options;
6340
- // const [result, total] = await this.repo.findAndCount({
6341
- // // where: { name: Like('%' + keyword + '%') },
6342
- // // order: { name: "DESC" },
6343
- // take: take,
6344
- // skip: skip,
6345
- // });
6346
- // return { result, total };
6347
- // }
6348
- //
6349
6749
  /**
6350
- * Finds entities that match given find options.
6351
- * Also counts all entities that match given conditions,
6352
- * but ignores pagination settings (from and take options).
6750
+ * Creates a new entity instance or instances.
6751
+ * Can copy properties from the given object into new entities.
6353
6752
  */
6354
- findAndCount(options) {
6355
- return this.repo.findAndCount(options);
6753
+ create(plainEntityLikeOrPlainEntityLikes) {
6754
+ return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6356
6755
  }
6357
- //#endregion
6358
- //#region crud operations / typeorm / find and count by
6359
- /**
6360
- * Finds entities that match given WHERE conditions.
6361
- * Also counts all entities that match given conditions,
6362
- * but ignores pagination settings (from and take options).
6363
- */
6364
- findAndCountBy(where) {
6365
- return this.repo.findAndCountBy(where);
6756
+ async bulkSave(items, options) {
6757
+ //#region @websqlFunc
6758
+ const models = [];
6759
+ for (let index = 0; index < items.length; index++) {
6760
+ const item = items[index];
6761
+ // TODO FIX THIS / REFACTOR
6762
+ const model = await this.save(item, options);
6763
+ models.push(model);
6764
+ }
6765
+ return models;
6766
+ //#endregion
6366
6767
  }
6367
- //#endregion
6368
- //#region crud operations / typeorm / find by ids
6369
6768
  /**
6370
- * Finds entities with ids.
6371
- * Optionally find options or conditions can be applied.
6372
- *
6373
- * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
6374
- *
6375
- * .findBy({
6376
- * id: In([1, 2, 3])
6377
- * })
6769
+ * @deprecated use bulkSave instead
6378
6770
  */
6379
- findByIds(ids) {
6380
- return this.repo.findByIds(ids);
6771
+ async bulkCreate(items, options) {
6772
+ return this.bulkSave(items, options);
6381
6773
  }
6382
- //#endregion
6383
- //#region crud operations / typeorm / find one
6774
+ //#region old typeorm version
6384
6775
  /**
6385
- * Finds first entity by a given find options.
6386
- * If entity was not found in the database - returns null.
6776
+ * Saves all given entities in the database.
6777
+ * If entities do not exist in the database then inserts, otherwise updates.
6387
6778
  */
6388
- findOne(options) {
6389
- return this.repo.findOne(options);
6390
- }
6779
+ // save<T extends DeepPartial<Entity>>(
6780
+ // entities: T[],
6781
+ // options: SaveOptions & {
6782
+ // reload: false;
6783
+ // },
6784
+ // ): Promise<T[]>;
6785
+ // /**
6786
+ // * Saves all given entities in the database.
6787
+ // * If entities do not exist in the database then inserts, otherwise updates.
6788
+ // */
6789
+ // save<T extends DeepPartial<Entity>>(
6790
+ // entities: T[],
6791
+ // options?: SaveOptions,
6792
+ // ): Promise<(T & Entity)[]>;
6793
+ // /**
6794
+ // * Saves a given entity in the database.
6795
+ // * If entity does not exist in the database then inserts, otherwise updates.
6796
+ // */
6797
+ // save<T extends DeepPartial<Entity>>(
6798
+ // entity: T,
6799
+ // options: SaveOptions & {
6800
+ // reload: false;
6801
+ // },
6802
+ // ): Promise<T>;
6803
+ // /**
6804
+ // * Saves a given entity in the database.
6805
+ // * If entity does not exist in the database then inserts, otherwise updates.
6806
+ // */
6807
+ // save<T extends DeepPartial<Entity>>(
6808
+ // entity: T,
6809
+ // options?: SaveOptions,
6810
+ // ): Promise<T & Entity> {
6811
+ // return this.repo.save(entity, options);
6812
+ // }
6391
6813
  //#endregion
6392
- //#region crud operations / typeorm / find one by
6814
+ //#endregion
6815
+ //#region crud operations / typeorm / merge
6393
6816
  /**
6394
- * Finds first entity that matches given where condition.
6395
- * If entity was not found in the database - returns null.
6817
+ * Merges multiple entities (or entity-like objects) into a given entity.
6396
6818
  */
6397
- findOneBy(where) {
6398
- return this.repo.findOneBy(where);
6819
+ merge(mergeIntoEntity, ...entityLikes) {
6820
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
6399
6821
  }
6400
6822
  //#endregion
6401
- //#region crud operations / typeorm / find one or fail
6823
+ //#region crud operations / typeorm / preload
6402
6824
  /**
6403
- * Finds first entity that matches given id.
6404
- * If entity was not found in the database - returns null.
6405
- *
6406
- * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
6825
+ * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
6826
+ * it loads it (and everything related to it), replaces all values with the new ones from the given object
6827
+ * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
6828
+ * replaced from the new object.
6407
6829
  *
6408
- * .findOneBy({
6409
- * id: 1 // where "id" is your primary column name
6410
- * })
6830
+ * Note that given entity-like object must have an entity id / primary key to find entity by.
6831
+ * Returns undefined if entity with given id was not found.
6411
6832
  */
6412
- findOneById(id) {
6413
- return this.repo.findOneById(id);
6833
+ preload(entityLike) {
6834
+ return this.repo.preload(entityLike);
6414
6835
  }
6415
6836
  //#endregion
6416
- //#region crud operations / typeorm / find one or fail
6837
+ //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6417
6838
  /**
6418
- * Finds first entity by a given find options.
6419
- * If entity was not found in the database - rejects with error.
6839
+ * Removes a given entities from the database.
6420
6840
  */
6421
- findOneOrFail(options) {
6422
- return this.repo.findOneOrFail(options);
6841
+ async remove(idOrEntity) {
6842
+ //#region @websqlFunc
6843
+ if (_.isObject(idOrEntity)) {
6844
+ idOrEntity = idOrEntity.id;
6845
+ }
6846
+ const deletedEntity = await this.repo.findOne({
6847
+ where: { id: idOrEntity },
6848
+ });
6849
+ if (!deletedEntity) {
6850
+ Helpers.warn(`[TaonBaseRepository] Entity "${ClassHelpers.getName(this.repo.target)}" ` + `with id ${idOrEntity} not found, cannot remove`);
6851
+ return;
6852
+ }
6853
+ const idCopy = deletedEntity.id;
6854
+ await this.repo.remove(deletedEntity);
6855
+ deletedEntity.id = idCopy;
6856
+ return deletedEntity;
6857
+ //#endregion
6423
6858
  }
6424
- //#endregion
6425
- //#region crud operations / typeorm / find one by or fail
6426
6859
  /**
6427
- * Finds first entity that matches given where condition.
6428
- * If entity was not found in the database - rejects with error.
6860
+ * alias to remove
6429
6861
  */
6430
- findOneByOrFail(where) {
6431
- return this.repo.findOneByOrFail(where);
6862
+ async delete(idOrEntity) {
6863
+ return this.remove(idOrEntity);
6432
6864
  }
6433
- //#endregion
6434
- //#region crud operations / typeorm / query
6435
6865
  /**
6436
- * Executes a raw SQL query and returns a raw database results.
6437
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
6866
+ * alias to removeById
6438
6867
  */
6439
- query(query, parameters) {
6440
- return this.repo.query(query, parameters);
6868
+ async deleteById(id) {
6869
+ return this.remove(id);
6441
6870
  }
6442
- //#endregion
6443
- //#region crud operations / typeorm / query
6444
- /**
6445
- * Executes a raw SQL query and returns a raw database results.
6446
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
6447
- */
6448
- createQueryBuilder(alias, queryRunner) {
6449
- return this.repo.createQueryBuilder(alias, queryRunner);
6871
+ async bulkRemove(idsOrEntities) {
6872
+ //#region @websqlFunc
6873
+ idsOrEntities = idsOrEntities.map(id => {
6874
+ return _.isObject(id) ? id.id : id;
6875
+ });
6876
+ const models = [];
6877
+ for (let index = 0; index < idsOrEntities.length; index++) {
6878
+ const id = idsOrEntities[index];
6879
+ const model = await this.remove(id);
6880
+ models.push(model);
6881
+ }
6882
+ return models;
6883
+ //#endregion
6884
+ }
6885
+ async bulkDelete(ids) {
6886
+ return this.bulkRemove(ids);
6450
6887
  }
6451
- //#endregion
6452
- //#region crud operations / typeorm / clear
6453
6888
  /**
6454
- * Clears all the data from the given table/collection (truncates/drops it).
6455
- *
6456
- * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
6457
- * @see https://stackoverflow.com/a/5972738/925151
6889
+ * Records the delete date of a given entity.
6458
6890
  */
6459
- clear() {
6460
- return this.repo.clear();
6891
+ softRemove(entity, options) {
6892
+ return this.repo.softRemove(entity, options);
6461
6893
  }
6462
- //#endregion
6463
- //#region crud operations / typeorm / increment
6464
6894
  /**
6465
- * Increments some column by provided value of the entities matched given conditions.
6895
+ * Recovers a given entity in the database.
6466
6896
  */
6467
- increment(conditions, propertyPath, value) {
6468
- return this.repo.increment(conditions, propertyPath, value);
6897
+ recover(entity, options) {
6898
+ return this.repo.recover(entity, options);
6469
6899
  }
6470
6900
  //#endregion
6471
- //#region crud operations / typeorm / decrement
6901
+ //#region crud operations / typeorm / insert
6472
6902
  /**
6473
- * Decrements some column by provided value of the entities matched given conditions.
6903
+ * Inserts a given entity into the database.
6904
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6905
+ * Executes fast and efficient INSERT query.
6906
+ * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
6474
6907
  */
6475
- decrement(conditions, propertyPath, value) {
6476
- return this.repo.decrement(conditions, propertyPath, value);
6908
+ insert(entity) {
6909
+ // debugger;
6910
+ return this.repo.insert(entity);
6477
6911
  }
6478
6912
  //#endregion
6479
- //#region crud operations / get all
6480
- /**
6481
- * @deprecated use findAndCount instead
6482
- */
6483
- async getAll() {
6913
+ //#region crud operations / typeorm / update & build update
6914
+ async update(item) {
6484
6915
  //#region @websqlFunc
6485
- // console.log('repo', this.__repository);
6486
- // console.log(
6487
- // `repo taget name "${ClassHelpers.getName(this.__repository.target)}"`,
6488
- // );
6489
- // debugger;
6490
- const totalCount = await this.repo.count();
6491
- const models = await this.repo.find();
6492
- // console.log('models', models);
6493
- // console.log('totalCount', totalCount);
6494
- return { models, totalCount };
6916
+ const { id } = item;
6917
+ return await this.updateById(id, item);
6495
6918
  //#endregion
6496
6919
  }
6497
- //#endregion
6498
- //#region crud operations / get by id
6499
- async getBy(id) {
6920
+ async updateById(id, item) {
6500
6921
  //#region @websqlFunc
6501
- const model = await await this.repo.findOne({
6922
+ const allowedPropsToUpdate = [];
6923
+ for (const key in item) {
6924
+ const metadataColumn = this.repo.metadata.ownColumns.find(c => c.propertyName === key);
6925
+ if (_.isObject(item) &&
6926
+ item.hasOwnProperty(key) &&
6927
+ (typeof item[key] !== 'object' ||
6928
+ this.allowedTypesToUpdate.includes(metadataColumn?.type)) &&
6929
+ !_.isUndefined(metadataColumn)) {
6930
+ allowedPropsToUpdate.push(key);
6931
+ }
6932
+ }
6933
+ for (let i = 0; i < allowedPropsToUpdate.length; i++) {
6934
+ const key = allowedPropsToUpdate[i];
6935
+ if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
6936
+ // const raw = _.isBoolean(item[key]) || _.isNumber(item[key]) || _.isNull(item[key]); // TODO does this make any sense ?
6937
+ const toSet = item[key];
6938
+ // const tableName = tableNameFrom(this.entity as any);
6939
+ await this.repo.update({
6940
+ id,
6941
+ }, {
6942
+ [key]: toSet,
6943
+ });
6944
+ // await this.repo.query(
6945
+ // `UPDATE '${tableName}' as ${table}
6946
+ // SET ${key}=${toSet}
6947
+ // WHERE ${table}.id='${id}'
6948
+ // `);
6949
+ }
6950
+ }
6951
+ let model = await this.repo.findOne({
6502
6952
  where: { id },
6503
6953
  });
6504
6954
  return model;
6505
6955
  //#endregion
6506
6956
  }
6507
- };
6508
- TaonBaseRepository = __decorate([
6509
- TaonRepository({ className: 'TaonBaseRepository' }),
6510
- __metadata("design:paramtypes", [Function])
6511
- ], TaonBaseRepository);
6512
-
6513
- const TaonBaseContext = createContext(() => ({
6514
- contextName: 'TaonBaseContext',
6515
- abstract: true,
6516
- middlewares: {
6517
- TaonBaseFileUploadMiddleware,
6518
- },
6519
- repositories: {
6520
- // @ts-ignore
6521
- TaonBaseRepository,
6522
- },
6523
- }));
6524
-
6525
- var baseContext = /*#__PURE__*/Object.freeze({
6526
- __proto__: null,
6527
- TaonBaseContext: TaonBaseContext
6528
- });
6529
-
6530
- /**
6531
- * Controller decorator
6532
- */
6533
- function TaonController(options) {
6534
- return function (constructor) {
6535
- ClassHelpers.setName(constructor, options?.className);
6536
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
6537
- const cfg = ClassHelpers.ensureClassConfig(constructor);
6538
- options = options || {};
6539
- cfg.className = options.className || constructor.name;
6540
- cfg.path = options.path || '';
6541
- cfg.realtime = options.realtime;
6542
- cfg.middlewares = options.middlewares;
6543
- };
6544
- }
6545
-
6546
- const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
6547
- const methodConfig = ClassHelpers.ensureMethodConfig(target, propertyKey);
6548
- let options;
6549
- if (typeof pathOrOptions === 'object') {
6550
- options = pathOrOptions;
6551
- pathOrOptions = options.path;
6552
- pathIsGlobal = !!options.pathIsGlobal;
6553
- path = options.path;
6554
- }
6555
- else {
6556
- options = { pathOrOptions, pathIsGlobal };
6557
- }
6558
- const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
6559
- methodConfig.methodName = propertyKey;
6560
- methodConfig.middlewares = middlewares;
6561
- methodConfig.type = method;
6562
- if (!path) {
6563
- let paramsPathConcatedPath = '';
6564
- for (const key in methodConfig.parameters) {
6565
- if (methodConfig.parameters.hasOwnProperty(key)) {
6566
- const element = methodConfig.parameters[key];
6567
- if (element.paramType === 'Path' &&
6568
- _.isString(element.paramName) &&
6569
- element.paramName.trim().length > 0) {
6570
- paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
6571
- }
6572
- }
6573
- }
6574
- methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
6575
- }
6576
- else {
6577
- methodConfig.path = path;
6578
- }
6579
- methodConfig.descriptor = descriptor;
6580
- methodConfig.global = pathIsGlobal;
6581
- methodConfig.contentType = overrideContentType;
6582
- methodConfig.responseType = overrideResponseType;
6583
- methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
6584
- };
6585
- function GET(pathOrOptions, pathIsGlobal = false) {
6586
- return function (target, propertyKey, descriptor) {
6587
- metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6588
- };
6589
- }
6590
- /**
6591
- * Method for sending html website from text
6592
- * Example
6593
- *
6594
- * ```ts
6595
- * ...
6596
- * // in your taon controller
6597
- * ..Taon.Http.HTML()
6598
- * sendHtmlDummyWebsite(): Taon.ResponseHtml {
6599
- * return `
6600
- <html>
6601
- <head>
6602
- <title>Dummy website</title>
6603
- </head>
6604
- <body>
6605
- <h1>This is dummy website</h1>
6606
- <p>Served as HTML string from Taon controller method</p>
6607
- </body>
6608
- </html>
6609
- * `; *
6610
- * }
6611
- * ...
6612
- * ```
6613
- */
6614
- function HTML(pathOrOptions) {
6615
- return function (target, propertyKey, descriptor) {
6616
- const opt = pathOrOptions;
6617
- opt.overrideExpressSendAsHtml = true;
6618
- metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
6619
- };
6620
- }
6621
- function HEAD(pathOrOptions, pathIsGlobal = false) {
6622
- return function (target, propertyKey, descriptor) {
6623
- metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6624
- };
6625
- }
6626
- function POST(pathOrOptions, pathIsGlobal = false) {
6627
- return function (target, propertyKey, descriptor) {
6628
- metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6629
- };
6630
- }
6631
- function PUT(pathOrOptions, pathIsGlobal = false) {
6632
- return function (target, propertyKey, descriptor) {
6633
- metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6634
- };
6635
- }
6636
- function PATCH(pathOrOptions, pathIsGlobal = false) {
6637
- return function (target, propertyKey, descriptor) {
6638
- metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6639
- };
6640
- }
6641
- function DELETE(pathOrOptions, pathIsGlobal = false) {
6642
- return function (target, propertyKey, descriptor) {
6643
- metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6644
- };
6645
- }
6646
-
6647
- function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
6648
- const methodCfg = ClassHelpers.ensureMethodConfig(target, propertyKey);
6649
- const nameKey = name ? name : param;
6650
- // const key = name || `${param}_${parameterIndex}`;
6651
- methodCfg.parameters[nameKey] = {
6652
- index: parameterIndex,
6653
- paramName: name,
6654
- paramType: param,
6655
- defaultType: defaultValue,
6656
- expireInSeconds: expire,
6657
- };
6658
- // console.log('params updated', methodConfig);
6659
- }
6660
- /**
6661
- * @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
6662
- */
6663
- function Path(name) {
6664
- return function (target, propertyKey, parameterIndex) {
6665
- metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
6666
- };
6667
- }
6668
- function Query(name) {
6669
- return function (target, propertyKey, parameterIndex) {
6670
- metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
6671
- };
6672
- }
6673
- function Cookie(name, expireInSecond = 3600) {
6674
- return function (target, propertyKey, parameterIndex) {
6675
- metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
6676
- };
6677
- }
6678
- function Header(name) {
6679
- return function (target, propertyKey, parameterIndex) {
6680
- metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
6681
- };
6682
- }
6683
- function Body(name) {
6684
- return function (target, propertyKey, parameterIndex) {
6685
- metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
6686
- };
6687
- }
6688
-
6689
- let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
6957
+ async bulkUpdate(items) {
6958
+ //#region @websqlFunc
6959
+ const models = [];
6960
+ for (let index = 0; index < items.length; index++) {
6961
+ const item = items[index];
6962
+ const { id } = item; // TOOD
6963
+ const model = await this.updateById(id, item);
6964
+ models.push(model);
6965
+ }
6966
+ return { models };
6967
+ //#endregion
6968
+ }
6969
+ //#region tpeorm update version
6970
+ // this version suck and will not return update entity
6971
+ // /**
6972
+ // * Updates entity partially. Entity can be found by a given conditions.
6973
+ // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6974
+ // * Executes fast and efficient UPDATE query.
6975
+ // * Does not check if entity exist in the database.
6976
+ // */
6977
+ // update(
6978
+ // criteria:
6979
+ // | string
6980
+ // | string[]
6981
+ // | number
6982
+ // | number[]
6983
+ // | Date
6984
+ // | Date[]
6985
+ // | ObjectID
6986
+ // | ObjectID[]
6987
+ // | FindOptionsWhere<Entity>,
6988
+ // partialEntity: QueryDeepPartialEntity<Entity>,
6989
+ // ): Promise<UpdateResult> {
6990
+ // return this.repo.update(criteria, partialEntity);
6991
+ // }
6992
+ //#endregion
6993
+ //#endregion
6994
+ //#region crud operations / typeorm / upsert
6690
6995
  /**
6691
- * Hook that is called when taon app is inited
6692
- * (all contexts are created and inited)
6996
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
6997
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6998
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
6693
6999
  */
6694
- async afterAllCtxInited(options) { }
6695
- //#region upload form data to server
6696
- uploadFormDataToServer(formData, queryParams) {
6697
- /* */
6698
- /* */
6699
- /* */
6700
- /* */
6701
- /* */
6702
- /* */
6703
- /* */
6704
- /* */
6705
- /* */
6706
- /* */
6707
- /* */
6708
- /* */
6709
- /* */
6710
- /* */
6711
- /* */
6712
- /* */
6713
- /* */
6714
- /* */
6715
- /* */
6716
- /* */
6717
- /* */
6718
- /* */
6719
- /* */
6720
- /* */
6721
- /* */
6722
- /* */
6723
- return (void 0);
7000
+ upsert(entityOrEntities, conflictPathsOrOptions) {
7001
+ return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
6724
7002
  }
6725
7003
  //#endregion
6726
- //#region after file upload hook
7004
+ //#region crud operations / typeorm / soft delete
6727
7005
  /**
6728
- * Hook after file is uploaded
6729
- * through `uploadFormDataToServer` or `uploadLocalFileToServer`
7006
+ * Records the delete date of entities by a given criteria.
7007
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7008
+ * Executes fast and efficient SOFT-DELETE query.
7009
+ * Does not check if entity exist in the database.
6730
7010
  */
6731
- afterFileUploadAction(file, queryParams) {
6732
- // empty
7011
+ softDelete(criteria) {
7012
+ return this.repo.softDelete(criteria);
6733
7013
  }
6734
- //#region upload local file to server
6735
- async uploadLocalFileToServer(absFilePath, options, queryParams) {
6736
- /* */
6737
- /* */
6738
- /* */
6739
- /* */
6740
- /* */
6741
- /* */
6742
- /* */
6743
- /* */
6744
- /* */
6745
- /* */
6746
- /* */
6747
- /* */
6748
- /* */
6749
- /* */
6750
- return (void 0);
7014
+ //#endregion
7015
+ //#region crud operations / typeorm / restore
7016
+ /**
7017
+ * Restores entities by a given criteria.
7018
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
7019
+ * Executes fast and efficient SOFT-DELETE query.
7020
+ * Does not check if entity exist in the database.
7021
+ */
7022
+ restore(criteria) {
7023
+ return this.repo.restore(criteria);
6751
7024
  }
6752
7025
  //#endregion
6753
- // async check() {
6754
- // await this._waitForProperStatusChange({
6755
- // request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6756
- // statusCheck: resp => resp.body.json[0].ok,
6757
- // });
7026
+ //#region crud operations / typeorm / count
7027
+ /**
7028
+ * Counts entities that match given options.
7029
+ * Useful for pagination.
7030
+ */
7031
+ count(options) {
7032
+ return this.repo.count(options);
7033
+ }
7034
+ //#endregion
7035
+ //#region crud operations / typeorm / count by
7036
+ /**
7037
+ * Counts entities that match given conditions.
7038
+ * Useful for pagination.
7039
+ */
7040
+ countBy(where) {
7041
+ return this.repo.countBy(where);
7042
+ }
7043
+ //#endregion
7044
+ //#region crud operations / typeorm / find
7045
+ /**
7046
+ * Finds entities that match given find options.
7047
+ */
7048
+ find(options) {
7049
+ return this.repo.find(options);
7050
+ }
7051
+ //#endregion
7052
+ //#region crud operations / typeorm / find by
7053
+ /**
7054
+ * Finds entities that match given find options.
7055
+ */
7056
+ findBy(where) {
7057
+ return this.repo.findBy(where);
7058
+ }
7059
+ //#endregion
7060
+ //#region crud operations / typeorm / find and count
7061
+ // async findAndCount(options: { take: number; skip: number }) {
7062
+ // const { take, skip } = options;
7063
+ // const [result, total] = await this.repo.findAndCount({
7064
+ // // where: { name: Like('%' + keyword + '%') },
7065
+ // // order: { name: "DESC" },
7066
+ // take: take,
7067
+ // skip: skip,
7068
+ // });
7069
+ // return { result, total };
6758
7070
  // }
7071
+ //
6759
7072
  /**
6760
- * Easy way to wait for status change with http (1s default) pooling.
7073
+ * Finds entities that match given find options.
7074
+ * Also counts all entities that match given conditions,
7075
+ * but ignores pagination settings (from and take options).
7076
+ */
7077
+ findAndCount(options) {
7078
+ return this.repo.findAndCount(options);
7079
+ }
7080
+ //#endregion
7081
+ //#region crud operations / typeorm / find and count by
7082
+ /**
7083
+ * Finds entities that match given WHERE conditions.
7084
+ * Also counts all entities that match given conditions,
7085
+ * but ignores pagination settings (from and take options).
7086
+ */
7087
+ findAndCountBy(where) {
7088
+ return this.repo.findAndCountBy(where);
7089
+ }
7090
+ //#endregion
7091
+ //#region crud operations / typeorm / find by ids
7092
+ /**
7093
+ * Finds entities with ids.
7094
+ * Optionally find options or conditions can be applied.
6761
7095
  *
6762
- * example (in sub class):
6763
- * ```ts
6764
- async check() {
6765
- await this.waitForProperStatusChange({
6766
- request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6767
- statusCheck: resp => resp.body.json[0].ok,
6768
- });
6769
- }
6770
- * ```
7096
+ * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
7097
+ *
7098
+ * .findBy({
7099
+ * id: In([1, 2, 3])
7100
+ * })
6771
7101
  */
6772
- async _waitForProperStatusChange(options) {
6773
- const poolingInterval = options.poolingInterval || 1000;
6774
- const taonRequest = options.request;
6775
- let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
6776
- let i = 0;
6777
- let httpErrorsCount = 0;
6778
- while (true) {
6779
- await UtilsTerminal.waitMilliseconds(poolingInterval);
6780
- try {
6781
- const resp = await taonRequest({
6782
- reqIndexNum: i,
6783
- httpErrorsCount,
6784
- });
6785
- if (options.statusCheck && options.statusCheck(resp)) {
6786
- return;
6787
- }
6788
- }
6789
- catch (error) {
6790
- httpErrorsCount++;
6791
- if (options.loopRequestsOnBackendError) {
6792
- const isProperTaonError = error instanceof HttpResponseError &&
6793
- error.body.json[CoreModels.TaonHttpErrorCustomProp];
6794
- const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
6795
- const isUnknownError = !(error instanceof HttpResponseError);
6796
- const resBool = await options.loopRequestsOnBackendError({
6797
- taonError: isProperTaonError ? error : void 0,
6798
- unknownHttpError: isHttpError ? error : void 0,
6799
- unknownError: isUnknownError ? error : void 0,
6800
- reqIndexNum: i,
6801
- httpErrorsCount,
6802
- });
6803
- if (resBool) {
6804
- i++;
6805
- continue;
6806
- }
6807
- else {
6808
- return;
6809
- }
6810
- }
6811
- if (httpErrorsCount >
6812
- (options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
6813
- throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
6814
- }
6815
- }
6816
- if (i++ > maxTries) {
6817
- throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
6818
- }
6819
- }
7102
+ findByIds(ids) {
7103
+ return this.repo.findByIds(ids);
7104
+ }
7105
+ //#endregion
7106
+ //#region crud operations / typeorm / find one
7107
+ /**
7108
+ * Finds first entity by a given find options.
7109
+ * If entity was not found in the database - returns null.
7110
+ */
7111
+ findOne(options) {
7112
+ return this.repo.findOne(options);
7113
+ }
7114
+ //#endregion
7115
+ //#region crud operations / typeorm / find one by
7116
+ /**
7117
+ * Finds first entity that matches given where condition.
7118
+ * If entity was not found in the database - returns null.
7119
+ */
7120
+ findOneBy(where) {
7121
+ return this.repo.findOneBy(where);
6820
7122
  }
6821
- };
6822
- __decorate([
6823
- POST({
6824
- overrideContentType: 'multipart/form-data',
6825
- middlewares: ({ parentMiddlewares }) => ({
6826
- ...parentMiddlewares,
6827
- TaonBaseFileUploadMiddleware,
6828
- }),
6829
- }),
6830
- __param(0, Body()),
6831
- __param(1, Query()),
6832
- __metadata("design:type", Function),
6833
- __metadata("design:paramtypes", [FormData, Object]),
6834
- __metadata("design:returntype", Object)
6835
- ], TaonBaseController.prototype, "uploadFormDataToServer", null);
6836
- TaonBaseController = __decorate([
6837
- TaonController({
6838
- className: 'TaonBaseController',
6839
- })
6840
- ], TaonBaseController);
6841
-
6842
- //#endregion
6843
- /**
6844
- * Please override property entityClassFn with entity class.
6845
- */
6846
- let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
6847
7123
  //#endregion
6848
- //#region init
6849
- async _() {
6850
- if (!_.isFunction(this.entityClassResolveFn)) {
6851
- Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
6852
- return;
6853
- }
6854
- let entityClassFn = this.entityClassResolveFn();
6855
- this.db = this.injectRepo(entityClassFn);
6856
- if (entityClassFn) {
6857
- const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
6858
- if (configEntity?.createTable === false) {
6859
- Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
6860
- }
6861
- }
6862
- else {
6863
- Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
6864
-
6865
- Please provide entity as class property entityClassFn:
6866
-
6867
- class ${ClassHelpers.getName(this)} extends TaonBaseCrudController<Entity> {
6868
- // ...
6869
- entityClassResolveFn = ()=> MyEntityClass;
6870
- // ...
6871
- }
6872
-
6873
- `);
6874
- }
6875
- await super._();
7124
+ //#region crud operations / typeorm / find one or fail
7125
+ /**
7126
+ * Finds first entity that matches given id.
7127
+ * If entity was not found in the database - returns null.
7128
+ *
7129
+ * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
7130
+ *
7131
+ * .findOneBy({
7132
+ * id: 1 // where "id" is your primary column name
7133
+ * })
7134
+ */
7135
+ findOneById(id) {
7136
+ return this.repo.findOneById(id);
6876
7137
  }
6877
7138
  //#endregion
6878
- //#region bufferd changes
6879
- bufforedChanges(id, property, alreadyLength) {
6880
- //#region @websqlFunc
6881
- return async (request, response) => {
6882
- const model = await this.db.getBy(id);
6883
- if (model === void 0) {
6884
- return;
6885
- }
6886
- Validators.preventUndefinedModel(model, id);
6887
- let value = model[property];
6888
- let result;
6889
- if (_.isString(value) || _.isArray(value)) {
6890
- result = value.slice(alreadyLength);
6891
- }
6892
- return result;
6893
- };
6894
- //#endregion
7139
+ //#region crud operations / typeorm / find one or fail
7140
+ /**
7141
+ * Finds first entity by a given find options.
7142
+ * If entity was not found in the database - rejects with error.
7143
+ */
7144
+ findOneOrFail(options) {
7145
+ return this.repo.findOneOrFail(options);
6895
7146
  }
6896
7147
  //#endregion
6897
- //#region pagintation
6898
- pagination(pageNumber = 1, pageSize = 10, search = '') {
6899
- //#region @websqlFunc
6900
- return async (request, response) => {
6901
- if (this.db.repositoryExists) {
6902
- const query = {
6903
- page: pageNumber,
6904
- take: pageSize,
6905
- keyword: search,
6906
- };
6907
- // console.log({
6908
- // query
6909
- // })
6910
- const take = query.take || 10;
6911
- const page = query.page || 1;
6912
- const skip = (page - 1) * take;
6913
- const keyword = query.keyword || '';
6914
- const [result, total] = await this.db.findAndCount({
6915
- // where: { name: Like('%' + keyword + '%') },
6916
- // order: { name: "DESC" },
6917
- take: take,
6918
- skip: skip,
6919
- });
6920
- response?.setHeader(Symbols.old.X_TOTAL_COUNT, total);
6921
- // const lastPage = Math.ceil(total / take);
6922
- // const nextPage = page + 1 > lastPage ? null : page + 1;
6923
- // const prevPage = page - 1 < 1 ? null : page - 1;
6924
- // console.log({
6925
- // result,
6926
- // total
6927
- // })
6928
- return result;
6929
- }
6930
- return [];
6931
- };
6932
- //#endregion
7148
+ //#region crud operations / typeorm / find one by or fail
7149
+ /**
7150
+ * Finds first entity that matches given where condition.
7151
+ * If entity was not found in the database - rejects with error.
7152
+ */
7153
+ findOneByOrFail(where) {
7154
+ return this.repo.findOneByOrFail(where);
6933
7155
  }
6934
7156
  //#endregion
6935
- //#region get all
6936
- getAll() {
6937
- //#region @websqlFunc
6938
- return async (request, response) => {
6939
- if (this.db.repositoryExists) {
6940
- const { models, totalCount } = await this.db.getAll();
6941
- response?.setHeader(Symbols.old.X_TOTAL_COUNT, totalCount);
6942
- return models;
6943
- }
6944
- return [];
6945
- };
6946
- //#endregion
7157
+ //#region crud operations / typeorm / query
7158
+ /**
7159
+ * Executes a raw SQL query and returns a raw database results.
7160
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
7161
+ */
7162
+ query(query, parameters) {
7163
+ return this.repo.query(query, parameters);
6947
7164
  }
6948
7165
  //#endregion
6949
- //#region get by id
6950
- getBy(id) {
6951
- //#region @websqlFunc
6952
- return async () => {
6953
- const model = await this.db.getBy(id);
6954
- return model;
6955
- };
6956
- //#endregion
7166
+ //#region crud operations / typeorm / query
7167
+ /**
7168
+ * Executes a raw SQL query and returns a raw database results.
7169
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
7170
+ */
7171
+ createQueryBuilder(alias, queryRunner) {
7172
+ return this.repo.createQueryBuilder(alias, queryRunner);
6957
7173
  }
6958
7174
  //#endregion
6959
- //#region update by id
6960
- updateById(id, item) {
6961
- //#region @websqlFunc
6962
- return async () => {
6963
- const model = await this.db.updateById(id, item);
6964
- return model;
6965
- };
6966
- //#endregion
7175
+ //#region crud operations / typeorm / clear
7176
+ /**
7177
+ * Clears all the data from the given table/collection (truncates/drops it).
7178
+ *
7179
+ * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
7180
+ * @see https://stackoverflow.com/a/5972738/925151
7181
+ */
7182
+ clear() {
7183
+ return this.repo.clear();
6967
7184
  }
6968
7185
  //#endregion
6969
- //#region patch by id
6970
- patchById(id, item) {
7186
+ //#region crud operations / typeorm / increment
7187
+ /**
7188
+ * Increments some column by provided value of the entities matched given conditions.
7189
+ */
7190
+ increment(conditions, propertyPath, value) {
7191
+ return this.repo.increment(conditions, propertyPath, value);
7192
+ }
7193
+ //#endregion
7194
+ //#region crud operations / typeorm / decrement
7195
+ /**
7196
+ * Decrements some column by provided value of the entities matched given conditions.
7197
+ */
7198
+ decrement(conditions, propertyPath, value) {
7199
+ return this.repo.decrement(conditions, propertyPath, value);
7200
+ }
7201
+ //#endregion
7202
+ //#region crud operations / get all
7203
+ /**
7204
+ * @deprecated use findAndCount instead
7205
+ */
7206
+ async getAll() {
6971
7207
  //#region @websqlFunc
6972
- return async () => {
6973
- const model = await this.db.updateById(id, item);
6974
- return model;
6975
- };
7208
+ // console.log('repo', this.__repository);
7209
+ // console.log(
7210
+ // `repo taget name "${ClassHelpers.getName(this.__repository.target)}"`,
7211
+ // );
7212
+ // debugger;
7213
+ const totalCount = await this.repo.count();
7214
+ const models = await this.repo.find();
7215
+ // console.log('models', models);
7216
+ // console.log('totalCount', totalCount);
7217
+ return { models, totalCount };
6976
7218
  //#endregion
6977
7219
  }
6978
7220
  //#endregion
6979
- //#region bulk update
6980
- bulkUpdate(items) {
7221
+ //#region crud operations / get by id
7222
+ async getBy(id) {
6981
7223
  //#region @websqlFunc
6982
- return async () => {
6983
- if (!Array.isArray(items) || items?.length === 0) {
6984
- return [];
6985
- }
6986
- const { models } = await this.db.bulkUpdate(items);
6987
- return models;
6988
- };
7224
+ const model = await await this.repo.findOne({
7225
+ where: { id },
7226
+ });
7227
+ return model;
6989
7228
  //#endregion
6990
7229
  }
6991
- //#endregion
6992
- //#region delete by id
6993
- deleteById(id) {
7230
+ };
7231
+ TaonBaseRepository = __decorate([
7232
+ TaonRepository({ className: 'TaonBaseRepository' }),
7233
+ __metadata("design:paramtypes", [Function])
7234
+ ], TaonBaseRepository);
7235
+
7236
+ var TaonGlobalStateUtils;
7237
+ (function (TaonGlobalStateUtils) {
7238
+ // export function isActive(state: string): state is TaonGlobalStateStatus {
7239
+ // return state === 'active';
7240
+ // }
7241
+ TaonGlobalStateUtils.assertAllowedTransition = (from, to) => {
7242
+ if (!allowedTaonGlobalStatusOrders[from]?.includes(to)) {
7243
+ throw new Error(`Invalid state transition: ${from} → ${to}`);
7244
+ }
7245
+ };
7246
+ })(TaonGlobalStateUtils || (TaonGlobalStateUtils = {}));
7247
+
7248
+ //#region imports
7249
+ //#endregion
7250
+ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBaseRepository {
7251
+ constructor() {
7252
+ super(...arguments);
7253
+ this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
7254
+ }
7255
+ async getLastStatus() {
6994
7256
  //#region @websqlFunc
6995
- return async () => {
6996
- const model = await this.db.deleteById(id);
6997
- return model;
6998
- };
7257
+ const lastStatus = await this.findOne({
7258
+ order: { createdAt: 'DESC' },
7259
+ });
7260
+ return lastStatus;
6999
7261
  //#endregion
7000
7262
  }
7001
- //#endregion
7002
- //#region bulk delete
7003
- bulkDelete(ids) {
7263
+ async setDraining(secondsBeforeReadonly = 0) {
7004
7264
  //#region @websqlFunc
7005
- return async () => {
7006
- const models = await this.db.bulkDelete(ids);
7007
- return models;
7008
- };
7265
+ await this.transitionTo(TaonGlobalStateStatus.DRAINING);
7266
+ if (secondsBeforeReadonly > 0) {
7267
+ setTimeout(async () => {
7268
+ await this.transitionTo(TaonGlobalStateStatus.READONLY);
7269
+ }, secondsBeforeReadonly);
7270
+ }
7009
7271
  //#endregion
7010
7272
  }
7011
- //#endregion
7012
- //#region bulk delete
7013
- clearTable() {
7273
+ async transitionTo(next) {
7014
7274
  //#region @websqlFunc
7015
- return async () => {
7016
- await this.db.clear();
7017
- };
7275
+ const current = await this.getLastStatus();
7276
+ TaonGlobalStateUtils.assertAllowedTransition(current.status, next);
7277
+ const newState = this.create({ status: next });
7278
+ await this.save(newState);
7279
+ return newState;
7018
7280
  //#endregion
7019
7281
  }
7020
- //#endregion
7021
- //#region create
7022
- save(item) {
7023
- //#region @websqlFunc
7282
+ };
7283
+ TaonGlobalStateRepository = __decorate([
7284
+ TaonRepository({
7285
+ className: 'TaonGlobalStateRepository',
7286
+ })
7287
+ ], TaonGlobalStateRepository);
7288
+
7289
+ //#region imports
7290
+ //#endregion
7291
+ let TaonGlobalStateController = class TaonGlobalStateController extends TaonBaseCrudController {
7292
+ constructor() {
7293
+ super(...arguments);
7294
+ this.entityClassResolveFn = () => TAON_GLOBAL_STATE;
7295
+ this.taonGlobalStateRepository = this.injectCustomRepo(TaonGlobalStateRepository);
7296
+ }
7297
+ getStatus() {
7024
7298
  return async () => {
7025
- const model = await this.db.save(item);
7026
- return model;
7299
+ //#region @websqlFunc
7300
+ const stateEntity = await this.taonGlobalStateRepository.getLastStatus();
7301
+ return stateEntity.status;
7302
+ //#endregion
7027
7303
  };
7028
- //#endregion
7029
7304
  }
7030
- //#endregion
7031
- //#region bulk create
7032
- bulkCreate(items) {
7033
- //#region @websqlFunc
7305
+ setDraining(secondsBeforeReadonly = 0) {
7034
7306
  return async () => {
7035
- const models = await this.db.bulkCreate(items);
7036
- return models;
7307
+ await this.taonGlobalStateRepository.setDraining(secondsBeforeReadonly);
7037
7308
  };
7038
- //#endregion
7039
7309
  }
7040
7310
  };
7041
- __decorate([
7042
- GET(),
7043
- __param(0, Query(`id`)),
7044
- __param(1, Query(`property`)),
7045
- __param(2, Query('alreadyLength')),
7046
- __metadata("design:type", Function),
7047
- __metadata("design:paramtypes", [Object, String, Number]),
7048
- __metadata("design:returntype", Object)
7049
- ], TaonBaseCrudController.prototype, "bufforedChanges", null);
7050
- __decorate([
7051
- GET(),
7052
- __param(0, Query('pageNumber')),
7053
- __param(1, Query('pageSize')),
7054
- __param(2, Query('search')),
7055
- __metadata("design:type", Function),
7056
- __metadata("design:paramtypes", [Number, Number, String]),
7057
- __metadata("design:returntype", Object)
7058
- ], TaonBaseCrudController.prototype, "pagination", null);
7059
7311
  __decorate([
7060
7312
  GET(),
7061
7313
  __metadata("design:type", Function),
7062
7314
  __metadata("design:paramtypes", []),
7063
7315
  __metadata("design:returntype", Object)
7064
- ], TaonBaseCrudController.prototype, "getAll", null);
7065
- __decorate([
7066
- GET(),
7067
- __param(0, Query(`id`)),
7068
- __metadata("design:type", Function),
7069
- __metadata("design:paramtypes", [Object]),
7070
- __metadata("design:returntype", Object)
7071
- ], TaonBaseCrudController.prototype, "getBy", null);
7072
- __decorate([
7073
- PUT(),
7074
- __param(0, Query(`id`)),
7075
- __param(1, Body()),
7076
- __metadata("design:type", Function),
7077
- __metadata("design:paramtypes", [Object, Object]),
7078
- __metadata("design:returntype", Object)
7079
- ], TaonBaseCrudController.prototype, "updateById", null);
7080
- __decorate([
7081
- PATCH(),
7082
- __param(0, Query(`id`)),
7083
- __param(1, Body()),
7084
- __metadata("design:type", Function),
7085
- __metadata("design:paramtypes", [Object, Object]),
7086
- __metadata("design:returntype", Object)
7087
- ], TaonBaseCrudController.prototype, "patchById", null);
7088
- __decorate([
7089
- PUT(),
7090
- __param(0, Body()),
7091
- __metadata("design:type", Function),
7092
- __metadata("design:paramtypes", [Array]),
7093
- __metadata("design:returntype", Object)
7094
- ], TaonBaseCrudController.prototype, "bulkUpdate", null);
7095
- __decorate([
7096
- DELETE(),
7097
- __param(0, Query(`id`)),
7098
- __metadata("design:type", Function),
7099
- __metadata("design:paramtypes", [Object]),
7100
- __metadata("design:returntype", Object)
7101
- ], TaonBaseCrudController.prototype, "deleteById", null);
7102
- __decorate([
7103
- DELETE(),
7104
- __param(0, Query(`ids`)),
7105
- __metadata("design:type", Function),
7106
- __metadata("design:paramtypes", [Array]),
7107
- __metadata("design:returntype", Object)
7108
- ], TaonBaseCrudController.prototype, "bulkDelete", null);
7109
- __decorate([
7110
- DELETE(),
7111
- __metadata("design:type", Function),
7112
- __metadata("design:paramtypes", []),
7113
- __metadata("design:returntype", Object)
7114
- ], TaonBaseCrudController.prototype, "clearTable", null);
7115
- __decorate([
7116
- POST(),
7117
- __param(0, Body()),
7118
- __metadata("design:type", Function),
7119
- __metadata("design:paramtypes", [Object]),
7120
- __metadata("design:returntype", Object)
7121
- ], TaonBaseCrudController.prototype, "save", null);
7316
+ ], TaonGlobalStateController.prototype, "getStatus", null);
7122
7317
  __decorate([
7123
7318
  POST(),
7124
- __param(0, Body()),
7319
+ __param(0, Query('secondsBeforeReadonly')),
7125
7320
  __metadata("design:type", Function),
7126
7321
  __metadata("design:paramtypes", [Object]),
7127
7322
  __metadata("design:returntype", Object)
7128
- ], TaonBaseCrudController.prototype, "bulkCreate", null);
7129
- TaonBaseCrudController = __decorate([
7130
- TaonController({ className: 'TaonBaseCrudController' })
7131
- ], TaonBaseCrudController);
7132
-
7133
- class TaonBaseMigration extends TaonBaseInjector {
7134
- /**
7135
- * by default is READY to run
7136
- */
7137
- isReadyToRun() {
7138
- return true;
7139
- }
7140
- getDescription() {
7141
- return _.startCase(ClassHelpers.getName(this));
7142
- }
7143
- async up(queryRunner) {
7144
- console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
7145
- }
7146
- async down(queryRunner) {
7147
- console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
7148
- }
7149
- }
7323
+ ], TaonGlobalStateController.prototype, "setDraining", null);
7324
+ TaonGlobalStateController = __decorate([
7325
+ TaonController({
7326
+ className: 'TaonGlobalStateController',
7327
+ })
7328
+ ], TaonGlobalStateController);
7150
7329
 
7151
7330
  /**
7152
7331
  * TODO
@@ -7156,6 +7335,39 @@ class TaonBaseMigration extends TaonBaseInjector {
7156
7335
  class TaonBaseProvider extends TaonBaseInjector {
7157
7336
  }
7158
7337
 
7338
+ /**
7339
+ * Provider decorator
7340
+ */
7341
+ function TaonProvider(options) {
7342
+ return function (constructor) {
7343
+ Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
7344
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
7345
+ ClassHelpers.setName(constructor, options?.className || constructor.name);
7346
+ };
7347
+ }
7348
+ class TaonProviderOptions extends DecoratorAbstractOpt {
7349
+ }
7350
+
7351
+ //#region imports
7352
+ //#endregion
7353
+ let TaonGlobalStateProvider = class TaonGlobalStateProvider extends TaonBaseProvider {
7354
+ };
7355
+ TaonGlobalStateProvider = __decorate([
7356
+ TaonProvider({
7357
+ className: 'TaonGlobalStateProvider',
7358
+ })
7359
+ ], TaonGlobalStateProvider);
7360
+
7361
+ //#region imports
7362
+ //#endregion
7363
+ let TaonGlobalStateMiddleware = class TaonGlobalStateMiddleware extends TaonBaseMiddleware {
7364
+ };
7365
+ TaonGlobalStateMiddleware = __decorate([
7366
+ TaonMiddleware({
7367
+ className: 'TaonGlobalStateMiddleware',
7368
+ })
7369
+ ], TaonGlobalStateMiddleware);
7370
+
7159
7371
  /**
7160
7372
  * Subscriber decorator
7161
7373
  */
@@ -7312,6 +7524,75 @@ TaonBaseSubscriberForEntity = __decorate([
7312
7524
  })
7313
7525
  ], TaonBaseSubscriberForEntity);
7314
7526
 
7527
+ //#region imports
7528
+ //#endregion
7529
+ let TaonGlobalStateSubscriber = class TaonGlobalStateSubscriber extends TaonBaseSubscriberForEntity {
7530
+ constructor() {
7531
+ super(...arguments);
7532
+ this.taonGlobalStateProvider = this.injectProvider(TaonGlobalStateProvider);
7533
+ }
7534
+ listenTo() {
7535
+ return TAON_GLOBAL_STATE;
7536
+ }
7537
+ };
7538
+ TaonGlobalStateSubscriber = __decorate([
7539
+ TaonSubscriber({
7540
+ className: 'TaonGlobalStateSubscriber',
7541
+ // allowedEvents: ['afterUpdate'],
7542
+ })
7543
+ ], TaonGlobalStateSubscriber);
7544
+
7545
+ //#region imports
7546
+ //#endregion
7547
+ const TaonGlobalStateContext = createContext(() => ({
7548
+ contextName: 'TaonGlobalStateContext',
7549
+ abstract: true,
7550
+ entities: { TAON_GLOBAL_STATE },
7551
+ controllers: { TaonGlobalStateController },
7552
+ repositories: { TaonGlobalStateRepository },
7553
+ providers: { TaonGlobalStateProvider },
7554
+ middlewares: { TaonGlobalStateMiddleware },
7555
+ subscribers: { TaonGlobalStateSubscriber },
7556
+ }));
7557
+
7558
+ const TaonBaseContext = createContext(() => ({
7559
+ contextName: 'TaonBaseContext',
7560
+ abstract: true,
7561
+ contexts: {
7562
+ TaonGlobalStateContext,
7563
+ },
7564
+ middlewares: {
7565
+ TaonBaseFileUploadMiddleware,
7566
+ },
7567
+ repositories: {
7568
+ // @ts-ignore
7569
+ TaonBaseRepository,
7570
+ },
7571
+ }));
7572
+
7573
+ var baseContext = /*#__PURE__*/Object.freeze({
7574
+ __proto__: null,
7575
+ TaonBaseContext: TaonBaseContext
7576
+ });
7577
+
7578
+ class TaonBaseMigration extends TaonBaseInjector {
7579
+ /**
7580
+ * by default is READY to run
7581
+ */
7582
+ isReadyToRun() {
7583
+ return true;
7584
+ }
7585
+ getDescription() {
7586
+ return _.startCase(ClassHelpers.getName(this));
7587
+ }
7588
+ async up(queryRunner) {
7589
+ console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
7590
+ }
7591
+ async down(queryRunner) {
7592
+ console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
7593
+ }
7594
+ }
7595
+
7315
7596
  //#region models / method config
7316
7597
  /**
7317
7598
  * @link './decorators/http/http-methods-decorators.ts' TaonHttpDecoratorOptions
@@ -7325,8 +7606,8 @@ class ParamConfig {
7325
7606
  }
7326
7607
 
7327
7608
  class FormlyHorizontalWrapper extends FieldWrapper {
7328
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FormlyHorizontalWrapper, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
7329
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.6", type: FormlyHorizontalWrapper, isStandalone: false, selector: "formly-horizontal-wrapper", viewQueries: [{ propertyName: "fieldComponent", first: true, predicate: ["fieldComponent"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: `
7609
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: FormlyHorizontalWrapper, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
7610
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: FormlyHorizontalWrapper, isStandalone: false, selector: "formly-horizontal-wrapper", viewQueries: [{ propertyName: "fieldComponent", first: true, predicate: ["fieldComponent"], descendants: true, read: ViewContainerRef }], usesInheritance: true, ngImport: i0, template: `
7330
7611
  <div class="form-group row">
7331
7612
  <label
7332
7613
  [attr.for]="id"
@@ -7343,7 +7624,7 @@ class FormlyHorizontalWrapper extends FieldWrapper {
7343
7624
  </div>
7344
7625
  `, isInline: true, styles: [":host{display:block;padding:5px;margin-bottom:5px;border:1px dotted gray}\n"] }); }
7345
7626
  }
7346
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FormlyHorizontalWrapper, decorators: [{
7627
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: FormlyHorizontalWrapper, decorators: [{
7347
7628
  type: Component,
7348
7629
  args: [{ selector: 'formly-horizontal-wrapper', standalone: false, template: `
7349
7630
  <div class="form-group row">
@@ -7388,8 +7669,8 @@ class RepeatTypeComponent extends FieldArrayType {
7388
7669
  // @ts-ignore
7389
7670
  super(builder);
7390
7671
  }
7391
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: RepeatTypeComponent, deps: [{ token: i1.FormlyFormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
7392
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.6", type: RepeatTypeComponent, isStandalone: false, selector: "formly-repeat-section", usesInheritance: true, ngImport: i0, template: `
7672
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: RepeatTypeComponent, deps: [{ token: i1.FormlyFormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
7673
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: RepeatTypeComponent, isStandalone: false, selector: "formly-repeat-section", usesInheritance: true, ngImport: i0, template: `
7393
7674
  <div *ngIf="field.fieldGroup && field.fieldGroup.length === 0">
7394
7675
  Press button to add new element...
7395
7676
  </div>
@@ -7421,7 +7702,7 @@ class RepeatTypeComponent extends FieldArrayType {
7421
7702
  </div>
7422
7703
  `, isInline: true, styles: [":host{display:block;padding:5px;margin-bottom:5px;border:1px solid gray}formly-group{display:block;border:1px dashed gray;margin-bottom:5px;padding:5px}.taon-formly-array{padding:5px;background:#fff}\n"] }); }
7423
7704
  }
7424
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: RepeatTypeComponent, decorators: [{
7705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: RepeatTypeComponent, decorators: [{
7425
7706
  type: Component,
7426
7707
  args: [{ selector: 'formly-repeat-section', standalone: false, template: `
7427
7708
  <div *ngIf="field.fieldGroup && field.fieldGroup.length === 0">
@@ -7708,28 +7989,6 @@ function getFromlyConfigFor(target, options = {}) {
7708
7989
  return fields.filter(f => !!f);
7709
7990
  }
7710
7991
 
7711
- /**
7712
- * Entity decorator
7713
- */
7714
- function TaonEntity(options) {
7715
- return function (constructor) {
7716
- options = options || {};
7717
- options.uniqueKeyProp = options.uniqueKeyProp || 'id';
7718
- ClassHelpers.setName(constructor, options?.className);
7719
- Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
7720
- // TODO when entit metadata generator read use this
7721
- Mapping.DefaultModelWithMapping(void 0, {})(constructor);
7722
- Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
7723
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
7724
- //#region @websql
7725
- Entity(options?.className)(constructor);
7726
- //#endregion
7727
- CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
7728
- };
7729
- }
7730
- class TaonEntityOptions extends DecoratorAbstractOpt {
7731
- }
7732
-
7733
7992
  /**
7734
7993
  * Migration decorator
7735
7994
  */
@@ -7743,19 +8002,6 @@ function TaonMigration(options) {
7743
8002
  class TaonMigrationOptions extends DecoratorAbstractOpt {
7744
8003
  }
7745
8004
 
7746
- /**
7747
- * Provider decorator
7748
- */
7749
- function TaonProvider(options) {
7750
- return function (constructor) {
7751
- Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
7752
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
7753
- ClassHelpers.setName(constructor, options?.className || constructor.name);
7754
- };
7755
- }
7756
- class TaonProviderOptions extends DecoratorAbstractOpt {
7757
- }
7758
-
7759
8005
  // TODO export all things
7760
8006
  var Taon;
7761
8007
  (function (Taon) {
@@ -7948,5 +8194,5 @@ const TAON_FLATTEN_MAPPING = {
7948
8194
  * Generated bundle index. Do not edit.
7949
8195
  */
7950
8196
 
7951
- export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, ContextDbMigrations, ContextsEndpointStorage, ControllerConfig, Cookie, DELETE, DITaonContainer, DateTimeColumn, DecimalNumberColumn, DecoratorAbstractOpt, EndpointContext, EntityProcess, FormlyHorizontalWrapper, GET, HEAD, HTML, Header, MethodConfig, MockNamespaceIpc, MockServerIpc, MockSocketIpc, Models, NumberColumn, PATCH, POST, PUT, ParamConfig, Path, Query, RealtimeClient, RealtimeCore, RealtimeServer, RealtimeStrategy, RealtimeStrategyIpc, RealtimeStrategyMock, RealtimeStrategySocketIO, RealtimeSubsManager, RegisterComponentType, RegisterComponentTypeForEntity, RepeatTypeComponent, SimpleJsonColumn, String100Column, String200Column, String45Column, String500Column, StringColumn, Symbols, TAON_CONTEXT, TAON_FLATTEN_MAPPING, Taon, TaonAdminService, TaonBaseAbstractEntity, TaonBaseAngularService, TaonBaseClass, TaonBaseContext, TaonBaseController, TaonBaseCrudController, TaonBaseCustomRepository, TaonBaseEntity, TaonBaseFileUploadMiddleware, TaonBaseInjector, TaonBaseMiddleware, TaonBaseMigration, TaonBaseProvider, TaonBaseRepository, TaonBaseSubscriberForEntity, TaonController, TaonControllerOptions, TaonEntity, TaonEntityKeysToOmitArr, TaonEntityOptions, TaonHelpers, TaonMiddleware, TaonMiddlewareOptions, TaonMigration, TaonMigrationOptions, TaonProvider, TaonProviderOptions, TaonRepository, TaonRepositoryOptions, TaonRestResponseWrapper, TaonSubscriber, TaonSubscriberOptions, TaonTempDatabasesFolder, TaonTempRoutesFolder, Validators, apiPrefix, cloneObj, controllerConfigFrom, createContext, createContextTemplate, findTypeForEntity, getFromlyConfigFor, getRegisteredComponents, getResponseValue, getTransformFunction, inject, singleTransform, typeFromEntity, typeFromName };
8197
+ export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers, ContextDbMigrations, ContextsEndpointStorage, ControllerConfig, Cookie, DELETE, DITaonContainer, DateTimeColumn, DecimalNumberColumn, DecoratorAbstractOpt, EndpointContext, EntityProcess, FormlyHorizontalWrapper, GET, HEAD, HTML, Header, MethodConfig, MockNamespaceIpc, MockServerIpc, MockSocketIpc, Models, NumberColumn, PATCH, POST, PUT, ParamConfig, Path, Query, RealtimeClient, RealtimeCore, RealtimeServer, RealtimeStrategy, RealtimeStrategyIpc, RealtimeStrategyMock, RealtimeStrategySocketIO, RealtimeSubsManager, RegisterComponentType, RegisterComponentTypeForEntity, RepeatTypeComponent, SimpleJsonColumn, String100Column, String200Column, String20Column, String45Column, String500Column, StringColumn, Symbols, TAON_CONTEXT, TAON_FLATTEN_MAPPING, Taon, TaonAdminService, TaonBaseAbstractEntity, TaonBaseAngularService, TaonBaseClass, TaonBaseContext, TaonBaseController, TaonBaseCrudController, TaonBaseCustomRepository, TaonBaseEntity, TaonBaseFileUploadMiddleware, TaonBaseInjector, TaonBaseMiddleware, TaonBaseMigration, TaonBaseProvider, TaonBaseRepository, TaonBaseSubscriberForEntity, TaonController, TaonControllerOptions, TaonEntity, TaonEntityKeysToOmitArr, TaonEntityOptions, TaonHelpers, TaonMiddleware, TaonMiddlewareOptions, TaonMigration, TaonMigrationOptions, TaonProvider, TaonProviderOptions, TaonRepository, TaonRepositoryOptions, TaonRestResponseWrapper, TaonSubscriber, TaonSubscriberOptions, TaonTempDatabasesFolder, TaonTempRoutesFolder, Validators, apiPrefix, cloneObj, controllerConfigFrom, createContext, createContextTemplate, findTypeForEntity, getFromlyConfigFor, getRegisteredComponents, getResponseValue, getTransformFunction, inject, singleTransform, typeFromEntity, typeFromName };
7952
8198
  //# sourceMappingURL=taon-websql.mjs.map