KOHAMI Docs
ReferenceEvents Catalog

News — résultat

Auto-généré par scripts/gen-events-catalog.ts depuis le schéma Zod canonique dans packages/shared/src/events/widget-data-events.ts. Ne pas éditer ce fichier à la main — modifier la source puis relancer bun run gen:events.

Topic

news:result
  • Famille : News
  • Bloc d'origine : BLOC-06
  • Discriminant : kind: "news:result"

Description

Liste 1 à 10 actualités courtes. Publié après l'appel d'outil getLatestNews ou après le tap sur la card news.

Schéma JSON

{
  "$ref": "#/definitions/news-result",
  "definitions": {
    "news-result": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "news:result"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "category": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "summary": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              }
            },
            "required": [
              "id",
              "category",
              "title",
              "summary"
            ],
            "additionalProperties": false
          },
          "minItems": 1,
          "maxItems": 10
        }
      },
      "required": [
        "kind",
        "items"
      ],
      "additionalProperties": false
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Import TypeScript

import {
  NewsResultEventSchema,
  type NewsResultEvent,
} from "@kohami/shared";

Parsing côté tablette

import { NewsResultEventSchema } from "@kohami/shared";

room.on(RoomEvent.DataReceived, (payload, _participant, _kind, topic) => {
  if (topic !== "news:result") return;
  const raw = new TextDecoder().decode(payload);
  const event = NewsResultEventSchema.parse(JSON.parse(raw));
  // ... handle event
});