@orakl/protocol 0.13.0 → 0.14.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/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export * from "./pages/common.schema.ts";
10
10
  export * from "./pages/history.schema.ts";
11
11
  export * from "./pages/quiz.schema.ts";
12
12
  export type { PlayerSafeQuestion } from "./player-safe-question.ts";
13
- export { ATTRIBUTION_LICENCES, CREDIT_LICENCE_LABEL, CREDIT_LICENCES, type CreditLicence, CreditLicenceSchema, DISTRIBUTABLE_LICENCES, DifficultySchema, type ImageChoiceQuestion, type ImageMatchingQuestion, isHttpsUrl, type Media, type MediaCredit, MediaCreditSchema, MediaSchema, type MediaType, MediaTypeSchema, PostAnswerNoteSchema, type Question, QuestionSchema, type QuestionSource, QuestionSourceSchema, type QuestionType, QuestionTypeSchema, type Source, SourceSchema, type TextChoiceQuestion, type TrueFalseQuestion, } from "./question.schema.ts";
13
+ export { ATTRIBUTION_LICENCES, CREDIT_LICENCE_LABEL, CREDIT_LICENCES, type CreditLicence, CreditLicenceSchema, DISTRIBUTABLE_LICENCES, DifficultySchema, type ImageChoiceQuestion, type ImageMatchingQuestion, isHttpsUrl, type Media, type MediaCredit, MediaCreditSchema, MediaSchema, type MediaType, MediaTypeSchema, POST_ANSWER_NOTE_MAX_LEN, PostAnswerNoteSchema, type Question, QuestionSchema, type QuestionSource, QuestionSourceSchema, type QuestionType, QuestionTypeSchema, SOURCE_LABEL_MAX_LEN, SOURCE_URL_MAX_LEN, type Source, SourceSchema, type TextChoiceQuestion, type TrueFalseQuestion, } from "./question.schema.ts";
14
14
  export { hasMedia, isImageMatching, isTextChoice, isTrueFalse, } from "./question.ts";
15
15
  export type { QuestionRating } from "./question-rating.ts";
16
16
  export { OptionalScoringModeSchema, ScoringModeSchema, } from "./scoring.schema.ts";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export * from "./pages/auth.schema.js";
5
5
  export * from "./pages/common.schema.js";
6
6
  export * from "./pages/history.schema.js";
7
7
  export * from "./pages/quiz.schema.js";
8
- export { ATTRIBUTION_LICENCES, CREDIT_LICENCE_LABEL, CREDIT_LICENCES, CreditLicenceSchema, DISTRIBUTABLE_LICENCES, DifficultySchema, isHttpsUrl, MediaCreditSchema, MediaSchema, MediaTypeSchema, PostAnswerNoteSchema, QuestionSchema, QuestionSourceSchema, QuestionTypeSchema, SourceSchema, } from "./question.schema.js";
8
+ export { ATTRIBUTION_LICENCES, CREDIT_LICENCE_LABEL, CREDIT_LICENCES, CreditLicenceSchema, DISTRIBUTABLE_LICENCES, DifficultySchema, isHttpsUrl, MediaCreditSchema, MediaSchema, MediaTypeSchema, POST_ANSWER_NOTE_MAX_LEN, PostAnswerNoteSchema, QuestionSchema, QuestionSourceSchema, QuestionTypeSchema, SOURCE_LABEL_MAX_LEN, SOURCE_URL_MAX_LEN, SourceSchema, } from "./question.schema.js";
9
9
  export { hasMedia, isImageMatching, isTextChoice, isTrueFalse, } from "./question.js";
10
10
  export { OptionalScoringModeSchema, ScoringModeSchema, } from "./scoring.schema.js";
11
11
  export { soloError, } from "./solo-ws.js";
@@ -288,6 +288,47 @@ export declare const ManageQuestionRatingsPageSchema: Schema.Struct<{
288
288
  initialHasMore: typeof Schema.Boolean;
289
289
  page: typeof Schema.Number;
290
290
  }>;
291
+ declare const BankQuestionRowSchema: Schema.Struct<{
292
+ id: typeof Schema.String;
293
+ excerpt: typeof Schema.String;
294
+ source: Schema.Literal<["built-in", "promoted"]>;
295
+ category: typeof Schema.String;
296
+ /** The stored question type, e.g. `text_choice`. */
297
+ type: typeof Schema.String;
298
+ difficulty: Schema.NullOr<Schema.Literal<["easy", "medium", "hard"]>>;
299
+ /** At least one revision exists. */
300
+ edited: typeof Schema.Boolean;
301
+ }>;
302
+ /** One question an operator may edit on the question bank page: built-in or promoted. */
303
+ export type BankQuestionRow = typeof BankQuestionRowSchema.Type;
304
+ /** Body of `GET /api/pages/manage/bank`. */
305
+ export declare const ManageBankPageSchema: Schema.Struct<{
306
+ initial: Schema.mutable<Schema.Array$<Schema.Schema<{
307
+ readonly type: string;
308
+ readonly source: "built-in" | "promoted";
309
+ readonly id: string;
310
+ readonly category: string;
311
+ readonly difficulty: "medium" | "easy" | "hard" | null;
312
+ readonly excerpt: string;
313
+ readonly edited: boolean;
314
+ }, {
315
+ readonly type: string;
316
+ readonly source: "built-in" | "promoted";
317
+ readonly id: string;
318
+ readonly category: string;
319
+ readonly difficulty: "medium" | "easy" | "hard" | null;
320
+ readonly excerpt: string;
321
+ readonly edited: boolean;
322
+ }, never>>>;
323
+ initialHasMore: typeof Schema.Boolean;
324
+ page: typeof Schema.Number;
325
+ /** The search term the page was loaded with; empty for none. */
326
+ q: typeof Schema.String;
327
+ /** The category name the page was filtered to; empty for all. */
328
+ category: typeof Schema.String;
329
+ /** Category names offered by the filter, A to Z. */
330
+ categories: Schema.mutable<Schema.Array$<Schema.Schema<string, string, never>>>;
331
+ }>;
291
332
  declare const AuthoredQuestionRowSchema: Schema.Struct<{
292
333
  id: typeof Schema.String;
293
334
  category: typeof Schema.String;
@@ -196,6 +196,29 @@ export const ManageQuestionRatingsPageSchema = Schema.Struct({
196
196
  initialHasMore: Schema.Boolean,
197
197
  page: Schema.Number,
198
198
  });
199
+ const BankQuestionRowSchema = Schema.Struct({
200
+ id: Schema.String,
201
+ excerpt: Schema.String,
202
+ source: Schema.Literal("built-in", "promoted"),
203
+ category: Schema.String,
204
+ /** The stored question type, e.g. `text_choice`. */
205
+ type: Schema.String,
206
+ difficulty: Schema.NullOr(Schema.Literal("easy", "medium", "hard")),
207
+ /** At least one revision exists. */
208
+ edited: Schema.Boolean,
209
+ });
210
+ /** Body of `GET /api/pages/manage/bank`. */
211
+ export const ManageBankPageSchema = Schema.Struct({
212
+ initial: Arr(BankQuestionRowSchema),
213
+ initialHasMore: Schema.Boolean,
214
+ page: Schema.Number,
215
+ /** The search term the page was loaded with; empty for none. */
216
+ q: Schema.String,
217
+ /** The category name the page was filtered to; empty for all. */
218
+ category: Schema.String,
219
+ /** Category names offered by the filter, A to Z. */
220
+ categories: Arr(Schema.String),
221
+ });
199
222
  const AuthoredQuestionRowSchema = Schema.Struct({
200
223
  id: Schema.String,
201
224
  category: Schema.String,
@@ -53,6 +53,12 @@ export declare const MediaSchema: Schema.Struct<{
53
53
  licenceUrl: Schema.optional<Schema.filter<Schema.filter<typeof Schema.String>>>;
54
54
  }>>>;
55
55
  }>;
56
+ /** Max characters in a question source URL. */
57
+ export declare const SOURCE_URL_MAX_LEN = 2048;
58
+ /** Max characters in a question source label. */
59
+ export declare const SOURCE_LABEL_MAX_LEN = 200;
60
+ /** Max characters in a post-answer note. */
61
+ export declare const POST_ANSWER_NOTE_MAX_LEN = 160;
56
62
  export declare const QuestionSourceSchema: Schema.Struct<{
57
63
  url: Schema.filter<Schema.filter<typeof Schema.String>>;
58
64
  label: Schema.optional<Schema.filter<typeof Schema.String>>;
@@ -77,13 +77,19 @@ export const MediaSchema = Schema.Struct({
77
77
  // Security: source.url is stored in the DB and read back on results/history
78
78
  // pages; cap to match imageUrl's bound (curator.schema.ts) since both are
79
79
  // URLs of the same practical size.
80
- const HttpsUrlSchema = Schema.String.pipe(Schema.maxLength(2048, {
81
- message: () => "Source URL must be 2048 characters or fewer",
80
+ /** Max characters in a question source URL. */
81
+ export const SOURCE_URL_MAX_LEN = 2048;
82
+ /** Max characters in a question source label. */
83
+ export const SOURCE_LABEL_MAX_LEN = 200;
84
+ /** Max characters in a post-answer note. */
85
+ export const POST_ANSWER_NOTE_MAX_LEN = 160;
86
+ const HttpsUrlSchema = Schema.String.pipe(Schema.maxLength(SOURCE_URL_MAX_LEN, {
87
+ message: () => `Source URL must be ${SOURCE_URL_MAX_LEN} characters or fewer`,
82
88
  }), Schema.filter(isHttpsUrl, { message: () => "Source URL must be https" }));
83
89
  export const QuestionSourceSchema = Schema.Struct({
84
90
  url: HttpsUrlSchema,
85
- label: Schema.optional(Schema.String.pipe(Schema.maxLength(200, {
86
- message: () => "Source label must be 200 characters or fewer",
91
+ label: Schema.optional(Schema.String.pipe(Schema.maxLength(SOURCE_LABEL_MAX_LEN, {
92
+ message: () => `Source label must be ${SOURCE_LABEL_MAX_LEN} characters or fewer`,
87
93
  }))),
88
94
  });
89
95
  const isQuestionSource = Schema.is(QuestionSourceSchema);
@@ -97,8 +103,8 @@ export const StoredQuestionSourceSchema = Schema.transform(Schema.Unknown, Schem
97
103
  decode: (source) => (isQuestionSource(source) ? source : undefined),
98
104
  encode: (source) => source,
99
105
  });
100
- export const PostAnswerNoteSchema = Schema.String.pipe(Schema.maxLength(160, {
101
- message: () => "Post-answer note must be 160 characters or fewer",
106
+ export const PostAnswerNoteSchema = Schema.String.pipe(Schema.maxLength(POST_ANSWER_NOTE_MAX_LEN, {
107
+ message: () => `Post-answer note must be ${POST_ANSWER_NOTE_MAX_LEN} characters or fewer`,
102
108
  }));
103
109
  const MetadataSchema = Schema.Struct({
104
110
  source: SourceSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orakl/protocol",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Orakl wire contract: WebSocket frames and API response schemas.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {