@nakafa/aksara-contracts 6.4.0 → 7.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 (117) hide show
  1. package/dist/assessment/catalog.d.ts +30 -6
  2. package/dist/assessment/catalog.js +33 -10
  3. package/dist/assessment/choice.d.ts +10 -0
  4. package/dist/assessment/closure.d.ts +2 -1
  5. package/dist/assessment/closure.js +43 -62
  6. package/dist/assessment/document.d.ts +18 -0
  7. package/dist/assessment/document.js +10 -0
  8. package/dist/assessment/figure.d.ts +47605 -1555
  9. package/dist/assessment/figure.js +14 -217
  10. package/dist/assessment/hash.d.ts +274 -4
  11. package/dist/assessment/inline.d.ts +25 -0
  12. package/dist/assessment/inline.js +22 -3
  13. package/dist/assessment/interaction.d.ts +10 -0
  14. package/dist/assessment/item.d.ts +864 -0
  15. package/dist/assessment/item.js +10 -2
  16. package/dist/assessment/locales.d.ts +10 -0
  17. package/dist/assessment/locales.js +58 -0
  18. package/dist/assessment/paper.d.ts +1349 -12
  19. package/dist/assessment/paper.js +93 -9
  20. package/dist/assessment/part.d.ts +5 -0
  21. package/dist/assessment/profile.d.ts +4 -4
  22. package/dist/assessment/rows.d.ts +1409 -0
  23. package/dist/assessment/rows.js +44 -0
  24. package/dist/assessment/scalar.d.ts +1 -1
  25. package/dist/assessment/scoring.d.ts +1 -1
  26. package/dist/assessment/snapshot.d.ts +376 -20
  27. package/dist/assessment/structure.d.ts +6 -0
  28. package/dist/assessment/structure.js +22 -2
  29. package/dist/locale.d.ts +9 -9
  30. package/dist/locale.js +4 -3
  31. package/dist/program/snapshot/hash.d.ts +2 -2
  32. package/dist/program/snapshot/spec.d.ts +2 -2
  33. package/dist/projection/material.d.ts +10 -0
  34. package/dist/projection/material.js +1 -1
  35. package/dist/quran/attribution.d.ts +2 -2
  36. package/dist/quran/identity.d.ts +31 -10
  37. package/dist/quran/identity.js +15 -3
  38. package/dist/quran/provenance.d.ts +16 -16
  39. package/dist/quran/provenance.js +4 -1
  40. package/dist/quran/snapshot/hash.d.ts +2 -2
  41. package/dist/quran/snapshot/row/hash.d.ts +48 -15
  42. package/dist/quran/snapshot/row.d.ts +18 -8
  43. package/dist/quran/snapshot/spec.d.ts +2 -2
  44. package/dist/quran/source.d.ts +17 -7
  45. package/dist/quran/source.js +13 -1
  46. package/dist/quran/spec.d.ts +4 -4
  47. package/dist/quran/spec.js +2 -1
  48. package/dist/release/current/evidence.d.ts +9 -9
  49. package/dist/release/current/state.d.ts +11 -11
  50. package/dist/release/hash.d.ts +2 -2
  51. package/dist/release/identity.d.ts +1 -1
  52. package/dist/release/lifecycle.d.ts +7 -7
  53. package/dist/release/policy.d.ts +1 -1
  54. package/dist/release/snapshot/data.d.ts +37 -11
  55. package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
  56. package/dist/release/snapshot/evidence/program.d.ts +1 -1
  57. package/dist/release/snapshot/evidence/quran.d.ts +1 -1
  58. package/dist/release/snapshot/evidence.d.ts +3 -3
  59. package/dist/release/snapshot/verify.d.ts +180 -12
  60. package/dist/release/spec.d.ts +13 -13
  61. package/dist/release/verify.d.ts +2 -2
  62. package/dist/runtime/spec.d.ts +6 -6
  63. package/dist/runtime/verify.d.ts +4 -4
  64. package/dist/transport/group.d.ts +111 -33
  65. package/dist/transport/request.d.ts +1174 -114
  66. package/dist/transport/response.d.ts +64 -64
  67. package/dist/transport/snapshot.d.ts +74 -22
  68. package/dist/visual/base/layout.d.ts +27 -0
  69. package/dist/visual/base/layout.js +35 -0
  70. package/dist/visual/base/math.d.ts +523 -0
  71. package/dist/visual/base/math.js +72 -0
  72. package/dist/visual/base/media.d.ts +13 -0
  73. package/dist/visual/base/media.js +25 -0
  74. package/dist/visual/biology.d.ts +203 -0
  75. package/dist/visual/biology.js +108 -0
  76. package/dist/visual/card.d.ts +32 -0
  77. package/dist/visual/card.js +30 -0
  78. package/dist/visual/catalog.d.ts +28633 -0
  79. package/dist/visual/catalog.js +73 -0
  80. package/dist/visual/chemistry/atom.d.ts +79 -0
  81. package/dist/visual/chemistry/atom.js +109 -0
  82. package/dist/visual/chemistry/electron.d.ts +41 -0
  83. package/dist/visual/chemistry/electron.js +69 -0
  84. package/dist/visual/chemistry/laws.d.ts +86 -0
  85. package/dist/visual/chemistry/laws.js +117 -0
  86. package/dist/visual/chemistry/particles.d.ts +114 -0
  87. package/dist/visual/chemistry/particles.js +149 -0
  88. package/dist/visual/chemistry/periodic.d.ts +52 -0
  89. package/dist/visual/chemistry/periodic.js +85 -0
  90. package/dist/visual/chemistry/reaction.d.ts +60 -0
  91. package/dist/visual/chemistry/reaction.js +76 -0
  92. package/dist/visual/entry.d.ts +42 -0
  93. package/dist/visual/entry.js +48 -0
  94. package/dist/visual/mathematics/chart.d.ts +30 -0
  95. package/dist/{assessment → visual/mathematics}/chart.js +26 -18
  96. package/dist/visual/mathematics/charts.d.ts +118 -0
  97. package/dist/visual/mathematics/charts.js +100 -0
  98. package/dist/visual/mathematics/function.d.ts +82 -0
  99. package/dist/visual/mathematics/function.js +102 -0
  100. package/dist/visual/mathematics/geometry.d.ts +222 -0
  101. package/dist/visual/mathematics/geometry.js +81 -0
  102. package/dist/visual/mathematics/line.d.ts +179 -0
  103. package/dist/visual/mathematics/line.js +156 -0
  104. package/dist/visual/mathematics/number.d.ts +21 -0
  105. package/dist/visual/mathematics/number.js +53 -0
  106. package/dist/visual/physics/measurement.d.ts +66 -0
  107. package/dist/visual/physics/measurement.js +85 -0
  108. package/dist/visual/physics/motion.d.ts +85 -0
  109. package/dist/visual/physics/motion.js +110 -0
  110. package/dist/visual/physics/parabolic.d.ts +42 -0
  111. package/dist/visual/physics/parabolic.js +56 -0
  112. package/dist/visual/physics/velocity.d.ts +112 -0
  113. package/dist/visual/physics/velocity.js +144 -0
  114. package/dist/visual/politics.d.ts +92 -0
  115. package/dist/visual/politics.js +76 -0
  116. package/package.json +13 -5
  117. package/dist/assessment/chart.d.ts +0 -62
@@ -12,9 +12,18 @@ export declare const GroupAxisSchema: Schema.Literals<readonly ["grade", "instit
12
12
  * their own, and an `internal-entry` section is entered from its set.
13
13
  */
14
14
  export declare const SectionVisibilitySchema: Schema.Literals<readonly ["internal-entry", "visible"]>;
15
+ /**
16
+ * How hard a set is, measured by Aksara's difficulty panel against the real
17
+ * exam and published with the set, never picked by hand. The scale starts at
18
+ * the real exam: easy is the real exam's own level, and medium, hard and
19
+ * cooked climb above it, in this order.
20
+ */
21
+ export declare const SetLevelSchema: Schema.Literals<readonly ["easy", "medium", "hard", "cooked"]>;
22
+ export type SetLevel = typeof SetLevelSchema.Type;
15
23
  /** One localized country of the catalog. */
16
24
  export declare const CatalogCountrySchema: Schema.Struct<{
17
25
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
26
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
18
27
  readonly description: Schema.optionalKey<Schema.String>;
19
28
  readonly graph: Schema.Struct<{
20
29
  readonly alignmentId: Schema.String;
@@ -34,6 +43,7 @@ export declare const CatalogCountrySchema: Schema.Struct<{
34
43
  /** One localized exam of a country, and the axis that divides its tracks into groups. */
35
44
  export declare const CatalogExamSchema: Schema.Struct<{
36
45
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
46
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
37
47
  readonly description: Schema.optionalKey<Schema.String>;
38
48
  readonly graph: Schema.Struct<{
39
49
  readonly alignmentId: Schema.String;
@@ -54,6 +64,7 @@ export declare const CatalogExamSchema: Schema.Struct<{
54
64
  /** One localized group of an exam on its axis: a year, a grade, or an institution. */
55
65
  export declare const CatalogGroupSchema: Schema.Struct<{
56
66
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
67
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
57
68
  readonly description: Schema.optionalKey<Schema.String>;
58
69
  readonly graph: Schema.Struct<{
59
70
  readonly alignmentId: Schema.String;
@@ -79,6 +90,7 @@ export declare const CatalogGroupSchema: Schema.Struct<{
79
90
  */
80
91
  export declare const CatalogTrackSchema: Schema.Struct<{
81
92
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
93
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
82
94
  readonly description: Schema.optionalKey<Schema.String>;
83
95
  readonly graph: Schema.Struct<{
84
96
  readonly alignmentId: Schema.String;
@@ -98,12 +110,13 @@ export declare const CatalogTrackSchema: Schema.Struct<{
98
110
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
99
111
  }>;
100
112
  /**
101
- * One localized set of a track, and the paper a learner sits for it, by
102
- * identifier and hash. A set whose only section is entered from the set names
113
+ * One localized set of a track, its measured level, and the paper a learner
114
+ * sits for it, by identifier and hash. A set whose only section is entered from the set names
103
115
  * that section.
104
116
  */
105
117
  export declare const CatalogSetSchema: Schema.Struct<{
106
118
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
119
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
107
120
  readonly description: Schema.optionalKey<Schema.String>;
108
121
  readonly graph: Schema.Struct<{
109
122
  readonly alignmentId: Schema.String;
@@ -120,6 +133,7 @@ export declare const CatalogSetSchema: Schema.Struct<{
120
133
  readonly setKey: Schema.String;
121
134
  readonly internalEntrySectionKey: Schema.optionalKey<Schema.String>;
122
135
  readonly kind: Schema.Literal<"set">;
136
+ readonly level: Schema.Literals<readonly ["easy", "medium", "hard", "cooked"]>;
123
137
  readonly order: Schema.Int;
124
138
  readonly paper: Schema.Struct<{
125
139
  readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
@@ -134,6 +148,7 @@ export declare const CatalogSetSchema: Schema.Struct<{
134
148
  */
135
149
  export declare const CatalogSectionSchema: Schema.Struct<{
136
150
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
151
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
137
152
  readonly description: Schema.optionalKey<Schema.String>;
138
153
  readonly graph: Schema.Struct<{
139
154
  readonly alignmentId: Schema.String;
@@ -157,6 +172,7 @@ export declare const CatalogSectionSchema: Schema.Struct<{
157
172
  /** One row of the catalog, the navigation of the public try-outs. */
158
173
  export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
159
174
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
175
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
160
176
  readonly description: Schema.optionalKey<Schema.String>;
161
177
  readonly graph: Schema.Struct<{
162
178
  readonly alignmentId: Schema.String;
@@ -174,6 +190,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
174
190
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
175
191
  }>, Schema.Struct<{
176
192
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
193
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
177
194
  readonly description: Schema.optionalKey<Schema.String>;
178
195
  readonly graph: Schema.Struct<{
179
196
  readonly alignmentId: Schema.String;
@@ -192,6 +209,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
192
209
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
193
210
  }>, Schema.Struct<{
194
211
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
212
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
195
213
  readonly description: Schema.optionalKey<Schema.String>;
196
214
  readonly graph: Schema.Struct<{
197
215
  readonly alignmentId: Schema.String;
@@ -210,6 +228,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
210
228
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
211
229
  }>, Schema.Struct<{
212
230
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
231
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
213
232
  readonly description: Schema.optionalKey<Schema.String>;
214
233
  readonly graph: Schema.Struct<{
215
234
  readonly alignmentId: Schema.String;
@@ -229,6 +248,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
229
248
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
230
249
  }>, Schema.Struct<{
231
250
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
251
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
232
252
  readonly description: Schema.optionalKey<Schema.String>;
233
253
  readonly graph: Schema.Struct<{
234
254
  readonly alignmentId: Schema.String;
@@ -245,6 +265,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
245
265
  readonly setKey: Schema.String;
246
266
  readonly internalEntrySectionKey: Schema.optionalKey<Schema.String>;
247
267
  readonly kind: Schema.Literal<"set">;
268
+ readonly level: Schema.Literals<readonly ["easy", "medium", "hard", "cooked"]>;
248
269
  readonly order: Schema.Int;
249
270
  readonly paper: Schema.Struct<{
250
271
  readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
@@ -253,6 +274,7 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
253
274
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
254
275
  }>, Schema.Struct<{
255
276
  readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
277
+ readonly appLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">>;
256
278
  readonly description: Schema.optionalKey<Schema.String>;
257
279
  readonly graph: Schema.Struct<{
258
280
  readonly alignmentId: Schema.String;
@@ -275,9 +297,11 @@ export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
275
297
  }>]>;
276
298
  export type CatalogRow = typeof CatalogRowSchema.Type;
277
299
  /**
278
- * The identity of one catalog row, unique within a snapshot: its locale, its
279
- * kind, and the keys of its node and of every node above it. A group names
280
- * its own key; a track is unique within its exam, so a track and the rows
281
- * under it leave their group out.
300
+ * The identity of one catalog node, the same in every locale: its kind and the
301
+ * keys of its node and of every node above it. A group names its own key; a
302
+ * track is unique within its exam, so a track and the rows under it leave
303
+ * their group out.
282
304
  */
305
+ export declare function catalogNodeIdentity(row: CatalogRow): string;
306
+ /** The identity of one catalog row, unique within a snapshot: its locale and its node. */
283
307
  export declare function catalogRowIdentity(row: CatalogRow): string;
@@ -3,7 +3,7 @@ import { KebabKeySchema, PaperIdSchema } from "#contracts/assessment/identity";
3
3
  import { CountryCodeSchema } from "#contracts/country";
4
4
  import { LearningGraphIdentitySchema } from "#contracts/graph/spec";
5
5
  import { PublicPathSchema, Sha256HashSchema } from "#contracts/ids";
6
- import { AppLocaleSchema } from "#contracts/locale";
6
+ import { ActiveAppLocaleListSchema, AppLocaleSchema } from "#contracts/locale";
7
7
  const PositiveCountSchema = Schema.Int.check(Schema.isGreaterThan(0));
8
8
  /** Bounded authored revision shared by one catalog source hierarchy. */
9
9
  export const CatalogRevisionSchema = Schema.Trimmed.check(Schema.isNonEmpty(), Schema.isMaxLength(128));
@@ -25,9 +25,28 @@ export const SectionVisibilitySchema = Schema.Literals([
25
25
  "internal-entry",
26
26
  "visible",
27
27
  ]);
28
- /** What every row of the catalog says in one app locale. */
28
+ /**
29
+ * How hard a set is, measured by Aksara's difficulty panel against the real
30
+ * exam and published with the set, never picked by hand. The scale starts at
31
+ * the real exam: easy is the real exam's own level, and medium, hard and
32
+ * cooked climb above it, in this order.
33
+ */
34
+ export const SetLevelSchema = Schema.Literals([
35
+ "easy",
36
+ "medium",
37
+ "hard",
38
+ "cooked",
39
+ ]);
40
+ /**
41
+ * What every row of the catalog says in one app locale. `appLocales` lists
42
+ * every locale the node is published in, the same on each of its rows: a set
43
+ * names the locales it is written in, a section those of its set, and a
44
+ * country, exam, group, or track those of the sets beneath it, so no locale
45
+ * shows a node without a set and none falls back to another language.
46
+ */
29
47
  const LocalizedFields = {
30
48
  appLocale: AppLocaleSchema,
49
+ appLocales: ActiveAppLocaleListSchema,
31
50
  description: Schema.optionalKey(Schema.String),
32
51
  graph: LearningGraphIdentitySchema,
33
52
  sourceRevision: CatalogRevisionSchema,
@@ -79,8 +98,8 @@ export const CatalogTrackSchema = Schema.Struct({
79
98
  publicPath: PublicPathSchema,
80
99
  });
81
100
  /**
82
- * One localized set of a track, and the paper a learner sits for it, by
83
- * identifier and hash. A set whose only section is entered from the set names
101
+ * One localized set of a track, its measured level, and the paper a learner
102
+ * sits for it, by identifier and hash. A set whose only section is entered from the set names
84
103
  * that section.
85
104
  */
86
105
  export const CatalogSetSchema = Schema.Struct({
@@ -88,6 +107,7 @@ export const CatalogSetSchema = Schema.Struct({
88
107
  ...SetFields,
89
108
  internalEntrySectionKey: Schema.optionalKey(KebabKeySchema),
90
109
  kind: Schema.Literal("set"),
110
+ level: SetLevelSchema,
91
111
  order: PositiveCountSchema,
92
112
  paper: Schema.Struct({ hash: Sha256HashSchema, id: PaperIdSchema }),
93
113
  publicPath: PublicPathSchema,
@@ -116,14 +136,13 @@ export const CatalogRowSchema = Schema.Union([
116
136
  CatalogSectionSchema,
117
137
  ]);
118
138
  /**
119
- * The identity of one catalog row, unique within a snapshot: its locale, its
120
- * kind, and the keys of its node and of every node above it. A group names
121
- * its own key; a track is unique within its exam, so a track and the rows
122
- * under it leave their group out.
139
+ * The identity of one catalog node, the same in every locale: its kind and the
140
+ * keys of its node and of every node above it. A group names its own key; a
141
+ * track is unique within its exam, so a track and the rows under it leave
142
+ * their group out.
123
143
  */
124
- export function catalogRowIdentity(row) {
144
+ export function catalogNodeIdentity(row) {
125
145
  return Arr.join([
126
- row.appLocale,
127
146
  row.kind,
128
147
  row.countryKey,
129
148
  "examKey" in row ? row.examKey : "",
@@ -133,3 +152,7 @@ export function catalogRowIdentity(row) {
133
152
  "sectionKey" in row ? row.sectionKey : "",
134
153
  ], "\0");
135
154
  }
155
+ /** The identity of one catalog row, unique within a snapshot: its locale and its node. */
156
+ export function catalogRowIdentity(row) {
157
+ return `${row.appLocale}\0${catalogNodeIdentity(row)}`;
158
+ }
@@ -99,6 +99,11 @@ export declare const InlineChoiceInteractionSchema: Schema.Struct<{
99
99
  readonly label: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
100
100
  readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
101
101
  readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
102
+ }>, Schema.Struct<{
103
+ readonly attrs: Schema.Struct<{
104
+ readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
105
+ }>;
106
+ readonly type: Schema.Literal<"highlight">;
102
107
  }>, Schema.Struct<{
103
108
  readonly attrs: Schema.Struct<{
104
109
  readonly href: Schema.String;
@@ -130,6 +135,11 @@ export declare const GapMatchInteractionSchema: Schema.Struct<{
130
135
  readonly label: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
131
136
  readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
132
137
  readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
138
+ }>, Schema.Struct<{
139
+ readonly attrs: Schema.Struct<{
140
+ readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
141
+ }>;
142
+ readonly type: Schema.Literal<"highlight">;
133
143
  }>, Schema.Struct<{
134
144
  readonly attrs: Schema.Struct<{
135
145
  readonly href: Schema.String;
@@ -19,7 +19,8 @@ export declare class AssessmentClosureError extends AssessmentClosureError_base
19
19
  * Verifies that an assessment snapshot is closed: the catalog reaches papers it
20
20
  * holds, every paper fits the profile it follows and places versions it holds,
21
21
  * every version has its family, its reading, its key, and an explanation in
22
- * every active app locale, and no family, key, or explanation is left over.
22
+ * every locale of each set that places it, and no family, key, or explanation
23
+ * is left over.
23
24
  */
24
25
  export declare const verifyAssessmentClosure: <E, R>(input: {
25
26
  readonly activeAppLocales: ActiveAppLocaleList;
@@ -1,6 +1,7 @@
1
1
  import { Array as Arr, Effect, HashMap, HashSet, Option, Result, Schema, Stream, } from "effect";
2
- import { catalogRowIdentity } from "#contracts/assessment/catalog";
3
- import { verifyPaperStimuli } from "#contracts/assessment/paper";
2
+ import { catalogLocaleBreach } from "#contracts/assessment/locales";
3
+ import { verifyPaperPlaces, verifyPaperStimuli, } from "#contracts/assessment/paper";
4
+ import { explanationIdentity, indexRows, placedHashes, stimulusIdentity, } from "#contracts/assessment/rows";
4
5
  /**
5
6
  * Why a snapshot is not closed: a reference names a row it does not hold, a
6
7
  * row is never reached, or a paper does not fit the profile it follows.
@@ -23,43 +24,6 @@ export class AssessmentClosureError extends Schema.TaggedError()("AssessmentClos
23
24
  reason: AssessmentClosureReasonSchema,
24
25
  }) {
25
26
  }
26
- /** Gathers the rows of a snapshot by kind for the reference checks. */
27
- function indexRows(records) {
28
- const rows = Arr.map(records, ({ row }) => row);
29
- return {
30
- catalog: Arr.filterMap(rows, (row) => row.kind === "catalog" ? Result.succeed(row.row) : Result.failVoid),
31
- explanations: HashMap.fromIterable(Arr.filterMap(rows, (row) => row.kind === "explanation"
32
- ? Result.succeed([
33
- explanationIdentity(row.explanation.version, row.explanation.language),
34
- row.explanation.version,
35
- ])
36
- : Result.failVoid)),
37
- families: HashMap.fromIterable(Arr.filterMap(rows, (row) => row.kind === "family"
38
- ? Result.succeed([row.family.id, row.family])
39
- : Result.failVoid)),
40
- items: HashMap.fromIterable(Arr.filterMap(rows, (row) => row.kind === "item"
41
- ? Result.succeed([row.version.hash, row.version])
42
- : Result.failVoid)),
43
- keys: HashSet.fromIterable(Arr.filterMap(rows, (row) => row.kind === "key" ? Result.succeed(row.key.version) : Result.failVoid)),
44
- papers: HashMap.fromIterable(Arr.filterMap(rows, (row) => row.kind === "paper"
45
- ? Result.succeed([row.paper.id, row])
46
- : Result.failVoid)),
47
- profiles: HashMap.fromIterable(Arr.filterMap(rows, (row) => row.kind === "profile"
48
- ? Result.succeed([row.profile.id, row])
49
- : Result.failVoid)),
50
- stimuli: HashSet.fromIterable(Arr.filterMap(rows, (row) => row.kind === "stimulus"
51
- ? Result.succeed(stimulusIdentity(row.version))
52
- : Result.failVoid)),
53
- };
54
- }
55
- /** The identity of one explanation: the version it explains and its language. */
56
- function explanationIdentity(version, language) {
57
- return `${version}\0${language}`;
58
- }
59
- /** The identity of one stimulus version: its identifier and its hash. */
60
- function stimulusIdentity(version) {
61
- return `${version.id}\0${version.hash}`;
62
- }
63
27
  /** Fails with one closure reason unless the condition holds. */
64
28
  function require(holds, reason, identity) {
65
29
  return holds
@@ -78,29 +42,50 @@ const verifyPapers = Effect.fn("AksaraContracts.verifyAssessmentPapers")(functio
78
42
  const profile = HashMap.get(rows.profiles, paper.profile.id);
79
43
  yield* require(Option.exists(profile, ({ hash }) => hash === paper.profile.hash), "profile", paper.id);
80
44
  yield* require(Option.exists(profile, (entry) => fitsProfile(paper, entry.profile)), "section", paper.id);
81
- const placed = Arr.flatMap(paper.sections, ({ placements }) => placements);
82
- const versions = Arr.getSomes(Arr.map(placed, ({ family, hash }) => Option.filter(HashMap.get(rows.items, hash), (version) => version.family === family)));
83
- yield* require(versions.length === placed.length, "place", paper.id);
45
+ const placed = Arr.flatMap(paper.sections, ({ placements }) => Arr.flatMap(placements, (placement) => Arr.map(placement.versions, (version) => ({
46
+ ...version,
47
+ family: placement.family,
48
+ }))));
49
+ const versions = Arr.getSomes(Arr.map(placed, ({ family, hash, language }) => Option.filter(HashMap.get(rows.items, hash), (version) => version.family === family && version.deliveryLanguage === language)));
50
+ yield* verifyPaperPlaces(paper, versions, Arr.getSomes(Arr.map(versions, ({ hash }) => HashMap.get(rows.keys, hash)))).pipe(Effect.mapError(({ family, reason }) => new AssessmentClosureError({
51
+ identity: family,
52
+ reason: reason === "key" ? "key" : "place",
53
+ })));
84
54
  yield* verifyPaperStimuli(paper, versions).pipe(Effect.mapError(() => new AssessmentClosureError({
85
55
  identity: paper.id,
86
56
  reason: "stimulus",
87
57
  })));
88
58
  }
89
59
  });
90
- /** Verifies each item version: its family, its reading, its key, its explanations, and a paper that places it. */
91
- const verifyItems = Effect.fn("AksaraContracts.verifyAssessmentItems")(function* (rows, activeAppLocales) {
92
- const placed = HashSet.fromIterable(Arr.flatMap(Arr.fromIterable(HashMap.values(rows.papers)), ({ paper }) => Arr.flatMap(paper.sections, ({ placements }) => Arr.map(placements, ({ hash }) => hash))));
60
+ /**
61
+ * The explanations the catalog asks for: each version a set's paper places,
62
+ * in every locale that set is written in.
63
+ */
64
+ function requiredExplanations(rows) {
65
+ return HashSet.fromIterable(Arr.flatMap(rows.catalog, (row) => {
66
+ if (row.kind !== "set") {
67
+ return [];
68
+ }
69
+ const placed = Arr.flatMap(Option.toArray(HashMap.get(rows.papers, row.paper.id)), ({ paper }) => placedHashes(paper));
70
+ return Arr.flatMap(placed, (hash) => Arr.map(row.appLocales, (language) => explanationIdentity(hash, language)));
71
+ }));
72
+ }
73
+ /**
74
+ * Verifies each item version: its family, its reading, its key, a paper that
75
+ * places it, and its explanation in every locale of every set that places it.
76
+ */
77
+ const verifyItems = Effect.fn("AksaraContracts.verifyAssessmentItems")(function* (rows) {
78
+ const placed = HashSet.fromIterable(Arr.flatMap(Arr.fromIterable(HashMap.values(rows.papers)), ({ paper }) => placedHashes(paper)));
93
79
  for (const version of HashMap.values(rows.items)) {
94
80
  const family = HashMap.get(rows.families, version.family);
95
81
  yield* require(Option.exists(family, ({ stimulus }) => stimulus === version.stimulus?.id), "family", version.family);
96
82
  yield* require(version.stimulus === undefined ||
97
83
  HashSet.has(rows.stimuli, stimulusIdentity(version.stimulus)), "stimulus", version.family);
98
- yield* require(HashSet.has(rows.keys, version.hash), "key", version.hash);
84
+ yield* require(HashMap.has(rows.keys, version.hash), "key", version.hash);
99
85
  yield* require(HashSet.has(placed, version.hash), "unplaced", version.hash);
100
- for (const language of activeAppLocales) {
101
- const identity = explanationIdentity(version.hash, language);
102
- yield* require(HashMap.has(rows.explanations, identity), "explanation", identity);
103
- }
86
+ }
87
+ for (const identity of requiredExplanations(rows)) {
88
+ yield* require(HashMap.has(rows.explanations, identity), "explanation", identity);
104
89
  }
105
90
  const familiesWithVersions = HashSet.fromIterable(Arr.map(Arr.fromIterable(HashMap.values(rows.items)), ({ family }) => family));
106
91
  for (const id of HashMap.keys(rows.families)) {
@@ -110,7 +95,7 @@ const verifyItems = Effect.fn("AksaraContracts.verifyAssessmentItems")(function*
110
95
  /** Verifies that keys and explanations name item versions the snapshot holds. */
111
96
  function verifyRecordsOfItems(rows) {
112
97
  return Effect.gen(function* () {
113
- for (const version of rows.keys) {
98
+ for (const version of HashMap.keys(rows.keys)) {
114
99
  yield* require(HashMap.has(rows.items, version), "key", version);
115
100
  }
116
101
  for (const [identity, version] of rows.explanations) {
@@ -119,8 +104,8 @@ function verifyRecordsOfItems(rows) {
119
104
  });
120
105
  }
121
106
  /**
122
- * Verifies the catalog: every node in every active app locale, every set's
123
- * paper, and the sections of each set equal to the sections of its paper.
107
+ * Verifies the catalog: every set's paper, the sections of each set equal to
108
+ * the sections of its paper, and every node in exactly the locales it serves.
124
109
  */
125
110
  const verifyCatalog = Effect.fn("AksaraContracts.verifyAssessmentCatalog")(function* (rows, activeAppLocales) {
126
111
  for (const row of rows.catalog) {
@@ -141,24 +126,20 @@ const verifyCatalog = Effect.fn("AksaraContracts.verifyAssessmentCatalog")(funct
141
126
  sections.length === entry.paper.sections.length &&
142
127
  Arr.every(entry.paper.sections, ({ section }) => Arr.contains(sections, section))), "section", `${row.appLocale}\0${row.setKey}`);
143
128
  }
144
- const present = HashSet.fromIterable(Arr.map(rows.catalog, catalogRowIdentity));
145
- for (const row of rows.catalog) {
146
- for (const appLocale of activeAppLocales) {
147
- const identity = catalogRowIdentity({ ...row, appLocale });
148
- yield* require(HashSet.has(present, identity), "locale", identity);
149
- }
150
- }
129
+ const breach = catalogLocaleBreach(rows.catalog, activeAppLocales);
130
+ yield* require(Option.isNone(breach), "locale", Option.getOrElse(breach, () => ""));
151
131
  });
152
132
  /**
153
133
  * Verifies that an assessment snapshot is closed: the catalog reaches papers it
154
134
  * holds, every paper fits the profile it follows and places versions it holds,
155
135
  * every version has its family, its reading, its key, and an explanation in
156
- * every active app locale, and no family, key, or explanation is left over.
136
+ * every locale of each set that places it, and no family, key, or explanation
137
+ * is left over.
157
138
  */
158
139
  export const verifyAssessmentClosure = Effect.fn("AksaraContracts.verifyAssessmentClosure")(function* (input) {
159
140
  const rows = indexRows(yield* Stream.runCollect(input.records));
160
141
  yield* verifyCatalog(rows, input.activeAppLocales);
161
142
  yield* verifyPapers(rows);
162
- yield* verifyItems(rows, input.activeAppLocales);
143
+ yield* verifyItems(rows);
163
144
  yield* verifyRecordsOfItems(rows);
164
145
  });
@@ -15,6 +15,11 @@ declare const ParagraphSchema: Schema.Struct<{
15
15
  readonly content: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
16
16
  readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
17
17
  readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
18
+ }>, Schema.Struct<{
19
+ readonly attrs: Schema.Struct<{
20
+ readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
21
+ }>;
22
+ readonly type: Schema.Literal<"highlight">;
18
23
  }>, Schema.Struct<{
19
24
  readonly attrs: Schema.Struct<{
20
25
  readonly href: Schema.String;
@@ -47,6 +52,11 @@ declare const HeadingSchema: Schema.Struct<{
47
52
  readonly content: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
48
53
  readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
49
54
  readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
55
+ }>, Schema.Struct<{
56
+ readonly attrs: Schema.Struct<{
57
+ readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
58
+ }>;
59
+ readonly type: Schema.Literal<"highlight">;
50
60
  }>, Schema.Struct<{
51
61
  readonly attrs: Schema.Struct<{
52
62
  readonly href: Schema.String;
@@ -128,6 +138,9 @@ export type BlockNode = ParagraphNode | typeof HeadingSchema.Type | typeof CodeB
128
138
  } | {
129
139
  readonly content: readonly [TableRowNode, ...TableRowNode[]];
130
140
  readonly type: "table";
141
+ } | {
142
+ readonly content: readonly [BlockNode, ...BlockNode[]];
143
+ readonly type: "contentBlock" | "contentStack";
131
144
  };
132
145
  export type ListItemNode = typeof ListItemSchema.Type;
133
146
  export type TableRowNode = typeof TableRowSchema.Type;
@@ -138,6 +151,11 @@ declare const ListItemSchema: Schema.Struct<{
138
151
  readonly content: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
139
152
  readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
140
153
  readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
154
+ }>, Schema.Struct<{
155
+ readonly attrs: Schema.Struct<{
156
+ readonly variant: Schema.NullOr<Schema.Literals<readonly ["success", "warning"]>>;
157
+ }>;
158
+ readonly type: Schema.Literal<"highlight">;
141
159
  }>, Schema.Struct<{
142
160
  readonly attrs: Schema.Struct<{
143
161
  readonly href: Schema.String;
@@ -77,6 +77,15 @@ const TableCellSchema = Schema.Struct({
77
77
  content: Schema.NonEmptyArray(BlockRef),
78
78
  type: Schema.Literals(["tableCell", "tableHeader"]),
79
79
  });
80
+ /**
81
+ * A group of blocks, as a lesson groups them: `contentStack` stacks related
82
+ * blocks, such as a formula and the graph it draws, and `contentBlock` sets one
83
+ * block apart with space around it.
84
+ */
85
+ const ContentGroupSchema = Schema.Struct({
86
+ content: Schema.NonEmptyArray(BlockRef),
87
+ type: Schema.Literals(["contentBlock", "contentStack"]),
88
+ });
80
89
  const TableRowSchema = Schema.Struct({
81
90
  content: Schema.NonEmptyArray(TableCellSchema),
82
91
  type: Schema.Literal("tableRow"),
@@ -98,6 +107,7 @@ export const BlockSchema = Schema.Union([
98
107
  OrderedListSchema,
99
108
  BlockquoteSchema,
100
109
  TableSchema,
110
+ ContentGroupSchema,
101
111
  ]);
102
112
  const DocumentRootSchema = Schema.Struct({
103
113
  content: Schema.NonEmptyArray(BlockSchema),