@nakafa/aksara-contracts 1.0.1 → 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.
Files changed (164) hide show
  1. package/README.md +8 -25
  2. package/dist/{question → assessment}/answer.d.ts +14 -58
  3. package/dist/{question → assessment}/answer.js +13 -60
  4. package/dist/assessment/catalog.d.ts +235 -0
  5. package/dist/assessment/catalog.js +115 -0
  6. package/dist/assessment/chart.d.ts +62 -0
  7. package/dist/assessment/chart.js +64 -0
  8. package/dist/assessment/closure.d.ts +28 -0
  9. package/dist/assessment/closure.js +164 -0
  10. package/dist/assessment/explanation.d.ts +13 -8
  11. package/dist/assessment/explanation.js +14 -8
  12. package/dist/assessment/figure.d.ts +140 -1
  13. package/dist/assessment/figure.js +9 -2
  14. package/dist/assessment/hash.d.ts +348 -208
  15. package/dist/assessment/hash.js +14 -0
  16. package/dist/assessment/inline.d.ts +3 -1
  17. package/dist/assessment/inline.js +20 -5
  18. package/dist/assessment/item.d.ts +8 -4
  19. package/dist/assessment/item.js +6 -2
  20. package/dist/assessment/key.js +6 -6
  21. package/dist/assessment/paper.d.ts +74 -74
  22. package/dist/assessment/snapshot.d.ts +3778 -0
  23. package/dist/assessment/snapshot.js +192 -0
  24. package/dist/cache/content.d.ts +4 -4
  25. package/dist/canonical.d.ts +6 -0
  26. package/dist/canonical.js +8 -1
  27. package/dist/content.d.ts +1 -1
  28. package/dist/content.js +0 -1
  29. package/dist/delivery.d.ts +0 -3
  30. package/dist/delivery.js +0 -5
  31. package/dist/preview/artifact.d.ts +1 -120
  32. package/dist/preview/document.d.ts +0 -586
  33. package/dist/preview/document.js +1 -47
  34. package/dist/preview/spec.d.ts +6 -1984
  35. package/dist/preview/spec.js +7 -47
  36. package/dist/preview/target.d.ts +0 -173
  37. package/dist/preview/target.js +1 -70
  38. package/dist/projection/digest.d.ts +0 -127
  39. package/dist/projection/hash.d.ts +0 -127
  40. package/dist/projection/spec.d.ts +6 -211
  41. package/dist/projection/spec.js +4 -18
  42. package/dist/projection/verify.d.ts +0 -127
  43. package/dist/projection/verify.js +0 -3
  44. package/dist/release/canonical.d.ts +2 -2
  45. package/dist/release/current/evidence.d.ts +24 -24
  46. package/dist/release/current/state.d.ts +28 -56
  47. package/dist/release/current/state.js +1 -6
  48. package/dist/release/digest.d.ts +2 -2
  49. package/dist/release/hash.d.ts +5 -5
  50. package/dist/release/head.d.ts +10 -57
  51. package/dist/release/head.js +3 -14
  52. package/dist/release/identity.d.ts +3 -3
  53. package/dist/release/items.d.ts +2 -2
  54. package/dist/release/lifecycle.d.ts +18 -18
  55. package/dist/release/policy.d.ts +3 -4
  56. package/dist/release/policy.js +2 -11
  57. package/dist/release/result/digest.d.ts +6 -18
  58. package/dist/release/result/digest.js +1 -2
  59. package/dist/release/rollback/digest.d.ts +4 -19
  60. package/dist/release/rollback/spec.d.ts +30 -792
  61. package/dist/release/rollback/spec.js +1 -4
  62. package/dist/release/snapshot/data.d.ts +599 -249
  63. package/dist/release/snapshot/data.js +11 -28
  64. package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
  65. package/dist/release/snapshot/evidence/assessment.js +44 -0
  66. package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
  67. package/dist/release/snapshot/evidence.d.ts +19 -19
  68. package/dist/release/snapshot/evidence.js +2 -2
  69. package/dist/release/snapshot/scope.d.ts +5 -5
  70. package/dist/release/snapshot/scope.js +1 -1
  71. package/dist/release/snapshot/spec.d.ts +15 -15
  72. package/dist/release/snapshot/spec.js +8 -8
  73. package/dist/release/snapshot/verify.d.ts +1278 -268
  74. package/dist/release/snapshot/verify.js +8 -5
  75. package/dist/release/spec.d.ts +33 -33
  76. package/dist/release/verify.d.ts +5 -5
  77. package/dist/runtime/spec.d.ts +38 -38
  78. package/dist/runtime/spec.js +4 -5
  79. package/dist/runtime/verify.d.ts +40 -40
  80. package/dist/signature/spec.d.ts +5 -5
  81. package/dist/signature/spec.js +0 -1
  82. package/dist/transport/batch.d.ts +6 -244
  83. package/dist/transport/failure.d.ts +6 -20
  84. package/dist/transport/failure.js +0 -10
  85. package/dist/transport/group.d.ts +1969 -1369
  86. package/dist/transport/group.js +0 -2
  87. package/dist/transport/request.d.ts +10691 -5086
  88. package/dist/transport/request.js +0 -3
  89. package/dist/transport/response.d.ts +219 -1442
  90. package/dist/transport/response.js +0 -4
  91. package/dist/transport/snapshot.d.ts +1187 -487
  92. package/package.json +187 -295
  93. package/dist/projection/question.d.ts +0 -1067
  94. package/dist/projection/question.js +0 -121
  95. package/dist/question/identity.d.ts +0 -175
  96. package/dist/question/identity.js +0 -207
  97. package/dist/question/item.d.ts +0 -450
  98. package/dist/question/item.js +0 -174
  99. package/dist/question/label.d.ts +0 -3
  100. package/dist/question/label.js +0 -3
  101. package/dist/question/points.d.ts +0 -18
  102. package/dist/question/points.js +0 -22
  103. package/dist/question/response.d.ts +0 -289
  104. package/dist/question/response.js +0 -167
  105. package/dist/question/rubric.d.ts +0 -234
  106. package/dist/question/rubric.js +0 -186
  107. package/dist/release/current/runtime.d.ts +0 -4
  108. package/dist/release/current/runtime.js +0 -15
  109. package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
  110. package/dist/release/snapshot/evidence/tryout.js +0 -91
  111. package/dist/runtime/protected/limits.d.ts +0 -10
  112. package/dist/runtime/protected/limits.js +0 -16
  113. package/dist/runtime/protected/spec.d.ts +0 -310
  114. package/dist/runtime/protected/spec.js +0 -80
  115. package/dist/runtime/protected/verify.d.ts +0 -83
  116. package/dist/runtime/protected/verify.js +0 -70
  117. package/dist/transport/runtime.d.ts +0 -77
  118. package/dist/transport/runtime.js +0 -33
  119. package/dist/tryout/canonical.d.ts +0 -12
  120. package/dist/tryout/canonical.js +0 -7
  121. package/dist/tryout/catalog.d.ts +0 -396
  122. package/dist/tryout/catalog.js +0 -155
  123. package/dist/tryout/closure/accounting.d.ts +0 -20
  124. package/dist/tryout/closure/accounting.js +0 -70
  125. package/dist/tryout/closure/locale.d.ts +0 -14
  126. package/dist/tryout/closure/locale.js +0 -113
  127. package/dist/tryout/closure/placement.d.ts +0 -5
  128. package/dist/tryout/closure/placement.js +0 -32
  129. package/dist/tryout/digest.d.ts +0 -34
  130. package/dist/tryout/digest.js +0 -57
  131. package/dist/tryout/hash/catalog.d.ts +0 -364
  132. package/dist/tryout/hash/catalog.js +0 -209
  133. package/dist/tryout/hash/content.d.ts +0 -215
  134. package/dist/tryout/hash/content.js +0 -75
  135. package/dist/tryout/hash/placement.d.ts +0 -242
  136. package/dist/tryout/hash/placement.js +0 -56
  137. package/dist/tryout/identity.d.ts +0 -12
  138. package/dist/tryout/identity.js +0 -47
  139. package/dist/tryout/key.d.ts +0 -4
  140. package/dist/tryout/key.js +0 -8
  141. package/dist/tryout/language.d.ts +0 -24
  142. package/dist/tryout/language.js +0 -30
  143. package/dist/tryout/placement.d.ts +0 -331
  144. package/dist/tryout/placement.js +0 -96
  145. package/dist/tryout/runtime/canonical.d.ts +0 -8
  146. package/dist/tryout/runtime/canonical.js +0 -34
  147. package/dist/tryout/runtime/hash.d.ts +0 -34
  148. package/dist/tryout/runtime/hash.js +0 -13
  149. package/dist/tryout/runtime/source.d.ts +0 -44
  150. package/dist/tryout/runtime/source.js +0 -47
  151. package/dist/tryout/runtime/spec.d.ts +0 -58
  152. package/dist/tryout/runtime/spec.js +0 -21
  153. package/dist/tryout/runtime/verify.d.ts +0 -69
  154. package/dist/tryout/runtime/verify.js +0 -67
  155. package/dist/tryout/scoring.d.ts +0 -148
  156. package/dist/tryout/scoring.js +0 -98
  157. package/dist/tryout/snapshot/canonical.d.ts +0 -7
  158. package/dist/tryout/snapshot/canonical.js +0 -18
  159. package/dist/tryout/snapshot/hash.d.ts +0 -49
  160. package/dist/tryout/snapshot/hash.js +0 -22
  161. package/dist/tryout/snapshot/spec.d.ts +0 -46
  162. package/dist/tryout/snapshot/spec.js +0 -30
  163. package/dist/tryout/spec.d.ts +0 -41
  164. package/dist/tryout/spec.js +0 -46
@@ -1,186 +0,0 @@
1
- import { Array as Arr, Schema, Struct } from "effect";
2
- import { ActiveAppLocaleCodeSchema } from "#contracts/locale";
3
- import { canonicalQuestionAnswerKey, canonicalQuestionAnswerKeyStructure, QuestionAnswerKeySchema, } from "#contracts/question/answer";
4
- import { QuestionResponseLabelSchema } from "#contracts/question/label";
5
- const CRITERION_KEY_PATTERN = /^criterion-[1-9]\d*$/u;
6
- const LEVEL_KEY_PATTERN = /^level-[1-9]\d*$/u;
7
- const PositiveOrderSchema = Schema.Int.check(Schema.isGreaterThan(0));
8
- const LevelPointsSchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
9
- /**
10
- * One learner-facing rubric label written for every active app locale. A
11
- * learner reads it after the attempt in the app locale, even when the prompt
12
- * is delivered in a fixed assessed language, so every rubric copy carries all
13
- * locales.
14
- */
15
- export const QuestionRubricLabelSchema = Schema.Record(ActiveAppLocaleCodeSchema, QuestionResponseLabelSchema);
16
- /**
17
- * Checks one criterion scale: two or more levels whose points strictly
18
- * ascend. A final-answer criterion has exactly two levels and its lower level
19
- * is worth zero, because a wrong result earns nothing. The criterion holds the
20
- * scale facts shared by authored, frozen, and label-free rubric criteria.
21
- */
22
- function hasOrderedScale(criterion) {
23
- let previous = -1;
24
- for (const { points } of criterion.levels) {
25
- if (points <= previous) {
26
- return false;
27
- }
28
- previous = points;
29
- }
30
- if (criterion.finalAnswer === undefined) {
31
- return criterion.levels.length >= 2;
32
- }
33
- const [lower] = criterion.levels;
34
- return criterion.levels.length === 2 && lower?.points === 0;
35
- }
36
- const ORDERED_SCALE_MESSAGE = "Rubric criteria need two or more levels whose points strictly ascend, and a final-answer criterion needs exactly a zero level and one higher level.";
37
- /**
38
- * Checks one or more criteria and the stable keys derived from their order. A
39
- * labeled criterion is a scale criterion with labels, so both kinds pass here.
40
- */
41
- function hasCanonicalCriteria(criteria) {
42
- return (criteria.length > 0 &&
43
- Arr.every(criteria, ({ criterionKey, levels, order }, index) => order === index + 1 &&
44
- criterionKey === `criterion-${order}` &&
45
- Arr.every(levels, (level, levelIndex) => level.order === levelIndex + 1 &&
46
- level.levelKey === `level-${level.order}`)));
47
- }
48
- const CANONICAL_CRITERIA_MESSAGE = "Rubric criteria and levels require canonical keys and order.";
49
- const LevelScaleFields = {
50
- levelKey: Schema.String.check(Schema.isPattern(LEVEL_KEY_PATTERN)),
51
- order: PositiveOrderSchema,
52
- points: LevelPointsSchema,
53
- };
54
- const CriterionScaleFields = {
55
- criterionKey: Schema.String.check(Schema.isPattern(CRITERION_KEY_PATTERN)),
56
- finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
57
- order: PositiveOrderSchema,
58
- };
59
- /** One label-free rubric criterion with its ordered level scale. */
60
- const QuestionRubricCriterionScaleSchema = Schema.Struct({
61
- ...CriterionScaleFields,
62
- levels: Schema.Array(Schema.Struct(LevelScaleFields)),
63
- }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
64
- /**
65
- * Locale-neutral rubric scale that grading reads: ordered criteria with
66
- * stable keys, ordered levels with points, and optional final-answer keys. It
67
- * ignores labels, so content written in one language, such as a School
68
- * tenant's rubric, validates its scale here and owns its own labels. A judged
69
- * criterion maps onto one Effect `Decision.rate` decision keyed by
70
- * `criterionKey`: its level keys are the rating scale from lowest to highest,
71
- * a rating answer's probabilities are keyed by them, and the chosen level's
72
- * points are earned. A final-answer criterion is graded with
73
- * `matchesAnswerKey` instead: a match earns its upper level and any other
74
- * answer its zero level. A blank answer earns zero on every criterion.
75
- */
76
- export const QuestionRubricScaleSchema = Schema.Struct({
77
- criteria: Schema.Array(QuestionRubricCriterionScaleSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
78
- message: CANONICAL_CRITERIA_MESSAGE,
79
- })),
80
- kind: Schema.Literal("rubric"),
81
- });
82
- /** One frozen scoring level of a rubric criterion. */
83
- const QuestionRubricLevelSchema = Schema.Struct({
84
- ...LevelScaleFields,
85
- label: QuestionRubricLabelSchema,
86
- });
87
- /** One frozen rubric criterion with its ordered level scale. */
88
- const QuestionRubricCriterionSchema = Schema.Struct({
89
- ...CriterionScaleFields,
90
- label: QuestionRubricLabelSchema,
91
- levels: Schema.Array(QuestionRubricLevelSchema),
92
- }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
93
- /**
94
- * Frozen open-response rubric of Aksara content: the rubric scale with every
95
- * criterion and level labeled in every active app locale.
96
- */
97
- export const QuestionRubricResponseSchema = Schema.Struct({
98
- criteria: Schema.Array(QuestionRubricCriterionSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
99
- message: CANONICAL_CRITERIA_MESSAGE,
100
- })),
101
- kind: Schema.Literal("rubric"),
102
- });
103
- /** One authored scoring level before its stable key is derived. */
104
- const QuestionRubricLevelSourceSchema = Schema.Struct({
105
- label: QuestionRubricLabelSchema,
106
- points: LevelPointsSchema,
107
- }).mapFields(Struct.map(Schema.mutableKey));
108
- /** One authored criterion before its stable key and order are derived. */
109
- const QuestionRubricCriterionSourceSchema = Schema.Struct({
110
- finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
111
- label: QuestionRubricLabelSchema,
112
- levels: Schema.Array(QuestionRubricLevelSourceSchema).pipe(Schema.mutable),
113
- })
114
- .mapFields(Struct.map(Schema.mutableKey))
115
- .check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
116
- /** One rubric authored in array order without duplicated runtime keys. */
117
- export const QuestionRubricResponseSourceSchema = Schema.Struct({
118
- criteria: Schema.Array(QuestionRubricCriterionSourceSchema).pipe(Schema.mutable, Schema.check(Schema.makeFilter((criteria) => criteria.length > 0, {
119
- message: "Expected at least one rubric criterion.",
120
- }))),
121
- kind: Schema.Literal("rubric"),
122
- }).mapFields(Struct.map(Schema.mutableKey));
123
- /** Derives stable criterion and level keys once from authored array order. */
124
- export function freezeQuestionRubric(source) {
125
- return QuestionRubricResponseSchema.make({
126
- criteria: Arr.map(source.criteria, (criterion, index) => ({
127
- criterionKey: `criterion-${index + 1}`,
128
- ...(criterion.finalAnswer === undefined
129
- ? {}
130
- : { finalAnswer: criterion.finalAnswer }),
131
- label: criterion.label,
132
- levels: Arr.map(criterion.levels, ({ label, points }, levelIndex) => ({
133
- label,
134
- levelKey: `level-${levelIndex + 1}`,
135
- order: levelIndex + 1,
136
- points,
137
- })),
138
- order: index + 1,
139
- })),
140
- kind: "rubric",
141
- });
142
- }
143
- /** Returns one label with every active app locale in alphabetical order. */
144
- function canonicalRubricLabel(label) {
145
- return { de: label.de, en: label.en, id: label.id };
146
- }
147
- /** Serializes criteria in stable field order with one answer-key encoding. */
148
- function canonicalRubricCriteria(rubric, canonicalKey) {
149
- return Arr.map(rubric.criteria, ({ criterionKey, finalAnswer, label, levels, order }) => ({
150
- criterionKey,
151
- ...(finalAnswer === undefined
152
- ? {}
153
- : { finalAnswer: canonicalKey(finalAnswer) }),
154
- label: canonicalRubricLabel(label),
155
- levels: Arr.map(levels, (level) => ({
156
- label: canonicalRubricLabel(level.label),
157
- levelKey: level.levelKey,
158
- order: level.order,
159
- points: level.points,
160
- })),
161
- order,
162
- }));
163
- }
164
- /**
165
- * Returns the rubric facts shared by every delivery language: keys, order,
166
- * points, labels in every active app locale, and final-answer rules without
167
- * accepted text written in one delivery language.
168
- */
169
- export function canonicalQuestionRubricStructure(rubric) {
170
- return {
171
- criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKeyStructure),
172
- kind: rubric.kind,
173
- };
174
- }
175
- /** Returns every rubric fact, accepted final-answer text included. */
176
- export function canonicalQuestionRubric(rubric) {
177
- return {
178
- criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKey),
179
- kind: rubric.kind,
180
- };
181
- }
182
- /** Returns the rubric total: the sum of every criterion's highest level. */
183
- export function questionRubricPoints(rubric) {
184
- return Arr.reduce(rubric.criteria, 0, (total, { levels }) => total +
185
- Arr.reduce(levels, 0, (highest, { points }) => Math.max(highest, points)));
186
- }
@@ -1,4 +0,0 @@
1
- import type { ActiveContentRelease } from "#contracts/release/current/evidence";
2
- import type { SignedTryoutRuntimeBundle } from "#contracts/tryout/runtime/spec";
3
- /** Accepts only the permanent runtime bound to the active try-out snapshot. */
4
- export declare function hasCurrentTryoutRuntimeBundle(active: ActiveContentRelease | null, bundle: SignedTryoutRuntimeBundle | null): boolean;
@@ -1,15 +0,0 @@
1
- /** Accepts only the permanent runtime bound to the active try-out snapshot. */
2
- export function hasCurrentTryoutRuntimeBundle(active, bundle) {
3
- if (active === null) {
4
- return bundle === null;
5
- }
6
- const snapshotId = active.release.manifest.snapshots.tryout.resultSnapshotId;
7
- if (snapshotId === null || snapshotId === undefined) {
8
- return bundle === null;
9
- }
10
- if (bundle === null) {
11
- return false;
12
- }
13
- return (snapshotId === bundle.payload.snapshot.snapshotId &&
14
- active.rendererManifest.hash === bundle.payload.rendererManifestHash);
15
- }
@@ -1,22 +0,0 @@
1
- import { Effect } from "effect";
2
- import { type SnapshotRowSource } from "#contracts/release/snapshot/evidence/requirement";
3
- /** Verifies all try-out hashes, digests, counts, routes, and identity. */
4
- export declare const verifyTryoutSnapshotRows: <E, R>(snapshot: {
5
- readonly family: "tryout";
6
- readonly manifest: {
7
- readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
8
- readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
9
- readonly counts: {
10
- readonly country: number;
11
- readonly exam: number;
12
- readonly section: number;
13
- readonly set: number;
14
- readonly track: number;
15
- };
16
- readonly placementCount: number;
17
- readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
18
- readonly routeCount: number;
19
- readonly format: "localized-tryout-snapshot";
20
- readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
21
- };
22
- }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("effect/PlatformError").PlatformError | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../../tryout/canonical.js").TryoutCanonicalHashError | import("../../../tryout/closure/accounting.js").TryoutClosureError | import("../../../tryout/digest.js").TryoutDigestError | import("../../../tryout/scoring.js").TryoutScoringError, R>;
@@ -1,91 +0,0 @@
1
- import { Effect, Result, Schema, Stream } from "effect";
2
- import { requireSnapshotEvidence, } from "#contracts/release/snapshot/evidence/requirement";
3
- import { verifyTryoutLocaleClosure } from "#contracts/tryout/closure/locale";
4
- import { digestTryoutCatalog } from "#contracts/tryout/hash/catalog";
5
- import { digestTryoutPlacements } from "#contracts/tryout/hash/placement";
6
- import { makeTryoutSnapshot } from "#contracts/tryout/snapshot/hash";
7
- import { TryoutCatalogCountsSchema } from "#contracts/tryout/snapshot/spec";
8
- const TryoutCatalogEvidenceSchema = Schema.Struct({
9
- counts: TryoutCatalogCountsSchema,
10
- routeCount: Schema.Finite,
11
- });
12
- /** Selects current hierarchy rows while preserving source failures. */
13
- function currentTryoutCatalog(rows) {
14
- return rows.pipe(Stream.filterMap((row) => row.family === "tryout" && row.rowKind === "catalog"
15
- ? Result.succeed(row.record)
16
- : Result.failVoid));
17
- }
18
- /** Selects current placements while preserving source failures. */
19
- function currentPlacements(rows) {
20
- return rows.pipe(Stream.filterMap((row) => row.family === "tryout" && row.rowKind === "placement"
21
- ? Result.succeed(row.record)
22
- : Result.failVoid));
23
- }
24
- /** Derives signed per-kind and public-route counts from catalog rows. */
25
- function summarizeTryoutCatalog(records) {
26
- const initial = {
27
- counts: { country: 0, exam: 0, section: 0, set: 0, track: 0 },
28
- routeCount: 0,
29
- };
30
- return records.pipe(Stream.runFold(() => initial, (state, { row }) => ({
31
- counts: {
32
- ...state.counts,
33
- [row.kind]: state.counts[row.kind] + 1,
34
- },
35
- routeCount: state.routeCount + (row.publicPath === undefined ? 0 : 1),
36
- })));
37
- }
38
- /** Verifies all try-out hashes, digests, counts, routes, and identity. */
39
- export const verifyTryoutSnapshotRows = Effect.fn("AksaraContracts.verifyTryoutSnapshotRows")(function* (snapshot, rows) {
40
- const [placementDigest, catalogDigest, catalogEvidence] = yield* Effect.all([
41
- rows.pipe(currentPlacements, digestTryoutPlacements),
42
- rows.pipe(currentTryoutCatalog, digestTryoutCatalog),
43
- rows.pipe(currentTryoutCatalog, summarizeTryoutCatalog),
44
- ]);
45
- yield* verifyTryoutLocaleClosure({
46
- activeAppLocales: snapshot.manifest.activeAppLocales,
47
- catalog: currentTryoutCatalog(rows),
48
- placements: currentPlacements(rows),
49
- });
50
- yield* requireSnapshotEvidence({
51
- actual: catalogDigest.digest,
52
- expected: snapshot.manifest.catalogDigest,
53
- family: "tryout",
54
- field: "catalogDigest",
55
- });
56
- yield* requireSnapshotEvidence({
57
- actual: placementDigest.count,
58
- expected: snapshot.manifest.placementCount,
59
- family: "tryout",
60
- field: "placementCount",
61
- });
62
- yield* requireSnapshotEvidence({
63
- actual: placementDigest.digest,
64
- expected: snapshot.manifest.placementDigest,
65
- family: "tryout",
66
- field: "placementDigest",
67
- });
68
- for (const kind of ["country", "exam", "section", "set", "track"]) {
69
- yield* requireSnapshotEvidence({
70
- actual: catalogEvidence.counts[kind],
71
- expected: snapshot.manifest.counts[kind],
72
- family: "tryout",
73
- field: `${kind}Count`,
74
- });
75
- }
76
- yield* requireSnapshotEvidence({
77
- actual: catalogEvidence.routeCount,
78
- expected: snapshot.manifest.routeCount,
79
- family: "tryout",
80
- field: "routeCount",
81
- });
82
- const { format: _format, snapshotId, ...facts } = snapshot.manifest;
83
- const actualId = (yield* makeTryoutSnapshot(facts)).snapshotId;
84
- yield* requireSnapshotEvidence({
85
- actual: actualId,
86
- expected: snapshotId,
87
- family: "tryout",
88
- field: "snapshotId",
89
- });
90
- return catalogDigest.count + placementDigest.count;
91
- });
@@ -1,10 +0,0 @@
1
- /** Maximum protected selectors accepted in one retained-snapshot read. */
2
- export declare const MAX_PROTECTED_RUNTIME_SELECTORS = 64;
3
- /** Maximum UTF-8 bytes accepted by the protected batch endpoint. */
4
- export declare const MAX_PROTECTED_RUNTIME_REQUEST_BYTES: number;
5
- /** Maximum UTF-8 bytes returned by the protected batch endpoint. */
6
- export declare const MAX_PROTECTED_RUNTIME_RESPONSE_BYTES: number;
7
- /** Measures the exact JSON bytes written by the protected HTTP response. */
8
- export declare function protectedRuntimeResponseBytes(response: object): number;
9
- /** Keeps every found result inside the protected response wire ceiling. */
10
- export declare function hasBoundedProtectedRuntimeResponse(response: object): boolean;
@@ -1,16 +0,0 @@
1
- import { encodeJsonText } from "#contracts/text/json";
2
- /** Maximum protected selectors accepted in one retained-snapshot read. */
3
- export const MAX_PROTECTED_RUNTIME_SELECTORS = 64;
4
- /** Maximum UTF-8 bytes accepted by the protected batch endpoint. */
5
- export const MAX_PROTECTED_RUNTIME_REQUEST_BYTES = 64 * 1024;
6
- /** Maximum UTF-8 bytes returned by the protected batch endpoint. */
7
- export const MAX_PROTECTED_RUNTIME_RESPONSE_BYTES = 4 * 1024 * 1024;
8
- /** Measures the exact JSON bytes written by the protected HTTP response. */
9
- export function protectedRuntimeResponseBytes(response) {
10
- return new TextEncoder().encode(encodeJsonText(response)).byteLength;
11
- }
12
- /** Keeps every found result inside the protected response wire ceiling. */
13
- export function hasBoundedProtectedRuntimeResponse(response) {
14
- return (protectedRuntimeResponseBytes(response) <=
15
- MAX_PROTECTED_RUNTIME_RESPONSE_BYTES);
16
- }