@nakafa/aksara-contracts 0.47.0 → 0.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content.d.ts +8 -6
- package/dist/content.js +8 -3
- package/dist/math/arc.js +5 -1
- package/dist/math/base.js +6 -6
- package/dist/math/collision.d.ts +4 -4
- package/dist/math/collision.js +15 -9
- package/dist/math/coordinate.d.ts +24 -13
- package/dist/math/coordinate.js +16 -2
- package/dist/math/extent.d.ts +26 -17
- package/dist/math/extent.js +18 -2
- package/dist/math/intersection.d.ts +21 -11
- package/dist/math/intersection.js +14 -1
- package/dist/math/precision.js +3 -3
- package/dist/math/proximity.d.ts +11 -7
- package/dist/math/proximity.js +21 -4
- package/dist/math/rational.d.ts +6 -5
- package/dist/math/rational.js +6 -1
- package/dist/math/resolution.d.ts +1 -1
- package/dist/math/resolution.js +12 -4
- package/dist/math/scene.d.ts +22 -3
- package/dist/preview/auth.js +2 -1
- package/dist/preview/target.js +7 -0
- package/dist/program/curriculum.js +2 -1
- package/dist/program/snapshot/digest.js +32 -31
- package/dist/program/snapshot/hash.js +2 -1
- package/dist/program/spec.js +2 -1
- package/dist/projection/article.js +2 -1
- package/dist/projection/material.js +2 -1
- package/dist/projection/page.js +2 -1
- package/dist/projection/question.d.ts +544 -17
- package/dist/projection/question.js +17 -3
- package/dist/projection/verify.d.ts +4 -3
- package/dist/projection/verify.js +14 -7
- package/dist/question/answer.d.ts +12 -6
- package/dist/question/answer.js +17 -2
- package/dist/question/item.js +5 -4
- package/dist/question/response.js +3 -3
- package/dist/question/rubric.js +2 -1
- package/dist/quran/identity.js +11 -0
- package/dist/quran/notes.js +13 -0
- package/dist/quran/provenance.js +3 -2
- package/dist/quran/snapshot/digest.js +4 -3
- package/dist/quran/snapshot/hash.js +2 -1
- package/dist/quran/snapshot/row/hash.js +5 -4
- package/dist/quran/snapshot/spec.js +3 -2
- package/dist/release/canonical.js +2 -1
- package/dist/release/head.js +2 -1
- package/dist/release/items.d.ts +5 -4
- package/dist/release/items.js +14 -9
- package/dist/release/result/digest.js +4 -4
- package/dist/release/rollback/spec.js +6 -5
- package/dist/release/route/spec.js +4 -3
- package/dist/release/route/verify.d.ts +4 -3
- package/dist/release/route/verify.js +9 -6
- package/dist/release/signing.js +2 -1
- package/dist/release/snapshot/data.js +3 -2
- package/dist/release/snapshot/evidence/tryout.js +6 -1
- package/dist/release/snapshot/spec.js +7 -6
- package/dist/release/snapshot/verify.d.ts +27 -4
- package/dist/release/snapshot/verify.js +13 -9
- package/dist/renderer/compatibility.js +8 -5
- package/dist/renderer/contract.js +5 -4
- package/dist/runtime/protected/limits.js +2 -1
- package/dist/runtime/protected/spec.js +3 -3
- package/dist/text/json.d.ts +5 -0
- package/dist/text/json.js +5 -0
- package/dist/transport/request.d.ts +108 -108
- package/dist/tryout/closure/accounting.d.ts +5 -3
- package/dist/tryout/closure/accounting.js +12 -10
- package/dist/tryout/closure/locale.js +32 -24
- package/dist/tryout/closure/placement.js +3 -2
- package/dist/tryout/hash/catalog.js +11 -10
- package/dist/tryout/hash/content.js +2 -1
- package/dist/tryout/hash/placement.js +2 -1
- package/dist/tryout/language.js +2 -4
- package/dist/tryout/runtime/canonical.js +2 -1
- package/dist/tryout/scoring.d.ts +13 -9
- package/dist/tryout/scoring.js +17 -8
- package/dist/tryout/snapshot/canonical.js +2 -1
- package/dist/tryout/snapshot/hash.js +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Schema, Stream } from "effect";
|
|
1
|
+
import { Effect, MutableHashMap, Option, Schema, Stream } from "effect";
|
|
2
2
|
import { compareContentHeads, routeIdentity } from "#contracts/content";
|
|
3
3
|
import { PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
4
4
|
import { digestProjections } from "#contracts/projection/digest";
|
|
@@ -31,6 +31,16 @@ export class ProjectionDigestError extends Schema.TaggedError()("ProjectionDiges
|
|
|
31
31
|
releaseId: ReleaseIdSchema,
|
|
32
32
|
}) {
|
|
33
33
|
}
|
|
34
|
+
/** Creates the replay state that one stream of projections shares while it decodes. */
|
|
35
|
+
function projectionState() {
|
|
36
|
+
return {
|
|
37
|
+
firstIndexByRoute: MutableHashMap.empty(),
|
|
38
|
+
previous: undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const VerifiedContentProjectionsSchema = Schema.Struct({
|
|
42
|
+
count: Schema.Finite,
|
|
43
|
+
});
|
|
34
44
|
/** Decodes one row and applies canonical order and route uniqueness rules. */
|
|
35
45
|
const decodeProjection = Effect.fn("AksaraContracts.decodeProjection")(function* (state, source, projectionIndex) {
|
|
36
46
|
const projection = yield* Schema.decodeUnknownEffect(ContentProjectionSchema)(source, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new ProjectionDecodeError({ projectionIndex })));
|
|
@@ -44,7 +54,7 @@ const decodeProjection = Effect.fn("AksaraContracts.decodeProjection")(function*
|
|
|
44
54
|
}
|
|
45
55
|
const { appLocale, publicPath } = projection;
|
|
46
56
|
const identity = routeIdentity({ appLocale, publicPath });
|
|
47
|
-
const firstIndex =
|
|
57
|
+
const firstIndex = Option.getOrUndefined(MutableHashMap.get(state.firstIndexByRoute, identity));
|
|
48
58
|
if (firstIndex !== undefined) {
|
|
49
59
|
return yield* new ProjectionRouteError({
|
|
50
60
|
duplicateIndex: projectionIndex,
|
|
@@ -52,16 +62,13 @@ const decodeProjection = Effect.fn("AksaraContracts.decodeProjection")(function*
|
|
|
52
62
|
publicPath,
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
|
-
state.firstIndexByRoute
|
|
65
|
+
MutableHashMap.set(state.firstIndexByRoute, identity, projectionIndex);
|
|
56
66
|
return projection;
|
|
57
67
|
});
|
|
58
68
|
/** Strictly decodes a replayable canonical content projection stream. */
|
|
59
69
|
export function decodeContentProjections(projections) {
|
|
60
70
|
return Stream.unwrap(Effect.sync(() => {
|
|
61
|
-
const state =
|
|
62
|
-
firstIndexByRoute: new Map(),
|
|
63
|
-
previous: undefined,
|
|
64
|
-
};
|
|
71
|
+
const state = projectionState();
|
|
65
72
|
return projections.pipe(Stream.zipWithIndex, Stream.mapEffect(([source, projectionIndex]) => decodeProjection(state, source, projectionIndex)));
|
|
66
73
|
}));
|
|
67
74
|
}
|
|
@@ -70,11 +70,12 @@ export type QuestionAnswerKey = typeof QuestionAnswerKeySchema.Type;
|
|
|
70
70
|
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
71
71
|
* records that the learner wrote `p/q`.
|
|
72
72
|
*/
|
|
73
|
-
|
|
74
|
-
readonly denominator:
|
|
75
|
-
readonly fraction:
|
|
76
|
-
readonly numerator:
|
|
77
|
-
}
|
|
73
|
+
declare const QuestionNumberAnswerSchema: Schema.Struct<{
|
|
74
|
+
readonly denominator: Schema.BigDecimal;
|
|
75
|
+
readonly fraction: Schema.Boolean;
|
|
76
|
+
readonly numerator: Schema.BigDecimal;
|
|
77
|
+
}>;
|
|
78
|
+
export type QuestionNumberAnswer = typeof QuestionNumberAnswerSchema.Type;
|
|
78
79
|
/**
|
|
79
80
|
* Checks whether one typed learner answer is blank: nothing remains once it is
|
|
80
81
|
* read as visible text, so whitespace and invisible format characters alone
|
|
@@ -94,7 +95,11 @@ export declare function isBlankAnswer(answer: string): boolean;
|
|
|
94
95
|
* separators, exponents, mixed numbers such as `1 1/2`, and empty input are
|
|
95
96
|
* not numbers.
|
|
96
97
|
*/
|
|
97
|
-
export declare function readNumberAnswer(input: string, language: AppLocaleCode): Option.Option<
|
|
98
|
+
export declare function readNumberAnswer(input: string, language: AppLocaleCode): Option.Option<{
|
|
99
|
+
readonly denominator: BigDecimal.BigDecimal;
|
|
100
|
+
readonly fraction: boolean;
|
|
101
|
+
readonly numerator: BigDecimal.BigDecimal;
|
|
102
|
+
}>;
|
|
98
103
|
/**
|
|
99
104
|
* Grades one typed learner answer against its key, as every runtime must. A
|
|
100
105
|
* text key matches when the answer normalizes to one accepted answer. A
|
|
@@ -147,3 +152,4 @@ export declare function canonicalQuestionAnswerKeyStructure(key: QuestionAnswerK
|
|
|
147
152
|
ignoreCase: boolean;
|
|
148
153
|
kind: "text";
|
|
149
154
|
};
|
|
155
|
+
export {};
|
package/dist/question/answer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigDecimal, Option, Schema, String as Str } from "effect";
|
|
1
|
+
import { BigDecimal, HashSet, Option, Schema, String as Str } from "effect";
|
|
2
2
|
const DECIMAL_PATTERN = /^(?:0|-?[1-9]\d*|-?(?:0|[1-9]\d*)\.\d*[1-9])$/u;
|
|
3
3
|
const UNTYPABLE_CHARACTER_PATTERN = /[\p{Cc}\p{Cf}]|[^\S ]/u;
|
|
4
4
|
const FORMAT_CHARACTER_PATTERN = /\p{Cf}/gu;
|
|
@@ -77,6 +77,11 @@ function visibleText(text) {
|
|
|
77
77
|
.trim()
|
|
78
78
|
.replace(WHITESPACE_PATTERN, " ");
|
|
79
79
|
}
|
|
80
|
+
/** Text grading rules that every learner and accepted answer passes through. */
|
|
81
|
+
const TextKeyRulesSchema = Schema.Struct({
|
|
82
|
+
collapseWhitespace: Schema.Boolean,
|
|
83
|
+
ignoreCase: Schema.Boolean,
|
|
84
|
+
});
|
|
80
85
|
/**
|
|
81
86
|
* Normalizes one learner or accepted text answer exactly as graders compare
|
|
82
87
|
* it. `ignoreCase` first applies the locale-independent Unicode lowercase
|
|
@@ -94,7 +99,7 @@ function normalizeTextAnswer(text, rules) {
|
|
|
94
99
|
/** Checks that no two accepted answers grade as the same normalized text. */
|
|
95
100
|
function hasDistinctAcceptedAnswers(key) {
|
|
96
101
|
const normalized = key.acceptedAnswers.map((text) => normalizeTextAnswer(text, key));
|
|
97
|
-
return
|
|
102
|
+
return HashSet.size(HashSet.fromIterable(normalized)) === normalized.length;
|
|
98
103
|
}
|
|
99
104
|
/**
|
|
100
105
|
* Deterministic text answer key written in the delivery language. A learner
|
|
@@ -115,6 +120,16 @@ export const QuestionAnswerKeySchema = Schema.Union([
|
|
|
115
120
|
QuestionNumberKeySchema,
|
|
116
121
|
QuestionTextKeySchema,
|
|
117
122
|
]);
|
|
123
|
+
/**
|
|
124
|
+
* One learner number read exactly as `numerator / denominator`, with a
|
|
125
|
+
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
126
|
+
* records that the learner wrote `p/q`.
|
|
127
|
+
*/
|
|
128
|
+
const QuestionNumberAnswerSchema = Schema.Struct({
|
|
129
|
+
denominator: Schema.BigDecimal,
|
|
130
|
+
fraction: Schema.Boolean,
|
|
131
|
+
numerator: Schema.BigDecimal,
|
|
132
|
+
});
|
|
118
133
|
/** Reads one signed ASCII number, where U+2212 is a minus sign. */
|
|
119
134
|
function readSigned(text) {
|
|
120
135
|
return BigDecimal.fromString(text.trim().replace("\u2212", "-"));
|
package/dist/question/item.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Effect, Schema, Struct } from "effect";
|
|
1
|
+
import { Effect, Record as Rec, Schema, Struct } from "effect";
|
|
2
2
|
import { AppLocaleCodeSchema, ArtifactLocaleSchema, artifactLocaleCode, } from "#contracts/locale";
|
|
3
3
|
import { QuestionAnswerKeySchema } from "#contracts/question/answer";
|
|
4
4
|
import { QuestionResponseLabelSchema } from "#contracts/question/label";
|
|
5
5
|
import { AuthoredQuestionPointsSchema } from "#contracts/question/points";
|
|
6
6
|
import { canonicalQuestionResponseStructure, QuestionResponseSchema, } from "#contracts/question/response";
|
|
7
7
|
import { freezeQuestionRubric, QuestionRubricResponseSourceSchema, } from "#contracts/question/rubric";
|
|
8
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
8
9
|
import { TryoutKeySchema } from "#contracts/tryout/key";
|
|
9
10
|
const PositiveOrderSchema = Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0)));
|
|
10
11
|
/** One source-authored option before stable runtime identities are derived. */
|
|
@@ -122,11 +123,11 @@ function freezeQuestionResponse(response) {
|
|
|
122
123
|
}
|
|
123
124
|
/** Serializes response shape and answer key for locale comparison. */
|
|
124
125
|
function responseStructure(response) {
|
|
125
|
-
return
|
|
126
|
+
return encodeJsonText(canonicalQuestionResponseStructure(freezeQuestionResponse(response)));
|
|
126
127
|
}
|
|
127
128
|
/** Requires locale siblings to preserve one response format and answer key. */
|
|
128
129
|
function hasCoherentLocalizedResponses(input) {
|
|
129
|
-
const responses =
|
|
130
|
+
const responses = Rec.values(input.responses).filter((response) => response !== undefined);
|
|
130
131
|
const [first] = responses;
|
|
131
132
|
return (first !== undefined &&
|
|
132
133
|
responses.every((response) => responseStructure(response) === responseStructure(first)));
|
|
@@ -134,7 +135,7 @@ function hasCoherentLocalizedResponses(input) {
|
|
|
134
135
|
/** Requires a rubric item to take its worth from the rubric total alone. */
|
|
135
136
|
function hasCoherentPoints(input) {
|
|
136
137
|
return (input.points === undefined ||
|
|
137
|
-
|
|
138
|
+
Rec.values(input.responses).every((response) => response?.kind !== "rubric"));
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
140
141
|
* Complete source-owned item with optional shared-stimulus identity and points.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { HashSet, Schema } from "effect";
|
|
2
2
|
import { canonicalQuestionAnswerKey, canonicalQuestionAnswerKeyStructure, QuestionAnswerKeySchema, } from "#contracts/question/answer";
|
|
3
3
|
import { QuestionResponseLabelSchema } from "#contracts/question/label";
|
|
4
4
|
import { canonicalQuestionRubric, canonicalQuestionRubricStructure, QuestionRubricResponseSchema, } from "#contracts/question/rubric";
|
|
@@ -58,13 +58,13 @@ const QuestionCategoryStatementSchema = Schema.Struct({
|
|
|
58
58
|
});
|
|
59
59
|
/** Checks stable category and statement identities plus valid references. */
|
|
60
60
|
function hasCanonicalCategories(input) {
|
|
61
|
-
const categoryKeys =
|
|
61
|
+
const categoryKeys = HashSet.fromIterable(input.categories.map(({ categoryKey }) => categoryKey));
|
|
62
62
|
return (input.categories.length >= 2 &&
|
|
63
63
|
input.statements.length > 0 &&
|
|
64
64
|
input.categories.every(({ categoryKey, order }, index) => order === index + 1 && categoryKey === `category-${order}`) &&
|
|
65
65
|
input.statements.every(({ correctCategoryKey, order, statementKey }, index) => order === index + 1 &&
|
|
66
66
|
statementKey === `statement-${order}` &&
|
|
67
|
-
|
|
67
|
+
HashSet.has(categoryKeys, correctCategoryKey)));
|
|
68
68
|
}
|
|
69
69
|
const CategoryResponseSchema = Schema.Struct({
|
|
70
70
|
categories: Schema.Array(QuestionCategorySchema),
|
package/dist/question/rubric.js
CHANGED
|
@@ -16,7 +16,8 @@ export const QuestionRubricLabelSchema = Schema.Record(ActiveAppLocaleCodeSchema
|
|
|
16
16
|
/**
|
|
17
17
|
* Checks one criterion scale: two or more levels whose points strictly
|
|
18
18
|
* ascend. A final-answer criterion has exactly two levels and its lower level
|
|
19
|
-
* is worth zero, because a wrong result earns nothing.
|
|
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.
|
|
20
21
|
*/
|
|
21
22
|
function hasOrderedScale(criterion) {
|
|
22
23
|
let previous = -1;
|
package/dist/quran/identity.js
CHANGED
|
@@ -33,6 +33,10 @@ export const QuranNameProvenanceScopeSchema = Schema.TemplateLiteral([
|
|
|
33
33
|
AppLocaleCodeSchema,
|
|
34
34
|
"-surah-name",
|
|
35
35
|
]);
|
|
36
|
+
const QuranNameBindingSchema = Schema.Struct({
|
|
37
|
+
scope: QuranNameProvenanceScopeSchema,
|
|
38
|
+
sourceId: QuranEmbeddedSourceIdSchema,
|
|
39
|
+
});
|
|
36
40
|
const QURAN_NAME_BY_LOCALE = {
|
|
37
41
|
[ENGLISH_APP_LOCALE_CODE]: {
|
|
38
42
|
scope: "en-surah-name",
|
|
@@ -47,6 +51,10 @@ const QURAN_NAME_BY_LOCALE = {
|
|
|
47
51
|
sourceId: "kemenag-names",
|
|
48
52
|
},
|
|
49
53
|
};
|
|
54
|
+
const QuranTranslationBindingSchema = Schema.Struct({
|
|
55
|
+
scope: QuranTranslationProvenanceScopeSchema,
|
|
56
|
+
sourceId: QuranEmbeddedSourceIdSchema,
|
|
57
|
+
});
|
|
50
58
|
const QURAN_TRANSLATION_BY_LOCALE = {
|
|
51
59
|
[ENGLISH_APP_LOCALE_CODE]: {
|
|
52
60
|
scope: "en-translation",
|
|
@@ -61,6 +69,9 @@ const QURAN_TRANSLATION_BY_LOCALE = {
|
|
|
61
69
|
sourceId: "quranenc-indonesian",
|
|
62
70
|
},
|
|
63
71
|
};
|
|
72
|
+
const QuranTafsirBindingSchema = Schema.Struct({
|
|
73
|
+
sourceId: QuranSourceIdSchema,
|
|
74
|
+
});
|
|
64
75
|
const QURAN_TAFSIR_BY_LOCALE = {
|
|
65
76
|
[ENGLISH_APP_LOCALE_CODE]: { sourceId: "mokhtasar-english" },
|
|
66
77
|
[GERMAN_APP_LOCALE_CODE]: { sourceId: "mokhtasar-german" },
|
package/dist/quran/notes.js
CHANGED
|
@@ -34,6 +34,19 @@ export class QuranTranslationNotesError extends Schema.TaggedError()("QuranTrans
|
|
|
34
34
|
]),
|
|
35
35
|
}) {
|
|
36
36
|
}
|
|
37
|
+
const MarkerSchema = Schema.Struct({
|
|
38
|
+
end: Schema.Finite,
|
|
39
|
+
number: Schema.Finite,
|
|
40
|
+
start: Schema.Finite,
|
|
41
|
+
});
|
|
42
|
+
const TranslationAnalysisSchema = Schema.Union([
|
|
43
|
+
Schema.TaggedStruct("Failure", {
|
|
44
|
+
reason: QuranTranslationNotesError.fields.reason,
|
|
45
|
+
}),
|
|
46
|
+
Schema.TaggedStruct("Success", {
|
|
47
|
+
document: QuranTranslationDocumentSchema,
|
|
48
|
+
}),
|
|
49
|
+
]);
|
|
37
50
|
const QuranTranslationSourceSchema = Schema.Struct({
|
|
38
51
|
footnotes: Schema.String,
|
|
39
52
|
text: QuranMeaningfulTextSchema,
|
package/dist/quran/provenance.js
CHANGED
|
@@ -6,6 +6,7 @@ import { canonicalizeQuranAttribution } from "#contracts/quran/attribution";
|
|
|
6
6
|
import { QuranNameProvenanceScopeSchema, QuranTranslationProvenanceScopeSchema, quranNameProvenanceScope, quranNameSourceForScope, quranTafsirSourceId, quranTranslationProvenanceScope, quranTranslationSourceForScope, } from "#contracts/quran/identity";
|
|
7
7
|
import { QuranProvenanceStatusSchema } from "#contracts/quran/snapshot/spec";
|
|
8
8
|
import { hasCompleteQuranSourceCopy, QuranSourceAttributionSchema, } from "#contracts/quran/source";
|
|
9
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
9
10
|
/** Quran source fields that require independent provenance decisions. */
|
|
10
11
|
const QuranStaticProvenanceScopeSchema = Schema.Literals([
|
|
11
12
|
"arabic-text",
|
|
@@ -106,7 +107,7 @@ export class QuranProvenanceHashError extends Schema.TaggedError()("QuranProvena
|
|
|
106
107
|
const PROVENANCE_DOMAIN = "nakafa.aksara.quran-provenance";
|
|
107
108
|
/** Produces stable JSON for one reviewed Quran provenance record. */
|
|
108
109
|
export function canonicalizeQuranProvenance(record) {
|
|
109
|
-
return
|
|
110
|
+
return encodeJsonText({
|
|
110
111
|
attribution: canonicalizeQuranAttribution(record.attribution),
|
|
111
112
|
evidence: record.evidence,
|
|
112
113
|
scope: record.scope,
|
|
@@ -119,7 +120,7 @@ export const hashQuranProvenance = Effect.fn("AksaraContracts.hashQuranProvenanc
|
|
|
119
120
|
try: () => {
|
|
120
121
|
const hash = createHash("sha256")
|
|
121
122
|
.update(`${PROVENANCE_DOMAIN}\n`)
|
|
122
|
-
.update(
|
|
123
|
+
.update(encodeJsonText(input.activeAppLocales))
|
|
123
124
|
.update("\n");
|
|
124
125
|
for (const record of input.records) {
|
|
125
126
|
hash.update(canonicalizeQuranProvenance(record));
|
|
@@ -5,6 +5,7 @@ import { AppLocaleSchema } from "#contracts/locale";
|
|
|
5
5
|
import { hashQuranRow, QuranRowHashError, } from "#contracts/quran/snapshot/row/hash";
|
|
6
6
|
import { quranSourceIds } from "#contracts/quran/source";
|
|
7
7
|
import { QURAN_ATTRIBUTION_COUNT, QURAN_CHUNK_SIZE, QURAN_SURAH_COUNT, QURAN_VERSE_COUNT, } from "#contracts/quran/spec";
|
|
8
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
8
9
|
const RUNTIME_DOMAIN = "nakafa.aksara.quran-runtime";
|
|
9
10
|
const SEARCH_DOMAIN = "nakafa.aksara.quran-search";
|
|
10
11
|
const PROJECTION_DOMAIN = "nakafa.aksara.quran-projection";
|
|
@@ -112,9 +113,9 @@ class QuranDigestState {
|
|
|
112
113
|
const expectedTafsir = this.#activeAppLocales.includes(AppLocaleSchema.make("id"))
|
|
113
114
|
? ["id"]
|
|
114
115
|
: [];
|
|
115
|
-
return payload.verses.every((verse) =>
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
return payload.verses.every((verse) => encodeJsonText(verse.translations.map((translation) => translation.appLocale)) === encodeJsonText(this.#activeAppLocales) &&
|
|
117
|
+
encodeJsonText(verse.tafsir.map((tafsir) => tafsir.appLocale)) ===
|
|
118
|
+
encodeJsonText(expectedTafsir));
|
|
118
119
|
}
|
|
119
120
|
/** Advances deterministic identity state after one accepted row. */
|
|
120
121
|
advance(payload) {
|
|
@@ -2,13 +2,14 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
4
4
|
import { QURAN_SNAPSHOT_FORMAT, QuranSnapshotSchema, } from "#contracts/quran/snapshot/spec";
|
|
5
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
5
6
|
const SNAPSHOT_DOMAIN = "nakafa.aksara.localized-quran-snapshot";
|
|
6
7
|
/** Node could not compute a deterministic Quran snapshot identity. */
|
|
7
8
|
export class QuranSnapshotHashError extends Schema.TaggedError()("QuranSnapshotHashError", {}) {
|
|
8
9
|
}
|
|
9
10
|
/** Serializes Quran snapshot facts in stable signed field order. */
|
|
10
11
|
export function canonicalizeQuranSnapshot(input) {
|
|
11
|
-
return
|
|
12
|
+
return encodeJsonText({
|
|
12
13
|
activeAppLocales: input.activeAppLocales,
|
|
13
14
|
attributionCount: input.attributionCount,
|
|
14
15
|
chunkCount: input.chunkCount,
|
|
@@ -4,6 +4,7 @@ import { canonicalizeLearningGraphIdentity } from "#contracts/graph/spec";
|
|
|
4
4
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
5
5
|
import { canonicalizeQuranAttribution } from "#contracts/quran/attribution";
|
|
6
6
|
import { QuranSnapshotRowSchema, } from "#contracts/quran/snapshot/row";
|
|
7
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
7
8
|
const ROW_DOMAIN = "nakafa.aksara.quran-row";
|
|
8
9
|
/** Node could not compute a deterministic Quran row identity. */
|
|
9
10
|
export class QuranRowHashError extends Schema.TaggedError()("QuranRowHashError", { scope: Schema.Literals(["digest", "row"]) }) {
|
|
@@ -54,7 +55,7 @@ function canonicalizeVerse(verse) {
|
|
|
54
55
|
/** Produces stable JSON for one exhaustive current Quran payload. */
|
|
55
56
|
export function canonicalizeQuranRow(payload) {
|
|
56
57
|
if (payload.kind === "quran-attribution") {
|
|
57
|
-
return
|
|
58
|
+
return encodeJsonText({
|
|
58
59
|
activeAppLocales: payload.activeAppLocales,
|
|
59
60
|
kind: payload.kind,
|
|
60
61
|
sources: payload.sources.map(canonicalizeQuranAttribution),
|
|
@@ -62,7 +63,7 @@ export function canonicalizeQuranRow(payload) {
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
if (payload.kind === "quran-surah") {
|
|
65
|
-
return
|
|
66
|
+
return encodeJsonText({
|
|
66
67
|
kind: payload.kind,
|
|
67
68
|
name: {
|
|
68
69
|
arabic: payload.name.arabic,
|
|
@@ -82,7 +83,7 @@ export function canonicalizeQuranRow(payload) {
|
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
if (payload.kind === "quran-chunk") {
|
|
85
|
-
return
|
|
86
|
+
return encodeJsonText({
|
|
86
87
|
firstQuranNumber: payload.firstQuranNumber,
|
|
87
88
|
firstVerse: payload.firstVerse,
|
|
88
89
|
kind: payload.kind,
|
|
@@ -91,7 +92,7 @@ export function canonicalizeQuranRow(payload) {
|
|
|
91
92
|
verses: payload.verses.map(canonicalizeVerse),
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
|
-
return
|
|
95
|
+
return encodeJsonText({
|
|
95
96
|
appLocale: payload.appLocale,
|
|
96
97
|
graph: canonicalizeLearningGraphIdentity(payload.graph),
|
|
97
98
|
kind: payload.kind,
|
|
@@ -3,6 +3,7 @@ import { Sha256HashSchema } from "#contracts/ids";
|
|
|
3
3
|
import { ActiveAppLocaleListSchema, AppLocaleSchema, } from "#contracts/locale";
|
|
4
4
|
import { quranSourceFileCount } from "#contracts/quran/source";
|
|
5
5
|
import { QURAN_ATTRIBUTION_COUNT, QURAN_SURAH_COUNT, QURAN_VERSE_COUNT, } from "#contracts/quran/spec";
|
|
6
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
6
7
|
/** Semantic wire identity of the current localized Quran snapshot. */
|
|
7
8
|
export const QURAN_SNAPSHOT_FORMAT = "localized-quran-snapshot";
|
|
8
9
|
const CountSchema = Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)));
|
|
@@ -39,8 +40,8 @@ function hasCompleteSnapshotCounts(input) {
|
|
|
39
40
|
input.verseCount === QURAN_VERSE_COUNT &&
|
|
40
41
|
input.searchCount === QURAN_SURAH_COUNT * input.activeAppLocales.length &&
|
|
41
42
|
input.sourceFileCount === quranSourceFileCount(input.activeAppLocales) &&
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
encodeJsonText(input.tafsirLocales) ===
|
|
44
|
+
encodeJsonText(hasIndonesian ? ["id"] : []));
|
|
44
45
|
}
|
|
45
46
|
/** Checks runtime and search arithmetic for complete projection inventory. */
|
|
46
47
|
function hasCoherentProjectionCounts(input) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
1
2
|
/** Serializes one change with stable fields for item digest computation. */
|
|
2
3
|
export function canonicalizeContentChange(change) {
|
|
3
4
|
if (change.operation === "upsert") {
|
|
@@ -21,7 +22,7 @@ export function canonicalizeContentChange(change) {
|
|
|
21
22
|
}
|
|
22
23
|
/** Serializes one release item with stable identity, order, and content. */
|
|
23
24
|
export function canonicalizeContentReleaseItem(item) {
|
|
24
|
-
return
|
|
25
|
+
return encodeJsonText({
|
|
25
26
|
change: canonicalizeContentChange(item.change),
|
|
26
27
|
index: item.index,
|
|
27
28
|
releaseId: item.releaseId,
|
package/dist/release/head.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ContentDeliveryClassSchema } from "#contracts/delivery";
|
|
|
4
4
|
import { ContentKeySchema, CorpusSourcePathSchema, PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
5
5
|
import { ArtifactLocaleSchema } from "#contracts/locale";
|
|
6
6
|
import { RendererDomainSchema } from "#contracts/renderer/domain";
|
|
7
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
7
8
|
import { MAX_HEAD_PAGE_COUNT } from "#contracts/transport/limits";
|
|
8
9
|
const HeadCursorSchema = Schema.NullOr(Schema.Trimmed.check(Schema.isNonEmpty()).pipe(Schema.check(Schema.isMaxLength(4096))));
|
|
9
10
|
const ContentHeadFields = {
|
|
@@ -51,7 +52,7 @@ export const ContentHeadSchema = Schema.Union([
|
|
|
51
52
|
]);
|
|
52
53
|
/** Serializes one compact head in stable catalog field order. */
|
|
53
54
|
export function canonicalizeContentHead(head) {
|
|
54
|
-
return
|
|
55
|
+
return encodeJsonText({
|
|
55
56
|
artifactHash: head.artifactHash,
|
|
56
57
|
artifactLocale: head.artifactLocale,
|
|
57
58
|
compilerConfigHash: head.compilerConfigHash,
|
package/dist/release/items.d.ts
CHANGED
|
@@ -56,11 +56,12 @@ declare const ReleaseItemsDigestMismatchError_base: Schema.Class<ReleaseItemsDig
|
|
|
56
56
|
/** The separate ordered items do not match the signed digest. */
|
|
57
57
|
export declare class ReleaseItemsDigestMismatchError extends ReleaseItemsDigestMismatchError_base {
|
|
58
58
|
}
|
|
59
|
+
declare const VerifiedContentReleaseItemsSchema: Schema.Struct<{
|
|
60
|
+
readonly deleteCount: Schema.Finite;
|
|
61
|
+
readonly upsertCount: Schema.Finite;
|
|
62
|
+
}>;
|
|
59
63
|
/** Counts derived without retaining a complete release-item collection. */
|
|
60
|
-
export
|
|
61
|
-
readonly deleteCount: number;
|
|
62
|
-
readonly upsertCount: number;
|
|
63
|
-
}
|
|
64
|
+
export type VerifiedContentReleaseItems = typeof VerifiedContentReleaseItemsSchema.Type;
|
|
64
65
|
/**
|
|
65
66
|
* Strictly decodes a replayable item stream without retaining its bodies.
|
|
66
67
|
* Every evaluation owns fresh ordering and route-collision state.
|
package/dist/release/items.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Schema, Stream } from "effect";
|
|
1
|
+
import { Effect, MutableRef, Option, Schema, Stream } from "effect";
|
|
2
2
|
import { compareContentHeads } from "#contracts/content";
|
|
3
3
|
import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
|
|
4
4
|
import { digestItems } from "#contracts/release/digest";
|
|
@@ -37,6 +37,10 @@ export class ReleaseItemsDigestMismatchError extends Schema.TaggedError()("Relea
|
|
|
37
37
|
releaseId: ReleaseIdSchema,
|
|
38
38
|
}) {
|
|
39
39
|
}
|
|
40
|
+
const VerifiedContentReleaseItemsSchema = Schema.Struct({
|
|
41
|
+
deleteCount: Schema.Finite,
|
|
42
|
+
upsertCount: Schema.Finite,
|
|
43
|
+
});
|
|
40
44
|
/** Verifies one item's signed release identity and sequence position. */
|
|
41
45
|
function validateItemIdentity(manifest, item, expectedIndex) {
|
|
42
46
|
if (item.releaseId !== manifest.releaseId) {
|
|
@@ -57,19 +61,20 @@ function validateItemIdentity(manifest, item, expectedIndex) {
|
|
|
57
61
|
return Effect.void;
|
|
58
62
|
}
|
|
59
63
|
/** Rejects a head that is duplicated or outside canonical head order. */
|
|
60
|
-
function validateItemOrder(
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
function validateItemOrder(previous, item) {
|
|
65
|
+
const last = MutableRef.get(previous);
|
|
66
|
+
if (Option.isSome(last) &&
|
|
67
|
+
compareContentHeads(last.value.change, item.change) >= 0) {
|
|
63
68
|
return Effect.fail(new ReleaseItemOrderError({ itemOffset: item.index }));
|
|
64
69
|
}
|
|
65
|
-
|
|
70
|
+
MutableRef.set(previous, Option.some(item));
|
|
66
71
|
return Effect.void;
|
|
67
72
|
}
|
|
68
73
|
/** Decodes one item and applies stateful canonical stream invariants. */
|
|
69
|
-
const decodeItem = Effect.fn("AksaraContracts.decodeReleaseItem")(function* (manifest,
|
|
74
|
+
const decodeItem = Effect.fn("AksaraContracts.decodeReleaseItem")(function* (manifest, previous, source, itemOffset) {
|
|
70
75
|
const item = yield* Schema.decodeUnknownEffect(ContentReleaseItemSchema)(source, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new ReleaseItemDecodeError({ itemOffset })));
|
|
71
76
|
yield* validateItemIdentity(manifest, item, itemOffset);
|
|
72
|
-
yield* validateItemOrder(
|
|
77
|
+
yield* validateItemOrder(previous, item);
|
|
73
78
|
return item;
|
|
74
79
|
});
|
|
75
80
|
/**
|
|
@@ -78,8 +83,8 @@ const decodeItem = Effect.fn("AksaraContracts.decodeReleaseItem")(function* (man
|
|
|
78
83
|
*/
|
|
79
84
|
export function decodeContentReleaseItems(input) {
|
|
80
85
|
return Stream.unwrap(Effect.sync(() => {
|
|
81
|
-
const
|
|
82
|
-
return input.items.pipe(Stream.zipWithIndex, Stream.mapEffect(([source, itemOffset]) => decodeItem(input.manifest,
|
|
86
|
+
const previous = MutableRef.make(Option.none());
|
|
87
|
+
return input.items.pipe(Stream.zipWithIndex, Stream.mapEffect(([source, itemOffset]) => decodeItem(input.manifest, previous, source, itemOffset)));
|
|
83
88
|
}));
|
|
84
89
|
}
|
|
85
90
|
/** Authenticates a replayable ordered stream against its signed manifest. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { Effect, Schema, Stream } from "effect";
|
|
2
|
+
import { Effect, MutableHashSet, Schema, Stream } from "effect";
|
|
3
3
|
import { compareContentHeads, routeIdentity } from "#contracts/content";
|
|
4
4
|
import { ContentKeySchema, PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
5
5
|
import { AppLocaleSchema, ArtifactLocaleSchema, } from "#contracts/locale";
|
|
@@ -40,7 +40,7 @@ export class ResultCatalogDigestMismatchError extends Schema.TaggedError()("Resu
|
|
|
40
40
|
/** Keeps mutable hash and ordering state private to one catalog replay. */
|
|
41
41
|
class ResultCatalogDigestState {
|
|
42
42
|
#hash = createHash("sha256");
|
|
43
|
-
#routes =
|
|
43
|
+
#routes = MutableHashSet.empty();
|
|
44
44
|
count = 0;
|
|
45
45
|
previous;
|
|
46
46
|
/** Initializes one domain-separated result-catalog hash. */
|
|
@@ -54,10 +54,10 @@ class ResultCatalogDigestState {
|
|
|
54
54
|
appLocale: AppLocaleSchema.make(artifactLocale),
|
|
55
55
|
publicPath,
|
|
56
56
|
});
|
|
57
|
-
if (this.#routes
|
|
57
|
+
if (MutableHashSet.has(this.#routes, identity)) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
-
this.#routes
|
|
60
|
+
MutableHashSet.add(this.#routes, identity);
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
/** Adds one canonical compact head and advances ordering evidence. */
|
|
@@ -5,6 +5,7 @@ import { ContentProjectionSchema, canonicalizeContentProjection, familyForProjec
|
|
|
5
5
|
import { canonicalizeContentChange } from "#contracts/release/canonical";
|
|
6
6
|
import { ArticleHeadSchema, canonicalizeContentHead, MaterialHeadSchema, PageHeadSchema, QuestionHeadSchema, } from "#contracts/release/head";
|
|
7
7
|
import { ContentDeleteSchema, ContentUpsertSchema, ReleaseItemIndexSchema, } from "#contracts/release/spec";
|
|
8
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
8
9
|
/** Maximum complete body rollback page below the publication wire ceiling. */
|
|
9
10
|
export const MAX_ROLLBACK_PAGE_BYTES = 4 * 1024 * 1024;
|
|
10
11
|
/** Maximum byte-bounded rollback transitions requested from one target page. */
|
|
@@ -54,9 +55,9 @@ export const RollbackSnapshotEntrySchema = Schema.Struct({
|
|
|
54
55
|
/** Serializes one authenticated prior state for incremental digest computation. */
|
|
55
56
|
export function canonicalizeRollbackSnapshotEntry(entry) {
|
|
56
57
|
const snapshot = entry.snapshot.state === "absent"
|
|
57
|
-
? `{"artifactLocale":${
|
|
58
|
-
: `{"head":${canonicalizeContentHead(entry.snapshot.head)},"state":${
|
|
59
|
-
return `{"index":${entry.index},"releaseId":${
|
|
58
|
+
? `{"artifactLocale":${encodeJsonText(entry.snapshot.artifactLocale)},"contentKey":${encodeJsonText(entry.snapshot.contentKey)},"family":${encodeJsonText(entry.snapshot.family)},"state":"absent"}`
|
|
59
|
+
: `{"head":${canonicalizeContentHead(entry.snapshot.head)},"state":${encodeJsonText(entry.snapshot.state)}}`;
|
|
60
|
+
return `{"index":${entry.index},"releaseId":${encodeJsonText(entry.releaseId)},"snapshot":${snapshot}}`;
|
|
60
61
|
}
|
|
61
62
|
/** Checks identity coherence across one upsert, artifact, and projection. */
|
|
62
63
|
function hasBoundRollbackUpsert(input) {
|
|
@@ -138,7 +139,7 @@ export function isRollbackUpsert(state) {
|
|
|
138
139
|
}
|
|
139
140
|
/** Serializes one complete rollback state in stable wire field order. */
|
|
140
141
|
function canonicalizeRollbackState(state) {
|
|
141
|
-
const change =
|
|
142
|
+
const change = encodeJsonText(canonicalizeContentChange(state.change));
|
|
142
143
|
if (!isRollbackUpsert(state)) {
|
|
143
144
|
return `{"change":${change}}`;
|
|
144
145
|
}
|
|
@@ -152,5 +153,5 @@ export function canonicalizeRollbackRecord(record) {
|
|
|
152
153
|
export function canonicalizeRollbackPage(page) {
|
|
153
154
|
return `{"done":${page.done},"nextIndex":${page.nextIndex},"records":[${page.records
|
|
154
155
|
.map(canonicalizeRollbackRecord)
|
|
155
|
-
.join(",")}],"rollbackOfManifestHash":${
|
|
156
|
+
.join(",")}],"rollbackOfManifestHash":${encodeJsonText(page.rollbackOfManifestHash)},"rollbackOf":${encodeJsonText(page.rollbackOf)},"total":${page.total}}`;
|
|
156
157
|
}
|
|
@@ -3,6 +3,7 @@ import { Schema } from "effect";
|
|
|
3
3
|
import { ContentKeySchema, PublicPathSchema, ReleaseIdSchema, } from "#contracts/ids";
|
|
4
4
|
import { AppLocaleSchema } from "#contracts/locale";
|
|
5
5
|
import { ReleaseItemIndexSchema } from "#contracts/release/spec";
|
|
6
|
+
import { encodeJsonText } from "#contracts/text/json";
|
|
6
7
|
/** One public route bound to a stable locale-specific content identity. */
|
|
7
8
|
export const ContentRouteBindSchema = Schema.Struct({
|
|
8
9
|
appLocale: AppLocaleSchema,
|
|
@@ -30,11 +31,11 @@ export const ContentRouteItemSchema = Schema.Struct({
|
|
|
30
31
|
/** Serializes one route change in stable wire field order. */
|
|
31
32
|
export function canonicalizeContentRouteChange(change) {
|
|
32
33
|
if (change.operation === "delete") {
|
|
33
|
-
return `{"appLocale":${
|
|
34
|
+
return `{"appLocale":${encodeJsonText(change.appLocale)},"operation":"delete","publicPath":${encodeJsonText(change.publicPath)}}`;
|
|
34
35
|
}
|
|
35
|
-
return `{"appLocale":${
|
|
36
|
+
return `{"appLocale":${encodeJsonText(change.appLocale)},"contentKey":${encodeJsonText(change.contentKey)},"operation":"bind","publicPath":${encodeJsonText(change.publicPath)}}`;
|
|
36
37
|
}
|
|
37
38
|
/** Serializes one indexed route item for signed digest computation. */
|
|
38
39
|
export function canonicalizeContentRouteItem(item) {
|
|
39
|
-
return `{"change":${canonicalizeContentRouteChange(item.change)},"index":${item.index},"releaseId":${
|
|
40
|
+
return `{"change":${canonicalizeContentRouteChange(item.change)},"index":${item.index},"releaseId":${encodeJsonText(item.releaseId)}}`;
|
|
40
41
|
}
|
|
@@ -34,10 +34,11 @@ declare const RouteDigestError_base: Schema.Class<RouteDigestError, Schema.Tagge
|
|
|
34
34
|
/** The streamed route digest differs from its signed manifest. */
|
|
35
35
|
export declare class RouteDigestError extends RouteDigestError_base {
|
|
36
36
|
}
|
|
37
|
+
declare const VerifiedContentRoutesSchema: Schema.Struct<{
|
|
38
|
+
readonly count: Schema.Finite;
|
|
39
|
+
}>;
|
|
37
40
|
/** Count authenticated without retaining complete route rows. */
|
|
38
|
-
export
|
|
39
|
-
readonly count: number;
|
|
40
|
-
}
|
|
41
|
+
export type VerifiedContentRoutes = typeof VerifiedContentRoutesSchema.Type;
|
|
41
42
|
/** Strictly decodes one replayable canonical route stream. */
|
|
42
43
|
export declare function decodeContentRoutes<E, R>(input: {
|
|
43
44
|
readonly manifest: ContentReleaseManifest;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Schema, Stream } from "effect";
|
|
1
|
+
import { Effect, MutableHashMap, Option, Schema, Stream } from "effect";
|
|
2
2
|
import { routeIdentity } from "#contracts/content";
|
|
3
3
|
import { PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
4
4
|
import { digestRoutes } from "#contracts/release/route/digest";
|
|
@@ -23,28 +23,31 @@ export class RouteDigestError extends Schema.TaggedError()("RouteDigestError", {
|
|
|
23
23
|
releaseId: ReleaseIdSchema,
|
|
24
24
|
}) {
|
|
25
25
|
}
|
|
26
|
+
const VerifiedContentRoutesSchema = Schema.Struct({
|
|
27
|
+
count: Schema.Finite,
|
|
28
|
+
});
|
|
26
29
|
/** Decodes one route and applies release, index, and uniqueness invariants. */
|
|
27
|
-
function decodeRoute(manifest,
|
|
30
|
+
function decodeRoute(manifest, firstRouteIndex, source, routeOffset) {
|
|
28
31
|
return Schema.decodeUnknownEffect(ContentRouteItemSchema)(source, {
|
|
29
32
|
onExcessProperty: "error",
|
|
30
33
|
}).pipe(Effect.mapError(() => new RouteDecodeError({ routeOffset })), Effect.filterOrFail((item) => item.releaseId === manifest.releaseId && item.index === routeOffset, () => new RouteIdentityError({ routeOffset })), Effect.flatMap((item) => {
|
|
31
34
|
const identity = routeIdentity(item.change);
|
|
32
|
-
const firstIndex =
|
|
35
|
+
const firstIndex = Option.getOrUndefined(MutableHashMap.get(firstRouteIndex, identity));
|
|
33
36
|
if (firstIndex !== undefined) {
|
|
34
37
|
return Effect.fail(new RouteDuplicateError({
|
|
35
38
|
firstIndex,
|
|
36
39
|
publicPath: item.change.publicPath,
|
|
37
40
|
}));
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
MutableHashMap.set(firstRouteIndex, identity, item.index);
|
|
40
43
|
return Effect.succeed(item);
|
|
41
44
|
}));
|
|
42
45
|
}
|
|
43
46
|
/** Strictly decodes one replayable canonical route stream. */
|
|
44
47
|
export function decodeContentRoutes(input) {
|
|
45
48
|
return Stream.unwrap(Effect.sync(() => {
|
|
46
|
-
const
|
|
47
|
-
return input.routes.pipe(Stream.zipWithIndex, Stream.mapEffect(([source, routeOffset]) => decodeRoute(input.manifest,
|
|
49
|
+
const firstRouteIndex = MutableHashMap.empty();
|
|
50
|
+
return input.routes.pipe(Stream.zipWithIndex, Stream.mapEffect(([source, routeOffset]) => decodeRoute(input.manifest, firstRouteIndex, source, routeOffset)));
|
|
48
51
|
}));
|
|
49
52
|
}
|
|
50
53
|
/** Authenticates a replayable route stream against its signed manifest. */
|