@things-factory/integration-base 4.0.4 → 4.0.9
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.
|
@@ -9,9 +9,13 @@ const debug = require('debug')('things-factory:integration-base:restful:unstable
|
|
|
9
9
|
api_1.restfulApiRouter.post('/unstable/run-scenario/:scenarioName', async (context, next) => {
|
|
10
10
|
const { client } = context.state;
|
|
11
11
|
const { scenarioName } = context.params;
|
|
12
|
-
const
|
|
12
|
+
const body = context.request.body || {};
|
|
13
|
+
let { instanceName = '', variables = {} } = body;
|
|
14
|
+
if (Object.keys(variables).length === 0) {
|
|
15
|
+
variables = body;
|
|
16
|
+
}
|
|
13
17
|
debug('post:/unstable/run-scenario/:scenarioName', scenarioName);
|
|
14
|
-
|
|
18
|
+
let response = await client.mutate({
|
|
15
19
|
mutation: (0, graphql_tag_1.default) `
|
|
16
20
|
mutation($instanceName: String, $scenarioName: String!, $variables: Object) {
|
|
17
21
|
runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {
|
|
@@ -31,5 +35,6 @@ api_1.restfulApiRouter.post('/unstable/run-scenario/:scenarioName', async (conte
|
|
|
31
35
|
},
|
|
32
36
|
context
|
|
33
37
|
});
|
|
38
|
+
context.body = response.data.runScenario.data || {};
|
|
34
39
|
});
|
|
35
40
|
//# sourceMappingURL=run-scenario.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/run-scenario.ts"],"names":[],"mappings":";;;;;AAAA,8DAA6B;
|
|
1
|
+
{"version":3,"file":"run-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/run-scenario.ts"],"names":[],"mappings":";;;;;AAAA,8DAA6B;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;;;;;;;;;;;KAWZ;QACD,SAAS,EAAE;YACT,YAAY;YACZ,YAAY;YACZ,SAAS;SACV;QACD,OAAO;KACR,CAAC,CAAA;IACF,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAA;AACrD,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-base",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apollo/client": "^3.4.17",
|
|
29
|
-
"@things-factory/api": "^4.0.
|
|
30
|
-
"@things-factory/auth-base": "^4.0.
|
|
31
|
-
"@things-factory/oauth2-client": "^4.0.
|
|
32
|
-
"@things-factory/shell": "^4.0.
|
|
29
|
+
"@things-factory/api": "^4.0.9",
|
|
30
|
+
"@things-factory/auth-base": "^4.0.9",
|
|
31
|
+
"@things-factory/oauth2-client": "^4.0.9",
|
|
32
|
+
"@things-factory/shell": "^4.0.9",
|
|
33
33
|
"async-mqtt": "^2.5.0",
|
|
34
34
|
"cron": "^1.7.2",
|
|
35
35
|
"cross-fetch": "^3.0.4",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"promise-socket": "^7.0.0",
|
|
41
41
|
"vm2": "^3.9.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "81c8ae24487cfe79da62717f12bb6752761911ae"
|
|
44
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import gql from 'graphql-tag'
|
|
2
|
+
|
|
2
3
|
import { restfulApiRouter as router } from '@things-factory/api'
|
|
3
4
|
|
|
4
5
|
const debug = require('debug')('things-factory:integration-base:restful:unstable:run-scenario')
|
|
@@ -6,11 +7,15 @@ const debug = require('debug')('things-factory:integration-base:restful:unstable
|
|
|
6
7
|
router.post('/unstable/run-scenario/:scenarioName', async (context, next) => {
|
|
7
8
|
const { client } = context.state
|
|
8
9
|
const { scenarioName } = context.params
|
|
9
|
-
const
|
|
10
|
+
const body = context.request.body || {}
|
|
11
|
+
let { instanceName = '', variables = {} } = body
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
if (Object.keys(variables).length === 0) {
|
|
14
|
+
variables = body
|
|
15
|
+
}
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
debug('post:/unstable/run-scenario/:scenarioName', scenarioName)
|
|
18
|
+
let response = await client.mutate({
|
|
14
19
|
mutation: gql`
|
|
15
20
|
mutation($instanceName: String, $scenarioName: String!, $variables: Object) {
|
|
16
21
|
runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {
|
|
@@ -30,4 +35,5 @@ router.post('/unstable/run-scenario/:scenarioName', async (context, next) => {
|
|
|
30
35
|
},
|
|
31
36
|
context
|
|
32
37
|
})
|
|
38
|
+
context.body = response.data.runScenario.data || {}
|
|
33
39
|
})
|