@things-factory/reference-app 5.0.0-zeta.7 → 5.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/attachments/1aa35791-259f-42f3-9bab-faf4dc81c54a.png +0 -0
- package/attachments/39e79f93-f50c-4d0d-9016-12ef6fc72d04.pptx +0 -0
- package/attachments/5705d276-f428-44d6-a0b8-9667671fc011.png +0 -0
- package/attachments/5f63a469-132c-4ddd-a7a8-37d01f693c9d.png +0 -0
- package/attachments/69808491-8e6b-45e2-9bf8-dccea1c5b52e.png +0 -0
- package/attachments/6c3b55e5-8a42-4afa-a456-9f540972a4b5.png +0 -0
- package/attachments/7927fe8e-2246-453d-9869-7072b983437c.png +0 -0
- package/attachments/7d150574-01b8-4439-96a0-d57299f3ffcf.png +0 -0
- package/attachments/8bacec9a-bd5d-4dbf-bbcb-9f08dd7b60d5.png +0 -0
- package/attachments/a1cf142c-f3c2-442c-b8d5-a7f9cc6a59b3.png +0 -0
- package/attachments/aedcc3d7-a4ab-4ada-98bd-0db6fa5061ba.png +0 -0
- package/attachments/c1cd9051-bcf4-4711-89a2-63dfefbd969a.png +0 -0
- package/attachments/cb3ac834-ece0-4802-bef0-dfdc0fcd93bd.png +0 -0
- package/attachments/fb06c90b-df44-4ac7-b71c-056278439290.png +0 -0
- package/client/bootstrap.js +21 -11
- package/client/components/ocr-viewpart.js +1 -1
- package/client/editors/id-editor.js +1 -1
- package/client/editors/id-selector.js +1 -1
- package/client/menu.js +10 -5
- package/client/pages/data-entry/data-entry-form.js +117 -0
- package/client/pages/data-entry/data-entry-generator-popup.js +110 -0
- package/client/pages/data-set/data-item-list.js +277 -0
- package/client/pages/data-set/data-set-importer.js +103 -0
- package/client/pages/data-set/data-set-list-page.js +738 -0
- package/client/pages/ocr-page.js +1 -1
- package/client/pages/operation/operation-api.js +85 -0
- package/client/pages/operation/operation-master.js +432 -0
- package/client/pages/pending-job-page.js +1 -1
- package/client/pages/product/product-api.js +150 -0
- package/client/pages/product/product-master.js +888 -0
- package/client/pages/product-combination-settings-popup.js +395 -0
- package/client/pages/product-combinations-popup.js +372 -0
- package/client/pages/product-details-popup.js +744 -0
- package/client/pages/upload-page.js +1 -1
- package/client/route.js +12 -0
- package/config/config.development.js +1 -1
- package/config.development.js +16 -2
- package/db.sqlite +0 -0
- package/dist-server/constants/index.js +18 -0
- package/dist-server/constants/index.js.map +1 -0
- package/dist-server/constants/type-constants.js +26 -0
- package/dist-server/constants/type-constants.js.map +1 -0
- package/dist-server/controllers/create-data-sample-mockup.js +236 -0
- package/dist-server/controllers/create-data-sample-mockup.js.map +1 -0
- package/dist-server/controllers/index.js +17 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/service/data-sample-mockup/data-sample-mockup-mutation.js +40 -0
- package/dist-server/service/data-sample-mockup/data-sample-mockup-mutation.js.map +1 -0
- package/dist-server/service/data-sample-mockup/data-sample-mockup-type.js +28 -0
- package/dist-server/service/data-sample-mockup/data-sample-mockup-type.js.map +1 -0
- package/dist-server/service/data-sample-mockup/index.js +7 -0
- package/dist-server/service/data-sample-mockup/index.js.map +1 -0
- package/dist-server/service/index.js +5 -2
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/reference/reference-mutation.js +6 -3
- package/dist-server/service/reference/reference-mutation.js.map +1 -1
- package/dist-server/service/reference/reference-query.js +7 -4
- package/dist-server/service/reference/reference-query.js.map +1 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +4 -4
- package/logs/.33a2b6820ab05dbb0f8bea4849090e12685d0b36-audit.json +3 -8
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +29 -4
- package/logs/application-2022-06-16-13.log +4 -0
- package/logs/application-2022-06-16-20.log +4 -0
- package/logs/application-2022-06-16-21.log +7 -0
- package/logs/application-2022-07-22-10.log +26 -0
- package/logs/{connections-2022-01-17-14.log → connections-2022-01-01-00.log} +0 -0
- package/logs/{connections-2022-01-17-15.log → connections-2022-06-05-11.log} +0 -0
- package/logs/{connections-2022-06-20-13.log → connections-2022-06-08-11.log} +0 -0
- package/logs/connections-2022-06-08-12.log +0 -0
- package/logs/connections-2022-06-08-13.log +0 -0
- package/logs/connections-2022-06-08-15.log +0 -0
- package/logs/connections-2022-06-08-16.log +0 -0
- package/logs/connections-2022-06-08-17.log +0 -0
- package/logs/connections-2022-06-08-18.log +0 -0
- package/logs/connections-2022-06-09-00.log +0 -0
- package/logs/connections-2022-06-10-10.log +0 -0
- package/logs/connections-2022-06-10-15.log +0 -0
- package/logs/connections-2022-06-12-17.log +0 -0
- package/logs/connections-2022-06-12-19.log +0 -0
- package/logs/connections-2022-06-16-13.log +0 -0
- package/logs/connections-2022-06-16-20.log +0 -0
- package/logs/connections-2022-06-16-21.log +0 -0
- package/logs/connections-2022-07-12-00.log +0 -0
- package/logs/connections-2022-07-14-14.log +0 -0
- package/logs/connections-2022-07-14-15.log +0 -0
- package/logs/connections-2022-07-14-16.log +0 -0
- package/logs/connections-2022-07-14-17.log +0 -0
- package/logs/connections-2022-07-22-10.log +0 -0
- package/logs/system/.de213bae5e079f641b78bdb917979b79dcc8e501-audit.json +15 -0
- package/logs/system/scenario-1-2022-04-15-16.log +176 -0
- package/package.json +58 -56
- package/server/constants/index.ts +1 -0
- package/server/constants/type-constants.ts +24 -0
- package/server/controllers/create-data-sample-mockup.ts +268 -0
- package/server/controllers/index.ts +1 -0
- package/server/service/data-sample-mockup/data-sample-mockup-mutation.ts +18 -0
- package/server/service/data-sample-mockup/data-sample-mockup-type.ts +10 -0
- package/server/service/data-sample-mockup/index.ts +4 -0
- package/server/service/index.ts +5 -2
- package/server/service/reference/reference-mutation.ts +5 -3
- package/server/service/reference/reference-query.ts +8 -7
- package/things-factory.config.js +8 -0
- package/translations/en.json +6 -1
- package/translations/ko.json +7 -1
- package/attachments/02d2c4ea-147a-411e-a34e-5dbd96eea3f8.jpeg +0 -0
- package/attachments/05284c84-1330-4b54-a698-bcd3020d9d90.png +0 -0
- package/attachments/0554c8c2-aefe-4ce5-b030-94c643976577.jpeg +0 -0
- package/attachments/0598f578-ddd9-4b8c-8726-74ea5fe13778.jpeg +0 -0
- package/attachments/09fd9f4d-1909-4fbb-b5bd-b3604dd44d83.pdf +0 -0
- package/attachments/0c759fb7-b15a-4eba-b55f-1c97c9320e12.jpeg +0 -0
- package/attachments/0ca13d71-3df4-4932-b834-0057a6454776.jpeg +0 -0
- package/attachments/0fe94be8-c2bf-44ea-b8bd-3b2e5d65cb07.png +0 -0
- package/attachments/105aff20-62d2-41ae-a9ab-8ea1eb03a064.jpeg +0 -0
- package/attachments/124d6ef2-6ab9-4963-8b0b-5f8607b79a5b.png +0 -0
- package/attachments/1a4edbc9-b06c-4e1b-8b7a-4af7a8a08720.jpeg +0 -0
- package/attachments/1aaa7721-7a6c-47fa-a375-b186b82dd3b1.jpeg +0 -0
- package/attachments/1e647161-13ff-4540-9115-0fe383860516.jpeg +0 -0
- package/attachments/1e7fec94-e08f-468e-af89-e108904e4401.png +0 -0
- package/attachments/1ee44a5b-b946-4609-bf09-bc4f741325f1.png +0 -0
- package/attachments/244fbab5-0821-4e57-8c7e-745feaac12b3.jpeg +0 -0
- package/attachments/2b1cfec6-4d1c-4130-8ac5-5dffa64ac4d5.png +0 -0
- package/attachments/3a328a7f-b7fd-4ea1-9c4c-005e24e1e897.png +0 -0
- package/attachments/3c562896-8cc8-489b-8760-5109602b631a.jpeg +0 -0
- package/attachments/426bd3d4-aaec-496c-8d20-a84692d574dc.jpeg +0 -0
- package/attachments/4412432a-b79b-49b8-81b2-af6b927703b4.png +0 -0
- package/attachments/5427ece0-13b3-48a8-ac14-b25dcfae3cd9.jpeg +0 -0
- package/attachments/56aad6a3-e99d-4186-985b-d8d3ccd4ab68.jpeg +0 -0
- package/attachments/5a4d23c9-6fa0-43ce-87d1-27fbb252438d.jpeg +0 -0
- package/attachments/5a564ed4-1858-4656-8d88-b6a490bc0309.jpeg +0 -0
- package/attachments/5ba01610-dc05-483e-8988-da9d34c141df.jpeg +0 -0
- package/attachments/5d34b97a-61b9-472f-a88f-636b85c1e45c.jpeg +0 -0
- package/attachments/5dc41b95-4970-4221-accb-86afa94b4f3b.png +0 -0
- package/attachments/60ca3d2a-cfa4-4f14-b952-a96be9f64f96.png +0 -0
- package/attachments/62232866-32ef-43fe-b84b-993d074c173d.png +0 -0
- package/attachments/6309383a-7c72-4a2c-8fb9-b14fe4f1905a.jpeg +0 -0
- package/attachments/63142721-6030-4889-b52d-d21e8ddd52cd.jpeg +0 -0
- package/attachments/6a284a40-de4a-4e79-adbb-fe2ac6f123d4.png +0 -0
- package/attachments/6b1839fa-098b-4881-9d26-f950282f0ee7.pdf +0 -0
- package/attachments/6cb59217-600f-47a1-91fc-299c27e5e248.png +0 -0
- package/attachments/6da5c66a-08a0-409b-8f35-1a953cf44c3f.jpeg +0 -0
- package/attachments/709a2c9d-c919-42ca-8001-6b1688daf978.jpeg +0 -0
- package/attachments/70bd97b9-0cfe-4c43-9cba-3c0dbedfff70.jpeg +0 -0
- package/attachments/71a71839-5521-456b-8eee-134b5f0a6c1c.jpeg +0 -0
- package/attachments/79d67c49-a3a0-4cd9-a78c-a012732d9d8b.jpeg +0 -0
- package/attachments/7f4f78ba-bfe5-466c-88b4-b31824263b84.png +0 -0
- package/attachments/82214212-6296-4c73-812f-18a509368247.jpeg +0 -0
- package/attachments/8488bba6-353a-4f77-84be-1526c92f7b7f.png +0 -0
- package/attachments/891d2e46-a01d-408d-b715-4513fcb52240.jpeg +0 -0
- package/attachments/8a240663-dffe-4c20-a6a0-51e4561c2037.png +0 -0
- package/attachments/8b82bd3d-10ed-4c9e-94d5-7f01400b1fe1.jpeg +0 -0
- package/attachments/8cee2fe7-1bb9-48b1-b759-1efd0164b8c9.jpeg +0 -0
- package/attachments/90ea058c-ed47-4802-a694-bce0e86c217f.png +0 -0
- package/attachments/92be3157-e6b1-4104-b86c-4e510895a71e.jpeg +0 -0
- package/attachments/93a9638b-34b6-4625-9a23-dc088d5ed615.jpeg +0 -0
- package/attachments/9c92e78d-afcb-4d62-b51e-f73f15211314.png +0 -0
- package/attachments/9edcd63b-39e9-4e0c-b3e4-b255ffadc037.jpeg +0 -0
- package/attachments/a64d028e-7e33-4455-a1c4-f294250b5650.png +0 -0
- package/attachments/b1008da4-9e8a-4360-9600-2aeca8e4503a.pdf +0 -0
- package/attachments/b174f420-3f33-463a-8efd-6abad2f709fe.jpeg +0 -0
- package/attachments/b27517ec-f2ac-4735-9d8a-353af2fa5f67.png +0 -0
- package/attachments/b3b99d3b-6e95-4ac8-a349-b4bcf5d78dcd.png +0 -0
- package/attachments/b6c2d24d-8f18-4925-bc2d-4d3bffad4a02.png +0 -0
- package/attachments/b8a5d357-e196-4c32-8059-6d9b94470672.jpeg +0 -0
- package/attachments/b93a5d06-7395-4409-8680-64e8fa9542bb.jpeg +0 -0
- package/attachments/bacf8fe2-a3ef-433b-a00d-f154378db75a.png +0 -0
- package/attachments/bcb6e85d-9dae-4271-9ff6-47a235c41488.jpeg +0 -0
- package/attachments/c3fdecd2-b06e-461e-b2c7-23c69a30e744.jpeg +0 -0
- package/attachments/c47bf238-810c-489b-bc2e-c942033b2ac3.png +0 -0
- package/attachments/c5953130-2bc7-4f73-ab00-835e10658027.png +0 -0
- package/attachments/c66e06b2-32d5-416e-bc8a-c057cf938491.png +0 -0
- package/attachments/c7e77261-cfa2-48e8-8135-383cb0487901.jpeg +0 -0
- package/attachments/cc7892b9-fca6-49f9-a10b-3febeef83fd2.png +0 -0
- package/attachments/d179dc14-baf5-4549-b79e-580ce6b9b897.jpeg +0 -0
- package/attachments/d5ac154b-8c03-4456-9296-e9ce0b24c9ac.png +0 -0
- package/attachments/dbf0459a-4f1a-44c6-a4fc-d73adc3e4cfa.png +0 -0
- package/attachments/de443f64-d2b8-4b10-9b8c-e55b9ab30944.png +0 -0
- package/attachments/de9e417e-9636-41c7-8e27-49ff2c759ddb.jpeg +0 -0
- package/attachments/e5bfd176-32ac-48c0-ad7c-d65478950e28.jpeg +0 -0
- package/attachments/e6fcee2a-cdda-4131-8f9c-90b1fa06a4f4.png +0 -0
- package/attachments/f8a9e56b-6205-4dc8-991e-eec568403810.jpeg +0 -0
- package/logs/application-2022-06-20-13.log +0 -4
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import moment from 'moment-timezone'
|
|
2
|
+
import { EntityManager } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { DataSet, DataSample, DataUseCase } from '@things-factory/dataset'
|
|
6
|
+
import { Product } from '@things-factory/product-base'
|
|
7
|
+
import { Operation } from '@things-factory/routing-base'
|
|
8
|
+
import { Domain } from '@things-factory/shell'
|
|
9
|
+
import { getWorkDateAndShift } from '@things-factory/work-shift'
|
|
10
|
+
|
|
11
|
+
import { DataSampleMockupInfo } from '../service/data-sample-mockup/data-sample-mockup-type'
|
|
12
|
+
|
|
13
|
+
const randomWords = require('random-words')
|
|
14
|
+
const debug = require('debug')('things-factory:reference-app:controller/create-data-sample-mockup')
|
|
15
|
+
|
|
16
|
+
// parse variable javascript string pattern
|
|
17
|
+
const replaceVariables = (keys, dic) => {
|
|
18
|
+
for (const k in keys) {
|
|
19
|
+
const matches = keys[k].match(/\$\{\w*\}/g)
|
|
20
|
+
matches &&
|
|
21
|
+
matches.forEach(m => {
|
|
22
|
+
keys[k] = keys[k].replace(m, dic[m.slice(2, -1)])
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
return keys
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// It is required UTC date for Partitioning File System like AWS S3 from Athena.
|
|
29
|
+
// ex) %YYYY, %MM, %DD
|
|
30
|
+
const formatDate = (keys, _moment) => {
|
|
31
|
+
for (const k in keys) {
|
|
32
|
+
const matches = keys[k].match(/%\w*/g)
|
|
33
|
+
matches &&
|
|
34
|
+
matches.forEach(m => {
|
|
35
|
+
keys[k] = keys[k].replace(m, _moment.format(m.substr(1)))
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
return keys
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Normal Distribution
|
|
43
|
+
* https://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve
|
|
44
|
+
*/
|
|
45
|
+
function normal_dist(min, max, skew) {
|
|
46
|
+
let u = 0, v = 0;
|
|
47
|
+
while(u === 0) u = Math.random() //Converting [0,1) to (0,1)
|
|
48
|
+
while(v === 0) v = Math.random()
|
|
49
|
+
let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v )
|
|
50
|
+
|
|
51
|
+
num = num / 10.0 + 0.5 // Translate to 0 -> 1
|
|
52
|
+
if (num > 1 || num < 0)
|
|
53
|
+
num = normal_dist(min, max, skew) // resample between 0 and 1 if out of range
|
|
54
|
+
|
|
55
|
+
else{
|
|
56
|
+
num = Math.pow(num, skew) // Skew
|
|
57
|
+
num *= max - min // Stretch to fill range
|
|
58
|
+
num += min // offset to min
|
|
59
|
+
}
|
|
60
|
+
return num
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function randomIndex(max = 2) {
|
|
64
|
+
return Math.floor(Math.random() * max)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function fillColumns(prev, next, dict) {
|
|
68
|
+
let values = []
|
|
69
|
+
try {
|
|
70
|
+
const gap = 20
|
|
71
|
+
const timeFormat = 'HH:mm'
|
|
72
|
+
const dateFormat = 'YYYY-MM-DD'
|
|
73
|
+
const atFormat = 'YYYY-MM-DD HH:mm:ss'
|
|
74
|
+
const now = moment()
|
|
75
|
+
const { type, spec, quota } = next
|
|
76
|
+
const isValidSpec = spec && Object.keys(spec).length
|
|
77
|
+
const arr = Array.from(Array(quota).keys())
|
|
78
|
+
|
|
79
|
+
if(type == 'number') {
|
|
80
|
+
if (isValidSpec) { /* generate values refer to spec info. */
|
|
81
|
+
const { CCP: { criticalLimits: { minimum, maximum } } } = spec
|
|
82
|
+
while (values.length < quota) {
|
|
83
|
+
let value = 0
|
|
84
|
+
if (typeof minimum === 'number' && typeof maximum === 'number') {
|
|
85
|
+
value = Math.floor(normal_dist(minimum, maximum, 1))
|
|
86
|
+
} else if (typeof minimum === 'number' && typeof maximum !== 'number') {
|
|
87
|
+
const max = minimum + gap
|
|
88
|
+
value = Math.floor(normal_dist(minimum, max, 1))
|
|
89
|
+
} else if (typeof minimum !== 'number' && typeof maximum === 'number') {
|
|
90
|
+
const min = maximum - gap
|
|
91
|
+
value = Math.floor(normal_dist(min, maximum, 1))
|
|
92
|
+
}
|
|
93
|
+
values.push(value)
|
|
94
|
+
}
|
|
95
|
+
} else { /* random number */
|
|
96
|
+
const p = Math.random()
|
|
97
|
+
const q = () => randomIndex(10) + 1
|
|
98
|
+
// fixed
|
|
99
|
+
if (p > 0.33) {
|
|
100
|
+
values = Array(quota).fill(q())
|
|
101
|
+
} else if(p > 0.66) { /* or random */
|
|
102
|
+
values = arr.map(i => q())
|
|
103
|
+
|
|
104
|
+
} else { /* or incremental */
|
|
105
|
+
values = arr.reduce((prev, i) => {
|
|
106
|
+
prev.push(!!prev.length ? prev[0] + i: q())
|
|
107
|
+
return prev
|
|
108
|
+
}, [])
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else if (type == 'select') {
|
|
112
|
+
const options = next['options']['options']
|
|
113
|
+
values = arr.map(i => options[randomIndex(options.length)]['value'])
|
|
114
|
+
} else if (type == 'boolean') {
|
|
115
|
+
values = arr.map(i => !!randomIndex())
|
|
116
|
+
} else if (next['tag'].toLowerCase().indexOf('time') >= 0) {
|
|
117
|
+
/* ex) startTime => 09:21 */
|
|
118
|
+
arr.reduce(curr => {
|
|
119
|
+
values.push(curr.format(timeFormat))
|
|
120
|
+
curr.add(randomIndex(60), 'minutes')
|
|
121
|
+
return curr
|
|
122
|
+
}, now)
|
|
123
|
+
} else if (next['tag'].indexOf('edAt') > 0) {
|
|
124
|
+
/* ex) createdAt => '2022-06-15 09:21:30 */
|
|
125
|
+
arr.reduce(curr => {
|
|
126
|
+
values.push(curr.format(atFormat))
|
|
127
|
+
curr.add(randomIndex(12), 'hours')
|
|
128
|
+
return curr
|
|
129
|
+
}, now)
|
|
130
|
+
} else if (next['tag'].toLowerCase().indexOf('date') > 0) {
|
|
131
|
+
/* ex) startDate => '2022-06-15 */
|
|
132
|
+
arr.reduce(curr => {
|
|
133
|
+
values.push(curr.format(dateFormat))
|
|
134
|
+
curr.add(randomIndex(7), 'days')
|
|
135
|
+
return curr
|
|
136
|
+
}, now)
|
|
137
|
+
} else if (dict.hasOwnProperty(next['tag'])) {
|
|
138
|
+
values = Array(quota).fill(dict[next['tag']])
|
|
139
|
+
} else {
|
|
140
|
+
if (type == 'text') {
|
|
141
|
+
values = randomWords(quota)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} finally {
|
|
145
|
+
prev[next['tag']] = values
|
|
146
|
+
return prev
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function _generateMockupData(dataSources:any, tx:EntityManager) {
|
|
151
|
+
const { user, domain, dataSet, spec, products, operations } = dataSources
|
|
152
|
+
|
|
153
|
+
const collectedAt = new Date()
|
|
154
|
+
|
|
155
|
+
const timezone = dataSet.timezone || domain.timezone || 'UTC'
|
|
156
|
+
const format = 'YYYY-MM-DD'
|
|
157
|
+
|
|
158
|
+
// workDate ex) 2022-04-04
|
|
159
|
+
const { workDate, workShift } = await getWorkDateAndShift(domain, collectedAt, { timezone, format })
|
|
160
|
+
|
|
161
|
+
// local time dataSet timezone or domain timezone or default 'UTC'
|
|
162
|
+
|
|
163
|
+
// const collectedAt = dataSample.collectedAt || new Date()
|
|
164
|
+
const localDateTz = moment(collectedAt).tz(timezone)
|
|
165
|
+
const defaultPartitionKeys = {
|
|
166
|
+
domain: domain.subdomain,
|
|
167
|
+
datasetid: dataSet.id, /* It should not be 'data_set_id' as column name duplicated for Glue */
|
|
168
|
+
date: localDateTz.format(format), /* local time date */
|
|
169
|
+
workdate: workDate, /* working date */
|
|
170
|
+
workshift: workShift
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var partitionKeys = {
|
|
174
|
+
...defaultPartitionKeys,
|
|
175
|
+
...dataSet.partitionKeys
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// get product, operation as a map
|
|
179
|
+
const oper = operations[Math.floor(Math.random() * operations.length)]
|
|
180
|
+
const prod = products[Math.floor(Math.random() * products.length)]
|
|
181
|
+
const dict = {
|
|
182
|
+
operation: oper['name'],
|
|
183
|
+
operationId: oper['id'],
|
|
184
|
+
product: prod['name'],
|
|
185
|
+
productId: prod['id']
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const sample = dataSet.dataItems.reduce((prev, next) => fillColumns(prev, next, dict), {})
|
|
189
|
+
debug('sample', sample)
|
|
190
|
+
|
|
191
|
+
partitionKeys = formatDate(partitionKeys, localDateTz)
|
|
192
|
+
partitionKeys = replaceVariables(partitionKeys, {
|
|
193
|
+
...sample
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
const { ooc, oos, judgment } = DataUseCase.evaluate(dataSet, dataSet.dataItems, sample) || {}
|
|
197
|
+
const result = await tx.getRepository(DataSample).save({
|
|
198
|
+
name: dataSet.name,
|
|
199
|
+
description: dataSet.description,
|
|
200
|
+
useCase: dataSet.useCase,
|
|
201
|
+
dataSet: dataSet,
|
|
202
|
+
dataSetVersion: dataSet.version,
|
|
203
|
+
data: sample,
|
|
204
|
+
domain,
|
|
205
|
+
partitionKeys,
|
|
206
|
+
spec,
|
|
207
|
+
ooc,
|
|
208
|
+
oos,
|
|
209
|
+
judgment,
|
|
210
|
+
collectedAt,
|
|
211
|
+
workDate,
|
|
212
|
+
workShift,
|
|
213
|
+
creator: user,
|
|
214
|
+
updater: user
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
return true
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export async function generateMockupData(
|
|
221
|
+
params: DataSampleMockupInfo,
|
|
222
|
+
context: {
|
|
223
|
+
state: {
|
|
224
|
+
domain: Domain
|
|
225
|
+
user: User
|
|
226
|
+
tx: EntityManager
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
): Promise<Boolean> {
|
|
230
|
+
const { domain, user, tx } = context.state
|
|
231
|
+
|
|
232
|
+
const dataSet: DataSet = await tx.getRepository(DataSet).findOne({
|
|
233
|
+
where: { id: params.dataSetId }
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const products = await tx.getRepository(Product).find({
|
|
237
|
+
select: [ 'id', 'name', 'description' ],
|
|
238
|
+
where: {
|
|
239
|
+
domain
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
const operations = await tx.getRepository(Operation).find({
|
|
244
|
+
select: [ 'id', 'name', 'description' ],
|
|
245
|
+
where: {
|
|
246
|
+
domain
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const dataItems = dataSet.dataItems
|
|
251
|
+
|
|
252
|
+
const spec = dataItems.reduce((spec, dataItem) => {
|
|
253
|
+
spec[dataItem.tag] = {
|
|
254
|
+
...dataItem.spec,
|
|
255
|
+
name: dataItem.name, /* do we need ? */
|
|
256
|
+
hidden: dataItem.hidden
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return spec
|
|
260
|
+
}, {})
|
|
261
|
+
|
|
262
|
+
const promises = Array(params.numSamples).fill(0).map(x => {
|
|
263
|
+
return _generateMockupData({ domain, user, dataSet, products, operations, spec }, tx)
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
await Promise.all(promises)
|
|
267
|
+
return true
|
|
268
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-data-sample-mockup'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { DataSample } from '@things-factory/dataset'
|
|
4
|
+
|
|
5
|
+
import { generateMockupData } from '../../controllers/create-data-sample-mockup'
|
|
6
|
+
import { DataSampleMockupInfo } from './data-sample-mockup-type'
|
|
7
|
+
|
|
8
|
+
const debug = require('debug')('things-factory:dataset:data-sample:data-sample-mutation')
|
|
9
|
+
|
|
10
|
+
@Resolver(DataSample)
|
|
11
|
+
export class DataSampleMockupMutation {
|
|
12
|
+
@Directive('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)')
|
|
13
|
+
@Directive('@transaction')
|
|
14
|
+
@Mutation(returns => Boolean, { description: 'To generate data sample one' })
|
|
15
|
+
async generateMockupData(@Arg('params') params: DataSampleMockupInfo, @Ctx() context: any): Promise<Boolean> {
|
|
16
|
+
return await generateMockupData(params, context)
|
|
17
|
+
}
|
|
18
|
+
}
|
package/server/service/index.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
4
4
|
import { entities as ReferenceEntities, resolvers as ReferenceResolvers } from './reference'
|
|
5
|
+
import { entities as DataSampleMockupEntities, resolvers as DataSampleMockupMutation } from './data-sample-mockup'
|
|
5
6
|
|
|
6
7
|
export const entities = [
|
|
7
8
|
/* ENTITIES */
|
|
8
|
-
...ReferenceEntities
|
|
9
|
+
...ReferenceEntities,
|
|
10
|
+
...DataSampleMockupEntities
|
|
9
11
|
]
|
|
10
12
|
|
|
11
13
|
export const schema = {
|
|
12
14
|
resolverClasses: [
|
|
13
15
|
/* RESOLVER CLASSES */
|
|
14
|
-
...ReferenceResolvers
|
|
16
|
+
...ReferenceResolvers,
|
|
17
|
+
...DataSampleMockupMutation
|
|
15
18
|
]
|
|
16
19
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
+
import { Arg, Ctx, Mutation, Resolver, Root } from 'type-graphql'
|
|
4
|
+
|
|
5
|
+
import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
3
6
|
import { publishProgress } from '@things-factory/shell'
|
|
4
7
|
import { sleep } from '@things-factory/utils'
|
|
5
|
-
import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
6
8
|
|
|
7
9
|
@Resolver()
|
|
8
10
|
export class ReferenceMutation {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FileUpload
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
2
3
|
import { Arg, Ctx, Query, Resolver, Root } from 'type-graphql'
|
|
3
4
|
|
|
4
5
|
import { Attachment, createAttachments } from '@things-factory/attachment-base'
|
|
@@ -41,7 +42,7 @@ export class ReferenceQuery {
|
|
|
41
42
|
return { data: image, name: filename, format: formatArr[formatArr.length - 1] }
|
|
42
43
|
})
|
|
43
44
|
)
|
|
44
|
-
const res = await extractInfos(files)
|
|
45
|
+
const res: any = await extractInfos(files)
|
|
45
46
|
console.log('interpretImages response', JSON.stringify(res, null, ' '))
|
|
46
47
|
return res.data?.extractInfos
|
|
47
48
|
}
|
|
@@ -49,12 +50,12 @@ export class ReferenceQuery {
|
|
|
49
50
|
return []
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
streamToString
|
|
53
|
-
const chunks = []
|
|
53
|
+
streamToString(stream) {
|
|
54
|
+
const chunks = []
|
|
54
55
|
return new Promise((resolve, reject) => {
|
|
55
|
-
stream.on('data',
|
|
56
|
-
stream.on('error',
|
|
57
|
-
stream.on('end', () => resolve(Buffer.concat(chunks).toString('base64')))
|
|
56
|
+
stream.on('data', chunk => chunks.push(Buffer.from(chunk)))
|
|
57
|
+
stream.on('error', err => reject(err))
|
|
58
|
+
stream.on('end', () => resolve(Buffer.concat(chunks).toString('base64')))
|
|
58
59
|
})
|
|
59
60
|
}
|
|
60
61
|
|
package/things-factory.config.js
CHANGED
|
@@ -12,6 +12,14 @@ export default {
|
|
|
12
12
|
tagname: 'reference-app-main',
|
|
13
13
|
page: 'reference-app-main'
|
|
14
14
|
},
|
|
15
|
+
{
|
|
16
|
+
tagname: 'operation-master',
|
|
17
|
+
page: 'operation_master'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
tagname: 'product-master',
|
|
21
|
+
page: 'product_master'
|
|
22
|
+
},
|
|
15
23
|
{
|
|
16
24
|
tagname: 'upload-page',
|
|
17
25
|
page: 'upload-page'
|
package/translations/en.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"button.generate_mockup": "Generate Mockup Data",
|
|
2
3
|
"field.company": "company",
|
|
3
4
|
"field.barcode": "barcode",
|
|
4
5
|
"field.active": "active",
|
|
@@ -7,5 +8,9 @@
|
|
|
7
8
|
"field.role": "role",
|
|
8
9
|
"field.dynamic_type": "dynamic type",
|
|
9
10
|
"field.dynamic_value": "dynamic value",
|
|
10
|
-
"
|
|
11
|
+
"label.num_samples": "Number of Samples",
|
|
12
|
+
"text.mockup data created successfully": "mockup data created successfully",
|
|
13
|
+
"text.ox-data-report-grand-total": "grand total",
|
|
14
|
+
"title.edit code": "edit code",
|
|
15
|
+
"title.generate_mockup": "Generate Mockup Data"
|
|
11
16
|
}
|
package/translations/ko.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"button.generate_mockup": "테스트 데이타 생성",
|
|
2
3
|
"field.company": "회사",
|
|
3
4
|
"field.barcode": "바코드",
|
|
4
5
|
"field.active": "활성화",
|
|
@@ -7,5 +8,10 @@
|
|
|
7
8
|
"field.role": "역할",
|
|
8
9
|
"field.dynamic_type": "변화 타입",
|
|
9
10
|
"field.dynamic_value": "변화타입 값",
|
|
10
|
-
"
|
|
11
|
+
"label.maximum value": "최대값",
|
|
12
|
+
"label.num_samples": "샘플 수",
|
|
13
|
+
"text.ox-data-report-grand-total": "총합계",
|
|
14
|
+
"text.mockup data created successfully": "테스트 데이타가 성공적으로 생성되었습니다",
|
|
15
|
+
"title.edit code": "코드 편집",
|
|
16
|
+
"title.generate_mockup": "테스트 데이타 생성"
|
|
11
17
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
2022-06-20T13:41:05+09:00 info: File Storage is Ready.
|
|
2
|
-
2022-06-20T13:41:07+09:00 info: Database connection established
|
|
3
|
-
2022-06-20T13:41:08+09:00 info: 🚀 Server ready at http://0.0.0.0:3000/graphql
|
|
4
|
-
2022-06-20T13:41:08+09:00 info: 🚀 Subscriptions ready at ws://0.0.0.0:3000/subscriptions
|