@nakafa/aksara-contracts 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -25
- package/dist/{question → assessment}/answer.d.ts +14 -58
- package/dist/{question → assessment}/answer.js +13 -60
- package/dist/assessment/catalog.d.ts +235 -0
- package/dist/assessment/catalog.js +115 -0
- package/dist/assessment/chart.d.ts +62 -0
- package/dist/assessment/chart.js +64 -0
- package/dist/assessment/closure.d.ts +28 -0
- package/dist/assessment/closure.js +164 -0
- package/dist/assessment/explanation.d.ts +13 -8
- package/dist/assessment/explanation.js +14 -8
- package/dist/assessment/figure.d.ts +140 -1
- package/dist/assessment/figure.js +9 -2
- package/dist/assessment/hash.d.ts +348 -208
- package/dist/assessment/hash.js +14 -0
- package/dist/assessment/inline.d.ts +3 -1
- package/dist/assessment/inline.js +20 -5
- package/dist/assessment/item.d.ts +8 -4
- package/dist/assessment/item.js +6 -2
- package/dist/assessment/key.js +6 -6
- package/dist/assessment/paper.d.ts +74 -74
- package/dist/assessment/snapshot.d.ts +3778 -0
- package/dist/assessment/snapshot.js +192 -0
- package/dist/cache/content.d.ts +4 -4
- package/dist/canonical.d.ts +6 -0
- package/dist/canonical.js +8 -1
- package/dist/content.d.ts +1 -1
- package/dist/content.js +0 -1
- package/dist/delivery.d.ts +0 -3
- package/dist/delivery.js +0 -5
- package/dist/preview/artifact.d.ts +1 -120
- package/dist/preview/document.d.ts +0 -586
- package/dist/preview/document.js +1 -47
- package/dist/preview/spec.d.ts +6 -1984
- package/dist/preview/spec.js +7 -47
- package/dist/preview/target.d.ts +0 -173
- package/dist/preview/target.js +1 -70
- package/dist/projection/digest.d.ts +0 -127
- package/dist/projection/hash.d.ts +0 -127
- package/dist/projection/spec.d.ts +6 -211
- package/dist/projection/spec.js +4 -18
- package/dist/projection/verify.d.ts +0 -127
- package/dist/projection/verify.js +0 -3
- package/dist/release/canonical.d.ts +2 -2
- package/dist/release/current/evidence.d.ts +24 -24
- package/dist/release/current/state.d.ts +28 -56
- package/dist/release/current/state.js +1 -6
- package/dist/release/digest.d.ts +2 -2
- package/dist/release/hash.d.ts +5 -5
- package/dist/release/head.d.ts +10 -57
- package/dist/release/head.js +3 -14
- package/dist/release/identity.d.ts +3 -3
- package/dist/release/items.d.ts +2 -2
- package/dist/release/lifecycle.d.ts +18 -18
- package/dist/release/policy.d.ts +3 -4
- package/dist/release/policy.js +2 -11
- package/dist/release/result/digest.d.ts +6 -18
- package/dist/release/result/digest.js +1 -2
- package/dist/release/rollback/digest.d.ts +4 -19
- package/dist/release/rollback/spec.d.ts +30 -792
- package/dist/release/rollback/spec.js +1 -4
- package/dist/release/snapshot/data.d.ts +599 -249
- package/dist/release/snapshot/data.js +11 -28
- package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
- package/dist/release/snapshot/evidence/assessment.js +44 -0
- package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
- package/dist/release/snapshot/evidence.d.ts +19 -19
- package/dist/release/snapshot/evidence.js +2 -2
- package/dist/release/snapshot/scope.d.ts +5 -5
- package/dist/release/snapshot/scope.js +1 -1
- package/dist/release/snapshot/spec.d.ts +15 -15
- package/dist/release/snapshot/spec.js +8 -8
- package/dist/release/snapshot/verify.d.ts +1278 -268
- package/dist/release/snapshot/verify.js +8 -5
- package/dist/release/spec.d.ts +33 -33
- package/dist/release/verify.d.ts +5 -5
- package/dist/runtime/spec.d.ts +38 -38
- package/dist/runtime/spec.js +4 -5
- package/dist/runtime/verify.d.ts +40 -40
- package/dist/signature/spec.d.ts +5 -5
- package/dist/signature/spec.js +0 -1
- package/dist/transport/batch.d.ts +6 -244
- package/dist/transport/failure.d.ts +6 -20
- package/dist/transport/failure.js +0 -10
- package/dist/transport/group.d.ts +1969 -1369
- package/dist/transport/group.js +0 -2
- package/dist/transport/request.d.ts +10691 -5086
- package/dist/transport/request.js +0 -3
- package/dist/transport/response.d.ts +219 -1442
- package/dist/transport/response.js +0 -4
- package/dist/transport/snapshot.d.ts +1187 -487
- package/package.json +187 -295
- package/dist/projection/question.d.ts +0 -1067
- package/dist/projection/question.js +0 -121
- package/dist/question/identity.d.ts +0 -175
- package/dist/question/identity.js +0 -207
- package/dist/question/item.d.ts +0 -450
- package/dist/question/item.js +0 -174
- package/dist/question/label.d.ts +0 -3
- package/dist/question/label.js +0 -3
- package/dist/question/points.d.ts +0 -18
- package/dist/question/points.js +0 -22
- package/dist/question/response.d.ts +0 -289
- package/dist/question/response.js +0 -167
- package/dist/question/rubric.d.ts +0 -234
- package/dist/question/rubric.js +0 -186
- package/dist/release/current/runtime.d.ts +0 -4
- package/dist/release/current/runtime.js +0 -15
- package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
- package/dist/release/snapshot/evidence/tryout.js +0 -91
- package/dist/runtime/protected/limits.d.ts +0 -10
- package/dist/runtime/protected/limits.js +0 -16
- package/dist/runtime/protected/spec.d.ts +0 -310
- package/dist/runtime/protected/spec.js +0 -80
- package/dist/runtime/protected/verify.d.ts +0 -83
- package/dist/runtime/protected/verify.js +0 -70
- package/dist/transport/runtime.d.ts +0 -77
- package/dist/transport/runtime.js +0 -33
- package/dist/tryout/canonical.d.ts +0 -12
- package/dist/tryout/canonical.js +0 -7
- package/dist/tryout/catalog.d.ts +0 -396
- package/dist/tryout/catalog.js +0 -155
- package/dist/tryout/closure/accounting.d.ts +0 -20
- package/dist/tryout/closure/accounting.js +0 -70
- package/dist/tryout/closure/locale.d.ts +0 -14
- package/dist/tryout/closure/locale.js +0 -113
- package/dist/tryout/closure/placement.d.ts +0 -5
- package/dist/tryout/closure/placement.js +0 -32
- package/dist/tryout/digest.d.ts +0 -34
- package/dist/tryout/digest.js +0 -57
- package/dist/tryout/hash/catalog.d.ts +0 -364
- package/dist/tryout/hash/catalog.js +0 -209
- package/dist/tryout/hash/content.d.ts +0 -215
- package/dist/tryout/hash/content.js +0 -75
- package/dist/tryout/hash/placement.d.ts +0 -242
- package/dist/tryout/hash/placement.js +0 -56
- package/dist/tryout/identity.d.ts +0 -12
- package/dist/tryout/identity.js +0 -47
- package/dist/tryout/key.d.ts +0 -4
- package/dist/tryout/key.js +0 -8
- package/dist/tryout/language.d.ts +0 -24
- package/dist/tryout/language.js +0 -30
- package/dist/tryout/placement.d.ts +0 -331
- package/dist/tryout/placement.js +0 -96
- package/dist/tryout/runtime/canonical.d.ts +0 -8
- package/dist/tryout/runtime/canonical.js +0 -34
- package/dist/tryout/runtime/hash.d.ts +0 -34
- package/dist/tryout/runtime/hash.js +0 -13
- package/dist/tryout/runtime/source.d.ts +0 -44
- package/dist/tryout/runtime/source.js +0 -47
- package/dist/tryout/runtime/spec.d.ts +0 -58
- package/dist/tryout/runtime/spec.js +0 -21
- package/dist/tryout/runtime/verify.d.ts +0 -69
- package/dist/tryout/runtime/verify.js +0 -67
- package/dist/tryout/scoring.d.ts +0 -148
- package/dist/tryout/scoring.js +0 -98
- package/dist/tryout/snapshot/canonical.d.ts +0 -7
- package/dist/tryout/snapshot/canonical.js +0 -18
- package/dist/tryout/snapshot/hash.d.ts +0 -49
- package/dist/tryout/snapshot/hash.js +0 -22
- package/dist/tryout/snapshot/spec.d.ts +0 -46
- package/dist/tryout/snapshot/spec.js +0 -30
- package/dist/tryout/spec.d.ts +0 -41
- package/dist/tryout/spec.js +0 -46
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Array as Arr, Effect, Schema } from "effect";
|
|
2
|
-
import { ContentAuthorSchema } from "#contracts/content";
|
|
3
|
-
import { withPublicationDates } from "#contracts/date";
|
|
4
|
-
import { ContentKeySchema } from "#contracts/ids";
|
|
5
|
-
import { ArtifactLocaleSchema } from "#contracts/locale";
|
|
6
|
-
import { QuestionAnswerIdentitySchema, QuestionBodyKindSchema, QuestionKeySchema, QuestionPromptIdentitySchema, QuestionSetKeySchema, } from "#contracts/question/identity";
|
|
7
|
-
import { canonicalQuestionBlueprint, QuestionBlueprintSchema, QuestionItemSchema, questionResponseFor, } from "#contracts/question/item";
|
|
8
|
-
import { canonicalQuestionResponse, QuestionResponseSchema, } from "#contracts/question/response";
|
|
9
|
-
import { encodeJsonText } from "#contracts/text/json";
|
|
10
|
-
import { TryoutKeySchema } from "#contracts/tryout/key";
|
|
11
|
-
/** Exact metadata authored by every current question and answer body. */
|
|
12
|
-
export const QuestionMetadataSchema = withPublicationDates({
|
|
13
|
-
authors: Schema.Array(ContentAuthorSchema),
|
|
14
|
-
title: Schema.String,
|
|
15
|
-
});
|
|
16
|
-
const QuestionProjectionFields = {
|
|
17
|
-
blueprint: Schema.optionalKey(QuestionBlueprintSchema),
|
|
18
|
-
kind: Schema.Literal("question-body"),
|
|
19
|
-
metadata: QuestionMetadataSchema,
|
|
20
|
-
stimulusKey: Schema.optionalKey(TryoutKeySchema),
|
|
21
|
-
};
|
|
22
|
-
/** Published body and localized response for one authored question prompt. */
|
|
23
|
-
export const QuestionPromptProjectionSchema = QuestionPromptIdentitySchema.mapFields((fields) => ({
|
|
24
|
-
...fields,
|
|
25
|
-
...QuestionProjectionFields,
|
|
26
|
-
response: QuestionResponseSchema,
|
|
27
|
-
}), { unsafePreserveChecks: true });
|
|
28
|
-
/** Published body for one entitled answer without a duplicated response. */
|
|
29
|
-
export const QuestionAnswerProjectionSchema = QuestionAnswerIdentitySchema.mapFields((fields) => ({ ...fields, ...QuestionProjectionFields }), { unsafePreserveChecks: true });
|
|
30
|
-
/** Complete non-route projection vocabulary for question-bank MDX bodies. */
|
|
31
|
-
export const QuestionBodyProjectionSchema = Schema.Union([
|
|
32
|
-
QuestionPromptProjectionSchema,
|
|
33
|
-
QuestionAnswerProjectionSchema,
|
|
34
|
-
]);
|
|
35
|
-
const QuestionProjectionInputSchema = Schema.Struct({
|
|
36
|
-
artifactLocale: ArtifactLocaleSchema,
|
|
37
|
-
bodyKind: QuestionBodyKindSchema,
|
|
38
|
-
contentKey: ContentKeySchema,
|
|
39
|
-
item: QuestionItemSchema,
|
|
40
|
-
metadata: QuestionMetadataSchema,
|
|
41
|
-
peerContentKey: ContentKeySchema,
|
|
42
|
-
questionKey: QuestionKeySchema,
|
|
43
|
-
questionNumber: Schema.Finite,
|
|
44
|
-
setKey: QuestionSetKeySchema,
|
|
45
|
-
});
|
|
46
|
-
/** Shared identity and metadata carried by both question body projections. */
|
|
47
|
-
function questionProjectionFields(input) {
|
|
48
|
-
return {
|
|
49
|
-
artifactLocale: input.artifactLocale,
|
|
50
|
-
contentKey: input.contentKey,
|
|
51
|
-
metadata: input.metadata,
|
|
52
|
-
peerContentKey: input.peerContentKey,
|
|
53
|
-
questionKey: input.questionKey,
|
|
54
|
-
questionNumber: input.questionNumber,
|
|
55
|
-
setKey: input.setKey,
|
|
56
|
-
...(input.item.blueprint === undefined
|
|
57
|
-
? {}
|
|
58
|
-
: { blueprint: input.item.blueprint }),
|
|
59
|
-
...(input.item.stimulusKey === undefined
|
|
60
|
-
? {}
|
|
61
|
-
: { stimulusKey: input.item.stimulusKey }),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/** Builds one prompt projection with its exact-locale frozen response. */
|
|
65
|
-
export const makeQuestionPromptProjection = Effect.fn("AksaraContracts.makeQuestionPromptProjection")(function* (input) {
|
|
66
|
-
const response = yield* questionResponseFor(input.item, input.artifactLocale);
|
|
67
|
-
return {
|
|
68
|
-
...questionProjectionFields(input),
|
|
69
|
-
bodyKind: "question",
|
|
70
|
-
kind: "question-body",
|
|
71
|
-
response,
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
/** Builds one answer projection without duplicating the prompt response. */
|
|
75
|
-
export function makeQuestionAnswerProjection(input) {
|
|
76
|
-
return {
|
|
77
|
-
...questionProjectionFields(input),
|
|
78
|
-
bodyKind: "answer",
|
|
79
|
-
kind: "question-body",
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/** Builds one strictly bound question or answer projection from authored facts. */
|
|
83
|
-
export const makeQuestionBodyProjection = Effect.fn("AksaraContracts.makeQuestionBodyProjection")(function* (input) {
|
|
84
|
-
if (input.bodyKind === "question") {
|
|
85
|
-
return yield* makeQuestionPromptProjection({
|
|
86
|
-
...input,
|
|
87
|
-
bodyKind: "question",
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return makeQuestionAnswerProjection({ ...input, bodyKind: "answer" });
|
|
91
|
-
});
|
|
92
|
-
/** Serializes one question projection with stable signed field order. */
|
|
93
|
-
export function canonicalizeQuestionProjection(projection) {
|
|
94
|
-
return encodeJsonText({
|
|
95
|
-
bodyKind: projection.bodyKind,
|
|
96
|
-
...(projection.bodyKind === "question"
|
|
97
|
-
? { response: canonicalQuestionResponse(projection.response) }
|
|
98
|
-
: {}),
|
|
99
|
-
artifactLocale: projection.artifactLocale,
|
|
100
|
-
...(projection.blueprint === undefined
|
|
101
|
-
? {}
|
|
102
|
-
: { blueprint: canonicalQuestionBlueprint(projection.blueprint) }),
|
|
103
|
-
contentKey: projection.contentKey,
|
|
104
|
-
kind: projection.kind,
|
|
105
|
-
metadata: {
|
|
106
|
-
authors: Arr.map(projection.metadata.authors, ({ name }) => ({ name })),
|
|
107
|
-
...(projection.metadata.dateModified === undefined
|
|
108
|
-
? {}
|
|
109
|
-
: { dateModified: projection.metadata.dateModified }),
|
|
110
|
-
datePublished: projection.metadata.datePublished,
|
|
111
|
-
title: projection.metadata.title,
|
|
112
|
-
},
|
|
113
|
-
peerContentKey: projection.peerContentKey,
|
|
114
|
-
questionKey: projection.questionKey,
|
|
115
|
-
questionNumber: projection.questionNumber,
|
|
116
|
-
setKey: projection.setKey,
|
|
117
|
-
...(projection.stimulusKey === undefined
|
|
118
|
-
? {}
|
|
119
|
-
: { stimulusKey: projection.stimulusKey }),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
/** Stable namespace shared by every try-out question-bank identity. */
|
|
3
|
-
export declare const QUESTION_BANK_KEY_ROOT = "question-bank/tryout";
|
|
4
|
-
/** Canonical terminal directory identity for one numbered question. */
|
|
5
|
-
export declare const QuestionSegmentSchema: Schema.String;
|
|
6
|
-
/** Authored MDX body roles carried by each localized question. */
|
|
7
|
-
export declare const QuestionBodyKindSchema: Schema.Literals<readonly ["question", "answer"]>;
|
|
8
|
-
export type QuestionBodyKind = typeof QuestionBodyKindSchema.Type;
|
|
9
|
-
/** Generic hierarchy derived from one canonical try-out question set. */
|
|
10
|
-
export declare const QuestionSetPartsSchema: Schema.Struct<{
|
|
11
|
-
readonly countryKey: Schema.String;
|
|
12
|
-
readonly examKey: Schema.String;
|
|
13
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
14
|
-
readonly sectionKey: Schema.String;
|
|
15
|
-
readonly setKey: Schema.String;
|
|
16
|
-
}>;
|
|
17
|
-
export type QuestionSetParts = typeof QuestionSetPartsSchema.Type;
|
|
18
|
-
/** Generic hierarchy and authored order derived from one question key. */
|
|
19
|
-
export declare const QuestionKeyPartsSchema: Schema.Struct<{
|
|
20
|
-
readonly countryKey: Schema.String;
|
|
21
|
-
readonly examKey: Schema.String;
|
|
22
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
23
|
-
readonly sectionKey: Schema.String;
|
|
24
|
-
readonly setKey: Schema.String;
|
|
25
|
-
readonly questionNumber: Schema.Finite;
|
|
26
|
-
}>;
|
|
27
|
-
export type QuestionKeyParts = typeof QuestionKeyPartsSchema.Type;
|
|
28
|
-
/** Stable logical identity shared by every locale and body of one question. */
|
|
29
|
-
export declare const QuestionKeySchema: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
30
|
-
export type QuestionKey = typeof QuestionKeySchema.Type;
|
|
31
|
-
/** Stable logical identity shared by every question within one authored set. */
|
|
32
|
-
export declare const QuestionSetKeySchema: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
33
|
-
export type QuestionSetKey = typeof QuestionSetKeySchema.Type;
|
|
34
|
-
/** Derives the renderer-owned bank identity above one authored set. */
|
|
35
|
-
export declare function questionBankKey(questionSetKey: QuestionSetKey): string;
|
|
36
|
-
/** Derives generic country, exam, bank, section, and set identities. */
|
|
37
|
-
export declare function questionSetKeyParts(questionSetKey: QuestionSetKey): {
|
|
38
|
-
readonly countryKey: string;
|
|
39
|
-
readonly examKey: string;
|
|
40
|
-
readonly intermediateBankKeys: readonly string[];
|
|
41
|
-
readonly sectionKey: string;
|
|
42
|
-
readonly setKey: string;
|
|
43
|
-
};
|
|
44
|
-
/** Derives the parent hierarchy and safe authored order from one question. */
|
|
45
|
-
export declare function questionKeyParts(questionKey: QuestionKey): {
|
|
46
|
-
countryKey: string;
|
|
47
|
-
examKey: string;
|
|
48
|
-
intermediateBankKeys: readonly string[];
|
|
49
|
-
sectionKey: string;
|
|
50
|
-
setKey: string;
|
|
51
|
-
questionNumber: number;
|
|
52
|
-
questionSetKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionSetKey">;
|
|
53
|
-
};
|
|
54
|
-
/** Complete physical MDX source identity derived from one question body. */
|
|
55
|
-
export declare const QuestionBodySourcePartsSchema: Schema.Struct<{
|
|
56
|
-
readonly countryKey: Schema.String;
|
|
57
|
-
readonly examKey: Schema.String;
|
|
58
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
59
|
-
readonly sectionKey: Schema.String;
|
|
60
|
-
readonly setKey: Schema.String;
|
|
61
|
-
readonly questionNumber: Schema.Finite;
|
|
62
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
63
|
-
readonly sourcePath: Schema.brand<Schema.String, "@NakafaAI/AksaraCorpusSourcePath">;
|
|
64
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
65
|
-
readonly bodyKind: Schema.Literals<readonly ["question", "answer"]>;
|
|
66
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
67
|
-
readonly kind: Schema.Literal<"body">;
|
|
68
|
-
}>;
|
|
69
|
-
/** Complete physical TypeScript source identity for one assessment item. */
|
|
70
|
-
export declare const QuestionItemSourcePartsSchema: Schema.Struct<{
|
|
71
|
-
readonly countryKey: Schema.String;
|
|
72
|
-
readonly examKey: Schema.String;
|
|
73
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
74
|
-
readonly sectionKey: Schema.String;
|
|
75
|
-
readonly setKey: Schema.String;
|
|
76
|
-
readonly questionNumber: Schema.Finite;
|
|
77
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
78
|
-
readonly sourcePath: Schema.brand<Schema.String, "@NakafaAI/AksaraCorpusSourcePath">;
|
|
79
|
-
readonly kind: Schema.Literal<"item">;
|
|
80
|
-
}>;
|
|
81
|
-
/** Every direct authored source accepted inside one question directory. */
|
|
82
|
-
export declare const QuestionSourcePartsSchema: Schema.Union<readonly [Schema.Struct<{
|
|
83
|
-
readonly countryKey: Schema.String;
|
|
84
|
-
readonly examKey: Schema.String;
|
|
85
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
86
|
-
readonly sectionKey: Schema.String;
|
|
87
|
-
readonly setKey: Schema.String;
|
|
88
|
-
readonly questionNumber: Schema.Finite;
|
|
89
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
90
|
-
readonly sourcePath: Schema.brand<Schema.String, "@NakafaAI/AksaraCorpusSourcePath">;
|
|
91
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
92
|
-
readonly bodyKind: Schema.Literals<readonly ["question", "answer"]>;
|
|
93
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
94
|
-
readonly kind: Schema.Literal<"body">;
|
|
95
|
-
}>, Schema.Struct<{
|
|
96
|
-
readonly countryKey: Schema.String;
|
|
97
|
-
readonly examKey: Schema.String;
|
|
98
|
-
readonly intermediateBankKeys: Schema.$Array<Schema.String>;
|
|
99
|
-
readonly sectionKey: Schema.String;
|
|
100
|
-
readonly setKey: Schema.String;
|
|
101
|
-
readonly questionNumber: Schema.Finite;
|
|
102
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
103
|
-
readonly sourcePath: Schema.brand<Schema.String, "@NakafaAI/AksaraCorpusSourcePath">;
|
|
104
|
-
readonly kind: Schema.Literal<"item">;
|
|
105
|
-
}>]>;
|
|
106
|
-
export type QuestionSourceParts = typeof QuestionSourcePartsSchema.Type;
|
|
107
|
-
/** Exact direct authored source path below one Aksara question directory. */
|
|
108
|
-
export declare const QuestionSourcePathSchema: Schema.brand<Schema.brand<Schema.String, "@NakafaAI/AksaraCorpusSourcePath">, "@NakafaAI/AksaraQuestionSourcePath">;
|
|
109
|
-
export type QuestionSourcePath = typeof QuestionSourcePathSchema.Type;
|
|
110
|
-
/** Derives every logical identity from one validated physical source path. */
|
|
111
|
-
export declare function questionSourcePathParts(sourcePath: QuestionSourcePath): {
|
|
112
|
-
readonly countryKey: string;
|
|
113
|
-
readonly examKey: string;
|
|
114
|
-
readonly intermediateBankKeys: readonly string[];
|
|
115
|
-
readonly sectionKey: string;
|
|
116
|
-
readonly setKey: string;
|
|
117
|
-
readonly questionNumber: number;
|
|
118
|
-
readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
|
|
119
|
-
readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
120
|
-
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
121
|
-
readonly bodyKind: "answer" | "question";
|
|
122
|
-
readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
123
|
-
readonly kind: "body";
|
|
124
|
-
} | {
|
|
125
|
-
readonly countryKey: string;
|
|
126
|
-
readonly examKey: string;
|
|
127
|
-
readonly intermediateBankKeys: readonly string[];
|
|
128
|
-
readonly sectionKey: string;
|
|
129
|
-
readonly setKey: string;
|
|
130
|
-
readonly questionNumber: number;
|
|
131
|
-
readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
|
|
132
|
-
readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
133
|
-
readonly kind: "item";
|
|
134
|
-
};
|
|
135
|
-
/** Exact stable identity carried by one localized question prompt. */
|
|
136
|
-
export declare const QuestionPromptIdentitySchema: Schema.Struct<{
|
|
137
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
138
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
139
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
140
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
141
|
-
readonly questionNumber: Schema.Finite;
|
|
142
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
143
|
-
readonly bodyKind: Schema.Literal<"question">;
|
|
144
|
-
}>;
|
|
145
|
-
export type QuestionPromptIdentity = typeof QuestionPromptIdentitySchema.Type;
|
|
146
|
-
/** Exact stable identity carried by one localized entitled answer. */
|
|
147
|
-
export declare const QuestionAnswerIdentitySchema: Schema.Struct<{
|
|
148
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
149
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
150
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
151
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
152
|
-
readonly questionNumber: Schema.Finite;
|
|
153
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
154
|
-
readonly bodyKind: Schema.Literal<"answer">;
|
|
155
|
-
}>;
|
|
156
|
-
export type QuestionAnswerIdentity = typeof QuestionAnswerIdentitySchema.Type;
|
|
157
|
-
/** Complete prompt and answer identity vocabulary for question bodies. */
|
|
158
|
-
export declare const QuestionBodyIdentitySchema: Schema.Union<readonly [Schema.Struct<{
|
|
159
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
160
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
161
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
162
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
163
|
-
readonly questionNumber: Schema.Finite;
|
|
164
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
165
|
-
readonly bodyKind: Schema.Literal<"question">;
|
|
166
|
-
}>, Schema.Struct<{
|
|
167
|
-
readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
|
|
168
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
169
|
-
readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
170
|
-
readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
|
|
171
|
-
readonly questionNumber: Schema.Finite;
|
|
172
|
-
readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
|
|
173
|
-
readonly bodyKind: Schema.Literal<"answer">;
|
|
174
|
-
}>]>;
|
|
175
|
-
export type QuestionBodyIdentity = typeof QuestionBodyIdentitySchema.Type;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { Array as Arr, Schema } from "effect";
|
|
2
|
-
import { CONTENT_KEY_MAX_LENGTH, ContentKeySchema, CorpusSourcePathSchema, } from "#contracts/ids";
|
|
3
|
-
import { ArtifactLocaleSchema } from "#contracts/locale";
|
|
4
|
-
import { TryoutKeySchema } from "#contracts/tryout/key";
|
|
5
|
-
/** Stable namespace shared by every try-out question-bank identity. */
|
|
6
|
-
export const QUESTION_BANK_KEY_ROOT = "question-bank/tryout";
|
|
7
|
-
const QUESTION_NUMBER_PATTERN = /^question-[1-9]\d*$/u;
|
|
8
|
-
const QUESTION_SEGMENT_PREFIX = "question-";
|
|
9
|
-
const MAX_QUESTION_KEY_LENGTH = CONTENT_KEY_MAX_LENGTH - "/question".length;
|
|
10
|
-
const MAX_QUESTION_SET_KEY_LENGTH = MAX_QUESTION_KEY_LENGTH - "/question-1".length;
|
|
11
|
-
const isTryoutKey = Schema.is(TryoutKeySchema);
|
|
12
|
-
/** Checks that one canonical question number stays a safe integer. */
|
|
13
|
-
function hasSafeQuestionNumber(segment) {
|
|
14
|
-
return Number.isSafeInteger(Number(segment.slice(QUESTION_SEGMENT_PREFIX.length)));
|
|
15
|
-
}
|
|
16
|
-
/** Canonical terminal directory identity for one numbered question. */
|
|
17
|
-
export const QuestionSegmentSchema = Schema.String.pipe(Schema.check(Schema.isPattern(QUESTION_NUMBER_PATTERN)), Schema.check(Schema.makeFilter(hasSafeQuestionNumber)));
|
|
18
|
-
const isQuestionSegment = Schema.is(QuestionSegmentSchema);
|
|
19
|
-
/** Authored MDX body roles carried by each localized question. */
|
|
20
|
-
export const QuestionBodyKindSchema = Schema.Literals(["question", "answer"]);
|
|
21
|
-
/** Generic hierarchy derived from one canonical try-out question set. */
|
|
22
|
-
export const QuestionSetPartsSchema = Schema.Struct({
|
|
23
|
-
countryKey: TryoutKeySchema,
|
|
24
|
-
examKey: TryoutKeySchema,
|
|
25
|
-
intermediateBankKeys: Schema.Array(TryoutKeySchema),
|
|
26
|
-
sectionKey: TryoutKeySchema,
|
|
27
|
-
setKey: TryoutKeySchema,
|
|
28
|
-
});
|
|
29
|
-
/** Generic hierarchy and authored order derived from one question key. */
|
|
30
|
-
export const QuestionKeyPartsSchema = Schema.Struct({
|
|
31
|
-
...QuestionSetPartsSchema.fields,
|
|
32
|
-
questionNumber: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThan(0))),
|
|
33
|
-
});
|
|
34
|
-
/** Parses the protocol root plus generic country, exam, and set hierarchy. */
|
|
35
|
-
function parseQuestionSetParts(input) {
|
|
36
|
-
const prefix = `${QUESTION_BANK_KEY_ROOT}/`;
|
|
37
|
-
if (!input.startsWith(prefix)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const keys = input.slice(prefix.length).split("/");
|
|
41
|
-
if (keys.length < 4 ||
|
|
42
|
-
Arr.some(keys, (key) => !isTryoutKey(key) || isQuestionSegment(key))) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const [countryKey, examKey, ...rest] = keys;
|
|
46
|
-
const [sectionKey, setKey] = Arr.takeRight(rest, 2);
|
|
47
|
-
return Schema.decodeUnknownSync(QuestionSetPartsSchema)({
|
|
48
|
-
countryKey,
|
|
49
|
-
examKey,
|
|
50
|
-
intermediateBankKeys: Arr.dropRight(rest, 2),
|
|
51
|
-
sectionKey,
|
|
52
|
-
setKey,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/** Parses one numbered question beneath a structurally valid set identity. */
|
|
56
|
-
function parseQuestionKeyParts(input) {
|
|
57
|
-
const separator = input.lastIndexOf("/");
|
|
58
|
-
if (separator === -1) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const question = input.slice(separator + 1);
|
|
62
|
-
const setParts = parseQuestionSetParts(input.slice(0, separator));
|
|
63
|
-
if (!isQuestionSegment(question) || setParts === undefined) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
...setParts,
|
|
68
|
-
questionNumber: Number(question.slice(QUESTION_SEGMENT_PREFIX.length)),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/** Stable logical identity shared by every locale and body of one question. */
|
|
72
|
-
export const QuestionKeySchema = Schema.String.pipe(Schema.check(Schema.isMaxLength(MAX_QUESTION_KEY_LENGTH)), Schema.check(Schema.makeFilter((input) => parseQuestionKeyParts(input) !== undefined, {
|
|
73
|
-
identifier: "QuestionKey",
|
|
74
|
-
message: "Invalid try-out question key.",
|
|
75
|
-
})), Schema.brand("@NakafaAI/AksaraQuestionKey"));
|
|
76
|
-
/** Stable logical identity shared by every question within one authored set. */
|
|
77
|
-
export const QuestionSetKeySchema = Schema.String.pipe(Schema.check(Schema.isMaxLength(MAX_QUESTION_SET_KEY_LENGTH)), Schema.check(Schema.makeFilter((input) => parseQuestionSetParts(input) !== undefined, {
|
|
78
|
-
identifier: "QuestionSetKey",
|
|
79
|
-
message: "Invalid try-out question-set key.",
|
|
80
|
-
})), Schema.brand("@NakafaAI/AksaraQuestionSetKey"));
|
|
81
|
-
/** Derives the renderer-owned bank identity above one authored set. */
|
|
82
|
-
export function questionBankKey(questionSetKey) {
|
|
83
|
-
return questionSetKey.slice(0, questionSetKey.lastIndexOf("/"));
|
|
84
|
-
}
|
|
85
|
-
/** Derives generic country, exam, bank, section, and set identities. */
|
|
86
|
-
export function questionSetKeyParts(questionSetKey) {
|
|
87
|
-
return Schema.decodeUnknownSync(QuestionSetPartsSchema)(parseQuestionSetParts(questionSetKey));
|
|
88
|
-
}
|
|
89
|
-
/** Derives the parent hierarchy and safe authored order from one question. */
|
|
90
|
-
export function questionKeyParts(questionKey) {
|
|
91
|
-
const parts = Schema.decodeUnknownSync(QuestionKeyPartsSchema)(parseQuestionKeyParts(questionKey));
|
|
92
|
-
const separator = questionKey.lastIndexOf("/");
|
|
93
|
-
return {
|
|
94
|
-
...parts,
|
|
95
|
-
questionSetKey: QuestionSetKeySchema.make(questionKey.slice(0, separator)),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const QuestionSourceFields = {
|
|
99
|
-
...QuestionKeyPartsSchema.fields,
|
|
100
|
-
questionKey: QuestionKeySchema,
|
|
101
|
-
sourcePath: CorpusSourcePathSchema,
|
|
102
|
-
};
|
|
103
|
-
/** Complete physical MDX source identity derived from one question body. */
|
|
104
|
-
export const QuestionBodySourcePartsSchema = Schema.Struct({
|
|
105
|
-
...QuestionSourceFields,
|
|
106
|
-
artifactLocale: ArtifactLocaleSchema,
|
|
107
|
-
bodyKind: QuestionBodyKindSchema,
|
|
108
|
-
contentKey: ContentKeySchema,
|
|
109
|
-
kind: Schema.Literal("body"),
|
|
110
|
-
});
|
|
111
|
-
/** Complete physical TypeScript source identity for one assessment item. */
|
|
112
|
-
export const QuestionItemSourcePartsSchema = Schema.Struct({
|
|
113
|
-
...QuestionSourceFields,
|
|
114
|
-
kind: Schema.Literal("item"),
|
|
115
|
-
});
|
|
116
|
-
/** Every direct authored source accepted inside one question directory. */
|
|
117
|
-
export const QuestionSourcePartsSchema = Schema.Union([
|
|
118
|
-
QuestionBodySourcePartsSchema,
|
|
119
|
-
QuestionItemSourcePartsSchema,
|
|
120
|
-
]);
|
|
121
|
-
/** Parses one exact body or item source below the question corpus. */
|
|
122
|
-
function parseQuestionSourceParts(input) {
|
|
123
|
-
const corpusPrefix = "packages/corpus/";
|
|
124
|
-
const fileSeparator = input.lastIndexOf("/");
|
|
125
|
-
const questionKey = input.slice(corpusPrefix.length, fileSeparator);
|
|
126
|
-
const questionParts = parseQuestionKeyParts(questionKey);
|
|
127
|
-
if (questionParts === undefined ||
|
|
128
|
-
!Schema.is(QuestionKeySchema)(questionKey)) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const sourceFile = input.slice(fileSeparator + 1);
|
|
132
|
-
if (sourceFile === "item.ts") {
|
|
133
|
-
return Schema.decodeSync(QuestionItemSourcePartsSchema)({
|
|
134
|
-
...questionParts,
|
|
135
|
-
kind: "item",
|
|
136
|
-
questionKey,
|
|
137
|
-
sourcePath: input,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
const extension = ".mdx";
|
|
141
|
-
if (!sourceFile.endsWith(extension)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const fileStem = sourceFile.slice(0, -extension.length);
|
|
145
|
-
const localeSeparator = fileStem.lastIndexOf(".");
|
|
146
|
-
if (localeSeparator === -1) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const bodyKind = fileStem.slice(0, localeSeparator);
|
|
150
|
-
const artifactLocale = fileStem.slice(localeSeparator + 1);
|
|
151
|
-
if (!(Schema.is(QuestionBodyKindSchema)(bodyKind) &&
|
|
152
|
-
Schema.is(ArtifactLocaleSchema)(artifactLocale))) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
return Schema.decodeSync(QuestionBodySourcePartsSchema)({
|
|
156
|
-
...questionParts,
|
|
157
|
-
artifactLocale,
|
|
158
|
-
bodyKind,
|
|
159
|
-
contentKey: `${questionKey}/${bodyKind}`,
|
|
160
|
-
kind: "body",
|
|
161
|
-
questionKey,
|
|
162
|
-
sourcePath: input,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
/** Exact direct authored source path below one Aksara question directory. */
|
|
166
|
-
export const QuestionSourcePathSchema = CorpusSourcePathSchema.pipe(Schema.check(Schema.makeFilter((input) => parseQuestionSourceParts(input) !== undefined, {
|
|
167
|
-
message: "Invalid try-out question source path.",
|
|
168
|
-
})), Schema.brand("@NakafaAI/AksaraQuestionSourcePath"));
|
|
169
|
-
/** Derives every logical identity from one validated physical source path. */
|
|
170
|
-
export function questionSourcePathParts(sourcePath) {
|
|
171
|
-
return Schema.decodeUnknownSync(QuestionSourcePartsSchema)(parseQuestionSourceParts(sourcePath));
|
|
172
|
-
}
|
|
173
|
-
const QuestionIdentityFields = {
|
|
174
|
-
artifactLocale: ArtifactLocaleSchema,
|
|
175
|
-
contentKey: ContentKeySchema,
|
|
176
|
-
peerContentKey: ContentKeySchema,
|
|
177
|
-
questionKey: QuestionKeySchema,
|
|
178
|
-
questionNumber: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThan(0))),
|
|
179
|
-
setKey: QuestionSetKeySchema,
|
|
180
|
-
};
|
|
181
|
-
/** Checks logical question, body, peer, set, and numeric identities together. */
|
|
182
|
-
function hasCoherentQuestionIdentity(input) {
|
|
183
|
-
const expectedQuestionKey = `${input.setKey}/question-${input.questionNumber}`;
|
|
184
|
-
const peerKind = input.bodyKind === "question" ? "answer" : "question";
|
|
185
|
-
return (input.questionKey === expectedQuestionKey &&
|
|
186
|
-
input.contentKey === `${input.questionKey}/${input.bodyKind}` &&
|
|
187
|
-
input.peerContentKey === `${input.questionKey}/${peerKind}`);
|
|
188
|
-
}
|
|
189
|
-
/** Exact stable identity carried by one localized question prompt. */
|
|
190
|
-
export const QuestionPromptIdentitySchema = Schema.Struct({
|
|
191
|
-
...QuestionIdentityFields,
|
|
192
|
-
bodyKind: Schema.Literal("question"),
|
|
193
|
-
}).pipe(Schema.check(Schema.makeFilter(hasCoherentQuestionIdentity, {
|
|
194
|
-
message: "Expected question body, peer, set, and number identities to agree.",
|
|
195
|
-
})));
|
|
196
|
-
/** Exact stable identity carried by one localized entitled answer. */
|
|
197
|
-
export const QuestionAnswerIdentitySchema = Schema.Struct({
|
|
198
|
-
...QuestionIdentityFields,
|
|
199
|
-
bodyKind: Schema.Literal("answer"),
|
|
200
|
-
}).pipe(Schema.check(Schema.makeFilter(hasCoherentQuestionIdentity, {
|
|
201
|
-
message: "Expected answer body, peer, set, and number identities to agree.",
|
|
202
|
-
})));
|
|
203
|
-
/** Complete prompt and answer identity vocabulary for question bodies. */
|
|
204
|
-
export const QuestionBodyIdentitySchema = Schema.Union([
|
|
205
|
-
QuestionPromptIdentitySchema,
|
|
206
|
-
QuestionAnswerIdentitySchema,
|
|
207
|
-
]);
|