@digimakers/core 0.2.1 → 0.3.20

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.
Files changed (56) hide show
  1. package/dist/agents/code-formatter.d.ts +2 -0
  2. package/dist/agents/code-formatter.d.ts.map +1 -0
  3. package/dist/agents/code-formatter.js +23 -0
  4. package/dist/agents/code-formatter.js.map +1 -0
  5. package/dist/docling-cleaner/cleaner.py +34 -0
  6. package/dist/docling-cleaner/pyproject.toml +10 -0
  7. package/dist/docling-cleaner/uv.lock +2077 -0
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +0 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/parsing/docling-parser.d.ts +17 -0
  13. package/dist/parsing/docling-parser.d.ts.map +1 -0
  14. package/dist/parsing/docling-parser.js +109 -0
  15. package/dist/parsing/docling-parser.js.map +1 -0
  16. package/dist/parsing/docling-runners.d.ts +2 -0
  17. package/dist/parsing/docling-runners.d.ts.map +1 -0
  18. package/dist/parsing/docling-runners.js +85 -0
  19. package/dist/parsing/docling-runners.js.map +1 -0
  20. package/dist/parsing/docx-parser.d.ts +2 -2
  21. package/dist/parsing/docx-parser.d.ts.map +1 -1
  22. package/dist/parsing/docx-parser.js +118 -45
  23. package/dist/parsing/docx-parser.js.map +1 -1
  24. package/dist/parsing/index.d.ts +3 -0
  25. package/dist/parsing/index.d.ts.map +1 -1
  26. package/dist/parsing/index.js +2 -0
  27. package/dist/parsing/index.js.map +1 -1
  28. package/dist/parsing/normalise.d.ts +1 -0
  29. package/dist/parsing/normalise.d.ts.map +1 -1
  30. package/dist/parsing/normalise.js +41 -1
  31. package/dist/parsing/normalise.js.map +1 -1
  32. package/dist/parsing/post-processors.d.ts +6 -0
  33. package/dist/parsing/post-processors.d.ts.map +1 -0
  34. package/dist/parsing/post-processors.js +217 -0
  35. package/dist/parsing/post-processors.js.map +1 -0
  36. package/dist/parsing/prompts.d.ts +5 -0
  37. package/dist/parsing/prompts.d.ts.map +1 -0
  38. package/dist/parsing/prompts.js +24 -0
  39. package/dist/parsing/prompts.js.map +1 -0
  40. package/dist/pdf-generator.d.ts +3 -3
  41. package/dist/pdf-generator.d.ts.map +1 -1
  42. package/dist/pdf-generator.js +1 -1
  43. package/dist/pdf-generator.js.map +1 -1
  44. package/dist/sample-data.d.ts +2 -2
  45. package/dist/sample-data.d.ts.map +1 -1
  46. package/dist/sample-data.js +8 -7
  47. package/dist/sample-data.js.map +1 -1
  48. package/dist/schemas/index.d.ts +1 -1
  49. package/dist/schemas/index.d.ts.map +1 -1
  50. package/dist/schemas/index.js +1 -1
  51. package/dist/schemas/index.js.map +1 -1
  52. package/dist/schemas/lesson.d.ts +385 -39
  53. package/dist/schemas/lesson.d.ts.map +1 -1
  54. package/dist/schemas/lesson.js +96 -34
  55. package/dist/schemas/lesson.js.map +1 -1
  56. package/package.json +5 -3
@@ -8,31 +8,227 @@ export declare const languageEnum: z.ZodEnum<{
8
8
  java: "java";
9
9
  c: "c";
10
10
  }>;
11
- export declare const StepWithImageSchema: z.ZodObject<{
12
- step: z.ZodString;
13
- image: z.ZodDefault<z.ZodNullable<z.ZodString>>;
11
+ export declare const ImageSlotSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ base64: z.ZodOptional<z.ZodString>;
14
14
  }, z.core.$strip>;
15
15
  export declare const StepsWithCodeBlockSchema: z.ZodObject<{
16
16
  steps: z.ZodArray<z.ZodString>;
17
- codeBlock: z.ZodPipe<z.ZodDefault<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null>>;
17
+ codeBlock: z.ZodDefault<z.ZodNullable<z.ZodString>>;
18
18
  }, z.core.$strip>;
19
- export declare const MultipleStepsWithCodeBlockSchema: z.ZodArray<z.ZodObject<{
20
- steps: z.ZodArray<z.ZodString>;
21
- codeBlock: z.ZodPipe<z.ZodDefault<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null>>;
22
- }, z.core.$strip>>;
23
19
  export declare const ChallengeSchema: z.ZodObject<{
24
20
  name: z.ZodString;
25
21
  task: z.ZodString;
26
- hintCode: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
22
+ hintCode: z.ZodNullable<z.ZodString>;
27
23
  }, z.core.$strip>;
28
24
  export declare const NewProjectSchema: z.ZodObject<{
29
25
  name: z.ZodString;
30
26
  task: z.ZodString;
31
27
  }, z.core.$strip>;
32
- export declare const ParsedLessonSchema: z.ZodObject<{
28
+ export declare const ProgrammingLessonSchema: z.ZodObject<{
29
+ lessonType: z.ZodLiteral<"text-based (programming) lesson">;
30
+ topic: z.ZodString;
31
+ project: z.ZodString;
32
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
33
+ projectExplainer: z.ZodString;
34
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
35
+ none: "none";
36
+ scratch: "scratch";
37
+ "small-basic": "small-basic";
38
+ "javascript or html or css": "javascript or html or css";
39
+ python: "python";
40
+ java: "java";
41
+ c: "c";
42
+ }>>;
43
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
44
+ id: z.ZodString;
45
+ base64: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strip>>>;
47
+ getReadySection: z.ZodArray<z.ZodString>;
48
+ addYourCodeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
49
+ steps: z.ZodArray<z.ZodString>;
50
+ codeBlock: z.ZodDefault<z.ZodNullable<z.ZodString>>;
51
+ }, z.core.$strip>>>;
52
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
53
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
54
+ name: z.ZodString;
55
+ task: z.ZodString;
56
+ hintCode: z.ZodNullable<z.ZodString>;
57
+ }, z.core.$strip>>>;
58
+ newProject: z.ZodNullable<z.ZodObject<{
59
+ name: z.ZodString;
60
+ task: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ testYourself: z.ZodNullable<z.ZodString>;
63
+ funFact: z.ZodNullable<z.ZodString>;
64
+ }, z.core.$strip>;
65
+ export declare const StepWithImageSchema: z.ZodObject<{
66
+ step: z.ZodString;
67
+ imageSlot: z.ZodDefault<z.ZodNullable<z.ZodObject<{
68
+ id: z.ZodString;
69
+ base64: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>>>;
71
+ }, z.core.$strip>;
72
+ export declare const ScratchLessonSchema: z.ZodObject<{
73
+ topic: z.ZodString;
74
+ project: z.ZodString;
75
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
76
+ projectExplainer: z.ZodString;
77
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
78
+ none: "none";
79
+ scratch: "scratch";
80
+ "small-basic": "small-basic";
81
+ "javascript or html or css": "javascript or html or css";
82
+ python: "python";
83
+ java: "java";
84
+ c: "c";
85
+ }>>;
86
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
87
+ id: z.ZodString;
88
+ base64: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>>>;
90
+ getReadySection: z.ZodArray<z.ZodString>;
91
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
92
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
93
+ name: z.ZodString;
94
+ task: z.ZodString;
95
+ hintCode: z.ZodNullable<z.ZodString>;
96
+ }, z.core.$strip>>>;
97
+ newProject: z.ZodNullable<z.ZodObject<{
98
+ name: z.ZodString;
99
+ task: z.ZodString;
100
+ }, z.core.$strip>>;
101
+ testYourself: z.ZodNullable<z.ZodString>;
102
+ funFact: z.ZodNullable<z.ZodString>;
103
+ lessonType: z.ZodLiteral<"block-based (scratch) lesson">;
104
+ addYourCodeSection: z.ZodArray<z.ZodObject<{
105
+ step: z.ZodString;
106
+ imageSlot: z.ZodDefault<z.ZodNullable<z.ZodObject<{
107
+ id: z.ZodString;
108
+ base64: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strip>>>;
110
+ }, z.core.$strip>>;
111
+ }, z.core.$strip>;
112
+ export declare const ScratchLessonLLMSchema: z.ZodObject<{
113
+ lessonType: z.ZodLiteral<"block-based (scratch) lesson">;
114
+ topic: z.ZodString;
115
+ project: z.ZodString;
116
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
117
+ projectExplainer: z.ZodString;
118
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
119
+ none: "none";
120
+ scratch: "scratch";
121
+ "small-basic": "small-basic";
122
+ "javascript or html or css": "javascript or html or css";
123
+ python: "python";
124
+ java: "java";
125
+ c: "c";
126
+ }>>;
127
+ getReadySection: z.ZodArray<z.ZodString>;
128
+ addYourCodeSection: z.ZodArray<z.ZodObject<{
129
+ step: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
132
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
133
+ name: z.ZodString;
134
+ task: z.ZodString;
135
+ hintCode: z.ZodNullable<z.ZodString>;
136
+ }, z.core.$strip>>>;
137
+ newProject: z.ZodNullable<z.ZodObject<{
138
+ name: z.ZodString;
139
+ task: z.ZodString;
140
+ }, z.core.$strip>>;
141
+ testYourself: z.ZodNullable<z.ZodString>;
142
+ funFact: z.ZodNullable<z.ZodString>;
143
+ }, z.core.$strip>;
144
+ export declare const DebugStepSchema: z.ZodObject<{
145
+ linkToCode: z.ZodURL;
146
+ issue: z.ZodString;
147
+ }, z.core.$strip>;
148
+ export declare const DebugLessonSchema: z.ZodObject<{
149
+ lessonType: z.ZodLiteral<"debugging lesson">;
150
+ topic: z.ZodString;
151
+ project: z.ZodString;
152
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
153
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
154
+ none: "none";
155
+ scratch: "scratch";
156
+ "small-basic": "small-basic";
157
+ "javascript or html or css": "javascript or html or css";
158
+ python: "python";
159
+ java: "java";
160
+ c: "c";
161
+ }>>;
162
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
163
+ id: z.ZodString;
164
+ base64: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>>>;
166
+ getReadySection: z.ZodArray<z.ZodString>;
167
+ debugSection: z.ZodArray<z.ZodObject<{
168
+ linkToCode: z.ZodURL;
169
+ issue: z.ZodString;
170
+ }, z.core.$strip>>;
171
+ }, z.core.$strip>;
172
+ export declare const DebugLessonLLMSchema: z.ZodObject<{
173
+ lessonType: z.ZodLiteral<"debugging lesson">;
174
+ topic: z.ZodString;
175
+ project: z.ZodString;
176
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
177
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
178
+ none: "none";
179
+ scratch: "scratch";
180
+ "small-basic": "small-basic";
181
+ "javascript or html or css": "javascript or html or css";
182
+ python: "python";
183
+ java: "java";
184
+ c: "c";
185
+ }>>;
186
+ getReadySection: z.ZodArray<z.ZodString>;
187
+ debugSection: z.ZodArray<z.ZodObject<{
188
+ linkToCode: z.ZodURL;
189
+ issue: z.ZodString;
190
+ }, z.core.$strip>>;
191
+ }, z.core.$strip>;
192
+ export declare const LessonSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
193
+ lessonType: z.ZodLiteral<"text-based (programming) lesson">;
194
+ topic: z.ZodString;
195
+ project: z.ZodString;
196
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
197
+ projectExplainer: z.ZodString;
198
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
199
+ none: "none";
200
+ scratch: "scratch";
201
+ "small-basic": "small-basic";
202
+ "javascript or html or css": "javascript or html or css";
203
+ python: "python";
204
+ java: "java";
205
+ c: "c";
206
+ }>>;
207
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
208
+ id: z.ZodString;
209
+ base64: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strip>>>;
211
+ getReadySection: z.ZodArray<z.ZodString>;
212
+ addYourCodeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
213
+ steps: z.ZodArray<z.ZodString>;
214
+ codeBlock: z.ZodDefault<z.ZodNullable<z.ZodString>>;
215
+ }, z.core.$strip>>>;
216
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
217
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
218
+ name: z.ZodString;
219
+ task: z.ZodString;
220
+ hintCode: z.ZodNullable<z.ZodString>;
221
+ }, z.core.$strip>>>;
222
+ newProject: z.ZodNullable<z.ZodObject<{
223
+ name: z.ZodString;
224
+ task: z.ZodString;
225
+ }, z.core.$strip>>;
226
+ testYourself: z.ZodNullable<z.ZodString>;
227
+ funFact: z.ZodNullable<z.ZodString>;
228
+ }, z.core.$strip>, z.ZodObject<{
33
229
  topic: z.ZodString;
34
230
  project: z.ZodString;
35
- description: z.ZodString;
231
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
36
232
  projectExplainer: z.ZodString;
37
233
  programmingLanguage: z.ZodDefault<z.ZodEnum<{
38
234
  none: "none";
@@ -43,42 +239,192 @@ export declare const ParsedLessonSchema: z.ZodObject<{
43
239
  java: "java";
44
240
  c: "c";
45
241
  }>>;
46
- projectImage: z.ZodDefault<z.ZodNullable<z.ZodString>>;
242
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
243
+ id: z.ZodString;
244
+ base64: z.ZodOptional<z.ZodString>;
245
+ }, z.core.$strip>>>;
47
246
  getReadySection: z.ZodArray<z.ZodString>;
48
- addYourCodeSection: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
247
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
248
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
249
+ name: z.ZodString;
250
+ task: z.ZodString;
251
+ hintCode: z.ZodNullable<z.ZodString>;
252
+ }, z.core.$strip>>>;
253
+ newProject: z.ZodNullable<z.ZodObject<{
254
+ name: z.ZodString;
255
+ task: z.ZodString;
256
+ }, z.core.$strip>>;
257
+ testYourself: z.ZodNullable<z.ZodString>;
258
+ funFact: z.ZodNullable<z.ZodString>;
259
+ lessonType: z.ZodLiteral<"block-based (scratch) lesson">;
260
+ addYourCodeSection: z.ZodArray<z.ZodObject<{
49
261
  step: z.ZodString;
50
- image: z.ZodDefault<z.ZodNullable<z.ZodString>>;
51
- }, z.core.$strip>>, z.ZodObject<{
262
+ imageSlot: z.ZodDefault<z.ZodNullable<z.ZodObject<{
263
+ id: z.ZodString;
264
+ base64: z.ZodOptional<z.ZodString>;
265
+ }, z.core.$strip>>>;
266
+ }, z.core.$strip>>;
267
+ }, z.core.$strip>, z.ZodObject<{
268
+ lessonType: z.ZodLiteral<"debugging lesson">;
269
+ topic: z.ZodString;
270
+ project: z.ZodString;
271
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
272
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
273
+ none: "none";
274
+ scratch: "scratch";
275
+ "small-basic": "small-basic";
276
+ "javascript or html or css": "javascript or html or css";
277
+ python: "python";
278
+ java: "java";
279
+ c: "c";
280
+ }>>;
281
+ prefaceImageSlots: z.ZodNullable<z.ZodArray<z.ZodObject<{
282
+ id: z.ZodString;
283
+ base64: z.ZodOptional<z.ZodString>;
284
+ }, z.core.$strip>>>;
285
+ getReadySection: z.ZodArray<z.ZodString>;
286
+ debugSection: z.ZodArray<z.ZodObject<{
287
+ linkToCode: z.ZodURL;
288
+ issue: z.ZodString;
289
+ }, z.core.$strip>>;
290
+ }, z.core.$strip>], "lessonType">;
291
+ export declare const LessonLLMSchema: z.ZodUnion<readonly [z.ZodObject<{
292
+ topic: z.ZodString;
293
+ project: z.ZodString;
294
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
295
+ projectExplainer: z.ZodString;
296
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
297
+ none: "none";
298
+ scratch: "scratch";
299
+ "small-basic": "small-basic";
300
+ "javascript or html or css": "javascript or html or css";
301
+ python: "python";
302
+ java: "java";
303
+ c: "c";
304
+ }>>;
305
+ getReadySection: z.ZodArray<z.ZodString>;
306
+ addYourCodeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
52
307
  steps: z.ZodArray<z.ZodString>;
53
- codeBlock: z.ZodPipe<z.ZodDefault<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null>>;
54
- }, z.core.$strip>, z.ZodArray<z.ZodObject<{
308
+ codeBlock: z.ZodDefault<z.ZodNullable<z.ZodString>>;
309
+ }, z.core.$strip>>>;
310
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
311
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
312
+ name: z.ZodString;
313
+ task: z.ZodString;
314
+ hintCode: z.ZodNullable<z.ZodString>;
315
+ }, z.core.$strip>>>;
316
+ newProject: z.ZodNullable<z.ZodObject<{
317
+ name: z.ZodString;
318
+ task: z.ZodString;
319
+ }, z.core.$strip>>;
320
+ funFact: z.ZodNullable<z.ZodString>;
321
+ }, z.core.$strip>, z.ZodObject<{
322
+ topic: z.ZodString;
323
+ project: z.ZodString;
324
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
325
+ projectExplainer: z.ZodString;
326
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
327
+ none: "none";
328
+ scratch: "scratch";
329
+ "small-basic": "small-basic";
330
+ "javascript or html or css": "javascript or html or css";
331
+ python: "python";
332
+ java: "java";
333
+ c: "c";
334
+ }>>;
335
+ getReadySection: z.ZodArray<z.ZodString>;
336
+ addYourCodeSection: z.ZodArray<z.ZodObject<{
337
+ step: z.ZodString;
338
+ }, z.core.$strip>>;
339
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
340
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
341
+ name: z.ZodString;
342
+ task: z.ZodString;
343
+ hintCode: z.ZodNullable<z.ZodString>;
344
+ }, z.core.$strip>>>;
345
+ newProject: z.ZodNullable<z.ZodObject<{
346
+ name: z.ZodString;
347
+ task: z.ZodString;
348
+ }, z.core.$strip>>;
349
+ testYourself: z.ZodNullable<z.ZodString>;
350
+ funFact: z.ZodNullable<z.ZodString>;
351
+ }, z.core.$strip>, z.ZodObject<{
352
+ topic: z.ZodString;
353
+ project: z.ZodString;
354
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
355
+ programmingLanguage: z.ZodDefault<z.ZodEnum<{
356
+ none: "none";
357
+ scratch: "scratch";
358
+ "small-basic": "small-basic";
359
+ "javascript or html or css": "javascript or html or css";
360
+ python: "python";
361
+ java: "java";
362
+ c: "c";
363
+ }>>;
364
+ getReadySection: z.ZodArray<z.ZodString>;
365
+ debugSection: z.ZodArray<z.ZodObject<{
366
+ linkToCode: z.ZodURL;
367
+ issue: z.ZodString;
368
+ }, z.core.$strip>>;
369
+ }, z.core.$strip>]>;
370
+ export declare const LessonLLMSchemaWithoutLanguage: z.ZodUnion<readonly [z.ZodObject<{
371
+ topic: z.ZodString;
372
+ project: z.ZodString;
373
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
374
+ projectExplainer: z.ZodString;
375
+ getReadySection: z.ZodArray<z.ZodString>;
376
+ addYourCodeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
55
377
  steps: z.ZodArray<z.ZodString>;
56
- codeBlock: z.ZodPipe<z.ZodDefault<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null>>;
57
- }, z.core.$strip>>]>;
58
- tryItOutSection: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
59
- challengeSection: z.ZodArray<z.ZodObject<{
378
+ codeBlock: z.ZodDefault<z.ZodNullable<z.ZodString>>;
379
+ }, z.core.$strip>>>;
380
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
381
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
382
+ name: z.ZodString;
383
+ task: z.ZodString;
384
+ hintCode: z.ZodNullable<z.ZodString>;
385
+ }, z.core.$strip>>>;
386
+ newProject: z.ZodNullable<z.ZodObject<{
60
387
  name: z.ZodString;
61
388
  task: z.ZodString;
62
- hintCode: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<string | null, string | null>>;
63
389
  }, z.core.$strip>>;
64
- newProject: z.ZodObject<{
390
+ funFact: z.ZodNullable<z.ZodString>;
391
+ }, z.core.$strip>, z.ZodObject<{
392
+ topic: z.ZodString;
393
+ project: z.ZodString;
394
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
395
+ projectExplainer: z.ZodString;
396
+ getReadySection: z.ZodArray<z.ZodString>;
397
+ addYourCodeSection: z.ZodArray<z.ZodObject<{
398
+ step: z.ZodString;
399
+ }, z.core.$strip>>;
400
+ tryItOutSection: z.ZodNullable<z.ZodArray<z.ZodString>>;
401
+ challengeSection: z.ZodNullable<z.ZodArray<z.ZodObject<{
65
402
  name: z.ZodString;
66
403
  task: z.ZodString;
67
- }, z.core.$strip>;
68
- testYourself: z.ZodDefault<z.ZodNullable<z.ZodString>>;
69
- funFact: z.ZodDefault<z.ZodNullable<z.ZodString>>;
70
- }, z.core.$strip>;
404
+ hintCode: z.ZodNullable<z.ZodString>;
405
+ }, z.core.$strip>>>;
406
+ newProject: z.ZodNullable<z.ZodObject<{
407
+ name: z.ZodString;
408
+ task: z.ZodString;
409
+ }, z.core.$strip>>;
410
+ testYourself: z.ZodNullable<z.ZodString>;
411
+ funFact: z.ZodNullable<z.ZodString>;
412
+ }, z.core.$strip>, z.ZodObject<{
413
+ topic: z.ZodString;
414
+ project: z.ZodString;
415
+ description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
416
+ getReadySection: z.ZodArray<z.ZodString>;
417
+ debugSection: z.ZodArray<z.ZodObject<{
418
+ linkToCode: z.ZodURL;
419
+ issue: z.ZodString;
420
+ }, z.core.$strip>>;
421
+ }, z.core.$strip>]>;
71
422
  export type ProgrammingLanguage = z.infer<typeof languageEnum>;
72
- export interface StepWithImage extends z.infer<typeof StepWithImageSchema> {
73
- }
74
- export interface StepsWithCodeBlock extends z.infer<typeof StepsWithCodeBlockSchema> {
75
- }
76
- export interface MultipleStepsWithCodeBlock extends z.infer<typeof MultipleStepsWithCodeBlockSchema> {
77
- }
78
- export interface Challenge extends z.infer<typeof ChallengeSchema> {
79
- }
80
- export interface NewProject extends z.infer<typeof NewProjectSchema> {
81
- }
82
- export interface ParsedLesson extends z.infer<typeof ParsedLessonSchema> {
83
- }
423
+ export type ImageSlot = z.infer<typeof ImageSlotSchema>;
424
+ export type StepWithImage = z.infer<typeof StepWithImageSchema>;
425
+ export type StepsWithCodeBlock = z.infer<typeof StepsWithCodeBlockSchema>;
426
+ export type Challenge = z.infer<typeof ChallengeSchema>;
427
+ export type NewProject = z.infer<typeof NewProjectSchema>;
428
+ export type Lesson = z.infer<typeof LessonSchema>;
429
+ export type LessonLLM = z.infer<typeof LessonLLMSchema>;
84
430
  //# sourceMappingURL=lesson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lesson.d.ts","sourceRoot":"","sources":["../../src/schemas/lesson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;;;;EAQvB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;iBAUnC,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;kBAAoC,CAAC;AAElF,eAAO,MAAM,eAAe;;;;iBAc1B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;iBAS3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoD7B,CAAC;AAGH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAA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languageEnum = z.enum([
4
4
  'none',
5
5
  'scratch',
@@ -9,9 +9,11 @@ export const languageEnum = z.enum([
9
9
  'java',
10
10
  'c',
11
11
  ]);
12
- export const StepWithImageSchema = z.object({
13
- step: z.string().describe('The instruction text for this step'),
14
- image: z.string().nullable().default(null).describe('Image reference if present, otherwise null'),
12
+ // NOTE: Fields with no describe() are assigned using rule-based logic.
13
+ // Reusable pieces that are apart of the standard lesson
14
+ export const ImageSlotSchema = z.object({
15
+ id: z.string(),
16
+ base64: z.string().optional(),
15
17
  });
16
18
  export const StepsWithCodeBlockSchema = z.object({
17
19
  steps: z
@@ -21,10 +23,8 @@ export const StepsWithCodeBlockSchema = z.object({
21
23
  .string()
22
24
  .nullable()
23
25
  .default(null)
24
- .describe('The code block that students have to write to get started')
25
- .transform((val) => normaliseCodeBlock(val)),
26
+ .describe('The code block that students have to write to get started (white-space and new-lines preserved)'),
26
27
  });
27
- export const MultipleStepsWithCodeBlockSchema = z.array(StepsWithCodeBlockSchema);
28
28
  export const ChallengeSchema = z.object({
29
29
  name: z
30
30
  .string()
@@ -35,8 +35,7 @@ export const ChallengeSchema = z.object({
35
35
  hintCode: z
36
36
  .string()
37
37
  .nullable()
38
- .describe('Code that gives a hint on how to complete the challenge (only code allowed)')
39
- .transform((val) => normaliseCodeBlock(val)),
38
+ .describe('Code that gives a hint on how to complete the challenge (only code allowed, perserve whitespace and add line breaks)'),
40
39
  });
41
40
  export const NewProjectSchema = z.object({
42
41
  name: z
@@ -46,7 +45,11 @@ export const NewProjectSchema = z.object({
46
45
  .string()
47
46
  .describe('The task for the new project, explained as a requirement or new feature to add'),
48
47
  });
49
- export const ParsedLessonSchema = z.object({
48
+ // Representation of any lesson that digimaker provides, dynamic fields that
49
+ // account for all possible variations of input.
50
+ // Programming text-based lessons
51
+ export const ProgrammingLessonSchema = z.object({
52
+ lessonType: z.literal('text-based (programming) lesson'),
50
53
  topic: z
51
54
  .string()
52
55
  .describe('The main topic/category of the lesson (e.g., "Decisions", "Loops", "Variables")'),
@@ -55,44 +58,103 @@ export const ParsedLessonSchema = z.object({
55
58
  .describe('The name of the project being built (e.g., "Crossy Road", "Space Invaders")'),
56
59
  description: z
57
60
  .string()
58
- .describe('A brief description explaining the programming concept being taught'),
61
+ .describe('A brief description explaining the programming concept being taught')
62
+ .transform((val) => {
63
+ return normaliseText(val) ?? val;
64
+ }),
59
65
  projectExplainer: z.string().describe('Explanation of what will be built in this lesson'),
60
66
  programmingLanguage: languageEnum
61
67
  .default('none')
62
68
  .describe('The programming language used in this lesson, figurable through code visible or wording'),
63
- projectImage: z
64
- .string()
69
+ prefaceImageSlots: z
70
+ .array(ImageSlotSchema)
65
71
  .nullable()
66
- .default(null)
67
- .describe('Reference to the main project image if present'),
72
+ .describe('Image slots for the preface, before the "Get Ready" section'),
68
73
  getReadySection: z
69
74
  .array(z.string())
70
75
  .describe('List of setup steps to prepare for the project (adding sprites, backdrops, etc.)'),
71
- addYourCodeSection: z.union([
72
- z
73
- .array(StepWithImageSchema)
74
- .describe('Step-by-step coding instructions, each step may have an associated image'),
75
- StepsWithCodeBlockSchema.describe('A block of code given with steps on what it does'),
76
- MultipleStepsWithCodeBlockSchema.describe('Multiple steps with a code block directly following each, or some without a code block'),
77
- ]),
76
+ addYourCodeSection: z
77
+ .array(StepsWithCodeBlockSchema)
78
+ .describe('Multiple steps with a code block directly following each, or some without a code block. If there is only one step provide it as an array with one item')
79
+ .nullable()
80
+ .describe('Section that guides students on adding the base code. Null only when it is a debugging lesson'),
78
81
  tryItOutSection: z
79
82
  .array(z.string())
80
83
  .nullable()
81
- .default(null)
82
- .describe('Steps to test the project after coding'),
84
+ .describe('Steps to test the project after coding. Null only when it is a debugging lesson'),
83
85
  challengeSection: z
84
86
  .array(ChallengeSchema)
85
- .describe('Challenge tasks for students to extend the project'),
86
- newProject: NewProjectSchema.describe('Suggestion for a new project or extension activity'),
87
- testYourself: z
88
- .string()
89
87
  .nullable()
90
- .default(null)
91
- .describe('A link to the quiz, found under the "Test Yourself" header'),
92
- funFact: z
88
+ .describe('Challenge tasks for students to extend the project. Null only when it is a debugging lesson'),
89
+ newProject: NewProjectSchema.nullable().describe('Suggestion for a new project or extension activity. Null only when it is a debugging lesson'),
90
+ testYourself: z.string().nullable(),
91
+ funFact: z.string().nullable().describe('An interesting fact related to the lesson topic'),
92
+ }); // LLM version of the same schema
93
+ const StandardLessonLLMSchema = ProgrammingLessonSchema.omit({
94
+ prefaceImageSlots: true,
95
+ testYourself: true,
96
+ });
97
+ // Scratch lessons
98
+ export const StepWithImageSchema = z.object({
99
+ step: z.string().describe('The instruction text for this step'),
100
+ imageSlot: ImageSlotSchema.nullable().default(null),
101
+ });
102
+ export const ScratchLessonSchema = ProgrammingLessonSchema.extend({
103
+ lessonType: z.literal('block-based (scratch) lesson'),
104
+ addYourCodeSection: z.array(StepWithImageSchema),
105
+ }); // LLM version of the same schema
106
+ const StepWithImageLLMSchema = StepWithImageSchema.omit({ imageSlot: true });
107
+ export const ScratchLessonLLMSchema = ScratchLessonSchema.extend({
108
+ addYourCodeSection: z.array(StepWithImageLLMSchema).describe('Step-by-step coding instructions'),
109
+ }).omit({
110
+ prefaceImageSlots: true,
111
+ });
112
+ // Dbugging lessons
113
+ export const DebugStepSchema = z.object({
114
+ linkToCode: z.url().describe('URL link to the static content'),
115
+ issue: z
93
116
  .string()
94
- .nullable()
95
- .default(null)
96
- .describe('An interesting fact related to the lesson topic'),
117
+ .describe('The issue that must be fixed, preserve all original paragraph breaks and newlines'),
97
118
  });
119
+ export const DebugLessonSchema = ProgrammingLessonSchema.extend({
120
+ lessonType: z.literal('debugging lesson'),
121
+ debugSection: z.array(DebugStepSchema).describe('Content found under the "Debug" headre'),
122
+ }).omit({
123
+ projectExplainer: true,
124
+ addYourCodeSection: true,
125
+ tryItOutSection: true,
126
+ challengeSection: true,
127
+ newProject: true,
128
+ testYourself: true,
129
+ funFact: true,
130
+ }); // LLM version of the same schema
131
+ export const DebugLessonLLMSchema = DebugLessonSchema.omit({
132
+ prefaceImageSlots: true,
133
+ });
134
+ export const LessonSchema = z.discriminatedUnion('lessonType', [
135
+ ProgrammingLessonSchema,
136
+ ScratchLessonSchema,
137
+ DebugLessonSchema,
138
+ ]);
139
+ // The fields that the LLM will not be able to see at all, when generating
140
+ // These are populated with rule based logic
141
+ const StandardLessonLLMSchemaNoType = StandardLessonLLMSchema.omit({
142
+ lessonType: true,
143
+ }).describe('Use this for text-based programming lessons (Python, JS, Java, etc.) that follow a standard "Add your code" and "Challenge" flow.');
144
+ const ScratchLessonLLMSchemaNoType = ScratchLessonLLMSchema.omit({
145
+ lessonType: true,
146
+ }).describe('Use this ONLY for Scratch/block-based lessons where instructions are tied to visual steps rather than raw code blocks.');
147
+ const DebugLessonLLMSchemaNoType = DebugLessonLLMSchema.omit({
148
+ lessonType: true,
149
+ }).describe('Use this for debugging exercises where the goal is to fix an existing issues rather than building one from scratch.');
150
+ export const LessonLLMSchema = z.union([
151
+ StandardLessonLLMSchemaNoType,
152
+ ScratchLessonLLMSchemaNoType,
153
+ DebugLessonLLMSchemaNoType,
154
+ ]);
155
+ export const LessonLLMSchemaWithoutLanguage = z.union([
156
+ StandardLessonLLMSchemaNoType.omit({ programmingLanguage: true }),
157
+ ScratchLessonLLMSchemaNoType.omit({ programmingLanguage: true }),
158
+ DebugLessonLLMSchemaNoType.omit({ programmingLanguage: true }),
159
+ ]);
98
160
  //# sourceMappingURL=lesson.js.map