@intellectif/lk-core 0.4.0 → 0.5.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 (54) hide show
  1. package/dist/{chunk-QOAORTA4.cjs → chunk-4JR3UXX6.cjs} +51 -2
  2. package/dist/chunk-4JR3UXX6.cjs.map +1 -0
  3. package/dist/{chunk-A6JXV5GP.js → chunk-DUQVGLQ3.js} +56 -57
  4. package/dist/chunk-DUQVGLQ3.js.map +1 -0
  5. package/dist/chunk-FCM5VJBS.cjs +187 -0
  6. package/dist/chunk-FCM5VJBS.cjs.map +1 -0
  7. package/dist/chunk-LSHDNA2T.js +187 -0
  8. package/dist/chunk-LSHDNA2T.js.map +1 -0
  9. package/dist/{chunk-5GJJHGY5.js → chunk-NUCEUU4P.js} +50 -1
  10. package/dist/chunk-NUCEUU4P.js.map +1 -0
  11. package/dist/{chunk-RUZ52Q7A.cjs → chunk-R7PDJBRX.cjs} +19 -4
  12. package/dist/chunk-R7PDJBRX.cjs.map +1 -0
  13. package/dist/{chunk-5ZAW76F3.cjs → chunk-SM5HUGYU.cjs} +59 -60
  14. package/dist/chunk-SM5HUGYU.cjs.map +1 -0
  15. package/dist/{chunk-APDLWLYD.js → chunk-WV5WQ3SZ.js} +19 -4
  16. package/dist/chunk-WV5WQ3SZ.js.map +1 -0
  17. package/dist/index-BKyZrd94.d.cts +732 -0
  18. package/dist/index-CLmXzBhB.d.ts +732 -0
  19. package/dist/index.cjs +192 -15
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +133 -3
  22. package/dist/index.d.ts +133 -3
  23. package/dist/index.js +189 -12
  24. package/dist/index.js.map +1 -1
  25. package/dist/schemas.cjs +17 -4
  26. package/dist/schemas.cjs.map +1 -1
  27. package/dist/schemas.d.cts +3 -460
  28. package/dist/schemas.d.ts +3 -460
  29. package/dist/schemas.js +16 -3
  30. package/dist/scoring.cjs +3 -4
  31. package/dist/scoring.cjs.map +1 -1
  32. package/dist/scoring.d.cts +9 -1
  33. package/dist/scoring.d.ts +9 -1
  34. package/dist/scoring.js +2 -3
  35. package/dist/xapi.cjs +5 -3
  36. package/dist/xapi.cjs.map +1 -1
  37. package/dist/xapi.d.cts +18 -1
  38. package/dist/xapi.d.ts +18 -1
  39. package/dist/xapi.js +6 -4
  40. package/package.json +3 -2
  41. package/dist/chunk-3YAVDV5F.js +0 -47
  42. package/dist/chunk-3YAVDV5F.js.map +0 -1
  43. package/dist/chunk-55O4M45K.js +0 -57
  44. package/dist/chunk-55O4M45K.js.map +0 -1
  45. package/dist/chunk-5GJJHGY5.js.map +0 -1
  46. package/dist/chunk-5ZAW76F3.cjs.map +0 -1
  47. package/dist/chunk-A6JXV5GP.js.map +0 -1
  48. package/dist/chunk-APDLWLYD.js.map +0 -1
  49. package/dist/chunk-PIMX4B4D.cjs +0 -47
  50. package/dist/chunk-PIMX4B4D.cjs.map +0 -1
  51. package/dist/chunk-QOAORTA4.cjs.map +0 -1
  52. package/dist/chunk-RUZ52Q7A.cjs.map +0 -1
  53. package/dist/chunk-YNTYWHZI.cjs +0 -57
  54. package/dist/chunk-YNTYWHZI.cjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { V as ValidationError, C as CriterionScore, A as ActivityData, G as GradeRecord, m as ItemOutcome, r as ScoringResult, D as DeferredScoringPartial, F as FillInTheBlanksData, f as FillInTheBlanksLearnerResponse, M as MultipleChoiceData, o as MultipleChoiceLearnerResponse, W as WrittenResponseData, u as WrittenResponseLearnerResponse } from './activity-wkzRemHx.js';
2
2
  export { a as ActivityDataMap, b as ActivityFeedback, c as ActivityMedia, d as ActivityResult, e as ActivityType, B as BlankConfig, g as Grader, h as GraderKind, i as GraderUsage, j as GradingState, I as InlineCorrection, k as InteractionEvent, l as InteractionKind, L as LearnerResponse, n as LearnerResponseMap, p as MultipleChoiceOption, S as ScoringDetail, q as ScoringOutcome, T as TextMatchPolicy, s as TextMatchResult, t as ValidationResult, v as WrittenResponseRubric, w as WrittenResponseRubricCriterion, X as XAPIActor, x as XAPIConfig, y as XAPIContext, z as XAPIContextActivities, E as XAPIError, H as XAPIObject, J as XAPIResult, K as XAPIScore, N as XAPIStatement, O as XAPIVerbObject, P as levenshteinDistance, Q as matchText } from './activity-wkzRemHx.js';
3
+ import { S as SequenceEntry, l as SequenceSlot, I as ItemGroup } from './index-CLmXzBhB.js';
4
+ export { B as BlankConfigSchema, F as FeedbackSchema, a as FillInTheBlanksDataSchema, b as ItemGroupSchema, M as MediaSchema, c as MediaUrlSchema, d as MultipleChoiceDataSchema, e as MultipleChoiceOptionSchema, R as RedactedBlankConfigSchema, f as RedactedFillInTheBlanksDataSchema, g as RedactedItemGroupSchema, h as RedactedMultipleChoiceDataSchema, i as RedactedMultipleChoiceOptionSchema, j as RedactedStimulusSchema, k as RedactedWrittenResponseDataSchema, m as SequenceSlotGroup, n as Stimulus, o as StimulusKind, p as StimulusSchema, T as TextMatchPolicySchema, W as WrittenResponseDataSchema, q as WrittenResponseRubricCriterionSchema, r as WrittenResponseRubricSchema, s as fillInTheBlanksJsonSchema, t as itemGroupJsonSchema, u as jsonSchemaFor, v as multipleChoiceJsonSchema, w as stimulusJsonSchema, x as validateActivity, y as validateItemGroup, z as writtenResponseJsonSchema } from './index-CLmXzBhB.js';
3
5
  import { z } from 'zod/v4';
4
- export { BlankConfigSchema, FeedbackSchema, FillInTheBlanksDataSchema, MediaSchema, MediaUrlSchema, MultipleChoiceDataSchema, MultipleChoiceOptionSchema, RedactedBlankConfigSchema, RedactedFillInTheBlanksDataSchema, RedactedMultipleChoiceDataSchema, RedactedMultipleChoiceOptionSchema, RedactedWrittenResponseDataSchema, TextMatchPolicySchema, WrittenResponseDataSchema, WrittenResponseRubricCriterionSchema, WrittenResponseRubricSchema, fillInTheBlanksJsonSchema, jsonSchemaFor, multipleChoiceJsonSchema, validateActivity, writtenResponseJsonSchema } from './schemas.js';
5
6
  export { AssessmentScore, AssessmentSectionInput, Band, CompositionPolicy, DEFAULT_PASS_THRESHOLD, PassFailureReason, RoundingMode, RoundingPolicy, ScoredItem, SectionScore, classifyBand, composeAssessmentScore, computePassThreshold, evaluate, gte, roundGrade, score } from './scoring.js';
6
- export { AnsweredStatementParams, CompletedStatementParams, SubmittedStatementParams, XAPIObjectParams, XAPIStatementParams, XAPIVerb, XAPIVerbKey, XAPI_VERB_DISPLAY, validateXAPIStatement, xAPIBuilder } from './xapi.js';
7
+ export { AnsweredStatementParams, CompletedStatementParams, SubmittedStatementParams, XAPIObjectParams, XAPIStatementParams, XAPIVerb, XAPIVerbKey, XAPI_VERB_DISPLAY, validateXAPIStatement, xAPIBuilder, xapiDefinitionFor } from './xapi.js';
7
8
 
8
9
  /**
9
10
  * Canonical word counter for written-response bounds (Req 22.9): tokens are
@@ -95,6 +96,46 @@ declare function hasGrade(outcome: ItemOutcome): outcome is Extract<ItemOutcome,
95
96
  status: 'scored' | 'graded';
96
97
  }>;
97
98
 
99
+ /** Narrows a sequence entry to an item group. */
100
+ declare function isItemGroup<TItem extends {
101
+ type: string;
102
+ }>(entry: SequenceEntry<TItem>): entry is ItemGroup<TItem>;
103
+ /** Options for {@link flattenSequence}. */
104
+ interface FlattenSequenceOptions {
105
+ /**
106
+ * Shuffle the top-level entries. A group moves as ONE block — its items are
107
+ * never interleaved with other entries — which is the reason a group exists
108
+ * as a container rather than as a flag on each item.
109
+ */
110
+ shuffleEntries?: boolean;
111
+ /**
112
+ * Seed for every shuffle in this call: the entries, and each group whose
113
+ * `shuffle` is `within-group`. REQUIRED whenever anything shuffles. The SDK
114
+ * never invents one, because the server that stores an attempt and the
115
+ * client that renders it must derive the SAME order, and only a shared seed
116
+ * makes that true. The attempt id is the natural choice.
117
+ */
118
+ seed?: string;
119
+ }
120
+ /**
121
+ * Turns a sequence definition — loose activities and item groups, in authored
122
+ * order — into the ordered list of slots to present. Pure and deterministic:
123
+ * call it on the server to record an attempt's order, and on the client to
124
+ * render it, and the two agree.
125
+ *
126
+ * Shuffling is opt-in and seeded. Groups are shuffle-atomic: with
127
+ * `shuffleEntries` a group changes position but stays one contiguous block,
128
+ * and only a group that declares `shuffle: 'within-group'` has its items
129
+ * reordered. Every slot carries a `slotId` derived from the authored
130
+ * position, so identities survive shuffling.
131
+ *
132
+ * @throws Error when a shuffle is requested without a `seed`.
133
+ */
134
+ declare function flattenSequence<TItem extends {
135
+ id: string;
136
+ type: string;
137
+ }>(entries: readonly SequenceEntry<TItem>[], options?: FlattenSequenceOptions): SequenceSlot<TItem>[];
138
+
98
139
  /** ScoringResult without `passed` — the public `score()` / `evaluate()` fill that in. */
99
140
  type PartialScoringResult = Omit<ScoringResult, 'passed'>;
100
141
  /**
@@ -295,6 +336,32 @@ declare function redact<T extends {
295
336
  * that must not hold the key.
296
337
  */
297
338
  declare function assertRedacted(data: unknown): asserts data is RedactedActivityData;
339
+ /** A learner-safe item group: the container with its marker, holding `redact()` projections. */
340
+ type RedactedItemGroup = ItemGroup<RedactedActivityData> & {
341
+ redacted: true;
342
+ };
343
+ /**
344
+ * Produces the learner-safe projection of an item group: the container and
345
+ * stimulus under their own fail-closed policy (the author transcript goes;
346
+ * the passage, media and attribution stay — the learner is meant to see
347
+ * them), and every item through {@link redact} with the same `options`, so
348
+ * a per-call `policy` tightens each item exactly as it would alone.
349
+ *
350
+ * With the default `reveal: 'none'` the container is verified against the
351
+ * strict redacted schema; each item was already verified by `redact`.
352
+ */
353
+ declare function redactItemGroup<TItem extends {
354
+ type: string;
355
+ }>(group: ItemGroup<TItem>, options?: RedactOptions): RedactedItemGroup;
356
+ /**
357
+ * Asserts that `data` is a learner-safe item group: it carries the marker,
358
+ * its container and stimulus satisfy the strict redacted schema (so no
359
+ * transcript, no unclassified field), and EVERY item passes
360
+ * {@link assertRedacted} against its own type's redacted schema. Item
361
+ * failures are reported at `items.<index>.…`. Use it at the server boundary
362
+ * before sending a group to a client that must not hold the key.
363
+ */
364
+ declare function assertRedactedItemGroup(data: unknown): asserts data is RedactedItemGroup;
298
365
 
299
366
  /** Built-in Multiple Choice descriptor. */
300
367
  declare const multipleChoiceType: ActivityTypeDescriptor<MultipleChoiceData, MultipleChoiceLearnerResponse>;
@@ -309,6 +376,69 @@ declare const fillInTheBlanksType: ActivityTypeDescriptor<FillInTheBlanksData, F
309
376
  */
310
377
  declare const writtenResponseType: ActivityTypeDescriptor<WrittenResponseData, WrittenResponseLearnerResponse>;
311
378
 
379
+ /**
380
+ * Seeded, deterministic shuffling — the ONE algorithm every presentation-order
381
+ * decision in the SDK goes through: option order in a multiple-choice item,
382
+ * item order inside an item group, entry order in a sequence. A server and a
383
+ * client holding the same seed derive the same order, and an order recorded
384
+ * against an attempt can be rebuilt later from nothing but its seed.
385
+ *
386
+ * STABILITY: the hash and the generator are part of the wire contract. A
387
+ * stored attempt may hold only a seed and rely on this function to reproduce
388
+ * the order it presented; changing either would silently re-order every
389
+ * recorded attempt. Any change here is a package major, and the pinned
390
+ * permutation test exists so an accidental one fails loudly.
391
+ */
392
+ /** FNV-1a hash of a string → unsigned 32-bit integer. */
393
+ declare function hashSeed(input: string): number;
394
+ /**
395
+ * Which draw the Fisher–Yates step uses.
396
+ *
397
+ * - `1` — the original. Takes the index from the LCG's LOW bits (`s % (i+1)`).
398
+ * - `2` — takes it from the HIGH bits. Same LCG, same seed, different draw.
399
+ *
400
+ * The difference is not cosmetic. In a linear congruential generator with a
401
+ * power-of-two modulus, the low bits have drastically short periods: bit 0
402
+ * alternates, bit 1 has period 4, and so on. `% (i+1)` reads exactly those
403
+ * bits, so consecutive draws are correlated and most permutations become
404
+ * unreachable FOR EVERY SEED THAT WILL EVER EXIST:
405
+ *
406
+ * | items | permutations | reachable under v1 | under v2 |
407
+ * | ----- | ------------ | ------------------ | -------- |
408
+ * | 4 | 24 | 12 | 24 |
409
+ * | 5 | 120 | 60 | 120 |
410
+ * | 6 | 720 | 180 | 720 |
411
+ *
412
+ * It also biases WHERE an option lands. On a four-option item under v1 the
413
+ * last authored option takes the first presented position 8.3% of the time
414
+ * and the second position 41.7%, against 25% each — a systematic advantage to
415
+ * anyone who notices. For a summative exam that is a fairness defect, not a
416
+ * curiosity.
417
+ *
418
+ * v1 remains the DEFAULT regardless, because these permutations are a wire
419
+ * contract: an attempt may be stored with nothing but its seed, and a review
420
+ * render of that attempt has to reproduce the order the learner actually saw.
421
+ * Switching the default would silently re-order every recorded attempt, so it
422
+ * is a package major — scheduled, not smuggled in. Choose v2 for new content
423
+ * where no attempt has been recorded yet.
424
+ */
425
+ type ShuffleVersion = 1 | 2;
426
+ /** Options for {@link seededShuffle}. */
427
+ interface SeededShuffleOptions {
428
+ /** Draw algorithm. Defaults to `1` — see {@link ShuffleVersion}. */
429
+ version?: ShuffleVersion;
430
+ }
431
+ /**
432
+ * Returns a new array holding a permutation of `items` determined entirely by
433
+ * `seed` (and the chosen {@link ShuffleVersion}): same inputs, same order —
434
+ * across processes, runtimes and releases. The input is never mutated.
435
+ *
436
+ * Compose the seed from the attempt identity AND the thing being shuffled
437
+ * (`${attemptId}:${itemId}`), so two shuffles in one attempt do not share an
438
+ * order.
439
+ */
440
+ declare function seededShuffle<T>(items: readonly T[], seed: string, options?: SeededShuffleOptions): T[];
441
+
312
442
  /**
313
443
  * All CSS custom property tokens consumed by learning-kit components.
314
444
  * Every key maps to a `--lk-*` CSS variable name; every value is a CSS value string.
@@ -345,4 +475,4 @@ interface ThemeTokens {
345
475
  '--lk-transition-base': string;
346
476
  }
347
477
 
348
- export { ActivityData, ActivitySchemaError, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, CriterionScore, DeferredScoringError, DeferredScoringPartial, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type GradeFromRubricOptions, GradeRecord, ItemOutcome, MultipleChoiceData, MultipleChoiceLearnerResponse, type PartialScoringResult, type RedactOptions, type RedactedActivityData, RedactedScoringError, type RegisteredActivityTypeDescriptor, ScoringResult, type Sensitivity, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, assertRedacted, countWords, defineActivityType, fillInTheBlanksType, getActivityTypeDescriptor, gradeFromRubric, hasGrade, multipleChoiceType, outcomeFromGrade, redact, registerActivityType, registeredActivityTypes, writtenResponseType };
478
+ export { ActivityData, ActivitySchemaError, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, CriterionScore, DeferredScoringError, DeferredScoringPartial, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type FlattenSequenceOptions, type GradeFromRubricOptions, GradeRecord, ItemGroup, ItemOutcome, MultipleChoiceData, MultipleChoiceLearnerResponse, type PartialScoringResult, type RedactOptions, type RedactedActivityData, type RedactedItemGroup, RedactedScoringError, type RegisteredActivityTypeDescriptor, ScoringResult, type SeededShuffleOptions, type Sensitivity, SequenceEntry, SequenceSlot, type ShuffleVersion, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, assertRedacted, assertRedactedItemGroup, countWords, defineActivityType, fillInTheBlanksType, flattenSequence, getActivityTypeDescriptor, gradeFromRubric, hasGrade, hashSeed, isItemGroup, multipleChoiceType, outcomeFromGrade, redact, redactItemGroup, registerActivityType, registeredActivityTypes, seededShuffle, writtenResponseType };
package/dist/index.js CHANGED
@@ -10,22 +10,32 @@ import {
10
10
  outcomeFromGrade,
11
11
  roundGrade,
12
12
  score
13
- } from "./chunk-A6JXV5GP.js";
13
+ } from "./chunk-DUQVGLQ3.js";
14
14
  import {
15
15
  XAPIVerb,
16
16
  XAPI_VERB_DISPLAY,
17
17
  validateXAPIStatement,
18
- xAPIBuilder
19
- } from "./chunk-APDLWLYD.js";
18
+ xAPIBuilder,
19
+ xapiDefinitionFor
20
+ } from "./chunk-WV5WQ3SZ.js";
20
21
  import {
22
+ ItemGroupSchema,
23
+ RedactedItemGroupSchema,
24
+ RedactedStimulusSchema,
25
+ StimulusSchema,
21
26
  fillInTheBlanksJsonSchema,
27
+ itemGroupJsonSchema,
22
28
  jsonSchemaFor,
23
29
  multipleChoiceJsonSchema,
30
+ stimulusJsonSchema,
24
31
  validateActivity,
32
+ validateItemGroup,
25
33
  writtenResponseJsonSchema
26
- } from "./chunk-55O4M45K.js";
34
+ } from "./chunk-LSHDNA2T.js";
27
35
  import {
36
+ ActivitySchemaError,
28
37
  BlankConfigSchema,
38
+ DeferredScoringError,
29
39
  FeedbackSchema,
30
40
  FillInTheBlanksDataSchema,
31
41
  MediaSchema,
@@ -36,8 +46,10 @@ import {
36
46
  RedactedFillInTheBlanksDataSchema,
37
47
  RedactedMultipleChoiceDataSchema,
38
48
  RedactedMultipleChoiceOptionSchema,
49
+ RedactedScoringError,
39
50
  RedactedWrittenResponseDataSchema,
40
51
  TextMatchPolicySchema,
52
+ UnknownActivityTypeError,
41
53
  WrittenResponseDataSchema,
42
54
  WrittenResponseRubricCriterionSchema,
43
55
  WrittenResponseRubricSchema,
@@ -51,13 +63,77 @@ import {
51
63
  registerActivityType,
52
64
  registeredActivityTypes,
53
65
  writtenResponseType
54
- } from "./chunk-5GJJHGY5.js";
55
- import {
56
- ActivitySchemaError,
57
- DeferredScoringError,
58
- RedactedScoringError,
59
- UnknownActivityTypeError
60
- } from "./chunk-3YAVDV5F.js";
66
+ } from "./chunk-NUCEUU4P.js";
67
+
68
+ // src/shuffle.ts
69
+ function hashSeed(input) {
70
+ let h = 2166136261 >>> 0;
71
+ for (let i = 0; i < input.length; i += 1) {
72
+ h ^= input.charCodeAt(i);
73
+ h = Math.imul(h, 16777619) >>> 0;
74
+ }
75
+ return h;
76
+ }
77
+ function shuffleWithSeed(items, seed, version) {
78
+ const out = [...items];
79
+ let s = seed >>> 0 || 1;
80
+ for (let i = out.length - 1; i > 0; i -= 1) {
81
+ s = Math.imul(s, 1664525) + 1013904223 >>> 0;
82
+ const j = version === 2 ? Math.floor(s / 4294967296 * (i + 1)) : s % (i + 1);
83
+ [out[i], out[j]] = [out[j], out[i]];
84
+ }
85
+ return out;
86
+ }
87
+ function seededShuffle(items, seed, options = {}) {
88
+ return shuffleWithSeed(items, hashSeed(seed), options.version ?? 1);
89
+ }
90
+
91
+ // src/item-group.ts
92
+ function isItemGroup(entry) {
93
+ return entry.type === "item-group";
94
+ }
95
+ function flattenSequence(entries, options = {}) {
96
+ const shuffleEntries = options.shuffleEntries === true;
97
+ const needsSeed = shuffleEntries || entries.some((entry) => isItemGroup(entry) && entry.shuffle === "within-group");
98
+ if (needsSeed && options.seed === void 0) {
99
+ throw new Error(
100
+ 'flattenSequence: a seed is required when shuffling (shuffleEntries, or a group with shuffle: "within-group"). Pass the attempt id so the server and the client derive the same order.'
101
+ );
102
+ }
103
+ const seed = options.seed ?? "";
104
+ const authored = entries.map((entry, entryIndex) => ({ entry, entryIndex }));
105
+ const ordered = shuffleEntries ? seededShuffle(authored, `${seed}:entries`) : authored;
106
+ const slots = [];
107
+ for (const { entry, entryIndex } of ordered) {
108
+ if (!isItemGroup(entry)) {
109
+ slots.push({ slotId: String(entryIndex), index: slots.length, activity: entry });
110
+ continue;
111
+ }
112
+ if (entry.items.length === 0) {
113
+ throw new Error(
114
+ `flattenSequence: item group "${entry.id}" has no items. An empty group would silently remove its stimulus and its questions from the presented sequence.`
115
+ );
116
+ }
117
+ const items = entry.items.map((item, itemIndex) => ({ item, itemIndex }));
118
+ const presented = entry.shuffle === "within-group" ? seededShuffle(items, `${seed}:group:${entry.id}`) : items;
119
+ const size = presented.length;
120
+ presented.forEach(({ item, itemIndex }, position) => {
121
+ slots.push({
122
+ slotId: `${entryIndex}.${itemIndex}`,
123
+ index: slots.length,
124
+ activity: item,
125
+ group: {
126
+ id: entry.id,
127
+ ...entry.title !== void 0 ? { title: entry.title } : {},
128
+ stimulus: entry.stimulus,
129
+ position,
130
+ size
131
+ }
132
+ });
133
+ });
134
+ }
135
+ return slots;
136
+ }
61
137
 
62
138
  // src/redact.ts
63
139
  function mergePolicy(base, overrides) {
@@ -181,6 +257,93 @@ function assertRedacted(data) {
181
257
  );
182
258
  }
183
259
  }
260
+ var STIMULUS_FIELD_POLICY = {
261
+ id: "public",
262
+ kind: "public",
263
+ title: "public",
264
+ body: "public",
265
+ bodyHtml: "public",
266
+ media: "public",
267
+ locale: "public",
268
+ attribution: "public",
269
+ transcript: "author-only"
270
+ };
271
+ var ITEM_GROUP_FIELD_POLICY = {
272
+ schemaVersion: "public",
273
+ type: "public",
274
+ id: "public",
275
+ title: "public",
276
+ shuffle: "public",
277
+ stimulus: STIMULUS_FIELD_POLICY
278
+ };
279
+ function redactItemGroup(group, options = {}) {
280
+ const reveal = options.reveal ?? "none";
281
+ const { items, ...container } = group;
282
+ const projected = redactValue(container, ITEM_GROUP_FIELD_POLICY, reveal);
283
+ const result = {
284
+ ...projected,
285
+ items: items.map((item) => redact(item, options)),
286
+ redacted: true
287
+ };
288
+ if (reveal === "none") {
289
+ const parsed = RedactedItemGroupSchema.safeParse(result);
290
+ if (!parsed.success) {
291
+ throw new ActivitySchemaError(
292
+ "item-group",
293
+ parsed.error.issues.map((issue) => ({
294
+ path: issue.path.map(String),
295
+ message: issue.message,
296
+ code: issue.code
297
+ }))
298
+ );
299
+ }
300
+ }
301
+ return result;
302
+ }
303
+ function assertRedactedItemGroup(data) {
304
+ if (typeof data !== "object" || data === null) {
305
+ throw new ActivitySchemaError("item-group", [
306
+ { path: [], message: "Redacted item group must be an object.", code: "invalid_type" }
307
+ ]);
308
+ }
309
+ const candidate = data;
310
+ if (candidate.redacted !== true) {
311
+ throw new ActivitySchemaError("item-group", [
312
+ {
313
+ path: ["redacted"],
314
+ message: "Missing redacted marker \u2014 this payload is not a redactItemGroup() projection.",
315
+ code: "custom"
316
+ }
317
+ ]);
318
+ }
319
+ const parsed = RedactedItemGroupSchema.safeParse(candidate);
320
+ if (!parsed.success) {
321
+ throw new ActivitySchemaError(
322
+ "item-group",
323
+ parsed.error.issues.map((issue) => ({
324
+ path: issue.path.map(String),
325
+ message: issue.message,
326
+ code: issue.code
327
+ }))
328
+ );
329
+ }
330
+ parsed.data.items.forEach((item, index) => {
331
+ try {
332
+ assertRedacted(item);
333
+ } catch (error) {
334
+ if (error instanceof ActivitySchemaError) {
335
+ throw new ActivitySchemaError(
336
+ "item-group",
337
+ error.errors.map((issue) => ({
338
+ ...issue,
339
+ path: ["items", String(index), ...issue.path]
340
+ }))
341
+ );
342
+ }
343
+ throw error;
344
+ }
345
+ });
346
+ }
184
347
  export {
185
348
  ActivitySchemaError,
186
349
  BlankConfigSchema,
@@ -188,16 +351,20 @@ export {
188
351
  DeferredScoringError,
189
352
  FeedbackSchema,
190
353
  FillInTheBlanksDataSchema,
354
+ ItemGroupSchema,
191
355
  MediaSchema,
192
356
  MediaUrlSchema,
193
357
  MultipleChoiceDataSchema,
194
358
  MultipleChoiceOptionSchema,
195
359
  RedactedBlankConfigSchema,
196
360
  RedactedFillInTheBlanksDataSchema,
361
+ RedactedItemGroupSchema,
197
362
  RedactedMultipleChoiceDataSchema,
198
363
  RedactedMultipleChoiceOptionSchema,
199
364
  RedactedScoringError,
365
+ RedactedStimulusSchema,
200
366
  RedactedWrittenResponseDataSchema,
367
+ StimulusSchema,
201
368
  TextMatchPolicySchema,
202
369
  UnknownActivityTypeError,
203
370
  WrittenResponseDataSchema,
@@ -206,6 +373,7 @@ export {
206
373
  XAPIVerb,
207
374
  XAPI_VERB_DISPLAY,
208
375
  assertRedacted,
376
+ assertRedactedItemGroup,
209
377
  classifyBand,
210
378
  composeAssessmentScore,
211
379
  computePassThreshold,
@@ -214,10 +382,14 @@ export {
214
382
  evaluate,
215
383
  fillInTheBlanksJsonSchema,
216
384
  fillInTheBlanksType,
385
+ flattenSequence,
217
386
  getActivityTypeDescriptor,
218
387
  gradeFromRubric,
219
388
  gte,
220
389
  hasGrade,
390
+ hashSeed,
391
+ isItemGroup,
392
+ itemGroupJsonSchema,
221
393
  jsonSchemaFor,
222
394
  levenshteinDistance,
223
395
  matchText,
@@ -225,14 +397,19 @@ export {
225
397
  multipleChoiceType,
226
398
  outcomeFromGrade,
227
399
  redact,
400
+ redactItemGroup,
228
401
  registerActivityType,
229
402
  registeredActivityTypes,
230
403
  roundGrade,
231
404
  score,
405
+ seededShuffle,
406
+ stimulusJsonSchema,
232
407
  validateActivity,
408
+ validateItemGroup,
233
409
  validateXAPIStatement,
234
410
  writtenResponseJsonSchema,
235
411
  writtenResponseType,
236
- xAPIBuilder
412
+ xAPIBuilder,
413
+ xapiDefinitionFor
237
414
  };
238
415
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/redact.ts"],"sourcesContent":["import { ActivitySchemaError, UnknownActivityTypeError } from './errors.js';\nimport { getActivityTypeDescriptor } from './registry/index.js';\nimport type { FieldPolicy, Sensitivity } from './registry/registry.js';\n\n/**\n * A learner-safe projection of activity data produced by {@link redact}:\n * the activity's public fields plus the `redacted: true` marker. Renderable\n * and validatable (each built-in type registers a strict redacted schema),\n * but stripped of the answer key, scoring rules, authored feedback, and\n * author-only assets.\n */\nexport interface RedactedActivityData {\n redacted: true;\n schemaVersion: string;\n type: string;\n id: string;\n title: string;\n [key: string]: unknown;\n}\n\n/** Options for {@link redact}. */\nexport interface RedactOptions {\n /**\n * Which sensitivity tiers to keep beyond `public`:\n * - `'none'` (default) — public fields only; the output satisfies the\n * type's strict redacted schema and `assertRedacted`.\n * - `'after-submit'` — public + answer-key fields (for post-submission\n * review renders). `author-only` fields and unclassified fields are\n * STILL removed; the output will NOT pass `assertRedacted`.\n */\n reveal?: 'none' | 'after-submit';\n /**\n * Per-call sensitivity overrides, merged over the type's registered\n * `fieldPolicy` (top-level keys replace; nested objects merge one level).\n *\n * Sensitivity is partly a PEDAGOGICAL decision, not purely a security one —\n * whether a rubric or a hint is learner-visible differs legitimately between\n * deployments — and the SDK must not freeze that choice. Use this to tighten\n * a field the SDK ships as `public`:\n *\n * ```ts\n * redact(essay, { policy: { rubric: 'author-only' } });\n * ```\n *\n * Overrides can only be applied to fields; they cannot re-open a field the\n * caller has not classified, because unclassified still means removed.\n * Note that tightening below what the type's `redactedSchema` requires is\n * allowed — the schema check only rejects payloads that reveal MORE than\n * the learner-safe shape.\n */\n policy?: FieldPolicy;\n}\n\n/** Merges per-call overrides over a registered policy, one level deep. */\nfunction mergePolicy(base: FieldPolicy, overrides: FieldPolicy | undefined): FieldPolicy {\n if (overrides === undefined) {\n return base;\n }\n const merged: Record<string, Sensitivity | FieldPolicy> = { ...base };\n for (const [key, override] of Object.entries(overrides)) {\n const current = merged[key];\n merged[key] =\n typeof override === 'object' && typeof current === 'object'\n ? { ...current, ...override }\n : override;\n }\n return merged;\n}\n\nfunction isSensitivity(value: Sensitivity | FieldPolicy): value is Sensitivity {\n return typeof value === 'string';\n}\n\nfunction keepField(sensitivity: Sensitivity, reveal: 'none' | 'after-submit'): boolean {\n if (sensitivity === 'public') {\n return true;\n }\n return sensitivity === 'answer-key' && reveal === 'after-submit';\n}\n\nfunction redactValue(\n value: unknown,\n policy: FieldPolicy,\n reveal: 'none' | 'after-submit',\n): unknown {\n if (Array.isArray(value)) {\n return value.map((element) => redactValue(element, policy, reveal));\n }\n if (value === null || typeof value !== 'object') {\n // A nested FieldPolicy cannot classify a primitive's sub-fields; the\n // policy author classified an object shape that is not there. Fail\n // closed: drop it (handled by the caller returning undefined).\n return undefined;\n }\n\n const source = value as Record<string, unknown>;\n const output: Record<string, unknown> = {};\n for (const [key, fieldValue] of Object.entries(source)) {\n if (fieldValue === undefined) {\n continue;\n }\n const classification = policy[key];\n if (classification === undefined) {\n // Fail closed: unclassified fields are never emitted, at any reveal\n // level. Adding a field without classifying it hides it — never leaks it.\n continue;\n }\n if (isSensitivity(classification)) {\n if (keepField(classification, reveal)) {\n output[key] = fieldValue;\n }\n continue;\n }\n const nested = redactValue(fieldValue, classification, reveal);\n if (nested !== undefined) {\n output[key] = nested;\n }\n }\n return output;\n}\n\n/**\n * Produces the learner-safe projection of activity data (R7), driven by the\n * `fieldPolicy` registered for `data.type`. Fail-closed and exhaustive by\n * construction: a field the policy does not classify is removed — including\n * unknown passthrough fields — so a NEW field added by a future SDK or a\n * consumer sidecar can never leak through an out-of-date redactor.\n *\n * With the default `reveal: 'none'`, the output validates against the type's\n * strict redacted schema (verified here; an invalid projection throws\n * {@link ActivitySchemaError} rather than shipping an unproven payload).\n *\n * @throws UnknownActivityTypeError when `data.type` is not registered.\n * @throws Error when the registered descriptor declares no `fieldPolicy`\n * (redaction cannot guess sensitivities).\n */\nexport function redact<T extends { type: string }>(\n data: T,\n options: RedactOptions = {},\n): RedactedActivityData {\n const reveal = options.reveal ?? 'none';\n const descriptor = getActivityTypeDescriptor(data.type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(String(data.type));\n }\n if (descriptor.fieldPolicy === undefined) {\n throw new Error(\n `Activity type \"${descriptor.type}\" has no fieldPolicy; redact() cannot run fail-closed redaction without one.`,\n );\n }\n\n const effectivePolicy = mergePolicy(descriptor.fieldPolicy, options.policy);\n const projected = redactValue(data, effectivePolicy, reveal) as Record<string, unknown>;\n const result = { ...projected, redacted: true as const } as RedactedActivityData;\n\n if (reveal === 'none' && descriptor.redactedSchema !== undefined) {\n const parsed = descriptor.redactedSchema.safeParse(result);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n descriptor.type,\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n }\n\n return result;\n}\n\n/**\n * Asserts that `data` is a learner-safe redacted projection: it carries the\n * `redacted: true` marker and, when its type registers a strict redacted\n * schema, validates against it (proving the absence of answer-key fields).\n * Use this at the server boundary before sending activity data to a client\n * that must not hold the key.\n */\nexport function assertRedacted(data: unknown): asserts data is RedactedActivityData {\n if (typeof data !== 'object' || data === null) {\n throw new ActivitySchemaError('unknown', [\n { path: [], message: 'Redacted activity data must be an object.', code: 'invalid_type' },\n ]);\n }\n const candidate = data as Record<string, unknown>;\n if (candidate.redacted !== true) {\n throw new ActivitySchemaError(String(candidate.type ?? 'unknown'), [\n {\n path: ['redacted'],\n message: 'Missing redacted marker — this payload is not a redact() projection.',\n code: 'custom',\n },\n ]);\n }\n const type = typeof candidate.type === 'string' ? candidate.type : '';\n const descriptor = getActivityTypeDescriptor(type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(type);\n }\n if (descriptor.redactedSchema === undefined) {\n // Fail closed: without a registered redacted schema there is no way to\n // PROVE the absence of answer-key fields, and a marker alone proves\n // nothing (any object can carry `redacted: true`).\n throw new ActivitySchemaError(descriptor.type, [\n {\n path: [],\n message: `Activity type \"${descriptor.type}\" registers no redactedSchema; assertRedacted cannot prove this payload is learner-safe.`,\n code: 'custom',\n },\n ]);\n }\n const parsed = descriptor.redactedSchema.safeParse(candidate);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n descriptor.type,\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAS,YAAY,MAAmB,WAAiD;AACvF,MAAI,cAAc,QAAW;AAC3B,WAAO;AAAA,EACT;AACA,QAAM,SAAoD,EAAE,GAAG,KAAK;AACpE,aAAW,CAAC,KAAK,QAAQ,KAAK,OAAO,QAAQ,SAAS,GAAG;AACvD,UAAM,UAAU,OAAO,GAAG;AAC1B,WAAO,GAAG,IACR,OAAO,aAAa,YAAY,OAAO,YAAY,WAC/C,EAAE,GAAG,SAAS,GAAG,SAAS,IAC1B;AAAA,EACR;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAAwD;AAC7E,SAAO,OAAO,UAAU;AAC1B;AAEA,SAAS,UAAU,aAA0B,QAA0C;AACrF,MAAI,gBAAgB,UAAU;AAC5B,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB,gBAAgB,WAAW;AACpD;AAEA,SAAS,YACP,OACA,QACA,QACS;AACT,MAAI,MAAM,QAAQ,KAAK,GAAG;A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;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/shuffle.ts","../src/item-group.ts","../src/redact.ts"],"sourcesContent":["/**\n * Seeded, deterministic shuffling — the ONE algorithm every presentation-order\n * decision in the SDK goes through: option order in a multiple-choice item,\n * item order inside an item group, entry order in a sequence. A server and a\n * client holding the same seed derive the same order, and an order recorded\n * against an attempt can be rebuilt later from nothing but its seed.\n *\n * STABILITY: the hash and the generator are part of the wire contract. A\n * stored attempt may hold only a seed and rely on this function to reproduce\n * the order it presented; changing either would silently re-order every\n * recorded attempt. Any change here is a package major, and the pinned\n * permutation test exists so an accidental one fails loudly.\n */\n\n/** FNV-1a hash of a string → unsigned 32-bit integer. */\nexport function hashSeed(input: string): number {\n let h = 2166136261 >>> 0;\n for (let i = 0; i < input.length; i += 1) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 16777619) >>> 0;\n }\n return h;\n}\n\n/**\n * Which draw the Fisher–Yates step uses.\n *\n * - `1` — the original. Takes the index from the LCG's LOW bits (`s % (i+1)`).\n * - `2` — takes it from the HIGH bits. Same LCG, same seed, different draw.\n *\n * The difference is not cosmetic. In a linear congruential generator with a\n * power-of-two modulus, the low bits have drastically short periods: bit 0\n * alternates, bit 1 has period 4, and so on. `% (i+1)` reads exactly those\n * bits, so consecutive draws are correlated and most permutations become\n * unreachable FOR EVERY SEED THAT WILL EVER EXIST:\n *\n * | items | permutations | reachable under v1 | under v2 |\n * | ----- | ------------ | ------------------ | -------- |\n * | 4 | 24 | 12 | 24 |\n * | 5 | 120 | 60 | 120 |\n * | 6 | 720 | 180 | 720 |\n *\n * It also biases WHERE an option lands. On a four-option item under v1 the\n * last authored option takes the first presented position 8.3% of the time\n * and the second position 41.7%, against 25% each — a systematic advantage to\n * anyone who notices. For a summative exam that is a fairness defect, not a\n * curiosity.\n *\n * v1 remains the DEFAULT regardless, because these permutations are a wire\n * contract: an attempt may be stored with nothing but its seed, and a review\n * render of that attempt has to reproduce the order the learner actually saw.\n * Switching the default would silently re-order every recorded attempt, so it\n * is a package major — scheduled, not smuggled in. Choose v2 for new content\n * where no attempt has been recorded yet.\n */\nexport type ShuffleVersion = 1 | 2;\n\n/** Options for {@link seededShuffle}. */\nexport interface SeededShuffleOptions {\n /** Draw algorithm. Defaults to `1` — see {@link ShuffleVersion}. */\n version?: ShuffleVersion;\n}\n\n/** LCG-driven Fisher–Yates over a 32-bit seed; returns a permutation (no loss, no duplicate). */\nfunction shuffleWithSeed<T>(items: readonly T[], seed: number, version: ShuffleVersion): T[] {\n const out = [...items];\n let s = seed >>> 0 || 1;\n for (let i = out.length - 1; i > 0; i -= 1) {\n s = (Math.imul(s, 1664525) + 1013904223) >>> 0;\n // v1 reads the low bits; v2 scales the whole 32-bit word, which uses the\n // high bits and reaches every permutation.\n const j = version === 2 ? Math.floor((s / 4294967296) * (i + 1)) : s % (i + 1);\n [out[i], out[j]] = [out[j] as T, out[i] as T];\n }\n return out;\n}\n\n/**\n * Returns a new array holding a permutation of `items` determined entirely by\n * `seed` (and the chosen {@link ShuffleVersion}): same inputs, same order —\n * across processes, runtimes and releases. The input is never mutated.\n *\n * Compose the seed from the attempt identity AND the thing being shuffled\n * (`${attemptId}:${itemId}`), so two shuffles in one attempt do not share an\n * order.\n */\nexport function seededShuffle<T>(\n items: readonly T[],\n seed: string,\n options: SeededShuffleOptions = {},\n): T[] {\n return shuffleWithSeed(items, hashSeed(seed), options.version ?? 1);\n}\n","import { seededShuffle } from './shuffle.js';\nimport type { ItemGroup, SequenceEntry, SequenceSlot } from './types/item-group.js';\n\n/** Narrows a sequence entry to an item group. */\nexport function isItemGroup<TItem extends { type: string }>(\n entry: SequenceEntry<TItem>,\n): entry is ItemGroup<TItem> {\n return entry.type === 'item-group';\n}\n\n/** Options for {@link flattenSequence}. */\nexport interface FlattenSequenceOptions {\n /**\n * Shuffle the top-level entries. A group moves as ONE block — its items are\n * never interleaved with other entries — which is the reason a group exists\n * as a container rather than as a flag on each item.\n */\n shuffleEntries?: boolean;\n /**\n * Seed for every shuffle in this call: the entries, and each group whose\n * `shuffle` is `within-group`. REQUIRED whenever anything shuffles. The SDK\n * never invents one, because the server that stores an attempt and the\n * client that renders it must derive the SAME order, and only a shared seed\n * makes that true. The attempt id is the natural choice.\n */\n seed?: string;\n}\n\n/**\n * Turns a sequence definition — loose activities and item groups, in authored\n * order — into the ordered list of slots to present. Pure and deterministic:\n * call it on the server to record an attempt's order, and on the client to\n * render it, and the two agree.\n *\n * Shuffling is opt-in and seeded. Groups are shuffle-atomic: with\n * `shuffleEntries` a group changes position but stays one contiguous block,\n * and only a group that declares `shuffle: 'within-group'` has its items\n * reordered. Every slot carries a `slotId` derived from the authored\n * position, so identities survive shuffling.\n *\n * @throws Error when a shuffle is requested without a `seed`.\n */\nexport function flattenSequence<TItem extends { id: string; type: string }>(\n entries: readonly SequenceEntry<TItem>[],\n options: FlattenSequenceOptions = {},\n): SequenceSlot<TItem>[] {\n const shuffleEntries = options.shuffleEntries === true;\n const needsSeed =\n shuffleEntries ||\n entries.some((entry) => isItemGroup(entry) && entry.shuffle === 'within-group');\n if (needsSeed && options.seed === undefined) {\n throw new Error(\n 'flattenSequence: a seed is required when shuffling (shuffleEntries, or a group with ' +\n 'shuffle: \"within-group\"). Pass the attempt id so the server and the client derive the same order.',\n );\n }\n const seed = options.seed ?? '';\n\n // Carry the AUTHORED index through the shuffle: slot identity comes from\n // where an entry was written, never from where it happens to be shown.\n const authored = entries.map((entry, entryIndex) => ({ entry, entryIndex }));\n const ordered = shuffleEntries ? seededShuffle(authored, `${seed}:entries`) : authored;\n\n const slots: SequenceSlot<TItem>[] = [];\n for (const { entry, entryIndex } of ordered) {\n if (!isItemGroup(entry)) {\n slots.push({ slotId: String(entryIndex), index: slots.length, activity: entry });\n continue;\n }\n // An empty group contributes no slots, so it would DISAPPEAR — stimulus,\n // questions and all — from a sequence that still looks well-formed. A\n // listening section filtered to nothing upstream would leave an 18-slot\n // paper presented as 12 slots, and `composeAssessmentScore` would then\n // report a `final` grade over the survivors with nothing pending. The\n // type already declares `items` non-empty; this makes that enforceable at\n // the point where the omission would otherwise become invisible.\n if (entry.items.length === 0) {\n throw new Error(\n `flattenSequence: item group \"${entry.id}\" has no items. An empty group would silently ` +\n 'remove its stimulus and its questions from the presented sequence.',\n );\n }\n const items = entry.items.map((item, itemIndex) => ({ item, itemIndex }));\n const presented =\n entry.shuffle === 'within-group' ? seededShuffle(items, `${seed}:group:${entry.id}`) : items;\n const size = presented.length;\n presented.forEach(({ item, itemIndex }, position) => {\n slots.push({\n slotId: `${entryIndex}.${itemIndex}`,\n index: slots.length,\n activity: item,\n group: {\n id: entry.id,\n ...(entry.title !== undefined ? { title: entry.title } : {}),\n stimulus: entry.stimulus,\n position,\n size,\n },\n });\n });\n }\n return slots;\n}\n","import { ActivitySchemaError, UnknownActivityTypeError } from './errors.js';\nimport { getActivityTypeDescriptor } from './registry/index.js';\nimport type { FieldPolicy, Sensitivity } from './registry/registry.js';\nimport { RedactedItemGroupSchema } from './schemas/item-group.js';\nimport type { ItemGroup } from './types/item-group.js';\n\n/**\n * A learner-safe projection of activity data produced by {@link redact}:\n * the activity's public fields plus the `redacted: true` marker. Renderable\n * and validatable (each built-in type registers a strict redacted schema),\n * but stripped of the answer key, scoring rules, authored feedback, and\n * author-only assets.\n */\nexport interface RedactedActivityData {\n redacted: true;\n schemaVersion: string;\n type: string;\n id: string;\n title: string;\n [key: string]: unknown;\n}\n\n/** Options for {@link redact}. */\nexport interface RedactOptions {\n /**\n * Which sensitivity tiers to keep beyond `public`:\n * - `'none'` (default) — public fields only; the output satisfies the\n * type's strict redacted schema and `assertRedacted`.\n * - `'after-submit'` — public + answer-key fields (for post-submission\n * review renders). `author-only` fields and unclassified fields are\n * STILL removed; the output will NOT pass `assertRedacted`.\n */\n reveal?: 'none' | 'after-submit';\n /**\n * Per-call sensitivity overrides, merged over the type's registered\n * `fieldPolicy` (top-level keys replace; nested objects merge one level).\n *\n * Sensitivity is partly a PEDAGOGICAL decision, not purely a security one —\n * whether a rubric or a hint is learner-visible differs legitimately between\n * deployments — and the SDK must not freeze that choice. Use this to tighten\n * a field the SDK ships as `public`:\n *\n * ```ts\n * redact(essay, { policy: { rubric: 'author-only' } });\n * ```\n *\n * Overrides can only be applied to fields; they cannot re-open a field the\n * caller has not classified, because unclassified still means removed.\n * Note that tightening below what the type's `redactedSchema` requires is\n * allowed — the schema check only rejects payloads that reveal MORE than\n * the learner-safe shape.\n */\n policy?: FieldPolicy;\n}\n\n/** Merges per-call overrides over a registered policy, one level deep. */\nfunction mergePolicy(base: FieldPolicy, overrides: FieldPolicy | undefined): FieldPolicy {\n if (overrides === undefined) {\n return base;\n }\n const merged: Record<string, Sensitivity | FieldPolicy> = { ...base };\n for (const [key, override] of Object.entries(overrides)) {\n const current = merged[key];\n merged[key] =\n typeof override === 'object' && typeof current === 'object'\n ? { ...current, ...override }\n : override;\n }\n return merged;\n}\n\nfunction isSensitivity(value: Sensitivity | FieldPolicy): value is Sensitivity {\n return typeof value === 'string';\n}\n\nfunction keepField(sensitivity: Sensitivity, reveal: 'none' | 'after-submit'): boolean {\n if (sensitivity === 'public') {\n return true;\n }\n return sensitivity === 'answer-key' && reveal === 'after-submit';\n}\n\nfunction redactValue(\n value: unknown,\n policy: FieldPolicy,\n reveal: 'none' | 'after-submit',\n): unknown {\n if (Array.isArray(value)) {\n return value.map((element) => redactValue(element, policy, reveal));\n }\n if (value === null || typeof value !== 'object') {\n // A nested FieldPolicy cannot classify a primitive's sub-fields; the\n // policy author classified an object shape that is not there. Fail\n // closed: drop it (handled by the caller returning undefined).\n return undefined;\n }\n\n const source = value as Record<string, unknown>;\n const output: Record<string, unknown> = {};\n for (const [key, fieldValue] of Object.entries(source)) {\n if (fieldValue === undefined) {\n continue;\n }\n const classification = policy[key];\n if (classification === undefined) {\n // Fail closed: unclassified fields are never emitted, at any reveal\n // level. Adding a field without classifying it hides it — never leaks it.\n continue;\n }\n if (isSensitivity(classification)) {\n if (keepField(classification, reveal)) {\n output[key] = fieldValue;\n }\n continue;\n }\n const nested = redactValue(fieldValue, classification, reveal);\n if (nested !== undefined) {\n output[key] = nested;\n }\n }\n return output;\n}\n\n/**\n * Produces the learner-safe projection of activity data (R7), driven by the\n * `fieldPolicy` registered for `data.type`. Fail-closed and exhaustive by\n * construction: a field the policy does not classify is removed — including\n * unknown passthrough fields — so a NEW field added by a future SDK or a\n * consumer sidecar can never leak through an out-of-date redactor.\n *\n * With the default `reveal: 'none'`, the output validates against the type's\n * strict redacted schema (verified here; an invalid projection throws\n * {@link ActivitySchemaError} rather than shipping an unproven payload).\n *\n * @throws UnknownActivityTypeError when `data.type` is not registered.\n * @throws Error when the registered descriptor declares no `fieldPolicy`\n * (redaction cannot guess sensitivities).\n */\nexport function redact<T extends { type: string }>(\n data: T,\n options: RedactOptions = {},\n): RedactedActivityData {\n const reveal = options.reveal ?? 'none';\n const descriptor = getActivityTypeDescriptor(data.type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(String(data.type));\n }\n if (descriptor.fieldPolicy === undefined) {\n throw new Error(\n `Activity type \"${descriptor.type}\" has no fieldPolicy; redact() cannot run fail-closed redaction without one.`,\n );\n }\n\n const effectivePolicy = mergePolicy(descriptor.fieldPolicy, options.policy);\n const projected = redactValue(data, effectivePolicy, reveal) as Record<string, unknown>;\n const result = { ...projected, redacted: true as const } as RedactedActivityData;\n\n if (reveal === 'none' && descriptor.redactedSchema !== undefined) {\n const parsed = descriptor.redactedSchema.safeParse(result);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n descriptor.type,\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n }\n\n return result;\n}\n\n/**\n * Asserts that `data` is a learner-safe redacted projection: it carries the\n * `redacted: true` marker and, when its type registers a strict redacted\n * schema, validates against it (proving the absence of answer-key fields).\n * Use this at the server boundary before sending activity data to a client\n * that must not hold the key.\n */\nexport function assertRedacted(data: unknown): asserts data is RedactedActivityData {\n if (typeof data !== 'object' || data === null) {\n throw new ActivitySchemaError('unknown', [\n { path: [], message: 'Redacted activity data must be an object.', code: 'invalid_type' },\n ]);\n }\n const candidate = data as Record<string, unknown>;\n if (candidate.redacted !== true) {\n throw new ActivitySchemaError(String(candidate.type ?? 'unknown'), [\n {\n path: ['redacted'],\n message: 'Missing redacted marker — this payload is not a redact() projection.',\n code: 'custom',\n },\n ]);\n }\n const type = typeof candidate.type === 'string' ? candidate.type : '';\n const descriptor = getActivityTypeDescriptor(type);\n if (descriptor === undefined) {\n throw new UnknownActivityTypeError(type);\n }\n if (descriptor.redactedSchema === undefined) {\n // Fail closed: without a registered redacted schema there is no way to\n // PROVE the absence of answer-key fields, and a marker alone proves\n // nothing (any object can carry `redacted: true`).\n throw new ActivitySchemaError(descriptor.type, [\n {\n path: [],\n message: `Activity type \"${descriptor.type}\" registers no redactedSchema; assertRedacted cannot prove this payload is learner-safe.`,\n code: 'custom',\n },\n ]);\n }\n const parsed = descriptor.redactedSchema.safeParse(candidate);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n descriptor.type,\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n}\n\n/**\n * Sensitivity of a stimulus. Everything is learner-visible — that is what a\n * stimulus IS — except the author transcript. Fail-closed like every other\n * policy: a field added to `Stimulus` without a classification here is\n * dropped, never leaked.\n */\nconst STIMULUS_FIELD_POLICY: FieldPolicy = {\n id: 'public',\n kind: 'public',\n title: 'public',\n body: 'public',\n bodyHtml: 'public',\n media: 'public',\n locale: 'public',\n attribution: 'public',\n transcript: 'author-only',\n};\n\n/** The group container's own fields. `items` is handled separately, per item type. */\nconst ITEM_GROUP_FIELD_POLICY: FieldPolicy = {\n schemaVersion: 'public',\n type: 'public',\n id: 'public',\n title: 'public',\n shuffle: 'public',\n stimulus: STIMULUS_FIELD_POLICY,\n};\n\n/** A learner-safe item group: the container with its marker, holding `redact()` projections. */\nexport type RedactedItemGroup = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Produces the learner-safe projection of an item group: the container and\n * stimulus under their own fail-closed policy (the author transcript goes;\n * the passage, media and attribution stay — the learner is meant to see\n * them), and every item through {@link redact} with the same `options`, so\n * a per-call `policy` tightens each item exactly as it would alone.\n *\n * With the default `reveal: 'none'` the container is verified against the\n * strict redacted schema; each item was already verified by `redact`.\n */\nexport function redactItemGroup<TItem extends { type: string }>(\n group: ItemGroup<TItem>,\n options: RedactOptions = {},\n): RedactedItemGroup {\n const reveal = options.reveal ?? 'none';\n const { items, ...container } = group;\n const projected = redactValue(container, ITEM_GROUP_FIELD_POLICY, reveal) as Record<\n string,\n unknown\n >;\n const result = {\n ...projected,\n items: items.map((item) => redact(item, options)),\n redacted: true as const,\n } as RedactedItemGroup;\n\n if (reveal === 'none') {\n const parsed = RedactedItemGroupSchema.safeParse(result);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n 'item-group',\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n }\n return result;\n}\n\n/**\n * Asserts that `data` is a learner-safe item group: it carries the marker,\n * its container and stimulus satisfy the strict redacted schema (so no\n * transcript, no unclassified field), and EVERY item passes\n * {@link assertRedacted} against its own type's redacted schema. Item\n * failures are reported at `items.<index>.…`. Use it at the server boundary\n * before sending a group to a client that must not hold the key.\n */\nexport function assertRedactedItemGroup(data: unknown): asserts data is RedactedItemGroup {\n if (typeof data !== 'object' || data === null) {\n throw new ActivitySchemaError('item-group', [\n { path: [], message: 'Redacted item group must be an object.', code: 'invalid_type' },\n ]);\n }\n const candidate = data as Record<string, unknown>;\n if (candidate.redacted !== true) {\n throw new ActivitySchemaError('item-group', [\n {\n path: ['redacted'],\n message: 'Missing redacted marker — this payload is not a redactItemGroup() projection.',\n code: 'custom',\n },\n ]);\n }\n const parsed = RedactedItemGroupSchema.safeParse(candidate);\n if (!parsed.success) {\n throw new ActivitySchemaError(\n 'item-group',\n parsed.error.issues.map((issue) => ({\n path: issue.path.map(String),\n message: issue.message,\n code: issue.code,\n })),\n );\n }\n parsed.data.items.forEach((item, index) => {\n try {\n assertRedacted(item);\n } catch (error) {\n if (error instanceof ActivitySchemaError) {\n throw new ActivitySchemaError(\n 'item-group',\n error.errors.map((issue) => ({\n ...issue,\n path: ['items', String(index), ...issue.path],\n })),\n );\n }\n throw error;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,SAAS,OAAuB;AAC9C,MAAI,IAAI,eAAe;AACvB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AACxC,SAAK,MAAM,WAAW,CAAC;AACvB,QAAI,KAAK,KAAK,GAAG,QAAQ,MAAM;AAAA,EACjC;AACA,SAAO;AACT;AA0CA,SAAS,gBAAmB,OAAqB,MAAc,SAA8B;AAC3F,QAAM,MAAM,CAAC,GAAG,KAAK;AACrB,MAAI,IAAI,SAAS,KAAK;AACtB,WAAS,IAAI,IAAI,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG;AAC1C,QAAK,KAAK,KAAK,GAAG,OAAO,IAAI,eAAgB;AAG7C,UAAM,IAAI,YAAY,IAAI,KAAK,MAAO,IAAI,cAAe,IAAI,EAAE,IAAI,KAAK,IAAI;AAC5E,KAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,IAAI,CAAC,CAAM;AAAA,EAC9C;AACA,SAAO;AACT;AAWO,SAAS,cACd,OACA,MACA,UAAgC,CAAC,GAC5B;AACL,SAAO,gBAAgB,OAAO,SAAS,IAAI,GAAG,QAAQ,WAAW,CAAC;AACpE;;;ACxFO,SAAS,YACd,OAC2B;AAC3B,SAAO,MAAM,SAAS;AACxB;AAkCO,SAAS,gBACd,SACA,UAAkC,CAAC,GACZ;AACvB,QAAM,iBAAiB,QAAQ,mBAAmB;AA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AO,KAAK,GAAG,GAAG,MAAM,IAAI;AAAA,UAC9C,EAAE;AAAA,QACJ;AAAA,MACF;AACA,YAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;","names":[]}
package/dist/schemas.cjs CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkYNTYWHZIcjs = require('./chunk-YNTYWHZI.cjs');
8
7
 
9
8
 
10
9
 
@@ -12,6 +11,7 @@ var _chunkYNTYWHZIcjs = require('./chunk-YNTYWHZI.cjs');
12
11
 
13
12
 
14
13
 
14
+ var _chunkFCM5VJBScjs = require('./chunk-FCM5VJBS.cjs');
15
15
 
16
16
 
17
17
 
@@ -22,8 +22,6 @@ var _chunkYNTYWHZIcjs = require('./chunk-YNTYWHZI.cjs');
22
22
 
23
23
 
24
24
 
25
- var _chunkQOAORTA4cjs = require('./chunk-QOAORTA4.cjs');
26
- require('./chunk-PIMX4B4D.cjs');
27
25
 
28
26
 
29
27
 
@@ -31,6 +29,7 @@ require('./chunk-PIMX4B4D.cjs');
31
29
 
32
30
 
33
31
 
32
+ var _chunk4JR3UXX6cjs = require('./chunk-4JR3UXX6.cjs');
34
33
 
35
34
 
36
35
 
@@ -46,5 +45,19 @@ require('./chunk-PIMX4B4D.cjs');
46
45
 
47
46
 
48
47
 
49
- exports.BlankConfigSchema = _chunkQOAORTA4cjs.BlankConfigSchema; exports.FeedbackSchema = _chunkQOAORTA4cjs.FeedbackSchema; exports.FillInTheBlanksDataSchema = _chunkQOAORTA4cjs.FillInTheBlanksDataSchema; exports.MediaSchema = _chunkQOAORTA4cjs.MediaSchema; exports.MediaUrlSchema = _chunkQOAORTA4cjs.MediaUrlSchema; exports.MultipleChoiceDataSchema = _chunkQOAORTA4cjs.MultipleChoiceDataSchema; exports.MultipleChoiceOptionSchema = _chunkQOAORTA4cjs.MultipleChoiceOptionSchema; exports.RedactedBlankConfigSchema = _chunkQOAORTA4cjs.RedactedBlankConfigSchema; exports.RedactedFillInTheBlanksDataSchema = _chunkQOAORTA4cjs.RedactedFillInTheBlanksDataSchema; exports.RedactedMultipleChoiceDataSchema = _chunkQOAORTA4cjs.RedactedMultipleChoiceDataSchema; exports.RedactedMultipleChoiceOptionSchema = _chunkQOAORTA4cjs.RedactedMultipleChoiceOptionSchema; exports.RedactedWrittenResponseDataSchema = _chunkQOAORTA4cjs.RedactedWrittenResponseDataSchema; exports.TextMatchPolicySchema = _chunkQOAORTA4cjs.TextMatchPolicySchema; exports.WrittenResponseDataSchema = _chunkQOAORTA4cjs.WrittenResponseDataSchema; exports.WrittenResponseRubricCriterionSchema = _chunkQOAORTA4cjs.WrittenResponseRubricCriterionSchema; exports.WrittenResponseRubricSchema = _chunkQOAORTA4cjs.WrittenResponseRubricSchema; exports.fillInTheBlanksJsonSchema = _chunkYNTYWHZIcjs.fillInTheBlanksJsonSchema; exports.jsonSchemaFor = _chunkYNTYWHZIcjs.jsonSchemaFor; exports.multipleChoiceJsonSchema = _chunkYNTYWHZIcjs.multipleChoiceJsonSchema; exports.validateActivity = _chunkYNTYWHZIcjs.validateActivity; exports.writtenResponseJsonSchema = _chunkYNTYWHZIcjs.writtenResponseJsonSchema;
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+ exports.BlankConfigSchema = _chunk4JR3UXX6cjs.BlankConfigSchema; exports.FeedbackSchema = _chunk4JR3UXX6cjs.FeedbackSchema; exports.FillInTheBlanksDataSchema = _chunk4JR3UXX6cjs.FillInTheBlanksDataSchema; exports.ItemGroupSchema = _chunkFCM5VJBScjs.ItemGroupSchema; exports.MediaSchema = _chunk4JR3UXX6cjs.MediaSchema; exports.MediaUrlSchema = _chunk4JR3UXX6cjs.MediaUrlSchema; exports.MultipleChoiceDataSchema = _chunk4JR3UXX6cjs.MultipleChoiceDataSchema; exports.MultipleChoiceOptionSchema = _chunk4JR3UXX6cjs.MultipleChoiceOptionSchema; exports.RedactedBlankConfigSchema = _chunk4JR3UXX6cjs.RedactedBlankConfigSchema; exports.RedactedFillInTheBlanksDataSchema = _chunk4JR3UXX6cjs.RedactedFillInTheBlanksDataSchema; exports.RedactedItemGroupSchema = _chunkFCM5VJBScjs.RedactedItemGroupSchema; exports.RedactedMultipleChoiceDataSchema = _chunk4JR3UXX6cjs.RedactedMultipleChoiceDataSchema; exports.RedactedMultipleChoiceOptionSchema = _chunk4JR3UXX6cjs.RedactedMultipleChoiceOptionSchema; exports.RedactedStimulusSchema = _chunkFCM5VJBScjs.RedactedStimulusSchema; exports.RedactedWrittenResponseDataSchema = _chunk4JR3UXX6cjs.RedactedWrittenResponseDataSchema; exports.StimulusSchema = _chunkFCM5VJBScjs.StimulusSchema; exports.TextMatchPolicySchema = _chunk4JR3UXX6cjs.TextMatchPolicySchema; exports.WrittenResponseDataSchema = _chunk4JR3UXX6cjs.WrittenResponseDataSchema; exports.WrittenResponseRubricCriterionSchema = _chunk4JR3UXX6cjs.WrittenResponseRubricCriterionSchema; exports.WrittenResponseRubricSchema = _chunk4JR3UXX6cjs.WrittenResponseRubricSchema; exports.fillInTheBlanksJsonSchema = _chunkFCM5VJBScjs.fillInTheBlanksJsonSchema; exports.itemGroupJsonSchema = _chunkFCM5VJBScjs.itemGroupJsonSchema; exports.jsonSchemaFor = _chunkFCM5VJBScjs.jsonSchemaFor; exports.multipleChoiceJsonSchema = _chunkFCM5VJBScjs.multipleChoiceJsonSchema; exports.stimulusJsonSchema = _chunkFCM5VJBScjs.stimulusJsonSchema; exports.validateActivity = _chunkFCM5VJBScjs.validateActivity; exports.validateItemGroup = _chunkFCM5VJBScjs.validateItemGroup; exports.writtenResponseJsonSchema = _chunkFCM5VJBScjs.writtenResponseJsonSchema;
50
63
  //# sourceMappingURL=schemas.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/schemas.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,knDAAC","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/schemas.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/schemas.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2kEAAC","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/schemas.cjs"}