@nakafa/aksara-contracts 0.47.0 → 0.47.1

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 (64) hide show
  1. package/dist/content.d.ts +8 -6
  2. package/dist/content.js +8 -3
  3. package/dist/math/arc.js +5 -1
  4. package/dist/math/base.js +6 -6
  5. package/dist/math/collision.d.ts +4 -4
  6. package/dist/math/collision.js +15 -9
  7. package/dist/math/coordinate.d.ts +24 -13
  8. package/dist/math/coordinate.js +16 -2
  9. package/dist/math/extent.d.ts +26 -17
  10. package/dist/math/extent.js +18 -2
  11. package/dist/math/intersection.d.ts +21 -11
  12. package/dist/math/intersection.js +14 -1
  13. package/dist/math/precision.js +3 -3
  14. package/dist/math/proximity.d.ts +11 -7
  15. package/dist/math/proximity.js +21 -4
  16. package/dist/math/rational.d.ts +6 -5
  17. package/dist/math/rational.js +6 -1
  18. package/dist/math/resolution.d.ts +1 -1
  19. package/dist/math/resolution.js +12 -4
  20. package/dist/math/scene.d.ts +22 -3
  21. package/dist/preview/auth.js +2 -1
  22. package/dist/preview/target.js +7 -0
  23. package/dist/program/curriculum.js +2 -1
  24. package/dist/program/snapshot/digest.js +32 -31
  25. package/dist/program/snapshot/hash.js +2 -1
  26. package/dist/program/spec.js +2 -1
  27. package/dist/projection/article.js +2 -1
  28. package/dist/projection/material.js +2 -1
  29. package/dist/projection/page.js +2 -1
  30. package/dist/projection/question.d.ts +544 -17
  31. package/dist/projection/question.js +17 -3
  32. package/dist/projection/verify.d.ts +4 -3
  33. package/dist/projection/verify.js +14 -7
  34. package/dist/question/answer.d.ts +12 -6
  35. package/dist/question/answer.js +17 -2
  36. package/dist/question/item.js +5 -4
  37. package/dist/question/response.js +3 -3
  38. package/dist/question/rubric.js +2 -1
  39. package/dist/quran/identity.js +11 -0
  40. package/dist/quran/notes.js +13 -0
  41. package/dist/quran/provenance.js +3 -2
  42. package/dist/quran/snapshot/digest.js +4 -3
  43. package/dist/quran/snapshot/hash.js +2 -1
  44. package/dist/quran/snapshot/row/hash.js +5 -4
  45. package/dist/quran/snapshot/spec.js +3 -2
  46. package/dist/renderer/compatibility.js +8 -5
  47. package/dist/renderer/contract.js +5 -4
  48. package/dist/runtime/protected/limits.js +2 -1
  49. package/dist/runtime/protected/spec.js +3 -3
  50. package/dist/text/json.d.ts +5 -0
  51. package/dist/text/json.js +5 -0
  52. package/dist/transport/request.d.ts +108 -108
  53. package/dist/tryout/closure/accounting.js +5 -4
  54. package/dist/tryout/closure/placement.js +3 -2
  55. package/dist/tryout/hash/catalog.js +11 -10
  56. package/dist/tryout/hash/content.js +2 -1
  57. package/dist/tryout/hash/placement.js +2 -1
  58. package/dist/tryout/language.js +2 -4
  59. package/dist/tryout/runtime/canonical.js +2 -1
  60. package/dist/tryout/scoring.d.ts +13 -9
  61. package/dist/tryout/scoring.js +17 -8
  62. package/dist/tryout/snapshot/canonical.js +2 -1
  63. package/dist/tryout/snapshot/hash.js +2 -1
  64. package/package.json +1 -1
@@ -3064,24 +3064,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
3064
3064
  readonly family: "tryout";
3065
3065
  readonly record: {
3066
3066
  readonly row: {
3067
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3068
- readonly description?: string | undefined;
3069
- readonly graph: {
3070
- readonly alignmentId: string;
3071
- readonly assetId: string;
3072
- readonly conceptId: string;
3073
- readonly learningObjectId: string;
3074
- readonly lensId: string;
3075
- };
3076
- readonly sourceRevision: string;
3077
- readonly title: string;
3078
- readonly countryKey: string;
3079
- readonly examKey: string;
3080
- readonly kind: "exam";
3081
- readonly order: number;
3082
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
3083
- readonly scoringStrategy: "irt" | "penalized" | "raw";
3084
- } | {
3085
3067
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3086
3068
  readonly description?: string | undefined;
3087
3069
  readonly graph: {
@@ -3157,6 +3139,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
3157
3139
  readonly trackKey: string;
3158
3140
  readonly trackKind: "institution" | "subject" | "year";
3159
3141
  readonly visibleSectionCount: number;
3142
+ } | {
3143
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3144
+ readonly description?: string | undefined;
3145
+ readonly graph: {
3146
+ readonly alignmentId: string;
3147
+ readonly assetId: string;
3148
+ readonly conceptId: string;
3149
+ readonly learningObjectId: string;
3150
+ readonly lensId: string;
3151
+ };
3152
+ readonly sourceRevision: string;
3153
+ readonly title: string;
3154
+ readonly countryKey: string;
3155
+ readonly examKey: string;
3156
+ readonly kind: "exam";
3157
+ readonly order: number;
3158
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
3159
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
3160
3160
  } | {
3161
3161
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3162
3162
  readonly description?: string | undefined;
@@ -3630,24 +3630,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
3630
3630
  readonly family: "tryout";
3631
3631
  readonly record: {
3632
3632
  readonly row: {
3633
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3634
- readonly description?: string | undefined;
3635
- readonly graph: {
3636
- readonly alignmentId: string;
3637
- readonly assetId: string;
3638
- readonly conceptId: string;
3639
- readonly learningObjectId: string;
3640
- readonly lensId: string;
3641
- };
3642
- readonly sourceRevision: string;
3643
- readonly title: string;
3644
- readonly countryKey: string;
3645
- readonly examKey: string;
3646
- readonly kind: "exam";
3647
- readonly order: number;
3648
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
3649
- readonly scoringStrategy: "irt" | "penalized" | "raw";
3650
- } | {
3651
3633
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3652
3634
  readonly description?: string | undefined;
3653
3635
  readonly graph: {
@@ -3723,6 +3705,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
3723
3705
  readonly trackKey: string;
3724
3706
  readonly trackKind: "institution" | "subject" | "year";
3725
3707
  readonly visibleSectionCount: number;
3708
+ } | {
3709
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3710
+ readonly description?: string | undefined;
3711
+ readonly graph: {
3712
+ readonly alignmentId: string;
3713
+ readonly assetId: string;
3714
+ readonly conceptId: string;
3715
+ readonly learningObjectId: string;
3716
+ readonly lensId: string;
3717
+ };
3718
+ readonly sourceRevision: string;
3719
+ readonly title: string;
3720
+ readonly countryKey: string;
3721
+ readonly examKey: string;
3722
+ readonly kind: "exam";
3723
+ readonly order: number;
3724
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
3725
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
3726
3726
  } | {
3727
3727
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
3728
3728
  readonly description?: string | undefined;
@@ -4836,24 +4836,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
4836
4836
  readonly family: "tryout";
4837
4837
  readonly record: {
4838
4838
  readonly row: {
4839
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
4840
- readonly description?: string | undefined;
4841
- readonly graph: {
4842
- readonly alignmentId: string;
4843
- readonly assetId: string;
4844
- readonly conceptId: string;
4845
- readonly learningObjectId: string;
4846
- readonly lensId: string;
4847
- };
4848
- readonly sourceRevision: string;
4849
- readonly title: string;
4850
- readonly countryKey: string;
4851
- readonly examKey: string;
4852
- readonly kind: "exam";
4853
- readonly order: number;
4854
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
4855
- readonly scoringStrategy: "irt" | "penalized" | "raw";
4856
- } | {
4857
4839
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
4858
4840
  readonly description?: string | undefined;
4859
4841
  readonly graph: {
@@ -4929,6 +4911,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
4929
4911
  readonly trackKey: string;
4930
4912
  readonly trackKind: "institution" | "subject" | "year";
4931
4913
  readonly visibleSectionCount: number;
4914
+ } | {
4915
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
4916
+ readonly description?: string | undefined;
4917
+ readonly graph: {
4918
+ readonly alignmentId: string;
4919
+ readonly assetId: string;
4920
+ readonly conceptId: string;
4921
+ readonly learningObjectId: string;
4922
+ readonly lensId: string;
4923
+ };
4924
+ readonly sourceRevision: string;
4925
+ readonly title: string;
4926
+ readonly countryKey: string;
4927
+ readonly examKey: string;
4928
+ readonly kind: "exam";
4929
+ readonly order: number;
4930
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
4931
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
4932
4932
  } | {
4933
4933
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
4934
4934
  readonly description?: string | undefined;
@@ -5402,24 +5402,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
5402
5402
  readonly family: "tryout";
5403
5403
  readonly record: {
5404
5404
  readonly row: {
5405
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
5406
- readonly description?: string | undefined;
5407
- readonly graph: {
5408
- readonly alignmentId: string;
5409
- readonly assetId: string;
5410
- readonly conceptId: string;
5411
- readonly learningObjectId: string;
5412
- readonly lensId: string;
5413
- };
5414
- readonly sourceRevision: string;
5415
- readonly title: string;
5416
- readonly countryKey: string;
5417
- readonly examKey: string;
5418
- readonly kind: "exam";
5419
- readonly order: number;
5420
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
5421
- readonly scoringStrategy: "irt" | "penalized" | "raw";
5422
- } | {
5423
5405
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
5424
5406
  readonly description?: string | undefined;
5425
5407
  readonly graph: {
@@ -5495,6 +5477,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
5495
5477
  readonly trackKey: string;
5496
5478
  readonly trackKind: "institution" | "subject" | "year";
5497
5479
  readonly visibleSectionCount: number;
5480
+ } | {
5481
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
5482
+ readonly description?: string | undefined;
5483
+ readonly graph: {
5484
+ readonly alignmentId: string;
5485
+ readonly assetId: string;
5486
+ readonly conceptId: string;
5487
+ readonly learningObjectId: string;
5488
+ readonly lensId: string;
5489
+ };
5490
+ readonly sourceRevision: string;
5491
+ readonly title: string;
5492
+ readonly countryKey: string;
5493
+ readonly examKey: string;
5494
+ readonly kind: "exam";
5495
+ readonly order: number;
5496
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
5497
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
5498
5498
  } | {
5499
5499
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
5500
5500
  readonly description?: string | undefined;
@@ -6606,24 +6606,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
6606
6606
  readonly family: "tryout";
6607
6607
  readonly record: {
6608
6608
  readonly row: {
6609
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
6610
- readonly description?: string | undefined;
6611
- readonly graph: {
6612
- readonly alignmentId: string;
6613
- readonly assetId: string;
6614
- readonly conceptId: string;
6615
- readonly learningObjectId: string;
6616
- readonly lensId: string;
6617
- };
6618
- readonly sourceRevision: string;
6619
- readonly title: string;
6620
- readonly countryKey: string;
6621
- readonly examKey: string;
6622
- readonly kind: "exam";
6623
- readonly order: number;
6624
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
6625
- readonly scoringStrategy: "irt" | "penalized" | "raw";
6626
- } | {
6627
6609
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
6628
6610
  readonly description?: string | undefined;
6629
6611
  readonly graph: {
@@ -6699,6 +6681,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
6699
6681
  readonly trackKey: string;
6700
6682
  readonly trackKind: "institution" | "subject" | "year";
6701
6683
  readonly visibleSectionCount: number;
6684
+ } | {
6685
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
6686
+ readonly description?: string | undefined;
6687
+ readonly graph: {
6688
+ readonly alignmentId: string;
6689
+ readonly assetId: string;
6690
+ readonly conceptId: string;
6691
+ readonly learningObjectId: string;
6692
+ readonly lensId: string;
6693
+ };
6694
+ readonly sourceRevision: string;
6695
+ readonly title: string;
6696
+ readonly countryKey: string;
6697
+ readonly examKey: string;
6698
+ readonly kind: "exam";
6699
+ readonly order: number;
6700
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
6701
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
6702
6702
  } | {
6703
6703
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
6704
6704
  readonly description?: string | undefined;
@@ -7172,24 +7172,6 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
7172
7172
  readonly family: "tryout";
7173
7173
  readonly record: {
7174
7174
  readonly row: {
7175
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
7176
- readonly description?: string | undefined;
7177
- readonly graph: {
7178
- readonly alignmentId: string;
7179
- readonly assetId: string;
7180
- readonly conceptId: string;
7181
- readonly learningObjectId: string;
7182
- readonly lensId: string;
7183
- };
7184
- readonly sourceRevision: string;
7185
- readonly title: string;
7186
- readonly countryKey: string;
7187
- readonly examKey: string;
7188
- readonly kind: "exam";
7189
- readonly order: number;
7190
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
7191
- readonly scoringStrategy: "irt" | "penalized" | "raw";
7192
- } | {
7193
7175
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
7194
7176
  readonly description?: string | undefined;
7195
7177
  readonly graph: {
@@ -7265,6 +7247,24 @@ export declare const decodePublicationRequest: (input: unknown) => Effect.Effect
7265
7247
  readonly trackKey: string;
7266
7248
  readonly trackKind: "institution" | "subject" | "year";
7267
7249
  readonly visibleSectionCount: number;
7250
+ } | {
7251
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
7252
+ readonly description?: string | undefined;
7253
+ readonly graph: {
7254
+ readonly alignmentId: string;
7255
+ readonly assetId: string;
7256
+ readonly conceptId: string;
7257
+ readonly learningObjectId: string;
7258
+ readonly lensId: string;
7259
+ };
7260
+ readonly sourceRevision: string;
7261
+ readonly title: string;
7262
+ readonly countryKey: string;
7263
+ readonly examKey: string;
7264
+ readonly kind: "exam";
7265
+ readonly order: number;
7266
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
7267
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
7268
7268
  } | {
7269
7269
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
7270
7270
  readonly description?: string | undefined;
@@ -1,4 +1,5 @@
1
1
  import { Effect, Schema } from "effect";
2
+ import { encodeJsonText } from "#contracts/text/json";
2
3
  /** A try-out snapshot is incomplete or inconsistent across app locales. */
3
4
  export class TryoutClosureError extends Schema.TaggedError()("TryoutClosureError", {
4
5
  actual: Schema.String,
@@ -17,7 +18,7 @@ export class TryoutClosureError extends Schema.TaggedError()("TryoutClosureError
17
18
  }
18
19
  /** Serializes locale sets through the active list's signed canonical order. */
19
20
  function localeSetIdentity(locales, activeAppLocales) {
20
- return JSON.stringify(activeAppLocales.filter((locale) => locales.has(locale)));
21
+ return encodeJsonText(activeAppLocales.filter((locale) => locales.has(locale)));
21
22
  }
22
23
  /** Adds one active locale to a logical identity without duplicates. */
23
24
  export function addLocale(localesByIdentity, activeAppLocales, identity, appLocale) {
@@ -25,7 +26,7 @@ export function addLocale(localesByIdentity, activeAppLocales, identity, appLoca
25
26
  return Effect.fail(new TryoutClosureError({
26
27
  actual: appLocale,
27
28
  code: "inactive-locale",
28
- expected: JSON.stringify(activeAppLocales),
29
+ expected: encodeJsonText(activeAppLocales),
29
30
  identity,
30
31
  }));
31
32
  }
@@ -48,13 +49,13 @@ export function validateLocales(localesByIdentity, activeAppLocales) {
48
49
  return Effect.fail(new TryoutClosureError({
49
50
  actual: "[]",
50
51
  code: "missing-locale",
51
- expected: JSON.stringify(activeAppLocales),
52
+ expected: encodeJsonText(activeAppLocales),
52
53
  identity: "empty",
53
54
  }));
54
55
  }
55
56
  return Effect.forEach(localesByIdentity, ([identity, locales]) => {
56
57
  const actual = localeSetIdentity(locales, activeAppLocales);
57
- const expected = JSON.stringify(activeAppLocales);
58
+ const expected = encodeJsonText(activeAppLocales);
58
59
  if (actual === expected) {
59
60
  return Effect.void;
60
61
  }
@@ -1,9 +1,10 @@
1
1
  import { canonicalQuestionBlueprint } from "#contracts/question/item";
2
2
  import { canonicalQuestionResponse, canonicalQuestionResponseStructure, } from "#contracts/question/response";
3
+ import { encodeJsonText } from "#contracts/text/json";
3
4
  import { canonicalAssessmentLanguagePolicy } from "#contracts/tryout/language";
4
5
  /** Serializes assessed prompt facts reused across application locales. */
5
6
  export function canonicalizeAssessedLanguagePlacementFacts(row) {
6
- return JSON.stringify({
7
+ return encodeJsonText({
7
8
  deliveryLanguage: row.deliveryLanguage,
8
9
  questionArtifactHash: row.questionArtifactHash,
9
10
  questionArtifactLocale: row.questionArtifactLocale,
@@ -13,7 +14,7 @@ export function canonicalizeAssessedLanguagePlacementFacts(row) {
13
14
  }
14
15
  /** Serializes placement facts that cannot vary with application locale. */
15
16
  export function canonicalizeLocaleNeutralPlacementFacts(row) {
16
- return JSON.stringify({
17
+ return encodeJsonText({
17
18
  answerContentKey: row.answerContentKey,
18
19
  ...(row.blueprint === undefined
19
20
  ? {}
@@ -1,5 +1,6 @@
1
1
  import { Effect } from "effect";
2
2
  import { canonicalizeLearningGraphIdentity } from "#contracts/graph/spec";
3
+ import { encodeJsonText } from "#contracts/text/json";
3
4
  import { compareCodeUnits } from "#contracts/text/order";
4
5
  import { hashTryoutCanonical } from "#contracts/tryout/canonical";
5
6
  import { TryoutCatalogRecordSchema, } from "#contracts/tryout/catalog";
@@ -52,14 +53,14 @@ export function canonicalizeTryoutCatalogFacts(row) {
52
53
  sourceRevision: row.sourceRevision,
53
54
  };
54
55
  if (row.kind === "country") {
55
- return JSON.stringify({
56
+ return encodeJsonText({
56
57
  ...shared,
57
58
  countryCode: row.countryCode,
58
59
  countryKey: row.countryKey,
59
60
  });
60
61
  }
61
62
  if (row.kind === "exam") {
62
- return JSON.stringify({
63
+ return encodeJsonText({
63
64
  ...shared,
64
65
  countryKey: row.countryKey,
65
66
  examKey: row.examKey,
@@ -67,7 +68,7 @@ export function canonicalizeTryoutCatalogFacts(row) {
67
68
  });
68
69
  }
69
70
  if (row.kind === "track") {
70
- return JSON.stringify({
71
+ return encodeJsonText({
71
72
  ...shared,
72
73
  countryKey: row.countryKey,
73
74
  examKey: row.examKey,
@@ -80,7 +81,7 @@ export function canonicalizeTryoutCatalogFacts(row) {
80
81
  });
81
82
  }
82
83
  if (row.kind === "set") {
83
- return JSON.stringify({
84
+ return encodeJsonText({
84
85
  ...shared,
85
86
  countryKey: row.countryKey,
86
87
  examKey: row.examKey,
@@ -93,7 +94,7 @@ export function canonicalizeTryoutCatalogFacts(row) {
93
94
  visibleSectionCount: row.visibleSectionCount,
94
95
  });
95
96
  }
96
- return JSON.stringify({
97
+ return encodeJsonText({
97
98
  ...shared,
98
99
  countryKey: row.countryKey,
99
100
  examKey: row.examKey,
@@ -119,7 +120,7 @@ export function canonicalizeTryoutCatalog(row) {
119
120
  title: row.title,
120
121
  };
121
122
  if (row.kind === "country") {
122
- return JSON.stringify({
123
+ return encodeJsonText({
123
124
  ...localized,
124
125
  countryCode: row.countryCode,
125
126
  countryKey: row.countryKey,
@@ -129,7 +130,7 @@ export function canonicalizeTryoutCatalog(row) {
129
130
  });
130
131
  }
131
132
  if (row.kind === "exam") {
132
- return JSON.stringify({
133
+ return encodeJsonText({
133
134
  ...localized,
134
135
  countryKey: row.countryKey,
135
136
  examKey: row.examKey,
@@ -140,7 +141,7 @@ export function canonicalizeTryoutCatalog(row) {
140
141
  });
141
142
  }
142
143
  if (row.kind === "track") {
143
- return JSON.stringify({
144
+ return encodeJsonText({
144
145
  ...localized,
145
146
  countryKey: row.countryKey,
146
147
  examKey: row.examKey,
@@ -156,7 +157,7 @@ export function canonicalizeTryoutCatalog(row) {
156
157
  });
157
158
  }
158
159
  if (row.kind === "set") {
159
- return JSON.stringify({
160
+ return encodeJsonText({
160
161
  ...localized,
161
162
  countryKey: row.countryKey,
162
163
  examKey: row.examKey,
@@ -172,7 +173,7 @@ export function canonicalizeTryoutCatalog(row) {
172
173
  visibleSectionCount: row.visibleSectionCount,
173
174
  });
174
175
  }
175
- return JSON.stringify({
176
+ return encodeJsonText({
176
177
  ...localized,
177
178
  countryKey: row.countryKey,
178
179
  examKey: row.examKey,
@@ -5,6 +5,7 @@ import { AppLocaleSchema, ArtifactLocaleSchema, DeliveryLanguageSchema, } from "
5
5
  import { QuestionKeySchema } from "#contracts/question/identity";
6
6
  import { canonicalQuestionBlueprint, QuestionBlueprintSchema, } from "#contracts/question/item";
7
7
  import { canonicalQuestionResponse, QuestionResponseSchema, } from "#contracts/question/response";
8
+ import { encodeJsonText } from "#contracts/text/json";
8
9
  import { TryoutKeySchema } from "#contracts/tryout/key";
9
10
  import { AssessmentLanguagePolicySchema, canonicalAssessmentLanguagePolicy, } from "#contracts/tryout/language";
10
11
  import { TryoutContentHashSchema, TryoutSourceRevisionSchema, } from "#contracts/tryout/spec";
@@ -40,7 +41,7 @@ function dateEpoch(date) {
40
41
  }
41
42
  /** Serializes every current question-pair identity field in stable order. */
42
43
  export function canonicalizeTryoutContent(input) {
43
- return JSON.stringify({
44
+ return encodeJsonText({
44
45
  answerArtifactLocale: input.answerArtifactLocale,
45
46
  answerBody: normalizeBody(input.answerBody),
46
47
  appLocale: input.appLocale,
@@ -1,5 +1,6 @@
1
1
  import { canonicalQuestionBlueprint } from "#contracts/question/item";
2
2
  import { canonicalQuestionResponse } from "#contracts/question/response";
3
+ import { encodeJsonText } from "#contracts/text/json";
3
4
  import { hashTryoutCanonical } from "#contracts/tryout/canonical";
4
5
  import { digestTryoutRecords } from "#contracts/tryout/digest";
5
6
  import { tryoutPlacementIdentity } from "#contracts/tryout/identity";
@@ -8,7 +9,7 @@ import { TryoutPlacementRecordSchema, } from "#contracts/tryout/placement";
8
9
  const PLACEMENT_DOMAIN = "nakafa.aksara.tryout-placements";
9
10
  /** Serializes one artifact-bound placement with stable field order. */
10
11
  export function canonicalizeTryoutPlacement(row) {
11
- return JSON.stringify({
12
+ return encodeJsonText({
12
13
  answerArtifactHash: row.answerArtifactHash,
13
14
  answerArtifactLocale: row.answerArtifactLocale,
14
15
  answerContentKey: row.answerContentKey,
@@ -1,4 +1,4 @@
1
- import { Schema } from "effect";
1
+ import { Array as Arr, Schema } from "effect";
2
2
  import { ACTIVE_APP_LOCALES, ArtifactLocaleSchema, DeliveryLanguageSchema, } from "#contracts/locale";
3
3
  /** Source-owned policy for the language presented by one assessment section. */
4
4
  export const AssessmentLanguagePolicySchema = Schema.Union([
@@ -20,9 +20,7 @@ export function questionArtifactLocaleForPolicy(policy, appLocale) {
20
20
  }
21
21
  /** Lists unique prompt and response locales required by one section policy. */
22
22
  export function questionArtifactLocalesForPolicy(policy) {
23
- return Object.freeze([
24
- ...new Set(ACTIVE_APP_LOCALES.map((appLocale) => questionArtifactLocaleForPolicy(policy, appLocale))),
25
- ]);
23
+ return Object.freeze(Arr.dedupe(ACTIVE_APP_LOCALES.map((appLocale) => questionArtifactLocaleForPolicy(policy, appLocale))));
26
24
  }
27
25
  /** Returns policy facts in stable field order for signed canonicalizers. */
28
26
  export function canonicalAssessmentLanguagePolicy(policy) {
@@ -1,9 +1,10 @@
1
+ import { encodeJsonText } from "#contracts/text/json";
1
2
  import { TRYOUT_RUNTIME_BUNDLE_FORMAT } from "#contracts/tryout/runtime/spec";
2
3
  /** Ed25519 domain separating runtime bundles from every other signed object. */
3
4
  export const TRYOUT_RUNTIME_BUNDLE_SIGNATURE_DOMAIN = "nakafa.aksara.tryout-runtime-bundle";
4
5
  /** Serializes one complete runtime payload with stable signed field order. */
5
6
  export function canonicalizeTryoutRuntimeBundlePayload(payload) {
6
- return JSON.stringify({
7
+ return encodeJsonText({
7
8
  format: TRYOUT_RUNTIME_BUNDLE_FORMAT,
8
9
  rendererManifestHash: payload.rendererManifestHash,
9
10
  snapshot: {
@@ -1,4 +1,4 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect, MutableHashMap, Schema } from "effect";
2
2
  import type { TryoutCatalogRow, TryoutSection, TryoutSet } from "#contracts/tryout/catalog";
3
3
  import type { TryoutPlacement } from "#contracts/tryout/placement";
4
4
  import type { TryoutScoring } from "#contracts/tryout/spec";
@@ -14,21 +14,25 @@ declare const TryoutScoringError_base: Schema.Class<TryoutScoringError, Schema.T
14
14
  */
15
15
  export declare class TryoutScoringError extends TryoutScoringError_base {
16
16
  }
17
- /** Exam strategies, sets, and sections gathered while a catalog is read. */
18
- export interface TryoutScoringFacts {
19
- readonly exams: Map<string, TryoutScoring>;
20
- readonly sections: TryoutSection[];
21
- readonly sets: Map<string, TryoutSet>;
22
- }
23
17
  /** Creates empty scoring facts for one snapshot verification pass. */
24
- export declare function makeTryoutScoringFacts(): TryoutScoringFacts;
18
+ export declare function makeTryoutScoringFacts(): {
19
+ readonly exams: MutableHashMap.MutableHashMap<string, TryoutScoring>;
20
+ readonly sections: TryoutSection[];
21
+ readonly sets: MutableHashMap.MutableHashMap<string, TryoutSet>;
22
+ };
23
+ /** Exam strategies, sets, and sections gathered while a catalog is read. */
24
+ export type TryoutScoringFacts = ReturnType<typeof makeTryoutScoringFacts>;
25
25
  /** Records the scoring facts carried by one localized catalog row. */
26
26
  export declare function recordTryoutScoringFacts(facts: TryoutScoringFacts, row: TryoutCatalogRow): void;
27
27
  /**
28
28
  * Requires every set to repeat its exam's strategy and marks on exactly the
29
29
  * sections of penalized sets, once the complete catalog has been recorded.
30
30
  */
31
- export declare const validateTryoutScoringFacts: (facts: TryoutScoringFacts) => Effect.Effect<void, TryoutScoringError, never>;
31
+ export declare const validateTryoutScoringFacts: (facts: {
32
+ readonly exams: MutableHashMap.MutableHashMap<string, TryoutScoring>;
33
+ readonly sections: TryoutSection[];
34
+ readonly sets: MutableHashMap.MutableHashMap<string, TryoutSet>;
35
+ }) => Effect.Effect<void, TryoutScoringError, never>;
32
36
  /**
33
37
  * Requires one rubric placement to belong to a raw-scored set, because a
34
38
  * rubric awards points per criterion instead of a correct or wrong outcome.
@@ -1,4 +1,4 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect, MutableHashMap, Option, Schema } from "effect";
2
2
  import { tryoutCatalogIdentity, tryoutCatalogNodeIdentity, tryoutPlacementIdentity, } from "#contracts/tryout/identity";
3
3
  /**
4
4
  * A signed try-out row cannot be scored as published. `strategy` means a set
@@ -13,21 +13,28 @@ export class TryoutScoringError extends Schema.TaggedError()("TryoutScoringError
13
13
  }
14
14
  /** Creates empty scoring facts for one snapshot verification pass. */
15
15
  export function makeTryoutScoringFacts() {
16
- return { exams: new Map(), sections: [], sets: new Map() };
16
+ return {
17
+ exams: MutableHashMap.empty(),
18
+ sections: [],
19
+ sets: MutableHashMap.empty(),
20
+ };
17
21
  }
18
22
  /** Records the scoring facts carried by one localized catalog row. */
19
23
  export function recordTryoutScoringFacts(facts, row) {
20
24
  if (row.kind === "exam") {
21
- facts.exams.set(tryoutCatalogIdentity(row), row.scoringStrategy);
25
+ MutableHashMap.set(facts.exams, tryoutCatalogIdentity(row), row.scoringStrategy);
22
26
  }
23
27
  if (row.kind === "set") {
24
- facts.sets.set(tryoutCatalogIdentity(row), row);
28
+ MutableHashMap.set(facts.sets, tryoutCatalogIdentity(row), row);
25
29
  }
26
30
  if (row.kind === "section") {
27
31
  facts.sections.push(row);
28
32
  }
29
33
  }
30
- /** Returns the strategy of the set that owns one section or placement. */
34
+ /**
35
+ * Returns the strategy of the set that owns one section or placement. The row
36
+ * is a locale-specific set reference shared by sections and placements.
37
+ */
31
38
  function setStrategy(facts, row) {
32
39
  const identity = tryoutCatalogNodeIdentity({
33
40
  appLocale: row.appLocale,
@@ -37,7 +44,8 @@ function setStrategy(facts, row) {
37
44
  setKey: row.setKey,
38
45
  trackKey: row.trackKey,
39
46
  });
40
- return facts.sets.get(identity)?.scoringStrategy;
47
+ return Option.getOrUndefined(MutableHashMap.get(facts.sets, identity))
48
+ ?.scoringStrategy;
41
49
  }
42
50
  /** Requires one set to score with the strategy its exam declares. */
43
51
  function validateSetStrategy(facts, row) {
@@ -47,7 +55,8 @@ function validateSetStrategy(facts, row) {
47
55
  examKey: row.examKey,
48
56
  kind: "exam",
49
57
  });
50
- if (facts.exams.get(exam) === row.scoringStrategy) {
58
+ if (Option.getOrUndefined(MutableHashMap.get(facts.exams, exam)) ===
59
+ row.scoringStrategy) {
51
60
  return Effect.void;
52
61
  }
53
62
  return Effect.fail(new TryoutScoringError({
@@ -71,7 +80,7 @@ function validateSectionMarks(facts, row) {
71
80
  * sections of penalized sets, once the complete catalog has been recorded.
72
81
  */
73
82
  export const validateTryoutScoringFacts = Effect.fn("AksaraContracts.validateTryoutScoringFacts")(function* (facts) {
74
- yield* Effect.forEach(facts.sets.values(), (row) => validateSetStrategy(facts, row), { discard: true });
83
+ yield* Effect.forEach(MutableHashMap.values(facts.sets), (row) => validateSetStrategy(facts, row), { discard: true });
75
84
  yield* Effect.forEach(facts.sections, (row) => validateSectionMarks(facts, row), { discard: true });
76
85
  });
77
86
  /**
@@ -1,3 +1,4 @@
1
+ import { encodeJsonText } from "#contracts/text/json";
1
2
  import { TRYOUT_SNAPSHOT_FORMAT } from "#contracts/tryout/snapshot/spec";
2
3
  /** Domain separating snapshot identities from every other try-out digest. */
3
4
  export const TRYOUT_SNAPSHOT_DOMAIN = "nakafa.aksara.localized-tryout-snapshot";
@@ -5,7 +6,7 @@ export const TRYOUT_SNAPSHOT_DOMAIN = "nakafa.aksara.localized-tryout-snapshot";
5
6
  export const TRYOUT_SNAPSHOT_ROWS_DOMAIN = "nakafa.aksara.tryout-rows";
6
7
  /** Serializes snapshot facts without content-addressed identity. */
7
8
  export function canonicalizeTryoutSnapshot(input) {
8
- return JSON.stringify({
9
+ return encodeJsonText({
9
10
  activeAppLocales: input.activeAppLocales,
10
11
  catalogDigest: input.catalogDigest,
11
12
  counts: input.counts,
@@ -1,3 +1,4 @@
1
+ import { Record as Rec } from "effect";
1
2
  import { hashTryoutCanonical } from "#contracts/tryout/canonical";
2
3
  import { canonicalizeTryoutSnapshot, TRYOUT_SNAPSHOT_DOMAIN, TRYOUT_SNAPSHOT_ROWS_DOMAIN, } from "#contracts/tryout/snapshot/canonical";
3
4
  import { TRYOUT_SNAPSHOT_FORMAT, TryoutSnapshotSchema, } from "#contracts/tryout/snapshot/spec";
@@ -12,7 +13,7 @@ export function makeTryoutSnapshot(input) {
12
13
  /** Returns exact structured row evidence authenticated by a snapshot. */
13
14
  export function tryoutSnapshotRowEvidence(input) {
14
15
  return {
15
- rowCount: Object.values(input.counts).reduce((total, count) => total + count, 0) +
16
+ rowCount: Rec.values(input.counts).reduce((total, count) => total + count, 0) +
16
17
  input.placementCount,
17
18
  rowDigest: hashTryoutCanonical(TRYOUT_SNAPSHOT_ROWS_DOMAIN, `${input.catalogDigest}\n${input.placementDigest}`),
18
19
  };