@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.
- package/README.md +10 -27
- package/dist/artifact/integrity.d.ts +3 -3
- package/dist/artifact/integrity.js +2 -2
- package/dist/artifact/source.d.ts +2 -2
- package/dist/artifact/source.js +2 -8
- package/dist/artifact/spec.d.ts +0 -16
- package/dist/artifact/spec.js +0 -6
- package/dist/artifact/verify.d.ts +1 -1
- package/dist/{question → assessment}/answer.d.ts +14 -58
- package/dist/{question → assessment}/answer.js +13 -60
- package/dist/assessment/catalog.d.ts +235 -0
- package/dist/assessment/catalog.js +115 -0
- package/dist/assessment/chart.d.ts +62 -0
- package/dist/assessment/chart.js +64 -0
- package/dist/assessment/closure.d.ts +28 -0
- package/dist/assessment/closure.js +164 -0
- package/dist/assessment/explanation.d.ts +13 -8
- package/dist/assessment/explanation.js +14 -8
- package/dist/assessment/figure.d.ts +140 -1
- package/dist/assessment/figure.js +9 -2
- package/dist/assessment/hash.d.ts +352 -212
- package/dist/assessment/hash.js +14 -0
- package/dist/assessment/inline.d.ts +3 -1
- package/dist/assessment/inline.js +20 -5
- package/dist/assessment/item.d.ts +8 -4
- package/dist/assessment/item.js +6 -2
- package/dist/assessment/key.js +6 -6
- package/dist/assessment/paper.d.ts +74 -74
- package/dist/assessment/snapshot.d.ts +3778 -0
- package/dist/assessment/snapshot.js +192 -0
- package/dist/cache/content.d.ts +4 -4
- package/dist/canonical.d.ts +6 -0
- package/dist/canonical.js +8 -1
- package/dist/content.d.ts +1 -1
- package/dist/content.js +0 -1
- package/dist/delivery.d.ts +0 -3
- package/dist/delivery.js +0 -5
- package/dist/hash/digest.d.ts +7 -7
- package/dist/hash/digest.js +9 -30
- package/dist/hash/stream.d.ts +1 -1
- package/dist/hash/text.d.ts +3 -12
- package/dist/hash/text.js +3 -6
- package/dist/ids.js +8 -8
- package/dist/preview/artifact.d.ts +1 -120
- package/dist/preview/auth.d.ts +1 -1
- package/dist/preview/auth.js +29 -25
- package/dist/preview/document.d.ts +0 -586
- package/dist/preview/document.js +1 -47
- package/dist/preview/spec.d.ts +6 -1984
- package/dist/preview/spec.js +7 -47
- package/dist/preview/target.d.ts +0 -173
- package/dist/preview/target.js +1 -70
- package/dist/program/snapshot/digest.d.ts +1 -2
- package/dist/program/snapshot/digest.js +2 -4
- package/dist/program/snapshot/hash.d.ts +6 -21
- package/dist/program/snapshot/hash.js +3 -9
- package/dist/projection/digest.d.ts +7 -143
- package/dist/projection/digest.js +7 -13
- package/dist/projection/hash.d.ts +2 -138
- package/dist/projection/hash.js +2 -5
- package/dist/projection/material.js +1 -1
- package/dist/projection/spec.d.ts +6 -211
- package/dist/projection/spec.js +4 -18
- package/dist/projection/verify.d.ts +1 -128
- package/dist/projection/verify.js +1 -4
- package/dist/quran/provenance.d.ts +2 -8
- package/dist/quran/provenance.js +1 -4
- package/dist/quran/snapshot/digest.d.ts +1 -2
- package/dist/quran/snapshot/digest.js +2 -2
- package/dist/quran/snapshot/hash.d.ts +3 -10
- package/dist/quran/snapshot/hash.js +2 -5
- package/dist/quran/snapshot/row/hash.d.ts +3 -12
- package/dist/quran/snapshot/row/hash.js +2 -5
- package/dist/release/canonical.d.ts +2 -2
- package/dist/release/current/evidence.d.ts +24 -24
- package/dist/release/current/state.d.ts +28 -56
- package/dist/release/current/state.js +1 -6
- package/dist/release/digest.d.ts +9 -18
- package/dist/release/digest.js +7 -13
- package/dist/release/hash.d.ts +7 -16
- package/dist/release/hash.js +2 -6
- package/dist/release/head.d.ts +10 -57
- package/dist/release/head.js +3 -14
- package/dist/release/identity.d.ts +3 -3
- package/dist/release/items.d.ts +3 -3
- package/dist/release/items.js +1 -1
- package/dist/release/lifecycle.d.ts +18 -18
- package/dist/release/policy.d.ts +3 -4
- package/dist/release/policy.js +2 -11
- package/dist/release/result/digest.d.ts +11 -31
- package/dist/release/result/digest.js +5 -11
- package/dist/release/rollback/digest.d.ts +11 -35
- package/dist/release/rollback/digest.js +7 -13
- package/dist/release/rollback/spec.d.ts +30 -792
- package/dist/release/rollback/spec.js +1 -4
- package/dist/release/route/digest.d.ts +7 -16
- package/dist/release/route/digest.js +7 -13
- package/dist/release/route/verify.d.ts +1 -1
- package/dist/release/route/verify.js +1 -1
- package/dist/release/snapshot/data.d.ts +599 -249
- package/dist/release/snapshot/data.js +11 -28
- package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
- package/dist/release/snapshot/evidence/assessment.js +44 -0
- package/dist/release/snapshot/evidence/program.d.ts +1 -1
- package/dist/release/snapshot/evidence/quran.d.ts +1 -1
- package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
- package/dist/release/snapshot/evidence.d.ts +19 -19
- package/dist/release/snapshot/evidence.js +2 -2
- package/dist/release/snapshot/scope.d.ts +5 -5
- package/dist/release/snapshot/scope.js +1 -1
- package/dist/release/snapshot/spec.d.ts +15 -15
- package/dist/release/snapshot/spec.js +8 -8
- package/dist/release/snapshot/verify.d.ts +1278 -268
- package/dist/release/snapshot/verify.js +8 -5
- package/dist/release/spec.d.ts +33 -33
- package/dist/release/verify.d.ts +7 -7
- package/dist/renderer/compatibility.d.ts +1 -1
- package/dist/renderer/component.js +1 -1
- package/dist/renderer/contract.d.ts +0 -8
- package/dist/renderer/contract.js +0 -3
- package/dist/renderer/manifest.d.ts +3 -3
- package/dist/renderer/manifest.js +2 -2
- package/dist/runtime/spec.d.ts +38 -38
- package/dist/runtime/spec.js +4 -5
- package/dist/runtime/verify.d.ts +42 -42
- package/dist/signature/key.d.ts +0 -2
- package/dist/signature/key.js +37 -88
- package/dist/signature/spec.d.ts +5 -5
- package/dist/signature/spec.js +0 -1
- package/dist/signature/verify.js +31 -46
- package/dist/transport/batch.d.ts +6 -244
- package/dist/transport/failure.d.ts +6 -20
- package/dist/transport/failure.js +0 -10
- package/dist/transport/group.d.ts +1969 -1369
- package/dist/transport/group.js +0 -2
- package/dist/transport/request.d.ts +10691 -5086
- package/dist/transport/request.js +0 -3
- package/dist/transport/response.d.ts +219 -1442
- package/dist/transport/response.js +0 -4
- package/dist/transport/snapshot.d.ts +1187 -487
- package/dist/tree.js +1 -1
- package/package.json +188 -296
- package/dist/projection/question.d.ts +0 -1067
- package/dist/projection/question.js +0 -121
- package/dist/question/identity.d.ts +0 -175
- package/dist/question/identity.js +0 -207
- package/dist/question/item.d.ts +0 -450
- package/dist/question/item.js +0 -174
- package/dist/question/label.d.ts +0 -3
- package/dist/question/label.js +0 -3
- package/dist/question/points.d.ts +0 -18
- package/dist/question/points.js +0 -22
- package/dist/question/response.d.ts +0 -289
- package/dist/question/response.js +0 -167
- package/dist/question/rubric.d.ts +0 -234
- package/dist/question/rubric.js +0 -186
- package/dist/release/current/runtime.d.ts +0 -4
- package/dist/release/current/runtime.js +0 -15
- package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
- package/dist/release/snapshot/evidence/tryout.js +0 -91
- package/dist/runtime/protected/limits.d.ts +0 -10
- package/dist/runtime/protected/limits.js +0 -16
- package/dist/runtime/protected/spec.d.ts +0 -310
- package/dist/runtime/protected/spec.js +0 -80
- package/dist/runtime/protected/verify.d.ts +0 -83
- package/dist/runtime/protected/verify.js +0 -70
- package/dist/transport/runtime.d.ts +0 -77
- package/dist/transport/runtime.js +0 -33
- package/dist/tryout/canonical.d.ts +0 -12
- package/dist/tryout/canonical.js +0 -7
- package/dist/tryout/catalog.d.ts +0 -396
- package/dist/tryout/catalog.js +0 -155
- package/dist/tryout/closure/accounting.d.ts +0 -20
- package/dist/tryout/closure/accounting.js +0 -70
- package/dist/tryout/closure/locale.d.ts +0 -14
- package/dist/tryout/closure/locale.js +0 -113
- package/dist/tryout/closure/placement.d.ts +0 -5
- package/dist/tryout/closure/placement.js +0 -32
- package/dist/tryout/digest.d.ts +0 -34
- package/dist/tryout/digest.js +0 -57
- package/dist/tryout/hash/catalog.d.ts +0 -364
- package/dist/tryout/hash/catalog.js +0 -209
- package/dist/tryout/hash/content.d.ts +0 -215
- package/dist/tryout/hash/content.js +0 -75
- package/dist/tryout/hash/placement.d.ts +0 -242
- package/dist/tryout/hash/placement.js +0 -56
- package/dist/tryout/identity.d.ts +0 -12
- package/dist/tryout/identity.js +0 -47
- package/dist/tryout/key.d.ts +0 -4
- package/dist/tryout/key.js +0 -8
- package/dist/tryout/language.d.ts +0 -24
- package/dist/tryout/language.js +0 -30
- package/dist/tryout/placement.d.ts +0 -331
- package/dist/tryout/placement.js +0 -96
- package/dist/tryout/runtime/canonical.d.ts +0 -8
- package/dist/tryout/runtime/canonical.js +0 -34
- package/dist/tryout/runtime/hash.d.ts +0 -34
- package/dist/tryout/runtime/hash.js +0 -13
- package/dist/tryout/runtime/source.d.ts +0 -44
- package/dist/tryout/runtime/source.js +0 -47
- package/dist/tryout/runtime/spec.d.ts +0 -58
- package/dist/tryout/runtime/spec.js +0 -21
- package/dist/tryout/runtime/verify.d.ts +0 -69
- package/dist/tryout/runtime/verify.js +0 -67
- package/dist/tryout/scoring.d.ts +0 -148
- package/dist/tryout/scoring.js +0 -98
- package/dist/tryout/snapshot/canonical.d.ts +0 -7
- package/dist/tryout/snapshot/canonical.js +0 -18
- package/dist/tryout/snapshot/hash.d.ts +0 -49
- package/dist/tryout/snapshot/hash.js +0 -22
- package/dist/tryout/snapshot/spec.d.ts +0 -46
- package/dist/tryout/snapshot/spec.js +0 -30
- package/dist/tryout/spec.d.ts +0 -41
- package/dist/tryout/spec.js +0 -46
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Bounded authored revision shared by one catalog source hierarchy. */
|
|
3
|
+
export declare const CatalogRevisionSchema: Schema.Trimmed;
|
|
4
|
+
/**
|
|
5
|
+
* Navigation role of one track: one exam `year`, one `subject`, or the sets of
|
|
6
|
+
* one `institution`, such as a Studienkolleg.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TrackKindSchema: Schema.Literals<readonly ["institution", "subject", "year"]>;
|
|
9
|
+
/**
|
|
10
|
+
* Public route behavior of one section: `visible` sections have a page of
|
|
11
|
+
* their own, and an `internal-entry` section is entered from its set.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SectionVisibilitySchema: Schema.Literals<readonly ["internal-entry", "visible"]>;
|
|
14
|
+
/** One localized country of the catalog. */
|
|
15
|
+
export declare const CatalogCountrySchema: Schema.Struct<{
|
|
16
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
17
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
18
|
+
readonly graph: Schema.Struct<{
|
|
19
|
+
readonly alignmentId: Schema.String;
|
|
20
|
+
readonly assetId: Schema.String;
|
|
21
|
+
readonly conceptId: Schema.String;
|
|
22
|
+
readonly learningObjectId: Schema.String;
|
|
23
|
+
readonly lensId: Schema.String;
|
|
24
|
+
}>;
|
|
25
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
26
|
+
readonly title: Schema.String;
|
|
27
|
+
readonly countryKey: Schema.String;
|
|
28
|
+
readonly countryCode: Schema.String;
|
|
29
|
+
readonly kind: Schema.Literal<"country">;
|
|
30
|
+
readonly order: Schema.Int;
|
|
31
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
32
|
+
}>;
|
|
33
|
+
/** One localized exam of a country. */
|
|
34
|
+
export declare const CatalogExamSchema: Schema.Struct<{
|
|
35
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
36
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
37
|
+
readonly graph: Schema.Struct<{
|
|
38
|
+
readonly alignmentId: Schema.String;
|
|
39
|
+
readonly assetId: Schema.String;
|
|
40
|
+
readonly conceptId: Schema.String;
|
|
41
|
+
readonly learningObjectId: Schema.String;
|
|
42
|
+
readonly lensId: Schema.String;
|
|
43
|
+
}>;
|
|
44
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
45
|
+
readonly title: Schema.String;
|
|
46
|
+
readonly countryKey: Schema.String;
|
|
47
|
+
readonly examKey: Schema.String;
|
|
48
|
+
readonly kind: Schema.Literal<"exam">;
|
|
49
|
+
readonly order: Schema.Int;
|
|
50
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
51
|
+
}>;
|
|
52
|
+
/** One localized track of an exam: a year, a subject, or an institution. */
|
|
53
|
+
export declare const CatalogTrackSchema: Schema.Struct<{
|
|
54
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
55
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
56
|
+
readonly graph: Schema.Struct<{
|
|
57
|
+
readonly alignmentId: Schema.String;
|
|
58
|
+
readonly assetId: Schema.String;
|
|
59
|
+
readonly conceptId: Schema.String;
|
|
60
|
+
readonly learningObjectId: Schema.String;
|
|
61
|
+
readonly lensId: Schema.String;
|
|
62
|
+
}>;
|
|
63
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
64
|
+
readonly title: Schema.String;
|
|
65
|
+
readonly countryKey: Schema.String;
|
|
66
|
+
readonly examKey: Schema.String;
|
|
67
|
+
readonly trackKey: Schema.String;
|
|
68
|
+
readonly kind: Schema.Literal<"track">;
|
|
69
|
+
readonly order: Schema.Int;
|
|
70
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
71
|
+
readonly trackKind: Schema.Literals<readonly ["institution", "subject", "year"]>;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* One localized set of a track, and the paper a learner sits for it, by
|
|
75
|
+
* identifier and hash. A set whose only section is entered from the set names
|
|
76
|
+
* that section.
|
|
77
|
+
*/
|
|
78
|
+
export declare const CatalogSetSchema: Schema.Struct<{
|
|
79
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
80
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
81
|
+
readonly graph: Schema.Struct<{
|
|
82
|
+
readonly alignmentId: Schema.String;
|
|
83
|
+
readonly assetId: Schema.String;
|
|
84
|
+
readonly conceptId: Schema.String;
|
|
85
|
+
readonly learningObjectId: Schema.String;
|
|
86
|
+
readonly lensId: Schema.String;
|
|
87
|
+
}>;
|
|
88
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
89
|
+
readonly title: Schema.String;
|
|
90
|
+
readonly countryKey: Schema.String;
|
|
91
|
+
readonly examKey: Schema.String;
|
|
92
|
+
readonly trackKey: Schema.String;
|
|
93
|
+
readonly setKey: Schema.String;
|
|
94
|
+
readonly internalEntrySectionKey: Schema.optionalKey<Schema.String>;
|
|
95
|
+
readonly kind: Schema.Literal<"set">;
|
|
96
|
+
readonly order: Schema.Int;
|
|
97
|
+
readonly paper: Schema.Struct<{
|
|
98
|
+
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
99
|
+
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraPaperId">;
|
|
100
|
+
}>;
|
|
101
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* One localized section of a set. Its key is the identifier of a section of
|
|
105
|
+
* the exam profile that the set's paper follows, so the profile owns its time,
|
|
106
|
+
* its items, and its scoring, and the paper owns its places.
|
|
107
|
+
*/
|
|
108
|
+
export declare const CatalogSectionSchema: Schema.Struct<{
|
|
109
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
110
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
111
|
+
readonly graph: Schema.Struct<{
|
|
112
|
+
readonly alignmentId: Schema.String;
|
|
113
|
+
readonly assetId: Schema.String;
|
|
114
|
+
readonly conceptId: Schema.String;
|
|
115
|
+
readonly learningObjectId: Schema.String;
|
|
116
|
+
readonly lensId: Schema.String;
|
|
117
|
+
}>;
|
|
118
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
119
|
+
readonly title: Schema.String;
|
|
120
|
+
readonly countryKey: Schema.String;
|
|
121
|
+
readonly examKey: Schema.String;
|
|
122
|
+
readonly trackKey: Schema.String;
|
|
123
|
+
readonly setKey: Schema.String;
|
|
124
|
+
readonly kind: Schema.Literal<"section">;
|
|
125
|
+
readonly order: Schema.Int;
|
|
126
|
+
readonly publicPath: Schema.optionalKey<Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">>;
|
|
127
|
+
readonly sectionKey: Schema.String;
|
|
128
|
+
readonly visibility: Schema.Literals<readonly ["internal-entry", "visible"]>;
|
|
129
|
+
}>;
|
|
130
|
+
/** One row of the catalog, the navigation of the public try-outs. */
|
|
131
|
+
export declare const CatalogRowSchema: Schema.Union<readonly [Schema.Struct<{
|
|
132
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
133
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
134
|
+
readonly graph: Schema.Struct<{
|
|
135
|
+
readonly alignmentId: Schema.String;
|
|
136
|
+
readonly assetId: Schema.String;
|
|
137
|
+
readonly conceptId: Schema.String;
|
|
138
|
+
readonly learningObjectId: Schema.String;
|
|
139
|
+
readonly lensId: Schema.String;
|
|
140
|
+
}>;
|
|
141
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
142
|
+
readonly title: Schema.String;
|
|
143
|
+
readonly countryKey: Schema.String;
|
|
144
|
+
readonly countryCode: Schema.String;
|
|
145
|
+
readonly kind: Schema.Literal<"country">;
|
|
146
|
+
readonly order: Schema.Int;
|
|
147
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
148
|
+
}>, Schema.Struct<{
|
|
149
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
150
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
151
|
+
readonly graph: Schema.Struct<{
|
|
152
|
+
readonly alignmentId: Schema.String;
|
|
153
|
+
readonly assetId: Schema.String;
|
|
154
|
+
readonly conceptId: Schema.String;
|
|
155
|
+
readonly learningObjectId: Schema.String;
|
|
156
|
+
readonly lensId: Schema.String;
|
|
157
|
+
}>;
|
|
158
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
159
|
+
readonly title: Schema.String;
|
|
160
|
+
readonly countryKey: Schema.String;
|
|
161
|
+
readonly examKey: Schema.String;
|
|
162
|
+
readonly kind: Schema.Literal<"exam">;
|
|
163
|
+
readonly order: Schema.Int;
|
|
164
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
165
|
+
}>, Schema.Struct<{
|
|
166
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
167
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
168
|
+
readonly graph: Schema.Struct<{
|
|
169
|
+
readonly alignmentId: Schema.String;
|
|
170
|
+
readonly assetId: Schema.String;
|
|
171
|
+
readonly conceptId: Schema.String;
|
|
172
|
+
readonly learningObjectId: Schema.String;
|
|
173
|
+
readonly lensId: Schema.String;
|
|
174
|
+
}>;
|
|
175
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
176
|
+
readonly title: Schema.String;
|
|
177
|
+
readonly countryKey: Schema.String;
|
|
178
|
+
readonly examKey: Schema.String;
|
|
179
|
+
readonly trackKey: Schema.String;
|
|
180
|
+
readonly kind: Schema.Literal<"track">;
|
|
181
|
+
readonly order: Schema.Int;
|
|
182
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
183
|
+
readonly trackKind: Schema.Literals<readonly ["institution", "subject", "year"]>;
|
|
184
|
+
}>, Schema.Struct<{
|
|
185
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
186
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
187
|
+
readonly graph: Schema.Struct<{
|
|
188
|
+
readonly alignmentId: Schema.String;
|
|
189
|
+
readonly assetId: Schema.String;
|
|
190
|
+
readonly conceptId: Schema.String;
|
|
191
|
+
readonly learningObjectId: Schema.String;
|
|
192
|
+
readonly lensId: Schema.String;
|
|
193
|
+
}>;
|
|
194
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
195
|
+
readonly title: Schema.String;
|
|
196
|
+
readonly countryKey: Schema.String;
|
|
197
|
+
readonly examKey: Schema.String;
|
|
198
|
+
readonly trackKey: Schema.String;
|
|
199
|
+
readonly setKey: Schema.String;
|
|
200
|
+
readonly internalEntrySectionKey: Schema.optionalKey<Schema.String>;
|
|
201
|
+
readonly kind: Schema.Literal<"set">;
|
|
202
|
+
readonly order: Schema.Int;
|
|
203
|
+
readonly paper: Schema.Struct<{
|
|
204
|
+
readonly hash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
205
|
+
readonly id: Schema.brand<Schema.String, "@NakafaAI/AksaraPaperId">;
|
|
206
|
+
}>;
|
|
207
|
+
readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
|
|
208
|
+
}>, Schema.Struct<{
|
|
209
|
+
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">;
|
|
210
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
211
|
+
readonly graph: Schema.Struct<{
|
|
212
|
+
readonly alignmentId: Schema.String;
|
|
213
|
+
readonly assetId: Schema.String;
|
|
214
|
+
readonly conceptId: Schema.String;
|
|
215
|
+
readonly learningObjectId: Schema.String;
|
|
216
|
+
readonly lensId: Schema.String;
|
|
217
|
+
}>;
|
|
218
|
+
readonly sourceRevision: Schema.Trimmed;
|
|
219
|
+
readonly title: Schema.String;
|
|
220
|
+
readonly countryKey: Schema.String;
|
|
221
|
+
readonly examKey: Schema.String;
|
|
222
|
+
readonly trackKey: Schema.String;
|
|
223
|
+
readonly setKey: Schema.String;
|
|
224
|
+
readonly kind: Schema.Literal<"section">;
|
|
225
|
+
readonly order: Schema.Int;
|
|
226
|
+
readonly publicPath: Schema.optionalKey<Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">>;
|
|
227
|
+
readonly sectionKey: Schema.String;
|
|
228
|
+
readonly visibility: Schema.Literals<readonly ["internal-entry", "visible"]>;
|
|
229
|
+
}>]>;
|
|
230
|
+
export type CatalogRow = typeof CatalogRowSchema.Type;
|
|
231
|
+
/**
|
|
232
|
+
* The identity of one catalog row, unique within a snapshot: its locale, its
|
|
233
|
+
* kind, and the keys of its node and of every node above it.
|
|
234
|
+
*/
|
|
235
|
+
export declare function catalogRowIdentity(row: CatalogRow): string;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { KebabKeySchema, PaperIdSchema } from "#contracts/assessment/identity";
|
|
3
|
+
import { CountryCodeSchema } from "#contracts/country";
|
|
4
|
+
import { LearningGraphIdentitySchema } from "#contracts/graph/spec";
|
|
5
|
+
import { PublicPathSchema, Sha256HashSchema } from "#contracts/ids";
|
|
6
|
+
import { AppLocaleSchema } from "#contracts/locale";
|
|
7
|
+
const PositiveCountSchema = Schema.Int.check(Schema.isGreaterThan(0));
|
|
8
|
+
/** Bounded authored revision shared by one catalog source hierarchy. */
|
|
9
|
+
export const CatalogRevisionSchema = Schema.Trimmed.check(Schema.isNonEmpty(), Schema.isMaxLength(128));
|
|
10
|
+
/**
|
|
11
|
+
* Navigation role of one track: one exam `year`, one `subject`, or the sets of
|
|
12
|
+
* one `institution`, such as a Studienkolleg.
|
|
13
|
+
*/
|
|
14
|
+
export const TrackKindSchema = Schema.Literals([
|
|
15
|
+
"institution",
|
|
16
|
+
"subject",
|
|
17
|
+
"year",
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Public route behavior of one section: `visible` sections have a page of
|
|
21
|
+
* their own, and an `internal-entry` section is entered from its set.
|
|
22
|
+
*/
|
|
23
|
+
export const SectionVisibilitySchema = Schema.Literals([
|
|
24
|
+
"internal-entry",
|
|
25
|
+
"visible",
|
|
26
|
+
]);
|
|
27
|
+
/** What every row of the catalog says in one app locale. */
|
|
28
|
+
const LocalizedFields = {
|
|
29
|
+
appLocale: AppLocaleSchema,
|
|
30
|
+
description: Schema.optionalKey(Schema.String),
|
|
31
|
+
graph: LearningGraphIdentitySchema,
|
|
32
|
+
sourceRevision: CatalogRevisionSchema,
|
|
33
|
+
title: Schema.String,
|
|
34
|
+
};
|
|
35
|
+
const CountryFields = { countryKey: KebabKeySchema };
|
|
36
|
+
const ExamFields = { ...CountryFields, examKey: KebabKeySchema };
|
|
37
|
+
const TrackFields = { ...ExamFields, trackKey: KebabKeySchema };
|
|
38
|
+
const SetFields = { ...TrackFields, setKey: KebabKeySchema };
|
|
39
|
+
/** One localized country of the catalog. */
|
|
40
|
+
export const CatalogCountrySchema = Schema.Struct({
|
|
41
|
+
...LocalizedFields,
|
|
42
|
+
...CountryFields,
|
|
43
|
+
countryCode: CountryCodeSchema,
|
|
44
|
+
kind: Schema.Literal("country"),
|
|
45
|
+
order: PositiveCountSchema,
|
|
46
|
+
publicPath: PublicPathSchema,
|
|
47
|
+
});
|
|
48
|
+
/** One localized exam of a country. */
|
|
49
|
+
export const CatalogExamSchema = Schema.Struct({
|
|
50
|
+
...LocalizedFields,
|
|
51
|
+
...ExamFields,
|
|
52
|
+
kind: Schema.Literal("exam"),
|
|
53
|
+
order: PositiveCountSchema,
|
|
54
|
+
publicPath: PublicPathSchema,
|
|
55
|
+
});
|
|
56
|
+
/** One localized track of an exam: a year, a subject, or an institution. */
|
|
57
|
+
export const CatalogTrackSchema = Schema.Struct({
|
|
58
|
+
...LocalizedFields,
|
|
59
|
+
...TrackFields,
|
|
60
|
+
kind: Schema.Literal("track"),
|
|
61
|
+
order: PositiveCountSchema,
|
|
62
|
+
publicPath: PublicPathSchema,
|
|
63
|
+
trackKind: TrackKindSchema,
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* One localized set of a track, and the paper a learner sits for it, by
|
|
67
|
+
* identifier and hash. A set whose only section is entered from the set names
|
|
68
|
+
* that section.
|
|
69
|
+
*/
|
|
70
|
+
export const CatalogSetSchema = Schema.Struct({
|
|
71
|
+
...LocalizedFields,
|
|
72
|
+
...SetFields,
|
|
73
|
+
internalEntrySectionKey: Schema.optionalKey(KebabKeySchema),
|
|
74
|
+
kind: Schema.Literal("set"),
|
|
75
|
+
order: PositiveCountSchema,
|
|
76
|
+
paper: Schema.Struct({ hash: Sha256HashSchema, id: PaperIdSchema }),
|
|
77
|
+
publicPath: PublicPathSchema,
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* One localized section of a set. Its key is the identifier of a section of
|
|
81
|
+
* the exam profile that the set's paper follows, so the profile owns its time,
|
|
82
|
+
* its items, and its scoring, and the paper owns its places.
|
|
83
|
+
*/
|
|
84
|
+
export const CatalogSectionSchema = Schema.Struct({
|
|
85
|
+
...LocalizedFields,
|
|
86
|
+
...SetFields,
|
|
87
|
+
kind: Schema.Literal("section"),
|
|
88
|
+
order: PositiveCountSchema,
|
|
89
|
+
publicPath: Schema.optionalKey(PublicPathSchema),
|
|
90
|
+
sectionKey: KebabKeySchema,
|
|
91
|
+
visibility: SectionVisibilitySchema,
|
|
92
|
+
}).check(Schema.makeFilter(({ publicPath, visibility }) => (visibility === "visible") === (publicPath !== undefined), { message: "Expected a public path on a visible section only." }));
|
|
93
|
+
/** One row of the catalog, the navigation of the public try-outs. */
|
|
94
|
+
export const CatalogRowSchema = Schema.Union([
|
|
95
|
+
CatalogCountrySchema,
|
|
96
|
+
CatalogExamSchema,
|
|
97
|
+
CatalogTrackSchema,
|
|
98
|
+
CatalogSetSchema,
|
|
99
|
+
CatalogSectionSchema,
|
|
100
|
+
]);
|
|
101
|
+
/**
|
|
102
|
+
* The identity of one catalog row, unique within a snapshot: its locale, its
|
|
103
|
+
* kind, and the keys of its node and of every node above it.
|
|
104
|
+
*/
|
|
105
|
+
export function catalogRowIdentity(row) {
|
|
106
|
+
return Arr.join([
|
|
107
|
+
row.appLocale,
|
|
108
|
+
row.kind,
|
|
109
|
+
row.countryKey,
|
|
110
|
+
"examKey" in row ? row.examKey : "",
|
|
111
|
+
"trackKey" in row ? row.trackKey : "",
|
|
112
|
+
"setKey" in row ? row.setKey : "",
|
|
113
|
+
"sectionKey" in row ? row.sectionKey : "",
|
|
114
|
+
], "\0");
|
|
115
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Props of `Chart`: categories along one axis and one or more series of
|
|
4
|
+
* values drawn as bars or lines over them, the data of a bar chart, a line
|
|
5
|
+
* chart, a histogram, or both marks at once. The data is the figure, so a
|
|
6
|
+
* learner reads the same values that the figure draws. Every series has a
|
|
7
|
+
* name, because no meaning may ride on color alone.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ChartPropsSchema: Schema.Struct<{
|
|
10
|
+
/**
|
|
11
|
+
* How the bars of a chart that has bars stand: `apart` leaves a gap between
|
|
12
|
+
* neighboring categories, as a bar chart does, and `touching` closes it, as a
|
|
13
|
+
* histogram of classes does. A chart of lines alone has no bars to place.
|
|
14
|
+
*/
|
|
15
|
+
readonly bars: Schema.optionalKey<Schema.Literals<readonly ["apart", "touching"]>>;
|
|
16
|
+
readonly categories: Schema.NonEmptyArray<Schema.Trimmed>;
|
|
17
|
+
readonly description: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
18
|
+
readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
19
|
+
readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
|
|
20
|
+
}>, Schema.Struct<{
|
|
21
|
+
readonly attrs: Schema.Struct<{
|
|
22
|
+
readonly href: Schema.String;
|
|
23
|
+
}>;
|
|
24
|
+
readonly type: Schema.Literal<"link">;
|
|
25
|
+
}>]>>>;
|
|
26
|
+
readonly text: Schema.String;
|
|
27
|
+
readonly type: Schema.Literal<"text">;
|
|
28
|
+
}>, Schema.Struct<{
|
|
29
|
+
readonly attrs: Schema.Struct<{
|
|
30
|
+
readonly latex: Schema.Trimmed;
|
|
31
|
+
}>;
|
|
32
|
+
readonly type: Schema.Literal<"mathInline">;
|
|
33
|
+
}>]>>;
|
|
34
|
+
readonly series: Schema.NonEmptyArray<Schema.Struct<{
|
|
35
|
+
readonly label: Schema.Trimmed;
|
|
36
|
+
readonly mark: Schema.Literals<readonly ["bar", "line"]>;
|
|
37
|
+
readonly values: Schema.NonEmptyArray<Schema.NullOr<Schema.Finite>>;
|
|
38
|
+
}>>;
|
|
39
|
+
readonly title: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
40
|
+
readonly marks: Schema.optionalKey<Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
41
|
+
readonly type: Schema.Literals<readonly ["bold", "italic", "underline", "code", "subscript", "superscript"]>;
|
|
42
|
+
}>, Schema.Struct<{
|
|
43
|
+
readonly attrs: Schema.Struct<{
|
|
44
|
+
readonly href: Schema.String;
|
|
45
|
+
}>;
|
|
46
|
+
readonly type: Schema.Literal<"link">;
|
|
47
|
+
}>]>>>;
|
|
48
|
+
readonly text: Schema.String;
|
|
49
|
+
readonly type: Schema.Literal<"text">;
|
|
50
|
+
}>, Schema.Struct<{
|
|
51
|
+
readonly attrs: Schema.Struct<{
|
|
52
|
+
readonly latex: Schema.Trimmed;
|
|
53
|
+
}>;
|
|
54
|
+
readonly type: Schema.Literal<"mathInline">;
|
|
55
|
+
}>]>>;
|
|
56
|
+
readonly valueLabel: Schema.optionalKey<Schema.Trimmed>;
|
|
57
|
+
readonly valueRange: Schema.optionalKey<Schema.Struct<{
|
|
58
|
+
readonly max: Schema.Finite;
|
|
59
|
+
readonly min: Schema.Finite;
|
|
60
|
+
}>>;
|
|
61
|
+
}>;
|
|
62
|
+
export type ChartProps = typeof ChartPropsSchema.Type;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { hasDistinctIds } from "#contracts/assessment/identity";
|
|
3
|
+
import { RichTextSchema } from "#contracts/assessment/inline";
|
|
4
|
+
import { PlainTextSchema } from "#contracts/assessment/scalar";
|
|
5
|
+
/**
|
|
6
|
+
* One series of a chart: its name, whether it is drawn as bars or as a line,
|
|
7
|
+
* and one value for each category. A value is null where the series has no
|
|
8
|
+
* value for that category, as a line of yearly growth that bars mark only in
|
|
9
|
+
* some years.
|
|
10
|
+
*/
|
|
11
|
+
const ChartSeriesSchema = Schema.Struct({
|
|
12
|
+
label: PlainTextSchema,
|
|
13
|
+
mark: Schema.Literals(["bar", "line"]),
|
|
14
|
+
values: Schema.NonEmptyArray(Schema.NullOr(Schema.Finite)),
|
|
15
|
+
});
|
|
16
|
+
/** The part of the value axis that a chart shows, from its minimum to its maximum. */
|
|
17
|
+
const ValueRangeSchema = Schema.Struct({
|
|
18
|
+
max: Schema.Finite,
|
|
19
|
+
min: Schema.Finite,
|
|
20
|
+
}).check(Schema.makeFilter(({ max, min }) => min < max, {
|
|
21
|
+
message: "Expected a value range whose minimum is below its maximum.",
|
|
22
|
+
}));
|
|
23
|
+
const ChartFieldsSchema = Schema.Struct({
|
|
24
|
+
/**
|
|
25
|
+
* How the bars of a chart that has bars stand: `apart` leaves a gap between
|
|
26
|
+
* neighboring categories, as a bar chart does, and `touching` closes it, as a
|
|
27
|
+
* histogram of classes does. A chart of lines alone has no bars to place.
|
|
28
|
+
*/
|
|
29
|
+
bars: Schema.optionalKey(Schema.Literals(["apart", "touching"])),
|
|
30
|
+
categories: Schema.NonEmptyArray(PlainTextSchema),
|
|
31
|
+
description: RichTextSchema,
|
|
32
|
+
series: Schema.NonEmptyArray(ChartSeriesSchema),
|
|
33
|
+
title: RichTextSchema,
|
|
34
|
+
valueLabel: Schema.optionalKey(PlainTextSchema),
|
|
35
|
+
valueRange: Schema.optionalKey(ValueRangeSchema),
|
|
36
|
+
});
|
|
37
|
+
/** Checks that every series has one value for each category, and at least one that is not null. */
|
|
38
|
+
function hasValuePerCategory(chart) {
|
|
39
|
+
return Arr.every(chart.series, ({ values }) => values.length === chart.categories.length &&
|
|
40
|
+
Arr.some(values, (value) => value !== null));
|
|
41
|
+
}
|
|
42
|
+
/** Checks that no two series share a name, so a legend tells them apart in words. */
|
|
43
|
+
function hasDistinctSeries(chart) {
|
|
44
|
+
return hasDistinctIds(Arr.map(chart.series, ({ label }) => label));
|
|
45
|
+
}
|
|
46
|
+
/** Checks that a chart says how its bars stand exactly when it has bars. */
|
|
47
|
+
function hasBarPlacement(chart) {
|
|
48
|
+
const hasBars = Arr.some(chart.series, ({ mark }) => mark === "bar");
|
|
49
|
+
return hasBars === (chart.bars !== undefined);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Props of `Chart`: categories along one axis and one or more series of
|
|
53
|
+
* values drawn as bars or lines over them, the data of a bar chart, a line
|
|
54
|
+
* chart, a histogram, or both marks at once. The data is the figure, so a
|
|
55
|
+
* learner reads the same values that the figure draws. Every series has a
|
|
56
|
+
* name, because no meaning may ride on color alone.
|
|
57
|
+
*/
|
|
58
|
+
export const ChartPropsSchema = ChartFieldsSchema.check(Schema.makeFilter(hasValuePerCategory, {
|
|
59
|
+
message: "Expected each series to have one value for each category, and at least one value.",
|
|
60
|
+
}), Schema.makeFilter(hasDistinctSeries, {
|
|
61
|
+
message: "Expected each series to have a name of its own.",
|
|
62
|
+
}), Schema.makeFilter(hasBarPlacement, {
|
|
63
|
+
message: "Expected a bar placement on a chart with bars, and on no other.",
|
|
64
|
+
}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Effect, Schema, Stream } from "effect";
|
|
2
|
+
import type { AssessmentRecord } from "#contracts/assessment/snapshot";
|
|
3
|
+
import type { ActiveAppLocaleList } from "#contracts/locale";
|
|
4
|
+
/**
|
|
5
|
+
* Why a snapshot is not closed: a reference names a row it does not hold, a
|
|
6
|
+
* row is never reached, or a paper does not fit the profile it follows.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AssessmentClosureReasonSchema: Schema.Literals<readonly ["explanation", "family", "key", "locale", "paper", "place", "profile", "section", "stimulus", "unplaced"]>;
|
|
9
|
+
declare const AssessmentClosureError_base: Schema.Class<AssessmentClosureError, Schema.TaggedStruct<"AssessmentClosureError", {
|
|
10
|
+
readonly identity: Schema.String;
|
|
11
|
+
readonly reason: Schema.Literals<readonly ["explanation", "family", "key", "locale", "paper", "place", "profile", "section", "stimulus", "unplaced"]>;
|
|
12
|
+
}>, import("effect/Cause").YieldableError & {
|
|
13
|
+
readonly brand: unique symbol;
|
|
14
|
+
}>;
|
|
15
|
+
/** A snapshot holds a reference that leads nowhere, or a row that nothing reaches. */
|
|
16
|
+
export declare class AssessmentClosureError extends AssessmentClosureError_base {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Verifies that an assessment snapshot is closed: the catalog reaches papers it
|
|
20
|
+
* holds, every paper fits the profile it follows and places versions it holds,
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
export declare const verifyAssessmentClosure: <E, R>(input: {
|
|
25
|
+
readonly activeAppLocales: ActiveAppLocaleList;
|
|
26
|
+
readonly records: Stream.Stream<AssessmentRecord, E, R>;
|
|
27
|
+
}) => Effect.Effect<void, E | AssessmentClosureError, R>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
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";
|
|
4
|
+
/**
|
|
5
|
+
* Why a snapshot is not closed: a reference names a row it does not hold, a
|
|
6
|
+
* row is never reached, or a paper does not fit the profile it follows.
|
|
7
|
+
*/
|
|
8
|
+
export const AssessmentClosureReasonSchema = Schema.Literals([
|
|
9
|
+
"explanation",
|
|
10
|
+
"family",
|
|
11
|
+
"key",
|
|
12
|
+
"locale",
|
|
13
|
+
"paper",
|
|
14
|
+
"place",
|
|
15
|
+
"profile",
|
|
16
|
+
"section",
|
|
17
|
+
"stimulus",
|
|
18
|
+
"unplaced",
|
|
19
|
+
]);
|
|
20
|
+
/** A snapshot holds a reference that leads nowhere, or a row that nothing reaches. */
|
|
21
|
+
export class AssessmentClosureError extends Schema.TaggedError()("AssessmentClosureError", {
|
|
22
|
+
identity: Schema.String,
|
|
23
|
+
reason: AssessmentClosureReasonSchema,
|
|
24
|
+
}) {
|
|
25
|
+
}
|
|
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
|
+
/** Fails with one closure reason unless the condition holds. */
|
|
64
|
+
function require(holds, reason, identity) {
|
|
65
|
+
return holds
|
|
66
|
+
? Effect.void
|
|
67
|
+
: Effect.fail(new AssessmentClosureError({ identity, reason }));
|
|
68
|
+
}
|
|
69
|
+
/** Checks that a paper follows its profile: the same sections, in order, each with its count of places. */
|
|
70
|
+
function fitsProfile(paper, profile) {
|
|
71
|
+
return (paper.sections.length === profile.sections.length &&
|
|
72
|
+
Arr.every(Arr.zip(paper.sections, profile.sections), ([placed, section]) => placed.section === section.id &&
|
|
73
|
+
placed.placements.length === section.items));
|
|
74
|
+
}
|
|
75
|
+
/** Verifies the papers: their profiles, their places, and the readings they list. */
|
|
76
|
+
const verifyPapers = Effect.fn("AksaraContracts.verifyAssessmentPapers")(function* (rows) {
|
|
77
|
+
for (const { paper } of HashMap.values(rows.papers)) {
|
|
78
|
+
const profile = HashMap.get(rows.profiles, paper.profile.id);
|
|
79
|
+
yield* require(Option.exists(profile, ({ hash }) => hash === paper.profile.hash), "profile", paper.id);
|
|
80
|
+
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);
|
|
84
|
+
yield* verifyPaperStimuli(paper, versions).pipe(Effect.mapError(() => new AssessmentClosureError({
|
|
85
|
+
identity: paper.id,
|
|
86
|
+
reason: "stimulus",
|
|
87
|
+
})));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
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))));
|
|
93
|
+
for (const version of HashMap.values(rows.items)) {
|
|
94
|
+
const family = HashMap.get(rows.families, version.family);
|
|
95
|
+
yield* require(Option.exists(family, ({ stimulus }) => stimulus === version.stimulus?.id), "family", version.family);
|
|
96
|
+
yield* require(version.stimulus === undefined ||
|
|
97
|
+
HashSet.has(rows.stimuli, stimulusIdentity(version.stimulus)), "stimulus", version.family);
|
|
98
|
+
yield* require(HashSet.has(rows.keys, version.hash), "key", version.hash);
|
|
99
|
+
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
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const familiesWithVersions = HashSet.fromIterable(Arr.map(Arr.fromIterable(HashMap.values(rows.items)), ({ family }) => family));
|
|
106
|
+
for (const id of HashMap.keys(rows.families)) {
|
|
107
|
+
yield* require(HashSet.has(familiesWithVersions, id), "family", id);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
/** Verifies that keys and explanations name item versions the snapshot holds. */
|
|
111
|
+
function verifyRecordsOfItems(rows) {
|
|
112
|
+
return Effect.gen(function* () {
|
|
113
|
+
for (const version of rows.keys) {
|
|
114
|
+
yield* require(HashMap.has(rows.items, version), "key", version);
|
|
115
|
+
}
|
|
116
|
+
for (const [identity, version] of rows.explanations) {
|
|
117
|
+
yield* require(HashMap.has(rows.items, version), "explanation", identity);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
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.
|
|
124
|
+
*/
|
|
125
|
+
const verifyCatalog = Effect.fn("AksaraContracts.verifyAssessmentCatalog")(function* (rows, activeAppLocales) {
|
|
126
|
+
for (const row of rows.catalog) {
|
|
127
|
+
if (row.kind !== "set") {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const paper = HashMap.get(rows.papers, row.paper.id);
|
|
131
|
+
yield* require(Option.exists(paper, ({ hash }) => hash === row.paper.hash), "paper", row.paper.id);
|
|
132
|
+
const sections = Arr.filterMap(rows.catalog, (section) => section.kind === "section" &&
|
|
133
|
+
section.appLocale === row.appLocale &&
|
|
134
|
+
section.countryKey === row.countryKey &&
|
|
135
|
+
section.examKey === row.examKey &&
|
|
136
|
+
section.trackKey === row.trackKey &&
|
|
137
|
+
section.setKey === row.setKey
|
|
138
|
+
? Result.succeed(section.sectionKey)
|
|
139
|
+
: Result.failVoid);
|
|
140
|
+
yield* require(Option.exists(paper, (entry) => HashSet.size(HashSet.fromIterable(sections)) === sections.length &&
|
|
141
|
+
sections.length === entry.paper.sections.length &&
|
|
142
|
+
Arr.every(entry.paper.sections, ({ section }) => Arr.contains(sections, section))), "section", `${row.appLocale}\0${row.setKey}`);
|
|
143
|
+
}
|
|
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
|
+
}
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Verifies that an assessment snapshot is closed: the catalog reaches papers it
|
|
154
|
+
* holds, every paper fits the profile it follows and places versions it holds,
|
|
155
|
+
* 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.
|
|
157
|
+
*/
|
|
158
|
+
export const verifyAssessmentClosure = Effect.fn("AksaraContracts.verifyAssessmentClosure")(function* (input) {
|
|
159
|
+
const rows = indexRows(yield* Stream.runCollect(input.records));
|
|
160
|
+
yield* verifyCatalog(rows, input.activeAppLocales);
|
|
161
|
+
yield* verifyPapers(rows);
|
|
162
|
+
yield* verifyItems(rows, input.activeAppLocales);
|
|
163
|
+
yield* verifyRecordsOfItems(rows);
|
|
164
|
+
});
|