@openframe-org/criteria-set-protocol 1.0.48 → 1.0.50
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/README.md +2 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -5
- package/dist/v1/schemas/tree-and-matrix-body-schema.d.ts +3 -3
- package/dist/v1/schemas/tree-and-matrix-body-schema.js +4 -4
- package/dist/v1/services/i-criteria-set.service.d.ts +9 -0
- package/dist/v1/services/i-criteria-set.service.js +2 -0
- package/dist/v1/services/index.d.ts +2 -1
- package/dist/v1/services/index.js +2 -1
- package/dist/v1/services/manager.service.d.ts +1 -0
- package/dist/v1/services/manager.service.js +31 -0
- package/dist/v1/types/criteria.d.ts +4 -8
- package/dist/v1/types/express.d.ts +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ The library contains the types defined in the protocol v1 specification, and a s
|
|
|
27
27
|
| `Color` | |
|
|
28
28
|
| **Task tree types** | |
|
|
29
29
|
| `CriteriaTree` | |
|
|
30
|
+
| `Quality` | |
|
|
30
31
|
| `Criterion` | |
|
|
31
32
|
| `TaskGroup` | |
|
|
32
33
|
| `Task` | |
|
|
@@ -41,7 +42,7 @@ The library contains the types defined in the protocol v1 specification, and a s
|
|
|
41
42
|
| `TaskItemScalarValue` | The raw value of a TaskItem |
|
|
42
43
|
| **Express types** | |
|
|
43
44
|
| `MetadataResponse` | Metadata endpoint response body |
|
|
44
|
-
| `
|
|
45
|
+
| `TreeAndMatrixRequestBody` | Request body for the matrix streaming endpoints |
|
|
45
46
|
| `StreamMatrixResponse` | Matrix streaming endpoints response body |
|
|
46
47
|
|
|
47
48
|
##### Schemas
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,9 +15,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
19
|
if (mod && mod.__esModule) return mod;
|
|
23
20
|
var result = {};
|
|
@@ -27,6 +24,4 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
24
|
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.v1 = void 0;
|
|
30
|
-
__exportStar(require("./services"), exports);
|
|
31
|
-
__exportStar(require("./types"), exports);
|
|
32
27
|
exports.v1 = __importStar(require("./v1"));
|
|
@@ -4,10 +4,10 @@ import * as yup from 'yup';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const treeAndMatrixBodySchema: yup.ObjectSchema<{
|
|
6
6
|
body: {
|
|
7
|
+
values?: {} | undefined;
|
|
7
8
|
locale?: string | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
9
|
+
parameters?: {} | undefined;
|
|
10
|
+
} | undefined;
|
|
11
11
|
}, yup.AnyObject, {
|
|
12
12
|
body: {
|
|
13
13
|
locale: undefined;
|
|
@@ -30,8 +30,8 @@ const yup = __importStar(require("yup"));
|
|
|
30
30
|
*/
|
|
31
31
|
exports.treeAndMatrixBodySchema = yup.object({
|
|
32
32
|
body: yup.object({
|
|
33
|
-
locale: yup.string(),
|
|
34
|
-
parameters: yup.object(),
|
|
35
|
-
values: yup.object()
|
|
36
|
-
})
|
|
33
|
+
locale: yup.string().optional(),
|
|
34
|
+
parameters: yup.object().optional(),
|
|
35
|
+
values: yup.object().optional()
|
|
36
|
+
}).optional()
|
|
37
37
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CriteriaTree, Metadata, StreamMatrixResponse, TaskItemValueMap } from '../types';
|
|
2
|
+
export interface ICriteriaSetService<ParametersType extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
validateParameters(parameters: ParametersType): Promise<void>;
|
|
6
|
+
getMetadata(): Metadata;
|
|
7
|
+
getCriteriaTree(parameters?: ParametersType, values?: TaskItemValueMap | null, locale?: string | null): CriteriaTree;
|
|
8
|
+
streamMatrix(parameters?: ParametersType, values?: TaskItemValueMap | null, locale?: string | null): StreamMatrixResponse;
|
|
9
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './i-
|
|
1
|
+
export * from './i-criteria-set.service';
|
|
2
|
+
export * from './manager.service';
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./i-
|
|
17
|
+
__exportStar(require("./i-criteria-set.service"), exports);
|
|
18
|
+
__exportStar(require("./manager.service"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ManagerService {
|
|
4
|
+
constructor(criteriaSetServices = {}) {
|
|
5
|
+
this.criteriaSetServices = criteriaSetServices;
|
|
6
|
+
}
|
|
7
|
+
// Get the criteria sets and versions available to this service
|
|
8
|
+
getCriteriaSetsAndVersions() {
|
|
9
|
+
return Object.fromEntries(Object.entries(this.criteriaSetServices).map(([criteriaSetId, services]) => {
|
|
10
|
+
return [criteriaSetId, services.map((service) => service.getMetadata())];
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
// Get the criteria set with the given ID. If no version is requested, return the latest version
|
|
14
|
+
getServiceForCriteriaSet(criteriaSetId, version) {
|
|
15
|
+
var _a;
|
|
16
|
+
const services = (_a = this.criteriaSetServices) === null || _a === void 0 ? void 0 : _a[criteriaSetId];
|
|
17
|
+
if (!(services === null || services === void 0 ? void 0 : services.length)) {
|
|
18
|
+
throw new Error(`Criteria set ID not found: ${criteriaSetId}`);
|
|
19
|
+
}
|
|
20
|
+
if (!version) {
|
|
21
|
+
return services[services.length - 1];
|
|
22
|
+
}
|
|
23
|
+
const service = services === null || services === void 0 ? void 0 : services.find((service) => {
|
|
24
|
+
return service.version === version;
|
|
25
|
+
});
|
|
26
|
+
if (!service) {
|
|
27
|
+
throw new Error(`Criteria set version not found: ${criteriaSetId}/${version}`);
|
|
28
|
+
}
|
|
29
|
+
return service;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -8,20 +8,16 @@ export type QualityStyle = {
|
|
|
8
8
|
secondaryColor: Color;
|
|
9
9
|
};
|
|
10
10
|
export type Metadata = {
|
|
11
|
-
protocol: number;
|
|
12
|
-
metadata: CriteriaSetMetadata;
|
|
13
|
-
locales?: string[];
|
|
14
|
-
defaultLocale?: string;
|
|
15
|
-
parameters?: Record<string, any>;
|
|
16
|
-
result?: Record<string, any>;
|
|
17
|
-
};
|
|
18
|
-
export type CriteriaSetMetadata = {
|
|
19
11
|
id: string;
|
|
20
12
|
version: string;
|
|
21
13
|
date: Date;
|
|
22
14
|
name: string;
|
|
23
15
|
description: string;
|
|
24
16
|
documentation?: string;
|
|
17
|
+
locales?: string[];
|
|
18
|
+
defaultLocale?: string;
|
|
19
|
+
parameters?: Record<string, any>;
|
|
20
|
+
result?: Record<string, any>;
|
|
25
21
|
};
|
|
26
22
|
export type PdfDocumentationItem = {
|
|
27
23
|
type: 'pdf';
|
|
@@ -7,7 +7,7 @@ export type StringParam<ParamName extends string> = Record<ParamName, string>;
|
|
|
7
7
|
export type TaskItemValueMap = Record<string, TaskItemValue>;
|
|
8
8
|
export type TreeAndMatrixRequestBody = {
|
|
9
9
|
locale?: string;
|
|
10
|
-
parameters
|
|
10
|
+
parameters?: ParameterCombination;
|
|
11
11
|
values?: TaskItemValueMap;
|
|
12
12
|
};
|
|
13
13
|
export type StreamMatrixResponse = {
|
|
@@ -15,5 +15,4 @@ export type StreamMatrixResponse = {
|
|
|
15
15
|
contentType: string;
|
|
16
16
|
stream: Stream;
|
|
17
17
|
};
|
|
18
|
-
export type CriteriaSetsAndVersionsMap = Record<string, Metadata[]>;
|
|
19
18
|
export type ParameterCombination = Record<string, any>;
|
package/package.json
CHANGED