@nakafa/aksara-contracts 6.5.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.
- package/dist/assessment/catalog.d.ts +18 -5
- package/dist/assessment/catalog.js +18 -8
- package/dist/assessment/choice.d.ts +10 -0
- package/dist/assessment/closure.d.ts +2 -1
- package/dist/assessment/closure.js +43 -62
- package/dist/assessment/document.d.ts +18 -0
- package/dist/assessment/document.js +10 -0
- package/dist/assessment/figure.d.ts +47605 -1555
- package/dist/assessment/figure.js +14 -217
- package/dist/assessment/hash.d.ts +274 -4
- package/dist/assessment/inline.d.ts +25 -0
- package/dist/assessment/inline.js +22 -3
- package/dist/assessment/interaction.d.ts +10 -0
- package/dist/assessment/item.d.ts +864 -0
- package/dist/assessment/item.js +10 -2
- package/dist/assessment/locales.d.ts +10 -0
- package/dist/assessment/locales.js +58 -0
- package/dist/assessment/paper.d.ts +1349 -12
- package/dist/assessment/paper.js +93 -9
- package/dist/assessment/part.d.ts +5 -0
- package/dist/assessment/profile.d.ts +4 -4
- package/dist/assessment/rows.d.ts +1409 -0
- package/dist/assessment/rows.js +44 -0
- package/dist/assessment/scalar.d.ts +1 -1
- package/dist/assessment/scoring.d.ts +1 -1
- package/dist/assessment/snapshot.d.ts +372 -20
- package/dist/assessment/structure.d.ts +6 -0
- package/dist/assessment/structure.js +22 -2
- package/dist/locale.d.ts +9 -9
- package/dist/locale.js +4 -3
- package/dist/program/snapshot/hash.d.ts +2 -2
- package/dist/program/snapshot/spec.d.ts +2 -2
- package/dist/projection/material.d.ts +10 -0
- package/dist/projection/material.js +1 -1
- package/dist/quran/attribution.d.ts +2 -2
- package/dist/quran/identity.d.ts +31 -10
- package/dist/quran/identity.js +15 -3
- package/dist/quran/provenance.d.ts +16 -16
- package/dist/quran/provenance.js +4 -1
- package/dist/quran/snapshot/hash.d.ts +2 -2
- package/dist/quran/snapshot/row/hash.d.ts +48 -15
- package/dist/quran/snapshot/row.d.ts +18 -8
- package/dist/quran/snapshot/spec.d.ts +2 -2
- package/dist/quran/source.d.ts +17 -7
- package/dist/quran/source.js +13 -1
- package/dist/quran/spec.d.ts +4 -4
- package/dist/quran/spec.js +2 -1
- package/dist/release/current/evidence.d.ts +9 -9
- package/dist/release/current/state.d.ts +11 -11
- package/dist/release/hash.d.ts +2 -2
- package/dist/release/identity.d.ts +1 -1
- package/dist/release/lifecycle.d.ts +7 -7
- package/dist/release/policy.d.ts +1 -1
- package/dist/release/snapshot/data.d.ts +36 -11
- package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
- 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.d.ts +3 -3
- package/dist/release/snapshot/verify.d.ts +179 -12
- package/dist/release/spec.d.ts +13 -13
- package/dist/release/verify.d.ts +2 -2
- package/dist/runtime/spec.d.ts +6 -6
- package/dist/runtime/verify.d.ts +4 -4
- package/dist/transport/group.d.ts +108 -33
- package/dist/transport/request.d.ts +1166 -114
- package/dist/transport/response.d.ts +64 -64
- package/dist/transport/snapshot.d.ts +72 -22
- package/dist/visual/base/layout.d.ts +27 -0
- package/dist/visual/base/layout.js +35 -0
- package/dist/visual/base/math.d.ts +523 -0
- package/dist/visual/base/math.js +72 -0
- package/dist/visual/base/media.d.ts +13 -0
- package/dist/visual/base/media.js +25 -0
- package/dist/visual/biology.d.ts +203 -0
- package/dist/visual/biology.js +108 -0
- package/dist/visual/card.d.ts +32 -0
- package/dist/visual/card.js +30 -0
- package/dist/visual/catalog.d.ts +28633 -0
- package/dist/visual/catalog.js +73 -0
- package/dist/visual/chemistry/atom.d.ts +79 -0
- package/dist/visual/chemistry/atom.js +109 -0
- package/dist/visual/chemistry/electron.d.ts +41 -0
- package/dist/visual/chemistry/electron.js +69 -0
- package/dist/visual/chemistry/laws.d.ts +86 -0
- package/dist/visual/chemistry/laws.js +117 -0
- package/dist/visual/chemistry/particles.d.ts +114 -0
- package/dist/visual/chemistry/particles.js +149 -0
- package/dist/visual/chemistry/periodic.d.ts +52 -0
- package/dist/visual/chemistry/periodic.js +85 -0
- package/dist/visual/chemistry/reaction.d.ts +60 -0
- package/dist/visual/chemistry/reaction.js +76 -0
- package/dist/visual/entry.d.ts +42 -0
- package/dist/visual/entry.js +48 -0
- package/dist/visual/mathematics/chart.d.ts +30 -0
- package/dist/{assessment → visual/mathematics}/chart.js +26 -18
- package/dist/visual/mathematics/charts.d.ts +118 -0
- package/dist/visual/mathematics/charts.js +100 -0
- package/dist/visual/mathematics/function.d.ts +82 -0
- package/dist/visual/mathematics/function.js +102 -0
- package/dist/visual/mathematics/geometry.d.ts +222 -0
- package/dist/visual/mathematics/geometry.js +81 -0
- package/dist/visual/mathematics/line.d.ts +179 -0
- package/dist/visual/mathematics/line.js +156 -0
- package/dist/visual/mathematics/number.d.ts +21 -0
- package/dist/visual/mathematics/number.js +53 -0
- package/dist/visual/physics/measurement.d.ts +66 -0
- package/dist/visual/physics/measurement.js +85 -0
- package/dist/visual/physics/motion.d.ts +85 -0
- package/dist/visual/physics/motion.js +110 -0
- package/dist/visual/physics/parabolic.d.ts +42 -0
- package/dist/visual/physics/parabolic.js +56 -0
- package/dist/visual/physics/velocity.d.ts +112 -0
- package/dist/visual/physics/velocity.js +144 -0
- package/dist/visual/politics.d.ts +92 -0
- package/dist/visual/politics.js +76 -0
- package/package.json +13 -5
- package/dist/assessment/chart.d.ts +0 -62
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Array as Arr,
|
|
2
|
-
import { ChartPropsSchema } from "#contracts/assessment/chart";
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
3
2
|
import { AssetIdSchema } from "#contracts/assessment/identity";
|
|
4
3
|
import { RichTextSchema } from "#contracts/assessment/inline";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { MathVisualSchema, mathVisualLabelKeys } from "#contracts/math/visual";
|
|
4
|
+
import { PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
|
|
5
|
+
import { assessmentVisuals, FIGURE_NAMES } from "#contracts/visual/catalog";
|
|
8
6
|
/**
|
|
9
7
|
* One uploaded image. The text alternative is required, and the pixel size is
|
|
10
8
|
* required so a page can reserve the space before the file loads.
|
|
@@ -15,182 +13,6 @@ export const ImageSchema = Schema.Struct({
|
|
|
15
13
|
height: PositiveIntSchema,
|
|
16
14
|
width: PositiveIntSchema,
|
|
17
15
|
});
|
|
18
|
-
/** Three finite numbers, such as a camera position or an offset: x, y, and z. */
|
|
19
|
-
const TripleSchema = Schema.Tuple([
|
|
20
|
-
Schema.Finite,
|
|
21
|
-
Schema.Finite,
|
|
22
|
-
Schema.Finite,
|
|
23
|
-
]);
|
|
24
|
-
/**
|
|
25
|
-
* The width of a line on screen. Zero is a width: the renderer draws no stroke,
|
|
26
|
-
* so a series with `showPoints` shows its points alone, as the answer to TKA
|
|
27
|
-
* compulsory mathematics set 3, question 8, shows its two fixed points.
|
|
28
|
-
*/
|
|
29
|
-
const LineWidthSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
30
|
-
/** The header every figure card shows: a title and a description. */
|
|
31
|
-
const CardFields = {
|
|
32
|
-
description: RichTextSchema,
|
|
33
|
-
title: RichTextSchema,
|
|
34
|
-
};
|
|
35
|
-
/** Checks that the rich labels match the anchors of the scene, key for key. */
|
|
36
|
-
function hasSceneLabels(props) {
|
|
37
|
-
const anchors = mathVisualLabelKeys(props.scene);
|
|
38
|
-
const keys = Rec.keys(props.labels);
|
|
39
|
-
return (anchors.length === keys.length &&
|
|
40
|
-
Arr.every(anchors, (anchor) => Arr.contains(keys, anchor)));
|
|
41
|
-
}
|
|
42
|
-
/** Props of `MathVisual`: a plane or space scene and the rich labels it anchors. */
|
|
43
|
-
export const MathVisualPropsSchema = Schema.Struct({
|
|
44
|
-
...CardFields,
|
|
45
|
-
labels: Schema.Record(MathVisualKeySchema, RichTextSchema),
|
|
46
|
-
scene: MathVisualSchema,
|
|
47
|
-
}).check(Schema.makeFilter(hasSceneLabels, {
|
|
48
|
-
message: "Expected one rich label for each label anchor of the scene.",
|
|
49
|
-
}));
|
|
50
|
-
/** A segment start: a number, or minus infinity, which JSON cannot hold. */
|
|
51
|
-
const SegmentStartSchema = Schema.Union([
|
|
52
|
-
Schema.Finite,
|
|
53
|
-
Schema.Literal("-infinity"),
|
|
54
|
-
]);
|
|
55
|
-
/** A segment end: a number, or plus infinity, which JSON cannot hold. */
|
|
56
|
-
const SegmentEndSchema = Schema.Union([
|
|
57
|
-
Schema.Finite,
|
|
58
|
-
Schema.Literal("infinity"),
|
|
59
|
-
]);
|
|
60
|
-
/** Checks that a segment that has two numbers does not end before it starts. */
|
|
61
|
-
function isOrderedSegment(segment) {
|
|
62
|
-
return (typeof segment.start !== "number" ||
|
|
63
|
-
typeof segment.end !== "number" ||
|
|
64
|
-
segment.start <= segment.end);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* One segment of a number line. The corpus sets a background only to
|
|
68
|
-
* transparent, and an arbitrary color is not part of this contract, because no
|
|
69
|
-
* meaning may ride on color.
|
|
70
|
-
*/
|
|
71
|
-
const NumberLineSegmentSchema = Schema.Struct({
|
|
72
|
-
backgroundColor: Schema.optionalKey(Schema.Literal("transparent")),
|
|
73
|
-
end: SegmentEndSchema,
|
|
74
|
-
endInclusive: Schema.optionalKey(Schema.Boolean),
|
|
75
|
-
endLabel: Schema.optionalKey(RichTextSchema),
|
|
76
|
-
label: Schema.optionalKey(RichTextSchema),
|
|
77
|
-
shaded: Schema.optionalKey(Schema.Boolean),
|
|
78
|
-
showPoints: Schema.optionalKey(Schema.Boolean),
|
|
79
|
-
start: SegmentStartSchema,
|
|
80
|
-
startInclusive: Schema.optionalKey(Schema.Boolean),
|
|
81
|
-
startLabel: Schema.optionalKey(RichTextSchema),
|
|
82
|
-
}).check(Schema.makeFilter(isOrderedSegment, {
|
|
83
|
-
message: "Expected a segment that does not end before it starts.",
|
|
84
|
-
}));
|
|
85
|
-
/** Checks that the visible range of a number line runs upward. */
|
|
86
|
-
function isOrderedRange(props) {
|
|
87
|
-
return (props.min === undefined || props.max === undefined || props.min < props.max);
|
|
88
|
-
}
|
|
89
|
-
/** Props of `NumberLine`: segments on a line, with an optional visible range. */
|
|
90
|
-
export const NumberLinePropsSchema = Schema.Struct({
|
|
91
|
-
...CardFields,
|
|
92
|
-
max: Schema.optionalKey(Schema.Finite),
|
|
93
|
-
min: Schema.optionalKey(Schema.Finite),
|
|
94
|
-
segments: Schema.NonEmptyArray(NumberLineSegmentSchema),
|
|
95
|
-
}).check(Schema.makeFilter(isOrderedRange, {
|
|
96
|
-
message: "Expected a visible range whose minimum is below its maximum.",
|
|
97
|
-
}));
|
|
98
|
-
/** Whether the first or last point of a line belongs to it. */
|
|
99
|
-
const EndpointStateSchema = Schema.Literals(["open", "closed"]);
|
|
100
|
-
/** A label on a line: rich text at one of its points, nudged by an offset, at an optional size. */
|
|
101
|
-
const LineLabelSchema = Schema.Struct({
|
|
102
|
-
anchorX: Schema.optionalKey(Schema.Literals(["center", "left", "right"])),
|
|
103
|
-
at: Schema.optionalKey(NonNegativeIntSchema),
|
|
104
|
-
fontSize: Schema.optionalKey(PositiveMeasureSchema),
|
|
105
|
-
offset: Schema.optionalKey(TripleSchema),
|
|
106
|
-
text: RichTextSchema,
|
|
107
|
-
});
|
|
108
|
-
/** One line or curve through points, with the markers and labels it shows. */
|
|
109
|
-
const LineFieldsSchema = Schema.Struct({
|
|
110
|
-
color: PlainTextSchema,
|
|
111
|
-
cone: Schema.optionalKey(Schema.Struct({
|
|
112
|
-
position: Schema.Literals(["start", "end", "both"]),
|
|
113
|
-
size: Schema.optionalKey(PositiveMeasureSchema),
|
|
114
|
-
})),
|
|
115
|
-
endpoints: Schema.optionalKey(Schema.Struct({
|
|
116
|
-
end: Schema.optionalKey(EndpointStateSchema),
|
|
117
|
-
start: Schema.optionalKey(EndpointStateSchema),
|
|
118
|
-
})),
|
|
119
|
-
labels: Schema.optionalKey(Schema.NonEmptyArray(LineLabelSchema)),
|
|
120
|
-
lineWidth: Schema.optionalKey(LineWidthSchema),
|
|
121
|
-
pointIndices: Schema.optionalKey(Schema.NonEmptyArray(NonNegativeIntSchema)),
|
|
122
|
-
points: Schema.NonEmptyArray(SpacePointSchema),
|
|
123
|
-
showPoints: Schema.optionalKey(Schema.Boolean),
|
|
124
|
-
smooth: Schema.optionalKey(Schema.Boolean),
|
|
125
|
-
});
|
|
126
|
-
/** Checks that every index of a line names one of its points. */
|
|
127
|
-
function hasIndexedPoints(line) {
|
|
128
|
-
const count = line.points.length;
|
|
129
|
-
return (Arr.every(line.pointIndices ?? [], (index) => index < count) &&
|
|
130
|
-
Arr.every(line.labels ?? [], ({ at }) => at === undefined || at < count));
|
|
131
|
-
}
|
|
132
|
-
/** One line whose point indices and label places all name a point of it. */
|
|
133
|
-
const LineSchema = LineFieldsSchema.check(Schema.makeFilter(hasIndexedPoints, {
|
|
134
|
-
message: "Expected every point index to name a point of the line.",
|
|
135
|
-
}));
|
|
136
|
-
/**
|
|
137
|
-
* Where the `LineEquation` card puts the camera when `cameraPosition` is left
|
|
138
|
-
* out: `DEFAULT_CAMERA_POSITION_X`, `_Y`, and `_Z` in
|
|
139
|
-
* `components/contents/mathematics/line/equation.tsx` of Nakafa's design system
|
|
140
|
-
* (read on 13 October 2026).
|
|
141
|
-
*/
|
|
142
|
-
const DEFAULT_CAMERA_POSITION = [10, 6, 10];
|
|
143
|
-
/**
|
|
144
|
-
* Where the scene looks when `cameraTarget` is left out: the origin, as
|
|
145
|
-
* `DEFAULT_CAMERA_TARGET` in `components/three/camera-controls.tsx` of the
|
|
146
|
-
* same package says (read on 13 October 2026).
|
|
147
|
-
*/
|
|
148
|
-
const DEFAULT_CAMERA_TARGET = [0, 0, 0];
|
|
149
|
-
const LineEquationFieldsSchema = Schema.Struct({
|
|
150
|
-
...CardFields,
|
|
151
|
-
cameraPosition: Schema.optionalKey(TripleSchema),
|
|
152
|
-
cameraTarget: Schema.optionalKey(TripleSchema),
|
|
153
|
-
data: Schema.NonEmptyArray(LineSchema),
|
|
154
|
-
showZAxis: Schema.optionalKey(Schema.Boolean),
|
|
155
|
-
});
|
|
156
|
-
/**
|
|
157
|
-
* Checks that the camera sits away from the point it looks at, with the
|
|
158
|
-
* renderer's defaults for a pose that is left out. A camera on its target has
|
|
159
|
-
* no direction to look in, and the renderer measures its zoom and its distance
|
|
160
|
-
* limits from that distance, which is then zero.
|
|
161
|
-
*/
|
|
162
|
-
function hasCameraDistance({ cameraPosition = DEFAULT_CAMERA_POSITION, cameraTarget = DEFAULT_CAMERA_TARGET, }) {
|
|
163
|
-
const [x, y, z] = cameraPosition;
|
|
164
|
-
const [targetX, targetY, targetZ] = cameraTarget;
|
|
165
|
-
return x !== targetX || y !== targetY || z !== targetZ;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Props of `LineEquation`: lines in three dimensions, as the question bank uses
|
|
169
|
-
* them. Lessons also draw circle shapes (`kind` set to `circle-arc`,
|
|
170
|
-
* `circle-chord`, `circle-outline`, `circle-radius`, or `circle-segment`); no
|
|
171
|
-
* item uses one, so they are not part of this contract.
|
|
172
|
-
*/
|
|
173
|
-
export const LineEquationPropsSchema = LineEquationFieldsSchema.check(Schema.makeFilter(hasCameraDistance, {
|
|
174
|
-
message: "Expected a camera that sits away from the point it looks at.",
|
|
175
|
-
}));
|
|
176
|
-
/** The exact sine, cosine, and tangent of the angle, each as LaTeX, such as `5/13`. */
|
|
177
|
-
const TrigValuesSchema = Schema.Struct({
|
|
178
|
-
cos: Schema.optionalKey(LatexSchema),
|
|
179
|
-
sin: Schema.optionalKey(LatexSchema),
|
|
180
|
-
tan: Schema.optionalKey(LatexSchema),
|
|
181
|
-
});
|
|
182
|
-
/** Props of `UnitCircle`: the angle in degrees and its exact values in LaTeX. */
|
|
183
|
-
export const UnitCirclePropsSchema = Schema.Struct({
|
|
184
|
-
...CardFields,
|
|
185
|
-
angle: Schema.optionalKey(Schema.Finite),
|
|
186
|
-
trigValues: Schema.optionalKey(TrigValuesSchema),
|
|
187
|
-
});
|
|
188
|
-
/** Props of `Mermaid`: a diagram source with a plain title and description. */
|
|
189
|
-
export const MermaidPropsSchema = Schema.Struct({
|
|
190
|
-
chart: Schema.String.check(Schema.isNonEmpty()),
|
|
191
|
-
description: PlainTextSchema,
|
|
192
|
-
title: PlainTextSchema,
|
|
193
|
-
});
|
|
194
16
|
/**
|
|
195
17
|
* What every figure carries besides its props. The text alternative is
|
|
196
18
|
* required, because a figure must say in words what it shows, and the caption
|
|
@@ -201,42 +23,17 @@ const FigureFields = {
|
|
|
201
23
|
caption: Schema.NullOr(RichTextSchema),
|
|
202
24
|
};
|
|
203
25
|
/**
|
|
204
|
-
* The attributes of a figure node:
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
component: Schema.Literal("MathVisual"),
|
|
216
|
-
props: MathVisualPropsSchema,
|
|
217
|
-
}),
|
|
218
|
-
Schema.Struct({
|
|
219
|
-
...FigureFields,
|
|
220
|
-
component: Schema.Literal("NumberLine"),
|
|
221
|
-
props: NumberLinePropsSchema,
|
|
222
|
-
}),
|
|
223
|
-
Schema.Struct({
|
|
224
|
-
...FigureFields,
|
|
225
|
-
component: Schema.Literal("LineEquation"),
|
|
226
|
-
props: LineEquationPropsSchema,
|
|
227
|
-
}),
|
|
228
|
-
Schema.Struct({
|
|
229
|
-
...FigureFields,
|
|
230
|
-
component: Schema.Literal("Mermaid"),
|
|
231
|
-
props: MermaidPropsSchema,
|
|
232
|
-
}),
|
|
233
|
-
Schema.Struct({
|
|
234
|
-
...FigureFields,
|
|
235
|
-
component: Schema.Literal("UnitCircle"),
|
|
236
|
-
props: UnitCirclePropsSchema,
|
|
237
|
-
}),
|
|
238
|
-
]);
|
|
239
|
-
/** A figure block: an interactive visual with a required text alternative. */
|
|
26
|
+
* The attributes of a figure node: any figure component of the Visual
|
|
27
|
+
* Catalog and the props its catalog schema takes, so a figure is checked,
|
|
28
|
+
* edited, and exported through the schema of its component. The catalog is
|
|
29
|
+
* the one list of visuals: a lesson and an assessment draw the same ones.
|
|
30
|
+
*/
|
|
31
|
+
export const FigureAttrsSchema = Schema.Union(Arr.map(FIGURE_NAMES, (component) => Schema.Struct({
|
|
32
|
+
...FigureFields,
|
|
33
|
+
component: Schema.Literal(component),
|
|
34
|
+
props: assessmentVisuals[component].props,
|
|
35
|
+
})));
|
|
36
|
+
/** A figure block: a catalog visual with a required text alternative. */
|
|
240
37
|
export const FigureNodeSchema = Schema.Struct({
|
|
241
38
|
attrs: FigureAttrsSchema,
|
|
242
39
|
type: Schema.Literal("figure"),
|