@things-factory/integration-base 6.2.86 → 6.2.88
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-type.js +34 -5
- package/dist-server/service/connection/connection-type.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-type.ts +67 -0
- 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
|
@@ -30,72 +30,126 @@ registerEnumType(ConnectionStatus, {
|
|
30
30
|
@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })
|
31
31
|
@ObjectType()
|
32
32
|
export class Connection {
|
33
|
+
/**
|
34
|
+
* Unique identifier for the connection, generated in UUID format.
|
35
|
+
*/
|
33
36
|
@PrimaryGeneratedColumn('uuid')
|
34
37
|
@Field(type => ID)
|
35
38
|
readonly id: string
|
36
39
|
|
40
|
+
/**
|
41
|
+
* Many-to-One relationship with the Domain entity.
|
42
|
+
*/
|
37
43
|
@ManyToOne(type => Domain)
|
38
44
|
@Field({ nullable: true })
|
39
45
|
domain: Domain
|
40
46
|
|
47
|
+
/**
|
48
|
+
* Stores the ID of the associated Domain.
|
49
|
+
*/
|
41
50
|
@RelationId((connection: Connection) => connection.domain)
|
42
51
|
domainId: string
|
43
52
|
|
53
|
+
/**
|
54
|
+
* The name of the connection.
|
55
|
+
*/
|
44
56
|
@Column()
|
45
57
|
@Field()
|
46
58
|
name: string
|
47
59
|
|
60
|
+
/**
|
61
|
+
* Optional description for the connection.
|
62
|
+
*/
|
48
63
|
@Column({
|
49
64
|
nullable: true
|
50
65
|
})
|
51
66
|
@Field({ nullable: true })
|
52
67
|
description: string
|
53
68
|
|
69
|
+
/**
|
70
|
+
* The type of the connection.
|
71
|
+
*/
|
54
72
|
@Column()
|
55
73
|
@Field({ nullable: true })
|
56
74
|
type: string
|
57
75
|
|
76
|
+
/**
|
77
|
+
* The endpoint for the connection.
|
78
|
+
*/
|
58
79
|
@Column()
|
59
80
|
@Field({ nullable: true })
|
60
81
|
endpoint: string
|
61
82
|
|
83
|
+
/**
|
84
|
+
* Indicates the active status of the connection.
|
85
|
+
*/
|
62
86
|
@Column({
|
63
87
|
nullable: true
|
64
88
|
})
|
65
89
|
@Field({ nullable: true })
|
66
90
|
active: boolean
|
67
91
|
|
92
|
+
/**
|
93
|
+
* The status of the connection, using the ConnectionStatus type.
|
94
|
+
*/
|
68
95
|
@Field({ nullable: true })
|
69
96
|
state: ConnectionStatus
|
70
97
|
|
98
|
+
/**
|
99
|
+
* Additional parameters for the connection, stored as a JSON string.
|
100
|
+
*/
|
71
101
|
@Column({
|
72
102
|
nullable: true
|
73
103
|
})
|
74
104
|
@Field({ nullable: true })
|
75
105
|
params: string
|
76
106
|
|
107
|
+
/**
|
108
|
+
* The date and time when the connection was created.
|
109
|
+
*/
|
77
110
|
@CreateDateColumn()
|
78
111
|
@Field({ nullable: true })
|
79
112
|
createdAt: Date
|
80
113
|
|
114
|
+
/**
|
115
|
+
* The date and time when the connection was last updated.
|
116
|
+
*/
|
81
117
|
@UpdateDateColumn()
|
82
118
|
@Field({ nullable: true })
|
83
119
|
updatedAt: Date
|
84
120
|
|
121
|
+
/**
|
122
|
+
* Many-to-One relationship with the User entity who created the connection. Optional field.
|
123
|
+
*/
|
85
124
|
@ManyToOne(type => User, { nullable: true })
|
86
125
|
@Field({ nullable: true })
|
87
126
|
creator: User
|
88
127
|
|
128
|
+
/**
|
129
|
+
* Stores the ID of the User who created the connection.
|
130
|
+
*/
|
89
131
|
@RelationId((connection: Connection) => connection.creator)
|
90
132
|
creatorId: string
|
91
133
|
|
134
|
+
/**
|
135
|
+
* Many-to-One relationship with the User entity who last updated the connection.
|
136
|
+
* Optional field.
|
137
|
+
*/
|
92
138
|
@ManyToOne(type => User, { nullable: true })
|
93
139
|
@Field({ nullable: true })
|
94
140
|
updater: User
|
95
141
|
|
142
|
+
/**
|
143
|
+
* Stores the ID of the User who last updated the connection.
|
144
|
+
*
|
145
|
+
*/
|
96
146
|
@RelationId((connection: Connection) => connection.updater)
|
97
147
|
updaterId: string
|
98
148
|
|
149
|
+
/**
|
150
|
+
* Asynchronous method to establish the connection.
|
151
|
+
*
|
152
|
+
*/
|
99
153
|
async connect() {
|
100
154
|
var connector = ConnectionManager.getConnector(this.type)
|
101
155
|
var params = {}
|
@@ -112,6 +166,10 @@ export class Connection {
|
|
112
166
|
})
|
113
167
|
}
|
114
168
|
|
169
|
+
/**
|
170
|
+
* @brief Asynchronous method to disconnect the connection.
|
171
|
+
*
|
172
|
+
*/
|
115
173
|
async disconnect() {
|
116
174
|
try {
|
117
175
|
var connector = ConnectionManager.getConnector(this.type)
|
@@ -121,6 +179,15 @@ export class Connection {
|
|
121
179
|
}
|
122
180
|
}
|
123
181
|
|
182
|
+
/**
|
183
|
+
* Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
|
184
|
+
* 추후, 타입 일치를 통해서 제거할 예정임.
|
185
|
+
*
|
186
|
+
*/
|
187
|
+
export interface InputConnection extends Connection {
|
188
|
+
params: any;
|
189
|
+
}
|
190
|
+
|
124
191
|
@ObjectType()
|
125
192
|
export class ConnectionState {
|
126
193
|
@Field({ nullable: true })
|