@things-factory/qc 8.0.0-beta.9 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/qc",
3
- "version": "8.0.0-beta.9",
3
+ "version": "8.0.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,9 +24,9 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
25
25
  },
26
26
  "dependencies": {
27
- "@operato/dataset": "^8.0.0-beta",
28
- "@things-factory/dataset": "^8.0.0-beta.9",
29
- "@things-factory/shell": "^8.0.0-beta.9"
27
+ "@operato/dataset": "^8.0.0",
28
+ "@things-factory/dataset": "^8.0.0",
29
+ "@things-factory/shell": "^8.0.0"
30
30
  },
31
- "gitHead": "86b1dfa26292926a2d5447fdc23bfa5a9e983245"
31
+ "gitHead": "07ef27d272dd9a067a9648ac7013748510556a18"
32
32
  }
@@ -0,0 +1,44 @@
1
+ import { DataItemSpecSet, DataUseCase, EvaluationResult } from '@things-factory/dataset'
2
+
3
+ export class DataUseCaseQC implements DataUseCase {
4
+ getSpecification(): DataItemSpecSet {
5
+ return {
6
+ name: 'QC',
7
+ description: 'Quality Control Data Spec',
8
+ help: '',
9
+ specs: [
10
+ {
11
+ type: 'qc-limits' /* 'A value which seperates acceptability from unacceptability' */,
12
+ label: 'pass limits',
13
+ name: 'passLimits'
14
+ }
15
+ ]
16
+ }
17
+ }
18
+
19
+ evaluate(spec: any, values: any | any[]): EvaluationResult {
20
+ const { minimum, maximum, acceptables } = spec['passLimits']
21
+
22
+ if (!(values instanceof Array)) {
23
+ values = [values]
24
+ }
25
+
26
+ for (let i = 0; i < values.length; i++) {
27
+ const value = values[i]
28
+
29
+ if (minimum != null && value < minimum) {
30
+ return { oos: true, ooc: true }
31
+ }
32
+
33
+ if (maximum != null && value > maximum) {
34
+ return { oos: true, ooc: true }
35
+ }
36
+
37
+ if (acceptables != null && !acceptables.includes(value)) {
38
+ return { oos: true, ooc: true }
39
+ }
40
+ }
41
+
42
+ return { oos: false, ooc: false }
43
+ }
44
+ }
@@ -0,0 +1 @@
1
+ export * from './data-use-case-qc'
@@ -0,0 +1,8 @@
1
+ import { DataUseCase } from '@things-factory/dataset'
2
+ import { DataUseCaseQC } from './controllers'
3
+
4
+ process.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {
5
+ DataUseCase.registerUseCase('QC', new DataUseCaseQC())
6
+
7
+ console.log('[qc:bootstrap] QC has just registered as a DataUseCase.')
8
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist-server",
5
+ "baseUrl": "./"
6
+ },
7
+ "include": ["./server/**/*"],
8
+ "exclude": ["**/*.spec.ts"]
9
+ }