@examplary/schemas 1.3.0 → 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.
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+
3
+ import { Translatable } from "./translatable";
4
+
5
+ // Setting option for enum type settings
6
+ export const QuestionTypeSettingOption = z
7
+ .object({
8
+ value: z.string().describe("Option value"),
9
+ label: Translatable.describe("Option label"),
10
+ })
11
+ .strict()
12
+ .describe("Setting option");
13
+
14
+ // Setting configuration
15
+ export const QuestionTypeSetting = z
16
+ .object({
17
+ id: z.string().describe("Unique identifier for the setting"),
18
+ name: Translatable.describe("Display name for the setting"),
19
+ description: z
20
+ .string()
21
+ .optional()
22
+ .describe(
23
+ "Description to help AI agents auto-generate question settings",
24
+ ),
25
+ type: z
26
+ .enum([
27
+ "enum",
28
+ "string",
29
+ "string-array",
30
+ "number",
31
+ "boolean",
32
+ "custom",
33
+ "scoring-criteria",
34
+ "tags",
35
+ "question-type",
36
+ ])
37
+ .describe("Type of the setting"),
38
+ index: z.number().optional(),
39
+ hidden: z
40
+ .boolean()
41
+ .optional()
42
+ .describe("Whether the setting is hidden from the user"),
43
+ default: z.any().optional().describe("Default value for the setting"),
44
+ required: z
45
+ .boolean()
46
+ .optional()
47
+ .describe("Whether this setting is required"),
48
+ options: z
49
+ .array(QuestionTypeSettingOption)
50
+ .optional()
51
+ .describe("Available options for enum type settings"),
52
+ placeholder: Translatable.optional().describe(
53
+ "Placeholder text for the setting",
54
+ ),
55
+ step: z.number().optional().describe("Step value for number type settings"),
56
+ min: z
57
+ .number()
58
+ .optional()
59
+ .describe("Minimum value for number type settings"),
60
+ max: z
61
+ .number()
62
+ .optional()
63
+ .describe("Maximum value for number type settings"),
64
+ })
65
+ .strict()
66
+ .describe("Setting configuration");
67
+
68
+ export type SettingType = z.infer<typeof QuestionTypeSetting>;
69
+ export type SettingOptionType = z.infer<typeof QuestionTypeSettingOption>;
@@ -1,103 +1,14 @@
1
1
  import { z } from "zod";
2
2
 
3
- // Translatable type - can be a simple string or translation object
4
- const Translatable = z.union([
5
- z.string().describe("Simple string value"),
6
- z
7
- .record(
8
- z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, "Language code format"),
9
- z.string(),
10
- )
11
- .refine(
12
- (obj) => Object.keys(obj).length >= 1,
13
- "Translation object must have at least one property",
14
- )
15
- .describe("Translation object with language codes as keys"),
16
- ]);
3
+ import {
4
+ PathOrUrlReference,
5
+ QuestionTypeComponents,
6
+ } from "./question-type-components";
7
+ import { QuestionTypeGenerationOptions } from "./question-type-generation-options";
8
+ import { QuestionTypeGradingOptions } from "./question-type-grading-options";
9
+ import { QuestionTypeSetting } from "./question-type-setting";
10
+ import { Translatable } from "./translatable";
17
11
 
18
- // Path or URL reference type
19
- const PathOrUrlReference = z
20
- .string()
21
- .regex(
22
- /^(https?:\/\/|\.)([a-zA-Z0-9._~:/?#@!$&'()*+,;=%-]+)$/,
23
- "Valid path or URL format",
24
- );
25
-
26
- // Component reference type
27
- const ComponentReference = PathOrUrlReference.describe(
28
- "Reference to a component, typically a file path or URL",
29
- );
30
-
31
- // Setting option for enum type settings
32
- const SettingOption = z
33
- .object({
34
- value: z.string().describe("Option value"),
35
- label: Translatable.describe("Option label"),
36
- })
37
- .strict()
38
- .describe("Setting option");
39
-
40
- // Setting configuration
41
- const Setting = z
42
- .object({
43
- id: z.string().describe("Unique identifier for the setting"),
44
- name: Translatable.describe("Display name for the setting"),
45
- type: z
46
- .enum([
47
- "enum",
48
- "string",
49
- "number",
50
- "boolean",
51
- "custom",
52
- "scoring-criteria",
53
- "question-type",
54
- ])
55
- .describe("Type of the setting"),
56
- default: z.any().optional().describe("Default value for the setting"),
57
- required: z
58
- .boolean()
59
- .optional()
60
- .describe("Whether this setting is required"),
61
- options: z
62
- .array(SettingOption)
63
- .optional()
64
- .describe("Available options for enum type settings"),
65
- placeholder: Translatable.optional().describe(
66
- "Placeholder text for the setting",
67
- ),
68
- step: z.number().optional().describe("Step value for number type settings"),
69
- min: z
70
- .number()
71
- .optional()
72
- .describe("Minimum value for number type settings"),
73
- max: z
74
- .number()
75
- .optional()
76
- .describe("Maximum value for number type settings"),
77
- })
78
- .strict()
79
- .describe("Setting configuration");
80
-
81
- // Components configuration
82
- const Components = z
83
- .object({
84
- assessment: ComponentReference.optional().describe(
85
- "Path to the assessment component (question content)",
86
- ),
87
- print: ComponentReference.optional().describe(
88
- "Path to the print component (for printing the question)",
89
- ),
90
- "settings-area": ComponentReference.optional().describe(
91
- "Path to the settings area component (for configuring question settings)",
92
- ),
93
- results: ComponentReference.optional().describe(
94
- "Path to the results component (for displaying answers)",
95
- ),
96
- })
97
- .strict()
98
- .describe("Paths to the components used by this question type");
99
-
100
- // Main question type schema
101
12
  export const QuestionTypeSchema = z
102
13
  .object({
103
14
  $schema: z.string().optional(),
@@ -124,10 +35,8 @@ export const QuestionTypeSchema = z
124
35
  .max(1)
125
36
  .optional()
126
37
  .describe("Keyboard shortcut for quick access to this question type"),
127
- canAutoGenerate: z
128
- .boolean()
129
- .optional()
130
- .describe("Whether this question type can be automatically generated"),
38
+ generation: QuestionTypeGenerationOptions.optional(),
39
+ grading: QuestionTypeGradingOptions.optional(),
131
40
  timeEstimateMinutes: z
132
41
  .number()
133
42
  .min(1)
@@ -173,11 +82,11 @@ export const QuestionTypeSchema = z
173
82
  untitledPlaceholder: Translatable.optional().describe(
174
83
  "Placeholder text for untitled questions",
175
84
  ),
176
- components: Components.optional().describe(
85
+ components: QuestionTypeComponents.optional().describe(
177
86
  "Paths to the components used by this question type",
178
87
  ),
179
88
  settings: z
180
- .array(Setting)
89
+ .array(QuestionTypeSetting)
181
90
  .optional()
182
91
  .describe("Configuration settings for the question type"),
183
92
  public: z
@@ -197,8 +106,3 @@ export const QuestionTypeSchema = z
197
106
  .describe("Schema for defining question types in the Examplary system");
198
107
 
199
108
  export type QuestionType = z.infer<typeof QuestionTypeSchema>;
200
- export type TranslatableType = z.infer<typeof Translatable>;
201
- export type ComponentReferenceType = z.infer<typeof ComponentReference>;
202
- export type SettingType = z.infer<typeof Setting>;
203
- export type SettingOptionType = z.infer<typeof SettingOption>;
204
- export type ComponentsType = z.infer<typeof Components>;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+
3
+ // Translatable type - can be a simple string or translation object
4
+ export const Translatable = z.union([
5
+ z.string().describe("Simple string value"),
6
+ z
7
+ .record(
8
+ z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, "Language code format"),
9
+ z.string(),
10
+ )
11
+ .refine(
12
+ (obj) => Object.keys(obj).length >= 1,
13
+ "Translation object must have at least one property",
14
+ )
15
+ .describe("Translation object with language codes as keys"),
16
+ ]);
17
+ export type TranslatableType = z.infer<typeof Translatable>;