@intellectif/lk-core 1.1.0 → 1.3.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 (99) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +4 -3
  3. package/dist/ai-B222dtHH.d.cts +2154 -0
  4. package/dist/ai-B222dtHH.d.cts.map +1 -0
  5. package/dist/ai-B222dtHH.d.ts +2154 -0
  6. package/dist/ai-B222dtHH.d.ts.map +1 -0
  7. package/dist/ai-check.cjs +758 -464
  8. package/dist/ai-check.cjs.map +1 -1
  9. package/dist/ai-check.d.cts +82 -68
  10. package/dist/ai-check.d.cts.map +1 -0
  11. package/dist/ai-check.d.ts +82 -68
  12. package/dist/ai-check.d.ts.map +1 -0
  13. package/dist/ai-check.js +756 -465
  14. package/dist/ai-check.js.map +1 -1
  15. package/dist/ai-writing-CCBjTOM3.js +2496 -0
  16. package/dist/ai-writing-CCBjTOM3.js.map +1 -0
  17. package/dist/ai-writing-DCVkv4Zj.cjs +2735 -0
  18. package/dist/ai-writing-DCVkv4Zj.cjs.map +1 -0
  19. package/dist/{index-DlcqkM_L.d.ts → index-BWPRPIXL.d.ts} +263 -258
  20. package/dist/index-BWPRPIXL.d.ts.map +1 -0
  21. package/dist/index-CXyOV8sm.d.cts +153 -0
  22. package/dist/index-CXyOV8sm.d.cts.map +1 -0
  23. package/dist/index-CegM8o15.d.ts +153 -0
  24. package/dist/index-CegM8o15.d.ts.map +1 -0
  25. package/dist/index-Dyu66R4-.d.cts +1071 -0
  26. package/dist/index-Dyu66R4-.d.cts.map +1 -0
  27. package/dist/{index-DlCW0XaQ.d.cts → index-O4_ExlAD.d.cts} +263 -258
  28. package/dist/index-O4_ExlAD.d.cts.map +1 -0
  29. package/dist/index-UGxRSopE.d.ts +1071 -0
  30. package/dist/index-UGxRSopE.d.ts.map +1 -0
  31. package/dist/index.cjs +1210 -1671
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +1090 -853
  34. package/dist/index.d.cts.map +1 -0
  35. package/dist/index.d.ts +1090 -853
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +1063 -1672
  38. package/dist/index.js.map +1 -1
  39. package/dist/item-group-DXiR8nOr.js +445 -0
  40. package/dist/item-group-DXiR8nOr.js.map +1 -0
  41. package/dist/item-group-DroFXgLb.cjs +505 -0
  42. package/dist/item-group-DroFXgLb.cjs.map +1 -0
  43. package/dist/registry-DVi0LR_i.cjs +5915 -0
  44. package/dist/registry-DVi0LR_i.cjs.map +1 -0
  45. package/dist/registry-Dsx9mNsS.js +5449 -0
  46. package/dist/registry-Dsx9mNsS.js.map +1 -0
  47. package/dist/schemas-Bdw0nGPo.js +152 -0
  48. package/dist/schemas-Bdw0nGPo.js.map +1 -0
  49. package/dist/schemas-DVbAOrtd.cjs +224 -0
  50. package/dist/schemas-DVbAOrtd.cjs.map +1 -0
  51. package/dist/schemas.cjs +16 -32
  52. package/dist/schemas.d.cts +2 -2
  53. package/dist/schemas.d.ts +2 -2
  54. package/dist/schemas.js +3 -32
  55. package/dist/scoring-B2_HEhMT.cjs +1748 -0
  56. package/dist/scoring-B2_HEhMT.cjs.map +1 -0
  57. package/dist/scoring-BZqUkuDF.js +1604 -0
  58. package/dist/scoring-BZqUkuDF.js.map +1 -0
  59. package/dist/scoring.cjs +37 -75
  60. package/dist/scoring.d.cts +3 -1103
  61. package/dist/scoring.d.ts +3 -1103
  62. package/dist/scoring.js +3 -75
  63. package/dist/xapi-CMTph7wG.js +332 -0
  64. package/dist/xapi-CMTph7wG.js.map +1 -0
  65. package/dist/xapi-DNzkSJ0S.cjs +362 -0
  66. package/dist/xapi-DNzkSJ0S.cjs.map +1 -0
  67. package/dist/xapi.cjs +7 -16
  68. package/dist/xapi.d.cts +2 -150
  69. package/dist/xapi.d.ts +2 -150
  70. package/dist/xapi.js +2 -16
  71. package/package.json +4 -4
  72. package/dist/activity-MBOYLBjR.d.cts +0 -1840
  73. package/dist/activity-MBOYLBjR.d.ts +0 -1840
  74. package/dist/chunk-2JT2WUQ2.cjs +0 -458
  75. package/dist/chunk-2JT2WUQ2.cjs.map +0 -1
  76. package/dist/chunk-DSDXL3JO.cjs +0 -4597
  77. package/dist/chunk-DSDXL3JO.cjs.map +0 -1
  78. package/dist/chunk-FBKTION6.js +0 -4597
  79. package/dist/chunk-FBKTION6.js.map +0 -1
  80. package/dist/chunk-IARLJ5MW.js +0 -1256
  81. package/dist/chunk-IARLJ5MW.js.map +0 -1
  82. package/dist/chunk-LDFQUZII.cjs +0 -950
  83. package/dist/chunk-LDFQUZII.cjs.map +0 -1
  84. package/dist/chunk-NQHETFDA.js +0 -950
  85. package/dist/chunk-NQHETFDA.js.map +0 -1
  86. package/dist/chunk-SJVRUPJT.js +0 -272
  87. package/dist/chunk-SJVRUPJT.js.map +0 -1
  88. package/dist/chunk-TJJFKKH2.cjs +0 -272
  89. package/dist/chunk-TJJFKKH2.cjs.map +0 -1
  90. package/dist/chunk-VSH7ECQL.cjs +0 -1256
  91. package/dist/chunk-VSH7ECQL.cjs.map +0 -1
  92. package/dist/chunk-XS6U2ARZ.js +0 -458
  93. package/dist/chunk-XS6U2ARZ.js.map +0 -1
  94. package/dist/schemas.cjs.map +0 -1
  95. package/dist/schemas.js.map +0 -1
  96. package/dist/scoring.cjs.map +0 -1
  97. package/dist/scoring.js.map +0 -1
  98. package/dist/xapi.cjs.map +0 -1
  99. package/dist/xapi.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ import { E as MultipleChoiceOptionMediaSchema, T as MultipleChoiceDataSchema, U as DictationDataSchema, Y as UnknownActivityTypeError, _ as ReadAloudDataSchema, _t as MediaSchema, a as readSchema, g as GapSelectDataSchema, gt as FillInTheBlanksDataSchema, h as WrittenResponseDataSchema, i as isOwnSchema, o as standardJsonSchemaOf, t as getActivityTypeDescriptor } from "./registry-Dsx9mNsS.js";
2
+ import { r as StimulusSchema, t as ItemGroupSchema } from "./item-group-DXiR8nOr.js";
3
+ import * as z from "zod/v4";
4
+ //#region src/schemas/json-schema.ts
5
+ /**
6
+ * JSON Schema (Draft 7) for a `Stimulus`. Structural contract only — the
7
+ * kind/media/body consistency guards are Zod-only.
8
+ */
9
+ const stimulusJsonSchema = z.toJSONSchema(StimulusSchema, { target: "draft-7" });
10
+ /**
11
+ * JSON Schema (Draft 7) for an `ItemGroup` CONTAINER. Items appear as objects
12
+ * with `type` and `id` only; each item's own contract is `jsonSchemaFor(type)`.
13
+ * For an AI generation pipeline, ask for the group and each item separately
14
+ * rather than a single nested schema — that keeps the per-type schema the
15
+ * registry's, not a copy.
16
+ */
17
+ const itemGroupJsonSchema = z.toJSONSchema(ItemGroupSchema, { target: "draft-7" });
18
+ /**
19
+ * JSON Schema (Draft 7) representation of the Multiple Choice activity data
20
+ * contract, generated natively by Zod 4. Draft 7 is mandated by Requirement
21
+ * 2.2 for the widest AI-prompt / OpenAPI tooling compatibility. The semantic
22
+ * `.refine()` guards are not representable in JSON Schema and are
23
+ * intentionally omitted — the export captures the *structural* contract only.
24
+ * Since v0.3 the source schemas are loose, so these no longer emit
25
+ * `additionalProperties: false` — the JSON Schema and `validateActivity` now
26
+ * agree on unknown-key handling.
27
+ */
28
+ /**
29
+ * JSON Schema (Draft 7) representation of the Gap Select activity data
30
+ * contract. Structural contract only: the six semantic guards — the
31
+ * passage/gap bijection, id uniqueness, the one-choice-source rule, and an
32
+ * answer key that names a choice the gap offers — are Zod-only, as they are
33
+ * for the other types.
34
+ */
35
+ const gapSelectJsonSchema = z.toJSONSchema(GapSelectDataSchema, { target: "draft-7" });
36
+ /**
37
+ * JSON Schema (Draft 7) representation of the Dictation activity data
38
+ * contract. Structural contract, plus the raw length caps JSON Schema can
39
+ * state in code points as zod counts them — `maxLength` 2000 on a transcript
40
+ * and an accepted transcript, 200 on a rule's `from` and `to`. The twelve
41
+ * semantic guards — a transcript that survives normalisation, the caps after
42
+ * equivalences are applied, distinct candidates, audio only, the
43
+ * slow-recording rules, no captions, no transcript in the title — are
44
+ * Zod-only, as they are for the other types.
45
+ */
46
+ const dictationJsonSchema = z.toJSONSchema(DictationDataSchema, { target: "draft-7" });
47
+ /**
48
+ * JSON Schema (Draft 7) representation of the Read Aloud activity data
49
+ * contract. Structural contract, plus the raw cap JSON Schema can state in code
50
+ * points as zod counts them — `maxLength` 2000 on the reference text — and the
51
+ * canonical locale pattern. The ten semantic guards — the cap after
52
+ * normalisation, a text that survives it, the spaced-script rule, the
53
+ * model-recording rules, unique dimensions, a weight above 0, and the take
54
+ * bounds — are Zod-only, as they are for the other types.
55
+ */
56
+ const readAloudJsonSchema = z.toJSONSchema(ReadAloudDataSchema, { target: "draft-7" });
57
+ const multipleChoiceJsonSchema = z.toJSONSchema(MultipleChoiceDataSchema, { target: "draft-7" });
58
+ /**
59
+ * JSON Schema (Draft 7) representation of the Fill-in-the-Blanks activity data
60
+ * contract, generated natively by Zod 4. Structural contract only (semantic
61
+ * `.refine()` guards are Zod-only and not representable in JSON Schema).
62
+ */
63
+ const fillInTheBlanksJsonSchema = z.toJSONSchema(FillInTheBlanksDataSchema, { target: "draft-7" });
64
+ /**
65
+ * JSON Schema (Draft 7) representation of the Written Response activity data
66
+ * contract. Structural contract only.
67
+ */
68
+ const writtenResponseJsonSchema = z.toJSONSchema(WrittenResponseDataSchema, { target: "draft-7" });
69
+ /**
70
+ * Derives the JSON Schema (Draft 7) for any REGISTERED activity type — the
71
+ * live, registry-backed replacement for the static per-type exports above,
72
+ * and the building block for AI generation pipelines (R6.1): pass the result
73
+ * as a structured-output schema so a model can only emit valid items.
74
+ *
75
+ * For a type you registered, it is the descriptor's `jsonSchema` when you gave
76
+ * one, or else what the schema produces through the Standard JSON Schema
77
+ * converter (`'~standard'.jsonSchema`) — a zod 4.6 schema has one. A fresh copy
78
+ * every call.
79
+ *
80
+ * @throws UnknownActivityTypeError when `type` has no registered descriptor.
81
+ * @throws Error when a registered type has neither a `jsonSchema` nor a schema
82
+ * that can produce one.
83
+ */
84
+ function jsonSchemaFor(type) {
85
+ const descriptor = getActivityTypeDescriptor(type);
86
+ if (descriptor === void 0) throw new UnknownActivityTypeError(type);
87
+ if (isOwnSchema(descriptor.schema)) return z.toJSONSchema(descriptor.schema, { target: "draft-7" });
88
+ if (descriptor.jsonSchema !== void 0) return structuredClone(descriptor.jsonSchema);
89
+ const generated = standardJsonSchemaOf(descriptor.schema);
90
+ if (generated === void 0) throw new Error(`Activity type "${descriptor.type}" has no JSON Schema: its schema implements no Standard JSON Schema converter ('~standard'.jsonSchema). Give its descriptor a \`jsonSchema\`.`);
91
+ return generated;
92
+ }
93
+ //#endregion
94
+ //#region src/schemas/index.ts
95
+ /**
96
+ * Checks a piece of activity media — an item's `media`, a stimulus's, a
97
+ * dictation's `slowMedia` — on its own, the way `validateActivity` checks it
98
+ * inside an item: its kind, an address in the allowed schemes, a playback
99
+ * policy only on audio, captions and tracks only where they can play. For an
100
+ * editor's media picker, which holds the media before the item is whole.
101
+ *
102
+ * @returns `{ success: true, data }`, or `{ success: false, errors }` with the
103
+ * same codes, paths and messages `validateActivity` reports.
104
+ */
105
+ function validateMedia(value) {
106
+ return asValidation(readSchema(MediaSchema, value, "Media"));
107
+ }
108
+ /**
109
+ * Checks a multiple-choice option's `media` on its own: a picture or a
110
+ * recording, at an address in the allowed schemes, with no playback policy.
111
+ *
112
+ * @returns `{ success: true, data }`, or `{ success: false, errors }` with the
113
+ * same codes, paths and messages `validateActivity` reports.
114
+ */
115
+ function validateOptionMedia(value) {
116
+ return asValidation(readSchema(MultipleChoiceOptionMediaSchema, value, "Option media"));
117
+ }
118
+ function asValidation(reading) {
119
+ if (reading.success) return {
120
+ success: true,
121
+ data: reading.data
122
+ };
123
+ return {
124
+ success: false,
125
+ errors: reading.issues.map((issue) => ({
126
+ path: issue.path.map(String),
127
+ message: issue.message,
128
+ code: issue.code
129
+ }))
130
+ };
131
+ }
132
+ /**
133
+ * Validates raw activity data against the schema registered for the given
134
+ * activity type (built-in or consumer-registered via `registerActivityType`).
135
+ *
136
+ * Unknown keys are PRESERVED, not stripped: every built-in schema is loose,
137
+ * so consumer sidecar fields and forward-version fields survive validation
138
+ * verbatim in the returned `data`.
139
+ *
140
+ * @returns `{ success: true, data }` with the typed, validated data, or
141
+ * `{ success: false, errors }` with one entry per failed constraint.
142
+ * @throws UnknownActivityTypeError when `type` has no registered descriptor.
143
+ */
144
+ function validateActivity(type, data) {
145
+ const descriptor = getActivityTypeDescriptor(type);
146
+ if (descriptor === void 0) throw new UnknownActivityTypeError(String(type));
147
+ return asValidation(readSchema(descriptor.schema, data, `Activity type "${descriptor.type}"`));
148
+ }
149
+ //#endregion
150
+ export { fillInTheBlanksJsonSchema as a, jsonSchemaFor as c, stimulusJsonSchema as d, writtenResponseJsonSchema as f, dictationJsonSchema as i, multipleChoiceJsonSchema as l, validateMedia as n, gapSelectJsonSchema as o, validateOptionMedia as r, itemGroupJsonSchema as s, validateActivity as t, readAloudJsonSchema as u };
151
+
152
+ //# sourceMappingURL=schemas-Bdw0nGPo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas-Bdw0nGPo.js","names":[],"sources":["../src/schemas/json-schema.ts","../src/schemas/index.ts"],"sourcesContent":["import * as 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 { isOwnSchema, standardJsonSchemaOf } from './read-schema.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: Record<string, unknown> = z.toJSONSchema(StimulusSchema, {\n target: 'draft-7',\n});\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: Record<string, unknown> = z.toJSONSchema(ItemGroupSchema, {\n target: 'draft-7',\n});\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: Record<string, unknown> = 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: Record<string, unknown> = 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: Record<string, unknown> = z.toJSONSchema(ReadAloudDataSchema, {\n target: 'draft-7',\n});\n\nexport const multipleChoiceJsonSchema: Record<string, unknown> = z.toJSONSchema(\n MultipleChoiceDataSchema,\n {\n target: 'draft-7',\n },\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: Record<string, unknown> = z.toJSONSchema(\n FillInTheBlanksDataSchema,\n {\n target: 'draft-7',\n },\n);\n\n/**\n * JSON Schema (Draft 7) representation of the Written Response activity data\n * contract. Structural contract only.\n */\nexport const writtenResponseJsonSchema: Record<string, unknown> = z.toJSONSchema(\n WrittenResponseDataSchema,\n {\n target: 'draft-7',\n },\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 * For a type you registered, it is the descriptor's `jsonSchema` when you gave\n * one, or else what the schema produces through the Standard JSON Schema\n * converter (`'~standard'.jsonSchema`) — a zod 4.6 schema has one. A fresh copy\n * every call.\n *\n * @throws UnknownActivityTypeError when `type` has no registered descriptor.\n * @throws Error when a registered type has neither a `jsonSchema` nor a schema\n * that can produce one.\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 if (isOwnSchema(descriptor.schema)) {\n return z.toJSONSchema(descriptor.schema as never, { target: 'draft-7' }) as Record<\n string,\n unknown\n >;\n }\n if (descriptor.jsonSchema !== undefined) {\n return structuredClone(descriptor.jsonSchema) as Record<string, unknown>;\n }\n const generated = standardJsonSchemaOf(descriptor.schema);\n if (generated === undefined) {\n throw new Error(\n `Activity type \"${descriptor.type}\" has no JSON Schema: its schema implements no Standard JSON Schema converter ('~standard'.jsonSchema). Give its descriptor a \\`jsonSchema\\`.`,\n );\n }\n return generated;\n}\n","import { UnknownActivityTypeError } from '../errors.js';\nimport { getActivityTypeDescriptor } from '../registry/index.js';\nimport type {\n ActivityDataMap,\n ActivityMedia,\n ActivityType,\n MultipleChoiceOptionMedia,\n ValidationResult,\n} from '../types/activity.js';\nimport { MediaSchema } from './media.js';\nimport { MultipleChoiceOptionMediaSchema } from './multiple-choice.js';\nimport { readSchema, type SchemaReading } from './read-schema.js';\n\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 RedactedStimulus,\n RedactedWrittenResponseData,\n} from '../types/redacted.js';\nexport { validateItemGroup } 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';\n\n/**\n * Checks a piece of activity media — an item's `media`, a stimulus's, a\n * dictation's `slowMedia` — on its own, the way `validateActivity` checks it\n * inside an item: its kind, an address in the allowed schemes, a playback\n * policy only on audio, captions and tracks only where they can play. For an\n * editor's media picker, which holds the media before the item is whole.\n *\n * @returns `{ success: true, data }`, or `{ success: false, errors }` with the\n * same codes, paths and messages `validateActivity` reports.\n */\nexport function validateMedia(value: unknown): ValidationResult<ActivityMedia> {\n return asValidation(readSchema(MediaSchema as never, value, 'Media'));\n}\n\n/**\n * Checks a multiple-choice option's `media` on its own: a picture or a\n * recording, at an address in the allowed schemes, with no playback policy.\n *\n * @returns `{ success: true, data }`, or `{ success: false, errors }` with the\n * same codes, paths and messages `validateActivity` reports.\n */\nexport function validateOptionMedia(value: unknown): ValidationResult<MultipleChoiceOptionMedia> {\n return asValidation(readSchema(MultipleChoiceOptionMediaSchema as never, value, 'Option media'));\n}\n\nfunction asValidation<T>(reading: SchemaReading<unknown>): ValidationResult<T> {\n if (reading.success) {\n return { success: true, data: reading.data as T };\n }\n return {\n success: false,\n errors: reading.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n };\n}\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 return asValidation(readSchema(descriptor.schema, data, `Activity type \"${descriptor.type}\"`));\n}\n"],"mappings":";;;;;;;;AAgBA,MAAa,qBAA8C,EAAE,aAAa,gBAAgB,EACxF,QAAQ,UACV,CAAC;;;;;;;;AASD,MAAa,sBAA+C,EAAE,aAAa,iBAAiB,EAC1F,QAAQ,UACV,CAAC;;;;;;;;;;;;;;;;;;AAmBD,MAAa,sBAA+C,EAAE,aAAa,qBAAqB,EAC9F,QAAQ,UACV,CAAC;;;;;;;;;;;AAYD,MAAa,sBAA+C,EAAE,aAAa,qBAAqB,EAC9F,QAAQ,UACV,CAAC;;;;;;;;;;AAWD,MAAa,sBAA+C,EAAE,aAAa,qBAAqB,EAC9F,QAAQ,UACV,CAAC;AAED,MAAa,2BAAoD,EAAE,aACjE,0BACA,EACE,QAAQ,UACV,CACF;;;;;;AAOA,MAAa,4BAAqD,EAAE,aAClE,2BACA,EACE,QAAQ,UACV,CACF;;;;;AAMA,MAAa,4BAAqD,EAAE,aAClE,2BACA,EACE,QAAQ,UACV,CACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAuC;CACnE,MAAM,aAAa,0BAA0B,IAAI;CACjD,IAAI,eAAe,KAAA,GACjB,MAAM,IAAI,yBAAyB,IAAI;CAEzC,IAAI,YAAY,WAAW,MAAM,GAC/B,OAAO,EAAE,aAAa,WAAW,QAAiB,EAAE,QAAQ,UAAU,CAAC;CAKzE,IAAI,WAAW,eAAe,KAAA,GAC5B,OAAO,gBAAgB,WAAW,UAAU;CAE9C,MAAM,YAAY,qBAAqB,WAAW,MAAM;CACxD,IAAI,cAAc,KAAA,GAChB,MAAM,IAAI,MACR,kBAAkB,WAAW,KAAK,8IACpC;CAEF,OAAO;AACT;;;;;;;;;;;;;AC5FA,SAAgB,cAAc,OAAiD;CAC7E,OAAO,aAAa,WAAW,aAAsB,OAAO,OAAO,CAAC;AACtE;;;;;;;;AASA,SAAgB,oBAAoB,OAA6D;CAC/F,OAAO,aAAa,WAAW,iCAA0C,OAAO,cAAc,CAAC;AACjG;AAEA,SAAS,aAAgB,SAAsD;CAC7E,IAAI,QAAQ,SACV,OAAO;EAAE,SAAS;EAAM,MAAM,QAAQ;CAAU;CAElD,OAAO;EACL,SAAS;EACT,QAAQ,QAAQ,OAAO,KAAK,WAAW;GACrC,MAAM,MAAM,KAAK,IAAI,MAAM;GAC3B,SAAS,MAAM;GACf,MAAM,MAAM;EACd,EAAE;CACJ;AACF;;;;;;;;;;;;;AAcA,SAAgB,iBACd,MACA,MACsC;CACtC,MAAM,aAAa,0BAA0B,IAAI;CACjD,IAAI,eAAe,KAAA,GACjB,MAAM,IAAI,yBAAyB,OAAO,IAAI,CAAC;CAGjD,OAAO,aAAa,WAAW,WAAW,QAAQ,MAAM,kBAAkB,WAAW,KAAK,EAAE,CAAC;AAC/F"}
@@ -0,0 +1,224 @@
1
+ const require_registry = require("./registry-DVi0LR_i.cjs");
2
+ const require_item_group = require("./item-group-DroFXgLb.cjs");
3
+ let zod_v4 = require("zod/v4");
4
+ zod_v4 = require_registry.__toESM(zod_v4, 1);
5
+ //#region src/schemas/json-schema.ts
6
+ /**
7
+ * JSON Schema (Draft 7) for a `Stimulus`. Structural contract only — the
8
+ * kind/media/body consistency guards are Zod-only.
9
+ */
10
+ const stimulusJsonSchema = zod_v4.toJSONSchema(require_item_group.StimulusSchema, { target: "draft-7" });
11
+ /**
12
+ * JSON Schema (Draft 7) for an `ItemGroup` CONTAINER. Items appear as objects
13
+ * with `type` and `id` only; each item's own contract is `jsonSchemaFor(type)`.
14
+ * For an AI generation pipeline, ask for the group and each item separately
15
+ * rather than a single nested schema — that keeps the per-type schema the
16
+ * registry's, not a copy.
17
+ */
18
+ const itemGroupJsonSchema = zod_v4.toJSONSchema(require_item_group.ItemGroupSchema, { target: "draft-7" });
19
+ /**
20
+ * JSON Schema (Draft 7) representation of the Multiple Choice activity data
21
+ * contract, generated natively by Zod 4. Draft 7 is mandated by Requirement
22
+ * 2.2 for the widest AI-prompt / OpenAPI tooling compatibility. The semantic
23
+ * `.refine()` guards are not representable in JSON Schema and are
24
+ * intentionally omitted — the export captures the *structural* contract only.
25
+ * Since v0.3 the source schemas are loose, so these no longer emit
26
+ * `additionalProperties: false` — the JSON Schema and `validateActivity` now
27
+ * agree on unknown-key handling.
28
+ */
29
+ /**
30
+ * JSON Schema (Draft 7) representation of the Gap Select activity data
31
+ * contract. Structural contract only: the six semantic guards — the
32
+ * passage/gap bijection, id uniqueness, the one-choice-source rule, and an
33
+ * answer key that names a choice the gap offers — are Zod-only, as they are
34
+ * for the other types.
35
+ */
36
+ const gapSelectJsonSchema = zod_v4.toJSONSchema(require_registry.GapSelectDataSchema, { target: "draft-7" });
37
+ /**
38
+ * JSON Schema (Draft 7) representation of the Dictation activity data
39
+ * contract. Structural contract, plus the raw length caps JSON Schema can
40
+ * state in code points as zod counts them — `maxLength` 2000 on a transcript
41
+ * and an accepted transcript, 200 on a rule's `from` and `to`. The twelve
42
+ * semantic guards — a transcript that survives normalisation, the caps after
43
+ * equivalences are applied, distinct candidates, audio only, the
44
+ * slow-recording rules, no captions, no transcript in the title — are
45
+ * Zod-only, as they are for the other types.
46
+ */
47
+ const dictationJsonSchema = zod_v4.toJSONSchema(require_registry.DictationDataSchema, { target: "draft-7" });
48
+ /**
49
+ * JSON Schema (Draft 7) representation of the Read Aloud activity data
50
+ * contract. Structural contract, plus the raw cap JSON Schema can state in code
51
+ * points as zod counts them — `maxLength` 2000 on the reference text — and the
52
+ * canonical locale pattern. The ten semantic guards — the cap after
53
+ * normalisation, a text that survives it, the spaced-script rule, the
54
+ * model-recording rules, unique dimensions, a weight above 0, and the take
55
+ * bounds — are Zod-only, as they are for the other types.
56
+ */
57
+ const readAloudJsonSchema = zod_v4.toJSONSchema(require_registry.ReadAloudDataSchema, { target: "draft-7" });
58
+ const multipleChoiceJsonSchema = zod_v4.toJSONSchema(require_registry.MultipleChoiceDataSchema, { target: "draft-7" });
59
+ /**
60
+ * JSON Schema (Draft 7) representation of the Fill-in-the-Blanks activity data
61
+ * contract, generated natively by Zod 4. Structural contract only (semantic
62
+ * `.refine()` guards are Zod-only and not representable in JSON Schema).
63
+ */
64
+ const fillInTheBlanksJsonSchema = zod_v4.toJSONSchema(require_registry.FillInTheBlanksDataSchema, { target: "draft-7" });
65
+ /**
66
+ * JSON Schema (Draft 7) representation of the Written Response activity data
67
+ * contract. Structural contract only.
68
+ */
69
+ const writtenResponseJsonSchema = zod_v4.toJSONSchema(require_registry.WrittenResponseDataSchema, { target: "draft-7" });
70
+ /**
71
+ * Derives the JSON Schema (Draft 7) for any REGISTERED activity type — the
72
+ * live, registry-backed replacement for the static per-type exports above,
73
+ * and the building block for AI generation pipelines (R6.1): pass the result
74
+ * as a structured-output schema so a model can only emit valid items.
75
+ *
76
+ * For a type you registered, it is the descriptor's `jsonSchema` when you gave
77
+ * one, or else what the schema produces through the Standard JSON Schema
78
+ * converter (`'~standard'.jsonSchema`) — a zod 4.6 schema has one. A fresh copy
79
+ * every call.
80
+ *
81
+ * @throws UnknownActivityTypeError when `type` has no registered descriptor.
82
+ * @throws Error when a registered type has neither a `jsonSchema` nor a schema
83
+ * that can produce one.
84
+ */
85
+ function jsonSchemaFor(type) {
86
+ const descriptor = require_registry.getActivityTypeDescriptor(type);
87
+ if (descriptor === void 0) throw new require_registry.UnknownActivityTypeError(type);
88
+ if (require_registry.isOwnSchema(descriptor.schema)) return zod_v4.toJSONSchema(descriptor.schema, { target: "draft-7" });
89
+ if (descriptor.jsonSchema !== void 0) return structuredClone(descriptor.jsonSchema);
90
+ const generated = require_registry.standardJsonSchemaOf(descriptor.schema);
91
+ if (generated === void 0) throw new Error(`Activity type "${descriptor.type}" has no JSON Schema: its schema implements no Standard JSON Schema converter ('~standard'.jsonSchema). Give its descriptor a \`jsonSchema\`.`);
92
+ return generated;
93
+ }
94
+ //#endregion
95
+ //#region src/schemas/index.ts
96
+ /**
97
+ * Checks a piece of activity media — an item's `media`, a stimulus's, a
98
+ * dictation's `slowMedia` — on its own, the way `validateActivity` checks it
99
+ * inside an item: its kind, an address in the allowed schemes, a playback
100
+ * policy only on audio, captions and tracks only where they can play. For an
101
+ * editor's media picker, which holds the media before the item is whole.
102
+ *
103
+ * @returns `{ success: true, data }`, or `{ success: false, errors }` with the
104
+ * same codes, paths and messages `validateActivity` reports.
105
+ */
106
+ function validateMedia(value) {
107
+ return asValidation(require_registry.readSchema(require_registry.MediaSchema, value, "Media"));
108
+ }
109
+ /**
110
+ * Checks a multiple-choice option's `media` on its own: a picture or a
111
+ * recording, at an address in the allowed schemes, with no playback policy.
112
+ *
113
+ * @returns `{ success: true, data }`, or `{ success: false, errors }` with the
114
+ * same codes, paths and messages `validateActivity` reports.
115
+ */
116
+ function validateOptionMedia(value) {
117
+ return asValidation(require_registry.readSchema(require_registry.MultipleChoiceOptionMediaSchema, value, "Option media"));
118
+ }
119
+ function asValidation(reading) {
120
+ if (reading.success) return {
121
+ success: true,
122
+ data: reading.data
123
+ };
124
+ return {
125
+ success: false,
126
+ errors: reading.issues.map((issue) => ({
127
+ path: issue.path.map(String),
128
+ message: issue.message,
129
+ code: issue.code
130
+ }))
131
+ };
132
+ }
133
+ /**
134
+ * Validates raw activity data against the schema registered for the given
135
+ * activity type (built-in or consumer-registered via `registerActivityType`).
136
+ *
137
+ * Unknown keys are PRESERVED, not stripped: every built-in schema is loose,
138
+ * so consumer sidecar fields and forward-version fields survive validation
139
+ * verbatim in the returned `data`.
140
+ *
141
+ * @returns `{ success: true, data }` with the typed, validated data, or
142
+ * `{ success: false, errors }` with one entry per failed constraint.
143
+ * @throws UnknownActivityTypeError when `type` has no registered descriptor.
144
+ */
145
+ function validateActivity(type, data) {
146
+ const descriptor = require_registry.getActivityTypeDescriptor(type);
147
+ if (descriptor === void 0) throw new require_registry.UnknownActivityTypeError(String(type));
148
+ return asValidation(require_registry.readSchema(descriptor.schema, data, `Activity type "${descriptor.type}"`));
149
+ }
150
+ //#endregion
151
+ Object.defineProperty(exports, "dictationJsonSchema", {
152
+ enumerable: true,
153
+ get: function() {
154
+ return dictationJsonSchema;
155
+ }
156
+ });
157
+ Object.defineProperty(exports, "fillInTheBlanksJsonSchema", {
158
+ enumerable: true,
159
+ get: function() {
160
+ return fillInTheBlanksJsonSchema;
161
+ }
162
+ });
163
+ Object.defineProperty(exports, "gapSelectJsonSchema", {
164
+ enumerable: true,
165
+ get: function() {
166
+ return gapSelectJsonSchema;
167
+ }
168
+ });
169
+ Object.defineProperty(exports, "itemGroupJsonSchema", {
170
+ enumerable: true,
171
+ get: function() {
172
+ return itemGroupJsonSchema;
173
+ }
174
+ });
175
+ Object.defineProperty(exports, "jsonSchemaFor", {
176
+ enumerable: true,
177
+ get: function() {
178
+ return jsonSchemaFor;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, "multipleChoiceJsonSchema", {
182
+ enumerable: true,
183
+ get: function() {
184
+ return multipleChoiceJsonSchema;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, "readAloudJsonSchema", {
188
+ enumerable: true,
189
+ get: function() {
190
+ return readAloudJsonSchema;
191
+ }
192
+ });
193
+ Object.defineProperty(exports, "stimulusJsonSchema", {
194
+ enumerable: true,
195
+ get: function() {
196
+ return stimulusJsonSchema;
197
+ }
198
+ });
199
+ Object.defineProperty(exports, "validateActivity", {
200
+ enumerable: true,
201
+ get: function() {
202
+ return validateActivity;
203
+ }
204
+ });
205
+ Object.defineProperty(exports, "validateMedia", {
206
+ enumerable: true,
207
+ get: function() {
208
+ return validateMedia;
209
+ }
210
+ });
211
+ Object.defineProperty(exports, "validateOptionMedia", {
212
+ enumerable: true,
213
+ get: function() {
214
+ return validateOptionMedia;
215
+ }
216
+ });
217
+ Object.defineProperty(exports, "writtenResponseJsonSchema", {
218
+ enumerable: true,
219
+ get: function() {
220
+ return writtenResponseJsonSchema;
221
+ }
222
+ });
223
+
224
+ //# sourceMappingURL=schemas-DVbAOrtd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas-DVbAOrtd.cjs","names":["z","StimulusSchema","ItemGroupSchema","GapSelectDataSchema","DictationDataSchema","ReadAloudDataSchema","MultipleChoiceDataSchema","FillInTheBlanksDataSchema","WrittenResponseDataSchema","getActivityTypeDescriptor","UnknownActivityTypeError","isOwnSchema","standardJsonSchemaOf","readSchema","MediaSchema","MultipleChoiceOptionMediaSchema","getActivityTypeDescriptor","UnknownActivityTypeError"],"sources":["../src/schemas/json-schema.ts","../src/schemas/index.ts"],"sourcesContent":["import * as 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 { isOwnSchema, standardJsonSchemaOf } from './read-schema.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: Record<string, unknown> = z.toJSONSchema(StimulusSchema, {\n target: 'draft-7',\n});\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: Record<string, unknown> = z.toJSONSchema(ItemGroupSchema, {\n target: 'draft-7',\n});\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: Record<string, unknown> = 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: Record<string, unknown> = 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: Record<string, unknown> = z.toJSONSchema(ReadAloudDataSchema, {\n target: 'draft-7',\n});\n\nexport const multipleChoiceJsonSchema: Record<string, unknown> = z.toJSONSchema(\n MultipleChoiceDataSchema,\n {\n target: 'draft-7',\n },\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: Record<string, unknown> = z.toJSONSchema(\n FillInTheBlanksDataSchema,\n {\n target: 'draft-7',\n },\n);\n\n/**\n * JSON Schema (Draft 7) representation of the Written Response activity data\n * contract. Structural contract only.\n */\nexport const writtenResponseJsonSchema: Record<string, unknown> = z.toJSONSchema(\n WrittenResponseDataSchema,\n {\n target: 'draft-7',\n },\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 * For a type you registered, it is the descriptor's `jsonSchema` when you gave\n * one, or else what the schema produces through the Standard JSON Schema\n * converter (`'~standard'.jsonSchema`) — a zod 4.6 schema has one. A fresh copy\n * every call.\n *\n * @throws UnknownActivityTypeError when `type` has no registered descriptor.\n * @throws Error when a registered type has neither a `jsonSchema` nor a schema\n * that can produce one.\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 if (isOwnSchema(descriptor.schema)) {\n return z.toJSONSchema(descriptor.schema as never, { target: 'draft-7' }) as Record<\n string,\n unknown\n >;\n }\n if (descriptor.jsonSchema !== undefined) {\n return structuredClone(descriptor.jsonSchema) as Record<string, unknown>;\n }\n const generated = standardJsonSchemaOf(descriptor.schema);\n if (generated === undefined) {\n throw new Error(\n `Activity type \"${descriptor.type}\" has no JSON Schema: its schema implements no Standard JSON Schema converter ('~standard'.jsonSchema). Give its descriptor a \\`jsonSchema\\`.`,\n );\n }\n return generated;\n}\n","import { UnknownActivityTypeError } from '../errors.js';\nimport { getActivityTypeDescriptor } from '../registry/index.js';\nimport type {\n ActivityDataMap,\n ActivityMedia,\n ActivityType,\n MultipleChoiceOptionMedia,\n ValidationResult,\n} from '../types/activity.js';\nimport { MediaSchema } from './media.js';\nimport { MultipleChoiceOptionMediaSchema } from './multiple-choice.js';\nimport { readSchema, type SchemaReading } from './read-schema.js';\n\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 RedactedStimulus,\n RedactedWrittenResponseData,\n} from '../types/redacted.js';\nexport { validateItemGroup } 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';\n\n/**\n * Checks a piece of activity media — an item's `media`, a stimulus's, a\n * dictation's `slowMedia` — on its own, the way `validateActivity` checks it\n * inside an item: its kind, an address in the allowed schemes, a playback\n * policy only on audio, captions and tracks only where they can play. For an\n * editor's media picker, which holds the media before the item is whole.\n *\n * @returns `{ success: true, data }`, or `{ success: false, errors }` with the\n * same codes, paths and messages `validateActivity` reports.\n */\nexport function validateMedia(value: unknown): ValidationResult<ActivityMedia> {\n return asValidation(readSchema(MediaSchema as never, value, 'Media'));\n}\n\n/**\n * Checks a multiple-choice option's `media` on its own: a picture or a\n * recording, at an address in the allowed schemes, with no playback policy.\n *\n * @returns `{ success: true, data }`, or `{ success: false, errors }` with the\n * same codes, paths and messages `validateActivity` reports.\n */\nexport function validateOptionMedia(value: unknown): ValidationResult<MultipleChoiceOptionMedia> {\n return asValidation(readSchema(MultipleChoiceOptionMediaSchema as never, value, 'Option media'));\n}\n\nfunction asValidation<T>(reading: SchemaReading<unknown>): ValidationResult<T> {\n if (reading.success) {\n return { success: true, data: reading.data as T };\n }\n return {\n success: false,\n errors: reading.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n };\n}\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 return asValidation(readSchema(descriptor.schema, data, `Activity type \"${descriptor.type}\"`));\n}\n"],"mappings":";;;;;;;;;AAgBA,MAAa,qBAA8CA,OAAE,aAAaC,mBAAAA,gBAAgB,EACxF,QAAQ,UACV,CAAC;;;;;;;;AASD,MAAa,sBAA+CD,OAAE,aAAaE,mBAAAA,iBAAiB,EAC1F,QAAQ,UACV,CAAC;;;;;;;;;;;;;;;;;;AAmBD,MAAa,sBAA+CF,OAAE,aAAaG,iBAAAA,qBAAqB,EAC9F,QAAQ,UACV,CAAC;;;;;;;;;;;AAYD,MAAa,sBAA+CH,OAAE,aAAaI,iBAAAA,qBAAqB,EAC9F,QAAQ,UACV,CAAC;;;;;;;;;;AAWD,MAAa,sBAA+CJ,OAAE,aAAaK,iBAAAA,qBAAqB,EAC9F,QAAQ,UACV,CAAC;AAED,MAAa,2BAAoDL,OAAE,aACjEM,iBAAAA,0BACA,EACE,QAAQ,UACV,CACF;;;;;;AAOA,MAAa,4BAAqDN,OAAE,aAClEO,iBAAAA,2BACA,EACE,QAAQ,UACV,CACF;;;;;AAMA,MAAa,4BAAqDP,OAAE,aAClEQ,iBAAAA,2BACA,EACE,QAAQ,UACV,CACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAuC;CACnE,MAAM,aAAaC,iBAAAA,0BAA0B,IAAI;CACjD,IAAI,eAAe,KAAA,GACjB,MAAM,IAAIC,iBAAAA,yBAAyB,IAAI;CAEzC,IAAIC,iBAAAA,YAAY,WAAW,MAAM,GAC/B,OAAOX,OAAE,aAAa,WAAW,QAAiB,EAAE,QAAQ,UAAU,CAAC;CAKzE,IAAI,WAAW,eAAe,KAAA,GAC5B,OAAO,gBAAgB,WAAW,UAAU;CAE9C,MAAM,YAAYY,iBAAAA,qBAAqB,WAAW,MAAM;CACxD,IAAI,cAAc,KAAA,GAChB,MAAM,IAAI,MACR,kBAAkB,WAAW,KAAK,8IACpC;CAEF,OAAO;AACT;;;;;;;;;;;;;AC5FA,SAAgB,cAAc,OAAiD;CAC7E,OAAO,aAAaC,iBAAAA,WAAWC,iBAAAA,aAAsB,OAAO,OAAO,CAAC;AACtE;;;;;;;;AASA,SAAgB,oBAAoB,OAA6D;CAC/F,OAAO,aAAaD,iBAAAA,WAAWE,iBAAAA,iCAA0C,OAAO,cAAc,CAAC;AACjG;AAEA,SAAS,aAAgB,SAAsD;CAC7E,IAAI,QAAQ,SACV,OAAO;EAAE,SAAS;EAAM,MAAM,QAAQ;CAAU;CAElD,OAAO;EACL,SAAS;EACT,QAAQ,QAAQ,OAAO,KAAK,WAAW;GACrC,MAAM,MAAM,KAAK,IAAI,MAAM;GAC3B,SAAS,MAAM;GACf,MAAM,MAAM;EACd,EAAE;CACJ;AACF;;;;;;;;;;;;;AAcA,SAAgB,iBACd,MACA,MACsC;CACtC,MAAM,aAAaC,iBAAAA,0BAA0B,IAAI;CACjD,IAAI,eAAe,KAAA,GACjB,MAAM,IAAIC,iBAAAA,yBAAyB,OAAO,IAAI,CAAC;CAGjD,OAAO,aAAaJ,iBAAAA,WAAW,WAAW,QAAQ,MAAM,kBAAkB,WAAW,KAAK,EAAE,CAAC;AAC/F"}
package/dist/schemas.cjs CHANGED
@@ -1,32 +1,16 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
- var _chunk2JT2WUQ2cjs = require('./chunk-2JT2WUQ2.cjs');
16
- require('./chunk-DSDXL3JO.cjs');
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
- exports.dictationJsonSchema = _chunk2JT2WUQ2cjs.dictationJsonSchema; exports.fillInTheBlanksJsonSchema = _chunk2JT2WUQ2cjs.fillInTheBlanksJsonSchema; exports.gapSelectJsonSchema = _chunk2JT2WUQ2cjs.gapSelectJsonSchema; exports.itemGroupJsonSchema = _chunk2JT2WUQ2cjs.itemGroupJsonSchema; exports.jsonSchemaFor = _chunk2JT2WUQ2cjs.jsonSchemaFor; exports.multipleChoiceJsonSchema = _chunk2JT2WUQ2cjs.multipleChoiceJsonSchema; exports.readAloudJsonSchema = _chunk2JT2WUQ2cjs.readAloudJsonSchema; exports.stimulusJsonSchema = _chunk2JT2WUQ2cjs.stimulusJsonSchema; exports.validateActivity = _chunk2JT2WUQ2cjs.validateActivity; exports.validateItemGroup = _chunk2JT2WUQ2cjs.validateItemGroup; exports.validateMedia = _chunk2JT2WUQ2cjs.validateMedia; exports.validateOptionMedia = _chunk2JT2WUQ2cjs.validateOptionMedia; exports.writtenResponseJsonSchema = _chunk2JT2WUQ2cjs.writtenResponseJsonSchema;
32
- //# sourceMappingURL=schemas.cjs.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_item_group = require("./item-group-DroFXgLb.cjs");
3
+ const require_schemas = require("./schemas-DVbAOrtd.cjs");
4
+ exports.dictationJsonSchema = require_schemas.dictationJsonSchema;
5
+ exports.fillInTheBlanksJsonSchema = require_schemas.fillInTheBlanksJsonSchema;
6
+ exports.gapSelectJsonSchema = require_schemas.gapSelectJsonSchema;
7
+ exports.itemGroupJsonSchema = require_schemas.itemGroupJsonSchema;
8
+ exports.jsonSchemaFor = require_schemas.jsonSchemaFor;
9
+ exports.multipleChoiceJsonSchema = require_schemas.multipleChoiceJsonSchema;
10
+ exports.readAloudJsonSchema = require_schemas.readAloudJsonSchema;
11
+ exports.stimulusJsonSchema = require_schemas.stimulusJsonSchema;
12
+ exports.validateActivity = require_schemas.validateActivity;
13
+ exports.validateItemGroup = require_item_group.validateItemGroup;
14
+ exports.validateMedia = require_schemas.validateMedia;
15
+ exports.validateOptionMedia = require_schemas.validateOptionMedia;
16
+ exports.writtenResponseJsonSchema = require_schemas.writtenResponseJsonSchema;
@@ -1,2 +1,2 @@
1
- import './activity-MBOYLBjR.cjs';
2
- export { R as RedactedActivity, b as RedactedBlankConfig, c as RedactedDictationData, d as RedactedDictationSlowMedia, e as RedactedFillInTheBlanksData, f as RedactedGapSelectBank, g as RedactedGapSelectChoice, h as RedactedGapSelectData, i as RedactedGapSelectGap, j as RedactedMultipleChoiceData, k as RedactedMultipleChoiceOption, l as RedactedMultipleChoiceOptionMedia, m as RedactedReadAloudData, n as RedactedStimulus, o as RedactedWrittenResponseData, u as dictationJsonSchema, v as fillInTheBlanksJsonSchema, w as gapSelectJsonSchema, x as itemGroupJsonSchema, y as jsonSchemaFor, z as multipleChoiceJsonSchema, A as readAloudJsonSchema, B as stimulusJsonSchema, C as validateActivity, D as validateItemGroup, E as validateMedia, F as validateOptionMedia, G as writtenResponseJsonSchema } from './index-DlCW0XaQ.cjs';
1
+ import { C as RedactedMultipleChoiceData, D as RedactedStimulus, E as RedactedReadAloudData, O as RedactedWrittenResponseData, S as RedactedGapSelectGap, T as RedactedMultipleChoiceOptionMedia, _ as RedactedDictationSlowMedia, a as fillInTheBlanksJsonSchema, b as RedactedGapSelectChoice, c as jsonSchemaFor, d as stimulusJsonSchema, f as writtenResponseJsonSchema, g as RedactedDictationData, h as RedactedBlankConfig, i as dictationJsonSchema, l as multipleChoiceJsonSchema, m as RedactedActivity, n as validateMedia, o as gapSelectJsonSchema, p as validateItemGroup, r as validateOptionMedia, s as itemGroupJsonSchema, t as validateActivity, u as readAloudJsonSchema, v as RedactedFillInTheBlanksData, w as RedactedMultipleChoiceOption, x as RedactedGapSelectData, y as RedactedGapSelectBank } from "./index-O4_ExlAD.cjs";
2
+ export { type RedactedActivity, type RedactedBlankConfig, type RedactedDictationData, type RedactedDictationSlowMedia, type RedactedFillInTheBlanksData, type RedactedGapSelectBank, type RedactedGapSelectChoice, type RedactedGapSelectData, type RedactedGapSelectGap, type RedactedMultipleChoiceData, type RedactedMultipleChoiceOption, type RedactedMultipleChoiceOptionMedia, type RedactedReadAloudData, type RedactedStimulus, type RedactedWrittenResponseData, dictationJsonSchema, fillInTheBlanksJsonSchema, gapSelectJsonSchema, itemGroupJsonSchema, jsonSchemaFor, multipleChoiceJsonSchema, readAloudJsonSchema, stimulusJsonSchema, validateActivity, validateItemGroup, validateMedia, validateOptionMedia, writtenResponseJsonSchema };
package/dist/schemas.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import './activity-MBOYLBjR.js';
2
- export { R as RedactedActivity, b as RedactedBlankConfig, c as RedactedDictationData, d as RedactedDictationSlowMedia, e as RedactedFillInTheBlanksData, f as RedactedGapSelectBank, g as RedactedGapSelectChoice, h as RedactedGapSelectData, i as RedactedGapSelectGap, j as RedactedMultipleChoiceData, k as RedactedMultipleChoiceOption, l as RedactedMultipleChoiceOptionMedia, m as RedactedReadAloudData, n as RedactedStimulus, o as RedactedWrittenResponseData, u as dictationJsonSchema, v as fillInTheBlanksJsonSchema, w as gapSelectJsonSchema, x as itemGroupJsonSchema, y as jsonSchemaFor, z as multipleChoiceJsonSchema, A as readAloudJsonSchema, B as stimulusJsonSchema, C as validateActivity, D as validateItemGroup, E as validateMedia, F as validateOptionMedia, G as writtenResponseJsonSchema } from './index-DlcqkM_L.js';
1
+ import { C as RedactedMultipleChoiceData, D as RedactedStimulus, E as RedactedReadAloudData, O as RedactedWrittenResponseData, S as RedactedGapSelectGap, T as RedactedMultipleChoiceOptionMedia, _ as RedactedDictationSlowMedia, a as fillInTheBlanksJsonSchema, b as RedactedGapSelectChoice, c as jsonSchemaFor, d as stimulusJsonSchema, f as writtenResponseJsonSchema, g as RedactedDictationData, h as RedactedBlankConfig, i as dictationJsonSchema, l as multipleChoiceJsonSchema, m as RedactedActivity, n as validateMedia, o as gapSelectJsonSchema, p as validateItemGroup, r as validateOptionMedia, s as itemGroupJsonSchema, t as validateActivity, u as readAloudJsonSchema, v as RedactedFillInTheBlanksData, w as RedactedMultipleChoiceOption, x as RedactedGapSelectData, y as RedactedGapSelectBank } from "./index-BWPRPIXL.js";
2
+ export { type RedactedActivity, type RedactedBlankConfig, type RedactedDictationData, type RedactedDictationSlowMedia, type RedactedFillInTheBlanksData, type RedactedGapSelectBank, type RedactedGapSelectChoice, type RedactedGapSelectData, type RedactedGapSelectGap, type RedactedMultipleChoiceData, type RedactedMultipleChoiceOption, type RedactedMultipleChoiceOptionMedia, type RedactedReadAloudData, type RedactedStimulus, type RedactedWrittenResponseData, dictationJsonSchema, fillInTheBlanksJsonSchema, gapSelectJsonSchema, itemGroupJsonSchema, jsonSchemaFor, multipleChoiceJsonSchema, readAloudJsonSchema, stimulusJsonSchema, validateActivity, validateItemGroup, validateMedia, validateOptionMedia, writtenResponseJsonSchema };
package/dist/schemas.js CHANGED
@@ -1,32 +1,3 @@
1
- import {
2
- dictationJsonSchema,
3
- fillInTheBlanksJsonSchema,
4
- gapSelectJsonSchema,
5
- itemGroupJsonSchema,
6
- jsonSchemaFor,
7
- multipleChoiceJsonSchema,
8
- readAloudJsonSchema,
9
- stimulusJsonSchema,
10
- validateActivity,
11
- validateItemGroup,
12
- validateMedia,
13
- validateOptionMedia,
14
- writtenResponseJsonSchema
15
- } from "./chunk-XS6U2ARZ.js";
16
- import "./chunk-FBKTION6.js";
17
- export {
18
- dictationJsonSchema,
19
- fillInTheBlanksJsonSchema,
20
- gapSelectJsonSchema,
21
- itemGroupJsonSchema,
22
- jsonSchemaFor,
23
- multipleChoiceJsonSchema,
24
- readAloudJsonSchema,
25
- stimulusJsonSchema,
26
- validateActivity,
27
- validateItemGroup,
28
- validateMedia,
29
- validateOptionMedia,
30
- writtenResponseJsonSchema
31
- };
32
- //# sourceMappingURL=schemas.js.map
1
+ import { i as validateItemGroup } from "./item-group-DXiR8nOr.js";
2
+ import { a as fillInTheBlanksJsonSchema, c as jsonSchemaFor, d as stimulusJsonSchema, f as writtenResponseJsonSchema, i as dictationJsonSchema, l as multipleChoiceJsonSchema, n as validateMedia, o as gapSelectJsonSchema, r as validateOptionMedia, s as itemGroupJsonSchema, t as validateActivity, u as readAloudJsonSchema } from "./schemas-Bdw0nGPo.js";
3
+ export { dictationJsonSchema, fillInTheBlanksJsonSchema, gapSelectJsonSchema, itemGroupJsonSchema, jsonSchemaFor, multipleChoiceJsonSchema, readAloudJsonSchema, stimulusJsonSchema, validateActivity, validateItemGroup, validateMedia, validateOptionMedia, writtenResponseJsonSchema };