@things-factory/integration-base 6.1.48 → 6.1.52
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 -3
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/restful/unstable/run-scenario.js +10 -2
- package/dist-server/restful/unstable/run-scenario.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +11 -0
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/step/step-type.js +15 -0
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/engine/connection-manager.ts +8 -3
- package/server/restful/unstable/run-scenario.ts +16 -2
- package/server/service/scenario-instance/scenario-instance-type.ts +12 -0
- package/server/service/step/step-type.ts +10 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-base",
|
3
|
-
"version": "6.1.
|
3
|
+
"version": "6.1.52",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"devDependencies": {
|
47
47
|
"@types/cron": "^2.0.1"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ef84aece7f35bd03fbdfc9dcde264d2fbe5ef215"
|
50
50
|
}
|
@@ -109,13 +109,18 @@ export class ConnectionManager {
|
|
109
109
|
}
|
110
110
|
|
111
111
|
static getConnectionInstanceByName(domain: Domain, name: string) {
|
112
|
-
|
112
|
+
const connections = ConnectionManager.connections[domain.id]
|
113
|
+
const connection = connections?.[name]
|
114
|
+
|
115
|
+
if (!connection) {
|
116
|
+
throw `The connection with the given name(${name}) cannot be found`
|
117
|
+
}
|
113
118
|
|
114
|
-
return
|
119
|
+
return connection
|
115
120
|
}
|
116
121
|
|
117
122
|
static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {
|
118
|
-
|
123
|
+
const connections = ConnectionManager.connections[domain.id]
|
119
124
|
|
120
125
|
return {
|
121
126
|
...connections
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
2
|
|
3
3
|
import { restfulApiRouter as router } from '@things-factory/api'
|
4
|
+
import { ScenarioInstanceStatus } from '../../service/scenario-instance/scenario-instance-type'
|
4
5
|
|
5
6
|
const debug = require('debug')('things-factory:integration-base:restful:unstable:run-scenario')
|
6
7
|
|
@@ -17,12 +18,13 @@ router.post('/unstable/run-scenario/:scenarioName', async (context, next) => {
|
|
17
18
|
debug('post:/unstable/run-scenario/:scenarioName', scenarioName)
|
18
19
|
let response = await client.mutate({
|
19
20
|
mutation: gql`
|
20
|
-
mutation($instanceName: String, $scenarioName: String!, $variables: Object) {
|
21
|
+
mutation ($instanceName: String, $scenarioName: String!, $variables: Object) {
|
21
22
|
runScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {
|
22
23
|
instanceName
|
23
24
|
scenarioName
|
24
25
|
state
|
25
26
|
data
|
27
|
+
result
|
26
28
|
message
|
27
29
|
timestamp
|
28
30
|
}
|
@@ -35,5 +37,17 @@ router.post('/unstable/run-scenario/:scenarioName', async (context, next) => {
|
|
35
37
|
},
|
36
38
|
context
|
37
39
|
})
|
38
|
-
|
40
|
+
|
41
|
+
const { errors, data } = response
|
42
|
+
|
43
|
+
if (!data) {
|
44
|
+
context.status = 500
|
45
|
+
context.body = errors
|
46
|
+
|
47
|
+
return
|
48
|
+
}
|
49
|
+
|
50
|
+
const { result } = data.runScenario
|
51
|
+
|
52
|
+
context.body = result
|
39
53
|
})
|
@@ -114,6 +114,9 @@ export class ScenarioInstance {
|
|
114
114
|
@Field(type => ScalarObject, { nullable: true })
|
115
115
|
data: any
|
116
116
|
|
117
|
+
@Field(type => ScalarObject, { nullable: true })
|
118
|
+
result: any
|
119
|
+
|
117
120
|
@Field({ nullable: true })
|
118
121
|
timestamp: Date
|
119
122
|
|
@@ -256,7 +259,16 @@ export class ScenarioInstance {
|
|
256
259
|
ScenarioInstanceStatus.HALTED,
|
257
260
|
typeof message == 'object' ? JSON.stringify(message, null, 2) : message
|
258
261
|
)
|
262
|
+
|
263
|
+
throw ex
|
259
264
|
}
|
265
|
+
|
266
|
+
this.result = this.steps
|
267
|
+
.filter(step => !!step.result)
|
268
|
+
.reduce((sum, step) => {
|
269
|
+
sum[step.name] = this.context.data[step.name]
|
270
|
+
return sum
|
271
|
+
}, {})
|
260
272
|
}
|
261
273
|
|
262
274
|
async loadSubscenario(step, scenarioConfig, context) {
|
@@ -81,6 +81,13 @@ export class Step {
|
|
81
81
|
@Field({ nullable: true })
|
82
82
|
params: string
|
83
83
|
|
84
|
+
@Column({ nullable: true, default: true })
|
85
|
+
@Field({
|
86
|
+
nullable: true,
|
87
|
+
description: 'a boolean attribute indicating the inclusion status of an element in the result'
|
88
|
+
})
|
89
|
+
result: boolean = true
|
90
|
+
|
84
91
|
@CreateDateColumn()
|
85
92
|
@Field({ nullable: true })
|
86
93
|
createdAt: Date
|
@@ -133,6 +140,9 @@ export class StepPatch {
|
|
133
140
|
@Field({ nullable: true })
|
134
141
|
params?: string
|
135
142
|
|
143
|
+
@Field({ nullable: true })
|
144
|
+
result?: boolean
|
145
|
+
|
136
146
|
@Field({ nullable: true })
|
137
147
|
cuFlag?: string
|
138
148
|
}
|