@things-factory/dataset 7.0.0-alpha.6 → 7.0.0-alpha.7

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 (117) hide show
  1. package/client/activities/activity-data-collect-view.ts +7 -0
  2. package/client/activities/activity-data-review-edit.ts +66 -4
  3. package/client/activities/activity-data-review-view.ts +78 -4
  4. package/client/activities/activity-ooc-resolve-view.ts +12 -0
  5. package/client/activities/activity-ooc-review-view.ts +12 -0
  6. package/client/pages/data-ooc/data-ooc-list-page.ts +38 -9
  7. package/client/pages/data-ooc/data-ooc-page.ts +42 -0
  8. package/client/pages/data-ooc/data-ooc-view.ts +158 -19
  9. package/client/pages/data-ooc/data-oocs-page.ts +69 -3
  10. package/client/pages/data-sample/data-sample-list-page.ts +23 -6
  11. package/client/pages/data-sample/data-sample-page.ts +7 -0
  12. package/client/pages/data-sample/data-sample-search-page.ts +2 -2
  13. package/client/pages/data-sample/data-sample-view.ts +144 -22
  14. package/client/pages/data-sample/data-samples-page.ts +131 -5
  15. package/client/pages/data-sensor/data-sensor-list-page.ts +28 -6
  16. package/client/pages/data-set/data-item-list.ts +2 -2
  17. package/dist-client/activities/activity-data-collect-view.js +7 -0
  18. package/dist-client/activities/activity-data-collect-view.js.map +1 -1
  19. package/dist-client/activities/activity-data-review-edit.d.ts +1 -1
  20. package/dist-client/activities/activity-data-review-edit.js +63 -5
  21. package/dist-client/activities/activity-data-review-edit.js.map +1 -1
  22. package/dist-client/activities/activity-data-review-view.d.ts +1 -1
  23. package/dist-client/activities/activity-data-review-view.js +75 -5
  24. package/dist-client/activities/activity-data-review-view.js.map +1 -1
  25. package/dist-client/activities/activity-ooc-resolve-view.js +12 -0
  26. package/dist-client/activities/activity-ooc-resolve-view.js.map +1 -1
  27. package/dist-client/activities/activity-ooc-review-view.js +12 -0
  28. package/dist-client/activities/activity-ooc-review-view.js.map +1 -1
  29. package/dist-client/pages/data-ooc/data-ooc-list-page.js +38 -9
  30. package/dist-client/pages/data-ooc/data-ooc-list-page.js.map +1 -1
  31. package/dist-client/pages/data-ooc/data-ooc-page.js +42 -0
  32. package/dist-client/pages/data-ooc/data-ooc-page.js.map +1 -1
  33. package/dist-client/pages/data-ooc/data-ooc-view.d.ts +6 -3
  34. package/dist-client/pages/data-ooc/data-ooc-view.js +155 -22
  35. package/dist-client/pages/data-ooc/data-ooc-view.js.map +1 -1
  36. package/dist-client/pages/data-ooc/data-oocs-page.d.ts +1 -0
  37. package/dist-client/pages/data-ooc/data-oocs-page.js +69 -3
  38. package/dist-client/pages/data-ooc/data-oocs-page.js.map +1 -1
  39. package/dist-client/pages/data-sample/data-sample-list-page.js +23 -6
  40. package/dist-client/pages/data-sample/data-sample-list-page.js.map +1 -1
  41. package/dist-client/pages/data-sample/data-sample-page.js +7 -0
  42. package/dist-client/pages/data-sample/data-sample-page.js.map +1 -1
  43. package/dist-client/pages/data-sample/data-sample-search-page.js +2 -2
  44. package/dist-client/pages/data-sample/data-sample-search-page.js.map +1 -1
  45. package/dist-client/pages/data-sample/data-sample-view.d.ts +18 -0
  46. package/dist-client/pages/data-sample/data-sample-view.js +143 -21
  47. package/dist-client/pages/data-sample/data-sample-view.js.map +1 -1
  48. package/dist-client/pages/data-sample/data-samples-page.d.ts +2 -0
  49. package/dist-client/pages/data-sample/data-samples-page.js +132 -5
  50. package/dist-client/pages/data-sample/data-samples-page.js.map +1 -1
  51. package/dist-client/pages/data-sensor/data-sensor-list-page.js +28 -6
  52. package/dist-client/pages/data-sensor/data-sensor-list-page.js.map +1 -1
  53. package/dist-client/pages/data-set/data-item-list.js +2 -2
  54. package/dist-client/pages/data-set/data-item-list.js.map +1 -1
  55. package/dist-client/tsconfig.tsbuildinfo +1 -1
  56. package/dist-server/activities/activity-data-review.js.map +1 -1
  57. package/dist-server/activities/activity-ooc-review.js +2 -1
  58. package/dist-server/activities/activity-ooc-review.js.map +1 -1
  59. package/dist-server/controllers/create-data-sample.js +27 -29
  60. package/dist-server/controllers/create-data-sample.js.map +1 -1
  61. package/dist-server/engine/index.js +4 -0
  62. package/dist-server/engine/index.js.map +1 -0
  63. package/dist-server/engine/task/create-data-sample.js +80 -0
  64. package/dist-server/engine/task/create-data-sample.js.map +1 -0
  65. package/dist-server/engine/task/index.js +4 -0
  66. package/dist-server/engine/task/index.js.map +1 -0
  67. package/dist-server/index.js +1 -0
  68. package/dist-server/index.js.map +1 -1
  69. package/dist-server/routes.js +35 -27
  70. package/dist-server/routes.js.map +1 -1
  71. package/dist-server/service/data-ooc/data-ooc-query.js +32 -0
  72. package/dist-server/service/data-ooc/data-ooc-query.js.map +1 -1
  73. package/dist-server/service/data-ooc/data-ooc.js +15 -26
  74. package/dist-server/service/data-ooc/data-ooc.js.map +1 -1
  75. package/dist-server/service/data-sample/data-sample-query.js +24 -0
  76. package/dist-server/service/data-sample/data-sample-query.js.map +1 -1
  77. package/dist-server/service/data-sample/data-sample.js +17 -21
  78. package/dist-server/service/data-sample/data-sample.js.map +1 -1
  79. package/dist-server/service/data-sensor/data-sensor-query.js +16 -1
  80. package/dist-server/service/data-sensor/data-sensor-query.js.map +1 -1
  81. package/dist-server/service/data-sensor/data-sensor-type.js +8 -0
  82. package/dist-server/service/data-sensor/data-sensor-type.js.map +1 -1
  83. package/dist-server/service/data-sensor/data-sensor.js +15 -1
  84. package/dist-server/service/data-sensor/data-sensor.js.map +1 -1
  85. package/dist-server/service/data-set/data-item-type.js +1 -0
  86. package/dist-server/service/data-set/data-item-type.js.map +1 -1
  87. package/dist-server/service/data-set/data-set-query.js +2 -2
  88. package/dist-server/service/data-set/data-set-query.js.map +1 -1
  89. package/dist-server/tsconfig.tsbuildinfo +1 -1
  90. package/helps/dataset/task/create-data-sample.ja.md +28 -0
  91. package/helps/dataset/task/create-data-sample.ko.md +28 -0
  92. package/helps/dataset/task/create-data-sample.md +28 -0
  93. package/helps/dataset/task/create-data-sample.ms.md +30 -0
  94. package/helps/dataset/task/create-data-sample.zh.md +28 -0
  95. package/package.json +11 -11
  96. package/server/activities/activity-data-review.ts +1 -5
  97. package/server/activities/activity-ooc-review.ts +5 -15
  98. package/server/controllers/create-data-sample.ts +31 -38
  99. package/server/engine/index.ts +1 -0
  100. package/server/engine/task/create-data-sample.ts +92 -0
  101. package/server/engine/task/index.ts +1 -0
  102. package/server/index.ts +1 -0
  103. package/server/routes.ts +47 -31
  104. package/server/service/data-ooc/data-ooc-query.ts +17 -0
  105. package/server/service/data-ooc/data-ooc.ts +17 -28
  106. package/server/service/data-sample/data-sample-query.ts +17 -17
  107. package/server/service/data-sample/data-sample.ts +18 -23
  108. package/server/service/data-sensor/data-sensor-query.ts +13 -1
  109. package/server/service/data-sensor/data-sensor-type.ts +6 -0
  110. package/server/service/data-sensor/data-sensor.ts +13 -11
  111. package/server/service/data-set/data-item-type.ts +1 -0
  112. package/server/service/data-set/data-set-query.ts +7 -7
  113. package/translations/en.json +14 -2
  114. package/translations/ja.json +11 -1
  115. package/translations/ko.json +13 -1
  116. package/translations/ms.json +10 -0
  117. package/translations/zh.json +11 -1
package/server/routes.ts CHANGED
@@ -4,6 +4,7 @@ import { Domain, getDataSource } from '@things-factory/shell'
4
4
  import { User } from '@things-factory/auth-base'
5
5
  import { Activity } from '@things-factory/worklist'
6
6
  import { issue } from '@things-factory/worklist/dist-server/controllers/activity-instance/issue'
7
+ import { runScenario } from '@things-factory/integration-base'
7
8
  import { ScheduleRegisterRequest } from '@things-factory/scheduler-client'
8
9
 
9
10
  import { createDataSample } from './controllers/create-data-sample'
@@ -23,8 +24,8 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
23
24
  globalPublicRouter.post('/sensor-data', async (context, next) => {
24
25
  // 데이타 검증
25
26
  const { deviceId, data, rawData, timestamp = Date.now() } = context.request.body
26
- if (!deviceId || !data) {
27
- throw new Error(`deviceId(${deviceId}) and data(${JSON.stringify(data)}) properties are mandatory`)
27
+ if (!deviceId) {
28
+ throw new Error(`The deviceId(${deviceId}) property are mandatory`)
28
29
  }
29
30
 
30
31
  // make new data-sample
@@ -32,7 +33,7 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
32
33
  // find sensor through deviceId
33
34
  const sensor = await tx.getRepository(DataSensor).findOne({
34
35
  where: { deviceId },
35
- relations: ['domain', 'appliance', 'dataSet']
36
+ relations: ['domain', 'appliance', 'dataSet', 'decoder']
36
37
  })
37
38
 
38
39
  if (!sensor) {
@@ -47,18 +48,18 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
47
48
  throw new Error(`Appliance of the sensor given deviceId(${deviceId}) is not set up`)
48
49
  }
49
50
 
50
- if (!sensor.dataSet) {
51
- throw new Error(`DataSet of the sensor given deviceId(${deviceId}) is not set up`)
52
- }
51
+ // if (!sensor.dataSet) {
52
+ // throw new Error(`DataSet of the sensor given deviceId(${deviceId}) is not set up`)
53
+ // }
53
54
 
54
55
  const domain = sensor.domain
55
56
  const dataSet = sensor.dataSet
56
- const user: User = await tx.getRepository(User).findOne({
57
- where: {
58
- reference: sensor.appliance.id,
59
- userType: 'appliance'
60
- }
61
- })
57
+ // const user: User = await tx.getRepository(User).findOne({
58
+ // where: {
59
+ // reference: sensor.appliance.id,
60
+ // userType: 'appliance'
61
+ // }
62
+ // })
62
63
 
63
64
  context.state = {
64
65
  ...context.state,
@@ -66,19 +67,40 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
66
67
  tx
67
68
  }
68
69
 
69
- return await createDataSample(
70
- {
71
- dataSet,
70
+ var decoded
71
+ if (sensor.decoder) {
72
+ const { name: scenarioName } = sensor.decoder
73
+ const variables = {
74
+ dataSensor: sensor,
75
+ source: deviceId,
72
76
  data,
73
77
  rawData,
74
- source: deviceId,
75
- collectedAt: new Date(timestamp)
76
- },
77
- context
78
- )
79
- })
78
+ timestamp
79
+ }
80
80
 
81
- context.status = 200
81
+ decoded = (await runScenario(null, scenarioName, variables, context))?.result
82
+ }
83
+
84
+ if (dataSet) {
85
+ await createDataSample(
86
+ {
87
+ dataSet,
88
+ data,
89
+ rawData,
90
+ source: deviceId,
91
+ collectedAt: new Date(timestamp),
92
+ ...decoded
93
+ },
94
+ context
95
+ )
96
+ }
97
+
98
+ context.status = 200
99
+ context.body = {
100
+ data,
101
+ ...decoded
102
+ }
103
+ })
82
104
  })
83
105
 
84
106
  /* When a callback occurs from the scheduler when a scheduled dataset is on schedule, data collection task for the dataset should be issued. */
@@ -102,9 +124,7 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
102
124
  throw new Error(`domain(${domainId}) not found`)
103
125
  }
104
126
 
105
- const dataSet = await tx
106
- .getRepository(DataSet)
107
- .findOne({ where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSetId } })
127
+ const dataSet = await tx.getRepository(DataSet).findOne({ where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSetId } })
108
128
 
109
129
  const activity = (await tx.getRepository(Activity).findOneBy({
110
130
  domain: { id: domainId },
@@ -136,9 +156,7 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
136
156
 
137
157
  await issue(activityInstance, context)
138
158
  } else {
139
- throw new Error(
140
- `Assignees not set. So Data Collect Activity for ${dataSet.name}($dataSet.id) could not be issued.`
141
- )
159
+ throw new Error(`Assignees not set. So Data Collect Activity for ${dataSet.name}($dataSet.id) could not be issued.`)
142
160
  }
143
161
  } else {
144
162
  throw new Error(`Data Collect Activity is not installed.`)
@@ -169,9 +187,7 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
169
187
  throw new Error(`domain(${domainId}) not found`)
170
188
  }
171
189
 
172
- const dataSet = await tx
173
- .getRepository(DataSet)
174
- .findOne({ where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSetId } })
190
+ const dataSet = await tx.getRepository(DataSet).findOne({ where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: dataSetId } })
175
191
 
176
192
  // do what you gotta do
177
193
  })
@@ -2,10 +2,12 @@ import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
+ import { ActivityInstance } from '@things-factory/worklist'
5
6
 
6
7
  import { DataSetHistory } from '../data-set-history/data-set-history'
7
8
  import { DataItem } from '../data-set/data-item-type'
8
9
  import { DataSet } from '../data-set/data-set'
10
+ import { DataSample } from '../data-sample/data-sample'
9
11
  import { DataOoc } from './data-ooc'
10
12
  import { DataOocList } from './data-ooc-type'
11
13
 
@@ -51,11 +53,26 @@ export class DataOocQuery {
51
53
  return dataSetHistory?.dataItems || []
52
54
  }
53
55
 
56
+ @FieldResolver(type => DataSample)
57
+ async dataSample(@Root() dataOoc: DataOoc): Promise<DataSample> {
58
+ return dataOoc.dataSampleId && (await getRepository(DataSample).findOneBy({ id: dataOoc.dataSampleId }))
59
+ }
60
+
54
61
  @FieldResolver(type => DataSet)
55
62
  async dataSet(@Root() dataOoc: DataOoc): Promise<DataSet> {
56
63
  return dataOoc.dataSetId && (await getRepository(DataSet).findOneBy({ id: dataOoc.dataSetId }))
57
64
  }
58
65
 
66
+ @FieldResolver(type => ActivityInstance)
67
+ async reviewActivityInstance(@Root() dataOoc: DataOoc): Promise<ActivityInstance> {
68
+ return dataOoc.reviewActivityInstanceId && (await getRepository(ActivityInstance).findOneBy({ id: dataOoc.reviewActivityInstanceId }))
69
+ }
70
+
71
+ @FieldResolver(type => ActivityInstance)
72
+ async resolveActivityInstance(@Root() dataOoc: DataOoc): Promise<ActivityInstance> {
73
+ return dataOoc.resolveActivityInstanceId && (await getRepository(ActivityInstance).findOneBy({ id: dataOoc.resolveActivityInstanceId }))
74
+ }
75
+
59
76
  @FieldResolver(type => User)
60
77
  async corrector(@Root() dataOoc: DataOoc): Promise<User> {
61
78
  return dataOoc.correctorId && (await getRepository(User).findOneBy({ id: dataOoc.correctorId }))
@@ -1,5 +1,5 @@
1
1
  import { Field, ID, ObjectType, registerEnumType } from 'type-graphql'
2
- import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
2
+ import { Column, CreateDateColumn, Entity, Index, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
3
3
 
4
4
  import { User } from '@things-factory/auth-base'
5
5
  import { config } from '@things-factory/env'
@@ -40,12 +40,10 @@ export class DataOoc {
40
40
  domainId?: string
41
41
 
42
42
  @Column()
43
- @Field()
44
- name: string
43
+ @Field({ nullable: true })
44
+ name?: string
45
45
 
46
- @Column({
47
- nullable: true
48
- })
46
+ @Column({ nullable: true })
49
47
  @Field({ nullable: true })
50
48
  description?: string
51
49
 
@@ -60,21 +58,15 @@ export class DataOoc {
60
58
  @Field({ nullable: true })
61
59
  dataSetVersion?: number
62
60
 
63
- @Column({
64
- nullable: true
65
- })
61
+ @Column({ nullable: true })
66
62
  @Field({ nullable: true })
67
63
  ooc?: boolean
68
64
 
69
- @Column({
70
- nullable: true
71
- })
65
+ @Column({ nullable: true })
72
66
  @Field({ nullable: true })
73
67
  oos?: boolean
74
68
 
75
- @Column({
76
- nullable: true
77
- })
69
+ @Column({ nullable: true })
78
70
  @Field({ nullable: true })
79
71
  state?: DataOocStatus
80
72
 
@@ -92,15 +84,11 @@ export class DataOoc {
92
84
  @Field({ nullable: true })
93
85
  correctiveAction?: string
94
86
 
95
- @Column({
96
- nullable: true
97
- })
87
+ @Column({ nullable: true })
98
88
  @Field({ nullable: true })
99
89
  type?: string
100
90
 
101
- @Column({
102
- nullable: true
103
- })
91
+ @Column({ nullable: true })
104
92
  @Field({ nullable: true })
105
93
  useCase?: string
106
94
 
@@ -150,27 +138,28 @@ export class DataOoc {
150
138
  @Field({ nullable: true })
151
139
  rawData?: string
152
140
 
153
- @Column({
154
- nullable: true
155
- })
141
+ @Column({ nullable: true })
156
142
  @Field({ nullable: true })
157
143
  source?: string
158
144
 
159
- @ManyToOne(type => DataSample, { nullable: true })
160
- @Field({ nullable: true })
145
+ @OneToOne(type => DataSample, { nullable: true })
146
+ @JoinColumn()
147
+ @Field(type => DataSample, { nullable: true })
161
148
  dataSample?: DataSample
162
149
 
163
150
  @RelationId((dataOoc: DataOoc) => dataOoc.dataSample)
164
151
  dataSampleId?: string
165
152
 
166
- @ManyToOne(type => ActivityInstance, { nullable: true })
153
+ @OneToOne(type => ActivityInstance, { nullable: true })
154
+ @JoinColumn()
167
155
  @Field({ nullable: true })
168
156
  reviewActivityInstance?: ActivityInstance
169
157
 
170
158
  @RelationId((dataOoc: DataOoc) => dataOoc.reviewActivityInstance)
171
159
  reviewActivityInstanceId?: string
172
160
 
173
- @ManyToOne(type => ActivityInstance, { nullable: true })
161
+ @OneToOne(type => ActivityInstance, { nullable: true })
162
+ @JoinColumn()
174
163
  @Field({ nullable: true })
175
164
  resolveActivityInstance?: ActivityInstance
176
165
 
@@ -2,18 +2,14 @@ import { In } from 'typeorm'
2
2
  import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
3
3
 
4
4
  import { User } from '@things-factory/auth-base'
5
- import {
6
- Domain,
7
- getQueryBuilderFromListParams,
8
- getRepository,
9
- getISOStringsForPeriod,
10
- ListParam
11
- } from '@things-factory/shell'
5
+ import { Domain, getQueryBuilderFromListParams, getRepository, getISOStringsForPeriod, ListParam } from '@things-factory/shell'
6
+ import { ActivityInstance } from '@things-factory/worklist'
12
7
 
13
8
  import { DataKeySet } from '../data-key-set/data-key-set'
14
9
  import { DataSetHistory } from '../data-set-history/data-set-history'
15
10
  import { DataItem } from '../data-set/data-item-type'
16
11
  import { DataSet } from '../data-set/data-set'
12
+ import { DataOoc } from '../data-ooc/data-ooc'
17
13
  import { DataSample } from './data-sample'
18
14
  import { DataSampleList } from './data-sample-type'
19
15
 
@@ -48,11 +44,7 @@ export class DataSampleQuery {
48
44
 
49
45
  @Directive('@privilege(category: "data-sample", privilege: "query", domainOwnerGranted: true)')
50
46
  @Query(returns => DataSampleList, { description: 'To fetch multiple data samples by data set' })
51
- async dataSamplesByDataSet(
52
- @Arg('dataSetId') dataSetId: string,
53
- @Args() params: ListParam,
54
- @Ctx() context: ResolverContext
55
- ): Promise<DataSampleList> {
47
+ async dataSamplesByDataSet(@Arg('dataSetId') dataSetId: string, @Args() params: ListParam, @Ctx() context: ResolverContext): Promise<DataSampleList> {
56
48
  const { domain } = context.state
57
49
 
58
50
  const dataSet = await getRepository(DataSet).findOne({
@@ -84,11 +76,7 @@ export class DataSampleQuery {
84
76
 
85
77
  @Directive('@privilege(category: "data-sample", privilege: "query", domainOwnerGranted: true)')
86
78
  @Query(returns => DataSampleList, { description: 'To fetch multiple data samples by data key set' })
87
- async dataSamplesByDataKeySet(
88
- @Arg('dataKeySetId') dataKeySetId: string,
89
- @Args() params: ListParam,
90
- @Ctx() context: ResolverContext
91
- ): Promise<DataSampleList> {
79
+ async dataSamplesByDataKeySet(@Arg('dataKeySetId') dataKeySetId: string, @Args() params: ListParam, @Ctx() context: ResolverContext): Promise<DataSampleList> {
92
80
  const { domain } = context.state
93
81
 
94
82
  const dataKeySet = await getRepository(DataKeySet).findOneBy({ id: dataKeySetId })
@@ -178,6 +166,18 @@ export class DataSampleQuery {
178
166
  return dataSample.dataSetId && (await getRepository(DataSet).findOneBy({ id: dataSample.dataSetId }))
179
167
  }
180
168
 
169
+ @FieldResolver(type => DataOoc)
170
+ async dataOoc(@Root() dataSample: DataSample): Promise<DataOoc> {
171
+ if (dataSample.ooc || dataSample.oos) {
172
+ return await getRepository(DataOoc).findOneBy({ dataSample: { id: dataSample.id } })
173
+ }
174
+ }
175
+
176
+ @FieldResolver(type => ActivityInstance)
177
+ async reviewActivityInstance(@Root() dataSample: DataSample): Promise<ActivityInstance> {
178
+ return dataSample.reviewActivityInstanceId && (await getRepository(ActivityInstance).findOneBy({ id: dataSample.reviewActivityInstanceId }))
179
+ }
180
+
181
181
  @FieldResolver(type => Domain)
182
182
  async domain(@Root() dataSample: DataSample): Promise<Domain> {
183
183
  return dataSample.domainId && (await getRepository(Domain).findOneBy({ id: dataSample.domainId }))
@@ -1,13 +1,14 @@
1
1
  import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
2
+ import { Column, CreateDateColumn, Entity, Index, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
3
3
 
4
4
  import { User } from '@things-factory/auth-base'
5
5
  import { config } from '@things-factory/env'
6
- import { Domain, ScalarObject } from '@things-factory/shell'
6
+ import { Domain, ScalarObject, json5Transformer } from '@things-factory/shell'
7
7
  import { ActivityInstance } from '@things-factory/worklist'
8
8
 
9
9
  import { DataItem } from '../data-set/data-item-type'
10
10
  import { DataSet } from '../data-set/data-set'
11
+ import { DataOoc } from '../data-ooc/data-ooc'
11
12
 
12
13
  const ORMCONFIG = config.get('ormconfig', {})
13
14
  const DATABASE_TYPE = ORMCONFIG.type
@@ -30,24 +31,18 @@ export class DataSample {
30
31
  domainId?: string
31
32
 
32
33
  @Column()
33
- @Field()
34
+ @Field({ nullable: true })
34
35
  name: string
35
36
 
36
- @Column({
37
- nullable: true
38
- })
37
+ @Column({ nullable: true })
39
38
  @Field({ nullable: true })
40
39
  description?: string
41
40
 
42
- @Column({
43
- nullable: true
44
- })
41
+ @Column({ nullable: true })
45
42
  @Field({ nullable: true })
46
43
  type?: string
47
44
 
48
- @Column({
49
- nullable: true
50
- })
45
+ @Column({ nullable: true })
51
46
  @Field({ nullable: true })
52
47
  useCase?: string
53
48
 
@@ -79,26 +74,21 @@ export class DataSample {
79
74
 
80
75
  @Column({
81
76
  nullable: true,
82
- type: DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? 'longtext' : DATABASE_TYPE == 'oracle' ? 'clob' : 'varchar'
77
+ type: DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? 'longtext' : DATABASE_TYPE == 'oracle' ? 'clob' : 'varchar',
78
+ transformer: json5Transformer
83
79
  })
84
80
  @Field({ nullable: true })
85
81
  rawData?: string
86
82
 
87
- @Column({
88
- nullable: true
89
- })
83
+ @Column({ nullable: true })
90
84
  @Field({ nullable: true })
91
85
  source?: string
92
86
 
93
- @Column({
94
- nullable: true
95
- })
87
+ @Column({ nullable: true })
96
88
  @Field({ nullable: true })
97
89
  ooc?: boolean
98
90
 
99
- @Column({
100
- nullable: true
101
- })
91
+ @Column({ nullable: true })
102
92
  @Field({ nullable: true })
103
93
  oos?: boolean
104
94
 
@@ -130,13 +120,18 @@ export class DataSample {
130
120
  @Field({ nullable: true })
131
121
  workShift?: string
132
122
 
133
- @ManyToOne(type => ActivityInstance, { nullable: true })
123
+ @OneToOne(type => ActivityInstance, { nullable: true })
124
+ @JoinColumn()
134
125
  @Field({ nullable: true })
135
126
  reviewActivityInstance?: ActivityInstance
136
127
 
137
128
  @RelationId((dataSample: DataSample) => dataSample.reviewActivityInstance)
138
129
  reviewActivityInstanceId?: string
139
130
 
131
+ @OneToOne(type => DataOoc, dataOoc => dataOoc.dataSample, { nullable: true })
132
+ @Field(type => DataOoc, { nullable: true })
133
+ dataOoc?: DataOoc
134
+
140
135
  @Column({ nullable: true })
141
136
  @Field({ nullable: true })
142
137
  collectedAt?: Date
@@ -2,6 +2,7 @@ import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graph
2
2
 
3
3
  import { Appliance, User } from '@things-factory/auth-base'
4
4
  import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
+ import { Scenario } from '@things-factory/integration-base'
5
6
 
6
7
  import { DataSet } from '../data-set/data-set'
7
8
  import { DataSensor } from './data-sensor'
@@ -39,11 +40,22 @@ export class DataSensorQuery {
39
40
  return dataSensor.applianceId && (await getRepository(Appliance).findOneBy({ id: dataSensor.applianceId }))
40
41
  }
41
42
 
42
- @FieldResolver(type => Appliance)
43
+ @FieldResolver(type => DataSet)
43
44
  async dataSet(@Root() dataSensor: DataSensor): Promise<DataSet> {
44
45
  return dataSensor.dataSetId && (await getRepository(DataSet).findOneBy({ id: dataSensor.dataSetId }))
45
46
  }
46
47
 
48
+ @FieldResolver(type => Scenario)
49
+ async decoder(@Root() dataSensor: DataSensor): Promise<Scenario> {
50
+ return (
51
+ dataSensor.decoder ||
52
+ (dataSensor.decoderId &&
53
+ (await getRepository(Scenario).findOneBy({
54
+ id: dataSensor.decoderId
55
+ })))
56
+ )
57
+ }
58
+
47
59
  @FieldResolver(type => Domain)
48
60
  async domain(@Root() dataSensor: DataSensor): Promise<Domain> {
49
61
  return dataSensor.domainId && (await getRepository(Domain).findOneBy({ id: dataSensor.domainId }))
@@ -41,6 +41,9 @@ export class NewDataSensor {
41
41
 
42
42
  @Field(type => ObjectRef, { nullable: true })
43
43
  dataSet?: ObjectRef
44
+
45
+ @Field(type => ObjectRef, { nullable: true })
46
+ decoder?: ObjectRef
44
47
  }
45
48
 
46
49
  @InputType()
@@ -84,6 +87,9 @@ export class DataSensorPatch {
84
87
  @Field(type => ObjectRef, { nullable: true })
85
88
  dataSet?: ObjectRef
86
89
 
90
+ @Field(type => ObjectRef, { nullable: true })
91
+ decoder?: ObjectRef
92
+
87
93
  @Field()
88
94
  cuFlag: string
89
95
  }
@@ -1,17 +1,9 @@
1
1
  import { Field, ID, ObjectType } from 'type-graphql'
2
- import {
3
- Column,
4
- CreateDateColumn,
5
- Entity,
6
- Index,
7
- ManyToOne,
8
- PrimaryGeneratedColumn,
9
- RelationId,
10
- UpdateDateColumn
11
- } from 'typeorm'
2
+ import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'
12
3
 
13
- import { Appliance, User } from '@things-factory/auth-base'
14
4
  import { Domain } from '@things-factory/shell'
5
+ import { Appliance, User } from '@things-factory/auth-base'
6
+ import { Scenario } from '@things-factory/integration-base'
15
7
 
16
8
  import { DataSet } from '../data-set/data-set'
17
9
 
@@ -91,6 +83,16 @@ export class DataSensor {
91
83
  @RelationId((dataSensor: DataSensor) => dataSensor.dataSet)
92
84
  dataSetId?: string
93
85
 
86
+ @ManyToOne(type => Scenario, { nullable: true })
87
+ @Field(type => Scenario, {
88
+ nullable: true,
89
+ description: 'The decoder scenario that automatically executes based on the trigger of raw data collection'
90
+ })
91
+ decoder?: Scenario
92
+
93
+ @RelationId((dataSensor: DataSensor) => dataSensor.decoder)
94
+ decoderId?: string
95
+
94
96
  @CreateDateColumn()
95
97
  @Field({ nullable: true })
96
98
  createdAt?: Date
@@ -7,6 +7,7 @@ export enum DataItemType {
7
7
  text = 'text',
8
8
  boolean = 'boolean',
9
9
  select = 'select',
10
+ radio = 'radio',
10
11
  date = 'date',
11
12
  datetime = 'datetime',
12
13
  file = 'file'
@@ -243,21 +243,21 @@ export class DataSetQuery {
243
243
  }
244
244
 
245
245
  @FieldResolver(type => Board, { nullable: true })
246
- async entryBoard(@Root() dataSet: DataSet) {
246
+ async entryBoard(@Root() dataSet: DataSet): Promise<Board> {
247
247
  if (dataSet.entryType == 'board' && dataSet.entryView) {
248
248
  return await getRepository(Board).findOneBy({ id: dataSet.entryView })
249
249
  }
250
250
  }
251
251
 
252
252
  @FieldResolver(type => Board, { nullable: true })
253
- async monitorBoard(@Root() dataSet: DataSet) {
253
+ async monitorBoard(@Root() dataSet: DataSet): Promise<Board> {
254
254
  if (dataSet.monitorType == 'board' && dataSet.monitorView) {
255
255
  return await getRepository(Board).findOneBy({ id: dataSet.monitorView })
256
256
  }
257
257
  }
258
258
 
259
259
  @FieldResolver(type => DataKeySet, { nullable: true })
260
- async dataKeySet(@Root() dataSet: DataSet) {
260
+ async dataKeySet(@Root() dataSet: DataSet): Promise<DataKeySet> {
261
261
  return (
262
262
  dataSet.dataKeySet ||
263
263
  (dataSet.dataKeySetId &&
@@ -267,8 +267,8 @@ export class DataSetQuery {
267
267
  )
268
268
  }
269
269
 
270
- @FieldResolver(type => Role)
271
- async normalScenario(@Root() dataSet: DataSet): Promise<Role> {
270
+ @FieldResolver(type => Scenario)
271
+ async normalScenario(@Root() dataSet: DataSet): Promise<Scenario> {
272
272
  return (
273
273
  dataSet.normalScenario ||
274
274
  (dataSet.normalScenarioId &&
@@ -278,8 +278,8 @@ export class DataSetQuery {
278
278
  )
279
279
  }
280
280
 
281
- @FieldResolver(type => Role)
282
- async outlierScenario(@Root() dataSet: DataSet): Promise<Role> {
281
+ @FieldResolver(type => Scenario)
282
+ async outlierScenario(@Root() dataSet: DataSet): Promise<Scenario> {
283
283
  return (
284
284
  dataSet.outlierScenario ||
285
285
  (dataSet.outlierScenarioId &&
@@ -10,7 +10,8 @@
10
10
  "field.assignees": "assignees",
11
11
  "field.collected-at": "collected at",
12
12
  "field.corrected-at": "corrected at",
13
- "field.corrective-action": "corrective action",
13
+ "field.corrective-action": "action",
14
+ "field.corrective-instruction": "instruction",
14
15
  "field.corrector": "corrector",
15
16
  "field.count": "count",
16
17
  "field.count-ooc": "oos count",
@@ -26,6 +27,8 @@
26
27
  "field.data-sample": "data sample",
27
28
  "field.data-set": "data set",
28
29
  "field.date": "date",
30
+ "field.decoder": "decoder",
31
+ "field.decoder-scenario": "decoder scenario",
29
32
  "field.device-id": "device id",
30
33
  "field.download-url": "download url",
31
34
  "field.entry-role": "entry role",
@@ -84,22 +87,28 @@
84
87
  "label.corrective action": "corrective action",
85
88
  "label.corrective instruction": "corrective instruction",
86
89
  "label.critical-limits": "critical limits",
90
+ "label.data-set": "data set",
87
91
  "label.data-set-type": "type",
92
+ "label.datasample review timeline": "data sample review timeline",
88
93
  "label.end-date": "end date",
89
94
  "label.group-by data-keys": "group by each data-keys",
90
95
  "label.maximum value": "maximum value",
91
96
  "label.minimum value": "minimum value",
97
+ "label.ooc resolve timeline": "OOC resolve timeline",
98
+ "label.ooc review timeline": "OOC review timeline",
92
99
  "label.pass-limits": "pass limits",
93
100
  "label.period-12-months": "12 months",
94
101
  "label.period-30-days": "30 days",
95
102
  "label.period-this-month": "this month",
96
103
  "label.period-this-year": "this year",
97
104
  "label.period-today": "today",
105
+ "label.raw-data": "raw data",
98
106
  "label.start-date": "start date",
99
107
  "label.state-corrected": "corrected",
100
108
  "label.state-issued": "issued",
101
109
  "label.state-reviewed": "reviewed",
102
110
  "label.target-limits": "target limits",
111
+ "label.timestamp": "timestamp",
103
112
  "text.automatically collected": "automatically collected",
104
113
  "text.corrective action placeholder": "Please enter details for implementing corrective and preventive actions",
105
114
  "text.corrective instruction placeholder": "Please enter instructions for corrective and preventive actions",
@@ -141,10 +150,13 @@
141
150
  "title.edit duration": "edit duration",
142
151
  "title.edit hashtag": "edit hashtag",
143
152
  "title.edit json": "edit json",
153
+ "title.lookup scenario": "lookup scenario",
144
154
  "title.open data sample report page": "open data sample report page",
145
155
  "title.open data sample search page": "open data sample search page",
146
156
  "title.open data sample view": "open data sample view",
147
157
  "title.open data summary view": "open data summary view",
148
158
  "title.ready": "ready",
149
- "title.view detail ooc data": "view detail ooc data"
159
+ "title.view detail ooc data": "view detail ooc data",
160
+ "title.Data Key Set Master": "data key set master",
161
+ "menu.Data Key Set Master": "Data Key Set Master"
150
162
  }