ReferenceEvents Catalog
Guess-Word — devinette
Auto-généré par
scripts/gen-events-catalog.tsdepuis le schéma Zod canonique danspackages/shared/src/events/widget-data-events.ts. Ne pas éditer ce fichier à la main — modifier la source puis relancerbun run gen:events.
Topic
guess:question- Famille : Games
- Bloc d'origine : BLOC-06
- Discriminant :
kind: "guess:question"
Description
Devinette guess-word — même structure que le quiz mais avec un prompt descriptif. Schéma question partagé.
Schéma JSON
{
"$ref": "#/definitions/guess-question",
"definitions": {
"guess-question": {
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "guess:question"
},
"question": {
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 64
},
"prompt": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"answers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 64
},
"text": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"isCorrect": {
"type": "boolean"
}
},
"required": [
"id",
"text",
"isCorrect"
],
"additionalProperties": false
},
"minItems": 2,
"maxItems": 4
}
},
"required": [
"id",
"prompt",
"answers"
],
"additionalProperties": false
}
},
"required": [
"kind",
"question"
],
"additionalProperties": false
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}Import TypeScript
import {
GuessQuestionEventSchema,
type GuessQuestionEvent,
} from "@kohami/shared";Parsing côté tablette
import { GuessQuestionEventSchema } from "@kohami/shared";
room.on(RoomEvent.DataReceived, (payload, _participant, _kind, topic) => {
if (topic !== "guess:question") return;
const raw = new TextDecoder().decode(payload);
const event = GuessQuestionEventSchema.parse(JSON.parse(raw));
// ... handle event
});