@things-factory/integration-base 6.2.177 → 6.3.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 (253) 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 +3 -4
  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 +24 -0
  9. package/dist-server/engine/connection-manager.js.map +1 -1
  10. package/dist-server/engine/connector/echo-back-connector.d.ts +9 -0
  11. package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
  12. package/dist-server/engine/connector/echo-back-server.d.ts +8 -0
  13. package/dist-server/engine/connector/echo-back-server.js.map +1 -1
  14. package/dist-server/engine/connector/graphql-connector.d.ts +19 -0
  15. package/dist-server/engine/connector/graphql-connector.js +1 -1
  16. package/dist-server/engine/connector/graphql-connector.js.map +1 -1
  17. package/dist-server/engine/connector/http-connector.d.ts +25 -0
  18. package/dist-server/engine/connector/http-connector.js.map +1 -1
  19. package/dist-server/engine/connector/index.d.ts +12 -0
  20. package/dist-server/engine/connector/mqtt-connector.d.ts +14 -0
  21. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  22. package/dist-server/engine/connector/mssql-connector.d.ts +30 -0
  23. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  24. package/dist-server/engine/connector/mysql-connector.d.ts +13 -0
  25. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  26. package/dist-server/engine/connector/operato-connector.d.ts +27 -0
  27. package/dist-server/engine/connector/operato-connector.js +1 -1
  28. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  29. package/dist-server/engine/connector/oracle-connector.d.ts +29 -0
  30. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  31. package/dist-server/engine/connector/postgresql-connector.d.ts +14 -0
  32. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  33. package/dist-server/engine/connector/socket-server.d.ts +9 -0
  34. package/dist-server/engine/connector/socket-server.js.map +1 -1
  35. package/dist-server/engine/connector/sqlite-connector.d.ts +10 -0
  36. package/dist-server/engine/connector/sqlite-connector.js.map +1 -1
  37. package/dist-server/engine/index.d.ts +7 -0
  38. package/dist-server/engine/index.js.map +1 -1
  39. package/dist-server/engine/pending-queue.d.ts +24 -0
  40. package/dist-server/engine/pending-queue.js.map +1 -1
  41. package/dist-server/engine/scenario-engine.d.ts +11 -0
  42. package/dist-server/engine/scenario-engine.js.map +1 -1
  43. package/dist-server/engine/task/book-up-scenario.d.ts +1 -0
  44. package/dist-server/engine/task/csv-readline.d.ts +1 -0
  45. package/dist-server/engine/task/csv-readline.js.map +1 -1
  46. package/dist-server/engine/task/data-accessor.d.ts +1 -0
  47. package/dist-server/engine/task/data-mapper.d.ts +1 -0
  48. package/dist-server/engine/task/data-mapper.js.map +1 -1
  49. package/dist-server/engine/task/database-query.d.ts +1 -0
  50. package/dist-server/engine/task/echo-receive.d.ts +1 -0
  51. package/dist-server/engine/task/echo-send.d.ts +1 -0
  52. package/dist-server/engine/task/echo-send.js.map +1 -1
  53. package/dist-server/engine/task/empty-check.d.ts +1 -0
  54. package/dist-server/engine/task/empty-check.js.map +1 -1
  55. package/dist-server/engine/task/end.d.ts +1 -0
  56. package/dist-server/engine/task/floating-point.d.ts +1 -0
  57. package/dist-server/engine/task/floating-point.js.map +1 -1
  58. package/dist-server/engine/task/goto.d.ts +1 -0
  59. package/dist-server/engine/task/graphql-mutate.d.ts +1 -0
  60. package/dist-server/engine/task/graphql-query.d.ts +1 -0
  61. package/dist-server/engine/task/headless-post.d.ts +1 -0
  62. package/dist-server/engine/task/headless-post.js.map +1 -1
  63. package/dist-server/engine/task/headless-scrap.d.ts +1 -0
  64. package/dist-server/engine/task/headless-scrap.js.map +1 -1
  65. package/dist-server/engine/task/http-get.d.ts +1 -0
  66. package/dist-server/engine/task/http-get.js.map +1 -1
  67. package/dist-server/engine/task/http-post.d.ts +1 -0
  68. package/dist-server/engine/task/http-post.js.map +1 -1
  69. package/dist-server/engine/task/index.d.ts +43 -0
  70. package/dist-server/engine/task/jsonata.d.ts +1 -0
  71. package/dist-server/engine/task/local-graphql-mutate.d.ts +1 -0
  72. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  73. package/dist-server/engine/task/local-graphql-query.d.ts +1 -0
  74. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  75. package/dist-server/engine/task/log.d.ts +1 -0
  76. package/dist-server/engine/task/log.js.map +1 -1
  77. package/dist-server/engine/task/mqtt-publish.d.ts +1 -0
  78. package/dist-server/engine/task/mqtt-publish.js.map +1 -1
  79. package/dist-server/engine/task/mqtt-subscribe.d.ts +1 -0
  80. package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
  81. package/dist-server/engine/task/oracle-procedure.d.ts +1 -0
  82. package/dist-server/engine/task/oracle-procedure.js.map +1 -1
  83. package/dist-server/engine/task/pick-pending-scenario.d.ts +1 -0
  84. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  85. package/dist-server/engine/task/publish.d.ts +1 -0
  86. package/dist-server/engine/task/publish.js.map +1 -1
  87. package/dist-server/engine/task/random.d.ts +1 -0
  88. package/dist-server/engine/task/reset-pending-queue.d.ts +1 -0
  89. package/dist-server/engine/task/script.d.ts +1 -0
  90. package/dist-server/engine/task/set-domain.d.ts +1 -0
  91. package/dist-server/engine/task/set-domain.js.map +1 -1
  92. package/dist-server/engine/task/sleep.d.ts +1 -0
  93. package/dist-server/engine/task/sleep.js.map +1 -1
  94. package/dist-server/engine/task/socket-listener.d.ts +1 -0
  95. package/dist-server/engine/task/socket-listener.js.map +1 -1
  96. package/dist-server/engine/task/state-read.d.ts +1 -0
  97. package/dist-server/engine/task/state-read.js.map +1 -1
  98. package/dist-server/engine/task/state-write.d.ts +1 -0
  99. package/dist-server/engine/task/state-write.js.map +1 -1
  100. package/dist-server/engine/task/stop-scenario.d.ts +1 -0
  101. package/dist-server/engine/task/sub-scenario.d.ts +1 -0
  102. package/dist-server/engine/task/switch-goto.d.ts +1 -0
  103. package/dist-server/engine/task/switch-range-goto.d.ts +1 -0
  104. package/dist-server/engine/task/switch-range-goto.js.map +1 -1
  105. package/dist-server/engine/task/switch-range-scenario.d.ts +1 -0
  106. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  107. package/dist-server/engine/task/switch-range-set.d.ts +1 -0
  108. package/dist-server/engine/task/switch-range-set.js.map +1 -1
  109. package/dist-server/engine/task/switch-scenario.d.ts +1 -0
  110. package/dist-server/engine/task/switch-set.d.ts +1 -0
  111. package/dist-server/engine/task/throw.d.ts +1 -0
  112. package/dist-server/engine/task/utils/headless-pool-for-scenario.d.ts +1 -0
  113. package/dist-server/engine/task/utils/headless-pool-for-scenario.js +1 -2
  114. package/dist-server/engine/task/utils/headless-pool-for-scenario.js.map +1 -1
  115. package/dist-server/engine/task/utils/substitute.d.ts +1 -0
  116. package/dist-server/engine/task/utils/substitute.js +1 -2
  117. package/dist-server/engine/task/utils/substitute.js.map +1 -1
  118. package/dist-server/engine/task/variables.d.ts +1 -0
  119. package/dist-server/engine/task-registry.d.ts +12 -0
  120. package/dist-server/engine/types.d.ts +94 -0
  121. package/dist-server/index.d.ts +6 -0
  122. package/dist-server/index.js.map +1 -1
  123. package/dist-server/migrations/index.d.ts +1 -0
  124. package/dist-server/restful/index.d.ts +1 -0
  125. package/dist-server/restful/unstable/index.d.ts +7 -0
  126. package/dist-server/restful/unstable/run-scenario.d.ts +1 -0
  127. package/dist-server/restful/unstable/run-scenario.js.map +1 -1
  128. package/dist-server/restful/unstable/scenario-instance.d.ts +1 -0
  129. package/dist-server/restful/unstable/scenario-instances.d.ts +1 -0
  130. package/dist-server/restful/unstable/scenario.d.ts +1 -0
  131. package/dist-server/restful/unstable/scenarios.d.ts +1 -0
  132. package/dist-server/restful/unstable/start-scenario.d.ts +1 -0
  133. package/dist-server/restful/unstable/stop-scenario.d.ts +1 -0
  134. package/dist-server/routers/scenario-schedule-callback-router.d.ts +1 -0
  135. package/dist-server/routers/scenario-schedule-callback-router.js +1 -2
  136. package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
  137. package/dist-server/routers/scenario-view-router.d.ts +1 -0
  138. package/dist-server/routers/scenario-view-router.js.map +1 -1
  139. package/dist-server/routes.d.ts +1 -0
  140. package/dist-server/routes.js.map +1 -1
  141. package/dist-server/service/analysis/analysis-query.d.ts +3 -0
  142. package/dist-server/service/analysis/analysis-query.js +2 -2
  143. package/dist-server/service/analysis/analysis-query.js.map +1 -1
  144. package/dist-server/service/analysis/index.d.ts +2 -0
  145. package/dist-server/service/connection/connection-mutation.d.ts +28 -0
  146. package/dist-server/service/connection/connection-mutation.js +2 -2
  147. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  148. package/dist-server/service/connection/connection-query.d.ts +11 -0
  149. package/dist-server/service/connection/connection-query.js +2 -2
  150. package/dist-server/service/connection/connection-query.js.map +1 -1
  151. package/dist-server/service/connection/connection-subscription.d.ts +10 -0
  152. package/dist-server/service/connection/connection-subscription.js +2 -2
  153. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  154. package/dist-server/service/connection/connection-type.d.ts +122 -0
  155. package/dist-server/service/connection/connection-type.js +11 -11
  156. package/dist-server/service/connection/connection-type.js.map +1 -1
  157. package/dist-server/service/connection/index.d.ts +6 -0
  158. package/dist-server/service/connector/connector-query.d.ts +6 -0
  159. package/dist-server/service/connector/connector-query.js +2 -2
  160. package/dist-server/service/connector/connector-query.js.map +1 -1
  161. package/dist-server/service/connector/connector-type.d.ts +12 -0
  162. package/dist-server/service/connector/connector-type.js +4 -4
  163. package/dist-server/service/connector/connector-type.js.map +1 -1
  164. package/dist-server/service/connector/index.d.ts +3 -0
  165. package/dist-server/service/index.d.ts +17 -0
  166. package/dist-server/service/payload-log/index.d.ts +5 -0
  167. package/dist-server/service/payload-log/payload-log-mutation.d.ts +10 -0
  168. package/dist-server/service/payload-log/payload-log-mutation.js +4 -4
  169. package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
  170. package/dist-server/service/payload-log/payload-log-query.d.ts +11 -0
  171. package/dist-server/service/payload-log/payload-log-query.js +2 -2
  172. package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
  173. package/dist-server/service/payload-log/payload-log-type.d.ts +15 -0
  174. package/dist-server/service/payload-log/payload-log-type.js +6 -6
  175. package/dist-server/service/payload-log/payload-log-type.js.map +1 -1
  176. package/dist-server/service/payload-log/payload-log.d.ts +23 -0
  177. package/dist-server/service/payload-log/payload-log.js +3 -3
  178. package/dist-server/service/payload-log/payload-log.js.map +1 -1
  179. package/dist-server/service/property-spec.d.ts +9 -0
  180. package/dist-server/service/property-spec.js +2 -2
  181. package/dist-server/service/property-spec.js.map +1 -1
  182. package/dist-server/service/scenario/index.d.ts +5 -0
  183. package/dist-server/service/scenario/scenario-mutation.d.ts +13 -0
  184. package/dist-server/service/scenario/scenario-mutation.js +3 -3
  185. package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
  186. package/dist-server/service/scenario/scenario-query.d.ts +18 -0
  187. package/dist-server/service/scenario/scenario-query.js +2 -2
  188. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  189. package/dist-server/service/scenario/scenario-type.d.ts +28 -0
  190. package/dist-server/service/scenario/scenario-type.js +6 -6
  191. package/dist-server/service/scenario/scenario-type.js.map +1 -1
  192. package/dist-server/service/scenario/scenario.d.ts +35 -0
  193. package/dist-server/service/scenario/scenario.js +2 -2
  194. package/dist-server/service/scenario/scenario.js.map +1 -1
  195. package/dist-server/service/scenario-flow/scenario-flow.d.ts +6 -0
  196. package/dist-server/service/scenario-flow/scenario-flow.js +2 -2
  197. package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
  198. package/dist-server/service/scenario-instance/index.d.ts +5 -0
  199. package/dist-server/service/scenario-instance/scenario-instance-mutation.d.ts +6 -0
  200. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +2 -2
  201. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  202. package/dist-server/service/scenario-instance/scenario-instance-query.d.ts +12 -0
  203. package/dist-server/service/scenario-instance/scenario-instance-query.js +2 -2
  204. package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
  205. package/dist-server/service/scenario-instance/scenario-instance-subscription.d.ts +10 -0
  206. package/dist-server/service/scenario-instance/scenario-instance-subscription.js +2 -2
  207. package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
  208. package/dist-server/service/scenario-instance/scenario-instance-type.d.ts +78 -0
  209. package/dist-server/service/scenario-instance/scenario-instance-type.js +9 -9
  210. package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
  211. package/dist-server/service/scenario-queue/index.d.ts +3 -0
  212. package/dist-server/service/scenario-queue/scenario-queue-subscription.d.ts +6 -0
  213. package/dist-server/service/scenario-queue/scenario-queue-subscription.js +2 -2
  214. package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
  215. package/dist-server/service/scenario-queue/scenario-queue-type.d.ts +11 -0
  216. package/dist-server/service/scenario-queue/scenario-queue-type.js +4 -4
  217. package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
  218. package/dist-server/service/state-register/index.d.ts +6 -0
  219. package/dist-server/service/state-register/state-register-mutation.d.ts +11 -0
  220. package/dist-server/service/state-register/state-register-mutation.js +2 -2
  221. package/dist-server/service/state-register/state-register-mutation.js.map +1 -1
  222. package/dist-server/service/state-register/state-register-query.d.ts +14 -0
  223. package/dist-server/service/state-register/state-register-query.js +2 -2
  224. package/dist-server/service/state-register/state-register-query.js.map +1 -1
  225. package/dist-server/service/state-register/state-register-type.d.ts +23 -0
  226. package/dist-server/service/state-register/state-register-type.js +6 -6
  227. package/dist-server/service/state-register/state-register-type.js.map +1 -1
  228. package/dist-server/service/state-register/state-register.d.ts +22 -0
  229. package/dist-server/service/state-register/state-register.js +2 -2
  230. package/dist-server/service/state-register/state-register.js.map +1 -1
  231. package/dist-server/service/step/index.d.ts +5 -0
  232. package/dist-server/service/step/step-mutation.d.ts +5 -0
  233. package/dist-server/service/step/step-mutation.js +2 -2
  234. package/dist-server/service/step/step-mutation.js.map +1 -1
  235. package/dist-server/service/step/step-query.d.ts +12 -0
  236. package/dist-server/service/step/step-query.js +2 -2
  237. package/dist-server/service/step/step-query.js.map +1 -1
  238. package/dist-server/service/step/step-type.d.ts +111 -0
  239. package/dist-server/service/step/step-type.js +6 -6
  240. package/dist-server/service/step/step-type.js.map +1 -1
  241. package/dist-server/service/task-type/index.d.ts +3 -0
  242. package/dist-server/service/task-type/task-type-query.d.ts +6 -0
  243. package/dist-server/service/task-type/task-type-query.js +2 -2
  244. package/dist-server/service/task-type/task-type-query.js.map +1 -1
  245. package/dist-server/service/task-type/task-type-type.d.ts +12 -0
  246. package/dist-server/service/task-type/task-type-type.js +4 -4
  247. package/dist-server/service/task-type/task-type-type.js.map +1 -1
  248. package/dist-server/tsconfig.tsbuildinfo +1 -1
  249. package/package.json +9 -9
  250. package/server/engine/connection-manager.ts +1 -1
  251. package/server/engine/index.ts +1 -1
  252. package/server/routers/scenario-schedule-callback-router.ts +2 -2
  253. package/server/service/scenario-instance/scenario-instance-type.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"headless-pool-for-scenario.js","sourceRoot":"","sources":["../../../../server/engine/task/utils/headless-pool-for-scenario.ts"],"names":[],"mappings":";;;;AAAA,kEAA2C;AAE3C,6CAAoD;AAEpD,IAAI;IACF,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CACrC;AAAC,OAAO,GAAG,EAAE;IACZ,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;CAClB;AAED,IAAI,YAAY,CAAA;AAEhB,SAAgB,eAAe;IAC7B,IAAI,CAAC,Y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A;KACf;IAAC,OAAO,GAAG,EAAE;QACZ,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KAClB;AACH,CAAC","sourcesContent":["import * as genericPool from 'generic-pool'\n\nimport { config, logger } from '@things-factory/env'\n\ntry {\n var puppeteer = require('puppeteer')\n} catch (err) {\n logger.error(err)\n}\n\nvar headlessPool\n\nexport function getHeadlessPool() {\n if (!headlessPool) {\n headlessPool = genericPool.createPool(\n {\n create() {\n console.log('headless-pool-for-scensrio about to create')\n return initializeChromium()\n },\n validate(browser) {\n return Promise.race([\n new Promise(res => setTimeout(() => res(false), 1500)),\n browser\n //@ts-ignore\n .version()\n .then(_ => true)\n .catch(_ => false)\n ])\n },\n destroy(browser) {\n //@ts-ignore\n return browser.close()\n }\n },\n {\n min: 2,\n max: 10,\n testOnBorrow: true,\n acquireTimeoutMillis: 15000\n }\n )\n }\n\n return headlessPool\n}\n\nconst CHROMIUM_PATH = config.get('CHROMIUM_PATH')\n\nasync function initializeChromium() {\n try {\n if (!puppeteer) {\n return\n }\n\n var launchSetting = {\n args: ['--mute-audio', '--no-sandbox'],\n headless: 'new'\n }\n\n if (CHROMIUM_PATH) {\n launchSetting['executablePath'] = CHROMIUM_PATH\n }\n\n const browser = await puppeteer.launch(launchSetting)\n\n return browser\n } catch (err) {\n logger.error(err)\n }\n}\n"]}
1
+ {"version":3,"file":"headless-pool-for-scenario.js","sourceRoot":"","sources":["../../../../server/engine/task/utils/headless-pool-for-scenario.ts"],"names":[],"mappings":";;AAYA,0CAiCC;;AA7CD,kEAA2C;AAE3C,6CAAoD;AAEpD,IAAI,CAAC;IACH,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AACtC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACnB,CAAC;AAED,IAAI,YAAY,CAAA;AAEhB,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;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OAAO,CAAA;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;AACH,CAAC","sourcesContent":["import * as genericPool from 'generic-pool'\n\nimport { config, logger } from '@things-factory/env'\n\ntry {\n var puppeteer = require('puppeteer')\n} catch (err) {\n logger.error(err)\n}\n\nvar headlessPool\n\nexport function getHeadlessPool() {\n if (!headlessPool) {\n headlessPool = genericPool.createPool(\n {\n create() {\n console.log('headless-pool-for-scensrio about to create')\n return initializeChromium()\n },\n validate(browser) {\n return Promise.race([\n new Promise(res => setTimeout(() => res(false), 1500)),\n browser\n //@ts-ignore\n .version()\n .then(_ => true)\n .catch(_ => false)\n ])\n },\n destroy(browser) {\n //@ts-ignore\n return browser.close()\n }\n },\n {\n min: 2,\n max: 10,\n testOnBorrow: true,\n acquireTimeoutMillis: 15000\n }\n )\n }\n\n return headlessPool\n}\n\nconst CHROMIUM_PATH = config.get('CHROMIUM_PATH')\n\nasync function initializeChromium() {\n try {\n if (!puppeteer) {\n return\n }\n\n var launchSetting = {\n args: ['--mute-audio', '--no-sandbox'],\n headless: 'new'\n }\n\n if (CHROMIUM_PATH) {\n launchSetting['executablePath'] = CHROMIUM_PATH\n }\n\n const browser = await puppeteer.launch(launchSetting)\n\n return browser\n } catch (err) {\n logger.error(err)\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function substitute(value: any, data: any): any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.substitute = void 0;
3
+ exports.substitute = substitute;
4
4
  const SELF = function (o) {
5
5
  return o;
6
6
  };
@@ -42,5 +42,4 @@ function substitute(value, data) {
42
42
  }
43
43
  return value;
44
44
  }
45
- exports.substitute = substitute;
46
45
  //# sourceMappingURL=substitute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"substitute.js","sourceRoot":"","sources":["../../../../server/engine/task/utils/substitute.ts"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OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;YAC5E,CAAC;YACH,CAAC,CAAC,IAAI;KACX,CAAA;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,KAAK,EAAE,IAAI;IACpC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACxB,IAAI,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAC5C,IAAI,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC9D,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;KACxC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AARD,gCAQC","sourcesContent":["const SELF = function (o) {\n return o\n}\n\nfunction parse(text) {\n var defaultIndex = text.indexOf('||')\n var originText = ''\n var defaultValue = ''\n if (defaultIndex != -1) {\n originText = text\n defaultValue = text.substring(defaultIndex + 2, text.length - 1).trim()\n text = text.replace(text.substring(defaultIndex, text.length - 1), '').trim()\n }\n var parsed = text\n .substr(2, text.length - 3)\n .trim()\n .replace(/\\[(\\w+)\\]/g, '.$1')\n .replace(/^\\./, '')\n .split('.')\n .filter(accessor => !!accessor.trim())\n var accessors = parsed.slice(1)\n return {\n defaultValue: defaultValue,\n match: text,\n originText: originText || text,\n target: parsed[0],\n accessor:\n accessors.length > 0\n ? function (o) {\n return accessors.reduce((o, accessor) => (o ? o[accessor] : undefined), o)\n }\n : SELF\n }\n}\n\nexport function substitute(value, data) {\n var text = String(value)\n var substituteVal = text.match(/#{[^}]*}/gi)\n var prop = substituteVal ? parse(substituteVal[0]) : undefined\n if (prop && data.hasOwnProperty(prop.target)) {\n return prop.accessor(data[prop.target])\n }\n return value\n}\n"]}
1
+ {"version":3,"file":"substitute.js","sourceRoot":"","sources":["../../../../server/engine/task/utils/substitute.ts"],"names":[],"mappings":";;AAmCA,gCAQC;AA3CD,MAAM,IAAI,GAAG,UAAU,CAAC;IACtB,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,SAAS,KAAK,CAAC,IAAI;IACjB,IAAI,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC;QACvB,UAAU,GAAG,IAAI,CAAA;QACjB,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACvE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/E,CAAC;IACD,IAAI,MAAM,GAAG,IAAI;SACd,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;SAC5B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IACxC,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/B,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,UAAU,IAAI,IAAI;QAC9B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACjB,QAAQ,EACN,SAAS,CAAC,MAAM,GAAG,CAAC;YAClB,CAAC,CAAC,UAAU,CAAC;gBACT,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;YAC5E,CAAC;YACH,CAAC,CAAC,IAAI;KACX,CAAA;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,KAAK,EAAE,IAAI;IACpC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACxB,IAAI,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAC5C,IAAI,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC9D,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACzC,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["const SELF = function (o) {\n return o\n}\n\nfunction parse(text) {\n var defaultIndex = text.indexOf('||')\n var originText = ''\n var defaultValue = ''\n if (defaultIndex != -1) {\n originText = text\n defaultValue = text.substring(defaultIndex + 2, text.length - 1).trim()\n text = text.replace(text.substring(defaultIndex, text.length - 1), '').trim()\n }\n var parsed = text\n .substr(2, text.length - 3)\n .trim()\n .replace(/\\[(\\w+)\\]/g, '.$1')\n .replace(/^\\./, '')\n .split('.')\n .filter(accessor => !!accessor.trim())\n var accessors = parsed.slice(1)\n return {\n defaultValue: defaultValue,\n match: text,\n originText: originText || text,\n target: parsed[0],\n accessor:\n accessors.length > 0\n ? function (o) {\n return accessors.reduce((o, accessor) => (o ? o[accessor] : undefined), o)\n }\n : SELF\n }\n}\n\nexport function substitute(value, data) {\n var text = String(value)\n var substituteVal = text.match(/#{[^}]*}/gi)\n var prop = substituteVal ? parse(substituteVal[0]) : undefined\n if (prop && data.hasOwnProperty(prop.target)) {\n return prop.accessor(data[prop.target])\n }\n return value\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { TaskHandler } from './types';
2
+ export declare class TaskRegistry {
3
+ static handlers: {
4
+ [type: string]: TaskHandler;
5
+ };
6
+ static getTaskHandler(type: string): TaskHandler;
7
+ static registerTaskHandler(type: string, handler: TaskHandler): void;
8
+ static unregisterTaskHandler(type: string): void;
9
+ static getTaskHandlers(): {
10
+ [propName: string]: TaskHandler;
11
+ };
12
+ }
@@ -0,0 +1,94 @@
1
+ import { Connection, PropertySpec, ScenarioInstanceStatus, Step } from '../service';
2
+ import { Domain } from '@things-factory/shell';
3
+ import { User } from '@things-factory/auth-base';
4
+ export interface Connector {
5
+ ready(connections: Connection[]): Promise<any>;
6
+ connect(connection: Connection): Promise<any>;
7
+ disconnect(connection: Connection): Promise<any>;
8
+ parameterSpec: PropertySpec[];
9
+ taskPrefixes?: string[];
10
+ description?: string;
11
+ help?: string;
12
+ }
13
+ export type Context = {
14
+ /**
15
+ * Represents the domain context.
16
+ */
17
+ domain: Domain;
18
+ /**
19
+ * User information.
20
+ */
21
+ user: User;
22
+ /**
23
+ * Language code, for example 'en', 'ko'.
24
+ */
25
+ lng: string;
26
+ /**
27
+ * Flag to indicate if the IP is unsafe, can be undefined.
28
+ */
29
+ unsafeIP: boolean | undefined;
30
+ /**
31
+ * List of prohibited privileges, can be undefined.
32
+ */
33
+ prohibitedPrivileges: {
34
+ category: string;
35
+ privilege: string;
36
+ }[] | undefined;
37
+ /**
38
+ * Logger for logging purposes.
39
+ */
40
+ logger: any;
41
+ /**
42
+ * Function to publish events or messages.
43
+ */
44
+ publish: Function;
45
+ /**
46
+ * Function to load resources or data.
47
+ */
48
+ load: Function;
49
+ /**
50
+ * Current status of the scenario instance.
51
+ */
52
+ state: ScenarioInstanceStatus;
53
+ /**
54
+ * General data storage object.
55
+ */
56
+ data: any;
57
+ /**
58
+ * Variables related to the context.
59
+ */
60
+ variables: Object;
61
+ /**
62
+ * Local GraphQL client object.
63
+ */
64
+ client: any;
65
+ /**
66
+ * Root object, can be used for various purposes.
67
+ */
68
+ root: Object;
69
+ /**
70
+ * Array of function closures.
71
+ */
72
+ closures: Function[];
73
+ /**
74
+ * Function to check the state.
75
+ */
76
+ checkState: Function;
77
+ /**
78
+ * MQTT subscriber context object.
79
+ */
80
+ __mqtt_subscriber?: any;
81
+ /**
82
+ * socket listener context object.
83
+ */
84
+ __socket_listener?: any;
85
+ /**
86
+ * csv readline context object.
87
+ */
88
+ __csv_resources?: any;
89
+ };
90
+ export type TaskHandler = (step: Step, context: Context) => Promise<{
91
+ next?: string;
92
+ state?: ScenarioInstanceStatus;
93
+ data?: any;
94
+ }>;
@@ -0,0 +1,6 @@
1
+ export * from './migrations';
2
+ export * from './engine';
3
+ export * from './controllers';
4
+ export * from './service';
5
+ import './routes';
6
+ import './restful';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,mDAAwB;AACxB,wDAA6B;AAC7B,oDAAyB;AAEzB,oBAAiB;AACjB,qBAAkB,CAAC,UAAU;AAE7B,qCAA4D;AAE5D,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI;QACF,MAAM,0BAAiB,CAAC,KAAK,EAAE,CAAA;QAC/B,MAAM,uBAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;KACjD;IAAC,OAAO,EAAE,EAAE;QACX,0BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;KACzD;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './migrations'\nexport * from './engine'\nexport * from './controllers'\nexport * from './service'\n\nimport './routes'\nimport './restful' /* APIs */\n\nimport { ConnectionManager, ScenarioEngine } from './engine'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await ConnectionManager.ready()\n await ScenarioEngine.loadAll()\n\n console.log('Scenario Engine has just started.')\n } catch (ex) {\n ConnectionManager.logger.error(ex)\n console.log('Just has failed to start Scenario Engine.')\n }\n})\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,mDAAwB;AACxB,wDAA6B;AAC7B,oDAAyB;AAEzB,oBAAiB;AACjB,qBAAkB,CAAC,UAAU;AAE7B,qCAA4D;AAE5D,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,0BAAiB,CAAC,KAAK,EAAE,CAAA;QAC/B,MAAM,uBAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,0BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './migrations'\nexport * from './engine'\nexport * from './controllers'\nexport * from './service'\n\nimport './routes'\nimport './restful' /* APIs */\n\nimport { ConnectionManager, ScenarioEngine } from './engine'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await ConnectionManager.ready()\n await ScenarioEngine.loadAll()\n\n console.log('Scenario Engine has just started.')\n } catch (ex) {\n ConnectionManager.logger.error(ex)\n console.log('Just has failed to start Scenario Engine.')\n }\n})\n"]}
@@ -0,0 +1 @@
1
+ export declare var migrations: any[];
@@ -0,0 +1 @@
1
+ import './unstable';
@@ -0,0 +1,7 @@
1
+ import './scenario';
2
+ import './scenarios';
3
+ import './scenario-instance';
4
+ import './scenario-instances';
5
+ import './run-scenario';
6
+ import './start-scenario';
7
+ import './stop-scenario';
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"run-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/run-scenario.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAE7B,6CAAgE;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+DAA+D,CAAC,CAAA;AAE/F,sBAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA;IACvC,IAAI,EAAE,YAAY,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;IAEhD,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACvC,SAAS,GAAG,IAAI,CAAA;KACjB;IAED,KAAK,CAAC,2CAA2C,EAAE,YAAY,CAAC,CAAA;IAChE,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;KAYZ;QACD,SAAS,EAAE;YACT,YAAY;YACZ,YAAY;YACZ,SAAS;SACV;QACD,OAAO;KACR,CAAC,CAAA;IAEF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;IAEjC,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;QAErB,OAAM;KACP;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAA;IAEnC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;AACvB,CAAC,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nconst debug = require('debug')('things-factory:integration-base:restful:unstable:run-scenario')\n\nrouter.post('/unstable/run-scenario/:scenarioName', async (context, next) => {\n const { client } = context.state\n const { scenarioName } = context.params\n const body = context.request.body || {}\n let { instanceName = '', variables = {} } = body\n\n if (Object.keys(variables).length === 0) {\n variables = body\n }\n\n debug('post:/unstable/run-scenario/:scenarioName', scenarioName)\n let response = await client.mutate({\n mutation: gql`\n mutation ($instanceName: String, $scenarioName: String!, $variables: Object) {\n runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {\n instanceName\n scenarioName\n state\n data\n result\n message\n timestamp\n }\n }\n `,\n variables: {\n instanceName,\n scenarioName,\n variables\n },\n context\n })\n\n const { errors, data } = response\n\n if (!data) {\n context.status = 500\n context.body = errors\n\n return\n }\n\n const { result } = data.runScenario\n\n context.body = result\n})\n"]}
1
+ {"version":3,"file":"run-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/run-scenario.ts"],"names":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outer as router } from '@things-factory/api'\n\nconst debug = require('debug')('things-factory:integration-base:restful:unstable:run-scenario')\n\nrouter.post('/unstable/run-scenario/:scenarioName', async (context, next) => {\n const { client } = context.state\n const { scenarioName } = context.params\n const body = context.request.body || {}\n let { instanceName = '', variables = {} } = body\n\n if (Object.keys(variables).length === 0) {\n variables = body\n }\n\n debug('post:/unstable/run-scenario/:scenarioName', scenarioName)\n let response = await client.mutate({\n mutation: gql`\n mutation ($instanceName: String, $scenarioName: String!, $variables: Object) {\n runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {\n instanceName\n scenarioName\n state\n data\n result\n message\n timestamp\n }\n }\n `,\n variables: {\n instanceName,\n scenarioName,\n variables\n },\n context\n })\n\n const { errors, data } = response\n\n if (!data) {\n context.status = 500\n context.body = errors\n\n return\n }\n\n const { result } = data.runScenario\n\n context.body = result\n})\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const scenarioScheduleCallbackRouter: any;
@@ -10,7 +10,6 @@ const scenario_engine_1 = require("../engine/scenario-engine");
10
10
  exports.scenarioScheduleCallbackRouter = new koa_router_1.default();
11
11
  /* When a callback occurs from the scheduler when a scheduled scenario is on schedule. */
12
12
  exports.scenarioScheduleCallbackRouter.post('/callback-schedule-for-scenario', async (context, next) => {
13
- var _a;
14
13
  const { client, task } = context.request.body;
15
14
  const { userId } = task === null || task === void 0 ? void 0 : task.data;
16
15
  // application: Application,
@@ -49,7 +48,7 @@ exports.scenarioScheduleCallbackRouter.post('/callback-schedule-for-scenario', a
49
48
  scenario_engine_1.ScenarioEngine.load(scenario.name, scenario, {
50
49
  domain,
51
50
  user,
52
- variables: (_a = client.task) === null || _a === void 0 ? void 0 : _a.data
51
+ /* variables: schedule 등록시 variables 설정할 방법이 없음. */
53
52
  });
54
53
  context.status = 200;
55
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"scenario-schedule-callback-router.js","sourceRoot":"","sources":["../../server/routers/scenario-schedule-callback-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,iDAAqD;AACrD,yDAAgD;AAGhD,2DAAuD;AACvD,+DAA0D;AAE7C,QAAA,8BAA8B,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE1D,yFAAyF;AACzF,sCAA8B,CAAC,IAAI,CAAC,iCAAiC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;IAC7F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAA+B,CAAA;IACxE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA;IAE7B,4BAA4B;IAC5B,yBAAyB;IACzB,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IAErB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEhC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;KACvD;IAED,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;KACtE;IAED,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAEpE,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,aAAa,UAAU,kCAAkC,CAAC,CAAA;KAC5F;IAED,IAAI,QAAQ,IAAI,MAAM,CAAC,EAAE,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;KAClF;IAED,IAAI,IAAI,IAAI,UAAU,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;KACjF;IAED,IAAI,SAAS,IAAI,OAAO,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;KACtF;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;QACrD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;QACnD,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;KAC1C,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,IAAI,UAAU,aAAa,CAAC,CAAA;KAClG;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAA;IAE3G,gCAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE;QAC3C,MAAM;QACN,IAAI;QACJ,SAAS,EAAE,MAAA,MAAM,CAAC,IAAI,0CAAE,IAAI;KAC7B,CAAC,CAAA;IAEF,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;AACtB,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ScheduleRegisterRequest } from '@things-factory/scheduler-client'\n\nimport { Scenario } from '../service/scenario/scenario'\nimport { ScenarioEngine } from '../engine/scenario-engine'\n\nexport const scenarioScheduleCallbackRouter = new Router()\n\n/* When a callback occurs from the scheduler when a scheduled scenario is on schedule. */\nscenarioScheduleCallbackRouter.post('/callback-schedule-for-scenario', async (context, next) => {\n const { client, task } = context.request.body as ScheduleRegisterRequest\n const { userId } = task?.data\n\n // application: Application,\n // group: `${domain.id}`,\n // type: 'scenario',\n // key: scenario.id,\n // operation: 'start'\n\n const { domain } = context.state\n\n if (!domain) {\n throw new Error('cannot identify the current domain.')\n }\n\n if (!client || typeof client !== 'object') {\n throw new Error('client property should be a part of callback body.')\n }\n\n const { group: domainId, key: scenarioId, operation, type } = client\n\n if (!domainId || !scenarioId) {\n throw new Error(`group(${domainId}) and key(${scenarioId}) properties should not be empty`)\n }\n\n if (domainId != domain.id) {\n throw new Error('client property(group) is not matched with the current domain.')\n }\n\n if (type != 'scenario') {\n throw new Error('client property(type) is not matched with the required value.')\n }\n\n if (operation != 'start') {\n throw new Error('client property(operation) is not matched with the required value.')\n }\n\n const scenario = await getRepository(Scenario).findOne({\n where: { domain: { id: domainId }, id: scenarioId },\n relations: ['domain', 'steps', 'creator']\n })\n\n if (!scenario) {\n throw new Error(`Scenario having given scenarioId(${domain?.subdomain}:${scenarioId}) not found`)\n }\n\n const user = (userId && (await getRepository(User).findOne({ where: { id: userId } }))) || scenario.creator\n\n ScenarioEngine.load(scenario.name, scenario, {\n domain,\n user,\n variables: client.task?.data\n })\n\n context.status = 200\n})\n"]}
1
+ {"version":3,"file":"scenario-schedule-callback-router.js","sourceRoot":"","sources":["../../server/routers/scenario-schedule-callback-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,iDAAqD;AACrD,yDAAgD;AAGhD,2DAAuD;AACvD,+DAA0D;AAE7C,QAAA,8BAA8B,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE1D,yFAAyF;AACzF,sCAA8B,CAAC,IAAI,CAAC,iCAAiC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC7F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,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ACnD,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;KAC1C,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,IAAI,UAAU,aAAa,CAAC,CAAA;IACnG,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAA;IAE3G,gCAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE;QAC3C,MAAM;QACN,IAAI;QACJ,qDAAqD;KACtD,CAAC,CAAA;IAEF,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;AACtB,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ScheduleRegisterRequest } from '@things-factory/scheduler-client/dist-server'\n\nimport { Scenario } from '../service/scenario/scenario'\nimport { ScenarioEngine } from '../engine/scenario-engine'\n\nexport const scenarioScheduleCallbackRouter = new Router()\n\n/* When a callback occurs from the scheduler when a scheduled scenario is on schedule. */\nscenarioScheduleCallbackRouter.post('/callback-schedule-for-scenario', async (context, next) => {\n const { client, task } = context.request.body as ScheduleRegisterRequest\n const { userId } = task?.data\n\n // application: Application,\n // group: `${domain.id}`,\n // type: 'scenario',\n // key: scenario.id,\n // operation: 'start'\n\n const { domain } = context.state\n\n if (!domain) {\n throw new Error('cannot identify the current domain.')\n }\n\n if (!client || typeof client !== 'object') {\n throw new Error('client property should be a part of callback body.')\n }\n\n const { group: domainId, key: scenarioId, operation, type } = client\n\n if (!domainId || !scenarioId) {\n throw new Error(`group(${domainId}) and key(${scenarioId}) properties should not be empty`)\n }\n\n if (domainId != domain.id) {\n throw new Error('client property(group) is not matched with the current domain.')\n }\n\n if (type != 'scenario') {\n throw new Error('client property(type) is not matched with the required value.')\n }\n\n if (operation != 'start') {\n throw new Error('client property(operation) is not matched with the required value.')\n }\n\n const scenario = await getRepository(Scenario).findOne({\n where: { domain: { id: domainId }, id: scenarioId },\n relations: ['domain', 'steps', 'creator']\n })\n\n if (!scenario) {\n throw new Error(`Scenario having given scenarioId(${domain?.subdomain}:${scenarioId}) not found`)\n }\n\n const user = (userId && (await getRepository(User).findOne({ where: { id: userId } }))) || scenario.creator\n\n ScenarioEngine.load(scenario.name, scenario, {\n domain,\n user,\n /* variables: schedule 등록시 variables 는 설정할 방법이 없음. */\n })\n\n context.status = 200\n})\n"]}
@@ -0,0 +1 @@
1
+ export declare const scenarioViewRouter: any;
@@ -1 +1 @@
1
- {"version":3,"file":"scenario-view-router.js","sourceRoot":"","sources":["../../server/routers/scenario-view-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,iDAAqD;AAErD,2DAAuD;AAG1C,QAAA,kBAAkB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE9C,0BAAkB,CAAC,GAAG,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAE/B,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;QACrD,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;YACzB,IAAI;SACL;QACD,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CAAC,CAAA;IAEF,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAA;IACpC,MAAM,KAAK,GAAG,EAAE,CAAA;IAChB,MAAM,KAAK,GAAG,EAAE,CAAA;IAEhB,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7B,KAAK,CAAC,EAAE,CAAC,GAAG;YACV,EAAE;YACF,IAAI;SACL,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;YACnB,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;SACxB,CAAC,CAAA;KACH;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;QACpC,KAAK,EAAE;YACL,KAAK;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Scenario } from '../service/scenario/scenario'\nimport { Step } from '../service/step/step-type'\n\nexport const scenarioViewRouter = new Router()\n\nscenarioViewRouter.get('/scenario-view/:name', async (context, next) => {\n const { domain } = context.state\n const { name } = context.params\n\n const scenario = await getRepository(Scenario).findOne({\n where: {\n domain: { id: domain.id },\n name\n },\n relations: ['steps']\n })\n\n const steps: Step[] = scenario.steps\n const nodes = {}\n const edges = []\n\n steps.forEach(({ id, name }) => {\n nodes[id] = {\n id,\n name\n }\n })\n\n for (let i = 0; i < steps.length - 1; i++) {\n edges.push({\n source: steps[i].id,\n target: steps[i + 1].id\n })\n }\n\n await context.render('scenario-view', {\n model: {\n nodes,\n edges\n }\n })\n})\n"]}
1
+ {"version":3,"file":"scenario-view-router.js","sourceRoot":"","sources":["../../server/routers/scenario-view-router.ts"],"names":[],"mappings":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C,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Scenario } from '../service/scenario/scenario'\nimport { Step } from '../service/step/step-type'\n\nexport const scenarioViewRouter = new Router()\n\nscenarioViewRouter.get('/scenario-view/:name', async (context, next) => {\n const { domain } = context.state\n const { name } = context.params\n\n const scenario = await getRepository(Scenario).findOne({\n where: {\n domain: { id: domain.id },\n name\n },\n relations: ['steps']\n })\n\n const steps: Step[] = scenario.steps\n const nodes = {}\n const edges = []\n\n steps.forEach(({ id, name }) => {\n nodes[id] = {\n id,\n name\n }\n })\n\n for (let i = 0; i < steps.length - 1; i++) {\n edges.push({\n source: steps[i].id,\n target: steps[i + 1].id\n })\n }\n\n await context.render('scenario-view', {\n model: {\n nodes,\n edges\n }\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAE5C,yEAAmE;AACnE,mGAA4F;AAE5F,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACrF,IAAI,gBAAgB,EAAE;QACpB,mBAAmB,CAAC,GAAG,CACrB,iBAAiB,EACjB,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;KACF;SAAM;QACL,mBAAmB,CAAC,GAAG,CACrB,EAAE,EACF,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;KACF;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE;QACpB,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC7G;SAAM;QACL,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC9F;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\n\nimport { scenarioViewRouter } from './routers/scenario-view-router'\nimport { scenarioScheduleCallbackRouter } from './routers/scenario-schedule-callback-router'\n\nconst isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(\n '/domain/:domain',\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n } else {\n domainPrivateRouter.use(\n '',\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n }\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use('/domain/:domain', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n } else {\n domainPrivateRouter.use('', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n }\n})\n"]}
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAE5C,yEAAmE;AACnE,mGAA4F;AAE5F,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACrF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CACrB,iBAAiB,EACjB,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;IACH,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CACrB,EAAE,EACF,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;IACH,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;IAC9G,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/F,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\n\nimport { scenarioViewRouter } from './routers/scenario-view-router'\nimport { scenarioScheduleCallbackRouter } from './routers/scenario-schedule-callback-router'\n\nconst isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(\n '/domain/:domain',\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n } else {\n domainPrivateRouter.use(\n '',\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n }\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use('/domain/:domain', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n } else {\n domainPrivateRouter.use('', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n }\n})\n"]}
@@ -0,0 +1,3 @@
1
+ export declare class IntegrationAnalysisQuery {
2
+ integrationAnalysis(context: ResolverContext): Promise<any>;
3
+ }
@@ -11,6 +11,7 @@ let IntegrationAnalysisQuery = class IntegrationAnalysisQuery {
11
11
  return await (0, analyze_integration_1.analyzeIntegration)(domain);
12
12
  }
13
13
  };
14
+ exports.IntegrationAnalysisQuery = IntegrationAnalysisQuery;
14
15
  tslib_1.__decorate([
15
16
  (0, type_graphql_1.Query)(returns => shell_1.ScalarObject, { description: 'To fetch integration Analyses' }),
16
17
  tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
@@ -18,8 +19,7 @@ tslib_1.__decorate([
18
19
  tslib_1.__metadata("design:paramtypes", [Object]),
19
20
  tslib_1.__metadata("design:returntype", Promise)
20
21
  ], IntegrationAnalysisQuery.prototype, "integrationAnalysis", null);
21
- IntegrationAnalysisQuery = tslib_1.__decorate([
22
+ exports.IntegrationAnalysisQuery = IntegrationAnalysisQuery = tslib_1.__decorate([
22
23
  (0, type_graphql_1.Resolver)()
23
24
  ], IntegrationAnalysisQuery);
24
- exports.IntegrationAnalysisQuery = IntegrationAnalysisQuery;
25
25
  //# sourceMappingURL=analysis-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analysis-query.js","sourceRoot":"","sources":["../../../server/service/analysis/analysis-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmD;AACnD,iDAAoD;AACpD,mFAA8E;AAGvE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAE7B,AAAN,KAAK,CAAC,mBAAmB,CAAQ,OAAwB;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,wCAAkB,EAAC,MAAM,CAAC,CAAA;IACzC,CAAC;CACF,CAAA;AALO;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACtD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAI/B;AANU,wBAAwB;IADpC,IAAA,uBAAQ,GAAE;GACE,wBAAwB,CAOpC;AAPY,4DAAwB","sourcesContent":["import { Resolver, Query, Ctx } from 'type-graphql'\nimport { ScalarObject } from '@things-factory/shell'\nimport { analyzeIntegration } from '../../engine/analyzer/analyze-integration'\n\n@Resolver()\nexport class IntegrationAnalysisQuery {\n @Query(returns => ScalarObject, { description: 'To fetch integration Analyses' })\n async integrationAnalysis(@Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n\n return await analyzeIntegration(domain)\n }\n}\n"]}
1
+ {"version":3,"file":"analysis-query.js","sourceRoot":"","sources":["../../../server/service/analysis/analysis-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmD;AACnD,iDAAoD;AACpD,mFAA8E;AAGvE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAE7B,AAAN,KAAK,CAAC,mBAAmB,CAAQ,OAAwB;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,wCAAkB,EAAC,MAAM,CAAC,CAAA;IACzC,CAAC;CACF,CAAA;AAPY,4DAAwB;AAE7B;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACtD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAI/B;mCANU,wBAAwB;IADpC,IAAA,uBAAQ,GAAE;GACE,wBAAwB,CAOpC","sourcesContent":["import { Resolver, Query, Ctx } from 'type-graphql'\nimport { ScalarObject } from '@things-factory/shell'\nimport { analyzeIntegration } from '../../engine/analyzer/analyze-integration'\n\n@Resolver()\nexport class IntegrationAnalysisQuery {\n @Query(returns => ScalarObject, { description: 'To fetch integration Analyses' })\n async integrationAnalysis(@Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n\n return await analyzeIntegration(domain)\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { IntegrationAnalysisQuery } from './analysis-query';
2
+ export declare const resolvers: (typeof IntegrationAnalysisQuery)[];
@@ -0,0 +1,28 @@
1
+ import { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type';
2
+ export declare class ConnectionMutation {
3
+ createConnection(connection: NewConnection, context: ResolverContext): Promise<Connection>;
4
+ updateConnection(name: string, patch: ConnectionPatch, context: ResolverContext): Promise<Connection>;
5
+ updateMultipleConnection(patches: ConnectionPatch[], context: ResolverContext): Promise<Connection[]>;
6
+ deleteConnection(name: string, context: ResolverContext): Promise<boolean>;
7
+ deleteConnections(names: string[], context: ResolverContext): Promise<boolean>;
8
+ connectConnection(name: string, context: ResolverContext): Promise<Connection>;
9
+ disconnectConnection(name: string, context: ResolverContext): Promise<{
10
+ state: ConnectionStatus;
11
+ id: string;
12
+ domain: import("@things-factory/shell").Domain;
13
+ domainId: string;
14
+ name: string;
15
+ description: string;
16
+ type: string;
17
+ endpoint: string;
18
+ active: boolean;
19
+ params: string;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ creator: import("@things-factory/auth-base").User;
23
+ creatorId: string;
24
+ updater: import("@things-factory/auth-base").User;
25
+ updaterId: string;
26
+ }>;
27
+ importConnections(connections: Connection[], context: ResolverContext): Promise<boolean>;
28
+ }
@@ -106,6 +106,7 @@ let ConnectionMutation = class ConnectionMutation {
106
106
  return true;
107
107
  }
108
108
  };
109
+ exports.ConnectionMutation = ConnectionMutation;
109
110
  tslib_1.__decorate([
110
111
  (0, type_graphql_1.Directive)('@transaction'),
111
112
  (0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To create new connection' }),
@@ -179,8 +180,7 @@ tslib_1.__decorate([
179
180
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
180
181
  tslib_1.__metadata("design:returntype", Promise)
181
182
  ], ConnectionMutation.prototype, "importConnections", null);
182
- ConnectionMutation = tslib_1.__decorate([
183
+ exports.ConnectionMutation = ConnectionMutation = tslib_1.__decorate([
183
184
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
184
185
  ], ConnectionMutation);
185
- exports.ConnectionMutation = ConnectionMutation;
186
186
  //# sourceMappingURL=connection-mutation.js.map
@@ -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,EAAE,EAAE,IAAI,EA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E,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,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,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,CAAC,wBAAwB,CACe,OAA0B,E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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;6BAvMU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAwM9B","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"]}
@@ -0,0 +1,11 @@
1
+ import { 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
+ domain(connection: Connection): Promise<Domain>;
9
+ updater(connection: Connection): Promise<User>;
10
+ creator(connection: Connection): Promise<User>;
11
+ }
@@ -53,6 +53,7 @@ let ConnectionQuery = class ConnectionQuery {
53
53
  return 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')),
@@ -98,8 +99,7 @@ tslib_1.__decorate([
98
99
  tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
99
100
  tslib_1.__metadata("design:returntype", Promise)
100
101
  ], ConnectionQuery.prototype, "creator", null);
101
- ConnectionQuery = tslib_1.__decorate([
102
+ exports.ConnectionQuery = ConnectionQuery = tslib_1.__decorate([
102
103
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
103
104
  ], ConnectionQuery);
104
- exports.ConnectionQuery = ConnectionQuery;
105
105
  //# 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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AE,CAAA;;;;iDAcjD;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;kDAoB1C;AAED;IAAC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;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;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAE1C;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;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,yDAAgD;AAChD,iDAAuG;AAEvG,wEAA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;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAcjD;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;kDAoB1C;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;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;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAE1C;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;0BAlEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAmE3B","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"]}
@@ -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) => {
@@ -92,8 +93,7 @@ tslib_1.__decorate([
92
93
  tslib_1.__metadata("design:paramtypes", [Object, String]),
93
94
  tslib_1.__metadata("design:returntype", shell_1.Log)
94
95
  ], ConnectionSubscription.prototype, "connectionLog", null);
95
- ConnectionSubscription = tslib_1.__decorate([
96
+ exports.ConnectionSubscription = ConnectionSubscription = tslib_1.__decorate([
96
97
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
97
98
  ], ConnectionSubscription);
98
- exports.ConnectionSubscription = ConnectionSubscription;
99
99
  //# 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,iEAAkD;AAClD,+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;IAiDjC,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;AA5FC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;YACpC,MAAM,EAA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B,CAAC,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,kCAAU,EACf,GAAG,EAAE,CAAC,cAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAC5C,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBACpC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAA;gBAC7D,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,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,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;AA5FU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CA6FlC;AA7FY,wDAAsB","sourcesContent":["import { withFilter } from 'graphql-subscriptions'\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 withFilter(\n () => pubsub.asyncIterator('connection-state'),\n (payload, variables, context, info) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const { name } = variables\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n }\n )(_, args, context, info)\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 withFilter(\n () => pubsub.asyncIterator('connection-log'),\n (payload, variables, context, info) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.connectionLog\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 )(_, args, context, info)\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,iEAAkD;AAClD,+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;IAiDjC,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;AA7FY,wDAAsB;AAiDjC;IAhDC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;YACpC,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,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AS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBACpC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAA;gBAC7D,qCAAqC;gBAErC,0CAA0C;gBAC1C,iBAAiB;gBACjB,IAAI;gBAEJ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBAC9B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,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;iCA5FU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CA6FlC","sourcesContent":["import { withFilter } from 'graphql-subscriptions'\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 withFilter(\n () => pubsub.asyncIterator('connection-state'),\n (payload, variables, context, info) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const { name } = variables\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n }\n )(_, args, context, info)\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 withFilter(\n () => pubsub.asyncIterator('connection-log'),\n (payload, variables, context, info) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.connectionLog\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 )(_, args, context, info)\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}