@things-factory/integration-base 7.0.0-alpha.1 → 7.0.0-alpha.21
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/controllers/index.js +5 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/controllers/scenario-controller.js +87 -0
- package/dist-server/controllers/scenario-controller.js.map +1 -0
- package/dist-server/engine/connection-manager.js +37 -6
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js +6 -6
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js +19 -22
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js +113 -17
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/proxy-connector.js +44 -0
- package/dist-server/engine/connector/proxy-connector.js.map +1 -0
- package/dist-server/engine/edge-client.js +38 -0
- package/dist-server/engine/edge-client.js.map +1 -0
- package/dist-server/engine/index.js +1 -0
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.js +1 -15
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/script.js +1 -0
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/engine/task/utils/headless-pool-for-scenario.js +1 -1
- package/dist-server/engine/task/utils/headless-pool-for-scenario.js.map +1 -1
- package/dist-server/engine/types.js.map +1 -1
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/restful/unstable/run-scenario.js.map +1 -1
- package/dist-server/restful/unstable/start-scenario.js +1 -1
- package/dist-server/restful/unstable/start-scenario.js.map +1 -1
- package/dist-server/restful/unstable/stop-scenario.js +1 -1
- package/dist-server/restful/unstable/stop-scenario.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +4 -8
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +17 -14
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +2 -2
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.js +32 -8
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +4 -71
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +18 -5
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/concept/script-internal-variables.ja.md +21 -1
- package/helps/integration/concept/script-internal-variables.ko.md +17 -0
- package/helps/integration/concept/script-internal-variables.md +18 -0
- package/helps/integration/concept/script-internal-variables.ms.md +19 -1
- package/helps/integration/concept/script-internal-variables.zh.md +18 -0
- package/helps/integration/connector/oracle-connector.ja.md +90 -0
- package/helps/integration/connector/oracle-connector.ko.md +87 -0
- package/helps/integration/connector/oracle-connector.md +46 -25
- package/helps/integration/connector/oracle-connector.ms.md +87 -0
- package/helps/integration/connector/oracle-connector.zh.md +87 -0
- package/helps/integration/task/script.ja.md +1 -1
- package/helps/integration/task/script.ko.md +1 -1
- package/helps/integration/task/script.md +1 -1
- package/helps/integration/task/script.ms.md +1 -1
- package/helps/integration/task/script.zh.md +1 -1
- package/openapi/unstable/scenario.yaml +100 -100
- package/openapi/unstable.yaml +11 -11
- package/package.json +7 -11
- package/server/controllers/index.ts +1 -0
- package/server/controllers/scenario-controller.ts +116 -0
- package/server/engine/connection-manager.ts +49 -7
- package/server/engine/connector/graphql-connector.ts +8 -10
- package/server/engine/connector/operato-connector.ts +22 -32
- package/server/engine/connector/oracle-connector.ts +132 -22
- package/server/engine/connector/proxy-connector.ts +53 -0
- package/server/engine/edge-client.ts +45 -0
- package/server/engine/index.ts +1 -0
- package/server/engine/task/oracle-procedure.ts +1 -16
- package/server/engine/task/script.ts +1 -0
- package/server/engine/task/utils/headless-pool-for-scenario.ts +1 -1
- package/server/engine/types.ts +45 -46
- package/server/index.ts +1 -0
- package/server/restful/unstable/run-scenario.ts +0 -1
- package/server/restful/unstable/start-scenario.ts +1 -1
- package/server/restful/unstable/stop-scenario.ts +1 -1
- package/server/service/connection/connection-mutation.ts +9 -29
- package/server/service/connection/connection-query.ts +13 -12
- package/server/service/connection/connection-subscription.ts +2 -2
- package/server/service/connection/connection-type.ts +53 -41
- package/server/service/scenario-instance/scenario-instance-mutation.ts +10 -121
- package/server/service/scenario-instance/scenario-instance-type.ts +24 -13
@@ -23,10 +23,6 @@ const defaultOptions: any = {
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
26
|
-
const cache = new InMemoryCache({
|
27
|
-
addTypename: false
|
28
|
-
})
|
29
|
-
|
30
26
|
export class GraphqlConnector implements Connector {
|
31
27
|
async ready(connectionConfigs: InputConnection[]) {
|
32
28
|
await Promise.all(connectionConfigs.map(this.connect.bind(this)))
|
@@ -35,12 +31,12 @@ export class GraphqlConnector implements Connector {
|
|
35
31
|
}
|
36
32
|
|
37
33
|
async connect(connection: InputConnection) {
|
38
|
-
|
34
|
+
const {
|
39
35
|
endpoint: uri,
|
40
36
|
params: { authClient }
|
41
37
|
} = connection
|
42
38
|
|
43
|
-
|
39
|
+
const ERROR_HANDLER: any = ({ graphQLErrors, networkError }) => {
|
44
40
|
if (graphQLErrors)
|
45
41
|
graphQLErrors.map(({ message, locations, path }) => {
|
46
42
|
ConnectionManager.logger.error(`[GraphQL error] Message: ${message}, Location: ${locations}, Path: ${path}`)
|
@@ -65,6 +61,10 @@ export class GraphqlConnector implements Connector {
|
|
65
61
|
return forward(operation)
|
66
62
|
})
|
67
63
|
|
64
|
+
const cache = new InMemoryCache({
|
65
|
+
addTypename: false
|
66
|
+
})
|
67
|
+
|
68
68
|
ConnectionManager.addConnectionInstance(
|
69
69
|
connection,
|
70
70
|
new ApolloClient({
|
@@ -81,13 +81,11 @@ export class GraphqlConnector implements Connector {
|
|
81
81
|
})
|
82
82
|
)
|
83
83
|
|
84
|
-
ConnectionManager.logger.info(
|
85
|
-
`graphql-connector connection(${connection.name}:${connection.endpoint}) is connected`
|
86
|
-
)
|
84
|
+
ConnectionManager.logger.info(`graphql-connector connection(${connection.name}:${connection.endpoint}) is connected`)
|
87
85
|
}
|
88
86
|
|
89
87
|
async disconnect(connection: InputConnection) {
|
90
|
-
|
88
|
+
const client = ConnectionManager.getConnectionInstance(connection)
|
91
89
|
client.stop()
|
92
90
|
ConnectionManager.removeConnectionInstance(connection)
|
93
91
|
|
@@ -3,7 +3,6 @@ import 'cross-fetch/polyfill'
|
|
3
3
|
import { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client/core'
|
4
4
|
import { setContext } from '@apollo/client/link/context'
|
5
5
|
|
6
|
-
// for subscription
|
7
6
|
import WebSocket from 'ws'
|
8
7
|
import { createClient } from 'graphql-ws'
|
9
8
|
import { GraphQLWsLink } from '@apollo/client/link/subscriptions'
|
@@ -20,7 +19,7 @@ import { ScenarioInstance } from '../../service/scenario-instance/scenario-insta
|
|
20
19
|
import { getRepository, GraphqlLocalClient, Domain } from '@things-factory/shell'
|
21
20
|
import { User, checkPermission } from '@things-factory/auth-base'
|
22
21
|
|
23
|
-
const debug = require('debug')('things-factory:integration-base:operato-connector
|
22
|
+
const debug = require('debug')('things-factory:integration-base:operato-connector')
|
24
23
|
|
25
24
|
const defaultOptions: any = {
|
26
25
|
watchQuery: {
|
@@ -36,10 +35,6 @@ const defaultOptions: any = {
|
|
36
35
|
}
|
37
36
|
}
|
38
37
|
|
39
|
-
const cache = new InMemoryCache({
|
40
|
-
addTypename: false
|
41
|
-
})
|
42
|
-
|
43
38
|
export const GRAPHQL_URI = '/graphql'
|
44
39
|
export const SUBSCRIPTION_URI = GRAPHQL_URI
|
45
40
|
|
@@ -48,7 +43,6 @@ interface SubscriberData {
|
|
48
43
|
scenario: any
|
49
44
|
subscriptionObserver: any
|
50
45
|
}
|
51
|
-
;``
|
52
46
|
|
53
47
|
export class OperatoConnector implements Connector {
|
54
48
|
private context: any
|
@@ -56,11 +50,11 @@ export class OperatoConnector implements Connector {
|
|
56
50
|
async ready(connectionConfigs: InputConnection[]) {
|
57
51
|
await Promise.all(connectionConfigs.map(this.connect.bind(this)))
|
58
52
|
|
59
|
-
ConnectionManager.logger.info('
|
53
|
+
ConnectionManager.logger.info('operato-connector connections are ready')
|
60
54
|
}
|
61
55
|
|
62
56
|
async connect(connection: InputConnection) {
|
63
|
-
|
57
|
+
const {
|
64
58
|
endpoint: uri,
|
65
59
|
params: { authKey, domain, subscriptionHandlers = {} }
|
66
60
|
} = connection
|
@@ -69,7 +63,7 @@ export class OperatoConnector implements Connector {
|
|
69
63
|
throw new Error('some connection paramter missing.')
|
70
64
|
}
|
71
65
|
|
72
|
-
|
66
|
+
const domainOwner = await getRepository(User).findOne({
|
73
67
|
where: {
|
74
68
|
id: connection.domain.owner
|
75
69
|
}
|
@@ -125,20 +119,24 @@ export class OperatoConnector implements Connector {
|
|
125
119
|
}).concat(httpLink)
|
126
120
|
)
|
127
121
|
|
128
|
-
|
122
|
+
const cache = new InMemoryCache({
|
123
|
+
addTypename: false
|
124
|
+
})
|
125
|
+
|
126
|
+
const client = new ApolloClient({
|
129
127
|
defaultOptions,
|
130
128
|
cache,
|
131
129
|
link: splitLink
|
132
130
|
})
|
133
131
|
|
134
|
-
|
132
|
+
const subscriptions: SubscriberData[] = []
|
135
133
|
Object.keys(subscriptionHandlers).forEach(async tag => {
|
136
134
|
if (!tag || !subscriptionHandlers[tag]) return
|
137
135
|
|
138
|
-
|
136
|
+
const scenarioName = subscriptionHandlers[tag]
|
139
137
|
|
140
138
|
// fetch a scenario
|
141
|
-
|
139
|
+
const selectedScenario = await getRepository(Scenario).findOne({
|
142
140
|
where: {
|
143
141
|
name: scenarioName
|
144
142
|
},
|
@@ -156,7 +154,7 @@ export class OperatoConnector implements Connector {
|
|
156
154
|
`
|
157
155
|
})
|
158
156
|
|
159
|
-
|
157
|
+
const subscriptionObserver = subscription.subscribe({
|
160
158
|
next: async data => {
|
161
159
|
debug('received pubsub msg.:', data?.data)
|
162
160
|
await this.runScenario(subscriptions, data?.data?.data)
|
@@ -169,9 +167,7 @@ export class OperatoConnector implements Connector {
|
|
169
167
|
}
|
170
168
|
})
|
171
169
|
|
172
|
-
ConnectionManager.logger.info(
|
173
|
-
`(${connection.name}:${connection.endpoint}) subscription closed flag: ${subscriptionObserver.closed}`
|
174
|
-
)
|
170
|
+
ConnectionManager.logger.info(`(${connection.name}:${connection.endpoint}) subscription closed flag: ${subscriptionObserver.closed}`)
|
175
171
|
|
176
172
|
subscriptions.push({
|
177
173
|
tag,
|
@@ -184,19 +180,17 @@ export class OperatoConnector implements Connector {
|
|
184
180
|
client['subscriptions'] = subscriptions
|
185
181
|
ConnectionManager.addConnectionInstance(connection, client)
|
186
182
|
|
187
|
-
ConnectionManager.logger.info(
|
188
|
-
`graphql-connector connection(${connection.name}:${connection.endpoint}) is connected`
|
189
|
-
)
|
183
|
+
ConnectionManager.logger.info(`operato-connector connection(${connection.name}:${connection.endpoint}) is connected`)
|
190
184
|
}
|
191
185
|
|
192
186
|
async disconnect(connection: InputConnection) {
|
193
|
-
|
194
|
-
|
187
|
+
const client = ConnectionManager.getConnectionInstance(connection)
|
188
|
+
const subscriptions: SubscriberData[] = client['subscriptions']
|
195
189
|
subscriptions.forEach(subscription => subscription.subscriptionObserver.unsubscribe())
|
196
190
|
client.stop()
|
197
191
|
ConnectionManager.removeConnectionInstance(connection)
|
198
192
|
|
199
|
-
ConnectionManager.logger.info(`
|
193
|
+
ConnectionManager.logger.info(`operato-connector connection(${connection.name}) is disconnected`)
|
200
194
|
}
|
201
195
|
|
202
196
|
async runScenario(subscriptions: SubscriberData[], variables: any): Promise<ScenarioInstance> {
|
@@ -207,23 +201,19 @@ export class OperatoConnector implements Connector {
|
|
207
201
|
throw new Error(`tag is invalid - ${tag}`)
|
208
202
|
}
|
209
203
|
|
210
|
-
|
204
|
+
const scenario = subscriptions.find(subscription => subscription.tag === tag)?.scenario
|
211
205
|
if (!scenario) {
|
212
206
|
throw new Error(`scenario is not found - ${tag}`)
|
213
207
|
}
|
214
208
|
|
215
209
|
if (!(await checkPermission(scenario.privilege, user, domain, unsafeIP, prohibitedPrivileges))) {
|
216
210
|
const { category, privilege } = scenario.privilege || {}
|
217
|
-
throw new Error(
|
218
|
-
`Unauthorized! ${
|
219
|
-
category && privilege ? category + ':' + privilege + ' privilege' : 'ownership granted'
|
220
|
-
} required`
|
221
|
-
)
|
211
|
+
throw new Error(`Unauthorized! ${category && privilege ? category + ':' + privilege + ' privilege' : 'ownership granted'} required`)
|
222
212
|
}
|
223
213
|
|
224
214
|
/* create a scenario instance */
|
225
|
-
|
226
|
-
|
215
|
+
const instanceName = scenario.name + '-' + String(Date.now())
|
216
|
+
const instance = new ScenarioInstance(instanceName, scenario, {
|
227
217
|
user,
|
228
218
|
domain,
|
229
219
|
variables,
|
@@ -4,9 +4,8 @@ import { ConnectionManager } from '../connection-manager'
|
|
4
4
|
import { Connector } from '../types'
|
5
5
|
import { InputConnection } from '../../service/connection/connection-type'
|
6
6
|
|
7
|
-
|
8
7
|
try {
|
9
|
-
var
|
8
|
+
var oracledb = require('oracledb')
|
10
9
|
} catch (err) {
|
11
10
|
logger.error('oracledb module loading failed')
|
12
11
|
}
|
@@ -18,42 +17,132 @@ export class OracleConnector implements Connector {
|
|
18
17
|
ConnectionManager.logger.info('oracle-connector connections are ready')
|
19
18
|
}
|
20
19
|
|
21
|
-
async
|
20
|
+
async recreatePool(connection: InputConnection) {
|
22
21
|
const {
|
22
|
+
name,
|
23
23
|
endpoint,
|
24
|
-
params: { user, password, database }
|
24
|
+
params: { user, password, database, poolMin, poolMax, poolIncrement },
|
25
|
+
domain
|
25
26
|
} = connection
|
26
27
|
|
27
|
-
if (!
|
28
|
+
if (!oracledb) {
|
28
29
|
throw new Error('oracledb module loading failed')
|
29
30
|
}
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
const poolAlias = `${domain.name}-${name}`
|
33
|
+
await oracledb.getPool(poolAlias).close(10)
|
34
|
+
await oracledb.createPool({
|
33
35
|
user,
|
34
36
|
password,
|
35
|
-
|
37
|
+
// when oracle not using default port must add connection string with port like localhost:port
|
38
|
+
connectString: `${endpoint.trim()}/${database}`,
|
39
|
+
poolMin,
|
40
|
+
poolMax,
|
41
|
+
poolIncrement,
|
42
|
+
poolAlias
|
36
43
|
})
|
37
44
|
|
45
|
+
ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} recreated.`)
|
46
|
+
}
|
47
|
+
|
48
|
+
async connect(connection: InputConnection) {
|
49
|
+
const {
|
50
|
+
name,
|
51
|
+
endpoint,
|
52
|
+
params: { user, password, database, poolMin, poolMax, poolIncrement },
|
53
|
+
domain
|
54
|
+
} = connection
|
55
|
+
|
56
|
+
if (!oracledb) {
|
57
|
+
throw new Error('oracledb module loading failed')
|
58
|
+
}
|
59
|
+
|
60
|
+
const poolAlias = `${domain.name}-${name}`
|
61
|
+
|
62
|
+
var enableStatistics = true
|
63
|
+
const pool = await oracledb.createPool({
|
64
|
+
user,
|
65
|
+
password,
|
66
|
+
// when oracle not using default port must add connection string with port like localhost:port
|
67
|
+
connectString: `${endpoint.trim()}/${database}`,
|
68
|
+
poolMin,
|
69
|
+
poolMax,
|
70
|
+
poolIncrement,
|
71
|
+
poolAlias,
|
72
|
+
enableStatistics
|
73
|
+
})
|
74
|
+
|
38
75
|
ConnectionManager.addConnectionInstance(connection, {
|
39
76
|
query: async (query, params) => {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
77
|
+
let dbConnection: any = {}
|
78
|
+
let taskResult: any = {}
|
79
|
+
try {
|
80
|
+
dbConnection = await oracledb.getConnection(poolAlias)
|
81
|
+
|
82
|
+
taskResult = (
|
83
|
+
await dbConnection.execute(query, params, {
|
84
|
+
outFormat: oracledb.OBJECT
|
85
|
+
})
|
86
|
+
).rows
|
87
|
+
} catch (e) {
|
88
|
+
if (e.name === 'Error' && e.message.includes('NJS-040')) {
|
89
|
+
await this.recreatePool(connection)
|
90
|
+
}
|
91
|
+
throw e
|
92
|
+
}
|
93
|
+
finally {
|
94
|
+
await dbConnection.close()
|
95
|
+
}
|
96
|
+
return taskResult
|
97
|
+
|
45
98
|
},
|
46
99
|
execute: async (procedure, params) => {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
100
|
+
let dbConnection: any = {}
|
101
|
+
let taskResult: any = {}
|
102
|
+
try {
|
103
|
+
// TODO: need to check if this is available when procedure string is a common query.
|
104
|
+
procedure = `BEGIN
|
105
|
+
${procedure}
|
106
|
+
END;`
|
107
|
+
dbConnection = await oracledb.getConnection(poolAlias)
|
108
|
+
|
109
|
+
// console.log('\n************* stat after get ****************')
|
110
|
+
// await oracledb.getPool(poolAlias).logStatistics()
|
111
|
+
|
112
|
+
const result = await dbConnection.execute(procedure, params, {
|
113
|
+
outFormat: oracledb.OBJECT
|
114
|
+
})
|
115
|
+
|
116
|
+
let paramKeys = Object.keys(params)
|
117
|
+
|
118
|
+
for (const paramKey of paramKeys) {
|
119
|
+
if (params[paramKey].dir === oracledb?.BIND_OUT) {
|
120
|
+
if (params[paramKey].type === oracledb?.CURSOR) {
|
121
|
+
const resultSetTemp = result.outBinds[paramKey]
|
122
|
+
taskResult[paramKey] = await resultSetTemp.getRows()
|
123
|
+
await resultSetTemp.close()
|
124
|
+
} else {
|
125
|
+
taskResult[paramKey] = result.outBinds[paramKey]
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
} catch (e) {
|
130
|
+
if (e.name === 'Error' && e.message.includes('NJS-040')) {
|
131
|
+
await this.recreatePool(connection)
|
132
|
+
}
|
133
|
+
throw e
|
134
|
+
}
|
135
|
+
finally {
|
136
|
+
await dbConnection.close()
|
137
|
+
|
138
|
+
// console.log('\n************* stat after close ****************')
|
139
|
+
// await oracledb.getPool(poolAlias).logStatistics()
|
140
|
+
}
|
141
|
+
return taskResult
|
55
142
|
},
|
56
|
-
close:
|
143
|
+
close: async () => {
|
144
|
+
await oracledb.getPool(poolAlias).close(10)
|
145
|
+
}
|
57
146
|
})
|
58
147
|
|
59
148
|
ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)
|
@@ -89,6 +178,27 @@ export class OracleConnector implements Connector {
|
|
89
178
|
name: 'database',
|
90
179
|
placeholder: 'SID',
|
91
180
|
label: 'database'
|
181
|
+
},
|
182
|
+
{
|
183
|
+
type: 'number',
|
184
|
+
name: 'poolMin',
|
185
|
+
placeholder: 'minimum connection-pool size',
|
186
|
+
label: 'pool-min',
|
187
|
+
value: 0
|
188
|
+
},
|
189
|
+
{
|
190
|
+
type: 'number',
|
191
|
+
name: 'poolMax',
|
192
|
+
placeholder: 'maximum connection-pool size',
|
193
|
+
label: 'pool-max',
|
194
|
+
value: 4
|
195
|
+
},
|
196
|
+
{
|
197
|
+
type: 'number',
|
198
|
+
name: 'poolIncrement',
|
199
|
+
placeholder: 'connection incremental size',
|
200
|
+
label: 'pool-increment',
|
201
|
+
value: 1
|
92
202
|
}
|
93
203
|
]
|
94
204
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { ConnectionManager } from '../connection-manager'
|
2
|
+
import { Connector } from '../types'
|
3
|
+
import { InputConnection } from '../../service/connection/connection-type'
|
4
|
+
import { connectConnections, disconnectConnections } from '../edge-client'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* This connector is a proxy connector installed on the edge server to manage connections from the host.
|
8
|
+
* It interacts with connections established on the edge server and provides synchronization functionality.
|
9
|
+
*/
|
10
|
+
export class ProxyConnector implements Connector {
|
11
|
+
public static instance = new ProxyConnector()
|
12
|
+
|
13
|
+
async ready(connectionConfigs: InputConnection[]) {
|
14
|
+
await Promise.all(connectionConfigs.map(this.connect.bind(this)))
|
15
|
+
|
16
|
+
ConnectionManager.logger.info('proxy-connector connections are ready')
|
17
|
+
}
|
18
|
+
|
19
|
+
async connect(connection: InputConnection) {
|
20
|
+
// TODO 원래 커넥션과 에지설정을 참고하여, 에지 서버로 CONNECT/DISCONNECT 명령을 보낸다.
|
21
|
+
const proxy = {
|
22
|
+
disconnect: async () => {
|
23
|
+
ConnectionManager.logger.info('[proxy-connector] trying disconnect')
|
24
|
+
await disconnectConnections([connection])
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
await connectConnections([connection])
|
29
|
+
|
30
|
+
ConnectionManager.addConnectionInstance(connection, proxy)
|
31
|
+
|
32
|
+
ConnectionManager.logger.info(`proxy-connector connection(${connection.name}:${connection.endpoint}) is connected`)
|
33
|
+
}
|
34
|
+
|
35
|
+
async disconnect(connection: InputConnection) {
|
36
|
+
const proxy = ConnectionManager.removeConnectionInstance(connection)
|
37
|
+
await proxy.disconnect()
|
38
|
+
|
39
|
+
ConnectionManager.logger.info(`proxy-connector connection(${connection.name}) is disconnected`)
|
40
|
+
}
|
41
|
+
|
42
|
+
get parameterSpec() {
|
43
|
+
return []
|
44
|
+
}
|
45
|
+
|
46
|
+
get taskPrefixes() {
|
47
|
+
return []
|
48
|
+
}
|
49
|
+
|
50
|
+
get description() {
|
51
|
+
return 'Operato Proxy Connector'
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { Connection } from '../service/connection/connection-type'
|
2
|
+
import { Step } from '../service/step/step-type'
|
3
|
+
import { Context, TaskHandler } from './types'
|
4
|
+
|
5
|
+
export type EdgeClient = {
|
6
|
+
handler: TaskHandler
|
7
|
+
syncConnections(connections: Connection[], context?: ResolverContext): Promise<any>
|
8
|
+
connectConnections(connections: Connection[], context?: ResolverContext): Promise<any>
|
9
|
+
disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any>
|
10
|
+
}
|
11
|
+
|
12
|
+
var edgeClient: EdgeClient = {
|
13
|
+
async handler(step: Step, scenarioContext: Context) {
|
14
|
+
throw 'edgeClient not supported'
|
15
|
+
},
|
16
|
+
async syncConnections(connections: Connection[], context: ResolverContext): Promise<any> {
|
17
|
+
throw 'edgeClient not supported'
|
18
|
+
},
|
19
|
+
async connectConnections(connections: Connection[], context: ResolverContext): Promise<any> {
|
20
|
+
throw 'edgeClient not supported'
|
21
|
+
},
|
22
|
+
async disconnectConnections(connections: Connection[], context: ResolverContext): Promise<any> {
|
23
|
+
throw 'edgeClient not supported'
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
export async function handler(step: Step, scenarioContext: Context) {
|
28
|
+
return await edgeClient.handler(step, scenarioContext)
|
29
|
+
}
|
30
|
+
|
31
|
+
export async function syncConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
|
32
|
+
return await edgeClient.syncConnections(connections, context)
|
33
|
+
}
|
34
|
+
|
35
|
+
export async function connectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
|
36
|
+
return await edgeClient.connectConnections(connections, context)
|
37
|
+
}
|
38
|
+
|
39
|
+
export async function disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {
|
40
|
+
return await edgeClient.disconnectConnections(connections, context)
|
41
|
+
}
|
42
|
+
|
43
|
+
export function setEdgeClient(edge: EdgeClient) {
|
44
|
+
edgeClient = edge
|
45
|
+
}
|
package/server/engine/index.ts
CHANGED
@@ -97,23 +97,8 @@ async function OracleProcedure(step: InputStep, context: Context) {
|
|
97
97
|
|
98
98
|
const result = await dbconnection.execute(code, procedureParameters)
|
99
99
|
|
100
|
-
var taskResult = {}
|
101
|
-
let paramKeys = Object.keys(procedureParameters)
|
102
|
-
|
103
|
-
for (const paramKey of paramKeys) {
|
104
|
-
if (procedureParameters[paramKey].dir === oracledb?.BIND_OUT) {
|
105
|
-
if (procedureParameters[paramKey].type === oracledb?.CURSOR) {
|
106
|
-
const resultSetTemp = result.outBinds[paramKey]
|
107
|
-
taskResult[paramKey] = await resultSetTemp.getRows()
|
108
|
-
await resultSetTemp.close()
|
109
|
-
} else {
|
110
|
-
taskResult[paramKey] = result.outBinds[paramKey]
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
100
|
return {
|
116
|
-
data:
|
101
|
+
data: result
|
117
102
|
}
|
118
103
|
}
|
119
104
|
|
package/server/engine/types.ts
CHANGED
@@ -13,79 +13,79 @@ export interface Connector {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
export type Context = {
|
16
|
-
/**
|
17
|
-
|
18
|
-
|
16
|
+
/**
|
17
|
+
* Represents the domain context.
|
18
|
+
*/
|
19
19
|
domain: Domain
|
20
20
|
|
21
|
-
/**
|
22
|
-
|
23
|
-
|
21
|
+
/**
|
22
|
+
* User information.
|
23
|
+
*/
|
24
24
|
user: User
|
25
25
|
|
26
|
-
/**
|
27
|
-
|
28
|
-
|
26
|
+
/**
|
27
|
+
* Language code, for example 'en', 'ko'.
|
28
|
+
*/
|
29
29
|
lng: string
|
30
30
|
|
31
|
-
/**
|
32
|
-
|
33
|
-
|
31
|
+
/**
|
32
|
+
* Flag to indicate if the IP is unsafe, can be undefined.
|
33
|
+
*/
|
34
34
|
unsafeIP: boolean | undefined
|
35
35
|
|
36
|
-
/**
|
37
|
-
|
38
|
-
|
36
|
+
/**
|
37
|
+
* List of prohibited privileges, can be undefined.
|
38
|
+
*/
|
39
39
|
prohibitedPrivileges: { category: string; privilege: string }[] | undefined
|
40
40
|
|
41
|
-
/**
|
42
|
-
|
43
|
-
|
41
|
+
/**
|
42
|
+
* Logger for logging purposes.
|
43
|
+
*/
|
44
44
|
logger: any
|
45
45
|
|
46
|
-
/**
|
47
|
-
|
48
|
-
|
46
|
+
/**
|
47
|
+
* Function to publish events or messages.
|
48
|
+
*/
|
49
49
|
publish: Function
|
50
50
|
|
51
|
-
/**
|
52
|
-
|
53
|
-
|
51
|
+
/**
|
52
|
+
* Function to load resources or data.
|
53
|
+
*/
|
54
54
|
load: Function
|
55
55
|
|
56
|
-
/**
|
57
|
-
|
58
|
-
|
56
|
+
/**
|
57
|
+
* Current status of the scenario instance.
|
58
|
+
*/
|
59
59
|
state: ScenarioInstanceStatus
|
60
60
|
|
61
|
-
/**
|
62
|
-
|
63
|
-
|
61
|
+
/**
|
62
|
+
* General data storage object.
|
63
|
+
*/
|
64
64
|
data: any
|
65
65
|
|
66
|
-
/**
|
67
|
-
|
68
|
-
|
66
|
+
/**
|
67
|
+
* Variables related to the context.
|
68
|
+
*/
|
69
69
|
variables: Object
|
70
70
|
|
71
|
-
/**
|
72
|
-
|
73
|
-
|
71
|
+
/**
|
72
|
+
* Local GraphQL client object.
|
73
|
+
*/
|
74
74
|
client: any /* graphql local client */
|
75
75
|
|
76
|
-
/**
|
77
|
-
|
78
|
-
|
76
|
+
/**
|
77
|
+
* Root object, can be used for various purposes.
|
78
|
+
*/
|
79
79
|
root: Object
|
80
80
|
|
81
|
-
/**
|
82
|
-
|
83
|
-
|
81
|
+
/**
|
82
|
+
* Array of function closures.
|
83
|
+
*/
|
84
84
|
closures: Function[]
|
85
85
|
|
86
|
-
/**
|
87
|
-
|
88
|
-
|
86
|
+
/**
|
87
|
+
* Function to check the state.
|
88
|
+
*/
|
89
89
|
checkState: Function
|
90
90
|
|
91
91
|
/**
|
@@ -104,7 +104,6 @@ export type Context = {
|
|
104
104
|
__csv_resources?: any
|
105
105
|
}
|
106
106
|
|
107
|
-
|
108
107
|
export type TaskHandler = (
|
109
108
|
step: Step,
|
110
109
|
context: Context
|