@things-factory/ccp 5.0.0-alpha.13 → 5.0.0-alpha.14

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.
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataUseCaseCCP = void 0;
4
+ class DataUseCaseCCP {
5
+ getSpecification() {
6
+ return {
7
+ name: 'CCP',
8
+ description: 'Critical Control Point Data Spec',
9
+ help: '',
10
+ specs: [
11
+ {
12
+ type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
13
+ label: 'critical-limits',
14
+ name: 'criticalLimits'
15
+ },
16
+ {
17
+ type: 'ccp-limits',
18
+ label: 'target-limits',
19
+ name: 'targetLimits'
20
+ }
21
+ ]
22
+ };
23
+ }
24
+ evaluate(spec, values) {
25
+ if (!spec || typeof values === 'undefined') {
26
+ return;
27
+ }
28
+ if (!(values instanceof Array)) {
29
+ values = [values];
30
+ }
31
+ const { minimum: criticalMinimum, maximum: criticalMaximum, acceptables: criticalAcceptables } = spec['criticalLimits'] || {};
32
+ const { minimum: targetMinimum, maximum: targetMaximum, acceptables: targetAcceptables } = spec['targetLimits'] || {};
33
+ var oos = false;
34
+ var ooc = false;
35
+ for (let i = 0; i < values.length; i++) {
36
+ const value = values[i];
37
+ if (typeof criticalMinimum !== 'undefined' && value < criticalMinimum) {
38
+ oos = true;
39
+ break;
40
+ }
41
+ if (typeof criticalMaximum !== 'undefined' && value > criticalMaximum) {
42
+ oos = true;
43
+ break;
44
+ }
45
+ if (typeof criticalAcceptables !== 'undefined' && criticalAcceptables.includes(value)) {
46
+ oos = true;
47
+ break;
48
+ }
49
+ }
50
+ for (let i = 0; i < values.length; i++) {
51
+ const value = values[i];
52
+ if (typeof targetMinimum !== 'undefined' && value < targetMinimum) {
53
+ ooc = true;
54
+ break;
55
+ }
56
+ if (typeof targetMaximum !== 'undefined' && value > targetMaximum) {
57
+ ooc = true;
58
+ break;
59
+ }
60
+ if (typeof targetAcceptables !== 'undefined' && targetAcceptables.includes(value)) {
61
+ ooc = true;
62
+ break;
63
+ }
64
+ }
65
+ return { oos, ooc };
66
+ }
67
+ }
68
+ exports.DataUseCaseCCP = DataUseCaseCCP;
69
+ //# sourceMappingURL=data-use-case-ccp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-use-case-ccp.js","sourceRoot":"","sources":["../../server/controllers/data-use-case-ccp.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IACzB,gBAAgB;QACd,OAAO;YACL,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,EAAE;YACR,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,YAAY,CAAC,gEAAgE;oBACnF,KAAK,EAAE,iBAAiB;oBACxB,IAAI,EAAE,gBAAgB;iBACvB;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,KAAK,EAAE,eAAe;oBACtB,IAAI,EAAE,cAAc;iBACrB;aACF;SACF,CAAA;IACH,CAAC;IAED,QAAQ,CAAC,IAAS,EAAE,MAAmB;QACrC,IAAI,CAAC,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAC1C,OAAM;SACP;QAED,IAAI,CAAC,CAAC,MAAM,YAAY,KAAK,CAAC,EAAE;YAC9B,MAAM,GAAG,CAAC,MAAM,CAAC,CAAA;SAClB;QAED,MAAM,EACJ,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,mBAAmB,EACjC,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAA;QAEhC,MAAM,EACJ,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,iBAAiB,EAC/B,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;QAE9B,IAAI,GAAG,GAAG,KAAK,CAAA;QACf,IAAI,GAAG,GAAG,KAAK,CAAA;QAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YAEvB,IAAI,OAAO,eAAe,KAAK,WAAW,IAAI,KAAK,GAAG,eAAe,EAAE;gBACrE,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;YAED,IAAI,OAAO,eAAe,KAAK,WAAW,IAAI,KAAK,GAAG,eAAe,EAAE;gBACrE,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;YAED,IAAI,OAAO,mBAAmB,KAAK,WAAW,IAAI,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACrF,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;SACF;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YAEvB,IAAI,OAAO,aAAa,KAAK,WAAW,IAAI,KAAK,GAAG,aAAa,EAAE;gBACjE,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;YAED,IAAI,OAAO,aAAa,KAAK,WAAW,IAAI,KAAK,GAAG,aAAa,EAAE;gBACjE,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;YAED,IAAI,OAAO,iBAAiB,KAAK,WAAW,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACjF,GAAG,GAAG,IAAI,CAAA;gBACV,MAAK;aACN;SACF;QAED,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;IACrB,CAAC;CACF;AArFD,wCAqFC"}
@@ -1 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./data-use-case-ccp"), exports);
1
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC"}
@@ -18,8 +18,8 @@ __exportStar(require("./migrations"), exports);
18
18
  __exportStar(require("./middlewares"), exports);
19
19
  require("./routes");
20
20
  const dataset_1 = require("@things-factory/dataset");
21
- const ccp_data_spec_1 = require("./controllers/ccp-data-spec");
21
+ const controllers_1 = require("./controllers");
22
22
  process.on('bootstrap-module-start', async ({ app, config, schema }) => {
23
- dataset_1.DataSpecManager.registerDataSpec('ccp', ccp_data_spec_1.CCP_DATA_SPEC);
23
+ dataset_1.DataUseCase.registerUseCase('CCP', new controllers_1.DataUseCaseCCP());
24
24
  });
25
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,gDAA6B;AAE7B,oBAAiB;AAEjB,qDAAyD;AACzD,+DAA2D;AAE3D,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,yBAAe,CAAC,gBAAgB,CAAC,KAAK,EAAE,6BAAa,CAAC,CAAA;AACxD,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,gDAA6B;AAE7B,oBAAiB;AAEjB,qDAAqD;AACrD,+CAA8C;AAE9C,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,qBAAW,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,4BAAc,EAAE,CAAC,CAAA;AAC1D,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/ccp",
3
- "version": "5.0.0-alpha.13",
3
+ "version": "5.0.0-alpha.14",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,10 +24,10 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@operato/ccp": "^1.0.0-alpha.33",
28
- "@operato/dataset": "^1.0.0-alpha.33",
29
- "@things-factory/dataset": "^5.0.0-alpha.13",
30
- "@things-factory/shell": "^5.0.0-alpha.13"
27
+ "@operato/ccp": "^1.0.0-alpha.34",
28
+ "@operato/dataset": "^1.0.0-alpha.34",
29
+ "@things-factory/dataset": "^5.0.0-alpha.14",
30
+ "@things-factory/shell": "^5.0.0-alpha.14"
31
31
  },
32
- "gitHead": "49704052461599b174959ff494abb9ef1facd887"
32
+ "gitHead": "e64e66b147eca1d3219fed7d9764fe2a221a5569"
33
33
  }
@@ -0,0 +1,88 @@
1
+ import { DataItemSpecSet, DataUseCase, EvaluationResult } from '@things-factory/dataset'
2
+
3
+ export class DataUseCaseCCP implements DataUseCase {
4
+ getSpecification(): DataItemSpecSet {
5
+ return {
6
+ name: 'CCP',
7
+ description: 'Critical Control Point Data Spec',
8
+ help: '',
9
+ specs: [
10
+ {
11
+ type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
12
+ label: 'critical-limits',
13
+ name: 'criticalLimits'
14
+ },
15
+ {
16
+ type: 'ccp-limits',
17
+ label: 'target-limits',
18
+ name: 'targetLimits'
19
+ }
20
+ ]
21
+ }
22
+ }
23
+
24
+ evaluate(spec: any, values: any | any[]): EvaluationResult {
25
+ if (!spec || typeof values === 'undefined') {
26
+ return
27
+ }
28
+
29
+ if (!(values instanceof Array)) {
30
+ values = [values]
31
+ }
32
+
33
+ const {
34
+ minimum: criticalMinimum,
35
+ maximum: criticalMaximum,
36
+ acceptables: criticalAcceptables
37
+ } = spec['criticalLimits'] || {}
38
+
39
+ const {
40
+ minimum: targetMinimum,
41
+ maximum: targetMaximum,
42
+ acceptables: targetAcceptables
43
+ } = spec['targetLimits'] || {}
44
+
45
+ var oos = false
46
+ var ooc = false
47
+
48
+ for (let i = 0; i < values.length; i++) {
49
+ const value = values[i]
50
+
51
+ if (typeof criticalMinimum !== 'undefined' && value < criticalMinimum) {
52
+ oos = true
53
+ break
54
+ }
55
+
56
+ if (typeof criticalMaximum !== 'undefined' && value > criticalMaximum) {
57
+ oos = true
58
+ break
59
+ }
60
+
61
+ if (typeof criticalAcceptables !== 'undefined' && criticalAcceptables.includes(value)) {
62
+ oos = true
63
+ break
64
+ }
65
+ }
66
+
67
+ for (let i = 0; i < values.length; i++) {
68
+ const value = values[i]
69
+
70
+ if (typeof targetMinimum !== 'undefined' && value < targetMinimum) {
71
+ ooc = true
72
+ break
73
+ }
74
+
75
+ if (typeof targetMaximum !== 'undefined' && value > targetMaximum) {
76
+ ooc = true
77
+ break
78
+ }
79
+
80
+ if (typeof targetAcceptables !== 'undefined' && targetAcceptables.includes(value)) {
81
+ ooc = true
82
+ break
83
+ }
84
+ }
85
+
86
+ return { oos, ooc }
87
+ }
88
+ }
@@ -0,0 +1 @@
1
+ export * from './data-use-case-ccp'
package/server/index.ts CHANGED
@@ -3,9 +3,9 @@ export * from './middlewares'
3
3
 
4
4
  import './routes'
5
5
 
6
- import { DataSpecManager } from '@things-factory/dataset'
7
- import { CCP_DATA_SPEC } from './controllers/ccp-data-spec'
6
+ import { DataUseCase } from '@things-factory/dataset'
7
+ import { DataUseCaseCCP } from './controllers'
8
8
 
9
9
  process.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {
10
- DataSpecManager.registerDataSpec('ccp', CCP_DATA_SPEC)
10
+ DataUseCase.registerUseCase('CCP', new DataUseCaseCCP())
11
11
  })
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CCP_DATA_SPEC = void 0;
4
- exports.CCP_DATA_SPEC = {
5
- name: 'CCP',
6
- description: 'Critical Control Point Data Spec',
7
- help: '',
8
- specItems: [
9
- {
10
- type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
11
- label: 'critical-limits',
12
- name: 'criticalLimits',
13
- placeholder: '식품안전 확보를 위해 한계 이내로 관리되어야 하는 이론적 한계기준',
14
- property: {}
15
- },
16
- {
17
- type: 'ccp-limits',
18
- label: 'target-limits',
19
- name: 'targetLimits',
20
- placeholder: '한계기준에 현장운영시의 안전관리 수치를 더한 초과 기준',
21
- property: {}
22
- }
23
- ]
24
- };
25
- //# sourceMappingURL=ccp-data-spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ccp-data-spec.js","sourceRoot":"","sources":["../../server/controllers/ccp-data-spec.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,kCAAkC;IAC/C,IAAI,EAAE,EAAE;IACR,SAAS,EAAE;QACT;YACE,IAAI,EAAE,YAAY,CAAC,gEAAgE;YACnF,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,EAAE;SACb;KACF;CACF,CAAA"}
@@ -1,19 +0,0 @@
1
- const CCP_UNITS = [
2
- 'Temperature',
3
- 'Time',
4
- 'Viscosity',
5
- 'pH',
6
- 'Flow rate',
7
- 'Available Chlorine',
8
- 'Titratable acidity',
9
- 'Water activity',
10
- 'Preservative concentrations',
11
- 'Humidity',
12
- 'Salt concentration',
13
- 'Sensory information such as aroma and visual appearance',
14
- 'Moisture level',
15
- 'Physical dimensions',
16
- 'Line Speed',
17
- 'Weight'
18
- ];
19
- //# sourceMappingURL=ccp-units.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ccp-units.js","sourceRoot":"","sources":["../../server/controllers/ccp-units.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG;IAChB,aAAa;IACb,MAAM;IACN,WAAW;IACX,IAAI;IACJ,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,gBAAgB;IAChB,6BAA6B;IAC7B,UAAU;IACV,oBAAoB;IACpB,yDAAyD;IACzD,gBAAgB;IAChB,qBAAqB;IACrB,YAAY;IACZ,QAAQ;CACT,CAAA"}
@@ -1,21 +0,0 @@
1
- export const CCP_DATA_SPEC = {
2
- name: 'CCP',
3
- description: 'Critical Control Point Data Spec',
4
- help: '',
5
- specItems: [
6
- {
7
- type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
8
- label: 'critical-limits',
9
- name: 'criticalLimits',
10
- placeholder: '식품안전 확보를 위해 한계 이내로 관리되어야 하는 이론적 한계기준',
11
- property: {}
12
- },
13
- {
14
- type: 'ccp-limits',
15
- label: 'target-limits',
16
- name: 'targetLimits',
17
- placeholder: '한계기준에 현장운영시의 안전관리 수치를 더한 초과 기준',
18
- property: {}
19
- }
20
- ]
21
- }
@@ -1,18 +0,0 @@
1
- const CCP_UNITS = [
2
- 'Temperature',
3
- 'Time',
4
- 'Viscosity',
5
- 'pH',
6
- 'Flow rate',
7
- 'Available Chlorine',
8
- 'Titratable acidity',
9
- 'Water activity',
10
- 'Preservative concentrations',
11
- 'Humidity',
12
- 'Salt concentration',
13
- 'Sensory information such as aroma and visual appearance',
14
- 'Moisture level',
15
- 'Physical dimensions',
16
- 'Line Speed',
17
- 'Weight'
18
- ]