@intellectif/lk-core 0.14.0 → 0.15.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +1 -0
  3. package/dist/{activity-BVkg9VDo.d.cts → activity-C7cR8U9n.d.cts} +35 -2
  4. package/dist/{activity-BVkg9VDo.d.ts → activity-C7cR8U9n.d.ts} +35 -2
  5. package/dist/{chunk-R7PV3XIC.js → chunk-54XYQ3CS.js} +7 -4
  6. package/dist/chunk-54XYQ3CS.js.map +1 -0
  7. package/dist/{chunk-J5OIRIOW.cjs → chunk-5KWF34LJ.cjs} +31 -31
  8. package/dist/{chunk-J5OIRIOW.cjs.map → chunk-5KWF34LJ.cjs.map} +1 -1
  9. package/dist/{chunk-CZRUMHKW.cjs → chunk-7ETU6EXQ.cjs} +13 -10
  10. package/dist/chunk-7ETU6EXQ.cjs.map +1 -0
  11. package/dist/{chunk-6RND47QE.js → chunk-DPHX4E7X.js} +62 -3
  12. package/dist/chunk-DPHX4E7X.js.map +1 -0
  13. package/dist/{chunk-NBADQ3JU.js → chunk-EEMVWBPP.js} +195 -4
  14. package/dist/chunk-EEMVWBPP.js.map +1 -0
  15. package/dist/{chunk-RTIR6R2U.js → chunk-L6YBQXSB.js} +2 -2
  16. package/dist/{chunk-VCXIPLEW.cjs → chunk-QFWEF5ST.cjs} +63 -4
  17. package/dist/chunk-QFWEF5ST.cjs.map +1 -0
  18. package/dist/chunk-W7AQP6AV.cjs +418 -0
  19. package/dist/chunk-W7AQP6AV.cjs.map +1 -0
  20. package/dist/{index-v2_-Fyn3.d.ts → index-BWyMDlUS.d.cts} +367 -2
  21. package/dist/{index-BE1bM2Wi.d.cts → index-D10NaztZ.d.ts} +367 -2
  22. package/dist/index.cjs +397 -96
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +103 -7
  25. package/dist/index.d.ts +103 -7
  26. package/dist/index.js +310 -9
  27. package/dist/index.js.map +1 -1
  28. package/dist/schemas.cjs +11 -3
  29. package/dist/schemas.cjs.map +1 -1
  30. package/dist/schemas.d.cts +2 -2
  31. package/dist/schemas.d.ts +2 -2
  32. package/dist/schemas.js +10 -2
  33. package/dist/scoring.cjs +3 -3
  34. package/dist/scoring.d.cts +2 -2
  35. package/dist/scoring.d.ts +2 -2
  36. package/dist/scoring.js +2 -2
  37. package/dist/xapi.cjs +3 -3
  38. package/dist/xapi.d.cts +1 -1
  39. package/dist/xapi.d.ts +1 -1
  40. package/dist/xapi.js +2 -2
  41. package/package.json +1 -1
  42. package/dist/chunk-2NIALQEH.cjs +0 -227
  43. package/dist/chunk-2NIALQEH.cjs.map +0 -1
  44. package/dist/chunk-6RND47QE.js.map +0 -1
  45. package/dist/chunk-CZRUMHKW.cjs.map +0 -1
  46. package/dist/chunk-NBADQ3JU.js.map +0 -1
  47. package/dist/chunk-R7PV3XIC.js.map +0 -1
  48. package/dist/chunk-VCXIPLEW.cjs.map +0 -1
  49. /package/dist/{chunk-RTIR6R2U.js.map → chunk-L6YBQXSB.js.map} +0 -0
@@ -0,0 +1,418 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ var _chunkQFWEF5STcjs = require('./chunk-QFWEF5ST.cjs');
15
+
16
+ // src/schemas/item-group.ts
17
+ var _v4 = require('zod/v4');
18
+
19
+ // src/timeline-limits.ts
20
+ var INTERACTIVE_VIDEO_ITEM_TYPES = [
21
+ "multiple-choice",
22
+ "fill-in-the-blanks",
23
+ "gap-select",
24
+ "dictation",
25
+ "read-aloud"
26
+ ];
27
+ function isInteractiveVideoItemType(type) {
28
+ return INTERACTIVE_VIDEO_ITEM_TYPES.includes(type);
29
+ }
30
+ var TIMELINE_MAX_QUIZZES = 100;
31
+ var TIMELINE_MAX_ITEMS = 200;
32
+ var TIMELINE_MAX_CHAPTERS = 100;
33
+ var TIMELINE_MAX_TITLE_LENGTH = 120;
34
+
35
+ // src/schemas/item-group.ts
36
+ var SlotKeySchema = _v4.z.string().min(1).refine((key) => !key.includes("."), {
37
+ error: 'slotKey must not contain "." \u2014 that character separates a group from its item in a slot id, so a key containing one would make the slot ambiguous.'
38
+ });
39
+ function hasBody(stimulus) {
40
+ return typeof stimulus.body === "string" && stimulus.body.trim().length > 0;
41
+ }
42
+ function mediaFits(kind, mediaType) {
43
+ switch (kind) {
44
+ case "audio":
45
+ return mediaType === "audio";
46
+ case "video":
47
+ return mediaType === "video" || mediaType === "embed";
48
+ case "image":
49
+ return mediaType === "image";
50
+ default:
51
+ return true;
52
+ }
53
+ }
54
+ var StimulusSchema = _v4.z.looseObject({
55
+ id: _v4.z.string().min(1),
56
+ kind: _v4.z.enum(["text", "audio", "video", "image", "mixed"]),
57
+ title: _v4.z.string().optional(),
58
+ body: _v4.z.string().optional(),
59
+ bodyHtml: _v4.z.string().optional(),
60
+ media: _chunkQFWEF5STcjs.MediaSchema.optional(),
61
+ transcript: _v4.z.string().optional(),
62
+ locale: _v4.z.string().optional(),
63
+ attribution: _v4.z.string().optional()
64
+ }).refine((stimulus) => stimulus.bodyHtml === void 0 || hasBody(stimulus), {
65
+ error: "bodyHtml requires a plain-text body: it is the accessible fallback rendered when no sanitiser is supplied.",
66
+ path: ["body"]
67
+ }).refine(
68
+ (stimulus) => stimulus.kind !== "text" && stimulus.kind !== "mixed" || hasBody(stimulus),
69
+ {
70
+ error: "A text or mixed stimulus needs a non-empty body.",
71
+ path: ["body"]
72
+ }
73
+ ).refine((stimulus) => stimulus.kind === "text" || stimulus.media !== void 0, {
74
+ error: "An audio, video, image or mixed stimulus needs media.",
75
+ path: ["media"]
76
+ }).refine(
77
+ (stimulus) => stimulus.media === void 0 || mediaFits(stimulus.kind, stimulus.media.type),
78
+ {
79
+ error: "media.type does not fit the stimulus kind: audio needs audio; video needs video or embed; image needs image.",
80
+ path: ["media", "type"]
81
+ }
82
+ );
83
+ var TimelineTitleSchema = _v4.z.string().max(TIMELINE_MAX_TITLE_LENGTH).refine((title) => title.trim().length > 0, { error: "A title must not be empty." });
84
+ var TimelineTimeSchema = _v4.z.number().min(0, { error: "A time is 0 seconds or more." });
85
+ var TimelineCueSchema = _v4.z.strictObject({
86
+ id: _v4.z.string().min(1).max(64),
87
+ at: TimelineTimeSchema,
88
+ itemIds: _v4.z.array(_v4.z.string().min(1)).min(1).max(TIMELINE_MAX_ITEMS),
89
+ title: TimelineTitleSchema.optional(),
90
+ required: _v4.z.boolean().optional()
91
+ });
92
+ var TimelineChapterSchema = _v4.z.strictObject({
93
+ at: TimelineTimeSchema,
94
+ title: TimelineTitleSchema
95
+ });
96
+ var MediaTimelineSchema = _v4.z.strictObject({
97
+ cues: _v4.z.array(TimelineCueSchema).max(TIMELINE_MAX_QUIZZES),
98
+ chapters: _v4.z.array(TimelineChapterSchema).max(TIMELINE_MAX_CHAPTERS).optional(),
99
+ navigation: _v4.z.enum(["free", "no-skip-ahead"]).optional()
100
+ }).check((ctx) => {
101
+ const seen = /* @__PURE__ */ new Set();
102
+ ctx.value.cues.forEach((cue, index) => {
103
+ if (seen.has(cue.id)) {
104
+ ctx.issues.push({
105
+ code: "custom",
106
+ input: cue.id,
107
+ message: `Quiz id "${cue.id}" is used twice: events, drafts and the contents panel name a quiz by its id.`,
108
+ path: ["cues", index, "id"]
109
+ });
110
+ }
111
+ seen.add(cue.id);
112
+ });
113
+ const chapters = _nullishCoalesce(ctx.value.chapters, () => ( []));
114
+ chapters.forEach((chapter, index) => {
115
+ const previous = chapters[index - 1];
116
+ if (previous !== void 0 && chapter.at <= previous.at) {
117
+ ctx.issues.push({
118
+ code: "custom",
119
+ input: chapter.at,
120
+ message: "Chapter times must be strictly increasing.",
121
+ path: ["chapters", index, "at"]
122
+ });
123
+ }
124
+ });
125
+ });
126
+ function isLocalOnlyUrl(url) {
127
+ return typeof url === "string" && /^(data|blob):/i.test(url);
128
+ }
129
+ function timelineIssues(group, scope) {
130
+ const timeline = group.timeline;
131
+ if (timeline === void 0) {
132
+ return [];
133
+ }
134
+ const issues = [];
135
+ const media = group.stimulus.media;
136
+ if (group.stimulus.kind !== "video") {
137
+ issues.push({
138
+ path: ["stimulus", "kind"],
139
+ input: group.stimulus.kind,
140
+ message: "An interactive video needs a video stimulus: quizzes open at moments of a video, and nothing else has them."
141
+ });
142
+ } else if (media !== void 0 && media.type !== "video") {
143
+ issues.push({
144
+ path: ["stimulus", "media", "type"],
145
+ input: media.type,
146
+ message: "An interactive video needs a video file. An embedded provider player cannot be paused at the moment a quiz opens."
147
+ });
148
+ }
149
+ if (group.shuffle === "within-group") {
150
+ issues.push({
151
+ path: ["shuffle"],
152
+ input: group.shuffle,
153
+ message: 'An interactive video presents its questions in the order its quizzes open; shuffle: "within-group" cannot apply to it.'
154
+ });
155
+ }
156
+ if (group.items.length > TIMELINE_MAX_ITEMS) {
157
+ issues.push({
158
+ path: ["items"],
159
+ input: group.items.length,
160
+ message: `An interactive video holds at most ${TIMELINE_MAX_ITEMS} questions.`
161
+ });
162
+ }
163
+ const itemIds = /* @__PURE__ */ new Map();
164
+ group.items.forEach((item, index) => {
165
+ const {
166
+ id,
167
+ type,
168
+ media: itemMedia
169
+ } = _nullishCoalesce(item, () => ( {}));
170
+ if (typeof id === "string") {
171
+ itemIds.set(id, index);
172
+ }
173
+ if (!isInteractiveVideoItemType(type)) {
174
+ issues.push({
175
+ path: ["items", index, "type"],
176
+ input: type,
177
+ message: `An interactive video may hold only ${INTERACTIVE_VIDEO_ITEM_TYPES.join(", ")} questions.`
178
+ });
179
+ }
180
+ if (scope === "content" && type === "dictation" && itemMedia === void 0) {
181
+ issues.push({
182
+ path: ["items", index, "media"],
183
+ input: itemMedia,
184
+ message: "A dictation inside an interactive video needs its own recording."
185
+ });
186
+ }
187
+ });
188
+ const placed = /* @__PURE__ */ new Set();
189
+ timeline.cues.forEach((cue, cueIndex) => {
190
+ cue.itemIds.forEach((itemId, position) => {
191
+ const path = ["timeline", "cues", cueIndex, "itemIds", position];
192
+ if (!itemIds.has(itemId)) {
193
+ issues.push({
194
+ path,
195
+ input: itemId,
196
+ message: `No item in this group has the id "${itemId}".`
197
+ });
198
+ } else if (placed.has(itemId)) {
199
+ issues.push({
200
+ path,
201
+ input: itemId,
202
+ message: `Item "${itemId}" is placed twice: every question belongs to exactly one quiz.`
203
+ });
204
+ }
205
+ placed.add(itemId);
206
+ });
207
+ });
208
+ for (const [itemId, index] of itemIds) {
209
+ if (!placed.has(itemId)) {
210
+ issues.push({
211
+ path: ["items", index],
212
+ input: itemId,
213
+ message: `Item "${itemId}" is in no quiz, so the video would never show it.`
214
+ });
215
+ }
216
+ }
217
+ if (scope === "content" && media !== void 0) {
218
+ const urls = [
219
+ [media.url, ["stimulus", "media", "url"]],
220
+ [media.poster, ["stimulus", "media", "poster"]],
221
+ ...(_nullishCoalesce(media.tracks, () => ( []))).map((track, index) => [
222
+ track.src,
223
+ ["stimulus", "media", "tracks", index, "src"]
224
+ ])
225
+ ];
226
+ for (const [url, path] of urls) {
227
+ if (isLocalOnlyUrl(url)) {
228
+ issues.push({
229
+ path,
230
+ input: url,
231
+ message: "An interactive video is stored and served: its URLs cannot be data: or blob: URLs."
232
+ });
233
+ }
234
+ }
235
+ }
236
+ return issues;
237
+ }
238
+ var ItemShapeSchema = _v4.z.looseObject({
239
+ type: _v4.z.string().min(1),
240
+ id: _v4.z.string().min(1),
241
+ slotKey: SlotKeySchema.optional()
242
+ });
243
+ var ItemGroupSchema = _v4.z.looseObject({
244
+ schemaVersion: _v4.z.literal("1.0"),
245
+ type: _v4.z.literal("item-group"),
246
+ id: _v4.z.string().min(1),
247
+ title: _v4.z.string().optional(),
248
+ slotKey: SlotKeySchema.optional(),
249
+ stimulus: StimulusSchema,
250
+ items: _v4.z.array(ItemShapeSchema).min(1),
251
+ shuffle: _v4.z.enum(["none", "within-group"]).optional(),
252
+ timeline: MediaTimelineSchema.optional()
253
+ }).refine((group) => group.items.every((item) => item.type !== "item-group"), {
254
+ error: "Item groups do not nest: every item must be an activity.",
255
+ path: ["items"]
256
+ }).refine((group) => new Set(group.items.map((item) => item.id)).size === group.items.length, {
257
+ error: "Item ids must be unique within a group.",
258
+ path: ["items"]
259
+ }).check((ctx) => {
260
+ for (const issue of timelineIssues(ctx.value, "content")) {
261
+ ctx.issues.push({ code: "custom", ...issue });
262
+ }
263
+ });
264
+ var RedactedStimulusSchema = _v4.z.strictObject({
265
+ id: _v4.z.string().min(1),
266
+ kind: _v4.z.enum(["text", "audio", "video", "image", "mixed"]),
267
+ title: _v4.z.string().optional(),
268
+ body: _v4.z.string().optional(),
269
+ bodyHtml: _v4.z.string().optional(),
270
+ media: _chunkQFWEF5STcjs.RedactedMediaSchema.optional(),
271
+ locale: _v4.z.string().optional(),
272
+ attribution: _v4.z.string().optional()
273
+ });
274
+ var RedactedItemGroupSchema = _v4.z.strictObject({
275
+ redacted: _v4.z.literal(true),
276
+ schemaVersion: _v4.z.literal("1.0"),
277
+ type: _v4.z.literal("item-group"),
278
+ id: _v4.z.string().min(1),
279
+ title: _v4.z.string().optional(),
280
+ slotKey: SlotKeySchema.optional(),
281
+ stimulus: RedactedStimulusSchema,
282
+ items: _v4.z.array(_v4.z.unknown()).min(1),
283
+ shuffle: _v4.z.enum(["none", "within-group"]).optional(),
284
+ timeline: MediaTimelineSchema.optional()
285
+ }).check((ctx) => {
286
+ for (const issue of timelineIssues(ctx.value, "redacted")) {
287
+ ctx.issues.push({ code: "custom", ...issue });
288
+ }
289
+ if (_chunkQFWEF5STcjs.groupCaptionsRevealDictation.call(void 0, ctx.value)) {
290
+ ctx.issues.push({
291
+ code: "custom",
292
+ input: _optionalChain([ctx, 'access', _ => _.value, 'access', _2 => _2.stimulus, 'access', _3 => _3.media, 'optionalAccess', _4 => _4.captionsUrl]),
293
+ message: _chunkQFWEF5STcjs.GROUP_CAPTIONS_REVEAL_DICTATION,
294
+ path: ["stimulus", "media", "captionsUrl"]
295
+ });
296
+ }
297
+ });
298
+ function toValidationErrors(issues, prefix) {
299
+ return issues.map((issue) => ({
300
+ path: [...prefix, ...issue.path.map(String)],
301
+ message: issue.message,
302
+ code: issue.code
303
+ }));
304
+ }
305
+ function validateItemGroup(data) {
306
+ const container = ItemGroupSchema.safeParse(data);
307
+ if (!container.success) {
308
+ return { success: false, errors: toValidationErrors(container.error.issues, []) };
309
+ }
310
+ const errors = [];
311
+ const items = [];
312
+ container.data.items.forEach((item, index) => {
313
+ const descriptor = _chunkQFWEF5STcjs.getActivityTypeDescriptor.call(void 0, item.type);
314
+ if (descriptor === void 0) {
315
+ errors.push({
316
+ path: ["items", String(index), "type"],
317
+ message: `Activity type "${item.type}" is not registered`,
318
+ code: "unknown_activity_type"
319
+ });
320
+ return;
321
+ }
322
+ const parsed = descriptor.schema.safeParse(item);
323
+ if (!parsed.success) {
324
+ errors.push(...toValidationErrors(parsed.error.issues, ["items", String(index)]));
325
+ return;
326
+ }
327
+ items.push(parsed.data);
328
+ });
329
+ if (_chunkQFWEF5STcjs.groupCaptionsRevealDictation.call(void 0, container.data)) {
330
+ errors.push({
331
+ path: ["stimulus", "media", "captionsUrl"],
332
+ message: _chunkQFWEF5STcjs.GROUP_CAPTIONS_REVEAL_DICTATION,
333
+ code: "custom"
334
+ });
335
+ }
336
+ if (errors.length > 0) {
337
+ return { success: false, errors };
338
+ }
339
+ return { success: true, data: { ...container.data, items } };
340
+ }
341
+
342
+ // src/schemas/json-schema.ts
343
+
344
+ var stimulusJsonSchema = _v4.z.toJSONSchema(StimulusSchema, { target: "draft-7" });
345
+ var itemGroupJsonSchema = _v4.z.toJSONSchema(ItemGroupSchema, { target: "draft-7" });
346
+ var gapSelectJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.GapSelectDataSchema, {
347
+ target: "draft-7"
348
+ });
349
+ var dictationJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.DictationDataSchema, {
350
+ target: "draft-7"
351
+ });
352
+ var readAloudJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.ReadAloudDataSchema, {
353
+ target: "draft-7"
354
+ });
355
+ var multipleChoiceJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.MultipleChoiceDataSchema, {
356
+ target: "draft-7"
357
+ });
358
+ var fillInTheBlanksJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.FillInTheBlanksDataSchema, {
359
+ target: "draft-7"
360
+ });
361
+ var writtenResponseJsonSchema = _v4.z.toJSONSchema(_chunkQFWEF5STcjs.WrittenResponseDataSchema, {
362
+ target: "draft-7"
363
+ });
364
+ function jsonSchemaFor(type) {
365
+ const descriptor = _chunkQFWEF5STcjs.getActivityTypeDescriptor.call(void 0, type);
366
+ if (descriptor === void 0) {
367
+ throw new (0, _chunkQFWEF5STcjs.UnknownActivityTypeError)(type);
368
+ }
369
+ return _v4.z.toJSONSchema(descriptor.schema, { target: "draft-7" });
370
+ }
371
+
372
+ // src/schemas/index.ts
373
+ function validateActivity(type, data) {
374
+ const descriptor = _chunkQFWEF5STcjs.getActivityTypeDescriptor.call(void 0, type);
375
+ if (descriptor === void 0) {
376
+ throw new (0, _chunkQFWEF5STcjs.UnknownActivityTypeError)(String(type));
377
+ }
378
+ const result = descriptor.schema.safeParse(data);
379
+ if (result.success) {
380
+ return { success: true, data: result.data };
381
+ }
382
+ return {
383
+ success: false,
384
+ errors: result.error.issues.map((issue) => ({
385
+ path: issue.path.map(String),
386
+ message: issue.message,
387
+ code: issue.code
388
+ }))
389
+ };
390
+ }
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+ exports.INTERACTIVE_VIDEO_ITEM_TYPES = INTERACTIVE_VIDEO_ITEM_TYPES; exports.isInteractiveVideoItemType = isInteractiveVideoItemType; exports.TIMELINE_MAX_QUIZZES = TIMELINE_MAX_QUIZZES; exports.TIMELINE_MAX_ITEMS = TIMELINE_MAX_ITEMS; exports.TIMELINE_MAX_CHAPTERS = TIMELINE_MAX_CHAPTERS; exports.TIMELINE_MAX_TITLE_LENGTH = TIMELINE_MAX_TITLE_LENGTH; exports.StimulusSchema = StimulusSchema; exports.TimelineCueSchema = TimelineCueSchema; exports.TimelineChapterSchema = TimelineChapterSchema; exports.MediaTimelineSchema = MediaTimelineSchema; exports.ItemGroupSchema = ItemGroupSchema; exports.RedactedStimulusSchema = RedactedStimulusSchema; exports.RedactedItemGroupSchema = RedactedItemGroupSchema; exports.validateItemGroup = validateItemGroup; exports.stimulusJsonSchema = stimulusJsonSchema; exports.itemGroupJsonSchema = itemGroupJsonSchema; exports.gapSelectJsonSchema = gapSelectJsonSchema; exports.dictationJsonSchema = dictationJsonSchema; exports.readAloudJsonSchema = readAloudJsonSchema; exports.multipleChoiceJsonSchema = multipleChoiceJsonSchema; exports.fillInTheBlanksJsonSchema = fillInTheBlanksJsonSchema; exports.writtenResponseJsonSchema = writtenResponseJsonSchema; exports.jsonSchemaFor = jsonSchemaFor; exports.validateActivity = validateActivity;
418
+ //# sourceMappingURL=chunk-W7AQP6AV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/chunk-W7AQP6AV.cjs","../src/schemas/item-group.ts","../src/timeline-limits.ts","../src/schemas/json-schema.ts","../src/schemas/index.ts"],"names":["z"],"mappings":"AAAA;AACE;AAC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AACA;AACF,6vCAAC","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/chunk-W7AQP6AV.cjs","sourcesContent":[null,"import { z } from 'zod/v4';\nimport { getActivityTypeDescriptor } from '../registry/index.js';\nimport {\n INTERACTIVE_VIDEO_ITEM_TYPES,\n isInteractiveVideoItemType,\n TIMELINE_MAX_CHAPTERS,\n TIMELINE_MAX_ITEMS,\n TIMELINE_MAX_QUIZZES,\n TIMELINE_MAX_TITLE_LENGTH,\n} from '../timeline-limits.js';\nimport type { ActivityData, ValidationError, ValidationResult } from '../types/activity.js';\nimport type { ItemGroup, StimulusKind } from '../types/item-group.js';\nimport { GROUP_CAPTIONS_REVEAL_DICTATION, groupCaptionsRevealDictation } from './dictation.js';\nimport { MediaSchema, RedactedMediaSchema } from './media.js';\n\n/**\n * An authored slot key.\n *\n * A `.` is rejected here, not at render time: `flattenSequence` uses the first\n * `.` to separate a group from its item, so a key containing one would produce\n * an ambiguous slot id. `keyOf` already threw on it — this moves the rejection\n * to `validateItemGroup`, where an author finds it, instead of leaving it to\n * surface when a learner opens the paper. Content that would newly fail\n * validation already threw at flatten time, so it can never have been sat.\n */\nconst SlotKeySchema = z\n .string()\n .min(1)\n .refine((key) => !key.includes('.'), {\n error:\n 'slotKey must not contain \".\" — that character separates a group from its item in a slot id, so a key containing one would make the slot ambiguous.',\n });\n\nfunction hasBody(stimulus: { body?: string | undefined }): boolean {\n return typeof stimulus.body === 'string' && stimulus.body.trim().length > 0;\n}\n\n/** Which media types can carry a stimulus of each kind. `text`/`mixed` accept any. */\nfunction mediaFits(kind: StimulusKind, mediaType: string | undefined): boolean {\n switch (kind) {\n case 'audio':\n return mediaType === 'audio';\n case 'video':\n return mediaType === 'video' || mediaType === 'embed';\n case 'image':\n return mediaType === 'image';\n default:\n return true;\n }\n}\n\n/**\n * Zod schema for a {@link Stimulus}. Loose: unknown keys preserved.\n *\n * The semantic guards exist because a stimulus that does not carry what its\n * `kind` promises is an authoring error that must not reach an exam: an\n * \"audio\" stimulus with no recording renders as a blank panel above six\n * listening questions. Unrepresentable in JSON Schema; dropped from\n * `stimulusJsonSchema` by design.\n */\nexport const StimulusSchema = z\n .looseObject({\n id: z.string().min(1),\n kind: z.enum(['text', 'audio', 'video', 'image', 'mixed']),\n title: z.string().optional(),\n body: z.string().optional(),\n bodyHtml: z.string().optional(),\n media: MediaSchema.optional(),\n transcript: z.string().optional(),\n locale: z.string().optional(),\n attribution: z.string().optional(),\n })\n .refine((stimulus) => stimulus.bodyHtml === undefined || hasBody(stimulus), {\n error:\n 'bodyHtml requires a plain-text body: it is the accessible fallback rendered when no sanitiser is supplied.',\n path: ['body'],\n })\n .refine(\n (stimulus) => (stimulus.kind !== 'text' && stimulus.kind !== 'mixed') || hasBody(stimulus),\n {\n error: 'A text or mixed stimulus needs a non-empty body.',\n path: ['body'],\n },\n )\n .refine((stimulus) => stimulus.kind === 'text' || stimulus.media !== undefined, {\n error: 'An audio, video, image or mixed stimulus needs media.',\n path: ['media'],\n })\n .refine(\n (stimulus) => stimulus.media === undefined || mediaFits(stimulus.kind, stimulus.media.type),\n {\n error:\n 'media.type does not fit the stimulus kind: audio needs audio; video needs video or embed; image needs image.',\n path: ['media', 'type'],\n },\n );\n\nconst TimelineTitleSchema = z\n .string()\n .max(TIMELINE_MAX_TITLE_LENGTH)\n .refine((title) => title.trim().length > 0, { error: 'A title must not be empty.' });\n\n/** Seconds from the start of the video. zod rejects NaN and ±Infinity itself. */\nconst TimelineTimeSchema = z.number().min(0, { error: 'A time is 0 seconds or more.' });\n\n/**\n * A quiz. STRICT, like every part of a timeline: a misspelt `requried` would\n * otherwise be kept and the quiz silently optional on a paper that believed it\n * was required.\n */\nexport const TimelineCueSchema = z.strictObject({\n id: z.string().min(1).max(64),\n at: TimelineTimeSchema,\n itemIds: z.array(z.string().min(1)).min(1).max(TIMELINE_MAX_ITEMS),\n title: TimelineTitleSchema.optional(),\n required: z.boolean().optional(),\n});\n\nexport const TimelineChapterSchema = z.strictObject({\n at: TimelineTimeSchema,\n title: TimelineTitleSchema,\n});\n\n/**\n * A timeline on its own: its quizzes, chapters and navigation. The rules that\n * need the group — every item in exactly one quiz, a video stimulus, the five\n * item types — are {@link timelineIssues}, which both group schemas run.\n */\nexport const MediaTimelineSchema = z\n .strictObject({\n cues: z.array(TimelineCueSchema).max(TIMELINE_MAX_QUIZZES),\n chapters: z.array(TimelineChapterSchema).max(TIMELINE_MAX_CHAPTERS).optional(),\n navigation: z.enum(['free', 'no-skip-ahead']).optional(),\n })\n .check((ctx) => {\n const seen = new Set<string>();\n ctx.value.cues.forEach((cue, index) => {\n if (seen.has(cue.id)) {\n ctx.issues.push({\n code: 'custom',\n input: cue.id,\n message: `Quiz id \"${cue.id}\" is used twice: events, drafts and the contents panel name a quiz by its id.`,\n path: ['cues', index, 'id'],\n });\n }\n seen.add(cue.id);\n });\n // Strictly increasing, not merely sorted: two chapters starting at one\n // moment leave the first with no length, and the scrubber no room to draw it.\n const chapters = ctx.value.chapters ?? [];\n chapters.forEach((chapter, index) => {\n const previous = chapters[index - 1];\n if (previous !== undefined && chapter.at <= previous.at) {\n ctx.issues.push({\n code: 'custom',\n input: chapter.at,\n message: 'Chapter times must be strictly increasing.',\n path: ['chapters', index, 'at'],\n });\n }\n });\n });\n\n/** A URL only this document can resolve, or one that inlines the bytes. */\nfunction isLocalOnlyUrl(url: unknown): boolean {\n return typeof url === 'string' && /^(data|blob):/i.test(url);\n}\n\n/**\n * The rules of an interactive video that span the timeline, the stimulus and\n * the items. Run by the content schema and, for everything but the two\n * authoring-only rules, by the strict redacted schema — a projection built by\n * hand never passed through the content schema.\n *\n * Items are read defensively: the redacted schema leaves them opaque, and each\n * is proven against its own type's schema elsewhere.\n */\nfunction timelineIssues(\n group: {\n stimulus: {\n kind: string;\n media?:\n | {\n type: string;\n url: string;\n poster?: string | undefined;\n tracks?: readonly { src: string }[] | undefined;\n }\n | undefined;\n };\n items: readonly unknown[];\n shuffle?: string | undefined;\n timeline?: { cues: readonly { itemIds: readonly string[] }[] } | undefined;\n },\n scope: 'content' | 'redacted',\n): { path: (string | number)[]; message: string; input: unknown }[] {\n const timeline = group.timeline;\n if (timeline === undefined) {\n return [];\n }\n const issues: { path: (string | number)[]; message: string; input: unknown }[] = [];\n const media = group.stimulus.media;\n\n // Reported at the field that is wrong, so an editor's own check at that path\n // can stand in for it without hiding anything else about the stimulus.\n if (group.stimulus.kind !== 'video') {\n issues.push({\n path: ['stimulus', 'kind'],\n input: group.stimulus.kind,\n message:\n 'An interactive video needs a video stimulus: quizzes open at moments of a video, and nothing else has them.',\n });\n } else if (media !== undefined && media.type !== 'video') {\n issues.push({\n path: ['stimulus', 'media', 'type'],\n input: media.type,\n message:\n 'An interactive video needs a video file. An embedded provider player cannot be paused at the moment a quiz opens.',\n });\n }\n if (group.shuffle === 'within-group') {\n issues.push({\n path: ['shuffle'],\n input: group.shuffle,\n message:\n 'An interactive video presents its questions in the order its quizzes open; shuffle: \"within-group\" cannot apply to it.',\n });\n }\n if (group.items.length > TIMELINE_MAX_ITEMS) {\n issues.push({\n path: ['items'],\n input: group.items.length,\n message: `An interactive video holds at most ${TIMELINE_MAX_ITEMS} questions.`,\n });\n }\n\n const itemIds = new Map<string, number>();\n group.items.forEach((item, index) => {\n const {\n id,\n type,\n media: itemMedia,\n } = (item ?? {}) as { id?: unknown; type?: unknown; media?: unknown };\n if (typeof id === 'string') {\n itemIds.set(id, index);\n }\n if (!isInteractiveVideoItemType(type)) {\n issues.push({\n path: ['items', index, 'type'],\n input: type,\n message: `An interactive video may hold only ${INTERACTIVE_VIDEO_ITEM_TYPES.join(', ')} questions.`,\n });\n }\n // The \"play the stimulus\" fallback a dictation has in a listening group\n // means nothing halfway through a video.\n if (scope === 'content' && type === 'dictation' && itemMedia === undefined) {\n issues.push({\n path: ['items', index, 'media'],\n input: itemMedia,\n message: 'A dictation inside an interactive video needs its own recording.',\n });\n }\n });\n\n const placed = new Set<string>();\n timeline.cues.forEach((cue, cueIndex) => {\n cue.itemIds.forEach((itemId, position) => {\n const path = ['timeline', 'cues', cueIndex, 'itemIds', position];\n if (!itemIds.has(itemId)) {\n issues.push({\n path,\n input: itemId,\n message: `No item in this group has the id \"${itemId}\".`,\n });\n } else if (placed.has(itemId)) {\n issues.push({\n path,\n input: itemId,\n message: `Item \"${itemId}\" is placed twice: every question belongs to exactly one quiz.`,\n });\n }\n placed.add(itemId);\n });\n });\n for (const [itemId, index] of itemIds) {\n if (!placed.has(itemId)) {\n issues.push({\n path: ['items', index],\n input: itemId,\n message: `Item \"${itemId}\" is in no quiz, so the video would never show it.`,\n });\n }\n }\n\n // A `data:` video swells the payload and every fingerprint over it; a stored\n // `blob:` URL means nothing in another document.\n if (scope === 'content' && media !== undefined) {\n const urls: [unknown, (string | number)[]][] = [\n [media.url, ['stimulus', 'media', 'url']],\n [media.poster, ['stimulus', 'media', 'poster']],\n ...(media.tracks ?? []).map((track, index): [unknown, (string | number)[]] => [\n track.src,\n ['stimulus', 'media', 'tracks', index, 'src'],\n ]),\n ];\n for (const [url, path] of urls) {\n if (isLocalOnlyUrl(url)) {\n issues.push({\n path,\n input: url,\n message:\n 'An interactive video is stored and served: its URLs cannot be data: or blob: URLs.',\n });\n }\n }\n }\n return issues;\n}\n\n/**\n * The structural minimum of an item as seen by the CONTAINER schema. Each\n * item's own contract is checked against its registered schema by\n * {@link validateItemGroup} — a zod schema cannot dispatch on a registry\n * that consumers extend at runtime.\n */\nconst ItemShapeSchema = z.looseObject({\n type: z.string().min(1),\n id: z.string().min(1),\n slotKey: SlotKeySchema.optional(),\n});\n\n/**\n * Zod schema for an {@link ItemGroup} CONTAINER. Loose: unknown keys\n * preserved. Validates the group's own fields and the stimulus in full, and\n * each item only structurally (`type` and `id`); use {@link validateItemGroup}\n * to validate the items against their registered schemas as well.\n */\nexport const ItemGroupSchema = z\n .looseObject({\n schemaVersion: z.literal('1.0'),\n type: z.literal('item-group'),\n id: z.string().min(1),\n title: z.string().optional(),\n slotKey: SlotKeySchema.optional(),\n stimulus: StimulusSchema,\n items: z.array(ItemShapeSchema).min(1),\n shuffle: z.enum(['none', 'within-group']).optional(),\n timeline: MediaTimelineSchema.optional(),\n })\n .refine((group) => group.items.every((item) => item.type !== 'item-group'), {\n error: 'Item groups do not nest: every item must be an activity.',\n path: ['items'],\n })\n .refine((group) => new Set(group.items.map((item) => item.id)).size === group.items.length, {\n error: 'Item ids must be unique within a group.',\n path: ['items'],\n })\n .check((ctx) => {\n for (const issue of timelineIssues(ctx.value, 'content')) {\n ctx.issues.push({ code: 'custom', ...issue });\n }\n });\n\n/** The learner-safe shape of a stimulus, derived from the strict schema below. */\nexport type RedactedStimulus = z.infer<typeof RedactedStimulusSchema>;\n\n/** Strict learner-safe stimulus: everything but the author-only `transcript`. */\nexport const RedactedStimulusSchema = z.strictObject({\n id: z.string().min(1),\n kind: z.enum(['text', 'audio', 'video', 'image', 'mixed']),\n title: z.string().optional(),\n body: z.string().optional(),\n bodyHtml: z.string().optional(),\n media: RedactedMediaSchema.optional(),\n locale: z.string().optional(),\n attribution: z.string().optional(),\n});\n\n/**\n * Strict learner-safe item group. Items are left opaque here — each is proven\n * learner-safe by `assertRedacted` against its OWN type's redacted schema,\n * which is the only place that knowledge lives. The one exception is the one\n * rule that spans the container and an item: a captioned stimulus recording\n * played to a dictation is not learner-safe, because the captions are the\n * dictation's answer.\n */\nexport const RedactedItemGroupSchema = z\n .strictObject({\n redacted: z.literal(true),\n schemaVersion: z.literal('1.0'),\n type: z.literal('item-group'),\n id: z.string().min(1),\n title: z.string().optional(),\n slotKey: SlotKeySchema.optional(),\n stimulus: RedactedStimulusSchema,\n items: z.array(z.unknown()).min(1),\n shuffle: z.enum(['none', 'within-group']).optional(),\n timeline: MediaTimelineSchema.optional(),\n })\n .check((ctx) => {\n for (const issue of timelineIssues(ctx.value, 'redacted')) {\n ctx.issues.push({ code: 'custom', ...issue });\n }\n if (groupCaptionsRevealDictation(ctx.value)) {\n ctx.issues.push({\n code: 'custom',\n input: ctx.value.stimulus.media?.captionsUrl,\n message: GROUP_CAPTIONS_REVEAL_DICTATION,\n path: ['stimulus', 'media', 'captionsUrl'],\n });\n }\n });\n\nfunction toValidationErrors(\n issues: readonly { path: PropertyKey[]; message: string; code: string }[],\n prefix: string[],\n): ValidationError[] {\n return issues.map((issue) => ({\n path: [...prefix, ...issue.path.map(String)],\n message: issue.message,\n code: issue.code,\n }));\n}\n\n/**\n * Validates an item group in full: the container and stimulus against\n * {@link ItemGroupSchema}, then every item against the schema registered for\n * its `type`. Errors from items are reported at `items.<index>.…`.\n *\n * Unlike `validateActivity`, an item whose type is not registered is REPORTED\n * (code `unknown_activity_type`) rather than thrown: a group is validated as\n * a whole, and an author fixing a six-item group wants every problem listed,\n * not the first one that happened to throw.\n */\nexport function validateItemGroup(data: unknown): ValidationResult<ItemGroup> {\n const container = ItemGroupSchema.safeParse(data);\n if (!container.success) {\n return { success: false, errors: toValidationErrors(container.error.issues, []) };\n }\n\n const errors: ValidationError[] = [];\n const items: ActivityData[] = [];\n container.data.items.forEach((item, index) => {\n const descriptor = getActivityTypeDescriptor(item.type);\n if (descriptor === undefined) {\n errors.push({\n path: ['items', String(index), 'type'],\n message: `Activity type \"${item.type}\" is not registered`,\n code: 'unknown_activity_type',\n });\n return;\n }\n const parsed = descriptor.schema.safeParse(item);\n if (!parsed.success) {\n errors.push(...toValidationErrors(parsed.error.issues, ['items', String(index)]));\n return;\n }\n items.push(parsed.data as ActivityData);\n });\n if (groupCaptionsRevealDictation(container.data)) {\n errors.push({\n path: ['stimulus', 'media', 'captionsUrl'],\n message: GROUP_CAPTIONS_REVEAL_DICTATION,\n code: 'custom',\n });\n }\n\n if (errors.length > 0) {\n return { success: false, errors };\n }\n // zod4 optional outputs are `T | undefined`; the wire type uses exact\n // optionals. Structurally identical at runtime — the cast is type-level.\n return { success: true, data: { ...container.data, items } as unknown as ItemGroup };\n}\n","/**\n * The bounds of an interactive video — an item group with a `timeline`.\n *\n * A leaf module on purpose: the schemas, the authoring checks and the timeline\n * helpers all read these, and nothing here may import any of them back.\n */\n\n/**\n * The item types an interactive video may present. CLOSED on purpose: a type\n * added to the SDK later, or a custom type a host registers, is not silently\n * embeddable. Each one here was chosen, and each works inside a paused video —\n * a read-aloud's microphone included, because every quiz pauses the video\n * first.\n */\nexport const INTERACTIVE_VIDEO_ITEM_TYPES = [\n 'multiple-choice',\n 'fill-in-the-blanks',\n 'gap-select',\n 'dictation',\n 'read-aloud',\n] as const;\n\n/** One of {@link INTERACTIVE_VIDEO_ITEM_TYPES}. */\nexport type InteractiveVideoItemType = (typeof INTERACTIVE_VIDEO_ITEM_TYPES)[number];\n\n/** Whether `type` is one of the item types an interactive video may present. */\nexport function isInteractiveVideoItemType(type: unknown): type is InteractiveVideoItemType {\n return (INTERACTIVE_VIDEO_ITEM_TYPES as readonly unknown[]).includes(type);\n}\n\n/** The most quizzes one video may hold. */\nexport const TIMELINE_MAX_QUIZZES = 100;\n\n/**\n * The most questions one interactive video may hold, across all its quizzes.\n * The player keeps every one of them mounted, so an answer survives the\n * learner rewinding past its quiz.\n */\nexport const TIMELINE_MAX_ITEMS = 200;\n\n/** The most chapters one video may hold. */\nexport const TIMELINE_MAX_CHAPTERS = 100;\n\n/** The longest quiz or chapter title, in UTF-16 units. A title sits on one line of the player. */\nexport const TIMELINE_MAX_TITLE_LENGTH = 120;\n","import { z } from 'zod/v4';\nimport { UnknownActivityTypeError } from '../errors.js';\nimport { getActivityTypeDescriptor } from '../registry/index.js';\nimport { DictationDataSchema } from './dictation.js';\nimport { FillInTheBlanksDataSchema } from './fill-in-the-blanks.js';\nimport { GapSelectDataSchema } from './gap-select.js';\nimport { ItemGroupSchema, StimulusSchema } from './item-group.js';\nimport { MultipleChoiceDataSchema } from './multiple-choice.js';\nimport { ReadAloudDataSchema } from './read-aloud.js';\nimport { WrittenResponseDataSchema } from './written-response.js';\n\n/**\n * JSON Schema (Draft 7) for a `Stimulus`. Structural contract only — the\n * kind/media/body consistency guards are Zod-only.\n */\nexport const stimulusJsonSchema = z.toJSONSchema(StimulusSchema, { target: 'draft-7' });\n\n/**\n * JSON Schema (Draft 7) for an `ItemGroup` CONTAINER. Items appear as objects\n * with `type` and `id` only; each item's own contract is `jsonSchemaFor(type)`.\n * For an AI generation pipeline, ask for the group and each item separately\n * rather than a single nested schema — that keeps the per-type schema the\n * registry's, not a copy.\n */\nexport const itemGroupJsonSchema = z.toJSONSchema(ItemGroupSchema, { target: 'draft-7' });\n\n/**\n * JSON Schema (Draft 7) representation of the Multiple Choice activity data\n * contract, generated natively by Zod 4. Draft 7 is mandated by Requirement\n * 2.2 for the widest AI-prompt / OpenAPI tooling compatibility. The semantic\n * `.refine()` guards are not representable in JSON Schema and are\n * intentionally omitted — the export captures the *structural* contract only.\n * Since v0.3 the source schemas are loose, so these no longer emit\n * `additionalProperties: false` — the JSON Schema and `validateActivity` now\n * agree on unknown-key handling.\n */\n/**\n * JSON Schema (Draft 7) representation of the Gap Select activity data\n * contract. Structural contract only: the six semantic guards — the\n * passage/gap bijection, id uniqueness, the one-choice-source rule, and an\n * answer key that names a choice the gap offers — are Zod-only, as they are\n * for the other types.\n */\nexport const gapSelectJsonSchema = z.toJSONSchema(GapSelectDataSchema, {\n target: 'draft-7',\n});\n\n/**\n * JSON Schema (Draft 7) representation of the Dictation activity data\n * contract. Structural contract, plus the raw length caps JSON Schema can\n * state in code points as zod counts them — `maxLength` 2000 on a transcript\n * and an accepted transcript, 200 on a rule's `from` and `to`. The twelve\n * semantic guards — a transcript that survives normalisation, the caps after\n * equivalences are applied, distinct candidates, audio only, the\n * slow-recording rules, no captions, no transcript in the title — are\n * Zod-only, as they are for the other types.\n */\nexport const dictationJsonSchema = z.toJSONSchema(DictationDataSchema, {\n target: 'draft-7',\n});\n\n/**\n * JSON Schema (Draft 7) representation of the Read Aloud activity data\n * contract. Structural contract, plus the raw cap JSON Schema can state in code\n * points as zod counts them — `maxLength` 2000 on the reference text — and the\n * canonical locale pattern. The ten semantic guards — the cap after\n * normalisation, a text that survives it, the spaced-script rule, the\n * model-recording rules, unique dimensions, a weight above 0, and the take\n * bounds — are Zod-only, as they are for the other types.\n */\nexport const readAloudJsonSchema = z.toJSONSchema(ReadAloudDataSchema, {\n target: 'draft-7',\n});\n\nexport const multipleChoiceJsonSchema = z.toJSONSchema(MultipleChoiceDataSchema, {\n target: 'draft-7',\n});\n\n/**\n * JSON Schema (Draft 7) representation of the Fill-in-the-Blanks activity data\n * contract, generated natively by Zod 4. Structural contract only (semantic\n * `.refine()` guards are Zod-only and not representable in JSON Schema).\n */\nexport const fillInTheBlanksJsonSchema = z.toJSONSchema(FillInTheBlanksDataSchema, {\n target: 'draft-7',\n});\n\n/**\n * JSON Schema (Draft 7) representation of the Written Response activity data\n * contract. Structural contract only.\n */\nexport const writtenResponseJsonSchema = z.toJSONSchema(WrittenResponseDataSchema, {\n target: 'draft-7',\n});\n\n/**\n * Derives the JSON Schema (Draft 7) for any REGISTERED activity type — the\n * live, registry-backed replacement for the static per-type exports above,\n * and the building block for AI generation pipelines (R6.1): pass the result\n * as a structured-output schema so a model can only emit valid items.\n *\n * @throws UnknownActivityTypeError when `type` has no registered descriptor.\n */\nexport function jsonSchemaFor(type: string): Record<string, unknown> {\n const descriptor = getActivityTypeDescriptor(type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(type);\n }\n return z.toJSONSchema(descriptor.schema as never, { target: 'draft-7' }) as Record<\n string,\n unknown\n >;\n}\n","import { UnknownActivityTypeError } from '../errors.js';\nimport { getActivityTypeDescriptor } from '../registry/index.js';\nimport type { ActivityDataMap, ActivityType, ValidationResult } from '../types/activity.js';\n\nexport {\n DictationDataSchema,\n DictationEquivalenceSchema,\n DictationSlowMediaSchema,\n DictationToleranceSchema,\n} from './dictation.js';\nexport { FeedbackSchema } from './feedback.js';\nexport {\n BlankConfigSchema,\n FillInTheBlanksDataSchema,\n TextMatchPolicySchema,\n} from './fill-in-the-blanks.js';\nexport {\n GapSelectBankSchema,\n GapSelectChoiceSchema,\n GapSelectDataSchema,\n GapSelectGapSchema,\n} from './gap-select.js';\nexport type { RedactedStimulus } from './item-group.js';\nexport {\n ItemGroupSchema,\n MediaTimelineSchema,\n RedactedItemGroupSchema,\n RedactedStimulusSchema,\n StimulusSchema,\n TimelineChapterSchema,\n TimelineCueSchema,\n validateItemGroup,\n} from './item-group.js';\nexport {\n dictationJsonSchema,\n fillInTheBlanksJsonSchema,\n gapSelectJsonSchema,\n itemGroupJsonSchema,\n jsonSchemaFor,\n multipleChoiceJsonSchema,\n readAloudJsonSchema,\n stimulusJsonSchema,\n writtenResponseJsonSchema,\n} from './json-schema.js';\nexport {\n MediaPlaybackSchema,\n MediaSchema,\n MediaTrackSchema,\n MediaUrlSchema,\n NativeControlHintSchema,\n RedactedMediaSchema,\n} from './media.js';\nexport {\n MultipleChoiceDataSchema,\n MultipleChoiceOptionMediaSchema,\n MultipleChoiceOptionSchema,\n} from './multiple-choice.js';\nexport { ReadAloudDataSchema, ReadAloudSlowMediaSchema } from './read-aloud.js';\nexport type {\n RedactedActivity,\n RedactedBlankConfig,\n RedactedDictationData,\n RedactedDictationSlowMedia,\n RedactedFillInTheBlanksData,\n RedactedGapSelectBank,\n RedactedGapSelectChoice,\n RedactedGapSelectData,\n RedactedGapSelectGap,\n RedactedMultipleChoiceData,\n RedactedMultipleChoiceOption,\n RedactedMultipleChoiceOptionMedia,\n RedactedReadAloudData,\n RedactedWrittenResponseData,\n} from './redacted.js';\nexport {\n RedactedBlankConfigSchema,\n RedactedDictationDataSchema,\n RedactedDictationSlowMediaSchema,\n RedactedFillInTheBlanksDataSchema,\n RedactedGapSelectBankSchema,\n RedactedGapSelectChoiceSchema,\n RedactedGapSelectDataSchema,\n RedactedGapSelectGapSchema,\n RedactedMultipleChoiceDataSchema,\n RedactedMultipleChoiceOptionMediaSchema,\n RedactedMultipleChoiceOptionSchema,\n RedactedReadAloudDataSchema,\n RedactedWrittenResponseDataSchema,\n} from './redacted.js';\nexport {\n WrittenResponseDataSchema,\n WrittenResponseRubricCriterionSchema,\n WrittenResponseRubricSchema,\n} from './written-response.js';\n\n/**\n * Validates raw activity data against the schema registered for the given\n * activity type (built-in or consumer-registered via `registerActivityType`).\n *\n * Unknown keys are PRESERVED, not stripped: every built-in schema is loose,\n * so consumer sidecar fields and forward-version fields survive validation\n * verbatim in the returned `data`.\n *\n * @returns `{ success: true, data }` with the typed, validated data, or\n * `{ success: false, errors }` with one entry per failed constraint.\n * @throws UnknownActivityTypeError when `type` has no registered descriptor.\n */\nexport function validateActivity<T extends ActivityType>(\n type: T,\n data: unknown,\n): ValidationResult<ActivityDataMap[T]> {\n const descriptor = getActivityTypeDescriptor(type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(String(type));\n }\n\n const result = descriptor.schema.safeParse(data);\n\n if (result.success) {\n return { success: true, data: result.data as ActivityDataMap[T] };\n }\n\n return {\n success: false,\n errors: result.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n };\n}\n"]}