@things-factory/integration-base 7.0.0-alpha.0 → 7.0.0-alpha.1
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/connector/echo-back-connector.js +1 -1
- package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
- package/dist-server/engine/connector/echo-back-server.js +1 -1
- package/dist-server/engine/connector/echo-back-server.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
- package/dist-server/engine/connector/mssql-connector.js.map +1 -1
- package/dist-server/engine/connector/mysql-connector.js +3 -3
- package/dist-server/engine/connector/mysql-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- 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.map +1 -1
- package/dist-server/engine/task/book-up-scenario.js.map +1 -1
- package/dist-server/engine/task/csv-readline.js.map +1 -1
- package/dist-server/engine/task/data-accessor.js.map +1 -1
- package/dist-server/engine/task/data-mapper.js.map +1 -1
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/echo-receive.js.map +1 -1
- package/dist-server/engine/task/echo-send.js.map +1 -1
- package/dist-server/engine/task/empty-check.js.map +1 -1
- package/dist-server/engine/task/end.js.map +1 -1
- package/dist-server/engine/task/floating-point.js.map +1 -1
- package/dist-server/engine/task/goto.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/jsonata.js +1 -1
- package/dist-server/engine/task/jsonata.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/log.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/publish.js.map +1 -1
- package/dist-server/engine/task/random.js.map +1 -1
- package/dist-server/engine/task/reset-pending-queue.js.map +1 -1
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/engine/task/set-domain.js.map +1 -1
- package/dist-server/engine/task/sleep.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/engine/task/state-read.js.map +1 -1
- package/dist-server/engine/task/state-write.js.map +1 -1
- package/dist-server/engine/task/stop-scenario.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-goto.js.map +1 -1
- package/dist-server/engine/task/switch-range-goto.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-set.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-set.js.map +1 -1
- package/dist-server/engine/task/throw.js.map +1 -1
- package/dist-server/engine/task/variables.js.map +1 -1
- package/dist-server/engine/types.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +9 -12
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.js +34 -5
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +8 -9
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js +4 -4
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
- package/dist-server/service/step/step-type.js +41 -28
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/server/engine/connector/echo-back-connector.ts +4 -3
- package/server/engine/connector/echo-back-server.ts +5 -4
- package/server/engine/connector/graphql-connector.ts +4 -3
- package/server/engine/connector/http-connector.ts +4 -3
- package/server/engine/connector/mqtt-connector.ts +4 -3
- package/server/engine/connector/mssql-connector.ts +4 -3
- package/server/engine/connector/mysql-connector.ts +8 -6
- package/server/engine/connector/operato-connector.ts +5 -3
- package/server/engine/connector/oracle-connector.ts +6 -3
- package/server/engine/connector/postgresql-connector.ts +4 -3
- package/server/engine/connector/socket-server.ts +5 -4
- package/server/engine/connector/sqlite-connector.ts +5 -3
- package/server/engine/task/book-up-scenario.ts +3 -1
- package/server/engine/task/csv-readline.ts +4 -1
- package/server/engine/task/data-accessor.ts +4 -1
- package/server/engine/task/data-mapper.ts +4 -1
- package/server/engine/task/database-query.ts +3 -1
- package/server/engine/task/echo-receive.ts +4 -1
- package/server/engine/task/echo-send.ts +3 -1
- package/server/engine/task/empty-check.ts +4 -1
- package/server/engine/task/end.ts +4 -1
- package/server/engine/task/floating-point.ts +4 -1
- package/server/engine/task/goto.ts +4 -1
- package/server/engine/task/graphql-mutate.ts +3 -1
- package/server/engine/task/graphql-query.ts +3 -1
- package/server/engine/task/headless-post.ts +4 -1
- package/server/engine/task/headless-scrap.ts +3 -1
- package/server/engine/task/http-get.ts +3 -1
- package/server/engine/task/http-post.ts +3 -1
- package/server/engine/task/jsonata.ts +5 -2
- package/server/engine/task/local-graphql-mutate.ts +5 -1
- package/server/engine/task/local-graphql-query.ts +3 -1
- package/server/engine/task/log.ts +3 -1
- package/server/engine/task/mqtt-publish.ts +3 -1
- package/server/engine/task/mqtt-subscribe.ts +3 -1
- package/server/engine/task/oracle-procedure.ts +3 -1
- package/server/engine/task/pick-pending-scenario.ts +3 -1
- package/server/engine/task/publish.ts +3 -1
- package/server/engine/task/random.ts +4 -1
- package/server/engine/task/reset-pending-queue.ts +3 -1
- package/server/engine/task/script.ts +4 -1
- package/server/engine/task/set-domain.ts +4 -1
- package/server/engine/task/sleep.ts +3 -1
- package/server/engine/task/socket-listener.ts +3 -1
- package/server/engine/task/state-read.ts +3 -1
- package/server/engine/task/state-write.ts +3 -1
- package/server/engine/task/stop-scenario.ts +3 -1
- package/server/engine/task/sub-scenario.ts +3 -1
- package/server/engine/task/switch-goto.ts +4 -1
- package/server/engine/task/switch-range-goto.ts +3 -1
- package/server/engine/task/switch-range-scenario.ts +3 -1
- package/server/engine/task/switch-range-set.ts +3 -1
- package/server/engine/task/switch-scenario.ts +3 -1
- package/server/engine/task/switch-set.ts +3 -1
- package/server/engine/task/throw.ts +3 -1
- package/server/engine/task/variables.ts +3 -1
- package/server/engine/types.ts +81 -4
- package/server/service/connection/connection-subscription.ts +16 -22
- package/server/service/connection/connection-type.ts +67 -0
- package/server/service/scenario-instance/scenario-instance-subscription.ts +16 -23
- package/server/service/scenario-queue/scenario-queue-subscription.ts +7 -7
- package/server/service/step/step-type.ts +78 -22
@@ -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
|
-
|
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
|
-
|
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
|
|
@@ -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
|
-
|
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
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import { TaskRegistry } from '../task-registry'
|
2
2
|
import { Domain, getRepository } from '@things-factory/shell'
|
3
3
|
|
4
|
-
|
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
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { sleep } 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
7
|
function convertDataFormat(data, format) {
|
6
8
|
try {
|
@@ -16,7 +18,7 @@ function convertDataFormat(data, format) {
|
|
16
18
|
return data
|
17
19
|
}
|
18
20
|
|
19
|
-
async function SocketListener(step, context) {
|
21
|
+
async function SocketListener(step: InputStep, context: Context) {
|
20
22
|
//get connection data
|
21
23
|
const {
|
22
24
|
connection: connectionName,
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
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 StateRead(step, { logger, publish, data, domain, user, client }) {
|
6
|
+
async function StateRead(step: InputStep, { logger, publish, data, domain, user, client }: Context) {
|
5
7
|
var {
|
6
8
|
params: { name }
|
7
9
|
} = step
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import gql from 'graphql-tag'
|
2
2
|
import { access } from '@things-factory/utils'
|
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 StateWrite(step, { logger, publish, data, domain, user, client }) {
|
7
|
+
async function StateWrite(step: InputStep, { logger, publish, data, domain, user, client }: Context) {
|
6
8
|
var {
|
7
9
|
params: { name, accessor }
|
8
10
|
} = step
|
@@ -3,8 +3,10 @@ import { getRepository } from '@things-factory/shell'
|
|
3
3
|
import { Scenario } from '../../service/scenario/scenario'
|
4
4
|
import { ScenarioEngine } from '../../engine'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
6
|
+
import { InputStep } from '../../service/step/step-type'
|
7
|
+
import { Context } from '../types'
|
6
8
|
|
7
|
-
async function StopScenario(step, context) {
|
9
|
+
async function StopScenario(step: InputStep, context: Context) {
|
8
10
|
var { logger, domain } = context
|
9
11
|
var {
|
10
12
|
params: { scenario }
|
@@ -3,8 +3,10 @@ import { access, deepClone } from '@things-factory/utils'
|
|
3
3
|
|
4
4
|
import { Scenario } from '../../service/scenario/scenario'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
6
|
+
import { InputStep } from '../../service/step/step-type'
|
7
|
+
import { Context } from '../types'
|
6
8
|
|
7
|
-
async function SubScenario(step, context) {
|
9
|
+
async function SubScenario(step: InputStep, context: Context) {
|
8
10
|
var { logger, load, data } = context
|
9
11
|
var {
|
10
12
|
params: { scenario, variables }
|
@@ -2,7 +2,10 @@ import { access } from '@things-factory/utils'
|
|
2
2
|
|
3
3
|
import { TaskRegistry } from '../task-registry'
|
4
4
|
|
5
|
-
|
5
|
+
import { InputStep } from '../../service/step/step-type'
|
6
|
+
import { Context } from '../types'
|
7
|
+
|
8
|
+
async function SwitchGoTo(step: InputStep, { logger, data }: Context) {
|
6
9
|
var {
|
7
10
|
params: { accessor, cases }
|
8
11
|
} = step
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { access } from '@things-factory/utils'
|
2
2
|
|
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 SwitchRangeGoTo(step, { logger, data }) {
|
7
|
+
async function SwitchRangeGoTo(step: InputStep, { logger, data }: Context) {
|
6
8
|
var {
|
7
9
|
params: { accessor, cases }
|
8
10
|
} = step
|
@@ -3,8 +3,10 @@ import { access, deepClone } from '@things-factory/utils'
|
|
3
3
|
|
4
4
|
import { Scenario } from '../../service/scenario/scenario'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
6
|
+
import { InputStep } from '../../service/step/step-type'
|
7
|
+
import { Context } from '../types'
|
6
8
|
|
7
|
-
async function SwitchRangeScenario(step, context) {
|
9
|
+
async function SwitchRangeScenario(step: InputStep, context: Context) {
|
8
10
|
var { logger, data, load } = context
|
9
11
|
var {
|
10
12
|
params: { accessor, cases, variables }
|
@@ -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 SwitchRangeSet(step, { logger, data }) {
|
6
|
+
async function SwitchRangeSet(step: InputStep, { logger, data }: Context) {
|
5
7
|
var {
|
6
8
|
params: { accessor, cases }
|
7
9
|
} = step
|
@@ -3,8 +3,10 @@ import { access, deepClone } from '@things-factory/utils'
|
|
3
3
|
|
4
4
|
import { Scenario } from '../../service/scenario/scenario'
|
5
5
|
import { TaskRegistry } from '../task-registry'
|
6
|
+
import { InputStep } from '../../service/step/step-type'
|
7
|
+
import { Context } from '../types'
|
6
8
|
|
7
|
-
async function SwitchScenario(step, context) {
|
9
|
+
async function SwitchScenario(step: InputStep, context: Context) {
|
8
10
|
var { logger, data, load } = context
|
9
11
|
var {
|
10
12
|
params: { accessor, cases, variables }
|
@@ -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 SwitchSet(step, { logger, data }) {
|
6
|
+
async function SwitchSet(step: InputStep, { logger, data }: Context) {
|
5
7
|
var {
|
6
8
|
params: { accessor, cases }
|
7
9
|
} = step
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { TaskRegistry } from '../task-registry'
|
2
|
+
import { InputStep } from '../../service/step/step-type'
|
3
|
+
import { Context } from '../types'
|
2
4
|
|
3
|
-
async function Throw(step, { logger }) {
|
5
|
+
async function Throw(step: InputStep, { logger }: Context) {
|
4
6
|
var {
|
5
7
|
name,
|
6
8
|
params: { message }
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { TaskRegistry } from '../task-registry'
|
2
|
+
import { InputStep } from '../../service/step/step-type'
|
3
|
+
import { Context } from '../types'
|
2
4
|
|
3
|
-
async function Variables(step, { variables }) {
|
5
|
+
async function Variables(step: InputStep, { variables }: Context) {
|
4
6
|
return {
|
5
7
|
data: variables instanceof Array ? [...variables] : typeof variables == 'object' ? { ...variables } : variables
|
6
8
|
}
|
package/server/engine/types.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import { Connection, PropertySpec, ScenarioInstanceStatus, Step } from '../service'
|
2
|
+
import { Domain } from '@things-factory/shell'
|
3
|
+
import { User } from '@things-factory/auth-base'
|
2
4
|
|
3
5
|
export interface Connector {
|
4
6
|
ready(connections: Connection[]): Promise<any>
|
@@ -11,23 +13,98 @@ export interface Connector {
|
|
11
13
|
}
|
12
14
|
|
13
15
|
export type Context = {
|
14
|
-
|
15
|
-
|
16
|
+
/**
|
17
|
+
* Represents the domain context.
|
18
|
+
*/
|
19
|
+
domain: Domain
|
20
|
+
|
21
|
+
/**
|
22
|
+
* User information.
|
23
|
+
*/
|
24
|
+
user: User
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Language code, for example 'en', 'ko'.
|
28
|
+
*/
|
16
29
|
lng: string
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Flag to indicate if the IP is unsafe, can be undefined.
|
33
|
+
*/
|
17
34
|
unsafeIP: boolean | undefined
|
35
|
+
|
36
|
+
/**
|
37
|
+
* List of prohibited privileges, can be undefined.
|
38
|
+
*/
|
18
39
|
prohibitedPrivileges: { category: string; privilege: string }[] | undefined
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Logger for logging purposes.
|
43
|
+
*/
|
19
44
|
logger: any
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Function to publish events or messages.
|
48
|
+
*/
|
20
49
|
publish: Function
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Function to load resources or data.
|
53
|
+
*/
|
21
54
|
load: Function
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Current status of the scenario instance.
|
58
|
+
*/
|
22
59
|
state: ScenarioInstanceStatus
|
23
|
-
|
60
|
+
|
61
|
+
/**
|
62
|
+
* General data storage object.
|
63
|
+
*/
|
64
|
+
data: any
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Variables related to the context.
|
68
|
+
*/
|
24
69
|
variables: Object
|
25
|
-
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Local GraphQL client object.
|
73
|
+
*/
|
74
|
+
client: any /* graphql local client */
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Root object, can be used for various purposes.
|
78
|
+
*/
|
26
79
|
root: Object
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Array of function closures.
|
83
|
+
*/
|
27
84
|
closures: Function[]
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Function to check the state.
|
88
|
+
*/
|
28
89
|
checkState: Function
|
90
|
+
|
91
|
+
/**
|
92
|
+
* MQTT subscriber context object.
|
93
|
+
*/
|
94
|
+
__mqtt_subscriber?: any
|
95
|
+
|
96
|
+
/**
|
97
|
+
* socket listener context object.
|
98
|
+
*/
|
99
|
+
__socket_listener?: any
|
100
|
+
|
101
|
+
/**
|
102
|
+
* csv readline context object.
|
103
|
+
*/
|
104
|
+
__csv_resources?: any
|
29
105
|
}
|
30
106
|
|
107
|
+
|
31
108
|
export type TaskHandler = (
|
32
109
|
step: Step,
|
33
110
|
context: Context
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { filter, pipe } from 'graphql-yoga'
|
2
2
|
import { Arg, Resolver, Root, Subscription } from 'type-graphql'
|
3
3
|
|
4
4
|
import { getRepository, Log, pubsub } from '@things-factory/shell'
|
@@ -11,7 +11,7 @@ const debug = require('debug')('things-factory:integration:connection-subscripti
|
|
11
11
|
@Resolver(Connection)
|
12
12
|
export class ConnectionSubscription {
|
13
13
|
@Subscription({
|
14
|
-
subscribe: (
|
14
|
+
subscribe: ({ args, context, info }) => {
|
15
15
|
const { domain, user } = context.state
|
16
16
|
const { name } = args
|
17
17
|
const subdomain = domain?.subdomain
|
@@ -40,35 +40,29 @@ export class ConnectionSubscription {
|
|
40
40
|
pubsub.publish('connection-state', {
|
41
41
|
connectionState: {
|
42
42
|
...connection,
|
43
|
-
state: ConnectionManager.getConnectionInstance(connection)
|
44
|
-
? ConnectionStatus.CONNECTED
|
45
|
-
: ConnectionStatus.DISCONNECTED,
|
43
|
+
state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED,
|
46
44
|
timestamp: new Date()
|
47
45
|
}
|
48
46
|
})
|
49
47
|
})
|
50
48
|
})
|
51
49
|
|
52
|
-
return
|
53
|
-
|
54
|
-
(payload
|
50
|
+
return pipe(
|
51
|
+
pubsub.subscribe('connection-state'),
|
52
|
+
filter(async (payload: { connectionState: ConnectionState }) => {
|
55
53
|
const { domain: pdomain, name: pname } = payload.connectionState
|
56
|
-
const { name } = variables
|
57
54
|
|
58
55
|
return (!name || name === pname) && subdomain === pdomain?.subdomain
|
59
|
-
}
|
60
|
-
)
|
56
|
+
})
|
57
|
+
)
|
61
58
|
}
|
62
59
|
})
|
63
|
-
connectionState(
|
64
|
-
@Root() payload: { connectionState: ConnectionState },
|
65
|
-
@Arg('name', { nullable: true }) name: string
|
66
|
-
): ConnectionState {
|
60
|
+
connectionState(@Root() payload: { connectionState: ConnectionState }, @Arg('name', { nullable: true }) name: string): ConnectionState {
|
67
61
|
return payload.connectionState
|
68
62
|
}
|
69
63
|
|
70
64
|
@Subscription({
|
71
|
-
subscribe: (
|
65
|
+
subscribe: ({ args, context, info }) => {
|
72
66
|
const { domain, user } = context.state
|
73
67
|
const { level } = args
|
74
68
|
|
@@ -84,11 +78,11 @@ export class ConnectionSubscription {
|
|
84
78
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
|
85
79
|
}
|
86
80
|
|
87
|
-
return
|
88
|
-
|
89
|
-
(payload
|
81
|
+
return pipe(
|
82
|
+
pubsub.subscribe('connection-log'),
|
83
|
+
filter(async (payload: { log: Log }) => {
|
90
84
|
// TODO support domain filtering
|
91
|
-
const { /* source, */ level: plevel } = payload.
|
85
|
+
const { /* source, */ level: plevel } = payload.log
|
92
86
|
// const { domain: pdomain } = source
|
93
87
|
|
94
88
|
// if (subdomain !== pdomain?.subdomain) {
|
@@ -100,8 +94,8 @@ export class ConnectionSubscription {
|
|
100
94
|
}
|
101
95
|
|
102
96
|
return true
|
103
|
-
}
|
104
|
-
)
|
97
|
+
})
|
98
|
+
)
|
105
99
|
}
|
106
100
|
})
|
107
101
|
connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {
|