@nakafa/aksara-contracts 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/date.js +3 -5
- package/dist/math/base.d.ts +1 -2
- package/dist/math/base.js +9 -5
- package/dist/math/plane.d.ts +2 -4
- package/dist/math/plane.js +2 -3
- package/dist/math/space.d.ts +2 -4
- package/dist/math/space.js +2 -3
- package/dist/math/visual.d.ts +4 -8
- package/dist/preview/artifact.js +2 -2
- package/dist/projection/digest.d.ts +0 -36
- package/dist/projection/question.d.ts +1 -159
- package/dist/projection/question.js +15 -75
- package/dist/projection/spec.d.ts +1 -199
- package/dist/projection/spec.js +1 -8
- package/dist/projection/verify.d.ts +0 -36
- package/dist/release/current/evidence.d.ts +6 -21
- package/dist/release/current/state.d.ts +10 -35
- package/dist/release/hash.d.ts +0 -5
- package/dist/release/items.js +1 -2
- package/dist/release/lifecycle.d.ts +4 -14
- package/dist/release/rollback/spec.d.ts +12 -228
- package/dist/release/snapshot/scope.d.ts +3 -48
- package/dist/release/snapshot/scope.js +7 -69
- package/dist/release/snapshot/spec.js +2 -3
- package/dist/release/spec.d.ts +6 -21
- package/dist/release/verify.d.ts +0 -5
- package/dist/runtime/spec.d.ts +4 -19
- package/dist/runtime/verify.d.ts +0 -10
- package/dist/transport/batch.d.ts +0 -405
- package/dist/transport/batch.js +2 -14
- package/dist/transport/group.d.ts +33 -633
- package/dist/transport/group.js +1 -2
- package/dist/transport/request.d.ts +845 -1905
- package/dist/transport/response.d.ts +36 -394
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,10 @@ Article, material, public page, and question metadata carry one required
|
|
|
43
43
|
`datePublished` and one optional `dateModified`, both as exact `DateOnly`
|
|
44
44
|
values.
|
|
45
45
|
|
|
46
|
+
Decode external metadata and signed payloads with `onExcessProperty: "error"`.
|
|
47
|
+
Effect schemas own the shape and invariants; the decoder owns excess-property
|
|
48
|
+
policy. This rejects obsolete fields instead of silently discarding them.
|
|
49
|
+
|
|
46
50
|
- `datePublished` is the first verified public availability of that specific
|
|
47
51
|
locale page.
|
|
48
52
|
- `dateModified` is the public activation date of a later signed release that
|
package/dist/date.js
CHANGED
|
@@ -20,16 +20,14 @@ const PublicationDateFields = {
|
|
|
20
20
|
dateModified: Schema.optionalKey(DateOnlySchema),
|
|
21
21
|
datePublished: DateOnlySchema,
|
|
22
22
|
};
|
|
23
|
-
const PublicationDatesStruct = Schema.Struct(PublicationDateFields)
|
|
24
|
-
parseOptions: { onExcessProperty: "error" },
|
|
25
|
-
});
|
|
23
|
+
const PublicationDatesStruct = Schema.Struct(PublicationDateFields);
|
|
26
24
|
/**
|
|
27
25
|
* Public authored dates backed by signed activation history.
|
|
28
26
|
* Publication is locale-specific; modification records only a later meaningful
|
|
29
27
|
* content activation and is never synthesized from a runtime clock.
|
|
30
28
|
*/
|
|
31
29
|
export const PublicationDatesSchema = PublicationDatesStruct.pipe(Schema.check(Schema.makeFilter((input) => input.dateModified === undefined ||
|
|
32
|
-
input.dateModified > input.datePublished, { message: PUBLICATION_DATE_ORDER_MESSAGE }))
|
|
30
|
+
input.dateModified > input.datePublished, { message: PUBLICATION_DATE_ORDER_MESSAGE })));
|
|
33
31
|
/**
|
|
34
32
|
* Adds exact publication dates and their chronological invariant to metadata.
|
|
35
33
|
*
|
|
@@ -40,5 +38,5 @@ export function withPublicationDates(fields) {
|
|
|
40
38
|
return PublicationDatesSchema.mapFields((dateFields) => ({ ...fields, ...dateFields }),
|
|
41
39
|
// Adding fields cannot invalidate the date check because the owning date
|
|
42
40
|
// fields are preserved unchanged and always win key collisions.
|
|
43
|
-
{ unsafePreserveChecks: true })
|
|
41
|
+
{ unsafePreserveChecks: true });
|
|
44
42
|
}
|
package/dist/math/base.d.ts
CHANGED
|
@@ -21,8 +21,6 @@ export declare const MathAxisRangeSchema: Schema.Struct<{
|
|
|
21
21
|
readonly max: Schema.Finite;
|
|
22
22
|
readonly min: Schema.Finite;
|
|
23
23
|
}>;
|
|
24
|
-
/** Semantic visibility of one mathematical frame feature. */
|
|
25
|
-
export declare const MathFeatureVisibilitySchema: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
26
24
|
/** Stable visual roles that Nakafa maps to its current design system. */
|
|
27
25
|
export declare const MathAppearanceSchema: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
28
26
|
/** Screen-relative placement of one rich label around its exact anchor. */
|
|
@@ -44,6 +42,7 @@ export declare function mathVisualIdentityIssues(objects: readonly {
|
|
|
44
42
|
readonly id: string;
|
|
45
43
|
}[], labels: readonly {
|
|
46
44
|
readonly key: string;
|
|
45
|
+
readonly objectId: string;
|
|
47
46
|
}[]): readonly Schema.FilterIssue[];
|
|
48
47
|
/** Checks that an authored coordinate sequence contains no repeated position. */
|
|
49
48
|
export declare function hasUniquePositions<T>(values: readonly T[], same: (left: T, right: T) => boolean): boolean;
|
package/dist/math/base.js
CHANGED
|
@@ -24,11 +24,6 @@ export const MathAxisRangeSchema = Schema.Struct({
|
|
|
24
24
|
}).pipe(Schema.check(Schema.makeFilter(({ max, min }) => min < max, {
|
|
25
25
|
message: "Expected an axis range whose minimum is below its maximum.",
|
|
26
26
|
})));
|
|
27
|
-
/** Semantic visibility of one mathematical frame feature. */
|
|
28
|
-
export const MathFeatureVisibilitySchema = Schema.Literals([
|
|
29
|
-
"hidden",
|
|
30
|
-
"visible",
|
|
31
|
-
]);
|
|
32
27
|
/** Stable visual roles that Nakafa maps to its current design system. */
|
|
33
28
|
export const MathAppearanceSchema = Schema.Literals([
|
|
34
29
|
"answer",
|
|
@@ -86,6 +81,7 @@ function duplicateKeyIndexes(values, keyOf) {
|
|
|
86
81
|
}
|
|
87
82
|
/** Reports every repeated scene identity at its exact authored key path. */
|
|
88
83
|
export function mathVisualIdentityIssues(objects, labels) {
|
|
84
|
+
const objectIds = new Set(objects.map(({ id }) => id));
|
|
89
85
|
return [
|
|
90
86
|
...duplicateKeyIndexes(objects, ({ id }) => id).map((index) => ({
|
|
91
87
|
issue: "Expected a unique mathematical object id.",
|
|
@@ -95,6 +91,14 @@ export function mathVisualIdentityIssues(objects, labels) {
|
|
|
95
91
|
issue: "Expected a unique mathematical label key.",
|
|
96
92
|
path: ["labels", index, "key"],
|
|
97
93
|
})),
|
|
94
|
+
...labels.flatMap((label, index) => objectIds.has(label.objectId)
|
|
95
|
+
? []
|
|
96
|
+
: [
|
|
97
|
+
{
|
|
98
|
+
issue: "Expected a label to reference an existing mathematical object.",
|
|
99
|
+
path: ["labels", index, "objectId"],
|
|
100
|
+
},
|
|
101
|
+
]),
|
|
98
102
|
];
|
|
99
103
|
}
|
|
100
104
|
/** Checks that an authored coordinate sequence contains no repeated position. */
|
package/dist/math/plane.d.ts
CHANGED
|
@@ -112,8 +112,6 @@ export declare const PlaneMathObjectSchema: Schema.Union<readonly [Schema.Struct
|
|
|
112
112
|
export type PlaneMathObject = typeof PlaneMathObjectSchema.Type;
|
|
113
113
|
/** Exact Cartesian frame presented behind a plane construction. */
|
|
114
114
|
export declare const PlaneMathFrameSchema: Schema.Struct<{
|
|
115
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
116
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
117
115
|
readonly kind: Schema.Literal<"cartesian">;
|
|
118
116
|
readonly x: Schema.Struct<{
|
|
119
117
|
readonly max: Schema.Finite;
|
|
@@ -138,14 +136,13 @@ export declare const PlaneLabelAnchorSchema: Schema.Struct<{
|
|
|
138
136
|
readonly y: Schema.Finite;
|
|
139
137
|
}>;
|
|
140
138
|
readonly key: Schema.String;
|
|
139
|
+
readonly objectId: Schema.String;
|
|
141
140
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
142
141
|
}>;
|
|
143
142
|
export type PlaneLabelAnchor = typeof PlaneLabelAnchorSchema.Type;
|
|
144
143
|
/** Complete stable plane visual before rich labels are attached. */
|
|
145
144
|
export declare const PlaneMathVisualSchema: Schema.Struct<{
|
|
146
145
|
readonly frame: Schema.Struct<{
|
|
147
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
148
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
149
146
|
readonly kind: Schema.Literal<"cartesian">;
|
|
150
147
|
readonly x: Schema.Struct<{
|
|
151
148
|
readonly max: Schema.Finite;
|
|
@@ -162,6 +159,7 @@ export declare const PlaneMathVisualSchema: Schema.Struct<{
|
|
|
162
159
|
readonly y: Schema.Finite;
|
|
163
160
|
}>;
|
|
164
161
|
readonly key: Schema.String;
|
|
162
|
+
readonly objectId: Schema.String;
|
|
165
163
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
166
164
|
}>>>;
|
|
167
165
|
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
package/dist/math/plane.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { ArcStartDegreesSchema, ArcSweepDegreesSchema, GEOMETRY_TOLERANCE, hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema,
|
|
2
|
+
import { ArcStartDegreesSchema, ArcSweepDegreesSchema, GEOMETRY_TOLERANCE, hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PlanePointSchema, PositiveMeasureSchema, samePlanePoint, } from "#contracts/math/base";
|
|
3
3
|
import { planeBoundsIssues } from "#contracts/math/bounds";
|
|
4
4
|
import { planeResolutionIssues } from "#contracts/math/resolution";
|
|
5
5
|
const ObjectFields = {
|
|
@@ -126,8 +126,6 @@ export const PlaneMathObjectSchema = Schema.Union([
|
|
|
126
126
|
]);
|
|
127
127
|
/** Exact Cartesian frame presented behind a plane construction. */
|
|
128
128
|
export const PlaneMathFrameSchema = Schema.Struct({
|
|
129
|
-
axes: MathFeatureVisibilitySchema,
|
|
130
|
-
grid: MathFeatureVisibilitySchema,
|
|
131
129
|
kind: Schema.Literal("cartesian"),
|
|
132
130
|
x: MathAxisRangeSchema,
|
|
133
131
|
y: MathAxisRangeSchema,
|
|
@@ -141,6 +139,7 @@ export const PlaneMathViewSchema = Schema.Struct({
|
|
|
141
139
|
export const PlaneLabelAnchorSchema = Schema.Struct({
|
|
142
140
|
at: PlanePointSchema,
|
|
143
141
|
key: MathVisualKeySchema,
|
|
142
|
+
objectId: MathVisualKeySchema,
|
|
144
143
|
placement: Schema.optionalKey(MathLabelPlacementSchema),
|
|
145
144
|
});
|
|
146
145
|
/** Complete stable plane visual before rich labels are attached. */
|
package/dist/math/space.d.ts
CHANGED
|
@@ -106,8 +106,6 @@ export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct
|
|
|
106
106
|
export type SpaceMathObject = typeof SpaceMathObjectSchema.Type;
|
|
107
107
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
108
108
|
export declare const SpaceMathFrameSchema: Schema.Struct<{
|
|
109
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
110
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
111
109
|
readonly kind: Schema.Literal<"cartesian">;
|
|
112
110
|
readonly x: Schema.Struct<{
|
|
113
111
|
readonly max: Schema.Finite;
|
|
@@ -156,14 +154,13 @@ export declare const SpaceLabelAnchorSchema: Schema.Struct<{
|
|
|
156
154
|
readonly z: Schema.Finite;
|
|
157
155
|
}>;
|
|
158
156
|
readonly key: Schema.String;
|
|
157
|
+
readonly objectId: Schema.String;
|
|
159
158
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
160
159
|
}>;
|
|
161
160
|
export type SpaceLabelAnchor = typeof SpaceLabelAnchorSchema.Type;
|
|
162
161
|
/** Complete stable space visual before rich labels are attached. */
|
|
163
162
|
export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
164
163
|
readonly frame: Schema.Struct<{
|
|
165
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
166
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
167
164
|
readonly kind: Schema.Literal<"cartesian">;
|
|
168
165
|
readonly x: Schema.Struct<{
|
|
169
166
|
readonly max: Schema.Finite;
|
|
@@ -185,6 +182,7 @@ export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
|
185
182
|
readonly z: Schema.Finite;
|
|
186
183
|
}>;
|
|
187
184
|
readonly key: Schema.String;
|
|
185
|
+
readonly objectId: Schema.String;
|
|
188
186
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
189
187
|
}>>>;
|
|
190
188
|
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
package/dist/math/space.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema,
|
|
2
|
+
import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PositiveMeasureSchema, SpacePointSchema, sameSpacePoint, } from "#contracts/math/base";
|
|
3
3
|
import { spaceBoundsIssues } from "#contracts/math/bounds";
|
|
4
4
|
import { spaceResolutionIssues } from "#contracts/math/resolution";
|
|
5
5
|
import { hasCoplanarArea } from "#contracts/math/vector";
|
|
@@ -75,8 +75,6 @@ export const SpaceMathObjectSchema = Schema.Union([
|
|
|
75
75
|
]);
|
|
76
76
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
77
77
|
export const SpaceMathFrameSchema = Schema.Struct({
|
|
78
|
-
axes: MathFeatureVisibilitySchema,
|
|
79
|
-
grid: MathFeatureVisibilitySchema,
|
|
80
78
|
kind: Schema.Literal("cartesian"),
|
|
81
79
|
x: MathAxisRangeSchema,
|
|
82
80
|
y: MathAxisRangeSchema,
|
|
@@ -105,6 +103,7 @@ export const SpaceMathViewSchema = Schema.Union([
|
|
|
105
103
|
export const SpaceLabelAnchorSchema = Schema.Struct({
|
|
106
104
|
at: SpacePointSchema,
|
|
107
105
|
key: MathVisualKeySchema,
|
|
106
|
+
objectId: MathVisualKeySchema,
|
|
108
107
|
placement: Schema.optionalKey(MathLabelPlacementSchema),
|
|
109
108
|
});
|
|
110
109
|
/** Complete stable space visual before rich labels are attached. */
|
package/dist/math/visual.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
/** Pure mathematical scene data shared by Aksara authoring and Nakafa. */
|
|
3
3
|
export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
4
4
|
readonly frame: Schema.Struct<{
|
|
5
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
6
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
7
5
|
readonly kind: Schema.Literal<"cartesian">;
|
|
8
6
|
readonly x: Schema.Struct<{
|
|
9
7
|
readonly max: Schema.Finite;
|
|
@@ -20,6 +18,7 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
20
18
|
readonly y: Schema.Finite;
|
|
21
19
|
}>;
|
|
22
20
|
readonly key: Schema.String;
|
|
21
|
+
readonly objectId: Schema.String;
|
|
23
22
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
24
23
|
}>>>;
|
|
25
24
|
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -138,8 +137,6 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
138
137
|
}>;
|
|
139
138
|
}>, Schema.Struct<{
|
|
140
139
|
readonly frame: Schema.Struct<{
|
|
141
|
-
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
142
|
-
readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
143
140
|
readonly kind: Schema.Literal<"cartesian">;
|
|
144
141
|
readonly x: Schema.Struct<{
|
|
145
142
|
readonly max: Schema.Finite;
|
|
@@ -161,6 +158,7 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
161
158
|
readonly z: Schema.Finite;
|
|
162
159
|
}>;
|
|
163
160
|
readonly key: Schema.String;
|
|
161
|
+
readonly objectId: Schema.String;
|
|
164
162
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
165
163
|
}>>>;
|
|
166
164
|
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -295,8 +293,6 @@ export type MathVisual = typeof MathVisualSchema.Type;
|
|
|
295
293
|
/** Strictly decodes one untrusted mathematical scene into its stable contract. */
|
|
296
294
|
export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
297
295
|
readonly frame: {
|
|
298
|
-
readonly axes: "hidden" | "visible";
|
|
299
|
-
readonly grid: "hidden" | "visible";
|
|
300
296
|
readonly kind: "cartesian";
|
|
301
297
|
readonly x: {
|
|
302
298
|
readonly max: number;
|
|
@@ -313,6 +309,7 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
313
309
|
readonly y: number;
|
|
314
310
|
};
|
|
315
311
|
readonly key: string;
|
|
312
|
+
readonly objectId: string;
|
|
316
313
|
readonly placement?: "above" | "above-left" | "above-right" | "below" | "below-left" | "below-right" | "center" | "left" | "right";
|
|
317
314
|
}[];
|
|
318
315
|
readonly objects: readonly [{
|
|
@@ -539,8 +536,6 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
539
536
|
};
|
|
540
537
|
} | {
|
|
541
538
|
readonly frame: {
|
|
542
|
-
readonly axes: "hidden" | "visible";
|
|
543
|
-
readonly grid: "hidden" | "visible";
|
|
544
539
|
readonly kind: "cartesian";
|
|
545
540
|
readonly x: {
|
|
546
541
|
readonly max: number;
|
|
@@ -562,6 +557,7 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
|
|
|
562
557
|
readonly z: number;
|
|
563
558
|
};
|
|
564
559
|
readonly key: string;
|
|
560
|
+
readonly objectId: string;
|
|
565
561
|
readonly placement?: "above" | "above-left" | "above-right" | "below" | "below-left" | "below-right" | "center" | "left" | "right";
|
|
566
562
|
}[];
|
|
567
563
|
readonly objects: readonly [{
|
package/dist/preview/artifact.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Sha256HashSchema } from "#contracts/ids";
|
|
3
|
-
import {
|
|
3
|
+
import { ContentProjectionSchema } from "#contracts/projection/spec";
|
|
4
4
|
export const LOCAL_PREVIEW_ARTIFACT_PREFIX = "/v1/artifacts/";
|
|
5
5
|
/** Builds the one content-addressed path owned by the preview protocol. */
|
|
6
6
|
export function localPreviewArtifactPath(artifactHash) {
|
|
@@ -14,7 +14,7 @@ function hasCoherentArtifactPath(input) {
|
|
|
14
14
|
export const PreviewArtifactSchema = Schema.Struct({
|
|
15
15
|
artifactHash: Sha256HashSchema,
|
|
16
16
|
artifactPath: Schema.Trimmed.check(Schema.isNonEmpty()),
|
|
17
|
-
projection:
|
|
17
|
+
projection: ContentProjectionSchema,
|
|
18
18
|
}).pipe(Schema.check(Schema.makeFilter(hasCoherentArtifactPath, {
|
|
19
19
|
message: "Expected the artifact path to match its signed hash.",
|
|
20
20
|
})));
|
|
@@ -184,42 +184,6 @@ export declare const digestProjections: <E, R>(releaseId: string & import("effec
|
|
|
184
184
|
readonly title: string;
|
|
185
185
|
};
|
|
186
186
|
readonly stimulusKey?: string;
|
|
187
|
-
} | {
|
|
188
|
-
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
189
|
-
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
190
|
-
readonly peerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
191
|
-
readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
|
|
192
|
-
readonly questionNumber: number;
|
|
193
|
-
readonly setKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionSetKey">;
|
|
194
|
-
readonly bodyKind: "question";
|
|
195
|
-
readonly kind: "question-body";
|
|
196
|
-
readonly metadata: {
|
|
197
|
-
readonly authors: readonly {
|
|
198
|
-
readonly name: string;
|
|
199
|
-
}[];
|
|
200
|
-
readonly date: string;
|
|
201
|
-
readonly title: string;
|
|
202
|
-
};
|
|
203
|
-
readonly choices: {
|
|
204
|
-
label: string;
|
|
205
|
-
value: boolean;
|
|
206
|
-
}[];
|
|
207
|
-
} | {
|
|
208
|
-
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
209
|
-
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
210
|
-
readonly peerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
211
|
-
readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
|
|
212
|
-
readonly questionNumber: number;
|
|
213
|
-
readonly setKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionSetKey">;
|
|
214
|
-
readonly bodyKind: "answer";
|
|
215
|
-
readonly kind: "question-body";
|
|
216
|
-
readonly metadata: {
|
|
217
|
-
readonly authors: readonly {
|
|
218
|
-
readonly name: string;
|
|
219
|
-
}[];
|
|
220
|
-
readonly date: string;
|
|
221
|
-
readonly title: string;
|
|
222
|
-
};
|
|
223
187
|
}, E, R>) => Effect.Effect<{
|
|
224
188
|
count: number;
|
|
225
189
|
digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
@@ -174,164 +174,6 @@ export declare const QuestionBodyProjectionSchema: Schema.Union<readonly [Schema
|
|
|
174
174
|
readonly stimulusKey: Schema.optionalKey<Schema.String>;
|
|
175
175
|
}>]>;
|
|
176
176
|
export type QuestionBodyProjection = typeof QuestionBodyProjectionSchema.Type;
|
|
177
|
-
/**
|
|
178
|
-
* Exact predecessor Question bytes retained for authenticated rollback reads.
|
|
179
|
-
* Delete only after two accepted scoped rebuilds and an authoritative
|
|
180
|
-
* current/prior audit reports zero `choices` and `date` projections.
|
|
181
|
-
*/
|
|
182
|
-
export declare const HistoricalQuestionBodyProjectionSchema: Schema.Union<readonly [Schema.Struct<{
|
|
183
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
184
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
185
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
186
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
187
|
-
readonly questionNumber: Schema.Finite;
|
|
188
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
189
|
-
readonly bodyKind: Schema.Literal<"question">;
|
|
190
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
191
|
-
readonly metadata: Schema.Struct<{
|
|
192
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
193
|
-
readonly name: Schema.String;
|
|
194
|
-
}>>;
|
|
195
|
-
readonly date: Schema.String;
|
|
196
|
-
readonly title: Schema.String;
|
|
197
|
-
}>;
|
|
198
|
-
readonly choices: Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
199
|
-
readonly label: Schema.mutableKey<Schema.String>;
|
|
200
|
-
readonly value: Schema.mutableKey<Schema.Boolean>;
|
|
201
|
-
}>>>;
|
|
202
|
-
}>, Schema.Struct<{
|
|
203
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
204
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
205
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
206
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
207
|
-
readonly questionNumber: Schema.Finite;
|
|
208
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
209
|
-
readonly bodyKind: Schema.Literal<"answer">;
|
|
210
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
211
|
-
readonly metadata: Schema.Struct<{
|
|
212
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
213
|
-
readonly name: Schema.String;
|
|
214
|
-
}>>;
|
|
215
|
-
readonly date: Schema.String;
|
|
216
|
-
readonly title: Schema.String;
|
|
217
|
-
}>;
|
|
218
|
-
}>]>;
|
|
219
|
-
export type HistoricalQuestionBodyProjection = typeof HistoricalQuestionBodyProjectionSchema.Type;
|
|
220
|
-
/** Current Question values plus exact predecessor rollback bytes. */
|
|
221
|
-
export declare const ReadableQuestionBodyProjectionSchema: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
222
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
223
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
224
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
225
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
226
|
-
readonly questionNumber: Schema.Finite;
|
|
227
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
228
|
-
readonly bodyKind: Schema.Literal<"question">;
|
|
229
|
-
readonly blueprint: Schema.optionalKey<Schema.Struct<{
|
|
230
|
-
readonly cognitiveLevel: Schema.String;
|
|
231
|
-
readonly contentDomain: Schema.String;
|
|
232
|
-
readonly topic: Schema.String;
|
|
233
|
-
}>>;
|
|
234
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
235
|
-
readonly metadata: Schema.Struct<{
|
|
236
|
-
readonly dateModified: Schema.optionalKey<Schema.String>;
|
|
237
|
-
readonly datePublished: Schema.String;
|
|
238
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
239
|
-
readonly name: Schema.String;
|
|
240
|
-
}>>;
|
|
241
|
-
readonly title: Schema.String;
|
|
242
|
-
}>;
|
|
243
|
-
readonly stimulusKey: Schema.optionalKey<Schema.String>;
|
|
244
|
-
readonly response: Schema.Union<readonly [Schema.Struct<{
|
|
245
|
-
readonly categories: Schema.$Array<Schema.Struct<{
|
|
246
|
-
readonly categoryKey: Schema.String;
|
|
247
|
-
readonly label: Schema.String;
|
|
248
|
-
readonly order: Schema.Int;
|
|
249
|
-
}>>;
|
|
250
|
-
readonly kind: Schema.Literal<"category">;
|
|
251
|
-
readonly statements: Schema.$Array<Schema.Struct<{
|
|
252
|
-
readonly correctCategoryKey: Schema.String;
|
|
253
|
-
readonly label: Schema.String;
|
|
254
|
-
readonly order: Schema.Int;
|
|
255
|
-
readonly statementKey: Schema.String;
|
|
256
|
-
}>>;
|
|
257
|
-
}>, Schema.Struct<{
|
|
258
|
-
readonly kind: Schema.Literal<"multiple-choice">;
|
|
259
|
-
readonly options: Schema.$Array<Schema.Struct<{
|
|
260
|
-
readonly isCorrect: Schema.Boolean;
|
|
261
|
-
readonly label: Schema.String;
|
|
262
|
-
readonly optionKey: Schema.String;
|
|
263
|
-
readonly order: Schema.Int;
|
|
264
|
-
}>>;
|
|
265
|
-
}>, Schema.Struct<{
|
|
266
|
-
readonly kind: Schema.Literal<"single-choice">;
|
|
267
|
-
readonly options: Schema.$Array<Schema.Struct<{
|
|
268
|
-
readonly isCorrect: Schema.Boolean;
|
|
269
|
-
readonly label: Schema.String;
|
|
270
|
-
readonly optionKey: Schema.String;
|
|
271
|
-
readonly order: Schema.Int;
|
|
272
|
-
}>>;
|
|
273
|
-
}>]>;
|
|
274
|
-
}>, Schema.Struct<{
|
|
275
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
276
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
277
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
278
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
279
|
-
readonly questionNumber: Schema.Finite;
|
|
280
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
281
|
-
readonly bodyKind: Schema.Literal<"answer">;
|
|
282
|
-
readonly blueprint: Schema.optionalKey<Schema.Struct<{
|
|
283
|
-
readonly cognitiveLevel: Schema.String;
|
|
284
|
-
readonly contentDomain: Schema.String;
|
|
285
|
-
readonly topic: Schema.String;
|
|
286
|
-
}>>;
|
|
287
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
288
|
-
readonly metadata: Schema.Struct<{
|
|
289
|
-
readonly dateModified: Schema.optionalKey<Schema.String>;
|
|
290
|
-
readonly datePublished: Schema.String;
|
|
291
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
292
|
-
readonly name: Schema.String;
|
|
293
|
-
}>>;
|
|
294
|
-
readonly title: Schema.String;
|
|
295
|
-
}>;
|
|
296
|
-
readonly stimulusKey: Schema.optionalKey<Schema.String>;
|
|
297
|
-
}>]>, Schema.Union<readonly [Schema.Struct<{
|
|
298
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
299
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
300
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
301
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
302
|
-
readonly questionNumber: Schema.Finite;
|
|
303
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
304
|
-
readonly bodyKind: Schema.Literal<"question">;
|
|
305
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
306
|
-
readonly metadata: Schema.Struct<{
|
|
307
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
308
|
-
readonly name: Schema.String;
|
|
309
|
-
}>>;
|
|
310
|
-
readonly date: Schema.String;
|
|
311
|
-
readonly title: Schema.String;
|
|
312
|
-
}>;
|
|
313
|
-
readonly choices: Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
314
|
-
readonly label: Schema.mutableKey<Schema.String>;
|
|
315
|
-
readonly value: Schema.mutableKey<Schema.Boolean>;
|
|
316
|
-
}>>>;
|
|
317
|
-
}>, Schema.Struct<{
|
|
318
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
319
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
320
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
321
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
322
|
-
readonly questionNumber: Schema.Finite;
|
|
323
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
324
|
-
readonly bodyKind: Schema.Literal<"answer">;
|
|
325
|
-
readonly kind: Schema.Literal<"question-body">;
|
|
326
|
-
readonly metadata: Schema.Struct<{
|
|
327
|
-
readonly authors: Schema.$Array<Schema.Struct<{
|
|
328
|
-
readonly name: Schema.String;
|
|
329
|
-
}>>;
|
|
330
|
-
readonly date: Schema.String;
|
|
331
|
-
readonly title: Schema.String;
|
|
332
|
-
}>;
|
|
333
|
-
}>]>]>;
|
|
334
|
-
export type ReadableQuestionBodyProjection = typeof ReadableQuestionBodyProjectionSchema.Type;
|
|
335
177
|
interface QuestionProjectionInput {
|
|
336
178
|
readonly artifactLocale: typeof ArtifactLocaleSchema.Type;
|
|
337
179
|
readonly bodyKind: QuestionBodyKind;
|
|
@@ -506,5 +348,5 @@ export declare const makeQuestionBodyProjection: (input: QuestionProjectionInput
|
|
|
506
348
|
kind: "question-body";
|
|
507
349
|
}, import("#contracts/question/item").QuestionResponseLocaleMissingError, never>;
|
|
508
350
|
/** Serializes one question projection with stable signed field order. */
|
|
509
|
-
export declare function canonicalizeQuestionProjection(projection:
|
|
351
|
+
export declare function canonicalizeQuestionProjection(projection: QuestionBodyProjection): string;
|
|
510
352
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Effect, Schema
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
2
|
import { ContentAuthorSchema } from "#contracts/content";
|
|
3
|
-
import {
|
|
3
|
+
import { withPublicationDates } from "#contracts/date";
|
|
4
4
|
import { QuestionAnswerIdentitySchema, QuestionPromptIdentitySchema, } from "#contracts/question/identity";
|
|
5
5
|
import { canonicalQuestionBlueprint, QuestionBlueprintSchema, questionResponseFor, } from "#contracts/question/item";
|
|
6
6
|
import { canonicalQuestionResponse, QuestionResponseSchema, } from "#contracts/question/response";
|
|
@@ -29,48 +29,6 @@ export const QuestionBodyProjectionSchema = Schema.Union([
|
|
|
29
29
|
QuestionPromptProjectionSchema,
|
|
30
30
|
QuestionAnswerProjectionSchema,
|
|
31
31
|
]);
|
|
32
|
-
/** One predecessor choice retained only while authenticated rollback needs it. */
|
|
33
|
-
const HistoricalQuestionChoiceSchema = Schema.Struct({
|
|
34
|
-
label: Schema.String,
|
|
35
|
-
value: Schema.Boolean,
|
|
36
|
-
}).mapFields(Struct.map(Schema.mutableKey));
|
|
37
|
-
/** Checks that one predecessor prompt preserves exactly one correct choice. */
|
|
38
|
-
function hasExactlyOneCorrectChoice(choices) {
|
|
39
|
-
return choices.filter(({ value }) => value).length === 1;
|
|
40
|
-
}
|
|
41
|
-
const HistoricalQuestionChoiceListSchema = Schema.Array(HistoricalQuestionChoiceSchema).pipe(Schema.mutable, Schema.check(Schema.makeFilter(hasExactlyOneCorrectChoice, {
|
|
42
|
-
identifier: "HistoricalQuestionChoiceList",
|
|
43
|
-
message: "Expected exactly one correct historical choice.",
|
|
44
|
-
})));
|
|
45
|
-
const HistoricalQuestionMetadataSchema = Schema.Struct({
|
|
46
|
-
authors: Schema.Array(ContentAuthorSchema),
|
|
47
|
-
date: DateOnlySchema,
|
|
48
|
-
title: Schema.String,
|
|
49
|
-
});
|
|
50
|
-
const HistoricalQuestionProjectionFields = {
|
|
51
|
-
kind: Schema.Literal("question-body"),
|
|
52
|
-
metadata: HistoricalQuestionMetadataSchema,
|
|
53
|
-
};
|
|
54
|
-
const HistoricalQuestionPromptProjectionSchema = QuestionPromptIdentitySchema.mapFields((fields) => ({
|
|
55
|
-
...fields,
|
|
56
|
-
...HistoricalQuestionProjectionFields,
|
|
57
|
-
choices: HistoricalQuestionChoiceListSchema,
|
|
58
|
-
}), { unsafePreserveChecks: true });
|
|
59
|
-
const HistoricalQuestionAnswerProjectionSchema = QuestionAnswerIdentitySchema.mapFields((fields) => ({ ...fields, ...HistoricalQuestionProjectionFields }), { unsafePreserveChecks: true });
|
|
60
|
-
/**
|
|
61
|
-
* Exact predecessor Question bytes retained for authenticated rollback reads.
|
|
62
|
-
* Delete only after two accepted scoped rebuilds and an authoritative
|
|
63
|
-
* current/prior audit reports zero `choices` and `date` projections.
|
|
64
|
-
*/
|
|
65
|
-
export const HistoricalQuestionBodyProjectionSchema = Schema.Union([
|
|
66
|
-
HistoricalQuestionPromptProjectionSchema,
|
|
67
|
-
HistoricalQuestionAnswerProjectionSchema,
|
|
68
|
-
]);
|
|
69
|
-
/** Current Question values plus exact predecessor rollback bytes. */
|
|
70
|
-
export const ReadableQuestionBodyProjectionSchema = Schema.Union([
|
|
71
|
-
QuestionBodyProjectionSchema,
|
|
72
|
-
HistoricalQuestionBodyProjectionSchema,
|
|
73
|
-
]);
|
|
74
32
|
/** Shared identity and metadata carried by both question body projections. */
|
|
75
33
|
function questionProjectionFields(input) {
|
|
76
34
|
return {
|
|
@@ -117,50 +75,32 @@ export const makeQuestionBodyProjection = Effect.fn("AksaraContracts.makeQuestio
|
|
|
117
75
|
}
|
|
118
76
|
return makeQuestionAnswerProjection({ ...input, bodyKind: "answer" });
|
|
119
77
|
});
|
|
120
|
-
/** Preserves the exact response fields owned by each readable prompt format. */
|
|
121
|
-
function canonicalQuestionBody(projection) {
|
|
122
|
-
if (projection.bodyKind === "answer") {
|
|
123
|
-
return {};
|
|
124
|
-
}
|
|
125
|
-
if ("response" in projection) {
|
|
126
|
-
return { response: canonicalQuestionResponse(projection.response) };
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
choices: projection.choices.map(({ label, value }) => ({ label, value })),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
78
|
/** Serializes one question projection with stable signed field order. */
|
|
133
79
|
export function canonicalizeQuestionProjection(projection) {
|
|
134
|
-
const body = canonicalQuestionBody(projection);
|
|
135
|
-
const metadata = "date" in projection.metadata
|
|
136
|
-
? {
|
|
137
|
-
authors: projection.metadata.authors.map(({ name }) => ({ name })),
|
|
138
|
-
date: projection.metadata.date,
|
|
139
|
-
title: projection.metadata.title,
|
|
140
|
-
}
|
|
141
|
-
: {
|
|
142
|
-
authors: projection.metadata.authors.map(({ name }) => ({ name })),
|
|
143
|
-
...(projection.metadata.dateModified === undefined
|
|
144
|
-
? {}
|
|
145
|
-
: { dateModified: projection.metadata.dateModified }),
|
|
146
|
-
datePublished: projection.metadata.datePublished,
|
|
147
|
-
title: projection.metadata.title,
|
|
148
|
-
};
|
|
149
80
|
return JSON.stringify({
|
|
150
81
|
bodyKind: projection.bodyKind,
|
|
151
|
-
...
|
|
82
|
+
...(projection.bodyKind === "question"
|
|
83
|
+
? { response: canonicalQuestionResponse(projection.response) }
|
|
84
|
+
: {}),
|
|
152
85
|
artifactLocale: projection.artifactLocale,
|
|
153
|
-
...(
|
|
86
|
+
...(projection.blueprint === undefined
|
|
154
87
|
? {}
|
|
155
88
|
: { blueprint: canonicalQuestionBlueprint(projection.blueprint) }),
|
|
156
89
|
contentKey: projection.contentKey,
|
|
157
90
|
kind: projection.kind,
|
|
158
|
-
metadata
|
|
91
|
+
metadata: {
|
|
92
|
+
authors: projection.metadata.authors.map(({ name }) => ({ name })),
|
|
93
|
+
...(projection.metadata.dateModified === undefined
|
|
94
|
+
? {}
|
|
95
|
+
: { dateModified: projection.metadata.dateModified }),
|
|
96
|
+
datePublished: projection.metadata.datePublished,
|
|
97
|
+
title: projection.metadata.title,
|
|
98
|
+
},
|
|
159
99
|
peerContentKey: projection.peerContentKey,
|
|
160
100
|
questionKey: projection.questionKey,
|
|
161
101
|
questionNumber: projection.questionNumber,
|
|
162
102
|
setKey: projection.setKey,
|
|
163
|
-
...(
|
|
103
|
+
...(projection.stimulusKey === undefined
|
|
164
104
|
? {}
|
|
165
105
|
: { stimulusKey: projection.stimulusKey }),
|
|
166
106
|
});
|