@nakafa/aksara-contracts 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -32
- 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 +348 -208
- 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/preview/artifact.d.ts +1 -120
- 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/projection/digest.d.ts +0 -127
- package/dist/projection/hash.d.ts +0 -127
- package/dist/projection/spec.d.ts +6 -211
- package/dist/projection/spec.js +4 -18
- package/dist/projection/verify.d.ts +0 -127
- package/dist/projection/verify.js +0 -3
- 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 +2 -2
- package/dist/release/hash.d.ts +5 -5
- 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 +2 -2
- 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 +6 -18
- package/dist/release/result/digest.js +1 -2
- package/dist/release/rollback/digest.d.ts +4 -19
- package/dist/release/rollback/spec.d.ts +30 -792
- package/dist/release/rollback/spec.js +1 -4
- 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/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 +5 -5
- package/dist/runtime/spec.d.ts +38 -38
- package/dist/runtime/spec.js +4 -5
- package/dist/runtime/verify.d.ts +40 -40
- package/dist/signature/spec.d.ts +5 -5
- package/dist/signature/spec.js +0 -1
- package/dist/signature/trusted.d.ts +4 -1
- package/dist/signature/trusted.js +4 -1
- 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/package.json +187 -295
- 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
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This package defines exact runtime contracts for the Aksara compiler and
|
|
4
4
|
publisher. Nakafa runtime consumes the exact published contract: a proven npm
|
|
5
|
-
package, its immutable release archive, and
|
|
5
|
+
package, its immutable release archive, and the renderer manifest that its
|
|
6
|
+
releases sign.
|
|
6
7
|
|
|
7
8
|
This package contains schemas, branded identifiers, canonical wire encodings,
|
|
8
9
|
and Web Crypto signature verification. It contains no corpus, renderer
|
|
@@ -11,9 +12,8 @@ runtime.
|
|
|
11
12
|
|
|
12
13
|
Consumers install the exact `@nakafa/aksara-contracts` version from npm and
|
|
13
14
|
commit its pnpm lockfile integrity. npm provenance and the matching immutable
|
|
14
|
-
GitHub Release bind those package bytes to the reviewed Aksara source.
|
|
15
|
-
|
|
16
|
-
renderer is live.
|
|
15
|
+
GitHub Release bind those package bytes to the reviewed Aksara source. A contract
|
|
16
|
+
change ships with the Nakafa renderer that consumes it, in one step.
|
|
17
17
|
|
|
18
18
|
Node-only writer and incremental digest exports remain isolated behind package
|
|
19
19
|
conditions. Default-runtime exports used by Convex are audited to reject
|
|
@@ -30,31 +30,10 @@ Current consumers use unversioned semantic Interfaces:
|
|
|
30
30
|
`canonicalizeContentTree` gives the bytes that hashes and signatures cover.
|
|
31
31
|
- `graph/family` classifies either a complete graph identity or one exact
|
|
32
32
|
asset ID into its application locale and content family.
|
|
33
|
-
- `tryout/catalog` owns minimal catalog node schemas, while `tryout/identity`
|
|
34
|
-
builds their pure lookup identities before complete signed rows are loaded.
|
|
35
33
|
- `projection/material` owns the application-locale material namespace and
|
|
36
34
|
validates every signed route and projection against it. Lesson metadata may
|
|
37
35
|
carry an optional `searchTitle` for the HTML title, while `title` stays the
|
|
38
36
|
short navigation name.
|
|
39
|
-
- `question/response` owns the frozen response formats: `single-choice`,
|
|
40
|
-
`multiple-choice`, `category`, `short-answer`, and `rubric`.
|
|
41
|
-
- `question/answer` owns deterministic short-answer and final-answer keys: an
|
|
42
|
-
exact canonical decimal with an optional tolerance and an explicit fraction
|
|
43
|
-
flag, or accepted text with explicit normalization rules. Every runtime
|
|
44
|
-
grades a typed answer only through `matchesAnswerKey`, reads a typed number
|
|
45
|
-
only through `readNumberAnswer`, the one number grammar, and decides that a
|
|
46
|
-
typed answer is blank only through `isBlankAnswer`, so whitespace and
|
|
47
|
-
invisible format characters alone never count as an answer.
|
|
48
|
-
- `question/rubric` owns the locale-neutral `QuestionRubricScaleSchema`
|
|
49
|
-
(ordered criteria and levels with points and optional final-answer keys)
|
|
50
|
-
and the Aksara rubric, which labels every criterion and level in every
|
|
51
|
-
active app locale. Each judged criterion maps onto one Effect
|
|
52
|
-
`Decision.rate` decision, and its total is derived, never stored.
|
|
53
|
-
- `question/points` owns a question's worth. Raw, penalized, and IRT scoring
|
|
54
|
-
read it only through `questionPoints`.
|
|
55
|
-
- `tryout/spec` owns the `irt`, `penalized`, and `raw` scoring strategies, the
|
|
56
|
-
per-section marks of a penalized exam, and the `institution`, `subject`, and
|
|
57
|
-
`year` track kinds.
|
|
58
37
|
- `projection/page` owns stable public page identities, localized paths, and
|
|
59
38
|
signed metadata for human, agent, and sitemap delivery.
|
|
60
39
|
- `math/base` owns the unversioned base schemas that mathematical visuals
|
|
@@ -68,15 +47,19 @@ Current consumers use unversioned semantic Interfaces:
|
|
|
68
47
|
with typed `figure` props, twelve `interaction` kinds that hold no answer
|
|
69
48
|
key, `scoring` as data, the `key` and the `explanation` of an item version as
|
|
70
49
|
records of their own, `item` and `stimulus` versions named by a content hash,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
the exam `profile`, the frozen `paper`, and the `tools` registry. `answer`
|
|
51
|
+
owns the typed-answer keys: every runtime grades a typed answer only through
|
|
52
|
+
`matchesAnswerKey`, reads a typed number only through `readNumberAnswer`, the
|
|
53
|
+
one number grammar, and decides that a typed answer is blank only through
|
|
54
|
+
`isBlankAnswer`. `catalog` owns the try-out navigation rows, each set naming
|
|
55
|
+
its paper, and `snapshot` the `assessment` snapshot family that publishes all
|
|
56
|
+
of it in one signed release.
|
|
74
57
|
[ADR 0005](https://github.com/nakafaai/aksara/blob/main/docs/adr/assessment.md)
|
|
75
58
|
records the decisions.
|
|
76
59
|
|
|
77
60
|
## Publication dates
|
|
78
61
|
|
|
79
|
-
Article, material, public page
|
|
62
|
+
Article, material, and public page metadata carry one required
|
|
80
63
|
`datePublished` and one optional `dateModified`, both as exact `DateOnly`
|
|
81
64
|
values.
|
|
82
65
|
|
|
@@ -109,9 +92,9 @@ it still publishes the selected domain and contains every required component
|
|
|
109
92
|
name. Every current manifest contains the complete canonical domain set. The same
|
|
110
93
|
contract validates stored and deployed manifests. A renderer-changing release
|
|
111
94
|
remains bound to the exact deployed manifest. A scoped content-only release may
|
|
112
|
-
retain the active frozen manifest only when activation proves the live renderer
|
|
113
|
-
domain and contains every frozen component name. The
|
|
114
|
-
third signed value. Current production trusts authenticated
|
|
95
|
+
retain the active frozen manifest only when activation proves the live renderer
|
|
96
|
+
still publishes every frozen domain and contains every frozen component name. The
|
|
97
|
+
renderer is not a third signed value. Current production trusts authenticated
|
|
115
98
|
Convex state for route/head membership, delivery class, and the active pointer;
|
|
116
99
|
a release result digest is not a per-row inclusion proof. This boundary is
|
|
117
100
|
recorded explicitly in
|
|
@@ -7,26 +7,26 @@ import type { AppLocaleCode } from "#contracts/locale";
|
|
|
7
7
|
* Graders compare it exactly through `matchesAnswerKey`, never through binary
|
|
8
8
|
* floating point.
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
11
|
-
export type
|
|
10
|
+
export declare const DecimalSchema: Schema.String;
|
|
11
|
+
export type Decimal = typeof DecimalSchema.Type;
|
|
12
12
|
/**
|
|
13
13
|
* Largest accepted distance from the exact value, inclusive. An absolute
|
|
14
14
|
* tolerance `t` accepts `|answer - value| <= t`. A relative tolerance `r`
|
|
15
15
|
* accepts `|answer - value| <= r * |value|`, is below one, and needs a nonzero
|
|
16
16
|
* value.
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const ToleranceSchema: Schema.Struct<{
|
|
19
19
|
readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
|
|
20
20
|
readonly value: Schema.String;
|
|
21
21
|
}>;
|
|
22
|
-
export type
|
|
22
|
+
export type Tolerance = typeof ToleranceSchema.Type;
|
|
23
23
|
/**
|
|
24
24
|
* Deterministic numeric answer key. A learner number, read by
|
|
25
25
|
* `readNumberAnswer` in the delivery language, matches when its exact value
|
|
26
26
|
* equals `value`, or lies within `tolerance` when present. A fraction such as
|
|
27
27
|
* `6/8` matches only when `acceptsFractions` is true.
|
|
28
28
|
*/
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const NumberKeySchema: Schema.Struct<{
|
|
30
30
|
readonly acceptsFractions: Schema.Boolean;
|
|
31
31
|
readonly kind: Schema.Literal<"number">;
|
|
32
32
|
readonly tolerance: Schema.optionalKey<Schema.Struct<{
|
|
@@ -35,22 +35,22 @@ export declare const QuestionNumberKeySchema: Schema.Struct<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
readonly value: Schema.String;
|
|
37
37
|
}>;
|
|
38
|
-
export type
|
|
38
|
+
export type NumberKey = typeof NumberKeySchema.Type;
|
|
39
39
|
/**
|
|
40
40
|
* Deterministic text answer key written in the delivery language. A learner
|
|
41
41
|
* answer matches when it normalizes, under `ignoreCase` and
|
|
42
42
|
* `collapseWhitespace`, to the same text as one accepted answer. Accepted
|
|
43
43
|
* answers are plain text, never Markdown, so show them without rich rendering.
|
|
44
44
|
*/
|
|
45
|
-
export declare const
|
|
45
|
+
export declare const TextKeySchema: Schema.Struct<{
|
|
46
46
|
readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
|
|
47
47
|
readonly collapseWhitespace: Schema.Boolean;
|
|
48
48
|
readonly ignoreCase: Schema.Boolean;
|
|
49
49
|
readonly kind: Schema.Literal<"text">;
|
|
50
50
|
}>;
|
|
51
|
-
export type
|
|
52
|
-
/**
|
|
53
|
-
export declare const
|
|
51
|
+
export type TextKey = typeof TextKeySchema.Type;
|
|
52
|
+
/** A key that a typed answer is graded against: a number or accepted texts. */
|
|
53
|
+
export declare const AnswerKeySchema: Schema.Union<readonly [Schema.Struct<{
|
|
54
54
|
readonly acceptsFractions: Schema.Boolean;
|
|
55
55
|
readonly kind: Schema.Literal<"number">;
|
|
56
56
|
readonly tolerance: Schema.optionalKey<Schema.Struct<{
|
|
@@ -64,18 +64,18 @@ export declare const QuestionAnswerKeySchema: Schema.Union<readonly [Schema.Stru
|
|
|
64
64
|
readonly ignoreCase: Schema.Boolean;
|
|
65
65
|
readonly kind: Schema.Literal<"text">;
|
|
66
66
|
}>]>;
|
|
67
|
-
export type
|
|
67
|
+
export type AnswerKey = typeof AnswerKeySchema.Type;
|
|
68
68
|
/**
|
|
69
69
|
* One learner number read exactly as `numerator / denominator`, with a
|
|
70
70
|
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
71
71
|
* records that the learner wrote `p/q`.
|
|
72
72
|
*/
|
|
73
|
-
declare const
|
|
73
|
+
declare const NumberAnswerSchema: Schema.Struct<{
|
|
74
74
|
readonly denominator: Schema.BigDecimal;
|
|
75
75
|
readonly fraction: Schema.Boolean;
|
|
76
76
|
readonly numerator: Schema.BigDecimal;
|
|
77
77
|
}>;
|
|
78
|
-
export type
|
|
78
|
+
export type NumberAnswer = typeof NumberAnswerSchema.Type;
|
|
79
79
|
/**
|
|
80
80
|
* Checks whether one typed learner answer is blank: nothing remains once it is
|
|
81
81
|
* read as visible text, so whitespace and invisible format characters alone
|
|
@@ -107,49 +107,5 @@ export declare function readNumberAnswer(input: string, language: AppLocaleCode)
|
|
|
107
107
|
* language and compares its exact value, so an unreadable or empty answer
|
|
108
108
|
* never matches.
|
|
109
109
|
*/
|
|
110
|
-
export declare function matchesAnswerKey(key:
|
|
111
|
-
/** Returns one answer key in stable field order for signed canonicalizers. */
|
|
112
|
-
export declare function canonicalQuestionAnswerKey(key: QuestionAnswerKey): {
|
|
113
|
-
acceptedAnswers: [string, ...string[]];
|
|
114
|
-
collapseWhitespace: boolean;
|
|
115
|
-
ignoreCase: boolean;
|
|
116
|
-
kind: "text";
|
|
117
|
-
} | {
|
|
118
|
-
acceptedAnswers?: never;
|
|
119
|
-
collapseWhitespace?: never;
|
|
120
|
-
ignoreCase?: never;
|
|
121
|
-
acceptsFractions: boolean;
|
|
122
|
-
kind: "number";
|
|
123
|
-
tolerance?: {
|
|
124
|
-
kind: "absolute" | "relative";
|
|
125
|
-
value: string;
|
|
126
|
-
};
|
|
127
|
-
value: string;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Returns the grading rules shared by every delivery language. A numeric key is
|
|
131
|
-
* language-neutral and stays whole; text keeps its rules but drops accepted
|
|
132
|
-
* answers, which each delivery language writes in its own words.
|
|
133
|
-
*/
|
|
134
|
-
export declare function canonicalQuestionAnswerKeyStructure(key: QuestionAnswerKey): {
|
|
135
|
-
acceptedAnswers: [string, ...string[]];
|
|
136
|
-
collapseWhitespace: boolean;
|
|
137
|
-
ignoreCase: boolean;
|
|
138
|
-
kind: "text";
|
|
139
|
-
} | {
|
|
140
|
-
acceptedAnswers?: never;
|
|
141
|
-
collapseWhitespace?: never;
|
|
142
|
-
ignoreCase?: never;
|
|
143
|
-
acceptsFractions: boolean;
|
|
144
|
-
kind: "number";
|
|
145
|
-
tolerance?: {
|
|
146
|
-
kind: "absolute" | "relative";
|
|
147
|
-
value: string;
|
|
148
|
-
};
|
|
149
|
-
value: string;
|
|
150
|
-
} | {
|
|
151
|
-
collapseWhitespace: boolean;
|
|
152
|
-
ignoreCase: boolean;
|
|
153
|
-
kind: "text";
|
|
154
|
-
};
|
|
110
|
+
export declare function matchesAnswerKey(key: AnswerKey, answer: string, language: AppLocaleCode): boolean;
|
|
155
111
|
export {};
|
|
@@ -21,9 +21,9 @@ const NUMBER_PATTERNS = {
|
|
|
21
21
|
* Graders compare it exactly through `matchesAnswerKey`, never through binary
|
|
22
22
|
* floating point.
|
|
23
23
|
*/
|
|
24
|
-
export const
|
|
24
|
+
export const DecimalSchema = Schema.String.check(Schema.isPattern(DECIMAL_PATTERN, {
|
|
25
25
|
description: "Exact decimal written in its canonical dot-separated form.",
|
|
26
|
-
identifier: "
|
|
26
|
+
identifier: "AssessmentDecimal",
|
|
27
27
|
message: "Invalid canonical decimal.",
|
|
28
28
|
}));
|
|
29
29
|
/** Checks that one canonical decimal is strictly greater than zero. */
|
|
@@ -36,9 +36,9 @@ function isPositiveDecimal(value) {
|
|
|
36
36
|
* accepts `|answer - value| <= r * |value|`, is below one, and needs a nonzero
|
|
37
37
|
* value.
|
|
38
38
|
*/
|
|
39
|
-
export const
|
|
39
|
+
export const ToleranceSchema = Schema.Struct({
|
|
40
40
|
kind: Schema.Literals(["absolute", "relative"]),
|
|
41
|
-
value:
|
|
41
|
+
value: DecimalSchema.check(Schema.makeFilter(isPositiveDecimal, {
|
|
42
42
|
message: "Expected a positive tolerance.",
|
|
43
43
|
})),
|
|
44
44
|
}).check(Schema.makeFilter(({ kind, value }) => kind === "absolute" || value.startsWith("0."), { message: "Expected a relative tolerance below one." }));
|
|
@@ -48,11 +48,11 @@ export const QuestionToleranceSchema = Schema.Struct({
|
|
|
48
48
|
* equals `value`, or lies within `tolerance` when present. A fraction such as
|
|
49
49
|
* `6/8` matches only when `acceptsFractions` is true.
|
|
50
50
|
*/
|
|
51
|
-
export const
|
|
51
|
+
export const NumberKeySchema = Schema.Struct({
|
|
52
52
|
acceptsFractions: Schema.Boolean,
|
|
53
53
|
kind: Schema.Literal("number"),
|
|
54
|
-
tolerance: Schema.optionalKey(
|
|
55
|
-
value:
|
|
54
|
+
tolerance: Schema.optionalKey(ToleranceSchema),
|
|
55
|
+
value: DecimalSchema,
|
|
56
56
|
}).check(Schema.makeFilter(({ tolerance, value }) => tolerance?.kind !== "relative" || value !== "0", { message: "A relative tolerance cannot measure distance from zero." }));
|
|
57
57
|
/**
|
|
58
58
|
* One accepted answer as a learner types it on one line: trimmed, non-empty,
|
|
@@ -60,7 +60,7 @@ export const QuestionNumberKeySchema = Schema.Struct({
|
|
|
60
60
|
* control or invisible format character. Each key therefore has one signed
|
|
61
61
|
* spelling and can be typed into a single-line answer field.
|
|
62
62
|
*/
|
|
63
|
-
const
|
|
63
|
+
const AcceptedTextSchema = Schema.Trimmed.check(Schema.isNonEmpty(), Schema.makeFilter((text) => !UNTYPABLE_CHARACTER_PATTERN.test(text), {
|
|
64
64
|
message: "Expected one typed line whose only whitespace is the ordinary space.",
|
|
65
65
|
}), Schema.makeFilter((text) => text === text.normalize("NFC"), {
|
|
66
66
|
message: "Expected NFC text.",
|
|
@@ -107,25 +107,22 @@ function hasDistinctAcceptedAnswers(key) {
|
|
|
107
107
|
* `collapseWhitespace`, to the same text as one accepted answer. Accepted
|
|
108
108
|
* answers are plain text, never Markdown, so show them without rich rendering.
|
|
109
109
|
*/
|
|
110
|
-
export const
|
|
111
|
-
acceptedAnswers: Schema.NonEmptyArray(
|
|
110
|
+
export const TextKeySchema = Schema.Struct({
|
|
111
|
+
acceptedAnswers: Schema.NonEmptyArray(AcceptedTextSchema),
|
|
112
112
|
collapseWhitespace: Schema.Boolean,
|
|
113
113
|
ignoreCase: Schema.Boolean,
|
|
114
114
|
kind: Schema.Literal("text"),
|
|
115
115
|
}).check(Schema.makeFilter(hasDistinctAcceptedAnswers, {
|
|
116
116
|
message: "Accepted answers must stay distinct after normalization.",
|
|
117
117
|
}));
|
|
118
|
-
/**
|
|
119
|
-
export const
|
|
120
|
-
QuestionNumberKeySchema,
|
|
121
|
-
QuestionTextKeySchema,
|
|
122
|
-
]);
|
|
118
|
+
/** A key that a typed answer is graded against: a number or accepted texts. */
|
|
119
|
+
export const AnswerKeySchema = Schema.Union([NumberKeySchema, TextKeySchema]);
|
|
123
120
|
/**
|
|
124
121
|
* One learner number read exactly as `numerator / denominator`, with a
|
|
125
122
|
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
126
123
|
* records that the learner wrote `p/q`.
|
|
127
124
|
*/
|
|
128
|
-
const
|
|
125
|
+
const NumberAnswerSchema = Schema.Struct({
|
|
129
126
|
denominator: Schema.BigDecimal,
|
|
130
127
|
fraction: Schema.Boolean,
|
|
131
128
|
numerator: Schema.BigDecimal,
|
|
@@ -217,47 +214,3 @@ export function matchesAnswerKey(key, answer, language) {
|
|
|
217
214
|
}
|
|
218
215
|
return Option.exists(readNumberAnswer(answer, language), (number) => matchesNumberKey(key, number));
|
|
219
216
|
}
|
|
220
|
-
/** Copies accepted answers while keeping their non-empty tuple type. */
|
|
221
|
-
function canonicalAcceptedAnswers(answers) {
|
|
222
|
-
const [first, ...rest] = answers;
|
|
223
|
-
return [first, ...rest];
|
|
224
|
-
}
|
|
225
|
-
/** Returns one answer key in stable field order for signed canonicalizers. */
|
|
226
|
-
export function canonicalQuestionAnswerKey(key) {
|
|
227
|
-
if (key.kind === "text") {
|
|
228
|
-
return {
|
|
229
|
-
acceptedAnswers: canonicalAcceptedAnswers(key.acceptedAnswers),
|
|
230
|
-
collapseWhitespace: key.collapseWhitespace,
|
|
231
|
-
ignoreCase: key.ignoreCase,
|
|
232
|
-
kind: key.kind,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
acceptsFractions: key.acceptsFractions,
|
|
237
|
-
kind: key.kind,
|
|
238
|
-
...(key.tolerance === undefined
|
|
239
|
-
? {}
|
|
240
|
-
: {
|
|
241
|
-
tolerance: {
|
|
242
|
-
kind: key.tolerance.kind,
|
|
243
|
-
value: key.tolerance.value,
|
|
244
|
-
},
|
|
245
|
-
}),
|
|
246
|
-
value: key.value,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Returns the grading rules shared by every delivery language. A numeric key is
|
|
251
|
-
* language-neutral and stays whole; text keeps its rules but drops accepted
|
|
252
|
-
* answers, which each delivery language writes in its own words.
|
|
253
|
-
*/
|
|
254
|
-
export function canonicalQuestionAnswerKeyStructure(key) {
|
|
255
|
-
if (key.kind === "text") {
|
|
256
|
-
return {
|
|
257
|
-
collapseWhitespace: key.collapseWhitespace,
|
|
258
|
-
ignoreCase: key.ignoreCase,
|
|
259
|
-
kind: key.kind,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return canonicalQuestionAnswerKey(key);
|
|
263
|
-
}
|
|
@@ -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;
|