@things-factory/integration-base 7.0.1-beta.0 → 7.0.1-beta.10

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 (263) 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.map +1 -1
  4. package/dist-server/engine/analyzer/analyze-integration.d.ts +5 -0
  5. package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
  6. package/dist-server/engine/connection-manager.d.ts +35 -0
  7. package/dist-server/engine/connection-manager.js.map +1 -1
  8. package/dist-server/engine/connector/echo-back-connector.d.ts +9 -0
  9. package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
  10. package/dist-server/engine/connector/echo-back-server.d.ts +8 -0
  11. package/dist-server/engine/connector/echo-back-server.js.map +1 -1
  12. package/dist-server/engine/connector/graphql-connector.d.ts +19 -0
  13. package/dist-server/engine/connector/graphql-connector.js +1 -1
  14. package/dist-server/engine/connector/graphql-connector.js.map +1 -1
  15. package/dist-server/engine/connector/http-connector.d.ts +25 -0
  16. package/dist-server/engine/connector/http-connector.js.map +1 -1
  17. package/dist-server/engine/connector/index.d.ts +12 -0
  18. package/dist-server/engine/connector/mqtt-connector.d.ts +14 -0
  19. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  20. package/dist-server/engine/connector/mssql-connector.d.ts +30 -0
  21. package/dist-server/engine/connector/mssql-connector.js +20 -4
  22. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  23. package/dist-server/engine/connector/mysql-connector.d.ts +13 -0
  24. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  25. package/dist-server/engine/connector/operato-connector.d.ts +27 -0
  26. package/dist-server/engine/connector/operato-connector.js +1 -1
  27. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  28. package/dist-server/engine/connector/oracle-connector.d.ts +29 -0
  29. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  30. package/dist-server/engine/connector/postgresql-connector.d.ts +14 -0
  31. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  32. package/dist-server/engine/connector/proxy-connector.d.ts +15 -0
  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/edge-client.d.ts +18 -0
  38. package/dist-server/engine/index.d.ts +8 -0
  39. package/dist-server/engine/index.js.map +1 -1
  40. package/dist-server/engine/pending-queue.d.ts +24 -0
  41. package/dist-server/engine/pending-queue.js.map +1 -1
  42. package/dist-server/engine/scenario-engine.d.ts +11 -0
  43. package/dist-server/engine/scenario-engine.js.map +1 -1
  44. package/dist-server/engine/task/book-up-scenario.d.ts +1 -0
  45. package/dist-server/engine/task/csv-readline.d.ts +1 -0
  46. package/dist-server/engine/task/csv-readline.js.map +1 -1
  47. package/dist-server/engine/task/data-accessor.d.ts +1 -0
  48. package/dist-server/engine/task/data-mapper.d.ts +1 -0
  49. package/dist-server/engine/task/data-mapper.js.map +1 -1
  50. package/dist-server/engine/task/database-query.d.ts +1 -0
  51. package/dist-server/engine/task/echo-receive.d.ts +1 -0
  52. package/dist-server/engine/task/echo-send.d.ts +1 -0
  53. package/dist-server/engine/task/echo-send.js.map +1 -1
  54. package/dist-server/engine/task/empty-check.d.ts +1 -0
  55. package/dist-server/engine/task/empty-check.js.map +1 -1
  56. package/dist-server/engine/task/end.d.ts +1 -0
  57. package/dist-server/engine/task/floating-point.d.ts +1 -0
  58. package/dist-server/engine/task/floating-point.js.map +1 -1
  59. package/dist-server/engine/task/goto.d.ts +1 -0
  60. package/dist-server/engine/task/graphql-mutate.d.ts +1 -0
  61. package/dist-server/engine/task/graphql-query.d.ts +1 -0
  62. package/dist-server/engine/task/headless-post.d.ts +1 -0
  63. package/dist-server/engine/task/headless-post.js.map +1 -1
  64. package/dist-server/engine/task/headless-scrap.d.ts +1 -0
  65. package/dist-server/engine/task/headless-scrap.js.map +1 -1
  66. package/dist-server/engine/task/http-get.d.ts +1 -0
  67. package/dist-server/engine/task/http-get.js.map +1 -1
  68. package/dist-server/engine/task/http-post.d.ts +1 -0
  69. package/dist-server/engine/task/http-post.js.map +1 -1
  70. package/dist-server/engine/task/index.d.ts +43 -0
  71. package/dist-server/engine/task/jsonata.d.ts +1 -0
  72. package/dist-server/engine/task/local-graphql-mutate.d.ts +1 -0
  73. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  74. package/dist-server/engine/task/local-graphql-query.d.ts +1 -0
  75. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  76. package/dist-server/engine/task/log.d.ts +1 -0
  77. package/dist-server/engine/task/log.js.map +1 -1
  78. package/dist-server/engine/task/mqtt-publish.d.ts +1 -0
  79. package/dist-server/engine/task/mqtt-publish.js.map +1 -1
  80. package/dist-server/engine/task/mqtt-subscribe.d.ts +1 -0
  81. package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
  82. package/dist-server/engine/task/oracle-procedure.d.ts +1 -0
  83. package/dist-server/engine/task/oracle-procedure.js.map +1 -1
  84. package/dist-server/engine/task/pick-pending-scenario.d.ts +1 -0
  85. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  86. package/dist-server/engine/task/publish.d.ts +1 -0
  87. package/dist-server/engine/task/publish.js.map +1 -1
  88. package/dist-server/engine/task/random.d.ts +1 -0
  89. package/dist-server/engine/task/reset-pending-queue.d.ts +1 -0
  90. package/dist-server/engine/task/script.d.ts +1 -0
  91. package/dist-server/engine/task/set-domain.d.ts +1 -0
  92. package/dist-server/engine/task/set-domain.js.map +1 -1
  93. package/dist-server/engine/task/sleep.d.ts +1 -0
  94. package/dist-server/engine/task/sleep.js.map +1 -1
  95. package/dist-server/engine/task/socket-listener.d.ts +1 -0
  96. package/dist-server/engine/task/socket-listener.js.map +1 -1
  97. package/dist-server/engine/task/state-read.d.ts +1 -0
  98. package/dist-server/engine/task/state-read.js.map +1 -1
  99. package/dist-server/engine/task/state-write.d.ts +1 -0
  100. package/dist-server/engine/task/state-write.js.map +1 -1
  101. package/dist-server/engine/task/stop-scenario.d.ts +1 -0
  102. package/dist-server/engine/task/sub-scenario.d.ts +1 -0
  103. package/dist-server/engine/task/switch-goto.d.ts +1 -0
  104. package/dist-server/engine/task/switch-range-goto.d.ts +1 -0
  105. package/dist-server/engine/task/switch-range-goto.js.map +1 -1
  106. package/dist-server/engine/task/switch-range-scenario.d.ts +1 -0
  107. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  108. package/dist-server/engine/task/switch-range-set.d.ts +1 -0
  109. package/dist-server/engine/task/switch-range-set.js.map +1 -1
  110. package/dist-server/engine/task/switch-scenario.d.ts +1 -0
  111. package/dist-server/engine/task/switch-set.d.ts +1 -0
  112. package/dist-server/engine/task/throw.d.ts +1 -0
  113. package/dist-server/engine/task/utils/headless-pool-for-scenario.d.ts +1 -0
  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.map +1 -1
  117. package/dist-server/engine/task/variables.d.ts +1 -0
  118. package/dist-server/engine/task-registry.d.ts +12 -0
  119. package/dist-server/engine/types.d.ts +94 -0
  120. package/dist-server/index.d.ts +6 -0
  121. package/dist-server/index.js.map +1 -1
  122. package/dist-server/migrations/index.d.ts +1 -0
  123. package/dist-server/restful/index.d.ts +1 -0
  124. package/dist-server/restful/unstable/index.d.ts +7 -0
  125. package/dist-server/restful/unstable/run-scenario.d.ts +1 -0
  126. package/dist-server/restful/unstable/run-scenario.js.map +1 -1
  127. package/dist-server/restful/unstable/scenario-instance.d.ts +1 -0
  128. package/dist-server/restful/unstable/scenario-instances.d.ts +1 -0
  129. package/dist-server/restful/unstable/scenario.d.ts +1 -0
  130. package/dist-server/restful/unstable/scenarios.d.ts +1 -0
  131. package/dist-server/restful/unstable/start-scenario.d.ts +1 -0
  132. package/dist-server/restful/unstable/stop-scenario.d.ts +1 -0
  133. package/dist-server/routers/scenario-schedule-callback-router.d.ts +1 -0
  134. package/dist-server/routers/scenario-schedule-callback-router.js +1 -2
  135. package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
  136. package/dist-server/routers/scenario-view-router.d.ts +1 -0
  137. package/dist-server/routers/scenario-view-router.js.map +1 -1
  138. package/dist-server/routes.d.ts +1 -0
  139. package/dist-server/routes.js.map +1 -1
  140. package/dist-server/service/analysis/analysis-query.d.ts +3 -0
  141. package/dist-server/service/analysis/analysis-query.js +2 -2
  142. package/dist-server/service/analysis/analysis-query.js.map +1 -1
  143. package/dist-server/service/analysis/index.d.ts +2 -0
  144. package/dist-server/service/connection/connection-mutation.d.ts +30 -0
  145. package/dist-server/service/connection/connection-mutation.js +2 -2
  146. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  147. package/dist-server/service/connection/connection-query.d.ts +12 -0
  148. package/dist-server/service/connection/connection-query.js +2 -2
  149. package/dist-server/service/connection/connection-query.js.map +1 -1
  150. package/dist-server/service/connection/connection-subscription.d.ts +10 -0
  151. package/dist-server/service/connection/connection-subscription.js +2 -2
  152. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  153. package/dist-server/service/connection/connection-type.d.ts +133 -0
  154. package/dist-server/service/connection/connection-type.js +11 -11
  155. package/dist-server/service/connection/connection-type.js.map +1 -1
  156. package/dist-server/service/connection/index.d.ts +6 -0
  157. package/dist-server/service/connector/connector-query.d.ts +6 -0
  158. package/dist-server/service/connector/connector-query.js +2 -2
  159. package/dist-server/service/connector/connector-query.js.map +1 -1
  160. package/dist-server/service/connector/connector-type.d.ts +12 -0
  161. package/dist-server/service/connector/connector-type.js +4 -4
  162. package/dist-server/service/connector/connector-type.js.map +1 -1
  163. package/dist-server/service/connector/index.d.ts +3 -0
  164. package/dist-server/service/index.d.ts +17 -0
  165. package/dist-server/service/payload-log/index.d.ts +5 -0
  166. package/dist-server/service/payload-log/payload-log-mutation.d.ts +10 -0
  167. package/dist-server/service/payload-log/payload-log-mutation.js +2 -2
  168. package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
  169. package/dist-server/service/payload-log/payload-log-query.d.ts +11 -0
  170. package/dist-server/service/payload-log/payload-log-query.js +2 -2
  171. package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
  172. package/dist-server/service/payload-log/payload-log-type.d.ts +15 -0
  173. package/dist-server/service/payload-log/payload-log-type.js +6 -6
  174. package/dist-server/service/payload-log/payload-log-type.js.map +1 -1
  175. package/dist-server/service/payload-log/payload-log.d.ts +23 -0
  176. package/dist-server/service/payload-log/payload-log.js +3 -3
  177. package/dist-server/service/payload-log/payload-log.js.map +1 -1
  178. package/dist-server/service/property-spec.d.ts +12 -0
  179. package/dist-server/service/property-spec.js +2 -2
  180. package/dist-server/service/property-spec.js.map +1 -1
  181. package/dist-server/service/scenario/index.d.ts +5 -0
  182. package/dist-server/service/scenario/scenario-mutation.d.ts +13 -0
  183. package/dist-server/service/scenario/scenario-mutation.js +3 -3
  184. package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
  185. package/dist-server/service/scenario/scenario-query.d.ts +18 -0
  186. package/dist-server/service/scenario/scenario-query.js +2 -2
  187. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  188. package/dist-server/service/scenario/scenario-type.d.ts +28 -0
  189. package/dist-server/service/scenario/scenario-type.js +6 -6
  190. package/dist-server/service/scenario/scenario-type.js.map +1 -1
  191. package/dist-server/service/scenario/scenario.d.ts +26 -0
  192. package/dist-server/service/scenario/scenario.js +2 -2
  193. package/dist-server/service/scenario/scenario.js.map +1 -1
  194. package/dist-server/service/scenario-flow/scenario-flow.d.ts +6 -0
  195. package/dist-server/service/scenario-flow/scenario-flow.js +2 -2
  196. package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
  197. package/dist-server/service/scenario-instance/index.d.ts +5 -0
  198. package/dist-server/service/scenario-instance/scenario-instance-mutation.d.ts +6 -0
  199. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +2 -2
  200. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  201. package/dist-server/service/scenario-instance/scenario-instance-query.d.ts +12 -0
  202. package/dist-server/service/scenario-instance/scenario-instance-query.js +2 -2
  203. package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
  204. package/dist-server/service/scenario-instance/scenario-instance-subscription.d.ts +10 -0
  205. package/dist-server/service/scenario-instance/scenario-instance-subscription.js +2 -2
  206. package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
  207. package/dist-server/service/scenario-instance/scenario-instance-type.d.ts +78 -0
  208. package/dist-server/service/scenario-instance/scenario-instance-type.js +9 -9
  209. package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
  210. package/dist-server/service/scenario-queue/index.d.ts +3 -0
  211. package/dist-server/service/scenario-queue/scenario-queue-subscription.d.ts +6 -0
  212. package/dist-server/service/scenario-queue/scenario-queue-subscription.js +2 -2
  213. package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
  214. package/dist-server/service/scenario-queue/scenario-queue-type.d.ts +11 -0
  215. package/dist-server/service/scenario-queue/scenario-queue-type.js +4 -4
  216. package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
  217. package/dist-server/service/state-register/index.d.ts +6 -0
  218. package/dist-server/service/state-register/state-register-mutation.d.ts +11 -0
  219. package/dist-server/service/state-register/state-register-mutation.js +2 -2
  220. package/dist-server/service/state-register/state-register-mutation.js.map +1 -1
  221. package/dist-server/service/state-register/state-register-query.d.ts +14 -0
  222. package/dist-server/service/state-register/state-register-query.js +2 -2
  223. package/dist-server/service/state-register/state-register-query.js.map +1 -1
  224. package/dist-server/service/state-register/state-register-type.d.ts +23 -0
  225. package/dist-server/service/state-register/state-register-type.js +6 -6
  226. package/dist-server/service/state-register/state-register-type.js.map +1 -1
  227. package/dist-server/service/state-register/state-register.d.ts +22 -0
  228. package/dist-server/service/state-register/state-register.js +2 -2
  229. package/dist-server/service/state-register/state-register.js.map +1 -1
  230. package/dist-server/service/step/index.d.ts +5 -0
  231. package/dist-server/service/step/step-mutation.d.ts +5 -0
  232. package/dist-server/service/step/step-mutation.js +2 -2
  233. package/dist-server/service/step/step-mutation.js.map +1 -1
  234. package/dist-server/service/step/step-query.d.ts +12 -0
  235. package/dist-server/service/step/step-query.js +2 -2
  236. package/dist-server/service/step/step-query.js.map +1 -1
  237. package/dist-server/service/step/step-type.d.ts +111 -0
  238. package/dist-server/service/step/step-type.js +6 -6
  239. package/dist-server/service/step/step-type.js.map +1 -1
  240. package/dist-server/service/task-type/index.d.ts +3 -0
  241. package/dist-server/service/task-type/task-type-query.d.ts +6 -0
  242. package/dist-server/service/task-type/task-type-query.js +2 -2
  243. package/dist-server/service/task-type/task-type-query.js.map +1 -1
  244. package/dist-server/service/task-type/task-type-type.d.ts +12 -0
  245. package/dist-server/service/task-type/task-type-type.js +4 -4
  246. package/dist-server/service/task-type/task-type-type.js.map +1 -1
  247. package/dist-server/tsconfig.tsbuildinfo +1 -1
  248. package/helps/integration/connector/mssql-connector.ja.md +13 -9
  249. package/helps/integration/connector/mssql-connector.ko.md +13 -9
  250. package/helps/integration/connector/mssql-connector.md +13 -9
  251. package/helps/integration/connector/mssql-connector.ms.md +13 -9
  252. package/helps/integration/connector/mssql-connector.zh.md +13 -9
  253. package/helps/integration/connector/operato-connector.ja.md +0 -3
  254. package/package.json +10 -10
  255. package/server/engine/connector/mssql-connector.ts +20 -4
  256. package/server/engine/index.ts +1 -1
  257. package/server/routers/scenario-schedule-callback-router.ts +1 -1
  258. package/server/service/step/step-type.ts +20 -20
  259. package/translations/en.json +2 -1
  260. package/translations/ja.json +2 -1
  261. package/translations/ko.json +2 -1
  262. package/translations/ms.json +2 -1
  263. package/translations/zh.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"switch-range-set.js","sourceRoot":"","sources":["../../../server/engine/task/switch-range-set.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,oDAA+C;AAI/C,KAAK,UAAU,cAAc,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAW;IACtE,IAAI,EACF,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC5B,GAAG,IAAI,CAAA;IAER,IAAI,KAAK,GAAG,MAAM,CAAC,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;IAE1C,IAAI,KAAK,GACP,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,GAAG,IAAI,SAAS,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAA;IACpD,CAAC,CAAC,IAAI,SAAS,CAAA;IAEjB,IAAI,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IAEvB,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,eAAe,KAAK,KAAK,CAAC,CAAA;IAEnE,OAAO;QACL,IAAI;KACL,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;CACF,CAAA;AAED,cAAc,CAAC,aAAa,GAAG,IAAI,CAAA;AAEnC,4BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { access } from '@things-factory/utils'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function SwitchRangeSet(step: InputStep, { logger, data }: Context) {\n var {\n params: { accessor, cases }\n } = step\n\n var value = Number(access(accessor, data))\n\n var range =\n Object.keys(cases).find(key => {\n if (key == 'default') {\n return\n }\n\n var [from, to] = key.split('~')\n\n return Number(from) <= value && Number(to) > value\n }) || 'default'\n\n var data = cases[range]\n\n logger.info(`switch-range to data '${data}' by value '${value}' .`)\n\n return {\n data\n }\n}\n\nSwitchRangeSet.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'range',\n name: 'cases',\n label: 'cases'\n }\n]\n\nSwitchRangeSet.connectorFree = true\n\nTaskRegistry.registerTaskHandler('switch-range-set', SwitchRangeSet)\n"]}
1
+ {"version":3,"file":"switch-range-set.js","sourceRoot":"","sources":["../../../server/engine/task/switch-range-set.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,oDAA+C;AAI/C,KAAK,UAAU,cAAc,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAW;IACtE,IAAI,EACF,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC5B,GAAG,IAAI,CAAA;IAER,IAAI,KAAK,GAAG,MAAM,CAAC,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;IAE1C,IAAI,KAAK,GACP,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC;YACrB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAA;IACpD,CAAC,CAAC,IAAI,SAAS,CAAA;IAEjB,IAAI,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IAEvB,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,eAAe,KAAK,KAAK,CAAC,CAAA;IAEnE,OAAO;QACL,IAAI;KACL,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;CACF,CAAA;AAED,cAAc,CAAC,aAAa,GAAG,IAAI,CAAA;AAEnC,4BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { access } from '@things-factory/utils'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function SwitchRangeSet(step: InputStep, { logger, data }: Context) {\n var {\n params: { accessor, cases }\n } = step\n\n var value = Number(access(accessor, data))\n\n var range =\n Object.keys(cases).find(key => {\n if (key == 'default') {\n return\n }\n\n var [from, to] = key.split('~')\n\n return Number(from) <= value && Number(to) > value\n }) || 'default'\n\n var data = cases[range]\n\n logger.info(`switch-range to data '${data}' by value '${value}' .`)\n\n return {\n data\n }\n}\n\nSwitchRangeSet.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'range',\n name: 'cases',\n label: 'cases'\n }\n]\n\nSwitchRangeSet.connectorFree = true\n\nTaskRegistry.registerTaskHandler('switch-range-set', SwitchRangeSet)\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function getHeadlessPool(): any;
@@ -1 +1 @@
1
- {"version":3,"file":"headless-pool-for-scenario.js","sourceRoot":"","sources":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E;YACd,OAAM;SACP;QAED,IAAI,aAAa,GAAG;YAClB,IAAI,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;YACtC,QAAQ,EAAE,OAAO;SAClB,CAAA;QAED,IAAI,aAAa,EAAE;YACjB,aAAa,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAA;SAChD;QAED,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAErD,OAAO,OAAO,CAAA;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: 'shell'\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":";;;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,OAAM;QACR,CAAC;QAED,IAAI,aAAa,GAAG;YAClB,IAAI,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;YACtC,QAAQ,EAAE,OAAO;SAClB,CAAA;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAA;QACjD,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAErD,OAAO,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: 'shell'\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 +1 @@
1
- {"version":3,"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AM,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;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":";;;AAAA,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;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"]}
@@ -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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C,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"]}
@@ -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: task === null || task === void 0 ? void 0 : task.data
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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AAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;QACnD,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,SAAS,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI;KACtB,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: task?.data\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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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"]}
@@ -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,30 @@
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
+ edge: import("@things-factory/auth-base").Appliance;
18
+ edgeId: string;
19
+ endpoint: string;
20
+ active: boolean;
21
+ params: string;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ creator: import("@things-factory/auth-base").User;
25
+ creatorId: string;
26
+ updater: import("@things-factory/auth-base").User;
27
+ updaterId: string;
28
+ }>;
29
+ importConnections(connections: Connection[], context: ResolverContext): Promise<boolean>;
30
+ }
@@ -102,6 +102,7 @@ let ConnectionMutation = class ConnectionMutation {
102
102
  return true;
103
103
  }
104
104
  };
105
+ exports.ConnectionMutation = ConnectionMutation;
105
106
  tslib_1.__decorate([
106
107
  (0, type_graphql_1.Directive)('@transaction'),
107
108
  (0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To create new connection' }),
@@ -175,8 +176,7 @@ tslib_1.__decorate([
175
176
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
176
177
  tslib_1.__metadata("design:returntype", Promise)
177
178
  ], ConnectionMutation.prototype, "importConnections", null);
178
- ConnectionMutation = tslib_1.__decorate([
179
+ exports.ConnectionMutation = ConnectionMutation = tslib_1.__decorate([
179
180
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
180
181
  ], ConnectionMutation);
181
- exports.ConnectionMutation = ConnectionMutation;
182
182
  //# 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,CAAoB,UAAyB,EAAS,OAAwB;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CAAc,IAAY,EAAgB,KAAsB,EAAS,OAAwB;QACrH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC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,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAexD;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAgB3D;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IAC1B,oGAAoG;;IACnG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAA6B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA2CvG;AAnLU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAoL9B;AApLY,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(@Arg('connection') connection: NewConnection, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(@Arg('name') name: string, @Arg('patch') patch: ConnectionPatch, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(@Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[], @Ctx() context: ResolverContext): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(@Arg('names', type => [String]) names: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n // @Directive('@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(@Arg('connections', type => [ConnectionPatch]) connections: Connection[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGzF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAwB;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CAAc,IAAY,EAAgB,KAAsB,EAAS,OAAwB;QACrH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,UAAU,GACV,KAA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;IACvD,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAexD;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAgB3D;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IAC1B,oGAAoG;;IACnG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAA6B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA2CvG;6BAnLU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAoL9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(@Arg('connection') connection: NewConnection, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(@Arg('name') name: string, @Arg('patch') patch: ConnectionPatch, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(@Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[], @Ctx() context: ResolverContext): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(@Arg('names', type => [String]) names: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n // @Directive('@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(@Arg('connections', type => [ConnectionPatch]) connections: Connection[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Appliance, User } from '@things-factory/auth-base';
2
+ import { Domain, ListParam } from '@things-factory/shell';
3
+ import { Connection, ConnectionList, ConnectionState } from './connection-type';
4
+ export declare class ConnectionQuery {
5
+ connection(name: string, context: ResolverContext): Promise<Connection>;
6
+ connections(params: ListParam, context: ResolverContext): Promise<ConnectionList>;
7
+ fetchConnectionState(name: string, context: ResolverContext): ConnectionState;
8
+ edge(connection: Connection): Promise<Appliance>;
9
+ domain(connection: Connection): Promise<Domain>;
10
+ updater(connection: Connection): Promise<User>;
11
+ creator(connection: Connection): Promise<User>;
12
+ }
@@ -49,6 +49,7 @@ let ConnectionQuery = class ConnectionQuery {
49
49
  return connection.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.creatorId }));
50
50
  }
51
51
  };
52
+ exports.ConnectionQuery = ConnectionQuery;
52
53
  tslib_1.__decorate([
53
54
  (0, type_graphql_1.Query)(returns => connection_type_1.Connection, { description: 'To fetch a connection' }),
54
55
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
@@ -101,8 +102,7 @@ tslib_1.__decorate([
101
102
  tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
102
103
  tslib_1.__metadata("design:returntype", Promise)
103
104
  ], ConnectionQuery.prototype, "creator", null);
104
- ConnectionQuery = tslib_1.__decorate([
105
+ exports.ConnectionQuery = ConnectionQuery = tslib_1.__decorate([
105
106
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
106
107
  ], ConnectionQuery);
107
- exports.ConnectionQuery = ConnectionQuery;
108
108
  //# sourceMappingURL=connection-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","source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AAI,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;AAnEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAoE3B;AApEY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : 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) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAG1F,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,kCAAgB,CAAC,SAAS,CAAC,CAAC,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;;6CAAjB,iBAAS;;kDAkB1C;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;IAClB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;2CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;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;0BAnEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAoE3B","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : 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) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Log } from '@things-factory/shell';
2
+ import { ConnectionState } from './connection-type';
3
+ export declare class ConnectionSubscription {
4
+ connectionState(payload: {
5
+ connectionState: ConnectionState;
6
+ }, name: string): ConnectionState;
7
+ connectionLog(payload: {
8
+ log: Log;
9
+ }, level: string): Log;
10
+ }
@@ -16,6 +16,7 @@ let ConnectionSubscription = class ConnectionSubscription {
16
16
  return payload.log;
17
17
  }
18
18
  };
19
+ exports.ConnectionSubscription = ConnectionSubscription;
19
20
  tslib_1.__decorate([
20
21
  (0, type_graphql_1.Subscription)({
21
22
  subscribe: ({ args, context, info }) => {
@@ -91,8 +92,7 @@ tslib_1.__decorate([
91
92
  tslib_1.__metadata("design:paramtypes", [Object, String]),
92
93
  tslib_1.__metadata("design:returntype", shell_1.Log)
93
94
  ], ConnectionSubscription.prototype, "connectionLog", null);
94
- ConnectionSubscription = tslib_1.__decorate([
95
+ exports.ConnectionSubscription = ConnectionSubscription = tslib_1.__decorate([
95
96
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
96
97
  ], ConnectionSubscription);
97
- exports.ConnectionSubscription = ConnectionSubscription;
98
98
  //# sourceMappingURL=connection-subscription.js.map