@things-factory/integration-base 8.0.40 → 9.0.0-9.0.0-beta.59.0
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/headless-connector.d.ts +23 -0
- package/dist-server/engine/connector/headless-connector.js +357 -0
- package/dist-server/engine/connector/headless-connector.js.map +1 -0
- package/dist-server/engine/connector/http-connector.js +1 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/index.d.ts +1 -0
- package/dist-server/engine/connector/index.js +1 -0
- package/dist-server/engine/connector/index.js.map +1 -1
- package/dist-server/engine/index.d.ts +3 -2
- package/dist-server/engine/index.js +3 -2
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/resource-pool/headless-pool.d.ts +1 -0
- package/dist-server/engine/resource-pool/headless-pool.js +62 -0
- package/dist-server/engine/resource-pool/headless-pool.js.map +1 -0
- package/dist-server/engine/resource-pool/index.d.ts +1 -0
- package/dist-server/engine/resource-pool/index.js +5 -0
- package/dist-server/engine/resource-pool/index.js.map +1 -0
- package/dist-server/engine/task/headless-post.js +19 -33
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +20 -13
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/index.d.ts +6 -6
- package/dist-server/index.js +10 -10
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +6 -6
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +17 -5
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +3 -0
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/translations/en.json +12 -4
- package/translations/ja.json +12 -4
- package/translations/ko.json +12 -4
- package/translations/ms.json +12 -4
- package/translations/zh.json +12 -4
- package/server/controllers/index.ts +0 -2
- package/server/controllers/publish-data.ts +0 -29
- package/server/controllers/scenario-controller.ts +0 -154
- package/server/engine/analyzer/analyze-integration.ts +0 -115
- package/server/engine/connection-manager.ts +0 -232
- package/server/engine/connector/echo-back-connector.ts +0 -51
- package/server/engine/connector/echo-back-server.ts +0 -72
- package/server/engine/connector/graphql-connector.ts +0 -126
- package/server/engine/connector/http-connector.ts +0 -65
- package/server/engine/connector/index.ts +0 -12
- package/server/engine/connector/mqtt-connector.ts +0 -78
- package/server/engine/connector/mssql-connector.ts +0 -152
- package/server/engine/connector/mysql-connector.ts +0 -94
- package/server/engine/connector/operato-connector.ts +0 -264
- package/server/engine/connector/oracle-connector.ts +0 -218
- package/server/engine/connector/postgresql-connector.ts +0 -152
- package/server/engine/connector/proxy-connector.ts +0 -53
- package/server/engine/connector/socket-server.ts +0 -86
- package/server/engine/connector/sqlite-connector.ts +0 -69
- package/server/engine/edge-client.ts +0 -45
- package/server/engine/index.ts +0 -10
- package/server/engine/pending-queue.ts +0 -97
- package/server/engine/scenario-engine.ts +0 -106
- package/server/engine/task/book-up-scenario.ts +0 -73
- package/server/engine/task/csv-readline.ts +0 -127
- package/server/engine/task/data-accessor.ts +0 -36
- package/server/engine/task/data-mapper.ts +0 -47
- package/server/engine/task/database-query.ts +0 -56
- package/server/engine/task/echo-receive.ts +0 -21
- package/server/engine/task/echo-send.ts +0 -32
- package/server/engine/task/empty-check.ts +0 -38
- package/server/engine/task/end.ts +0 -18
- package/server/engine/task/floating-point.ts +0 -71
- package/server/engine/task/goto.ts +0 -27
- package/server/engine/task/graphql-mutate.ts +0 -79
- package/server/engine/task/graphql-query.ts +0 -78
- package/server/engine/task/headless-post.ts +0 -147
- package/server/engine/task/headless-scrap.ts +0 -80
- package/server/engine/task/http-get.ts +0 -117
- package/server/engine/task/http-post.ts +0 -148
- package/server/engine/task/index.ts +0 -45
- package/server/engine/task/jsonata.ts +0 -45
- package/server/engine/task/local-graphql-mutate.ts +0 -100
- package/server/engine/task/local-graphql-query.ts +0 -100
- package/server/engine/task/log.ts +0 -78
- package/server/engine/task/mqtt-publish.ts +0 -69
- package/server/engine/task/mqtt-subscribe.ts +0 -291
- package/server/engine/task/mssql-procedure.ts +0 -128
- package/server/engine/task/oracle-procedure.ts +0 -124
- package/server/engine/task/pick-pending-scenario.ts +0 -80
- package/server/engine/task/publish.ts +0 -40
- package/server/engine/task/random.ts +0 -53
- package/server/engine/task/reset-pending-queue.ts +0 -17
- package/server/engine/task/script.ts +0 -63
- package/server/engine/task/set-domain.ts +0 -37
- package/server/engine/task/sleep.ts +0 -34
- package/server/engine/task/socket-listener.ts +0 -96
- package/server/engine/task/state-group-read.ts +0 -69
- package/server/engine/task/state-read.ts +0 -56
- package/server/engine/task/state-write.ts +0 -65
- package/server/engine/task/stop-scenario.ts +0 -44
- package/server/engine/task/sub-scenario.ts +0 -57
- package/server/engine/task/switch-goto.ts +0 -43
- package/server/engine/task/switch-range-goto.ts +0 -53
- package/server/engine/task/switch-range-scenario.ts +0 -79
- package/server/engine/task/switch-range-set.ts +0 -48
- package/server/engine/task/switch-scenario.ts +0 -67
- package/server/engine/task/switch-set.ts +0 -37
- package/server/engine/task/throw.ts +0 -27
- package/server/engine/task/utils/headless-pool-for-scenario.ts +0 -71
- package/server/engine/task/utils/substitute.ts +0 -44
- package/server/engine/task/variables.ts +0 -17
- package/server/engine/task-registry.ts +0 -23
- package/server/engine/types.ts +0 -114
- package/server/index.ts +0 -20
- package/server/migrations/index.ts +0 -9
- package/server/restful/index.ts +0 -1
- package/server/restful/unstable/index.ts +0 -7
- package/server/restful/unstable/run-scenario.ts +0 -51
- package/server/restful/unstable/scenario-instance.ts +0 -52
- package/server/restful/unstable/scenario-instances.ts +0 -80
- package/server/restful/unstable/scenario.ts +0 -41
- package/server/restful/unstable/scenarios.ts +0 -69
- package/server/restful/unstable/start-scenario.ts +0 -33
- package/server/restful/unstable/stop-scenario.ts +0 -30
- package/server/routers/scenario-schedule-callback-router.ts +0 -69
- package/server/routers/scenario-view-router.ts +0 -46
- package/server/routes.ts +0 -35
- package/server/service/analysis/analysis-query.ts +0 -13
- package/server/service/analysis/index.ts +0 -3
- package/server/service/connection/connection-mutation.ts +0 -190
- package/server/service/connection/connection-query.ts +0 -87
- package/server/service/connection/connection-subscription.ts +0 -104
- package/server/service/connection/connection-type.ts +0 -305
- package/server/service/connection/index.ts +0 -7
- package/server/service/connector/connector-query.ts +0 -62
- package/server/service/connector/connector-type.ts +0 -29
- package/server/service/connector/index.ts +0 -4
- package/server/service/index.ts +0 -52
- package/server/service/payload-log/index.ts +0 -7
- package/server/service/payload-log/payload-log-mutation.ts +0 -151
- package/server/service/payload-log/payload-log-query.ts +0 -49
- package/server/service/payload-log/payload-log-type.ts +0 -36
- package/server/service/payload-log/payload-log.ts +0 -100
- package/server/service/property-spec.ts +0 -24
- package/server/service/scenario/index.ts +0 -6
- package/server/service/scenario/scenario-mutation.ts +0 -396
- package/server/service/scenario/scenario-query.ts +0 -109
- package/server/service/scenario/scenario-type.ts +0 -78
- package/server/service/scenario/scenario.ts +0 -124
- package/server/service/scenario-flow/scenario-flow.ts +0 -17
- package/server/service/scenario-instance/index.ts +0 -6
- package/server/service/scenario-instance/scenario-instance-mutation.ts +0 -44
- package/server/service/scenario-instance/scenario-instance-query.ts +0 -42
- package/server/service/scenario-instance/scenario-instance-subscription.ts +0 -118
- package/server/service/scenario-instance/scenario-instance-type.ts +0 -557
- package/server/service/scenario-queue/index.ts +0 -4
- package/server/service/scenario-queue/scenario-queue-subscription.ts +0 -55
- package/server/service/scenario-queue/scenario-queue-type.ts +0 -27
- package/server/service/state-register/data-resolver.ts +0 -56
- package/server/service/state-register/index.ts +0 -8
- package/server/service/state-register/state-register-mutation.ts +0 -166
- package/server/service/state-register/state-register-query.ts +0 -80
- package/server/service/state-register/state-register-type.ts +0 -80
- package/server/service/state-register/state-register.ts +0 -113
- package/server/service/step/index.ts +0 -6
- package/server/service/step/step-mutation.ts +0 -52
- package/server/service/step/step-query.ts +0 -55
- package/server/service/step/step-type.ts +0 -238
- package/server/service/task-type/index.ts +0 -4
- package/server/service/task-type/task-type-query.ts +0 -95
- package/server/service/task-type/task-type-type.ts +0 -29
@@ -1,87 +0,0 @@
|
|
1
|
-
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
2
|
-
|
3
|
-
import { Appliance, User } from '@things-factory/auth-base'
|
4
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
5
|
-
|
6
|
-
import { ConnectionManager } from '../../engine/connection-manager'
|
7
|
-
import { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'
|
8
|
-
|
9
|
-
@Resolver(Connection)
|
10
|
-
export class ConnectionQuery {
|
11
|
-
@Query(returns => Connection, { description: 'To fetch a connection' })
|
12
|
-
async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {
|
13
|
-
const { domain } = context.state
|
14
|
-
|
15
|
-
var connection = await getRepository(Connection).findOne({
|
16
|
-
where: { domain: { id: domain.id }, name },
|
17
|
-
relations: ['domain']
|
18
|
-
})
|
19
|
-
|
20
|
-
return {
|
21
|
-
...connection,
|
22
|
-
state: ConnectionManager.getConnectionInstance(connection)
|
23
|
-
? ConnectionStatus.CONNECTED
|
24
|
-
: ConnectionStatus.DISCONNECTED
|
25
|
-
} as Connection
|
26
|
-
}
|
27
|
-
|
28
|
-
@Query(returns => ConnectionList, { description: 'To fetch multiple connections' })
|
29
|
-
async connections(
|
30
|
-
@Args(type => ListParam) params: ListParam,
|
31
|
-
@Ctx() context: ResolverContext
|
32
|
-
): Promise<ConnectionList> {
|
33
|
-
const { domain } = context.state
|
34
|
-
|
35
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
36
|
-
repository: getRepository(Connection),
|
37
|
-
params,
|
38
|
-
domain,
|
39
|
-
alias: 'connection',
|
40
|
-
searchables: ['name', 'description', 'type', 'endpoint']
|
41
|
-
})
|
42
|
-
|
43
|
-
const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()
|
44
|
-
|
45
|
-
items.forEach(connection => {
|
46
|
-
connection['state'] = ConnectionManager.getConnectionInstance(connection)
|
47
|
-
? ConnectionStatus.CONNECTED
|
48
|
-
: ConnectionStatus.DISCONNECTED
|
49
|
-
})
|
50
|
-
|
51
|
-
return { items, total }
|
52
|
-
}
|
53
|
-
|
54
|
-
@Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })
|
55
|
-
fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {
|
56
|
-
const { domain } = context.state
|
57
|
-
|
58
|
-
const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)
|
59
|
-
|
60
|
-
return {
|
61
|
-
...connection,
|
62
|
-
state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
@FieldResolver(type => Domain)
|
67
|
-
async edge(@Root() connection: Connection) {
|
68
|
-
return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))
|
69
|
-
}
|
70
|
-
|
71
|
-
@FieldResolver(type => Domain)
|
72
|
-
async domain(@Root() connection: Connection) {
|
73
|
-
return (
|
74
|
-
connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))
|
75
|
-
)
|
76
|
-
}
|
77
|
-
|
78
|
-
@FieldResolver(type => User)
|
79
|
-
async updater(@Root() connection: Connection): Promise<User> {
|
80
|
-
return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))
|
81
|
-
}
|
82
|
-
|
83
|
-
@FieldResolver(type => User)
|
84
|
-
async creator(@Root() connection: Connection): Promise<User> {
|
85
|
-
return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))
|
86
|
-
}
|
87
|
-
}
|
@@ -1,104 +0,0 @@
|
|
1
|
-
import { filter, pipe } from 'graphql-yoga'
|
2
|
-
import { Arg, Resolver, Root, Subscription } from 'type-graphql'
|
3
|
-
|
4
|
-
import { getRepository, Log, pubsub } from '@things-factory/shell'
|
5
|
-
|
6
|
-
import { ConnectionManager } from '../../engine/connection-manager'
|
7
|
-
import { Connection, ConnectionState, ConnectionStatus } from './connection-type'
|
8
|
-
|
9
|
-
const debug = require('debug')('things-factory:integration:connection-subscription')
|
10
|
-
|
11
|
-
@Resolver(Connection)
|
12
|
-
export class ConnectionSubscription {
|
13
|
-
@Subscription({
|
14
|
-
subscribe: ({ args, context, info }) => {
|
15
|
-
const { domain, user } = context.state
|
16
|
-
const { name } = args
|
17
|
-
const subdomain = domain?.subdomain
|
18
|
-
|
19
|
-
debug('subscribe', subdomain)
|
20
|
-
if (!domain) {
|
21
|
-
throw new Error('domain required.')
|
22
|
-
}
|
23
|
-
|
24
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
25
|
-
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
|
26
|
-
}
|
27
|
-
|
28
|
-
process.nextTick(async () => {
|
29
|
-
var where = { domain: { id: domain.id } }
|
30
|
-
if (name) {
|
31
|
-
where['name'] = name
|
32
|
-
}
|
33
|
-
|
34
|
-
var connections = await getRepository(Connection).find({
|
35
|
-
where,
|
36
|
-
relations: ['domain', 'edge']
|
37
|
-
})
|
38
|
-
|
39
|
-
connections.forEach(connection => {
|
40
|
-
pubsub.publish('connection-state', {
|
41
|
-
connectionState: {
|
42
|
-
...connection,
|
43
|
-
state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED,
|
44
|
-
timestamp: new Date()
|
45
|
-
}
|
46
|
-
})
|
47
|
-
})
|
48
|
-
})
|
49
|
-
|
50
|
-
return pipe(
|
51
|
-
pubsub.subscribe('connection-state'),
|
52
|
-
filter(async (payload: { connectionState: ConnectionState }) => {
|
53
|
-
const { domain: pdomain, name: pname } = payload.connectionState
|
54
|
-
|
55
|
-
return (!name || name === pname) && subdomain === pdomain?.subdomain
|
56
|
-
})
|
57
|
-
)
|
58
|
-
}
|
59
|
-
})
|
60
|
-
connectionState(@Root() payload: { connectionState: ConnectionState }, @Arg('name', { nullable: true }) name: string): ConnectionState {
|
61
|
-
return payload.connectionState
|
62
|
-
}
|
63
|
-
|
64
|
-
@Subscription({
|
65
|
-
subscribe: ({ args, context, info }) => {
|
66
|
-
const { domain, user } = context.state
|
67
|
-
const { level } = args
|
68
|
-
|
69
|
-
const subdomain = domain?.subdomain
|
70
|
-
|
71
|
-
debug('subscribe', subdomain)
|
72
|
-
|
73
|
-
if (!domain) {
|
74
|
-
throw new Error('domain required')
|
75
|
-
}
|
76
|
-
|
77
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
78
|
-
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
|
79
|
-
}
|
80
|
-
|
81
|
-
return pipe(
|
82
|
-
pubsub.subscribe('connection-log'),
|
83
|
-
filter(async (payload: { log: Log }) => {
|
84
|
-
// TODO support domain filtering
|
85
|
-
const { /* source, */ level: plevel } = payload.log
|
86
|
-
// const { domain: pdomain } = source
|
87
|
-
|
88
|
-
// if (subdomain !== pdomain?.subdomain) {
|
89
|
-
// return false
|
90
|
-
// }
|
91
|
-
|
92
|
-
if (level && level !== plevel) {
|
93
|
-
return false
|
94
|
-
}
|
95
|
-
|
96
|
-
return true
|
97
|
-
})
|
98
|
-
)
|
99
|
-
}
|
100
|
-
})
|
101
|
-
connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {
|
102
|
-
return payload.log
|
103
|
-
}
|
104
|
-
}
|
@@ -1,305 +0,0 @@
|
|
1
|
-
import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'
|
2
|
-
import {
|
3
|
-
Column,
|
4
|
-
CreateDateColumn,
|
5
|
-
Entity,
|
6
|
-
Index,
|
7
|
-
ManyToOne,
|
8
|
-
PrimaryGeneratedColumn,
|
9
|
-
RelationId,
|
10
|
-
UpdateDateColumn
|
11
|
-
} from 'typeorm'
|
12
|
-
|
13
|
-
import { User, Appliance } from '@things-factory/auth-base'
|
14
|
-
import { config } from '@things-factory/env'
|
15
|
-
import { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'
|
16
|
-
|
17
|
-
import { ConnectionManager } from '../../engine'
|
18
|
-
import { ProxyConnector } from '../../engine/connector/proxy-connector'
|
19
|
-
|
20
|
-
const ORMCONFIG = config.get('ormconfig', {})
|
21
|
-
const DATABASE_TYPE = ORMCONFIG.type
|
22
|
-
|
23
|
-
export enum ConnectionStatus {
|
24
|
-
CONNECTED = 'CONNECTED',
|
25
|
-
DISCONNECTED = 'DISCONNECTED'
|
26
|
-
}
|
27
|
-
|
28
|
-
registerEnumType(ConnectionStatus, {
|
29
|
-
name: 'ConnectionStatus',
|
30
|
-
description: 'state enumeration of a connection'
|
31
|
-
})
|
32
|
-
|
33
|
-
@Entity()
|
34
|
-
@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })
|
35
|
-
@ObjectType()
|
36
|
-
export class Connection {
|
37
|
-
/**
|
38
|
-
* Unique identifier for the connection, generated in UUID format.
|
39
|
-
*/
|
40
|
-
@PrimaryGeneratedColumn('uuid')
|
41
|
-
@Field(type => ID)
|
42
|
-
readonly id: string
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Many-to-One relationship with the Domain entity.
|
46
|
-
*/
|
47
|
-
@ManyToOne(type => Domain)
|
48
|
-
@Field(type => Domain, { nullable: true })
|
49
|
-
domain: Domain
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Stores the ID of the associated Domain.
|
53
|
-
*/
|
54
|
-
@RelationId((connection: Connection) => connection.domain)
|
55
|
-
domainId: string
|
56
|
-
|
57
|
-
/**
|
58
|
-
* The name of the connection.
|
59
|
-
*/
|
60
|
-
@Column()
|
61
|
-
@Field()
|
62
|
-
name: string
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Optional description for the connection.
|
66
|
-
*/
|
67
|
-
@Column({
|
68
|
-
nullable: true
|
69
|
-
})
|
70
|
-
@Field({ nullable: true })
|
71
|
-
description: string
|
72
|
-
|
73
|
-
/**
|
74
|
-
* The type of the connection.
|
75
|
-
*/
|
76
|
-
@Column()
|
77
|
-
@Field({ nullable: true })
|
78
|
-
type: string
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.
|
82
|
-
*/
|
83
|
-
@ManyToOne(type => Appliance, { nullable: true })
|
84
|
-
@Field({ nullable: true })
|
85
|
-
edge: Appliance
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Stores the ID of the Appliance who delegate the connection.
|
89
|
-
*/
|
90
|
-
@RelationId((connection: Connection) => connection.edge)
|
91
|
-
edgeId: string
|
92
|
-
|
93
|
-
/**
|
94
|
-
* The endpoint for the connection.
|
95
|
-
*/
|
96
|
-
@Column()
|
97
|
-
@Field({ nullable: true })
|
98
|
-
endpoint: string
|
99
|
-
|
100
|
-
/**
|
101
|
-
* Indicates the active status of the connection.
|
102
|
-
*/
|
103
|
-
@Column({ nullable: true })
|
104
|
-
@Field({ nullable: true })
|
105
|
-
active: boolean
|
106
|
-
|
107
|
-
/**
|
108
|
-
* The status of the connection, using the ConnectionStatus type.
|
109
|
-
*/
|
110
|
-
@Field({ nullable: true })
|
111
|
-
state: ConnectionStatus
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Additional parameters for the connection, stored as a JSON string.
|
115
|
-
*
|
116
|
-
* [Caution]
|
117
|
-
* 이 컬럼타입은 postgres 데이터베이스에서는 varchar 타입을 유지한다.
|
118
|
-
* 이는 데이터베이스 타입을 변경하면 기존 데이터가 손실될 수 있기 때문이다.
|
119
|
-
* 'simple-json' 타입으로 변경 전에 postgres 데이타베이스에 이미 varchar 타입으로 사용한 사례가 많기 때문이다.
|
120
|
-
*/
|
121
|
-
@Column({
|
122
|
-
type: DATABASE_TYPE == 'postgres' ? 'varchar' : 'simple-json',
|
123
|
-
nullable: true,
|
124
|
-
transformer:
|
125
|
-
DATABASE_TYPE == 'postgres'
|
126
|
-
? {
|
127
|
-
to: (value: any) => JSON.stringify(value),
|
128
|
-
from: (value: string) => {
|
129
|
-
try {
|
130
|
-
return JSON.parse(value)
|
131
|
-
} catch (error) {
|
132
|
-
return null
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
: undefined
|
137
|
-
})
|
138
|
-
@Field(type => ScalarObject, { nullable: true })
|
139
|
-
params: { [key: string]: any }
|
140
|
-
|
141
|
-
/**
|
142
|
-
* The date and time when the connection was created.
|
143
|
-
*/
|
144
|
-
@CreateDateColumn()
|
145
|
-
@Field({ nullable: true })
|
146
|
-
createdAt: Date
|
147
|
-
|
148
|
-
/**
|
149
|
-
* The date and time when the connection was last updated.
|
150
|
-
*/
|
151
|
-
@UpdateDateColumn()
|
152
|
-
@Field({ nullable: true })
|
153
|
-
updatedAt: Date
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Many-to-One relationship with the User entity who created the connection. Optional field.
|
157
|
-
*/
|
158
|
-
@ManyToOne(type => User, { nullable: true })
|
159
|
-
@Field({ nullable: true })
|
160
|
-
creator: User
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Stores the ID of the User who created the connection.
|
164
|
-
*/
|
165
|
-
@RelationId((connection: Connection) => connection.creator)
|
166
|
-
creatorId: string
|
167
|
-
|
168
|
-
/**
|
169
|
-
* Many-to-One relationship with the User entity who last updated the connection.
|
170
|
-
* Optional field.
|
171
|
-
*/
|
172
|
-
@ManyToOne(type => User, { nullable: true })
|
173
|
-
@Field({ nullable: true })
|
174
|
-
updater: User
|
175
|
-
|
176
|
-
/**
|
177
|
-
* Stores the ID of the User who last updated the connection.
|
178
|
-
*
|
179
|
-
*/
|
180
|
-
@RelationId((connection: Connection) => connection.updater)
|
181
|
-
updaterId: string
|
182
|
-
|
183
|
-
/**
|
184
|
-
* Asynchronous method to establish the connection.
|
185
|
-
*
|
186
|
-
*/
|
187
|
-
async connect() {
|
188
|
-
const { type, edge } = this
|
189
|
-
const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
190
|
-
|
191
|
-
await connector.connect({
|
192
|
-
...this,
|
193
|
-
params: this.params || {}
|
194
|
-
})
|
195
|
-
}
|
196
|
-
|
197
|
-
/**
|
198
|
-
* @brief Asynchronous method to disconnect the connection.
|
199
|
-
*
|
200
|
-
*/
|
201
|
-
async disconnect() {
|
202
|
-
try {
|
203
|
-
const { type, edge } = this
|
204
|
-
const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
205
|
-
await connector.disconnect(this)
|
206
|
-
} finally {
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
/**
|
212
|
-
* Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
|
213
|
-
* 추후, 타입 일치를 통해서 제거할 예정임.
|
214
|
-
*
|
215
|
-
*/
|
216
|
-
export interface InputConnection extends Connection {
|
217
|
-
params: any
|
218
|
-
}
|
219
|
-
|
220
|
-
@ObjectType()
|
221
|
-
export class ConnectionState {
|
222
|
-
@Field(type => Domain)
|
223
|
-
domain?: Domain
|
224
|
-
|
225
|
-
@Field({ nullable: true })
|
226
|
-
id?: string
|
227
|
-
|
228
|
-
@Field({ nullable: true })
|
229
|
-
name?: string
|
230
|
-
|
231
|
-
@Field({ nullable: true })
|
232
|
-
description?: string
|
233
|
-
|
234
|
-
@Field({ nullable: true })
|
235
|
-
type?: string
|
236
|
-
|
237
|
-
@Field(type => Appliance, { nullable: true })
|
238
|
-
edge?: Appliance
|
239
|
-
|
240
|
-
@Field({ nullable: true })
|
241
|
-
state?: ConnectionStatus
|
242
|
-
|
243
|
-
@Field({ nullable: true })
|
244
|
-
timestamp?: Date
|
245
|
-
}
|
246
|
-
|
247
|
-
@InputType()
|
248
|
-
export class NewConnection {
|
249
|
-
@Field()
|
250
|
-
name: string
|
251
|
-
|
252
|
-
@Field({ nullable: true })
|
253
|
-
description?: string
|
254
|
-
|
255
|
-
@Field({ nullable: true })
|
256
|
-
type?: string
|
257
|
-
|
258
|
-
@Field(type => ObjectRef, { nullable: true })
|
259
|
-
edge?: Appliance
|
260
|
-
|
261
|
-
@Field({ nullable: true })
|
262
|
-
endpoint?: string
|
263
|
-
|
264
|
-
@Field(type => ScalarObject, { nullable: true })
|
265
|
-
params?: { [key: string]: any }
|
266
|
-
}
|
267
|
-
|
268
|
-
@InputType()
|
269
|
-
export class ConnectionPatch {
|
270
|
-
@Field(type => ID, { nullable: true })
|
271
|
-
id: string
|
272
|
-
|
273
|
-
@Field({ nullable: true })
|
274
|
-
name?: string
|
275
|
-
|
276
|
-
@Field({ nullable: true })
|
277
|
-
description?: string
|
278
|
-
|
279
|
-
@Field({ nullable: true })
|
280
|
-
type?: string
|
281
|
-
|
282
|
-
@Field(type => ObjectRef, { nullable: true })
|
283
|
-
edge?: Appliance
|
284
|
-
|
285
|
-
@Field({ nullable: true })
|
286
|
-
endpoint?: string
|
287
|
-
|
288
|
-
@Field({ nullable: true })
|
289
|
-
active?: boolean
|
290
|
-
|
291
|
-
@Field(type => ScalarObject, { nullable: true })
|
292
|
-
params?: { [key: string]: any }
|
293
|
-
|
294
|
-
@Field({ nullable: true })
|
295
|
-
cuFlag?: string
|
296
|
-
}
|
297
|
-
|
298
|
-
@ObjectType()
|
299
|
-
export class ConnectionList {
|
300
|
-
@Field(type => [Connection])
|
301
|
-
items: Connection[]
|
302
|
-
|
303
|
-
@Field(type => Int)
|
304
|
-
total: number
|
305
|
-
}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { Connection } from './connection-type'
|
2
|
-
import { ConnectionQuery } from './connection-query'
|
3
|
-
import { ConnectionMutation } from './connection-mutation'
|
4
|
-
import { ConnectionSubscription } from './connection-subscription'
|
5
|
-
|
6
|
-
export const entities = [Connection]
|
7
|
-
export const resolvers = [ConnectionQuery, ConnectionMutation, ConnectionSubscription]
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { Arg, Ctx, Query, Resolver } from 'type-graphql'
|
2
|
-
|
3
|
-
import { getRepository } from '@things-factory/shell'
|
4
|
-
|
5
|
-
import { ConnectionManager } from '../../engine/connection-manager'
|
6
|
-
import { Connection } from '../connection/connection-type'
|
7
|
-
import { ConnectorList, ConnectorType } from './connector-type'
|
8
|
-
|
9
|
-
@Resolver(ConnectorType)
|
10
|
-
export class ConnectorQuery {
|
11
|
-
@Query(returns => ConnectorType, { description: 'To fetch a connector' })
|
12
|
-
async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<ConnectorType> {
|
13
|
-
// @ts-ignore
|
14
|
-
const { description, help, parameterSpec, taskPrefixes } = ConnectionManager.getConnector(name) || {}
|
15
|
-
|
16
|
-
return {
|
17
|
-
name,
|
18
|
-
description,
|
19
|
-
help,
|
20
|
-
parameterSpec,
|
21
|
-
taskPrefixes: taskPrefixes || []
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
@Query(returns => ConnectorList, { description: 'To fetch multiple connector' })
|
26
|
-
async connectors(): Promise<ConnectorList> {
|
27
|
-
var connectors = ConnectionManager.getConnectors()
|
28
|
-
var items = Object.keys(connectors)
|
29
|
-
.map(name => {
|
30
|
-
var connector = connectors[name]
|
31
|
-
return {
|
32
|
-
name,
|
33
|
-
description: connector.description,
|
34
|
-
help: connector.help,
|
35
|
-
parameterSpec: connector.parameterSpec,
|
36
|
-
taskPrefixes: connector.taskPrefixes || []
|
37
|
-
}
|
38
|
-
})
|
39
|
-
.sort((x, y) => {
|
40
|
-
return x.name < y.name ? -1 : 1
|
41
|
-
})
|
42
|
-
|
43
|
-
return {
|
44
|
-
items,
|
45
|
-
total: items.length
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
@Query(returns => ConnectorType, { description: 'To fetch the connector from a connection' })
|
50
|
-
async connectorByConnection(
|
51
|
-
@Arg('connectionName') connectionName: string,
|
52
|
-
@Ctx() context: ResolverContext
|
53
|
-
): Promise<ConnectorType> {
|
54
|
-
const { domain } = context.state
|
55
|
-
|
56
|
-
var connection = await getRepository(Connection).findOne({
|
57
|
-
where: { domain: { id: domain.id }, name: connectionName }
|
58
|
-
})
|
59
|
-
|
60
|
-
return connection && (ConnectionManager.getConnector(connection.type) as any)
|
61
|
-
}
|
62
|
-
}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { ObjectType, Field, Int } from 'type-graphql'
|
2
|
-
import { PropertySpec } from '../property-spec'
|
3
|
-
|
4
|
-
@ObjectType()
|
5
|
-
export class ConnectorType {
|
6
|
-
@Field()
|
7
|
-
name: string
|
8
|
-
|
9
|
-
@Field({ nullable: true })
|
10
|
-
description: string
|
11
|
-
|
12
|
-
@Field({ nullable: true })
|
13
|
-
help?: string
|
14
|
-
|
15
|
-
@Field(type => [PropertySpec], { nullable: true })
|
16
|
-
parameterSpec: PropertySpec[]
|
17
|
-
|
18
|
-
@Field(type => [String], { nullable: true })
|
19
|
-
taskPrefixes?: string[]
|
20
|
-
}
|
21
|
-
|
22
|
-
@ObjectType()
|
23
|
-
export class ConnectorList {
|
24
|
-
@Field(type => [ConnectorType])
|
25
|
-
items: ConnectorType[]
|
26
|
-
|
27
|
-
@Field(type => Int)
|
28
|
-
total: number
|
29
|
-
}
|
package/server/service/index.ts
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
import { entities as ConnectionEntities, resolvers as ConnectionResolvers } from './connection'
|
2
|
-
import { entities as ConnectorEntities, resolvers as ConnectorResolvers } from './connector'
|
3
|
-
import { entities as ScenarioEntities, resolvers as ScenarioResolvers } from './scenario'
|
4
|
-
import { entities as ScenarioInstanceEntities, resolvers as ScenarioInstanceResolvers } from './scenario-instance'
|
5
|
-
import { entities as ScenarioQueueEntities, resolvers as ScenarioQueueResolvers } from './scenario-queue'
|
6
|
-
import { entities as StepEntities, resolvers as StepResolvers } from './step'
|
7
|
-
import { entities as TaskTypeEntities, resolvers as TaskTypeResolvers } from './task-type'
|
8
|
-
import { entities as PayloadLogEntities, resolvers as PayloadLogResolvers } from './payload-log'
|
9
|
-
import { entities as StateRegisterEntities, resolvers as StateRegisterResolvers } from './state-register'
|
10
|
-
import { resolvers as IntegrationAnalysisQuery } from './analysis'
|
11
|
-
|
12
|
-
export * from './property-spec'
|
13
|
-
export * from './task-type/task-type-type'
|
14
|
-
export * from './connector/connector-type'
|
15
|
-
export * from './connection/connection-type'
|
16
|
-
export * from './scenario/scenario'
|
17
|
-
export * from './scenario-instance/scenario-instance-type'
|
18
|
-
export * from './scenario-queue/scenario-queue-type'
|
19
|
-
export * from './step/step-type'
|
20
|
-
export * from './scenario-flow/scenario-flow'
|
21
|
-
export * from './payload-log/payload-log'
|
22
|
-
export * from './state-register/state-register'
|
23
|
-
|
24
|
-
export const entities = [
|
25
|
-
...TaskTypeEntities,
|
26
|
-
...ConnectorEntities,
|
27
|
-
...ConnectionEntities,
|
28
|
-
...ScenarioEntities,
|
29
|
-
...ScenarioInstanceEntities,
|
30
|
-
...ScenarioQueueEntities,
|
31
|
-
...StepEntities,
|
32
|
-
...PayloadLogEntities,
|
33
|
-
...StateRegisterEntities
|
34
|
-
]
|
35
|
-
|
36
|
-
export const schema = {
|
37
|
-
resolverClasses: [
|
38
|
-
...TaskTypeResolvers,
|
39
|
-
...ConnectorResolvers,
|
40
|
-
...ConnectionResolvers,
|
41
|
-
...ScenarioResolvers,
|
42
|
-
...ScenarioInstanceResolvers,
|
43
|
-
...ScenarioQueueResolvers,
|
44
|
-
...StepResolvers,
|
45
|
-
...PayloadLogResolvers,
|
46
|
-
...IntegrationAnalysisQuery,
|
47
|
-
...StateRegisterResolvers
|
48
|
-
]
|
49
|
-
}
|
50
|
-
|
51
|
-
export { PayloadType } from './payload-log/payload-log'
|
52
|
-
export { createPayloadLog } from './payload-log/payload-log-mutation'
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { PayloadLog } from './payload-log'
|
2
|
-
import { PayloadLogQuery } from './payload-log-query'
|
3
|
-
import { PayloadLogMutation } from './payload-log-mutation'
|
4
|
-
|
5
|
-
export const entities = [PayloadLog]
|
6
|
-
export const resolvers = [PayloadLogQuery, PayloadLogMutation]
|
7
|
-
|