@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.
Files changed (60) hide show
  1. package/README.md +34 -27
  2. package/dist/index.d.ts +1 -1
  3. package/dist/v1/errors/DataValidationError.d.ts +1 -1
  4. package/dist/v1/errors/DataValidationError.js +1 -1
  5. package/dist/v1/errors/ParameterValidationError.d.ts +1 -1
  6. package/dist/v1/errors/ParameterValidationError.js +1 -1
  7. package/dist/v1/errors/ValidationError.d.ts +1 -1
  8. package/dist/v1/errors/ValidationError.js +1 -1
  9. package/dist/v1/errors/index.d.ts +4 -4
  10. package/dist/v1/errors/types.d.ts +1 -1
  11. package/dist/v1/index.d.ts +5 -5
  12. package/dist/v1/schemas/certification.d.ts +1 -1
  13. package/dist/v1/schemas/certification.js +19 -13
  14. package/dist/v1/schemas/common.d.ts +13 -11
  15. package/dist/v1/schemas/common.js +27 -11
  16. package/dist/v1/schemas/criteria-tree.d.ts +377 -365
  17. package/dist/v1/schemas/criteria-tree.js +13 -5
  18. package/dist/v1/schemas/criterion.d.ts +70 -68
  19. package/dist/v1/schemas/criterion.js +4 -4
  20. package/dist/v1/schemas/data-map.d.ts +1 -1
  21. package/dist/v1/schemas/data-map.js +1 -1
  22. package/dist/v1/schemas/documentation.d.ts +1 -1
  23. package/dist/v1/schemas/documentation.js +9 -5
  24. package/dist/v1/schemas/index.d.ts +13 -13
  25. package/dist/v1/schemas/metadata.d.ts +1 -1
  26. package/dist/v1/schemas/metadata.js +6 -6
  27. package/dist/v1/schemas/quality.d.ts +469 -141
  28. package/dist/v1/schemas/quality.js +7 -7
  29. package/dist/v1/schemas/request/criteria-set-id-param-schema.d.ts +1 -1
  30. package/dist/v1/schemas/request/criteria-set-id-param-schema.js +3 -2
  31. package/dist/v1/schemas/request/index.d.ts +4 -4
  32. package/dist/v1/schemas/request/matrix-body-schema.d.ts +1 -1
  33. package/dist/v1/schemas/request/matrix-body-schema.js +5 -3
  34. package/dist/v1/schemas/request/matrix-request-body-schema.d.ts +1 -1
  35. package/dist/v1/schemas/request/matrix-request-body-schema.js +8 -6
  36. package/dist/v1/schemas/request/tree-and-data-body-schema.d.ts +1 -1
  37. package/dist/v1/schemas/request/tree-and-data-body-schema.js +5 -3
  38. package/dist/v1/schemas/request/tree-and-data-request-body-schema.d.ts +1 -1
  39. package/dist/v1/schemas/request/tree-and-data-request-body-schema.js +7 -5
  40. package/dist/v1/schemas/request/version-param-schema.d.ts +1 -1
  41. package/dist/v1/schemas/request/version-param-schema.js +3 -2
  42. package/dist/v1/schemas/response.d.ts +2 -2
  43. package/dist/v1/schemas/response.js +1 -1
  44. package/dist/v1/schemas/task-group.d.ts +49 -47
  45. package/dist/v1/schemas/task-group.js +5 -5
  46. package/dist/v1/schemas/task-item.d.ts +25 -24
  47. package/dist/v1/schemas/task-item.js +30 -36
  48. package/dist/v1/schemas/task.d.ts +32 -30
  49. package/dist/v1/schemas/task.js +4 -4
  50. package/dist/v1/schemas/theme.d.ts +95 -93
  51. package/dist/v1/schemas/theme.js +4 -4
  52. package/dist/v1/services/i-criteria-set.service.d.ts +1 -1
  53. package/dist/v1/services/index.d.ts +2 -2
  54. package/dist/v1/services/manager.service.js +4 -1
  55. package/dist/v1/types/criteria.d.ts +2 -2
  56. package/dist/v1/types/express.d.ts +3 -3
  57. package/dist/v1/types/index.d.ts +2 -2
  58. package/dist/v1/utils.d.ts +38 -38
  59. package/dist/v1/utils.js +6 -6
  60. 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
- | Type | Remarks |
22
- |-------------------------------|-----------------------------------------------------|
23
- | **Metadata types** | |
24
- | `Metadata` | |
25
- | `Theme` | |
26
- | `ThemeStyle` | |
27
- | `Color` | |
28
- | **Task tree types** | |
29
- | `CriteriaTree` | |
30
- | `Theme` | |
31
- | `Criterion` | |
32
- | `TaskGroup` | |
33
- | `Task` | |
34
- | `TaskItem` | |
35
- | **TaskItem value types** | |
36
- | `SelectSingleType` | |
37
- | `SelectMultipleType` | |
38
- | `NumberType` | |
39
- | `BooleanType` | |
40
- | `PointOption` | Used by `SelectSingleType` and `SelectMultipleType` |
41
- | `TaskItemValue` | The raw value of a TaskItem, which can be an array |
42
- | `TaskItemScalarValue` | The raw value of a TaskItem |
43
- | **Express types** | |
44
- | `MetadataResponse` | Metadata endpoint response body |
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` | Matrix streaming endpoints response body |
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 './v1';
1
+ export * as v1 from "./v1";
@@ -1,4 +1,4 @@
1
- import { ValidationError } from './ValidationError';
1
+ import { ValidationError } from "./ValidationError";
2
2
  export declare class DataValidationError extends ValidationError {
3
3
  code: string;
4
4
  path?: string | undefined;
@@ -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('data', code, path, args);
7
+ super("data", code, path, args);
8
8
  this.code = code;
9
9
  this.path = path;
10
10
  }
@@ -1,4 +1,4 @@
1
- import { ValidationError } from './ValidationError';
1
+ import { ValidationError } from "./ValidationError";
2
2
  export declare class ParameterValidationError extends ValidationError {
3
3
  code: string;
4
4
  path?: string | undefined;
@@ -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('parameter', code, path, args);
7
+ super("parameter", code, path, args);
8
8
  this.code = code;
9
9
  this.path = path;
10
10
  }
@@ -1,4 +1,4 @@
1
- import { ValidationErrorType } from './types';
1
+ import { ValidationErrorType } from "./types";
2
2
  export declare abstract class ValidationError extends Error {
3
3
  errorType: ValidationErrorType;
4
4
  code: string;
@@ -14,7 +14,7 @@ class ValidationError extends Error {
14
14
  errorType: this.errorType,
15
15
  code: this.code,
16
16
  path: this.path,
17
- arguments: this.arguments
17
+ arguments: this.arguments,
18
18
  };
19
19
  }
20
20
  }
@@ -1,4 +1,4 @@
1
- export * from './ValidationError';
2
- export * from './DataValidationError';
3
- export * from './ParameterValidationError';
4
- export * from './types';
1
+ export * from "./ValidationError";
2
+ export * from "./DataValidationError";
3
+ export * from "./ParameterValidationError";
4
+ export * from "./types";
@@ -1 +1 @@
1
- export type ValidationErrorType = 'data' | 'parameter';
1
+ export type ValidationErrorType = "data" | "parameter";
@@ -1,5 +1,5 @@
1
- export * from './schemas';
2
- export * from './services';
3
- export * from './types';
4
- export * from './utils';
5
- export * from './errors';
1
+ export * from "./schemas";
2
+ export * from "./services";
3
+ export * from "./types";
4
+ export * from "./utils";
5
+ export * from "./errors";
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const certificationDefinitionTypeSchema: z.ZodEnum<["number", "percentage"]>;
3
3
  export declare const numberBasedCertificationDefinitionRulesSchema: z.ZodObject<{
4
4
  minimum: z.ZodOptional<z.ZodNumber>;
@@ -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(['number', 'percentage']);
5
+ exports.certificationDefinitionTypeSchema = zod_1.z.enum([
6
+ "number",
7
+ "percentage",
8
+ ]);
6
9
  exports.numberBasedCertificationDefinitionRulesSchema = zod_1.z.object({
7
- minimum: (0, zod_1.optional)(zod_1.z.number()),
8
- exclusiveMinimum: (0, zod_1.optional)(zod_1.z.number()),
9
- maximum: (0, zod_1.optional)(zod_1.z.number()),
10
- exclusiveMaximum: (0, zod_1.optional)(zod_1.z.number()),
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: (0, zod_1.optional)(zod_1.z.string()),
19
+ icon: zod_1.z.string().optional(),
17
20
  name: zod_1.z.string(),
18
- description: (0, zod_1.optional)(zod_1.z.string()),
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('number'),
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('percentage'),
27
- rules: exports.percentageBasedCertificationDefinitionRulesSchema
29
+ type: zod_1.z.literal("percentage"),
30
+ rules: exports.percentageBasedCertificationDefinitionRulesSchema,
28
31
  });
29
- exports.certificationDefinitionSchema = zod_1.z.discriminatedUnion('type', [exports.numberBasedCertificationDefinitionSchema, exports.percentageBasedCertificationDefinitionSchema]);
32
+ exports.certificationDefinitionSchema = zod_1.z.discriminatedUnion("type", [
33
+ exports.numberBasedCertificationDefinitionSchema,
34
+ exports.percentageBasedCertificationDefinitionSchema,
35
+ ]);
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
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 elementDataSchema: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
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.ZodOptional<z.ZodString>>;
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.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
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.ZodOptional<z.ZodString>>;
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?: (Record<string, any> & {
97
+ data?: {
96
98
  value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
97
99
  text?: string | undefined;
98
- }) | undefined;
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?: (Record<string, any> & {
122
+ data?: {
121
123
  value?: string | number | boolean | (string | number | boolean | null)[] | null | undefined;
122
124
  text?: string | undefined;
123
- }) | undefined;
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
- exports.elementDataSchema = zod_1.z.intersection(zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.object({
16
- value: task_item_1.taskItemValueSchema,
17
- text: (0, zod_1.optional)(zod_1.z.string()),
18
- }).partial());
19
- exports.criteriaTreeElementTypeSchema = zod_1.z.enum(['theme', 'criterion', 'task-group', 'task', 'task-item']);
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: (0, zod_1.optional)(zod_1.z.array(zod_1.z.string())),
25
- documentation: (0, zod_1.optional)(zod_1.z.array(documentation_1.documentationItemSchema)),
26
- data: (0, zod_1.optional)(exports.elementDataSchema),
27
- sortOrder: (0, zod_1.optional)(zod_1.z.number()),
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
  });