@things-factory/dataset 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/data-key-set/data-key-item-list.js +196 -0
- package/client/pages/data-key-set/data-key-set-importer.js +107 -0
- package/client/pages/data-key-set/data-key-set-list-page.js +354 -0
- package/client/pages/data-ooc/data-ooc-list-page.js +60 -0
- package/client/pages/data-sample/data-sample-list-page.js +60 -0
- package/client/pages/data-sample/data-sample-search-page.js +439 -0
- package/client/pages/data-set/data-set-list-page.js +20 -1
- package/client/route.js +9 -1
- package/dist-server/controllers/create-data-sample.js +15 -3
- package/dist-server/controllers/create-data-sample.js.map +1 -1
- package/dist-server/service/data-key-set/data-key-item-type.js +58 -0
- package/dist-server/service/data-key-set/data-key-item-type.js.map +1 -0
- package/dist-server/service/data-key-set/data-key-set-mutation.js +179 -0
- package/dist-server/service/data-key-set/data-key-set-mutation.js.map +1 -0
- package/dist-server/service/data-key-set/data-key-set-query.js +110 -0
- package/dist-server/service/data-key-set/data-key-set-query.js.map +1 -0
- package/dist-server/service/data-key-set/data-key-set-type.js +94 -0
- package/dist-server/service/data-key-set/data-key-set-type.js.map +1 -0
- package/dist-server/service/data-key-set/data-key-set.js +101 -0
- package/dist-server/service/data-key-set/data-key-set.js.map +1 -0
- package/dist-server/service/data-key-set/index.js +9 -0
- package/dist-server/service/data-key-set/index.js.map +1 -0
- package/dist-server/service/data-ooc/data-ooc.js +32 -0
- package/dist-server/service/data-ooc/data-ooc.js.map +1 -1
- package/dist-server/service/data-sample/data-sample-query.js +27 -1
- package/dist-server/service/data-sample/data-sample-query.js.map +1 -1
- package/dist-server/service/data-sample/data-sample.js +41 -0
- package/dist-server/service/data-sample/data-sample.js.map +1 -1
- package/dist-server/service/data-set/data-item-type.js +1 -1
- package/dist-server/service/data-set/data-item-type.js.map +1 -1
- package/dist-server/service/data-set/data-set-query.js +14 -0
- package/dist-server/service/data-set/data-set-query.js.map +1 -1
- package/dist-server/service/data-set/data-set-type.js +14 -6
- package/dist-server/service/data-set/data-set-type.js.map +1 -1
- package/dist-server/service/data-set/data-set.js +32 -54
- package/dist-server/service/data-set/data-set.js.map +1 -1
- package/dist-server/service/index.js +4 -1
- package/dist-server/service/index.js.map +1 -1
- package/package.json +2 -2
- package/server/controllers/create-data-sample.ts +19 -12
- package/server/service/data-key-set/data-key-item-type.ts +31 -0
- package/server/service/data-key-set/data-key-set-mutation.ts +198 -0
- package/server/service/data-key-set/data-key-set-query.ts +65 -0
- package/server/service/data-key-set/data-key-set-type.ts +57 -0
- package/server/service/data-key-set/data-key-set.ts +81 -0
- package/server/service/data-key-set/index.ts +6 -0
- package/server/service/data-ooc/data-ooc.ts +20 -0
- package/server/service/data-sample/data-sample-query.ts +27 -0
- package/server/service/data-sample/data-sample.ts +33 -0
- package/server/service/data-set/data-item-type.ts +1 -1
- package/server/service/data-set/data-set-query.ts +11 -0
- package/server/service/data-set/data-set-type.ts +6 -0
- package/server/service/data-set/data-set.ts +24 -48
- package/server/service/index.ts +4 -1
- package/things-factory.config.js +8 -0
- package/translations/en.json +11 -0
- package/translations/ko.json +11 -0
- package/translations/ms.json +12 -1
- package/translations/zh.json +11 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"data-set.js","sourceRoot":"","sources":["../../../server/service/data-set/data-set.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAUgB;AAEhB,yDAAsD;AACtD,iDAA4D;AAE5D,qDAA2C;AAE3C,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,4CAAwB,CAAA;AAC1B,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,qCAAqC;CACnD,CAAC,CAAA;AAEF,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,6CAAuB,CAAA;IACvB,qCAAe,CAAA;IACf,mCAAa,CAAA;IACb,8CAAwB,CAAA;AAC1B,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAED,IAAA,+BAAgB,EAAC,kBAAkB,EAAE;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,uCAAuC;CACrD,CAAC,CAAA;AAEF,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;IACvB,oCAAe,CAAA;IACf,kCAAa,CAAA;IACb,6CAAwB,CAAA;AAC1B,CAAC,EALW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAK5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,sCAAsC;CACpD,CAAC,CAAA;AAKF,IAAa,OAAO,GAApB,MAAa,OAAO;IAApB;
|
1
|
+
{"version":3,"file":"data-set.js","sourceRoot":"","sources":["../../../server/service/data-set/data-set.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAUgB;AAEhB,yDAAsD;AACtD,iDAA4D;AAE5D,+DAAyD;AACzD,qDAA2C;AAE3C,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,4CAAwB,CAAA;AAC1B,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,qCAAqC;CACnD,CAAC,CAAA;AAEF,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,6CAAuB,CAAA;IACvB,qCAAe,CAAA;IACf,mCAAa,CAAA;IACb,8CAAwB,CAAA;AAC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mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AAxHP,OAAO;IAHnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC9F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;GACrC,OAAO,CAyHnB;AAzHY,0BAAO"}
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
exports.schema = exports.subscribers = exports.entities = void 0;
|
18
18
|
const data_item_1 = require("./data-item");
|
19
|
-
|
19
|
+
const data_key_set_1 = require("./data-key-set");
|
20
20
|
const data_ooc_1 = require("./data-ooc");
|
21
21
|
const data_sample_1 = require("./data-sample");
|
22
22
|
const data_sensor_1 = require("./data-sensor");
|
@@ -24,6 +24,7 @@ const data_set_1 = require("./data-set");
|
|
24
24
|
const data_set_history_1 = require("./data-set-history");
|
25
25
|
const data_spec_1 = require("./data-spec");
|
26
26
|
/* EXPORT ENTITY TYPES */
|
27
|
+
__exportStar(require("./data-key-set/data-key-set"), exports);
|
27
28
|
__exportStar(require("./data-ooc/data-ooc"), exports);
|
28
29
|
__exportStar(require("./data-sensor/data-sensor"), exports);
|
29
30
|
__exportStar(require("./data-sample/data-sample"), exports);
|
@@ -33,6 +34,7 @@ __exportStar(require("./data-set/data-item-type"), exports);
|
|
33
34
|
__exportStar(require("./data-spec/data-spec"), exports);
|
34
35
|
exports.entities = [
|
35
36
|
/* ENTITIES */
|
37
|
+
...data_key_set_1.entities,
|
36
38
|
...data_item_1.entities,
|
37
39
|
...data_ooc_1.entities,
|
38
40
|
...data_sensor_1.entities,
|
@@ -48,6 +50,7 @@ exports.subscribers = [
|
|
48
50
|
exports.schema = {
|
49
51
|
resolverClasses: [
|
50
52
|
/* RESOLVER CLASSES */
|
53
|
+
...data_key_set_1.resolvers,
|
51
54
|
...data_ooc_1.resolvers,
|
52
55
|
...data_sensor_1.resolvers,
|
53
56
|
...data_sample_1.resolvers,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,iDAAiG;AACjG,yCAAuF;AACvF,+CAAgG;AAChG,+CAAgG;AAChG,yCAAuF;AACvF,yDAI2B;AAC3B,2CAA0F;AAE1F,yBAAyB;AACzB,8DAA2C;AAC3C,sDAAmC;AACnC,4DAAyC;AACzC,4DAAyC;AACzC,sDAAmC;AACnC,sEAAmD;AACnD,4DAAyC;AACzC,wDAAqC;AAExB,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,uBAAkB;IACrB,GAAG,oBAAgB;IACnB,GAAG,mBAAe;IAClB,GAAG,sBAAkB;IACrB,GAAG,sBAAkB;IACrB,GAAG,mBAAe;IAClB,GAAG,2BAAsB;IACzB,GAAG,oBAAgB;CACpB,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,iBAAiB;IACjB,GAAG,8BAAyB;CAC7B,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,wBAAmB;QACtB,GAAG,oBAAgB;QACnB,GAAG,uBAAmB;QACtB,GAAG,uBAAmB;QACtB,GAAG,oBAAgB;QACnB,GAAG,4BAAuB;QAC1B,GAAG,qBAAiB;KACrB;CACF,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "5.0.
|
3
|
+
"version": "5.0.3",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -43,5 +43,5 @@
|
|
43
43
|
"cron-parser": "^4.3.0",
|
44
44
|
"moment-timezone": "^0.5.34"
|
45
45
|
},
|
46
|
-
"gitHead": "
|
46
|
+
"gitHead": "b4757c445c307a7a53c8ad73a43848648c33f16f"
|
47
47
|
}
|
@@ -13,6 +13,17 @@ import { DataUseCase } from './data-use-case'
|
|
13
13
|
|
14
14
|
const debug = require('debug')('things-factory:dataset:controller/save-data-sample')
|
15
15
|
|
16
|
+
const fillDataKeys = (dataKeySet, data) => {
|
17
|
+
const keys = dataKeySet?.dataKeyItems || []
|
18
|
+
return keys.reduce((sum, key, index) => {
|
19
|
+
const value = data[key.dataKey]
|
20
|
+
if (value != null) {
|
21
|
+
sum[`key0${index + 1}`] = value instanceof Array ? value[0] : value
|
22
|
+
}
|
23
|
+
return sum
|
24
|
+
}, {})
|
25
|
+
}
|
26
|
+
|
16
27
|
// parse variable javascript string pattern
|
17
28
|
const replaceVariables = (keys, dic) => {
|
18
29
|
for (const k in keys) {
|
@@ -40,18 +51,13 @@ const formatDate = (keys, _moment) => {
|
|
40
51
|
|
41
52
|
export async function createDataSample(
|
42
53
|
dataSample: NewDataSample,
|
43
|
-
context: {
|
44
|
-
state: {
|
45
|
-
domain: Domain
|
46
|
-
user: User
|
47
|
-
tx: EntityManager
|
48
|
-
}
|
49
|
-
}
|
54
|
+
context: { state: { domain: Domain; user: User; tx: EntityManager } }
|
50
55
|
): Promise<DataSample> {
|
51
56
|
const { domain, user, tx } = context.state
|
52
57
|
|
53
58
|
const dataSet = await tx.getRepository(DataSet).findOne({
|
54
|
-
where: { id: dataSample.dataSet.id }
|
59
|
+
where: { id: dataSample.dataSet.id },
|
60
|
+
relations: ['dataKeySet']
|
55
61
|
})
|
56
62
|
|
57
63
|
const dataItems = dataSet.dataItems
|
@@ -80,9 +86,9 @@ export async function createDataSample(
|
|
80
86
|
}
|
81
87
|
|
82
88
|
partitionKeys = formatDate(partitionKeys, localDateTz)
|
83
|
-
partitionKeys = replaceVariables(partitionKeys,
|
84
|
-
|
85
|
-
|
89
|
+
partitionKeys = replaceVariables(partitionKeys, dataSample.data)
|
90
|
+
|
91
|
+
const dataKeys = fillDataKeys(dataSet?.dataKeySet, dataSample.data)
|
86
92
|
|
87
93
|
const { ooc, oos, judgment } = DataUseCase.evaluate(dataSet, dataItems, dataSample.data) || {}
|
88
94
|
const result = await tx.getRepository(DataSample).save({
|
@@ -90,6 +96,7 @@ export async function createDataSample(
|
|
90
96
|
description: dataSet.description,
|
91
97
|
useCase: dataSet.useCase,
|
92
98
|
...dataSample,
|
99
|
+
...dataKeys,
|
93
100
|
dataSetVersion: dataSet.version,
|
94
101
|
domain,
|
95
102
|
partitionKeys,
|
@@ -137,4 +144,4 @@ export async function createDataSample(
|
|
137
144
|
}
|
138
145
|
|
139
146
|
return result
|
140
|
-
}
|
147
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Field, InputType, ObjectType } from 'type-graphql'
|
2
|
+
|
3
|
+
@ObjectType({ description: 'Entity for DataKeyItem' })
|
4
|
+
export class DataKeyItem {
|
5
|
+
@Field()
|
6
|
+
name: string
|
7
|
+
|
8
|
+
@Field({ nullable: true })
|
9
|
+
description?: string
|
10
|
+
|
11
|
+
@Field({ nullable: true })
|
12
|
+
dataKey: string
|
13
|
+
|
14
|
+
@Field({ nullable: true })
|
15
|
+
tKey?: string
|
16
|
+
}
|
17
|
+
|
18
|
+
@InputType()
|
19
|
+
export class DataKeyItemPatch {
|
20
|
+
@Field({ nullable: true })
|
21
|
+
name?: string
|
22
|
+
|
23
|
+
@Field({ nullable: true })
|
24
|
+
description?: string
|
25
|
+
|
26
|
+
@Field({ nullable: true })
|
27
|
+
dataKey?: string
|
28
|
+
|
29
|
+
@Field({ nullable: true })
|
30
|
+
tKey?: string
|
31
|
+
}
|
@@ -0,0 +1,198 @@
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
2
|
+
import { getRepository, In } from 'typeorm'
|
3
|
+
|
4
|
+
import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
5
|
+
|
6
|
+
import { DataKeySet } from './data-key-set'
|
7
|
+
import { NewDataKeySet, DataKeySetPatch } from './data-key-set-type'
|
8
|
+
|
9
|
+
@Resolver(DataKeySet)
|
10
|
+
export class DataKeySetMutation {
|
11
|
+
@Directive('@transaction')
|
12
|
+
@Mutation(returns => DataKeySet, { description: 'To create new DataKeySet' })
|
13
|
+
async createDataKeySet(@Arg('dataKeySet') dataKeySet: NewDataKeySet, @Ctx() context: any): Promise<DataKeySet> {
|
14
|
+
const { domain, user, tx } = context.state
|
15
|
+
|
16
|
+
const result = await tx.getRepository(DataKeySet).save({
|
17
|
+
...dataKeySet,
|
18
|
+
domain,
|
19
|
+
creator: user,
|
20
|
+
updater: user
|
21
|
+
})
|
22
|
+
|
23
|
+
if (dataKeySet.thumbnail) {
|
24
|
+
await createAttachment(
|
25
|
+
null,
|
26
|
+
{
|
27
|
+
attachment: {
|
28
|
+
file: dataKeySet.thumbnail,
|
29
|
+
refType: DataKeySet.name,
|
30
|
+
refBy: result.id
|
31
|
+
}
|
32
|
+
},
|
33
|
+
context
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
return result
|
38
|
+
}
|
39
|
+
|
40
|
+
@Directive('@transaction')
|
41
|
+
@Mutation(returns => DataKeySet, { description: 'To modify DataKeySet information' })
|
42
|
+
async updateDataKeySet(
|
43
|
+
@Arg('id') id: string,
|
44
|
+
@Arg('patch') patch: DataKeySetPatch,
|
45
|
+
@Ctx() context: any
|
46
|
+
): Promise<DataKeySet> {
|
47
|
+
const { domain, user, tx } = context.state
|
48
|
+
|
49
|
+
const repository = tx.getRepository(DataKeySet)
|
50
|
+
const dataKeySet = await repository.findOne({
|
51
|
+
where: { domain, id }
|
52
|
+
})
|
53
|
+
|
54
|
+
const result = await repository.save({
|
55
|
+
...dataKeySet,
|
56
|
+
...patch,
|
57
|
+
updater: user
|
58
|
+
})
|
59
|
+
|
60
|
+
if (patch.thumbnail) {
|
61
|
+
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
62
|
+
await createAttachment(
|
63
|
+
null,
|
64
|
+
{
|
65
|
+
attachment: {
|
66
|
+
file: patch.thumbnail,
|
67
|
+
refType: DataKeySet.name,
|
68
|
+
refBy: result.id
|
69
|
+
}
|
70
|
+
},
|
71
|
+
context
|
72
|
+
)
|
73
|
+
}
|
74
|
+
|
75
|
+
return result
|
76
|
+
}
|
77
|
+
|
78
|
+
@Directive('@transaction')
|
79
|
+
@Mutation(returns => [DataKeySet], { description: "To modify multiple DataKeySets' information" })
|
80
|
+
async updateMultipleDataKeySet(
|
81
|
+
@Arg('patches', type => [DataKeySetPatch]) patches: DataKeySetPatch[],
|
82
|
+
@Ctx() context: any
|
83
|
+
): Promise<DataKeySet[]> {
|
84
|
+
const { domain, user, tx } = context.state
|
85
|
+
|
86
|
+
let results = []
|
87
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
88
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
89
|
+
const dataKeySetRepo = tx.getRepository(DataKeySet)
|
90
|
+
|
91
|
+
if (_createRecords.length > 0) {
|
92
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
93
|
+
const newRecord = _createRecords[i]
|
94
|
+
|
95
|
+
const result = await dataKeySetRepo.save({
|
96
|
+
...newRecord,
|
97
|
+
domain,
|
98
|
+
creator: user,
|
99
|
+
updater: user
|
100
|
+
})
|
101
|
+
|
102
|
+
if (newRecord.thumbnail) {
|
103
|
+
await createAttachment(
|
104
|
+
null,
|
105
|
+
{
|
106
|
+
attachment: {
|
107
|
+
file: newRecord.thumbnail,
|
108
|
+
refType: DataKeySet.name,
|
109
|
+
refBy: result.id
|
110
|
+
}
|
111
|
+
},
|
112
|
+
context
|
113
|
+
)
|
114
|
+
}
|
115
|
+
|
116
|
+
results.push({ ...result, cuFlag: '+' })
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
if (_updateRecords.length > 0) {
|
121
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
122
|
+
const updateRecord = _updateRecords[i]
|
123
|
+
const dataKeySet = await dataKeySetRepo.findOne(updateRecord.id)
|
124
|
+
|
125
|
+
const result = await dataKeySetRepo.save({
|
126
|
+
...dataKeySet,
|
127
|
+
...updateRecord,
|
128
|
+
updater: user
|
129
|
+
})
|
130
|
+
|
131
|
+
if (updateRecord.thumbnail) {
|
132
|
+
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
133
|
+
await createAttachment(
|
134
|
+
null,
|
135
|
+
{
|
136
|
+
attachment: {
|
137
|
+
file: updateRecord.thumbnail,
|
138
|
+
refType: DataKeySet.name,
|
139
|
+
refBy: result.id
|
140
|
+
}
|
141
|
+
},
|
142
|
+
context
|
143
|
+
)
|
144
|
+
}
|
145
|
+
|
146
|
+
results.push({ ...result, cuFlag: 'M' })
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
return results
|
151
|
+
}
|
152
|
+
|
153
|
+
@Directive('@transaction')
|
154
|
+
@Mutation(returns => Boolean, { description: 'To delete DataKeySet' })
|
155
|
+
async deleteDataKeySet(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
|
156
|
+
const { domain, tx } = context.state
|
157
|
+
|
158
|
+
await tx.getRepository(DataKeySet).delete({ domain, id })
|
159
|
+
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
160
|
+
|
161
|
+
return true
|
162
|
+
}
|
163
|
+
|
164
|
+
@Directive('@transaction')
|
165
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple DataKeySets' })
|
166
|
+
async deleteDataKeySets(
|
167
|
+
@Arg('ids', type => [String]) ids: string[],
|
168
|
+
@Ctx() context: any
|
169
|
+
): Promise<boolean> {
|
170
|
+
const { domain, tx } = context.state
|
171
|
+
|
172
|
+
await tx.getRepository(DataKeySet).delete({
|
173
|
+
domain,
|
174
|
+
id: In(ids)
|
175
|
+
})
|
176
|
+
|
177
|
+
await deleteAttachmentsByRef(null, { refBys: ids }, context)
|
178
|
+
|
179
|
+
return true
|
180
|
+
}
|
181
|
+
|
182
|
+
@Directive('@transaction')
|
183
|
+
@Mutation(returns => Boolean, { description: 'To import multiple DataKeySets' })
|
184
|
+
async importDataKeySets(
|
185
|
+
@Arg('dataKeySets', type => [DataKeySetPatch]) dataKeySets: DataKeySetPatch[],
|
186
|
+
@Ctx() context: any
|
187
|
+
): Promise<boolean> {
|
188
|
+
const { domain, tx } = context.state
|
189
|
+
|
190
|
+
await Promise.all(
|
191
|
+
dataKeySets.map(async (dataKeySet: DataKeySetPatch) => {
|
192
|
+
const createdDataKeySet: DataKeySet = await tx.getRepository(DataKeySet).save({ domain, ...dataKeySet })
|
193
|
+
})
|
194
|
+
)
|
195
|
+
|
196
|
+
return true
|
197
|
+
}
|
198
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
2
|
+
import { getRepository } from 'typeorm'
|
3
|
+
|
4
|
+
import { Attachment } from '@things-factory/attachment-base'
|
5
|
+
import { User } from '@things-factory/auth-base'
|
6
|
+
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
7
|
+
|
8
|
+
import { DataKeySet } from './data-key-set'
|
9
|
+
import { DataKeySetList } from './data-key-set-type'
|
10
|
+
|
11
|
+
@Resolver(DataKeySet)
|
12
|
+
export class DataKeySetQuery {
|
13
|
+
@Query(returns => DataKeySet!, { nullable: true, description: 'To fetch a DataKeySet' })
|
14
|
+
async dataKeySet(@Arg('id') id: string, @Ctx() context: any): Promise<DataKeySet> {
|
15
|
+
const { domain } = context.state
|
16
|
+
|
17
|
+
return await getRepository(DataKeySet).findOne({
|
18
|
+
where: { domain, id }
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
@Query(returns => DataKeySetList, { description: 'To fetch multiple DataKeySets' })
|
23
|
+
async dataKeySets(@Args() params: ListParam, @Ctx() context: any): Promise<DataKeySetList> {
|
24
|
+
const { domain } = context.state
|
25
|
+
|
26
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
27
|
+
domain,
|
28
|
+
params,
|
29
|
+
repository: await getRepository(DataKeySet),
|
30
|
+
searchables: ['name', 'description']
|
31
|
+
})
|
32
|
+
|
33
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
34
|
+
|
35
|
+
return { items, total }
|
36
|
+
}
|
37
|
+
|
38
|
+
@FieldResolver(type => String)
|
39
|
+
async thumbnail(@Root() dataKeySet: DataKeySet): Promise<string | undefined> {
|
40
|
+
const attachment: Attachment = await getRepository(Attachment).findOne({
|
41
|
+
where: {
|
42
|
+
domain: dataKeySet.domainId,
|
43
|
+
refType: DataKeySet.name,
|
44
|
+
refBy: dataKeySet.id
|
45
|
+
}
|
46
|
+
})
|
47
|
+
|
48
|
+
return attachment?.fullpath
|
49
|
+
}
|
50
|
+
|
51
|
+
@FieldResolver(type => Domain)
|
52
|
+
async domain(@Root() dataKeySet: DataKeySet): Promise<Domain> {
|
53
|
+
return await getRepository(Domain).findOne(dataKeySet.domainId)
|
54
|
+
}
|
55
|
+
|
56
|
+
@FieldResolver(type => User)
|
57
|
+
async updater(@Root() dataKeySet: DataKeySet): Promise<User> {
|
58
|
+
return await getRepository(User).findOne(dataKeySet.updaterId)
|
59
|
+
}
|
60
|
+
|
61
|
+
@FieldResolver(type => User)
|
62
|
+
async creator(@Root() dataKeySet: DataKeySet): Promise<User> {
|
63
|
+
return await getRepository(User).findOne(dataKeySet.creatorId)
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
3
|
+
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
4
|
+
|
5
|
+
import { DataKeyItemPatch } from './data-key-item-type'
|
6
|
+
import { DataKeySet } from './data-key-set'
|
7
|
+
|
8
|
+
@InputType()
|
9
|
+
export class NewDataKeySet {
|
10
|
+
@Field()
|
11
|
+
name: string
|
12
|
+
|
13
|
+
@Field({ nullable: true })
|
14
|
+
description?: string
|
15
|
+
|
16
|
+
@Field({ nullable: true })
|
17
|
+
active?: boolean
|
18
|
+
|
19
|
+
@Field(type => [DataKeyItemPatch], { nullable: true })
|
20
|
+
dataKeyItems?: DataKeyItemPatch[]
|
21
|
+
|
22
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
23
|
+
thumbnail?: FileUpload
|
24
|
+
}
|
25
|
+
|
26
|
+
@InputType()
|
27
|
+
export class DataKeySetPatch {
|
28
|
+
@Field(type => ID, { nullable: true })
|
29
|
+
id?: string
|
30
|
+
|
31
|
+
@Field({ nullable: true })
|
32
|
+
name?: string
|
33
|
+
|
34
|
+
@Field({ nullable: true })
|
35
|
+
description?: string
|
36
|
+
|
37
|
+
@Field({ nullable: true })
|
38
|
+
active?: boolean
|
39
|
+
|
40
|
+
@Field(type => [DataKeyItemPatch], { nullable: true })
|
41
|
+
dataKeyItems?: DataKeyItemPatch[]
|
42
|
+
|
43
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
44
|
+
thumbnail?: FileUpload
|
45
|
+
|
46
|
+
@Field({ nullable: true })
|
47
|
+
cuFlag?: string
|
48
|
+
}
|
49
|
+
|
50
|
+
@ObjectType()
|
51
|
+
export class DataKeySetList {
|
52
|
+
@Field(type => [DataKeySet])
|
53
|
+
items: DataKeySet[]
|
54
|
+
|
55
|
+
@Field(type => Int)
|
56
|
+
total: number
|
57
|
+
}
|
@@ -0,0 +1,81 @@
|
|
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'
|
12
|
+
|
13
|
+
import { User } from '@things-factory/auth-base'
|
14
|
+
import { Domain } from '@things-factory/shell'
|
15
|
+
|
16
|
+
import { DataKeyItem } from './data-key-item-type'
|
17
|
+
|
18
|
+
@Entity()
|
19
|
+
@Index('ix_data_key_set_0', (dataKeySet: DataKeySet) => [dataKeySet.domain, dataKeySet.name], { unique: true })
|
20
|
+
@ObjectType({ description: 'Entity for DataKeySet' })
|
21
|
+
export class DataKeySet {
|
22
|
+
@PrimaryGeneratedColumn('uuid')
|
23
|
+
@Field(type => ID)
|
24
|
+
readonly id: string
|
25
|
+
|
26
|
+
@ManyToOne(type => Domain)
|
27
|
+
@Field({ nullable: true })
|
28
|
+
domain?: Domain
|
29
|
+
|
30
|
+
@RelationId((dataKeySet: DataKeySet) => dataKeySet.domain)
|
31
|
+
domainId?: string
|
32
|
+
|
33
|
+
@Column()
|
34
|
+
@Field()
|
35
|
+
name: string
|
36
|
+
|
37
|
+
@Column({
|
38
|
+
nullable: true
|
39
|
+
})
|
40
|
+
@Field({ nullable: true })
|
41
|
+
description?: string
|
42
|
+
|
43
|
+
@Column({
|
44
|
+
nullable: true
|
45
|
+
})
|
46
|
+
@Field({ nullable: true })
|
47
|
+
active?: boolean
|
48
|
+
|
49
|
+
@Column('simple-json', { nullable: true })
|
50
|
+
@Field(type => [DataKeyItem], { nullable: true })
|
51
|
+
dataKeyItems: DataKeyItem[]
|
52
|
+
|
53
|
+
@CreateDateColumn()
|
54
|
+
@Field({ nullable: true })
|
55
|
+
createdAt?: Date
|
56
|
+
|
57
|
+
@UpdateDateColumn()
|
58
|
+
@Field({ nullable: true })
|
59
|
+
updatedAt?: Date
|
60
|
+
|
61
|
+
@ManyToOne(type => User, {
|
62
|
+
nullable: true
|
63
|
+
})
|
64
|
+
@Field({ nullable: true })
|
65
|
+
creator?: User
|
66
|
+
|
67
|
+
@RelationId((dataKeySet: DataKeySet) => dataKeySet.creator)
|
68
|
+
creatorId?: string
|
69
|
+
|
70
|
+
@ManyToOne(type => User, {
|
71
|
+
nullable: true
|
72
|
+
})
|
73
|
+
@Field({ nullable: true })
|
74
|
+
updater?: User
|
75
|
+
|
76
|
+
@RelationId((dataKeySet: DataKeySet) => dataKeySet.creator)
|
77
|
+
updaterId?: string
|
78
|
+
|
79
|
+
@Field(type => String, { nullable: true })
|
80
|
+
thumbnail?: string
|
81
|
+
}
|
@@ -109,6 +109,26 @@ export class DataOoc {
|
|
109
109
|
@Field({ nullable: true })
|
110
110
|
useCase?: string
|
111
111
|
|
112
|
+
@Column({ nullable: true, default: '' })
|
113
|
+
@Field({ nullable: true })
|
114
|
+
key01?: string = ''
|
115
|
+
|
116
|
+
@Column({ nullable: true, default: '' })
|
117
|
+
@Field({ nullable: true })
|
118
|
+
key02?: string = ''
|
119
|
+
|
120
|
+
@Column({ nullable: true, default: '' })
|
121
|
+
@Field({ nullable: true })
|
122
|
+
key03?: string = ''
|
123
|
+
|
124
|
+
@Column({ nullable: true, default: '' })
|
125
|
+
@Field({ nullable: true })
|
126
|
+
key04?: string = ''
|
127
|
+
|
128
|
+
@Column({ nullable: true, default: '' })
|
129
|
+
@Field({ nullable: true })
|
130
|
+
key05?: string = ''
|
131
|
+
|
112
132
|
@Column('simple-json', { nullable: true })
|
113
133
|
@Field(type => ScalarObject, { nullable: true })
|
114
134
|
partitionKeys?: ScalarObject
|
@@ -4,6 +4,7 @@ import { getRepository } from 'typeorm'
|
|
4
4
|
import { User } from '@things-factory/auth-base'
|
5
5
|
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
6
6
|
|
7
|
+
import { DataKeySet } from '../data-key-set/data-key-set'
|
7
8
|
import { DataSetHistory } from '../data-set-history/data-set-history'
|
8
9
|
import { DataItem } from '../data-set/data-item-type'
|
9
10
|
import { DataSet } from '../data-set/data-set'
|
@@ -39,6 +40,32 @@ export class DataSampleQuery {
|
|
39
40
|
return { items, total }
|
40
41
|
}
|
41
42
|
|
43
|
+
@Directive('@privilege(category: "data-sample", privilege: "query", domainOwnerGranted: true)')
|
44
|
+
@Query(returns => DataSampleList, { description: 'To fetch multiple data samples by data key set' })
|
45
|
+
async dataSamplesByDataKeySet(
|
46
|
+
@Arg('dataKeySetId') dataKeySetId: string,
|
47
|
+
@Args() params: ListParam,
|
48
|
+
@Ctx() context: any
|
49
|
+
): Promise<DataSampleList> {
|
50
|
+
const { domain } = context.state
|
51
|
+
|
52
|
+
const dataKeySet = await getRepository(DataKeySet).findOne(dataKeySetId)
|
53
|
+
const dataKeyItems = dataKeySet?.dataKeyItems || []
|
54
|
+
const searchables = dataKeyItems.map((item, index) => `key0${index + 1}`)
|
55
|
+
|
56
|
+
/* TODO DataKeySet 과 관련된 DataSample만 조회되도록 할 것. */
|
57
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
58
|
+
repository: getRepository(DataSample),
|
59
|
+
params,
|
60
|
+
domain,
|
61
|
+
searchables: ['name', 'description'].concat(searchables)
|
62
|
+
})
|
63
|
+
|
64
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
65
|
+
|
66
|
+
return { items, total }
|
67
|
+
}
|
68
|
+
|
42
69
|
@FieldResolver(type => [DataItem])
|
43
70
|
async dataItems(@Root() dataSample: DataSample): Promise<DataItem[]> {
|
44
71
|
const dataSetHistory: DataSetHistory = await getRepository(DataSetHistory).findOne({
|