@things-factory/integration-base 7.0.0-alpha.0 → 7.0.0-alpha.18

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 (202) hide show
  1. package/dist-server/controllers/index.js +5 -0
  2. package/dist-server/controllers/index.js.map +1 -0
  3. package/dist-server/controllers/scenario-controller.js +87 -0
  4. package/dist-server/controllers/scenario-controller.js.map +1 -0
  5. package/dist-server/engine/connection-manager.js +37 -6
  6. package/dist-server/engine/connection-manager.js.map +1 -1
  7. package/dist-server/engine/connector/echo-back-connector.js +1 -1
  8. package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
  9. package/dist-server/engine/connector/echo-back-server.js +1 -1
  10. package/dist-server/engine/connector/echo-back-server.js.map +1 -1
  11. package/dist-server/engine/connector/graphql-connector.js +6 -6
  12. package/dist-server/engine/connector/graphql-connector.js.map +1 -1
  13. package/dist-server/engine/connector/http-connector.js.map +1 -1
  14. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  15. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  16. package/dist-server/engine/connector/mysql-connector.js +3 -3
  17. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  18. package/dist-server/engine/connector/operato-connector.js +19 -22
  19. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  20. package/dist-server/engine/connector/oracle-connector.js +113 -17
  21. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  22. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  23. package/dist-server/engine/connector/proxy-connector.js +44 -0
  24. package/dist-server/engine/connector/proxy-connector.js.map +1 -0
  25. package/dist-server/engine/connector/socket-server.js +1 -1
  26. package/dist-server/engine/connector/socket-server.js.map +1 -1
  27. package/dist-server/engine/connector/sqlite-connector.js.map +1 -1
  28. package/dist-server/engine/edge-client.js +38 -0
  29. package/dist-server/engine/edge-client.js.map +1 -0
  30. package/dist-server/engine/index.js +1 -0
  31. package/dist-server/engine/index.js.map +1 -1
  32. package/dist-server/engine/task/book-up-scenario.js.map +1 -1
  33. package/dist-server/engine/task/csv-readline.js.map +1 -1
  34. package/dist-server/engine/task/data-accessor.js.map +1 -1
  35. package/dist-server/engine/task/data-mapper.js.map +1 -1
  36. package/dist-server/engine/task/database-query.js.map +1 -1
  37. package/dist-server/engine/task/echo-receive.js.map +1 -1
  38. package/dist-server/engine/task/echo-send.js.map +1 -1
  39. package/dist-server/engine/task/empty-check.js.map +1 -1
  40. package/dist-server/engine/task/end.js.map +1 -1
  41. package/dist-server/engine/task/floating-point.js.map +1 -1
  42. package/dist-server/engine/task/goto.js.map +1 -1
  43. package/dist-server/engine/task/graphql-mutate.js.map +1 -1
  44. package/dist-server/engine/task/graphql-query.js.map +1 -1
  45. package/dist-server/engine/task/headless-post.js.map +1 -1
  46. package/dist-server/engine/task/headless-scrap.js.map +1 -1
  47. package/dist-server/engine/task/http-get.js.map +1 -1
  48. package/dist-server/engine/task/http-post.js.map +1 -1
  49. package/dist-server/engine/task/jsonata.js +1 -1
  50. package/dist-server/engine/task/jsonata.js.map +1 -1
  51. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  52. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  53. package/dist-server/engine/task/log.js.map +1 -1
  54. package/dist-server/engine/task/mqtt-publish.js.map +1 -1
  55. package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
  56. package/dist-server/engine/task/oracle-procedure.js +1 -15
  57. package/dist-server/engine/task/oracle-procedure.js.map +1 -1
  58. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  59. package/dist-server/engine/task/publish.js.map +1 -1
  60. package/dist-server/engine/task/random.js.map +1 -1
  61. package/dist-server/engine/task/reset-pending-queue.js.map +1 -1
  62. package/dist-server/engine/task/script.js +1 -0
  63. package/dist-server/engine/task/script.js.map +1 -1
  64. package/dist-server/engine/task/set-domain.js.map +1 -1
  65. package/dist-server/engine/task/sleep.js.map +1 -1
  66. package/dist-server/engine/task/socket-listener.js.map +1 -1
  67. package/dist-server/engine/task/state-read.js.map +1 -1
  68. package/dist-server/engine/task/state-write.js.map +1 -1
  69. package/dist-server/engine/task/stop-scenario.js.map +1 -1
  70. package/dist-server/engine/task/sub-scenario.js.map +1 -1
  71. package/dist-server/engine/task/switch-goto.js.map +1 -1
  72. package/dist-server/engine/task/switch-range-goto.js.map +1 -1
  73. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  74. package/dist-server/engine/task/switch-range-set.js.map +1 -1
  75. package/dist-server/engine/task/switch-scenario.js.map +1 -1
  76. package/dist-server/engine/task/switch-set.js.map +1 -1
  77. package/dist-server/engine/task/throw.js.map +1 -1
  78. package/dist-server/engine/task/utils/headless-pool-for-scenario.js +1 -1
  79. package/dist-server/engine/task/utils/headless-pool-for-scenario.js.map +1 -1
  80. package/dist-server/engine/task/variables.js.map +1 -1
  81. package/dist-server/engine/types.js.map +1 -1
  82. package/dist-server/index.js +1 -0
  83. package/dist-server/index.js.map +1 -1
  84. package/dist-server/restful/unstable/run-scenario.js.map +1 -1
  85. package/dist-server/restful/unstable/start-scenario.js +1 -1
  86. package/dist-server/restful/unstable/start-scenario.js.map +1 -1
  87. package/dist-server/restful/unstable/stop-scenario.js +1 -1
  88. package/dist-server/restful/unstable/stop-scenario.js.map +1 -1
  89. package/dist-server/service/connection/connection-mutation.js +4 -8
  90. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  91. package/dist-server/service/connection/connection-query.js +17 -14
  92. package/dist-server/service/connection/connection-query.js.map +1 -1
  93. package/dist-server/service/connection/connection-subscription.js +11 -14
  94. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  95. package/dist-server/service/connection/connection-type.js +66 -13
  96. package/dist-server/service/connection/connection-type.js.map +1 -1
  97. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +4 -71
  98. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  99. package/dist-server/service/scenario-instance/scenario-instance-subscription.js +8 -9
  100. package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
  101. package/dist-server/service/scenario-instance/scenario-instance-type.js +18 -5
  102. package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
  103. package/dist-server/service/scenario-queue/scenario-queue-subscription.js +4 -4
  104. package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
  105. package/dist-server/service/step/step-type.js +41 -28
  106. package/dist-server/service/step/step-type.js.map +1 -1
  107. package/dist-server/tsconfig.tsbuildinfo +1 -1
  108. package/helps/integration/concept/script-internal-variables.ja.md +21 -1
  109. package/helps/integration/concept/script-internal-variables.ko.md +17 -0
  110. package/helps/integration/concept/script-internal-variables.md +18 -0
  111. package/helps/integration/concept/script-internal-variables.ms.md +19 -1
  112. package/helps/integration/concept/script-internal-variables.zh.md +18 -0
  113. package/helps/integration/connector/oracle-connector.ja.md +90 -0
  114. package/helps/integration/connector/oracle-connector.ko.md +87 -0
  115. package/helps/integration/connector/oracle-connector.md +46 -25
  116. package/helps/integration/connector/oracle-connector.ms.md +87 -0
  117. package/helps/integration/connector/oracle-connector.zh.md +87 -0
  118. package/helps/integration/task/script.ja.md +1 -1
  119. package/helps/integration/task/script.ko.md +1 -1
  120. package/helps/integration/task/script.md +1 -1
  121. package/helps/integration/task/script.ms.md +1 -1
  122. package/helps/integration/task/script.zh.md +1 -1
  123. package/openapi/unstable/scenario.yaml +100 -100
  124. package/openapi/unstable.yaml +11 -11
  125. package/package.json +8 -11
  126. package/server/controllers/index.ts +1 -0
  127. package/server/controllers/scenario-controller.ts +116 -0
  128. package/server/engine/connection-manager.ts +49 -7
  129. package/server/engine/connector/echo-back-connector.ts +4 -3
  130. package/server/engine/connector/echo-back-server.ts +5 -4
  131. package/server/engine/connector/graphql-connector.ts +12 -13
  132. package/server/engine/connector/http-connector.ts +4 -3
  133. package/server/engine/connector/mqtt-connector.ts +4 -3
  134. package/server/engine/connector/mssql-connector.ts +4 -3
  135. package/server/engine/connector/mysql-connector.ts +8 -6
  136. package/server/engine/connector/operato-connector.ts +27 -35
  137. package/server/engine/connector/oracle-connector.ts +136 -23
  138. package/server/engine/connector/postgresql-connector.ts +4 -3
  139. package/server/engine/connector/proxy-connector.ts +53 -0
  140. package/server/engine/connector/socket-server.ts +5 -4
  141. package/server/engine/connector/sqlite-connector.ts +5 -3
  142. package/server/engine/edge-client.ts +45 -0
  143. package/server/engine/index.ts +1 -0
  144. package/server/engine/task/book-up-scenario.ts +3 -1
  145. package/server/engine/task/csv-readline.ts +4 -1
  146. package/server/engine/task/data-accessor.ts +4 -1
  147. package/server/engine/task/data-mapper.ts +4 -1
  148. package/server/engine/task/database-query.ts +3 -1
  149. package/server/engine/task/echo-receive.ts +4 -1
  150. package/server/engine/task/echo-send.ts +3 -1
  151. package/server/engine/task/empty-check.ts +4 -1
  152. package/server/engine/task/end.ts +4 -1
  153. package/server/engine/task/floating-point.ts +4 -1
  154. package/server/engine/task/goto.ts +4 -1
  155. package/server/engine/task/graphql-mutate.ts +3 -1
  156. package/server/engine/task/graphql-query.ts +3 -1
  157. package/server/engine/task/headless-post.ts +4 -1
  158. package/server/engine/task/headless-scrap.ts +3 -1
  159. package/server/engine/task/http-get.ts +3 -1
  160. package/server/engine/task/http-post.ts +3 -1
  161. package/server/engine/task/jsonata.ts +5 -2
  162. package/server/engine/task/local-graphql-mutate.ts +5 -1
  163. package/server/engine/task/local-graphql-query.ts +3 -1
  164. package/server/engine/task/log.ts +3 -1
  165. package/server/engine/task/mqtt-publish.ts +3 -1
  166. package/server/engine/task/mqtt-subscribe.ts +3 -1
  167. package/server/engine/task/oracle-procedure.ts +4 -17
  168. package/server/engine/task/pick-pending-scenario.ts +3 -1
  169. package/server/engine/task/publish.ts +3 -1
  170. package/server/engine/task/random.ts +4 -1
  171. package/server/engine/task/reset-pending-queue.ts +3 -1
  172. package/server/engine/task/script.ts +5 -1
  173. package/server/engine/task/set-domain.ts +4 -1
  174. package/server/engine/task/sleep.ts +3 -1
  175. package/server/engine/task/socket-listener.ts +3 -1
  176. package/server/engine/task/state-read.ts +3 -1
  177. package/server/engine/task/state-write.ts +3 -1
  178. package/server/engine/task/stop-scenario.ts +3 -1
  179. package/server/engine/task/sub-scenario.ts +3 -1
  180. package/server/engine/task/switch-goto.ts +4 -1
  181. package/server/engine/task/switch-range-goto.ts +3 -1
  182. package/server/engine/task/switch-range-scenario.ts +3 -1
  183. package/server/engine/task/switch-range-set.ts +3 -1
  184. package/server/engine/task/switch-scenario.ts +3 -1
  185. package/server/engine/task/switch-set.ts +3 -1
  186. package/server/engine/task/throw.ts +3 -1
  187. package/server/engine/task/utils/headless-pool-for-scenario.ts +1 -1
  188. package/server/engine/task/variables.ts +3 -1
  189. package/server/engine/types.ts +80 -4
  190. package/server/index.ts +1 -0
  191. package/server/restful/unstable/run-scenario.ts +0 -1
  192. package/server/restful/unstable/start-scenario.ts +1 -1
  193. package/server/restful/unstable/stop-scenario.ts +1 -1
  194. package/server/service/connection/connection-mutation.ts +9 -29
  195. package/server/service/connection/connection-query.ts +13 -12
  196. package/server/service/connection/connection-subscription.ts +18 -24
  197. package/server/service/connection/connection-type.ts +100 -21
  198. package/server/service/scenario-instance/scenario-instance-mutation.ts +10 -121
  199. package/server/service/scenario-instance/scenario-instance-subscription.ts +16 -23
  200. package/server/service/scenario-instance/scenario-instance-type.ts +24 -13
  201. package/server/service/scenario-queue/scenario-queue-subscription.ts +7 -7
  202. package/server/service/step/step-type.ts +78 -22
@@ -0,0 +1,53 @@
1
+ import { ConnectionManager } from '../connection-manager'
2
+ import { Connector } from '../types'
3
+ import { InputConnection } from '../../service/connection/connection-type'
4
+ import { connectConnections, disconnectConnections } from '../edge-client'
5
+
6
+ /**
7
+ * This connector is a proxy connector installed on the edge server to manage connections from the host.
8
+ * It interacts with connections established on the edge server and provides synchronization functionality.
9
+ */
10
+ export class ProxyConnector implements Connector {
11
+ public static instance = new ProxyConnector()
12
+
13
+ async ready(connectionConfigs: InputConnection[]) {
14
+ await Promise.all(connectionConfigs.map(this.connect.bind(this)))
15
+
16
+ ConnectionManager.logger.info('proxy-connector connections are ready')
17
+ }
18
+
19
+ async connect(connection: InputConnection) {
20
+ // TODO 원래 커넥션과 에지설정을 참고하여, 에지 서버로 CONNECT/DISCONNECT 명령을 보낸다.
21
+ const proxy = {
22
+ disconnect: async () => {
23
+ ConnectionManager.logger.info('[proxy-connector] trying disconnect')
24
+ await disconnectConnections([connection])
25
+ }
26
+ }
27
+
28
+ await connectConnections([connection])
29
+
30
+ ConnectionManager.addConnectionInstance(connection, proxy)
31
+
32
+ ConnectionManager.logger.info(`proxy-connector connection(${connection.name}:${connection.endpoint}) is connected`)
33
+ }
34
+
35
+ async disconnect(connection: InputConnection) {
36
+ const proxy = ConnectionManager.removeConnectionInstance(connection)
37
+ await proxy.disconnect()
38
+
39
+ ConnectionManager.logger.info(`proxy-connector connection(${connection.name}) is disconnected`)
40
+ }
41
+
42
+ get parameterSpec() {
43
+ return []
44
+ }
45
+
46
+ get taskPrefixes() {
47
+ return []
48
+ }
49
+
50
+ get description() {
51
+ return 'Operato Proxy Connector'
52
+ }
53
+ }
@@ -1,18 +1,19 @@
1
1
  import net from 'net'
2
+ import { EventEmitter } from 'events'
2
3
 
3
4
  import { Connector } from '../types'
4
5
  import { ConnectionManager } from '../connection-manager'
5
- import { EventEmitter } from 'events'
6
+ import { InputConnection } from '../../service/connection/connection-type'
6
7
 
7
8
  export class SocketServer implements Connector {
8
9
  // socket: any
9
10
 
10
- async ready(connectionConfigs) {
11
+ async ready(connectionConfigs: InputConnection[]) {
11
12
  await Promise.all(connectionConfigs.map(this.connect))
12
13
  ConnectionManager.logger.info('socket servers are ready')
13
14
  }
14
15
 
15
- async connect(config): Promise<void> {
16
+ async connect(config: InputConnection): Promise<void> {
16
17
  var em = new EventEmitter()
17
18
  var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')
18
19
  return new Promise((resolve, reject) => {
@@ -62,7 +63,7 @@ export class SocketServer implements Connector {
62
63
  })
63
64
  }
64
65
 
65
- async disconnect(connection) {
66
+ async disconnect(connection: InputConnection) {
66
67
  let em = ConnectionManager.removeConnectionInstance(connection)
67
68
  var tcp = em['__tcp__']
68
69
  var server = em['__server__']
@@ -4,6 +4,8 @@ import { logger } from '@things-factory/env'
4
4
 
5
5
  import { ConnectionManager } from '../connection-manager'
6
6
  import { Connector } from '../types'
7
+ import { InputConnection } from '../../service/connection/connection-type'
8
+
7
9
 
8
10
  try {
9
11
  var sqlite3 = require('sqlite3').verbose()
@@ -12,13 +14,13 @@ try {
12
14
  }
13
15
 
14
16
  export class SqliteConnector implements Connector {
15
- async ready(connectionConfigs) {
17
+ async ready(connectionConfigs: InputConnection[]) {
16
18
  await Promise.all(connectionConfigs.map(this.connect.bind(this)))
17
19
 
18
20
  ConnectionManager.logger.info('sqlite-connector connections are ready')
19
21
  }
20
22
 
21
- async connect(connection) {
23
+ async connect(connection: InputConnection) {
22
24
  var { endpoint } = connection
23
25
 
24
26
  if (!sqlite3) {
@@ -42,7 +44,7 @@ export class SqliteConnector implements Connector {
42
44
  })
43
45
  }
44
46
 
45
- async disconnect(connection) {
47
+ async disconnect(connection: InputConnection) {
46
48
  var database = ConnectionManager.getConnectionInstance(connection)
47
49
  try {
48
50
  await database.close()
@@ -0,0 +1,45 @@
1
+ import { Connection } from '../service/connection/connection-type'
2
+ import { Step } from '../service/step/step-type'
3
+ import { Context, TaskHandler } from './types'
4
+
5
+ export type EdgeClient = {
6
+ handler: TaskHandler
7
+ syncConnections(connections: Connection[], context?: ResolverContext): Promise<any>
8
+ connectConnections(connections: Connection[], context?: ResolverContext): Promise<any>
9
+ disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any>
10
+ }
11
+
12
+ var edgeClient: EdgeClient = {
13
+ async handler(step: Step, scenarioContext: Context) {
14
+ throw 'edgeClient not supported'
15
+ },
16
+ async syncConnections(connections: Connection[], context: ResolverContext): Promise<any> {
17
+ throw 'edgeClient not supported'
18
+ },
19
+ async connectConnections(connections: Connection[], context: ResolverContext): Promise<any> {
20
+ throw 'edgeClient not supported'
21
+ },
22
+ async disconnectConnections(connections: Connection[], context: ResolverContext): Promise<any> {
23
+ throw 'edgeClient not supported'
24
+ }
25
+ }
26
+
27
+ export async function handler(step: Step, scenarioContext: Context) {
28
+ return await edgeClient.handler(step, scenarioContext)
29
+ }
30
+
31
+ export async function syncConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
32
+ return await edgeClient.syncConnections(connections, context)
33
+ }
34
+
35
+ export async function connectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
36
+ return await edgeClient.connectConnections(connections, context)
37
+ }
38
+
39
+ export async function disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
40
+ return await edgeClient.disconnectConnections(connections, context)
41
+ }
42
+
43
+ export function setEdgeClient(edge: EdgeClient) {
44
+ edgeClient = edge
45
+ }
@@ -5,5 +5,6 @@ export * from './connection-manager'
5
5
  export * from './scenario-engine'
6
6
  export * from './task-registry'
7
7
  export * from './analyzer/analyze-integration'
8
+ export * from './edge-client'
8
9
 
9
10
  export { Connector } from './types'
@@ -2,10 +2,12 @@ import { access, deepClone } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
3
  import { substitute } from './utils/substitute'
4
4
  import { ScenarioEngine } from '../scenario-engine'
5
+ import { InputStep } from '../../service/step/step-type'
6
+ import { Context } from '../types'
5
7
 
6
8
  const debug = require('debug')('things-factory:integration-base:book-up-scenarios')
7
9
 
8
- async function BookUpScenario(step, { logger, data, domain }) {
10
+ async function BookUpScenario(step: InputStep, { logger, data, domain }: Context) {
9
11
  var {
10
12
  params: { scenario, delay, priority, variables, tag }
11
13
  } = step
@@ -6,6 +6,9 @@ const { Readable } = require('stream')
6
6
 
7
7
  import { TaskRegistry } from '../task-registry'
8
8
 
9
+ import { InputStep } from '../../service/step/step-type'
10
+ import { Context } from '../types'
11
+
9
12
  async function createReadStream(source) {
10
13
  let stream
11
14
 
@@ -37,7 +40,7 @@ async function createReadStream(source) {
37
40
  return stream
38
41
  }
39
42
 
40
- async function CsvReadline(step, context) {
43
+ async function CsvReadline(step: InputStep, context: Context) {
41
44
  var {
42
45
  params: { path }
43
46
  } = step
@@ -1,7 +1,10 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
3
 
4
- async function DataAccessor(step, { logger, data }) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function DataAccessor(step: InputStep, { logger, data }: Context) {
5
8
  var {
6
9
  params: { target, accessor }
7
10
  } = step
@@ -1,6 +1,9 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
3
 
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
4
7
  function mapping(rule, input) {
5
8
  if (Array.isArray(input)) {
6
9
  return input.map(i => mapping(rule, i))
@@ -12,7 +15,7 @@ function mapping(rule, input) {
12
15
  }, {} as any)
13
16
  }
14
17
 
15
- async function DataMapper(step, { logger, data }) {
18
+ async function DataMapper(step: InputStep, { logger, data }: Context) {
16
19
  var {
17
20
  params: { accessor, mappingRule }
18
21
  } = step
@@ -1,8 +1,10 @@
1
1
  import { VM } from 'vm2'
2
2
  import { ConnectionManager } from '../connection-manager'
3
3
  import { TaskRegistry } from '../task-registry'
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
4
6
 
5
- async function DatabaseQuery(step, context) {
7
+ async function DatabaseQuery(step: InputStep, context: Context) {
6
8
  var { domain, user, data, variables, lng } = context
7
9
  var {
8
10
  connection: connectionName,
@@ -1,7 +1,10 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { ConnectionManager } from '../connection-manager'
3
3
 
4
- async function EchoReceive(step, { logger, domain }) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function EchoReceive(step: InputStep, { logger, domain }: Context) {
5
8
  var { connection: connectionName } = step
6
9
 
7
10
  var connection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
@@ -1,7 +1,9 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { ConnectionManager } from '../connection-manager'
3
+ import { InputStep } from '../../service/step/step-type'
4
+ import { Context } from '../types'
3
5
 
4
- async function EchoSend(step, { logger, domain }) {
6
+ async function EchoSend(step: InputStep, { logger, domain }: Context) {
5
7
  var {
6
8
  connection: connectionName,
7
9
  params: { message }
@@ -1,7 +1,10 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { access } from '@things-factory/utils'
3
3
 
4
- async function EmptyCheck(step, { logger, data }) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function EmptyCheck(step: InputStep, { logger, data }: Context) {
5
8
  var {
6
9
  params: { accessor, goto }
7
10
  } = step
@@ -1,7 +1,10 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { ScenarioInstanceStatus } from '../../service'
3
3
 
4
- async function End(step, { logger }) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function End(step: InputStep, { logger }: Context) {
5
8
  return {
6
9
  state: ScenarioInstanceStatus.STOPPED
7
10
  }
@@ -2,7 +2,10 @@ import ieee754 from 'ieee754'
2
2
  import { access } from '@things-factory/utils'
3
3
  import { TaskRegistry } from '../task-registry'
4
4
 
5
- async function FloatingPoint(step, { logger, data }) {
5
+ import { InputStep } from '../../service/step/step-type'
6
+ import { Context } from '../types'
7
+
8
+ async function FloatingPoint(step: InputStep, { logger, data }: Context) {
6
9
  var {
7
10
  params: { accessor, operation, endian, floatType }
8
11
  } = step
@@ -1,6 +1,9 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
 
3
- async function Goto(step, { logger }) {
3
+ import { InputStep } from '../../service/step/step-type'
4
+ import { Context } from '../types'
5
+
6
+ async function Goto(step: InputStep, { logger }: Context) {
4
7
  var {
5
8
  params: { goto }
6
9
  } = step
@@ -5,8 +5,10 @@ import { access } from '@things-factory/utils'
5
5
 
6
6
  import { ConnectionManager } from '../connection-manager'
7
7
  import { TaskRegistry } from '../task-registry'
8
+ import { InputStep } from '../../service/step/step-type'
9
+ import { Context } from '../types'
8
10
 
9
- async function GraphqlMutate(step, context) {
11
+ async function GraphqlMutate(step: InputStep, context: Context) {
10
12
  var { connection: connectionName, params: stepOptions } = step
11
13
  var { mutation, variables: variablesAccessorMap, headers } = stepOptions || {}
12
14
 
@@ -5,8 +5,10 @@ import { access } from '@things-factory/utils'
5
5
 
6
6
  import { ConnectionManager } from '../connection-manager'
7
7
  import { TaskRegistry } from '../task-registry'
8
+ import { InputStep } from '../../service/step/step-type'
9
+ import { Context } from '../types'
8
10
 
9
- async function GraphqlQuery(step, context) {
11
+ async function GraphqlQuery(step: InputStep, context: Context) {
10
12
  var { connection: connectionName, params: stepOptions } = step
11
13
  var { query, variables: variablesAccessorMap, headers } = stepOptions || {}
12
14
  var { domain, user, data, variables, lng } = context
@@ -7,7 +7,10 @@ import { ConnectionManager } from '../connection-manager'
7
7
 
8
8
  import { getHeadlessPool } from './utils/headless-pool-for-scenario'
9
9
 
10
- async function HeadlessPost(step, { logger, data, domain }) {
10
+ import { InputStep } from '../../service/step/step-type'
11
+ import { Context } from '../types'
12
+
13
+ async function HeadlessPost(step: InputStep, { logger, data, domain }: Context) {
11
14
  var { connection: connectionName, params: stepOptions } = step
12
15
  var { headers: requestHeaders, contentType, path, accessor } = stepOptions || {}
13
16
 
@@ -4,8 +4,10 @@ import { TaskRegistry } from '../task-registry'
4
4
  import { ConnectionManager } from '../connection-manager'
5
5
 
6
6
  import { getHeadlessPool } from './utils/headless-pool-for-scenario'
7
+ import { InputStep } from '../../service/step/step-type'
8
+ import { Context } from '../types'
7
9
 
8
- async function HeadlessScrap(step, { logger, data, domain }) {
10
+ async function HeadlessScrap(step: InputStep, { logger, data, domain }: Context) {
9
11
  var { connection: connectionName, params: stepOptions } = step
10
12
  var { headers: requestHeaders, path, selectors = [] } = stepOptions || {}
11
13
 
@@ -5,8 +5,10 @@ import https from 'https'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
  import { ConnectionManager } from '../connection-manager'
7
7
  import { substitute } from './utils/substitute'
8
+ import { InputStep } from '../../service/step/step-type'
9
+ import { Context } from '../types'
8
10
 
9
- async function HttpGet(step, { logger, data, domain, user, variables, lng }) {
11
+ async function HttpGet(step: InputStep, { logger, data, domain, user, variables, lng }: Context) {
10
12
  var { connection: connectionName, params: stepOptions } = step
11
13
  var { headers: requestHeaders, searchParams = {}, path } = stepOptions || {}
12
14
  var connection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
@@ -5,8 +5,10 @@ import { access } from '@things-factory/utils'
5
5
  import { TaskRegistry } from '../task-registry'
6
6
  import { ConnectionManager } from '../connection-manager'
7
7
  import https from 'https'
8
+ import { InputStep } from '../../service/step/step-type'
9
+ import { Context } from '../types'
8
10
 
9
- async function HttpPost(step, { logger, data, domain, user, variables, lng }) {
11
+ async function HttpPost(step: InputStep, { logger, data, domain, user, variables, lng }: Context) {
10
12
  var { connection: connectionName, params: stepOptions } = step
11
13
  var { headers: requestHeaders, contentType, path, accessor } = stepOptions || {}
12
14
 
@@ -1,7 +1,10 @@
1
- import { TaskRegistry } from '../task-registry'
2
1
  import jsonata from 'jsonata'
3
2
 
4
- async function JSonata(step, context) {
3
+ import { TaskRegistry } from '../task-registry'
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function JSonata(step: InputStep, context: Context) {
5
8
  var {
6
9
  params: { expression }
7
10
  } = step
@@ -6,8 +6,12 @@ import { getRepository } from '@things-factory/shell'
6
6
  import { access } from '@things-factory/utils'
7
7
 
8
8
  import { TaskRegistry } from '../task-registry'
9
+ import { InputStep } from '../../service/step/step-type'
10
+ import { Context } from '../types'
9
11
 
10
- async function LocalGraphqlMutate(step, context) {
12
+
13
+
14
+ async function LocalGraphqlMutate(step: InputStep, context: Context) {
11
15
  var { params, updaterId } = step
12
16
  var { mutation, variables: variablesAccessorMap, headers } = params || {}
13
17
  var { logger, client, domain, user, data, variables, lng } = context
@@ -6,8 +6,10 @@ import { getRepository } from '@things-factory/shell'
6
6
  import { access } from '@things-factory/utils'
7
7
 
8
8
  import { TaskRegistry } from '../task-registry'
9
+ import { InputStep } from '../../service/step/step-type'
10
+ import { Context } from '../types'
9
11
 
10
- async function LocalGraphqlQuery(step, context) {
12
+ async function LocalGraphqlQuery(step: InputStep, context: Context) {
11
13
  var { params, updaterId } = step
12
14
  var { query, variables: variablesAccessorMap, headers } = params || {}
13
15
  var { logger, client, domain, user, data, variables, lng } = context
@@ -1,8 +1,10 @@
1
1
  import { access, hasTemplateExpression } from '@things-factory/utils'
2
2
  import { VM } from 'vm2'
3
3
  import { TaskRegistry } from '../task-registry'
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
4
6
 
5
- async function Log(step, { logger, data, variables, domain, user, lng }) {
7
+ async function Log(step: InputStep, { logger, data, variables, domain, user, lng }: Context) {
6
8
  var {
7
9
  params: { message, accessor, level = 'info' }
8
10
  } = step
@@ -1,8 +1,10 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
3
  import { ConnectionManager } from '../connection-manager'
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
4
6
 
5
- async function MqttPublish(step, { logger, data, domain }) {
7
+ async function MqttPublish(step: InputStep, { logger, data, domain }: Context) {
6
8
  var {
7
9
  connection: connectionName,
8
10
  params: { topic, accessor }
@@ -3,6 +3,8 @@ import mqtt from 'async-mqtt'
3
3
  import { TaskRegistry } from '../task-registry'
4
4
  import { ConnectionManager } from '../connection-manager'
5
5
  import { sleep } from '@things-factory/utils'
6
+ import { InputStep } from '../../service/step/step-type'
7
+ import { Context } from '../types'
6
8
 
7
9
  function convertDataFormat(data, format) {
8
10
  if (format == 'json') {
@@ -12,7 +14,7 @@ function convertDataFormat(data, format) {
12
14
  }
13
15
  }
14
16
 
15
- async function MqttSubscribe(step, context) {
17
+ async function MqttSubscribe(step: InputStep, context: Context) {
16
18
  const {
17
19
  connection: connectionName,
18
20
  params: { topic, dataFormat },
@@ -3,6 +3,8 @@ import { logger } from '@things-factory/env'
3
3
  import { access } from '@things-factory/utils'
4
4
  import { ConnectionManager } from '../connection-manager'
5
5
  import { TaskRegistry } from '../task-registry'
6
+ import { InputStep } from '../../service/step/step-type'
7
+ import { Context } from '../types'
6
8
 
7
9
  try {
8
10
  var oracledb = require('oracledb')
@@ -41,7 +43,7 @@ const DIR = {
41
43
  Out: oracledb?.BIND_OUT
42
44
  }
43
45
 
44
- async function OracleProcedure(step, context) {
46
+ async function OracleProcedure(step: InputStep, context: Context) {
45
47
  var { domain, user, data, variables, lng } = context
46
48
  var { connection: connectionName, params } = step
47
49
 
@@ -95,23 +97,8 @@ async function OracleProcedure(step, context) {
95
97
 
96
98
  const result = await dbconnection.execute(code, procedureParameters)
97
99
 
98
- var taskResult = {}
99
- let paramKeys = Object.keys(procedureParameters)
100
-
101
- for (const paramKey of paramKeys) {
102
- if (procedureParameters[paramKey].dir === oracledb?.BIND_OUT) {
103
- if (procedureParameters[paramKey].type === oracledb?.CURSOR) {
104
- const resultSetTemp = result.outBinds[paramKey]
105
- taskResult[paramKey] = await resultSetTemp.getRows()
106
- await resultSetTemp.close()
107
- } else {
108
- taskResult[paramKey] = result.outBinds[paramKey]
109
- }
110
- }
111
- }
112
-
113
100
  return {
114
- data: taskResult
101
+ data: result
115
102
  }
116
103
  }
117
104
 
@@ -4,10 +4,12 @@ import { sleep } from '@things-factory/utils'
4
4
  import { Scenario } from '../../service/scenario/scenario'
5
5
  import { ScenarioEngine } from '../scenario-engine'
6
6
  import { TaskRegistry } from '../task-registry'
7
+ import { InputStep } from '../../service/step/step-type'
8
+ import { Context } from '../types'
7
9
 
8
10
  const debug = require('debug')('things-factory:integration-base:pick-pending-scenario')
9
11
 
10
- async function PickPendingScenario(step, context) {
12
+ async function PickPendingScenario(step: InputStep, context: Context) {
11
13
  var { logger, load, domain } = context
12
14
  var { params } = step
13
15
  var { tag = '', waitFor = -1 } = params || {}
@@ -1,7 +1,9 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
+ import { InputStep } from '../../service/step/step-type'
4
+ import { Context } from '../types'
3
5
 
4
- async function Publish(step, { logger, publish, data }) {
6
+ async function Publish(step: InputStep, { logger, publish, data }: Context) {
5
7
  var {
6
8
  params: { tag, accessor }
7
9
  } = step
@@ -1,6 +1,9 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import Chance from 'chance'
3
3
 
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
4
7
  const formats = [
5
8
  'bool,character,floating,integer,letter,natural,string',
6
9
  'paragraph,sentence,syllable,word',
@@ -15,7 +18,7 @@ const formats = [
15
18
  .join(',')
16
19
  .split(',')
17
20
 
18
- async function Random(step, { logger, publish, data }) {
21
+ async function Random(step: InputStep, { logger, publish, data }: Context) {
19
22
  var {
20
23
  params: { format = 'integer', count = 1 }
21
24
  } = step
@@ -1,7 +1,9 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { ScenarioEngine } from '../scenario-engine'
3
+ import { InputStep } from '../../service/step/step-type'
4
+ import { Context } from '../types'
3
5
 
4
- async function ResetPendingScenario(step, { domain }) {
6
+ async function ResetPendingScenario(step: InputStep, { domain }: Context) {
5
7
  const pendingQueue = ScenarioEngine.getPendingQueue(domain)
6
8
  pendingQueue.reset()
7
9
 
@@ -1,7 +1,10 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { NodeVM } from 'vm2'
3
3
 
4
- async function Script(step, context) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function Script(step: InputStep, context: Context) {
5
8
  var {
6
9
  params: { script }
7
10
  } = step
@@ -16,6 +19,7 @@ async function Script(step, context) {
16
19
  domain,
17
20
  user,
18
21
  lng,
22
+ logger,
19
23
  data,
20
24
  variables
21
25
  }
@@ -1,7 +1,10 @@
1
1
  import { TaskRegistry } from '../task-registry'
2
2
  import { Domain, getRepository } from '@things-factory/shell'
3
3
 
4
- async function SetDomain(step, context) {
4
+ import { InputStep } from '../../service/step/step-type'
5
+ import { Context } from '../types'
6
+
7
+ async function SetDomain(step: InputStep, context: Context) {
5
8
  var {
6
9
  params: { subdomain }
7
10
  } = step
@@ -1,7 +1,9 @@
1
1
  import { sleep } from '@things-factory/utils'
2
2
  import { TaskRegistry } from '../task-registry'
3
+ import { InputStep } from '../../service/step/step-type'
4
+ import { Context } from '../types'
3
5
 
4
- async function Sleep(step, { logger }) {
6
+ async function Sleep(step: InputStep, { logger }: Context) {
5
7
  var {
6
8
  params: { duration }
7
9
  } = step