@nakafa/aksara-contracts 1.0.0 → 2.0.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 (166) hide show
  1. package/README.md +15 -32
  2. package/dist/{question → assessment}/answer.d.ts +14 -58
  3. package/dist/{question → assessment}/answer.js +13 -60
  4. package/dist/assessment/catalog.d.ts +235 -0
  5. package/dist/assessment/catalog.js +115 -0
  6. package/dist/assessment/chart.d.ts +62 -0
  7. package/dist/assessment/chart.js +64 -0
  8. package/dist/assessment/closure.d.ts +28 -0
  9. package/dist/assessment/closure.js +164 -0
  10. package/dist/assessment/explanation.d.ts +13 -8
  11. package/dist/assessment/explanation.js +14 -8
  12. package/dist/assessment/figure.d.ts +140 -1
  13. package/dist/assessment/figure.js +9 -2
  14. package/dist/assessment/hash.d.ts +348 -208
  15. package/dist/assessment/hash.js +14 -0
  16. package/dist/assessment/inline.d.ts +3 -1
  17. package/dist/assessment/inline.js +20 -5
  18. package/dist/assessment/item.d.ts +8 -4
  19. package/dist/assessment/item.js +6 -2
  20. package/dist/assessment/key.js +6 -6
  21. package/dist/assessment/paper.d.ts +74 -74
  22. package/dist/assessment/snapshot.d.ts +3778 -0
  23. package/dist/assessment/snapshot.js +192 -0
  24. package/dist/cache/content.d.ts +4 -4
  25. package/dist/canonical.d.ts +6 -0
  26. package/dist/canonical.js +8 -1
  27. package/dist/content.d.ts +1 -1
  28. package/dist/content.js +0 -1
  29. package/dist/delivery.d.ts +0 -3
  30. package/dist/delivery.js +0 -5
  31. package/dist/preview/artifact.d.ts +1 -120
  32. package/dist/preview/document.d.ts +0 -586
  33. package/dist/preview/document.js +1 -47
  34. package/dist/preview/spec.d.ts +6 -1984
  35. package/dist/preview/spec.js +7 -47
  36. package/dist/preview/target.d.ts +0 -173
  37. package/dist/preview/target.js +1 -70
  38. package/dist/projection/digest.d.ts +0 -127
  39. package/dist/projection/hash.d.ts +0 -127
  40. package/dist/projection/spec.d.ts +6 -211
  41. package/dist/projection/spec.js +4 -18
  42. package/dist/projection/verify.d.ts +0 -127
  43. package/dist/projection/verify.js +0 -3
  44. package/dist/release/canonical.d.ts +2 -2
  45. package/dist/release/current/evidence.d.ts +24 -24
  46. package/dist/release/current/state.d.ts +28 -56
  47. package/dist/release/current/state.js +1 -6
  48. package/dist/release/digest.d.ts +2 -2
  49. package/dist/release/hash.d.ts +5 -5
  50. package/dist/release/head.d.ts +10 -57
  51. package/dist/release/head.js +3 -14
  52. package/dist/release/identity.d.ts +3 -3
  53. package/dist/release/items.d.ts +2 -2
  54. package/dist/release/lifecycle.d.ts +18 -18
  55. package/dist/release/policy.d.ts +3 -4
  56. package/dist/release/policy.js +2 -11
  57. package/dist/release/result/digest.d.ts +6 -18
  58. package/dist/release/result/digest.js +1 -2
  59. package/dist/release/rollback/digest.d.ts +4 -19
  60. package/dist/release/rollback/spec.d.ts +30 -792
  61. package/dist/release/rollback/spec.js +1 -4
  62. package/dist/release/snapshot/data.d.ts +599 -249
  63. package/dist/release/snapshot/data.js +11 -28
  64. package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
  65. package/dist/release/snapshot/evidence/assessment.js +44 -0
  66. package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
  67. package/dist/release/snapshot/evidence.d.ts +19 -19
  68. package/dist/release/snapshot/evidence.js +2 -2
  69. package/dist/release/snapshot/scope.d.ts +5 -5
  70. package/dist/release/snapshot/scope.js +1 -1
  71. package/dist/release/snapshot/spec.d.ts +15 -15
  72. package/dist/release/snapshot/spec.js +8 -8
  73. package/dist/release/snapshot/verify.d.ts +1278 -268
  74. package/dist/release/snapshot/verify.js +8 -5
  75. package/dist/release/spec.d.ts +33 -33
  76. package/dist/release/verify.d.ts +5 -5
  77. package/dist/runtime/spec.d.ts +38 -38
  78. package/dist/runtime/spec.js +4 -5
  79. package/dist/runtime/verify.d.ts +40 -40
  80. package/dist/signature/spec.d.ts +5 -5
  81. package/dist/signature/spec.js +0 -1
  82. package/dist/signature/trusted.d.ts +4 -1
  83. package/dist/signature/trusted.js +4 -1
  84. package/dist/transport/batch.d.ts +6 -244
  85. package/dist/transport/failure.d.ts +6 -20
  86. package/dist/transport/failure.js +0 -10
  87. package/dist/transport/group.d.ts +1969 -1369
  88. package/dist/transport/group.js +0 -2
  89. package/dist/transport/request.d.ts +10691 -5086
  90. package/dist/transport/request.js +0 -3
  91. package/dist/transport/response.d.ts +219 -1442
  92. package/dist/transport/response.js +0 -4
  93. package/dist/transport/snapshot.d.ts +1187 -487
  94. package/package.json +187 -295
  95. package/dist/projection/question.d.ts +0 -1067
  96. package/dist/projection/question.js +0 -121
  97. package/dist/question/identity.d.ts +0 -175
  98. package/dist/question/identity.js +0 -207
  99. package/dist/question/item.d.ts +0 -450
  100. package/dist/question/item.js +0 -174
  101. package/dist/question/label.d.ts +0 -3
  102. package/dist/question/label.js +0 -3
  103. package/dist/question/points.d.ts +0 -18
  104. package/dist/question/points.js +0 -22
  105. package/dist/question/response.d.ts +0 -289
  106. package/dist/question/response.js +0 -167
  107. package/dist/question/rubric.d.ts +0 -234
  108. package/dist/question/rubric.js +0 -186
  109. package/dist/release/current/runtime.d.ts +0 -4
  110. package/dist/release/current/runtime.js +0 -15
  111. package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
  112. package/dist/release/snapshot/evidence/tryout.js +0 -91
  113. package/dist/runtime/protected/limits.d.ts +0 -10
  114. package/dist/runtime/protected/limits.js +0 -16
  115. package/dist/runtime/protected/spec.d.ts +0 -310
  116. package/dist/runtime/protected/spec.js +0 -80
  117. package/dist/runtime/protected/verify.d.ts +0 -83
  118. package/dist/runtime/protected/verify.js +0 -70
  119. package/dist/transport/runtime.d.ts +0 -77
  120. package/dist/transport/runtime.js +0 -33
  121. package/dist/tryout/canonical.d.ts +0 -12
  122. package/dist/tryout/canonical.js +0 -7
  123. package/dist/tryout/catalog.d.ts +0 -396
  124. package/dist/tryout/catalog.js +0 -155
  125. package/dist/tryout/closure/accounting.d.ts +0 -20
  126. package/dist/tryout/closure/accounting.js +0 -70
  127. package/dist/tryout/closure/locale.d.ts +0 -14
  128. package/dist/tryout/closure/locale.js +0 -113
  129. package/dist/tryout/closure/placement.d.ts +0 -5
  130. package/dist/tryout/closure/placement.js +0 -32
  131. package/dist/tryout/digest.d.ts +0 -34
  132. package/dist/tryout/digest.js +0 -57
  133. package/dist/tryout/hash/catalog.d.ts +0 -364
  134. package/dist/tryout/hash/catalog.js +0 -209
  135. package/dist/tryout/hash/content.d.ts +0 -215
  136. package/dist/tryout/hash/content.js +0 -75
  137. package/dist/tryout/hash/placement.d.ts +0 -242
  138. package/dist/tryout/hash/placement.js +0 -56
  139. package/dist/tryout/identity.d.ts +0 -12
  140. package/dist/tryout/identity.js +0 -47
  141. package/dist/tryout/key.d.ts +0 -4
  142. package/dist/tryout/key.js +0 -8
  143. package/dist/tryout/language.d.ts +0 -24
  144. package/dist/tryout/language.js +0 -30
  145. package/dist/tryout/placement.d.ts +0 -331
  146. package/dist/tryout/placement.js +0 -96
  147. package/dist/tryout/runtime/canonical.d.ts +0 -8
  148. package/dist/tryout/runtime/canonical.js +0 -34
  149. package/dist/tryout/runtime/hash.d.ts +0 -34
  150. package/dist/tryout/runtime/hash.js +0 -13
  151. package/dist/tryout/runtime/source.d.ts +0 -44
  152. package/dist/tryout/runtime/source.js +0 -47
  153. package/dist/tryout/runtime/spec.d.ts +0 -58
  154. package/dist/tryout/runtime/spec.js +0 -21
  155. package/dist/tryout/runtime/verify.d.ts +0 -69
  156. package/dist/tryout/runtime/verify.js +0 -67
  157. package/dist/tryout/scoring.d.ts +0 -148
  158. package/dist/tryout/scoring.js +0 -98
  159. package/dist/tryout/snapshot/canonical.d.ts +0 -7
  160. package/dist/tryout/snapshot/canonical.js +0 -18
  161. package/dist/tryout/snapshot/hash.d.ts +0 -49
  162. package/dist/tryout/snapshot/hash.js +0 -22
  163. package/dist/tryout/snapshot/spec.d.ts +0 -46
  164. package/dist/tryout/snapshot/spec.js +0 -30
  165. package/dist/tryout/spec.d.ts +0 -41
  166. package/dist/tryout/spec.js +0 -46
@@ -1,450 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- /** One locale-specific response authored without duplicated runtime keys. */
3
- export declare const QuestionResponseSourceSchema: Schema.Union<readonly [Schema.Struct<{
4
- readonly categories: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
5
- readonly kind: Schema.mutableKey<Schema.Literal<"category">>;
6
- readonly statements: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
7
- readonly correctCategoryOrder: Schema.mutableKey<Schema.Int>;
8
- readonly label: Schema.mutableKey<Schema.String>;
9
- }>>>>;
10
- }>, Schema.Struct<{
11
- readonly kind: Schema.mutableKey<Schema.Literal<"multiple-choice">>;
12
- readonly options: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
13
- readonly isCorrect: Schema.mutableKey<Schema.Boolean>;
14
- readonly label: Schema.mutableKey<Schema.String>;
15
- }>>>>;
16
- }>, Schema.Struct<{
17
- readonly criteria: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
18
- readonly finalAnswer: Schema.mutableKey<Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
19
- readonly acceptsFractions: Schema.Boolean;
20
- readonly kind: Schema.Literal<"number">;
21
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
22
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
23
- readonly value: Schema.String;
24
- }>>;
25
- readonly value: Schema.String;
26
- }>, Schema.Struct<{
27
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
28
- readonly collapseWhitespace: Schema.Boolean;
29
- readonly ignoreCase: Schema.Boolean;
30
- readonly kind: Schema.Literal<"text">;
31
- }>]>>>;
32
- readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
33
- readonly levels: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
34
- readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
35
- readonly points: Schema.mutableKey<Schema.Int>;
36
- }>>>>;
37
- }>>>>;
38
- readonly kind: Schema.mutableKey<Schema.Literal<"rubric">>;
39
- }>, Schema.Struct<{
40
- readonly key: Schema.mutableKey<Schema.Union<readonly [Schema.Struct<{
41
- readonly acceptsFractions: Schema.Boolean;
42
- readonly kind: Schema.Literal<"number">;
43
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
44
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
45
- readonly value: Schema.String;
46
- }>>;
47
- readonly value: Schema.String;
48
- }>, Schema.Struct<{
49
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
50
- readonly collapseWhitespace: Schema.Boolean;
51
- readonly ignoreCase: Schema.Boolean;
52
- readonly kind: Schema.Literal<"text">;
53
- }>]>>;
54
- readonly kind: Schema.mutableKey<Schema.Literal<"short-answer">>;
55
- }>, Schema.Struct<{
56
- readonly kind: Schema.mutableKey<Schema.Literal<"single-choice">>;
57
- readonly options: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
58
- readonly isCorrect: Schema.mutableKey<Schema.Boolean>;
59
- readonly label: Schema.mutableKey<Schema.String>;
60
- }>>>>;
61
- }>]>;
62
- export type QuestionResponseSource = typeof QuestionResponseSourceSchema.Type;
63
- /** Editorial blueprint coordinates used to prove assessment coverage. */
64
- export declare const QuestionBlueprintSchema: Schema.Struct<{
65
- readonly cognitiveLevel: Schema.String;
66
- readonly contentDomain: Schema.String;
67
- readonly topic: Schema.String;
68
- }>;
69
- export type QuestionBlueprint = typeof QuestionBlueprintSchema.Type;
70
- /**
71
- * Complete source-owned item with optional shared-stimulus identity and points.
72
- * Points appear only above the default single point and never on a rubric.
73
- */
74
- export declare const QuestionItemSchema: Schema.Struct<{
75
- readonly blueprint: Schema.optionalKey<Schema.Struct<{
76
- readonly cognitiveLevel: Schema.String;
77
- readonly contentDomain: Schema.String;
78
- readonly topic: Schema.String;
79
- }>>;
80
- readonly points: Schema.optionalKey<Schema.Int>;
81
- readonly responses: Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.optional<Schema.Union<readonly [Schema.Struct<{
82
- readonly categories: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
83
- readonly kind: Schema.mutableKey<Schema.Literal<"category">>;
84
- readonly statements: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
85
- readonly correctCategoryOrder: Schema.mutableKey<Schema.Int>;
86
- readonly label: Schema.mutableKey<Schema.String>;
87
- }>>>>;
88
- }>, Schema.Struct<{
89
- readonly kind: Schema.mutableKey<Schema.Literal<"multiple-choice">>;
90
- readonly options: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
91
- readonly isCorrect: Schema.mutableKey<Schema.Boolean>;
92
- readonly label: Schema.mutableKey<Schema.String>;
93
- }>>>>;
94
- }>, Schema.Struct<{
95
- readonly criteria: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
96
- readonly finalAnswer: Schema.mutableKey<Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
97
- readonly acceptsFractions: Schema.Boolean;
98
- readonly kind: Schema.Literal<"number">;
99
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
100
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
101
- readonly value: Schema.String;
102
- }>>;
103
- readonly value: Schema.String;
104
- }>, Schema.Struct<{
105
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
106
- readonly collapseWhitespace: Schema.Boolean;
107
- readonly ignoreCase: Schema.Boolean;
108
- readonly kind: Schema.Literal<"text">;
109
- }>]>>>;
110
- readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
111
- readonly levels: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
112
- readonly label: Schema.mutableKey<Schema.$Record<Schema.Literals<readonly ["en", "id", "de"]>, Schema.String>>;
113
- readonly points: Schema.mutableKey<Schema.Int>;
114
- }>>>>;
115
- }>>>>;
116
- readonly kind: Schema.mutableKey<Schema.Literal<"rubric">>;
117
- }>, Schema.Struct<{
118
- readonly key: Schema.mutableKey<Schema.Union<readonly [Schema.Struct<{
119
- readonly acceptsFractions: Schema.Boolean;
120
- readonly kind: Schema.Literal<"number">;
121
- readonly tolerance: Schema.optionalKey<Schema.Struct<{
122
- readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
123
- readonly value: Schema.String;
124
- }>>;
125
- readonly value: Schema.String;
126
- }>, Schema.Struct<{
127
- readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
128
- readonly collapseWhitespace: Schema.Boolean;
129
- readonly ignoreCase: Schema.Boolean;
130
- readonly kind: Schema.Literal<"text">;
131
- }>]>>;
132
- readonly kind: Schema.mutableKey<Schema.Literal<"short-answer">>;
133
- }>, Schema.Struct<{
134
- readonly kind: Schema.mutableKey<Schema.Literal<"single-choice">>;
135
- readonly options: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
136
- readonly isCorrect: Schema.mutableKey<Schema.Boolean>;
137
- readonly label: Schema.mutableKey<Schema.String>;
138
- }>>>>;
139
- }>]>>>;
140
- readonly stimulusKey: Schema.optionalKey<Schema.String>;
141
- }>;
142
- export type QuestionItem = typeof QuestionItemSchema.Type;
143
- /** Returns blueprint facts in stable field order for signed canonicalizers. */
144
- export declare function canonicalQuestionBlueprint(blueprint: QuestionBlueprint): {
145
- cognitiveLevel: string;
146
- contentDomain: string;
147
- topic: string;
148
- };
149
- declare const QuestionResponseLocaleMissingError_base: Schema.Class<QuestionResponseLocaleMissingError, Schema.TaggedStruct<"QuestionResponseLocaleMissingError", {
150
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
151
- }>, import("effect/Cause").YieldableError & {
152
- readonly brand: unique symbol;
153
- }>;
154
- /** One item does not contain the exact artifact locale it must assess. */
155
- export declare class QuestionResponseLocaleMissingError extends QuestionResponseLocaleMissingError_base {
156
- }
157
- /** Resolves and freezes one exact-locale response from an authored item. */
158
- export declare const questionResponseFor: (item: {
159
- readonly blueprint?: {
160
- readonly cognitiveLevel: string;
161
- readonly contentDomain: string;
162
- readonly topic: string;
163
- };
164
- readonly points?: number;
165
- readonly responses: {
166
- readonly de?: {
167
- categories: string[];
168
- kind: "category";
169
- statements: {
170
- correctCategoryOrder: number;
171
- label: string;
172
- }[];
173
- } | {
174
- kind: "multiple-choice";
175
- options: {
176
- isCorrect: boolean;
177
- label: string;
178
- }[];
179
- } | {
180
- criteria: {
181
- finalAnswer?: {
182
- readonly acceptsFractions: boolean;
183
- readonly kind: "number";
184
- readonly tolerance?: {
185
- readonly kind: "absolute" | "relative";
186
- readonly value: string;
187
- };
188
- readonly value: string;
189
- } | {
190
- readonly acceptedAnswers: readonly [string, ...string[]];
191
- readonly collapseWhitespace: boolean;
192
- readonly ignoreCase: boolean;
193
- readonly kind: "text";
194
- };
195
- label: {
196
- readonly de: string;
197
- readonly en: string;
198
- readonly id: string;
199
- };
200
- levels: {
201
- label: {
202
- readonly de: string;
203
- readonly en: string;
204
- readonly id: string;
205
- };
206
- points: number;
207
- }[];
208
- }[];
209
- kind: "rubric";
210
- } | {
211
- key: {
212
- readonly acceptsFractions: boolean;
213
- readonly kind: "number";
214
- readonly tolerance?: {
215
- readonly kind: "absolute" | "relative";
216
- readonly value: string;
217
- };
218
- readonly value: string;
219
- } | {
220
- readonly acceptedAnswers: readonly [string, ...string[]];
221
- readonly collapseWhitespace: boolean;
222
- readonly ignoreCase: boolean;
223
- readonly kind: "text";
224
- };
225
- kind: "short-answer";
226
- } | {
227
- kind: "single-choice";
228
- options: {
229
- isCorrect: boolean;
230
- label: string;
231
- }[];
232
- } | undefined;
233
- readonly en?: {
234
- categories: string[];
235
- kind: "category";
236
- statements: {
237
- correctCategoryOrder: number;
238
- label: string;
239
- }[];
240
- } | {
241
- kind: "multiple-choice";
242
- options: {
243
- isCorrect: boolean;
244
- label: string;
245
- }[];
246
- } | {
247
- criteria: {
248
- finalAnswer?: {
249
- readonly acceptsFractions: boolean;
250
- readonly kind: "number";
251
- readonly tolerance?: {
252
- readonly kind: "absolute" | "relative";
253
- readonly value: string;
254
- };
255
- readonly value: string;
256
- } | {
257
- readonly acceptedAnswers: readonly [string, ...string[]];
258
- readonly collapseWhitespace: boolean;
259
- readonly ignoreCase: boolean;
260
- readonly kind: "text";
261
- };
262
- label: {
263
- readonly de: string;
264
- readonly en: string;
265
- readonly id: string;
266
- };
267
- levels: {
268
- label: {
269
- readonly de: string;
270
- readonly en: string;
271
- readonly id: string;
272
- };
273
- points: number;
274
- }[];
275
- }[];
276
- kind: "rubric";
277
- } | {
278
- key: {
279
- readonly acceptsFractions: boolean;
280
- readonly kind: "number";
281
- readonly tolerance?: {
282
- readonly kind: "absolute" | "relative";
283
- readonly value: string;
284
- };
285
- readonly value: string;
286
- } | {
287
- readonly acceptedAnswers: readonly [string, ...string[]];
288
- readonly collapseWhitespace: boolean;
289
- readonly ignoreCase: boolean;
290
- readonly kind: "text";
291
- };
292
- kind: "short-answer";
293
- } | {
294
- kind: "single-choice";
295
- options: {
296
- isCorrect: boolean;
297
- label: string;
298
- }[];
299
- } | undefined;
300
- readonly id?: {
301
- categories: string[];
302
- kind: "category";
303
- statements: {
304
- correctCategoryOrder: number;
305
- label: string;
306
- }[];
307
- } | {
308
- kind: "multiple-choice";
309
- options: {
310
- isCorrect: boolean;
311
- label: string;
312
- }[];
313
- } | {
314
- criteria: {
315
- finalAnswer?: {
316
- readonly acceptsFractions: boolean;
317
- readonly kind: "number";
318
- readonly tolerance?: {
319
- readonly kind: "absolute" | "relative";
320
- readonly value: string;
321
- };
322
- readonly value: string;
323
- } | {
324
- readonly acceptedAnswers: readonly [string, ...string[]];
325
- readonly collapseWhitespace: boolean;
326
- readonly ignoreCase: boolean;
327
- readonly kind: "text";
328
- };
329
- label: {
330
- readonly de: string;
331
- readonly en: string;
332
- readonly id: string;
333
- };
334
- levels: {
335
- label: {
336
- readonly de: string;
337
- readonly en: string;
338
- readonly id: string;
339
- };
340
- points: number;
341
- }[];
342
- }[];
343
- kind: "rubric";
344
- } | {
345
- key: {
346
- readonly acceptsFractions: boolean;
347
- readonly kind: "number";
348
- readonly tolerance?: {
349
- readonly kind: "absolute" | "relative";
350
- readonly value: string;
351
- };
352
- readonly value: string;
353
- } | {
354
- readonly acceptedAnswers: readonly [string, ...string[]];
355
- readonly collapseWhitespace: boolean;
356
- readonly ignoreCase: boolean;
357
- readonly kind: "text";
358
- };
359
- kind: "short-answer";
360
- } | {
361
- kind: "single-choice";
362
- options: {
363
- isCorrect: boolean;
364
- label: string;
365
- }[];
366
- } | undefined;
367
- };
368
- readonly stimulusKey?: string;
369
- }, artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">) => Effect.Effect<{
370
- readonly categories: readonly {
371
- readonly categoryKey: string;
372
- readonly label: string;
373
- readonly order: number;
374
- }[];
375
- readonly kind: "category";
376
- readonly statements: readonly {
377
- readonly correctCategoryKey: string;
378
- readonly label: string;
379
- readonly order: number;
380
- readonly statementKey: string;
381
- }[];
382
- } | {
383
- readonly kind: "multiple-choice";
384
- readonly options: readonly {
385
- readonly isCorrect: boolean;
386
- readonly label: string;
387
- readonly optionKey: string;
388
- readonly order: number;
389
- }[];
390
- } | {
391
- readonly kind: "single-choice";
392
- readonly options: readonly {
393
- readonly isCorrect: boolean;
394
- readonly label: string;
395
- readonly optionKey: string;
396
- readonly order: number;
397
- }[];
398
- } | {
399
- readonly criteria: readonly {
400
- readonly criterionKey: string;
401
- readonly finalAnswer?: {
402
- readonly acceptsFractions: boolean;
403
- readonly kind: "number";
404
- readonly tolerance?: {
405
- readonly kind: "absolute" | "relative";
406
- readonly value: string;
407
- };
408
- readonly value: string;
409
- } | {
410
- readonly acceptedAnswers: readonly [string, ...string[]];
411
- readonly collapseWhitespace: boolean;
412
- readonly ignoreCase: boolean;
413
- readonly kind: "text";
414
- };
415
- readonly order: number;
416
- readonly label: {
417
- readonly de: string;
418
- readonly en: string;
419
- readonly id: string;
420
- };
421
- readonly levels: readonly {
422
- readonly levelKey: string;
423
- readonly order: number;
424
- readonly points: number;
425
- readonly label: {
426
- readonly de: string;
427
- readonly en: string;
428
- readonly id: string;
429
- };
430
- }[];
431
- }[];
432
- readonly kind: "rubric";
433
- } | {
434
- readonly key: {
435
- readonly acceptsFractions: boolean;
436
- readonly kind: "number";
437
- readonly tolerance?: {
438
- readonly kind: "absolute" | "relative";
439
- readonly value: string;
440
- };
441
- readonly value: string;
442
- } | {
443
- readonly acceptedAnswers: readonly [string, ...string[]];
444
- readonly collapseWhitespace: boolean;
445
- readonly ignoreCase: boolean;
446
- readonly kind: "text";
447
- };
448
- readonly kind: "short-answer";
449
- }, QuestionResponseLocaleMissingError, never>;
450
- export {};
@@ -1,174 +0,0 @@
1
- import { Array as Arr, Effect, Record as Rec, Schema, Struct } from "effect";
2
- import { AppLocaleCodeSchema, ArtifactLocaleSchema, artifactLocaleCode, } from "#contracts/locale";
3
- import { QuestionAnswerKeySchema } from "#contracts/question/answer";
4
- import { QuestionResponseLabelSchema } from "#contracts/question/label";
5
- import { AuthoredQuestionPointsSchema } from "#contracts/question/points";
6
- import { canonicalQuestionResponseStructure, QuestionResponseSchema, } from "#contracts/question/response";
7
- import { freezeQuestionRubric, QuestionRubricResponseSourceSchema, } from "#contracts/question/rubric";
8
- import { encodeJsonText } from "#contracts/text/json";
9
- import { TryoutKeySchema } from "#contracts/tryout/key";
10
- const PositiveOrderSchema = Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0)));
11
- /** One source-authored option before stable runtime identities are derived. */
12
- const QuestionOptionSourceSchema = Schema.Struct({
13
- isCorrect: Schema.Boolean,
14
- label: QuestionResponseLabelSchema,
15
- }).mapFields(Struct.map(Schema.mutableKey));
16
- /** Requires enough options to present one meaningful choice interaction. */
17
- function hasAtLeastTwoOptions(options) {
18
- return options.length >= 2;
19
- }
20
- /** Requires exactly one authored option to carry correctness. */
21
- function hasOneCorrectOption(options) {
22
- return Arr.filter(options, ({ isCorrect }) => isCorrect).length === 1;
23
- }
24
- /** Requires several correct options while retaining at least one distractor. */
25
- function hasSeveralCorrectOptions(options) {
26
- const correct = Arr.filter(options, ({ isCorrect }) => isCorrect).length;
27
- return correct >= 2 && correct < options.length;
28
- }
29
- const QuestionOptionSourceListSchema = Schema.Array(QuestionOptionSourceSchema).pipe(Schema.mutable, Schema.check(Schema.makeFilter(hasAtLeastTwoOptions, {
30
- message: "Expected at least two response options.",
31
- })));
32
- const SingleChoiceResponseSourceSchema = Schema.Struct({
33
- kind: Schema.Literal("single-choice"),
34
- options: QuestionOptionSourceListSchema.pipe(Schema.check(Schema.makeFilter(hasOneCorrectOption, {
35
- message: "Single-choice responses require one correct option.",
36
- }))),
37
- }).mapFields(Struct.map(Schema.mutableKey));
38
- const MultipleChoiceResponseSourceSchema = Schema.Struct({
39
- kind: Schema.Literal("multiple-choice"),
40
- options: QuestionOptionSourceListSchema.pipe(Schema.check(Schema.makeFilter(hasSeveralCorrectOptions, {
41
- message: "Multiple-choice responses require several correct options and one distractor.",
42
- }))),
43
- }).mapFields(Struct.map(Schema.mutableKey));
44
- const CategoryStatementSourceSchema = Schema.Struct({
45
- correctCategoryOrder: PositiveOrderSchema,
46
- label: QuestionResponseLabelSchema,
47
- }).mapFields(Struct.map(Schema.mutableKey));
48
- /** Checks category cardinality and every statement's category reference. */
49
- function hasCoherentCategoryResponse(input) {
50
- return (input.categories.length >= 2 &&
51
- input.statements.length > 0 &&
52
- Arr.every(input.statements, ({ correctCategoryOrder }) => correctCategoryOrder <= input.categories.length));
53
- }
54
- const CategoryResponseSourceSchema = Schema.Struct({
55
- categories: Schema.Array(QuestionResponseLabelSchema).pipe(Schema.mutable),
56
- kind: Schema.Literal("category"),
57
- statements: Schema.Array(CategoryStatementSourceSchema).pipe(Schema.mutable),
58
- })
59
- .mapFields(Struct.map(Schema.mutableKey))
60
- .pipe(Schema.check(Schema.makeFilter(hasCoherentCategoryResponse, {
61
- message: "Category responses require at least two categories and classified statements.",
62
- })));
63
- /** One typed answer authored exactly as it is frozen and graded. */
64
- const ShortAnswerResponseSourceSchema = Schema.Struct({
65
- key: QuestionAnswerKeySchema,
66
- kind: Schema.Literal("short-answer"),
67
- }).mapFields(Struct.map(Schema.mutableKey));
68
- /** One locale-specific response authored without duplicated runtime keys. */
69
- export const QuestionResponseSourceSchema = Schema.Union([
70
- CategoryResponseSourceSchema,
71
- MultipleChoiceResponseSourceSchema,
72
- QuestionRubricResponseSourceSchema,
73
- ShortAnswerResponseSourceSchema,
74
- SingleChoiceResponseSourceSchema,
75
- ]);
76
- const QuestionResponseSourceMapSchema = Schema.Record(AppLocaleCodeSchema, Schema.optional(QuestionResponseSourceSchema));
77
- /** Editorial blueprint coordinates used to prove assessment coverage. */
78
- export const QuestionBlueprintSchema = Schema.Struct({
79
- cognitiveLevel: TryoutKeySchema,
80
- contentDomain: TryoutKeySchema,
81
- topic: TryoutKeySchema,
82
- });
83
- /** Derives stable option keys and orders from source-authored array order. */
84
- function freezeOptions(options) {
85
- return Arr.map(options, ({ isCorrect, label }, index) => ({
86
- isCorrect,
87
- label,
88
- optionKey: `option-${index + 1}`,
89
- order: index + 1,
90
- }));
91
- }
92
- /** Freezes one authored response, deriving every stable runtime key once. */
93
- function freezeQuestionResponse(response) {
94
- if (response.kind === "rubric") {
95
- return freezeQuestionRubric(response);
96
- }
97
- if (response.kind === "short-answer") {
98
- return QuestionResponseSchema.make({
99
- key: response.key,
100
- kind: response.kind,
101
- });
102
- }
103
- if (response.kind === "category") {
104
- return QuestionResponseSchema.make({
105
- categories: Arr.map(response.categories, (label, index) => ({
106
- categoryKey: `category-${index + 1}`,
107
- label,
108
- order: index + 1,
109
- })),
110
- kind: response.kind,
111
- statements: Arr.map(response.statements, ({ correctCategoryOrder, label }, index) => ({
112
- correctCategoryKey: `category-${correctCategoryOrder}`,
113
- label,
114
- order: index + 1,
115
- statementKey: `statement-${index + 1}`,
116
- })),
117
- });
118
- }
119
- return QuestionResponseSchema.make({
120
- kind: response.kind,
121
- options: freezeOptions(response.options),
122
- });
123
- }
124
- /** Serializes response shape and answer key for locale comparison. */
125
- function responseStructure(response) {
126
- return encodeJsonText(canonicalQuestionResponseStructure(freezeQuestionResponse(response)));
127
- }
128
- /** Requires locale siblings to preserve one response format and answer key. */
129
- function hasCoherentLocalizedResponses(input) {
130
- const responses = Arr.filter(Rec.values(input.responses), (response) => response !== undefined);
131
- const [first] = responses;
132
- return (first !== undefined &&
133
- Arr.every(responses, (response) => responseStructure(response) === responseStructure(first)));
134
- }
135
- /** Requires a rubric item to take its worth from the rubric total alone. */
136
- function hasCoherentPoints(input) {
137
- return (input.points === undefined ||
138
- Arr.every(Rec.values(input.responses), (response) => response?.kind !== "rubric"));
139
- }
140
- /**
141
- * Complete source-owned item with optional shared-stimulus identity and points.
142
- * Points appear only above the default single point and never on a rubric.
143
- */
144
- export const QuestionItemSchema = Schema.Struct({
145
- blueprint: Schema.optionalKey(QuestionBlueprintSchema),
146
- points: Schema.optionalKey(AuthoredQuestionPointsSchema),
147
- responses: QuestionResponseSourceMapSchema,
148
- stimulusKey: Schema.optionalKey(TryoutKeySchema),
149
- }).pipe(Schema.check(Schema.makeFilter(hasCoherentLocalizedResponses, {
150
- message: "Localized responses must preserve one format, structure, and answer key.",
151
- })), Schema.check(Schema.makeFilter(hasCoherentPoints, {
152
- message: "Rubric items derive their points from the rubric total.",
153
- })));
154
- /** Returns blueprint facts in stable field order for signed canonicalizers. */
155
- export function canonicalQuestionBlueprint(blueprint) {
156
- return {
157
- cognitiveLevel: blueprint.cognitiveLevel,
158
- contentDomain: blueprint.contentDomain,
159
- topic: blueprint.topic,
160
- };
161
- }
162
- /** One item does not contain the exact artifact locale it must assess. */
163
- export class QuestionResponseLocaleMissingError extends Schema.TaggedError()("QuestionResponseLocaleMissingError", {
164
- artifactLocale: ArtifactLocaleSchema,
165
- }) {
166
- }
167
- /** Resolves and freezes one exact-locale response from an authored item. */
168
- export const questionResponseFor = Effect.fn("AksaraContracts.questionResponseFor")(function* (item, artifactLocale) {
169
- const response = item.responses[artifactLocaleCode(artifactLocale)];
170
- if (response === undefined) {
171
- return yield* new QuestionResponseLocaleMissingError({ artifactLocale });
172
- }
173
- return freezeQuestionResponse(response);
174
- });
@@ -1,3 +0,0 @@
1
- import { Schema } from "effect";
2
- /** One non-empty Markdown label rendered by the product-owned content surface. */
3
- export declare const QuestionResponseLabelSchema: Schema.String;
@@ -1,3 +0,0 @@
1
- import { Schema } from "effect";
2
- /** One non-empty Markdown label rendered by the product-owned content surface. */
3
- export const QuestionResponseLabelSchema = Schema.String.check(Schema.isNonEmpty());
@@ -1,18 +0,0 @@
1
- import { Schema } from "effect";
2
- import type { QuestionResponse } from "#contracts/question/response";
3
- /** Whole points one scored question is worth. */
4
- export declare const QuestionPointsSchema: Schema.Int;
5
- /**
6
- * Points written only when a question is worth more than the default single
7
- * point, so every placement keeps one canonical encoding of its worth.
8
- */
9
- export declare const AuthoredQuestionPointsSchema: Schema.Int;
10
- /**
11
- * Returns the points one placed question is worth. Every scoring strategy
12
- * reads worth through this function: a rubric is worth its derived total, and
13
- * any other response is worth its authored points or the default single point.
14
- */
15
- export declare function questionPoints(question: {
16
- readonly points?: number;
17
- readonly response: QuestionResponse;
18
- }): number;
@@ -1,22 +0,0 @@
1
- import { Schema } from "effect";
2
- import { questionRubricPoints } from "#contracts/question/rubric";
3
- /** Whole points one scored question is worth. */
4
- export const QuestionPointsSchema = Schema.Int.check(Schema.isGreaterThan(0));
5
- /**
6
- * Points written only when a question is worth more than the default single
7
- * point, so every placement keeps one canonical encoding of its worth.
8
- */
9
- export const AuthoredQuestionPointsSchema = QuestionPointsSchema.check(Schema.isGreaterThan(1, {
10
- message: "Omit points to use the default of one point.",
11
- }));
12
- /**
13
- * Returns the points one placed question is worth. Every scoring strategy
14
- * reads worth through this function: a rubric is worth its derived total, and
15
- * any other response is worth its authored points or the default single point.
16
- */
17
- export function questionPoints(question) {
18
- if (question.response.kind === "rubric") {
19
- return questionRubricPoints(question.response);
20
- }
21
- return question.points ?? 1;
22
- }