@nakafa/aksara-contracts 1.0.1 → 3.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 (214) hide show
  1. package/README.md +10 -27
  2. package/dist/artifact/integrity.d.ts +3 -3
  3. package/dist/artifact/integrity.js +2 -2
  4. package/dist/artifact/source.d.ts +2 -2
  5. package/dist/artifact/source.js +2 -8
  6. package/dist/artifact/spec.d.ts +0 -16
  7. package/dist/artifact/spec.js +0 -6
  8. package/dist/artifact/verify.d.ts +1 -1
  9. package/dist/{question → assessment}/answer.d.ts +14 -58
  10. package/dist/{question → assessment}/answer.js +13 -60
  11. package/dist/assessment/catalog.d.ts +235 -0
  12. package/dist/assessment/catalog.js +115 -0
  13. package/dist/assessment/chart.d.ts +62 -0
  14. package/dist/assessment/chart.js +64 -0
  15. package/dist/assessment/closure.d.ts +28 -0
  16. package/dist/assessment/closure.js +164 -0
  17. package/dist/assessment/explanation.d.ts +13 -8
  18. package/dist/assessment/explanation.js +14 -8
  19. package/dist/assessment/figure.d.ts +140 -1
  20. package/dist/assessment/figure.js +9 -2
  21. package/dist/assessment/hash.d.ts +352 -212
  22. package/dist/assessment/hash.js +14 -0
  23. package/dist/assessment/inline.d.ts +3 -1
  24. package/dist/assessment/inline.js +20 -5
  25. package/dist/assessment/item.d.ts +8 -4
  26. package/dist/assessment/item.js +6 -2
  27. package/dist/assessment/key.js +6 -6
  28. package/dist/assessment/paper.d.ts +74 -74
  29. package/dist/assessment/snapshot.d.ts +3778 -0
  30. package/dist/assessment/snapshot.js +192 -0
  31. package/dist/cache/content.d.ts +4 -4
  32. package/dist/canonical.d.ts +6 -0
  33. package/dist/canonical.js +8 -1
  34. package/dist/content.d.ts +1 -1
  35. package/dist/content.js +0 -1
  36. package/dist/delivery.d.ts +0 -3
  37. package/dist/delivery.js +0 -5
  38. package/dist/hash/digest.d.ts +7 -7
  39. package/dist/hash/digest.js +9 -30
  40. package/dist/hash/stream.d.ts +1 -1
  41. package/dist/hash/text.d.ts +3 -12
  42. package/dist/hash/text.js +3 -6
  43. package/dist/ids.js +8 -8
  44. package/dist/preview/artifact.d.ts +1 -120
  45. package/dist/preview/auth.d.ts +1 -1
  46. package/dist/preview/auth.js +29 -25
  47. package/dist/preview/document.d.ts +0 -586
  48. package/dist/preview/document.js +1 -47
  49. package/dist/preview/spec.d.ts +6 -1984
  50. package/dist/preview/spec.js +7 -47
  51. package/dist/preview/target.d.ts +0 -173
  52. package/dist/preview/target.js +1 -70
  53. package/dist/program/snapshot/digest.d.ts +1 -2
  54. package/dist/program/snapshot/digest.js +2 -4
  55. package/dist/program/snapshot/hash.d.ts +6 -21
  56. package/dist/program/snapshot/hash.js +3 -9
  57. package/dist/projection/digest.d.ts +7 -143
  58. package/dist/projection/digest.js +7 -13
  59. package/dist/projection/hash.d.ts +2 -138
  60. package/dist/projection/hash.js +2 -5
  61. package/dist/projection/material.js +1 -1
  62. package/dist/projection/spec.d.ts +6 -211
  63. package/dist/projection/spec.js +4 -18
  64. package/dist/projection/verify.d.ts +1 -128
  65. package/dist/projection/verify.js +1 -4
  66. package/dist/quran/provenance.d.ts +2 -8
  67. package/dist/quran/provenance.js +1 -4
  68. package/dist/quran/snapshot/digest.d.ts +1 -2
  69. package/dist/quran/snapshot/digest.js +2 -2
  70. package/dist/quran/snapshot/hash.d.ts +3 -10
  71. package/dist/quran/snapshot/hash.js +2 -5
  72. package/dist/quran/snapshot/row/hash.d.ts +3 -12
  73. package/dist/quran/snapshot/row/hash.js +2 -5
  74. package/dist/release/canonical.d.ts +2 -2
  75. package/dist/release/current/evidence.d.ts +24 -24
  76. package/dist/release/current/state.d.ts +28 -56
  77. package/dist/release/current/state.js +1 -6
  78. package/dist/release/digest.d.ts +9 -18
  79. package/dist/release/digest.js +7 -13
  80. package/dist/release/hash.d.ts +7 -16
  81. package/dist/release/hash.js +2 -6
  82. package/dist/release/head.d.ts +10 -57
  83. package/dist/release/head.js +3 -14
  84. package/dist/release/identity.d.ts +3 -3
  85. package/dist/release/items.d.ts +3 -3
  86. package/dist/release/items.js +1 -1
  87. package/dist/release/lifecycle.d.ts +18 -18
  88. package/dist/release/policy.d.ts +3 -4
  89. package/dist/release/policy.js +2 -11
  90. package/dist/release/result/digest.d.ts +11 -31
  91. package/dist/release/result/digest.js +5 -11
  92. package/dist/release/rollback/digest.d.ts +11 -35
  93. package/dist/release/rollback/digest.js +7 -13
  94. package/dist/release/rollback/spec.d.ts +30 -792
  95. package/dist/release/rollback/spec.js +1 -4
  96. package/dist/release/route/digest.d.ts +7 -16
  97. package/dist/release/route/digest.js +7 -13
  98. package/dist/release/route/verify.d.ts +1 -1
  99. package/dist/release/route/verify.js +1 -1
  100. package/dist/release/snapshot/data.d.ts +599 -249
  101. package/dist/release/snapshot/data.js +11 -28
  102. package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
  103. package/dist/release/snapshot/evidence/assessment.js +44 -0
  104. package/dist/release/snapshot/evidence/program.d.ts +1 -1
  105. package/dist/release/snapshot/evidence/quran.d.ts +1 -1
  106. package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
  107. package/dist/release/snapshot/evidence.d.ts +19 -19
  108. package/dist/release/snapshot/evidence.js +2 -2
  109. package/dist/release/snapshot/scope.d.ts +5 -5
  110. package/dist/release/snapshot/scope.js +1 -1
  111. package/dist/release/snapshot/spec.d.ts +15 -15
  112. package/dist/release/snapshot/spec.js +8 -8
  113. package/dist/release/snapshot/verify.d.ts +1278 -268
  114. package/dist/release/snapshot/verify.js +8 -5
  115. package/dist/release/spec.d.ts +33 -33
  116. package/dist/release/verify.d.ts +7 -7
  117. package/dist/renderer/compatibility.d.ts +1 -1
  118. package/dist/renderer/component.js +1 -1
  119. package/dist/renderer/contract.d.ts +0 -8
  120. package/dist/renderer/contract.js +0 -3
  121. package/dist/renderer/manifest.d.ts +3 -3
  122. package/dist/renderer/manifest.js +2 -2
  123. package/dist/runtime/spec.d.ts +38 -38
  124. package/dist/runtime/spec.js +4 -5
  125. package/dist/runtime/verify.d.ts +42 -42
  126. package/dist/signature/key.d.ts +0 -2
  127. package/dist/signature/key.js +37 -88
  128. package/dist/signature/spec.d.ts +5 -5
  129. package/dist/signature/spec.js +0 -1
  130. package/dist/signature/verify.js +31 -46
  131. package/dist/transport/batch.d.ts +6 -244
  132. package/dist/transport/failure.d.ts +6 -20
  133. package/dist/transport/failure.js +0 -10
  134. package/dist/transport/group.d.ts +1969 -1369
  135. package/dist/transport/group.js +0 -2
  136. package/dist/transport/request.d.ts +10691 -5086
  137. package/dist/transport/request.js +0 -3
  138. package/dist/transport/response.d.ts +219 -1442
  139. package/dist/transport/response.js +0 -4
  140. package/dist/transport/snapshot.d.ts +1187 -487
  141. package/dist/tree.js +1 -1
  142. package/package.json +188 -296
  143. package/dist/projection/question.d.ts +0 -1067
  144. package/dist/projection/question.js +0 -121
  145. package/dist/question/identity.d.ts +0 -175
  146. package/dist/question/identity.js +0 -207
  147. package/dist/question/item.d.ts +0 -450
  148. package/dist/question/item.js +0 -174
  149. package/dist/question/label.d.ts +0 -3
  150. package/dist/question/label.js +0 -3
  151. package/dist/question/points.d.ts +0 -18
  152. package/dist/question/points.js +0 -22
  153. package/dist/question/response.d.ts +0 -289
  154. package/dist/question/response.js +0 -167
  155. package/dist/question/rubric.d.ts +0 -234
  156. package/dist/question/rubric.js +0 -186
  157. package/dist/release/current/runtime.d.ts +0 -4
  158. package/dist/release/current/runtime.js +0 -15
  159. package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
  160. package/dist/release/snapshot/evidence/tryout.js +0 -91
  161. package/dist/runtime/protected/limits.d.ts +0 -10
  162. package/dist/runtime/protected/limits.js +0 -16
  163. package/dist/runtime/protected/spec.d.ts +0 -310
  164. package/dist/runtime/protected/spec.js +0 -80
  165. package/dist/runtime/protected/verify.d.ts +0 -83
  166. package/dist/runtime/protected/verify.js +0 -70
  167. package/dist/transport/runtime.d.ts +0 -77
  168. package/dist/transport/runtime.js +0 -33
  169. package/dist/tryout/canonical.d.ts +0 -12
  170. package/dist/tryout/canonical.js +0 -7
  171. package/dist/tryout/catalog.d.ts +0 -396
  172. package/dist/tryout/catalog.js +0 -155
  173. package/dist/tryout/closure/accounting.d.ts +0 -20
  174. package/dist/tryout/closure/accounting.js +0 -70
  175. package/dist/tryout/closure/locale.d.ts +0 -14
  176. package/dist/tryout/closure/locale.js +0 -113
  177. package/dist/tryout/closure/placement.d.ts +0 -5
  178. package/dist/tryout/closure/placement.js +0 -32
  179. package/dist/tryout/digest.d.ts +0 -34
  180. package/dist/tryout/digest.js +0 -57
  181. package/dist/tryout/hash/catalog.d.ts +0 -364
  182. package/dist/tryout/hash/catalog.js +0 -209
  183. package/dist/tryout/hash/content.d.ts +0 -215
  184. package/dist/tryout/hash/content.js +0 -75
  185. package/dist/tryout/hash/placement.d.ts +0 -242
  186. package/dist/tryout/hash/placement.js +0 -56
  187. package/dist/tryout/identity.d.ts +0 -12
  188. package/dist/tryout/identity.js +0 -47
  189. package/dist/tryout/key.d.ts +0 -4
  190. package/dist/tryout/key.js +0 -8
  191. package/dist/tryout/language.d.ts +0 -24
  192. package/dist/tryout/language.js +0 -30
  193. package/dist/tryout/placement.d.ts +0 -331
  194. package/dist/tryout/placement.js +0 -96
  195. package/dist/tryout/runtime/canonical.d.ts +0 -8
  196. package/dist/tryout/runtime/canonical.js +0 -34
  197. package/dist/tryout/runtime/hash.d.ts +0 -34
  198. package/dist/tryout/runtime/hash.js +0 -13
  199. package/dist/tryout/runtime/source.d.ts +0 -44
  200. package/dist/tryout/runtime/source.js +0 -47
  201. package/dist/tryout/runtime/spec.d.ts +0 -58
  202. package/dist/tryout/runtime/spec.js +0 -21
  203. package/dist/tryout/runtime/verify.d.ts +0 -69
  204. package/dist/tryout/runtime/verify.js +0 -67
  205. package/dist/tryout/scoring.d.ts +0 -148
  206. package/dist/tryout/scoring.js +0 -98
  207. package/dist/tryout/snapshot/canonical.d.ts +0 -7
  208. package/dist/tryout/snapshot/canonical.js +0 -18
  209. package/dist/tryout/snapshot/hash.d.ts +0 -49
  210. package/dist/tryout/snapshot/hash.js +0 -22
  211. package/dist/tryout/snapshot/spec.d.ts +0 -46
  212. package/dist/tryout/snapshot/spec.js +0 -30
  213. package/dist/tryout/spec.d.ts +0 -41
  214. 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
- }