@things-factory/integration-base 7.0.1-alpha.10 → 7.0.1-alpha.102

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.
Files changed (49) hide show
  1. package/dist-server/controllers/scenario-controller.js +13 -2
  2. package/dist-server/controllers/scenario-controller.js.map +1 -1
  3. package/dist-server/engine/task/database-query.js +5 -1
  4. package/dist-server/engine/task/database-query.js.map +1 -1
  5. package/dist-server/engine/task/graphql-mutate.js +7 -1
  6. package/dist-server/engine/task/graphql-mutate.js.map +1 -1
  7. package/dist-server/engine/task/graphql-query.js +7 -1
  8. package/dist-server/engine/task/graphql-query.js.map +1 -1
  9. package/dist-server/engine/task/jsonata.js +5 -1
  10. package/dist-server/engine/task/jsonata.js.map +1 -1
  11. package/dist-server/engine/task/local-graphql-mutate.js +7 -1
  12. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  13. package/dist-server/engine/task/local-graphql-query.js +7 -1
  14. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  15. package/dist-server/engine/task/script.js +5 -1
  16. package/dist-server/engine/task/script.js.map +1 -1
  17. package/dist-server/service/connection/connection-type.js +2 -2
  18. package/dist-server/service/connection/connection-type.js.map +1 -1
  19. package/dist-server/service/payload-log/payload-log.js +1 -1
  20. package/dist-server/service/payload-log/payload-log.js.map +1 -1
  21. package/dist-server/service/property-spec.js +4 -0
  22. package/dist-server/service/property-spec.js.map +1 -1
  23. package/dist-server/service/scenario/scenario.js +1 -1
  24. package/dist-server/service/scenario/scenario.js.map +1 -1
  25. package/dist-server/service/state-register/state-register.js +1 -1
  26. package/dist-server/service/state-register/state-register.js.map +1 -1
  27. package/dist-server/service/step/step-type.js +17 -14
  28. package/dist-server/service/step/step-type.js.map +1 -1
  29. package/dist-server/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +10 -10
  31. package/server/controllers/scenario-controller.ts +15 -2
  32. package/server/engine/task/database-query.ts +5 -1
  33. package/server/engine/task/graphql-mutate.ts +7 -1
  34. package/server/engine/task/graphql-query.ts +7 -1
  35. package/server/engine/task/jsonata.ts +5 -1
  36. package/server/engine/task/local-graphql-mutate.ts +7 -3
  37. package/server/engine/task/local-graphql-query.ts +7 -1
  38. package/server/engine/task/script.ts +5 -1
  39. package/server/service/connection/connection-type.ts +12 -3
  40. package/server/service/payload-log/payload-log.ts +3 -3
  41. package/server/service/property-spec.ts +3 -0
  42. package/server/service/scenario/scenario.ts +1 -1
  43. package/server/service/state-register/state-register.ts +1 -1
  44. package/server/service/step/step-type.ts +59 -57
  45. package/translations/en.json +2 -0
  46. package/translations/ja.json +2 -0
  47. package/translations/ko.json +2 -0
  48. package/translations/ms.json +2 -0
  49. package/translations/zh.json +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "7.0.1-alpha.10",
3
+ "version": "7.0.1-alpha.102",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,22 +26,22 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@apollo/client": "^3.6.9",
29
- "@things-factory/api": "^7.0.1-alpha.10",
30
- "@things-factory/auth-base": "^7.0.1-alpha.10",
31
- "@things-factory/env": "^7.0.1-alpha.0",
32
- "@things-factory/oauth2-client": "^7.0.1-alpha.10",
33
- "@things-factory/scheduler-client": "^7.0.1-alpha.10",
34
- "@things-factory/shell": "^7.0.1-alpha.10",
35
- "@things-factory/utils": "^7.0.1-alpha.4",
29
+ "@operato/moment-timezone-es": "^2.0.0-alpha.0",
30
+ "@things-factory/api": "^7.0.1-alpha.102",
31
+ "@things-factory/auth-base": "^7.0.1-alpha.102",
32
+ "@things-factory/env": "^7.0.1-alpha.71",
33
+ "@things-factory/oauth2-client": "^7.0.1-alpha.102",
34
+ "@things-factory/scheduler-client": "^7.0.1-alpha.102",
35
+ "@things-factory/shell": "^7.0.1-alpha.102",
36
+ "@things-factory/utils": "^7.0.1-alpha.71",
36
37
  "async-mqtt": "^2.5.0",
37
38
  "chance": "^1.1.11",
38
39
  "cross-fetch": "^3.0.4",
39
40
  "ieee754": "^1.2.1",
40
- "moment-timezone": "^0.5.40",
41
41
  "node-fetch": "^2.6.0",
42
42
  "promise-socket": "^7.0.0",
43
43
  "readline": "^1.3.0",
44
44
  "vm2": "^3.9.11"
45
45
  },
46
- "gitHead": "5adeb2a190f3c6eb5c5cbceac181a3d19fefda9b"
46
+ "gitHead": "2bce598261c2d7377ea008ee687358480a2869bc"
47
47
  }
@@ -43,7 +43,12 @@ export async function runScenario(instanceName: string, scenarioName: string, va
43
43
 
44
44
  if (!(await checkPermission(scenario.privilege, user, domain, unsafeIP, prohibitedPrivileges))) {
45
45
  const { category, privilege } = scenario.privilege || {}
46
- throw new Error(`Unauthorized! ${category && privilege ? category + ':' + privilege + ' privilege' : 'ownership granted'} required`)
46
+
47
+ console.error(`Unauthorized! ${category && privilege ? category + ':' + privilege + ' privilege' : 'ownership granted'} required`)
48
+
49
+ throw new Error(context.t('error.scenario run unauthorized', {
50
+ scenario: scenarioName
51
+ }))
47
52
  }
48
53
 
49
54
  /* 시나리오 인스턴스를 생성한다. */
@@ -56,7 +61,15 @@ export async function runScenario(instanceName: string, scenarioName: string, va
56
61
  client: GraphqlLocalClient.client
57
62
  })
58
63
 
59
- await instance.run()
64
+ try {
65
+ await instance.run()
66
+ } catch(err) {
67
+ console.error(err)
68
+
69
+ throw new Error(context.t('error.scenario run error', {
70
+ scenario: scenarioName
71
+ }))
72
+ }
60
73
 
61
74
  return instance
62
75
  }
@@ -37,7 +37,11 @@ DatabaseQuery.parameterSpec = [
37
37
  name: 'query',
38
38
  label: 'query',
39
39
  property: {
40
- language: 'sql'
40
+ language: 'sql',
41
+ showLineNumbers: true
42
+ },
43
+ styles: {
44
+ flex: '1'
41
45
  }
42
46
  }
43
47
  ]
@@ -51,7 +51,13 @@ GraphqlMutate.parameterSpec = [
51
51
  {
52
52
  type: 'graphql',
53
53
  name: 'mutation',
54
- label: 'mutation'
54
+ label: 'mutation',
55
+ property: {
56
+ showLineNumbers: true
57
+ },
58
+ styles: {
59
+ flex: 1
60
+ }
55
61
  },
56
62
  {
57
63
  type: 'key-values',
@@ -50,7 +50,13 @@ GraphqlQuery.parameterSpec = [
50
50
  {
51
51
  type: 'graphql',
52
52
  name: 'query',
53
- label: 'query'
53
+ label: 'query',
54
+ property: {
55
+ showLineNumbers: true
56
+ },
57
+ styles: {
58
+ flex: 1
59
+ }
54
60
  },
55
61
  {
56
62
  type: 'key-values',
@@ -30,7 +30,11 @@ JSonata.parameterSpec = [
30
30
  name: 'expression',
31
31
  label: 'jsonata-expression',
32
32
  property: {
33
- language: 'javascript'
33
+ language: 'javascript',
34
+ showLineNumbers: true
35
+ },
36
+ styles: {
37
+ flex: '1'
34
38
  }
35
39
  }
36
40
  ]
@@ -9,8 +9,6 @@ import { TaskRegistry } from '../task-registry'
9
9
  import { InputStep } from '../../service/step/step-type'
10
10
  import { Context } from '../types'
11
11
 
12
-
13
-
14
12
  async function LocalGraphqlMutate(step: InputStep, context: Context) {
15
13
  var { params, updaterId } = step
16
14
  var { mutation, variables: variablesAccessorMap, headers } = params || {}
@@ -70,7 +68,13 @@ LocalGraphqlMutate.parameterSpec = [
70
68
  {
71
69
  type: 'graphql',
72
70
  name: 'mutation',
73
- label: 'mutation'
71
+ label: 'mutation',
72
+ property: {
73
+ showLineNumbers: true
74
+ },
75
+ styles: {
76
+ flex: 1
77
+ }
74
78
  },
75
79
  {
76
80
  type: 'key-values',
@@ -68,7 +68,13 @@ LocalGraphqlQuery.parameterSpec = [
68
68
  {
69
69
  type: 'graphql',
70
70
  name: 'query',
71
- label: 'query'
71
+ label: 'query',
72
+ property: {
73
+ showLineNumbers: true
74
+ },
75
+ styles: {
76
+ flex: 1
77
+ }
72
78
  },
73
79
  {
74
80
  type: 'key-values',
@@ -38,7 +38,11 @@ Script.parameterSpec = [
38
38
  name: 'script',
39
39
  label: 'script',
40
40
  property: {
41
- language: 'javascript'
41
+ language: 'javascript',
42
+ showLineNumbers: true
43
+ },
44
+ styles: {
45
+ flex: '1'
42
46
  }
43
47
  }
44
48
  ]
@@ -1,5 +1,14 @@
1
1
  import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'
2
- import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ Entity,
6
+ Index,
7
+ ManyToOne,
8
+ PrimaryGeneratedColumn,
9
+ RelationId,
10
+ UpdateDateColumn
11
+ } from 'typeorm'
3
12
 
4
13
  import { User, Appliance } from '@things-factory/auth-base'
5
14
  import { logger } from '@things-factory/env'
@@ -33,7 +42,7 @@ export class Connection {
33
42
  * Many-to-One relationship with the Domain entity.
34
43
  */
35
44
  @ManyToOne(type => Domain)
36
- @Field({ nullable: true })
45
+ @Field(type => Domain, { nullable: true })
37
46
  domain: Domain
38
47
 
39
48
  /**
@@ -193,7 +202,7 @@ export interface InputConnection extends Connection {
193
202
 
194
203
  @ObjectType()
195
204
  export class ConnectionState {
196
- @Field({ nullable: true })
205
+ @Field(type => Domain)
197
206
  domain?: Domain
198
207
 
199
208
  @Field({ nullable: true })
@@ -32,7 +32,7 @@ export class PayloadLog {
32
32
  readonly id: string
33
33
 
34
34
  @ManyToOne(type => Domain)
35
- @Field({ nullable: true })
35
+ @Field(type => Domain)
36
36
  domain?: Domain
37
37
 
38
38
  @RelationId((payloadLog: PayloadLog) => payloadLog.domain)
@@ -47,8 +47,8 @@ export class PayloadLog {
47
47
  DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
48
48
  ? 'enum'
49
49
  : DATABASE_TYPE == 'oracle'
50
- ? 'varchar2'
51
- : 'smallint',
50
+ ? 'varchar2'
51
+ : 'smallint',
52
52
  enum: PayloadType,
53
53
  default: PayloadType.EGESTION,
54
54
  nullable: true
@@ -18,4 +18,7 @@ export class PropertySpec {
18
18
 
19
19
  @Field(type => ScalarObject, { nullable: true })
20
20
  property?: { [key: string]: any }
21
+
22
+ @Field(type => ScalarObject, { nullable: true })
23
+ styles?: { [key: string]: any }
21
24
  }
@@ -26,7 +26,7 @@ export class Scenario {
26
26
  id?: string
27
27
 
28
28
  @ManyToOne(type => Domain)
29
- @Field({ nullable: true })
29
+ @Field(type => Domain)
30
30
  domain?: Domain
31
31
 
32
32
  @RelationId((scenario: Scenario) => scenario.domain)
@@ -26,7 +26,7 @@ export class StateRegister {
26
26
  readonly id: string
27
27
 
28
28
  @ManyToOne(type => Domain)
29
- @Field({ nullable: true })
29
+ @Field(type => Domain)
30
30
  domain?: Domain
31
31
 
32
32
  @RelationId((stateRegister: StateRegister) => stateRegister.domain)
@@ -15,110 +15,112 @@ import { Domain } from '@things-factory/shell'
15
15
 
16
16
  import { Scenario } from '../scenario/scenario'
17
17
 
18
-
19
18
  @Entity()
20
19
  @Index('ix_step_0', (step: Step) => [step.scenario, step.sequence], { unique: true })
21
20
  @ObjectType()
22
21
  export class Step {
23
- /**
24
- * The unique identifier for each step.
25
- */
22
+ /**
23
+ * The unique identifier for each step.
24
+ */
26
25
  @PrimaryGeneratedColumn('uuid')
27
26
  @Field(type => ID)
28
27
  readonly id: string
29
28
 
30
- /**
31
- * The domain to which this step belongs.
32
- */
29
+ /**
30
+ * The domain to which this step belongs.
31
+ */
33
32
  @ManyToOne(type => Domain)
34
- @Field({ nullable: true })
33
+ @Field(type => Domain, { nullable: true })
35
34
  domain: Domain
36
35
 
37
- /**
38
- * The ID of the domain associated with this step.
39
- */
36
+ /**
37
+ * The ID of the domain associated with this step.
38
+ */
40
39
  @RelationId((step: Step) => step.domain)
41
40
  domainId: string
42
41
 
43
- /**
44
- * The name of the step.
45
- */
42
+ /**
43
+ * The name of the step.
44
+ */
46
45
  @Column({ nullable: true })
47
46
  @Field()
48
47
  name: string
49
48
 
50
- /**
51
- * A description of what the step involves.
52
- */
49
+ /**
50
+ * A description of what the step involves.
51
+ */
53
52
  @Column({ nullable: true })
54
53
  @Field({ nullable: true })
55
54
  description: string
56
55
 
57
- /**
58
- * The scenario that includes this step.
59
- */
56
+ /**
57
+ * The scenario that includes this step.
58
+ */
60
59
  @ManyToOne(type => Scenario, scenario => scenario.steps, { onDelete: 'CASCADE' })
61
60
  @Field(type => Scenario, { nullable: true })
62
61
  scenario: Scenario
63
62
 
64
- /**
65
- * The ID of the scenario associated with this step.
66
- */
63
+ /**
64
+ * The ID of the scenario associated with this step.
65
+ */
67
66
  @RelationId((step: Step) => step.scenario)
68
67
  scenarioId: string
69
68
 
70
- /**
71
- * The sequence number of the step within its scenario.
72
- */
69
+ /**
70
+ * The sequence number of the step within its scenario.
71
+ */
73
72
  @Column()
74
73
  @Field({ nullable: true })
75
74
  sequence: number
76
75
 
77
- /**
78
- * The specific task associated with this step.
79
- */
76
+ /**
77
+ * The specific task associated with this step.
78
+ */
80
79
  @Column()
81
80
  @Field({ nullable: true })
82
81
  task: string
83
82
 
84
- /**
85
- * Boolean value to indicate if the step should be skipped.
86
- */
83
+ /**
84
+ * Boolean value to indicate if the step should be skipped.
85
+ */
87
86
  @Column({ nullable: true })
88
87
  @Field({ nullable: true })
89
88
  skip: boolean
90
89
 
91
- /**
92
- * Boolean value to indicate if the step should be logged.
93
- */
90
+ /**
91
+ * Boolean value to indicate if the step should be logged.
92
+ */
94
93
  @Column({ nullable: true })
95
94
  @Field({ nullable: true })
96
95
  log: boolean
97
96
 
98
- /**
99
- * The connection details associated with this step.
100
- */
97
+ /**
98
+ * The connection details associated with this step.
99
+ */
101
100
  @Column({ nullable: true })
102
101
  @Field({ nullable: true })
103
102
  connection: string
104
103
 
105
- /**
106
- * The parameters for the step.
107
- */
104
+ /**
105
+ * The parameters for the step.
106
+ */
108
107
  @Column({ nullable: true })
109
108
  @Field({ nullable: true })
110
109
  params: string
111
110
 
112
- /**
113
- * A boolean attribute indicating the inclusion status of an element in the result.
114
- */
111
+ /**
112
+ * A boolean attribute indicating the inclusion status of an element in the result.
113
+ */
115
114
  @Column({ nullable: true, default: true })
116
- @Field({ nullable: true, description: 'A boolean attribute indicating the inclusion status of an element in the result' })
115
+ @Field({
116
+ nullable: true,
117
+ description: 'A boolean attribute indicating the inclusion status of an element in the result'
118
+ })
117
119
  result: boolean = true
118
120
 
119
- /**
120
- * The timestamp when the step was created.
121
- */
121
+ /**
122
+ * The timestamp when the step was created.
123
+ */
122
124
  @CreateDateColumn()
123
125
  @Field({ nullable: true })
124
126
  createdAt: Date
@@ -132,28 +134,28 @@ export class Step {
132
134
  updatedAt: Date
133
135
 
134
136
  /**
135
- * The user who created this step.
136
- */
137
+ * The user who created this step.
138
+ */
137
139
  @ManyToOne(type => User, { nullable: true })
138
140
  @Field({ nullable: true })
139
141
  creator: User
140
142
 
141
143
  /**
142
- * The ID of the user who created this step.
143
- */
144
+ * The ID of the user who created this step.
145
+ */
144
146
  @RelationId((step: Step) => step.creator)
145
147
  creatorId: string
146
148
 
147
149
  /**
148
- * The user who last updated this step.
149
- */
150
+ * The user who last updated this step.
151
+ */
150
152
  @ManyToOne(type => User, { nullable: true })
151
153
  @Field({ nullable: true })
152
154
  updater: User
153
155
 
154
156
  /**
155
- * The ID of the user who last updated this step.
156
- */
157
+ * The ID of the user who last updated this step.
158
+ */
157
159
  @RelationId((step: Step) => step.updater)
158
160
  updaterId: string
159
161
  }
@@ -197,7 +199,7 @@ export class StepPatch {
197
199
  /**
198
200
  * Step의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
199
201
  * 추후, 타입 일치를 통해서 제거할 예정임.
200
- *
202
+ *
201
203
  */
202
204
  export interface InputStep extends Step {
203
205
  params: any
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "error.scenario not found": "scenario '{scenario}' not found.",
3
+ "error.scenario run error": "an error occurred while processing the '{scenario}' request. please contact the administrator.",
4
+ "error.scenario run unauthorized": "you do not have permission to run the {scenario} scenario. please contact the administrator.",
3
5
  "error.schedule is not set": "schedule should be set for the scenario '{scenario}' in order to register as a schedule",
4
6
  "error.timezone is not set": "timezone should be set for the scenario '{scenario}' in order to register as a schedule",
5
7
  "error.scenario instance not found": "scenario instance '{instance}' not found.",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "error.scenario not found": "シナリオ'{scenario}'が見つかりません.",
3
+ "error.scenario run error": "シナリオ '{scenario}' のリクエストを処理中にエラーが発生しました。管理者に連絡してください。",
4
+ "error.scenario run unauthorized": "シナリオ {scenario} を実行する権限がありません。管理者に連絡してください。",
3
5
  "error.schedule is not set": "スケジュールとして登録するためにはシナリオ'{scenario}'にスケジュール情報が設定される必要があります.",
4
6
  "error.timezone is not set": "スケジュールとして登録するためにはシナリオ'{scenario}'にタイム ゾーン情報が設定される必要があります.",
5
7
  "error.scenario instance not found": "シナリオ インスタンス'{instance}'が見つかりません. 既に終了している可能性があります.",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "error.scenario not found": "시나리오 '{scenario}'를 찾을 수 없습니다.",
3
+ "error.scenario run error": "시나리오 '{scenario}' 요청을 처리하는 중 오류가 발생했습니다. 관리자에게 문의하십시오.",
4
+ "error.scenario run unauthorized": "시나리오 {scenario}를 실행할 권한이 없습니다. 관리자에게 문의하십히오.",
3
5
  "error.schedule is not set": "스케쥴로 등록하기 위해서는 시나리오 '{scenario}'에 스케쥴 정보가 설정되어야 합니다.",
4
6
  "error.timezone is not set": "스케쥴로 등록하기 위해서는 시나리오 '{scenario}'에 타임존 정보가 설정되어야 합니다.",
5
7
  "error.scenario instance not found": "시나리오 인스턴스 '{instance}'를 찾을 수 없습니다. 이미 종료되었을 수 있습니다.",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "error.scenario not found": "Tidak dapat mencari senario '{scenario}'.",
3
+ "error.scenario run error": "Ralat berlaku semasa memproses permintaan senario '{scenario}'. Sila hubungi pentadbir.",
4
+ "error.scenario run unauthorized": "Anda tidak mempunyai kebenaran untuk menjalankan senario {scenario}. Sila hubungi pentadbir.",
3
5
  "error.schedule is not set": "Untuk mendaftarkan sebagai jadual, maklumat jadual mesti diset dalam senario '{scenario}'.",
4
6
  "error.timezone is not set": "Untuk mendaftarkan sebagai jadual, maklumat zon masa mesti diset dalam senario '{scenario}'.",
5
7
  "error.scenario instance not found": "Tidak dapat mencari instans senario '{instance}'. Mungkin telah berakhir.",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "error.scenario not found": "无法找到场景 '{scenario}'。",
3
+ "error.scenario run error": "处理场景 '{scenario}' 请求时发生错误。请联系管理员。",
4
+ "error.scenario run unauthorized": "没有执行场景 {scenario} 的权限。请联系管理员。",
3
5
  "error.schedule is not set": "要注册为计划,场景 '{scenario}' 需要设置计划信息。",
4
6
  "error.timezone is not set": "要注册为计划,场景 '{scenario}' 需要设置时区信息。",
5
7
  "error.scenario instance not found": "无法找到场景实例 '{instance}'。它可能已经结束。",