@examplary/schemas 1.3.0 → 1.4.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.
- package/.serverless/cloudformation-template-update-stack.json +7 -10
- package/.serverless/meta.json +27 -26
- package/.serverless/serverless-state.json +22 -24
- package/.turbo/turbo-deploy.log +14 -13
- package/.turbo/turbo-release.log +78 -68
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/question-type-components.d.ts +11 -0
- package/dist/question-type-components.js +20 -0
- package/dist/question-type-generation-options.d.ts +6 -0
- package/dist/question-type-generation-options.js +15 -0
- package/dist/question-type-grading-options.d.ts +6 -0
- package/dist/question-type-grading-options.js +15 -0
- package/dist/question-type-setting.d.ts +33 -0
- package/dist/question-type-setting.js +60 -0
- package/dist/question-type.d.ts +11 -42
- package/dist/question-type.js +17 -85
- package/dist/schemas/question-type.json +44 -3
- package/dist/translatable.d.ts +3 -0
- package/dist/translatable.js +12 -0
- package/package.json +7 -7
- package/src/index.ts +11 -0
- package/src/question-type-components.ts +36 -0
- package/src/question-type-generation-options.ts +21 -0
- package/src/question-type-grading-options.ts +21 -0
- package/src/question-type-setting.ts +67 -0
- package/src/question-type.ts +12 -108
- package/src/translatable.ts +17 -0
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
"question-type",
|
|
35
|
+
])
|
|
36
|
+
.describe("Type of the setting"),
|
|
37
|
+
hidden: z
|
|
38
|
+
.boolean()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Whether the setting is hidden from the user"),
|
|
41
|
+
default: z.any().optional().describe("Default value for the setting"),
|
|
42
|
+
required: z
|
|
43
|
+
.boolean()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Whether this setting is required"),
|
|
46
|
+
options: z
|
|
47
|
+
.array(QuestionTypeSettingOption)
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Available options for enum type settings"),
|
|
50
|
+
placeholder: Translatable.optional().describe(
|
|
51
|
+
"Placeholder text for the setting",
|
|
52
|
+
),
|
|
53
|
+
step: z.number().optional().describe("Step value for number type settings"),
|
|
54
|
+
min: z
|
|
55
|
+
.number()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Minimum value for number type settings"),
|
|
58
|
+
max: z
|
|
59
|
+
.number()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Maximum value for number type settings"),
|
|
62
|
+
})
|
|
63
|
+
.strict()
|
|
64
|
+
.describe("Setting configuration");
|
|
65
|
+
|
|
66
|
+
export type SettingType = z.infer<typeof QuestionTypeSetting>;
|
|
67
|
+
export type SettingOptionType = z.infer<typeof QuestionTypeSettingOption>;
|
package/src/question-type.ts
CHANGED
|
@@ -1,103 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
128
|
-
|
|
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:
|
|
85
|
+
components: QuestionTypeComponents.optional().describe(
|
|
177
86
|
"Paths to the components used by this question type",
|
|
178
87
|
),
|
|
179
88
|
settings: z
|
|
180
|
-
.array(
|
|
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>;
|