@things-factory/integration-base 7.0.0-alpha.9 → 7.0.0

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 (351) hide show
  1. package/dist-server/controllers/index.d.ts +1 -0
  2. package/dist-server/controllers/scenario-controller.d.ts +4 -0
  3. package/dist-server/controllers/scenario-controller.js +23 -7
  4. package/dist-server/controllers/scenario-controller.js.map +1 -1
  5. package/dist-server/engine/analyzer/analyze-integration.d.ts +5 -0
  6. package/dist-server/engine/analyzer/analyze-integration.js +1 -2
  7. package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
  8. package/dist-server/engine/connection-manager.d.ts +35 -0
  9. package/dist-server/engine/connection-manager.js +50 -13
  10. package/dist-server/engine/connection-manager.js.map +1 -1
  11. package/dist-server/engine/connector/echo-back-connector.d.ts +9 -0
  12. package/dist-server/engine/connector/echo-back-connector.js +1 -1
  13. package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
  14. package/dist-server/engine/connector/echo-back-server.d.ts +8 -0
  15. package/dist-server/engine/connector/echo-back-server.js.map +1 -1
  16. package/dist-server/engine/connector/graphql-connector.d.ts +19 -0
  17. package/dist-server/engine/connector/graphql-connector.js +9 -9
  18. package/dist-server/engine/connector/graphql-connector.js.map +1 -1
  19. package/dist-server/engine/connector/http-connector.d.ts +25 -0
  20. package/dist-server/engine/connector/http-connector.js.map +1 -1
  21. package/dist-server/engine/connector/index.d.ts +12 -0
  22. package/dist-server/engine/connector/mqtt-connector.d.ts +14 -0
  23. package/dist-server/engine/connector/mqtt-connector.js +1 -1
  24. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  25. package/dist-server/engine/connector/mssql-connector.d.ts +30 -0
  26. package/dist-server/engine/connector/mssql-connector.js +21 -5
  27. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  28. package/dist-server/engine/connector/mysql-connector.d.ts +13 -0
  29. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  30. package/dist-server/engine/connector/operato-connector.d.ts +27 -0
  31. package/dist-server/engine/connector/operato-connector.js +21 -24
  32. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  33. package/dist-server/engine/connector/oracle-connector.d.ts +29 -0
  34. package/dist-server/engine/connector/oracle-connector.js +1 -1
  35. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  36. package/dist-server/engine/connector/postgresql-connector.d.ts +14 -0
  37. package/dist-server/engine/connector/postgresql-connector.js +2 -2
  38. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  39. package/dist-server/engine/connector/proxy-connector.d.ts +15 -0
  40. package/dist-server/engine/connector/proxy-connector.js +44 -0
  41. package/dist-server/engine/connector/proxy-connector.js.map +1 -0
  42. package/dist-server/engine/connector/socket-server.d.ts +9 -0
  43. package/dist-server/engine/connector/socket-server.js +1 -1
  44. package/dist-server/engine/connector/socket-server.js.map +1 -1
  45. package/dist-server/engine/connector/sqlite-connector.d.ts +10 -0
  46. package/dist-server/engine/connector/sqlite-connector.js +2 -2
  47. package/dist-server/engine/connector/sqlite-connector.js.map +1 -1
  48. package/dist-server/engine/edge-client.d.ts +18 -0
  49. package/dist-server/engine/edge-client.js +37 -0
  50. package/dist-server/engine/edge-client.js.map +1 -0
  51. package/dist-server/engine/index.d.ts +8 -0
  52. package/dist-server/engine/index.js +1 -0
  53. package/dist-server/engine/index.js.map +1 -1
  54. package/dist-server/engine/pending-queue.d.ts +24 -0
  55. package/dist-server/engine/pending-queue.js.map +1 -1
  56. package/dist-server/engine/scenario-engine.d.ts +11 -0
  57. package/dist-server/engine/scenario-engine.js.map +1 -1
  58. package/dist-server/engine/task/book-up-scenario.d.ts +1 -0
  59. package/dist-server/engine/task/csv-readline.d.ts +1 -0
  60. package/dist-server/engine/task/csv-readline.js.map +1 -1
  61. package/dist-server/engine/task/data-accessor.d.ts +1 -0
  62. package/dist-server/engine/task/data-mapper.d.ts +1 -0
  63. package/dist-server/engine/task/data-mapper.js.map +1 -1
  64. package/dist-server/engine/task/database-query.d.ts +1 -0
  65. package/dist-server/engine/task/database-query.js +21 -12
  66. package/dist-server/engine/task/database-query.js.map +1 -1
  67. package/dist-server/engine/task/echo-receive.d.ts +1 -0
  68. package/dist-server/engine/task/echo-send.d.ts +1 -0
  69. package/dist-server/engine/task/echo-send.js.map +1 -1
  70. package/dist-server/engine/task/empty-check.d.ts +1 -0
  71. package/dist-server/engine/task/empty-check.js.map +1 -1
  72. package/dist-server/engine/task/end.d.ts +1 -0
  73. package/dist-server/engine/task/floating-point.d.ts +1 -0
  74. package/dist-server/engine/task/floating-point.js.map +1 -1
  75. package/dist-server/engine/task/goto.d.ts +1 -0
  76. package/dist-server/engine/task/graphql-mutate.d.ts +1 -0
  77. package/dist-server/engine/task/graphql-mutate.js +23 -12
  78. package/dist-server/engine/task/graphql-mutate.js.map +1 -1
  79. package/dist-server/engine/task/graphql-query.d.ts +1 -0
  80. package/dist-server/engine/task/graphql-query.js +23 -12
  81. package/dist-server/engine/task/graphql-query.js.map +1 -1
  82. package/dist-server/engine/task/headless-post.d.ts +1 -0
  83. package/dist-server/engine/task/headless-post.js.map +1 -1
  84. package/dist-server/engine/task/headless-scrap.d.ts +1 -0
  85. package/dist-server/engine/task/headless-scrap.js.map +1 -1
  86. package/dist-server/engine/task/http-get.d.ts +1 -0
  87. package/dist-server/engine/task/http-get.js +28 -12
  88. package/dist-server/engine/task/http-get.js.map +1 -1
  89. package/dist-server/engine/task/http-post.d.ts +1 -0
  90. package/dist-server/engine/task/http-post.js +22 -11
  91. package/dist-server/engine/task/http-post.js.map +1 -1
  92. package/dist-server/engine/task/index.d.ts +43 -0
  93. package/dist-server/engine/task/jsonata.d.ts +1 -0
  94. package/dist-server/engine/task/jsonata.js +5 -1
  95. package/dist-server/engine/task/jsonata.js.map +1 -1
  96. package/dist-server/engine/task/local-graphql-mutate.d.ts +1 -0
  97. package/dist-server/engine/task/local-graphql-mutate.js +23 -11
  98. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  99. package/dist-server/engine/task/local-graphql-query.d.ts +1 -0
  100. package/dist-server/engine/task/local-graphql-query.js +23 -11
  101. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  102. package/dist-server/engine/task/log.d.ts +1 -0
  103. package/dist-server/engine/task/log.js +15 -11
  104. package/dist-server/engine/task/log.js.map +1 -1
  105. package/dist-server/engine/task/mqtt-publish.d.ts +1 -0
  106. package/dist-server/engine/task/mqtt-publish.js.map +1 -1
  107. package/dist-server/engine/task/mqtt-subscribe.d.ts +1 -0
  108. package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
  109. package/dist-server/engine/task/oracle-procedure.d.ts +1 -0
  110. package/dist-server/engine/task/oracle-procedure.js +19 -13
  111. package/dist-server/engine/task/oracle-procedure.js.map +1 -1
  112. package/dist-server/engine/task/pick-pending-scenario.d.ts +1 -0
  113. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  114. package/dist-server/engine/task/publish.d.ts +1 -0
  115. package/dist-server/engine/task/publish.js.map +1 -1
  116. package/dist-server/engine/task/random.d.ts +1 -0
  117. package/dist-server/engine/task/reset-pending-queue.d.ts +1 -0
  118. package/dist-server/engine/task/script.d.ts +1 -0
  119. package/dist-server/engine/task/script.js +35 -18
  120. package/dist-server/engine/task/script.js.map +1 -1
  121. package/dist-server/engine/task/set-domain.d.ts +1 -0
  122. package/dist-server/engine/task/set-domain.js.map +1 -1
  123. package/dist-server/engine/task/sleep.d.ts +1 -0
  124. package/dist-server/engine/task/sleep.js.map +1 -1
  125. package/dist-server/engine/task/socket-listener.d.ts +1 -0
  126. package/dist-server/engine/task/socket-listener.js.map +1 -1
  127. package/dist-server/engine/task/state-read.d.ts +1 -0
  128. package/dist-server/engine/task/state-read.js.map +1 -1
  129. package/dist-server/engine/task/state-write.d.ts +1 -0
  130. package/dist-server/engine/task/state-write.js.map +1 -1
  131. package/dist-server/engine/task/stop-scenario.d.ts +1 -0
  132. package/dist-server/engine/task/sub-scenario.d.ts +1 -0
  133. package/dist-server/engine/task/switch-goto.d.ts +1 -0
  134. package/dist-server/engine/task/switch-range-goto.d.ts +1 -0
  135. package/dist-server/engine/task/switch-range-goto.js.map +1 -1
  136. package/dist-server/engine/task/switch-range-scenario.d.ts +1 -0
  137. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  138. package/dist-server/engine/task/switch-range-set.d.ts +1 -0
  139. package/dist-server/engine/task/switch-range-set.js.map +1 -1
  140. package/dist-server/engine/task/switch-scenario.d.ts +1 -0
  141. package/dist-server/engine/task/switch-set.d.ts +1 -0
  142. package/dist-server/engine/task/throw.d.ts +1 -0
  143. package/dist-server/engine/task/utils/headless-pool-for-scenario.d.ts +1 -0
  144. package/dist-server/engine/task/utils/headless-pool-for-scenario.js +1 -2
  145. package/dist-server/engine/task/utils/headless-pool-for-scenario.js.map +1 -1
  146. package/dist-server/engine/task/utils/substitute.d.ts +1 -0
  147. package/dist-server/engine/task/utils/substitute.js +1 -2
  148. package/dist-server/engine/task/utils/substitute.js.map +1 -1
  149. package/dist-server/engine/task/variables.d.ts +1 -0
  150. package/dist-server/engine/task-registry.d.ts +12 -0
  151. package/dist-server/engine/types.d.ts +94 -0
  152. package/dist-server/engine/types.js.map +1 -1
  153. package/dist-server/index.d.ts +6 -0
  154. package/dist-server/index.js +1 -2
  155. package/dist-server/index.js.map +1 -1
  156. package/dist-server/migrations/index.d.ts +1 -0
  157. package/dist-server/restful/index.d.ts +1 -0
  158. package/dist-server/restful/unstable/index.d.ts +7 -0
  159. package/dist-server/restful/unstable/run-scenario.d.ts +1 -0
  160. package/dist-server/restful/unstable/run-scenario.js +0 -1
  161. package/dist-server/restful/unstable/run-scenario.js.map +1 -1
  162. package/dist-server/restful/unstable/scenario-instance.d.ts +1 -0
  163. package/dist-server/restful/unstable/scenario-instances.d.ts +1 -0
  164. package/dist-server/restful/unstable/scenario.d.ts +1 -0
  165. package/dist-server/restful/unstable/scenarios.d.ts +1 -0
  166. package/dist-server/restful/unstable/start-scenario.d.ts +1 -0
  167. package/dist-server/restful/unstable/stop-scenario.d.ts +1 -0
  168. package/dist-server/routers/scenario-schedule-callback-router.d.ts +1 -0
  169. package/dist-server/routers/scenario-schedule-callback-router.js +2 -3
  170. package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
  171. package/dist-server/routers/scenario-view-router.d.ts +1 -0
  172. package/dist-server/routers/scenario-view-router.js.map +1 -1
  173. package/dist-server/routes.d.ts +1 -0
  174. package/dist-server/routes.js.map +1 -1
  175. package/dist-server/service/analysis/analysis-query.d.ts +3 -0
  176. package/dist-server/service/analysis/analysis-query.js +2 -2
  177. package/dist-server/service/analysis/analysis-query.js.map +1 -1
  178. package/dist-server/service/analysis/index.d.ts +2 -0
  179. package/dist-server/service/connection/connection-mutation.d.ts +30 -0
  180. package/dist-server/service/connection/connection-mutation.js +6 -10
  181. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  182. package/dist-server/service/connection/connection-query.d.ts +12 -0
  183. package/dist-server/service/connection/connection-query.js +18 -11
  184. package/dist-server/service/connection/connection-query.js.map +1 -1
  185. package/dist-server/service/connection/connection-subscription.d.ts +10 -0
  186. package/dist-server/service/connection/connection-subscription.js +3 -3
  187. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  188. package/dist-server/service/connection/connection-type.d.ts +133 -0
  189. package/dist-server/service/connection/connection-type.js +45 -21
  190. package/dist-server/service/connection/connection-type.js.map +1 -1
  191. package/dist-server/service/connection/index.d.ts +6 -0
  192. package/dist-server/service/connector/connector-query.d.ts +6 -0
  193. package/dist-server/service/connector/connector-query.js +2 -2
  194. package/dist-server/service/connector/connector-query.js.map +1 -1
  195. package/dist-server/service/connector/connector-type.d.ts +12 -0
  196. package/dist-server/service/connector/connector-type.js +4 -4
  197. package/dist-server/service/connector/connector-type.js.map +1 -1
  198. package/dist-server/service/connector/index.d.ts +3 -0
  199. package/dist-server/service/index.d.ts +17 -0
  200. package/dist-server/service/payload-log/index.d.ts +5 -0
  201. package/dist-server/service/payload-log/payload-log-mutation.d.ts +10 -0
  202. package/dist-server/service/payload-log/payload-log-mutation.js +5 -5
  203. package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
  204. package/dist-server/service/payload-log/payload-log-query.d.ts +11 -0
  205. package/dist-server/service/payload-log/payload-log-query.js +3 -3
  206. package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
  207. package/dist-server/service/payload-log/payload-log-type.d.ts +15 -0
  208. package/dist-server/service/payload-log/payload-log-type.js +6 -6
  209. package/dist-server/service/payload-log/payload-log-type.js.map +1 -1
  210. package/dist-server/service/payload-log/payload-log.d.ts +23 -0
  211. package/dist-server/service/payload-log/payload-log.js +6 -6
  212. package/dist-server/service/payload-log/payload-log.js.map +1 -1
  213. package/dist-server/service/property-spec.d.ts +12 -0
  214. package/dist-server/service/property-spec.js +6 -2
  215. package/dist-server/service/property-spec.js.map +1 -1
  216. package/dist-server/service/scenario/index.d.ts +5 -0
  217. package/dist-server/service/scenario/scenario-mutation.d.ts +13 -0
  218. package/dist-server/service/scenario/scenario-mutation.js +3 -3
  219. package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
  220. package/dist-server/service/scenario/scenario-query.d.ts +18 -0
  221. package/dist-server/service/scenario/scenario-query.js +3 -3
  222. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  223. package/dist-server/service/scenario/scenario-type.d.ts +30 -0
  224. package/dist-server/service/scenario/scenario-type.js +14 -6
  225. package/dist-server/service/scenario/scenario-type.js.map +1 -1
  226. package/dist-server/service/scenario/scenario.d.ts +36 -0
  227. package/dist-server/service/scenario/scenario.js +18 -9
  228. package/dist-server/service/scenario/scenario.js.map +1 -1
  229. package/dist-server/service/scenario-flow/scenario-flow.d.ts +6 -0
  230. package/dist-server/service/scenario-flow/scenario-flow.js +2 -2
  231. package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
  232. package/dist-server/service/scenario-instance/index.d.ts +5 -0
  233. package/dist-server/service/scenario-instance/scenario-instance-mutation.d.ts +6 -0
  234. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +3 -3
  235. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  236. package/dist-server/service/scenario-instance/scenario-instance-query.d.ts +6 -0
  237. package/dist-server/service/scenario-instance/scenario-instance-query.js +3 -67
  238. package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
  239. package/dist-server/service/scenario-instance/scenario-instance-subscription.d.ts +10 -0
  240. package/dist-server/service/scenario-instance/scenario-instance-subscription.js +2 -2
  241. package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
  242. package/dist-server/service/scenario-instance/scenario-instance-type.d.ts +102 -0
  243. package/dist-server/service/scenario-instance/scenario-instance-type.js +127 -33
  244. package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
  245. package/dist-server/service/scenario-queue/index.d.ts +3 -0
  246. package/dist-server/service/scenario-queue/scenario-queue-subscription.d.ts +6 -0
  247. package/dist-server/service/scenario-queue/scenario-queue-subscription.js +2 -2
  248. package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
  249. package/dist-server/service/scenario-queue/scenario-queue-type.d.ts +11 -0
  250. package/dist-server/service/scenario-queue/scenario-queue-type.js +4 -4
  251. package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
  252. package/dist-server/service/state-register/index.d.ts +6 -0
  253. package/dist-server/service/state-register/state-register-mutation.d.ts +11 -0
  254. package/dist-server/service/state-register/state-register-mutation.js +2 -2
  255. package/dist-server/service/state-register/state-register-mutation.js.map +1 -1
  256. package/dist-server/service/state-register/state-register-query.d.ts +14 -0
  257. package/dist-server/service/state-register/state-register-query.js +3 -3
  258. package/dist-server/service/state-register/state-register-query.js.map +1 -1
  259. package/dist-server/service/state-register/state-register-type.d.ts +23 -0
  260. package/dist-server/service/state-register/state-register-type.js +6 -6
  261. package/dist-server/service/state-register/state-register-type.js.map +1 -1
  262. package/dist-server/service/state-register/state-register.d.ts +22 -0
  263. package/dist-server/service/state-register/state-register.js +3 -3
  264. package/dist-server/service/state-register/state-register.js.map +1 -1
  265. package/dist-server/service/step/index.d.ts +5 -0
  266. package/dist-server/service/step/step-mutation.d.ts +5 -0
  267. package/dist-server/service/step/step-mutation.js +2 -2
  268. package/dist-server/service/step/step-mutation.js.map +1 -1
  269. package/dist-server/service/step/step-query.d.ts +12 -0
  270. package/dist-server/service/step/step-query.js +3 -3
  271. package/dist-server/service/step/step-query.js.map +1 -1
  272. package/dist-server/service/step/step-type.d.ts +111 -0
  273. package/dist-server/service/step/step-type.js +25 -22
  274. package/dist-server/service/step/step-type.js.map +1 -1
  275. package/dist-server/service/task-type/index.d.ts +3 -0
  276. package/dist-server/service/task-type/task-type-query.d.ts +6 -0
  277. package/dist-server/service/task-type/task-type-query.js +2 -2
  278. package/dist-server/service/task-type/task-type-query.js.map +1 -1
  279. package/dist-server/service/task-type/task-type-type.d.ts +12 -0
  280. package/dist-server/service/task-type/task-type-type.js +4 -4
  281. package/dist-server/service/task-type/task-type-type.js.map +1 -1
  282. package/dist-server/tsconfig.tsbuildinfo +1 -1
  283. package/helps/integration/concept/script-internal-variables.ja.md +21 -1
  284. package/helps/integration/concept/script-internal-variables.ko.md +17 -0
  285. package/helps/integration/concept/script-internal-variables.md +18 -0
  286. package/helps/integration/concept/script-internal-variables.ms.md +19 -1
  287. package/helps/integration/concept/script-internal-variables.zh.md +18 -0
  288. package/helps/integration/connector/mssql-connector.ja.md +13 -9
  289. package/helps/integration/connector/mssql-connector.ko.md +13 -9
  290. package/helps/integration/connector/mssql-connector.md +13 -9
  291. package/helps/integration/connector/mssql-connector.ms.md +13 -9
  292. package/helps/integration/connector/mssql-connector.zh.md +13 -9
  293. package/helps/integration/connector/operato-connector.ja.md +0 -3
  294. package/helps/integration/task/script.ja.md +1 -1
  295. package/helps/integration/task/script.ko.md +1 -1
  296. package/helps/integration/task/script.md +1 -1
  297. package/helps/integration/task/script.ms.md +1 -1
  298. package/helps/integration/task/script.zh.md +1 -1
  299. package/package.json +12 -11
  300. package/server/controllers/scenario-controller.ts +60 -11
  301. package/server/engine/connection-manager.ts +63 -14
  302. package/server/engine/connector/echo-back-connector.ts +2 -1
  303. package/server/engine/connector/graphql-connector.ts +12 -9
  304. package/server/engine/connector/mqtt-connector.ts +2 -1
  305. package/server/engine/connector/mssql-connector.ts +21 -5
  306. package/server/engine/connector/operato-connector.ts +22 -26
  307. package/server/engine/connector/oracle-connector.ts +5 -8
  308. package/server/engine/connector/postgresql-connector.ts +3 -2
  309. package/server/engine/connector/proxy-connector.ts +53 -0
  310. package/server/engine/connector/socket-server.ts +1 -1
  311. package/server/engine/connector/sqlite-connector.ts +2 -5
  312. package/server/engine/edge-client.ts +45 -0
  313. package/server/engine/index.ts +2 -1
  314. package/server/engine/task/database-query.ts +21 -12
  315. package/server/engine/task/graphql-mutate.ts +23 -13
  316. package/server/engine/task/graphql-query.ts +22 -13
  317. package/server/engine/task/http-get.ts +26 -12
  318. package/server/engine/task/http-post.ts +22 -11
  319. package/server/engine/task/jsonata.ts +5 -1
  320. package/server/engine/task/local-graphql-mutate.ts +23 -13
  321. package/server/engine/task/local-graphql-query.ts +23 -11
  322. package/server/engine/task/log.ts +14 -11
  323. package/server/engine/task/oracle-procedure.ts +24 -18
  324. package/server/engine/task/script.ts +33 -18
  325. package/server/engine/types.ts +47 -48
  326. package/server/index.ts +1 -2
  327. package/server/restful/unstable/run-scenario.ts +0 -1
  328. package/server/routers/scenario-schedule-callback-router.ts +2 -2
  329. package/server/service/connection/connection-mutation.ts +9 -29
  330. package/server/service/connection/connection-query.ts +17 -7
  331. package/server/service/connection/connection-subscription.ts +1 -1
  332. package/server/service/connection/connection-type.ts +53 -32
  333. package/server/service/payload-log/payload-log-mutation.ts +1 -1
  334. package/server/service/payload-log/payload-log-query.ts +4 -1
  335. package/server/service/payload-log/payload-log.ts +5 -5
  336. package/server/service/property-spec.ts +3 -0
  337. package/server/service/scenario/scenario-query.ts +1 -1
  338. package/server/service/scenario/scenario-type.ts +6 -0
  339. package/server/service/scenario/scenario.ts +26 -7
  340. package/server/service/scenario-instance/scenario-instance-mutation.ts +7 -4
  341. package/server/service/scenario-instance/scenario-instance-query.ts +4 -30
  342. package/server/service/scenario-instance/scenario-instance-type.ts +105 -19
  343. package/server/service/state-register/state-register-query.ts +4 -1
  344. package/server/service/state-register/state-register.ts +1 -1
  345. package/server/service/step/step-query.ts +1 -1
  346. package/server/service/step/step-type.ts +81 -79
  347. package/translations/en.json +4 -1
  348. package/translations/ja.json +4 -1
  349. package/translations/ko.json +4 -1
  350. package/translations/ms.json +4 -1
  351. package/translations/zh.json +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGzF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CACP,IAAY,EACX,KAAsB,EAC7B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE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EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAUP;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiBxD;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAkB3D;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IAC1B,oGAAoG;;IACnG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IAE7E,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAC7C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA4CP;AAvMU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAwM9B;AAxMY,gDAAkB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(\n @Arg('connection') connection: NewConnection,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n // @Directive('@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(\n @Arg('connections', type => [ConnectionPatch]) connections: Connection[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGzF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAwB;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CAAc,IAAY,EAAgB,KAAsB,EAAS,OAAwB;QACrH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,UAAU,GACV,KAAK,KACR,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAA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CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAexD;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAgB3D;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IAC1B,oGAAoG;;IACnG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAA6B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA2CvG;6BAnLU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAoL9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(@Arg('connection') connection: NewConnection, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(@Arg('name') name: string, @Arg('patch') patch: ConnectionPatch, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(@Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[], @Ctx() context: ResolverContext): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(@Arg('names', type => [String]) names: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n // @Directive('@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(@Arg('connections', type => [ConnectionPatch]) connections: Connection[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Appliance, User } from '@things-factory/auth-base';
2
+ import { Domain, ListParam } from '@things-factory/shell';
3
+ import { Connection, ConnectionList, ConnectionState } from './connection-type';
4
+ export declare class ConnectionQuery {
5
+ connection(name: string, context: ResolverContext): Promise<Connection>;
6
+ connections(params: ListParam, context: ResolverContext): Promise<ConnectionList>;
7
+ fetchConnectionState(name: string, context: ResolverContext): ConnectionState;
8
+ edge(connection: Connection): Promise<Appliance>;
9
+ domain(connection: Connection): Promise<Domain>;
10
+ updater(connection: Connection): Promise<User>;
11
+ creator(connection: Connection): Promise<User>;
12
+ }
@@ -37,22 +37,23 @@ let ConnectionQuery = class ConnectionQuery {
37
37
  }
38
38
  fetchConnectionState(name, context) {
39
39
  const { domain } = context.state;
40
- var connection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, name);
41
- return {
42
- name,
43
- state: connection ? connection_type_1.ConnectionStatus.CONNECTED : connection_type_1.ConnectionStatus.DISCONNECTED
44
- };
40
+ const connection = connection_manager_1.ConnectionManager.getConnectionInstanceEntityByName(domain, name);
41
+ return Object.assign(Object.assign({}, connection), { state: connection ? connection_type_1.ConnectionStatus.CONNECTED : connection_type_1.ConnectionStatus.DISCONNECTED });
42
+ }
43
+ async edge(connection) {
44
+ return connection.edgeId && (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOneBy({ id: connection.edgeId }));
45
45
  }
46
46
  async domain(connection) {
47
- return connection.domain || (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: connection.domainId }));
47
+ return (connection.domain || (connection.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: connection.domainId }))));
48
48
  }
49
49
  async updater(connection) {
50
- return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.updaterId });
50
+ return connection.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.updaterId }));
51
51
  }
52
52
  async creator(connection) {
53
- return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.creatorId });
53
+ return connection.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.creatorId }));
54
54
  }
55
55
  };
56
+ exports.ConnectionQuery = ConnectionQuery;
56
57
  tslib_1.__decorate([
57
58
  (0, type_graphql_1.Query)(returns => connection_type_1.Connection, { description: 'To fetch a connection' }),
58
59
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
@@ -63,7 +64,7 @@ tslib_1.__decorate([
63
64
  ], ConnectionQuery.prototype, "connection", null);
64
65
  tslib_1.__decorate([
65
66
  (0, type_graphql_1.Query)(returns => connection_type_1.ConnectionList, { description: 'To fetch multiple connections' }),
66
- tslib_1.__param(0, (0, type_graphql_1.Args)()),
67
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
67
68
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
68
69
  tslib_1.__metadata("design:type", Function),
69
70
  tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
@@ -77,6 +78,13 @@ tslib_1.__decorate([
77
78
  tslib_1.__metadata("design:paramtypes", [String, Object]),
78
79
  tslib_1.__metadata("design:returntype", connection_type_1.ConnectionState)
79
80
  ], ConnectionQuery.prototype, "fetchConnectionState", null);
81
+ tslib_1.__decorate([
82
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
83
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
84
+ tslib_1.__metadata("design:type", Function),
85
+ tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
86
+ tslib_1.__metadata("design:returntype", Promise)
87
+ ], ConnectionQuery.prototype, "edge", null);
80
88
  tslib_1.__decorate([
81
89
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
82
90
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -98,8 +106,7 @@ tslib_1.__decorate([
98
106
  tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
99
107
  tslib_1.__metadata("design:returntype", Promise)
100
108
  ], ConnectionQuery.prototype, "creator", null);
101
- ConnectionQuery = tslib_1.__decorate([
109
+ exports.ConnectionQuery = ConnectionQuery = tslib_1.__decorate([
102
110
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
103
111
  ], ConnectionQuery);
104
- exports.ConnectionQuery = ConnectionQuery;
105
112
  //# sourceMappingURL=connection-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAAgD;AAChD,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAG1F,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,kCAAgB,CAAC,YAAY,GACpB,CAAA;IACjB,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAwB;QAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA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,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAlEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAmE3B;AAnEY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n var connection = ConnectionManager.getConnectionInstanceByName(domain, name)\n\n return {\n name,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (await getRepository(Domain).findOneBy({ id: connection.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOneBy({ id: connection.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOneBy({ id: connection.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAG1F,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,kCAAgB,CAAC,YAAY,GACpB,CAAA;IACjB,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CACU,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,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C;IACnE,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAA4B,iCAAe;2DAShG;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAClB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;2CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAI1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;0BA5EU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CA6E3B","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Log } from '@things-factory/shell';
2
+ import { ConnectionState } from './connection-type';
3
+ export declare class ConnectionSubscription {
4
+ connectionState(payload: {
5
+ connectionState: ConnectionState;
6
+ }, name: string): ConnectionState;
7
+ connectionLog(payload: {
8
+ log: Log;
9
+ }, level: string): Log;
10
+ }
@@ -16,6 +16,7 @@ let ConnectionSubscription = class ConnectionSubscription {
16
16
  return payload.log;
17
17
  }
18
18
  };
19
+ exports.ConnectionSubscription = ConnectionSubscription;
19
20
  tslib_1.__decorate([
20
21
  (0, type_graphql_1.Subscription)({
21
22
  subscribe: ({ args, context, info }) => {
@@ -37,7 +38,7 @@ tslib_1.__decorate([
37
38
  }
38
39
  var connections = await (0, shell_1.getRepository)(connection_type_1.Connection).find({
39
40
  where,
40
- relations: ['domain']
41
+ relations: ['domain', 'edge']
41
42
  });
42
43
  connections.forEach(connection => {
43
44
  shell_1.pubsub.publish('connection-state', {
@@ -91,8 +92,7 @@ tslib_1.__decorate([
91
92
  tslib_1.__metadata("design:paramtypes", [Object, String]),
92
93
  tslib_1.__metadata("design:returntype", shell_1.Log)
93
94
  ], ConnectionSubscription.prototype, "connectionLog", null);
94
- ConnectionSubscription = tslib_1.__decorate([
95
+ exports.ConnectionSubscription = ConnectionSubscription = tslib_1.__decorate([
95
96
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
96
97
  ], ConnectionSubscription);
97
- exports.ConnectionSubscription = ConnectionSubscription;
98
98
  //# sourceMappingURL=connection-subscription.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,uDAAiF;AAEjF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAgDjC,eAAe,CAAS,OAA6C,EAAmC,IAAY;QAClH,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAuCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AA3F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AC,CAAA;aACnC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAClG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aAChF;YAED,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAClC,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAqB,EAAE,EAAE;gBACrC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;gBACnD,qCAAqC;gBAErC,0CAA0C;gBAC1C,iBAAiB;gBACjB,IAAI;gBAEJ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE;oBAC7B,OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACa,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAyB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;4CAAiB,WAAG;2DAEjG;AA3FU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CA4FlC;AA5FY,wDAAsB","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { getRepository, Log, pubsub } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionState, ConnectionStatus } from './connection-type'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain: { id: domain.id } }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return pipe(\n pubsub.subscribe('connection-state'),\n filter(async (payload: { connectionState: ConnectionState }) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n })\n )\n }\n })\n connectionState(@Root() payload: { connectionState: ConnectionState }, @Arg('name', { nullable: true }) name: string): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('connection-log'),\n filter(async (payload: { log: Log }) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.log\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n })\n )\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
1
+ {"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,uDAAiF;AAEjF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAgDjC,eAAe,CAAS,OAA6C,EAAmC,IAAY;QAClH,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAuCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AA5FY,wDAAsB;AAgDjC;IA/CC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;;YACrC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YACrB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;gBACnG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,I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C;oBAC9B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACa,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAyB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;4CAAiB,WAAG;2DAEjG;iCA3FU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CA4FlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { getRepository, Log, pubsub } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionState, ConnectionStatus } from './connection-type'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain: { id: domain.id } }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain', 'edge']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return pipe(\n pubsub.subscribe('connection-state'),\n filter(async (payload: { connectionState: ConnectionState }) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n })\n )\n }\n })\n connectionState(@Root() payload: { connectionState: ConnectionState }, @Arg('name', { nullable: true }) name: string): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('connection-log'),\n filter(async (payload: { log: Log }) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.log\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n })\n )\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
@@ -0,0 +1,133 @@
1
+ import { User, Appliance } from '@things-factory/auth-base';
2
+ import { Domain } from '@things-factory/shell';
3
+ export declare enum ConnectionStatus {
4
+ CONNECTED = "CONNECTED",
5
+ DISCONNECTED = "DISCONNECTED"
6
+ }
7
+ export declare class Connection {
8
+ /**
9
+ * Unique identifier for the connection, generated in UUID format.
10
+ */
11
+ readonly id: string;
12
+ /**
13
+ * Many-to-One relationship with the Domain entity.
14
+ */
15
+ domain: Domain;
16
+ /**
17
+ * Stores the ID of the associated Domain.
18
+ */
19
+ domainId: string;
20
+ /**
21
+ * The name of the connection.
22
+ */
23
+ name: string;
24
+ /**
25
+ * Optional description for the connection.
26
+ */
27
+ description: string;
28
+ /**
29
+ * The type of the connection.
30
+ */
31
+ type: string;
32
+ /**
33
+ * Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.
34
+ */
35
+ edge: Appliance;
36
+ /**
37
+ * Stores the ID of the Appliance who delegate the connection.
38
+ */
39
+ edgeId: string;
40
+ /**
41
+ * The endpoint for the connection.
42
+ */
43
+ endpoint: string;
44
+ /**
45
+ * Indicates the active status of the connection.
46
+ */
47
+ active: boolean;
48
+ /**
49
+ * The status of the connection, using the ConnectionStatus type.
50
+ */
51
+ state: ConnectionStatus;
52
+ /**
53
+ * Additional parameters for the connection, stored as a JSON string.
54
+ */
55
+ params: string;
56
+ /**
57
+ * The date and time when the connection was created.
58
+ */
59
+ createdAt: Date;
60
+ /**
61
+ * The date and time when the connection was last updated.
62
+ */
63
+ updatedAt: Date;
64
+ /**
65
+ * Many-to-One relationship with the User entity who created the connection. Optional field.
66
+ */
67
+ creator: User;
68
+ /**
69
+ * Stores the ID of the User who created the connection.
70
+ */
71
+ creatorId: string;
72
+ /**
73
+ * Many-to-One relationship with the User entity who last updated the connection.
74
+ * Optional field.
75
+ */
76
+ updater: User;
77
+ /**
78
+ * Stores the ID of the User who last updated the connection.
79
+ *
80
+ */
81
+ updaterId: string;
82
+ /**
83
+ * Asynchronous method to establish the connection.
84
+ *
85
+ */
86
+ connect(): Promise<void>;
87
+ /**
88
+ * @brief Asynchronous method to disconnect the connection.
89
+ *
90
+ */
91
+ disconnect(): Promise<void>;
92
+ }
93
+ /**
94
+ * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
95
+ * 추후, 타입 일치를 통해서 제거할 예정임.
96
+ *
97
+ */
98
+ export interface InputConnection extends Connection {
99
+ params: any;
100
+ }
101
+ export declare class ConnectionState {
102
+ domain?: Domain;
103
+ id?: string;
104
+ name?: string;
105
+ description?: string;
106
+ type?: string;
107
+ edge?: Appliance;
108
+ state?: ConnectionStatus;
109
+ timestamp?: Date;
110
+ }
111
+ export declare class NewConnection {
112
+ name: string;
113
+ description?: string;
114
+ type?: string;
115
+ edge?: Appliance;
116
+ endpoint?: string;
117
+ params?: string;
118
+ }
119
+ export declare class ConnectionPatch {
120
+ id: string;
121
+ name?: string;
122
+ description?: string;
123
+ type?: string;
124
+ edge?: Appliance;
125
+ endpoint?: string;
126
+ active?: boolean;
127
+ params?: string;
128
+ cuFlag?: string;
129
+ }
130
+ export declare class ConnectionList {
131
+ items: Connection[];
132
+ total: number;
133
+ }
@@ -8,11 +8,12 @@ const auth_base_1 = require("@things-factory/auth-base");
8
8
  const env_1 = require("@things-factory/env");
9
9
  const shell_1 = require("@things-factory/shell");
10
10
  const engine_1 = require("../../engine");
11
+ const proxy_connector_1 = require("../../engine/connector/proxy-connector");
11
12
  var ConnectionStatus;
12
13
  (function (ConnectionStatus) {
13
14
  ConnectionStatus["CONNECTED"] = "CONNECTED";
14
15
  ConnectionStatus["DISCONNECTED"] = "DISCONNECTED";
15
- })(ConnectionStatus = exports.ConnectionStatus || (exports.ConnectionStatus = {}));
16
+ })(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {}));
16
17
  (0, type_graphql_1.registerEnumType)(ConnectionStatus, {
17
18
  name: 'ConnectionStatus',
18
19
  description: 'state enumeration of a connection'
@@ -23,7 +24,8 @@ let Connection = class Connection {
23
24
  *
24
25
  */
25
26
  async connect() {
26
- var connector = engine_1.ConnectionManager.getConnector(this.type);
27
+ const { type, edge } = this;
28
+ const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
27
29
  var params = {};
28
30
  try {
29
31
  params = JSON.parse(this.params || '{}');
@@ -39,13 +41,15 @@ let Connection = class Connection {
39
41
  */
40
42
  async disconnect() {
41
43
  try {
42
- var connector = engine_1.ConnectionManager.getConnector(this.type);
44
+ const { type, edge } = this;
45
+ const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
43
46
  await connector.disconnect(this);
44
47
  }
45
48
  finally {
46
49
  }
47
50
  }
48
51
  };
52
+ exports.Connection = Connection;
49
53
  tslib_1.__decorate([
50
54
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
51
55
  (0, type_graphql_1.Field)(type => type_graphql_1.ID),
@@ -53,7 +57,7 @@ tslib_1.__decorate([
53
57
  ], Connection.prototype, "id", void 0);
54
58
  tslib_1.__decorate([
55
59
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
56
- (0, type_graphql_1.Field)({ nullable: true }),
60
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
57
61
  tslib_1.__metadata("design:type", shell_1.Domain
58
62
  /**
59
63
  * Stores the ID of the associated Domain.
@@ -81,15 +85,26 @@ tslib_1.__decorate([
81
85
  (0, type_graphql_1.Field)({ nullable: true }),
82
86
  tslib_1.__metadata("design:type", String)
83
87
  ], Connection.prototype, "type", void 0);
88
+ tslib_1.__decorate([
89
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.Appliance, { nullable: true }),
90
+ (0, type_graphql_1.Field)({ nullable: true }),
91
+ tslib_1.__metadata("design:type", auth_base_1.Appliance
92
+ /**
93
+ * Stores the ID of the Appliance who delegate the connection.
94
+ */
95
+ )
96
+ ], Connection.prototype, "edge", void 0);
97
+ tslib_1.__decorate([
98
+ (0, typeorm_1.RelationId)((connection) => connection.edge),
99
+ tslib_1.__metadata("design:type", String)
100
+ ], Connection.prototype, "edgeId", void 0);
84
101
  tslib_1.__decorate([
85
102
  (0, typeorm_1.Column)(),
86
103
  (0, type_graphql_1.Field)({ nullable: true }),
87
104
  tslib_1.__metadata("design:type", String)
88
105
  ], Connection.prototype, "endpoint", void 0);
89
106
  tslib_1.__decorate([
90
- (0, typeorm_1.Column)({
91
- nullable: true
92
- }),
107
+ (0, typeorm_1.Column)({ nullable: true }),
93
108
  (0, type_graphql_1.Field)({ nullable: true }),
94
109
  tslib_1.__metadata("design:type", Boolean)
95
110
  ], Connection.prototype, "active", void 0);
@@ -98,9 +113,7 @@ tslib_1.__decorate([
98
113
  tslib_1.__metadata("design:type", String)
99
114
  ], Connection.prototype, "state", void 0);
100
115
  tslib_1.__decorate([
101
- (0, typeorm_1.Column)({
102
- nullable: true
103
- }),
116
+ (0, typeorm_1.Column)({ nullable: true }),
104
117
  (0, type_graphql_1.Field)({ nullable: true }),
105
118
  tslib_1.__metadata("design:type", String)
106
119
  ], Connection.prototype, "params", void 0);
@@ -149,16 +162,16 @@ tslib_1.__decorate([
149
162
  (0, typeorm_1.RelationId)((connection) => connection.updater),
150
163
  tslib_1.__metadata("design:type", String)
151
164
  ], Connection.prototype, "updaterId", void 0);
152
- Connection = tslib_1.__decorate([
165
+ exports.Connection = Connection = tslib_1.__decorate([
153
166
  (0, typeorm_1.Entity)(),
154
167
  (0, typeorm_1.Index)('ix_connection_0', (connection) => [connection.domain, connection.name], { unique: true }),
155
168
  (0, type_graphql_1.ObjectType)()
156
169
  ], Connection);
157
- exports.Connection = Connection;
158
170
  let ConnectionState = class ConnectionState {
159
171
  };
172
+ exports.ConnectionState = ConnectionState;
160
173
  tslib_1.__decorate([
161
- (0, type_graphql_1.Field)({ nullable: true }),
174
+ (0, type_graphql_1.Field)(type => shell_1.Domain),
162
175
  tslib_1.__metadata("design:type", shell_1.Domain)
163
176
  ], ConnectionState.prototype, "domain", void 0);
164
177
  tslib_1.__decorate([
@@ -177,6 +190,10 @@ tslib_1.__decorate([
177
190
  (0, type_graphql_1.Field)({ nullable: true }),
178
191
  tslib_1.__metadata("design:type", String)
179
192
  ], ConnectionState.prototype, "type", void 0);
193
+ tslib_1.__decorate([
194
+ (0, type_graphql_1.Field)(type => auth_base_1.Appliance, { nullable: true }),
195
+ tslib_1.__metadata("design:type", auth_base_1.Appliance)
196
+ ], ConnectionState.prototype, "edge", void 0);
180
197
  tslib_1.__decorate([
181
198
  (0, type_graphql_1.Field)({ nullable: true }),
182
199
  tslib_1.__metadata("design:type", String)
@@ -185,12 +202,12 @@ tslib_1.__decorate([
185
202
  (0, type_graphql_1.Field)({ nullable: true }),
186
203
  tslib_1.__metadata("design:type", Date)
187
204
  ], ConnectionState.prototype, "timestamp", void 0);
188
- ConnectionState = tslib_1.__decorate([
205
+ exports.ConnectionState = ConnectionState = tslib_1.__decorate([
189
206
  (0, type_graphql_1.ObjectType)()
190
207
  ], ConnectionState);
191
- exports.ConnectionState = ConnectionState;
192
208
  let NewConnection = class NewConnection {
193
209
  };
210
+ exports.NewConnection = NewConnection;
194
211
  tslib_1.__decorate([
195
212
  (0, type_graphql_1.Field)(),
196
213
  tslib_1.__metadata("design:type", String)
@@ -203,6 +220,10 @@ tslib_1.__decorate([
203
220
  (0, type_graphql_1.Field)({ nullable: true }),
204
221
  tslib_1.__metadata("design:type", String)
205
222
  ], NewConnection.prototype, "type", void 0);
223
+ tslib_1.__decorate([
224
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
225
+ tslib_1.__metadata("design:type", auth_base_1.Appliance)
226
+ ], NewConnection.prototype, "edge", void 0);
206
227
  tslib_1.__decorate([
207
228
  (0, type_graphql_1.Field)({ nullable: true }),
208
229
  tslib_1.__metadata("design:type", String)
@@ -211,12 +232,12 @@ tslib_1.__decorate([
211
232
  (0, type_graphql_1.Field)({ nullable: true }),
212
233
  tslib_1.__metadata("design:type", String)
213
234
  ], NewConnection.prototype, "params", void 0);
214
- NewConnection = tslib_1.__decorate([
235
+ exports.NewConnection = NewConnection = tslib_1.__decorate([
215
236
  (0, type_graphql_1.InputType)()
216
237
  ], NewConnection);
217
- exports.NewConnection = NewConnection;
218
238
  let ConnectionPatch = class ConnectionPatch {
219
239
  };
240
+ exports.ConnectionPatch = ConnectionPatch;
220
241
  tslib_1.__decorate([
221
242
  (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
222
243
  tslib_1.__metadata("design:type", String)
@@ -233,6 +254,10 @@ tslib_1.__decorate([
233
254
  (0, type_graphql_1.Field)({ nullable: true }),
234
255
  tslib_1.__metadata("design:type", String)
235
256
  ], ConnectionPatch.prototype, "type", void 0);
257
+ tslib_1.__decorate([
258
+ (0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
259
+ tslib_1.__metadata("design:type", auth_base_1.Appliance)
260
+ ], ConnectionPatch.prototype, "edge", void 0);
236
261
  tslib_1.__decorate([
237
262
  (0, type_graphql_1.Field)({ nullable: true }),
238
263
  tslib_1.__metadata("design:type", String)
@@ -249,12 +274,12 @@ tslib_1.__decorate([
249
274
  (0, type_graphql_1.Field)({ nullable: true }),
250
275
  tslib_1.__metadata("design:type", String)
251
276
  ], ConnectionPatch.prototype, "cuFlag", void 0);
252
- ConnectionPatch = tslib_1.__decorate([
277
+ exports.ConnectionPatch = ConnectionPatch = tslib_1.__decorate([
253
278
  (0, type_graphql_1.InputType)()
254
279
  ], ConnectionPatch);
255
- exports.ConnectionPatch = ConnectionPatch;
256
280
  let ConnectionList = class ConnectionList {
257
281
  };
282
+ exports.ConnectionList = ConnectionList;
258
283
  tslib_1.__decorate([
259
284
  (0, type_graphql_1.Field)(type => [Connection]),
260
285
  tslib_1.__metadata("design:type", Array)
@@ -263,8 +288,7 @@ tslib_1.__decorate([
263
288
  (0, type_graphql_1.Field)(type => type_graphql_1.Int),
264
289
  tslib_1.__metadata("design:type", Number)
265
290
  ], ConnectionList.prototype, "total", void 0);
266
- ConnectionList = tslib_1.__decorate([
291
+ exports.ConnectionList = ConnectionList = tslib_1.__decorate([
267
292
  (0, type_graphql_1.ObjectType)()
268
293
  ], ConnectionList);
269
- exports.ConnectionList = ConnectionList;
270
294
  //# sourceMappingURL=connection-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,qCASgB;AAEhB,yDAAgD;AAChD,6CAA4C;AAC5C,iDAA8C;AAE9C,yCAAgD;AAEhD,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA;AAC/B,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mCAAmC;CACjD,CAAC,CAAA;AAKK,IAAM,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ALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;;6CACT;AAEnB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { logger } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED',\n DISCONNECTED = 'DISCONNECTED'\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'state enumeration of a connection'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType()\nexport class Connection {\n /** \n * Unique identifier for the connection, generated in UUID format.\n */\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n /** \n * Many-to-One relationship with the Domain entity.\n */\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain: Domain\n\n /** \n * Stores the ID of the associated Domain.\n */\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n /** \n * The name of the connection.\n */\n @Column()\n @Field()\n name: string\n\n /** \n * Optional description for the connection.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n /** \n * The type of the connection.\n */\n @Column()\n @Field({ nullable: true })\n type: string\n\n /** \n * The endpoint for the connection.\n */\n @Column()\n @Field({ nullable: true })\n endpoint: string\n\n /** \n * Indicates the active status of the connection.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n active: boolean\n\n /** \n * The status of the connection, using the ConnectionStatus type.\n */\n @Field({ nullable: true })\n state: ConnectionStatus\n\n /** \n * Additional parameters for the connection, stored as a JSON string.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n params: string\n\n /** \n * The date and time when the connection was created.\n */\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n /** \n * The date and time when the connection was last updated.\n */\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /** \n * Many-to-One relationship with the User entity who created the connection. Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n /** \n * Stores the ID of the User who created the connection.\n */\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n /** \n * Many-to-One relationship with the User entity who last updated the connection.\n * Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n /**\n * Stores the ID of the User who last updated the connection.\n * \n */\n @RelationId((connection: Connection) => connection.updater)\n updaterId: string\n\n /**\n * Asynchronous method to establish the connection.\n * \n */\n async connect() {\n var connector = ConnectionManager.getConnector(this.type)\n var params = {}\n\n try {\n params = JSON.parse(this.params || '{}')\n } catch (ex) {\n logger.error(`connection '${this.name}' params should be JSON format`, ex)\n }\n\n await connector.connect({\n ...this,\n params\n })\n }\n\n /**\n * @brief Asynchronous method to disconnect the connection.\n * \n */\n async disconnect() {\n try {\n var connector = ConnectionManager.getConnector(this.type)\n await connector.disconnect(this)\n } finally {\n }\n }\n}\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n * \n */\nexport interface InputConnection extends Connection {\n params: any;\n}\n\n@ObjectType()\nexport class ConnectionState {\n @Field({ nullable: true })\n domain?: Domain\n\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n state?: ConnectionStatus\n\n @Field({ nullable: true })\n timestamp?: Date\n}\n\n@InputType()\nexport class NewConnection {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true })\n id: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ConnectionList {\n @Field(type => [Connection])\n items: Connection[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,qCASgB;AAEhB,yDAA2D;AAC3D,6CAA4C;AAC5C,iDAAyD;AAEzD,yCAAgD;AAChD,4EAAuE;AAEvE,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA;AAC/B,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mCAAmC;CACjD,CAAC,CAAA;AAKK,IAAM,UAAU,GAAhB,MAAM,UAAU;IA8HrB;;;OAGG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,gCAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,0BAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;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EAAE,IAAI,EAAE,CAAC;;6CACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACb;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACtC,qBAAS;6CAAA;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;0BA1BJ,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CA2B3B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;;6CACT;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;yBALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User, Appliance } from '@things-factory/auth-base'\nimport { logger } from '@things-factory/env'\nimport { Domain, ObjectRef } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\nimport { ProxyConnector } from '../../engine/connector/proxy-connector'\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED',\n DISCONNECTED = 'DISCONNECTED'\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'state enumeration of a connection'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType()\nexport class Connection {\n /**\n * Unique identifier for the connection, generated in UUID format.\n */\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n /**\n * Many-to-One relationship with the Domain entity.\n */\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true })\n domain: Domain\n\n /**\n * Stores the ID of the associated Domain.\n */\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n /**\n * The name of the connection.\n */\n @Column()\n @Field()\n name: string\n\n /**\n * Optional description for the connection.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n /**\n * The type of the connection.\n */\n @Column()\n @Field({ nullable: true })\n type: string\n\n /**\n * Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.\n */\n @ManyToOne(type => Appliance, { nullable: true })\n @Field({ nullable: true })\n edge: Appliance\n\n /**\n * Stores the ID of the Appliance who delegate the connection.\n */\n @RelationId((connection: Connection) => connection.edge)\n edgeId: string\n\n /**\n * The endpoint for the connection.\n */\n @Column()\n @Field({ nullable: true })\n endpoint: string\n\n /**\n * Indicates the active status of the connection.\n */\n @Column({ nullable: true })\n @Field({ nullable: true })\n active: boolean\n\n /**\n * The status of the connection, using the ConnectionStatus type.\n */\n @Field({ nullable: true })\n state: ConnectionStatus\n\n /**\n * Additional parameters for the connection, stored as a JSON string.\n */\n @Column({ nullable: true })\n @Field({ nullable: true })\n params: string\n\n /**\n * The date and time when the connection was created.\n */\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n /**\n * The date and time when the connection was last updated.\n */\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /**\n * Many-to-One relationship with the User entity who created the connection. Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n /**\n * Stores the ID of the User who created the connection.\n */\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n /**\n * Many-to-One relationship with the User entity who last updated the connection.\n * Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n /**\n * Stores the ID of the User who last updated the connection.\n *\n */\n @RelationId((connection: Connection) => connection.updater)\n updaterId: string\n\n /**\n * Asynchronous method to establish the connection.\n *\n */\n async connect() {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n var params = {}\n\n try {\n params = JSON.parse(this.params || '{}')\n } catch (ex) {\n logger.error(`connection '${this.name}' params should be JSON format`, ex)\n }\n\n await connector.connect({\n ...this,\n params\n })\n }\n\n /**\n * @brief Asynchronous method to disconnect the connection.\n *\n */\n async disconnect() {\n try {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n await connector.disconnect(this)\n } finally {\n }\n }\n}\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: any\n}\n\n@ObjectType()\nexport class ConnectionState {\n @Field(type => Domain)\n domain?: Domain\n\n @Field({ nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field(type => Appliance, { nullable: true })\n edge?: Appliance\n\n @Field({ nullable: true })\n state?: ConnectionStatus\n\n @Field({ nullable: true })\n timestamp?: Date\n}\n\n@InputType()\nexport class NewConnection {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true })\n edge?: Appliance\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true })\n id: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true })\n edge?: Appliance\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ConnectionList {\n @Field(type => [Connection])\n items: Connection[]\n\n @Field(type => Int)\n total: number\n}\n"]}