@examplary/schemas 0.0.1

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/.env ADDED
@@ -0,0 +1 @@
1
+ SERVERLESS_ACCESS_KEY=AKaam9TxRjIdaDijtpL22kSIfgFP8UfuTiOeXjEWTvLqR
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@examplary/schemas",
3
+ "packageManager": "yarn@4.8.1",
4
+ "version": "0.0.1",
5
+ "description": "Schemas for the Examplary platform.",
6
+ "scripts": {
7
+ "build:schema": "tsx ./scripts/build.ts",
8
+ "build:tsc": "tsc ./src/index.ts --outDir dist --skipLibCheck --declaration",
9
+ "start": "yarn build:tsc --watch",
10
+ "build": "yarn build:tsc && yarn build:schema",
11
+ "deploy": "serverless deploy --verbose --stage ${STAGE:-dev}",
12
+ "release": "semantic-release -e semantic-release-monorepo"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "devDependencies": {
17
+ "serverless": "^4.17.2",
18
+ "serverless-lift": "^1.31.0",
19
+ "tsx": "^4.20.3",
20
+ "typescript": "^5.8.3"
21
+ },
22
+ "dependencies": {
23
+ "zod": "^4.0.10"
24
+ },
25
+ "homepage": "https://developers.examplary.ai",
26
+ "author": {
27
+ "name": "Examplary AI",
28
+ "email": "hi@examplary.ai"
29
+ }
30
+ }
@@ -0,0 +1,16 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+
3
+ import * as z from "zod";
4
+
5
+ import { QuestionTypeSchema } from "../src";
6
+
7
+ (async () => {
8
+ await mkdir("./dist/schemas", { recursive: true });
9
+ await writeFile(
10
+ "./dist/schemas/question-type.json",
11
+ JSON.stringify(z.toJSONSchema(QuestionTypeSchema), null, 2),
12
+ "utf-8",
13
+ );
14
+
15
+ console.log("Schema built successfully!");
16
+ })();
package/serverless.yml ADDED
@@ -0,0 +1,25 @@
1
+ service: schemas
2
+
3
+ params:
4
+ default:
5
+ domain: schemas-${sls:stage}.examplary.ai
6
+ certificateArn: arn:aws:acm:us-east-1:864899853846:certificate/98929ce6-38a5-41ec-ac3c-6abd2f46087f
7
+ production:
8
+ domain: schemas.examplary.ai
9
+ certificateArn: arn:aws:acm:us-east-1:864899853846:certificate/98929ce6-38a5-41ec-ac3c-6abd2f46087f
10
+
11
+ provider:
12
+ name: aws
13
+ region: eu-central-1
14
+ stage: ${opt:stage, 'dev'}
15
+ deploymentMethod: direct
16
+
17
+ plugins:
18
+ - serverless-lift
19
+
20
+ constructs:
21
+ schemas:
22
+ type: static-website
23
+ path: dist/schemas
24
+ domain: ${param:domain}
25
+ certificate: ${param:certificateArn}
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./question-type";
2
+ export type * from "./question-type";
@@ -0,0 +1,203 @@
1
+ import { z } from "zod";
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
+ ]);
17
+
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
+ export const QuestionTypeSchema = z
102
+ .object({
103
+ $schema: z.string().optional(),
104
+ id: z
105
+ .string()
106
+ .regex(
107
+ /^([a-z][a-z0-9-]*)(\.[a-z][a-z0-9-]*)+$/,
108
+ "Valid question type ID format",
109
+ )
110
+ .describe(
111
+ "Unique identifier for the question type (e.g. 'my-org.color-picker')",
112
+ ),
113
+ name: Translatable.describe(
114
+ "Display name for the question type, can be a simple string or translation object",
115
+ ),
116
+ description: Translatable.describe(
117
+ "Description of the question type, can be a simple string or translation object",
118
+ ),
119
+ icon: PathOrUrlReference.optional().describe(
120
+ "Path to the icon for this question type",
121
+ ),
122
+ shortcut: z
123
+ .string()
124
+ .max(1)
125
+ .optional()
126
+ .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"),
131
+ timeEstimateMinutes: z
132
+ .number()
133
+ .min(1)
134
+ .optional()
135
+ .describe("Estimated time in minutes to complete this question type"),
136
+ isAi: z
137
+ .boolean()
138
+ .optional()
139
+ .describe("Whether this question type uses AI functionality"),
140
+ backgroundColor: z
141
+ .string()
142
+ .optional()
143
+ .describe("Background color for the question type"),
144
+ iconBackgroundColor: z
145
+ .string()
146
+ .optional()
147
+ .describe("Background color for the question type icon"),
148
+ enforcePosition: z
149
+ .enum(["start", "end"])
150
+ .optional()
151
+ .describe("Position enforcement for this question type"),
152
+ enforceTitle: Translatable.optional().describe(
153
+ "Enforced title for this question type",
154
+ ),
155
+ hideSettings: z
156
+ .boolean()
157
+ .optional()
158
+ .describe("Whether to hide settings for this question type"),
159
+ isPreviewRefreshable: z
160
+ .boolean()
161
+ .optional()
162
+ .describe("Whether the preview can be refreshed for this question type"),
163
+ hasSimpleScoring: z
164
+ .boolean()
165
+ .optional()
166
+ .describe("Whether this question type has simple scoring"),
167
+ titlePlaceholder: Translatable.optional().describe(
168
+ "Placeholder text for the title field",
169
+ ),
170
+ descriptionPlaceholder: Translatable.optional().describe(
171
+ "Placeholder text for the description field",
172
+ ),
173
+ untitledPlaceholder: Translatable.optional().describe(
174
+ "Placeholder text for untitled questions",
175
+ ),
176
+ components: Components.optional().describe(
177
+ "Paths to the components used by this question type",
178
+ ),
179
+ settings: z
180
+ .array(Setting)
181
+ .optional()
182
+ .describe("Configuration settings for the question type"),
183
+ public: z
184
+ .boolean()
185
+ .optional()
186
+ .describe(
187
+ "Whether this question type is public and can be used by all users",
188
+ ),
189
+ translations: z
190
+ .record(z.string(), Translatable)
191
+ .optional()
192
+ .describe("Custom translations for this question type"),
193
+ index: z.number().optional(),
194
+ })
195
+ .strict()
196
+ .describe("Schema for defining question types in the Examplary system");
197
+
198
+ export type QuestionType = z.infer<typeof QuestionTypeSchema>;
199
+ export type TranslatableType = z.infer<typeof Translatable>;
200
+ export type ComponentReferenceType = z.infer<typeof ComponentReference>;
201
+ export type SettingType = z.infer<typeof Setting>;
202
+ export type SettingOptionType = z.infer<typeof SettingOption>;
203
+ export type ComponentsType = z.infer<typeof Components>;
File without changes