Skip to content

Commit 7426a01

Browse files
ci: update api (#18)
Co-authored-by: CI <ci@rman.dev>
1 parent 6af4918 commit 7426a01

12 files changed

Lines changed: 97 additions & 23 deletions

specs/lichess-api.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: "3.1.0"
22
info:
3-
version: 2.0.129
3+
version: 2.0.130
44
title: Lichess.org API reference
55
contact:
66
name: "Lichess.org API"
@@ -346,6 +346,9 @@ paths:
346346
/game/export/{gameId}:
347347
$ref: "./tags/games/game-export-gameId.yaml"
348348

349+
/game/{gameId}/chat:
350+
$ref: "./tags/games/api-game-gameId-chat.yaml"
351+
349352
/api/user/{username}/current-game:
350353
$ref: "./tags/games/api-user-username-current-game.yaml"
351354

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: array
2+
items:
3+
type: object
4+
properties:
5+
text:
6+
type: string
7+
user:
8+
type: string
9+
required:
10+
- text
11+
- user
12+
13+
example: [{ "text": "e4 here we go", "user": "Toby" }, { "text": "Woof!", "user": "AnnoyingDog" }]

specs/schemas/_index.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ UserExtended:
112112
Crosstable:
113113
$ref: "./Crosstable.yaml"
114114

115-
GameChat:
116-
$ref: "./GameChat.yaml"
115+
PlayerGameChat:
116+
$ref: "./PlayerGameChat.yaml"
117+
118+
SpectatorGameChat:
119+
$ref: "./SpectatorGameChat.yaml"
117120

118121
PuzzleAndGame:
119122
$ref: "./PuzzleAndGame.yaml"

specs/tags/board/api-board-game-gameId-chat.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ post:
5252
$ref: "../../schemas/Error.yaml"
5353
get:
5454
operationId: boardGameChatGet
55-
summary: Fetch the game chat
55+
summary: Fetch the player chat
5656
description: |
57-
Get the messages posted in the game chat
57+
Get the messages posted in the private game chat, i.e. the chat between the 2 players of the game.
58+
59+
Games can also have a public spectator chat.
5860
tags:
5961
- Board
6062
security:
@@ -70,4 +72,4 @@ get:
7072
content:
7173
application/x-ndjson:
7274
schema:
73-
$ref: "../../schemas/GameChat.yaml"
75+
$ref: "../../schemas/PlayerGameChat.yaml"

specs/tags/bot/api-bot-game-gameId-chat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ get:
7777
content:
7878
application/x-ndjson:
7979
schema:
80-
$ref: "../../schemas/GameChat.yaml"
80+
$ref: "../../schemas/PlayerGameChat.yaml"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
parameters:
2+
- in: path
3+
name: gameId
4+
schema:
5+
type: string
6+
example: "5IrD6Gzz"
7+
required: true
8+
get:
9+
operationId: gameChatGet
10+
summary: Fetch the spectator game chat
11+
description: |
12+
Get the messages posted in the public spectator chat of a game.
13+
14+
Games also have a private players chat, which only the 2 players can see.
15+
tags:
16+
- Games
17+
security: []
18+
responses:
19+
"200":
20+
description: The messages posted in the chat.
21+
headers:
22+
Access-Control-Allow-Origin:
23+
schema:
24+
type: string
25+
default: "'*'"
26+
content:
27+
application/x-ndjson:
28+
schema:
29+
$ref: "../../schemas/SpectatorGameChat.yaml"

src/client/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,17 @@ export class Lichess {
430430
);
431431
}
432432

433+
/**
434+
* Fetch the spectator game chat
435+
*/
436+
async gameChatGet(params: { gameId: string }) {
437+
const path = `/game/${params.gameId}/chat` as const;
438+
return await this.requestor.get(
439+
{ path },
440+
{ 200: { kind: "ndjson", schema: schemas.SpectatorGameChat } },
441+
);
442+
}
443+
433444
/**
434445
* Export ongoing game of a user
435446
*/
@@ -2750,13 +2761,13 @@ export class Lichess {
27502761
}
27512762

27522763
/**
2753-
* Fetch the game chat
2764+
* Fetch the player chat
27542765
*/
27552766
async boardGameChatGet(params: { gameId: string }) {
27562767
const path = `/api/board/game/${params.gameId}/chat` as const;
27572768
return await this.requestor.get(
27582769
{ path },
2759-
{ 200: { kind: "ndjson", schema: schemas.GameChat } },
2770+
{ 200: { kind: "ndjson", schema: schemas.PlayerGameChat } },
27602771
);
27612772
}
27622773

@@ -2954,7 +2965,7 @@ export class Lichess {
29542965
const path = `/api/bot/game/${params.gameId}/chat` as const;
29552966
return await this.requestor.get(
29562967
{ path },
2957-
{ 200: { kind: "ndjson", schema: schemas.GameChat } },
2968+
{ 200: { kind: "ndjson", schema: schemas.PlayerGameChat } },
29582969
);
29592970
}
29602971

src/schemas/GameChat.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/schemas/PlayerGameChat.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as z from "minizod";
2+
3+
const PlayerGameChat = z.array(
4+
z.object({
5+
text: z.string(),
6+
user: z.string(),
7+
}),
8+
);
9+
10+
type PlayerGameChat = z.infer<typeof PlayerGameChat>;
11+
12+
export { PlayerGameChat };

0 commit comments

Comments
 (0)