@things-factory/reference-app 6.1.93 → 6.1.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -34
- package/attachments/03e21709-60c1-4796-bb0b-9920148ce2c6.png +0 -0
- package/attachments/1c5f7b4e-45f7-47dc-94e2-6d4aa04c331d.png +0 -0
- package/attachments/29b819e1-eaf5-4998-b711-1eece872a6c6.png +0 -0
- package/attachments/5c7f2330-a93d-4c48-bcca-6b2a10974386.png +0 -0
- package/attachments/92a49294-725c-445c-8fe3-98d328d6d0a5.png +0 -0
- package/attachments/97e18c62-6e73-4407-a062-276cd25de43a.png +0 -0
- package/attachments/9c6e1599-a4e2-483e-833d-c67e336b27e5.png +0 -0
- package/attachments/9d1d12ea-0140-46cc-8eba-b1ab475bfd98.png +0 -0
- package/attachments/a727d8fa-5afe-47b3-9b29-97a1f26637f3.png +0 -0
- package/attachments/b713c6b6-15e3-4c80-a288-b0e8eba5e091.png +0 -0
- package/attachments/c5a385d9-6a96-481a-9c10-f2cb108ec525.png +0 -0
- package/attachments/c7b6e18b-fd21-49c5-8a38-9b2455957c2a.png +0 -0
- package/attachments/cfbb23dc-a61d-4898-a988-73814f509b11.jpeg +0 -0
- package/attachments/dabc0a7e-bb5b-46a3-b73c-d310c95f0832.png +0 -0
- package/attachments/dd3a00c8-1175-4329-b374-1e7096f338aa.png +0 -0
- package/attachments/f099313a-c616-4753-b2d7-33db2ac29b3b.png +0 -0
- package/attachments/f90a4af7-5555-4078-8960-2c978363ac42.png +0 -0
- package/attachments/fb5bac1e-e5c6-44d3-89fa-b0f23a4dae62.jpeg +0 -0
- package/client/tsconfig.json +0 -13
- package/config.development.js +0 -42
- package/db.sqlite +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -20
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -15
- package/logs/application-2023-08-06-10.log +0 -4
- package/logs/application-2023-08-06-19.log +0 -1
- package/logs/connections-2023-08-06-10.log +0 -0
- package/server/constants/index.ts +0 -1
- package/server/constants/type-constants.ts +0 -24
- package/server/controllers/create-data-sample-mockup.ts +0 -291
- package/server/controllers/index.ts +0 -1
- package/server/index.ts +0 -5
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -26
- package/server/service/data-sample-mockup/data-sample-mockup-mutation.ts +0 -19
- package/server/service/data-sample-mockup/data-sample-mockup-type.ts +0 -10
- package/server/service/data-sample-mockup/index.ts +0 -4
- package/server/service/index.ts +0 -19
- package/server/service/reference/index.ts +0 -5
- package/server/service/reference/lambda-call.ts +0 -71
- package/server/service/reference/reference-mutation.ts +0 -53
- package/server/service/reference/reference-query.ts +0 -79
- package/server/tsconfig.json +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/reference-app",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.96",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -67,42 +67,42 @@
|
|
|
67
67
|
"@operato/scene-tab": "^1.0.0",
|
|
68
68
|
"@operato/shell": "^1.0.1",
|
|
69
69
|
"@operato/utils": "^1.0.1",
|
|
70
|
-
"@things-factory/api": "^6.1.
|
|
71
|
-
"@things-factory/apptool-ui": "^6.1.
|
|
72
|
-
"@things-factory/attachment-base": "^6.1.
|
|
73
|
-
"@things-factory/auth-ui": "^6.1.
|
|
74
|
-
"@things-factory/board-service": "^6.1.
|
|
75
|
-
"@things-factory/board-ui": "^6.1.
|
|
76
|
-
"@things-factory/ccp": "^6.1.
|
|
77
|
-
"@things-factory/contact": "^6.1.
|
|
78
|
-
"@things-factory/context-ui": "^6.1.
|
|
79
|
-
"@things-factory/dashboard": "^6.1.
|
|
80
|
-
"@things-factory/dataset": "^6.1.
|
|
81
|
-
"@things-factory/export-ui": "^6.1.
|
|
82
|
-
"@things-factory/export-ui-excel": "^6.1.
|
|
83
|
-
"@things-factory/help": "^6.1.
|
|
84
|
-
"@things-factory/integration-ui": "^6.1.
|
|
85
|
-
"@things-factory/lite-menu": "^6.1.
|
|
86
|
-
"@things-factory/more-ui": "^6.1.
|
|
87
|
-
"@things-factory/notification": "^6.1.
|
|
88
|
-
"@things-factory/oauth2-client": "^6.1.
|
|
89
|
-
"@things-factory/organization": "^6.1.
|
|
90
|
-
"@things-factory/print-ui": "^6.1.
|
|
91
|
-
"@things-factory/product-base": "^6.1.
|
|
92
|
-
"@things-factory/qc": "^6.1.
|
|
93
|
-
"@things-factory/resource-ui": "^6.1.
|
|
94
|
-
"@things-factory/routing-base": "^6.1.
|
|
95
|
-
"@things-factory/setting-base": "^6.1.
|
|
96
|
-
"@things-factory/setting-ui": "^6.1.
|
|
97
|
-
"@things-factory/shell": "^6.1.
|
|
98
|
-
"@things-factory/system-ui": "^6.1.
|
|
99
|
-
"@things-factory/web-editor": "^6.1.
|
|
100
|
-
"@things-factory/work-shift": "^6.1.
|
|
70
|
+
"@things-factory/api": "^6.1.96",
|
|
71
|
+
"@things-factory/apptool-ui": "^6.1.96",
|
|
72
|
+
"@things-factory/attachment-base": "^6.1.96",
|
|
73
|
+
"@things-factory/auth-ui": "^6.1.96",
|
|
74
|
+
"@things-factory/board-service": "^6.1.96",
|
|
75
|
+
"@things-factory/board-ui": "^6.1.96",
|
|
76
|
+
"@things-factory/ccp": "^6.1.96",
|
|
77
|
+
"@things-factory/contact": "^6.1.96",
|
|
78
|
+
"@things-factory/context-ui": "^6.1.96",
|
|
79
|
+
"@things-factory/dashboard": "^6.1.96",
|
|
80
|
+
"@things-factory/dataset": "^6.1.96",
|
|
81
|
+
"@things-factory/export-ui": "^6.1.96",
|
|
82
|
+
"@things-factory/export-ui-excel": "^6.1.96",
|
|
83
|
+
"@things-factory/help": "^6.1.96",
|
|
84
|
+
"@things-factory/integration-ui": "^6.1.96",
|
|
85
|
+
"@things-factory/lite-menu": "^6.1.96",
|
|
86
|
+
"@things-factory/more-ui": "^6.1.96",
|
|
87
|
+
"@things-factory/notification": "^6.1.96",
|
|
88
|
+
"@things-factory/oauth2-client": "^6.1.96",
|
|
89
|
+
"@things-factory/organization": "^6.1.96",
|
|
90
|
+
"@things-factory/print-ui": "^6.1.96",
|
|
91
|
+
"@things-factory/product-base": "^6.1.96",
|
|
92
|
+
"@things-factory/qc": "^6.1.96",
|
|
93
|
+
"@things-factory/resource-ui": "^6.1.96",
|
|
94
|
+
"@things-factory/routing-base": "^6.1.96",
|
|
95
|
+
"@things-factory/setting-base": "^6.1.96",
|
|
96
|
+
"@things-factory/setting-ui": "^6.1.96",
|
|
97
|
+
"@things-factory/shell": "^6.1.96",
|
|
98
|
+
"@things-factory/system-ui": "^6.1.96",
|
|
99
|
+
"@things-factory/web-editor": "^6.1.96",
|
|
100
|
+
"@things-factory/work-shift": "^6.1.96",
|
|
101
101
|
"@tinymce/tinymce-webcomponent": "^2.0.1",
|
|
102
102
|
"random-words": "^1.2.0"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@things-factory/builder": "^6.1.
|
|
105
|
+
"@things-factory/builder": "^6.1.96"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "535ca1d403d6c2d6e25314ece79f4b77d877c75b"
|
|
108
108
|
}
|
|
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
|
package/client/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig-base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"experimentalDecorators": true,
|
|
5
|
-
"strict": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"module": "esnext",
|
|
9
|
-
"outDir": "../dist-client",
|
|
10
|
-
"baseUrl": "./"
|
|
11
|
-
},
|
|
12
|
-
"include": ["./**/*"]
|
|
13
|
-
}
|
package/config.development.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
subdomain: 'system',
|
|
3
|
-
awsAppSync: {
|
|
4
|
-
apiUrl: '',
|
|
5
|
-
apiKey: ''
|
|
6
|
-
},
|
|
7
|
-
raygun: {
|
|
8
|
-
// apiKey: 'VvPzjH0zKdOM0hynpycw'
|
|
9
|
-
},
|
|
10
|
-
notification: {
|
|
11
|
-
fcm: {
|
|
12
|
-
serviceAccount: {
|
|
13
|
-
type: 'service_account',
|
|
14
|
-
project_id: 'reference-webapp',
|
|
15
|
-
private_key_id: '18328f14baf6b9e5b5138f545d12b8ae23bba0e7',
|
|
16
|
-
private_key:
|
|
17
|
-
'-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCdQsuxIAhkwEiY\nDvwyOw1u1VpDSy6jLw2wVvkGW6W3jUX1FJ82c+1/6TsfeNZ03SSGZQOVle9NMUpg\n0hLkL7hiwEO5qd0Q5V2AOTtoGp4tPyiANupx8VCosus9OvReLJdOySeDMoYY2hBw\ndseac2rMeAmJjLyhf+vMn1G6VMLwrLAlisaK7BKUvcVahNeT6FIIG0n3yU++BTm0\n9hHQFYKccWAVHmeCi10PVpGixhDEA4DWG4M3W4HfuoFonxFcU55FKncS2q4N3MnQ\nsLN+PLvtrFwb04YCoVS/Sh/qRC+7wce81dBjKlZmjnZjg6vuo2W8+1xSz1RbjJ8T\ne4Dt039hAgMBAAECggEAC+Myto7vU35dfnETi1B/cXNbQV77hYZXCI9qf5qJ6lgZ\ng68tYdZdi5+7wmNGAst8qVQVc0dEMZeaQbtfhjQ9Qem6tNwsQ8yyxrCM1w+8CTuO\n+jIsgrR1Hmt38Mb2FfBU97Wo8Pfuvw4s0/OGnxw+ZHpmbilfUO30iyE38lfZ7Iti\nybLGI6+QVXEi4LVHV9I3LeD7vzu/EYSHoTuPsPRjf6hB1ON9NxPioCxD8yimZ5ZQ\nvVL7vtLi2IqFbZHy6RUnBWQMmcuqrVzhUmRKU+2CxsGOpj/am0wo3OmP43sWOzs6\nVF83xX9JFl71u9kYQXm8JUEK+98t3AO8TeBEGCDU4QKBgQDbE3GdtFZPuUeIfHUO\n7EiXNHds5FQG8DkQpCpfO6+jrpF5AqsL//NwF6GOW1w+COp1KnR5uN0ImKsk5G4s\n4w/j1xonPhc4o4j+gzVfS0fA7pF7oDrLd23bxxCLLTylFSZdMpQ/4bbAIirl6wev\ndXgIMd7CufDgtPoTani7dOpXlQKBgQC3xDHD8a2iWmdxK8X9GaSJHC8Ysr95hSmi\nNH5X6hJXBT6ZMI+RHrMfS+RXVTs8CHhr6KTPuyDa3s/NXundmWdGi6uLk26VTCv3\n/ONdsjCuS+CeJD04DjXXYHvkDtU5gQPtMjl+5in4klAhBEZx9ChI0nc580rhc29J\nVDvSk9ZlnQKBgA2kU1HftfQ29GZiYaOxQP/xa3JjcXwRH2yS3HSbsd8+cp6XdPFF\nWfJj9lJ4C/Fs+rSbFS+zPEhZwWaFtvqilQ26Ck3hRu7m+BPpNbyeYnR4JqUNIDwl\nTrj912DjS0B4ZbAuAx9LPecO+Z7hmNPrO7M+78EudPp5Ko1k9umtaR5VAoGAeimL\n57WO9yHgKESwPrxAPAGncWTKkw8qCTGaV/k8LetHnPDCT/e3nfOGnWQEl7kNzLaA\ncbP1eGqse9s/3teu5x/Mb2IYHlnf1OChiVT+ta+tZ5OxusT/l+kFEyulJbAVmyZL\nQIfjmOIzMG+2IOTtrtNy/Ow2eD+T2IyNpEQxP6UCgYBIcC1e5tvrmbqtwo9DYjZj\nZRCvC1ppcoU3IJJQAgDziX/P4g+8PPkS+AOQxFS7hycDYRYy06cfvZnUk7KB0zv7\nGg+viPnuG/88LgpBG5aQ0PIyzaIRybMQYvUNg+clW9+VXh2tGOV1yjBJc1O3ASea\ncpnh46+ngSVKgtVkyL0GJg==\n-----END PRIVATE KEY-----\n',
|
|
18
|
-
client_email: 'firebase-adminsdk-c09d4@reference-webapp.iam.gserviceaccount.com',
|
|
19
|
-
client_id: '104201695264057062194',
|
|
20
|
-
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
|
|
21
|
-
token_uri: 'https://oauth2.googleapis.com/token',
|
|
22
|
-
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
|
|
23
|
-
client_x509_cert_url:
|
|
24
|
-
'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-c09d4%40reference-webapp.iam.gserviceaccount.com'
|
|
25
|
-
},
|
|
26
|
-
appConfig: {
|
|
27
|
-
apiKey: 'AIzaSyCCNsYExBY35aeeNqX0KkJgh9VdQDv4W-o',
|
|
28
|
-
authDomain: 'reference-webapp.firebaseapp.com',
|
|
29
|
-
projectId: 'reference-webapp',
|
|
30
|
-
storageBucket: 'reference-webapp.appspot.com',
|
|
31
|
-
messagingSenderId: '224894233495',
|
|
32
|
-
appId: '1:224894233495:web:79d5d957dc74a7f757f2d2',
|
|
33
|
-
measurementId: 'G-5M6X2DLNYJ'
|
|
34
|
-
},
|
|
35
|
-
serverKey:
|
|
36
|
-
'AAAANFy9q5c:APA91bFDOIRNKAZZdwa9YnPnZM9kTGUDhfg1u6wvO9-KuBT3E2GXISLOvm5S7vSb8U0-zMsts2UrCPVNbvKWU_IhH5Fa4thvSUrU8eyJPUt-qpO-LP6Dx595pW_mNUVssCoEhqHuEbc5'
|
|
37
|
-
},
|
|
38
|
-
vapidKey: {
|
|
39
|
-
publicKey: 'BNHIscoiA5FW3-gnqI09_ESEfFEHmjDSkItsgMBBzSy69sFC4shKphLhTY00ynD6mBzbaW5t51ir7WCrDGD07Pw'
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
package/db.sqlite
DELETED
|
Binary file
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"keep": {
|
|
3
|
-
"days": true,
|
|
4
|
-
"amount": 2
|
|
5
|
-
},
|
|
6
|
-
"auditLog": "logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json",
|
|
7
|
-
"files": [
|
|
8
|
-
{
|
|
9
|
-
"date": 1691316687973,
|
|
10
|
-
"name": "logs/application-2023-08-06-19.log",
|
|
11
|
-
"hash": "e6f6d94ba91a160cf014937a74d524d8a97bc3874e0b9334a2b1de86f7c91788"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"date": 1691316689488,
|
|
15
|
-
"name": "logs/application-2023-08-06-10.log",
|
|
16
|
-
"hash": "c592a34bf824e62642cd14f6e60c91e2374ae2a6c75662a8e7b152858c0f923b"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"hashType": "sha256"
|
|
20
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"keep": {
|
|
3
|
-
"days": true,
|
|
4
|
-
"amount": 14
|
|
5
|
-
},
|
|
6
|
-
"auditLog": "logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json",
|
|
7
|
-
"files": [
|
|
8
|
-
{
|
|
9
|
-
"date": 1691316689352,
|
|
10
|
-
"name": "logs/connections-2023-08-06-10.log",
|
|
11
|
-
"hash": "3bedc4d5dfdea0fbf2b9c72d3c8c98f745362ec2268fdcb7ee2220400848b419"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"hashType": "sha256"
|
|
15
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
2023-08-06T19:11:29+09:00 error: oracledb module loading failed
|
|
2
|
-
2023-08-06T19:11:30+09:00 info: Default DataSource established
|
|
3
|
-
2023-08-06T19:11:31+09:00 info: 🚀 Server ready at http://0.0.0.0:3000/graphql
|
|
4
|
-
2023-08-06T19:11:31+09:00 info: 🚀 Subscriptions ready at ws://0.0.0.0:3000/graphql
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2023-08-06T19:11:28+09:00 info: File Storage is Ready.
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './type-constants'
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inventory Type
|
|
3
|
-
*/
|
|
4
|
-
export const ROH_INVENTORY = 'ROH'
|
|
5
|
-
export const FINISHED_INVENTORY = 'FINISHED'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Product Type
|
|
9
|
-
*/
|
|
10
|
-
export const PRODUCT_TYPE = {
|
|
11
|
-
FERT: '완제품',
|
|
12
|
-
HALB: '반제품',
|
|
13
|
-
ROH: '원자재'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Warehouse Type
|
|
18
|
-
*/
|
|
19
|
-
export const WAREHOUSE_TYPE = {
|
|
20
|
-
FINISHED: '완제품',
|
|
21
|
-
HALF_COLD: '반제품(냉장)',
|
|
22
|
-
HALF_FROZEN: '반제품(냉동)',
|
|
23
|
-
ROH: '원자재'
|
|
24
|
-
}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import moment from 'moment-timezone'
|
|
2
|
-
import { EntityManager } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { DataSample, DataSet, 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
|
-
process.env.TZ = 'UTC'
|
|
14
|
-
const randomWords = require('random-words')
|
|
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
|
-
|
|
27
|
-
// parse variable javascript string pattern
|
|
28
|
-
const replaceVariables = (keys, dic) => {
|
|
29
|
-
for (const k in keys) {
|
|
30
|
-
const matches = keys[k].match(/\$\{\w*\}/g)
|
|
31
|
-
matches &&
|
|
32
|
-
matches.forEach(m => {
|
|
33
|
-
keys[k] = keys[k].replace(m, dic[m.slice(2, -1)])
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
return keys
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// It is required UTC date for Partitioning File System like AWS S3 from Athena.
|
|
40
|
-
// ex) %YYYY, %MM, %DD
|
|
41
|
-
const formatDate = (keys, _moment) => {
|
|
42
|
-
for (const k in keys) {
|
|
43
|
-
const matches = keys[k].match(/%\w*/g)
|
|
44
|
-
matches &&
|
|
45
|
-
matches.forEach(m => {
|
|
46
|
-
keys[k] = keys[k].replace(m, _moment.format(m.substr(1)))
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
return keys
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Normal Distribution
|
|
54
|
-
* https://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve
|
|
55
|
-
*/
|
|
56
|
-
function normal_dist(min, max, skew) {
|
|
57
|
-
let u = 0,
|
|
58
|
-
v = 0
|
|
59
|
-
while (u === 0) u = Math.random() //Converting [0,1) to (0,1)
|
|
60
|
-
while (v === 0) v = Math.random()
|
|
61
|
-
let num = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v)
|
|
62
|
-
|
|
63
|
-
num = num / 10.0 + 0.5 // Translate to 0 -> 1
|
|
64
|
-
if (num > 1 || num < 0) num = normal_dist(min, max, skew) // resample between 0 and 1 if out of range
|
|
65
|
-
else {
|
|
66
|
-
num = Math.pow(num, skew) // Skew
|
|
67
|
-
num *= max - min // Stretch to fill range
|
|
68
|
-
num += min // offset to min
|
|
69
|
-
}
|
|
70
|
-
return num
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function randomIndex(max = 2) {
|
|
74
|
-
return Math.floor(Math.random() * max)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function fillColumns(prev, next, dict) {
|
|
78
|
-
let values = []
|
|
79
|
-
try {
|
|
80
|
-
const gap = 20
|
|
81
|
-
const timeFormat = 'HH:mm'
|
|
82
|
-
const dateFormat = 'YYYY-MM-DD'
|
|
83
|
-
const atFormat = 'YYYY-MM-DD HH:mm:ss'
|
|
84
|
-
const now = moment()
|
|
85
|
-
const { type, spec, quota } = next
|
|
86
|
-
const isValidSpec = spec && Object.keys(spec).length
|
|
87
|
-
const arr = Array.from(Array(quota).keys())
|
|
88
|
-
|
|
89
|
-
if (type == 'number') {
|
|
90
|
-
if (isValidSpec) {
|
|
91
|
-
/* generate values refer to spec info. */
|
|
92
|
-
const {
|
|
93
|
-
CCP: {
|
|
94
|
-
criticalLimits: { minimum, maximum }
|
|
95
|
-
}
|
|
96
|
-
} = spec
|
|
97
|
-
while (values.length < quota) {
|
|
98
|
-
let value = 0
|
|
99
|
-
if (typeof minimum === 'number' && typeof maximum === 'number') {
|
|
100
|
-
value = Math.floor(normal_dist(minimum, maximum, 1))
|
|
101
|
-
} else if (typeof minimum === 'number' && typeof maximum !== 'number') {
|
|
102
|
-
const max = minimum + gap
|
|
103
|
-
value = Math.floor(normal_dist(minimum, max, 1))
|
|
104
|
-
} else if (typeof minimum !== 'number' && typeof maximum === 'number') {
|
|
105
|
-
const min = maximum - gap
|
|
106
|
-
value = Math.floor(normal_dist(min, maximum, 1))
|
|
107
|
-
}
|
|
108
|
-
values.push(value)
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
/* random number */
|
|
112
|
-
const p = Math.random()
|
|
113
|
-
const q = () => randomIndex(10) + 1
|
|
114
|
-
// fixed
|
|
115
|
-
if (p > 0.33) {
|
|
116
|
-
values = Array(quota).fill(q())
|
|
117
|
-
} else if (p > 0.66) {
|
|
118
|
-
/* or random */
|
|
119
|
-
values = arr.map(i => q())
|
|
120
|
-
} else {
|
|
121
|
-
/* or incremental */
|
|
122
|
-
values = arr.reduce((prev, i) => {
|
|
123
|
-
prev.push(!!prev.length ? prev[0] + i : q())
|
|
124
|
-
return prev
|
|
125
|
-
}, [])
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
} else if (type == 'select') {
|
|
129
|
-
const options = next['options']['options']
|
|
130
|
-
values = arr.map(i => options[randomIndex(options.length)]['value'])
|
|
131
|
-
} else if (type == 'boolean') {
|
|
132
|
-
values = arr.map(i => !!randomIndex())
|
|
133
|
-
} else if (next['tag'].toLowerCase().indexOf('time') >= 0) {
|
|
134
|
-
/* ex) startTime => 09:21 */
|
|
135
|
-
arr.reduce(curr => {
|
|
136
|
-
values.push(curr.format(timeFormat))
|
|
137
|
-
curr.add(randomIndex(60), 'minutes')
|
|
138
|
-
return curr
|
|
139
|
-
}, now)
|
|
140
|
-
} else if (next['tag'].indexOf('edAt') > 0) {
|
|
141
|
-
/* ex) createdAt => '2022-06-15 09:21:30 */
|
|
142
|
-
arr.reduce(curr => {
|
|
143
|
-
values.push(curr.format(atFormat))
|
|
144
|
-
curr.add(randomIndex(12), 'hours')
|
|
145
|
-
return curr
|
|
146
|
-
}, now)
|
|
147
|
-
} else if (next['tag'].toLowerCase().indexOf('date') > 0) {
|
|
148
|
-
/* ex) startDate => '2022-06-15 */
|
|
149
|
-
arr.reduce(curr => {
|
|
150
|
-
values.push(curr.format(dateFormat))
|
|
151
|
-
curr.add(randomIndex(7), 'days')
|
|
152
|
-
return curr
|
|
153
|
-
}, now)
|
|
154
|
-
} else if (dict.hasOwnProperty(next['tag'])) {
|
|
155
|
-
values = Array(quota).fill(dict[next['tag']])
|
|
156
|
-
} else {
|
|
157
|
-
if (type == 'text') {
|
|
158
|
-
values = randomWords(quota)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
} finally {
|
|
162
|
-
prev[next['tag']] = values
|
|
163
|
-
return prev
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async function _generateMockupData(dataSources: any, tx: EntityManager) {
|
|
168
|
-
const { user, domain, dataSet, spec, products, operations } = dataSources
|
|
169
|
-
|
|
170
|
-
const collectedAt = new Date()
|
|
171
|
-
|
|
172
|
-
const timezone = dataSet.timezone || domain.timezone || 'UTC'
|
|
173
|
-
const format = 'YYYY-MM-DD'
|
|
174
|
-
|
|
175
|
-
// workDate ex) 2022-04-04
|
|
176
|
-
const { workDate, workShift } = await getWorkDateAndShift(domain, collectedAt, { timezone, format })
|
|
177
|
-
|
|
178
|
-
// local time dataSet timezone or domain timezone or default 'UTC'
|
|
179
|
-
|
|
180
|
-
// const collectedAt = dataSample.collectedAt || new Date()
|
|
181
|
-
const localDateTz = moment(collectedAt).tz(timezone)
|
|
182
|
-
const defaultPartitionKeys = {
|
|
183
|
-
domain: domain.subdomain,
|
|
184
|
-
datasetid: dataSet.id /* It should not be 'data_set_id' as column name duplicated for Glue */,
|
|
185
|
-
date: localDateTz.format(format) /* local time date */,
|
|
186
|
-
workdate: workDate /* working date */,
|
|
187
|
-
workshift: workShift
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
var partitionKeys = {
|
|
191
|
-
...defaultPartitionKeys,
|
|
192
|
-
...dataSet.partitionKeys
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// get product, operation as a map
|
|
196
|
-
const oper = operations[Math.floor(Math.random() * operations.length)]
|
|
197
|
-
const prod = products[Math.floor(Math.random() * products.length)]
|
|
198
|
-
const dict = {
|
|
199
|
-
operation: oper['name'],
|
|
200
|
-
operationId: oper['id'],
|
|
201
|
-
product: prod['name'],
|
|
202
|
-
productId: prod['id']
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const sample = dataSet.dataItems.reduce((prev, next) => fillColumns(prev, next, dict), {})
|
|
206
|
-
|
|
207
|
-
partitionKeys = formatDate(partitionKeys, localDateTz)
|
|
208
|
-
partitionKeys = replaceVariables(partitionKeys, {
|
|
209
|
-
...sample
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
const dataKeys = fillDataKeys(dataSet?.dataKeySet, sample)
|
|
213
|
-
|
|
214
|
-
const { ooc, oos, judgment } = DataUseCase.evaluate(dataSet, dataSet.dataItems, sample) || {}
|
|
215
|
-
const result = await tx.getRepository(DataSample).save({
|
|
216
|
-
name: dataSet.name,
|
|
217
|
-
description: dataSet.description,
|
|
218
|
-
useCase: dataSet.useCase,
|
|
219
|
-
type: dataSet.type,
|
|
220
|
-
dataSet: dataSet,
|
|
221
|
-
dataSetVersion: dataSet.version,
|
|
222
|
-
data: sample,
|
|
223
|
-
domain,
|
|
224
|
-
partitionKeys,
|
|
225
|
-
...dataKeys,
|
|
226
|
-
spec,
|
|
227
|
-
ooc,
|
|
228
|
-
oos,
|
|
229
|
-
judgment,
|
|
230
|
-
collectedAt,
|
|
231
|
-
workDate,
|
|
232
|
-
workShift,
|
|
233
|
-
creator: user,
|
|
234
|
-
updater: user
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
return true
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export async function generateMockupData(
|
|
241
|
-
params: DataSampleMockupInfo,
|
|
242
|
-
context: {
|
|
243
|
-
state: {
|
|
244
|
-
domain: Domain
|
|
245
|
-
user: User
|
|
246
|
-
tx: EntityManager
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
): Promise<Boolean> {
|
|
250
|
-
const { domain, user, tx } = context.state
|
|
251
|
-
|
|
252
|
-
const dataSet: DataSet = await tx.getRepository(DataSet).findOne({
|
|
253
|
-
where: { id: params.dataSetId },
|
|
254
|
-
relations: ['dataKeySet']
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
const products = await tx.getRepository(Product).find({
|
|
258
|
-
select: ['id', 'name', 'description'],
|
|
259
|
-
where: {
|
|
260
|
-
domain: { id: domain.id }
|
|
261
|
-
}
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
const operations = await tx.getRepository(Operation).find({
|
|
265
|
-
select: ['id', 'name', 'description'],
|
|
266
|
-
where: {
|
|
267
|
-
domain: { id: domain.id }
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
const dataItems = dataSet.dataItems
|
|
272
|
-
|
|
273
|
-
const spec = dataItems.reduce((spec, dataItem) => {
|
|
274
|
-
spec[dataItem.tag] = {
|
|
275
|
-
...dataItem.spec,
|
|
276
|
-
name: dataItem.name /* do we need ? */,
|
|
277
|
-
hidden: dataItem.hidden
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return spec
|
|
281
|
-
}, {})
|
|
282
|
-
|
|
283
|
-
const promises = Array(params.numSamples)
|
|
284
|
-
.fill(0)
|
|
285
|
-
.map(x => {
|
|
286
|
-
return _generateMockupData({ domain, user, dataSet, products, operations, spec }, tx)
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
await Promise.all(promises)
|
|
290
|
-
return true
|
|
291
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './create-data-sample-mockup'
|
package/server/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const glob = require('glob')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
export var migrations = []
|
|
5
|
-
|
|
6
|
-
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
-
if (file.indexOf('index.js') !== -1) return
|
|
8
|
-
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
-
})
|
package/server/routes.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
2
|
-
/*
|
|
3
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
4
|
-
*
|
|
5
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
6
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
7
|
-
*/
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
|
|
11
|
-
/*
|
|
12
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
13
|
-
*/
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
|
|
17
|
-
/*
|
|
18
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
19
|
-
*/
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
23
|
-
/*
|
|
24
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
25
|
-
*/
|
|
26
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
@Resolver(DataSample)
|
|
9
|
-
export class DataSampleMockupMutation {
|
|
10
|
-
@Directive('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)')
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Mutation(returns => Boolean, { description: 'To generate data sample one' })
|
|
13
|
-
async generateMockupData(
|
|
14
|
-
@Arg('params') params: DataSampleMockupInfo,
|
|
15
|
-
@Ctx() context: ResolverContext
|
|
16
|
-
): Promise<Boolean> {
|
|
17
|
-
return await generateMockupData(params, context)
|
|
18
|
-
}
|
|
19
|
-
}
|