@things-factory/integration-base 8.0.0-beta.8 → 8.0.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/http-connector.js +1 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/index.d.ts +0 -1
- package/dist-server/engine/connector/index.js +0 -1
- package/dist-server/engine/connector/index.js.map +1 -1
- package/dist-server/engine/index.d.ts +0 -1
- package/dist-server/engine/index.js +0 -1
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/headless-post.js +33 -19
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +13 -20
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -12
- package/server/controllers/index.ts +2 -0
- package/server/controllers/publish-data.ts +29 -0
- package/server/controllers/scenario-controller.ts +156 -0
- package/server/engine/analyzer/analyze-integration.ts +115 -0
- package/server/engine/connection-manager.ts +239 -0
- package/server/engine/connector/echo-back-connector.ts +51 -0
- package/server/engine/connector/echo-back-server.ts +72 -0
- package/server/engine/connector/graphql-connector.ts +126 -0
- package/server/engine/connector/http-connector.ts +65 -0
- package/server/engine/connector/index.ts +12 -0
- package/server/engine/connector/mqtt-connector.ts +78 -0
- package/server/engine/connector/mssql-connector.ts +152 -0
- package/server/engine/connector/mysql-connector.ts +94 -0
- package/server/engine/connector/operato-connector.ts +264 -0
- package/server/engine/connector/oracle-connector.ts +218 -0
- package/server/engine/connector/postgresql-connector.ts +152 -0
- package/server/engine/connector/proxy-connector.ts +53 -0
- package/server/engine/connector/socket-server.ts +86 -0
- package/server/engine/connector/sqlite-connector.ts +69 -0
- package/server/engine/edge-client.ts +45 -0
- package/server/engine/index.ts +10 -0
- package/server/engine/pending-queue.ts +97 -0
- package/server/engine/scenario-engine.ts +106 -0
- package/server/engine/task/book-up-scenario.ts +73 -0
- package/server/engine/task/csv-readline.ts +127 -0
- package/server/engine/task/data-accessor.ts +36 -0
- package/server/engine/task/data-mapper.ts +47 -0
- package/server/engine/task/database-query.ts +56 -0
- package/server/engine/task/echo-receive.ts +21 -0
- package/server/engine/task/echo-send.ts +32 -0
- package/server/engine/task/empty-check.ts +38 -0
- package/server/engine/task/end.ts +18 -0
- package/server/engine/task/floating-point.ts +71 -0
- package/server/engine/task/goto.ts +27 -0
- package/server/engine/task/graphql-mutate.ts +79 -0
- package/server/engine/task/graphql-query.ts +78 -0
- package/server/engine/task/headless-post.ts +147 -0
- package/server/engine/task/headless-scrap.ts +80 -0
- package/server/engine/task/http-get.ts +117 -0
- package/server/engine/task/http-post.ts +148 -0
- package/server/engine/task/index.ts +45 -0
- package/server/engine/task/jsonata.ts +45 -0
- package/server/engine/task/local-graphql-mutate.ts +100 -0
- package/server/engine/task/local-graphql-query.ts +100 -0
- package/server/engine/task/log.ts +78 -0
- package/server/engine/task/mqtt-publish.ts +45 -0
- package/server/engine/task/mqtt-subscribe.ts +139 -0
- package/server/engine/task/mssql-procedure.ts +128 -0
- package/server/engine/task/oracle-procedure.ts +124 -0
- package/server/engine/task/pick-pending-scenario.ts +80 -0
- package/server/engine/task/publish.ts +40 -0
- package/server/engine/task/random.ts +53 -0
- package/server/engine/task/reset-pending-queue.ts +17 -0
- package/server/engine/task/script.ts +63 -0
- package/server/engine/task/set-domain.ts +37 -0
- package/server/engine/task/sleep.ts +34 -0
- package/server/engine/task/socket-listener.ts +96 -0
- package/server/engine/task/state-group-read.ts +69 -0
- package/server/engine/task/state-read.ts +56 -0
- package/server/engine/task/state-write.ts +65 -0
- package/server/engine/task/stop-scenario.ts +44 -0
- package/server/engine/task/sub-scenario.ts +57 -0
- package/server/engine/task/switch-goto.ts +43 -0
- package/server/engine/task/switch-range-goto.ts +53 -0
- package/server/engine/task/switch-range-scenario.ts +79 -0
- package/server/engine/task/switch-range-set.ts +48 -0
- package/server/engine/task/switch-scenario.ts +67 -0
- package/server/engine/task/switch-set.ts +37 -0
- package/server/engine/task/throw.ts +27 -0
- package/server/engine/task/utils/headless-pool-for-scenario.ts +71 -0
- package/server/engine/task/utils/substitute.ts +44 -0
- package/server/engine/task/variables.ts +17 -0
- package/server/engine/task-registry.ts +23 -0
- package/server/engine/types.ts +114 -0
- package/server/index.ts +20 -0
- package/server/migrations/index.ts +9 -0
- package/server/restful/index.ts +1 -0
- package/server/restful/unstable/index.ts +7 -0
- package/server/restful/unstable/run-scenario.ts +51 -0
- package/server/restful/unstable/scenario-instance.ts +52 -0
- package/server/restful/unstable/scenario-instances.ts +80 -0
- package/server/restful/unstable/scenario.ts +41 -0
- package/server/restful/unstable/scenarios.ts +69 -0
- package/server/restful/unstable/start-scenario.ts +33 -0
- package/server/restful/unstable/stop-scenario.ts +30 -0
- package/server/routers/scenario-schedule-callback-router.ts +69 -0
- package/server/routers/scenario-view-router.ts +46 -0
- package/server/routes.ts +30 -0
- package/server/service/analysis/analysis-query.ts +13 -0
- package/server/service/analysis/index.ts +3 -0
- package/server/service/connection/connection-mutation.ts +190 -0
- package/server/service/connection/connection-query.ts +87 -0
- package/server/service/connection/connection-subscription.ts +104 -0
- package/server/service/connection/connection-type.ts +288 -0
- package/server/service/connection/index.ts +7 -0
- package/server/service/connector/connector-query.ts +62 -0
- package/server/service/connector/connector-type.ts +29 -0
- package/server/service/connector/index.ts +4 -0
- package/server/service/index.ts +52 -0
- package/server/service/payload-log/index.ts +7 -0
- package/server/service/payload-log/payload-log-mutation.ts +151 -0
- package/server/service/payload-log/payload-log-query.ts +49 -0
- package/server/service/payload-log/payload-log-type.ts +36 -0
- package/server/service/payload-log/payload-log.ts +100 -0
- package/server/service/property-spec.ts +24 -0
- package/server/service/scenario/index.ts +6 -0
- package/server/service/scenario/scenario-mutation.ts +396 -0
- package/server/service/scenario/scenario-query.ts +109 -0
- package/server/service/scenario/scenario-type.ts +78 -0
- package/server/service/scenario/scenario.ts +124 -0
- package/server/service/scenario-flow/scenario-flow.ts +17 -0
- package/server/service/scenario-instance/index.ts +6 -0
- package/server/service/scenario-instance/scenario-instance-mutation.ts +44 -0
- package/server/service/scenario-instance/scenario-instance-query.ts +42 -0
- package/server/service/scenario-instance/scenario-instance-subscription.ts +118 -0
- package/server/service/scenario-instance/scenario-instance-type.ts +563 -0
- package/server/service/scenario-queue/index.ts +4 -0
- package/server/service/scenario-queue/scenario-queue-subscription.ts +55 -0
- package/server/service/scenario-queue/scenario-queue-type.ts +27 -0
- package/server/service/state-register/data-resolver.ts +56 -0
- package/server/service/state-register/index.ts +8 -0
- package/server/service/state-register/state-register-mutation.ts +166 -0
- package/server/service/state-register/state-register-query.ts +80 -0
- package/server/service/state-register/state-register-type.ts +80 -0
- package/server/service/state-register/state-register.ts +113 -0
- package/server/service/step/index.ts +6 -0
- package/server/service/step/step-mutation.ts +52 -0
- package/server/service/step/step-query.ts +55 -0
- package/server/service/step/step-type.ts +215 -0
- package/server/service/task-type/index.ts +4 -0
- package/server/service/task-type/task-type-query.ts +95 -0
- package/server/service/task-type/task-type-type.ts +29 -0
- package/translations/en.json +4 -12
- package/translations/ja.json +4 -12
- package/translations/ko.json +4 -12
- package/translations/ms.json +4 -12
- package/translations/zh.json +4 -12
- package/dist-server/engine/connector/headless-connector.d.ts +0 -23
- package/dist-server/engine/connector/headless-connector.js +0 -357
- package/dist-server/engine/connector/headless-connector.js.map +0 -1
- package/dist-server/engine/resource-pool/headless-pool.d.ts +0 -1
- package/dist-server/engine/resource-pool/headless-pool.js +0 -62
- package/dist-server/engine/resource-pool/headless-pool.js.map +0 -1
- package/dist-server/engine/resource-pool/index.d.ts +0 -1
- package/dist-server/engine/resource-pool/index.js +0 -5
- package/dist-server/engine/resource-pool/index.js.map +0 -1
@@ -0,0 +1,288 @@
|
|
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 { logger } from '@things-factory/env'
|
15
|
+
import { Domain, ObjectRef } from '@things-factory/shell'
|
16
|
+
|
17
|
+
import { ConnectionManager } from '../../engine'
|
18
|
+
import { ProxyConnector } from '../../engine/connector/proxy-connector'
|
19
|
+
|
20
|
+
export enum ConnectionStatus {
|
21
|
+
CONNECTED = 'CONNECTED',
|
22
|
+
DISCONNECTED = 'DISCONNECTED'
|
23
|
+
}
|
24
|
+
|
25
|
+
registerEnumType(ConnectionStatus, {
|
26
|
+
name: 'ConnectionStatus',
|
27
|
+
description: 'state enumeration of a connection'
|
28
|
+
})
|
29
|
+
|
30
|
+
@Entity()
|
31
|
+
@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })
|
32
|
+
@ObjectType()
|
33
|
+
export class Connection {
|
34
|
+
/**
|
35
|
+
* Unique identifier for the connection, generated in UUID format.
|
36
|
+
*/
|
37
|
+
@PrimaryGeneratedColumn('uuid')
|
38
|
+
@Field(type => ID)
|
39
|
+
readonly id: string
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Many-to-One relationship with the Domain entity.
|
43
|
+
*/
|
44
|
+
@ManyToOne(type => Domain)
|
45
|
+
@Field(type => Domain, { nullable: true })
|
46
|
+
domain: Domain
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Stores the ID of the associated Domain.
|
50
|
+
*/
|
51
|
+
@RelationId((connection: Connection) => connection.domain)
|
52
|
+
domainId: string
|
53
|
+
|
54
|
+
/**
|
55
|
+
* The name of the connection.
|
56
|
+
*/
|
57
|
+
@Column()
|
58
|
+
@Field()
|
59
|
+
name: string
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Optional description for the connection.
|
63
|
+
*/
|
64
|
+
@Column({
|
65
|
+
nullable: true
|
66
|
+
})
|
67
|
+
@Field({ nullable: true })
|
68
|
+
description: string
|
69
|
+
|
70
|
+
/**
|
71
|
+
* The type of the connection.
|
72
|
+
*/
|
73
|
+
@Column()
|
74
|
+
@Field({ nullable: true })
|
75
|
+
type: string
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.
|
79
|
+
*/
|
80
|
+
@ManyToOne(type => Appliance, { nullable: true })
|
81
|
+
@Field({ nullable: true })
|
82
|
+
edge: Appliance
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Stores the ID of the Appliance who delegate the connection.
|
86
|
+
*/
|
87
|
+
@RelationId((connection: Connection) => connection.edge)
|
88
|
+
edgeId: string
|
89
|
+
|
90
|
+
/**
|
91
|
+
* The endpoint for the connection.
|
92
|
+
*/
|
93
|
+
@Column()
|
94
|
+
@Field({ nullable: true })
|
95
|
+
endpoint: string
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Indicates the active status of the connection.
|
99
|
+
*/
|
100
|
+
@Column({ nullable: true })
|
101
|
+
@Field({ nullable: true })
|
102
|
+
active: boolean
|
103
|
+
|
104
|
+
/**
|
105
|
+
* The status of the connection, using the ConnectionStatus type.
|
106
|
+
*/
|
107
|
+
@Field({ nullable: true })
|
108
|
+
state: ConnectionStatus
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Additional parameters for the connection, stored as a JSON string.
|
112
|
+
*/
|
113
|
+
@Column({ nullable: true })
|
114
|
+
@Field({ nullable: true })
|
115
|
+
params: string
|
116
|
+
|
117
|
+
/**
|
118
|
+
* The date and time when the connection was created.
|
119
|
+
*/
|
120
|
+
@CreateDateColumn()
|
121
|
+
@Field({ nullable: true })
|
122
|
+
createdAt: Date
|
123
|
+
|
124
|
+
/**
|
125
|
+
* The date and time when the connection was last updated.
|
126
|
+
*/
|
127
|
+
@UpdateDateColumn()
|
128
|
+
@Field({ nullable: true })
|
129
|
+
updatedAt: Date
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Many-to-One relationship with the User entity who created the connection. Optional field.
|
133
|
+
*/
|
134
|
+
@ManyToOne(type => User, { nullable: true })
|
135
|
+
@Field({ nullable: true })
|
136
|
+
creator: User
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Stores the ID of the User who created the connection.
|
140
|
+
*/
|
141
|
+
@RelationId((connection: Connection) => connection.creator)
|
142
|
+
creatorId: string
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Many-to-One relationship with the User entity who last updated the connection.
|
146
|
+
* Optional field.
|
147
|
+
*/
|
148
|
+
@ManyToOne(type => User, { nullable: true })
|
149
|
+
@Field({ nullable: true })
|
150
|
+
updater: User
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Stores the ID of the User who last updated the connection.
|
154
|
+
*
|
155
|
+
*/
|
156
|
+
@RelationId((connection: Connection) => connection.updater)
|
157
|
+
updaterId: string
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Asynchronous method to establish the connection.
|
161
|
+
*
|
162
|
+
*/
|
163
|
+
async connect() {
|
164
|
+
const { type, edge } = this
|
165
|
+
const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
166
|
+
var params = {}
|
167
|
+
|
168
|
+
try {
|
169
|
+
params = JSON.parse(this.params || '{}')
|
170
|
+
} catch (ex) {
|
171
|
+
logger.error(`connection '${this.name}' params should be JSON format`, ex)
|
172
|
+
}
|
173
|
+
|
174
|
+
await connector.connect({
|
175
|
+
...this,
|
176
|
+
params
|
177
|
+
})
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* @brief Asynchronous method to disconnect the connection.
|
182
|
+
*
|
183
|
+
*/
|
184
|
+
async disconnect() {
|
185
|
+
try {
|
186
|
+
const { type, edge } = this
|
187
|
+
const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)
|
188
|
+
await connector.disconnect(this)
|
189
|
+
} finally {
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
|
196
|
+
* 추후, 타입 일치를 통해서 제거할 예정임.
|
197
|
+
*
|
198
|
+
*/
|
199
|
+
export interface InputConnection extends Connection {
|
200
|
+
params: any
|
201
|
+
}
|
202
|
+
|
203
|
+
@ObjectType()
|
204
|
+
export class ConnectionState {
|
205
|
+
@Field(type => Domain)
|
206
|
+
domain?: Domain
|
207
|
+
|
208
|
+
@Field({ nullable: true })
|
209
|
+
id?: string
|
210
|
+
|
211
|
+
@Field({ nullable: true })
|
212
|
+
name?: string
|
213
|
+
|
214
|
+
@Field({ nullable: true })
|
215
|
+
description?: string
|
216
|
+
|
217
|
+
@Field({ nullable: true })
|
218
|
+
type?: string
|
219
|
+
|
220
|
+
@Field(type => Appliance, { nullable: true })
|
221
|
+
edge?: Appliance
|
222
|
+
|
223
|
+
@Field({ nullable: true })
|
224
|
+
state?: ConnectionStatus
|
225
|
+
|
226
|
+
@Field({ nullable: true })
|
227
|
+
timestamp?: Date
|
228
|
+
}
|
229
|
+
|
230
|
+
@InputType()
|
231
|
+
export class NewConnection {
|
232
|
+
@Field()
|
233
|
+
name: string
|
234
|
+
|
235
|
+
@Field({ nullable: true })
|
236
|
+
description?: string
|
237
|
+
|
238
|
+
@Field({ nullable: true })
|
239
|
+
type?: string
|
240
|
+
|
241
|
+
@Field(type => ObjectRef, { nullable: true })
|
242
|
+
edge?: Appliance
|
243
|
+
|
244
|
+
@Field({ nullable: true })
|
245
|
+
endpoint?: string
|
246
|
+
|
247
|
+
@Field({ nullable: true })
|
248
|
+
params?: string
|
249
|
+
}
|
250
|
+
|
251
|
+
@InputType()
|
252
|
+
export class ConnectionPatch {
|
253
|
+
@Field(type => ID, { nullable: true })
|
254
|
+
id: string
|
255
|
+
|
256
|
+
@Field({ nullable: true })
|
257
|
+
name?: string
|
258
|
+
|
259
|
+
@Field({ nullable: true })
|
260
|
+
description?: string
|
261
|
+
|
262
|
+
@Field({ nullable: true })
|
263
|
+
type?: string
|
264
|
+
|
265
|
+
@Field(type => ObjectRef, { nullable: true })
|
266
|
+
edge?: Appliance
|
267
|
+
|
268
|
+
@Field({ nullable: true })
|
269
|
+
endpoint?: string
|
270
|
+
|
271
|
+
@Field({ nullable: true })
|
272
|
+
active?: boolean
|
273
|
+
|
274
|
+
@Field({ nullable: true })
|
275
|
+
params?: string
|
276
|
+
|
277
|
+
@Field({ nullable: true })
|
278
|
+
cuFlag?: string
|
279
|
+
}
|
280
|
+
|
281
|
+
@ObjectType()
|
282
|
+
export class ConnectionList {
|
283
|
+
@Field(type => [Connection])
|
284
|
+
items: Connection[]
|
285
|
+
|
286
|
+
@Field(type => Int)
|
287
|
+
total: number
|
288
|
+
}
|
@@ -0,0 +1,7 @@
|
|
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]
|
@@ -0,0 +1,62 @@
|
|
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
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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
|
+
}
|
@@ -0,0 +1,52 @@
|
|
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'
|
@@ -0,0 +1,7 @@
|
|
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
|
+
|
@@ -0,0 +1,151 @@
|
|
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
|
+
|
8
|
+
import { PayloadLog, PayloadType } from './payload-log'
|
9
|
+
import { NewPayloadLog, PayloadLogPatch } from './payload-log-type'
|
10
|
+
|
11
|
+
@Resolver(PayloadLog)
|
12
|
+
export class PayloadLogMutation {
|
13
|
+
@Directive('@transaction')
|
14
|
+
@Mutation(returns => PayloadLog, { description: 'To create new PayloadLog' })
|
15
|
+
async createPayloadLog(
|
16
|
+
@Arg('payloadLog') payloadLog: NewPayloadLog,
|
17
|
+
@Ctx() context: ResolverContext
|
18
|
+
): Promise<PayloadLog> {
|
19
|
+
const { domain, user, tx } = context.state
|
20
|
+
|
21
|
+
return await tx.getRepository(PayloadLog).save({
|
22
|
+
...payloadLog,
|
23
|
+
domain,
|
24
|
+
creator: user,
|
25
|
+
updater: user
|
26
|
+
})
|
27
|
+
}
|
28
|
+
|
29
|
+
@Directive('@transaction')
|
30
|
+
@Mutation(returns => PayloadLog, { description: 'To modify PayloadLog information' })
|
31
|
+
async updatePayloadLog(
|
32
|
+
@Arg('id') id: string,
|
33
|
+
@Arg('patch') patch: PayloadLogPatch,
|
34
|
+
@Ctx() context: ResolverContext
|
35
|
+
): Promise<PayloadLog> {
|
36
|
+
const { domain, user, tx } = context.state
|
37
|
+
|
38
|
+
const repository = tx.getRepository(PayloadLog)
|
39
|
+
const payloadLog = await repository.findOne({
|
40
|
+
where: { domain: { id: domain.id }, id }
|
41
|
+
})
|
42
|
+
|
43
|
+
return await repository.save({
|
44
|
+
...payloadLog,
|
45
|
+
...patch,
|
46
|
+
updater: user
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
@Directive('@transaction')
|
51
|
+
@Mutation(returns => [PayloadLog], { description: "To modify multiple PayloadLogs' information" })
|
52
|
+
async updateMultiplePayloadLog(
|
53
|
+
@Arg('patches', type => [PayloadLogPatch]) patches: PayloadLogPatch[],
|
54
|
+
@Ctx() context: ResolverContext
|
55
|
+
): Promise<PayloadLog[]> {
|
56
|
+
const { domain, user, tx } = context.state
|
57
|
+
|
58
|
+
let results = []
|
59
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
60
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
61
|
+
const payloadLogRepo = tx.getRepository(PayloadLog)
|
62
|
+
|
63
|
+
if (_createRecords.length > 0) {
|
64
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
65
|
+
const newRecord = _createRecords[i]
|
66
|
+
|
67
|
+
const result = await payloadLogRepo.save({
|
68
|
+
...newRecord,
|
69
|
+
domain,
|
70
|
+
creator: user,
|
71
|
+
updater: user
|
72
|
+
})
|
73
|
+
|
74
|
+
results.push({ ...result, cuFlag: '+' })
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
if (_updateRecords.length > 0) {
|
79
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
80
|
+
const newRecord = _updateRecords[i]
|
81
|
+
const payloadLog = await payloadLogRepo.findOneBy({ id: newRecord.id })
|
82
|
+
|
83
|
+
const result = await payloadLogRepo.save({
|
84
|
+
...payloadLog,
|
85
|
+
...newRecord,
|
86
|
+
updater: user
|
87
|
+
})
|
88
|
+
|
89
|
+
results.push({ ...result, cuFlag: 'M' })
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
return results
|
94
|
+
}
|
95
|
+
|
96
|
+
@Directive('@transaction')
|
97
|
+
@Mutation(returns => Boolean, { description: 'To delete PayloadLog' })
|
98
|
+
async deletePayloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
99
|
+
const { domain, tx } = context.state
|
100
|
+
|
101
|
+
await tx.getRepository(PayloadLog).delete({ domain: { id: domain.id }, id })
|
102
|
+
return true
|
103
|
+
}
|
104
|
+
|
105
|
+
@Directive('@transaction')
|
106
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple payloadLogs' })
|
107
|
+
async deletePayloadLogs(
|
108
|
+
@Arg('ids', type => [String]) ids: string[],
|
109
|
+
@Ctx() context: ResolverContext
|
110
|
+
): Promise<boolean> {
|
111
|
+
const { domain, tx } = context.state
|
112
|
+
|
113
|
+
await tx.getRepository(PayloadLog).delete({
|
114
|
+
domain: { id: domain.id },
|
115
|
+
id: In(ids)
|
116
|
+
})
|
117
|
+
|
118
|
+
return true
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
export async function createPayloadLog(
|
123
|
+
name: string,
|
124
|
+
endpoint: string,
|
125
|
+
request: string,
|
126
|
+
response: string,
|
127
|
+
context: any,
|
128
|
+
type: PayloadType = PayloadType.EGESTION,
|
129
|
+
src: string = null
|
130
|
+
): Promise<void> {
|
131
|
+
try {
|
132
|
+
const { domain, user }: { domain: Domain; user: User } = context?.state
|
133
|
+
|
134
|
+
// disabled due to high db server usage
|
135
|
+
await getRepository(PayloadLog).save({
|
136
|
+
name,
|
137
|
+
domain,
|
138
|
+
endpoint,
|
139
|
+
request,
|
140
|
+
response,
|
141
|
+
type,
|
142
|
+
src,
|
143
|
+
createdBy: user,
|
144
|
+
updatedBy: user,
|
145
|
+
createdAt: new Date(),
|
146
|
+
updatedAt: new Date()
|
147
|
+
})
|
148
|
+
} catch (error) {
|
149
|
+
logger.error(`PayloadLog Error`, error)
|
150
|
+
}
|
151
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
2
|
+
|
3
|
+
import { User } from '@things-factory/auth-base'
|
4
|
+
import { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'
|
5
|
+
|
6
|
+
import { PayloadLog } from './payload-log'
|
7
|
+
import { PayloadLogList } from './payload-log-type'
|
8
|
+
|
9
|
+
@Resolver(PayloadLog)
|
10
|
+
export class PayloadLogQuery {
|
11
|
+
@Query(returns => PayloadLog, { description: 'To fetch a PayloadLog' })
|
12
|
+
async payloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<PayloadLog> {
|
13
|
+
const { domain } = context.state
|
14
|
+
|
15
|
+
return await getRepository(PayloadLog).findOne({
|
16
|
+
where: { domain: { id: domain.id }, id }
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
20
|
+
@Query(returns => PayloadLogList, { description: 'To fetch multiple PayloadLogs' })
|
21
|
+
async payloadLogs(
|
22
|
+
@Args(type => ListParam) params: ListParam,
|
23
|
+
@Ctx() context: ResolverContext
|
24
|
+
): Promise<PayloadLogList> {
|
25
|
+
const { domain } = context.state
|
26
|
+
|
27
|
+
const convertedParams = convertListParams(params, {
|
28
|
+
domain
|
29
|
+
})
|
30
|
+
const [items, total] = await getRepository(PayloadLog).findAndCount(convertedParams)
|
31
|
+
|
32
|
+
return { items, total }
|
33
|
+
}
|
34
|
+
|
35
|
+
@FieldResolver(type => Domain)
|
36
|
+
async domain(@Root() payloadLog: PayloadLog): Promise<Domain> {
|
37
|
+
return await getRepository(Domain).findOneBy({ id: payloadLog.domainId })
|
38
|
+
}
|
39
|
+
|
40
|
+
@FieldResolver(type => User)
|
41
|
+
async updater(@Root() payloadLog: PayloadLog): Promise<User> {
|
42
|
+
return await getRepository(User).findOneBy({ id: payloadLog.updaterId })
|
43
|
+
}
|
44
|
+
|
45
|
+
@FieldResolver(type => User)
|
46
|
+
async creator(@Root() payloadLog: PayloadLog): Promise<User> {
|
47
|
+
return await getRepository(User).findOneBy({ id: payloadLog.creatorId })
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
2
|
+
|
3
|
+
import { PayloadLog } from './payload-log'
|
4
|
+
|
5
|
+
@InputType()
|
6
|
+
export class NewPayloadLog {
|
7
|
+
@Field()
|
8
|
+
name: string
|
9
|
+
|
10
|
+
@Field({ nullable: true })
|
11
|
+
description?: string
|
12
|
+
}
|
13
|
+
|
14
|
+
@InputType()
|
15
|
+
export class PayloadLogPatch {
|
16
|
+
@Field(type => ID, { nullable: true })
|
17
|
+
id?: string
|
18
|
+
|
19
|
+
@Field({ nullable: true })
|
20
|
+
name?: string
|
21
|
+
|
22
|
+
@Field({ nullable: true })
|
23
|
+
description?: string
|
24
|
+
|
25
|
+
@Field()
|
26
|
+
cuFlag: string
|
27
|
+
}
|
28
|
+
|
29
|
+
@ObjectType()
|
30
|
+
export class PayloadLogList {
|
31
|
+
@Field(type => [PayloadLog])
|
32
|
+
items: PayloadLog[]
|
33
|
+
|
34
|
+
@Field(type => Int)
|
35
|
+
total: number
|
36
|
+
}
|