@openframe-org/criteria-set-protocol 2.0.0 → 2.0.2
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 +34 -27
- package/dist/index.d.ts +1 -1
- package/dist/v1/errors/DataValidationError.d.ts +1 -1
- package/dist/v1/errors/DataValidationError.js +1 -1
- package/dist/v1/errors/ParameterValidationError.d.ts +1 -1
- package/dist/v1/errors/ParameterValidationError.js +1 -1
- package/dist/v1/errors/ValidationError.d.ts +1 -1
- package/dist/v1/errors/ValidationError.js +1 -1
- package/dist/v1/errors/index.d.ts +4 -4
- package/dist/v1/errors/types.d.ts +1 -1
- package/dist/v1/index.d.ts +5 -5
- package/dist/v1/schemas/certification.d.ts +1 -1
- package/dist/v1/schemas/certification.js +19 -13
- package/dist/v1/schemas/common.d.ts +13 -11
- package/dist/v1/schemas/common.js +27 -11
- package/dist/v1/schemas/criteria-tree.d.ts +377 -365
- package/dist/v1/schemas/criteria-tree.js +13 -5
- package/dist/v1/schemas/criterion.d.ts +70 -68
- package/dist/v1/schemas/criterion.js +4 -4
- package/dist/v1/schemas/data-map.d.ts +1 -1
- package/dist/v1/schemas/data-map.js +1 -1
- package/dist/v1/schemas/documentation.d.ts +1 -1
- package/dist/v1/schemas/documentation.js +9 -5
- package/dist/v1/schemas/index.d.ts +13 -13
- package/dist/v1/schemas/metadata.d.ts +1 -1
- package/dist/v1/schemas/metadata.js +6 -6
- package/dist/v1/schemas/quality.d.ts +469 -141
- package/dist/v1/schemas/quality.js +7 -7
- package/dist/v1/schemas/request/criteria-set-id-param-schema.d.ts +1 -1
- package/dist/v1/schemas/request/criteria-set-id-param-schema.js +3 -2
- package/dist/v1/schemas/request/index.d.ts +4 -4
- package/dist/v1/schemas/request/matrix-body-schema.d.ts +1 -1
- package/dist/v1/schemas/request/matrix-body-schema.js +5 -3
- package/dist/v1/schemas/request/matrix-request-body-schema.d.ts +1 -1
- package/dist/v1/schemas/request/matrix-request-body-schema.js +8 -6
- package/dist/v1/schemas/request/tree-and-data-body-schema.d.ts +1 -1
- package/dist/v1/schemas/request/tree-and-data-body-schema.js +5 -3
- package/dist/v1/schemas/request/tree-and-data-request-body-schema.d.ts +1 -1
- package/dist/v1/schemas/request/tree-and-data-request-body-schema.js +7 -5
- package/dist/v1/schemas/request/version-param-schema.d.ts +1 -1
- package/dist/v1/schemas/request/version-param-schema.js +3 -2
- package/dist/v1/schemas/response.d.ts +2 -2
- package/dist/v1/schemas/response.js +1 -1
- package/dist/v1/schemas/task-group.d.ts +49 -47
- package/dist/v1/schemas/task-group.js +5 -5
- package/dist/v1/schemas/task-item.d.ts +25 -24
- package/dist/v1/schemas/task-item.js +30 -36
- package/dist/v1/schemas/task.d.ts +32 -30
- package/dist/v1/schemas/task.js +4 -4
- package/dist/v1/schemas/theme.d.ts +95 -93
- package/dist/v1/schemas/theme.js +4 -4
- package/dist/v1/services/i-criteria-set.service.d.ts +1 -1
- package/dist/v1/services/index.d.ts +2 -2
- package/dist/v1/services/manager.service.js +4 -1
- package/dist/v1/types/criteria.d.ts +2 -2
- package/dist/v1/types/express.d.ts +3 -3
- package/dist/v1/types/index.d.ts +2 -2
- package/dist/v1/utils.d.ts +38 -38
- package/dist/v1/utils.js +6 -6
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -3,60 +3,67 @@
|
|
|
3
3
|
# Criteria Set Protocol
|
|
4
4
|
|
|
5
5
|
## TypeScript library
|
|
6
|
+
|
|
6
7
|
This is a TypeScript library with types and implementations of the Criteria Set Protocol. It is published
|
|
7
8
|
publicly on [npmjs](https://www.npmjs.com/package/@openframe-org/criteria-set-protocol) as `@openframe-org/criteria-set-protocol`.
|
|
8
9
|
|
|
9
10
|
### Installation
|
|
11
|
+
|
|
10
12
|
```bash
|
|
11
13
|
npm install --save @openframe-org/criteria-set-protocol
|
|
12
14
|
```
|
|
13
15
|
|
|
14
16
|
### Contents
|
|
17
|
+
|
|
15
18
|
The library contains a service to work with protocol versions, and an interface to interact with this service.
|
|
16
19
|
|
|
17
20
|
#### Protocol v1
|
|
21
|
+
|
|
18
22
|
The library contains the types defined in the protocol v1 specification, and a service that implements this specification.
|
|
19
23
|
|
|
20
24
|
##### Types
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
|
|
|
44
|
-
|
|
|
25
|
+
|
|
26
|
+
| Type | Remarks |
|
|
27
|
+
| -------------------------- | --------------------------------------------------- |
|
|
28
|
+
| **Metadata types** | |
|
|
29
|
+
| `Metadata` | |
|
|
30
|
+
| `Theme` | |
|
|
31
|
+
| `ThemeStyle` | |
|
|
32
|
+
| `Color` | |
|
|
33
|
+
| **Task tree types** | |
|
|
34
|
+
| `CriteriaTree` | |
|
|
35
|
+
| `Theme` | |
|
|
36
|
+
| `Criterion` | |
|
|
37
|
+
| `TaskGroup` | |
|
|
38
|
+
| `Task` | |
|
|
39
|
+
| `TaskItem` | |
|
|
40
|
+
| **TaskItem value types** | |
|
|
41
|
+
| `SelectSingleType` | |
|
|
42
|
+
| `SelectMultipleType` | |
|
|
43
|
+
| `NumberType` | |
|
|
44
|
+
| `BooleanType` | |
|
|
45
|
+
| `PointOption` | Used by `SelectSingleType` and `SelectMultipleType` |
|
|
46
|
+
| `TaskItemValue` | The raw value of a TaskItem, which can be an array |
|
|
47
|
+
| `TaskItemScalarValue` | The raw value of a TaskItem |
|
|
48
|
+
| **Express types** | |
|
|
49
|
+
| `MetadataResponse` | Metadata endpoint response body |
|
|
45
50
|
| `TreeAndMatrixRequestBody` | Request body for the matrix streaming endpoints |
|
|
46
|
-
| `StreamMatrixResponse`
|
|
51
|
+
| `StreamMatrixResponse` | Matrix streaming endpoints response body |
|
|
47
52
|
|
|
48
53
|
##### Schemas
|
|
54
|
+
|
|
49
55
|
Validation schemas are provided for validating the endpoints of the protocol v1 specification.
|
|
50
56
|
|
|
51
57
|
| Schema | Remarks |
|
|
52
|
-
|
|
58
|
+
| -------------------------- | ---------------------------------------------------------------- |
|
|
53
59
|
| `TreeAndMatrixBodySchema` | Validates the request body for the tree and matrix endpoints |
|
|
54
60
|
| `criteriaSetIdParamSchema` | Validates the criteriaSetId parameter for endpoints which use it |
|
|
55
61
|
| `versionParamSchema` | Validates the version parameter for endpoints which use it |
|
|
56
62
|
|
|
57
63
|
##### Services
|
|
58
|
-
The `IProtocolV1Service` interface defines a service which implements the v1 protocol.
|
|
59
64
|
|
|
65
|
+
The `IProtocolV1Service` interface defines a service which implements the v1 protocol.
|
|
60
66
|
|
|
61
67
|
## License
|
|
68
|
+
|
|
62
69
|
<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://github.com/Frame-ApS/criteria-set-protocol">Openframe Criteria Set Protocol</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://github.com/andresangulo">Openframe ApS</a> is licensed under <a href="http://creativecommons.org/licenses/by-nd/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY-ND 4.0<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nd.svg?ref=chooser-v1"></a></p>
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as v1 from
|
|
1
|
+
export * as v1 from "./v1";
|
|
@@ -4,7 +4,7 @@ exports.DataValidationError = void 0;
|
|
|
4
4
|
const ValidationError_1 = require("./ValidationError");
|
|
5
5
|
class DataValidationError extends ValidationError_1.ValidationError {
|
|
6
6
|
constructor(code, path, args) {
|
|
7
|
-
super(
|
|
7
|
+
super("data", code, path, args);
|
|
8
8
|
this.code = code;
|
|
9
9
|
this.path = path;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ exports.ParameterValidationError = void 0;
|
|
|
4
4
|
const ValidationError_1 = require("./ValidationError");
|
|
5
5
|
class ParameterValidationError extends ValidationError_1.ValidationError {
|
|
6
6
|
constructor(code, path, args) {
|
|
7
|
-
super(
|
|
7
|
+
super("parameter", code, path, args);
|
|
8
8
|
this.code = code;
|
|
9
9
|
this.path = path;
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./ValidationError";
|
|
2
|
+
export * from "./DataValidationError";
|
|
3
|
+
export * from "./ParameterValidationError";
|
|
4
|
+
export * from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ValidationErrorType =
|
|
1
|
+
export type ValidationErrorType = "data" | "parameter";
|
package/dist/v1/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./schemas";
|
|
2
|
+
export * from "./services";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./utils";
|
|
5
|
+
export * from "./errors";
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.certificationDefinitionSchema = exports.percentageBasedCertificationDefinitionSchema = exports.numberBasedCertificationDefinitionSchema = exports.percentageBasedCertificationDefinitionRulesSchema = exports.numberBasedCertificationDefinitionRulesSchema = exports.certificationDefinitionTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.certificationDefinitionTypeSchema = zod_1.z.enum([
|
|
5
|
+
exports.certificationDefinitionTypeSchema = zod_1.z.enum([
|
|
6
|
+
"number",
|
|
7
|
+
"percentage",
|
|
8
|
+
]);
|
|
6
9
|
exports.numberBasedCertificationDefinitionRulesSchema = zod_1.z.object({
|
|
7
|
-
minimum:
|
|
8
|
-
exclusiveMinimum:
|
|
9
|
-
maximum:
|
|
10
|
-
exclusiveMaximum:
|
|
10
|
+
minimum: zod_1.z.number().optional(),
|
|
11
|
+
exclusiveMinimum: zod_1.z.number().optional(),
|
|
12
|
+
maximum: zod_1.z.number().optional(),
|
|
13
|
+
exclusiveMaximum: zod_1.z.number().optional(),
|
|
11
14
|
});
|
|
12
15
|
exports.percentageBasedCertificationDefinitionRulesSchema = exports.numberBasedCertificationDefinitionRulesSchema;
|
|
13
16
|
const abstractCertificationDefinitionSchema = zod_1.z.object({
|
|
14
17
|
type: exports.certificationDefinitionTypeSchema,
|
|
15
18
|
code: zod_1.z.string(),
|
|
16
|
-
icon:
|
|
19
|
+
icon: zod_1.z.string().optional(),
|
|
17
20
|
name: zod_1.z.string(),
|
|
18
|
-
description:
|
|
19
|
-
rulesText: zod_1.z.string()
|
|
21
|
+
description: zod_1.z.string().optional(),
|
|
22
|
+
rulesText: zod_1.z.string(),
|
|
20
23
|
});
|
|
21
24
|
exports.numberBasedCertificationDefinitionSchema = abstractCertificationDefinitionSchema.extend({
|
|
22
|
-
type: zod_1.z.literal(
|
|
23
|
-
rules: exports.numberBasedCertificationDefinitionRulesSchema
|
|
25
|
+
type: zod_1.z.literal("number"),
|
|
26
|
+
rules: exports.numberBasedCertificationDefinitionRulesSchema,
|
|
24
27
|
});
|
|
25
28
|
exports.percentageBasedCertificationDefinitionSchema = abstractCertificationDefinitionSchema.extend({
|
|
26
|
-
type: zod_1.z.literal(
|
|
27
|
-
rules: exports.percentageBasedCertificationDefinitionRulesSchema
|
|
29
|
+
type: zod_1.z.literal("percentage"),
|
|
30
|
+
rules: exports.percentageBasedCertificationDefinitionRulesSchema,
|
|
28
31
|
});
|
|
29
|
-
exports.certificationDefinitionSchema = zod_1.z.discriminatedUnion(
|
|
32
|
+
exports.certificationDefinitionSchema = zod_1.z.discriminatedUnion("type", [
|
|
33
|
+
exports.numberBasedCertificationDefinitionSchema,
|
|
34
|
+
exports.percentageBasedCertificationDefinitionSchema,
|
|
35
|
+
]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare const colorSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
3
3
|
red: z.ZodNumber;
|
|
4
4
|
green: z.ZodNumber;
|
|
@@ -12,16 +12,18 @@ export declare const colorSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
|
12
12
|
green: number;
|
|
13
13
|
blue: number;
|
|
14
14
|
}>]>;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const taskItemScalarValueSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
16
|
+
export declare const taskItemValueSchema: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>;
|
|
17
|
+
export declare const elementDataSchema: z.ZodObject<{
|
|
16
18
|
value: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>;
|
|
17
|
-
text: z.ZodOptional<z.
|
|
19
|
+
text: z.ZodOptional<z.ZodString>;
|
|
18
20
|
}, "strip", z.ZodTypeAny, {
|
|
19
21
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
20
22
|
text?: string | undefined;
|
|
21
23
|
}, {
|
|
22
24
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
23
25
|
text?: string | undefined;
|
|
24
|
-
}
|
|
26
|
+
}>;
|
|
25
27
|
export declare const criteriaTreeElementTypeSchema: z.ZodEnum<["theme", "criterion", "task-group", "task", "task-item"]>;
|
|
26
28
|
export declare const abstractElementSchema: z.ZodObject<{
|
|
27
29
|
type: z.ZodEnum<["theme", "criterion", "task-group", "task", "task-item"]>;
|
|
@@ -77,25 +79,25 @@ export declare const abstractElementSchema: z.ZodObject<{
|
|
|
77
79
|
label: string;
|
|
78
80
|
text: string;
|
|
79
81
|
}>]>, "many">>;
|
|
80
|
-
data: z.ZodOptional<z.
|
|
82
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
81
83
|
value: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>;
|
|
82
|
-
text: z.ZodOptional<z.
|
|
84
|
+
text: z.ZodOptional<z.ZodString>;
|
|
83
85
|
}, "strip", z.ZodTypeAny, {
|
|
84
86
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
85
87
|
text?: string | undefined;
|
|
86
88
|
}, {
|
|
87
89
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
88
90
|
text?: string | undefined;
|
|
89
|
-
}
|
|
91
|
+
}>>;
|
|
90
92
|
sortOrder: z.ZodOptional<z.ZodNumber>;
|
|
91
93
|
}, "strip", z.ZodTypeAny, {
|
|
92
94
|
type: "theme" | "criterion" | "task-group" | "task" | "task-item";
|
|
93
95
|
code: string;
|
|
94
96
|
title: string;
|
|
95
|
-
data?:
|
|
97
|
+
data?: {
|
|
96
98
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
97
99
|
text?: string | undefined;
|
|
98
|
-
}
|
|
100
|
+
} | undefined;
|
|
99
101
|
tags?: string[] | undefined;
|
|
100
102
|
documentation?: ({
|
|
101
103
|
type: "pdf";
|
|
@@ -117,10 +119,10 @@ export declare const abstractElementSchema: z.ZodObject<{
|
|
|
117
119
|
type: "theme" | "criterion" | "task-group" | "task" | "task-item";
|
|
118
120
|
code: string;
|
|
119
121
|
title: string;
|
|
120
|
-
data?:
|
|
122
|
+
data?: {
|
|
121
123
|
value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
|
|
122
124
|
text?: string | undefined;
|
|
123
|
-
}
|
|
125
|
+
} | undefined;
|
|
124
126
|
tags?: string[] | undefined;
|
|
125
127
|
documentation?: ({
|
|
126
128
|
type: "pdf";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.abstractElementSchema = exports.criteriaTreeElementTypeSchema = exports.elementDataSchema = exports.colorSchema = void 0;
|
|
3
|
+
exports.abstractElementSchema = exports.criteriaTreeElementTypeSchema = exports.elementDataSchema = exports.taskItemValueSchema = exports.taskItemScalarValueSchema = exports.colorSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const task_item_1 = require("./task-item");
|
|
6
5
|
const documentation_1 = require("./documentation");
|
|
7
6
|
exports.colorSchema = zod_1.z.union([
|
|
8
7
|
zod_1.z.string(),
|
|
@@ -12,17 +11,34 @@ exports.colorSchema = zod_1.z.union([
|
|
|
12
11
|
blue: zod_1.z.number(),
|
|
13
12
|
}),
|
|
14
13
|
]);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// These are not "common" and are task-item specific, but generate a circular dependency if moved to task-item.ts
|
|
15
|
+
exports.taskItemScalarValueSchema = zod_1.z.union([
|
|
16
|
+
zod_1.z.string(),
|
|
17
|
+
zod_1.z.number(),
|
|
18
|
+
zod_1.z.boolean(),
|
|
19
|
+
zod_1.z.null(),
|
|
20
|
+
]);
|
|
21
|
+
exports.taskItemValueSchema = zod_1.z.union([
|
|
22
|
+
exports.taskItemScalarValueSchema,
|
|
23
|
+
zod_1.z.array(exports.taskItemScalarValueSchema),
|
|
24
|
+
]);
|
|
25
|
+
exports.elementDataSchema = zod_1.z.object({
|
|
26
|
+
value: exports.taskItemValueSchema.optional(),
|
|
27
|
+
text: zod_1.z.string().optional(),
|
|
28
|
+
});
|
|
29
|
+
exports.criteriaTreeElementTypeSchema = zod_1.z.enum([
|
|
30
|
+
"theme",
|
|
31
|
+
"criterion",
|
|
32
|
+
"task-group",
|
|
33
|
+
"task",
|
|
34
|
+
"task-item",
|
|
35
|
+
]);
|
|
20
36
|
exports.abstractElementSchema = zod_1.z.object({
|
|
21
37
|
type: exports.criteriaTreeElementTypeSchema,
|
|
22
38
|
title: zod_1.z.string(),
|
|
23
39
|
code: zod_1.z.string(),
|
|
24
|
-
tags:
|
|
25
|
-
documentation:
|
|
26
|
-
data:
|
|
27
|
-
sortOrder:
|
|
40
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
41
|
+
documentation: zod_1.z.array(documentation_1.documentationItemSchema).optional(),
|
|
42
|
+
data: exports.elementDataSchema.optional(),
|
|
43
|
+
sortOrder: zod_1.z.number().optional(),
|
|
28
44
|
});
|