@openframe-org/criteria-set-protocol 1.4.8 → 1.5.0

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.
@@ -1,13 +1,11 @@
1
- import * as yup from 'yup';
1
+ import { z } from 'zod';
2
2
  /**
3
3
  * Validates the criteriaSetId parameter for endpoints which use it
4
4
  */
5
- export declare const criteriaSetIdParamSchema: yup.ObjectSchema<{
6
- params: {
7
- criteriaSetId: string;
8
- };
9
- }, yup.AnyObject, {
10
- params: {
11
- criteriaSetId: undefined;
12
- };
13
- }, "">;
5
+ export declare const criteriaSetIdParamSchema: z.ZodObject<{
6
+ criteriaSetId: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ criteriaSetId: string;
9
+ }, {
10
+ criteriaSetId: string;
11
+ }>;
@@ -1,37 +1,11 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.criteriaSetIdParamSchema = void 0;
27
- const yup = __importStar(require("yup"));
4
+ const zod_1 = require("zod");
28
5
  /**
29
6
  * Validates the criteriaSetId parameter for endpoints which use it
30
7
  */
31
- exports.criteriaSetIdParamSchema = yup.object({
32
- params: yup.object({
33
- criteriaSetId: yup.string()
34
- .matches(/^[a-zA-Z0-9.\-_]+$/, 'Criteria set ID must contain only full stops, alphanumeric characters, dashes and underscores')
35
- .required()
36
- })
8
+ exports.criteriaSetIdParamSchema = zod_1.z.object({
9
+ criteriaSetId: zod_1.z.string()
10
+ .regex(/^[a-zA-Z0-9.\-_]+$/, 'Criteria set ID must contain only full stops, alphanumeric characters, dashes and underscores')
37
11
  });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { Criterion } from '../types';
3
+ export declare const criterionSchema: z.Schema<Criterion>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.criterionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
6
+ const task_group_1 = require("./task-group");
7
+ exports.criterionSchema = zod_1.z.object({
8
+ type: zod_1.z.literal('criterion'),
9
+ title: zod_1.z.string(),
10
+ code: zod_1.z.string(),
11
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
12
+ documentation: zod_1.z.array(task_item_1.documentationItemSchema).optional(),
13
+ data: zod_1.z.record(zod_1.z.any()).optional(),
14
+ sortOrder: zod_1.z.number().optional(),
15
+ items: zod_1.z.array(task_group_1.taskGroupSchema)
16
+ });
@@ -1,4 +1,9 @@
1
1
  export * from './criteria-set-id-param-schema';
2
- export * from './tree-body-schema';
2
+ export * from './tree-and-data-body-schema';
3
3
  export * from './matrix-body-schema';
4
4
  export * from './version-param-schema';
5
+ export * from './quality';
6
+ export * from './task-group';
7
+ export * from './criterion';
8
+ export * from './task';
9
+ export * from './task-item';
@@ -15,6 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./criteria-set-id-param-schema"), exports);
18
- __exportStar(require("./tree-body-schema"), exports);
18
+ __exportStar(require("./tree-and-data-body-schema"), exports);
19
19
  __exportStar(require("./matrix-body-schema"), exports);
20
20
  __exportStar(require("./version-param-schema"), exports);
21
+ __exportStar(require("./quality"), exports);
22
+ __exportStar(require("./task-group"), exports);
23
+ __exportStar(require("./criterion"), exports);
24
+ __exportStar(require("./task"), exports);
25
+ __exportStar(require("./task-item"), exports);
@@ -1,19 +1,6 @@
1
- import * as yup from 'yup';
1
+ import { z } from 'zod';
2
+ import { MatrixRequestBody } from '../types';
2
3
  /**
3
4
  * Validates the request body for the matrix endpoints
4
5
  */
5
- export declare const matrixBodySchema: yup.ObjectSchema<{
6
- body: {
7
- values?: {} | undefined;
8
- locale?: string | undefined;
9
- parameters?: {} | undefined;
10
- additional?: {} | undefined;
11
- } | undefined;
12
- }, yup.AnyObject, {
13
- body: {
14
- locale: undefined;
15
- parameters: {};
16
- values: {};
17
- additional: undefined;
18
- };
19
- }, "">;
6
+ export declare const matrixBodySchema: z.Schema<MatrixRequestBody | undefined>;
@@ -1,38 +1,14 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.matrixBodySchema = void 0;
27
- const yup = __importStar(require("yup"));
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
28
6
  /**
29
7
  * Validates the request body for the matrix endpoints
30
8
  */
31
- exports.matrixBodySchema = yup.object({
32
- body: yup.object({
33
- locale: yup.string().optional(),
34
- parameters: yup.object().optional(),
35
- values: yup.object().optional(),
36
- additional: yup.mixed().optional()
37
- }).optional()
38
- });
9
+ exports.matrixBodySchema = zod_1.z.object({
10
+ locale: zod_1.z.string().optional(),
11
+ parameters: zod_1.z.record(zod_1.z.string()).optional(),
12
+ values: task_item_1.taskItemValueMapSchema.optional(),
13
+ additional: zod_1.z.any().optional()
14
+ }).optional();
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ import { Color, Quality, QualityStyle } from '../types';
3
+ export declare const colorSchema: z.Schema<Color>;
4
+ export declare const qualityStyleSchema: z.Schema<QualityStyle>;
5
+ export declare const qualitySchema: z.Schema<Quality>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.qualitySchema = exports.qualityStyleSchema = exports.colorSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
6
+ const criterion_1 = require("./criterion");
7
+ exports.colorSchema = zod_1.z.union([
8
+ zod_1.z.string(),
9
+ zod_1.z.object({
10
+ red: zod_1.z.number(),
11
+ green: zod_1.z.number(),
12
+ blue: zod_1.z.number()
13
+ })
14
+ ]);
15
+ exports.qualityStyleSchema = zod_1.z.object({
16
+ primaryColor: exports.colorSchema,
17
+ secondaryColor: exports.colorSchema
18
+ });
19
+ exports.qualitySchema = zod_1.z.object({
20
+ type: zod_1.z.literal('quality'),
21
+ title: zod_1.z.string(),
22
+ code: zod_1.z.string(),
23
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
24
+ documentation: zod_1.z.array(task_item_1.documentationItemSchema).optional(),
25
+ data: zod_1.z.record(zod_1.z.any()).optional(),
26
+ sortOrder: zod_1.z.number().optional(),
27
+ style: exports.qualityStyleSchema.optional(),
28
+ items: zod_1.z.array(criterion_1.criterionSchema)
29
+ });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { TaskGroup } from '../types';
3
+ export declare const taskGroupSchema: z.Schema<TaskGroup>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskGroupSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
6
+ const task_1 = require("./task");
7
+ exports.taskGroupSchema = zod_1.z.object({
8
+ type: zod_1.z.literal('task-group'),
9
+ title: zod_1.z.string(),
10
+ code: zod_1.z.string(),
11
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
12
+ documentation: zod_1.z.array(task_item_1.documentationItemSchema).optional(),
13
+ data: zod_1.z.record(zod_1.z.any()).optional(),
14
+ sortOrder: zod_1.z.number().optional(),
15
+ category: zod_1.z.string().optional(),
16
+ items: zod_1.z.array(task_1.taskSchema)
17
+ });
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { BooleanType, DocumentationItem, InlineDocumentationItem, LinkDocumentationItem, NumberType, PdfDocumentationItem, PointOption, SelectMultipleType, SelectSingleType, TaskItem, TaskItemDefinition, TaskItemValueMap } from '../types';
3
+ export declare const pdfDocumentationItem: z.Schema<PdfDocumentationItem>;
4
+ export declare const inlineDocumentationItem: z.Schema<InlineDocumentationItem>;
5
+ export declare const linkDocumentationItem: z.Schema<LinkDocumentationItem>;
6
+ export declare const documentationItemSchema: z.Schema<DocumentationItem>;
7
+ export declare const taskItemScalarValueSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
8
+ 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">]>;
9
+ export declare const taskItemValueMapSchema: z.Schema<TaskItemValueMap>;
10
+ export declare const pointOptionSchema: z.Schema<PointOption>;
11
+ export declare const selectSingleTypeSchema: z.Schema<SelectSingleType>;
12
+ export declare const selectMultipleTypeSchema: z.Schema<SelectMultipleType>;
13
+ export declare const numberTypeSchema: z.Schema<NumberType>;
14
+ export declare const booleanTypeSchema: z.Schema<BooleanType>;
15
+ export declare const taskItemDefinitionSchema: z.Schema<TaskItemDefinition>;
16
+ export declare const taskItemSchema: z.Schema<TaskItem>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskItemSchema = exports.taskItemDefinitionSchema = exports.booleanTypeSchema = exports.numberTypeSchema = exports.selectMultipleTypeSchema = exports.selectSingleTypeSchema = exports.pointOptionSchema = exports.taskItemValueMapSchema = exports.taskItemValueSchema = exports.taskItemScalarValueSchema = exports.documentationItemSchema = exports.linkDocumentationItem = exports.inlineDocumentationItem = exports.pdfDocumentationItem = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.pdfDocumentationItem = zod_1.z.object({
6
+ type: zod_1.z.literal('pdf'),
7
+ label: zod_1.z.string(),
8
+ url: zod_1.z.string(),
9
+ text: zod_1.z.string()
10
+ });
11
+ exports.inlineDocumentationItem = zod_1.z.object({
12
+ type: zod_1.z.literal('text'),
13
+ label: zod_1.z.string(),
14
+ text: zod_1.z.string()
15
+ });
16
+ exports.linkDocumentationItem = zod_1.z.object({
17
+ type: zod_1.z.literal('link'),
18
+ label: zod_1.z.string(),
19
+ url: zod_1.z.string(),
20
+ text: zod_1.z.string()
21
+ });
22
+ exports.documentationItemSchema = zod_1.z.union([
23
+ exports.pdfDocumentationItem,
24
+ exports.inlineDocumentationItem,
25
+ exports.linkDocumentationItem
26
+ ]);
27
+ exports.taskItemScalarValueSchema = zod_1.z.union([
28
+ zod_1.z.string(),
29
+ zod_1.z.number(),
30
+ zod_1.z.boolean(),
31
+ zod_1.z.null()
32
+ ]);
33
+ exports.taskItemValueSchema = zod_1.z.union([exports.taskItemScalarValueSchema, zod_1.z.array(exports.taskItemScalarValueSchema)]);
34
+ exports.taskItemValueMapSchema = zod_1.z.record(zod_1.z.string(), exports.taskItemValueSchema);
35
+ exports.pointOptionSchema = zod_1.z.object({
36
+ id: zod_1.z.string().optional(),
37
+ text: zod_1.z.string(),
38
+ intro: zod_1.z.string().optional(),
39
+ outro: zod_1.z.string().optional(),
40
+ value: exports.taskItemScalarValueSchema
41
+ });
42
+ exports.selectSingleTypeSchema = zod_1.z.object({
43
+ type: zod_1.z.literal('select-single'),
44
+ options: zod_1.z.array(exports.pointOptionSchema)
45
+ });
46
+ exports.selectMultipleTypeSchema = zod_1.z.object({
47
+ type: zod_1.z.literal('select-multiple'),
48
+ options: zod_1.z.array(exports.pointOptionSchema)
49
+ });
50
+ exports.numberTypeSchema = zod_1.z.object({
51
+ type: zod_1.z.literal('number'),
52
+ minimum: zod_1.z.number().optional(),
53
+ maximum: zod_1.z.number().optional(),
54
+ step: zod_1.z.number().optional()
55
+ });
56
+ exports.booleanTypeSchema = zod_1.z.object({
57
+ type: zod_1.z.literal('boolean'),
58
+ labels: zod_1.z.object({
59
+ true: zod_1.z.string().optional(),
60
+ false: zod_1.z.string().optional()
61
+ }).optional()
62
+ });
63
+ exports.taskItemDefinitionSchema = zod_1.z.union([
64
+ exports.selectSingleTypeSchema,
65
+ exports.selectMultipleTypeSchema
66
+ ]);
67
+ exports.taskItemSchema = zod_1.z.object({
68
+ type: zod_1.z.literal('task-item'),
69
+ code: zod_1.z.string(),
70
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
71
+ documentation: zod_1.z.array(exports.documentationItemSchema).optional(),
72
+ data: zod_1.z.record(zod_1.z.string()).optional(),
73
+ sortOrder: zod_1.z.number().optional(),
74
+ definition: exports.taskItemDefinitionSchema,
75
+ description: zod_1.z.string().optional(),
76
+ providedData: exports.taskItemValueMapSchema.optional()
77
+ });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { Task } from '../types';
3
+ export declare const taskSchema: z.Schema<Task>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
6
+ exports.taskSchema = zod_1.z.object({
7
+ type: zod_1.z.literal('task'),
8
+ title: zod_1.z.string(),
9
+ code: zod_1.z.string(),
10
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
11
+ documentation: zod_1.z.array(task_item_1.documentationItemSchema).optional(),
12
+ data: zod_1.z.record(zod_1.z.any()).optional(),
13
+ sortOrder: zod_1.z.number().optional(),
14
+ description: zod_1.z.string().optional(),
15
+ items: zod_1.z.array(task_item_1.taskItemSchema)
16
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { TreeAndDataRequestBody } from '../types';
3
+ /**
4
+ * Validates the request body for the tree and data endpoints
5
+ */
6
+ export declare const treeAndDataBodySchema: z.Schema<TreeAndDataRequestBody | undefined>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.treeAndDataBodySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const task_item_1 = require("./task-item");
6
+ /**
7
+ * Validates the request body for the tree and data endpoints
8
+ */
9
+ exports.treeAndDataBodySchema = zod_1.z.object({
10
+ locale: zod_1.z.string().optional(),
11
+ parameters: zod_1.z.record(zod_1.z.string()).optional(),
12
+ values: task_item_1.taskItemValueMapSchema.optional()
13
+ }).optional();
@@ -1,13 +1,11 @@
1
- import * as yup from 'yup';
1
+ import { z } from 'zod';
2
2
  /**
3
3
  * Validates the version parameter for endpoints which use it
4
4
  */
5
- export declare const versionParamSchema: yup.ObjectSchema<{
6
- params: {
7
- version: string;
8
- };
9
- }, yup.AnyObject, {
10
- params: {
11
- version: undefined;
12
- };
13
- }, "">;
5
+ export declare const versionParamSchema: z.ZodObject<{
6
+ version: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ version: string;
9
+ }, {
10
+ version: string;
11
+ }>;
@@ -1,37 +1,11 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.versionParamSchema = void 0;
27
- const yup = __importStar(require("yup"));
4
+ const zod_1 = require("zod");
28
5
  /**
29
6
  * Validates the version parameter for endpoints which use it
30
7
  */
31
- exports.versionParamSchema = yup.object({
32
- params: yup.object({
33
- version: yup.string()
34
- .matches(/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/, 'Service version must be a SemVer-formatted string which includes exclusively a major, minor and patch version')
35
- .required()
36
- })
8
+ exports.versionParamSchema = zod_1.z.object({
9
+ version: zod_1.z.string()
10
+ .regex(/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/, 'Service version must be a SemVer-formatted string which includes exclusively a major, minor and patch version')
37
11
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openframe-org/criteria-set-protocol",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "description": "A protocol and tools for defining and working with criteria sets",
5
5
  "private": false,
6
6
  "author": "Andrés Angulo <aa@openframe.org>",
@@ -14,10 +14,10 @@
14
14
  "dist/**/*"
15
15
  ],
16
16
  "dependencies": {
17
- "yup": "^1.2.0"
17
+ "@types/node": "^20.6.3",
18
+ "zod": "^3.23.8"
18
19
  },
19
20
  "devDependencies": {
20
- "@types/node": "^20.6.3",
21
21
  "typescript": "^5.2.2"
22
22
  },
23
23
  "publishConfig": {