@nakafa/aksara-contracts 0.50.0 → 1.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/LICENSE +207 -152
- package/README.md +3 -0
- package/dist/artifact/integrity.d.ts +33 -8
- package/dist/artifact/integrity.js +19 -17
- package/dist/artifact/limits.d.ts +13 -7
- package/dist/artifact/limits.js +7 -15
- package/dist/artifact/source.d.ts +10 -4
- package/dist/artifact/source.js +4 -8
- package/dist/artifact/spec.d.ts +54 -22
- package/dist/artifact/spec.js +7 -8
- package/dist/artifact/verify.d.ts +11 -5
- package/dist/assessment/hash.d.ts +3 -1
- package/dist/assessment/paper.d.ts +3 -1
- package/dist/content.d.ts +37 -11
- package/dist/content.js +7 -21
- package/dist/errors.d.ts +3 -1
- package/dist/graph/family.d.ts +6 -2
- package/dist/graph/identity.d.ts +3 -1
- package/dist/hash/digest.d.ts +10 -0
- package/dist/hash/digest.js +40 -0
- package/dist/hash/stream.d.ts +12 -0
- package/dist/hash/stream.js +27 -0
- package/dist/hash/text.d.ts +3 -1
- package/dist/hash/text.js +2 -15
- package/dist/limits.d.ts +2 -2
- package/dist/limits.js +2 -2
- package/dist/preview/auth.d.ts +4 -2
- package/dist/preview/auth.js +26 -12
- package/dist/program/snapshot/digest.d.ts +3 -1
- package/dist/program/snapshot/digest.js +14 -22
- package/dist/program/snapshot/hash.d.ts +6 -2
- package/dist/program/snapshot/hash.js +10 -21
- package/dist/projection/digest.d.ts +11 -9
- package/dist/projection/digest.js +23 -32
- package/dist/projection/hash.d.ts +222 -2
- package/dist/projection/hash.js +6 -8
- package/dist/projection/verify.d.ts +16 -6
- package/dist/question/item.d.ts +3 -1
- package/dist/question/item.js +3 -1
- package/dist/quran/notes.d.ts +3 -1
- package/dist/quran/provenance.d.ts +6 -2
- package/dist/quran/provenance.js +8 -15
- package/dist/quran/snapshot/digest.d.ts +9 -5
- package/dist/quran/snapshot/digest.js +33 -41
- package/dist/quran/snapshot/hash.d.ts +3 -1
- package/dist/quran/snapshot/hash.js +9 -15
- package/dist/quran/snapshot/row/hash.d.ts +3 -1
- package/dist/quran/snapshot/row/hash.js +2 -8
- package/dist/release/digest.d.ts +10 -8
- package/dist/release/digest.js +22 -31
- package/dist/release/hash.d.ts +3 -1
- package/dist/release/hash.js +3 -8
- package/dist/release/items.d.ts +25 -9
- package/dist/release/items.js +12 -3
- package/dist/release/policy.d.ts +3 -1
- package/dist/release/result/digest.d.ts +23 -13
- package/dist/release/result/digest.js +20 -29
- package/dist/release/rollback/digest.d.ts +16 -10
- package/dist/release/rollback/digest.js +25 -32
- package/dist/release/rollback/spec.d.ts +102 -24
- package/dist/release/route/digest.d.ts +10 -8
- package/dist/release/route/digest.js +22 -31
- package/dist/release/route/verify.d.ts +16 -6
- package/dist/release/route/verify.js +8 -2
- package/dist/release/snapshot/evidence/requirement.d.ts +3 -1
- package/dist/release/snapshot/evidence/tryout.d.ts +1 -1
- package/dist/release/snapshot/evidence/tryout.js +1 -1
- package/dist/release/snapshot/evidence.d.ts +1 -1
- package/dist/release/snapshot/verify.d.ts +19 -7
- package/dist/release/snapshot/verify.js +20 -18
- package/dist/release/verify.d.ts +9 -3
- package/dist/renderer/compatibility.d.ts +6 -2
- package/dist/renderer/compatibility.js +3 -1
- package/dist/renderer/contract.d.ts +9 -3
- package/dist/renderer/contract.js +3 -1
- package/dist/runtime/error.d.ts +3 -1
- package/dist/runtime/protected/spec.d.ts +61 -16
- package/dist/runtime/protected/verify.d.ts +11 -5
- package/dist/runtime/spec.d.ts +44 -12
- package/dist/runtime/verify.d.ts +22 -10
- package/dist/runtime/verify.js +2 -1
- package/dist/signature/key.d.ts +21 -0
- package/dist/signature/key.js +104 -0
- package/dist/signature/spec.d.ts +18 -6
- package/dist/signature/spec.js +16 -4
- package/dist/transport/batch.d.ts +34 -8
- package/dist/transport/group.d.ts +51 -12
- package/dist/transport/request.d.ts +826 -764
- package/dist/transport/response.d.ts +148 -58
- package/dist/tree.d.ts +52 -0
- package/dist/tree.js +162 -0
- package/dist/tryout/canonical.d.ts +11 -1
- package/dist/tryout/canonical.js +6 -10
- package/dist/tryout/closure/accounting.d.ts +3 -1
- package/dist/tryout/digest.d.ts +12 -6
- package/dist/tryout/digest.js +21 -14
- package/dist/tryout/hash/catalog.d.ts +228 -3
- package/dist/tryout/hash/catalog.js +5 -7
- package/dist/tryout/hash/content.d.ts +113 -2
- package/dist/tryout/hash/content.js +10 -8
- package/dist/tryout/hash/placement.d.ts +236 -5
- package/dist/tryout/hash/placement.js +7 -8
- package/dist/tryout/runtime/hash.d.ts +3 -1
- package/dist/tryout/runtime/hash.js +3 -1
- package/dist/tryout/runtime/source.d.ts +3 -1
- package/dist/tryout/runtime/verify.d.ts +13 -5
- package/dist/tryout/runtime/verify.js +1 -1
- package/dist/tryout/scoring.d.ts +3 -1
- package/dist/tryout/snapshot/hash.d.ts +45 -4
- package/dist/tryout/snapshot/hash.js +9 -7
- package/package.json +22 -2
package/dist/tryout/digest.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { Effect, Schema, Stream } from "effect";
|
|
3
|
-
import {
|
|
2
|
+
import { DigestStream } from "#contracts/hash/stream";
|
|
4
3
|
import { compareCodeUnits } from "#contracts/text/order";
|
|
5
4
|
/** A snapshot stream is duplicated, unsorted, or tampered. */
|
|
6
5
|
export class TryoutDigestError extends Schema.TaggedError()("TryoutDigestError", {
|
|
@@ -10,25 +9,27 @@ export class TryoutDigestError extends Schema.TaggedError()("TryoutDigestError",
|
|
|
10
9
|
}
|
|
11
10
|
/** Keeps one stream digest and previous identity private to its replay. */
|
|
12
11
|
class TryoutDigestState {
|
|
13
|
-
#
|
|
12
|
+
#stream = new DigestStream();
|
|
14
13
|
count = 0;
|
|
15
14
|
previous;
|
|
16
|
-
/**
|
|
15
|
+
/** Starts one fresh domain-separated digest stream. */
|
|
17
16
|
constructor(domain) {
|
|
18
|
-
this.#
|
|
17
|
+
this.#stream.add(domain);
|
|
18
|
+
this.#stream.add("\n");
|
|
19
19
|
}
|
|
20
20
|
/** Adds one verified canonical record to the digest. */
|
|
21
21
|
update(canonical, identity) {
|
|
22
|
-
this.#
|
|
22
|
+
this.#stream.add(canonical);
|
|
23
|
+
this.#stream.add("\n");
|
|
23
24
|
this.count += 1;
|
|
24
25
|
this.previous = identity;
|
|
25
26
|
}
|
|
26
|
-
/**
|
|
27
|
+
/** Digests the complete stream once and returns its branded value. */
|
|
27
28
|
digest() {
|
|
28
|
-
return
|
|
29
|
+
return this.#stream.digest();
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
/** Verifies and adds
|
|
32
|
+
/** Verifies one immutable record and adds its canonical bytes to the digest stream. */
|
|
32
33
|
function updateDigest(state, record, identity, expectedHash, canonical) {
|
|
33
34
|
if (record.rowHash !== expectedHash) {
|
|
34
35
|
return Effect.fail(new TryoutDigestError({ code: "integrity", identity }));
|
|
@@ -40,11 +41,17 @@ function updateDigest(state, record, identity, expectedHash, canonical) {
|
|
|
40
41
|
state.update(canonical, identity);
|
|
41
42
|
return Effect.succeed(state);
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Digests one canonically ordered record stream. The canonical bytes are held
|
|
46
|
+
* until one Web Crypto digest runs over them, because Web Crypto has no
|
|
47
|
+
* incremental form.
|
|
48
|
+
*/
|
|
44
49
|
export const digestTryoutRecords = Effect.fn("AksaraContracts.digestTryoutRecords")(function* (input) {
|
|
45
|
-
const state = yield* input.records.pipe(Stream.runFoldEffect(() => new TryoutDigestState(input.domain), (current, record) => {
|
|
50
|
+
const state = yield* input.records.pipe(Stream.runFoldEffect(() => new TryoutDigestState(input.domain), (current, record) => Effect.gen(function* () {
|
|
46
51
|
const canonical = input.canonicalize(record.row);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
const expectedHash = yield* input.rowHash(record.row);
|
|
53
|
+
return yield* updateDigest(current, record, input.identity(record.row), expectedHash, `${canonical}\0${record.rowHash}`);
|
|
54
|
+
})));
|
|
55
|
+
const digest = yield* state.digest();
|
|
56
|
+
return { count: state.count, digest };
|
|
50
57
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, type Stream } from "effect";
|
|
2
|
-
import { type
|
|
2
|
+
import { type TryoutCatalogRow } from "#contracts/tryout/catalog";
|
|
3
3
|
/** Compares localized hierarchy rows in their canonical digest order. */
|
|
4
4
|
export declare function compareTryoutCatalog(left: TryoutCatalogRow, right: TryoutCatalogRow): -1 | 0 | 1;
|
|
5
5
|
/** Builds one locale-neutral hierarchy identity for closure checks. */
|
|
@@ -17,7 +17,232 @@ export declare function canonicalizeTryoutCatalogFacts(row: TryoutCatalogRow): s
|
|
|
17
17
|
/** Serializes one current hierarchy row in stable field order. */
|
|
18
18
|
export declare function canonicalizeTryoutCatalog(row: TryoutCatalogRow): string;
|
|
19
19
|
/** Creates one authenticated current hierarchy record. */
|
|
20
|
-
export declare
|
|
20
|
+
export declare const makeTryoutCatalogRecord: (row: {
|
|
21
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
22
|
+
readonly description?: string | undefined;
|
|
23
|
+
readonly graph: {
|
|
24
|
+
readonly alignmentId: string;
|
|
25
|
+
readonly assetId: string;
|
|
26
|
+
readonly conceptId: string;
|
|
27
|
+
readonly learningObjectId: string;
|
|
28
|
+
readonly lensId: string;
|
|
29
|
+
};
|
|
30
|
+
readonly sourceRevision: string;
|
|
31
|
+
readonly title: string;
|
|
32
|
+
readonly countryKey: string;
|
|
33
|
+
readonly examKey: string;
|
|
34
|
+
readonly kind: "section";
|
|
35
|
+
readonly marks?: {
|
|
36
|
+
readonly blank: number;
|
|
37
|
+
readonly correct: number;
|
|
38
|
+
readonly wrong: number;
|
|
39
|
+
};
|
|
40
|
+
readonly order: number;
|
|
41
|
+
readonly publicPath?: (string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">) | undefined;
|
|
42
|
+
readonly questionCount: number;
|
|
43
|
+
readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
44
|
+
readonly sectionKey: string;
|
|
45
|
+
readonly setKey: string;
|
|
46
|
+
readonly timeLimitSeconds: number;
|
|
47
|
+
readonly trackKey: string;
|
|
48
|
+
readonly visibility: "internal-entry" | "visible";
|
|
49
|
+
} | {
|
|
50
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
51
|
+
readonly description?: string | undefined;
|
|
52
|
+
readonly graph: {
|
|
53
|
+
readonly alignmentId: string;
|
|
54
|
+
readonly assetId: string;
|
|
55
|
+
readonly conceptId: string;
|
|
56
|
+
readonly learningObjectId: string;
|
|
57
|
+
readonly lensId: string;
|
|
58
|
+
};
|
|
59
|
+
readonly sourceRevision: string;
|
|
60
|
+
readonly title: string;
|
|
61
|
+
readonly countryKey: string;
|
|
62
|
+
readonly examKey: string;
|
|
63
|
+
readonly internalEntrySectionKey?: string | undefined;
|
|
64
|
+
readonly kind: "set";
|
|
65
|
+
readonly order: number;
|
|
66
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
67
|
+
readonly questionCount: number;
|
|
68
|
+
readonly scoringStrategy: "irt" | "penalized" | "raw";
|
|
69
|
+
readonly sectionCount: number;
|
|
70
|
+
readonly setKey: string;
|
|
71
|
+
readonly trackKey: string;
|
|
72
|
+
readonly visibleSectionCount: number;
|
|
73
|
+
} | {
|
|
74
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
75
|
+
readonly description?: string | undefined;
|
|
76
|
+
readonly graph: {
|
|
77
|
+
readonly alignmentId: string;
|
|
78
|
+
readonly assetId: string;
|
|
79
|
+
readonly conceptId: string;
|
|
80
|
+
readonly learningObjectId: string;
|
|
81
|
+
readonly lensId: string;
|
|
82
|
+
};
|
|
83
|
+
readonly sourceRevision: string;
|
|
84
|
+
readonly title: string;
|
|
85
|
+
readonly countryKey: string;
|
|
86
|
+
readonly examKey: string;
|
|
87
|
+
readonly kind: "track";
|
|
88
|
+
readonly order: number;
|
|
89
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
90
|
+
readonly questionCount: number;
|
|
91
|
+
readonly sectionCount: number;
|
|
92
|
+
readonly setCount: number;
|
|
93
|
+
readonly trackKey: string;
|
|
94
|
+
readonly trackKind: "institution" | "subject" | "year";
|
|
95
|
+
readonly visibleSectionCount: number;
|
|
96
|
+
} | {
|
|
97
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
98
|
+
readonly description?: string | undefined;
|
|
99
|
+
readonly graph: {
|
|
100
|
+
readonly alignmentId: string;
|
|
101
|
+
readonly assetId: string;
|
|
102
|
+
readonly conceptId: string;
|
|
103
|
+
readonly learningObjectId: string;
|
|
104
|
+
readonly lensId: string;
|
|
105
|
+
};
|
|
106
|
+
readonly sourceRevision: string;
|
|
107
|
+
readonly title: string;
|
|
108
|
+
readonly countryKey: string;
|
|
109
|
+
readonly examKey: string;
|
|
110
|
+
readonly kind: "exam";
|
|
111
|
+
readonly order: number;
|
|
112
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
113
|
+
readonly scoringStrategy: "irt" | "penalized" | "raw";
|
|
114
|
+
} | {
|
|
115
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
116
|
+
readonly description?: string | undefined;
|
|
117
|
+
readonly graph: {
|
|
118
|
+
readonly alignmentId: string;
|
|
119
|
+
readonly assetId: string;
|
|
120
|
+
readonly conceptId: string;
|
|
121
|
+
readonly learningObjectId: string;
|
|
122
|
+
readonly lensId: string;
|
|
123
|
+
};
|
|
124
|
+
readonly sourceRevision: string;
|
|
125
|
+
readonly title: string;
|
|
126
|
+
readonly countryCode: string;
|
|
127
|
+
readonly countryKey: string;
|
|
128
|
+
readonly kind: "country";
|
|
129
|
+
readonly order: number;
|
|
130
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
131
|
+
}) => Effect.Effect<{
|
|
132
|
+
readonly row: {
|
|
133
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
134
|
+
readonly description?: string | undefined;
|
|
135
|
+
readonly graph: {
|
|
136
|
+
readonly alignmentId: string;
|
|
137
|
+
readonly assetId: string;
|
|
138
|
+
readonly conceptId: string;
|
|
139
|
+
readonly learningObjectId: string;
|
|
140
|
+
readonly lensId: string;
|
|
141
|
+
};
|
|
142
|
+
readonly sourceRevision: string;
|
|
143
|
+
readonly title: string;
|
|
144
|
+
readonly countryKey: string;
|
|
145
|
+
readonly examKey: string;
|
|
146
|
+
readonly kind: "section";
|
|
147
|
+
readonly marks?: {
|
|
148
|
+
readonly blank: number;
|
|
149
|
+
readonly correct: number;
|
|
150
|
+
readonly wrong: number;
|
|
151
|
+
};
|
|
152
|
+
readonly order: number;
|
|
153
|
+
readonly publicPath?: (string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">) | undefined;
|
|
154
|
+
readonly questionCount: number;
|
|
155
|
+
readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
156
|
+
readonly sectionKey: string;
|
|
157
|
+
readonly setKey: string;
|
|
158
|
+
readonly timeLimitSeconds: number;
|
|
159
|
+
readonly trackKey: string;
|
|
160
|
+
readonly visibility: "internal-entry" | "visible";
|
|
161
|
+
} | {
|
|
162
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
163
|
+
readonly description?: string | undefined;
|
|
164
|
+
readonly graph: {
|
|
165
|
+
readonly alignmentId: string;
|
|
166
|
+
readonly assetId: string;
|
|
167
|
+
readonly conceptId: string;
|
|
168
|
+
readonly learningObjectId: string;
|
|
169
|
+
readonly lensId: string;
|
|
170
|
+
};
|
|
171
|
+
readonly sourceRevision: string;
|
|
172
|
+
readonly title: string;
|
|
173
|
+
readonly countryKey: string;
|
|
174
|
+
readonly examKey: string;
|
|
175
|
+
readonly internalEntrySectionKey?: string | undefined;
|
|
176
|
+
readonly kind: "set";
|
|
177
|
+
readonly order: number;
|
|
178
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
179
|
+
readonly questionCount: number;
|
|
180
|
+
readonly scoringStrategy: "irt" | "penalized" | "raw";
|
|
181
|
+
readonly sectionCount: number;
|
|
182
|
+
readonly setKey: string;
|
|
183
|
+
readonly trackKey: string;
|
|
184
|
+
readonly visibleSectionCount: number;
|
|
185
|
+
} | {
|
|
186
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
187
|
+
readonly description?: string | undefined;
|
|
188
|
+
readonly graph: {
|
|
189
|
+
readonly alignmentId: string;
|
|
190
|
+
readonly assetId: string;
|
|
191
|
+
readonly conceptId: string;
|
|
192
|
+
readonly learningObjectId: string;
|
|
193
|
+
readonly lensId: string;
|
|
194
|
+
};
|
|
195
|
+
readonly sourceRevision: string;
|
|
196
|
+
readonly title: string;
|
|
197
|
+
readonly countryKey: string;
|
|
198
|
+
readonly examKey: string;
|
|
199
|
+
readonly kind: "track";
|
|
200
|
+
readonly order: number;
|
|
201
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
202
|
+
readonly questionCount: number;
|
|
203
|
+
readonly sectionCount: number;
|
|
204
|
+
readonly setCount: number;
|
|
205
|
+
readonly trackKey: string;
|
|
206
|
+
readonly trackKind: "institution" | "subject" | "year";
|
|
207
|
+
readonly visibleSectionCount: number;
|
|
208
|
+
} | {
|
|
209
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
210
|
+
readonly description?: string | undefined;
|
|
211
|
+
readonly graph: {
|
|
212
|
+
readonly alignmentId: string;
|
|
213
|
+
readonly assetId: string;
|
|
214
|
+
readonly conceptId: string;
|
|
215
|
+
readonly learningObjectId: string;
|
|
216
|
+
readonly lensId: string;
|
|
217
|
+
};
|
|
218
|
+
readonly sourceRevision: string;
|
|
219
|
+
readonly title: string;
|
|
220
|
+
readonly countryKey: string;
|
|
221
|
+
readonly examKey: string;
|
|
222
|
+
readonly kind: "exam";
|
|
223
|
+
readonly order: number;
|
|
224
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
225
|
+
readonly scoringStrategy: "irt" | "penalized" | "raw";
|
|
226
|
+
} | {
|
|
227
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
228
|
+
readonly description?: string | undefined;
|
|
229
|
+
readonly graph: {
|
|
230
|
+
readonly alignmentId: string;
|
|
231
|
+
readonly assetId: string;
|
|
232
|
+
readonly conceptId: string;
|
|
233
|
+
readonly learningObjectId: string;
|
|
234
|
+
readonly lensId: string;
|
|
235
|
+
};
|
|
236
|
+
readonly sourceRevision: string;
|
|
237
|
+
readonly title: string;
|
|
238
|
+
readonly countryCode: string;
|
|
239
|
+
readonly countryKey: string;
|
|
240
|
+
readonly kind: "country";
|
|
241
|
+
readonly order: number;
|
|
242
|
+
readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
|
|
243
|
+
};
|
|
244
|
+
readonly rowHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
245
|
+
}, import("#contracts/tryout/canonical").TryoutCanonicalHashError, never>;
|
|
21
246
|
/** Digests canonically ordered current hierarchy records. */
|
|
22
247
|
export declare const digestTryoutCatalog: <E, R>(records: Stream.Stream<{
|
|
23
248
|
readonly row: {
|
|
@@ -136,4 +361,4 @@ export declare const digestTryoutCatalog: <E, R>(records: Stream.Stream<{
|
|
|
136
361
|
}, E, R>) => Effect.Effect<{
|
|
137
362
|
count: number;
|
|
138
363
|
digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
139
|
-
}, E | import("#contracts/tryout/digest").TryoutDigestError, R>;
|
|
364
|
+
}, E | import("effect/PlatformError").PlatformError | import("#contracts/tryout/canonical").TryoutCanonicalHashError | import("#contracts/tryout/digest").TryoutDigestError, R>;
|
|
@@ -193,12 +193,10 @@ export function canonicalizeTryoutCatalog(row) {
|
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
/** Creates one authenticated current hierarchy record. */
|
|
196
|
-
export
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
}
|
|
196
|
+
export const makeTryoutCatalogRecord = Effect.fn("AksaraContracts.makeTryoutCatalogRecord")(function* (row) {
|
|
197
|
+
const rowHash = yield* hashTryoutCanonical(CATALOG_DOMAIN, canonicalizeTryoutCatalog(row));
|
|
198
|
+
return TryoutCatalogRecordSchema.make({ row, rowHash });
|
|
199
|
+
});
|
|
202
200
|
/** Digests canonically ordered current hierarchy records. */
|
|
203
201
|
export const digestTryoutCatalog = Effect.fn("AksaraContracts.digestTryoutCatalog")(function* (records) {
|
|
204
202
|
return yield* digestTryoutRecords({
|
|
@@ -206,6 +204,6 @@ export const digestTryoutCatalog = Effect.fn("AksaraContracts.digestTryoutCatalo
|
|
|
206
204
|
domain: CATALOG_DOMAIN,
|
|
207
205
|
identity: tryoutCatalogIdentity,
|
|
208
206
|
records,
|
|
209
|
-
rowHash: (row) => makeTryoutCatalogRecord(row).rowHash,
|
|
207
|
+
rowHash: (row) => makeTryoutCatalogRecord(row).pipe(Effect.map((record) => record.rowHash)),
|
|
210
208
|
});
|
|
211
209
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
2
|
/** Exact authored facts that define one app and delivery-language question. */
|
|
3
3
|
export declare const TryoutContentInputSchema: Schema.Struct<{
|
|
4
4
|
readonly dateModified: Schema.optionalKey<Schema.String>;
|
|
@@ -100,5 +100,116 @@ export declare const TryoutContentInputSchema: Schema.Struct<{
|
|
|
100
100
|
export type TryoutContentInput = typeof TryoutContentInputSchema.Type;
|
|
101
101
|
/** Serializes every current question-pair identity field in stable order. */
|
|
102
102
|
export declare function canonicalizeTryoutContent(input: TryoutContentInput): string;
|
|
103
|
+
declare const TryoutContentHashError_base: Schema.Class<TryoutContentHashError, Schema.TaggedStruct<"TryoutContentHashError", {}>, import("effect/Cause").YieldableError & {
|
|
104
|
+
readonly brand: unique symbol;
|
|
105
|
+
}>;
|
|
106
|
+
/** Web Crypto could not hash one canonical try-out content identity. */
|
|
107
|
+
export declare class TryoutContentHashError extends TryoutContentHashError_base {
|
|
108
|
+
}
|
|
103
109
|
/** Hashes one complete current question pair through its canonical identity. */
|
|
104
|
-
export declare
|
|
110
|
+
export declare const hashTryoutContent: (input: {
|
|
111
|
+
readonly dateModified?: string;
|
|
112
|
+
readonly datePublished: string;
|
|
113
|
+
readonly answerArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
114
|
+
readonly answerBody: string;
|
|
115
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
116
|
+
readonly blueprint?: {
|
|
117
|
+
readonly cognitiveLevel: string;
|
|
118
|
+
readonly contentDomain: string;
|
|
119
|
+
readonly topic: string;
|
|
120
|
+
};
|
|
121
|
+
readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
122
|
+
readonly languagePolicy: {
|
|
123
|
+
readonly kind: "app-locale";
|
|
124
|
+
} | {
|
|
125
|
+
readonly kind: "fixed";
|
|
126
|
+
readonly language: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
127
|
+
};
|
|
128
|
+
readonly questionArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
129
|
+
readonly questionBody: string;
|
|
130
|
+
readonly response: {
|
|
131
|
+
readonly categories: readonly {
|
|
132
|
+
readonly categoryKey: string;
|
|
133
|
+
readonly label: string;
|
|
134
|
+
readonly order: number;
|
|
135
|
+
}[];
|
|
136
|
+
readonly kind: "category";
|
|
137
|
+
readonly statements: readonly {
|
|
138
|
+
readonly correctCategoryKey: string;
|
|
139
|
+
readonly label: string;
|
|
140
|
+
readonly order: number;
|
|
141
|
+
readonly statementKey: string;
|
|
142
|
+
}[];
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: "multiple-choice";
|
|
145
|
+
readonly options: readonly {
|
|
146
|
+
readonly isCorrect: boolean;
|
|
147
|
+
readonly label: string;
|
|
148
|
+
readonly optionKey: string;
|
|
149
|
+
readonly order: number;
|
|
150
|
+
}[];
|
|
151
|
+
} | {
|
|
152
|
+
readonly kind: "single-choice";
|
|
153
|
+
readonly options: readonly {
|
|
154
|
+
readonly isCorrect: boolean;
|
|
155
|
+
readonly label: string;
|
|
156
|
+
readonly optionKey: string;
|
|
157
|
+
readonly order: number;
|
|
158
|
+
}[];
|
|
159
|
+
} | {
|
|
160
|
+
readonly criteria: readonly {
|
|
161
|
+
readonly criterionKey: string;
|
|
162
|
+
readonly finalAnswer?: {
|
|
163
|
+
readonly acceptsFractions: boolean;
|
|
164
|
+
readonly kind: "number";
|
|
165
|
+
readonly tolerance?: {
|
|
166
|
+
readonly kind: "absolute" | "relative";
|
|
167
|
+
readonly value: string;
|
|
168
|
+
};
|
|
169
|
+
readonly value: string;
|
|
170
|
+
} | {
|
|
171
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
172
|
+
readonly collapseWhitespace: boolean;
|
|
173
|
+
readonly ignoreCase: boolean;
|
|
174
|
+
readonly kind: "text";
|
|
175
|
+
};
|
|
176
|
+
readonly order: number;
|
|
177
|
+
readonly label: {
|
|
178
|
+
readonly de: string;
|
|
179
|
+
readonly en: string;
|
|
180
|
+
readonly id: string;
|
|
181
|
+
};
|
|
182
|
+
readonly levels: readonly {
|
|
183
|
+
readonly levelKey: string;
|
|
184
|
+
readonly order: number;
|
|
185
|
+
readonly points: number;
|
|
186
|
+
readonly label: {
|
|
187
|
+
readonly de: string;
|
|
188
|
+
readonly en: string;
|
|
189
|
+
readonly id: string;
|
|
190
|
+
};
|
|
191
|
+
}[];
|
|
192
|
+
}[];
|
|
193
|
+
readonly kind: "rubric";
|
|
194
|
+
} | {
|
|
195
|
+
readonly key: {
|
|
196
|
+
readonly acceptsFractions: boolean;
|
|
197
|
+
readonly kind: "number";
|
|
198
|
+
readonly tolerance?: {
|
|
199
|
+
readonly kind: "absolute" | "relative";
|
|
200
|
+
readonly value: string;
|
|
201
|
+
};
|
|
202
|
+
readonly value: string;
|
|
203
|
+
} | {
|
|
204
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
205
|
+
readonly collapseWhitespace: boolean;
|
|
206
|
+
readonly ignoreCase: boolean;
|
|
207
|
+
readonly kind: "text";
|
|
208
|
+
};
|
|
209
|
+
readonly kind: "short-answer";
|
|
210
|
+
};
|
|
211
|
+
readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
|
|
212
|
+
readonly sourceRevision: string;
|
|
213
|
+
readonly stimulusKey?: string;
|
|
214
|
+
}) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraTryoutContentHash">, TryoutContentHashError, never>;
|
|
215
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Hex } from "effect/encoding";
|
|
3
3
|
import { withPublicationDates } from "#contracts/date";
|
|
4
|
+
import { digestSha256 } from "#contracts/hash/digest";
|
|
4
5
|
import { AppLocaleSchema, ArtifactLocaleSchema, DeliveryLanguageSchema, } from "#contracts/locale";
|
|
5
6
|
import { QuestionKeySchema } from "#contracts/question/identity";
|
|
6
7
|
import { canonicalQuestionBlueprint, QuestionBlueprintSchema, } from "#contracts/question/item";
|
|
@@ -64,10 +65,11 @@ export function canonicalizeTryoutContent(input) {
|
|
|
64
65
|
: { stimulusKey: input.stimulusKey }),
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
/**
|
|
68
|
-
export
|
|
69
|
-
const digest = createHash("sha256")
|
|
70
|
-
.update(canonicalizeTryoutContent(input), "utf8")
|
|
71
|
-
.digest("hex");
|
|
72
|
-
return TryoutContentHashSchema.make(digest);
|
|
68
|
+
/** Web Crypto could not hash one canonical try-out content identity. */
|
|
69
|
+
export class TryoutContentHashError extends Schema.TaggedError()("TryoutContentHashError", {}) {
|
|
73
70
|
}
|
|
71
|
+
/** Hashes one complete current question pair through its canonical identity. */
|
|
72
|
+
export const hashTryoutContent = Effect.fn("AksaraContracts.hashTryoutContent")(function* (input) {
|
|
73
|
+
const digest = yield* digestSha256(new TextEncoder().encode(canonicalizeTryoutContent(input))).pipe(Effect.mapError(() => new TryoutContentHashError()));
|
|
74
|
+
return TryoutContentHashSchema.make(Hex.encode(digest));
|
|
75
|
+
});
|