@things-factory/integration-base 7.0.1-rc.1 → 7.0.1-rc.7
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/dist-server/engine/connection-manager.js +7 -8
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/echo-back-connector.js +1 -1
- package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js +2 -2
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/mqtt-connector.js +1 -1
- package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
- package/dist-server/engine/connector/mssql-connector.js +1 -1
- package/dist-server/engine/connector/mssql-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js +1 -1
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js +1 -1
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/postgresql-connector.js +2 -2
- package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
- package/dist-server/engine/connector/socket-server.js +1 -1
- package/dist-server/engine/connector/socket-server.js.map +1 -1
- package/dist-server/engine/connector/sqlite-connector.js +2 -2
- package/dist-server/engine/connector/sqlite-connector.js.map +1 -1
- package/dist-server/engine/task/database-query.d.ts +1 -1
- package/dist-server/engine/task/database-query.js +16 -11
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.d.ts +1 -1
- package/dist-server/engine/task/graphql-mutate.js +16 -11
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.d.ts +1 -1
- package/dist-server/engine/task/graphql-query.js +16 -11
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/http-get.d.ts +1 -1
- package/dist-server/engine/task/http-get.js +28 -12
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.d.ts +1 -1
- package/dist-server/engine/task/http-post.js +22 -11
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.d.ts +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js +16 -10
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.d.ts +1 -1
- package/dist-server/engine/task/local-graphql-query.js +16 -10
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/log.d.ts +1 -1
- package/dist-server/engine/task/log.js +15 -11
- package/dist-server/engine/task/log.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.d.ts +1 -1
- package/dist-server/engine/task/oracle-procedure.js +19 -13
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/script.d.ts +1 -1
- package/dist-server/engine/task/script.js +30 -18
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/index.js +1 -2
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +6 -6
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/server/engine/connection-manager.ts +7 -8
- package/server/engine/connector/echo-back-connector.ts +2 -1
- package/server/engine/connector/graphql-connector.ts +8 -3
- package/server/engine/connector/mqtt-connector.ts +2 -1
- package/server/engine/connector/mssql-connector.ts +1 -1
- package/server/engine/connector/operato-connector.ts +10 -4
- package/server/engine/connector/oracle-connector.ts +5 -8
- package/server/engine/connector/postgresql-connector.ts +3 -2
- package/server/engine/connector/socket-server.ts +1 -1
- package/server/engine/connector/sqlite-connector.ts +2 -5
- package/server/engine/task/database-query.ts +16 -11
- package/server/engine/task/graphql-mutate.ts +16 -12
- package/server/engine/task/graphql-query.ts +15 -12
- package/server/engine/task/http-get.ts +26 -12
- package/server/engine/task/http-post.ts +22 -11
- package/server/engine/task/local-graphql-mutate.ts +16 -10
- package/server/engine/task/local-graphql-query.ts +16 -10
- package/server/engine/task/log.ts +14 -11
- package/server/engine/task/oracle-procedure.ts +24 -18
- package/server/engine/task/script.ts +28 -18
- package/server/index.ts +1 -2
- package/server/service/payload-log/payload-log-mutation.ts +1 -1
- package/server/service/scenario-instance/scenario-instance-type.ts +6 -6
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-base",
|
3
|
-
"version": "7.0.1-rc.
|
3
|
+
"version": "7.0.1-rc.7",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -27,14 +27,14 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"@apollo/client": "^3.6.9",
|
29
29
|
"@operato/moment-timezone-es": "^7.0.0-rc",
|
30
|
-
"@things-factory/api": "^7.0.1-rc.
|
31
|
-
"@things-factory/auth-base": "^7.0.1-rc.
|
32
|
-
"@things-factory/cache-service": "^7.0.1-rc.
|
33
|
-
"@things-factory/env": "^7.0.1-rc.
|
34
|
-
"@things-factory/oauth2-client": "^7.0.1-rc.
|
35
|
-
"@things-factory/scheduler-client": "^7.0.1-rc.
|
36
|
-
"@things-factory/shell": "^7.0.1-rc.
|
37
|
-
"@things-factory/utils": "^7.0.1-rc.
|
30
|
+
"@things-factory/api": "^7.0.1-rc.7",
|
31
|
+
"@things-factory/auth-base": "^7.0.1-rc.7",
|
32
|
+
"@things-factory/cache-service": "^7.0.1-rc.7",
|
33
|
+
"@things-factory/env": "^7.0.1-rc.7",
|
34
|
+
"@things-factory/oauth2-client": "^7.0.1-rc.7",
|
35
|
+
"@things-factory/scheduler-client": "^7.0.1-rc.7",
|
36
|
+
"@things-factory/shell": "^7.0.1-rc.7",
|
37
|
+
"@things-factory/utils": "^7.0.1-rc.7",
|
38
38
|
"async-mqtt": "^2.5.0",
|
39
39
|
"chance": "^1.1.11",
|
40
40
|
"cross-fetch": "^3.0.4",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"node-fetch": "^2.6.0",
|
43
43
|
"promise-socket": "^7.0.0",
|
44
44
|
"readline": "^1.3.0",
|
45
|
-
"
|
45
|
+
"ses": "^1.5.0"
|
46
46
|
},
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "0e8c627f3fbb83cc1c3fadac3ec342cb8f3f0149"
|
48
48
|
}
|
@@ -7,7 +7,7 @@ import { Connection, ConnectionStatus } from '../service'
|
|
7
7
|
import { Connector } from './types'
|
8
8
|
import { ProxyConnector } from './connector/proxy-connector'
|
9
9
|
|
10
|
-
const { combine,
|
10
|
+
const { combine, splat, printf, errors } = format
|
11
11
|
const debug = require('debug')('things-factory:integration-base:connections')
|
12
12
|
|
13
13
|
const SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone
|
@@ -20,12 +20,12 @@ export class ConnectionManager {
|
|
20
20
|
private static connectors: { [propName: string]: Connector } = {}
|
21
21
|
private static connections: { [domainId: string]: { [name: string]: any } } = {}
|
22
22
|
private static entities = {}
|
23
|
-
private static logFormat = printf(({ level, message, timestamp }) => {
|
24
|
-
return `${timestamp} ${level}: ${message}`
|
23
|
+
private static logFormat = printf(({ level, message, timestamp, stack }) => {
|
24
|
+
return `${timestamp} ${level}: ${stack || message}`
|
25
25
|
})
|
26
26
|
|
27
27
|
public static logger = createLogger({
|
28
|
-
format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), ConnectionManager.logFormat),
|
28
|
+
format: combine(errors({ stack: true }), systemTimestamp({ tz: SYSTEM_TZ }), splat(), ConnectionManager.logFormat),
|
29
29
|
transports: [
|
30
30
|
new (transports as any).DailyRotateFile({
|
31
31
|
filename: `logs/connections-%DATE%.log`,
|
@@ -52,8 +52,7 @@ export class ConnectionManager {
|
|
52
52
|
try {
|
53
53
|
params = JSON.parse(connection.params || '{}')
|
54
54
|
} catch (ex) {
|
55
|
-
ConnectionManager.logger.error(`connection '${connection.name}' params should be JSON format
|
56
|
-
ConnectionManager.logger.error(ex)
|
55
|
+
ConnectionManager.logger.error(`connection '${connection.name}' params should be JSON format`, ex)
|
57
56
|
}
|
58
57
|
|
59
58
|
return {
|
@@ -66,7 +65,7 @@ export class ConnectionManager {
|
|
66
65
|
|
67
66
|
return await Promise.all(
|
68
67
|
[...Object.keys(ConnectionManager.connectors), 'proxy-connector'].map(type => {
|
69
|
-
const connector = 'proxy-connector' ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
68
|
+
const connector = type == 'proxy-connector' ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
70
69
|
|
71
70
|
ConnectionManager.logger.info(`Connector '${type}' started to ready`)
|
72
71
|
|
@@ -81,7 +80,7 @@ export class ConnectionManager {
|
|
81
80
|
}) as any
|
82
81
|
)
|
83
82
|
.catch(error => {
|
84
|
-
ConnectionManager.logger.error(error
|
83
|
+
ConnectionManager.logger.error(error)
|
85
84
|
})
|
86
85
|
.then(() => {
|
87
86
|
ConnectionManager.logger.info(`All connector for '${type}' ready`)
|
@@ -25,7 +25,8 @@ export class EchoBack implements Connector {
|
|
25
25
|
)
|
26
26
|
} catch (e) {
|
27
27
|
ConnectionManager.logger.error(
|
28
|
-
`echo-back-connector connection(${connection.name}:${connection.endpoint}) is not connected
|
28
|
+
`echo-back-connector connection(${connection.name}:${connection.endpoint}) is not connected.`,
|
29
|
+
e
|
29
30
|
)
|
30
31
|
}
|
31
32
|
}
|
@@ -39,11 +39,14 @@ export class GraphqlConnector implements Connector {
|
|
39
39
|
const ERROR_HANDLER: any = ({ graphQLErrors, networkError }) => {
|
40
40
|
if (graphQLErrors)
|
41
41
|
graphQLErrors.map(({ message, locations, path }) => {
|
42
|
-
ConnectionManager.logger.error(
|
42
|
+
ConnectionManager.logger.error(
|
43
|
+
`[GraphQL error] Message: ${message}, Location: ${locations}, Path: ${path}`,
|
44
|
+
graphQLErrors
|
45
|
+
)
|
43
46
|
})
|
44
47
|
|
45
48
|
if (networkError) {
|
46
|
-
ConnectionManager.logger.error(`[Network error - ${networkError.statusCode}]
|
49
|
+
ConnectionManager.logger.error(`[Network error - ${networkError.statusCode}]`, networkError)
|
47
50
|
}
|
48
51
|
}
|
49
52
|
|
@@ -81,7 +84,9 @@ export class GraphqlConnector implements Connector {
|
|
81
84
|
})
|
82
85
|
)
|
83
86
|
|
84
|
-
ConnectionManager.logger.info(
|
87
|
+
ConnectionManager.logger.info(
|
88
|
+
`graphql-connector connection(${connection.name}:${connection.endpoint}) is connected`
|
89
|
+
)
|
85
90
|
}
|
86
91
|
|
87
92
|
async disconnect(connection: InputConnection) {
|
@@ -39,7 +39,8 @@ export class MqttConnector implements Connector {
|
|
39
39
|
ConnectionManager.logger.info(`mqtt-connector connection(${connection.name}:${connection.endpoint}) is connected`)
|
40
40
|
} catch (err) {
|
41
41
|
ConnectionManager.logger.error(
|
42
|
-
`mqtt-connector connection(${connection.name}:${connection.endpoint}) is failed
|
42
|
+
`mqtt-connector connection(${connection.name}:${connection.endpoint}) is failed.`,
|
43
|
+
err
|
43
44
|
)
|
44
45
|
}
|
45
46
|
}
|
@@ -7,7 +7,7 @@ import { InputConnection } from '../../service/connection/connection-type'
|
|
7
7
|
try {
|
8
8
|
var Client = require('mssql')
|
9
9
|
} catch (err) {
|
10
|
-
logger.error('mssql module loading failed')
|
10
|
+
logger.error('mssql module loading failed', err)
|
11
11
|
}
|
12
12
|
|
13
13
|
export class MssqlConnector implements Connector {
|
@@ -160,14 +160,16 @@ export class OperatoConnector implements Connector {
|
|
160
160
|
await this.runScenario(subscriptions, data?.data?.data)
|
161
161
|
},
|
162
162
|
error: error => {
|
163
|
-
ConnectionManager.logger.error(`(${connection.name}:${connection.endpoint}) subscription error
|
163
|
+
ConnectionManager.logger.error(`(${connection.name}:${connection.endpoint}) subscription error`, error)
|
164
164
|
},
|
165
165
|
complete: () => {
|
166
166
|
ConnectionManager.logger.info(`(${connection.name}:${connection.endpoint}) subscription complete`)
|
167
167
|
}
|
168
168
|
})
|
169
169
|
|
170
|
-
ConnectionManager.logger.info(
|
170
|
+
ConnectionManager.logger.info(
|
171
|
+
`(${connection.name}:${connection.endpoint}) subscription closed flag: ${subscriptionObserver.closed}`
|
172
|
+
)
|
171
173
|
|
172
174
|
subscriptions.push({
|
173
175
|
tag,
|
@@ -180,7 +182,9 @@ export class OperatoConnector implements Connector {
|
|
180
182
|
client['subscriptions'] = subscriptions
|
181
183
|
ConnectionManager.addConnectionInstance(connection, client)
|
182
184
|
|
183
|
-
ConnectionManager.logger.info(
|
185
|
+
ConnectionManager.logger.info(
|
186
|
+
`operato-connector connection(${connection.name}:${connection.endpoint}) is connected`
|
187
|
+
)
|
184
188
|
}
|
185
189
|
|
186
190
|
async disconnect(connection: InputConnection) {
|
@@ -208,7 +212,9 @@ export class OperatoConnector implements Connector {
|
|
208
212
|
|
209
213
|
if (!(await checkPermission(scenario.privilege, user, domain, unsafeIP, prohibitedPrivileges))) {
|
210
214
|
const { category, privilege } = scenario.privilege || {}
|
211
|
-
throw new Error(
|
215
|
+
throw new Error(
|
216
|
+
`Unauthorized! ${category && privilege ? category + ':' + privilege + ' privilege' : 'ownership granted'} required`
|
217
|
+
)
|
212
218
|
}
|
213
219
|
|
214
220
|
/* create a scenario instance */
|
@@ -7,7 +7,7 @@ import { InputConnection } from '../../service/connection/connection-type'
|
|
7
7
|
try {
|
8
8
|
var oracledb = require('oracledb')
|
9
9
|
} catch (err) {
|
10
|
-
logger.error('oracledb module loading failed')
|
10
|
+
logger.error('oracledb module loading failed', err)
|
11
11
|
}
|
12
12
|
|
13
13
|
export class OracleConnector implements Connector {
|
@@ -71,7 +71,7 @@ export class OracleConnector implements Connector {
|
|
71
71
|
poolAlias,
|
72
72
|
enableStatistics
|
73
73
|
})
|
74
|
-
|
74
|
+
|
75
75
|
ConnectionManager.addConnectionInstance(connection, {
|
76
76
|
query: async (query, params) => {
|
77
77
|
let dbConnection: any = {}
|
@@ -89,12 +89,10 @@ export class OracleConnector implements Connector {
|
|
89
89
|
await this.recreatePool(connection)
|
90
90
|
}
|
91
91
|
throw e
|
92
|
-
}
|
93
|
-
finally {
|
92
|
+
} finally {
|
94
93
|
await dbConnection.close()
|
95
94
|
}
|
96
95
|
return taskResult
|
97
|
-
|
98
96
|
},
|
99
97
|
execute: async (procedure, params) => {
|
100
98
|
let dbConnection: any = {}
|
@@ -105,7 +103,7 @@ export class OracleConnector implements Connector {
|
|
105
103
|
${procedure}
|
106
104
|
END;`
|
107
105
|
dbConnection = await oracledb.getConnection(poolAlias)
|
108
|
-
|
106
|
+
|
109
107
|
// console.log('\n************* stat after get ****************')
|
110
108
|
// await oracledb.getPool(poolAlias).logStatistics()
|
111
109
|
|
@@ -131,8 +129,7 @@ export class OracleConnector implements Connector {
|
|
131
129
|
await this.recreatePool(connection)
|
132
130
|
}
|
133
131
|
throw e
|
134
|
-
}
|
135
|
-
finally {
|
132
|
+
} finally {
|
136
133
|
await dbConnection.close()
|
137
134
|
|
138
135
|
// console.log('\n************* stat after close ****************')
|
@@ -7,7 +7,7 @@ import { InputConnection } from '../../service/connection/connection-type'
|
|
7
7
|
try {
|
8
8
|
var { Client } = require('pg')
|
9
9
|
} catch (err) {
|
10
|
-
logger.error('postgresql module loading failed')
|
10
|
+
logger.error('postgresql module loading failed', err)
|
11
11
|
}
|
12
12
|
|
13
13
|
export class PostgresqlConnector implements Connector {
|
@@ -55,7 +55,8 @@ export class PostgresqlConnector implements Connector {
|
|
55
55
|
ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} connected.`)
|
56
56
|
} catch (e) {
|
57
57
|
ConnectionManager.logger.error(
|
58
|
-
`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} not connected
|
58
|
+
`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} not connected.`,
|
59
|
+
e
|
59
60
|
)
|
60
61
|
}
|
61
62
|
}
|
@@ -40,7 +40,7 @@ export class SocketServer implements Connector {
|
|
40
40
|
var logger = ConnectionManager.logger
|
41
41
|
let message = ex.stack ? ex.stack : ex
|
42
42
|
let msg = typeof message == 'object' ? JSON.stringify(message, null, 2) : message
|
43
|
-
logger.error(msg)
|
43
|
+
logger.error(msg, ex)
|
44
44
|
reject(ex)
|
45
45
|
})
|
46
46
|
})
|
@@ -6,11 +6,10 @@ import { ConnectionManager } from '../connection-manager'
|
|
6
6
|
import { Connector } from '../types'
|
7
7
|
import { InputConnection } from '../../service/connection/connection-type'
|
8
8
|
|
9
|
-
|
10
9
|
try {
|
11
10
|
var sqlite3 = require('sqlite3').verbose()
|
12
11
|
} catch (err) {
|
13
|
-
logger.error('sqlite3 module loading failed')
|
12
|
+
logger.error('sqlite3 module loading failed', err)
|
14
13
|
}
|
15
14
|
|
16
15
|
export class SqliteConnector implements Connector {
|
@@ -29,9 +28,7 @@ export class SqliteConnector implements Connector {
|
|
29
28
|
|
30
29
|
var database = new sqlite3.Database(endpoint, sqlite3.OPEN_READWRITE, err => {
|
31
30
|
if (err) {
|
32
|
-
ConnectionManager.logger.error(
|
33
|
-
`SQLite Database(${connection.name}) at ${endpoint} not connected.\ncause: ${err}`
|
34
|
-
)
|
31
|
+
ConnectionManager.logger.error(`SQLite Database(${connection.name}) at ${endpoint} not connected.`, err)
|
35
32
|
return
|
36
33
|
}
|
37
34
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { VM } from 'vm2'
|
2
1
|
import { ConnectionManager } from '../connection-manager'
|
3
2
|
import { TaskRegistry } from '../task-registry'
|
4
3
|
import { InputStep } from '../../service/step/step-type'
|
5
4
|
import { Context } from '../types'
|
5
|
+
import 'ses'
|
6
6
|
|
7
7
|
async function DatabaseQuery(step: InputStep, context: Context) {
|
8
8
|
var { domain, user, data, variables, lng } = context
|
@@ -13,18 +13,23 @@ async function DatabaseQuery(step: InputStep, context: Context) {
|
|
13
13
|
|
14
14
|
var dbconnection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
|
15
15
|
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
16
|
+
const compartment = new Compartment({
|
17
|
+
domain,
|
18
|
+
user,
|
19
|
+
lng,
|
20
|
+
data,
|
21
|
+
variables,
|
22
|
+
console
|
24
23
|
})
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
let evalQuery
|
26
|
+
try {
|
27
|
+
evalQuery = compartment.evaluate('`' + query + '`')
|
28
|
+
} catch (err) {
|
29
|
+
throw new Error(`Failed to evaluate query: ${err.message}`)
|
30
|
+
}
|
31
|
+
|
32
|
+
var queryResult = await dbconnection.query(evalQuery, [])
|
28
33
|
|
29
34
|
return {
|
30
35
|
data: queryResult
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
|
-
import
|
2
|
+
import 'ses'
|
3
3
|
|
4
4
|
import { access } from '@things-factory/utils'
|
5
|
-
|
6
5
|
import { ConnectionManager } from '../connection-manager'
|
7
6
|
import { TaskRegistry } from '../task-registry'
|
8
7
|
import { InputStep } from '../../service/step/step-type'
|
@@ -14,17 +13,21 @@ async function GraphqlMutate(step: InputStep, context: Context) {
|
|
14
13
|
|
15
14
|
var { domain, user, data, variables, lng } = context
|
16
15
|
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
16
|
+
const compartment = new Compartment({
|
17
|
+
domain,
|
18
|
+
user,
|
19
|
+
lng,
|
20
|
+
data,
|
21
|
+
variables,
|
22
|
+
console
|
25
23
|
})
|
26
24
|
|
27
|
-
|
25
|
+
let evalMutation
|
26
|
+
try {
|
27
|
+
evalMutation = compartment.evaluate('`' + mutation + '`')
|
28
|
+
} catch (err) {
|
29
|
+
throw new Error(`Failed to evaluate mutation: ${err.message}`)
|
30
|
+
}
|
28
31
|
|
29
32
|
var client = ConnectionManager.getConnectionInstanceByName(context.domain, connectionName)
|
30
33
|
|
@@ -36,7 +39,7 @@ async function GraphqlMutate(step: InputStep, context: Context) {
|
|
36
39
|
|
37
40
|
var { data: mutateResult } = await client.mutate({
|
38
41
|
mutation: gql`
|
39
|
-
${
|
42
|
+
${evalMutation}
|
40
43
|
`,
|
41
44
|
variables: queryVariables,
|
42
45
|
headers
|
@@ -70,6 +73,7 @@ GraphqlMutate.parameterSpec = [
|
|
70
73
|
label: 'headers'
|
71
74
|
}
|
72
75
|
]
|
76
|
+
|
73
77
|
GraphqlMutate.help = 'integration/task/graphql-mutate'
|
74
78
|
|
75
79
|
TaskRegistry.registerTaskHandler('graphql-mutate', GraphqlMutate)
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
|
-
import
|
2
|
+
import 'ses'
|
3
3
|
|
4
4
|
import { access } from '@things-factory/utils'
|
5
|
-
|
6
5
|
import { ConnectionManager } from '../connection-manager'
|
7
6
|
import { TaskRegistry } from '../task-registry'
|
8
7
|
import { InputStep } from '../../service/step/step-type'
|
@@ -13,17 +12,21 @@ async function GraphqlQuery(step: InputStep, context: Context) {
|
|
13
12
|
var { query, variables: variablesAccessorMap, headers } = stepOptions || {}
|
14
13
|
var { domain, user, data, variables, lng } = context
|
15
14
|
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
15
|
+
const compartment = new Compartment({
|
16
|
+
domain,
|
17
|
+
user,
|
18
|
+
lng,
|
19
|
+
data,
|
20
|
+
variables,
|
21
|
+
console
|
24
22
|
})
|
25
23
|
|
26
|
-
|
24
|
+
let evalQuery
|
25
|
+
try {
|
26
|
+
evalQuery = compartment.evaluate('`' + query + '`')
|
27
|
+
} catch (err) {
|
28
|
+
throw new Error(`Failed to evaluate query: ${err.message}`)
|
29
|
+
}
|
27
30
|
|
28
31
|
var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)
|
29
32
|
|
@@ -35,7 +38,7 @@ async function GraphqlQuery(step: InputStep, context: Context) {
|
|
35
38
|
|
36
39
|
var { data: queryResult } = await client.query({
|
37
40
|
query: gql`
|
38
|
-
${
|
41
|
+
${evalQuery}
|
39
42
|
`,
|
40
43
|
variables: queryVariables,
|
41
44
|
headers
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import fetch from 'node-fetch'
|
2
|
-
import
|
2
|
+
import 'ses'
|
3
3
|
import { URL } from 'url'
|
4
4
|
import https from 'https'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
@@ -19,29 +19,43 @@ async function HttpGet(step: InputStep, { logger, data, domain, user, variables,
|
|
19
19
|
|
20
20
|
var { endpoint, params: connectionParams, authHeaders = {} } = connection
|
21
21
|
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
22
|
+
const compartment = new Compartment({
|
23
|
+
domain,
|
24
|
+
user,
|
25
|
+
lng,
|
26
|
+
data,
|
27
|
+
variables,
|
28
|
+
console
|
30
29
|
})
|
31
30
|
|
32
|
-
|
31
|
+
let evalPath
|
32
|
+
try {
|
33
|
+
evalPath = compartment.evaluate('`' + path + '`')
|
34
|
+
} catch (err) {
|
35
|
+
throw new Error(`Failed to evaluate path: ${err.message}`)
|
36
|
+
}
|
37
|
+
|
38
|
+
path = evalPath
|
33
39
|
|
34
40
|
requestHeaders =
|
35
41
|
requestHeaders &&
|
36
42
|
Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {
|
37
|
-
|
43
|
+
try {
|
44
|
+
sum[key] = compartment.evaluate('`' + value + '`')
|
45
|
+
} catch (err) {
|
46
|
+
throw new Error(`Failed to evaluate header value: ${err.message}`)
|
47
|
+
}
|
38
48
|
return sum
|
39
49
|
}, {})
|
40
50
|
|
41
51
|
searchParams =
|
42
52
|
searchParams &&
|
43
53
|
Object.entries(searchParams as { [key: string]: string }).reduce((sum, [key, value]) => {
|
44
|
-
|
54
|
+
try {
|
55
|
+
sum[key] = compartment.evaluate('`' + value + '`')
|
56
|
+
} catch (err) {
|
57
|
+
throw new Error(`Failed to evaluate search param value: ${err.message}`)
|
58
|
+
}
|
45
59
|
return sum
|
46
60
|
}, {})
|
47
61
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import fetch from 'node-fetch'
|
2
2
|
import { URL } from 'url'
|
3
|
-
import
|
3
|
+
import 'ses'
|
4
4
|
import { access } from '@things-factory/utils'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
6
6
|
import { ConnectionManager } from '../connection-manager'
|
@@ -20,21 +20,32 @@ async function HttpPost(step: InputStep, { logger, data, domain, user, variables
|
|
20
20
|
|
21
21
|
var { endpoint, params: connectionParams, authHeaders = {} } = connection
|
22
22
|
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
23
|
+
const compartment = new Compartment({
|
24
|
+
domain,
|
25
|
+
user,
|
26
|
+
lng,
|
27
|
+
data,
|
28
|
+
variables,
|
29
|
+
console
|
31
30
|
})
|
32
31
|
|
33
|
-
|
32
|
+
let evalPath
|
33
|
+
try {
|
34
|
+
evalPath = compartment.evaluate('`' + path + '`')
|
35
|
+
} catch (err) {
|
36
|
+
throw new Error(`Failed to evaluate path: ${err.message}`)
|
37
|
+
}
|
38
|
+
|
39
|
+
path = evalPath
|
40
|
+
|
34
41
|
requestHeaders =
|
35
42
|
requestHeaders &&
|
36
43
|
Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {
|
37
|
-
|
44
|
+
try {
|
45
|
+
sum[key] = compartment.evaluate('`' + value + '`')
|
46
|
+
} catch (err) {
|
47
|
+
throw new Error(`Failed to evaluate header value: ${err.message}`)
|
48
|
+
}
|
38
49
|
return sum
|
39
50
|
}, {})
|
40
51
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
|
-
import
|
2
|
+
import 'ses'
|
3
3
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
5
5
|
import { getRepository } from '@things-factory/shell'
|
@@ -21,17 +21,23 @@ async function LocalGraphqlMutate(step: InputStep, context: Context) {
|
|
21
21
|
relations: ['domains']
|
22
22
|
}))
|
23
23
|
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
24
|
+
const compartment = new Compartment({
|
25
|
+
domain,
|
26
|
+
user,
|
27
|
+
lng,
|
28
|
+
data,
|
29
|
+
variables,
|
30
|
+
console
|
32
31
|
})
|
33
32
|
|
34
|
-
|
33
|
+
let evalMutation
|
34
|
+
try {
|
35
|
+
evalMutation = compartment.evaluate('`' + mutation + '`')
|
36
|
+
} catch (err) {
|
37
|
+
throw new Error(`Failed to evaluate mutation: ${err.message}`)
|
38
|
+
}
|
39
|
+
|
40
|
+
mutation = evalMutation
|
35
41
|
|
36
42
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
37
43
|
const accessor = variablesAccessorMap[key]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
|
-
import
|
2
|
+
import 'ses'
|
3
3
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
5
5
|
import { getRepository } from '@things-factory/shell'
|
@@ -21,17 +21,23 @@ async function LocalGraphqlQuery(step: InputStep, context: Context) {
|
|
21
21
|
relations: ['domains']
|
22
22
|
}))
|
23
23
|
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
24
|
+
const compartment = new Compartment({
|
25
|
+
domain,
|
26
|
+
user,
|
27
|
+
lng,
|
28
|
+
data,
|
29
|
+
variables,
|
30
|
+
console
|
32
31
|
})
|
33
32
|
|
34
|
-
|
33
|
+
let evalQuery
|
34
|
+
try {
|
35
|
+
evalQuery = compartment.evaluate('`' + query + '`')
|
36
|
+
} catch (err) {
|
37
|
+
throw new Error(`Failed to evaluate query: ${err.message}`)
|
38
|
+
}
|
39
|
+
|
40
|
+
query = evalQuery
|
35
41
|
|
36
42
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
37
43
|
const accessor = variablesAccessorMap[key]
|