@orakl/protocol 0.1.0 → 0.2.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/dist/badges.d.ts +1 -1
- package/dist/pages/app.schema.d.ts +1 -4
- package/dist/pages/app.schema.js +2 -2
- package/dist/pages/common.schema.d.ts +7 -4
- package/dist/pages/common.schema.js +2 -2
- package/dist/pages/history.schema.d.ts +19 -13
- package/dist/pages/history.schema.js +4 -3
- package/dist/pages/quiz.schema.d.ts +7 -4
- package/dist/question.schema.d.ts +12 -0
- package/dist/question.schema.js +11 -0
- package/package.json +1 -1
package/dist/badges.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type BadgeId = "victor" | "flawless" | "sharpshooter" | "podium" | "unstoppable" | "on-a-roll" | "survivor" | "giant-slayer" | "pantheon" | "specialist" | "polymath" | "phoenix" | "strong-finish" | "master-of-none" | "faster-than-most" | "clutch" | "quick-draw" | "decisive" | "sure-handed" | "unbroken-focus" | "devotee";
|
|
1
|
+
export type BadgeId = "victor" | "flawless" | "sharpshooter" | "podium" | "unstoppable" | "on-a-roll" | "survivor" | "giant-slayer" | "pantheon" | "specialist" | "polymath" | "phoenix" | "strong-finish" | "master-of-none" | "faster-than-most" | "clutch" | "quick-draw" | "decisive" | "sure-handed" | "unbroken-focus" | "devotee" | "herculean" | "undaunted" | "measured" | "strong-start" | "new-heights" | "far-horizons" | "cassandra" | "lone-torch" | "ascendant" | "undisputed";
|
|
2
2
|
/** Modes a badge can be awarded in. */
|
|
3
3
|
export type BadgeMode = "solo" | "multiplayer";
|
|
4
4
|
export interface BadgeAward {
|
|
@@ -441,10 +441,7 @@ export declare const CuratorHistoryEntryPageSchema: Schema.Struct<{
|
|
|
441
441
|
readonly correct: boolean;
|
|
442
442
|
}[] | null;
|
|
443
443
|
readonly noAnswer: number;
|
|
444
|
-
readonly source?:
|
|
445
|
-
readonly url: string;
|
|
446
|
-
readonly label?: string | undefined;
|
|
447
|
-
} | undefined;
|
|
444
|
+
readonly source?: unknown;
|
|
448
445
|
readonly postAnswerNote?: string | undefined;
|
|
449
446
|
readonly questionText?: string | undefined;
|
|
450
447
|
readonly mediaUrl?: string | undefined;
|
package/dist/pages/app.schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { MediaTypeSchema,
|
|
2
|
+
import { MediaTypeSchema, StoredQuestionSourceSchema, } from "../question.schema.js";
|
|
3
3
|
import { ThemeModeSchema, UserPowerSchema, UserRoleSchema, } from "./common.schema.js";
|
|
4
4
|
/** Page-load response bodies for `src/api/routes/pages.ts`. */
|
|
5
5
|
/** A JSON array, decoded mutable — Effect's `Schema.Array` types its `.Type`
|
|
@@ -265,7 +265,7 @@ const QuestionRecapEntrySchema = Schema.Struct({
|
|
|
265
265
|
questionText: Schema.optional(Schema.String),
|
|
266
266
|
mediaUrl: Schema.optional(Schema.String),
|
|
267
267
|
mediaType: Schema.optional(MediaTypeSchema),
|
|
268
|
-
source: Schema.optional(
|
|
268
|
+
source: Schema.optional(StoredQuestionSourceSchema),
|
|
269
269
|
postAnswerNote: Schema.optional(Schema.String),
|
|
270
270
|
answered: Schema.Number,
|
|
271
271
|
correct: Schema.Number,
|
|
@@ -19,9 +19,12 @@ export declare const GameAnswerRecordSchema: Schema.Struct<{
|
|
|
19
19
|
correctAnswerText: Schema.optional<typeof Schema.String>;
|
|
20
20
|
mediaUrl: Schema.optional<typeof Schema.String>;
|
|
21
21
|
mediaType: Schema.optional<Schema.Literal<["image", "audio", "video"]>>;
|
|
22
|
-
source: Schema.optional<Schema.
|
|
23
|
-
url:
|
|
24
|
-
label
|
|
25
|
-
}
|
|
22
|
+
source: Schema.optional<Schema.transform<typeof Schema.Unknown, Schema.UndefinedOr<Schema.SchemaClass<{
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly label?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly label?: string | undefined;
|
|
28
|
+
}, never>>>>;
|
|
26
29
|
postAnswerNote: Schema.optional<typeof Schema.String>;
|
|
27
30
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { MediaTypeSchema,
|
|
2
|
+
import { MediaTypeSchema, StoredQuestionSourceSchema, } from "../question.schema.js";
|
|
3
3
|
/** Schemas shared by more than one page-load body. */
|
|
4
4
|
export const UserRoleSchema = Schema.Literal("anonymous", "display", "member", "curator", "admin");
|
|
5
5
|
export const UserPowerSchema = Schema.Literal("can-access-mimic", "can-send-feedback", "can-import-quizzes", "can-manage-features", "can-add-questions", "can-manage-categories", "can-moderate-questions", "can-publish-questions", "is-power-user", "can-manage-avatars", "can-apply-for-curation", "can-1v1");
|
|
@@ -20,7 +20,7 @@ export const GameAnswerRecordSchema = Schema.Struct({
|
|
|
20
20
|
correctAnswerText: Schema.optional(Schema.String),
|
|
21
21
|
mediaUrl: Schema.optional(Schema.String),
|
|
22
22
|
mediaType: Schema.optional(MediaTypeSchema),
|
|
23
|
-
source: Schema.optional(
|
|
23
|
+
source: Schema.optional(StoredQuestionSourceSchema),
|
|
24
24
|
postAnswerNote: Schema.optional(Schema.String),
|
|
25
25
|
});
|
|
26
26
|
// Assignability check: a schema drift that drops or mistypes a field the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
/** Page-load response bodies for `src/api/routes/pages-history.ts and admin-feature-flags.ts`. */
|
|
3
3
|
/** Achievement badge id (mirrors `BadgeId` in `src/lib/badges.ts`). */
|
|
4
|
-
export declare const BadgeIdSchema: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee"]>;
|
|
4
|
+
export declare const BadgeIdSchema: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed"]>;
|
|
5
5
|
/** Rarity tier a badge award reached (mirrors `Rarity` in `src/lib/badges.ts`). */
|
|
6
6
|
export declare const RaritySchema: Schema.Literal<["common", "rare", "legendary", "exotic"]>;
|
|
7
7
|
/** Per-badge counts + best rarity across a player's runs (mirrors `BadgeTally`). */
|
|
@@ -89,7 +89,7 @@ declare const PlayerGamePlacementSchema: Schema.Struct<{
|
|
|
89
89
|
final_score: typeof Schema.Number;
|
|
90
90
|
rank: typeof Schema.Number;
|
|
91
91
|
player_count: typeof Schema.Number;
|
|
92
|
-
badges: Schema.mutable<Schema.Array$<Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee"]>>>;
|
|
92
|
+
badges: Schema.mutable<Schema.Array$<Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed"]>>>;
|
|
93
93
|
}>;
|
|
94
94
|
export type PlayerGamePlacement = typeof PlayerGamePlacementSchema.Type;
|
|
95
95
|
/** Body of `GET /api/pages/history`. */
|
|
@@ -164,7 +164,7 @@ export declare const HistoryPageSchema: Schema.Struct<{
|
|
|
164
164
|
final_score: typeof Schema.Number;
|
|
165
165
|
rank: typeof Schema.Number;
|
|
166
166
|
player_count: typeof Schema.Number;
|
|
167
|
-
badges: Schema.mutable<Schema.Array$<Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee"]>>>;
|
|
167
|
+
badges: Schema.mutable<Schema.Array$<Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed"]>>>;
|
|
168
168
|
}>>>;
|
|
169
169
|
runsNextCursor: Schema.NullOr<typeof Schema.String>;
|
|
170
170
|
gamesNextCursor: Schema.NullOr<typeof Schema.String>;
|
|
@@ -190,7 +190,7 @@ export declare const GameReviewPageSchema: Schema.Struct<{
|
|
|
190
190
|
avatarSrc: typeof Schema.String;
|
|
191
191
|
}>>>;
|
|
192
192
|
badges: Schema.mutable<Schema.Array$<Schema.Struct<{
|
|
193
|
-
id: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee"]>;
|
|
193
|
+
id: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed"]>;
|
|
194
194
|
rarity: Schema.Literal<["common", "rare", "legendary", "exotic"]>;
|
|
195
195
|
}>>>;
|
|
196
196
|
breakdown: Schema.NullOr<Schema.mutable<Schema.Array$<Schema.Struct<{
|
|
@@ -207,10 +207,13 @@ export declare const GameReviewPageSchema: Schema.Struct<{
|
|
|
207
207
|
correctAnswerText: Schema.optional<typeof Schema.String>;
|
|
208
208
|
mediaUrl: Schema.optional<typeof Schema.String>;
|
|
209
209
|
mediaType: Schema.optional<Schema.Literal<["image", "audio", "video"]>>;
|
|
210
|
-
source: Schema.optional<Schema.
|
|
211
|
-
url:
|
|
212
|
-
label
|
|
213
|
-
}
|
|
210
|
+
source: Schema.optional<Schema.transform<typeof Schema.Unknown, Schema.UndefinedOr<Schema.SchemaClass<{
|
|
211
|
+
readonly url: string;
|
|
212
|
+
readonly label?: string | undefined;
|
|
213
|
+
}, {
|
|
214
|
+
readonly url: string;
|
|
215
|
+
readonly label?: string | undefined;
|
|
216
|
+
}, never>>>>;
|
|
214
217
|
postAnswerNote: Schema.optional<typeof Schema.String>;
|
|
215
218
|
}>>>>;
|
|
216
219
|
categoryName: Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
@@ -237,7 +240,7 @@ export declare const SoloReviewPageSchema: Schema.Struct<{
|
|
|
237
240
|
categories: Schema.mutable<Schema.Array$<typeof Schema.String>>;
|
|
238
241
|
}>;
|
|
239
242
|
badges: Schema.mutable<Schema.Array$<Schema.Struct<{
|
|
240
|
-
id: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee"]>;
|
|
243
|
+
id: Schema.Literal<["victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed"]>;
|
|
241
244
|
rarity: Schema.Literal<["common", "rare", "legendary", "exotic"]>;
|
|
242
245
|
}>>>;
|
|
243
246
|
categoryStats: Schema.mutable<Schema.Array$<Schema.Struct<{
|
|
@@ -258,10 +261,13 @@ export declare const SoloReviewPageSchema: Schema.Struct<{
|
|
|
258
261
|
questionId: Schema.NullOr<typeof Schema.String>;
|
|
259
262
|
mediaUrl: Schema.NullOr<typeof Schema.String>;
|
|
260
263
|
mediaType: Schema.NullOr<Schema.Literal<["image", "audio", "video"]>>;
|
|
261
|
-
source: Schema.
|
|
262
|
-
url:
|
|
263
|
-
label
|
|
264
|
-
}
|
|
264
|
+
source: Schema.Union<[typeof Schema.Null, Schema.transform<typeof Schema.Unknown, Schema.UndefinedOr<Schema.SchemaClass<{
|
|
265
|
+
readonly url: string;
|
|
266
|
+
readonly label?: string | undefined;
|
|
267
|
+
}, {
|
|
268
|
+
readonly url: string;
|
|
269
|
+
readonly label?: string | undefined;
|
|
270
|
+
}, never>>>]>;
|
|
265
271
|
postAnswerNote: Schema.NullOr<typeof Schema.String>;
|
|
266
272
|
}>>>;
|
|
267
273
|
alreadyFlaggedIds: Schema.mutable<Schema.Array$<typeof Schema.String>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { MediaTypeSchema,
|
|
2
|
+
import { MediaTypeSchema, StoredQuestionSourceSchema, } from "../question.schema.js";
|
|
3
3
|
import { GameAnswerRecordSchema, PlayerRoleSchema, UserPowerSchema, UserRoleSchema, } from "./common.schema.js";
|
|
4
4
|
/** Page-load response bodies for `src/api/routes/pages-history.ts and admin-feature-flags.ts`. */
|
|
5
5
|
/** Achievement badge id (mirrors `BadgeId` in `src/lib/badges.ts`). */
|
|
6
|
-
export const BadgeIdSchema = Schema.Literal("victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee");
|
|
6
|
+
export const BadgeIdSchema = Schema.Literal("victor", "flawless", "sharpshooter", "podium", "unstoppable", "on-a-roll", "survivor", "giant-slayer", "pantheon", "specialist", "polymath", "phoenix", "strong-finish", "master-of-none", "faster-than-most", "clutch", "quick-draw", "decisive", "sure-handed", "unbroken-focus", "devotee", "herculean", "undaunted", "measured", "strong-start", "new-heights", "far-horizons", "cassandra", "lone-torch", "ascendant", "undisputed");
|
|
7
7
|
/** Rarity tier a badge award reached (mirrors `Rarity` in `src/lib/badges.ts`). */
|
|
8
8
|
export const RaritySchema = Schema.Literal("common", "rare", "legendary", "exotic");
|
|
9
9
|
/** Per-badge counts + best rarity across a player's runs (mirrors `BadgeTally`). */
|
|
@@ -176,7 +176,8 @@ const SoloRunReviewEntrySchema = Schema.Struct({
|
|
|
176
176
|
questionId: Schema.NullOr(Schema.String),
|
|
177
177
|
mediaUrl: Schema.NullOr(Schema.String),
|
|
178
178
|
mediaType: Schema.NullOr(MediaTypeSchema),
|
|
179
|
-
|
|
179
|
+
// Null first: the stored-source transform accepts any value, null included.
|
|
180
|
+
source: Schema.Union(Schema.Null, StoredQuestionSourceSchema),
|
|
180
181
|
postAnswerNote: Schema.NullOr(Schema.String),
|
|
181
182
|
});
|
|
182
183
|
/** Body of `GET /api/pages/history/solo/:id`. */
|
|
@@ -132,10 +132,13 @@ export declare const QuizResultsPageSchema: Schema.Struct<{
|
|
|
132
132
|
correctAnswerText: Schema.optional<typeof Schema.String>;
|
|
133
133
|
mediaUrl: Schema.optional<typeof Schema.String>;
|
|
134
134
|
mediaType: Schema.optional<Schema.Literal<["image", "audio", "video"]>>;
|
|
135
|
-
source: Schema.optional<Schema.
|
|
136
|
-
url:
|
|
137
|
-
label
|
|
138
|
-
}
|
|
135
|
+
source: Schema.optional<Schema.transform<typeof Schema.Unknown, Schema.UndefinedOr<Schema.SchemaClass<{
|
|
136
|
+
readonly url: string;
|
|
137
|
+
readonly label?: string | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
readonly url: string;
|
|
140
|
+
readonly label?: string | undefined;
|
|
141
|
+
}, never>>>>;
|
|
139
142
|
postAnswerNote: Schema.optional<typeof Schema.String>;
|
|
140
143
|
}>>>>;
|
|
141
144
|
canFlag: typeof Schema.Boolean;
|
|
@@ -14,6 +14,18 @@ export declare const QuestionSourceSchema: Schema.Struct<{
|
|
|
14
14
|
url: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
15
15
|
label: Schema.optional<Schema.filter<typeof Schema.String>>;
|
|
16
16
|
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Read-side source: any stored value that fails `QuestionSourceSchema`
|
|
19
|
+
* (bad url, bad label, wrong shape) decodes to undefined, so one bad source
|
|
20
|
+
* never fails a whole page.
|
|
21
|
+
*/
|
|
22
|
+
export declare const StoredQuestionSourceSchema: Schema.transform<typeof Schema.Unknown, Schema.UndefinedOr<Schema.SchemaClass<{
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly label?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly label?: string | undefined;
|
|
28
|
+
}, never>>>;
|
|
17
29
|
export declare const PostAnswerNoteSchema: Schema.filter<typeof Schema.String>;
|
|
18
30
|
declare const TextChoiceSchema: Schema.Struct<{
|
|
19
31
|
type: Schema.Literal<["text_choice"]>;
|
package/dist/question.schema.js
CHANGED
|
@@ -30,6 +30,17 @@ export const QuestionSourceSchema = Schema.Struct({
|
|
|
30
30
|
message: () => "Source label must be 200 characters or fewer",
|
|
31
31
|
}))),
|
|
32
32
|
});
|
|
33
|
+
const isQuestionSource = Schema.is(QuestionSourceSchema);
|
|
34
|
+
/**
|
|
35
|
+
* Read-side source: any stored value that fails `QuestionSourceSchema`
|
|
36
|
+
* (bad url, bad label, wrong shape) decodes to undefined, so one bad source
|
|
37
|
+
* never fails a whole page.
|
|
38
|
+
*/
|
|
39
|
+
export const StoredQuestionSourceSchema = Schema.transform(Schema.Unknown, Schema.UndefinedOr(Schema.typeSchema(QuestionSourceSchema)), {
|
|
40
|
+
strict: true,
|
|
41
|
+
decode: (source) => (isQuestionSource(source) ? source : undefined),
|
|
42
|
+
encode: (source) => source,
|
|
43
|
+
});
|
|
33
44
|
export const PostAnswerNoteSchema = Schema.String.pipe(Schema.maxLength(160, {
|
|
34
45
|
message: () => "Post-answer note must be 160 characters or fewer",
|
|
35
46
|
}));
|