@things-factory/integration-base 6.0.127 → 6.0.141

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "6.0.127",
3
+ "version": "6.0.141",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@apollo/client": "^3.6.9",
29
- "@things-factory/api": "^6.0.125",
30
- "@things-factory/auth-base": "^6.0.125",
29
+ "@things-factory/api": "^6.0.133",
30
+ "@things-factory/auth-base": "^6.0.133",
31
31
  "@things-factory/env": "^6.0.124",
32
- "@things-factory/oauth2-client": "^6.0.125",
33
- "@things-factory/scheduler-client": "^6.0.125",
34
- "@things-factory/shell": "^6.0.125",
32
+ "@things-factory/oauth2-client": "^6.0.133",
33
+ "@things-factory/scheduler-client": "^6.0.133",
34
+ "@things-factory/shell": "^6.0.133",
35
35
  "async-mqtt": "^2.5.0",
36
36
  "chance": "^1.1.11",
37
37
  "cross-fetch": "^3.0.4",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "@types/cron": "^2.0.1"
48
48
  },
49
- "gitHead": "ad9678bc8d579de5907db7970515532a6fb56adf"
49
+ "gitHead": "d9fe5f28cee1bf8f527688e06d190ae78d6e2b04"
50
50
  }
@@ -1,11 +1,12 @@
1
- import { TaskRegistry } from '../task-registry'
2
- import { ConnectionManager } from '../connection-manager'
3
1
  import fetch from 'node-fetch'
2
+ import { VM } from 'vm2'
4
3
  import { URL } from 'url'
5
- import { substitute } from './utils/substitute'
6
4
  import https from 'https'
5
+ import { TaskRegistry } from '../task-registry'
6
+ import { ConnectionManager } from '../connection-manager'
7
+ import { substitute } from './utils/substitute'
7
8
 
8
- async function HttpGet(step, { logger, data, domain }) {
9
+ async function HttpGet(step, { logger, data, domain, variables }) {
9
10
  var { connection: connectionName, params: stepOptions } = step
10
11
  var { headers: requestHeaders, searchParams = {}, path } = stepOptions || {}
11
12
  var connection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
@@ -15,6 +16,17 @@ async function HttpGet(step, { logger, data, domain }) {
15
16
  }
16
17
 
17
18
  var { endpoint, params: connectionParams, authHeaders = {} } = connection
19
+
20
+ const vm = new VM({
21
+ sandbox: {
22
+ domain,
23
+ data,
24
+ variables
25
+ }
26
+ })
27
+
28
+ path = vm.run('`' + path + '`')
29
+
18
30
  var url = new URL(path, endpoint)
19
31
  if (searchParams) {
20
32
  Object.keys(searchParams).forEach(key => {
@@ -19,7 +19,7 @@ async function Script(step, context) {
19
19
  }
20
20
  })
21
21
 
22
- const result = vm.run(script)
22
+ const result = await vm.run(`(async () => {\n${script}\n})()`)
23
23
 
24
24
  return {
25
25
  data: result
@@ -0,0 +1,6 @@
1
+ {
2
+ "error.scenario not found": "シナリオ'{scenario}'が見つかりません.",
3
+ "error.schedule is not set": "スケジュールとして登録するためにはシナリオ'{scenario}'にスケジュール情報が設定される必要があります.",
4
+ "error.timezone is not set": "スケジュールとして登録するためにはシナリオ'{scenario}'にタイム ゾーン情報が設定される必要があります.",
5
+ "error.scenario instance not found": "シナリオ インスタンス'{instance}'が見つかりません. 既に終了している可能性があります."
6
+ }