@openframe-org/criteria-set-protocol 2.5.2 → 2.6.0-beta.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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.treeResultSchema = exports.reportOptionsSchema = exports.criteriaTreeOptionsSchema = exports.documentTreeOptionsSchema = exports.breadcrumbOptionsSchema = exports.abstractElementSchema = exports.criteriaTreeElementTypeSchema = exports.elementDataSchema = exports.taskItemValueSchema = exports.taskItemScalarValueSchema = exports.colorSchema = void 0;
3
+ exports.treeResultSchema = exports.reportOptionsSchema = exports.criteriaTreeOptionsSchema = exports.documentTreeOptionsSchema = exports.breadcrumbOptionsSchema = exports.abstractElementSchema = exports.criteriaTreeElementTypeSchema = exports.elementDataSchema = exports.elementDataTextSchema = exports.elementDataValueSchema = exports.taskItemValueSchema = exports.taskItemScalarValueSchema = exports.colorSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const documentation_1 = require("./documentation");
6
6
  exports.colorSchema = zod_1.z
@@ -20,18 +20,9 @@ exports.taskItemScalarValueSchema = zod_1.z
20
20
  exports.taskItemValueSchema = zod_1.z
21
21
  .union([exports.taskItemScalarValueSchema, zod_1.z.array(exports.taskItemScalarValueSchema)])
22
22
  .describe("TaskItemValue - Can be either a scalar value or an array of scalar values");
23
- exports.elementDataSchema = zod_1.z
24
- .object({
25
- type: zod_1.z
26
- .enum(["number", "percentage", "boolean"])
27
- .optional()
28
- .describe("Type of data"),
29
- value: zod_1.z.number().or(zod_1.z.boolean()).optional().describe("Value of the element"),
30
- text: zod_1.z.string().optional().describe("Text representation of the value"),
31
- total: zod_1.z
32
- .number()
33
- .optional()
34
- .describe("Total value, understood as 'value'/'total'"),
23
+ const abstractElementDataSchema = zod_1.z.object({}).catchall(zod_1.z.any());
24
+ const numericElementDataValueSchema = abstractElementDataSchema.extend(zod_1.z.object({
25
+ value: zod_1.z.number().describe("Value of the element"),
35
26
  maximumValue: zod_1.z
36
27
  .number()
37
28
  .optional()
@@ -49,9 +40,38 @@ exports.elementDataSchema = zod_1.z
49
40
  .optional()
50
41
  .describe("Minimum allowed value (exclusive)"),
51
42
  weight: zod_1.z.number().optional().describe("Weight of the element")
52
- })
53
- .catchall(zod_1.z.any())
43
+ }))
54
44
  .describe("ElementData - Element data containing value constraints and metadata");
45
+ const numberElementDataValueSchema = numericElementDataValueSchema.extend(zod_1.z.object({
46
+ type: zod_1.z
47
+ .literal("number")
48
+ .optional()
49
+ .describe("Type of data - if omitted, defaults to 'number'"),
50
+ total: zod_1.z
51
+ .number()
52
+ .describe("Total value, understood as 'value'/'total'"),
53
+ }));
54
+ const percentageElementDataValueSchema = numericElementDataValueSchema.extend(zod_1.z.object({
55
+ type: zod_1.z
56
+ .literal("percentage")
57
+ .describe("Type of data"),
58
+ value: zod_1.z.number().describe("Value of the element"),
59
+ }));
60
+ const booleanElementDataValueSchema = abstractElementDataSchema.extend(zod_1.z.object({
61
+ type: zod_1.z
62
+ .literal("boolean")
63
+ .describe("Type of data"),
64
+ value: zod_1.z.boolean().describe("Value of the element"),
65
+ }));
66
+ exports.elementDataValueSchema = zod_1.z.discriminatedUnion("type", [
67
+ numberElementDataValueSchema,
68
+ percentageElementDataValueSchema,
69
+ booleanElementDataValueSchema
70
+ ]);
71
+ exports.elementDataTextSchema = zod_1.z.object({
72
+ text: zod_1.z.string().describe("Text representation of the value"),
73
+ });
74
+ exports.elementDataSchema = zod_1.z.intersection(exports.elementDataTextSchema, exports.elementDataValueSchema);
55
75
  exports.criteriaTreeElementTypeSchema = zod_1.z
56
76
  .enum(["theme", "criterion", "task-group", "task", "task-item"])
57
77
  .describe("CriteriaTreeElementType - Types of elements that can exist in the criteria tree hierarchy");