taon 0.0.0 → 18.0.12

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 (668) hide show
  1. package/README.md +115 -0
  2. package/assets/shared/shared_folder_info.txt +7 -0
  3. package/bin/start.js +279 -0
  4. package/bin/taon +2 -1
  5. package/bin/taon-debug +2 -2
  6. package/bin/taon-debug-brk +3 -2
  7. package/browser/README.md +24 -0
  8. package/browser/esm2022/lib/base-classes/base-abstract-entity.mjs +18 -0
  9. package/browser/esm2022/lib/base-classes/base-class.mjs +17 -0
  10. package/browser/esm2022/lib/base-classes/base-context.mjs +14 -0
  11. package/browser/esm2022/lib/base-classes/base-controller.mjs +18 -0
  12. package/browser/esm2022/lib/base-classes/base-crud-controller.mjs +279 -0
  13. package/browser/esm2022/lib/base-classes/base-entity.mjs +18 -0
  14. package/browser/esm2022/lib/base-classes/base-injector.mjs +160 -0
  15. package/browser/esm2022/lib/base-classes/base-provider.mjs +6 -0
  16. package/browser/esm2022/lib/base-classes/base-repository.mjs +514 -0
  17. package/browser/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
  18. package/browser/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
  19. package/browser/esm2022/lib/base-classes/base.mjs +26 -0
  20. package/browser/esm2022/lib/constants.mjs +4 -0
  21. package/browser/esm2022/lib/create-context.mjs +87 -0
  22. package/browser/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
  23. package/browser/esm2022/lib/decorators/classes/entity-decorator.mjs +27 -0
  24. package/browser/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
  25. package/browser/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
  26. package/browser/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
  27. package/browser/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
  28. package/browser/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
  29. package/browser/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
  30. package/browser/esm2022/lib/dependency-injection/di-container.mjs +32 -0
  31. package/browser/esm2022/lib/endpoint-context.mjs +1746 -0
  32. package/browser/esm2022/lib/entity-process.mjs +207 -0
  33. package/browser/esm2022/lib/env.mjs +6 -0
  34. package/browser/esm2022/lib/get-response-value.mjs +41 -0
  35. package/browser/esm2022/lib/helpers/class-helpers.mjs +183 -0
  36. package/browser/esm2022/lib/helpers/taon-helpers.mjs +120 -0
  37. package/browser/esm2022/lib/index.mjs +79 -0
  38. package/browser/esm2022/lib/inject.mjs +70 -0
  39. package/browser/esm2022/lib/models.mjs +77 -0
  40. package/browser/esm2022/lib/orm.mjs +6 -0
  41. package/browser/esm2022/lib/realtime/realtime-client.mjs +129 -0
  42. package/browser/esm2022/lib/realtime/realtime-core.mjs +54 -0
  43. package/browser/esm2022/lib/realtime/realtime-server.mjs +274 -0
  44. package/browser/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
  45. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
  46. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
  47. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
  48. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
  49. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
  50. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +49 -0
  51. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
  52. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
  53. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
  54. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
  55. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
  56. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
  57. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
  58. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
  59. package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
  60. package/browser/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
  61. package/browser/esm2022/lib/realtime/realtime.models.mjs +4 -0
  62. package/browser/esm2022/lib/storage.mjs +5 -0
  63. package/browser/esm2022/lib/symbols.mjs +89 -0
  64. package/browser/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
  65. package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
  66. package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
  67. package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
  68. package/browser/esm2022/lib/validators.mjs +76 -0
  69. package/browser/esm2022/public-api.mjs +2 -0
  70. package/browser/esm2022/taon.mjs +5 -0
  71. package/browser/fesm2022/taon.mjs +4901 -0
  72. package/browser/fesm2022/taon.mjs.map +1 -0
  73. package/browser/index.d.ts +6 -0
  74. package/browser/lib/base-classes/base-abstract-entity.d.ts +7 -0
  75. package/browser/lib/base-classes/base-class.d.ts +9 -0
  76. package/browser/lib/base-classes/base-context.d.ts +17 -0
  77. package/browser/lib/base-classes/base-controller.d.ts +8 -0
  78. package/browser/lib/base-classes/base-crud-controller.d.ts +28 -0
  79. package/browser/lib/base-classes/base-entity.d.ts +8 -0
  80. package/browser/lib/base-classes/base-injector.d.ts +60 -0
  81. package/browser/lib/base-classes/base-provider.d.ts +4 -0
  82. package/browser/lib/base-classes/base-repository.d.ts +249 -0
  83. package/browser/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
  84. package/browser/lib/base-classes/base-subscriber.d.ts +5 -0
  85. package/browser/lib/base-classes/base.d.ts +36 -0
  86. package/browser/lib/constants.d.ts +2 -0
  87. package/browser/lib/create-context.d.ts +25 -0
  88. package/browser/lib/decorators/classes/controller-decorator.d.ts +13 -0
  89. package/browser/lib/decorators/classes/entity-decorator.d.ts +17 -0
  90. package/browser/lib/decorators/classes/provider-decorator.d.ts +5 -0
  91. package/browser/lib/decorators/classes/repository-decorator.d.ts +5 -0
  92. package/browser/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
  93. package/browser/lib/decorators/http/http-decorators.d.ts +18 -0
  94. package/browser/lib/decorators/http/http-methods-decorators.d.ts +15 -0
  95. package/browser/lib/decorators/http/http-params-decorators.d.ts +6 -0
  96. package/browser/lib/dependency-injection/di-container.d.ts +6 -0
  97. package/browser/lib/endpoint-context.d.ts +117 -0
  98. package/browser/lib/entity-process.d.ts +40 -0
  99. package/browser/lib/env.d.ts +3 -0
  100. package/browser/lib/get-response-value.d.ts +7 -0
  101. package/browser/lib/helpers/class-helpers.d.ts +19 -0
  102. package/browser/lib/helpers/taon-helpers.d.ts +17 -0
  103. package/browser/lib/index.d.ts +113 -0
  104. package/browser/lib/inject.d.ts +9 -0
  105. package/browser/lib/models.d.ts +175 -0
  106. package/browser/lib/orm.d.ts +3 -0
  107. package/browser/lib/realtime/realtime-client.d.ts +32 -0
  108. package/browser/lib/realtime/realtime-core.d.ts +41 -0
  109. package/browser/lib/realtime/realtime-server.d.ts +14 -0
  110. package/browser/lib/realtime/realtime-strategy/index.d.ts +5 -0
  111. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
  112. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
  113. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
  114. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
  115. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
  116. package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
  117. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
  118. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
  119. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
  120. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
  121. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
  122. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
  123. package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
  124. package/browser/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
  125. package/browser/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
  126. package/browser/lib/realtime/realtime-subs-manager.d.ts +15 -0
  127. package/browser/lib/realtime/realtime.models.d.ts +14 -0
  128. package/browser/lib/storage.d.ts +2 -0
  129. package/browser/lib/symbols.d.ts +73 -0
  130. package/browser/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
  131. package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
  132. package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
  133. package/browser/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
  134. package/browser/lib/validators.d.ts +8 -0
  135. package/browser/package.json +25 -0
  136. package/browser/public-api.d.ts +2 -0
  137. package/cli.d.ts +1 -0
  138. package/cli.js +24 -0
  139. package/cli.js.map +1 -0
  140. package/client/README.md +24 -0
  141. package/client/esm2022/lib/base-classes/base-abstract-entity.mjs +18 -0
  142. package/client/esm2022/lib/base-classes/base-class.mjs +17 -0
  143. package/client/esm2022/lib/base-classes/base-context.mjs +14 -0
  144. package/client/esm2022/lib/base-classes/base-controller.mjs +18 -0
  145. package/client/esm2022/lib/base-classes/base-crud-controller.mjs +279 -0
  146. package/client/esm2022/lib/base-classes/base-entity.mjs +18 -0
  147. package/client/esm2022/lib/base-classes/base-injector.mjs +160 -0
  148. package/client/esm2022/lib/base-classes/base-provider.mjs +6 -0
  149. package/client/esm2022/lib/base-classes/base-repository.mjs +514 -0
  150. package/client/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
  151. package/client/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
  152. package/client/esm2022/lib/base-classes/base.mjs +26 -0
  153. package/client/esm2022/lib/constants.mjs +4 -0
  154. package/client/esm2022/lib/create-context.mjs +87 -0
  155. package/client/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
  156. package/client/esm2022/lib/decorators/classes/entity-decorator.mjs +27 -0
  157. package/client/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
  158. package/client/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
  159. package/client/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
  160. package/client/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
  161. package/client/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
  162. package/client/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
  163. package/client/esm2022/lib/dependency-injection/di-container.mjs +32 -0
  164. package/client/esm2022/lib/endpoint-context.mjs +1746 -0
  165. package/client/esm2022/lib/entity-process.mjs +207 -0
  166. package/client/esm2022/lib/env.mjs +6 -0
  167. package/client/esm2022/lib/get-response-value.mjs +41 -0
  168. package/client/esm2022/lib/helpers/class-helpers.mjs +183 -0
  169. package/client/esm2022/lib/helpers/taon-helpers.mjs +120 -0
  170. package/client/esm2022/lib/index.mjs +79 -0
  171. package/client/esm2022/lib/inject.mjs +70 -0
  172. package/client/esm2022/lib/models.mjs +77 -0
  173. package/client/esm2022/lib/orm.mjs +6 -0
  174. package/client/esm2022/lib/realtime/realtime-client.mjs +129 -0
  175. package/client/esm2022/lib/realtime/realtime-core.mjs +54 -0
  176. package/client/esm2022/lib/realtime/realtime-server.mjs +274 -0
  177. package/client/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
  178. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
  179. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
  180. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
  181. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
  182. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
  183. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +49 -0
  184. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
  185. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
  186. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
  187. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
  188. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
  189. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
  190. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
  191. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
  192. package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
  193. package/client/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
  194. package/client/esm2022/lib/realtime/realtime.models.mjs +4 -0
  195. package/client/esm2022/lib/storage.mjs +5 -0
  196. package/client/esm2022/lib/symbols.mjs +89 -0
  197. package/client/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
  198. package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
  199. package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
  200. package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
  201. package/client/esm2022/lib/validators.mjs +76 -0
  202. package/client/esm2022/public-api.mjs +2 -0
  203. package/client/esm2022/taon.mjs +5 -0
  204. package/client/fesm2022/taon.mjs +4901 -0
  205. package/client/fesm2022/taon.mjs.map +1 -0
  206. package/client/index.d.ts +6 -0
  207. package/client/lib/base-classes/base-abstract-entity.d.ts +7 -0
  208. package/client/lib/base-classes/base-class.d.ts +9 -0
  209. package/client/lib/base-classes/base-context.d.ts +17 -0
  210. package/client/lib/base-classes/base-controller.d.ts +8 -0
  211. package/client/lib/base-classes/base-crud-controller.d.ts +28 -0
  212. package/client/lib/base-classes/base-entity.d.ts +8 -0
  213. package/client/lib/base-classes/base-injector.d.ts +60 -0
  214. package/client/lib/base-classes/base-provider.d.ts +4 -0
  215. package/client/lib/base-classes/base-repository.d.ts +249 -0
  216. package/client/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
  217. package/client/lib/base-classes/base-subscriber.d.ts +5 -0
  218. package/client/lib/base-classes/base.d.ts +36 -0
  219. package/client/lib/constants.d.ts +2 -0
  220. package/client/lib/create-context.d.ts +25 -0
  221. package/client/lib/decorators/classes/controller-decorator.d.ts +13 -0
  222. package/client/lib/decorators/classes/entity-decorator.d.ts +17 -0
  223. package/client/lib/decorators/classes/provider-decorator.d.ts +5 -0
  224. package/client/lib/decorators/classes/repository-decorator.d.ts +5 -0
  225. package/client/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
  226. package/client/lib/decorators/http/http-decorators.d.ts +18 -0
  227. package/client/lib/decorators/http/http-methods-decorators.d.ts +15 -0
  228. package/client/lib/decorators/http/http-params-decorators.d.ts +6 -0
  229. package/client/lib/dependency-injection/di-container.d.ts +6 -0
  230. package/client/lib/endpoint-context.d.ts +117 -0
  231. package/client/lib/entity-process.d.ts +40 -0
  232. package/client/lib/env.d.ts +3 -0
  233. package/client/lib/get-response-value.d.ts +7 -0
  234. package/client/lib/helpers/class-helpers.d.ts +19 -0
  235. package/client/lib/helpers/taon-helpers.d.ts +17 -0
  236. package/client/lib/index.d.ts +113 -0
  237. package/client/lib/inject.d.ts +9 -0
  238. package/client/lib/models.d.ts +175 -0
  239. package/client/lib/orm.d.ts +3 -0
  240. package/client/lib/realtime/realtime-client.d.ts +32 -0
  241. package/client/lib/realtime/realtime-core.d.ts +41 -0
  242. package/client/lib/realtime/realtime-server.d.ts +14 -0
  243. package/client/lib/realtime/realtime-strategy/index.d.ts +5 -0
  244. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
  245. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
  246. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
  247. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
  248. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
  249. package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
  250. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
  251. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
  252. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
  253. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
  254. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
  255. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
  256. package/client/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
  257. package/client/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
  258. package/client/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
  259. package/client/lib/realtime/realtime-subs-manager.d.ts +15 -0
  260. package/client/lib/realtime/realtime.models.d.ts +14 -0
  261. package/client/lib/storage.d.ts +2 -0
  262. package/client/lib/symbols.d.ts +73 -0
  263. package/client/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
  264. package/client/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
  265. package/client/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
  266. package/client/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
  267. package/client/lib/validators.d.ts +8 -0
  268. package/client/public-api.d.ts +2 -0
  269. package/index.d.ts +1 -0
  270. package/index.js +5 -1
  271. package/index.js.map +1 -0
  272. package/lib/base-classes/base-abstract-entity.d.ts +6 -0
  273. package/lib/base-classes/base-abstract-entity.js +40 -0
  274. package/lib/base-classes/base-abstract-entity.js.map +1 -0
  275. package/lib/base-classes/base-class.d.ts +8 -0
  276. package/lib/base-classes/base-class.js +35 -0
  277. package/lib/base-classes/base-class.js.map +1 -0
  278. package/lib/base-classes/base-context.d.ts +16 -0
  279. package/lib/base-classes/base-context.js +15 -0
  280. package/lib/base-classes/base-context.js.map +1 -0
  281. package/lib/base-classes/base-controller.d.ts +7 -0
  282. package/lib/base-classes/base-controller.js +24 -0
  283. package/lib/base-classes/base-controller.js.map +1 -0
  284. package/lib/base-classes/base-crud-controller.d.ts +27 -0
  285. package/lib/base-classes/base-crud-controller.js +385 -0
  286. package/lib/base-classes/base-crud-controller.js.map +1 -0
  287. package/lib/base-classes/base-entity.d.ts +7 -0
  288. package/lib/base-classes/base-entity.js +25 -0
  289. package/lib/base-classes/base-entity.js.map +1 -0
  290. package/lib/base-classes/base-injector.d.ts +59 -0
  291. package/lib/base-classes/base-injector.js +220 -0
  292. package/lib/base-classes/base-injector.js.map +1 -0
  293. package/lib/base-classes/base-provider.d.ts +3 -0
  294. package/lib/base-classes/base-provider.js +14 -0
  295. package/lib/base-classes/base-provider.js.map +1 -0
  296. package/lib/base-classes/base-repository.d.ts +254 -0
  297. package/lib/base-classes/base-repository.js +780 -0
  298. package/lib/base-classes/base-repository.js.map +1 -0
  299. package/lib/base-classes/base-subscriber-for-entity.d.ts +81 -0
  300. package/lib/base-classes/base-subscriber-for-entity.js +136 -0
  301. package/lib/base-classes/base-subscriber-for-entity.js.map +1 -0
  302. package/lib/base-classes/base-subscriber.d.ts +4 -0
  303. package/lib/base-classes/base-subscriber.js +25 -0
  304. package/lib/base-classes/base-subscriber.js.map +1 -0
  305. package/lib/base-classes/base.d.ts +35 -0
  306. package/lib/base-classes/base.js +27 -0
  307. package/lib/base-classes/base.js.map +1 -0
  308. package/lib/build-info._auto-generated_.d.ts +1 -0
  309. package/lib/build-info._auto-generated_.js +5 -0
  310. package/lib/build-info._auto-generated_.js.map +1 -0
  311. package/lib/constants.d.ts +1 -0
  312. package/lib/constants.js +3 -0
  313. package/lib/constants.js.map +1 -0
  314. package/lib/create-context.d.ts +24 -0
  315. package/lib/create-context.js +183 -0
  316. package/lib/create-context.js.map +1 -0
  317. package/lib/decorators/classes/controller-decorator.d.ts +12 -0
  318. package/lib/decorators/classes/controller-decorator.js +24 -0
  319. package/lib/decorators/classes/controller-decorator.js.map +1 -0
  320. package/lib/decorators/classes/entity-decorator.d.ts +16 -0
  321. package/lib/decorators/classes/entity-decorator.js +39 -0
  322. package/lib/decorators/classes/entity-decorator.js.map +1 -0
  323. package/lib/decorators/classes/provider-decorator.d.ts +4 -0
  324. package/lib/decorators/classes/provider-decorator.js +24 -0
  325. package/lib/decorators/classes/provider-decorator.js.map +1 -0
  326. package/lib/decorators/classes/repository-decorator.d.ts +4 -0
  327. package/lib/decorators/classes/repository-decorator.js +24 -0
  328. package/lib/decorators/classes/repository-decorator.js.map +1 -0
  329. package/lib/decorators/classes/subscriber-decorator.d.ts +5 -0
  330. package/lib/decorators/classes/subscriber-decorator.js +75 -0
  331. package/lib/decorators/classes/subscriber-decorator.js.map +1 -0
  332. package/lib/decorators/http/http-decorators.d.ts +17 -0
  333. package/lib/decorators/http/http-decorators.js +23 -0
  334. package/lib/decorators/http/http-decorators.js.map +1 -0
  335. package/lib/decorators/http/http-methods-decorators.d.ts +14 -0
  336. package/lib/decorators/http/http-methods-decorators.js +91 -0
  337. package/lib/decorators/http/http-methods-decorators.js.map +1 -0
  338. package/lib/decorators/http/http-params-decorators.d.ts +5 -0
  339. package/lib/decorators/http/http-params-decorators.js +55 -0
  340. package/lib/decorators/http/http-params-decorators.js.map +1 -0
  341. package/lib/dependency-injection/di-container.d.ts +5 -0
  342. package/lib/dependency-injection/di-container.js +40 -0
  343. package/lib/dependency-injection/di-container.js.map +1 -0
  344. package/lib/endpoint-context.d.ts +117 -0
  345. package/lib/endpoint-context.js +2128 -0
  346. package/lib/endpoint-context.js.map +1 -0
  347. package/lib/entity-process.d.ts +39 -0
  348. package/lib/entity-process.js +261 -0
  349. package/lib/entity-process.js.map +1 -0
  350. package/lib/env.d.ts +2 -0
  351. package/lib/env.js +7 -0
  352. package/lib/env.js.map +1 -0
  353. package/lib/formly/formly-group-wrapper-component.d.ts +5 -0
  354. package/lib/formly/formly-group-wrapper-component.js +28 -0
  355. package/lib/formly/formly-group-wrapper-component.js.map +1 -0
  356. package/lib/formly/formly-repeat-component.d.ts +5 -0
  357. package/lib/formly/formly-repeat-component.js +47 -0
  358. package/lib/formly/formly-repeat-component.js.map +1 -0
  359. package/lib/formly/formly.models.d.ts +1 -0
  360. package/lib/formly/formly.models.js +3 -0
  361. package/lib/formly/formly.models.js.map +1 -0
  362. package/lib/formly/fromly.d.ts +16 -0
  363. package/lib/formly/fromly.js +213 -0
  364. package/lib/formly/fromly.js.map +1 -0
  365. package/lib/formly/type-from-entity.d.ts +20 -0
  366. package/lib/formly/type-from-entity.js +65 -0
  367. package/lib/formly/type-from-entity.js.map +1 -0
  368. package/lib/get-response-value.d.ts +6 -0
  369. package/lib/get-response-value.js +65 -0
  370. package/lib/get-response-value.js.map +1 -0
  371. package/lib/helpers/class-helpers.d.ts +18 -0
  372. package/lib/helpers/class-helpers.js +227 -0
  373. package/lib/helpers/class-helpers.js.map +1 -0
  374. package/lib/helpers/taon-helpers.d.ts +16 -0
  375. package/lib/helpers/taon-helpers.js +144 -0
  376. package/lib/helpers/taon-helpers.js.map +1 -0
  377. package/lib/index.d.ts +112 -0
  378. package/lib/index.js +113 -0
  379. package/lib/index.js.map +1 -0
  380. package/lib/inject.d.ts +8 -0
  381. package/lib/inject.js +84 -0
  382. package/lib/inject.js.map +1 -0
  383. package/lib/models.d.ts +180 -0
  384. package/lib/models.js +107 -0
  385. package/lib/models.js.map +1 -0
  386. package/lib/orm.d.ts +51 -0
  387. package/lib/orm.js +79 -0
  388. package/lib/orm.js.map +1 -0
  389. package/lib/realtime/realtime-client.d.ts +31 -0
  390. package/lib/realtime/realtime-client.js +158 -0
  391. package/lib/realtime/realtime-client.js.map +1 -0
  392. package/lib/realtime/realtime-core.d.ts +40 -0
  393. package/lib/realtime/realtime-core.js +72 -0
  394. package/lib/realtime/realtime-core.js.map +1 -0
  395. package/lib/realtime/realtime-server.d.ts +13 -0
  396. package/lib/realtime/realtime-server.js +193 -0
  397. package/lib/realtime/realtime-server.js.map +1 -0
  398. package/lib/realtime/realtime-strategy/index.d.ts +4 -0
  399. package/lib/realtime/realtime-strategy/index.js +8 -0
  400. package/lib/realtime/realtime-strategy/index.js.map +1 -0
  401. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
  402. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +5 -0
  403. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +1 -0
  404. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
  405. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +139 -0
  406. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +1 -0
  407. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +16 -0
  408. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +68 -0
  409. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +1 -0
  410. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +10 -0
  411. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +56 -0
  412. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +1 -0
  413. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +10 -0
  414. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +50 -0
  415. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +1 -0
  416. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +13 -0
  417. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +3 -0
  418. package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +1 -0
  419. package/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +22 -0
  420. package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js +68 -0
  421. package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -0
  422. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +2 -0
  423. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +6 -0
  424. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +1 -0
  425. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +16 -0
  426. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +54 -0
  427. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +1 -0
  428. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +17 -0
  429. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +52 -0
  430. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +1 -0
  431. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +11 -0
  432. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +39 -0
  433. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +1 -0
  434. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +13 -0
  435. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +46 -0
  436. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +1 -0
  437. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +11 -0
  438. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +3 -0
  439. package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +1 -0
  440. package/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +14 -0
  441. package/lib/realtime/realtime-strategy/realtime-strategy-mock.js +42 -0
  442. package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -0
  443. package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
  444. package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js +48 -0
  445. package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -0
  446. package/lib/realtime/realtime-strategy/realtime-strategy.d.ts +12 -0
  447. package/lib/realtime/realtime-strategy/realtime-strategy.js +14 -0
  448. package/lib/realtime/realtime-strategy/realtime-strategy.js.map +1 -0
  449. package/lib/realtime/realtime-subs-manager.d.ts +14 -0
  450. package/lib/realtime/realtime-subs-manager.js +102 -0
  451. package/lib/realtime/realtime-subs-manager.js.map +1 -0
  452. package/lib/realtime/realtime.models.d.ts +13 -0
  453. package/lib/realtime/realtime.models.js +3 -0
  454. package/lib/realtime/realtime.models.js.map +1 -0
  455. package/lib/storage.d.ts +1 -0
  456. package/lib/storage.js +6 -0
  457. package/lib/storage.js.map +1 -0
  458. package/lib/symbols.d.ts +72 -0
  459. package/lib/symbols.js +91 -0
  460. package/lib/symbols.js.map +1 -0
  461. package/lib/ui/directives/firedev-inject-html.directive.d.ts +6 -0
  462. package/lib/ui/directives/firedev-long-press.directive.d.ts +22 -0
  463. package/lib/ui/directives/index.d.ts +4 -0
  464. package/lib/ui/directives/index.js +5 -0
  465. package/lib/ui/directives/index.js.map +1 -0
  466. package/lib/ui/directives/safe.pipe.d.ts +7 -0
  467. package/lib/ui/directives/view-mode.d.ts +5 -0
  468. package/lib/ui/directives/view-mode.js +10 -0
  469. package/lib/ui/directives/view-mode.js.map +1 -0
  470. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +2 -0
  471. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +5 -0
  472. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +1 -0
  473. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +31 -0
  474. package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +2 -0
  475. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +1 -0
  476. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +5 -0
  477. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +1 -0
  478. package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +9 -0
  479. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +2 -0
  480. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +5 -0
  481. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +1 -0
  482. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +14 -0
  483. package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +2 -0
  484. package/lib/ui/taon-admin-mode-configuration/index.d.ts +4 -0
  485. package/lib/ui/taon-admin-mode-configuration/index.js +5 -0
  486. package/lib/ui/taon-admin-mode-configuration/index.js.map +1 -0
  487. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +5 -0
  488. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +3 -0
  489. package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +1 -0
  490. package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +14 -0
  491. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +47 -0
  492. package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +2 -0
  493. package/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +21 -0
  494. package/lib/ui/taon-github-fork-me-corner/index.d.ts +2 -0
  495. package/lib/ui/taon-github-fork-me-corner/index.js +5 -0
  496. package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -0
  497. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +3 -0
  498. package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +2 -0
  499. package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +2 -0
  500. package/lib/ui/taon-github-fork-me-ribbon/index.js +5 -0
  501. package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -0
  502. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +3 -0
  503. package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +2 -0
  504. package/lib/ui/taon-notifications/index.d.ts +4 -0
  505. package/lib/ui/taon-notifications/index.js +11 -0
  506. package/lib/ui/taon-notifications/index.js.map +1 -0
  507. package/lib/ui/taon-notifications/taon-notifications.component.d.ts +9 -0
  508. package/lib/ui/taon-notifications/taon-notifications.models.d.ts +6 -0
  509. package/lib/ui/taon-notifications/taon-notifications.models.js +5 -0
  510. package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -0
  511. package/lib/ui/taon-notifications/taon-notifications.module.d.ts +2 -0
  512. package/lib/ui/taon-notifications/taon-notifications.service.d.ts +11 -0
  513. package/lib/ui/taon-progress-bar/index.d.ts +2 -0
  514. package/lib/ui/taon-progress-bar/index.js +5 -0
  515. package/lib/ui/taon-progress-bar/index.js.map +1 -0
  516. package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +14 -0
  517. package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +2 -0
  518. package/lib/ui/taon-session-passcode/index.d.ts +1 -0
  519. package/lib/ui/taon-session-passcode/index.js +5 -0
  520. package/lib/ui/taon-session-passcode/index.js.map +1 -0
  521. package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +35 -0
  522. package/lib/ui/taon.models.d.ts +11 -0
  523. package/lib/ui/taon.models.js +3 -0
  524. package/lib/ui/taon.models.js.map +1 -0
  525. package/lib/ui/toan-full-material.module.d.ts +2 -0
  526. package/lib/validators.d.ts +7 -0
  527. package/lib/validators.js +53 -0
  528. package/lib/validators.js.map +1 -0
  529. package/old-app .d.ts +0 -0
  530. package/old-app .js +115 -0
  531. package/old-app .js.map +1 -0
  532. package/package.json +74 -11
  533. package/playground.d.ts +0 -0
  534. package/playground.js +172 -0
  535. package/playground.js.map +1 -0
  536. package/src.d.ts +6 -0
  537. package/taon.jsonc +48 -0
  538. package/tmp-environment.json +393 -0
  539. package/websql/README.md +24 -0
  540. package/websql/esm2022/lib/base-classes/base-abstract-entity.mjs +25 -0
  541. package/websql/esm2022/lib/base-classes/base-class.mjs +17 -0
  542. package/websql/esm2022/lib/base-classes/base-context.mjs +14 -0
  543. package/websql/esm2022/lib/base-classes/base-controller.mjs +18 -0
  544. package/websql/esm2022/lib/base-classes/base-crud-controller.mjs +238 -0
  545. package/websql/esm2022/lib/base-classes/base-entity.mjs +16 -0
  546. package/websql/esm2022/lib/base-classes/base-injector.mjs +160 -0
  547. package/websql/esm2022/lib/base-classes/base-provider.mjs +6 -0
  548. package/websql/esm2022/lib/base-classes/base-repository.mjs +431 -0
  549. package/websql/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
  550. package/websql/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
  551. package/websql/esm2022/lib/base-classes/base.mjs +26 -0
  552. package/websql/esm2022/lib/constants.mjs +4 -0
  553. package/websql/esm2022/lib/create-context.mjs +86 -0
  554. package/websql/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
  555. package/websql/esm2022/lib/decorators/classes/entity-decorator.mjs +25 -0
  556. package/websql/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
  557. package/websql/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
  558. package/websql/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
  559. package/websql/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
  560. package/websql/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
  561. package/websql/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
  562. package/websql/esm2022/lib/dependency-injection/di-container.mjs +32 -0
  563. package/websql/esm2022/lib/endpoint-context.mjs +1506 -0
  564. package/websql/esm2022/lib/entity-process.mjs +207 -0
  565. package/websql/esm2022/lib/env.mjs +6 -0
  566. package/websql/esm2022/lib/get-response-value.mjs +45 -0
  567. package/websql/esm2022/lib/helpers/class-helpers.mjs +183 -0
  568. package/websql/esm2022/lib/helpers/taon-helpers.mjs +120 -0
  569. package/websql/esm2022/lib/index.mjs +81 -0
  570. package/websql/esm2022/lib/inject.mjs +70 -0
  571. package/websql/esm2022/lib/models.mjs +70 -0
  572. package/websql/esm2022/lib/orm.mjs +60 -0
  573. package/websql/esm2022/lib/realtime/realtime-client.mjs +129 -0
  574. package/websql/esm2022/lib/realtime/realtime-core.mjs +54 -0
  575. package/websql/esm2022/lib/realtime/realtime-server.mjs +158 -0
  576. package/websql/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
  577. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
  578. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
  579. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
  580. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
  581. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
  582. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +48 -0
  583. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
  584. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
  585. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
  586. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
  587. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
  588. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
  589. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
  590. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
  591. package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
  592. package/websql/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
  593. package/websql/esm2022/lib/realtime/realtime.models.mjs +4 -0
  594. package/websql/esm2022/lib/storage.mjs +5 -0
  595. package/websql/esm2022/lib/symbols.mjs +89 -0
  596. package/websql/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
  597. package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
  598. package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
  599. package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
  600. package/websql/esm2022/lib/validators.mjs +76 -0
  601. package/websql/esm2022/public-api.mjs +2 -0
  602. package/websql/esm2022/taon.mjs +5 -0
  603. package/websql/fesm2022/taon.mjs +4595 -0
  604. package/websql/fesm2022/taon.mjs.map +1 -0
  605. package/websql/index.d.ts +6 -0
  606. package/websql/lib/base-classes/base-abstract-entity.d.ts +7 -0
  607. package/websql/lib/base-classes/base-class.d.ts +9 -0
  608. package/websql/lib/base-classes/base-context.d.ts +17 -0
  609. package/websql/lib/base-classes/base-controller.d.ts +8 -0
  610. package/websql/lib/base-classes/base-crud-controller.d.ts +28 -0
  611. package/websql/lib/base-classes/base-entity.d.ts +8 -0
  612. package/websql/lib/base-classes/base-injector.d.ts +60 -0
  613. package/websql/lib/base-classes/base-provider.d.ts +4 -0
  614. package/websql/lib/base-classes/base-repository.d.ts +255 -0
  615. package/websql/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
  616. package/websql/lib/base-classes/base-subscriber.d.ts +5 -0
  617. package/websql/lib/base-classes/base.d.ts +36 -0
  618. package/websql/lib/constants.d.ts +2 -0
  619. package/websql/lib/create-context.d.ts +25 -0
  620. package/websql/lib/decorators/classes/controller-decorator.d.ts +13 -0
  621. package/websql/lib/decorators/classes/entity-decorator.d.ts +17 -0
  622. package/websql/lib/decorators/classes/provider-decorator.d.ts +5 -0
  623. package/websql/lib/decorators/classes/repository-decorator.d.ts +5 -0
  624. package/websql/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
  625. package/websql/lib/decorators/http/http-decorators.d.ts +18 -0
  626. package/websql/lib/decorators/http/http-methods-decorators.d.ts +15 -0
  627. package/websql/lib/decorators/http/http-params-decorators.d.ts +6 -0
  628. package/websql/lib/dependency-injection/di-container.d.ts +6 -0
  629. package/websql/lib/endpoint-context.d.ts +117 -0
  630. package/websql/lib/entity-process.d.ts +40 -0
  631. package/websql/lib/env.d.ts +3 -0
  632. package/websql/lib/get-response-value.d.ts +7 -0
  633. package/websql/lib/helpers/class-helpers.d.ts +19 -0
  634. package/websql/lib/helpers/taon-helpers.d.ts +17 -0
  635. package/websql/lib/index.d.ts +113 -0
  636. package/websql/lib/inject.d.ts +9 -0
  637. package/websql/lib/models.d.ts +181 -0
  638. package/websql/lib/orm.d.ts +52 -0
  639. package/websql/lib/realtime/realtime-client.d.ts +32 -0
  640. package/websql/lib/realtime/realtime-core.d.ts +41 -0
  641. package/websql/lib/realtime/realtime-server.d.ts +14 -0
  642. package/websql/lib/realtime/realtime-strategy/index.d.ts +5 -0
  643. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
  644. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
  645. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
  646. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
  647. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
  648. package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
  649. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
  650. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
  651. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
  652. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
  653. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
  654. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
  655. package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
  656. package/websql/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
  657. package/websql/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
  658. package/websql/lib/realtime/realtime-subs-manager.d.ts +15 -0
  659. package/websql/lib/realtime/realtime.models.d.ts +14 -0
  660. package/websql/lib/storage.d.ts +2 -0
  661. package/websql/lib/symbols.d.ts +73 -0
  662. package/websql/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
  663. package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
  664. package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
  665. package/websql/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
  666. package/websql/lib/validators.d.ts +8 -0
  667. package/websql/package.json +25 -0
  668. package/websql/public-api.d.ts +2 -0
@@ -0,0 +1,4595 @@
1
+ import 'reflect-metadata';
2
+ import * as coreHelpers from 'tnp-core/websql';
3
+ import { _, Helpers, path } from 'tnp-core/websql';
4
+ import { Models as Models$1, RestHeaders, Resource, Mapping } from 'ng2-rest/websql';
5
+ import * as tsorm from 'taon-typeorm/websql';
6
+ import { OrignalClassKey, Entity, EventSubscriber, DataSource } from 'taon-typeorm/websql';
7
+ import { SYMBOL, CLASS } from 'typescript-class-helpers/websql';
8
+ import * as JSON5 from 'json5';
9
+ import { __decorate, __param, __metadata } from 'tslib';
10
+ import { MySqlQuerySource } from 'taon-type-sql/websql';
11
+ import { Stor } from 'taon-storage/websql';
12
+ import { Subject, Observable, from } from 'rxjs';
13
+ import { config } from 'tnp-config/websql';
14
+ import * as i0 from '@angular/core';
15
+ import { Injectable, inject as inject$1 } from '@angular/core';
16
+ import { JSON10 } from 'json10/websql';
17
+ import axios from 'axios';
18
+ import { io } from 'socket.io-client';
19
+
20
+ var Symbols;
21
+ (function (Symbols) {
22
+ Symbols.ctxInClassOrClassObj = Symbol();
23
+ Symbols.classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
24
+ Symbols.fullClassNameStaticProperty = `$$fullclassName$$`;
25
+ Symbols.orignalClass = OrignalClassKey;
26
+ Symbols.orignalClassClonesObj = `$$originalClassClonesObj$$`;
27
+ Symbols.classMethodsNames = `$$classMethodsNames$$`;
28
+ Symbols.REALTIME = {
29
+ NAMESPACE: (contextName) => `${contextName}:taonRealtimeNsp`,
30
+ TABLE_CHANGE(contextName, tableName) {
31
+ return `${contextName}:listentablename${tableName}`;
32
+ },
33
+ /**
34
+ * for backendSocket.in(ROOM_NAME).emit(EVENT)
35
+ *
36
+ * Room names are uniqe..
37
+ * here I am limiting number of event for clients.
38
+ */
39
+ ROOM_NAME: {
40
+ CUSTOM(contextName, customEvent) {
41
+ return `${contextName}:roomcustomevnet${customEvent}`;
42
+ },
43
+ /**
44
+ * @LAST TODO
45
+ */
46
+ SUBSCRIBER_EVENT(contextName, className, propertyName) {
47
+ return `${contextName}:room${_.camelCase(className)}${propertyName}`.toLowerCase();
48
+ },
49
+ UPDATE_ENTITY(contextName, className, entityId) {
50
+ return `${contextName}:room${_.camelCase(className)}${entityId}`.toLowerCase();
51
+ },
52
+ UPDATE_ENTITY_PROPERTY(contextName, className, property, entityId) {
53
+ return `${contextName}:room${_.camelCase(className)}${_.camelCase(property)}${entityId}`.toLowerCase();
54
+ },
55
+ SUBSCRIBE: {
56
+ CUSTOM: (contextName) => `${contextName}:roomSubscribeCustomRoomEvent`,
57
+ ENTITY_UPDATE_EVENTS: (contextName) => `${contextName}:roomSubscribeEntityEvents`,
58
+ ENTITY_PROPERTY_UPDATE_EVENTS: (contextName) => `${contextName}:roomSubscribeEntityPropertyEvents`,
59
+ },
60
+ UNSUBSCRIBE: {
61
+ CUSTOM: (contextName) => `${contextName}:roomUnsubscribeCustomRoomEvent`,
62
+ ENTITY_UPDATE_EVENTS: (contextName) => `${contextName}:roomUnsubscribeEntityEvents`,
63
+ ENTITY_PROPERTY_UPDATE_EVENTS: (contextName) => `${contextName}:roomUnsubscribeEntityPropertyEvents`,
64
+ },
65
+ },
66
+ };
67
+ Symbols.metadata = {
68
+ className: `class:realname`,
69
+ options: {
70
+ runtimeController: `runtime:controller:options`,
71
+ controller: `controller:options`,
72
+ controllerMethod: `controller:method:options`,
73
+ entity: `entity:options`,
74
+ repository: `repository:options`,
75
+ provider: `provider:options`,
76
+ subscriber: `subscriber:options`,
77
+ },
78
+ };
79
+ Symbols.old = {
80
+ HAS_TABLE_IN_DB: Symbol(),
81
+ MDC_KEY: `modeldataconfig`,
82
+ WEBSQL_REST_PROGRESS_FUN: Symbol(),
83
+ WEBSQL_REST_PROGRESS_FUN_START: Symbol(),
84
+ WEBSQL_REST_PROGRESS_FUN_DONE: Symbol(),
85
+ WEBSQL_REST_PROGRESS_TIMEOUT: Symbol(),
86
+ X_TOTAL_COUNT: `x-total-count`,
87
+ CIRCURAL_OBJECTS_MAP_BODY: `circuralmapbody`,
88
+ CIRCURAL_OBJECTS_MAP_QUERY_PARAM: `circuralmapbody`,
89
+ MAPPING_CONFIG_HEADER: `mappingheader`,
90
+ MAPPING_CONFIG_HEADER_BODY_PARAMS: `mhbodyparams`,
91
+ MAPPING_CONFIG_HEADER_QUERY_PARAMS: `mhqueryparams`,
92
+ ENDPOINT_META_CONFIG: `ng2_rest_endpoint_config`,
93
+ CLASS_DECORATOR_CONTEXT: `$$ng2_rest_class_context`,
94
+ SOCKET_MSG: `socketmessageng2rest`,
95
+ ANGULAR: {
96
+ INPUT_NAMES: Symbol(),
97
+ },
98
+ ERROR_MESSAGES: {
99
+ CLASS_NAME_MATCH: `Please check if your "class name" matches @Controller( className ) or @Entity( className )`,
100
+ },
101
+ };
102
+ })(Symbols || (Symbols = {}));
103
+ ;
104
+ ({}); // @--end-of-file-for-module=taon lib/symbols.ts
105
+
106
+ var Validators;
107
+ (function (Validators) {
108
+ Validators.classNameVlidation = (className, target) => {
109
+ setTimeout(() => {
110
+ if (_.isUndefined(className)) {
111
+ throw `[Taon]
112
+ Please provide "className" property for each Controller and Entity:
113
+
114
+ @Taon.Controller({ className: 'MyExampleCtrl' })
115
+ class MyExampleCtrl {
116
+ ...
117
+ }
118
+
119
+ @Taon.Entity({ className: 'MyExampleEntity' })
120
+ class MyExampleEntity {
121
+ ...
122
+ }
123
+
124
+ Notice that minified javascript code does not preserve
125
+ Functions/Classes names -this is only solution to preserve classes names.
126
+
127
+ `;
128
+ }
129
+ });
130
+ return _.isUndefined(className) ? target.name : className;
131
+ };
132
+ Validators.checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
133
+ const defaultResponseType = 'text or JSON';
134
+ if (!current.responseType) {
135
+ return;
136
+ }
137
+ for (let index = 0; index < methods.length; index++) {
138
+ const m = methods[index];
139
+ if (m.path === current.path && m.responseType !== current.responseType) {
140
+ throw new Error(`
141
+ [taon] you can have 2 methods with same path but differetn reponseType-s
142
+
143
+ ${m.methodName}( ... path: ${m.path} ) -> responseType: ${m.responseType || defaultResponseType}
144
+ ${current.methodName}( ... path: ${current.path} ) -> responseType: ${current.responseType}
145
+
146
+ Please change path name on of the methods.
147
+
148
+ `);
149
+ }
150
+ }
151
+ };
152
+ Validators.validateClassFunctions = (controllers, entities, proviers, repositories) => {
153
+ if (_.isArray(controllers) &&
154
+ controllers.filter(f => !_.isFunction(f)).length > 0) {
155
+ console.error('controllers', controllers);
156
+ throw `
157
+
158
+ Incorect value for property "controllers" inside Taon.Init(...)
159
+
160
+ `;
161
+ }
162
+ if (_.isArray(entities) &&
163
+ entities.filter(f => !_.isFunction(f)).length > 0) {
164
+ console.error('entites', entities);
165
+ throw `
166
+
167
+ Incorect value for property "entities" inside Taon.Init(...)
168
+
169
+ `;
170
+ }
171
+ };
172
+ Validators.preventUndefinedModel = (model, id) => {
173
+ if (_.isUndefined(model)) {
174
+ throw `Bad update by id, config, id: ${id}`;
175
+ }
176
+ };
177
+ })(Validators || (Validators = {}));
178
+ ;
179
+ ({}); // @--end-of-file-for-module=taon lib/validators.ts
180
+
181
+ var TaonHelpers;
182
+ (function (TaonHelpers) {
183
+ TaonHelpers.fillUpTo = (s, nCharacters) => {
184
+ return _.times(nCharacters, n => {
185
+ if (s.charAt(n)) {
186
+ return s.charAt(n);
187
+ }
188
+ return ' ';
189
+ }).join('');
190
+ };
191
+ TaonHelpers.isGoodPath = (p) => {
192
+ return p && typeof p === 'string' && p.trim() !== '';
193
+ };
194
+ TaonHelpers.tryTransformParam = param => {
195
+ if (typeof param === 'string') {
196
+ let n = Number(param);
197
+ if (!isNaN(n))
198
+ return n;
199
+ const bool = param.trim().toLowerCase();
200
+ if (bool === 'true') {
201
+ return true;
202
+ }
203
+ if (bool === 'false') {
204
+ return false;
205
+ }
206
+ try {
207
+ const t = JSON5.parse(param);
208
+ return t;
209
+ }
210
+ catch (e) {
211
+ return param;
212
+ }
213
+ }
214
+ return param;
215
+ };
216
+ TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
217
+ if (typeof pathOrClassConfig === 'string')
218
+ return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
219
+ return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
220
+ };
221
+ TaonHelpers.defaultType = value => {
222
+ if (typeof value === 'string')
223
+ return '';
224
+ if (typeof value === 'boolean')
225
+ return false;
226
+ if (Array.isArray(value))
227
+ return {};
228
+ if (typeof value === 'object')
229
+ return {};
230
+ };
231
+ TaonHelpers.parseJSONwithStringJSONs = (object, waring = false) => {
232
+ if (!_.isObject(object)) {
233
+ if (waring) {
234
+ console.error(`
235
+ parseJSONwithStringJSONs(...)
236
+ Parameter should be a object, but is ${typeof object}
237
+ `, object);
238
+ }
239
+ return object;
240
+ }
241
+ let res = _.cloneDeep(object);
242
+ Object.keys(res).forEach(key => {
243
+ let isJson = false;
244
+ try {
245
+ const possibleJSON = JSON.parse(res[key]);
246
+ res[key] = possibleJSON;
247
+ isJson = true;
248
+ }
249
+ catch (e) {
250
+ isJson = false;
251
+ }
252
+ if (isJson) {
253
+ res[key] = TaonHelpers.parseJSONwithStringJSONs(res[key], false);
254
+ }
255
+ });
256
+ return res;
257
+ };
258
+ TaonHelpers.isPlainFileOrFolder = filePath => {
259
+ return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
260
+ };
261
+ TaonHelpers.ipcKeyNameResponse = (target, methodConfig, expressPath) => {
262
+ return [
263
+ 'response',
264
+ ClassHelpers.getName(target),
265
+ methodConfig.methodName,
266
+ methodConfig.type,
267
+ expressPath,
268
+ ].join('--');
269
+ };
270
+ TaonHelpers.ipcKeyNameRequest = (target, methodConfig, expressPath) => {
271
+ return [
272
+ 'request',
273
+ ClassHelpers.getName(target),
274
+ methodConfig.methodName,
275
+ methodConfig.type,
276
+ expressPath,
277
+ ].join('--');
278
+ };
279
+ TaonHelpers.websqlMocks = headers => {
280
+ const response = {
281
+ status(status) {
282
+ return {
283
+ send(send) {
284
+ },
285
+ };
286
+ },
287
+ setHeader(key, value) {
288
+ headers[key] = value;
289
+ },
290
+ };
291
+ const request = {};
292
+ return { request, response };
293
+ };
294
+ })(TaonHelpers || (TaonHelpers = {}));
295
+ ;
296
+ ({}); // @--end-of-file-for-module=taon lib/helpers/taon-helpers.ts
297
+
298
+ /* */
299
+ /* */
300
+ var ClassHelpers;
301
+ (function (ClassHelpers) {
302
+ /**
303
+ * TODO - repalce in every place when getting class fn from object
304
+ */
305
+ ClassHelpers.getClassFnFromObject = (json) => {
306
+ if (_.isUndefined(json) || _.isNull(json)) {
307
+ return;
308
+ }
309
+ if (json.constructor) {
310
+ return json.constructor;
311
+ }
312
+ const p = Object.getPrototypeOf(json);
313
+ return p && p.constructor && p.constructor.name !== 'Object'
314
+ ? p.constructor
315
+ : void 0;
316
+ };
317
+ ClassHelpers.getName = (classFnOrObject) => {
318
+ if (classFnOrObject instanceof FormData) {
319
+ return 'FormData';
320
+ }
321
+ if (!classFnOrObject) {
322
+ console.error('OBJECT OR CLASS', classFnOrObject);
323
+ throw new Error(`Cannot get name from this object or class.`);
324
+ }
325
+ return ((classFnOrObject[Symbols.classNameStaticProperty]
326
+ ? classFnOrObject[Symbols.classNameStaticProperty]
327
+ : classFnOrObject?.constructor[Symbols.classNameStaticProperty]) ||
328
+ CLASS.getName(classFnOrObject));
329
+ };
330
+ ClassHelpers.getOrginalClass = (classFnOrObject) => {
331
+ const org = classFnOrObject[Symbols.orignalClass];
332
+ if (!org) {
333
+ return classFnOrObject;
334
+ }
335
+ return ClassHelpers.getOrginalClass(org);
336
+ };
337
+ ClassHelpers.getFullInternalName = (classFnOrObject) => {
338
+ if (!classFnOrObject) {
339
+ throw new Error(`Cannot get name from: ${classFnOrObject}`);
340
+ }
341
+ return ((classFnOrObject[Symbols.fullClassNameStaticProperty]
342
+ ? classFnOrObject[Symbols.fullClassNameStaticProperty]
343
+ : classFnOrObject?.constructor[Symbols.fullClassNameStaticProperty]) ||
344
+ void 0);
345
+ };
346
+ ClassHelpers.getUniquKey = (classFnOrObject) => {
347
+ const classFn = _.isFunction(classFnOrObject)
348
+ ? classFnOrObject
349
+ : classFnOrObject.constructor;
350
+ const config = Reflect.getMetadata(Symbols.metadata.options.controller, classFn);
351
+ return config.uniqueKeyProp;
352
+ };
353
+ ClassHelpers.isContextClassObject = (obj) => {
354
+ if (!_.isObject(obj) ||
355
+ _.isArray(obj) ||
356
+ _.isRegExp(obj) ||
357
+ _.isBuffer(obj) ||
358
+ _.isArrayBuffer(obj)) {
359
+ return false;
360
+ }
361
+ if (_.isDate(obj)) {
362
+ return true;
363
+ }
364
+ const className = ClassHelpers.getName(obj);
365
+ return _.isString(className) && className !== 'Object';
366
+ };
367
+ ClassHelpers.setName = (target, className) => {
368
+ Validators.classNameVlidation(className, target);
369
+ target[Symbols.classNameStaticProperty] = className;
370
+ };
371
+ ClassHelpers.hasParentClassWithName = (target, className, targets = []) => {
372
+ if (!target) {
373
+ return false;
374
+ }
375
+ targets.push(target);
376
+ let targetProto = Object.getPrototypeOf(target);
377
+ if (_.isFunction(targetProto) &&
378
+ ClassHelpers.getName(targetProto) === className) {
379
+ return true;
380
+ }
381
+ return ClassHelpers.hasParentClassWithName(targetProto, className, targets);
382
+ };
383
+ ClassHelpers.getControllerConfig = (target) => {
384
+ const classMetadataOptions = Reflect.getMetadata(Symbols.metadata.options.controller, target);
385
+ const classMetadata = _.merge(new Models.ControllerConfig(), classMetadataOptions);
386
+ const methodNames = ClassHelpers.getMethodsNames(target); // Object.getOwnPropertyNames(target.prototype);
387
+ for (const methodName of methodNames) {
388
+ const methodMetadata = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target, methodName);
389
+ if (methodMetadata) {
390
+ classMetadata.methods[methodName] = methodMetadata;
391
+ }
392
+ }
393
+ return classMetadata;
394
+ };
395
+ const notAllowedAsMethodName = [
396
+ 'length',
397
+ 'name',
398
+ 'arguments',
399
+ 'caller',
400
+ 'constructor',
401
+ 'apply',
402
+ 'bind',
403
+ 'call',
404
+ 'toString',
405
+ '__defineGetter__',
406
+ '__defineSetter__',
407
+ 'hasOwnProperty',
408
+ '__lookupGetter__',
409
+ '__lookupSetter__',
410
+ 'isPrototypeOf',
411
+ 'propertyIsEnumerable',
412
+ 'valueOf',
413
+ '__proto__',
414
+ 'toLocaleString',
415
+ ];
416
+ ClassHelpers.getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
417
+ if (!classOrClassInstance) {
418
+ return allMethodsNames;
419
+ }
420
+ const isClassFunction = _.isFunction(classOrClassInstance);
421
+ const classFun = isClassFunction
422
+ ? classOrClassInstance
423
+ : Object.getPrototypeOf(classOrClassInstance);
424
+ const objectToCheck = isClassFunction
425
+ ? classOrClassInstance?.prototype
426
+ : classOrClassInstance;
427
+ const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
428
+ const properties = _.uniq([
429
+ ...Object.getOwnPropertyNames(objectToCheck || {}),
430
+ ...Object.getOwnPropertyNames(prototypeObj || {}),
431
+ ...Object.keys(objectToCheck || {}),
432
+ ...Object.keys(prototypeObj || {}),
433
+ ]).filter(f => !!f && !notAllowedAsMethodName.includes(f));
434
+ properties
435
+ .filter(methodName => typeof objectToCheck[methodName] === 'function')
436
+ .forEach(p => allMethodsNames.push(p));
437
+ if (!classFun ||
438
+ !classFun.constructor ||
439
+ classFun?.constructor?.name === 'Object') {
440
+ return allMethodsNames;
441
+ }
442
+ return ClassHelpers.getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
443
+ };
444
+ ClassHelpers.getControllerConfigs = (target, configs = [], callerTarget) => {
445
+ if (!_.isFunction(target)) {
446
+ throw `[typescript-class-helper][getClassConfig] Cannot get class config from: ${target}`;
447
+ }
448
+ let config;
449
+ const parentClass = Object.getPrototypeOf(target);
450
+ const parentName = parentClass ? ClassHelpers.getName(parentClass) : void 0;
451
+ const isValidParent = _.isFunction(parentClass) && parentName !== '';
452
+ config = ClassHelpers.getControllerConfig(target);
453
+ configs.push(config);
454
+ return isValidParent
455
+ ? ClassHelpers.getControllerConfigs(parentClass, configs, target)
456
+ : configs;
457
+ };
458
+ ClassHelpers.getCalculatedPathFor = (target) => {
459
+ const configs = ClassHelpers.getControllerConfigs(target);
460
+ const parentscalculatedPath = _.slice(configs, 1)
461
+ .reverse()
462
+ .map(bc => {
463
+ if (TaonHelpers.isGoodPath(bc.path)) {
464
+ return bc.path;
465
+ }
466
+ return bc.className;
467
+ })
468
+ .join('/');
469
+ return `/${parentscalculatedPath}/${ClassHelpers.getName(target)}`;
470
+ };
471
+ })(ClassHelpers || (ClassHelpers = {}));
472
+ ;
473
+ ({}); // @--end-of-file-for-module=taon lib/helpers/class-helpers.ts
474
+
475
+ /* */
476
+ /* */
477
+ var Models;
478
+ (function (Models) {
479
+ let ClassType;
480
+ (function (ClassType) {
481
+ ClassType["ENTITY"] = "ENTITY";
482
+ ClassType["CONTROLLER"] = "CONTROLLER";
483
+ ClassType["REPOSITORY"] = "REPOSITORY";
484
+ ClassType["PROVIDER"] = "PROVIDER";
485
+ ClassType["SUBSCRIBER"] = "SUBSCRIBER";
486
+ })(ClassType = Models.ClassType || (Models.ClassType = {}));
487
+ Models.ClassTypeKey = {
488
+ [ClassType.ENTITY]: 'entities',
489
+ [ClassType.CONTROLLER]: 'controllers',
490
+ [ClassType.REPOSITORY]: 'repositories',
491
+ [ClassType.PROVIDER]: 'providers',
492
+ [ClassType.SUBSCRIBER]: 'subscribers',
493
+ };
494
+ class DecoratorAbstractOpt {
495
+ }
496
+ Models.DecoratorAbstractOpt = DecoratorAbstractOpt;
497
+ class ParamConfig {
498
+ }
499
+ Models.ParamConfig = ParamConfig;
500
+ class MethodConfig {
501
+ constructor() {
502
+ this.parameters = {};
503
+ }
504
+ }
505
+ Models.MethodConfig = MethodConfig;
506
+ class ControllerConfig extends DecoratorAbstractOpt {
507
+ constructor() {
508
+ super(...arguments);
509
+ this.methods = {};
510
+ }
511
+ }
512
+ Models.ControllerConfig = ControllerConfig;
513
+ class RuntimeControllerConfig extends ControllerConfig {
514
+ }
515
+ Models.RuntimeControllerConfig = RuntimeControllerConfig;
516
+ let Http;
517
+ (function (Http) {
518
+ Http.Rest = Models$1;
519
+ class Errors {
520
+ constructor(message, code = 400) {
521
+ this.message = message;
522
+ this.code = code;
523
+ this.toString = () => {
524
+ return this.message;
525
+ };
526
+ }
527
+ static create(message, code = 400) {
528
+ return new Errors(message, code);
529
+ }
530
+ static entityNotFound(entity) {
531
+ return Errors.create(`Entity ${ClassHelpers.getName(entity)} not found`);
532
+ }
533
+ static custom(message, code = 400) {
534
+ return Errors.create(message, code);
535
+ }
536
+ }
537
+ Http.Errors = Errors;
538
+ })(Http = Models.Http || (Models.Http = {}));
539
+ })(Models || (Models = {}));
540
+ ;
541
+ ({}); // @--end-of-file-for-module=taon lib/models.ts
542
+
543
+ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
544
+ let options;
545
+ if (typeof pathOrOptions === 'object') {
546
+ options = pathOrOptions;
547
+ pathOrOptions = options.path;
548
+ pathIsGlobal = !!options.pathIsGlobal;
549
+ path = options.path;
550
+ }
551
+ else {
552
+ options = { pathOrOptions, pathIsGlobal };
553
+ }
554
+ const { overrideContentType, overridResponseType } = options;
555
+ let methodConfig = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target.constructor, propertyKey);
556
+ if (!methodConfig) {
557
+ methodConfig = new Models.MethodConfig();
558
+ Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
559
+ }
560
+ methodConfig.methodName = propertyKey;
561
+ methodConfig.type = method;
562
+ if (!path) {
563
+ let paramsPathConcatedPath = '';
564
+ for (const key in methodConfig.parameters) {
565
+ if (methodConfig.parameters.hasOwnProperty(key)) {
566
+ const element = methodConfig.parameters[key];
567
+ if (element.paramType === 'Path' &&
568
+ _.isString(element.paramName) &&
569
+ element.paramName.trim().length > 0) {
570
+ paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
571
+ }
572
+ }
573
+ }
574
+ methodConfig.path = `/${propertyKey}${paramsPathConcatedPath}`;
575
+ }
576
+ else {
577
+ methodConfig.path = path;
578
+ }
579
+ methodConfig.descriptor = descriptor;
580
+ methodConfig.global = pathIsGlobal;
581
+ methodConfig.contentType = overrideContentType;
582
+ methodConfig.responseType = overridResponseType;
583
+ Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
584
+ };
585
+ function GET(pathOrOptions, pathIsGlobal = false) {
586
+ return function (target, propertyKey, descriptor) {
587
+ metaReq('get', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
588
+ };
589
+ }
590
+ function HEAD(pathOrOptions, pathIsGlobal = false) {
591
+ return function (target, propertyKey, descriptor) {
592
+ metaReq('head', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
593
+ };
594
+ }
595
+ function POST(pathOrOptions, pathIsGlobal = false) {
596
+ return function (target, propertyKey, descriptor) {
597
+ metaReq('post', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
598
+ };
599
+ }
600
+ function PUT(pathOrOptions, pathIsGlobal = false) {
601
+ return function (target, propertyKey, descriptor) {
602
+ metaReq('put', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
603
+ };
604
+ }
605
+ function PATCH(pathOrOptions, pathIsGlobal = false) {
606
+ return function (target, propertyKey, descriptor) {
607
+ metaReq('patch', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
608
+ };
609
+ }
610
+ function DELETE(pathOrOptions, pathIsGlobal = false) {
611
+ return function (target, propertyKey, descriptor) {
612
+ metaReq('delete', pathOrOptions, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal);
613
+ };
614
+ }
615
+ ;
616
+ ({}); // @--end-of-file-for-module=taon lib/decorators/http/http-methods-decorators.ts
617
+
618
+ function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
619
+ let methodConfig = Reflect.getMetadata(Symbols.metadata.options.controllerMethod, target.constructor, propertyKey);
620
+ if (!methodConfig) {
621
+ methodConfig = new Models.MethodConfig();
622
+ Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
623
+ }
624
+ const nameKey = name ? name : param;
625
+ const p = (methodConfig.parameters[nameKey] = !methodConfig.parameters[nameKey]
626
+ ? new Models.ParamConfig()
627
+ : methodConfig.parameters[nameKey]);
628
+ p.index = parameterIndex;
629
+ p.paramName = name;
630
+ p.paramType = param;
631
+ p.defaultType = defaultValue;
632
+ p.expireInSeconds = expire;
633
+ Reflect.defineMetadata(Symbols.metadata.options.controllerMethod, methodConfig, target.constructor, propertyKey);
634
+ }
635
+ function Path(name) {
636
+ return function (target, propertyKey, parameterIndex) {
637
+ metaParam('Path', name, undefined, {}, target, propertyKey, parameterIndex);
638
+ };
639
+ }
640
+ function Query(name) {
641
+ return function (target, propertyKey, parameterIndex) {
642
+ metaParam('Query', name, undefined, {}, target, propertyKey, parameterIndex);
643
+ };
644
+ }
645
+ function Cookie(name, expireInSecond = 3600) {
646
+ return function (target, propertyKey, parameterIndex) {
647
+ metaParam('Cookie', name, expireInSecond, {}, target, propertyKey, parameterIndex);
648
+ };
649
+ }
650
+ function Header(name) {
651
+ return function (target, propertyKey, parameterIndex) {
652
+ metaParam('Header', name, undefined, {}, target, propertyKey, parameterIndex);
653
+ };
654
+ }
655
+ function Body(name) {
656
+ return function (target, propertyKey, parameterIndex) {
657
+ metaParam('Body', name, undefined, {}, target, propertyKey, parameterIndex);
658
+ };
659
+ }
660
+ ;
661
+ ({}); // @--end-of-file-for-module=taon lib/decorators/http/http-params-decorators.ts
662
+
663
+ var Http;
664
+ (function (Http) {
665
+ Http.GET = GET;
666
+ Http.POST = POST;
667
+ Http.PUT = PUT;
668
+ Http.DELETE = DELETE;
669
+ Http.PATCH = PATCH;
670
+ Http.HEAD = HEAD;
671
+ let Param;
672
+ (function (Param) {
673
+ Param.Query = Query;
674
+ Param.Path = Path;
675
+ Param.Body = Body;
676
+ Param.Cookie = Cookie;
677
+ Param.Header = Header;
678
+ })(Param = Http.Param || (Http.Param = {}));
679
+ })(Http || (Http = {}));
680
+ ;
681
+ ({}); // @--end-of-file-for-module=taon lib/decorators/http/http-decorators.ts
682
+
683
+ function TaonController(options) {
684
+ return function (constructor) {
685
+ ClassHelpers.setName(constructor, options?.className);
686
+ Reflect.defineMetadata(Symbols.metadata.options.controller, options, constructor);
687
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
688
+ };
689
+ }
690
+ class TaonControllerOptions extends Models.DecoratorAbstractOpt {
691
+ }
692
+ ;
693
+ ({}); // @--end-of-file-for-module=taon lib/decorators/classes/controller-decorator.ts
694
+
695
+ class BaseInjector {
696
+ constructor() {
697
+ /**
698
+ * Repositories to init (by controller)
699
+ */
700
+ this.__repositories_to_init__ = [];
701
+ }
702
+ /**
703
+ * class initialization hook
704
+ * taon after class instace creation
705
+ */
706
+ async _() {
707
+ const reposToInit = this.__repositories_to_init__;
708
+ for (const repo of reposToInit) {
709
+ await repo.__init(this);
710
+ }
711
+ }
712
+ /**
713
+ * Current endpoint context
714
+ */
715
+ get __endpoint_context__() {
716
+ return this[Symbols.ctxInClassOrClassObj];
717
+ }
718
+ /**
719
+ * inject crud repo for entity
720
+ */
721
+ injectRepo(entityForCrud) {
722
+ const repoProxy = this.__inject(void 0, {
723
+ localInstance: true,
724
+ resolveClassFromContext: 'BaseRepository',
725
+ locaInstanceConstructorArgs: [() => entityForCrud],
726
+ });
727
+ this.__repositories_to_init__.push(repoProxy);
728
+ return repoProxy;
729
+ }
730
+ injectCustomRepository(cutomRepositoryClass) {
731
+ const repoProxy = this.__inject(cutomRepositoryClass, {
732
+ localInstance: true,
733
+ locaInstanceConstructorArgs: [
734
+ () => cutomRepositoryClass.prototype.entityClassResolveFn(),
735
+ ],
736
+ });
737
+ this.__repositories_to_init__.push(repoProxy);
738
+ return repoProxy;
739
+ }
740
+ /**
741
+ * aliast to .injectRepository()
742
+ */
743
+ injectCustomRepo(cutomRepositoryClass) {
744
+ const repoProxy = this.injectCustomRepository(cutomRepositoryClass);
745
+ this.__repositories_to_init__.push(repoProxy);
746
+ return repoProxy;
747
+ }
748
+ injectController(ctor) {
749
+ return this.__inject(ctor, { localInstance: false });
750
+ }
751
+ /**
752
+ * aliast to .injectController()
753
+ */
754
+ injectSubscriber(ctor) {
755
+ return this.__inject(ctor, { localInstance: false });
756
+ }
757
+ /**
758
+ * aliast to .injectController()
759
+ */
760
+ injectCtrl(ctor) {
761
+ return this.injectController(ctor);
762
+ }
763
+ /**
764
+ * global provider available in every context
765
+ */
766
+ injectGlobalProvider(ctor) {
767
+ return this.__inject(ctor, { localInstance: false });
768
+ }
769
+ /**
770
+ * context scoped provider
771
+ * TODO
772
+ */
773
+ injectContextProvider(ctor) {
774
+ return this.__inject(ctor, { localInstance: false });
775
+ }
776
+ /**
777
+ * Inject: Controllers, Providers, Repositories, Services, etc.
778
+ * TODO addd nest js injecting
779
+ */
780
+ __inject(ctor, options) {
781
+ if (!options) {
782
+ options = {};
783
+ }
784
+ const contextClassInstance = this;
785
+ return new Proxy({}, {
786
+ get: (__, propName) => {
787
+ const contextFromClass = ctor && ctor[Symbols.ctxInClassOrClassObj];
788
+ const resultContext = contextFromClass
789
+ ? contextFromClass
790
+ : this.__endpoint_context__;
791
+ if (options.resolveClassFromContext) {
792
+ const resolvedClass = resultContext.getClassFunByClassName(options.resolveClassFromContext);
793
+ ctor = resolvedClass;
794
+ }
795
+ if (resultContext) {
796
+ var instance = resultContext.inject(ctor, {
797
+ ...options,
798
+ contextClassInstance,
799
+ });
800
+ if (!instance) {
801
+ throw new Error(`Not able to inject "${ClassHelpers.getName(ctor) || ctor.name}" inside ` +
802
+ `property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
803
+
804
+ Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
805
+
806
+ `);
807
+ }
808
+ const result = typeof instance[propName] === 'function'
809
+ ? instance[propName].bind(instance)
810
+ : instance[propName];
811
+ return result;
812
+ }
813
+ },
814
+ set: (__, propName, value) => {
815
+ const contextFromClass = ctor && ctor[Symbols.ctxInClassOrClassObj];
816
+ const resultContext = contextFromClass
817
+ ? contextFromClass
818
+ : this.__endpoint_context__;
819
+ if (options.resolveClassFromContext) {
820
+ const resolvedClass = resultContext.getClassFunByClassName(options.resolveClassFromContext);
821
+ ctor = resolvedClass;
822
+ }
823
+ if (resultContext) {
824
+ var instance = resultContext.inject(ctor, {
825
+ ...options,
826
+ contextClassInstance,
827
+ });
828
+ if (!instance) {
829
+ const classNameNotResolved = ClassHelpers.getName(ctor) || ctor.name;
830
+ throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
831
+ `property "${propName?.toString()}" on class "${ClassHelpers.getName(this)}".
832
+
833
+ Please add "${ClassHelpers.getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories)
834
+
835
+ `);
836
+ }
837
+ instance[propName] = value;
838
+ }
839
+ return true;
840
+ },
841
+ });
842
+ }
843
+ clone(override) {
844
+ const classFn = ClassHelpers.getClassFnFromObject(this);
845
+ const result = _.merge(new classFn(), _.merge(_.cloneDeep(this), override));
846
+ return result;
847
+ }
848
+ }
849
+ ;
850
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-injector.ts
851
+
852
+ let BaseController = class BaseController extends BaseInjector {
853
+ /**
854
+ * init example data for db
855
+ */
856
+ initExampleDbData() {
857
+ return void 0;
858
+ }
859
+ };
860
+ BaseController = __decorate([
861
+ TaonController({ className: 'BaseController' })
862
+ ], BaseController);
863
+ ;
864
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-controller.ts
865
+
866
+ /**
867
+ * Please override property entityClassFn with entity class.
868
+ */
869
+ let BaseCrudController = class BaseCrudController extends BaseController {
870
+ async _() {
871
+ if (!_.isFunction(this.entityClassResolveFn)) {
872
+ Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers.getName(this)} because entityClassResolveFn is not provided.`);
873
+ return;
874
+ }
875
+ let entityClassFn = this.entityClassResolveFn();
876
+ this.db = this.injectRepo(entityClassFn);
877
+ if (entityClassFn) {
878
+ const configEntity = Reflect.getMetadata(Symbols.metadata.options.entity, ClassHelpers.getClassFnFromObject(this));
879
+ if (configEntity?.createTable === false) {
880
+ Helpers.warn(`Table for entity ${ClassHelpers.getName(entityClassFn)} will not be created. Crud will not work properly.`);
881
+ }
882
+ }
883
+ else {
884
+ Helpers.error(`Entity class not provided for controller ${ClassHelpers.getName(this)}.
885
+
886
+ Please provide entity as class propery entityClassFn:
887
+
888
+ class ${ClassHelpers.getName(this)} extends BaseCrudController<Entity> {
889
+
890
+ entityClassResolveFn = ()=> MyEntityClass;
891
+
892
+ }
893
+
894
+ `);
895
+ }
896
+ await super._();
897
+ }
898
+ bufforedChanges(id, property, alreadyLength) {
899
+ return async (request, response) => {
900
+ const model = await this.db.getBy(id);
901
+ if (model === void 0) {
902
+ return;
903
+ }
904
+ Validators.preventUndefinedModel(model, id);
905
+ let value = model[property];
906
+ let result;
907
+ if (_.isString(value) || _.isArray(value)) {
908
+ result = value.slice(alreadyLength);
909
+ }
910
+ return result;
911
+ };
912
+ }
913
+ pagination(pageNumber = 1, pageSize = 10, search = '') {
914
+ return async (request, response) => {
915
+ if (this.db.repositoryExists) {
916
+ const query = {
917
+ page: pageNumber,
918
+ take: pageSize,
919
+ keyword: search,
920
+ };
921
+ const take = query.take || 10;
922
+ const page = query.page || 1;
923
+ const skip = (page - 1) * take;
924
+ const keyword = query.keyword || '';
925
+ const [result, total] = await this.db.findAndCount({
926
+ take: take,
927
+ skip: skip,
928
+ });
929
+ response?.setHeader(Symbols.old.X_TOTAL_COUNT, total);
930
+ return result;
931
+ }
932
+ return [];
933
+ };
934
+ }
935
+ getAll() {
936
+ return async (request, response) => {
937
+ if (this.db.repositoryExists) {
938
+ const { models, totalCount } = await this.db.getAll();
939
+ response?.setHeader(Symbols.old.X_TOTAL_COUNT, totalCount);
940
+ return models;
941
+ }
942
+ return [];
943
+ };
944
+ }
945
+ getBy(id) {
946
+ return async () => {
947
+ const model = await this.db.getBy(id);
948
+ return model;
949
+ };
950
+ }
951
+ updateById(id, item) {
952
+ return async () => {
953
+ const model = await this.db.updateById(id, item);
954
+ return model;
955
+ };
956
+ }
957
+ patchById(id, item) {
958
+ return async () => {
959
+ const model = await this.db.updateById(id, item);
960
+ return model;
961
+ };
962
+ }
963
+ bulkUpdate(items) {
964
+ return async () => {
965
+ if (!Array.isArray(items) || items?.length === 0) {
966
+ return [];
967
+ }
968
+ const { models } = await this.db.bulkUpdate(items);
969
+ return models;
970
+ };
971
+ }
972
+ deleteById(id) {
973
+ return async () => {
974
+ const model = await this.db.deleteById(id);
975
+ return model;
976
+ };
977
+ }
978
+ bulkDelete(ids) {
979
+ return async () => {
980
+ const models = await this.db.bulkDelete(ids);
981
+ return models;
982
+ };
983
+ }
984
+ create(item) {
985
+ return async () => {
986
+ const model = await this.db.create(item);
987
+ return model;
988
+ };
989
+ }
990
+ bulkCreate(items) {
991
+ return async () => {
992
+ const models = await this.db.bulkCreate(items);
993
+ return models;
994
+ };
995
+ }
996
+ };
997
+ __decorate([
998
+ GET(`/:id/property/:property`),
999
+ __param(0, Path(`id`)),
1000
+ __param(1, Path(`property`)),
1001
+ __param(2, Query('alreadyLength')),
1002
+ __metadata("design:type", Function),
1003
+ __metadata("design:paramtypes", [Object, String, Number]),
1004
+ __metadata("design:returntype", Object)
1005
+ ], BaseCrudController.prototype, "bufforedChanges", null);
1006
+ __decorate([
1007
+ GET(),
1008
+ __param(0, Query('pageNumber')),
1009
+ __param(1, Query('pageSize')),
1010
+ __param(2, Query('search')),
1011
+ __metadata("design:type", Function),
1012
+ __metadata("design:paramtypes", [Number, Number, String]),
1013
+ __metadata("design:returntype", Object)
1014
+ ], BaseCrudController.prototype, "pagination", null);
1015
+ __decorate([
1016
+ GET(),
1017
+ __metadata("design:type", Function),
1018
+ __metadata("design:paramtypes", []),
1019
+ __metadata("design:returntype", Object)
1020
+ ], BaseCrudController.prototype, "getAll", null);
1021
+ __decorate([
1022
+ GET(`/:id`),
1023
+ __param(0, Path(`id`)),
1024
+ __metadata("design:type", Function),
1025
+ __metadata("design:paramtypes", [Object]),
1026
+ __metadata("design:returntype", Object)
1027
+ ], BaseCrudController.prototype, "getBy", null);
1028
+ __decorate([
1029
+ PUT(`/:id`),
1030
+ __param(0, Path(`id`)),
1031
+ __param(1, Body()),
1032
+ __metadata("design:type", Function),
1033
+ __metadata("design:paramtypes", [Object, Object]),
1034
+ __metadata("design:returntype", Object)
1035
+ ], BaseCrudController.prototype, "updateById", null);
1036
+ __decorate([
1037
+ PATCH(`/:id`),
1038
+ __param(0, Path(`id`)),
1039
+ __param(1, Body()),
1040
+ __metadata("design:type", Function),
1041
+ __metadata("design:paramtypes", [Object, Object]),
1042
+ __metadata("design:returntype", Object)
1043
+ ], BaseCrudController.prototype, "patchById", null);
1044
+ __decorate([
1045
+ PUT(),
1046
+ __param(0, Body()),
1047
+ __metadata("design:type", Function),
1048
+ __metadata("design:paramtypes", [Array]),
1049
+ __metadata("design:returntype", Object)
1050
+ ], BaseCrudController.prototype, "bulkUpdate", null);
1051
+ __decorate([
1052
+ DELETE(`/:id`),
1053
+ __param(0, Path(`id`)),
1054
+ __metadata("design:type", Function),
1055
+ __metadata("design:paramtypes", [Number]),
1056
+ __metadata("design:returntype", Object)
1057
+ ], BaseCrudController.prototype, "deleteById", null);
1058
+ __decorate([
1059
+ DELETE(`/bulkDelete/:ids`),
1060
+ __param(0, Path(`ids`)),
1061
+ __metadata("design:type", Function),
1062
+ __metadata("design:paramtypes", [Array]),
1063
+ __metadata("design:returntype", Object)
1064
+ ], BaseCrudController.prototype, "bulkDelete", null);
1065
+ __decorate([
1066
+ POST(),
1067
+ __param(0, Body()),
1068
+ __metadata("design:type", Function),
1069
+ __metadata("design:paramtypes", [Object]),
1070
+ __metadata("design:returntype", Object)
1071
+ ], BaseCrudController.prototype, "create", null);
1072
+ __decorate([
1073
+ POST(),
1074
+ __param(0, Body()),
1075
+ __metadata("design:type", Function),
1076
+ __metadata("design:paramtypes", [Object]),
1077
+ __metadata("design:returntype", Object)
1078
+ ], BaseCrudController.prototype, "bulkCreate", null);
1079
+ BaseCrudController = __decorate([
1080
+ TaonController({ className: 'BaseCrudController' })
1081
+ ], BaseCrudController);
1082
+ ;
1083
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-crud-controller.ts
1084
+
1085
+ class BaseClass {
1086
+ /**
1087
+ * class initialization hook
1088
+ * taon after class instace creation
1089
+ */
1090
+ async _() { }
1091
+ clone(override) {
1092
+ const classFn = ClassHelpers.getClassFnFromObject(this);
1093
+ const result = _.merge(new classFn(), _.merge(_.cloneDeep(this), override));
1094
+ return result;
1095
+ }
1096
+ }
1097
+ ;
1098
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-class.ts
1099
+
1100
+ let EntityDecorator$1 = () => {
1101
+ return (target) => { };
1102
+ };
1103
+ EntityDecorator$1 = Entity;
1104
+ let BaseEntity = class BaseEntity extends BaseClass {
1105
+ };
1106
+ BaseEntity = __decorate([
1107
+ EntityDecorator$1()
1108
+ ], BaseEntity);
1109
+ ;
1110
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-entity.ts
1111
+
1112
+ var Orm;
1113
+ (function (Orm) {
1114
+ Orm.Repository = tsorm.Repository;
1115
+ Orm.Connection = tsorm.Connection;
1116
+ let ListenEvent;
1117
+ (function (ListenEvent) {
1118
+ ListenEvent.AfterInsert = tsorm.AfterInsert;
1119
+ ListenEvent.AfterLoad = tsorm.AfterLoad;
1120
+ ListenEvent.AfterRecover = tsorm.AfterRecover;
1121
+ ListenEvent.AfterRemove = tsorm.AfterRemove;
1122
+ ListenEvent.AfterSoftRemove = tsorm.AfterSoftRemove;
1123
+ ListenEvent.AfterUpdate = tsorm.AfterUpdate;
1124
+ ListenEvent.BeforeInsert = tsorm.BeforeInsert;
1125
+ ListenEvent.BeforeRecover = tsorm.BeforeRecover;
1126
+ ListenEvent.BeforeRemove = tsorm.BeforeRemove;
1127
+ ListenEvent.BeforeSoftRemove = tsorm.BeforeSoftRemove;
1128
+ ListenEvent.BeforeUpdate = tsorm.BeforeUpdate;
1129
+ })(ListenEvent = Orm.ListenEvent || (Orm.ListenEvent = {}));
1130
+ let Tree;
1131
+ (function (Tree) {
1132
+ Tree.Children = tsorm.TreeChildren;
1133
+ Tree.Parent = tsorm.TreeParent;
1134
+ })(Tree = Orm.Tree || (Orm.Tree = {}));
1135
+ let Column;
1136
+ (function (Column) {
1137
+ Column.Generated = tsorm.PrimaryGeneratedColumn;
1138
+ Column.Primary = tsorm.PrimaryColumn;
1139
+ Column.Index = tsorm.Index;
1140
+ Column.CreateDate = tsorm.CreateDateColumn;
1141
+ Column.UpdateDate = tsorm.UpdateDateColumn;
1142
+ Column.DeleteDate = tsorm.DeleteDateColumn;
1143
+ Column.Custom = tsorm.Column;
1144
+ /**
1145
+ * 100 characters varchar
1146
+ */
1147
+ Column.String = () => tsorm.Column({ type: 'varchar', length: 100, nullable: true });
1148
+ Column.Number = () => tsorm.Column({ type: 'int', nullable: true });
1149
+ Column.DecimalNumber = () => tsorm.Column({ type: 'float', nullable: true });
1150
+ Column.SimpleJson = () => tsorm.Column({ type: 'simple-json', nullable: true });
1151
+ Column.Boolean = (defaultValue) => tsorm.Column({ type: 'boolean', default: defaultValue });
1152
+ Column.Version = tsorm.VersionColumn;
1153
+ Column.Virtual = tsorm.VirtualColumn;
1154
+ })(Column = Orm.Column || (Orm.Column = {}));
1155
+ let Join;
1156
+ (function (Join) {
1157
+ Join.Table = tsorm.JoinTable;
1158
+ Join.Column = tsorm.JoinColumn;
1159
+ })(Join = Orm.Join || (Orm.Join = {}));
1160
+ let Relation;
1161
+ (function (Relation) {
1162
+ Relation.OneToMany = tsorm.OneToMany;
1163
+ Relation.OneToOne = tsorm.OneToOne;
1164
+ Relation.ManyToMany = tsorm.ManyToMany;
1165
+ Relation.ManyToOne = tsorm.ManyToOne;
1166
+ })(Relation = Orm.Relation || (Orm.Relation = {}));
1167
+ })(Orm || (Orm = {}));
1168
+ ;
1169
+ ({}); // @--end-of-file-for-module=taon lib/orm.ts
1170
+
1171
+ let EntityDecorator = () => {
1172
+ return (target) => { };
1173
+ };
1174
+ EntityDecorator = Entity;
1175
+ let BaseAbstractEntity = class BaseAbstractEntity extends BaseEntity {
1176
+ };
1177
+ __decorate([
1178
+ Orm.Column.Generated(),
1179
+ __metadata("design:type", String)
1180
+ ], BaseAbstractEntity.prototype, "id", void 0);
1181
+ __decorate([
1182
+ Orm.Column.Version(),
1183
+ __metadata("design:type", Number)
1184
+ ], BaseAbstractEntity.prototype, "version", void 0);
1185
+ BaseAbstractEntity = __decorate([
1186
+ EntityDecorator()
1187
+ ], BaseAbstractEntity);
1188
+ ;
1189
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-abstract-entity.ts
1190
+
1191
+ function TaonRepository(options) {
1192
+ return function (constructor) {
1193
+ Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
1194
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
1195
+ ClassHelpers.setName(constructor, options?.className);
1196
+ };
1197
+ }
1198
+ class TaonRepositoryOptions extends Models.DecoratorAbstractOpt {
1199
+ }
1200
+ ;
1201
+ ({}); // @--end-of-file-for-module=taon lib/decorators/classes/repository-decorator.ts
1202
+
1203
+ const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
1204
+ let BaseRepository = class BaseRepository extends BaseInjector {
1205
+ constructor(__entityClassResolveFn) {
1206
+ super();
1207
+ this.__entityClassResolveFn = __entityClassResolveFn;
1208
+ // @ts-ignore
1209
+ this.entityClassResolveFn = __entityClassResolveFn;
1210
+ }
1211
+ get dbQuery() {
1212
+ if (!this.__dbQuery) {
1213
+ if (!this.__endpoint_context__) {
1214
+ return; // TODO
1215
+ throw new Error(`[BaseRepository] Context not inited for class ${ClassHelpers.getName(this)}`);
1216
+ }
1217
+ const connection = this.__endpoint_context__?.connection;
1218
+ if (!connection) {
1219
+ throw new Error(`[BaseRepository] Database not inited for context ${this.__endpoint_context__?.contextName}`);
1220
+ }
1221
+ this.__dbQuery = new MySqlQuerySource(connection);
1222
+ }
1223
+ return this.__dbQuery;
1224
+ }
1225
+ get connection() {
1226
+ return this.__endpoint_context__?.connection;
1227
+ }
1228
+ get repository() {
1229
+ return this.__repository;
1230
+ }
1231
+ /**
1232
+ * target for repository
1233
+ */
1234
+ get target() {
1235
+ return this?.repository?.target;
1236
+ }
1237
+ /**
1238
+ * alias to repository
1239
+ */
1240
+ get repo() {
1241
+ return this.repository;
1242
+ }
1243
+ get repositoryExists() {
1244
+ return !!this.__repository;
1245
+ }
1246
+ async __init(context) {
1247
+ if (this.__repository) {
1248
+ return;
1249
+ }
1250
+ let entityClassFn = this.entityClassResolveFn();
1251
+ if (!entityClassFn) {
1252
+ Helpers.warn(`Entity class not provided for repository ${ClassHelpers.getName(this)}`);
1253
+ return;
1254
+ }
1255
+ const ctx = this.__endpoint_context__;
1256
+ if (ctx.remoteHost) {
1257
+ return;
1258
+ }
1259
+ const connection = ctx.connection;
1260
+ if (!connection) {
1261
+ throw new Error(`
1262
+
1263
+ Connection not found for context ${ctx.contextName}
1264
+
1265
+
1266
+ Maybe you forgot to init database ?
1267
+
1268
+ Taon.createContext({
1269
+ ...
1270
+ database:true
1271
+ ...
1272
+ })
1273
+
1274
+ `);
1275
+ }
1276
+ if (!entityClassFn) {
1277
+ Helpers.warn(`Entity class not found for repository ${ClassHelpers.getName(this)}`);
1278
+ return;
1279
+ }
1280
+ this.__repository = (await connection.getRepository(ClassHelpers.getOrginalClass(entityClassFn)));
1281
+ }
1282
+ /**
1283
+ * Checks if entity has an id.
1284
+ * If entity composite compose ids, it will check them all.
1285
+ */
1286
+ hasId(entity) {
1287
+ return this.repo.hasId(entity);
1288
+ }
1289
+ /**
1290
+ * Gets entity mixed id.
1291
+ */
1292
+ getId(entity) {
1293
+ return this.repo.getId(entity);
1294
+ }
1295
+ /**
1296
+ Saves a given entity in the database.
1297
+ * If entity does not exist in the database then inserts, otherwise updates.
1298
+ */
1299
+ async save(item, options) {
1300
+ let model = await this.repo.create(item);
1301
+ model = await this.repo.save(model, options);
1302
+ const { id } = model;
1303
+ model = await this.repo.findOne({
1304
+ where: { id },
1305
+ });
1306
+ return model;
1307
+ }
1308
+ /**
1309
+ * alias to save
1310
+ * -> it will actuall create new entity in db
1311
+ * in oposite to typeorm create method
1312
+ */
1313
+ async create(item, options) {
1314
+ return this.save(item, options);
1315
+ }
1316
+ async bulkSave(items, options) {
1317
+ const models = [];
1318
+ for (let index = 0; index < items.length; index++) {
1319
+ const item = items[index];
1320
+ const model = await this.save(item, options);
1321
+ models.push(model);
1322
+ }
1323
+ return models;
1324
+ }
1325
+ async bulkCreate(items, options) {
1326
+ return this.bulkSave(items, options);
1327
+ }
1328
+ /**
1329
+ * Saves all given entities in the database.
1330
+ * If entities do not exist in the database then inserts, otherwise updates.
1331
+ */
1332
+ /**
1333
+ * Merges multiple entities (or entity-like objects) into a given entity.
1334
+ */
1335
+ merge(mergeIntoEntity, ...entityLikes) {
1336
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
1337
+ }
1338
+ /**
1339
+ * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
1340
+ * it loads it (and everything related to it), replaces all values with the new ones from the given object
1341
+ * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
1342
+ * replaced from the new object.
1343
+ *
1344
+ * Note that given entity-like object must have an entity id / primary key to find entity by.
1345
+ * Returns undefined if entity with given id was not found.
1346
+ */
1347
+ preload(entityLike) {
1348
+ return this.repo.preload(entityLike);
1349
+ }
1350
+ /**
1351
+ * Removes a given entities from the database.
1352
+ */
1353
+ async remove(idOrEntity) {
1354
+ if (_.isObject(idOrEntity)) {
1355
+ idOrEntity = idOrEntity.id;
1356
+ }
1357
+ const deletedEntity = await this.repo.findOne({
1358
+ where: { id: idOrEntity },
1359
+ });
1360
+ const idCopy = deletedEntity.id;
1361
+ await this.repo.remove(deletedEntity);
1362
+ deletedEntity.id = idCopy;
1363
+ return deletedEntity;
1364
+ }
1365
+ /**
1366
+ * alias to remove
1367
+ */
1368
+ async delete(idOrEntity) {
1369
+ return this.remove(idOrEntity);
1370
+ }
1371
+ /**
1372
+ * alias to removeById
1373
+ */
1374
+ async deleteById(id) {
1375
+ return this.remove(id);
1376
+ }
1377
+ async bulkRemove(idsOrEntities) {
1378
+ idsOrEntities = idsOrEntities.map(id => {
1379
+ return _.isObject(id) ? id.id : id;
1380
+ });
1381
+ const models = [];
1382
+ for (let index = 0; index < idsOrEntities.length; index++) {
1383
+ const id = idsOrEntities[index];
1384
+ const model = await this.remove(id);
1385
+ models.push(model);
1386
+ }
1387
+ return models;
1388
+ }
1389
+ async bulkDelete(ids) {
1390
+ return this.bulkRemove(ids);
1391
+ }
1392
+ /**
1393
+ * Records the delete date of a given entity.
1394
+ */
1395
+ softRemove(entity, options) {
1396
+ return this.repo.softRemove(entity, options);
1397
+ }
1398
+ /**
1399
+ * Recovers a given entity in the database.
1400
+ */
1401
+ recover(entity, options) {
1402
+ return this.repo.recover(entity, options);
1403
+ }
1404
+ /**
1405
+ * Inserts a given entity into the database.
1406
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
1407
+ * Executes fast and efficient INSERT query.
1408
+ * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
1409
+ */
1410
+ insert(entity) {
1411
+ return this.repo.insert(entity);
1412
+ }
1413
+ async update(item) {
1414
+ const { id } = item;
1415
+ return await this.updateById(id, item);
1416
+ }
1417
+ async updateById(id, item) {
1418
+ const allowedPropsToUpdate = [];
1419
+ for (const key in item) {
1420
+ if (_.isObject(item) &&
1421
+ item.hasOwnProperty(key) &&
1422
+ typeof item[key] !== 'object' &&
1423
+ !_.isUndefined(this.repo.metadata.ownColumns.find(c => c.propertyName === key))) {
1424
+ allowedPropsToUpdate.push(key);
1425
+ }
1426
+ }
1427
+ for (let i = 0; i < allowedPropsToUpdate.length; i++) {
1428
+ const key = allowedPropsToUpdate[i];
1429
+ if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
1430
+ const toSet = item[key];
1431
+ await this.repo.update({
1432
+ id,
1433
+ }, {
1434
+ [key]: toSet,
1435
+ });
1436
+ }
1437
+ }
1438
+ let model = await this.repo.findOne({
1439
+ where: { id },
1440
+ });
1441
+ return model;
1442
+ }
1443
+ async bulkUpdate(items) {
1444
+ const models = [];
1445
+ for (let index = 0; index < items.length; index++) {
1446
+ const item = items[index];
1447
+ const { id } = item; // TOOD
1448
+ const model = await this.updateById(id, item);
1449
+ models.push(model);
1450
+ }
1451
+ return { models };
1452
+ }
1453
+ /**
1454
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
1455
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
1456
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
1457
+ */
1458
+ upsert(entityOrEntities, conflictPathsOrOptions) {
1459
+ return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
1460
+ }
1461
+ /**
1462
+ * Records the delete date of entities by a given criteria.
1463
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
1464
+ * Executes fast and efficient SOFT-DELETE query.
1465
+ * Does not check if entity exist in the database.
1466
+ */
1467
+ softDelete(criteria) {
1468
+ return this.repo.softDelete(criteria);
1469
+ }
1470
+ /**
1471
+ * Restores entities by a given criteria.
1472
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
1473
+ * Executes fast and efficient SOFT-DELETE query.
1474
+ * Does not check if entity exist in the database.
1475
+ */
1476
+ restore(criteria) {
1477
+ return this.repo.restore(criteria);
1478
+ }
1479
+ /**
1480
+ * Counts entities that match given options.
1481
+ * Useful for pagination.
1482
+ */
1483
+ count(options) {
1484
+ return this.repo.count(options);
1485
+ }
1486
+ /**
1487
+ * Counts entities that match given conditions.
1488
+ * Useful for pagination.
1489
+ */
1490
+ countBy(where) {
1491
+ return this.repo.countBy(where);
1492
+ }
1493
+ /**
1494
+ * Finds entities that match given find options.
1495
+ */
1496
+ find(options) {
1497
+ return this.repo.find(options);
1498
+ }
1499
+ /**
1500
+ * Finds entities that match given find options.
1501
+ */
1502
+ findBy(where) {
1503
+ return this.repo.findBy(where);
1504
+ }
1505
+ //
1506
+ /**
1507
+ * Finds entities that match given find options.
1508
+ * Also counts all entities that match given conditions,
1509
+ * but ignores pagination settings (from and take options).
1510
+ */
1511
+ findAndCount(options) {
1512
+ return this.repo.findAndCount(options);
1513
+ }
1514
+ /**
1515
+ * Finds entities that match given WHERE conditions.
1516
+ * Also counts all entities that match given conditions,
1517
+ * but ignores pagination settings (from and take options).
1518
+ */
1519
+ findAndCountBy(where) {
1520
+ return this.repo.findAndCountBy(where);
1521
+ }
1522
+ /**
1523
+ * Finds entities with ids.
1524
+ * Optionally find options or conditions can be applied.
1525
+ *
1526
+ * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
1527
+ *
1528
+ * .findBy({
1529
+ * id: In([1, 2, 3])
1530
+ * })
1531
+ */
1532
+ findByIds(ids) {
1533
+ return this.repo.findByIds(ids);
1534
+ }
1535
+ /**
1536
+ * Finds first entity by a given find options.
1537
+ * If entity was not found in the database - returns null.
1538
+ */
1539
+ findOne(options) {
1540
+ return this.repo.findOne(options);
1541
+ }
1542
+ /**
1543
+ * Finds first entity that matches given where condition.
1544
+ * If entity was not found in the database - returns null.
1545
+ */
1546
+ findOneBy(where) {
1547
+ return this.repo.findOneBy(where);
1548
+ }
1549
+ /**
1550
+ * Finds first entity that matches given id.
1551
+ * If entity was not found in the database - returns null.
1552
+ *
1553
+ * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
1554
+ *
1555
+ * .findOneBy({
1556
+ * id: 1 // where "id" is your primary column name
1557
+ * })
1558
+ */
1559
+ findOneById(id) {
1560
+ return this.repo.findOneById(id);
1561
+ }
1562
+ /**
1563
+ * Finds first entity by a given find options.
1564
+ * If entity was not found in the database - rejects with error.
1565
+ */
1566
+ findOneOrFail(options) {
1567
+ return this.repo.findOneOrFail(options);
1568
+ }
1569
+ /**
1570
+ * Finds first entity that matches given where condition.
1571
+ * If entity was not found in the database - rejects with error.
1572
+ */
1573
+ findOneByOrFail(where) {
1574
+ return this.repo.findOneByOrFail(where);
1575
+ }
1576
+ /**
1577
+ * Executes a raw SQL query and returns a raw database results.
1578
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
1579
+ */
1580
+ query(query, parameters) {
1581
+ return this.repo.query(query, parameters);
1582
+ }
1583
+ /**
1584
+ * Clears all the data from the given table/collection (truncates/drops it).
1585
+ *
1586
+ * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
1587
+ * @see https://stackoverflow.com/a/5972738/925151
1588
+ */
1589
+ clear() {
1590
+ return this.repo.clear();
1591
+ }
1592
+ /**
1593
+ * Increments some column by provided value of the entities matched given conditions.
1594
+ */
1595
+ increment(conditions, propertyPath, value) {
1596
+ return this.repo.increment(conditions, propertyPath, value);
1597
+ }
1598
+ /**
1599
+ * Decrements some column by provided value of the entities matched given conditions.
1600
+ */
1601
+ decrement(conditions, propertyPath, value) {
1602
+ return this.repo.decrement(conditions, propertyPath, value);
1603
+ }
1604
+ /**
1605
+ * @deprecated use findAndCount instead
1606
+ */
1607
+ async getAll() {
1608
+ const totalCount = await this.repo.count();
1609
+ const models = await this.repo.find();
1610
+ return { models, totalCount };
1611
+ }
1612
+ async getBy(id) {
1613
+ const model = await await this.repo.findOne({
1614
+ where: { id },
1615
+ });
1616
+ return model;
1617
+ }
1618
+ };
1619
+ BaseRepository = __decorate([
1620
+ TaonRepository({ className: 'BaseRepository' }),
1621
+ __metadata("design:paramtypes", [Function])
1622
+ ], BaseRepository);
1623
+ ;
1624
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-repository.ts
1625
+
1626
+ class BaseProvider extends BaseInjector {
1627
+ }
1628
+ ;
1629
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-provider.ts
1630
+
1631
+ const globalPublicStorage = Helpers.isBrowser ? window : global;
1632
+ ;
1633
+ ({}); // @--end-of-file-for-module=taon lib/storage.ts
1634
+
1635
+ const ENV$1 = Helpers.isBrowser ? window['ENV'] : global['ENV'];
1636
+ class TaonAdmin {
1637
+ constructor() {
1638
+ this.scrollableEnabled = false; // TOOD false by default
1639
+ this.onEditMode = new Subject();
1640
+ this.onEditMode$ = this.onEditMode.asObservable();
1641
+ this.enabledTabs = [];
1642
+ this.scrollableEnabled = !!ENV$1?.useGlobalNgxScrollbar;
1643
+ }
1644
+ static get Instance() {
1645
+ if (!globalPublicStorage[config.frameworkNames.taon]) {
1646
+ globalPublicStorage[config.frameworkNames.taon] = new TaonAdmin();
1647
+ }
1648
+ return globalPublicStorage[config.frameworkNames.taon];
1649
+ }
1650
+ setEditMode(value) {
1651
+ this.onEditMode.next(value);
1652
+ }
1653
+ setKeepWebsqlDbDataAfterReload(value) {
1654
+ this.keepWebsqlDbDataAfterReload = value;
1655
+ }
1656
+ hide() {
1657
+ this.draggablePopupMode = false;
1658
+ this.adminPanelIsOpen = false;
1659
+ }
1660
+ show() {
1661
+ this.draggablePopupMode = false;
1662
+ this.adminPanelIsOpen = true;
1663
+ }
1664
+ logout() { }
1665
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.5", ngImport: i0, type: TaonAdmin, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1666
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.5", ngImport: i0, type: TaonAdmin, providedIn: 'root' }); }
1667
+ }
1668
+ __decorate([
1669
+ Stor.property.in.localstorage.for(TaonAdmin).withDefaultValue(false),
1670
+ __metadata("design:type", Boolean)
1671
+ ], TaonAdmin.prototype, "adminPanelIsOpen", void 0);
1672
+ __decorate([
1673
+ Stor.property.in.localstorage.for(TaonAdmin).withDefaultValue(false),
1674
+ __metadata("design:type", Boolean)
1675
+ ], TaonAdmin.prototype, "draggablePopupMode", void 0);
1676
+ __decorate([
1677
+ Stor.property.in.localstorage.for(TaonAdmin).withDefaultValue(false),
1678
+ __metadata("design:type", Boolean)
1679
+ ], TaonAdmin.prototype, "draggablePopupModeFullScreen", void 0);
1680
+ __decorate([
1681
+ Stor.property.in.localstorage.for(TaonAdmin).withDefaultValue(false),
1682
+ __metadata("design:type", Boolean)
1683
+ ], TaonAdmin.prototype, "keepWebsqlDbDataAfterReload", void 0);
1684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.5", ngImport: i0, type: TaonAdmin, decorators: [{
1685
+ type: Injectable,
1686
+ args: [{ providedIn: 'root' }]
1687
+ }], ctorParameters: () => [] });
1688
+ ;
1689
+ ({}); // @--end-of-file-for-module=taon lib/ui/taon-admin-mode-configuration/taon-admin.service.ts
1690
+
1691
+ class DITaonContainer {
1692
+ static { this.instances = new Map(); }
1693
+ static resolve(target) {
1694
+ if (DITaonContainer.instances.has(target)) {
1695
+ return DITaonContainer.instances.get(target);
1696
+ }
1697
+ const injections = []; // tokens.map(token => Container.inject<any>(token));
1698
+ const instance = new target(...injections);
1699
+ DITaonContainer.instances.set(target, instance);
1700
+ return instance;
1701
+ }
1702
+ static inject(target) {
1703
+ return new Proxy({}, {
1704
+ get: (_, propName) => {
1705
+ let instance = DITaonContainer.instances.get(target) ||
1706
+ DITaonContainer.resolve(target);
1707
+ return typeof instance[propName] === 'function'
1708
+ ? instance[propName].bind(instance)
1709
+ : instance[propName];
1710
+ },
1711
+ set: (_, propName, value) => {
1712
+ let instance = DITaonContainer.instances.get(target) ||
1713
+ DITaonContainer.resolve(target);
1714
+ instance[propName] = value;
1715
+ return true;
1716
+ },
1717
+ });
1718
+ }
1719
+ }
1720
+ ;
1721
+ ({}); // @--end-of-file-for-module=taon lib/dependency-injection/di-container.ts
1722
+
1723
+ const getResponseValue = (response, options) => {
1724
+ const { req, res } = options || {};
1725
+ return new Promise(async (resolve, reject) => {
1726
+ const resp = response;
1727
+ if (!response && response.send === undefined) {
1728
+ console.error('[taon] Bad response value for function');
1729
+ resolve(undefined);
1730
+ }
1731
+ else if (typeof response === 'function') {
1732
+ const asyncResponse = response;
1733
+ try {
1734
+ const result = await asyncResponse(req, res);
1735
+ resolve(result);
1736
+ }
1737
+ catch (e) {
1738
+ console.error(e);
1739
+ console.error('[taon] Error during function call inside controller');
1740
+ Helpers.renderError(e);
1741
+ reject(e);
1742
+ }
1743
+ }
1744
+ else if (typeof response === 'object') {
1745
+ try {
1746
+ if (typeof response.send === 'function') {
1747
+ const result = response.send(req, res);
1748
+ resolve(result);
1749
+ }
1750
+ else {
1751
+ resolve(response.send);
1752
+ }
1753
+ }
1754
+ catch (error) {
1755
+ console.error('[taon] Bad synchonus function call ');
1756
+ Helpers.renderError(error);
1757
+ reject(error);
1758
+ }
1759
+ }
1760
+ else
1761
+ reject(`[taon] Not recognized type of reposne ${response}`);
1762
+ });
1763
+ };
1764
+ ;
1765
+ ({}); // @--end-of-file-for-module=taon lib/get-response-value.ts
1766
+
1767
+ const ENV = Helpers.isBrowser ? window['ENV'] : global['ENV'];
1768
+ ;
1769
+ ({}); // @--end-of-file-for-module=taon lib/env.ts
1770
+
1771
+ /* */
1772
+ /* */
1773
+ class RealtimeSubsManager {
1774
+ constructor(options) {
1775
+ this.options = options;
1776
+ this.isListening = false;
1777
+ this.observers = [];
1778
+ }
1779
+ startListenIfNotStarted(realtime) {
1780
+ if (this.options.core.ctx.disabledRealtime) {
1781
+ console.warn(`[Taon][startListenIfNotStarted] sockets are disabled`);
1782
+ return;
1783
+ }
1784
+ if (!realtime) {
1785
+ console.warn(`[Taon][startListenIfNotStarted] invalid socket connection`);
1786
+ return;
1787
+ }
1788
+ if (!this.isListening) {
1789
+ const subscribeEvent = Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.CUSTOM(this.options.core.ctx.contextName);
1790
+ this.isListening = true;
1791
+ if (this.options.customEvent) {
1792
+ realtime.emit(subscribeEvent, this.options.roomName);
1793
+ }
1794
+ else {
1795
+ if (_.isString(this.options.property)) {
1796
+ realtime.emit(Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), this.options.roomName);
1797
+ }
1798
+ else {
1799
+ realtime.emit(Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName), this.options.roomName);
1800
+ }
1801
+ }
1802
+ realtime.on(this.options.roomName, data => {
1803
+ this.update(data);
1804
+ });
1805
+ }
1806
+ }
1807
+ add(observer) {
1808
+ this.observers.push(observer);
1809
+ }
1810
+ remove(observer) {
1811
+ this.observers = this.observers.filter(obs => obs !== observer);
1812
+ if (this.observers.length === 0) {
1813
+ this.isListening = false;
1814
+ const { core, customEvent, roomName, property } = this.options;
1815
+ const realtime = core.FE_REALTIME;
1816
+ if (customEvent) {
1817
+ realtime.emit(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.CUSTOM(this.options.core.ctx.contextName), roomName);
1818
+ }
1819
+ else {
1820
+ if (_.isString(property)) {
1821
+ realtime.emit(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
1822
+ }
1823
+ else {
1824
+ realtime.emit(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
1825
+ }
1826
+ }
1827
+ }
1828
+ }
1829
+ update(data) {
1830
+ const ngZone = this.options.core.ctx.ngZone;
1831
+ this.observers.forEach(observer => {
1832
+ if (!observer.closed) {
1833
+ if (ngZone) {
1834
+ ngZone.run(() => {
1835
+ observer.next(data);
1836
+ });
1837
+ }
1838
+ else {
1839
+ observer.next(data);
1840
+ }
1841
+ }
1842
+ });
1843
+ }
1844
+ }
1845
+ ;
1846
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-subs-manager.ts
1847
+
1848
+ class RealtimeClient {
1849
+ constructor(core) {
1850
+ this.core = core;
1851
+ this.subsmanagers = {};
1852
+ this.core = core;
1853
+ if (!core.ctx.disabledRealtime) {
1854
+ this.init();
1855
+ }
1856
+ }
1857
+ init() {
1858
+ const nspPath = {
1859
+ global: this.core.pathFor(),
1860
+ realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
1861
+ };
1862
+ this.core.ctx.logRealtime &&
1863
+ console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
1864
+ this.core.ctx.logRealtime &&
1865
+ console.info('[CLIENT] NAMESPACE REALTIME', nspPath.realtime.href + ` host: ${this.core.ctx.host}`);
1866
+ this.core.FE = this.core.strategy.io(nspPath.global.origin, {
1867
+ path: nspPath.global.pathname,
1868
+ });
1869
+ if (this.core.FE.on) {
1870
+ this.core.FE.on('connect', () => {
1871
+ console.info(`[CLIENT] conented to GLOBAL namespace ${this.core.FE.id} of host: ${this.core.ctx.host}`);
1872
+ });
1873
+ }
1874
+ this.core.FE_REALTIME = this.core.strategy.io(nspPath.realtime.origin, {
1875
+ path: nspPath.realtime.pathname,
1876
+ });
1877
+ if (this.core.FE_REALTIME.on) {
1878
+ this.core.FE_REALTIME.on('connect', () => {
1879
+ console.info(`[CLIENT] conented to REALTIME namespace ${this.core.FE_REALTIME.id} host: ${this.core.ctx.host}`);
1880
+ });
1881
+ }
1882
+ }
1883
+ /**
1884
+ * Changes trigger on backend needs to be done manually.. example code:
1885
+ *
1886
+ * ...
1887
+ * Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
1888
+ * ...
1889
+ */
1890
+ listenChangesEntity(entityClassFn, idOrUniqValue, options) {
1891
+ options = options || {};
1892
+ const { property, customEvent } = options;
1893
+ const className = !customEvent && ClassHelpers.getName(entityClassFn);
1894
+ if (_.isString(property)) {
1895
+ if (property.trim() === '') {
1896
+ throw new Error(`[Taon][listenChangesEntity.. incorect property '' for ${className}`);
1897
+ }
1898
+ }
1899
+ return new Observable(observer => {
1900
+ if (this.core.ctx.disabledRealtime) {
1901
+ console.error(`[Taon][realtime rxjs] remove taon config flag:
1902
+
1903
+ ...
1904
+ disabledRealtime: true
1905
+ ...
1906
+
1907
+ to use socket realtime connection;
1908
+ `);
1909
+ return () => {
1910
+ };
1911
+ }
1912
+ let roomName;
1913
+ if (customEvent) {
1914
+ roomName = Symbols.REALTIME.ROOM_NAME.CUSTOM(this.core.ctx.contextName, customEvent);
1915
+ }
1916
+ else {
1917
+ roomName = _.isString(property)
1918
+ ? Symbols.REALTIME.ROOM_NAME.UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, idOrUniqValue)
1919
+ : Symbols.REALTIME.ROOM_NAME.UPDATE_ENTITY(this.core.ctx.contextName, className, idOrUniqValue);
1920
+ }
1921
+ const roomSubOptions = {
1922
+ core: this.core,
1923
+ property,
1924
+ roomName,
1925
+ customEvent,
1926
+ };
1927
+ const subManagerId = this.getRoomIdFrom(roomSubOptions);
1928
+ if (!this.subsmanagers[subManagerId]) {
1929
+ this.subsmanagers[subManagerId] = new RealtimeSubsManager(roomSubOptions);
1930
+ }
1931
+ const inst = this.subsmanagers[subManagerId];
1932
+ inst.add(observer);
1933
+ inst.startListenIfNotStarted(this.core.FE_REALTIME);
1934
+ return () => {
1935
+ inst.remove(observer);
1936
+ };
1937
+ });
1938
+ }
1939
+ listenChangesEntityTable(entityClassFn) {
1940
+ const className = ClassHelpers.getName(entityClassFn);
1941
+ return this.listenChangesEntity(entityClassFn, void 0, {
1942
+ customEvent: Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
1943
+ });
1944
+ }
1945
+ /**
1946
+ * Changes trigger on backend needs to be done manually.. example code:
1947
+ *
1948
+ * ...
1949
+ * Context.Realtime.Server.TrigggerEntityChanges(myEntityInstance);
1950
+ * // or
1951
+ * Context.Realtime.Server.TrigggerEntityPropertyChanges(myEntityInstance,{ property: 'geolocationX' });
1952
+ * ...
1953
+ */
1954
+ listenChangesEntityObj(entity, options) {
1955
+ const classFn = ClassHelpers.getClassFnFromObject(entity);
1956
+ const uniqueKey = ClassHelpers.getUniquKey(classFn);
1957
+ return this.listenChangesEntity(classFn, entity[uniqueKey], options);
1958
+ }
1959
+ listenChangesCustomEvent(customEvent) {
1960
+ return this.listenChangesEntity(void 0, void 0, {
1961
+ customEvent,
1962
+ });
1963
+ }
1964
+ getRoomIdFrom(options) {
1965
+ const url = new URL(options.core.ctx.host);
1966
+ return `${this.core.ctx.contextName}:${url.origin}|${options.roomName}|${options.property}|${options.customEvent}`;
1967
+ }
1968
+ }
1969
+ ;
1970
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-client.ts
1971
+
1972
+ const SOCKET_EVENT_DEBOUNCE = 500;
1973
+ class RealtimeServer {
1974
+ constructor(core) {
1975
+ this.core = core;
1976
+ this.jobs = {};
1977
+ this.core = core;
1978
+ if (!core.ctx.disabledRealtime) {
1979
+ this.init();
1980
+ }
1981
+ }
1982
+ init() {
1983
+ const nspPath = {
1984
+ global: this.core.pathFor(),
1985
+ realtime: this.core.pathFor(Symbols.REALTIME.NAMESPACE(this.core.ctx.contextName)),
1986
+ };
1987
+ this.core.BE = new this.core.strategy.Server(this.core.ctx.serverTcpUdp, {
1988
+ path: nspPath.global.pathname,
1989
+ cors: {
1990
+ origin: this.core.ctx.config.frontendHost,
1991
+ methods: this.core.allHttpMethods,
1992
+ },
1993
+ });
1994
+ this.core.ctx.logRealtime &&
1995
+ console.info(`CREATE GLOBAL NAMESPACE: '${this.core.BE.path()}' , path: '${nspPath.global.pathname}'`);
1996
+ this.core.BE.on('connection', clientSocket => {
1997
+ if (Helpers.isElectron) {
1998
+ // @ts-ignore
1999
+ this.core.BE.emit('connect'); // TODO QUICK_FIX
2000
+ }
2001
+ console.info(`client conected to namespace "${clientSocket.nsp?.name}", host: ${this.core.ctx.host}`);
2002
+ });
2003
+ this.core.BE_REALTIME = new this.core.strategy.Server(this.core.ctx.serverTcpUdp, {
2004
+ path: nspPath.realtime.pathname,
2005
+ cors: {
2006
+ origin: this.core.ctx.config.frontendHost,
2007
+ methods: this.core.allHttpMethods,
2008
+ },
2009
+ });
2010
+ this.core.ctx.logRealtime &&
2011
+ console.info(`CREATE REALTIME NAMESPACE: '${this.core.BE_REALTIME.path()}' , path: '${nspPath.realtime.pathname}' `);
2012
+ this.core.BE_REALTIME.on('connection', backendSocketForClient => {
2013
+ console.info(`client conected to namespace "${backendSocketForClient.nsp?.name}", host: ${this.core.ctx.host}`);
2014
+ if (Helpers.isElectron) {
2015
+ // @ts-ignore
2016
+ backendSocketForClient = this.core.BE_REALTIME; // TODO QUICK_FIX
2017
+ this.core.BE_REALTIME.emit('connect');
2018
+ }
2019
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.CUSTOM(this.core.ctx.contextName), roomName => {
2020
+ console.info(`Joining room ${roomName} in namespace REALTIME` +
2021
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2022
+ backendSocketForClient.join(roomName);
2023
+ });
2024
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
2025
+ console.info(`Joining room ${roomName} in namespace REALTIME` +
2026
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2027
+ backendSocketForClient.join(roomName);
2028
+ });
2029
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.SUBSCRIBE.ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
2030
+ console.info(`Joining room ${roomName} in namespace REALTIME ` +
2031
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2032
+ backendSocketForClient.join(roomName);
2033
+ });
2034
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.CUSTOM(this.core.ctx.contextName), roomName => {
2035
+ console.info(`Leaving room ${roomName} in namespace REALTIME` +
2036
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2037
+ backendSocketForClient.leave(roomName);
2038
+ });
2039
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
2040
+ console.info(`Leaving room ${roomName} in namespace REALTIME ` +
2041
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2042
+ backendSocketForClient.leave(roomName);
2043
+ });
2044
+ backendSocketForClient.on(Symbols.REALTIME.ROOM_NAME.UNSUBSCRIBE.ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
2045
+ console.info(`Leaving room ${roomName} in namespace REALTIME ` +
2046
+ ` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
2047
+ backendSocketForClient.leave(roomName);
2048
+ });
2049
+ });
2050
+ }
2051
+ triggerChanges(entityObjOrClass, property, valueOfUniquPropery, customEvent, customEventData) {
2052
+ let roomName;
2053
+ if (this.core.ctx.disabledRealtime) {
2054
+ return;
2055
+ }
2056
+ if (customEvent) {
2057
+ roomName = Symbols.REALTIME.ROOM_NAME.CUSTOM(this.core.ctx.contextName, customEvent);
2058
+ }
2059
+ else {
2060
+ let entityFn = entityObjOrClass;
2061
+ const enittyIsObject = !_.isFunction(entityObjOrClass) && _.isObject(entityObjOrClass);
2062
+ if (enittyIsObject) {
2063
+ entityFn = ClassHelpers.getClassFnFromObject(entityObjOrClass);
2064
+ }
2065
+ const uniqueKey = ClassHelpers.getUniquKey(entityFn);
2066
+ if (enittyIsObject) {
2067
+ valueOfUniquPropery = entityObjOrClass[uniqueKey];
2068
+ }
2069
+ if (!valueOfUniquPropery) {
2070
+ Helpers.error(`[Taon][Realtime] Entity without iD ! ${ClassHelpers.getName(entityFn)} `, true, true);
2071
+ return;
2072
+ }
2073
+ roomName = _.isString(property)
2074
+ ? Symbols.REALTIME.ROOM_NAME.UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, ClassHelpers.getName(entityFn), property, valueOfUniquPropery)
2075
+ : Symbols.REALTIME.ROOM_NAME.UPDATE_ENTITY(this.core.ctx.contextName, ClassHelpers.getName(entityFn), valueOfUniquPropery);
2076
+ }
2077
+ const job = () => {
2078
+ console.log(`Trigger realtime: ${this.core.ctx.contextName}/${roomName}`);
2079
+ this.core.BE_REALTIME.in(roomName).emit(roomName, // roomName == eventName in room na
2080
+ customEventData ? customEventData : '');
2081
+ };
2082
+ if (!_.isFunction(this.jobs[roomName])) {
2083
+ this.jobs[roomName] = _.debounce(() => {
2084
+ job();
2085
+ }, SOCKET_EVENT_DEBOUNCE);
2086
+ }
2087
+ this.jobs[roomName]();
2088
+ }
2089
+ trigggerEntityChanges(entityObjOrClass, idToTrigger) {
2090
+ if (this.core.ctx.disabledRealtime) {
2091
+ const className = ClassHelpers.getName(entityObjOrClass);
2092
+ console.warn(`[Taon][TrigggerEntityChanges] Entity "${className}' is not realtime`);
2093
+ return;
2094
+ }
2095
+ this.triggerChanges(entityObjOrClass, void 0, idToTrigger);
2096
+ }
2097
+ trigggerEntityPropertyChanges(entityObjOrClass, property, idToTrigger) {
2098
+ if (this.core.ctx.disabledRealtime) {
2099
+ const className = ClassHelpers.getName(entityObjOrClass);
2100
+ console.warn(`[Taon][TrigggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
2101
+ return;
2102
+ }
2103
+ if (_.isArray(property)) {
2104
+ property.forEach(propertyFromArr => {
2105
+ this.triggerChanges(entityObjOrClass, propertyFromArr, idToTrigger);
2106
+ });
2107
+ }
2108
+ else {
2109
+ this.triggerChanges(entityObjOrClass, property, idToTrigger);
2110
+ }
2111
+ }
2112
+ triggerCustomEvent(customEvent, dataToPush) {
2113
+ this.triggerChanges(void 0, void 0, void 0, customEvent, dataToPush);
2114
+ }
2115
+ trigggerEntityTableChanges(entityClass) {
2116
+ const className = ClassHelpers.getName(entityClass);
2117
+ if (this.core.ctx.disabledRealtime) {
2118
+ console.warn(`[Taon][TrigggerEntityTableChanges] Entity "${className}' is not realtime`);
2119
+ return;
2120
+ }
2121
+ this.triggerChanges(entityClass, void 0, void 0, Symbols.REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className));
2122
+ }
2123
+ }
2124
+ ;
2125
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-server.ts
2126
+
2127
+ class RealtimeStrategy {
2128
+ constructor(ctx) {
2129
+ this.ctx = ctx;
2130
+ }
2131
+ testTypes() {
2132
+ }
2133
+ }
2134
+ ;
2135
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy.ts
2136
+
2137
+ /* */
2138
+ /* */
2139
+ /* */
2140
+ class IpcMainNamespace {
2141
+ constructor(name) {
2142
+ this.name = name;
2143
+ this.rooms = {};
2144
+ this.listeners = {};
2145
+ }
2146
+ on(event, callback) {
2147
+ /* */
2148
+ /* */
2149
+ /* */
2150
+ /* */
2151
+ /* */
2152
+ /* */
2153
+ /* */
2154
+ /* */
2155
+ /* */
2156
+ return (void 0);
2157
+ }
2158
+ off(event, callback) {
2159
+ /* */
2160
+ /* */
2161
+ /* */
2162
+ /* */
2163
+ /* */
2164
+ /* */
2165
+ /* */
2166
+ /* */
2167
+ /* */
2168
+ /* */
2169
+ /* */
2170
+ /* */
2171
+ /* */
2172
+ return (void 0);
2173
+ }
2174
+ emit(event, ...args) {
2175
+ /* */
2176
+ /* */
2177
+ /* */
2178
+ /* */
2179
+ /* */
2180
+ /* */
2181
+ /* */
2182
+ return (void 0);
2183
+ }
2184
+ to(room) {
2185
+ return {
2186
+ emit: (event, ...args) => {
2187
+ const emitEvent = `(${this.name}) "${event}"`;
2188
+ const allWindows = Electron.BrowserWindow.getAllWindows();
2189
+ allWindows.forEach((win, index) => {
2190
+ win.webContents.send(emitEvent, ...args);
2191
+ });
2192
+ },
2193
+ };
2194
+ }
2195
+ in(room) {
2196
+ return {
2197
+ emit: (event, ...args) => {
2198
+ const sendEventKey = `(${this.name}) "${event}"`;
2199
+ const allWindows = Electron.BrowserWindow.getAllWindows();
2200
+ allWindows.forEach((win, index) => {
2201
+ win.webContents.send(sendEventKey, ...args);
2202
+ });
2203
+ },
2204
+ };
2205
+ }
2206
+ join(webContents, room) {
2207
+ if (!this.rooms[room]) {
2208
+ this.rooms[room] = new Set();
2209
+ }
2210
+ this.rooms[room].add(webContents);
2211
+ }
2212
+ leave(webContents, room) {
2213
+ if (this.rooms[room]) {
2214
+ this.rooms[room].delete(webContents);
2215
+ if (this.rooms[room].size === 0) {
2216
+ delete this.rooms[room];
2217
+ }
2218
+ }
2219
+ }
2220
+ path() {
2221
+ return this.name;
2222
+ }
2223
+ get nsp() {
2224
+ const self = this;
2225
+ return {
2226
+ get name() {
2227
+ return self.name;
2228
+ },
2229
+ };
2230
+ }
2231
+ }
2232
+ ;
2233
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.ts
2234
+
2235
+ class ioIpcStrategy {
2236
+ constructor(contextName) {
2237
+ this.contextName = contextName;
2238
+ this.namespaces = {
2239
+ ' /': new IpcMainNamespace('/'),
2240
+ };
2241
+ }
2242
+ of(namespace) {
2243
+ if (!this.namespaces[namespace]) {
2244
+ this.namespaces[namespace] = new IpcMainNamespace(namespace);
2245
+ }
2246
+ return this.namespaces[namespace];
2247
+ }
2248
+ on(event, callback) {
2249
+ const eventKey = `(${this.contextName}) "${event}"`;
2250
+ this.namespaces['/'].on(eventKey, callback);
2251
+ }
2252
+ emit(event, ...args) {
2253
+ const eventKey = `(${this.contextName}) "${event}"`;
2254
+ this.namespaces['/'].emit(eventKey, ...args);
2255
+ }
2256
+ path() {
2257
+ return '/';
2258
+ }
2259
+ get nsp() {
2260
+ return {
2261
+ get name() {
2262
+ return '/';
2263
+ },
2264
+ };
2265
+ }
2266
+ in(room) {
2267
+ return {
2268
+ emit: (event, ...args) => {
2269
+ Object.values(this.namespaces).forEach(namespace => {
2270
+ namespace.to(room).emit(event, ...args);
2271
+ });
2272
+ },
2273
+ };
2274
+ }
2275
+ }
2276
+ ;
2277
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.ts
2278
+
2279
+ class IpcRendererNamespace {
2280
+ constructor(name) {
2281
+ this.name = name;
2282
+ this.listeners = {};
2283
+ this.ipcRenderer = window.require('electron').ipcRenderer;
2284
+ }
2285
+ on(eventName, callback) {
2286
+ if (!this.listeners[eventName]) {
2287
+ this.listeners[eventName] = [];
2288
+ }
2289
+ this.listeners[eventName].push(callback);
2290
+ const listenToEvent = `(${this.name}) "${eventName}"`;
2291
+ this.ipcRenderer.on(listenToEvent, callback);
2292
+ if (eventName === 'connect') {
2293
+ this.emit('connection');
2294
+ }
2295
+ else {
2296
+ this.emit(eventName);
2297
+ }
2298
+ }
2299
+ off(event, callback) {
2300
+ if (!this.listeners[event])
2301
+ return;
2302
+ if (callback) {
2303
+ this.listeners[event] = this.listeners[event].filter(listener => listener !== callback);
2304
+ }
2305
+ else {
2306
+ delete this.listeners[event];
2307
+ }
2308
+ const removeListener = `(${this.name}) "${event}"`;
2309
+ this.ipcRenderer.removeListener(removeListener, callback);
2310
+ }
2311
+ emit(event, ...args) {
2312
+ const emitEvent = `(${this.name}) "${event}"`;
2313
+ this.ipcRenderer.send(emitEvent, ...args);
2314
+ }
2315
+ }
2316
+ ;
2317
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.ts
2318
+
2319
+ class IpcRendererWrapper {
2320
+ constructor(contextName) {
2321
+ this.contextName = contextName;
2322
+ this.namespaces = {
2323
+ '/': new IpcRendererNamespace('/'),
2324
+ };
2325
+ this.connected = false;
2326
+ }
2327
+ of(namespace) {
2328
+ if (!this.namespaces[namespace]) {
2329
+ this.namespaces[namespace] = new IpcRendererNamespace(namespace);
2330
+ }
2331
+ return this.namespaces[namespace];
2332
+ }
2333
+ on(event, callback) {
2334
+ this.namespaces['/'].on(event, callback);
2335
+ }
2336
+ emit(event, ...args) {
2337
+ this.namespaces['/'].emit(event, ...args);
2338
+ }
2339
+ }
2340
+ ;
2341
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.ts
2342
+
2343
+ /**
2344
+ * Purpose:
2345
+ * - backend-browser communication between 2 processes in electron mode
2346
+ */
2347
+ class RealtimeStrategyIpc extends RealtimeStrategy {
2348
+ toString() {
2349
+ return 'ipc';
2350
+ }
2351
+ establishConnection() {
2352
+ throw new Error('Method not implemented.');
2353
+ }
2354
+ constructor(ctx) {
2355
+ super(ctx);
2356
+ this.ctx = ctx;
2357
+ this.contextsServers = {};
2358
+ this.contextsIO = {};
2359
+ }
2360
+ get io() {
2361
+ return ((__, { path: namespacePath }) => {
2362
+ if (this.contextsIO[namespacePath]) {
2363
+ return this.contextsIO[namespacePath];
2364
+ }
2365
+ const wrap = new IpcRendererWrapper(this.ctx.contextName);
2366
+ const nsp = wrap.of(namespacePath);
2367
+ this.contextsIO[namespacePath] = nsp;
2368
+ return nsp;
2369
+ });
2370
+ return void 0;
2371
+ }
2372
+ get Server() {
2373
+ return ((___, { path: namespacePath }) => {
2374
+ if (this.contextsServers[namespacePath]) {
2375
+ return this.contextsServers[namespacePath];
2376
+ }
2377
+ const wrap = new ioIpcStrategy(this.ctx.contextName);
2378
+ const nsp = wrap.of(namespacePath);
2379
+ this.contextsServers[namespacePath] = nsp;
2380
+ return nsp;
2381
+ });
2382
+ return void 0;
2383
+ }
2384
+ }
2385
+ ;
2386
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-ipc.ts
2387
+
2388
+ class MockNamespace {
2389
+ constructor(name, contextName) {
2390
+ this.name = name;
2391
+ this.contextName = contextName;
2392
+ this.rooms = {};
2393
+ this.sockets = new Set();
2394
+ }
2395
+ on(event, callback) {
2396
+ if (event === 'connection') {
2397
+ this.sockets.forEach(socket => callback(socket));
2398
+ }
2399
+ }
2400
+ emit(event, data) {
2401
+ this.sockets.forEach(socket => socket.emit(event, data));
2402
+ }
2403
+ to(room) {
2404
+ return {
2405
+ emit: (event, data) => {
2406
+ if (this.rooms[room]) {
2407
+ this.rooms[room].forEach(socket => socket.emit(event, data));
2408
+ }
2409
+ }
2410
+ };
2411
+ }
2412
+ joinRoom(socket, room) {
2413
+ if (!this.rooms[room]) {
2414
+ this.rooms[room] = new Set();
2415
+ }
2416
+ this.rooms[room].add(socket);
2417
+ }
2418
+ leaveRoom(socket, room) {
2419
+ if (this.rooms[room]) {
2420
+ this.rooms[room].delete(socket);
2421
+ if (this.rooms[room].size === 0) {
2422
+ delete this.rooms[room];
2423
+ }
2424
+ }
2425
+ }
2426
+ addSocket(socket) {
2427
+ this.sockets.add(socket);
2428
+ }
2429
+ removeSocket(socket) {
2430
+ this.sockets.delete(socket);
2431
+ }
2432
+ }
2433
+ ;
2434
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.ts
2435
+
2436
+ class MockSocket {
2437
+ constructor(id, namespace) {
2438
+ this.id = id;
2439
+ this.namespace = namespace;
2440
+ this.listeners = {};
2441
+ this.namespace.addSocket(this);
2442
+ }
2443
+ on(event, callback) {
2444
+ if (!this.listeners[event]) {
2445
+ this.listeners[event] = [];
2446
+ }
2447
+ this.listeners[event].push(callback);
2448
+ }
2449
+ off(event, callback) {
2450
+ if (!this.listeners[event])
2451
+ return;
2452
+ if (callback) {
2453
+ this.listeners[event] = this.listeners[event].filter(listener => listener !== callback);
2454
+ }
2455
+ else {
2456
+ delete this.listeners[event];
2457
+ }
2458
+ }
2459
+ emit(event, data) {
2460
+ if (this.listeners[event]) {
2461
+ this.listeners[event].forEach(listener => listener(data));
2462
+ }
2463
+ }
2464
+ join(room) {
2465
+ this.namespace.joinRoom(this, room);
2466
+ }
2467
+ leave(room) {
2468
+ this.namespace.leaveRoom(this, room);
2469
+ }
2470
+ disconnect() {
2471
+ this.emit('disconnect');
2472
+ this.namespace.removeSocket(this);
2473
+ this.listeners = {};
2474
+ }
2475
+ }
2476
+ ;
2477
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.ts
2478
+
2479
+ class MockServer {
2480
+ constructor(contextName) {
2481
+ this.contextName = contextName;
2482
+ this.namespaces = {
2483
+ '/': new MockNamespace('/', this.contextName)
2484
+ };
2485
+ }
2486
+ of(namespace) {
2487
+ if (!this.namespaces[namespace]) {
2488
+ this.namespaces[namespace] = new MockNamespace(namespace, this.contextName);
2489
+ }
2490
+ return this.namespaces[namespace];
2491
+ }
2492
+ on(event, callback) {
2493
+ if (event === 'connection') {
2494
+ this.namespaces['/'].on('connection', callback);
2495
+ }
2496
+ }
2497
+ emit(event, data) {
2498
+ this.namespaces['/'].emit(event, data);
2499
+ }
2500
+ connect(id, namespace = '/') {
2501
+ const ns = this.of(namespace);
2502
+ const socket = new MockSocket(id, ns);
2503
+ ns.on('connection', (socket) => {
2504
+ socket.emit('connect');
2505
+ });
2506
+ return socket;
2507
+ }
2508
+ }
2509
+ ;
2510
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.ts
2511
+
2512
+ class MockClientSocket {
2513
+ constructor(serverSocket, contextName) {
2514
+ this.serverSocket = serverSocket;
2515
+ this.contextName = contextName;
2516
+ this.listeners = {};
2517
+ serverSocket.on('message', (data) => this.emit('message', data));
2518
+ }
2519
+ on(event, callback) {
2520
+ if (!this.listeners[event]) {
2521
+ this.listeners[event] = [];
2522
+ }
2523
+ this.listeners[event].push(callback);
2524
+ }
2525
+ off(event, callback) {
2526
+ if (!this.listeners[event])
2527
+ return;
2528
+ if (callback) {
2529
+ this.listeners[event] = this.listeners[event].filter(listener => listener !== callback);
2530
+ }
2531
+ else {
2532
+ delete this.listeners[event];
2533
+ }
2534
+ }
2535
+ emit(event, data) {
2536
+ this.serverSocket.emit(event, data);
2537
+ if (this.listeners[event]) {
2538
+ this.listeners[event].forEach(listener => listener(data));
2539
+ }
2540
+ }
2541
+ disconnect() {
2542
+ this.serverSocket.disconnect();
2543
+ this.listeners = {};
2544
+ }
2545
+ join(room) {
2546
+ this.serverSocket.join(room);
2547
+ }
2548
+ leave(room) {
2549
+ this.serverSocket.leave(room);
2550
+ }
2551
+ }
2552
+ function mockIo(server) {
2553
+ return (namespace = '/') => {
2554
+ const socketId = Math.random().toString(36).substring(2);
2555
+ const serverSocket = server.connect(socketId, namespace);
2556
+ return new MockClientSocket(serverSocket, server.contextName);
2557
+ };
2558
+ }
2559
+ ;
2560
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.ts
2561
+
2562
+ ;
2563
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.ts
2564
+
2565
+ /**
2566
+ * Purpose:
2567
+ * - browser-browser communication mock (in websql mode)
2568
+ */
2569
+ class RealtimeStrategyMock extends RealtimeStrategy {
2570
+ toString() {
2571
+ return 'mock';
2572
+ }
2573
+ constructor(ctx) {
2574
+ super(ctx);
2575
+ this.ctx = ctx;
2576
+ }
2577
+ get Server() {
2578
+ return MockServer;
2579
+ }
2580
+ ;
2581
+ get io() {
2582
+ return mockIo;
2583
+ }
2584
+ establishConnection() {
2585
+ throw new Error('Method not implemented.');
2586
+ }
2587
+ }
2588
+ ;
2589
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-mock.ts
2590
+
2591
+ /**
2592
+ * Purpose:
2593
+ * - backend-browser communication
2594
+ * - backend-backend communication
2595
+ */
2596
+ class RealtimeStrategySocketIO extends RealtimeStrategy {
2597
+ toString() {
2598
+ return 'socket-io';
2599
+ }
2600
+ constructor(ctx) {
2601
+ super(ctx);
2602
+ this.ctx = ctx;
2603
+ }
2604
+ get Server() {
2605
+ /* */
2606
+ /* */
2607
+ return (void 0);
2608
+ }
2609
+ ;
2610
+ get io() {
2611
+ return io;
2612
+ }
2613
+ establishConnection() {
2614
+ throw new Error('Method not implemented.');
2615
+ }
2616
+ }
2617
+ ;
2618
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/realtime-strategy-socket-io.ts
2619
+
2620
+ ;
2621
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-strategy/index.ts
2622
+
2623
+ /**
2624
+ * Realtime class
2625
+ * - mock (when browser-browser)
2626
+ * - sockets (from socket io when backend-browser)
2627
+ * - ipc (when electron is used or between processes)
2628
+ * - webworker (when webworker is used in browser or nodejs)
2629
+ */
2630
+ class RealtimeCore {
2631
+ constructor(ctx) {
2632
+ this.ctx = ctx;
2633
+ this.allHttpMethods = [
2634
+ 'GET',
2635
+ 'POST',
2636
+ 'PUT',
2637
+ 'DELETE',
2638
+ 'PATCH',
2639
+ 'OPTIONS',
2640
+ 'HEAD',
2641
+ ];
2642
+ this.strategy = this.resolveStrategy();
2643
+ ctx.logFramework &&
2644
+ console.log(`[taon] realtime strategy: ${this.strategy}`);
2645
+ this.client = new RealtimeClient(this);
2646
+ this.server = new RealtimeServer(this);
2647
+ }
2648
+ resolveStrategy() {
2649
+ if (this.ctx.mode === 'backend-frontend(websql)') {
2650
+ return new RealtimeStrategyMock(this.ctx);
2651
+ }
2652
+ if (this.ctx.mode === 'backend-frontend(ipc-electron)') {
2653
+ return new RealtimeStrategyIpc(this.ctx);
2654
+ }
2655
+ return new RealtimeStrategySocketIO(this.ctx);
2656
+ }
2657
+ pathFor(namespace) {
2658
+ const uri = this.ctx.uri;
2659
+ let nsp = namespace ? namespace : '';
2660
+ nsp = nsp === '/' ? '' : nsp;
2661
+ const pathname = uri.pathname !== '/' ? uri.pathname : '';
2662
+ let prefix = `taonContext-`;
2663
+ if (Helpers.isElectron) {
2664
+ prefix = ``;
2665
+ }
2666
+ const href = `${uri.origin}${pathname}/${prefix}${nsp}`;
2667
+ return new URL(href);
2668
+ }
2669
+ }
2670
+ ;
2671
+ ({}); // @--end-of-file-for-module=taon lib/realtime/realtime-core.ts
2672
+
2673
+ class TaonSubscriberOptions extends Models.DecoratorAbstractOpt {
2674
+ }
2675
+ function TaonSubscriber(options) {
2676
+ return function (constructor) {
2677
+ Reflect.defineMetadata(Symbols.metadata.options.repository, options, constructor);
2678
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
2679
+ ClassHelpers.setName(constructor, options?.className);
2680
+ return class extends constructor {
2681
+ constructor(...args) {
2682
+ super(...args);
2683
+ const methodNamesAll = ClassHelpers.getMethodsNames(constructor.prototype);
2684
+ const methodNames = methodNamesAll.filter(m => {
2685
+ return (!['__trigger_event__', 'clone'].includes(m) &&
2686
+ !m.startsWith('_') &&
2687
+ !m.startsWith('inject'));
2688
+ });
2689
+ methodNames.forEach(methodName => {
2690
+ const originalMethod = this[methodName];
2691
+ this[methodName] = async (...methodArgs) => {
2692
+ const result = originalMethod.apply(this, methodArgs);
2693
+ if (result instanceof Promise) {
2694
+ await result;
2695
+ }
2696
+ if (options.allowedEvents === undefined ||
2697
+ options.allowedEvents.includes(methodName)) {
2698
+ // @ts-ignore
2699
+ this.__trigger_event__(methodName);
2700
+ }
2701
+ return result;
2702
+ };
2703
+ });
2704
+ }
2705
+ };
2706
+ };
2707
+ }
2708
+ ;
2709
+ ({}); // @--end-of-file-for-module=taon lib/decorators/classes/subscriber-decorator.ts
2710
+
2711
+ let BaseSubscriberForEntity = class BaseSubscriberForEntity extends BaseInjector {
2712
+ /**
2713
+ * Called after entity is loaded.
2714
+ */
2715
+ afterLoad(entity) {
2716
+ console.log(`AFTER ENTITY LOADED: `, entity);
2717
+ }
2718
+ /**
2719
+ * Called before query execution.
2720
+ */
2721
+ beforeQuery(event) {
2722
+ console.log(`BEFORE QUERY: `, event.query);
2723
+ }
2724
+ /**
2725
+ * Called after query execution.
2726
+ */
2727
+ afterQuery(event) {
2728
+ console.log(`AFTER QUERY: `, event.query);
2729
+ }
2730
+ /**
2731
+ * Called before entity insertion.
2732
+ */
2733
+ beforeInsert(event) {
2734
+ console.log(`BEFORE ENTITY INSERTED: `, event.entity);
2735
+ }
2736
+ /**
2737
+ * Called after entity insertion.
2738
+ */
2739
+ afterInsert(event) {
2740
+ console.log(`AFTER ENTITY INSERTED: `, event.entity);
2741
+ }
2742
+ /**
2743
+ * Called before entity update.
2744
+ */
2745
+ beforeUpdate(event) {
2746
+ console.log(`BEFORE ENTITY UPDATED: `, event.entity);
2747
+ }
2748
+ /**
2749
+ * Called after entity update.
2750
+ */
2751
+ afterUpdate(event) {
2752
+ console.log(`AFTER ENTITY UPDATED: `, event.entity);
2753
+ }
2754
+ /**
2755
+ * Called before entity removal.
2756
+ */
2757
+ beforeRemove(event) {
2758
+ console.log(`BEFORE ENTITY WITH ID ${event.entityId} REMOVED: `, event.entity);
2759
+ }
2760
+ /**
2761
+ * Called after entity removal.
2762
+ */
2763
+ afterRemove(event) {
2764
+ console.log(`AFTER ENTITY WITH ID ${event.entityId} REMOVED: `, event.entity);
2765
+ }
2766
+ /**
2767
+ * Called before entity removal.
2768
+ */
2769
+ beforeSoftRemove(event) {
2770
+ console.log(`BEFORE ENTITY WITH ID ${event.entityId} SOFT REMOVED: `, event.entity);
2771
+ }
2772
+ /**
2773
+ * Called after entity removal.
2774
+ */
2775
+ afterSoftRemove(event) {
2776
+ console.log(`AFTER ENTITY WITH ID ${event.entityId} SOFT REMOVED: `, event.entity);
2777
+ }
2778
+ /**
2779
+ * Called before entity recovery.
2780
+ */
2781
+ beforeRecover(event) {
2782
+ console.log(`BEFORE ENTITY WITH ID ${event.entityId} RECOVERED: `, event.entity);
2783
+ }
2784
+ /**
2785
+ * Called after entity recovery.
2786
+ */
2787
+ afterRecover(event) {
2788
+ console.log(`AFTER ENTITY WITH ID ${event.entityId} RECOVERED: `, event.entity);
2789
+ }
2790
+ /**
2791
+ * Called before transaction start.
2792
+ */
2793
+ beforeTransactionStart(event) {
2794
+ console.log(`BEFORE TRANSACTION STARTED: `, event);
2795
+ }
2796
+ /**
2797
+ * Called after transaction start.
2798
+ */
2799
+ afterTransactionStart(event) {
2800
+ console.log(`AFTER TRANSACTION STARTED: `, event);
2801
+ }
2802
+ /**
2803
+ * Called before transaction commit.
2804
+ */
2805
+ beforeTransactionCommit(event) {
2806
+ console.log(`BEFORE TRANSACTION COMMITTED: `, event);
2807
+ }
2808
+ /**
2809
+ * Called after transaction commit.
2810
+ */
2811
+ afterTransactionCommit(event) {
2812
+ console.log(`AFTER TRANSACTION COMMITTED: `, event);
2813
+ }
2814
+ /**
2815
+ * Called before transaction rollback.
2816
+ */
2817
+ beforeTransactionRollback(event) {
2818
+ console.log(`BEFORE TRANSACTION ROLLBACK: `, event);
2819
+ }
2820
+ /**
2821
+ * Called after transaction rollback.
2822
+ */
2823
+ afterTransactionRollback(event) {
2824
+ console.log(`AFTER TRANSACTION ROLLBACK: `, event);
2825
+ }
2826
+ };
2827
+ BaseSubscriberForEntity = __decorate([
2828
+ TaonSubscriber({
2829
+ className: 'BaseSubscriberForEntity',
2830
+ })
2831
+ ], BaseSubscriberForEntity);
2832
+ ;
2833
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-subscriber-for-entity.ts
2834
+
2835
+ /* eslint-disable @typescript-eslint/typedef */
2836
+ class EndpointContext {
2837
+ static initNgZone(ngZone) {
2838
+ this.ngZone = ngZone;
2839
+ }
2840
+ static findForTraget(classFnOrObject) {
2841
+ const obj = ClassHelpers.getClassFnFromObject(classFnOrObject) || {};
2842
+ return (classFnOrObject[Symbols.ctxInClassOrClassObj] ||
2843
+ obj[Symbols.ctxInClassOrClassObj]);
2844
+ }
2845
+ get realtimeClient() {
2846
+ return this.realtime.client;
2847
+ }
2848
+ get realtimeServer() {
2849
+ return this.realtime.server;
2850
+ }
2851
+ get logHttp() {
2852
+ if (_.isObject(this.config?.logs)) {
2853
+ return !!this.config.logs.http;
2854
+ }
2855
+ return this.config?.logs === true;
2856
+ }
2857
+ get logRealtime() {
2858
+ if (_.isObject(this.config?.logs)) {
2859
+ return !!this.config.logs.realtime;
2860
+ }
2861
+ return this.config?.logs === true;
2862
+ }
2863
+ get logFramework() {
2864
+ if (_.isObject(this.config?.logs)) {
2865
+ return !!this.config.logs.framework;
2866
+ }
2867
+ return this.config?.logs === true;
2868
+ }
2869
+ get logDb() {
2870
+ if (_.isObject(this.config?.logs)) {
2871
+ return !!this.config.logs.db;
2872
+ }
2873
+ return this.config?.logs === true;
2874
+ }
2875
+ constructor(originalConfig, configFn) {
2876
+ this.originalConfig = originalConfig;
2877
+ this.configFn = configFn;
2878
+ this.disabledRealtime = false;
2879
+ /**
2880
+ * check whether context is inited
2881
+ * (with init() function )
2882
+ */
2883
+ this.inited = false;
2884
+ this.localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
2885
+ /**
2886
+ * all instances of classes from context
2887
+ * key is class name
2888
+ */
2889
+ this.allClassesInstances = {};
2890
+ this.classInstancesByNameObj = {};
2891
+ this.objWithClassesInstancesArr = {};
2892
+ this.activeRoutes = [];
2893
+ this.injectableTypesfromContexts = [
2894
+ Models.ClassType.CONTROLLER,
2895
+ Models.ClassType.PROVIDER,
2896
+ Models.ClassType.REPOSITORY,
2897
+ Models.ClassType.SUBSCRIBER,
2898
+ ];
2899
+ this.allTypesfromContexts = [
2900
+ ...this.injectableTypesfromContexts,
2901
+ Models.ClassType.ENTITY,
2902
+ ];
2903
+ this.expressApp = {};
2904
+ this.entitiesTriggers = {};
2905
+ this.cloneClassWithNewMetadata = ({ BaseClass, className, config, ctx, classType, }) => {
2906
+ const cloneClass = () => {
2907
+ var _a, _b, _c, _d, _e;
2908
+ if (BaseClass[Symbols.fullClassNameStaticProperty] ===
2909
+ `${ctx.contextName}.${className}`) {
2910
+ return BaseClass;
2911
+ }
2912
+ return class extends BaseClass {
2913
+ constructor() {
2914
+ super(...arguments);
2915
+ this[_e] = ctx;
2916
+ }
2917
+ static { _a = Symbols.orignalClass, _b = Symbols.fullClassNameStaticProperty, _c = Symbols.classNameStaticProperty, _d = Symbols.ctxInClassOrClassObj, _e = Symbols.ctxInClassOrClassObj; }
2918
+ // @ts-ignore
2919
+ static { this[_a] = BaseClass; }
2920
+ // @ts-ignore
2921
+ static { this[_b] = `${ctx.contextName}.${className}`; }
2922
+ // @ts-ignore
2923
+ static { this[_c] = className; }
2924
+ static { this[_d] = ctx; }
2925
+ static __getFullPathForClass__(arr = []) {
2926
+ const name = this[Symbols.fullClassNameStaticProperty];
2927
+ arr.push(name);
2928
+ // @ts-ignore
2929
+ if (this[Symbols.orignalClass] && // @ts-ignore
2930
+ this[Symbols.orignalClass].__getFullPathForClass__) {
2931
+ // @ts-ignore
2932
+ this[Symbols.orignalClass].__getFullPathForClass__(arr);
2933
+ }
2934
+ return arr.join('/');
2935
+ }
2936
+ static get fullPathForClass() {
2937
+ return this.__getFullPathForClass__();
2938
+ }
2939
+ };
2940
+ };
2941
+ const cloneClassFunction = cloneClass();
2942
+ return cloneClassFunction;
2943
+ };
2944
+ this.cloneClassesObjWithNewMetadata = ({ classesInput, config, ctx, classType, }) => {
2945
+ const classes = {};
2946
+ for (const key of Object.keys(classesInput || {})) {
2947
+ const BaseClass = classesInput[key];
2948
+ if (!BaseClass) {
2949
+ Helpers.error(`Class ${key} is not defined in context ${ctx.contextName}
2950
+
2951
+ Please check if you have correct import in context file
2952
+
2953
+ `);
2954
+ }
2955
+ var className = Reflect.getMetadata(Symbols.metadata.className, BaseClass);
2956
+ className = className || key;
2957
+ BaseClass[Symbols.classNameStaticProperty] = className;
2958
+ const clonedClass = this.cloneClassWithNewMetadata({
2959
+ BaseClass,
2960
+ className,
2961
+ config,
2962
+ ctx,
2963
+ classType,
2964
+ });
2965
+ classes[className] = clonedClass;
2966
+ }
2967
+ return classes;
2968
+ };
2969
+ }
2970
+ async init(options) {
2971
+ const { initFromRecrusiveContextResovle } = options || {}; // TODO use it ?
2972
+ this.inited = true;
2973
+ this.config = this.configFn(ENV);
2974
+ if (this.config.host) {
2975
+ this.mode = 'backend-frontend(tcp+udp)';
2976
+ this.mode = 'backend-frontend(websql)';
2977
+ }
2978
+ if (this.config.remoteHost) {
2979
+ if (this.config.host) {
2980
+ Helpers.error(`[taon] You can't have remoteHost and host at the same time`, false, true);
2981
+ }
2982
+ this.mode = 'remote-backend(tcp+udp)';
2983
+ }
2984
+ if (this.config.useIpcWhenElectron && Helpers.isElectron) {
2985
+ this.mode = 'backend-frontend(ipc-electron)';
2986
+ }
2987
+ if (!this.mode && !this.config.abstract) {
2988
+ Helpers.error(`[taon] Context "${this.contextName}": You need to provide host or remoteHost or useIpcWhenElectron`, false, true);
2989
+ /* */
2990
+ /* */
2991
+ }
2992
+ if (this.config.database === true) {
2993
+ this.databaseConfig = this.getAutoGeneratedConfig();
2994
+ }
2995
+ else if (_.isObject(this.config.database)) {
2996
+ this.databaseConfig = _.cloneDeep(this.config.database);
2997
+ }
2998
+ if (this.config.session) {
2999
+ this.session = _.cloneDeep(this.config.session);
3000
+ const oneHour = 1000 * 60 * 60 * 1; // 24;
3001
+ if (!this.session.cookieMaxAge) {
3002
+ this.session.cookieMaxAge = oneHour;
3003
+ }
3004
+ axios.defaults.withCredentials = true;
3005
+ }
3006
+ this.config.contexts = this.config.contexts || {};
3007
+ this.config.entities = this.config.entities || {};
3008
+ this.config.controllers = this.config.controllers || {};
3009
+ this.config.repositories = this.config.repositories || {};
3010
+ this.config.providers = this.config.providers || {};
3011
+ this.config.subscribers = this.config.subscribers || {};
3012
+ this.config.entities = {
3013
+ ...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.ENTITY)),
3014
+ ...this.config.entities,
3015
+ };
3016
+ this.config.controllers = {
3017
+ ...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.CONTROLLER)),
3018
+ ...this.config.controllers,
3019
+ };
3020
+ this.config.providers = {
3021
+ ...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.PROVIDER)),
3022
+ ...this.config.providers,
3023
+ };
3024
+ this.config.subscribers = {
3025
+ ...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.SUBSCRIBER)),
3026
+ ...this.config.subscribers,
3027
+ };
3028
+ this.config.repositories = {
3029
+ ...(await this.getRecrusiveClassesfromContextsObj(Models.ClassType.REPOSITORY)),
3030
+ ...this.config.repositories,
3031
+ };
3032
+ this.config.controllers = this.cloneClassesObjWithNewMetadata({
3033
+ classesInput: this.config.controllers,
3034
+ config: this.config,
3035
+ ctx: this,
3036
+ classType: Models.ClassType.CONTROLLER,
3037
+ });
3038
+ this.config.repositories = this.cloneClassesObjWithNewMetadata({
3039
+ classesInput: this.config.repositories,
3040
+ config: this.config,
3041
+ ctx: this,
3042
+ classType: Models.ClassType.REPOSITORY,
3043
+ });
3044
+ this.config.providers = this.cloneClassesObjWithNewMetadata({
3045
+ classesInput: this.config.providers,
3046
+ config: this.config,
3047
+ ctx: this,
3048
+ classType: Models.ClassType.PROVIDER,
3049
+ });
3050
+ this.config.subscribers = this.cloneClassesObjWithNewMetadata({
3051
+ classesInput: this.config.subscribers,
3052
+ config: this.config,
3053
+ ctx: this,
3054
+ classType: Models.ClassType.SUBSCRIBER,
3055
+ });
3056
+ for (const classTypeName of this.injectableTypesfromContexts) {
3057
+ this.classInstancesByNameObj[classTypeName] = {};
3058
+ this.objWithClassesInstancesArr[classTypeName] = [];
3059
+ }
3060
+ for (const classTypeName of this.injectableTypesfromContexts) {
3061
+ await this.createInstances(this.config[Models.ClassTypeKey[classTypeName]], classTypeName);
3062
+ }
3063
+ if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
3064
+ /* */
3065
+ /* */
3066
+ /* */
3067
+ /* */
3068
+ /* */
3069
+ /* */
3070
+ /* */
3071
+ /* */
3072
+ /* */
3073
+ /* */
3074
+ /* */
3075
+ /* */
3076
+ /* */
3077
+ /* */
3078
+ /* */
3079
+ /* */
3080
+ /* */
3081
+ /* */
3082
+ /* */
3083
+ }
3084
+ if (!this.config.abstract) {
3085
+ this.disabledRealtime = !!this.config.disabledRealtime;
3086
+ /* */
3087
+ /* */
3088
+ /* */
3089
+ /* */
3090
+ /* */
3091
+ this.realtime = new RealtimeCore(this);
3092
+ }
3093
+ if (this.config.abstract) {
3094
+ this.logFramework &&
3095
+ Helpers.info(`[taon] Create abstract context: ${this.config.contextName}`);
3096
+ }
3097
+ else {
3098
+ if (this.config.remoteHost) {
3099
+ this.logFramework &&
3100
+ Helpers.info(`[taon] Create context for remote host: ${this.config.remoteHost}`);
3101
+ }
3102
+ else {
3103
+ this.logFramework &&
3104
+ Helpers.info(`[taon] Create context for host: ${this.config.host}`);
3105
+ }
3106
+ }
3107
+ Object.keys(this.config).forEach(key => {
3108
+ this.originalConfig[key] = this.config[key];
3109
+ });
3110
+ }
3111
+ getAutoGeneratedConfig() {
3112
+ let databaseConfig;
3113
+ if (Helpers.isRunningInDocker()) {
3114
+ Helpers.info('Running in docker, using in mysql database');
3115
+ databaseConfig = {
3116
+ database: `tmp-db-${_.kebabCase(this.contextName)}.sqljs.db`,
3117
+ type: 'mysql',
3118
+ autoSave: true,
3119
+ synchronize: true,
3120
+ dropSchema: true,
3121
+ logging: this.logDb,
3122
+ databasePort: 3306,
3123
+ databaseHost: 'localhost',
3124
+ databaseUsername: 'root',
3125
+ databasePassword: 'admin',
3126
+ };
3127
+ }
3128
+ else {
3129
+ this.logFramework &&
3130
+ Helpers.info(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
3131
+ switch (this.mode) {
3132
+ case 'backend-frontend(ipc-electron)':
3133
+ return {
3134
+ location: `tmp-db-${_.kebabCase(this.contextName)}.sqljs`,
3135
+ type: 'sqljs',
3136
+ autoSave: true,
3137
+ synchronize: true,
3138
+ dropSchema: true,
3139
+ logging: this.logDb,
3140
+ };
3141
+ break;
3142
+ case 'backend-frontend(websql)':
3143
+ databaseConfig = {
3144
+ location: `tmp-db-${_.kebabCase(this.contextName)}.sqljs`,
3145
+ type: 'sqljs',
3146
+ useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
3147
+ autoSave: true,
3148
+ synchronize: true,
3149
+ dropSchema: true,
3150
+ logging: this.logDb,
3151
+ };
3152
+ let keepWebsqlDbDataAfterReload = false;
3153
+ keepWebsqlDbDataAfterReload =
3154
+ TaonAdmin.Instance.keepWebsqlDbDataAfterReload;
3155
+ if (keepWebsqlDbDataAfterReload) {
3156
+ databaseConfig.dropSchema = false;
3157
+ delete databaseConfig.synchronize; // false is not auto synchonize - from what I understand
3158
+ }
3159
+ else {
3160
+ databaseConfig.dropSchema = true;
3161
+ databaseConfig.synchronize = true;
3162
+ }
3163
+ break;
3164
+ case 'backend-frontend(tcp+udp)':
3165
+ databaseConfig = {
3166
+ database: `context-db-${_.kebabCase(this.contextName)}`,
3167
+ location: `tmp-db-${_.kebabCase(this.contextName)}.sqlite`,
3168
+ type: 'sqljs',
3169
+ autoSave: true,
3170
+ synchronize: true,
3171
+ dropSchema: true,
3172
+ logging: this.logDb,
3173
+ };
3174
+ break;
3175
+ }
3176
+ }
3177
+ return databaseConfig;
3178
+ }
3179
+ get ngZone() {
3180
+ return EndpointContext.ngZone;
3181
+ return;
3182
+ }
3183
+ startServer() {
3184
+ /* */
3185
+ /* */
3186
+ /* */
3187
+ /* */
3188
+ /* */
3189
+ /* */
3190
+ /* */
3191
+ /* */
3192
+ /* */
3193
+ /* */
3194
+ /* */
3195
+ /* */
3196
+ /* */
3197
+ return (void 0);
3198
+ }
3199
+ displayRoutes(app) {
3200
+ /* */
3201
+ /* */
3202
+ /* */
3203
+ /* */
3204
+ /* */
3205
+ /* */
3206
+ /* */
3207
+ /* */
3208
+ /* */
3209
+ /* */
3210
+ /* */
3211
+ /* */
3212
+ /* */
3213
+ /* */
3214
+ /* */
3215
+ /* */
3216
+ /* */
3217
+ /* */
3218
+ /* */
3219
+ /* */
3220
+ /* */
3221
+ /* */
3222
+ /* */
3223
+ /* */
3224
+ /* */
3225
+ /* */
3226
+ /* */
3227
+ /* */
3228
+ }
3229
+ get modeAllowsDatabaseCreation() {
3230
+ return (this.mode === 'backend-frontend(tcp+udp)' ||
3231
+ this.mode === 'backend-frontend(websql)' ||
3232
+ this.mode === 'backend-frontend(ipc-electron)');
3233
+ }
3234
+ async getRecrusiveClassesfromContextsObj(classType) {
3235
+ const arr = await this.getRecrusiveClassesfromContexts(classType);
3236
+ return arr.reduce((acc, c) => {
3237
+ acc[ClassHelpers.getName(c)] = c;
3238
+ return acc;
3239
+ }, {});
3240
+ }
3241
+ async getRecrusiveClassesfromContexts(classType, arr = []) {
3242
+ const contexts = Object.values(this.config.contexts || {});
3243
+ for (const ctx of contexts) {
3244
+ const ref = await ctx.__ref();
3245
+ const classesInput = ref.getClassFunBy(classType);
3246
+ const clonedClasses = Object.values(this.cloneClassesObjWithNewMetadata({
3247
+ classesInput,
3248
+ config: this.config,
3249
+ ctx: this,
3250
+ classType,
3251
+ }));
3252
+ clonedClasses.forEach(c => arr.push(c));
3253
+ await ref.getRecrusiveClassesfromContexts(classType, arr);
3254
+ }
3255
+ return arr;
3256
+ }
3257
+ getClassInstanceObjBy(classType) {
3258
+ return this.classInstancesByNameObj[classType];
3259
+ }
3260
+ getClassesInstancesArrBy(classType) {
3261
+ return this.objWithClassesInstancesArr[classType];
3262
+ }
3263
+ inject(ctor, options) {
3264
+ if (!options) {
3265
+ options = {};
3266
+ }
3267
+ const className = ClassHelpers.getName(ctor);
3268
+ const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
3269
+ if (this.isCLassType(Models.ClassType.REPOSITORY, ctor)) {
3270
+ options.localInstance = true;
3271
+ }
3272
+ if (options?.localInstance) {
3273
+ const ctxClassFn = this.getClassFunByClassName(className);
3274
+ let entityName = '';
3275
+ if (className === 'BaseRepository') {
3276
+ const entityFn = locaInstanceConstructorArgs[0];
3277
+ const entity = entityFn && entityFn();
3278
+ entityName = entity && ClassHelpers.getName(entity);
3279
+ }
3280
+ if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
3281
+ options.contextClassInstance[this.localInstaceObjSymbol] = {};
3282
+ }
3283
+ const instanceKey = className + (entityName ? `.${entityName}` : '');
3284
+ const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
3285
+ if (existed) {
3286
+ return existed;
3287
+ }
3288
+ if (!ctxClassFn) {
3289
+ throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
3290
+
3291
+ Make sure they share the same context or import context where "${className}" is defined.
3292
+
3293
+ `);
3294
+ }
3295
+ const injectedInstance = new ctxClassFn(...locaInstanceConstructorArgs);
3296
+ options.contextClassInstance[this.localInstaceObjSymbol][instanceKey] =
3297
+ injectedInstance;
3298
+ return injectedInstance;
3299
+ }
3300
+ const contextScopeInstance = this.allClassesInstances[className];
3301
+ return contextScopeInstance;
3302
+ }
3303
+ /**
3304
+ * alias for inject
3305
+ */
3306
+ getInstanceBy(ctor) {
3307
+ return this.inject(ctor, { localInstance: false });
3308
+ }
3309
+ checkIfContextInitialized() {
3310
+ if (_.isUndefined(this.config)) {
3311
+ throw new Error(`Please check if your context has been initilized.
3312
+
3313
+
3314
+ await Context.initialize();
3315
+
3316
+
3317
+
3318
+ `);
3319
+ }
3320
+ }
3321
+ getClassFunBy(classType) {
3322
+ this.checkIfContextInitialized();
3323
+ switch (classType) {
3324
+ case Models.ClassType.CONTROLLER:
3325
+ return this.config.controllers;
3326
+ case Models.ClassType.ENTITY:
3327
+ return this.config.entities;
3328
+ case Models.ClassType.PROVIDER:
3329
+ return this.config.providers;
3330
+ case Models.ClassType.REPOSITORY:
3331
+ return this.config.repositories;
3332
+ case Models.ClassType.SUBSCRIBER:
3333
+ return this.config.subscribers;
3334
+ }
3335
+ }
3336
+ isCLassType(classType, classFn) {
3337
+ return !!this.getClassFunBy(classType)[ClassHelpers.getName(classFn)];
3338
+ }
3339
+ /**
3340
+ * Only for injectable types
3341
+ * Only for classType: CONTROLLER, REPOSITORY, PROVIDER
3342
+ */
3343
+ getClassFunByClassName(className) {
3344
+ for (const classTypeName of this.allTypesfromContexts) {
3345
+ const classesForInjectableType = this.config[Models.ClassTypeKey[classTypeName]];
3346
+ if (classesForInjectableType[className]) {
3347
+ return classesForInjectableType[className];
3348
+ }
3349
+ }
3350
+ }
3351
+ getClassFunByClass(classFunction) {
3352
+ const className = ClassHelpers.getName(classFunction);
3353
+ return this.getClassFunByClassName(className);
3354
+ }
3355
+ getClassFunByArr(classType) {
3356
+ return Object.values(this.getClassFunBy(classType) || {});
3357
+ }
3358
+ async createInstances(classes, classType) {
3359
+ for (const classFn of [
3360
+ ...Object.values(classes),
3361
+ ]) {
3362
+ const instance = DITaonContainer.resolve(classFn);
3363
+ const classInstancesByNameObj = this.classInstancesByNameObj[classType];
3364
+ const className = ClassHelpers.getName(classFn);
3365
+ classInstancesByNameObj[className] = instance;
3366
+ this.config[Models.ClassTypeKey[classType]][className] = classFn;
3367
+ this.objWithClassesInstancesArr[classType].push(instance);
3368
+ this.allClassesInstances[className] = instance;
3369
+ }
3370
+ }
3371
+ async reinitControllers() {
3372
+ const controllers = this.getClassesInstancesArrBy(Models.ClassType.CONTROLLER);
3373
+ for (const ctrl of controllers) {
3374
+ if (_.isFunction(ctrl.initExampleDbData)) {
3375
+ await Helpers.runSyncOrAsync({
3376
+ functionFn: ctrl.initExampleDbData,
3377
+ context: ctrl,
3378
+ });
3379
+ }
3380
+ }
3381
+ }
3382
+ async initClasses() {
3383
+ for (const classTypeName of [
3384
+ Models.ClassType.PROVIDER,
3385
+ Models.ClassType.REPOSITORY,
3386
+ Models.ClassType.CONTROLLER,
3387
+ Models.ClassType.ENTITY,
3388
+ ]) {
3389
+ for (const classFun of this.getClassFunByArr(classTypeName)) {
3390
+ if (_.isFunction(classFun._)) {
3391
+ await Helpers.runSyncOrAsync({
3392
+ functionFn: classFun._,
3393
+ context: classFun,
3394
+ });
3395
+ }
3396
+ }
3397
+ }
3398
+ for (const classTypeName of [
3399
+ Models.ClassType.PROVIDER,
3400
+ Models.ClassType.REPOSITORY,
3401
+ Models.ClassType.CONTROLLER,
3402
+ ]) {
3403
+ for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
3404
+ if (_.isFunction(ctrl._)) {
3405
+ await Helpers.runSyncOrAsync({
3406
+ functionFn: ctrl._,
3407
+ context: ctrl,
3408
+ });
3409
+ }
3410
+ }
3411
+ }
3412
+ }
3413
+ isActiveOn(classInstance) {
3414
+ let contextRef = classInstance[Symbols.ctxInClassOrClassObj];
3415
+ return this === contextRef;
3416
+ }
3417
+ get uri() {
3418
+ const url = this.host
3419
+ ? new URL(this.host)
3420
+ : this.remoteHost
3421
+ ? new URL(this.remoteHost)
3422
+ : void 0;
3423
+ return url;
3424
+ }
3425
+ get isHttpServer() {
3426
+ return this.uri.protocol === 'https:';
3427
+ }
3428
+ /**
3429
+ * ipc/udp needs this
3430
+ */
3431
+ get contextName() {
3432
+ return this.config.contextName;
3433
+ }
3434
+ get publicAssets() {
3435
+ return this.config?.publicAssets || [];
3436
+ }
3437
+ get isProductionMode() {
3438
+ return this.config.productionMode;
3439
+ }
3440
+ get remoteHost() {
3441
+ return this.config.remoteHost;
3442
+ }
3443
+ get host() {
3444
+ return this.config.host;
3445
+ }
3446
+ get orgin() {
3447
+ return this.uri?.origin;
3448
+ }
3449
+ async initSubscribers() {
3450
+ return; // TODO
3451
+ if (!this.connection?.initialize) {
3452
+ return;
3453
+ }
3454
+ const subscribers = this.getClassFunByArr(Models.ClassType.SUBSCRIBER);
3455
+ for (const subscriber of subscribers) {
3456
+ const options = Reflect.getMetadata(Symbols.metadata.options.subscriber, subscriber);
3457
+ EventSubscriber()(subscriber);
3458
+ }
3459
+ console.log(this.config.subscribers);
3460
+ return;
3461
+ const entities = this.getClassFunByArr(Models.ClassType.ENTITY);
3462
+ for (let index = 0; index < entities.length; index++) {
3463
+ }
3464
+ }
3465
+ async initEntities() {
3466
+ const entities = this.getClassFunByArr(Models.ClassType.ENTITY);
3467
+ for (const entity of entities) {
3468
+ const options = Reflect.getMetadata(Symbols.metadata.options.entity, entity);
3469
+ const createTable = _.isUndefined(options.createTable)
3470
+ ? true
3471
+ : options.createTable;
3472
+ const nameForEntity = ClassHelpers.getName(entity);
3473
+ if (_.isUndefined(options.createTable) ? true : options.createTable) {
3474
+ this.logDb &&
3475
+ console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
3476
+ Entity(nameForEntity)(entity);
3477
+ }
3478
+ else {
3479
+ this.logDb &&
3480
+ console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
3481
+ }
3482
+ }
3483
+ }
3484
+ async initDatabaseConnection() {
3485
+ const entities = (this.config.override?.entities
3486
+ ? this.config.override.entities
3487
+ : this.getClassFunByArr(Models.ClassType.ENTITY)).map(entityFn => {
3488
+ return ClassHelpers.getOrginalClass(entityFn);
3489
+ });
3490
+ const subscribers = (this.config.override?.subscribers
3491
+ ? this.config.override.subscribers
3492
+ : this.getClassFunByArr(Models.ClassType.SUBSCRIBER)).filter(f => f instanceof BaseSubscriberForEntity);
3493
+ const dataSourceDbConfig = _.isObject(this.databaseConfig)
3494
+ ? {
3495
+ type: this.databaseConfig.type,
3496
+ port: this.databaseConfig.databasePort,
3497
+ host: this.databaseConfig.databaseHost,
3498
+ database: this.databaseConfig.database,
3499
+ username: this.databaseConfig.databaseUsername,
3500
+ password: this.databaseConfig.databasePassword,
3501
+ useLocalForage: this.databaseConfig.useLocalForage,
3502
+ entities,
3503
+ subscribers,
3504
+ synchronize: this.databaseConfig.synchronize,
3505
+ autoSave: this.databaseConfig.autoSave,
3506
+ dropSchema: this.databaseConfig.dropSchema,
3507
+ logging: !!this.databaseConfig.logging,
3508
+ location: this.databaseConfig.location,
3509
+ }
3510
+ : {};
3511
+ if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
3512
+ this.logDb &&
3513
+ this.logFramework &&
3514
+ Helpers.info('[taon][database] prepare typeorm connection...');
3515
+ try {
3516
+ const connection = new DataSource(dataSourceDbConfig);
3517
+ this.connection = connection;
3518
+ await this.connection.initialize();
3519
+ }
3520
+ catch (error) {
3521
+ console.error(error?.message || error);
3522
+ }
3523
+ if (!this.connection?.isInitialized) {
3524
+ console.log('WRONG CONFIG', dataSourceDbConfig);
3525
+ throw new Error(`Something wrong with connection init in ${this.mode}`);
3526
+ /* */
3527
+ /* */
3528
+ }
3529
+ (this.logDb || this.logFramework) &&
3530
+ console.info(`
3531
+
3532
+ CONTECTION OK for ${this.contextName} - ${this.mode}
3533
+
3534
+ [taon][typeorm] db prepration done.. db initialize=${this.connection?.isInitialized}
3535
+
3536
+
3537
+ `, dataSourceDbConfig);
3538
+ }
3539
+ else {
3540
+ Helpers.info(`[taon][typeorm] Not initing db for mode ${this.mode}`);
3541
+ }
3542
+ }
3543
+ initMetadata() {
3544
+ const allControllers = this.getClassFunByArr(Models.ClassType.CONTROLLER);
3545
+ for (const controllerClassFn of allControllers) {
3546
+ controllerClassFn[Symbols.classMethodsNames] =
3547
+ ClassHelpers.getMethodsNames(controllerClassFn);
3548
+ const configs = ClassHelpers.getControllerConfigs(controllerClassFn);
3549
+ const classConfig = configs[0];
3550
+ const parentscalculatedPath = _.slice(configs, 1)
3551
+ .reverse()
3552
+ .map(bc => {
3553
+ if (TaonHelpers.isGoodPath(bc.path)) {
3554
+ return bc.path;
3555
+ }
3556
+ return bc.className;
3557
+ })
3558
+ .join('/');
3559
+ if (TaonHelpers.isGoodPath(classConfig.path)) {
3560
+ classConfig.calculatedPath = classConfig.path;
3561
+ }
3562
+ else {
3563
+ classConfig.calculatedPath =
3564
+ `${parentscalculatedPath}/${ClassHelpers.getName(controllerClassFn)}`
3565
+ .replace(/\/\//g, '/')
3566
+ .split('/')
3567
+ .reduce((acc, bc) => {
3568
+ return _.last(acc) === bc ? acc : [...acc, bc];
3569
+ }, [])
3570
+ .join('/');
3571
+ }
3572
+ _.slice(configs, 1).forEach(bc => {
3573
+ const alreadyIs = classConfig.methods;
3574
+ const toMerge = _.cloneDeep(bc.methods);
3575
+ for (const key in toMerge) {
3576
+ if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
3577
+ const element = toMerge[key];
3578
+ alreadyIs[key] = element;
3579
+ }
3580
+ }
3581
+ });
3582
+ /* */
3583
+ /* */
3584
+ this.logHttp &&
3585
+ console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
3586
+ /* */
3587
+ /* */
3588
+ Object.keys(classConfig.methods).forEach(methodName => {
3589
+ const methodConfig = classConfig.methods[methodName];
3590
+ const type = methodConfig.type;
3591
+ const expressPath = methodConfig.global
3592
+ ? `/${methodConfig.path?.replace(/\//, '')}`
3593
+ : TaonHelpers.getExpressPath(classConfig, methodConfig);
3594
+ if (Helpers.isNode || Helpers.isWebSQL) {
3595
+ const { routePath, method } = this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn);
3596
+ this.activeRoutes.push({
3597
+ routePath,
3598
+ method,
3599
+ });
3600
+ }
3601
+ const shouldInitClient = Helpers.isBrowser || this.remoteHost || Helpers.isWebSQL;
3602
+ if (shouldInitClient) {
3603
+ this.initClient(controllerClassFn, type, methodConfig, expressPath);
3604
+ }
3605
+ });
3606
+ /* */
3607
+ /* */
3608
+ this.logHttp && console.groupEnd();
3609
+ /* */
3610
+ /* */
3611
+ }
3612
+ }
3613
+ writeActiveRoutes() {
3614
+ const contexts = [this];
3615
+ const troutes = this.activeRoutes.map(({ method, routePath }) => {
3616
+ return (TaonHelpers.fillUpTo(method.toUpperCase() + ':', 10) +
3617
+ this.uri.href.replace(/\/$/, '') +
3618
+ routePath);
3619
+ });
3620
+ const routes = [
3621
+ ...['', `---------- FOR HOST ${this.uri.href} ----------`],
3622
+ ...troutes,
3623
+ ];
3624
+ const fileName = path.join(
3625
+ /* */
3626
+ /* */
3627
+ `tmp-routes-${_.kebabCase(this.config.contextName)}.json`);
3628
+ this.logFramework && console.log(`[taon] routes file: ${fileName} `);
3629
+ /* */
3630
+ /* */
3631
+ /* */
3632
+ /* */
3633
+ /* */
3634
+ }
3635
+ get middlewares() {
3636
+ /* */
3637
+ /* */
3638
+ return (void 0);
3639
+ }
3640
+ initMidleware() {
3641
+ /* */
3642
+ /* */
3643
+ /* */
3644
+ /* */
3645
+ /* */
3646
+ /* */
3647
+ /* */
3648
+ /* */
3649
+ /* */
3650
+ /* */
3651
+ /* */
3652
+ /* */
3653
+ /* */
3654
+ /* */
3655
+ /* */
3656
+ /* */
3657
+ /* */
3658
+ /* */
3659
+ /* */
3660
+ /* */
3661
+ /* */
3662
+ /* */
3663
+ /* */
3664
+ /* */
3665
+ /* */
3666
+ /* */
3667
+ /* */
3668
+ /* */
3669
+ /* */
3670
+ /* */
3671
+ /* */
3672
+ /* */
3673
+ /* */
3674
+ /* */
3675
+ /* */
3676
+ /* */
3677
+ /* */
3678
+ /* */
3679
+ /* */
3680
+ /* */
3681
+ /* */
3682
+ /* */
3683
+ /* */
3684
+ /* */
3685
+ /* */
3686
+ /* */
3687
+ /* */
3688
+ /* */
3689
+ /* */
3690
+ /* */
3691
+ /* */
3692
+ /* */
3693
+ /* */
3694
+ /* */
3695
+ /* */
3696
+ /* */
3697
+ /* */
3698
+ /* */
3699
+ /* */
3700
+ /* */
3701
+ /* */
3702
+ /* */
3703
+ /* */
3704
+ /* */
3705
+ /* */
3706
+ /* */
3707
+ /* */
3708
+ /* */
3709
+ /* */
3710
+ /* */
3711
+ /* */
3712
+ /* */
3713
+ /* */
3714
+ /* */
3715
+ /* */
3716
+ /* */
3717
+ /* */
3718
+ /* */
3719
+ /* */
3720
+ /* */
3721
+ /* */
3722
+ /* */
3723
+ /* */
3724
+ /* */
3725
+ /* */
3726
+ /* */
3727
+ /* */
3728
+ /* */
3729
+ /* */
3730
+ /* */
3731
+ /* */
3732
+ /* */
3733
+ /* */
3734
+ /* */
3735
+ /* */
3736
+ /* */
3737
+ /* */
3738
+ /* */
3739
+ /* */
3740
+ /* */
3741
+ /* */
3742
+ /* */
3743
+ }
3744
+ initServer(type, methodConfig, classConfig, expressPath, target) {
3745
+ const requestHandler = methodConfig.requestHandler &&
3746
+ typeof methodConfig.requestHandler === 'function'
3747
+ ? methodConfig.requestHandler
3748
+ : (req, res, next) => {
3749
+ next();
3750
+ };
3751
+ const url = this.uri;
3752
+ const getResult = async (resolvedParams, req, res) => {
3753
+ const response = methodConfig.descriptor.value.apply(
3754
+ /**
3755
+ * Context for method @GET,@PUT etc.
3756
+ */
3757
+ this.getInstanceBy(target),
3758
+ /**
3759
+ * Params for metjod @GET, @PUT etc.
3760
+ */
3761
+ resolvedParams);
3762
+ let result = await getResponseValue(response, { req, res });
3763
+ return result;
3764
+ };
3765
+ url.pathname = url.pathname.replace(/\/$/, '');
3766
+ expressPath = url.pathname.startsWith('/')
3767
+ ? `${url.pathname}${expressPath}`
3768
+ : expressPath;
3769
+ expressPath = expressPath.replace(/\/\//g, '/');
3770
+ if (Helpers.isElectron) {
3771
+ /* */
3772
+ /* */
3773
+ /* */
3774
+ /* */
3775
+ /* */
3776
+ /* */
3777
+ /* */
3778
+ /* */
3779
+ /* */
3780
+ /* */
3781
+ /* */
3782
+ /* */
3783
+ /* */
3784
+ /* */
3785
+ /* */
3786
+ /* */
3787
+ /* */
3788
+ /* */
3789
+ /* */
3790
+ /* */
3791
+ /* */
3792
+ }
3793
+ if (!this.remoteHost) {
3794
+ if (Helpers.isWebSQL) {
3795
+ if (!this.expressApp[type.toLowerCase()]) {
3796
+ this.expressApp[type.toLowerCase()] = () => { };
3797
+ }
3798
+ }
3799
+ /* */
3800
+ /* */
3801
+ /* */
3802
+ /* */
3803
+ /* */
3804
+ /* */
3805
+ /* */
3806
+ /* */
3807
+ /* */
3808
+ /* */
3809
+ /* */
3810
+ /* */
3811
+ /* */
3812
+ /* */
3813
+ /* */
3814
+ /* */
3815
+ /* */
3816
+ /* */
3817
+ /* */
3818
+ /* */
3819
+ /* */
3820
+ /* */
3821
+ /* */
3822
+ /* */
3823
+ /* */
3824
+ /* */
3825
+ /* */
3826
+ /* */
3827
+ /* */
3828
+ /* */
3829
+ /* */
3830
+ /* */
3831
+ /* */
3832
+ /* */
3833
+ /* */
3834
+ /* */
3835
+ /* */
3836
+ /* */
3837
+ /* */
3838
+ /* */
3839
+ /* */
3840
+ /* */
3841
+ /* */
3842
+ /* */
3843
+ /* */
3844
+ /* */
3845
+ /* */
3846
+ /* */
3847
+ /* */
3848
+ /* */
3849
+ /* */
3850
+ /* */
3851
+ /* */
3852
+ /* */
3853
+ /* */
3854
+ /* */
3855
+ /* */
3856
+ /* */
3857
+ /* */
3858
+ /* */
3859
+ /* */
3860
+ /* */
3861
+ /* */
3862
+ /* */
3863
+ /* */
3864
+ /* */
3865
+ /* */
3866
+ /* */
3867
+ /* */
3868
+ /* */
3869
+ /* */
3870
+ /* */
3871
+ /* */
3872
+ /* */
3873
+ /* */
3874
+ /* */
3875
+ /* */
3876
+ /* */
3877
+ /* */
3878
+ /* */
3879
+ /* */
3880
+ /* */
3881
+ /* */
3882
+ /* */
3883
+ /* */
3884
+ /* */
3885
+ /* */
3886
+ /* */
3887
+ /* */
3888
+ /* */
3889
+ /* */
3890
+ /* */
3891
+ /* */
3892
+ /* */
3893
+ /* */
3894
+ /* */
3895
+ /* */
3896
+ /* */
3897
+ /* */
3898
+ /* */
3899
+ /* */
3900
+ /* */
3901
+ /* */
3902
+ /* */
3903
+ /* */
3904
+ /* */
3905
+ /* */
3906
+ /* */
3907
+ /* */
3908
+ /* */
3909
+ /* */
3910
+ /* */
3911
+ /* */
3912
+ /* */
3913
+ /* */
3914
+ /* */
3915
+ /* */
3916
+ /* */
3917
+ /* */
3918
+ /* */
3919
+ /* */
3920
+ /* */
3921
+ /* */
3922
+ /* */
3923
+ /* */
3924
+ /* */
3925
+ /* */
3926
+ /* */
3927
+ /* */
3928
+ /* */
3929
+ /* */
3930
+ /* */
3931
+ /* */
3932
+ /* */
3933
+ /* */
3934
+ /* */
3935
+ /* */
3936
+ /* */
3937
+ /* */
3938
+ /* */
3939
+ /* */
3940
+ /* */
3941
+ /* */
3942
+ /* */
3943
+ /* */
3944
+ /* */
3945
+ /* */
3946
+ /* */
3947
+ /* */
3948
+ /* */
3949
+ /* */
3950
+ /* */
3951
+ /* */
3952
+ /* */
3953
+ /* */
3954
+ /* */
3955
+ /* */
3956
+ /* */
3957
+ /* */
3958
+ /* */
3959
+ /* */
3960
+ /* */
3961
+ /* */
3962
+ /* */
3963
+ /* */
3964
+ /* */
3965
+ /* */
3966
+ /* */
3967
+ /* */
3968
+ /* */
3969
+ /* */
3970
+ /* */
3971
+ /* */
3972
+ /* */
3973
+ /* */
3974
+ /* */
3975
+ /* */
3976
+ /* */
3977
+ /* */
3978
+ /* */
3979
+ /* */
3980
+ /* */
3981
+ /* */
3982
+ /* */
3983
+ /* */
3984
+ /* */
3985
+ /* */
3986
+ /* */
3987
+ /* */
3988
+ /* */
3989
+ /* */
3990
+ /* */
3991
+ /* */
3992
+ /* */
3993
+ /* */
3994
+ /* */
3995
+ /* */
3996
+ /* */
3997
+ /* */
3998
+ /* */
3999
+ /* */
4000
+ /* */
4001
+ /* */
4002
+ /* */
4003
+ /* */
4004
+ /* */
4005
+ /* */
4006
+ /* */
4007
+ /* */
4008
+ /* */
4009
+ /* */
4010
+ /* */
4011
+ /* */
4012
+ /* */
4013
+ }
4014
+ return {
4015
+ routePath: expressPath,
4016
+ method: methodConfig.type,
4017
+ };
4018
+ }
4019
+ /**
4020
+ * client can be browser or nodejs (when remote host)
4021
+ */
4022
+ initClient(target, type, methodConfig, expressPath) {
4023
+ const ctx = this;
4024
+ this.logHttp && console.log(`${type?.toUpperCase()} ${expressPath} `);
4025
+ let storage;
4026
+ if (Helpers.isBrowser) {
4027
+ storage = window;
4028
+ }
4029
+ /* */
4030
+ /* */
4031
+ /* */
4032
+ /* */
4033
+ const orgMethods = target.prototype[methodConfig.methodName];
4034
+ if (Helpers.isElectron) {
4035
+ target.prototype[methodConfig.methodName] = function (...args) {
4036
+ const received = new Promise(async (resolve, reject) => {
4037
+ const headers = {};
4038
+ const { request, response } = TaonHelpers.websqlMocks(headers);
4039
+ Helpers.ipcRenderer.once(TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
4040
+ let res = responseData;
4041
+ console.log({ responseData });
4042
+ try {
4043
+ const body = res;
4044
+ res = new Models$1.HttpResponse({
4045
+ body: void 0,
4046
+ isArray: void 0,
4047
+ method: methodConfig.type,
4048
+ url: `${ctx.uri.origin}${'' // TODO express path
4049
+ }${methodConfig.path} `,
4050
+ }, Helpers.isBlob(body) || _.isString(body)
4051
+ ? body
4052
+ : JSON.stringify(body), RestHeaders.from(headers), void 0, () => body);
4053
+ resolve(res);
4054
+ }
4055
+ catch (error) {
4056
+ console.error(error);
4057
+ reject(error);
4058
+ }
4059
+ });
4060
+ Helpers.ipcRenderer.send(TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath), args);
4061
+ });
4062
+ received['observable'] = from(received);
4063
+ return {
4064
+ received,
4065
+ };
4066
+ };
4067
+ return;
4068
+ }
4069
+ const MIN_TIMEOUT = 500;
4070
+ const MIN_TIMEOUT_STEP = 200;
4071
+ const timeout = window[Symbols.old.WEBSQL_REST_PROGRESS_TIMEOUT] || MIN_TIMEOUT;
4072
+ let updateFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN];
4073
+ if (!window[Symbols.old.WEBSQL_REST_PROGRESS_FUN]) {
4074
+ window[Symbols.old.WEBSQL_REST_PROGRESS_FUN] = new Subject();
4075
+ }
4076
+ updateFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN];
4077
+ let startFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_START];
4078
+ if (!window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_START]) {
4079
+ window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_START] = new Subject();
4080
+ }
4081
+ startFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_START];
4082
+ let doneFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_DONE];
4083
+ if (!window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_DONE]) {
4084
+ window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_DONE] = new Subject();
4085
+ }
4086
+ doneFun = window[Symbols.old.WEBSQL_REST_PROGRESS_FUN_DONE];
4087
+ let periodsToUpdate = 0;
4088
+ if (timeout >= MIN_TIMEOUT) {
4089
+ periodsToUpdate = Math.floor(timeout / MIN_TIMEOUT_STEP);
4090
+ }
4091
+ const periods = async () => {
4092
+ startFun.next();
4093
+ for (let n = 1; n <= periodsToUpdate; n++) {
4094
+ let upValue = Math.round(((MIN_TIMEOUT_STEP * n) / timeout) * 100);
4095
+ if (upValue > 100) {
4096
+ upValue = 100;
4097
+ }
4098
+ updateFun.next(upValue);
4099
+ await new Promise((resolve, reject) => {
4100
+ setTimeout(() => {
4101
+ resolve(void 0);
4102
+ }, MIN_TIMEOUT_STEP);
4103
+ });
4104
+ }
4105
+ doneFun.next();
4106
+ };
4107
+ target.prototype[methodConfig.methodName] = function (...args) {
4108
+ const received = new Promise(async (resolve, reject) => {
4109
+ const headers = {};
4110
+ const { request, response } = TaonHelpers.websqlMocks(headers);
4111
+ let res;
4112
+ try {
4113
+ res = await Helpers.runSyncOrAsync({
4114
+ functionFn: orgMethods,
4115
+ context: this,
4116
+ arrayOfParams: args,
4117
+ });
4118
+ if (typeof res === 'function') {
4119
+ res = await Helpers.runSyncOrAsync({
4120
+ functionFn: res,
4121
+ context: this,
4122
+ arrayOfParams: [request, response],
4123
+ });
4124
+ }
4125
+ if (typeof res === 'function') {
4126
+ res = await Helpers.runSyncOrAsync({
4127
+ functionFn: res,
4128
+ context: this,
4129
+ arrayOfParams: [request, response],
4130
+ });
4131
+ }
4132
+ if (typeof res === 'object' && res?.received) {
4133
+ res = await res.received;
4134
+ }
4135
+ const body = res;
4136
+ res = new Models$1.HttpResponse({
4137
+ body: void 0,
4138
+ isArray: void 0,
4139
+ method: methodConfig.type,
4140
+ url: `${ctx.uri.origin}${'' // TODO express path
4141
+ }${methodConfig.path} `,
4142
+ }, Helpers.isBlob(body) || _.isString(body)
4143
+ ? body
4144
+ : JSON.stringify(body), RestHeaders.from(headers), void 0, () => body);
4145
+ await periods();
4146
+ resolve(res);
4147
+ }
4148
+ catch (error) {
4149
+ await periods();
4150
+ console.error(error);
4151
+ reject(error);
4152
+ }
4153
+ });
4154
+ received['observable'] = from(received);
4155
+ if (Helpers.isWebSQL) {
4156
+ return {
4157
+ received,
4158
+ };
4159
+ }
4160
+ };
4161
+ if (Helpers.isWebSQL) {
4162
+ return;
4163
+ }
4164
+ target.prototype[methodConfig.methodName] = function (...args) {
4165
+ if (!storage[Symbols.old.ENDPOINT_META_CONFIG])
4166
+ storage[Symbols.old.ENDPOINT_META_CONFIG] = {};
4167
+ if (!storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uri.href])
4168
+ storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uri.href] = {};
4169
+ const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
4170
+ let rest;
4171
+ if (!endpoints[ctx.uri.href][expressPath]) {
4172
+ let headers = {};
4173
+ if (methodConfig.contentType && !methodConfig.responseType) {
4174
+ rest = Resource.create(ctx.uri.href, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
4175
+ 'Content-Type': methodConfig.contentType,
4176
+ Accept: methodConfig.contentType,
4177
+ }));
4178
+ }
4179
+ else if (methodConfig.contentType && methodConfig.responseType) {
4180
+ rest = Resource.create(ctx.uri.href, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
4181
+ 'Content-Type': methodConfig.contentType,
4182
+ Accept: methodConfig.contentType,
4183
+ responsetypeaxios: methodConfig.responseType,
4184
+ }));
4185
+ }
4186
+ else if (!methodConfig.contentType && methodConfig.responseType) {
4187
+ rest = Resource.create(ctx.uri.href, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
4188
+ responsetypeaxios: methodConfig.responseType,
4189
+ }));
4190
+ }
4191
+ else {
4192
+ rest = Resource.create(ctx.uri.href, expressPath, Symbols.old.MAPPING_CONFIG_HEADER, Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
4193
+ }
4194
+ endpoints[ctx.uri.href][expressPath] = rest;
4195
+ }
4196
+ else {
4197
+ rest = endpoints[ctx.uri.href][expressPath];
4198
+ }
4199
+ const method = type.toLowerCase();
4200
+ const isWithBody = method === 'put' || method === 'post';
4201
+ const pathPrams = {};
4202
+ let queryParams = {};
4203
+ let bodyObject = {};
4204
+ args.forEach((param, i) => {
4205
+ let currentParam = void 0;
4206
+ for (let pp in methodConfig.parameters) {
4207
+ let v = methodConfig.parameters[pp];
4208
+ if (v.index === i) {
4209
+ currentParam = v;
4210
+ break;
4211
+ }
4212
+ }
4213
+ if (currentParam.paramType === 'Path') {
4214
+ pathPrams[currentParam.paramName] = param;
4215
+ }
4216
+ if (currentParam.paramType === 'Query') {
4217
+ if (currentParam.paramName) {
4218
+ const mapping = Mapping.decode(param, !ctx.isProductionMode);
4219
+ if (mapping) {
4220
+ rest.headers.set(`${Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
4221
+ }
4222
+ queryParams[currentParam.paramName] = param;
4223
+ }
4224
+ else {
4225
+ const mapping = Mapping.decode(param, !ctx.isProductionMode);
4226
+ if (mapping) {
4227
+ rest.headers.set(Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
4228
+ }
4229
+ queryParams = _.cloneDeep(param);
4230
+ }
4231
+ }
4232
+ if (currentParam.paramType === 'Header') {
4233
+ if (currentParam.paramName) {
4234
+ if (currentParam.paramName === Symbols.old.MDC_KEY) {
4235
+ rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
4236
+ }
4237
+ else {
4238
+ rest.headers.set(currentParam.paramName, param);
4239
+ }
4240
+ }
4241
+ else {
4242
+ for (let header in param) {
4243
+ rest.headers.set(header, param[header]);
4244
+ }
4245
+ }
4246
+ }
4247
+ if (currentParam.paramType === 'Cookie') {
4248
+ Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
4249
+ }
4250
+ if (currentParam.paramType === 'Body') {
4251
+ if (currentParam.paramName) {
4252
+ if (ClassHelpers.getName(bodyObject) === 'FormData') {
4253
+ throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
4254
+ Use this:
4255
+
4256
+ (@Taon.Http.Param.Body() formData: FormData) ...
4257
+
4258
+
4259
+ instead
4260
+
4261
+ (@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
4262
+
4263
+ `);
4264
+ }
4265
+ const mapping = Mapping.decode(param, !ctx.isProductionMode);
4266
+ if (mapping) {
4267
+ rest.headers.set(`${Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
4268
+ }
4269
+ bodyObject[currentParam.paramName] = param;
4270
+ }
4271
+ else {
4272
+ const mapping = Mapping.decode(param, !ctx.isProductionMode);
4273
+ if (mapping) {
4274
+ rest.headers.set(Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
4275
+ }
4276
+ bodyObject = param;
4277
+ }
4278
+ }
4279
+ });
4280
+ if (typeof bodyObject === 'object' &&
4281
+ ClassHelpers.getName(bodyObject) !== 'FormData') {
4282
+ let circuralFromItem = [];
4283
+ bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
4284
+ circuralFromItem = circs;
4285
+ }));
4286
+ rest.headers.set(Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
4287
+ }
4288
+ if (typeof queryParams === 'object') {
4289
+ let circuralFromQueryParams = [];
4290
+ queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
4291
+ circuralFromQueryParams = circs;
4292
+ }));
4293
+ rest.headers.set(Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
4294
+ }
4295
+ const httpResultObj = {
4296
+ received: isWithBody
4297
+ ? rest.model(pathPrams)[method](bodyObject, [queryParams])
4298
+ : rest.model(pathPrams)[method]([queryParams]),
4299
+ };
4300
+ return httpResultObj;
4301
+ };
4302
+ }
4303
+ }
4304
+ ;
4305
+ ({}); // @--end-of-file-for-module=taon lib/endpoint-context.ts
4306
+
4307
+ const createContext = (configFn) => {
4308
+ let config = configFn(ENV);
4309
+ const endpointContextRef = new EndpointContext(config, configFn);
4310
+ const res = {
4311
+ types: {
4312
+ get controllers() {
4313
+ return config.controllers;
4314
+ },
4315
+ get repositories() {
4316
+ return config.repositories;
4317
+ },
4318
+ get providers() {
4319
+ return config.providers;
4320
+ },
4321
+ get subscribers() {
4322
+ return config.subscribers;
4323
+ },
4324
+ },
4325
+ get contexts() {
4326
+ return config.contexts;
4327
+ },
4328
+ get contextName() {
4329
+ return config.contextName;
4330
+ },
4331
+ /**
4332
+ * - get reference to internal context
4333
+ */
4334
+ async __ref() {
4335
+ if (!endpointContextRef.inited) {
4336
+ await endpointContextRef.init({
4337
+ initFromRecrusiveContextResovle: true,
4338
+ });
4339
+ }
4340
+ return endpointContextRef;
4341
+ },
4342
+ get __refSync() {
4343
+ return endpointContextRef;
4344
+ },
4345
+ getClassInstance(ctor) {
4346
+ return endpointContextRef.getInstanceBy(ctor);
4347
+ },
4348
+ getClass(ctor) {
4349
+ const classFun = endpointContextRef.getClassFunByClass(ctor);
4350
+ return classFun;
4351
+ },
4352
+ /**
4353
+ * - create controller instances for context
4354
+ * - init database (if enable) + migation scripts
4355
+ */
4356
+ initialize: async () => {
4357
+ return await new Promise(async (resolve, reject) => {
4358
+ setTimeout(async () => {
4359
+ await endpointContextRef.init();
4360
+ if (config.abstract) {
4361
+ throw new Error(`Abstract context can not be initialized`);
4362
+ }
4363
+ await endpointContextRef.initEntities();
4364
+ await endpointContextRef.initSubscribers();
4365
+ await endpointContextRef.initDatabaseConnection();
4366
+ endpointContextRef.initMetadata();
4367
+ endpointContextRef.startServer();
4368
+ endpointContextRef.writeActiveRoutes();
4369
+ await endpointContextRef.initClasses();
4370
+ let keepWebsqlDbDataAfterReload = false;
4371
+ keepWebsqlDbDataAfterReload =
4372
+ TaonAdmin.Instance.keepWebsqlDbDataAfterReload;
4373
+ if (!Helpers.isNode && keepWebsqlDbDataAfterReload) {
4374
+ Helpers.info(`[taon] Keep websql data after reload`);
4375
+ }
4376
+ else {
4377
+ await endpointContextRef.reinitControllers();
4378
+ }
4379
+ resolve(endpointContextRef);
4380
+ });
4381
+ });
4382
+ },
4383
+ };
4384
+ return res;
4385
+ };
4386
+ ;
4387
+ ({}); // @--end-of-file-for-module=taon lib/create-context.ts
4388
+
4389
+ const BaseContext = createContext(() => ({
4390
+ contextName: 'BaseContext',
4391
+ abstract: true,
4392
+ repositories: {
4393
+ // @ts-ignore
4394
+ BaseRepository,
4395
+ },
4396
+ }));
4397
+ ;
4398
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-context.ts
4399
+
4400
+ var baseContext = /*#__PURE__*/Object.freeze({
4401
+ __proto__: null,
4402
+ BaseContext: BaseContext
4403
+ });
4404
+
4405
+ let BaseSubscriber = class BaseSubscriber extends BaseInjector {
4406
+ __trigger_event__(eventName) {
4407
+ const ctx = this.__endpoint_context__;
4408
+ console.log('Trigger event', eventName, ctx);
4409
+ }
4410
+ };
4411
+ BaseSubscriber = __decorate([
4412
+ TaonSubscriber({
4413
+ className: 'BaseSubscriber',
4414
+ })
4415
+ ], BaseSubscriber);
4416
+ ;
4417
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base-subscriber.ts
4418
+
4419
+ var Base;
4420
+ (function (Base) {
4421
+ Base.Controller = BaseController;
4422
+ Base.CrudController = BaseCrudController;
4423
+ Base.Entity = BaseEntity;
4424
+ Base.AbstractEntity = BaseAbstractEntity;
4425
+ Base.Provider = BaseProvider;
4426
+ Base.Class = BaseClass;
4427
+ Base.Repository = BaseRepository;
4428
+ Base.Subscriber = BaseSubscriber;
4429
+ Base.SubscriberForEntity = BaseSubscriberForEntity;
4430
+ Base.Context = BaseContext;
4431
+ })(Base || (Base = {}));
4432
+ ;
4433
+ ({}); // @--end-of-file-for-module=taon lib/base-classes/base.ts
4434
+
4435
+ function TaonEntity(options) {
4436
+ return function (constructor) {
4437
+ options = options || {};
4438
+ options.uniqueKeyProp = options.uniqueKeyProp || 'id';
4439
+ ClassHelpers.setName(constructor, options?.className);
4440
+ Mapping.DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
4441
+ Mapping.DefaultModelWithMapping(void 0, {})(constructor);
4442
+ Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
4443
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
4444
+ Entity(options?.className)(constructor);
4445
+ CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
4446
+ };
4447
+ }
4448
+ class TaonEntityOptions extends Models.DecoratorAbstractOpt {
4449
+ }
4450
+ ;
4451
+ ({}); // @--end-of-file-for-module=taon lib/decorators/classes/entity-decorator.ts
4452
+
4453
+ function TaonProvider(options) {
4454
+ return function (constructor) {
4455
+ Reflect.defineMetadata(Symbols.metadata.options.provider, options, constructor);
4456
+ Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
4457
+ ClassHelpers.setName(constructor, options?.className || constructor.name);
4458
+ };
4459
+ }
4460
+ class TaonProviderOptions extends Models.DecoratorAbstractOpt {
4461
+ }
4462
+ ;
4463
+ ({}); // @--end-of-file-for-module=taon lib/decorators/classes/provider-decorator.ts
4464
+
4465
+ const inject = (entity) => {
4466
+ return new Proxy({}, {
4467
+ get: (_, propName) => {
4468
+ if (propName === 'hasOwnProperty') {
4469
+ return () => false;
4470
+ }
4471
+ const ctor = entity();
4472
+ const contextFromClass = ctor[Symbols.ctxInClassOrClassObj];
4473
+ const resultContext = contextFromClass;
4474
+ if (resultContext) {
4475
+ let instance = resultContext.inject(ctor);
4476
+ if (propName === 'getOriginalPrototype') {
4477
+ return () => Object.getPrototypeOf(instance);
4478
+ }
4479
+ if (propName === 'getOriginalConstructor') {
4480
+ return () => instance.constructor;
4481
+ }
4482
+ const methods = ctor[Symbols.classMethodsNames] || [];
4483
+ const isMethods = methods.includes(propName);
4484
+ const methodOrProperty = isMethods
4485
+ ? instance[propName].bind(instance)
4486
+ : instance[propName];
4487
+ return methodOrProperty;
4488
+ }
4489
+ return inject$1(ctor)[propName];
4490
+ },
4491
+ });
4492
+ };
4493
+ const injectController = inject;
4494
+ const injectSubscriberEvents = (subscriberClassResolveFn, eventName) => {
4495
+ const eventsSrc = new Subject();
4496
+ const obs = eventsSrc.asObservable();
4497
+ let isFirstSubscription = true;
4498
+ const proxiedObservable = new Proxy(obs, {
4499
+ get(target, prop, receiver) {
4500
+ if (prop === 'subscribe') {
4501
+ return (...args) => {
4502
+ if (isFirstSubscription) {
4503
+ isFirstSubscription = false;
4504
+ const subscriberClassFN = subscriberClassResolveFn();
4505
+ const ctx = subscriberClassFN[Symbols.ctxInClassOrClassObj];
4506
+ if (!ctx) {
4507
+ throw new Error(`You are trying to inject class without context. Use context like this;
4508
+
4509
+ Taon.injectSubscriberEvents( ()=> ` +
4510
+ `MyContext.getInstance(${subscriberClassFN?.name}), '${eventName}' )
4511
+
4512
+
4513
+ `);
4514
+ }
4515
+ const subscriberInstance = ctx.getInstanceBy(subscriberClassFN);
4516
+ console.log('First subscription, you can access arguments here:', {
4517
+ subscriberClassFN,
4518
+ eventName,
4519
+ });
4520
+ }
4521
+ return target.subscribe(...args);
4522
+ };
4523
+ }
4524
+ return Reflect.get(target, prop, receiver);
4525
+ },
4526
+ });
4527
+ return proxiedObservable;
4528
+ };
4529
+ ;
4530
+ ({}); // @--end-of-file-for-module=taon lib/inject.ts
4531
+
4532
+ ;
4533
+ ({}); // @--end-of-file-for-module=taon lib/constants.ts
4534
+
4535
+ var Taon;
4536
+ (function (Taon) {
4537
+ Taon.Http = Http;
4538
+ Taon.Base = Base;
4539
+ Taon.Orm = Orm;
4540
+ Taon.getResponseValue = getResponseValue;
4541
+ Taon.Controller = TaonController;
4542
+ Taon.Entity = TaonEntity;
4543
+ Taon.Provider = TaonProvider;
4544
+ Taon.Repository = TaonRepository;
4545
+ Taon.Subscriber = TaonSubscriber;
4546
+ /**
4547
+ * @deprecated
4548
+ */
4549
+ Taon.isBrowser = coreHelpers.Helpers.isBrowser;
4550
+ /**
4551
+ * @deprecated
4552
+ */
4553
+ Taon.isNode = coreHelpers.Helpers.isNode;
4554
+ /**
4555
+ * @deprecated
4556
+ */
4557
+ Taon.isWebSQL = coreHelpers.Helpers.isWebSQL;
4558
+ /**
4559
+ * @deprecated
4560
+ */
4561
+ Taon.isElectron = coreHelpers.Helpers.isElectron;
4562
+ Taon.createContext = createContext;
4563
+ Taon.inject = inject;
4564
+ Taon.initNgZone = (ngZone) => {
4565
+ EndpointContext.initNgZone(ngZone);
4566
+ };
4567
+ Taon.symbols = Symbols;
4568
+ /**
4569
+ * @deprecated
4570
+ * use createContext instead
4571
+ */
4572
+ Taon.init = async (options) => {
4573
+ const BaseContext = (await Promise.resolve().then(function () { return baseContext; }))
4574
+ .BaseContext;
4575
+ const context = Taon.createContext(() => ({
4576
+ contextName: 'default',
4577
+ host: options.host,
4578
+ contexts: { BaseContext },
4579
+ database: true,
4580
+ entities: Array.from(options.entities),
4581
+ controllers: Array.from(options.controllers),
4582
+ }));
4583
+ await context.initialize();
4584
+ return context;
4585
+ };
4586
+ })(Taon || (Taon = {}));
4587
+ ;
4588
+ ({}); // @--end-of-file-for-module=taon lib/index.ts
4589
+
4590
+ /**
4591
+ * Generated bundle index. Do not edit.
4592
+ */
4593
+
4594
+ export { BaseContext, BaseController, BaseEntity, BaseProvider, BaseRepository, BaseSubscriber, ClassHelpers, Models, Taon, createContext, inject };
4595
+ //# sourceMappingURL=taon.mjs.map