taon 21.0.17 → 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 (426) hide show
  1. package/README.md +11 -2
  2. package/browser/fesm2022/taon-browser.mjs +1191 -1026
  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 +14 -9
  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/icon-menu-taon.svg +15 -15
  11. package/lib/base-classes/base-context.js +4 -0
  12. package/lib/base-classes/base-context.js.map +1 -1
  13. package/lib/base-classes/base-repository.d.ts +1 -0
  14. package/lib/base-classes/base-repository.js +27 -8
  15. package/lib/base-classes/base-repository.js.map +1 -1
  16. package/lib/build-info._auto-generated_.d.ts +5 -1
  17. package/lib/build-info._auto-generated_.js +6 -2
  18. package/lib/build-info._auto-generated_.js.map +1 -1
  19. package/lib/decorators/classes/middleware-decorator.d.ts +1 -0
  20. package/lib/decorators/classes/middleware-decorator.js +1 -0
  21. package/lib/decorators/classes/middleware-decorator.js.map +1 -1
  22. package/lib/decorators/classes/subscriber-decorator.d.ts +1 -1
  23. package/lib/decorators/classes/subscriber-decorator.js.map +1 -1
  24. package/lib/endpoint-context.d.ts +0 -4
  25. package/lib/endpoint-context.js +0 -18
  26. package/lib/endpoint-context.js.map +1 -1
  27. package/lib/env/env.angular-node-app.d.ts +30 -30
  28. package/lib/env/env.angular-node-app.js +32 -32
  29. package/lib/env/env.angular-node-app.js.map +1 -1
  30. package/lib/env/env.docs-webapp.d.ts +30 -30
  31. package/lib/env/env.docs-webapp.js +32 -32
  32. package/lib/env/env.docs-webapp.js.map +1 -1
  33. package/lib/env/env.electron-app.d.ts +30 -30
  34. package/lib/env/env.electron-app.js +32 -32
  35. package/lib/env/env.electron-app.js.map +1 -1
  36. package/lib/env/env.mobile-app.d.ts +30 -30
  37. package/lib/env/env.mobile-app.js +32 -32
  38. package/lib/env/env.mobile-app.js.map +1 -1
  39. package/lib/env/env.npm-lib-and-cli-tool.d.ts +30 -30
  40. package/lib/env/env.npm-lib-and-cli-tool.js +32 -32
  41. package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
  42. package/lib/env/env.vscode-plugin.d.ts +30 -30
  43. package/lib/env/env.vscode-plugin.js +32 -32
  44. package/lib/env/env.vscode-plugin.js.map +1 -1
  45. package/lib/formly/type-from-entity.js +9 -9
  46. package/lib/formly/type-from-entity.js.map +1 -1
  47. package/lib/global-state/taon-global-state/index.d.ts +6 -0
  48. package/lib/global-state/taon-global-state/index.js +23 -0
  49. package/lib/global-state/taon-global-state/index.js.map +1 -0
  50. package/lib/global-state/taon-global-state/taon-global-state-api.service.d.ts +7 -0
  51. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +19 -0
  52. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.js +23 -0
  53. package/lib/global-state/taon-global-state/taon-global-state.abstract.context.js.map +1 -0
  54. package/lib/global-state/taon-global-state/taon-global-state.constants.d.ts +2 -0
  55. package/lib/global-state/taon-global-state/taon-global-state.constants.js +11 -0
  56. package/lib/global-state/taon-global-state/taon-global-state.constants.js.map +1 -0
  57. package/lib/global-state/taon-global-state/taon-global-state.controller.d.ts +11 -0
  58. package/lib/global-state/taon-global-state/taon-global-state.controller.js +62 -0
  59. package/lib/global-state/taon-global-state/taon-global-state.controller.js.map +1 -0
  60. package/lib/global-state/taon-global-state/taon-global-state.entity.d.ts +7 -0
  61. package/lib/global-state/taon-global-state/taon-global-state.entity.js +64 -0
  62. package/lib/global-state/taon-global-state/taon-global-state.entity.js.map +1 -0
  63. package/lib/global-state/taon-global-state/taon-global-state.middleware.d.ts +3 -0
  64. package/lib/global-state/taon-global-state/taon-global-state.middleware.js +22 -0
  65. package/lib/global-state/taon-global-state/taon-global-state.middleware.js.map +1 -0
  66. package/lib/global-state/taon-global-state/taon-global-state.models.d.ts +28 -0
  67. package/lib/global-state/taon-global-state/taon-global-state.models.js +48 -0
  68. package/lib/global-state/taon-global-state/taon-global-state.models.js.map +1 -0
  69. package/lib/global-state/taon-global-state/taon-global-state.provider.d.ts +3 -0
  70. package/lib/global-state/taon-global-state/taon-global-state.provider.js +22 -0
  71. package/lib/global-state/taon-global-state/taon-global-state.provider.js.map +1 -0
  72. package/lib/global-state/taon-global-state/taon-global-state.repository.d.ts +9 -0
  73. package/lib/global-state/taon-global-state/taon-global-state.repository.js +53 -0
  74. package/lib/global-state/taon-global-state/taon-global-state.repository.js.map +1 -0
  75. package/lib/global-state/taon-global-state/taon-global-state.subscriber.d.ts +7 -0
  76. package/lib/global-state/taon-global-state/taon-global-state.subscriber.js +29 -0
  77. package/lib/global-state/taon-global-state/taon-global-state.subscriber.js.map +1 -0
  78. package/lib/global-state/taon-global-state/taon-global-state.utils.d.ts +4 -0
  79. package/lib/global-state/taon-global-state/taon-global-state.utils.js +16 -0
  80. package/lib/global-state/taon-global-state/taon-global-state.utils.js.map +1 -0
  81. package/lib/global-state/taon-transaction-registry/index.d.ts +11 -0
  82. package/lib/global-state/taon-transaction-registry/index.js +28 -0
  83. package/lib/global-state/taon-transaction-registry/index.js.map +1 -0
  84. package/lib/global-state/taon-transaction-registry/taon-transaction-registry-api.service.d.ts +7 -0
  85. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +19 -0
  86. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +25 -0
  87. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +1 -0
  88. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.d.ts +2 -0
  89. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +9 -0
  90. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +1 -0
  91. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +9 -0
  92. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +52 -0
  93. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -0
  94. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.d.ts +12 -0
  95. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +77 -0
  96. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +1 -0
  97. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.d.ts +3 -0
  98. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +22 -0
  99. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +1 -0
  100. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.d.ts +6 -0
  101. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.js +11 -0
  102. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +1 -0
  103. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.d.ts +3 -0
  104. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +22 -0
  105. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +1 -0
  106. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.d.ts +9 -0
  107. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +38 -0
  108. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +1 -0
  109. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.d.ts +7 -0
  110. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +29 -0
  111. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +1 -0
  112. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +4 -0
  113. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +11 -0
  114. package/lib/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -0
  115. package/lib/index._auto-generated_.js +1 -1
  116. package/lib/index._auto-generated_.js.map +1 -1
  117. package/lib/index.d.ts +4 -2
  118. package/lib/index.js +18 -5
  119. package/lib/index.js.map +1 -1
  120. package/lib/orm/columns.d.ts +5 -1
  121. package/lib/orm/columns.js +12 -2
  122. package/lib/orm/columns.js.map +1 -1
  123. package/lib/realtime/realtime-subs-manager.js +1 -10
  124. package/lib/realtime/realtime-subs-manager.js.map +1 -1
  125. package/lib/ui/index.js +2 -2
  126. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  127. package/lib-prod/base-classes/base-abstract-entity.d.ts +7 -0
  128. package/lib-prod/base-classes/base-abstract-entity.js +42 -0
  129. package/lib-prod/base-classes/base-abstract-entity.js.map +1 -0
  130. package/lib-prod/base-classes/base-angular-service.d.ts +27 -0
  131. package/lib-prod/base-classes/base-angular-service.js +89 -0
  132. package/lib-prod/base-classes/base-angular-service.js.map +1 -0
  133. package/lib-prod/base-classes/base-class.d.ts +15 -0
  134. package/lib-prod/base-classes/base-class.js +40 -0
  135. package/lib-prod/base-classes/base-class.js.map +1 -0
  136. package/lib-prod/base-classes/base-context.d.ts +20 -0
  137. package/lib-prod/base-classes/base-context.js +23 -0
  138. package/lib-prod/base-classes/base-context.js.map +1 -0
  139. package/lib-prod/base-classes/base-controller.d.ts +83 -0
  140. package/lib-prod/base-classes/base-controller.js +173 -0
  141. package/lib-prod/base-classes/base-controller.js.map +1 -0
  142. package/lib-prod/base-classes/base-crud-controller.d.ts +28 -0
  143. package/lib-prod/base-classes/base-crud-controller.js +319 -0
  144. package/lib-prod/base-classes/base-crud-controller.js.map +1 -0
  145. package/lib-prod/base-classes/base-custom-repository.d.ts +3 -0
  146. package/lib-prod/base-classes/base-custom-repository.js +19 -0
  147. package/lib-prod/base-classes/base-custom-repository.js.map +1 -0
  148. package/lib-prod/base-classes/base-electron-service.d.ts +0 -0
  149. package/lib-prod/base-classes/base-electron-service.js +50 -0
  150. package/lib-prod/base-classes/base-electron-service.js.map +1 -0
  151. package/lib-prod/base-classes/base-entity.d.ts +16 -0
  152. package/lib-prod/base-classes/base-entity.js +32 -0
  153. package/lib-prod/base-classes/base-entity.js.map +1 -0
  154. package/lib-prod/base-classes/base-file-upload.middleware.d.ts +14 -0
  155. package/lib-prod/base-classes/base-file-upload.middleware.js +85 -0
  156. package/lib-prod/base-classes/base-file-upload.middleware.js.map +1 -0
  157. package/lib-prod/base-classes/base-injector.d.ts +67 -0
  158. package/lib-prod/base-classes/base-injector.js +198 -0
  159. package/lib-prod/base-classes/base-injector.js.map +1 -0
  160. package/lib-prod/base-classes/base-middleware.d.ts +38 -0
  161. package/lib-prod/base-classes/base-middleware.js +14 -0
  162. package/lib-prod/base-classes/base-middleware.js.map +1 -0
  163. package/lib-prod/base-classes/base-migration.d.ts +11 -0
  164. package/lib-prod/base-classes/base-migration.js +25 -0
  165. package/lib-prod/base-classes/base-migration.js.map +1 -0
  166. package/lib-prod/base-classes/base-provider.d.ts +8 -0
  167. package/lib-prod/base-classes/base-provider.js +13 -0
  168. package/lib-prod/base-classes/base-provider.js.map +1 -0
  169. package/lib-prod/base-classes/base-repository.d.ts +272 -0
  170. package/lib-prod/base-classes/base-repository.js +634 -0
  171. package/lib-prod/base-classes/base-repository.js.map +1 -0
  172. package/lib-prod/base-classes/base-subscriber-for-entity.d.ts +81 -0
  173. package/lib-prod/base-classes/base-subscriber-for-entity.js +155 -0
  174. package/lib-prod/base-classes/base-subscriber-for-entity.js.map +1 -0
  175. package/lib-prod/base-classes/base.d.ts +1 -0
  176. package/lib-prod/base-classes/base.js +20 -0
  177. package/lib-prod/base-classes/base.js.map +1 -0
  178. package/lib-prod/build-info._auto-generated_.d.ts +24 -0
  179. package/lib-prod/build-info._auto-generated_.js +30 -0
  180. package/lib-prod/build-info._auto-generated_.js.map +1 -0
  181. package/lib-prod/config/controller-config.d.ts +21 -0
  182. package/lib-prod/config/controller-config.js +34 -0
  183. package/lib-prod/config/controller-config.js.map +1 -0
  184. package/lib-prod/config/controller-options.d.ts +16 -0
  185. package/lib-prod/config/controller-options.js +8 -0
  186. package/lib-prod/config/controller-options.js.map +1 -0
  187. package/lib-prod/config/method-config.d.ts +39 -0
  188. package/lib-prod/config/method-config.js +12 -0
  189. package/lib-prod/config/method-config.js.map +1 -0
  190. package/lib-prod/config/param-config.d.ts +8 -0
  191. package/lib-prod/config/param-config.js +8 -0
  192. package/lib-prod/config/param-config.js.map +1 -0
  193. package/lib-prod/constants.d.ts +9 -0
  194. package/lib-prod/constants.js +32 -0
  195. package/lib-prod/constants.js.map +1 -0
  196. package/lib-prod/context-db-migrations.d.ts +17 -0
  197. package/lib-prod/context-db-migrations.js +349 -0
  198. package/lib-prod/context-db-migrations.js.map +1 -0
  199. package/lib-prod/create-context.d.ts +78 -0
  200. package/lib-prod/create-context.js +223 -0
  201. package/lib-prod/create-context.js.map +1 -0
  202. package/lib-prod/decorators/classes/controller-decorator.d.ts +5 -0
  203. package/lib-prod/decorators/classes/controller-decorator.js +21 -0
  204. package/lib-prod/decorators/classes/controller-decorator.js.map +1 -0
  205. package/lib-prod/decorators/classes/entity-decorator.d.ts +19 -0
  206. package/lib-prod/decorators/classes/entity-decorator.js +43 -0
  207. package/lib-prod/decorators/classes/entity-decorator.js.map +1 -0
  208. package/lib-prod/decorators/classes/middleware-decorator.d.ts +8 -0
  209. package/lib-prod/decorators/classes/middleware-decorator.js +22 -0
  210. package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -0
  211. package/lib-prod/decorators/classes/migration-decorator.d.ts +7 -0
  212. package/lib-prod/decorators/classes/migration-decorator.js +21 -0
  213. package/lib-prod/decorators/classes/migration-decorator.js.map +1 -0
  214. package/lib-prod/decorators/classes/provider-decorator.d.ts +7 -0
  215. package/lib-prod/decorators/classes/provider-decorator.js +21 -0
  216. package/lib-prod/decorators/classes/provider-decorator.js.map +1 -0
  217. package/lib-prod/decorators/classes/repository-decorator.d.ts +7 -0
  218. package/lib-prod/decorators/classes/repository-decorator.js +21 -0
  219. package/lib-prod/decorators/classes/repository-decorator.js.map +1 -0
  220. package/lib-prod/decorators/classes/subscriber-decorator.d.ts +8 -0
  221. package/lib-prod/decorators/classes/subscriber-decorator.js +22 -0
  222. package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -0
  223. package/lib-prod/decorators/decorator-abstract-opt.d.ts +3 -0
  224. package/lib-prod/decorators/decorator-abstract-opt.js +7 -0
  225. package/lib-prod/decorators/decorator-abstract-opt.js.map +1 -0
  226. package/lib-prod/decorators/http/http-decorators.d.ts +2 -0
  227. package/lib-prod/decorators/http/http-decorators.js +24 -0
  228. package/lib-prod/decorators/http/http-decorators.js.map +1 -0
  229. package/lib-prod/decorators/http/http-methods-decorators.d.ts +70 -0
  230. package/lib-prod/decorators/http/http-methods-decorators.js +112 -0
  231. package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -0
  232. package/lib-prod/decorators/http/http-params-decorators.d.ts +8 -0
  233. package/lib-prod/decorators/http/http-params-decorators.js +50 -0
  234. package/lib-prod/decorators/http/http-params-decorators.js.map +1 -0
  235. package/lib-prod/dependency-injection/di-container.d.ts +5 -0
  236. package/lib-prod/dependency-injection/di-container.js +35 -0
  237. package/lib-prod/dependency-injection/di-container.js.map +1 -0
  238. package/lib-prod/endpoint-context-storage.d.ts +11 -0
  239. package/lib-prod/endpoint-context-storage.js +38 -0
  240. package/lib-prod/endpoint-context-storage.js.map +1 -0
  241. package/lib-prod/endpoint-context.d.ts +196 -0
  242. package/lib-prod/endpoint-context.js +2416 -0
  243. package/lib-prod/endpoint-context.js.map +1 -0
  244. package/lib-prod/entity-process.d.ts +39 -0
  245. package/lib-prod/entity-process.js +242 -0
  246. package/lib-prod/entity-process.js.map +1 -0
  247. package/lib-prod/env/env.angular-node-app.d.ts +64 -0
  248. package/lib-prod/env/env.angular-node-app.js +71 -0
  249. package/lib-prod/env/env.angular-node-app.js.map +1 -0
  250. package/lib-prod/env/env.docs-webapp.d.ts +64 -0
  251. package/lib-prod/env/env.docs-webapp.js +71 -0
  252. package/lib-prod/env/env.docs-webapp.js.map +1 -0
  253. package/lib-prod/env/env.electron-app.d.ts +64 -0
  254. package/lib-prod/env/env.electron-app.js +71 -0
  255. package/lib-prod/env/env.electron-app.js.map +1 -0
  256. package/lib-prod/env/env.mobile-app.d.ts +64 -0
  257. package/lib-prod/env/env.mobile-app.js +71 -0
  258. package/lib-prod/env/env.mobile-app.js.map +1 -0
  259. package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +64 -0
  260. package/lib-prod/env/env.npm-lib-and-cli-tool.js +71 -0
  261. package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
  262. package/lib-prod/env/env.vscode-plugin.d.ts +64 -0
  263. package/lib-prod/env/env.vscode-plugin.js +71 -0
  264. package/lib-prod/env/env.vscode-plugin.js.map +1 -0
  265. package/lib-prod/env/index.d.ts +6 -0
  266. package/lib-prod/env/index.js +23 -0
  267. package/lib-prod/env/index.js.map +1 -0
  268. package/lib-prod/express-types.d.ts +1 -0
  269. package/lib-prod/express-types.js +3 -0
  270. package/lib-prod/express-types.js.map +1 -0
  271. package/lib-prod/formly/formly.models.d.ts +1 -0
  272. package/lib-prod/formly/formly.models.js +3 -0
  273. package/lib-prod/formly/formly.models.js.map +1 -0
  274. package/lib-prod/formly/fromly.d.ts +16 -0
  275. package/lib-prod/formly/fromly.js +209 -0
  276. package/lib-prod/formly/fromly.js.map +1 -0
  277. package/lib-prod/formly/type-from-entity.d.ts +20 -0
  278. package/lib-prod/formly/type-from-entity.js +60 -0
  279. package/lib-prod/formly/type-from-entity.js.map +1 -0
  280. package/lib-prod/get-response-value.d.ts +6 -0
  281. package/lib-prod/get-response-value.js +27 -0
  282. package/lib-prod/get-response-value.js.map +1 -0
  283. package/lib-prod/global-state/taon-global-state/index.d.ts +5 -0
  284. package/lib-prod/global-state/taon-global-state/index.js +23 -0
  285. package/lib-prod/global-state/taon-global-state/index.js.map +1 -0
  286. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +19 -0
  287. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +23 -0
  288. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js.map +1 -0
  289. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.d.ts +2 -0
  290. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +11 -0
  291. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js.map +1 -0
  292. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.d.ts +11 -0
  293. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +62 -0
  294. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +1 -0
  295. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.d.ts +7 -0
  296. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +64 -0
  297. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js.map +1 -0
  298. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.d.ts +3 -0
  299. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +22 -0
  300. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js.map +1 -0
  301. package/lib-prod/global-state/taon-global-state/taon-global-state.models.d.ts +28 -0
  302. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +48 -0
  303. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js.map +1 -0
  304. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.d.ts +3 -0
  305. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +22 -0
  306. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js.map +1 -0
  307. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.d.ts +9 -0
  308. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +53 -0
  309. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +1 -0
  310. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.d.ts +7 -0
  311. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +29 -0
  312. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js.map +1 -0
  313. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.d.ts +4 -0
  314. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +16 -0
  315. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +1 -0
  316. package/lib-prod/global-state/taon-transaction-registry/index.d.ts +10 -0
  317. package/lib-prod/global-state/taon-transaction-registry/index.js +28 -0
  318. package/lib-prod/global-state/taon-transaction-registry/index.js.map +1 -0
  319. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +19 -0
  320. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +25 -0
  321. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +1 -0
  322. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.d.ts +2 -0
  323. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +9 -0
  324. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +1 -0
  325. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +9 -0
  326. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +52 -0
  327. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -0
  328. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.d.ts +12 -0
  329. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +77 -0
  330. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +1 -0
  331. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.d.ts +3 -0
  332. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +22 -0
  333. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +1 -0
  334. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.d.ts +6 -0
  335. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +11 -0
  336. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +1 -0
  337. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.d.ts +3 -0
  338. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +22 -0
  339. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +1 -0
  340. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.d.ts +9 -0
  341. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +38 -0
  342. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +1 -0
  343. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.d.ts +7 -0
  344. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +29 -0
  345. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +1 -0
  346. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +4 -0
  347. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +11 -0
  348. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -0
  349. package/lib-prod/helpers/class-helpers.d.ts +24 -0
  350. package/lib-prod/helpers/class-helpers.js +233 -0
  351. package/lib-prod/helpers/class-helpers.js.map +1 -0
  352. package/lib-prod/helpers/clone-obj.d.ts +1 -0
  353. package/lib-prod/helpers/clone-obj.js +22 -0
  354. package/lib-prod/helpers/clone-obj.js.map +1 -0
  355. package/lib-prod/helpers/taon-helpers.d.ts +18 -0
  356. package/lib-prod/helpers/taon-helpers.js +152 -0
  357. package/lib-prod/helpers/taon-helpers.js.map +1 -0
  358. package/lib-prod/index._auto-generated_.d.ts +0 -0
  359. package/lib-prod/index._auto-generated_.js +6 -0
  360. package/lib-prod/index._auto-generated_.js.map +1 -0
  361. package/lib-prod/index.d.ts +234 -0
  362. package/lib-prod/index.js +272 -0
  363. package/lib-prod/index.js.map +1 -0
  364. package/lib-prod/inject.d.ts +4 -0
  365. package/lib-prod/inject.js +94 -0
  366. package/lib-prod/inject.js.map +1 -0
  367. package/lib-prod/models.d.ts +260 -0
  368. package/lib-prod/models.js +125 -0
  369. package/lib-prod/models.js.map +1 -0
  370. package/lib-prod/orm/columns.d.ts +32 -0
  371. package/lib-prod/orm/columns.js +112 -0
  372. package/lib-prod/orm/columns.js.map +1 -0
  373. package/lib-prod/orm/index.d.ts +1 -0
  374. package/lib-prod/orm/index.js +73 -0
  375. package/lib-prod/orm/index.js.map +1 -0
  376. package/lib-prod/realtime/realtime-client.d.ts +41 -0
  377. package/lib-prod/realtime/realtime-client.js +204 -0
  378. package/lib-prod/realtime/realtime-client.js.map +1 -0
  379. package/lib-prod/realtime/realtime-core.d.ts +40 -0
  380. package/lib-prod/realtime/realtime-core.js +106 -0
  381. package/lib-prod/realtime/realtime-core.js.map +1 -0
  382. package/lib-prod/realtime/realtime-server.d.ts +43 -0
  383. package/lib-prod/realtime/realtime-server.js +243 -0
  384. package/lib-prod/realtime/realtime-server.js.map +1 -0
  385. package/lib-prod/realtime/realtime-strategy/index.d.ts +4 -0
  386. package/lib-prod/realtime/realtime-strategy/index.js +21 -0
  387. package/lib-prod/realtime/realtime-strategy/index.js.map +1 -0
  388. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +80 -0
  389. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +297 -0
  390. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -0
  391. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.d.ts +14 -0
  392. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +303 -0
  393. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -0
  394. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +16 -0
  395. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +33 -0
  396. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -0
  397. package/lib-prod/realtime/realtime-strategy/realtime-strategy.d.ts +11 -0
  398. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +17 -0
  399. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js.map +1 -0
  400. package/lib-prod/realtime/realtime-subs-manager.d.ts +14 -0
  401. package/lib-prod/realtime/realtime-subs-manager.js +94 -0
  402. package/lib-prod/realtime/realtime-subs-manager.js.map +1 -0
  403. package/lib-prod/realtime/realtime.models.d.ts +27 -0
  404. package/lib-prod/realtime/realtime.models.js +3 -0
  405. package/lib-prod/realtime/realtime.models.js.map +1 -0
  406. package/lib-prod/symbols.d.ts +65 -0
  407. package/lib-prod/symbols.js +110 -0
  408. package/lib-prod/symbols.js.map +1 -0
  409. package/lib-prod/ui/index.d.ts +1 -0
  410. package/lib-prod/ui/index.js +5 -0
  411. package/lib-prod/ui/index.js.map +1 -0
  412. package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -0
  413. package/lib-prod/ui/taon-admin-mode-configuration/index.js +5 -0
  414. package/lib-prod/ui/taon-admin-mode-configuration/index.js.map +1 -0
  415. package/lib-prod/validators.d.ts +7 -0
  416. package/lib-prod/validators.js +85 -0
  417. package/lib-prod/validators.js.map +1 -0
  418. package/package.json +22 -6
  419. package/websql/fesm2022/taon-websql.mjs +1405 -1152
  420. package/websql/fesm2022/taon-websql.mjs.map +1 -1
  421. package/websql/package.json +1 -1
  422. package/websql/types/taon-websql.d.ts +14 -9
  423. package/websql-prod/README.md +24 -0
  424. package/websql-prod/fesm2022/taon-websql.mjs +8198 -0
  425. package/websql-prod/fesm2022/taon-websql.mjs.map +1 -0
  426. 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';
@@ -1203,20 +1203,11 @@ class RealtimeSubsManager {
1203
1203
  //#region methods & getters / update
1204
1204
  update(data) {
1205
1205
  // log.data(`realtime update!!!!! observers=${this.observers?.length} `)
1206
- const ngZone = this.options.core.ctx.ngZone;
1207
1206
  // console.log('updating', data);
1208
- // console.log('ngzone', ngZone);
1209
1207
  this.observers.forEach(observer => {
1210
1208
  // console.log(`observer closed: ${observer.closed}`,observer);
1211
1209
  if (!observer.closed) {
1212
- if (ngZone) {
1213
- ngZone.run(() => {
1214
- observer.next(data);
1215
- });
1216
- }
1217
- else {
1218
- observer.next(data);
1219
- }
1210
+ observer.next(data);
1220
1211
  }
1221
1212
  });
1222
1213
  }
@@ -2376,15 +2367,10 @@ class TaonAdminService {
2376
2367
  logout() { }
2377
2368
  }
2378
2369
 
2370
+ /* */
2371
+ /* */
2379
2372
  //#endregion
2380
2373
  class EndpointContext {
2381
- //#endregion
2382
- //#region @browser
2383
- static initNgZone(ngZone) {
2384
- //#region @browser
2385
- this.ngZone = ngZone;
2386
- //#endregion
2387
- }
2388
2374
  //#endregion
2389
2375
  //#endregion
2390
2376
  //#region fields / source context
@@ -2449,8 +2435,6 @@ class EndpointContext {
2449
2435
  this.originalConfig = originalConfig;
2450
2436
  this.configFn = configFn;
2451
2437
  this.cloneOptions = cloneOptions;
2452
- //#endregion
2453
- //#endregion
2454
2438
  //#region fields
2455
2439
  //#region fields / use mariadb mysql in docker
2456
2440
  /**
@@ -3043,14 +3027,6 @@ class EndpointContext {
3043
3027
  //#endregion
3044
3028
  }
3045
3029
  //#endregion
3046
- //#region methods & getters / ng zone
3047
- get ngZone() {
3048
- //#region @browser
3049
- return EndpointContext.ngZone;
3050
- //#endregion
3051
- return;
3052
- }
3053
- //#endregion
3054
3030
  //#region methods & getters / start server
3055
3031
  async startServer() {
3056
3032
  /* */
@@ -4520,7 +4496,7 @@ class EndpointContext {
4520
4496
  //#region handling web sql request
4521
4497
  //#region @websqlOnly
4522
4498
  //#region resolve variables
4523
- const MIN_TIMEOUT = 500;
4499
+ const MIN_TIMEOUT = 400;
4524
4500
  const MIN_TIMEOUT_STEP = 200;
4525
4501
  const globalThisVar = globalThis; // TODO not a good idea! probably should be in context
4526
4502
  const timeout = globalThisVar[Symbols.old.WEBSQL_REST_PROGRESS_TIMEOUT] || MIN_TIMEOUT;
@@ -5374,7 +5350,16 @@ const String100Column = (defaultValue = null) => Column({
5374
5350
  default: defaultValue,
5375
5351
  });
5376
5352
  /**
5377
- * 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
5378
5363
  */
5379
5364
  const String45Column = (defaultValue = null) => Column({
5380
5365
  type: 'varchar',
@@ -5622,13 +5607,283 @@ class TaonBaseAngularService {
5622
5607
  return currentContext ? currentContext.getClass(ctor) : void 0;
5623
5608
  });
5624
5609
  }
5625
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TaonBaseAngularService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5626
- 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 }); }
5627
5612
  }
5628
- 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: [{
5629
5614
  type: Injectable
5630
5615
  }], ctorParameters: () => [] });
5631
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
+
5632
5887
  /**
5633
5888
  * Provider decorator
5634
5889
  */
@@ -5903,1255 +6158,1174 @@ TaonBaseFileUploadMiddleware = __decorate([
5903
6158
  })
5904
6159
  ], TaonBaseFileUploadMiddleware);
5905
6160
 
5906
- /**
5907
- * Repository decorator
5908
- */
5909
- function TaonRepository(options) {
5910
- return function (constructor) {
5911
- Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
5912
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
5913
- ClassHelpers.setName(constructor, options?.className);
5914
- };
5915
- }
5916
- class TaonRepositoryOptions extends DecoratorAbstractOpt {
5917
- }
5918
-
5919
- //#endregion
5920
- let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
5921
- };
5922
- TaonBaseCustomRepository = __decorate([
5923
- TaonRepository({ className: 'TaonBaseCustomRepository' })
5924
- ], TaonBaseCustomRepository);
5925
-
5926
- //#endregion
5927
- const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
5928
- const REPOS_CACHE = Symbol('repository cache inside instance');
5929
- let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
5930
- constructor(
5931
- // Injected through TaonBaseCrudController
5932
- __entityClassResolveFn) {
5933
- super();
5934
- this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
5935
- // @ts-ignore
5936
- this.entityClassResolveFn = __entityClassResolveFn;
5937
- }
5938
- get dbQuery() {
5939
- //#region @websqlFunc
5940
- if (!this.__dbQuery) {
5941
- if (!this.ctx) {
5942
- return; // TODO
5943
- throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers.getName(this)}`);
5944
- }
5945
- const connection = this.ctx?.connection;
5946
- if (!connection) {
5947
- throw new Error(`[TaonBaseRepository] Database not inited for context ${this.ctx?.contextName}`);
5948
- }
5949
- this.__dbQuery = new MySqlQuerySource(connection);
5950
- }
5951
- return this.__dbQuery;
5952
- //#endregion
5953
- }
5954
- //#endregion
5955
- //#region connection
5956
- get connection() {
5957
- //#region @websqlFunc
5958
- return this.ctx?.connection;
5959
- //#endregion
5960
- }
5961
- //#endregion
5962
- //#region repository
5963
- get repository() {
5964
- //#region @websqlFunc
5965
- if (this[REPOS_CACHE]) {
5966
- return this[REPOS_CACHE];
5967
- }
5968
- const repo = this.ctx.repos.get(ClassHelpers.getName(this.entityClassResolveFn()));
5969
- this[REPOS_CACHE] = repo;
5970
- return this[REPOS_CACHE];
5971
- //#endregion
5972
- }
6161
+ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
5973
6162
  /**
5974
- * target for repository
6163
+ * Hook that is called when taon app is inited
6164
+ * (all contexts are created and inited)
5975
6165
  */
5976
- get target() {
5977
- //#region @websqlFunc
5978
- return this?.repository?.target;
5979
- //#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);
5980
6196
  }
6197
+ //#endregion
6198
+ //#region after file upload hook
5981
6199
  /**
5982
- * alias to repository
6200
+ * Hook after file is uploaded
6201
+ * through `uploadFormDataToServer` or `uploadLocalFileToServer`
5983
6202
  */
5984
- get repo() {
5985
- //#region @websqlFunc
5986
- return this.repository;
5987
- //#endregion
6203
+ afterFileUploadAction(file, queryParams) {
6204
+ // empty
5988
6205
  }
5989
- get repositoryExists() {
5990
- //#region @websqlFunc
5991
- return !!this.repository;
5992
- //#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);
5993
6223
  }
5994
6224
  //#endregion
5995
- //#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
+ // }
5996
6231
  /**
5997
- * Checks if entity has an id.
5998
- * 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
+ * ```
5999
6243
  */
6000
- hasId(entity) {
6001
- 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
+ }
6002
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 {
6003
6319
  //#endregion
6004
- //#region crud operations / typeorm / get id
6005
- /**
6006
- * Gets entity mixed id.
6007
- */
6008
- getId(entity) {
6009
- 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._();
6010
6348
  }
6011
6349
  //#endregion
6012
- //#region crud operations / typeorm / create & bulk create
6013
- /**
6014
- Saves a given entity in the database.
6015
- * If entity does not exist in the database then inserts, otherwise updates.
6016
- */
6017
- async save(item, options) {
6350
+ //#region bufferd changes
6351
+ bufforedChanges(id, property, alreadyLength) {
6018
6352
  //#region @websqlFunc
6019
- // if (!this.repo) {
6020
- // debugger;
6021
- // }
6022
- let model = await this.repo.create(item);
6023
- model = await this.repo.save(model, options);
6024
- const { id } = model;
6025
- model = await this.repo.findOne({
6026
- where: { id },
6027
- });
6028
- 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
+ };
6029
6366
  //#endregion
6030
6367
  }
6031
- /**
6032
- * Creates a new entity instance or instances.
6033
- * Can copy properties from the given object into new entities.
6034
- */
6035
- create(plainEntityLikeOrPlainEntityLikes) {
6036
- return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6037
- }
6038
- async bulkSave(items, options) {
6368
+ //#endregion
6369
+ //#region pagintation
6370
+ pagination(pageNumber = 1, pageSize = 10, search = '') {
6039
6371
  //#region @websqlFunc
6040
- const models = [];
6041
- for (let index = 0; index < items.length; index++) {
6042
- const item = items[index];
6043
- // TODO FIX THIS / REFACTOR
6044
- const model = await this.save(item, options);
6045
- models.push(model);
6046
- }
6047
- 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
+ };
6048
6404
  //#endregion
6049
6405
  }
6050
- /**
6051
- * @deprecated use bulkSave instead
6052
- */
6053
- async bulkCreate(items, options) {
6054
- return this.bulkSave(items, options);
6055
- }
6056
- //#region old typeorm version
6057
- /**
6058
- * Saves all given entities in the database.
6059
- * If entities do not exist in the database then inserts, otherwise updates.
6060
- */
6061
- // save<T extends DeepPartial<Entity>>(
6062
- // entities: T[],
6063
- // options: SaveOptions & {
6064
- // reload: false;
6065
- // },
6066
- // ): Promise<T[]>;
6067
- // /**
6068
- // * Saves all given entities in the database.
6069
- // * If entities do not exist in the database then inserts, otherwise updates.
6070
- // */
6071
- // save<T extends DeepPartial<Entity>>(
6072
- // entities: T[],
6073
- // options?: SaveOptions,
6074
- // ): Promise<(T & Entity)[]>;
6075
- // /**
6076
- // * Saves a given entity in the database.
6077
- // * If entity does not exist in the database then inserts, otherwise updates.
6078
- // */
6079
- // save<T extends DeepPartial<Entity>>(
6080
- // entity: T,
6081
- // options: SaveOptions & {
6082
- // reload: false;
6083
- // },
6084
- // ): Promise<T>;
6085
- // /**
6086
- // * Saves a given entity in the database.
6087
- // * If entity does not exist in the database then inserts, otherwise updates.
6088
- // */
6089
- // save<T extends DeepPartial<Entity>>(
6090
- // entity: T,
6091
- // options?: SaveOptions,
6092
- // ): Promise<T & Entity> {
6093
- // return this.repo.save(entity, options);
6094
- // }
6095
6406
  //#endregion
6096
- //#endregion
6097
- //#region crud operations / typeorm / merge
6098
- /**
6099
- * Merges multiple entities (or entity-like objects) into a given entity.
6100
- */
6101
- merge(mergeIntoEntity, ...entityLikes) {
6102
- return this.repo.merge(mergeIntoEntity, ...entityLikes);
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
6103
6419
  }
6104
6420
  //#endregion
6105
- //#region crud operations / typeorm / preload
6106
- /**
6107
- * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
6108
- * it loads it (and everything related to it), replaces all values with the new ones from the given object
6109
- * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
6110
- * replaced from the new object.
6111
- *
6112
- * Note that given entity-like object must have an entity id / primary key to find entity by.
6113
- * Returns undefined if entity with given id was not found.
6114
- */
6115
- preload(entityLike) {
6116
- return this.repo.preload(entityLike);
6421
+ //#region get by id
6422
+ getBy(id) {
6423
+ //#region @websqlFunc
6424
+ return async () => {
6425
+ const model = await this.db.getBy(id);
6426
+ return model;
6427
+ };
6428
+ //#endregion
6117
6429
  }
6118
6430
  //#endregion
6119
- //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6120
- /**
6121
- * Removes a given entities from the database.
6122
- */
6123
- async remove(idOrEntity) {
6431
+ //#region update by id
6432
+ updateById(id, item) {
6124
6433
  //#region @websqlFunc
6125
- if (_.isObject(idOrEntity)) {
6126
- idOrEntity = idOrEntity.id;
6127
- }
6128
- const deletedEntity = await this.repo.findOne({
6129
- where: { id: idOrEntity },
6130
- });
6131
- if (!deletedEntity) {
6132
- Helpers.warn(`[TaonBaseRepository] Entity "${ClassHelpers.getName(this.repo.target)}" ` +
6133
- `with id ${idOrEntity} not found, cannot remove`);
6134
- return;
6135
- }
6136
- const idCopy = deletedEntity.id;
6137
- await this.repo.remove(deletedEntity);
6138
- deletedEntity.id = idCopy;
6139
- return deletedEntity;
6434
+ return async () => {
6435
+ const model = await this.db.updateById(id, item);
6436
+ return model;
6437
+ };
6140
6438
  //#endregion
6141
6439
  }
6142
- /**
6143
- * alias to remove
6144
- */
6145
- async delete(idOrEntity) {
6146
- return this.remove(idOrEntity);
6147
- }
6148
- /**
6149
- * alias to removeById
6150
- */
6151
- async deleteById(id) {
6152
- return this.remove(id);
6153
- }
6154
- async bulkRemove(idsOrEntities) {
6440
+ //#endregion
6441
+ //#region patch by id
6442
+ patchById(id, item) {
6155
6443
  //#region @websqlFunc
6156
- idsOrEntities = idsOrEntities.map(id => {
6157
- return _.isObject(id) ? id.id : id;
6158
- });
6159
- const models = [];
6160
- for (let index = 0; index < idsOrEntities.length; index++) {
6161
- const id = idsOrEntities[index];
6162
- const model = await this.remove(id);
6163
- models.push(model);
6164
- }
6165
- return models;
6444
+ return async () => {
6445
+ const model = await this.db.updateById(id, item);
6446
+ return model;
6447
+ };
6166
6448
  //#endregion
6167
6449
  }
6168
- async bulkDelete(ids) {
6169
- return this.bulkRemove(ids);
6170
- }
6171
- /**
6172
- * Records the delete date of a given entity.
6173
- */
6174
- softRemove(entity, options) {
6175
- return this.repo.softRemove(entity, options);
6176
- }
6177
- /**
6178
- * Recovers a given entity in the database.
6179
- */
6180
- recover(entity, options) {
6181
- return this.repo.recover(entity, options);
6182
- }
6183
6450
  //#endregion
6184
- //#region crud operations / typeorm / insert
6185
- /**
6186
- * Inserts a given entity into the database.
6187
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6188
- * Executes fast and efficient INSERT query.
6189
- * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
6190
- */
6191
- insert(entity) {
6192
- return this.repo.insert(entity);
6451
+ //#region bulk update
6452
+ bulkUpdate(items) {
6453
+ //#region @websqlFunc
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
+ };
6461
+ //#endregion
6193
6462
  }
6194
6463
  //#endregion
6195
- //#region crud operations / typeorm / update & build update
6196
- async update(item) {
6464
+ //#region delete by id
6465
+ deleteById(id) {
6197
6466
  //#region @websqlFunc
6198
- const { id } = item;
6199
- return await this.updateById(id, item);
6467
+ return async () => {
6468
+ const model = await this.db.deleteById(id);
6469
+ return model;
6470
+ };
6200
6471
  //#endregion
6201
6472
  }
6202
- async updateById(id, item) {
6473
+ //#endregion
6474
+ //#region bulk delete
6475
+ bulkDelete(ids) {
6203
6476
  //#region @websqlFunc
6204
- const allowedPropsToUpdate = [];
6205
- for (const key in item) {
6206
- const metadataColumn = this.repo.metadata.ownColumns.find(c => c.propertyName === key);
6207
- if (_.isObject(item) &&
6208
- item.hasOwnProperty(key) &&
6209
- (typeof item[key] !== 'object' ||
6210
- this.allowedTypesToUpdate.includes(metadataColumn?.type)) &&
6211
- !_.isUndefined(metadataColumn)) {
6212
- allowedPropsToUpdate.push(key);
6213
- }
6214
- }
6215
- for (let i = 0; i < allowedPropsToUpdate.length; i++) {
6216
- const key = allowedPropsToUpdate[i];
6217
- if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
6218
- // const raw = _.isBoolean(item[key]) || _.isNumber(item[key]) || _.isNull(item[key]); // TODO does this make any sense ?
6219
- const toSet = item[key];
6220
- // const tableName = tableNameFrom(this.entity as any);
6221
- await this.repo.update({
6222
- id,
6223
- }, {
6224
- [key]: toSet,
6225
- });
6226
- // await this.repo.query(
6227
- // `UPDATE '${tableName}' as ${table}
6228
- // SET ${key}=${toSet}
6229
- // WHERE ${table}.id='${id}'
6230
- // `);
6231
- }
6232
- }
6233
- let model = await this.repo.findOne({
6234
- where: { id },
6235
- });
6236
- return model;
6477
+ return async () => {
6478
+ const models = await this.db.bulkDelete(ids);
6479
+ return models;
6480
+ };
6237
6481
  //#endregion
6238
6482
  }
6239
- async bulkUpdate(items) {
6483
+ //#endregion
6484
+ //#region bulk delete
6485
+ clearTable() {
6240
6486
  //#region @websqlFunc
6241
- const models = [];
6242
- for (let index = 0; index < items.length; index++) {
6243
- const item = items[index];
6244
- const { id } = item; // TOOD
6245
- const model = await this.updateById(id, item);
6246
- models.push(model);
6247
- }
6248
- return { models };
6487
+ return async () => {
6488
+ await this.db.clear();
6489
+ };
6249
6490
  //#endregion
6250
6491
  }
6251
- //#region tpeorm update version
6252
- // this version suck and will not return update entity
6253
- // /**
6254
- // * Updates entity partially. Entity can be found by a given conditions.
6255
- // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6256
- // * Executes fast and efficient UPDATE query.
6257
- // * Does not check if entity exist in the database.
6258
- // */
6259
- // update(
6260
- // criteria:
6261
- // | string
6262
- // | string[]
6263
- // | number
6264
- // | number[]
6265
- // | Date
6266
- // | Date[]
6267
- // | ObjectID
6268
- // | ObjectID[]
6269
- // | FindOptionsWhere<Entity>,
6270
- // partialEntity: QueryDeepPartialEntity<Entity>,
6271
- // ): Promise<UpdateResult> {
6272
- // return this.repo.update(criteria, partialEntity);
6273
- // }
6274
6492
  //#endregion
6275
- //#endregion
6276
- //#region crud operations / typeorm / upsert
6277
- /**
6278
- * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
6279
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6280
- * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
6281
- */
6282
- upsert(entityOrEntities, conflictPathsOrOptions) {
6283
- 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
6284
6501
  }
6285
6502
  //#endregion
6286
- //#region crud operations / typeorm / soft delete
6287
- /**
6288
- * Records the delete date of entities by a given criteria.
6289
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6290
- * Executes fast and efficient SOFT-DELETE query.
6291
- * Does not check if entity exist in the database.
6292
- */
6293
- softDelete(criteria) {
6294
- 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
6295
6652
  }
6296
6653
  //#endregion
6297
- //#region crud operations / typeorm / restore
6298
- /**
6299
- * Restores entities by a given criteria.
6300
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
6301
- * Executes fast and efficient SOFT-DELETE query.
6302
- * Does not check if entity exist in the database.
6303
- */
6304
- restore(criteria) {
6305
- return this.repo.restore(criteria);
6654
+ //#region connection
6655
+ get connection() {
6656
+ //#region @websqlFunc
6657
+ return this.ctx?.connection;
6658
+ //#endregion
6306
6659
  }
6307
6660
  //#endregion
6308
- //#region crud operations / typeorm / count
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
+ }
6309
6691
  /**
6310
- * Counts entities that match given options.
6311
- * Useful for pagination.
6692
+ * target for repository
6312
6693
  */
6313
- count(options) {
6314
- return this.repo.count(options);
6694
+ get target() {
6695
+ //#region @websqlFunc
6696
+ return this?.repository?.target;
6697
+ //#endregion
6315
6698
  }
6316
- //#endregion
6317
- //#region crud operations / typeorm / count by
6318
6699
  /**
6319
- * Counts entities that match given conditions.
6320
- * Useful for pagination.
6700
+ * alias to repository
6321
6701
  */
6322
- countBy(where) {
6323
- return this.repo.countBy(where);
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
6324
6711
  }
6325
6712
  //#endregion
6326
- //#region crud operations / typeorm / find
6713
+ //#region crud operations / typeorm / has id
6327
6714
  /**
6328
- * Finds entities that match given find options.
6715
+ * Checks if entity has an id.
6716
+ * If entity composite compose ids, it will check them all.
6329
6717
  */
6330
- find(options) {
6331
- return this.repo.find(options);
6718
+ hasId(entity) {
6719
+ return this.repo.hasId(entity);
6332
6720
  }
6333
6721
  //#endregion
6334
- //#region crud operations / typeorm / find by
6722
+ //#region crud operations / typeorm / get id
6335
6723
  /**
6336
- * Finds entities that match given find options.
6724
+ * Gets entity mixed id.
6337
6725
  */
6338
- findBy(where) {
6339
- return this.repo.findBy(where);
6726
+ getId(entity) {
6727
+ return this.repo.getId(entity);
6340
6728
  }
6341
6729
  //#endregion
6342
- //#region crud operations / typeorm / find and count
6343
- // async findAndCount(options: { take: number; skip: number }) {
6344
- // const { take, skip } = options;
6345
- // const [result, total] = await this.repo.findAndCount({
6346
- // // where: { name: Like('%' + keyword + '%') },
6347
- // // order: { name: "DESC" },
6348
- // take: take,
6349
- // skip: skip,
6350
- // });
6351
- // return { result, total };
6352
- // }
6353
- //
6730
+ //#region crud operations / typeorm / create & bulk create
6354
6731
  /**
6355
- * Finds entities that match given find options.
6356
- * Also counts all entities that match given conditions,
6357
- * but ignores pagination settings (from and take options).
6732
+ Saves a given entity in the database.
6733
+ * If entity does not exist in the database then inserts, otherwise updates.
6358
6734
  */
6359
- findAndCount(options) {
6360
- return this.repo.findAndCount(options);
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
6361
6748
  }
6362
- //#endregion
6363
- //#region crud operations / typeorm / find and count by
6364
6749
  /**
6365
- * Finds entities that match given WHERE conditions.
6366
- * Also counts all entities that match given conditions,
6367
- * 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.
6368
6752
  */
6369
- findAndCountBy(where) {
6370
- return this.repo.findAndCountBy(where);
6753
+ create(plainEntityLikeOrPlainEntityLikes) {
6754
+ return this.repo.create(plainEntityLikeOrPlainEntityLikes);
6755
+ }
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
6371
6767
  }
6372
- //#endregion
6373
- //#region crud operations / typeorm / find by ids
6374
6768
  /**
6375
- * Finds entities with ids.
6376
- * Optionally find options or conditions can be applied.
6377
- *
6378
- * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
6379
- *
6380
- * .findBy({
6381
- * id: In([1, 2, 3])
6382
- * })
6769
+ * @deprecated use bulkSave instead
6383
6770
  */
6384
- findByIds(ids) {
6385
- return this.repo.findByIds(ids);
6771
+ async bulkCreate(items, options) {
6772
+ return this.bulkSave(items, options);
6386
6773
  }
6387
- //#endregion
6388
- //#region crud operations / typeorm / find one
6774
+ //#region old typeorm version
6389
6775
  /**
6390
- * Finds first entity by a given find options.
6391
- * 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.
6392
6778
  */
6393
- findOne(options) {
6394
- return this.repo.findOne(options);
6395
- }
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
+ // }
6396
6813
  //#endregion
6397
- //#region crud operations / typeorm / find one by
6814
+ //#endregion
6815
+ //#region crud operations / typeorm / merge
6398
6816
  /**
6399
- * Finds first entity that matches given where condition.
6400
- * If entity was not found in the database - returns null.
6817
+ * Merges multiple entities (or entity-like objects) into a given entity.
6401
6818
  */
6402
- findOneBy(where) {
6403
- return this.repo.findOneBy(where);
6819
+ merge(mergeIntoEntity, ...entityLikes) {
6820
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
6404
6821
  }
6405
6822
  //#endregion
6406
- //#region crud operations / typeorm / find one or fail
6823
+ //#region crud operations / typeorm / preload
6407
6824
  /**
6408
- * Finds first entity that matches given id.
6409
- * If entity was not found in the database - returns null.
6410
- *
6411
- * @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.
6412
6829
  *
6413
- * .findOneBy({
6414
- * id: 1 // where "id" is your primary column name
6415
- * })
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.
6416
6832
  */
6417
- findOneById(id) {
6418
- return this.repo.findOneById(id);
6833
+ preload(entityLike) {
6834
+ return this.repo.preload(entityLike);
6419
6835
  }
6420
6836
  //#endregion
6421
- //#region crud operations / typeorm / find one or fail
6837
+ //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
6422
6838
  /**
6423
- * Finds first entity by a given find options.
6424
- * If entity was not found in the database - rejects with error.
6839
+ * Removes a given entities from the database.
6425
6840
  */
6426
- findOneOrFail(options) {
6427
- 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
6428
6858
  }
6429
- //#endregion
6430
- //#region crud operations / typeorm / find one by or fail
6431
6859
  /**
6432
- * Finds first entity that matches given where condition.
6433
- * If entity was not found in the database - rejects with error.
6860
+ * alias to remove
6434
6861
  */
6435
- findOneByOrFail(where) {
6436
- return this.repo.findOneByOrFail(where);
6862
+ async delete(idOrEntity) {
6863
+ return this.remove(idOrEntity);
6437
6864
  }
6438
- //#endregion
6439
- //#region crud operations / typeorm / query
6440
6865
  /**
6441
- * Executes a raw SQL query and returns a raw database results.
6442
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
6866
+ * alias to removeById
6443
6867
  */
6444
- query(query, parameters) {
6445
- return this.repo.query(query, parameters);
6868
+ async deleteById(id) {
6869
+ return this.remove(id);
6446
6870
  }
6447
- //#endregion
6448
- //#region crud operations / typeorm / query
6449
- /**
6450
- * Executes a raw SQL query and returns a raw database results.
6451
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
6452
- */
6453
- createQueryBuilder(alias, queryRunner) {
6454
- 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);
6455
6887
  }
6456
- //#endregion
6457
- //#region crud operations / typeorm / clear
6458
6888
  /**
6459
- * Clears all the data from the given table/collection (truncates/drops it).
6460
- *
6461
- * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
6462
- * @see https://stackoverflow.com/a/5972738/925151
6889
+ * Records the delete date of a given entity.
6463
6890
  */
6464
- clear() {
6465
- return this.repo.clear();
6891
+ softRemove(entity, options) {
6892
+ return this.repo.softRemove(entity, options);
6466
6893
  }
6467
- //#endregion
6468
- //#region crud operations / typeorm / increment
6469
6894
  /**
6470
- * Increments some column by provided value of the entities matched given conditions.
6895
+ * Recovers a given entity in the database.
6471
6896
  */
6472
- increment(conditions, propertyPath, value) {
6473
- return this.repo.increment(conditions, propertyPath, value);
6897
+ recover(entity, options) {
6898
+ return this.repo.recover(entity, options);
6474
6899
  }
6475
6900
  //#endregion
6476
- //#region crud operations / typeorm / decrement
6901
+ //#region crud operations / typeorm / insert
6477
6902
  /**
6478
- * 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.
6479
6907
  */
6480
- decrement(conditions, propertyPath, value) {
6481
- return this.repo.decrement(conditions, propertyPath, value);
6908
+ insert(entity) {
6909
+ // debugger;
6910
+ return this.repo.insert(entity);
6482
6911
  }
6483
6912
  //#endregion
6484
- //#region crud operations / get all
6485
- /**
6486
- * @deprecated use findAndCount instead
6487
- */
6488
- async getAll() {
6913
+ //#region crud operations / typeorm / update & build update
6914
+ async update(item) {
6489
6915
  //#region @websqlFunc
6490
- // console.log('repo', this.__repository);
6491
- // console.log(
6492
- // `repo taget name "${ClassHelpers.getName(this.__repository.target)}"`,
6493
- // );
6494
- // debugger;
6495
- const totalCount = await this.repo.count();
6496
- const models = await this.repo.find();
6497
- // console.log('models', models);
6498
- // console.log('totalCount', totalCount);
6499
- return { models, totalCount };
6916
+ const { id } = item;
6917
+ return await this.updateById(id, item);
6500
6918
  //#endregion
6501
6919
  }
6502
- //#endregion
6503
- //#region crud operations / get by id
6504
- async getBy(id) {
6920
+ async updateById(id, item) {
6505
6921
  //#region @websqlFunc
6506
- 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({
6507
6952
  where: { id },
6508
6953
  });
6509
6954
  return model;
6510
6955
  //#endregion
6511
6956
  }
6512
- };
6513
- TaonBaseRepository = __decorate([
6514
- TaonRepository({ className: 'TaonBaseRepository' }),
6515
- __metadata("design:paramtypes", [Function])
6516
- ], TaonBaseRepository);
6517
-
6518
- const TaonBaseContext = createContext(() => ({
6519
- contextName: 'TaonBaseContext',
6520
- abstract: true,
6521
- middlewares: {
6522
- TaonBaseFileUploadMiddleware,
6523
- },
6524
- repositories: {
6525
- // @ts-ignore
6526
- TaonBaseRepository,
6527
- },
6528
- }));
6529
-
6530
- var baseContext = /*#__PURE__*/Object.freeze({
6531
- __proto__: null,
6532
- TaonBaseContext: TaonBaseContext
6533
- });
6534
-
6535
- /**
6536
- * Controller decorator
6537
- */
6538
- function TaonController(options) {
6539
- return function (constructor) {
6540
- ClassHelpers.setName(constructor, options?.className);
6541
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
6542
- const cfg = ClassHelpers.ensureClassConfig(constructor);
6543
- options = options || {};
6544
- cfg.className = options.className || constructor.name;
6545
- cfg.path = options.path || '';
6546
- cfg.realtime = options.realtime;
6547
- cfg.middlewares = options.middlewares;
6548
- };
6549
- }
6550
-
6551
- const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
6552
- const methodConfig = ClassHelpers.ensureMethodConfig(target, propertyKey);
6553
- let options;
6554
- if (typeof pathOrOptions === 'object') {
6555
- options = pathOrOptions;
6556
- pathOrOptions = options.path;
6557
- pathIsGlobal = !!options.pathIsGlobal;
6558
- path = options.path;
6559
- }
6560
- else {
6561
- options = { pathOrOptions, pathIsGlobal };
6562
- }
6563
- const { overrideContentType, overrideResponseType, overrideExpressSendAsHtml, middlewares, } = options;
6564
- methodConfig.methodName = propertyKey;
6565
- methodConfig.middlewares = middlewares;
6566
- methodConfig.type = method;
6567
- if (!path) {
6568
- let paramsPathConcatedPath = '';
6569
- for (const key in methodConfig.parameters) {
6570
- if (methodConfig.parameters.hasOwnProperty(key)) {
6571
- const element = methodConfig.parameters[key];
6572
- if (element.paramType === 'Path' &&
6573
- _.isString(element.paramName) &&
6574
- element.paramName.trim().length > 0) {
6575
- paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
6576
- }
6577
- }
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);
6578
6965
  }
6579
- methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
6580
- }
6581
- else {
6582
- methodConfig.path = path;
6966
+ return { models };
6967
+ //#endregion
6583
6968
  }
6584
- methodConfig.descriptor = descriptor;
6585
- methodConfig.global = pathIsGlobal;
6586
- methodConfig.contentType = overrideContentType;
6587
- methodConfig.responseType = overrideResponseType;
6588
- methodConfig.overrideExpressSendAsHtml = overrideExpressSendAsHtml;
6589
- };
6590
- function GET(pathOrOptions, pathIsGlobal = false) {
6591
- return function (target, propertyKey, descriptor) {
6592
- metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6593
- };
6594
- }
6595
- /**
6596
- * Method for sending html website from text
6597
- * Example
6598
- *
6599
- * ```ts
6600
- * ...
6601
- * // in your taon controller
6602
- * ..Taon.Http.HTML()
6603
- * sendHtmlDummyWebsite(): Taon.ResponseHtml {
6604
- * return `
6605
- <html>
6606
- <head>
6607
- <title>Dummy website</title>
6608
- </head>
6609
- <body>
6610
- <h1>This is dummy website</h1>
6611
- <p>Served as HTML string from Taon controller method</p>
6612
- </body>
6613
- </html>
6614
- * `; *
6615
- * }
6616
- * ...
6617
- * ```
6618
- */
6619
- function HTML(pathOrOptions) {
6620
- return function (target, propertyKey, descriptor) {
6621
- const opt = pathOrOptions;
6622
- opt.overrideExpressSendAsHtml = true;
6623
- metaReq('get', opt, target, propertyKey, descriptor, pathOrOptions, opt.pathIsGlobal);
6624
- };
6625
- }
6626
- function HEAD(pathOrOptions, pathIsGlobal = false) {
6627
- return function (target, propertyKey, descriptor) {
6628
- metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6629
- };
6630
- }
6631
- function POST(pathOrOptions, pathIsGlobal = false) {
6632
- return function (target, propertyKey, descriptor) {
6633
- metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6634
- };
6635
- }
6636
- function PUT(pathOrOptions, pathIsGlobal = false) {
6637
- return function (target, propertyKey, descriptor) {
6638
- metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6639
- };
6640
- }
6641
- function PATCH(pathOrOptions, pathIsGlobal = false) {
6642
- return function (target, propertyKey, descriptor) {
6643
- metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6644
- };
6645
- }
6646
- function DELETE(pathOrOptions, pathIsGlobal = false) {
6647
- return function (target, propertyKey, descriptor) {
6648
- metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
6649
- };
6650
- }
6651
-
6652
- function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
6653
- const methodCfg = ClassHelpers.ensureMethodConfig(target, propertyKey);
6654
- const nameKey = name ? name : param;
6655
- // const key = name || `${param}_${parameterIndex}`;
6656
- methodCfg.parameters[nameKey] = {
6657
- index: parameterIndex,
6658
- paramName: name,
6659
- paramType: param,
6660
- defaultType: defaultValue,
6661
- expireInSeconds: expire,
6662
- };
6663
- // console.log('params updated', methodConfig);
6664
- }
6665
- /**
6666
- * @deprecated use Taon.Http.Param.Path (is more safe and cleaner)
6667
- */
6668
- function Path(name) {
6669
- return function (target, propertyKey, parameterIndex) {
6670
- metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
6671
- };
6672
- }
6673
- function Query(name) {
6674
- return function (target, propertyKey, parameterIndex) {
6675
- metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
6676
- };
6677
- }
6678
- function Cookie(name, expireInSecond = 3600) {
6679
- return function (target, propertyKey, parameterIndex) {
6680
- metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
6681
- };
6682
- }
6683
- function Header(name) {
6684
- return function (target, propertyKey, parameterIndex) {
6685
- metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
6686
- };
6687
- }
6688
- function Body(name) {
6689
- return function (target, propertyKey, parameterIndex) {
6690
- metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
6691
- };
6692
- }
6693
-
6694
- let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
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
6695
6995
  /**
6696
- * Hook that is called when taon app is inited
6697
- * (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.
6698
6999
  */
6699
- async afterAllCtxInited(options) { }
6700
- //#region upload form data to server
6701
- uploadFormDataToServer(formData, queryParams) {
6702
- /* */
6703
- /* */
6704
- /* */
6705
- /* */
6706
- /* */
6707
- /* */
6708
- /* */
6709
- /* */
6710
- /* */
6711
- /* */
6712
- /* */
6713
- /* */
6714
- /* */
6715
- /* */
6716
- /* */
6717
- /* */
6718
- /* */
6719
- /* */
6720
- /* */
6721
- /* */
6722
- /* */
6723
- /* */
6724
- /* */
6725
- /* */
6726
- /* */
6727
- /* */
6728
- return (void 0);
7000
+ upsert(entityOrEntities, conflictPathsOrOptions) {
7001
+ return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
6729
7002
  }
6730
7003
  //#endregion
6731
- //#region after file upload hook
7004
+ //#region crud operations / typeorm / soft delete
6732
7005
  /**
6733
- * Hook after file is uploaded
6734
- * 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.
6735
7010
  */
6736
- afterFileUploadAction(file, queryParams) {
6737
- // empty
7011
+ softDelete(criteria) {
7012
+ return this.repo.softDelete(criteria);
6738
7013
  }
6739
- //#region upload local file to server
6740
- async uploadLocalFileToServer(absFilePath, options, queryParams) {
6741
- /* */
6742
- /* */
6743
- /* */
6744
- /* */
6745
- /* */
6746
- /* */
6747
- /* */
6748
- /* */
6749
- /* */
6750
- /* */
6751
- /* */
6752
- /* */
6753
- /* */
6754
- /* */
6755
- 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);
6756
7024
  }
6757
7025
  //#endregion
6758
- // async check() {
6759
- // await this._waitForProperStatusChange({
6760
- // request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6761
- // statusCheck: resp => resp.body.json[0].ok,
6762
- // });
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 };
6763
7070
  // }
7071
+ //
6764
7072
  /**
6765
- * 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.
6766
7095
  *
6767
- * example (in sub class):
6768
- * ```ts
6769
- async check() {
6770
- await this.waitForProperStatusChange({
6771
- request: () => this.uploadFormDataToServer(void 0, void 0).request(),
6772
- statusCheck: resp => resp.body.json[0].ok,
6773
- });
6774
- }
6775
- * ```
7096
+ * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
7097
+ *
7098
+ * .findBy({
7099
+ * id: In([1, 2, 3])
7100
+ * })
6776
7101
  */
6777
- async _waitForProperStatusChange(options) {
6778
- const poolingInterval = options.poolingInterval || 1000;
6779
- const taonRequest = options.request;
6780
- let maxTries = options.maxTries || Number.POSITIVE_INFINITY;
6781
- let i = 0;
6782
- let httpErrorsCount = 0;
6783
- while (true) {
6784
- await UtilsTerminal.waitMilliseconds(poolingInterval);
6785
- try {
6786
- const resp = await taonRequest({
6787
- reqIndexNum: i,
6788
- httpErrorsCount,
6789
- });
6790
- if (options.statusCheck && options.statusCheck(resp)) {
6791
- return;
6792
- }
6793
- }
6794
- catch (error) {
6795
- httpErrorsCount++;
6796
- if (options.loopRequestsOnBackendError) {
6797
- const isProperTaonError = error instanceof HttpResponseError &&
6798
- error.body.json[CoreModels.TaonHttpErrorCustomProp];
6799
- const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
6800
- const isUnknownError = !(error instanceof HttpResponseError);
6801
- const resBool = await options.loopRequestsOnBackendError({
6802
- taonError: isProperTaonError ? error : void 0,
6803
- unknownHttpError: isHttpError ? error : void 0,
6804
- unknownError: isUnknownError ? error : void 0,
6805
- reqIndexNum: i,
6806
- httpErrorsCount,
6807
- });
6808
- if (resBool) {
6809
- i++;
6810
- continue;
6811
- }
6812
- else {
6813
- return;
6814
- }
6815
- }
6816
- if (httpErrorsCount >
6817
- (options.allowedHttpErrors || Number.POSITIVE_INFINITY)) {
6818
- throw new Error(`Too many http errors (${httpErrorsCount}) for "${options.actionName}".`);
6819
- }
6820
- }
6821
- if (i++ > maxTries) {
6822
- throw new Error(`Timeout waiting for "${options.actionName}" to be finished. Waited for ${maxTries} seconds`);
6823
- }
6824
- }
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);
7122
+ }
7123
+ //#endregion
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);
6825
7137
  }
6826
- };
6827
- __decorate([
6828
- POST({
6829
- overrideContentType: 'multipart/form-data',
6830
- middlewares: ({ parentMiddlewares }) => ({
6831
- ...parentMiddlewares,
6832
- TaonBaseFileUploadMiddleware,
6833
- }),
6834
- }),
6835
- __param(0, Body()),
6836
- __param(1, Query()),
6837
- __metadata("design:type", Function),
6838
- __metadata("design:paramtypes", [FormData, Object]),
6839
- __metadata("design:returntype", Object)
6840
- ], TaonBaseController.prototype, "uploadFormDataToServer", null);
6841
- TaonBaseController = __decorate([
6842
- TaonController({
6843
- className: 'TaonBaseController',
6844
- })
6845
- ], TaonBaseController);
6846
-
6847
- //#endregion
6848
- /**
6849
- * Please override property entityClassFn with entity class.
6850
- */
6851
- let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseController {
6852
7138
  //#endregion
6853
- //#region init
6854
- async _() {
6855
- if (!_.isFunction(this.entityClassResolveFn)) {
6856
- Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
6857
- return;
6858
- }
6859
- let entityClassFn = this.entityClassResolveFn();
6860
- this.db = this.injectRepo(entityClassFn);
6861
- if (entityClassFn) {
6862
- const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
6863
- if (configEntity?.createTable === false) {
6864
- Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
6865
- }
6866
- }
6867
- else {
6868
- Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
6869
-
6870
- Please provide entity as class property entityClassFn:
6871
-
6872
- class ${ClassHelpers.getName(this)} extends TaonBaseCrudController<Entity> {
6873
- // ...
6874
- entityClassResolveFn = ()=> MyEntityClass;
6875
- // ...
6876
- }
6877
-
6878
- `);
6879
- }
6880
- await super._();
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);
6881
7146
  }
6882
7147
  //#endregion
6883
- //#region bufferd changes
6884
- bufforedChanges(id, property, alreadyLength) {
6885
- //#region @websqlFunc
6886
- return async (request, response) => {
6887
- const model = await this.db.getBy(id);
6888
- if (model === void 0) {
6889
- return;
6890
- }
6891
- Validators.preventUndefinedModel(model, id);
6892
- let value = model[property];
6893
- let result;
6894
- if (_.isString(value) || _.isArray(value)) {
6895
- result = value.slice(alreadyLength);
6896
- }
6897
- return result;
6898
- };
6899
- //#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);
6900
7155
  }
6901
7156
  //#endregion
6902
- //#region pagintation
6903
- pagination(pageNumber = 1, pageSize = 10, search = '') {
6904
- //#region @websqlFunc
6905
- return async (request, response) => {
6906
- if (this.db.repositoryExists) {
6907
- const query = {
6908
- page: pageNumber,
6909
- take: pageSize,
6910
- keyword: search,
6911
- };
6912
- // console.log({
6913
- // query
6914
- // })
6915
- const take = query.take || 10;
6916
- const page = query.page || 1;
6917
- const skip = (page - 1) * take;
6918
- const keyword = query.keyword || '';
6919
- const [result, total] = await this.db.findAndCount({
6920
- // where: { name: Like('%' + keyword + '%') },
6921
- // order: { name: "DESC" },
6922
- take: take,
6923
- skip: skip,
6924
- });
6925
- response?.setHeader(Symbols.old.X_TOTAL_COUNT, total);
6926
- // const lastPage = Math.ceil(total / take);
6927
- // const nextPage = page + 1 > lastPage ? null : page + 1;
6928
- // const prevPage = page - 1 < 1 ? null : page - 1;
6929
- // console.log({
6930
- // result,
6931
- // total
6932
- // })
6933
- return result;
6934
- }
6935
- return [];
6936
- };
6937
- //#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);
6938
7164
  }
6939
7165
  //#endregion
6940
- //#region get all
6941
- getAll() {
6942
- //#region @websqlFunc
6943
- return async (request, response) => {
6944
- if (this.db.repositoryExists) {
6945
- const { models, totalCount } = await this.db.getAll();
6946
- response?.setHeader(Symbols.old.X_TOTAL_COUNT, totalCount);
6947
- return models;
6948
- }
6949
- return [];
6950
- };
6951
- //#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);
6952
7173
  }
6953
7174
  //#endregion
6954
- //#region get by id
6955
- getBy(id) {
6956
- //#region @websqlFunc
6957
- return async () => {
6958
- const model = await this.db.getBy(id);
6959
- return model;
6960
- };
6961
- //#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();
6962
7184
  }
6963
7185
  //#endregion
6964
- //#region update by id
6965
- updateById(id, item) {
6966
- //#region @websqlFunc
6967
- return async () => {
6968
- const model = await this.db.updateById(id, item);
6969
- return model;
6970
- };
6971
- //#endregion
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);
6972
7192
  }
6973
7193
  //#endregion
6974
- //#region patch by id
6975
- patchById(id, item) {
6976
- //#region @websqlFunc
6977
- return async () => {
6978
- const model = await this.db.updateById(id, item);
6979
- return model;
6980
- };
6981
- //#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);
6982
7200
  }
6983
7201
  //#endregion
6984
- //#region bulk update
6985
- bulkUpdate(items) {
7202
+ //#region crud operations / get all
7203
+ /**
7204
+ * @deprecated use findAndCount instead
7205
+ */
7206
+ async getAll() {
6986
7207
  //#region @websqlFunc
6987
- return async () => {
6988
- if (!Array.isArray(items) || items?.length === 0) {
6989
- return [];
6990
- }
6991
- const { models } = await this.db.bulkUpdate(items);
6992
- return models;
6993
- };
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 };
6994
7218
  //#endregion
6995
7219
  }
6996
7220
  //#endregion
6997
- //#region delete by id
6998
- deleteById(id) {
7221
+ //#region crud operations / get by id
7222
+ async getBy(id) {
6999
7223
  //#region @websqlFunc
7000
- return async () => {
7001
- const model = await this.db.deleteById(id);
7002
- return model;
7003
- };
7224
+ const model = await await this.repo.findOne({
7225
+ where: { id },
7226
+ });
7227
+ return model;
7004
7228
  //#endregion
7005
7229
  }
7006
- //#endregion
7007
- //#region bulk delete
7008
- bulkDelete(ids) {
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() {
7009
7256
  //#region @websqlFunc
7010
- return async () => {
7011
- const models = await this.db.bulkDelete(ids);
7012
- return models;
7013
- };
7257
+ const lastStatus = await this.findOne({
7258
+ order: { createdAt: 'DESC' },
7259
+ });
7260
+ return lastStatus;
7014
7261
  //#endregion
7015
7262
  }
7016
- //#endregion
7017
- //#region bulk delete
7018
- clearTable() {
7263
+ async setDraining(secondsBeforeReadonly = 0) {
7019
7264
  //#region @websqlFunc
7020
- return async () => {
7021
- await this.db.clear();
7022
- };
7265
+ await this.transitionTo(TaonGlobalStateStatus.DRAINING);
7266
+ if (secondsBeforeReadonly > 0) {
7267
+ setTimeout(async () => {
7268
+ await this.transitionTo(TaonGlobalStateStatus.READONLY);
7269
+ }, secondsBeforeReadonly);
7270
+ }
7023
7271
  //#endregion
7024
7272
  }
7025
- //#endregion
7026
- //#region create
7027
- save(item) {
7273
+ async transitionTo(next) {
7028
7274
  //#region @websqlFunc
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;
7280
+ //#endregion
7281
+ }
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() {
7029
7298
  return async () => {
7030
- const model = await this.db.save(item);
7031
- return model;
7299
+ //#region @websqlFunc
7300
+ const stateEntity = await this.taonGlobalStateRepository.getLastStatus();
7301
+ return stateEntity.status;
7302
+ //#endregion
7032
7303
  };
7033
- //#endregion
7034
7304
  }
7035
- //#endregion
7036
- //#region bulk create
7037
- bulkCreate(items) {
7038
- //#region @websqlFunc
7305
+ setDraining(secondsBeforeReadonly = 0) {
7039
7306
  return async () => {
7040
- const models = await this.db.bulkCreate(items);
7041
- return models;
7307
+ await this.taonGlobalStateRepository.setDraining(secondsBeforeReadonly);
7042
7308
  };
7043
- //#endregion
7044
7309
  }
7045
7310
  };
7046
7311
  __decorate([
7047
7312
  GET(),
7048
- __param(0, Query(`id`)),
7049
- __param(1, Query(`property`)),
7050
- __param(2, Query('alreadyLength')),
7051
- __metadata("design:type", Function),
7052
- __metadata("design:paramtypes", [Object, String, Number]),
7053
- __metadata("design:returntype", Object)
7054
- ], TaonBaseCrudController.prototype, "bufforedChanges", null);
7055
- __decorate([
7056
- GET(),
7057
- __param(0, Query('pageNumber')),
7058
- __param(1, Query('pageSize')),
7059
- __param(2, Query('search')),
7060
- __metadata("design:type", Function),
7061
- __metadata("design:paramtypes", [Number, Number, String]),
7062
- __metadata("design:returntype", Object)
7063
- ], TaonBaseCrudController.prototype, "pagination", null);
7064
- __decorate([
7065
- GET(),
7066
- __metadata("design:type", Function),
7067
- __metadata("design:paramtypes", []),
7068
- __metadata("design:returntype", Object)
7069
- ], TaonBaseCrudController.prototype, "getAll", null);
7070
- __decorate([
7071
- GET(),
7072
- __param(0, Query(`id`)),
7073
- __metadata("design:type", Function),
7074
- __metadata("design:paramtypes", [Object]),
7075
- __metadata("design:returntype", Object)
7076
- ], TaonBaseCrudController.prototype, "getBy", null);
7077
- __decorate([
7078
- PUT(),
7079
- __param(0, Query(`id`)),
7080
- __param(1, Body()),
7081
- __metadata("design:type", Function),
7082
- __metadata("design:paramtypes", [Object, Object]),
7083
- __metadata("design:returntype", Object)
7084
- ], TaonBaseCrudController.prototype, "updateById", null);
7085
- __decorate([
7086
- PATCH(),
7087
- __param(0, Query(`id`)),
7088
- __param(1, Body()),
7089
- __metadata("design:type", Function),
7090
- __metadata("design:paramtypes", [Object, Object]),
7091
- __metadata("design:returntype", Object)
7092
- ], TaonBaseCrudController.prototype, "patchById", null);
7093
- __decorate([
7094
- PUT(),
7095
- __param(0, Body()),
7096
- __metadata("design:type", Function),
7097
- __metadata("design:paramtypes", [Array]),
7098
- __metadata("design:returntype", Object)
7099
- ], TaonBaseCrudController.prototype, "bulkUpdate", null);
7100
- __decorate([
7101
- DELETE(),
7102
- __param(0, Query(`id`)),
7103
- __metadata("design:type", Function),
7104
- __metadata("design:paramtypes", [Object]),
7105
- __metadata("design:returntype", Object)
7106
- ], TaonBaseCrudController.prototype, "deleteById", null);
7107
- __decorate([
7108
- DELETE(),
7109
- __param(0, Query(`ids`)),
7110
- __metadata("design:type", Function),
7111
- __metadata("design:paramtypes", [Array]),
7112
- __metadata("design:returntype", Object)
7113
- ], TaonBaseCrudController.prototype, "bulkDelete", null);
7114
- __decorate([
7115
- DELETE(),
7116
7313
  __metadata("design:type", Function),
7117
7314
  __metadata("design:paramtypes", []),
7118
7315
  __metadata("design:returntype", Object)
7119
- ], TaonBaseCrudController.prototype, "clearTable", null);
7120
- __decorate([
7121
- POST(),
7122
- __param(0, Body()),
7123
- __metadata("design:type", Function),
7124
- __metadata("design:paramtypes", [Object]),
7125
- __metadata("design:returntype", Object)
7126
- ], TaonBaseCrudController.prototype, "save", null);
7316
+ ], TaonGlobalStateController.prototype, "getStatus", null);
7127
7317
  __decorate([
7128
7318
  POST(),
7129
- __param(0, Body()),
7319
+ __param(0, Query('secondsBeforeReadonly')),
7130
7320
  __metadata("design:type", Function),
7131
7321
  __metadata("design:paramtypes", [Object]),
7132
7322
  __metadata("design:returntype", Object)
7133
- ], TaonBaseCrudController.prototype, "bulkCreate", null);
7134
- TaonBaseCrudController = __decorate([
7135
- TaonController({ className: 'TaonBaseCrudController' })
7136
- ], TaonBaseCrudController);
7137
-
7138
- class TaonBaseMigration extends TaonBaseInjector {
7139
- /**
7140
- * by default is READY to run
7141
- */
7142
- isReadyToRun() {
7143
- return true;
7144
- }
7145
- getDescription() {
7146
- return _.startCase(ClassHelpers.getName(this));
7147
- }
7148
- async up(queryRunner) {
7149
- console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers.getName(this)}"`);
7150
- }
7151
- async down(queryRunner) {
7152
- console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers.getName(this)}"`);
7153
- }
7154
- }
7323
+ ], TaonGlobalStateController.prototype, "setDraining", null);
7324
+ TaonGlobalStateController = __decorate([
7325
+ TaonController({
7326
+ className: 'TaonGlobalStateController',
7327
+ })
7328
+ ], TaonGlobalStateController);
7155
7329
 
7156
7330
  /**
7157
7331
  * TODO
@@ -7161,6 +7335,39 @@ class TaonBaseMigration extends TaonBaseInjector {
7161
7335
  class TaonBaseProvider extends TaonBaseInjector {
7162
7336
  }
7163
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
+
7164
7371
  /**
7165
7372
  * Subscriber decorator
7166
7373
  */
@@ -7317,6 +7524,75 @@ TaonBaseSubscriberForEntity = __decorate([
7317
7524
  })
7318
7525
  ], TaonBaseSubscriberForEntity);
7319
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
+
7320
7596
  //#region models / method config
7321
7597
  /**
7322
7598
  * @link './decorators/http/http-methods-decorators.ts' TaonHttpDecoratorOptions
@@ -7330,8 +7606,8 @@ class ParamConfig {
7330
7606
  }
7331
7607
 
7332
7608
  class FormlyHorizontalWrapper extends FieldWrapper {
7333
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FormlyHorizontalWrapper, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
7334
- 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: `
7335
7611
  <div class="form-group row">
7336
7612
  <label
7337
7613
  [attr.for]="id"
@@ -7348,7 +7624,7 @@ class FormlyHorizontalWrapper extends FieldWrapper {
7348
7624
  </div>
7349
7625
  `, isInline: true, styles: [":host{display:block;padding:5px;margin-bottom:5px;border:1px dotted gray}\n"] }); }
7350
7626
  }
7351
- 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: [{
7352
7628
  type: Component,
7353
7629
  args: [{ selector: 'formly-horizontal-wrapper', standalone: false, template: `
7354
7630
  <div class="form-group row">
@@ -7393,8 +7669,8 @@ class RepeatTypeComponent extends FieldArrayType {
7393
7669
  // @ts-ignore
7394
7670
  super(builder);
7395
7671
  }
7396
- 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 }); }
7397
- 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: `
7398
7674
  <div *ngIf="field.fieldGroup && field.fieldGroup.length === 0">
7399
7675
  Press button to add new element...
7400
7676
  </div>
@@ -7426,7 +7702,7 @@ class RepeatTypeComponent extends FieldArrayType {
7426
7702
  </div>
7427
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"] }); }
7428
7704
  }
7429
- 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: [{
7430
7706
  type: Component,
7431
7707
  args: [{ selector: 'formly-repeat-section', standalone: false, template: `
7432
7708
  <div *ngIf="field.fieldGroup && field.fieldGroup.length === 0">
@@ -7713,28 +7989,6 @@ function getFromlyConfigFor(target, options = {}) {
7713
7989
  return fields.filter(f => !!f);
7714
7990
  }
7715
7991
 
7716
- /**
7717
- * Entity decorator
7718
- */
7719
- function TaonEntity(options) {
7720
- return function (constructor) {
7721
- options = options || {};
7722
- options.uniqueKeyProp = options.uniqueKeyProp || 'id';
7723
- ClassHelpers.setName(constructor, options?.className);
7724
- Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
7725
- // TODO when entit metadata generator read use this
7726
- Mapping.DefaultModelWithMapping(void 0, {})(constructor);
7727
- Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
7728
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
7729
- //#region @websql
7730
- Entity(options?.className)(constructor);
7731
- //#endregion
7732
- CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
7733
- };
7734
- }
7735
- class TaonEntityOptions extends DecoratorAbstractOpt {
7736
- }
7737
-
7738
7992
  /**
7739
7993
  * Migration decorator
7740
7994
  */
@@ -7748,22 +8002,26 @@ function TaonMigration(options) {
7748
8002
  class TaonMigrationOptions extends DecoratorAbstractOpt {
7749
8003
  }
7750
8004
 
7751
- /**
7752
- * Provider decorator
7753
- */
7754
- function TaonProvider(options) {
7755
- return function (constructor) {
7756
- Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
7757
- Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
7758
- ClassHelpers.setName(constructor, options?.className || constructor.name);
7759
- };
7760
- }
7761
- class TaonProviderOptions extends DecoratorAbstractOpt {
7762
- }
7763
-
7764
8005
  // TODO export all things
7765
8006
  var Taon;
7766
8007
  (function (Taon) {
8008
+ /**
8009
+ * Remove global taon loader from env.ts [loading.preAngularBootstrap]
8010
+ */
8011
+ Taon.removeLoader = (afterMS = 0) => {
8012
+ return new Promise((resolve) => {
8013
+ setTimeout(() => {
8014
+ globalThis?.window?.document
8015
+ ?.getElementById('taonpreloadertoremove')
8016
+ ?.remove();
8017
+ const body = globalThis?.window?.document?.body;
8018
+ if (body && body.style) {
8019
+ body.style.backgroundColor = '';
8020
+ }
8021
+ resolve();
8022
+ }, afterMS);
8023
+ });
8024
+ };
7767
8025
  Taon.error = (opt) => {
7768
8026
  throw () => {
7769
8027
  if (typeof opt === 'string') {
@@ -7794,11 +8052,6 @@ var Taon;
7794
8052
  Taon.createContext = createContext;
7795
8053
  Taon.createContextTemplate = createContextTemplate;
7796
8054
  Taon.inject = inject;
7797
- //#region @browser
7798
- Taon.initNgZone = (ngZone) => {
7799
- EndpointContext.initNgZone(ngZone);
7800
- };
7801
- //#endregion
7802
8055
  Taon.symbols = Symbols;
7803
8056
  /**
7804
8057
  * @deprecated
@@ -7933,7 +8186,7 @@ const TAON_FLATTEN_MAPPING = {
7933
8186
  // Optional: if your old code had Stor.proper... (typo)
7934
8187
  'Stor.proper.in.localstorage': 'StorPropertyInLocalStorage',
7935
8188
  'Stor.proper.in.indexedb': 'StorPropertyInIndexedDb',
7936
- }
8189
+ },
7937
8190
  };
7938
8191
  //#endregion
7939
8192
 
@@ -7941,5 +8194,5 @@ const TAON_FLATTEN_MAPPING = {
7941
8194
  * Generated bundle index. Do not edit.
7942
8195
  */
7943
8196
 
7944
- 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 };
7945
8198
  //# sourceMappingURL=taon-websql.mjs.map