@nakafa/aksara-contracts 8.14.0 → 8.15.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.
@@ -0,0 +1,410 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /**
4
+ * Mendelian and human inheritance labs covering monohybrid crosses, dihybrid
5
+ * 9:3:3:1 grids, and human blood-group and X-linked pedigree analysis.
6
+ */
7
+ export declare function mendelianVisuals<E>(rich: RichSlot<E>): {
8
+ DihybridCrossLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
9
+ readonly description: RichSlot<E>;
10
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
11
+ readonly marks?: readonly [{
12
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
13
+ } | {
14
+ readonly attrs: {
15
+ readonly href: string;
16
+ };
17
+ readonly type: "link";
18
+ } | {
19
+ readonly attrs: {
20
+ readonly variant: "success" | "warning" | null;
21
+ };
22
+ readonly type: "highlight";
23
+ }, ...({
24
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
25
+ } | {
26
+ readonly attrs: {
27
+ readonly href: string;
28
+ };
29
+ readonly type: "link";
30
+ } | {
31
+ readonly attrs: {
32
+ readonly variant: "success" | "warning" | null;
33
+ };
34
+ readonly type: "highlight";
35
+ })[]];
36
+ readonly text: string;
37
+ readonly type: "text";
38
+ } | {
39
+ readonly attrs: {
40
+ readonly latex: string;
41
+ };
42
+ readonly marks?: readonly [{
43
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
44
+ } | {
45
+ readonly attrs: {
46
+ readonly href: string;
47
+ };
48
+ readonly type: "link";
49
+ } | {
50
+ readonly attrs: {
51
+ readonly variant: "success" | "warning" | null;
52
+ };
53
+ readonly type: "highlight";
54
+ }, ...({
55
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
56
+ } | {
57
+ readonly attrs: {
58
+ readonly href: string;
59
+ };
60
+ readonly type: "link";
61
+ } | {
62
+ readonly attrs: {
63
+ readonly variant: "success" | "warning" | null;
64
+ };
65
+ readonly type: "highlight";
66
+ })[]];
67
+ readonly type: "mathInline";
68
+ }, ...({
69
+ readonly marks?: readonly [{
70
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
71
+ } | {
72
+ readonly attrs: {
73
+ readonly href: string;
74
+ };
75
+ readonly type: "link";
76
+ } | {
77
+ readonly attrs: {
78
+ readonly variant: "success" | "warning" | null;
79
+ };
80
+ readonly type: "highlight";
81
+ }, ...({
82
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
83
+ } | {
84
+ readonly attrs: {
85
+ readonly href: string;
86
+ };
87
+ readonly type: "link";
88
+ } | {
89
+ readonly attrs: {
90
+ readonly variant: "success" | "warning" | null;
91
+ };
92
+ readonly type: "highlight";
93
+ })[]];
94
+ readonly text: string;
95
+ readonly type: "text";
96
+ } | {
97
+ readonly attrs: {
98
+ readonly latex: string;
99
+ };
100
+ readonly marks?: readonly [{
101
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
102
+ } | {
103
+ readonly attrs: {
104
+ readonly href: string;
105
+ };
106
+ readonly type: "link";
107
+ } | {
108
+ readonly attrs: {
109
+ readonly variant: "success" | "warning" | null;
110
+ };
111
+ readonly type: "highlight";
112
+ }, ...({
113
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
114
+ } | {
115
+ readonly attrs: {
116
+ readonly href: string;
117
+ };
118
+ readonly type: "link";
119
+ } | {
120
+ readonly attrs: {
121
+ readonly variant: "success" | "warning" | null;
122
+ };
123
+ readonly type: "highlight";
124
+ })[]];
125
+ readonly type: "mathInline";
126
+ })[]], E, never, never>>;
127
+ readonly title: RichSlot<E>;
128
+ readonly filters: Schema.NonEmptyArray<Schema.Literals<readonly ["all", "dominantBoth", "recombinants", "recessiveBoth"]>>;
129
+ readonly labels: Schema.Struct<{
130
+ readonly count: Schema.optionalKey<RichSlot<E>>;
131
+ readonly filter: Schema.Trimmed;
132
+ readonly filters: Schema.$Record<Schema.Literals<readonly ["all", "dominantBoth", "recombinants", "recessiveBoth"]>, Schema.optionalKey<Schema.Struct<{
133
+ readonly count: RichSlot<E>;
134
+ readonly name: Schema.Trimmed;
135
+ readonly ratio: RichSlot<E>;
136
+ }>>>;
137
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["roundYellow", "roundGreen", "wrinkledYellow", "wrinkledGreen"]>, Schema.Trimmed>;
138
+ readonly ratio: Schema.optionalKey<RichSlot<E>>;
139
+ readonly view: Schema.Trimmed;
140
+ }>;
141
+ }>, "figure">;
142
+ MonohybridCrossLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
143
+ readonly description: RichSlot<E>;
144
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
145
+ readonly marks?: readonly [{
146
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
147
+ } | {
148
+ readonly attrs: {
149
+ readonly href: string;
150
+ };
151
+ readonly type: "link";
152
+ } | {
153
+ readonly attrs: {
154
+ readonly variant: "success" | "warning" | null;
155
+ };
156
+ readonly type: "highlight";
157
+ }, ...({
158
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
159
+ } | {
160
+ readonly attrs: {
161
+ readonly href: string;
162
+ };
163
+ readonly type: "link";
164
+ } | {
165
+ readonly attrs: {
166
+ readonly variant: "success" | "warning" | null;
167
+ };
168
+ readonly type: "highlight";
169
+ })[]];
170
+ readonly text: string;
171
+ readonly type: "text";
172
+ } | {
173
+ readonly attrs: {
174
+ readonly latex: string;
175
+ };
176
+ readonly marks?: readonly [{
177
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
178
+ } | {
179
+ readonly attrs: {
180
+ readonly href: string;
181
+ };
182
+ readonly type: "link";
183
+ } | {
184
+ readonly attrs: {
185
+ readonly variant: "success" | "warning" | null;
186
+ };
187
+ readonly type: "highlight";
188
+ }, ...({
189
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
190
+ } | {
191
+ readonly attrs: {
192
+ readonly href: string;
193
+ };
194
+ readonly type: "link";
195
+ } | {
196
+ readonly attrs: {
197
+ readonly variant: "success" | "warning" | null;
198
+ };
199
+ readonly type: "highlight";
200
+ })[]];
201
+ readonly type: "mathInline";
202
+ }, ...({
203
+ readonly marks?: readonly [{
204
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
205
+ } | {
206
+ readonly attrs: {
207
+ readonly href: string;
208
+ };
209
+ readonly type: "link";
210
+ } | {
211
+ readonly attrs: {
212
+ readonly variant: "success" | "warning" | null;
213
+ };
214
+ readonly type: "highlight";
215
+ }, ...({
216
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
217
+ } | {
218
+ readonly attrs: {
219
+ readonly href: string;
220
+ };
221
+ readonly type: "link";
222
+ } | {
223
+ readonly attrs: {
224
+ readonly variant: "success" | "warning" | null;
225
+ };
226
+ readonly type: "highlight";
227
+ })[]];
228
+ readonly text: string;
229
+ readonly type: "text";
230
+ } | {
231
+ readonly attrs: {
232
+ readonly latex: string;
233
+ };
234
+ readonly marks?: readonly [{
235
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
236
+ } | {
237
+ readonly attrs: {
238
+ readonly href: string;
239
+ };
240
+ readonly type: "link";
241
+ } | {
242
+ readonly attrs: {
243
+ readonly variant: "success" | "warning" | null;
244
+ };
245
+ readonly type: "highlight";
246
+ }, ...({
247
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
248
+ } | {
249
+ readonly attrs: {
250
+ readonly href: string;
251
+ };
252
+ readonly type: "link";
253
+ } | {
254
+ readonly attrs: {
255
+ readonly variant: "success" | "warning" | null;
256
+ };
257
+ readonly type: "highlight";
258
+ })[]];
259
+ readonly type: "mathInline";
260
+ })[]], E, never, never>>;
261
+ readonly title: RichSlot<E>;
262
+ readonly crosses: Schema.NonEmptyArray<Schema.Literals<readonly ["pureF1", "heteroF2", "testCross"]>>;
263
+ readonly labels: Schema.Struct<{
264
+ readonly cross: Schema.Trimmed;
265
+ readonly crosses: Schema.$Record<Schema.Literals<readonly ["pureF1", "heteroF2", "testCross"]>, Schema.optionalKey<Schema.Struct<{
266
+ readonly genotypeRatio: RichSlot<E>;
267
+ readonly name: Schema.Trimmed;
268
+ readonly phenotypeRatio: RichSlot<E>;
269
+ }>>>;
270
+ readonly genotypeRatio: Schema.optionalKey<RichSlot<E>>;
271
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["parentA", "parentB", "gamete", "tallPea", "dwarfPea"]>, Schema.Trimmed>;
272
+ readonly phenotypeRatio: Schema.optionalKey<RichSlot<E>>;
273
+ readonly view: Schema.Trimmed;
274
+ }>;
275
+ }>, "figure">;
276
+ PedigreeSexLinkedLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
277
+ readonly description: RichSlot<E>;
278
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
279
+ readonly marks?: readonly [{
280
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
281
+ } | {
282
+ readonly attrs: {
283
+ readonly href: string;
284
+ };
285
+ readonly type: "link";
286
+ } | {
287
+ readonly attrs: {
288
+ readonly variant: "success" | "warning" | null;
289
+ };
290
+ readonly type: "highlight";
291
+ }, ...({
292
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
293
+ } | {
294
+ readonly attrs: {
295
+ readonly href: string;
296
+ };
297
+ readonly type: "link";
298
+ } | {
299
+ readonly attrs: {
300
+ readonly variant: "success" | "warning" | null;
301
+ };
302
+ readonly type: "highlight";
303
+ })[]];
304
+ readonly text: string;
305
+ readonly type: "text";
306
+ } | {
307
+ readonly attrs: {
308
+ readonly latex: string;
309
+ };
310
+ readonly marks?: readonly [{
311
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
312
+ } | {
313
+ readonly attrs: {
314
+ readonly href: string;
315
+ };
316
+ readonly type: "link";
317
+ } | {
318
+ readonly attrs: {
319
+ readonly variant: "success" | "warning" | null;
320
+ };
321
+ readonly type: "highlight";
322
+ }, ...({
323
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
324
+ } | {
325
+ readonly attrs: {
326
+ readonly href: string;
327
+ };
328
+ readonly type: "link";
329
+ } | {
330
+ readonly attrs: {
331
+ readonly variant: "success" | "warning" | null;
332
+ };
333
+ readonly type: "highlight";
334
+ })[]];
335
+ readonly type: "mathInline";
336
+ }, ...({
337
+ readonly marks?: readonly [{
338
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
339
+ } | {
340
+ readonly attrs: {
341
+ readonly href: string;
342
+ };
343
+ readonly type: "link";
344
+ } | {
345
+ readonly attrs: {
346
+ readonly variant: "success" | "warning" | null;
347
+ };
348
+ readonly type: "highlight";
349
+ }, ...({
350
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
351
+ } | {
352
+ readonly attrs: {
353
+ readonly href: string;
354
+ };
355
+ readonly type: "link";
356
+ } | {
357
+ readonly attrs: {
358
+ readonly variant: "success" | "warning" | null;
359
+ };
360
+ readonly type: "highlight";
361
+ })[]];
362
+ readonly text: string;
363
+ readonly type: "text";
364
+ } | {
365
+ readonly attrs: {
366
+ readonly latex: string;
367
+ };
368
+ readonly marks?: readonly [{
369
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
370
+ } | {
371
+ readonly attrs: {
372
+ readonly href: string;
373
+ };
374
+ readonly type: "link";
375
+ } | {
376
+ readonly attrs: {
377
+ readonly variant: "success" | "warning" | null;
378
+ };
379
+ readonly type: "highlight";
380
+ }, ...({
381
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
382
+ } | {
383
+ readonly attrs: {
384
+ readonly href: string;
385
+ };
386
+ readonly type: "link";
387
+ } | {
388
+ readonly attrs: {
389
+ readonly variant: "success" | "warning" | null;
390
+ };
391
+ readonly type: "highlight";
392
+ })[]];
393
+ readonly type: "mathInline";
394
+ })[]], E, never, never>>;
395
+ readonly title: RichSlot<E>;
396
+ readonly labels: Schema.Struct<{
397
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["male", "female", "carrier", "affected", "xChromosome", "yChromosome"]>, Schema.Trimmed>;
398
+ readonly pattern: Schema.Trimmed;
399
+ readonly patterns: Schema.$Record<Schema.Literals<readonly ["aboBlood", "sexDetermination", "xLinked"]>, Schema.optionalKey<Schema.Struct<{
400
+ readonly name: Schema.Trimmed;
401
+ readonly risk: RichSlot<E>;
402
+ readonly rule: RichSlot<E>;
403
+ }>>>;
404
+ readonly risk: Schema.optionalKey<RichSlot<E>>;
405
+ readonly rule: Schema.optionalKey<RichSlot<E>>;
406
+ readonly view: Schema.Trimmed;
407
+ }>;
408
+ readonly patterns: Schema.NonEmptyArray<Schema.Literals<readonly ["aboBlood", "sexDetermination", "xLinked"]>>;
409
+ }>, "figure">;
410
+ };
@@ -0,0 +1,107 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ const MONOHYBRID_CROSSES = ["pureF1", "heteroF2", "testCross"];
5
+ const DIHYBRID_VIEWS = [
6
+ "all",
7
+ "dominantBoth",
8
+ "recombinants",
9
+ "recessiveBoth",
10
+ ];
11
+ const HUMAN_PATTERNS = ["aboBlood", "sexDetermination", "xLinked"];
12
+ /**
13
+ * Props of `MonohybridCrossLab`: a 3D interactive Punnett board and pea-plant
14
+ * offspring row for Mendel's monohybrid crosses (TT x tt, Tt x Tt, Tt x tt)
15
+ * illustrating dominance and the Law of Segregation. Genotype and phenotype
16
+ * ratio readouts are optional answer state.
17
+ */
18
+ function monohybridCrossLab(rich) {
19
+ return figure(Schema.Struct({
20
+ ...cardFields(rich),
21
+ crosses: Schema.NonEmptyArray(Schema.Literals(MONOHYBRID_CROSSES)).check(Schema.isUnique()),
22
+ labels: Schema.Struct({
23
+ cross: TextSchema,
24
+ crosses: byPickedIds(MONOHYBRID_CROSSES, Schema.Struct({
25
+ genotypeRatio: rich,
26
+ name: TextSchema,
27
+ phenotypeRatio: rich,
28
+ })),
29
+ genotypeRatio: Schema.optionalKey(rich),
30
+ parts: byIds(["parentA", "parentB", "gamete", "tallPea", "dwarfPea"], TextSchema),
31
+ phenotypeRatio: Schema.optionalKey(rich),
32
+ view: TextSchema,
33
+ }),
34
+ }).check(Schema.makeFilter(({ crosses, labels }) => namesEach(crosses, labels.crosses), {
35
+ message: "Expected a name, genotype ratio, and phenotype ratio for every monohybrid cross shown, and no other.",
36
+ })), answerAt(["labels", "genotypeRatio"], ["labels", "phenotypeRatio"]));
37
+ }
38
+ /**
39
+ * Props of `DihybridCrossLab`: a 3D 4x4 Punnett cube of round/wrinkled and
40
+ * yellow/green pea seeds from RrYy x RrYy, highlighting parental and
41
+ * recombinant phenotypes in the 9:3:3:1 ratio. Ratio and count readouts are
42
+ * optional answer state.
43
+ */
44
+ function dihybridCrossLab(rich) {
45
+ return figure(Schema.Struct({
46
+ ...cardFields(rich),
47
+ filters: Schema.NonEmptyArray(Schema.Literals(DIHYBRID_VIEWS)).check(Schema.isUnique()),
48
+ labels: Schema.Struct({
49
+ count: Schema.optionalKey(rich),
50
+ filter: TextSchema,
51
+ filters: byPickedIds(DIHYBRID_VIEWS, Schema.Struct({
52
+ count: rich,
53
+ name: TextSchema,
54
+ ratio: rich,
55
+ })),
56
+ parts: byIds(["roundYellow", "roundGreen", "wrinkledYellow", "wrinkledGreen"], TextSchema),
57
+ ratio: Schema.optionalKey(rich),
58
+ view: TextSchema,
59
+ }),
60
+ }).check(Schema.makeFilter(({ filters, labels }) => namesEach(filters, labels.filters), {
61
+ message: "Expected a name, count, and ratio for every dihybrid filter shown, and no other.",
62
+ })), answerAt(["labels", "count"], ["labels", "ratio"]));
63
+ }
64
+ /**
65
+ * Props of `PedigreeSexLinkedLab`: a 3D human inheritance and family pedigree
66
+ * explorer contrasting ABO blood-group codominance, XX/XY sex determination,
67
+ * and X-linked recessive inheritance across three generations. Carrier risk
68
+ * and inheritance pattern readouts are optional answer state.
69
+ */
70
+ function pedigreeSexLinkedLab(rich) {
71
+ return figure(Schema.Struct({
72
+ ...cardFields(rich),
73
+ labels: Schema.Struct({
74
+ parts: byIds([
75
+ "male",
76
+ "female",
77
+ "carrier",
78
+ "affected",
79
+ "xChromosome",
80
+ "yChromosome",
81
+ ], TextSchema),
82
+ pattern: TextSchema,
83
+ patterns: byPickedIds(HUMAN_PATTERNS, Schema.Struct({
84
+ name: TextSchema,
85
+ risk: rich,
86
+ rule: rich,
87
+ })),
88
+ risk: Schema.optionalKey(rich),
89
+ rule: Schema.optionalKey(rich),
90
+ view: TextSchema,
91
+ }),
92
+ patterns: Schema.NonEmptyArray(Schema.Literals(HUMAN_PATTERNS)).check(Schema.isUnique()),
93
+ }).check(Schema.makeFilter(({ labels, patterns }) => namesEach(patterns, labels.patterns), {
94
+ message: "Expected a name, rule, and risk note for every human inheritance pattern shown, and no other.",
95
+ })), answerAt(["labels", "risk"], ["labels", "rule"]));
96
+ }
97
+ /**
98
+ * Mendelian and human inheritance labs covering monohybrid crosses, dihybrid
99
+ * 9:3:3:1 grids, and human blood-group and X-linked pedigree analysis.
100
+ */
101
+ export function mendelianVisuals(rich) {
102
+ return {
103
+ DihybridCrossLab: dihybridCrossLab(rich),
104
+ MonohybridCrossLab: monohybridCrossLab(rich),
105
+ PedigreeSexLinkedLab: pedigreeSexLinkedLab(rich),
106
+ };
107
+ }