@nakafa/aksara-contracts 0.48.1 → 0.48.3
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/canonical.d.ts +5 -0
- package/dist/canonical.js +10 -0
- package/dist/locale.js +2 -9
- package/dist/math/base.js +2 -2
- package/dist/math/plane.js +1 -1
- package/dist/math/precision.js +4 -7
- package/dist/math/proximity.js +2 -2
- package/dist/math/vector.js +10 -13
- package/dist/program/snapshot/digest.js +1 -1
- package/dist/program/spec.js +2 -6
- package/dist/question/identity.js +7 -5
- package/dist/quran/notes.js +1 -1
- package/dist/quran/snapshot/digest.js +10 -6
- package/dist/quran/snapshot/row.js +2 -6
- package/dist/quran/snapshot/spec.js +2 -2
- package/dist/quran/source.js +4 -8
- package/dist/release/items.js +2 -2
- package/dist/release/lifecycle.d.ts +67 -4
- package/dist/release/lifecycle.js +5 -1
- package/dist/release/policy.js +3 -3
- package/dist/release/rollback/spec.js +6 -6
- package/dist/release/route/page.js +6 -6
- package/dist/release/snapshot/scope.js +4 -15
- package/dist/release/snapshot/spec.js +2 -1
- package/dist/release/spec.d.ts +11 -9
- package/dist/release/spec.js +7 -3
- package/dist/renderer/compatibility.js +3 -3
- package/dist/signature/verify.js +9 -14
- package/dist/tryout/closure/accounting.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks that a list names members of one canonical list, each at most once,
|
|
3
|
+
* in the canonical order. A value outside the canonical list fails the check.
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasCanonicalOrder(canonical: readonly string[], values: readonly string[]): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Array as Arr } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Checks that a list names members of one canonical list, each at most once,
|
|
4
|
+
* in the canonical order. A value outside the canonical list fails the check.
|
|
5
|
+
*/
|
|
6
|
+
export function hasCanonicalOrder(canonical, values) {
|
|
7
|
+
const expected = Arr.filter(canonical, (member) => Arr.some(values, (value) => value === member));
|
|
8
|
+
return (expected.length === values.length &&
|
|
9
|
+
Arr.every(values, (value, index) => value === expected[index]));
|
|
10
|
+
}
|
package/dist/locale.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { hasCanonicalOrder } from "#contracts/canonical";
|
|
2
3
|
/** Stable locale codes supported by the current Aksara contract. */
|
|
3
4
|
export const AppLocaleCodeSchema = Schema.Literals(["en", "id", "de"]);
|
|
4
5
|
export const [ENGLISH_APP_LOCALE_CODE, INDONESIAN_APP_LOCALE_CODE, GERMAN_APP_LOCALE_CODE,] = AppLocaleCodeSchema.literals;
|
|
@@ -35,15 +36,7 @@ export function artifactLocaleCode(artifactLocale) {
|
|
|
35
36
|
}
|
|
36
37
|
/** Checks a nonempty locale subset for uniqueness and canonical order. */
|
|
37
38
|
function hasCanonicalActiveAppLocales(locales) {
|
|
38
|
-
|
|
39
|
-
for (const locale of locales) {
|
|
40
|
-
const index = APP_LOCALE_CODES.indexOf(locale);
|
|
41
|
-
if (index <= previousIndex) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
previousIndex = index;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
39
|
+
return hasCanonicalOrder(APP_LOCALE_CODES, locales);
|
|
47
40
|
}
|
|
48
41
|
/** Nonempty unique active locale subset in canonical contract order. */
|
|
49
42
|
export const ActiveAppLocaleListSchema = Schema.NonEmptyArray(AppLocaleSchema).pipe(Schema.check(Schema.makeFilter(hasCanonicalActiveAppLocales, {
|
package/dist/math/base.js
CHANGED
|
@@ -68,7 +68,7 @@ export function sameSpacePoint(left, right) {
|
|
|
68
68
|
function duplicateKeyIndexes(values, keyOf) {
|
|
69
69
|
const seen = MutableHashSet.empty();
|
|
70
70
|
const duplicates = MutableList.make();
|
|
71
|
-
|
|
71
|
+
Arr.forEach(values, (value, index) => {
|
|
72
72
|
const key = keyOf(value);
|
|
73
73
|
if (MutableHashSet.has(seen, key)) {
|
|
74
74
|
MutableList.append(duplicates, index);
|
|
@@ -76,7 +76,7 @@ function duplicateKeyIndexes(values, keyOf) {
|
|
|
76
76
|
else {
|
|
77
77
|
MutableHashSet.add(seen, key);
|
|
78
78
|
}
|
|
79
|
-
}
|
|
79
|
+
});
|
|
80
80
|
return MutableList.toArray(duplicates);
|
|
81
81
|
}
|
|
82
82
|
/** Reports every repeated scene identity at its exact authored key path. */
|
package/dist/math/plane.js
CHANGED
|
@@ -12,7 +12,7 @@ function hasPlaneArea(vertices) {
|
|
|
12
12
|
let twiceArea = 0;
|
|
13
13
|
let termMagnitude = 0;
|
|
14
14
|
let previous = { x: 0, y: 0 };
|
|
15
|
-
for (const current of
|
|
15
|
+
for (const current of Arr.drop(offsets, 1)) {
|
|
16
16
|
const positive = previous.x * current.y;
|
|
17
17
|
const negative = previous.y * current.x;
|
|
18
18
|
twiceArea += positive - negative;
|
package/dist/math/precision.js
CHANGED
|
@@ -78,7 +78,7 @@ export function polygonAltitudeUnresolved(vertices, threshold) {
|
|
|
78
78
|
z: decimal("z" in point ? point.z : 0),
|
|
79
79
|
}));
|
|
80
80
|
const thresholdSquared = BigDecimal.multiply(threshold, threshold);
|
|
81
|
-
|
|
81
|
+
return EffectArray.some(exact, (point, index) => {
|
|
82
82
|
const previous = EffectArray.getUnsafe(exact, (index + exact.length - 1) % exact.length);
|
|
83
83
|
const next = EffectArray.getUnsafe(exact, (index + 1) % exact.length);
|
|
84
84
|
const baseline = {
|
|
@@ -98,14 +98,11 @@ export function polygonAltitudeUnresolved(vertices, threshold) {
|
|
|
98
98
|
};
|
|
99
99
|
const crossSquared = BigDecimal.sumAll(EffectArray.map(Rec.values(cross), (value) => BigDecimal.multiply(value, value)));
|
|
100
100
|
if (BigDecimal.isZero(crossSquared)) {
|
|
101
|
-
|
|
101
|
+
return false;
|
|
102
102
|
}
|
|
103
103
|
const baselineSquared = BigDecimal.sumAll(EffectArray.map(Rec.values(baseline), (value) => BigDecimal.multiply(value, value)));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
104
|
+
return BigDecimal.isLessThan(crossSquared, BigDecimal.multiply(thresholdSquared, baselineSquared));
|
|
105
|
+
});
|
|
109
106
|
}
|
|
110
107
|
/** Checks exact quadratic curvature without relying on renderer sampling. */
|
|
111
108
|
export function quadraticCurvatureUnresolved(coefficient, domainSpan, threshold) {
|
package/dist/math/proximity.js
CHANGED
|
@@ -138,7 +138,7 @@ export function unresolvedProximityIndexes(entries, threshold) {
|
|
|
138
138
|
const leftTree = makeTree(upper.values.length);
|
|
139
139
|
const rightTree = makeTree(lower.values.length);
|
|
140
140
|
const unresolved = MutableHashSet.empty();
|
|
141
|
-
|
|
141
|
+
EffectArray.forEach(intervals, (interval, sourceIndex) => {
|
|
142
142
|
const leftEnd = firstRank(upper.values, interval.lower, false);
|
|
143
143
|
const closestLeft = queryTree(leftTree, 0, leftEnd, greaterRatio);
|
|
144
144
|
const rightStart = firstRank(lower.values, interval.upper, true);
|
|
@@ -153,6 +153,6 @@ export function unresolvedProximityIndexes(entries, threshold) {
|
|
|
153
153
|
}
|
|
154
154
|
updateTree(leftTree, EffectArray.getUnsafe(upper.ranks, sourceIndex), interval.lower, greaterRatio);
|
|
155
155
|
updateTree(rightTree, EffectArray.getUnsafe(lower.ranks, sourceIndex), interval.upper, lesserRatio);
|
|
156
|
-
}
|
|
156
|
+
});
|
|
157
157
|
return unresolved;
|
|
158
158
|
}
|
package/dist/math/vector.js
CHANGED
|
@@ -3,19 +3,7 @@ import { GEOMETRY_TOLERANCE } from "#contracts/math/base";
|
|
|
3
3
|
/** Checks a space polygon is planar and has non-zero area. */
|
|
4
4
|
export function hasCoplanarArea(vertices) {
|
|
5
5
|
const offsets = normalizedSpaceOffsets(vertices);
|
|
6
|
-
|
|
7
|
-
let strongestLength = 0;
|
|
8
|
-
const vectors = offsets.slice(1);
|
|
9
|
-
for (const [leftIndex, left] of vectors.entries()) {
|
|
10
|
-
for (const right of vectors.slice(leftIndex + 1)) {
|
|
11
|
-
const candidate = cross(left, right);
|
|
12
|
-
const candidateLength = length(candidate);
|
|
13
|
-
if (candidateLength > strongestLength) {
|
|
14
|
-
strongestLength = candidateLength;
|
|
15
|
-
strongestNormal = candidate;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
6
|
+
const [strongestNormal, strongestLength] = strongestCrossProduct(Arr.drop(offsets, 1));
|
|
19
7
|
if (!(strongestNormal && strongestLength > GEOMETRY_TOLERANCE)) {
|
|
20
8
|
return false;
|
|
21
9
|
}
|
|
@@ -23,6 +11,15 @@ export function hasCoplanarArea(vertices) {
|
|
|
23
11
|
return Arr.every(offsets, (offset) => Math.abs(dot(unitNormal, offset)) <=
|
|
24
12
|
GEOMETRY_TOLERANCE * Math.max(1, length(offset)));
|
|
25
13
|
}
|
|
14
|
+
/** Returns the first longest cross product of every ordered pair, with its length. */
|
|
15
|
+
function strongestCrossProduct(vectors) {
|
|
16
|
+
const initial = [undefined, 0];
|
|
17
|
+
return Arr.reduce(vectors, initial, (strongest, left, leftIndex) => Arr.reduce(Arr.drop(vectors, leftIndex + 1), strongest, (best, right) => {
|
|
18
|
+
const candidate = cross(left, right);
|
|
19
|
+
const candidateLength = length(candidate);
|
|
20
|
+
return candidateLength > best[1] ? [candidate, candidateLength] : best;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
26
23
|
/** Translates before scaling so coplanarity is independent of scene location. */
|
|
27
24
|
function normalizedSpaceOffsets(vertices) {
|
|
28
25
|
const [origin] = vertices;
|
|
@@ -148,7 +148,7 @@ class ProgramDigestState {
|
|
|
148
148
|
#addCurriculum(record) {
|
|
149
149
|
const { row } = record;
|
|
150
150
|
const program = Option.getOrUndefined(MutableHashMap.get(this.#programs, row.programKey));
|
|
151
|
-
if (!this.#activeAppLocales
|
|
151
|
+
if (!Arr.contains(this.#activeAppLocales, row.appLocale) ||
|
|
152
152
|
program?.navigation.model !== "curriculum-tree") {
|
|
153
153
|
return Effect.fail(new ProgramDigestError({ code: "program", identity: row.programKey }));
|
|
154
154
|
}
|
package/dist/program/spec.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { hasCanonicalOrder } from "#contracts/canonical";
|
|
2
3
|
import { CountryCodeSchema } from "#contracts/country";
|
|
3
4
|
import { DateOnlySchema } from "#contracts/date";
|
|
4
5
|
import { APP_LOCALE_CODES, AppLocaleSchema } from "#contracts/locale";
|
|
@@ -102,12 +103,7 @@ export const ProgramTranslationSchema = Schema.Struct({
|
|
|
102
103
|
});
|
|
103
104
|
/** Checks translations for unique canonical application-locale order. */
|
|
104
105
|
function hasCanonicalTranslations(translations) {
|
|
105
|
-
return Arr.
|
|
106
|
-
const previous = translations[index - 1];
|
|
107
|
-
return (previous === undefined ||
|
|
108
|
-
APP_LOCALE_CODES.indexOf(previous.appLocale) <
|
|
109
|
-
APP_LOCALE_CODES.indexOf(translation.appLocale));
|
|
110
|
-
});
|
|
106
|
+
return hasCanonicalOrder(APP_LOCALE_CODES, Arr.map(translations, (translation) => translation.appLocale));
|
|
111
107
|
}
|
|
112
108
|
const ProgramTranslationListSchema = Schema.NonEmptyArray(ProgramTranslationSchema).pipe(Schema.check(Schema.makeFilter(hasCanonicalTranslations, {
|
|
113
109
|
message: "Program translations must use unique canonical app-locale order.",
|
|
@@ -42,12 +42,14 @@ function parseQuestionSetParts(input) {
|
|
|
42
42
|
Arr.some(keys, (key) => !isTryoutKey(key) || isQuestionSegment(key))) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
const [countryKey, examKey, ...rest] = keys;
|
|
46
|
+
const [sectionKey, setKey] = Arr.takeRight(rest, 2);
|
|
45
47
|
return Schema.decodeUnknownSync(QuestionSetPartsSchema)({
|
|
46
|
-
countryKey
|
|
47
|
-
examKey
|
|
48
|
-
intermediateBankKeys:
|
|
49
|
-
sectionKey
|
|
50
|
-
setKey
|
|
48
|
+
countryKey,
|
|
49
|
+
examKey,
|
|
50
|
+
intermediateBankKeys: Arr.dropRight(rest, 2),
|
|
51
|
+
sectionKey,
|
|
52
|
+
setKey,
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
/** Parses one numbered question beneath a structurally valid set identity. */
|
package/dist/quran/notes.js
CHANGED
|
@@ -114,7 +114,7 @@ function analyzeTranslation(source) {
|
|
|
114
114
|
referenceOffset: uniqueReferences[index]?.start ?? -1,
|
|
115
115
|
}));
|
|
116
116
|
const definitionNumbers = Arr.map(definitions, ({ number }) => number);
|
|
117
|
-
const hasDuplicateDefinition = Arr.some(definitionNumbers, (number, index) =>
|
|
117
|
+
const hasDuplicateDefinition = Arr.some(definitionNumbers, (number, index) => Option.getOrUndefined(Arr.findFirstIndex(definitionNumbers, (value) => value === number)) !== index);
|
|
118
118
|
const hasMismatchedMarkers = hasDuplicateDefinition ||
|
|
119
119
|
uniqueReferences.length !== definitionNumbers.length ||
|
|
120
120
|
Arr.some(noteCandidates, ({ definition, referenceOffset }, index) => referenceOffset < 0 ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { Array as Arr, Effect, Schema, Stream } from "effect";
|
|
2
|
+
import { Array as Arr, Effect, Option, Schema, Stream } from "effect";
|
|
3
3
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
4
4
|
import { AppLocaleSchema } from "#contracts/locale";
|
|
5
5
|
import { hashQuranRow, QuranRowHashError, } from "#contracts/quran/snapshot/row/hash";
|
|
@@ -25,6 +25,10 @@ export class QuranRowOrderError extends Schema.TaggedError()("QuranRowOrderError
|
|
|
25
25
|
function joinIdentity(parts) {
|
|
26
26
|
return Arr.join(Arr.map(parts, String), ":");
|
|
27
27
|
}
|
|
28
|
+
/** Formats one finished digest as the signed sha256 hash of a Quran domain. */
|
|
29
|
+
function sha256Digest(hash) {
|
|
30
|
+
return Sha256HashSchema.make(`sha256:${hash.digest("hex")}`);
|
|
31
|
+
}
|
|
28
32
|
/** Resolves one complete stable current row identity. */
|
|
29
33
|
function rowIdentity(payload) {
|
|
30
34
|
if (payload.kind === "quran-attribution") {
|
|
@@ -115,7 +119,7 @@ class QuranDigestState {
|
|
|
115
119
|
if (payload.kind !== "quran-chunk") {
|
|
116
120
|
return true;
|
|
117
121
|
}
|
|
118
|
-
const expectedTafsir = this.#activeAppLocales
|
|
122
|
+
const expectedTafsir = Arr.contains(this.#activeAppLocales, AppLocaleSchema.make("id"))
|
|
119
123
|
? ["id"]
|
|
120
124
|
: [];
|
|
121
125
|
return Arr.every(payload.verses, (verse) => encodeJsonText(Arr.map(verse.translations, (translation) => translation.appLocale)) === encodeJsonText(this.#activeAppLocales) &&
|
|
@@ -142,7 +146,7 @@ class QuranDigestState {
|
|
|
142
146
|
this.#nextSurahVerse = payload.lastVerse + 1;
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
|
-
const localeIndex = this.#activeAppLocales
|
|
149
|
+
const localeIndex = Option.getOrThrow(Arr.findFirstIndex(this.#activeAppLocales, (locale) => locale === this.#nextSearchLocale));
|
|
146
150
|
const nextLocale = this.#activeAppLocales[localeIndex + 1];
|
|
147
151
|
if (nextLocale !== undefined) {
|
|
148
152
|
this.#nextSearchLocale = nextLocale;
|
|
@@ -204,11 +208,11 @@ class QuranDigestState {
|
|
|
204
208
|
attributionCount: this.attributionCount,
|
|
205
209
|
chunkCount: this.chunkCount,
|
|
206
210
|
projectionCount: this.projectionCount,
|
|
207
|
-
projectionDigest:
|
|
211
|
+
projectionDigest: sha256Digest(this.#projection),
|
|
208
212
|
runtimeCount: this.runtimeCount,
|
|
209
|
-
runtimeDigest:
|
|
213
|
+
runtimeDigest: sha256Digest(this.#runtime),
|
|
210
214
|
searchCount: this.searchCount,
|
|
211
|
-
searchDigest:
|
|
215
|
+
searchDigest: sha256Digest(this.#search),
|
|
212
216
|
};
|
|
213
217
|
}
|
|
214
218
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { hasCanonicalOrder } from "#contracts/canonical";
|
|
2
3
|
import { LearningGraphIdentitySchema } from "#contracts/graph/spec";
|
|
3
4
|
import { PublicPathSchema, Sha256HashSchema } from "#contracts/ids";
|
|
4
5
|
import { APP_LOCALE_CODES, AppLocaleSchema } from "#contracts/locale";
|
|
@@ -13,12 +14,7 @@ export const QuranLocalizedTranslationSchema = Schema.Struct({
|
|
|
13
14
|
});
|
|
14
15
|
/** Checks translation entries for unique canonical app-locale order. */
|
|
15
16
|
function hasCanonicalTranslations(translations) {
|
|
16
|
-
return Arr.
|
|
17
|
-
const previous = translations[index - 1];
|
|
18
|
-
return (previous === undefined ||
|
|
19
|
-
APP_LOCALE_CODES.indexOf(previous.appLocale) <
|
|
20
|
-
APP_LOCALE_CODES.indexOf(translation.appLocale));
|
|
21
|
-
});
|
|
17
|
+
return hasCanonicalOrder(APP_LOCALE_CODES, Arr.map(translations, (translation) => translation.appLocale));
|
|
22
18
|
}
|
|
23
19
|
const QuranTranslationListSchema = Schema.NonEmptyArray(QuranLocalizedTranslationSchema).pipe(Schema.check(Schema.makeFilter(hasCanonicalTranslations, {
|
|
24
20
|
message: "Quran translations must use unique canonical app-locale order.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
2
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
3
3
|
import { ActiveAppLocaleListSchema, AppLocaleSchema, } from "#contracts/locale";
|
|
4
4
|
import { quranSourceFileCount } from "#contracts/quran/source";
|
|
@@ -34,7 +34,7 @@ const QuranSnapshotFactFields = {
|
|
|
34
34
|
};
|
|
35
35
|
/** Checks source, translation, and Tafsir counts against active locales. */
|
|
36
36
|
function hasCompleteSnapshotCounts(input) {
|
|
37
|
-
const hasIndonesian = input.activeAppLocales
|
|
37
|
+
const hasIndonesian = Arr.contains(input.activeAppLocales, AppLocaleSchema.make("id"));
|
|
38
38
|
return (input.attributionCount === QURAN_ATTRIBUTION_COUNT &&
|
|
39
39
|
input.surahCount === QURAN_SURAH_COUNT &&
|
|
40
40
|
input.verseCount === QURAN_VERSE_COUNT &&
|
package/dist/quran/source.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, Schema } from "effect";
|
|
2
|
+
import { hasCanonicalOrder } from "#contracts/canonical";
|
|
2
3
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
3
4
|
import { ActiveAppLocaleListSchema, AppLocaleSchema, appLocaleLiteral, } from "#contracts/locale";
|
|
4
5
|
import { QURAN_SOURCE_IDS, QuranEmbeddedSourceIdSchema, QuranExternalSourceIdSchema, quranNameSourceId, quranTafsirSourceId, quranTranslationSourceId, } from "#contracts/quran/identity";
|
|
@@ -14,13 +15,13 @@ export function quranSourceIds(activeAppLocales) {
|
|
|
14
15
|
return [
|
|
15
16
|
"tanzil-text",
|
|
16
17
|
"tanzil-metadata",
|
|
17
|
-
...Arr.filter(
|
|
18
|
+
...Arr.filter(Arr.drop(QURAN_SOURCE_IDS, 2), (sourceId) => Arr.contains(sourceIds, sourceId)),
|
|
18
19
|
];
|
|
19
20
|
}
|
|
20
21
|
/** Counts exact source files required by one active locale set. */
|
|
21
22
|
export function quranSourceFileCount(activeAppLocales) {
|
|
22
23
|
const supplementalNameFileCount = Arr.filter(activeAppLocales, (appLocale) => quranNameSourceId(appLocale) !== "tanzil-metadata").length;
|
|
23
|
-
const tafsirFileCount =
|
|
24
|
+
const tafsirFileCount = Arr.contains(activeAppLocales, AppLocaleSchema.make("id"))
|
|
24
25
|
? QURAN_SURAH_COUNT
|
|
25
26
|
: 0;
|
|
26
27
|
return (2 + activeAppLocales.length + supplementalNameFileCount + tafsirFileCount);
|
|
@@ -103,12 +104,7 @@ export const QuranTafsirAccessSchema = Schema.Union([
|
|
|
103
104
|
]);
|
|
104
105
|
/** Checks source identities for uniqueness and canonical contract order. */
|
|
105
106
|
function hasCanonicalSources(sources) {
|
|
106
|
-
return Arr.
|
|
107
|
-
const previous = sources[index - 1];
|
|
108
|
-
return (previous === undefined ||
|
|
109
|
-
QURAN_SOURCE_IDS.indexOf(previous.id) <
|
|
110
|
-
QURAN_SOURCE_IDS.indexOf(source.id));
|
|
111
|
-
});
|
|
107
|
+
return hasCanonicalOrder(QURAN_SOURCE_IDS, Arr.map(sources, (source) => source.id));
|
|
112
108
|
}
|
|
113
109
|
/** Checks every source copy against the exact active locale set and order. */
|
|
114
110
|
export function hasCompleteQuranSourceCopy(source, activeAppLocales) {
|
package/dist/release/items.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, MutableRef, Option, Schema, Stream } from "effect";
|
|
1
|
+
import { Array as Arr, 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";
|
|
@@ -55,7 +55,7 @@ function validateItemIdentity(manifest, item, expectedIndex) {
|
|
|
55
55
|
expectedIndex,
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
|
-
if (!manifest.scope.families
|
|
58
|
+
if (!Arr.contains(manifest.scope.families, item.change.family)) {
|
|
59
59
|
return Effect.fail(new ReleaseItemScopeError({ itemOffset: expectedIndex }));
|
|
60
60
|
}
|
|
61
61
|
return Effect.void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { type RollbackSignedContentRelease } from "#contracts/release/spec";
|
|
3
2
|
/** Maximum rows the backend may delete in one cleanup transaction. */
|
|
4
3
|
export declare const MAX_CLEANUP_PAGE_COUNT = 100;
|
|
5
4
|
/** Exact immutable release identity requested from durable target state. */
|
|
@@ -84,10 +83,73 @@ export declare const ContentReleaseBundleSchema: Schema.Struct<{
|
|
|
84
83
|
}>;
|
|
85
84
|
}>;
|
|
86
85
|
export type ContentReleaseBundle = typeof ContentReleaseBundleSchema.Type;
|
|
86
|
+
/** Rollback provenance that narrows a bundle to its signed release. */
|
|
87
|
+
declare const RollbackBundleProvenanceSchema: Schema.Struct<{
|
|
88
|
+
readonly release: Schema.refine<import("#contracts/release/spec").RollbackSignedContentRelease, Schema.Struct<{
|
|
89
|
+
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
90
|
+
readonly manifest: Schema.Struct<{
|
|
91
|
+
readonly baseActiveAppLocales: Schema.NullOr<Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">>>;
|
|
92
|
+
readonly baseManifestHash: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
93
|
+
readonly baseReleaseId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">>;
|
|
94
|
+
readonly baseResultCount: Schema.Finite;
|
|
95
|
+
readonly baseResultDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
96
|
+
readonly deleteCount: Schema.Finite;
|
|
97
|
+
readonly itemCount: Schema.Finite;
|
|
98
|
+
readonly itemsDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
99
|
+
readonly origin: Schema.Union<readonly [Schema.Struct<{
|
|
100
|
+
readonly kind: Schema.Literal<"git">;
|
|
101
|
+
readonly sha: Schema.brand<Schema.String, "@NakafaAI/AksaraGitCommitSha">;
|
|
102
|
+
}>, Schema.Struct<{
|
|
103
|
+
readonly kind: Schema.Literal<"rollback">;
|
|
104
|
+
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
105
|
+
}>]>;
|
|
106
|
+
readonly projectionCount: Schema.Finite;
|
|
107
|
+
readonly projectionDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
108
|
+
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
109
|
+
readonly rendererManifestHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
110
|
+
readonly resultCount: Schema.Finite;
|
|
111
|
+
readonly resultDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
112
|
+
readonly rollbackCount: Schema.Finite;
|
|
113
|
+
readonly rollbackDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
114
|
+
readonly routeCount: Schema.Finite;
|
|
115
|
+
readonly routeDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
116
|
+
readonly scope: Schema.Struct<{
|
|
117
|
+
readonly families: Schema.$Array<Schema.Literals<readonly ["article", "material", "page", "question"]>>;
|
|
118
|
+
readonly snapshots: Schema.$Array<Schema.Literals<readonly ["program", "quran", "tryout"]>>;
|
|
119
|
+
}>;
|
|
120
|
+
readonly snapshots: Schema.Struct<{
|
|
121
|
+
readonly program: Schema.Struct<{
|
|
122
|
+
readonly baseSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
123
|
+
readonly mode: Schema.Literals<readonly ["inherit", "replace", "restore"]>;
|
|
124
|
+
readonly resultSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
125
|
+
readonly rowCount: Schema.Int;
|
|
126
|
+
readonly rowDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
127
|
+
}>;
|
|
128
|
+
readonly quran: Schema.Struct<{
|
|
129
|
+
readonly baseSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
130
|
+
readonly mode: Schema.Literals<readonly ["inherit", "replace", "restore"]>;
|
|
131
|
+
readonly resultSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
132
|
+
readonly rowCount: Schema.Int;
|
|
133
|
+
readonly rowDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
134
|
+
}>;
|
|
135
|
+
readonly tryout: Schema.Struct<{
|
|
136
|
+
readonly baseSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
137
|
+
readonly mode: Schema.Literals<readonly ["inherit", "replace", "restore"]>;
|
|
138
|
+
readonly resultSnapshotId: Schema.NullOr<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
|
|
139
|
+
readonly rowCount: Schema.Int;
|
|
140
|
+
readonly rowDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
141
|
+
}>;
|
|
142
|
+
}>;
|
|
143
|
+
readonly upsertCount: Schema.Finite;
|
|
144
|
+
readonly activeAppLocales: Schema.NonEmptyArray<Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraAppLocale">>;
|
|
145
|
+
readonly format: Schema.Literal<"localized-content-release">;
|
|
146
|
+
}>;
|
|
147
|
+
readonly manifestHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
148
|
+
readonly signature: Schema.brand<Schema.String, "@NakafaAI/AksaraEd25519Signature">;
|
|
149
|
+
}>>;
|
|
150
|
+
}>;
|
|
87
151
|
/** Frozen renderer plus one signed rollback release at recovery boundaries. */
|
|
88
|
-
export type RollbackContentReleaseBundle = ContentReleaseBundle &
|
|
89
|
-
readonly release: RollbackSignedContentRelease;
|
|
90
|
-
};
|
|
152
|
+
export type RollbackContentReleaseBundle = ContentReleaseBundle & typeof RollbackBundleProvenanceSchema.Type;
|
|
91
153
|
/** Exact renderer-bound bundle accepted only for recovery publication. */
|
|
92
154
|
export declare const RollbackContentReleaseBundleSchema: Schema.refine<RollbackContentReleaseBundle, Schema.Struct<{
|
|
93
155
|
readonly release: Schema.Struct<{
|
|
@@ -249,3 +311,4 @@ export declare const ReleaseCleanupReceiptSchema: Schema.Struct<{
|
|
|
249
311
|
readonly retryAt: Schema.optional<Schema.Finite>;
|
|
250
312
|
}>;
|
|
251
313
|
export type ReleaseCleanupReceipt = typeof ReleaseCleanupReceiptSchema.Type;
|
|
314
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
|
|
3
|
-
import { PublicationReceiptSchema, SignedContentReleaseSchema, } from "#contracts/release/spec";
|
|
3
|
+
import { PublicationReceiptSchema, RollbackSignedContentReleaseSchema, SignedContentReleaseSchema, } from "#contracts/release/spec";
|
|
4
4
|
import { RendererManifestEnvelopeSchema } from "#contracts/renderer/contract";
|
|
5
5
|
const CleanupCountSchema = Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0)));
|
|
6
6
|
/** Maximum rows the backend may delete in one cleanup transaction. */
|
|
@@ -19,6 +19,10 @@ export const ContentReleaseBundleSchema = Schema.Struct({
|
|
|
19
19
|
bundle.rendererManifest.hash, {
|
|
20
20
|
message: "Expected the signed release to bind the frozen renderer envelope.",
|
|
21
21
|
})));
|
|
22
|
+
/** Rollback provenance that narrows a bundle to its signed release. */
|
|
23
|
+
const RollbackBundleProvenanceSchema = Schema.Struct({
|
|
24
|
+
release: RollbackSignedContentReleaseSchema,
|
|
25
|
+
});
|
|
22
26
|
/** Exact renderer-bound bundle accepted only for recovery publication. */
|
|
23
27
|
export const RollbackContentReleaseBundleSchema = ContentReleaseBundleSchema.pipe(Schema.refine((bundle) => bundle.release.manifest.origin.kind === "rollback", { message: "Expected a renderer-bound rollback release." }));
|
|
24
28
|
const ContentReleaseStatusIdentity = {
|
package/dist/release/policy.js
CHANGED
|
@@ -57,7 +57,7 @@ export const verifyReleasePolicyTransition = Effect.fn("AksaraContracts.verifyRe
|
|
|
57
57
|
const requiresCompleteReplacement = input.basePolicy === null || !hasSamePolicy(input.basePolicy, input.policy);
|
|
58
58
|
if (requiresCompleteReplacement) {
|
|
59
59
|
for (const family of ContentFamilySchema.literals) {
|
|
60
|
-
if (!input.scope.families
|
|
60
|
+
if (!Arr.contains(input.scope.families, family)) {
|
|
61
61
|
return yield* failClosure({
|
|
62
62
|
actual: "partial",
|
|
63
63
|
expected: "complete-family",
|
|
@@ -105,7 +105,7 @@ export const verifyRendererPolicyTransition = Effect.fn("AksaraContracts.verifyR
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
for (const family of ContentFamilySchema.literals) {
|
|
108
|
-
if (!input.scope.families
|
|
108
|
+
if (!Arr.contains(input.scope.families, family)) {
|
|
109
109
|
return yield* failClosure({
|
|
110
110
|
actual: "partial",
|
|
111
111
|
expected: "complete-family",
|
|
@@ -115,7 +115,7 @@ export const verifyRendererPolicyTransition = Effect.fn("AksaraContracts.verifyR
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
if (input.baseTryoutSnapshotId !== null &&
|
|
118
|
-
!input.scope.snapshots
|
|
118
|
+
!Arr.contains(input.scope.snapshots, "tryout")) {
|
|
119
119
|
return yield* failClosure({
|
|
120
120
|
actual: "missing",
|
|
121
121
|
expected: "renderer-refresh",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array as Arr, Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Option, Schema } from "effect";
|
|
2
2
|
import { ContentFamilySchema, canonicalizeSignedContentArtifact, SignedContentArtifactSchema, } from "#contracts/content";
|
|
3
3
|
import { ContentKeySchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
4
4
|
import { ContentProjectionSchema, canonicalizeContentProjection, familyForProjection, projectionArtifactLocale, } from "#contracts/projection/spec";
|
|
@@ -111,14 +111,14 @@ export const RollbackPageRequestSchema = Schema.Struct({
|
|
|
111
111
|
});
|
|
112
112
|
/** Checks that one response describes a real final or progressing page. */
|
|
113
113
|
function hasCoherentRollbackPage(page) {
|
|
114
|
-
const
|
|
115
|
-
const last = page.records
|
|
116
|
-
if (
|
|
114
|
+
const first = Arr.head(page.records);
|
|
115
|
+
const last = Arr.last(page.records);
|
|
116
|
+
if (Option.isNone(first) || Option.isNone(last)) {
|
|
117
117
|
return page.done && page.nextIndex === -1 && page.total === 0;
|
|
118
118
|
}
|
|
119
|
-
const hasContiguousRecords = Arr.every(page.records, (record, offset) => record.index === first.index + offset);
|
|
119
|
+
const hasContiguousRecords = Arr.every(page.records, (record, offset) => record.index === first.value.index + offset);
|
|
120
120
|
return (hasContiguousRecords &&
|
|
121
|
-
last.index === page.nextIndex &&
|
|
121
|
+
last.value.index === page.nextIndex &&
|
|
122
122
|
page.nextIndex < page.total &&
|
|
123
123
|
page.done === (page.nextIndex + 1 === page.total));
|
|
124
124
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array as Arr, Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Option, Schema } from "effect";
|
|
2
2
|
import { ContentKeySchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
|
|
3
3
|
import { ContentRouteItemSchema } from "#contracts/release/route/spec";
|
|
4
4
|
/** Maximum route rollback records returned by one target page. */
|
|
@@ -22,14 +22,14 @@ export const RoutePageRequestSchema = Schema.Struct({
|
|
|
22
22
|
});
|
|
23
23
|
/** Checks stable total and contiguous signed route indexes. */
|
|
24
24
|
function hasCoherentRoutePage(page) {
|
|
25
|
-
const
|
|
26
|
-
const last = page.records
|
|
27
|
-
if (
|
|
25
|
+
const first = Arr.head(page.records);
|
|
26
|
+
const last = Arr.last(page.records);
|
|
27
|
+
if (Option.isNone(first) || Option.isNone(last)) {
|
|
28
28
|
return page.done && page.nextIndex === -1 && page.total === 0;
|
|
29
29
|
}
|
|
30
|
-
const contiguous = Arr.every(page.records, (record, offset) => record.current.index === first.current.index + offset);
|
|
30
|
+
const contiguous = Arr.every(page.records, (record, offset) => record.current.index === first.value.current.index + offset);
|
|
31
31
|
return (contiguous &&
|
|
32
|
-
last.current.index === page.nextIndex &&
|
|
32
|
+
last.value.current.index === page.nextIndex &&
|
|
33
33
|
page.nextIndex < page.total &&
|
|
34
34
|
page.done === (page.nextIndex + 1 === page.total));
|
|
35
35
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { hasCanonicalOrder } from "#contracts/canonical";
|
|
2
3
|
import { ContentFamilySchema } from "#contracts/content";
|
|
3
4
|
/** Fixed structured families selected by the one global release pointer. */
|
|
4
5
|
export const ContentSnapshotKindSchema = Schema.Literals([
|
|
@@ -8,20 +9,8 @@ export const ContentSnapshotKindSchema = Schema.Literals([
|
|
|
8
9
|
]);
|
|
9
10
|
/** Checks strict canonical ordering for selected content and snapshot families. */
|
|
10
11
|
function hasCanonicalPublicationScope(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return (previous === undefined ||
|
|
14
|
-
ContentSnapshotKindSchema.literals.indexOf(previous) <
|
|
15
|
-
ContentSnapshotKindSchema.literals.indexOf(family));
|
|
16
|
-
});
|
|
17
|
-
const familiesAreCanonical = Arr.every(input.families, (family, index) => {
|
|
18
|
-
const previous = input.families[index - 1];
|
|
19
|
-
return (previous === undefined ||
|
|
20
|
-
ContentFamilySchema.literals.indexOf(previous) <
|
|
21
|
-
ContentFamilySchema.literals.indexOf(family));
|
|
22
|
-
});
|
|
23
|
-
return (familiesAreCanonical &&
|
|
24
|
-
snapshotsAreCanonical &&
|
|
12
|
+
return (hasCanonicalOrder(ContentFamilySchema.literals, input.families) &&
|
|
13
|
+
hasCanonicalOrder(ContentSnapshotKindSchema.literals, input.snapshots) &&
|
|
25
14
|
input.families.length + input.snapshots.length > 0);
|
|
26
15
|
}
|
|
27
16
|
/** Whole content and structured families authenticated by one signed release. */
|
|
@@ -24,7 +24,8 @@ export const ContentSnapshotSetSchema = Schema.Struct({
|
|
|
24
24
|
});
|
|
25
25
|
/** Requires every unselected structured family to remain inherited. */
|
|
26
26
|
export function hasScopedSnapshotTransitions(scope, snapshots) {
|
|
27
|
-
return Arr.every(ContentSnapshotKindSchema.literals, (family) => scope.snapshots
|
|
27
|
+
return Arr.every(ContentSnapshotKindSchema.literals, (family) => Arr.contains(scope.snapshots, family) ||
|
|
28
|
+
snapshots[family].mode === "inherit");
|
|
28
29
|
}
|
|
29
30
|
/** Checks inheritance, replacement, and forward restore row semantics. */
|
|
30
31
|
export function hasCoherentSnapshotState(state) {
|
package/dist/release/spec.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { type ReleaseId } from "#contracts/ids";
|
|
3
2
|
import { type AppLocale } from "#contracts/locale";
|
|
4
3
|
/** Semantic wire identity of the current localized content release. */
|
|
5
4
|
export declare const CONTENT_RELEASE_FORMAT = "localized-content-release";
|
|
@@ -187,15 +186,17 @@ export declare const SignedContentReleaseSchema: Schema.Struct<{
|
|
|
187
186
|
export type SignedContentRelease = typeof SignedContentReleaseSchema.Type;
|
|
188
187
|
/** Checks whether one application locale is active in a signed release. */
|
|
189
188
|
export declare function releaseActivatesAppLocale(release: SignedContentRelease, appLocale: AppLocale): boolean;
|
|
189
|
+
/** Rollback provenance that narrows a signed release to its origin. */
|
|
190
|
+
declare const RollbackProvenanceSchema: Schema.Struct<{
|
|
191
|
+
readonly manifest: Schema.Struct<{
|
|
192
|
+
readonly origin: Schema.Struct<{
|
|
193
|
+
readonly kind: Schema.Literal<"rollback">;
|
|
194
|
+
readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
195
|
+
}>;
|
|
196
|
+
}>;
|
|
197
|
+
}>;
|
|
190
198
|
/** Signed release whose provenance identifies one exact rollback target. */
|
|
191
|
-
export type RollbackSignedContentRelease = SignedContentRelease &
|
|
192
|
-
readonly manifest: SignedContentRelease["manifest"] & {
|
|
193
|
-
readonly origin: {
|
|
194
|
-
readonly kind: "rollback";
|
|
195
|
-
readonly releaseId: ReleaseId;
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
+
export type RollbackSignedContentRelease = SignedContentRelease & typeof RollbackProvenanceSchema.Type;
|
|
199
200
|
/** Signed release contract accepted only for rollback-owned operations. */
|
|
200
201
|
export declare const RollbackSignedContentReleaseSchema: Schema.refine<RollbackSignedContentRelease, Schema.Struct<{
|
|
201
202
|
readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
|
|
@@ -468,3 +469,4 @@ export declare const PublicationReceiptSchema: Schema.Struct<{
|
|
|
468
469
|
readonly stagedSnapshotRows: Schema.Finite;
|
|
469
470
|
}>;
|
|
470
471
|
export type PublicationReceipt = typeof PublicationReceiptSchema.Type;
|
|
472
|
+
export {};
|
package/dist/release/spec.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Schema } from "effect";
|
|
2
2
|
import { ContentFamilySchema } from "#contracts/content";
|
|
3
3
|
import { ContentDeliveryClassSchema } from "#contracts/delivery";
|
|
4
4
|
import { ContentKeySchema, CorpusSourcePathSchema, Ed25519SignatureSchema, ReleaseIdSchema, Sha256HashSchema, SigningKeyIdSchema, } from "#contracts/ids";
|
|
5
5
|
import { ActiveAppLocaleListSchema, ArtifactLocaleSchema, } from "#contracts/locale";
|
|
6
|
-
import { ReleaseOriginSchema } from "#contracts/release/origin";
|
|
6
|
+
import { ReleaseOriginSchema, RollbackReleaseOriginSchema, } from "#contracts/release/origin";
|
|
7
7
|
import { EMPTY_RESULT_CATALOG_DIGEST } from "#contracts/release/result/spec";
|
|
8
8
|
import { PublicationScopeSchema } from "#contracts/release/snapshot/scope";
|
|
9
9
|
import { ContentSnapshotSetSchema, hasEmptySnapshotBases, hasGitSnapshotModes, hasRollbackSnapshotModes, hasScopedSnapshotTransitions, snapshotRowCount, } from "#contracts/release/snapshot/spec";
|
|
@@ -110,8 +110,12 @@ export const SignedContentReleaseSchema = Schema.Struct({
|
|
|
110
110
|
});
|
|
111
111
|
/** Checks whether one application locale is active in a signed release. */
|
|
112
112
|
export function releaseActivatesAppLocale(release, appLocale) {
|
|
113
|
-
return release.manifest.activeAppLocales
|
|
113
|
+
return Arr.contains(release.manifest.activeAppLocales, appLocale);
|
|
114
114
|
}
|
|
115
|
+
/** Rollback provenance that narrows a signed release to its origin. */
|
|
116
|
+
const RollbackProvenanceSchema = Schema.Struct({
|
|
117
|
+
manifest: Schema.Struct({ origin: RollbackReleaseOriginSchema }),
|
|
118
|
+
});
|
|
115
119
|
/** Signed release contract accepted only for rollback-owned operations. */
|
|
116
120
|
export const RollbackSignedContentReleaseSchema = SignedContentReleaseSchema.pipe(Schema.refine((release) => release.manifest.origin.kind === "rollback", { message: "Expected a signed rollback release." }));
|
|
117
121
|
/** Checks that every staged head has exactly one matching item and artifact. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, HashSet, Schema } from "effect";
|
|
1
|
+
import { Array as Arr, Effect, HashSet, Schema } from "effect";
|
|
2
2
|
import { ArtifactRendererComponentMissingError, ArtifactRendererDomainUnpublishedError, } from "#contracts/artifact/spec";
|
|
3
3
|
import { RendererComponentNameSchema, } from "#contracts/renderer/component";
|
|
4
4
|
import { selectRendererDomainCapability, } from "#contracts/renderer/contract";
|
|
@@ -37,7 +37,7 @@ export const verifyRendererManifestCompatibility = Effect.fn("AksaraContracts.ve
|
|
|
37
37
|
}
|
|
38
38
|
yield* verifyCapabilitySuperset(input.frozen.base, input.live.base, "base");
|
|
39
39
|
for (const rendererDomain of input.frozen.publishedDomains) {
|
|
40
|
-
if (!input.live.publishedDomains
|
|
40
|
+
if (!Arr.contains(input.live.publishedDomains, rendererDomain)) {
|
|
41
41
|
return yield* new RendererManifestDomainUnpublishedError({
|
|
42
42
|
rendererDomain,
|
|
43
43
|
});
|
|
@@ -51,7 +51,7 @@ export const verifyRendererManifestCompatibility = Effect.fn("AksaraContracts.ve
|
|
|
51
51
|
/** Verifies that a deployed live renderer can route and execute one artifact. */
|
|
52
52
|
export const verifyContentRendererCompatibility = Effect.fn("AksaraContracts.verifyContentRendererCompatibility")(function* ({ payload, rendererManifest, }) {
|
|
53
53
|
const manifest = yield* validateRendererManifestHash(rendererManifest);
|
|
54
|
-
if (!manifest.publishedDomains
|
|
54
|
+
if (!Arr.contains(manifest.publishedDomains, payload.rendererDomain)) {
|
|
55
55
|
return yield* new ArtifactRendererDomainUnpublishedError({
|
|
56
56
|
contentKey: payload.contentKey,
|
|
57
57
|
rendererDomain: payload.rendererDomain,
|
package/dist/signature/verify.js
CHANGED
|
@@ -24,20 +24,15 @@ function decodePublicKeyPem(keyId, publicKeyPem, subject) {
|
|
|
24
24
|
normalizedPublicKeyPem.trimEnd().endsWith(PUBLIC_KEY_FOOTER))) {
|
|
25
25
|
return Effect.fail(new PublicKeyParseError({ keyId, subject }));
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw new TypeError("Invalid public-key base64");
|
|
37
|
-
}
|
|
38
|
-
return decodeBase64(body);
|
|
39
|
-
},
|
|
40
|
-
});
|
|
27
|
+
const body = normalizedPublicKeyPem
|
|
28
|
+
.slice(PUBLIC_KEY_HEADER.length)
|
|
29
|
+
.replace(PUBLIC_KEY_FOOTER, "")
|
|
30
|
+
.replaceAll("\n", "")
|
|
31
|
+
.trim();
|
|
32
|
+
if (!PUBLIC_KEY_BASE64_PATTERN.test(body) || body.length % 4 !== 0) {
|
|
33
|
+
return Effect.fail(new PublicKeyParseError({ keyId, subject }));
|
|
34
|
+
}
|
|
35
|
+
return Effect.succeed(decodeBase64(body));
|
|
41
36
|
}
|
|
42
37
|
/** Imports one exact Ed25519 SPKI key through Web Crypto. */
|
|
43
38
|
function importEd25519PublicKey(keyId, publicKeyPem, subject) {
|
|
@@ -22,7 +22,7 @@ function localeSetIdentity(locales, activeAppLocales) {
|
|
|
22
22
|
}
|
|
23
23
|
/** Adds one active locale to a logical identity without duplicates. */
|
|
24
24
|
export function addLocale(localesByIdentity, activeAppLocales, identity, appLocale) {
|
|
25
|
-
if (!
|
|
25
|
+
if (!Arr.contains(activeAppLocales, appLocale)) {
|
|
26
26
|
return Effect.fail(new TryoutClosureError({
|
|
27
27
|
actual: appLocale,
|
|
28
28
|
code: "inactive-locale",
|
package/package.json
CHANGED