@things-factory/integration-base 5.0.11 → 6.0.0-alpha.3
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 +1 -2
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js +4 -4
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/http-connector.js +3 -3
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js +1 -1
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/scenario-engine.js +1 -2
- package/dist-server/engine/scenario-engine.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js +3 -2
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.js +3 -2
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js +4 -4
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js +3 -3
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js +2 -2
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js +2 -2
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/routers/scenario-view-router.js +6 -5
- package/dist-server/routers/scenario-view-router.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +8 -7
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +7 -9
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +4 -6
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.js +4 -5
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connector/connector-query.js +4 -4
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js +11 -8
- package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-query.js +7 -9
- package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log.js +8 -4
- package/dist-server/service/payload-log/payload-log.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +13 -8
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +9 -11
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +3 -4
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario-flow/scenario-flow.js +1 -2
- package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +4 -5
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-query.js +1 -2
- package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +1 -2
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +3 -3
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-type.js +1 -2
- package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +3 -3
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.js +8 -10
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/service/step/step-type.js +3 -4
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +5 -5
- package/dist-server/service/task-type/task-type-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/server/engine/connection-manager.ts +1 -2
- package/server/engine/connector/graphql-connector.ts +5 -5
- package/server/engine/connector/http-connector.ts +5 -5
- package/server/engine/connector/oracle-connector.ts +1 -1
- package/server/engine/scenario-engine.ts +2 -2
- package/server/engine/task/local-graphql-mutate.ts +3 -2
- package/server/engine/task/local-graphql-query.ts +3 -2
- package/server/engine/task/pick-pending-scenario.ts +4 -3
- package/server/engine/task/sub-scenario.ts +3 -2
- package/server/engine/task/switch-range-scenario.ts +1 -2
- package/server/engine/task/switch-scenario.ts +1 -2
- package/server/routers/scenario-view-router.ts +8 -8
- package/server/service/connection/connection-mutation.ts +21 -13
- package/server/service/connection/connection-query.ts +8 -9
- package/server/service/connection/connection-subscription.ts +5 -4
- package/server/service/connector/connector-query.ts +9 -7
- package/server/service/payload-log/payload-log-mutation.ts +25 -21
- package/server/service/payload-log/payload-log-query.ts +7 -8
- package/server/service/payload-log/payload-log.ts +5 -2
- package/server/service/scenario/scenario-mutation.ts +26 -20
- package/server/service/scenario/scenario-query.ts +11 -12
- package/server/service/scenario-instance/scenario-instance-mutation.ts +6 -7
- package/server/service/scenario-instance/scenario-instance-query.ts +5 -2
- package/server/service/step/step-mutation.ts +5 -5
- package/server/service/step/step-query.ts +8 -9
- package/server/service/task-type/task-type-query.ts +10 -8
- package/db.test.sqlite +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"author": "heartyoh",
|
|
8
|
+
"author": "heartyoh <heartyoh@hatiolab.com>",
|
|
9
9
|
"description": "Module for managing integration scenario.",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apollo/client": "^3.6.9",
|
|
29
|
-
"@things-factory/api": "^
|
|
30
|
-
"@things-factory/auth-base": "^
|
|
31
|
-
"@things-factory/env": "^
|
|
32
|
-
"@things-factory/oauth2-client": "^
|
|
33
|
-
"@things-factory/shell": "^
|
|
29
|
+
"@things-factory/api": "^6.0.0-alpha.3",
|
|
30
|
+
"@things-factory/auth-base": "^6.0.0-alpha.3",
|
|
31
|
+
"@things-factory/env": "^6.0.0-alpha.3",
|
|
32
|
+
"@things-factory/oauth2-client": "^6.0.0-alpha.3",
|
|
33
|
+
"@things-factory/shell": "^6.0.0-alpha.3",
|
|
34
34
|
"async-mqtt": "^2.5.0",
|
|
35
35
|
"cron": "^1.7.2",
|
|
36
36
|
"cross-fetch": "^3.0.4",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"promise-socket": "^7.0.0",
|
|
42
42
|
"vm2": "^3.9.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "1e273b6485662da938cae8fdca035d994ef4a95d"
|
|
45
45
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import moment from 'moment-timezone'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
import { createLogger, format, transports } from 'winston'
|
|
4
3
|
|
|
5
|
-
import { Domain, pubsub, PubSubLogTransport } from '@things-factory/shell'
|
|
4
|
+
import { Domain, getRepository, pubsub, PubSubLogTransport } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { Connection, ConnectionStatus } from '../service'
|
|
8
7
|
import { Connector } from './types'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import 'cross-fetch/polyfill'
|
|
2
2
|
|
|
3
|
-
import { ApolloClient, ApolloLink, HttpLink, InMemoryCache
|
|
3
|
+
import { ApolloClient, ApolloLink, from, HttpLink, InMemoryCache } from '@apollo/client/core'
|
|
4
|
+
import { onError } from '@apollo/client/link/error'
|
|
5
|
+
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
6
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
7
|
|
|
5
8
|
import { ConnectionManager } from '../connection-manager'
|
|
6
9
|
import { Connector } from '../types'
|
|
7
|
-
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
8
|
-
import { getRepository } from 'typeorm'
|
|
9
|
-
import { onError } from '@apollo/client/link/error'
|
|
10
10
|
|
|
11
11
|
const defaultOptions: any = {
|
|
12
12
|
watchQuery: {
|
|
@@ -50,7 +50,7 @@ export class GraphqlConnector implements Connector {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).
|
|
53
|
+
const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).findOneBy({ id: authClient })
|
|
54
54
|
|
|
55
55
|
const authMiddleware = new ApolloLink((operation, forward) => {
|
|
56
56
|
// add the authorization to the headers
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Connector } from '../types'
|
|
2
|
-
import { ConnectionManager } from '../connection-manager'
|
|
3
|
-
|
|
4
|
-
import { getRepository } from 'typeorm'
|
|
5
1
|
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
2
|
+
import { getRepository } from '@things-factory/shell'
|
|
3
|
+
|
|
4
|
+
import { ConnectionManager } from '../connection-manager'
|
|
5
|
+
import { Connector } from '../types'
|
|
6
6
|
|
|
7
7
|
export class HttpConnector implements Connector {
|
|
8
8
|
async ready(connectionConfigs) {
|
|
@@ -16,7 +16,7 @@ export class HttpConnector implements Connector {
|
|
|
16
16
|
params.rejectUnauthorized = (params.rejectUnauthorized || 'Y') === 'Y'
|
|
17
17
|
|
|
18
18
|
if (params.authClient) {
|
|
19
|
-
const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).
|
|
19
|
+
const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).findOneBy({ id: params.authClient })
|
|
20
20
|
var authHeaders = oauth2Client.getAuthHeaders()
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ export class OracleConnector implements Connector {
|
|
|
26
26
|
throw new Error('oracledb module loading failed')
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
//when oracle not using
|
|
29
|
+
//when oracle not using default port must add connection string with port like localhsot:port
|
|
30
30
|
const client = await Client.getConnection({
|
|
31
31
|
user,
|
|
32
32
|
password,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getRepository } from '
|
|
2
|
-
|
|
1
|
+
import { getRepository, GraphqlLocalClient, pubsub } from '@things-factory/shell'
|
|
2
|
+
|
|
3
3
|
import { Scenario, ScenarioInstance } from '../service'
|
|
4
4
|
import { PendingQueue } from './pending-queue'
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import gql from 'graphql-tag'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
import { VM } from 'vm2'
|
|
4
3
|
|
|
5
4
|
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { getRepository } from '@things-factory/shell'
|
|
6
6
|
import { access } from '@things-factory/utils'
|
|
7
7
|
|
|
8
8
|
import { TaskRegistry } from '../task-registry'
|
|
@@ -12,7 +12,8 @@ async function LocalGraphqlMutate(step, context) {
|
|
|
12
12
|
var { mutation, variables: variablesAccessorMap } = params || {}
|
|
13
13
|
var { client, domain, data, variables } = context
|
|
14
14
|
|
|
15
|
-
const user = await getRepository(User).findOne(
|
|
15
|
+
const user = await getRepository(User).findOne({
|
|
16
|
+
where: { id: updaterId },
|
|
16
17
|
relations: ['domains']
|
|
17
18
|
})
|
|
18
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import gql from 'graphql-tag'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
import { VM } from 'vm2'
|
|
4
3
|
|
|
5
4
|
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { getRepository } from '@things-factory/shell'
|
|
6
6
|
import { access } from '@things-factory/utils'
|
|
7
7
|
|
|
8
8
|
import { TaskRegistry } from '../task-registry'
|
|
@@ -12,7 +12,8 @@ async function LocalGraphqlQuery(step, context) {
|
|
|
12
12
|
var { query, variables: variablesAccessorMap } = params || {}
|
|
13
13
|
var { client, domain, data, variables } = context
|
|
14
14
|
|
|
15
|
-
const user = await getRepository(User).findOne(
|
|
15
|
+
const user = await getRepository(User).findOne({
|
|
16
|
+
where: { id: updaterId },
|
|
16
17
|
relations: ['domains']
|
|
17
18
|
})
|
|
18
19
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Scenario } from '../../service'
|
|
3
|
-
import { getRepository } from 'typeorm'
|
|
1
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
2
|
import { sleep } from '@things-factory/utils'
|
|
3
|
+
|
|
4
|
+
import { Scenario } from '../../service'
|
|
5
5
|
import { ScenarioEngine } from '../scenario-engine'
|
|
6
|
+
import { TaskRegistry } from '../task-registry'
|
|
6
7
|
|
|
7
8
|
const debug = require('debug')('things-factory:integration-base:pick-pending-scenario')
|
|
8
9
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { getRepository } from '@things-factory/shell'
|
|
1
2
|
import { access, deepClone } from '@things-factory/utils'
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import { Scenario } from '../../service'
|
|
4
|
-
import {
|
|
5
|
+
import { TaskRegistry } from '../task-registry'
|
|
5
6
|
|
|
6
7
|
async function SubScenario(step, context) {
|
|
7
8
|
var { logger, load, data } = context
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
|
+
|
|
3
5
|
import { Scenario, Step } from '../service'
|
|
4
6
|
|
|
5
7
|
export const scenarioViewRouter = new Router()
|
|
@@ -8,15 +10,13 @@ scenarioViewRouter.get('/scenario-view/:name', async (context, next) => {
|
|
|
8
10
|
const { domain } = context.state
|
|
9
11
|
const { name } = context.params
|
|
10
12
|
|
|
11
|
-
const scenario = await getRepository(Scenario).findOne(
|
|
12
|
-
{
|
|
13
|
-
domain,
|
|
13
|
+
const scenario = await getRepository(Scenario).findOne({
|
|
14
|
+
where: {
|
|
15
|
+
domain: { id: domain.id },
|
|
14
16
|
name
|
|
15
17
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
)
|
|
18
|
+
relations: ['steps']
|
|
19
|
+
})
|
|
20
20
|
|
|
21
21
|
const steps: Step[] = scenario.steps
|
|
22
22
|
const nodes = {}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import {
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { getRepository } from '@things-factory/shell'
|
|
3
5
|
|
|
4
6
|
import { ConnectionManager } from '../../engine/connection-manager'
|
|
5
7
|
import { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'
|
|
@@ -8,7 +10,10 @@ import { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './
|
|
|
8
10
|
export class ConnectionMutation {
|
|
9
11
|
@Directive('@transaction')
|
|
10
12
|
@Mutation(returns => Connection, { description: 'To create new connection' })
|
|
11
|
-
async createConnection(
|
|
13
|
+
async createConnection(
|
|
14
|
+
@Arg('connection') connection: NewConnection,
|
|
15
|
+
@Ctx() context: ResolverContext
|
|
16
|
+
): Promise<Connection> {
|
|
12
17
|
const { domain, user, tx } = context.state
|
|
13
18
|
|
|
14
19
|
return await tx.getRepository(Connection).save({
|
|
@@ -24,13 +29,13 @@ export class ConnectionMutation {
|
|
|
24
29
|
async updateConnection(
|
|
25
30
|
@Arg('name') name: string,
|
|
26
31
|
@Arg('patch') patch: ConnectionPatch,
|
|
27
|
-
@Ctx() context:
|
|
32
|
+
@Ctx() context: ResolverContext
|
|
28
33
|
): Promise<Connection> {
|
|
29
34
|
const { domain, user, tx } = context.state
|
|
30
35
|
|
|
31
36
|
const repository = tx.getRepository(Connection)
|
|
32
37
|
const connection = await repository.findOne({
|
|
33
|
-
where: { domain, name }
|
|
38
|
+
where: { domain: { id: domain.id }, name }
|
|
34
39
|
})
|
|
35
40
|
|
|
36
41
|
return await repository.save({
|
|
@@ -44,7 +49,7 @@ export class ConnectionMutation {
|
|
|
44
49
|
@Mutation(returns => [Connection], { description: "To modify multiple connections' information" })
|
|
45
50
|
async updateMultipleConnection(
|
|
46
51
|
@Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],
|
|
47
|
-
@Ctx() context:
|
|
52
|
+
@Ctx() context: ResolverContext
|
|
48
53
|
): Promise<Connection[]> {
|
|
49
54
|
const { domain, user, tx } = context.state
|
|
50
55
|
|
|
@@ -71,7 +76,7 @@ export class ConnectionMutation {
|
|
|
71
76
|
if (_updateRecords.length > 0) {
|
|
72
77
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
73
78
|
const newRecord = _updateRecords[i]
|
|
74
|
-
const connection = await connectionRepo.
|
|
79
|
+
const connection = await connectionRepo.findOneBy({ id: newRecord.id })
|
|
75
80
|
|
|
76
81
|
const result = await connectionRepo.save({
|
|
77
82
|
...connection,
|
|
@@ -88,7 +93,7 @@ export class ConnectionMutation {
|
|
|
88
93
|
|
|
89
94
|
@Directive('@transaction')
|
|
90
95
|
@Mutation(returns => Boolean, { description: 'To delete connection' })
|
|
91
|
-
async deleteConnection(@Arg('name') name: string, @Ctx() context:
|
|
96
|
+
async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
92
97
|
const { domain, tx } = context.state
|
|
93
98
|
|
|
94
99
|
await tx.getRepository(Connection).delete({ domain, name })
|
|
@@ -97,11 +102,14 @@ export class ConnectionMutation {
|
|
|
97
102
|
|
|
98
103
|
@Directive('@transaction')
|
|
99
104
|
@Mutation(returns => Boolean, { description: 'To delete multiple connections' })
|
|
100
|
-
async deleteConnections(
|
|
105
|
+
async deleteConnections(
|
|
106
|
+
@Arg('names', type => [String]) names: string[],
|
|
107
|
+
@Ctx() context: ResolverContext
|
|
108
|
+
): Promise<boolean> {
|
|
101
109
|
const { domain, tx } = context.state
|
|
102
110
|
|
|
103
111
|
await tx.getRepository(Connection).delete({
|
|
104
|
-
domain,
|
|
112
|
+
domain: { id: domain.id },
|
|
105
113
|
name: In(names)
|
|
106
114
|
})
|
|
107
115
|
|
|
@@ -109,11 +117,11 @@ export class ConnectionMutation {
|
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
@Mutation(returns => Connection, { description: 'To connect a connection' })
|
|
112
|
-
async connectConnection(@Arg('name') name: string, @Ctx() context:
|
|
120
|
+
async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {
|
|
113
121
|
const { domain } = context.state
|
|
114
122
|
var repository = getRepository(Connection)
|
|
115
123
|
var connection = await repository.findOne({
|
|
116
|
-
where: { domain: domain, name },
|
|
124
|
+
where: { domain: { id: domain.id }, name },
|
|
117
125
|
relations: ['domain']
|
|
118
126
|
})
|
|
119
127
|
|
|
@@ -129,12 +137,12 @@ export class ConnectionMutation {
|
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
@Mutation(returns => Connection, { description: 'To disconnect a connection' })
|
|
132
|
-
async disconnectConnection(@Arg('name') name: string, @Ctx() context:
|
|
140
|
+
async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {
|
|
133
141
|
const { domain } = context.state
|
|
134
142
|
|
|
135
143
|
var repository = getRepository(Connection)
|
|
136
144
|
var connection = await repository.findOne({
|
|
137
|
-
where: { domain, name },
|
|
145
|
+
where: { domain: { id: domain.id }, name },
|
|
138
146
|
relations: ['domain']
|
|
139
147
|
})
|
|
140
148
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { ConnectionManager } from '../../engine/connection-manager'
|
|
8
7
|
import { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'
|
|
@@ -10,11 +9,11 @@ import { Connection, ConnectionList, ConnectionState, ConnectionStatus } from '.
|
|
|
10
9
|
@Resolver(Connection)
|
|
11
10
|
export class ConnectionQuery {
|
|
12
11
|
@Query(returns => Connection, { description: 'To fetch a connection' })
|
|
13
|
-
async connection(@Arg('name') name: string, @Ctx() context:
|
|
12
|
+
async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {
|
|
14
13
|
const { domain } = context.state
|
|
15
14
|
|
|
16
15
|
var connection = await getRepository(Connection).findOne({
|
|
17
|
-
where: { domain, name },
|
|
16
|
+
where: { domain: { id: domain.id }, name },
|
|
18
17
|
relations: ['domain']
|
|
19
18
|
})
|
|
20
19
|
|
|
@@ -27,7 +26,7 @@ export class ConnectionQuery {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
@Query(returns => ConnectionList, { description: 'To fetch multiple connections' })
|
|
30
|
-
async connections(@Args() params: ListParam, @Ctx() context:
|
|
29
|
+
async connections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ConnectionList> {
|
|
31
30
|
const { domain } = context.state
|
|
32
31
|
|
|
33
32
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -50,7 +49,7 @@ export class ConnectionQuery {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
@Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })
|
|
53
|
-
fetchConnectionState(@Arg('name') name: string, @Ctx() context:
|
|
52
|
+
fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {
|
|
54
53
|
const { domain } = context.state
|
|
55
54
|
|
|
56
55
|
var connection = ConnectionManager.getConnectionInstanceByName(domain, name)
|
|
@@ -63,16 +62,16 @@ export class ConnectionQuery {
|
|
|
63
62
|
|
|
64
63
|
@FieldResolver(type => Domain)
|
|
65
64
|
async domain(@Root() connection: Connection) {
|
|
66
|
-
return connection.domain || (await getRepository(Domain).
|
|
65
|
+
return connection.domain || (await getRepository(Domain).findOneBy({ id: connection.domainId }))
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
@FieldResolver(type => User)
|
|
70
69
|
async updater(@Root() connection: Connection): Promise<User> {
|
|
71
|
-
return await getRepository(User).
|
|
70
|
+
return await getRepository(User).findOneBy({ id: connection.updaterId })
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
@FieldResolver(type => User)
|
|
75
74
|
async creator(@Root() connection: Connection): Promise<User> {
|
|
76
|
-
return await getRepository(User).
|
|
75
|
+
return await getRepository(User).findOneBy({ id: connection.creatorId })
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Resolver, Subscription, Root, Arg } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
|
-
import { Connection, ConnectionState, ConnectionStatus } from './connection-type'
|
|
4
|
-
import { pubsub, Log } from '@things-factory/shell'
|
|
5
1
|
import { withFilter } from 'graphql-subscriptions'
|
|
2
|
+
import { Arg, Resolver, Root, Subscription } from 'type-graphql'
|
|
3
|
+
|
|
4
|
+
import { getRepository, Log, pubsub } from '@things-factory/shell'
|
|
5
|
+
|
|
6
6
|
import { ConnectionManager } from '../../engine/connection-manager'
|
|
7
|
+
import { Connection, ConnectionState, ConnectionStatus } from './connection-type'
|
|
7
8
|
|
|
8
9
|
const debug = require('debug')('things-factory:integration:connection-subscription')
|
|
9
10
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { Arg, Ctx, Query, Resolver } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
|
+
|
|
5
5
|
import { ConnectionManager } from '../../engine/connection-manager'
|
|
6
|
+
import { Connection } from '../connection/connection-type'
|
|
7
|
+
import { ConnectorList, ConnectorType } from './connector-type'
|
|
6
8
|
|
|
7
9
|
@Resolver(ConnectorType)
|
|
8
10
|
export class ConnectorQuery {
|
|
9
11
|
@Query(returns => ConnectorType, { description: 'To fetch a connector' })
|
|
10
|
-
async connection(@Arg('name') name: string, @Ctx() context:
|
|
12
|
+
async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<ConnectorType> {
|
|
11
13
|
// @ts-ignore
|
|
12
14
|
const { description, help, parameterSpec, taskPrefixes } = ConnectionManager.getConnector(name) || {}
|
|
13
15
|
|
|
@@ -47,12 +49,12 @@ export class ConnectorQuery {
|
|
|
47
49
|
@Query(returns => ConnectorType, { description: 'To fetch the connector from a connection' })
|
|
48
50
|
async connectorByConnection(
|
|
49
51
|
@Arg('connectionName') connectionName: string,
|
|
50
|
-
@Ctx() context:
|
|
52
|
+
@Ctx() context: ResolverContext
|
|
51
53
|
): Promise<ConnectorType> {
|
|
52
54
|
const { domain } = context.state
|
|
53
55
|
|
|
54
56
|
var connection = await getRepository(Connection).findOne({
|
|
55
|
-
where: { domain, name: connectionName }
|
|
57
|
+
where: { domain: { id: domain.id }, name: connectionName }
|
|
56
58
|
})
|
|
57
59
|
|
|
58
60
|
return connection && (ConnectionManager.getConnector(connection.type) as any)
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { logger } from '@things-factory/env'
|
|
6
|
+
import { Domain, getRepository } from '@things-factory/shell'
|
|
7
|
+
|
|
3
8
|
import { PayloadLog, PayloadType } from './payload-log'
|
|
4
9
|
import { NewPayloadLog, PayloadLogPatch } from './payload-log-type'
|
|
5
|
-
import { logger } from '@things-factory/env'
|
|
6
|
-
import { Domain } from '@things-factory/shell'
|
|
7
|
-
import { User } from '@things-factory/auth-base'
|
|
8
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
9
10
|
|
|
10
11
|
@Resolver(PayloadLog)
|
|
11
12
|
export class PayloadLogMutation {
|
|
12
13
|
@Directive('@transaction')
|
|
13
14
|
@Mutation(returns => PayloadLog, { description: 'To create new PayloadLog' })
|
|
14
|
-
async createPayloadLog(
|
|
15
|
+
async createPayloadLog(
|
|
16
|
+
@Arg('payloadLog') payloadLog: NewPayloadLog,
|
|
17
|
+
@Ctx() context: ResolverContext
|
|
18
|
+
): Promise<PayloadLog> {
|
|
15
19
|
const { domain, user, tx } = context.state
|
|
16
20
|
|
|
17
21
|
return await tx.getRepository(PayloadLog).save({
|
|
@@ -27,13 +31,13 @@ export class PayloadLogMutation {
|
|
|
27
31
|
async updatePayloadLog(
|
|
28
32
|
@Arg('id') id: string,
|
|
29
33
|
@Arg('patch') patch: PayloadLogPatch,
|
|
30
|
-
@Ctx() context:
|
|
34
|
+
@Ctx() context: ResolverContext
|
|
31
35
|
): Promise<PayloadLog> {
|
|
32
36
|
const { domain, user, tx } = context.state
|
|
33
37
|
|
|
34
38
|
const repository = tx.getRepository(PayloadLog)
|
|
35
39
|
const payloadLog = await repository.findOne({
|
|
36
|
-
where: { domain, id }
|
|
40
|
+
where: { domain: { id: domain.id }, id }
|
|
37
41
|
})
|
|
38
42
|
|
|
39
43
|
return await repository.save({
|
|
@@ -47,7 +51,7 @@ export class PayloadLogMutation {
|
|
|
47
51
|
@Mutation(returns => [PayloadLog], { description: "To modify multiple PayloadLogs' information" })
|
|
48
52
|
async updateMultiplePayloadLog(
|
|
49
53
|
@Arg('patches', type => [PayloadLogPatch]) patches: PayloadLogPatch[],
|
|
50
|
-
@Ctx() context:
|
|
54
|
+
@Ctx() context: ResolverContext
|
|
51
55
|
): Promise<PayloadLog[]> {
|
|
52
56
|
const { domain, user, tx } = context.state
|
|
53
57
|
|
|
@@ -74,7 +78,7 @@ export class PayloadLogMutation {
|
|
|
74
78
|
if (_updateRecords.length > 0) {
|
|
75
79
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
76
80
|
const newRecord = _updateRecords[i]
|
|
77
|
-
const payloadLog = await payloadLogRepo.
|
|
81
|
+
const payloadLog = await payloadLogRepo.findOneBy({ id: newRecord.id })
|
|
78
82
|
|
|
79
83
|
const result = await payloadLogRepo.save({
|
|
80
84
|
...payloadLog,
|
|
@@ -91,10 +95,10 @@ export class PayloadLogMutation {
|
|
|
91
95
|
|
|
92
96
|
@Directive('@transaction')
|
|
93
97
|
@Mutation(returns => Boolean, { description: 'To delete PayloadLog' })
|
|
94
|
-
async deletePayloadLog(@Arg('id') id: string, @Ctx() context:
|
|
98
|
+
async deletePayloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
95
99
|
const { domain, tx } = context.state
|
|
96
100
|
|
|
97
|
-
await tx.getRepository(PayloadLog).delete({ domain, id })
|
|
101
|
+
await tx.getRepository(PayloadLog).delete({ domain: { id: domain.id }, id })
|
|
98
102
|
return true
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -102,12 +106,12 @@ export class PayloadLogMutation {
|
|
|
102
106
|
@Mutation(returns => Boolean, { description: 'To delete multiple payloadLogs' })
|
|
103
107
|
async deletePayloadLogs(
|
|
104
108
|
@Arg('ids', type => [String]) ids: string[],
|
|
105
|
-
@Ctx() context:
|
|
109
|
+
@Ctx() context: ResolverContext
|
|
106
110
|
): Promise<boolean> {
|
|
107
111
|
const { domain, tx } = context.state
|
|
108
112
|
|
|
109
113
|
await tx.getRepository(PayloadLog).delete({
|
|
110
|
-
domain,
|
|
114
|
+
domain: { id: domain.id },
|
|
111
115
|
id: In(ids)
|
|
112
116
|
})
|
|
113
117
|
|
|
@@ -115,18 +119,19 @@ export class PayloadLogMutation {
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
|
|
119
122
|
export async function createPayloadLog(
|
|
120
123
|
name: string,
|
|
121
124
|
endpoint: string,
|
|
122
125
|
request: string,
|
|
123
126
|
response: string,
|
|
124
127
|
context: any,
|
|
125
|
-
type: PayloadType = PayloadType.EGESTION
|
|
128
|
+
type: PayloadType = PayloadType.EGESTION,
|
|
129
|
+
src: string = null
|
|
126
130
|
): Promise<void> {
|
|
127
131
|
try {
|
|
128
132
|
const { domain, user }: { domain: Domain; user: User } = context?.state
|
|
129
133
|
|
|
134
|
+
// disabled due to high db server usage
|
|
130
135
|
await getRepository(PayloadLog).save({
|
|
131
136
|
name,
|
|
132
137
|
domain,
|
|
@@ -134,14 +139,13 @@ export async function createPayloadLog(
|
|
|
134
139
|
request,
|
|
135
140
|
response,
|
|
136
141
|
type,
|
|
142
|
+
src,
|
|
137
143
|
createdBy: user,
|
|
138
144
|
updatedBy: user,
|
|
139
145
|
createdAt: new Date(),
|
|
140
|
-
updatedAt: new Date()
|
|
146
|
+
updatedAt: new Date()
|
|
141
147
|
})
|
|
142
|
-
|
|
143
|
-
|
|
144
148
|
} catch (error) {
|
|
145
149
|
logger.error(`PayloadLog Error: ${error}`)
|
|
146
150
|
}
|
|
147
|
-
}
|
|
151
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { convertListParams, Domain, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { PayloadLog } from './payload-log'
|
|
8
7
|
import { PayloadLogList } from './payload-log-type'
|
|
@@ -10,16 +9,16 @@ import { PayloadLogList } from './payload-log-type'
|
|
|
10
9
|
@Resolver(PayloadLog)
|
|
11
10
|
export class PayloadLogQuery {
|
|
12
11
|
@Query(returns => PayloadLog, { description: 'To fetch a PayloadLog' })
|
|
13
|
-
async payloadLog(@Arg('id') id: string, @Ctx() context:
|
|
12
|
+
async payloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<PayloadLog> {
|
|
14
13
|
const { domain } = context.state
|
|
15
14
|
|
|
16
15
|
return await getRepository(PayloadLog).findOne({
|
|
17
|
-
where: { domain, id }
|
|
16
|
+
where: { domain: { id: domain.id }, id }
|
|
18
17
|
})
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
@Query(returns => PayloadLogList, { description: 'To fetch multiple PayloadLogs' })
|
|
22
|
-
async payloadLogs(@Args() params: ListParam, @Ctx() context:
|
|
21
|
+
async payloadLogs(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<PayloadLogList> {
|
|
23
22
|
const { domain } = context.state
|
|
24
23
|
|
|
25
24
|
const convertedParams = convertListParams(params, {
|
|
@@ -32,16 +31,16 @@ export class PayloadLogQuery {
|
|
|
32
31
|
|
|
33
32
|
@FieldResolver(type => Domain)
|
|
34
33
|
async domain(@Root() payloadLog: PayloadLog): Promise<Domain> {
|
|
35
|
-
return await getRepository(Domain).
|
|
34
|
+
return await getRepository(Domain).findOneBy({ id: payloadLog.domainId })
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
@FieldResolver(type => User)
|
|
39
38
|
async updater(@Root() payloadLog: PayloadLog): Promise<User> {
|
|
40
|
-
return await getRepository(User).
|
|
39
|
+
return await getRepository(User).findOneBy({ id: payloadLog.updaterId })
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
@FieldResolver(type => User)
|
|
44
43
|
async creator(@Root() payloadLog: PayloadLog): Promise<User> {
|
|
45
|
-
return await getRepository(User).
|
|
44
|
+
return await getRepository(User).findOneBy({ id: payloadLog.creatorId })
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -20,11 +20,10 @@ const DATABASE_TYPE = ORMCONFIG.type
|
|
|
20
20
|
|
|
21
21
|
export enum PayloadType {
|
|
22
22
|
INGESTION = 'ingestion',
|
|
23
|
-
EGESTION = 'egestion'
|
|
23
|
+
EGESTION = 'egestion'
|
|
24
24
|
}
|
|
25
25
|
@Entity()
|
|
26
26
|
@Index('ix_payload_log_0', (payloadLog: PayloadLog) => [payloadLog.domain])
|
|
27
|
-
|
|
28
27
|
@Index('ix_payload_log_1', (payloadLog: PayloadLog) => [payloadLog.domain, payloadLog.endpoint])
|
|
29
28
|
@ObjectType({ description: 'Entity for PayloadLog' })
|
|
30
29
|
export class PayloadLog {
|
|
@@ -57,6 +56,10 @@ export class PayloadLog {
|
|
|
57
56
|
@Field(type => String)
|
|
58
57
|
type: PayloadType
|
|
59
58
|
|
|
59
|
+
@Column({ nullable: true })
|
|
60
|
+
@Field({ nullable: true })
|
|
61
|
+
src: string
|
|
62
|
+
|
|
60
63
|
@Column()
|
|
61
64
|
@Field()
|
|
62
65
|
endpoint: string
|