@hellacardgames/speed 0.8.1 → 0.9.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.
Files changed (41) hide show
  1. package/dist/ClientState-Dx8UvhMt.d.cts +111 -0
  2. package/dist/ClientState-Dx8UvhMt.d.cts.map +1 -0
  3. package/dist/ClientState-Dx8UvhMt.d.mts +111 -0
  4. package/dist/ClientState-Dx8UvhMt.d.mts.map +1 -0
  5. package/dist/client/index.cjs +60 -10
  6. package/dist/client/index.cjs.map +1 -1
  7. package/dist/client/index.d.cts +89 -14
  8. package/dist/client/index.d.cts.map +1 -1
  9. package/dist/client/index.d.mts +89 -14
  10. package/dist/client/index.d.mts.map +1 -1
  11. package/dist/client/index.mjs +60 -10
  12. package/dist/client/index.mjs.map +1 -1
  13. package/dist/manager/index.cjs +2 -2
  14. package/dist/manager/index.d.cts +140 -2
  15. package/dist/manager/index.d.cts.map +1 -0
  16. package/dist/manager/index.d.mts +140 -2
  17. package/dist/manager/index.d.mts.map +1 -0
  18. package/dist/manager/index.mjs +2 -2
  19. package/dist/{manager-0r8lvLRR.cjs → manager-B7gHPSPL.cjs} +70 -154
  20. package/dist/manager-B7gHPSPL.cjs.map +1 -0
  21. package/dist/{manager-B32oi0dB.mjs → manager-C6kRM9IW.mjs} +70 -154
  22. package/dist/manager-C6kRM9IW.mjs.map +1 -0
  23. package/dist/server/index.cjs +45 -165
  24. package/dist/server/index.cjs.map +1 -1
  25. package/dist/server/index.d.cts +149 -3
  26. package/dist/server/index.d.cts.map +1 -0
  27. package/dist/server/index.d.mts +149 -3
  28. package/dist/server/index.d.mts.map +1 -0
  29. package/dist/server/index.mjs +45 -165
  30. package/dist/server/index.mjs.map +1 -1
  31. package/package.json +2 -2
  32. package/dist/index-CVbiOmI3.d.mts +0 -125
  33. package/dist/index-CVbiOmI3.d.mts.map +0 -1
  34. package/dist/index-DOimW07r.d.cts +0 -125
  35. package/dist/index-DOimW07r.d.cts.map +0 -1
  36. package/dist/index-DlRknHKq.d.cts +0 -247
  37. package/dist/index-DlRknHKq.d.cts.map +0 -1
  38. package/dist/index-DlRknHKq.d.mts +0 -247
  39. package/dist/index-DlRknHKq.d.mts.map +0 -1
  40. package/dist/manager-0r8lvLRR.cjs.map +0 -1
  41. package/dist/manager-B32oi0dB.mjs.map +0 -1
@@ -1,21 +1,96 @@
1
- import { g as Card, h as ChatMessage, m as GameEvent, p as ClientState } from "../index-DlRknHKq.mjs";
2
- import { a as GetJoinableGamesResult, c as PlayCardResult, f as StartGameResult, i as GetEventsAndClearAcknowledgedResult, l as ReportNoPlayableCardsResult, n as DrawCardResult, o as JoinGameResult, r as GetClientStateAndClearEventsResult, s as LeaveGameResult, t as CreateGameResult, u as SendChatResult } from "../index-CVbiOmI3.mjs";
1
+ import { i as Card, n as GameEvent, r as ChatMessage, t as ClientState } from "../ClientState-Dx8UvhMt.mjs";
3
2
  //#region src/client/Client.d.ts
4
3
  declare class Client {
5
4
  private readonly baseUrl;
6
5
  constructor(baseUrl: string);
7
- createGame(accessToken: string): Promise<CreateGameResult>;
8
- drawCard(gameId: string, playerId: string): Promise<DrawCardResult>;
9
- getClientStateAndClearEvents(gameId: string, playerId: string): Promise<GetClientStateAndClearEventsResult>;
10
- getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null): Promise<GetEventsAndClearAcknowledgedResult>;
11
- getJoinableGames(): Promise<GetJoinableGamesResult>;
12
- joinGame(gameId: string, accessToken: string): Promise<JoinGameResult>;
13
- leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult>;
14
- playCard(gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean): Promise<PlayCardResult>;
15
- reportNoPlayableCards(gameId: string, playerId: string): Promise<ReportNoPlayableCardsResult>;
16
- sendChat(gameId: string, playerId: string, text: string): Promise<SendChatResult>;
17
- startGame(gameId: string, playerId: string): Promise<StartGameResult>;
6
+ createGame(accessToken: string): Promise<{
7
+ readonly success: true;
8
+ readonly gameId: string;
9
+ readonly playerId: string;
10
+ } | {
11
+ readonly success: false;
12
+ readonly error: "maxGamesReached";
13
+ }>;
14
+ drawCard(gameId: string, playerId: string): Promise<{
15
+ readonly success: true;
16
+ readonly error?: never;
17
+ } | {
18
+ readonly success: false;
19
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "invalidInput";
20
+ }>;
21
+ getClientStateAndClearEvents(gameId: string, playerId: string): Promise<{
22
+ readonly success: true;
23
+ readonly state: ClientState;
24
+ } | {
25
+ readonly success: false;
26
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
27
+ }>;
28
+ getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null): Promise<{
29
+ readonly success: true;
30
+ readonly events: readonly GameEvent[];
31
+ } | {
32
+ readonly success: false;
33
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
34
+ }>;
35
+ getJoinableGames(): Promise<{
36
+ readonly games: readonly {
37
+ readonly id: string;
38
+ readonly numPlayers: number;
39
+ }[];
40
+ }>;
41
+ joinGame(gameId: string, accessToken: string): Promise<{
42
+ readonly success: true;
43
+ readonly playerId: string;
44
+ } | {
45
+ readonly success: false;
46
+ readonly error: "maxPlayersReached" | "alreadyInGame" | "gameNotFound" | "invalidStatus" | "invalidInput";
47
+ }>;
48
+ leaveGame(gameId: string, playerId: string): Promise<{
49
+ readonly success: true;
50
+ } | {
51
+ readonly success: false;
52
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
53
+ }>;
54
+ playCard(gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean): Promise<{
55
+ readonly success: true;
56
+ readonly error?: never;
57
+ } | {
58
+ readonly success: false;
59
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "invalidInput";
60
+ }>;
61
+ reportNoPlayableCards(gameId: string, playerId: string): Promise<{
62
+ readonly success: true;
63
+ readonly error?: never;
64
+ } | {
65
+ readonly success: false;
66
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "invalidInput";
67
+ }>;
68
+ sendChat(gameId: string, playerId: string, text: string): Promise<{
69
+ readonly success: true;
70
+ } | {
71
+ readonly success: false;
72
+ readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
73
+ }>;
74
+ startGame(gameId: string, playerId: string): Promise<{
75
+ readonly success: true;
76
+ } | {
77
+ readonly success: false;
78
+ readonly error: "playerNotFound" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound" | "invalidStatus" | "invalidInput";
79
+ }>;
18
80
  }
19
81
  //#endregion
20
- export { type Card, type ChatMessage, Client, type ClientState, type CreateGameResult, type DrawCardResult, type GameEvent, type GetClientStateAndClearEventsResult, type GetEventsAndClearAcknowledgedResult, type GetJoinableGamesResult, type JoinGameResult, type LeaveGameResult, type PlayCardResult, type ReportNoPlayableCardsResult, type SendChatResult, type StartGameResult };
82
+ //#region src/client/index.d.ts
83
+ type CreateGameResult = Awaited<ReturnType<Client["createGame"]>>;
84
+ type DrawCardResult = Awaited<ReturnType<Client["drawCard"]>>;
85
+ type GetClientStateAndClearEventsResult = Awaited<ReturnType<Client["getClientStateAndClearEvents"]>>;
86
+ type GetEventsAndClearAcknowledgedResult = Awaited<ReturnType<Client["getEventsAndClearAcknowledged"]>>;
87
+ type GetJoinableGamesResult = Awaited<ReturnType<Client["getJoinableGames"]>>;
88
+ type JoinGameResult = Awaited<ReturnType<Client["joinGame"]>>;
89
+ type LeaveGameResult = Awaited<ReturnType<Client["leaveGame"]>>;
90
+ type PlayCardResult = Awaited<ReturnType<Client["playCard"]>>;
91
+ type ReportNoPlayableCards = Awaited<ReturnType<Client["reportNoPlayableCards"]>>;
92
+ type SendChatResult = Awaited<ReturnType<Client["sendChat"]>>;
93
+ type StartGameResult = Awaited<ReturnType<Client["startGame"]>>;
94
+ //#endregion
95
+ export { type Card, type ChatMessage, Client, type ClientState, CreateGameResult, DrawCardResult, type GameEvent, GetClientStateAndClearEventsResult, GetEventsAndClearAcknowledgedResult, GetJoinableGamesResult, JoinGameResult, LeaveGameResult, PlayCardResult, ReportNoPlayableCards, SendChatResult, StartGameResult };
21
96
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/Client.ts"],"mappings":";;;cA4Ba;mBACM;EAEL,YAAA;EAIN,WAAW,sBAAsB,QAAQ;EAWzC,SAAS,gBAAgB,mBAAmB,QAAQ;EAYpD,6BACJ,gBACA,mBACC,QAAQ;EAeL,8BACJ,gBACA,kBACA,4BACC,QAAQ;EAeL,oBAAoB,QAAQ;EAQ5B,SAAS,gBAAgB,sBAAsB,QAAQ;EAavD,UAAU,gBAAgB,mBAAmB,QAAQ;EAYrD,SACJ,gBACA,kBACA,gBACA,gCACC,QAAQ;EAYL,sBACJ,gBACA,mBACC,QAAQ;EAYL,SACJ,gBACA,kBACA,eACC,QAAQ;EAYL,UAAU,gBAAgB,mBAAmB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/Client.ts","../../src/client/index.ts"],"mappings":";;cAYa;mBACM;EAEL,YAAA;EAIN,WAAW,sBAAmB;;;;;;;;EAc9B,SAAS,gBAAgB,mBAAgB;;;;;;;EAezC,6BAA6B,gBAAgB,mBAAgB;;oBAfpB;;;;;EAkCzC,8BACJ,gBACA,kBACA,4BAAyB;;8BAtBwC;;;;;EA0C7D,oBAAgB;;;;;;EAShB,SAAS,gBAAgB,sBAAmB;;;;;;;EAgB5C,UAAU,gBAAgB,mBAAgB;;;;;;EAe1C,SACJ,gBACA,kBACA,gBACA,gCAA6B;;;;;;;EAgBzB,sBAAsB,gBAAgB,mBAAgB;;;;;;;EAgBtD,SAAS,gBAAgB,kBAAkB,eAAY;;;;;;EAevD,UAAU,gBAAgB,mBAAgB;;;;;;;;;KClLtC,mBAAmB,QAAQ,WAAW;KACtC,iBAAiB,QAAQ,WAAW;KACpC,qCAAqC,QAC/C,WAAW;KAED,sCAAsC,QAChD,WAAW;KAED,yBAAyB,QACnC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW;KACrC,iBAAiB,QAAQ,WAAW;KACpC,wBAAwB,QAClC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW"}
@@ -5,13 +5,18 @@ var Client = class {
5
5
  this.baseUrl = baseUrl;
6
6
  }
7
7
  async createGame(accessToken) {
8
- return await (await fetch(`${this.baseUrl}/createGame`, {
8
+ const result = await (await fetch(`${this.baseUrl}/createGame`, {
9
9
  method: "POST",
10
10
  headers: { Authorization: `Bearer ${accessToken}` }
11
11
  })).json();
12
+ if (!result.success) return {
13
+ success: false,
14
+ error: result.error
15
+ };
16
+ return result;
12
17
  }
13
18
  async drawCard(gameId, playerId) {
14
- return await (await fetch(`${this.baseUrl}/drawCard`, {
19
+ const result = await (await fetch(`${this.baseUrl}/drawCard`, {
15
20
  method: "POST",
16
21
  headers: { "Content-Type": "application/json" },
17
22
  body: JSON.stringify({
@@ -19,9 +24,14 @@ var Client = class {
19
24
  playerId
20
25
  })
21
26
  })).json();
27
+ if (!result.success) return {
28
+ success: false,
29
+ error: result.error
30
+ };
31
+ return result;
22
32
  }
23
33
  async getClientStateAndClearEvents(gameId, playerId) {
24
- return await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
34
+ const result = await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
25
35
  method: "POST",
26
36
  headers: { "Content-Type": "application/json" },
27
37
  body: JSON.stringify({
@@ -29,9 +39,14 @@ var Client = class {
29
39
  playerId
30
40
  })
31
41
  })).json();
42
+ if (!result.success) return {
43
+ success: false,
44
+ error: result.error
45
+ };
46
+ return result;
32
47
  }
33
48
  async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
34
- return await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
49
+ const result = await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
35
50
  method: "POST",
36
51
  headers: { "Content-Type": "application/json" },
37
52
  body: JSON.stringify({
@@ -40,12 +55,17 @@ var Client = class {
40
55
  lastReadId
41
56
  })
42
57
  })).json();
58
+ if (!result.success) return {
59
+ success: false,
60
+ error: result.error
61
+ };
62
+ return result;
43
63
  }
44
64
  async getJoinableGames() {
45
65
  return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
46
66
  }
47
67
  async joinGame(gameId, accessToken) {
48
- return await (await fetch(`${this.baseUrl}/joinGame`, {
68
+ const result = await (await fetch(`${this.baseUrl}/joinGame`, {
49
69
  method: "POST",
50
70
  headers: {
51
71
  Authorization: `Bearer ${accessToken}`,
@@ -53,9 +73,14 @@ var Client = class {
53
73
  },
54
74
  body: JSON.stringify({ gameId })
55
75
  })).json();
76
+ if (!result.success) return {
77
+ success: false,
78
+ error: result.error
79
+ };
80
+ return result;
56
81
  }
57
82
  async leaveGame(gameId, playerId) {
58
- return await (await fetch(`${this.baseUrl}/leaveGame`, {
83
+ const result = await (await fetch(`${this.baseUrl}/leaveGame`, {
59
84
  method: "POST",
60
85
  headers: { "Content-Type": "application/json" },
61
86
  body: JSON.stringify({
@@ -63,9 +88,14 @@ var Client = class {
63
88
  playerId
64
89
  })
65
90
  })).json();
91
+ if (!result.success) return {
92
+ success: false,
93
+ error: result.error
94
+ };
95
+ return result;
66
96
  }
67
97
  async playCard(gameId, playerId, cardId, isForOtherPlayerPile) {
68
- return await (await fetch(`${this.baseUrl}/playCard`, {
98
+ const result = await (await fetch(`${this.baseUrl}/playCard`, {
69
99
  method: "POST",
70
100
  headers: { "Content-Type": "application/json" },
71
101
  body: JSON.stringify({
@@ -75,9 +105,14 @@ var Client = class {
75
105
  isForOtherPlayerPile
76
106
  })
77
107
  })).json();
108
+ if (!result.success) return {
109
+ success: false,
110
+ error: result.error
111
+ };
112
+ return result;
78
113
  }
79
114
  async reportNoPlayableCards(gameId, playerId) {
80
- return await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
115
+ const result = await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
81
116
  method: "POST",
82
117
  headers: { "Content-Type": "application/json" },
83
118
  body: JSON.stringify({
@@ -85,9 +120,14 @@ var Client = class {
85
120
  playerId
86
121
  })
87
122
  })).json();
123
+ if (!result.success) return {
124
+ success: false,
125
+ error: result.error
126
+ };
127
+ return result;
88
128
  }
89
129
  async sendChat(gameId, playerId, text) {
90
- return await (await fetch(`${this.baseUrl}/sendChat`, {
130
+ const result = await (await fetch(`${this.baseUrl}/sendChat`, {
91
131
  method: "POST",
92
132
  headers: { "Content-Type": "application/json" },
93
133
  body: JSON.stringify({
@@ -96,9 +136,14 @@ var Client = class {
96
136
  text
97
137
  })
98
138
  })).json();
139
+ if (!result.success) return {
140
+ success: false,
141
+ error: result.error
142
+ };
143
+ return result;
99
144
  }
100
145
  async startGame(gameId, playerId) {
101
- return await (await fetch(`${this.baseUrl}/startGame`, {
146
+ const result = await (await fetch(`${this.baseUrl}/startGame`, {
102
147
  method: "POST",
103
148
  headers: { "Content-Type": "application/json" },
104
149
  body: JSON.stringify({
@@ -106,6 +151,11 @@ var Client = class {
106
151
  playerId
107
152
  })
108
153
  })).json();
154
+ if (!result.success) return {
155
+ success: false,
156
+ error: result.error
157
+ };
158
+ return result;
109
159
  }
110
160
  };
111
161
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type {\n CreateGameResult,\n DrawCardResult,\n GetClientStateAndClearEventsResult,\n GetEventsAndClearAcknowledgedResult,\n GetJoinableGamesResult,\n JoinGameResult,\n LeaveGameResult,\n PlayCardResult,\n ReportNoPlayableCardsResult,\n SendChatResult,\n StartGameResult,\n} from \"../server/index.js\";\n\nexport type {\n CreateGameResult,\n DrawCardResult,\n GetClientStateAndClearEventsResult,\n GetEventsAndClearAcknowledgedResult,\n GetJoinableGamesResult,\n JoinGameResult,\n LeaveGameResult,\n PlayCardResult,\n ReportNoPlayableCardsResult,\n SendChatResult,\n StartGameResult,\n};\n\nexport class Client {\n private readonly baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async createGame(accessToken: string): Promise<CreateGameResult> {\n const response = await fetch(`${this.baseUrl}/createGame`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n const result = await response.json();\n return result;\n }\n\n async drawCard(gameId: string, playerId: string): Promise<DrawCardResult> {\n const response = await fetch(`${this.baseUrl}/drawCard`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async getClientStateAndClearEvents(\n gameId: string,\n playerId: string,\n ): Promise<GetClientStateAndClearEventsResult> {\n const response = await fetch(\n `${this.baseUrl}/getClientStateAndClearEvents`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getEventsAndClearAcknowledged(\n gameId: string,\n playerId: string,\n lastReadId: string | null,\n ): Promise<GetEventsAndClearAcknowledgedResult> {\n const response = await fetch(\n `${this.baseUrl}/getEventsAndClearAcknowledged`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, lastReadId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getJoinableGames(): Promise<GetJoinableGamesResult> {\n const response = await fetch(`${this.baseUrl}/getJoinableGames`, {\n method: \"POST\",\n });\n const result = await response.json();\n return result;\n }\n\n async joinGame(gameId: string, accessToken: string): Promise<JoinGameResult> {\n const response = await fetch(`${this.baseUrl}/joinGame`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId }),\n });\n const result = await response.json();\n return result;\n }\n\n async leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult> {\n const response = await fetch(`${this.baseUrl}/leaveGame`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async playCard(\n gameId: string,\n playerId: string,\n cardId: string,\n isForOtherPlayerPile: boolean,\n ): Promise<PlayCardResult> {\n const response = await fetch(`${this.baseUrl}/playCard`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, cardId, isForOtherPlayerPile }),\n });\n const result = await response.json();\n return result;\n }\n\n async reportNoPlayableCards(\n gameId: string,\n playerId: string,\n ): Promise<ReportNoPlayableCardsResult> {\n const response = await fetch(`${this.baseUrl}/reportNoPlayableCards`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async sendChat(\n gameId: string,\n playerId: string,\n text: string,\n ): Promise<SendChatResult> {\n const response = await fetch(`${this.baseUrl}/sendChat`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, text }),\n });\n const result = await response.json();\n return result;\n }\n\n async startGame(gameId: string, playerId: string): Promise<StartGameResult> {\n const response = await fetch(`${this.baseUrl}/startGame`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type { createServer } from \"../server/index.js\";\n\ntype Server = ReturnType<typeof createServer>;\n\ntype ServerResult<\n TServer extends {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n actions: readonly { path: string; action: (...args: any[]) => any }[];\n },\n TPath extends TServer[\"actions\"][number][\"path\"],\n> = ReturnType<Extract<TServer[\"actions\"][number], { path: TPath }>[\"action\"]>;\n\nexport class Client {\n private readonly baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async createGame(accessToken: string) {\n const response = await fetch(`${this.baseUrl}/createGame`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n const result: ServerResult<Server, \"/createGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async drawCard(gameId: string, playerId: string) {\n const response = await fetch(`${this.baseUrl}/drawCard`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result: ServerResult<Server, \"/drawCard\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getClientStateAndClearEvents(gameId: string, playerId: string) {\n const response = await fetch(\n `${this.baseUrl}/getClientStateAndClearEvents`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n },\n );\n const result: ServerResult<Server, \"/getClientStateAndClearEvents\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getEventsAndClearAcknowledged(\n gameId: string,\n playerId: string,\n lastReadId: string | null,\n ) {\n const response = await fetch(\n `${this.baseUrl}/getEventsAndClearAcknowledged`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, lastReadId }),\n },\n );\n const result: ServerResult<Server, \"/getEventsAndClearAcknowledged\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getJoinableGames() {\n const response = await fetch(`${this.baseUrl}/getJoinableGames`, {\n method: \"POST\",\n });\n const result: ServerResult<Server, \"/getJoinableGames\"> =\n await response.json();\n return result;\n }\n\n async joinGame(gameId: string, accessToken: string) {\n const response = await fetch(`${this.baseUrl}/joinGame`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId }),\n });\n const result: ServerResult<Server, \"/joinGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async leaveGame(gameId: string, playerId: string) {\n const response = await fetch(`${this.baseUrl}/leaveGame`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result: ServerResult<Server, \"/leaveGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async playCard(\n gameId: string,\n playerId: string,\n cardId: string,\n isForOtherPlayerPile: boolean,\n ) {\n const response = await fetch(`${this.baseUrl}/playCard`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, cardId, isForOtherPlayerPile }),\n });\n const result: ServerResult<Server, \"/playCard\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async reportNoPlayableCards(gameId: string, playerId: string) {\n const response = await fetch(`${this.baseUrl}/reportNoPlayableCards`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result: ServerResult<Server, \"/reportNoPlayableCards\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async sendChat(gameId: string, playerId: string, text: string) {\n const response = await fetch(`${this.baseUrl}/sendChat`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, text }),\n });\n const result: ServerResult<Server, \"/sendChat\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async startGame(gameId: string, playerId: string) {\n const response = await fetch(`${this.baseUrl}/startGame`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result: ServerResult<Server, \"/startGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n}\n"],"mappings":"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"}
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_manager = require("../manager-0r8lvLRR.cjs");
3
- exports.Manager = require_manager.Manager;
2
+ const require_manager = require("../manager-B7gHPSPL.cjs");
3
+ exports.createManager = require_manager.createManager;
@@ -1,2 +1,140 @@
1
- import { a as GetJoinableGamesResult, c as Manager, d as SendChatResult, f as StartGameResult, g as Card, h as ChatMessage, i as GetEventsAndClearAcknowledgedResult, l as PlayCardResult, m as GameEvent, n as DrawCardResult, o as JoinGameResult, p as ClientState, r as GetClientStateAndClearEventsResult, s as LeaveGameResult, t as CreateGameResult, u as ReportNoPlayableCardsResult } from "../index-DlRknHKq.cjs";
2
- export { type Card, type ChatMessage, type ClientState, type CreateGameResult, type DrawCardResult, type GameEvent, type GetClientStateAndClearEventsResult, type GetEventsAndClearAcknowledgedResult, type GetJoinableGamesResult, type JoinGameResult, type LeaveGameResult, Manager, type PlayCardResult, type ReportNoPlayableCardsResult, type SendChatResult, type StartGameResult };
1
+ import { n as GameEvent, t as ClientState } from "../ClientState-Dx8UvhMt.cjs";
2
+ //#region src/manager/createManager.d.ts
3
+ declare const createManager: (logKey: string, maxGames: number, watchdogIntervalMs: number) => {
4
+ readonly createGame: (userId: string, username: string) => {
5
+ readonly success: false;
6
+ readonly error: "maxGamesReached";
7
+ readonly gameId?: never;
8
+ readonly playerId?: never;
9
+ } | {
10
+ readonly success: true;
11
+ readonly gameId: string;
12
+ readonly playerId: string;
13
+ readonly error?: never;
14
+ };
15
+ readonly getClientStateAndClearEvents: (gameId: string, playerId: string) => {
16
+ readonly success: false;
17
+ readonly error: "gameNotFound";
18
+ readonly state?: never;
19
+ } | {
20
+ readonly success: false;
21
+ readonly error: "playerNotFound";
22
+ readonly state?: never;
23
+ } | {
24
+ readonly success: true;
25
+ readonly state: ClientState;
26
+ readonly error?: never;
27
+ };
28
+ readonly getEventsAndClearAcknowledged: (gameId: string, playerId: string, lastReadId: string | null) => {
29
+ readonly success: false;
30
+ readonly error: "gameNotFound";
31
+ readonly events?: never;
32
+ } | {
33
+ readonly success: false;
34
+ readonly error: "playerNotFound";
35
+ readonly events?: never;
36
+ } | {
37
+ readonly success: true;
38
+ readonly events: readonly GameEvent[];
39
+ readonly error?: never;
40
+ };
41
+ readonly getJoinableGames: () => {
42
+ readonly games: readonly {
43
+ readonly id: string;
44
+ readonly numPlayers: number;
45
+ }[];
46
+ };
47
+ readonly joinGame: (gameId: string, userId: string, username: string) => {
48
+ readonly success: false;
49
+ readonly error: "gameNotFound";
50
+ readonly playerId?: never;
51
+ } | {
52
+ readonly success: false;
53
+ readonly error: "invalidStatus";
54
+ readonly playerId?: never;
55
+ } | {
56
+ readonly success: true;
57
+ readonly playerId: string;
58
+ readonly error?: never;
59
+ } | {
60
+ readonly success: false;
61
+ readonly error: "maxPlayersReached" | "alreadyInGame";
62
+ readonly playerId?: never;
63
+ };
64
+ readonly leaveGame: (gameId: string, playerId: string) => {
65
+ readonly success: false;
66
+ readonly error: "gameNotFound";
67
+ } | {
68
+ readonly success: true;
69
+ readonly error?: never;
70
+ } | {
71
+ readonly success: false;
72
+ readonly error: "playerNotFound";
73
+ };
74
+ readonly sendChat: (gameId: string, playerId: string, text: string) => {
75
+ readonly success: false;
76
+ readonly error: "gameNotFound";
77
+ } | {
78
+ readonly success: true;
79
+ readonly error?: never;
80
+ } | {
81
+ readonly success: false;
82
+ readonly error: "playerNotFound";
83
+ };
84
+ readonly startGame: (gameId: string, playerId: string) => {
85
+ readonly success: false;
86
+ readonly error: "gameNotFound";
87
+ } | {
88
+ readonly success: false;
89
+ readonly error: "invalidStatus";
90
+ } | {
91
+ readonly success: true;
92
+ readonly error?: never;
93
+ } | {
94
+ readonly success: false;
95
+ readonly error: "playerNotFound" | "playerNotAdmin" | "minPlayersNotReached";
96
+ };
97
+ } & Readonly<{
98
+ drawCard: (gameId: string, playerId: string) => {
99
+ readonly success: false;
100
+ readonly error: "gameNotFound";
101
+ } | {
102
+ readonly success: false;
103
+ readonly error: "invalidStatus";
104
+ } | {
105
+ readonly success: false;
106
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty";
107
+ } | {
108
+ readonly success: true;
109
+ readonly error?: never;
110
+ };
111
+ playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => {
112
+ readonly success: false;
113
+ readonly error: "gameNotFound";
114
+ } | {
115
+ readonly success: false;
116
+ readonly error: "invalidStatus";
117
+ } | {
118
+ readonly success: false;
119
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable";
120
+ } | {
121
+ readonly success: true;
122
+ readonly error?: never;
123
+ };
124
+ reportNoPlayableCards: (gameId: string, playerId: string) => {
125
+ readonly success: false;
126
+ readonly error: "gameNotFound";
127
+ } | {
128
+ readonly success: false;
129
+ readonly error: "invalidStatus";
130
+ } | {
131
+ readonly success: false;
132
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw";
133
+ } | {
134
+ readonly success: true;
135
+ readonly error?: never;
136
+ };
137
+ }>;
138
+ //#endregion
139
+ export { createManager };
140
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;aA8DgmD;aAA+B;;;;;aAA4H;;;;;;;;;;;;oBA9DxwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUU,WAAA,gBAAM;;;;;;;;;;;;;EAgBf,WAAA,gBAAM,kBACE,gBACF;;;;;;;;;;;;;EAiBgB,wBAAA,gBAAM"}
@@ -1,2 +1,140 @@
1
- import { a as GetJoinableGamesResult, c as Manager, d as SendChatResult, f as StartGameResult, g as Card, h as ChatMessage, i as GetEventsAndClearAcknowledgedResult, l as PlayCardResult, m as GameEvent, n as DrawCardResult, o as JoinGameResult, p as ClientState, r as GetClientStateAndClearEventsResult, s as LeaveGameResult, t as CreateGameResult, u as ReportNoPlayableCardsResult } from "../index-DlRknHKq.mjs";
2
- export { type Card, type ChatMessage, type ClientState, type CreateGameResult, type DrawCardResult, type GameEvent, type GetClientStateAndClearEventsResult, type GetEventsAndClearAcknowledgedResult, type GetJoinableGamesResult, type JoinGameResult, type LeaveGameResult, Manager, type PlayCardResult, type ReportNoPlayableCardsResult, type SendChatResult, type StartGameResult };
1
+ import { n as GameEvent, t as ClientState } from "../ClientState-Dx8UvhMt.mjs";
2
+ //#region src/manager/createManager.d.ts
3
+ declare const createManager: (logKey: string, maxGames: number, watchdogIntervalMs: number) => {
4
+ readonly createGame: (userId: string, username: string) => {
5
+ readonly success: false;
6
+ readonly error: "maxGamesReached";
7
+ readonly gameId?: never;
8
+ readonly playerId?: never;
9
+ } | {
10
+ readonly success: true;
11
+ readonly gameId: string;
12
+ readonly playerId: string;
13
+ readonly error?: never;
14
+ };
15
+ readonly getClientStateAndClearEvents: (gameId: string, playerId: string) => {
16
+ readonly success: false;
17
+ readonly error: "gameNotFound";
18
+ readonly state?: never;
19
+ } | {
20
+ readonly success: false;
21
+ readonly error: "playerNotFound";
22
+ readonly state?: never;
23
+ } | {
24
+ readonly success: true;
25
+ readonly state: ClientState;
26
+ readonly error?: never;
27
+ };
28
+ readonly getEventsAndClearAcknowledged: (gameId: string, playerId: string, lastReadId: string | null) => {
29
+ readonly success: false;
30
+ readonly error: "gameNotFound";
31
+ readonly events?: never;
32
+ } | {
33
+ readonly success: false;
34
+ readonly error: "playerNotFound";
35
+ readonly events?: never;
36
+ } | {
37
+ readonly success: true;
38
+ readonly events: readonly GameEvent[];
39
+ readonly error?: never;
40
+ };
41
+ readonly getJoinableGames: () => {
42
+ readonly games: readonly {
43
+ readonly id: string;
44
+ readonly numPlayers: number;
45
+ }[];
46
+ };
47
+ readonly joinGame: (gameId: string, userId: string, username: string) => {
48
+ readonly success: false;
49
+ readonly error: "gameNotFound";
50
+ readonly playerId?: never;
51
+ } | {
52
+ readonly success: false;
53
+ readonly error: "invalidStatus";
54
+ readonly playerId?: never;
55
+ } | {
56
+ readonly success: true;
57
+ readonly playerId: string;
58
+ readonly error?: never;
59
+ } | {
60
+ readonly success: false;
61
+ readonly error: "maxPlayersReached" | "alreadyInGame";
62
+ readonly playerId?: never;
63
+ };
64
+ readonly leaveGame: (gameId: string, playerId: string) => {
65
+ readonly success: false;
66
+ readonly error: "gameNotFound";
67
+ } | {
68
+ readonly success: true;
69
+ readonly error?: never;
70
+ } | {
71
+ readonly success: false;
72
+ readonly error: "playerNotFound";
73
+ };
74
+ readonly sendChat: (gameId: string, playerId: string, text: string) => {
75
+ readonly success: false;
76
+ readonly error: "gameNotFound";
77
+ } | {
78
+ readonly success: true;
79
+ readonly error?: never;
80
+ } | {
81
+ readonly success: false;
82
+ readonly error: "playerNotFound";
83
+ };
84
+ readonly startGame: (gameId: string, playerId: string) => {
85
+ readonly success: false;
86
+ readonly error: "gameNotFound";
87
+ } | {
88
+ readonly success: false;
89
+ readonly error: "invalidStatus";
90
+ } | {
91
+ readonly success: true;
92
+ readonly error?: never;
93
+ } | {
94
+ readonly success: false;
95
+ readonly error: "playerNotFound" | "playerNotAdmin" | "minPlayersNotReached";
96
+ };
97
+ } & Readonly<{
98
+ drawCard: (gameId: string, playerId: string) => {
99
+ readonly success: false;
100
+ readonly error: "gameNotFound";
101
+ } | {
102
+ readonly success: false;
103
+ readonly error: "invalidStatus";
104
+ } | {
105
+ readonly success: false;
106
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty";
107
+ } | {
108
+ readonly success: true;
109
+ readonly error?: never;
110
+ };
111
+ playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => {
112
+ readonly success: false;
113
+ readonly error: "gameNotFound";
114
+ } | {
115
+ readonly success: false;
116
+ readonly error: "invalidStatus";
117
+ } | {
118
+ readonly success: false;
119
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable";
120
+ } | {
121
+ readonly success: true;
122
+ readonly error?: never;
123
+ };
124
+ reportNoPlayableCards: (gameId: string, playerId: string) => {
125
+ readonly success: false;
126
+ readonly error: "gameNotFound";
127
+ } | {
128
+ readonly success: false;
129
+ readonly error: "invalidStatus";
130
+ } | {
131
+ readonly success: false;
132
+ readonly error: "playerNotFound" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw";
133
+ } | {
134
+ readonly success: true;
135
+ readonly error?: never;
136
+ };
137
+ }>;
138
+ //#endregion
139
+ export { createManager };
140
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;aA8DgmD;aAA+B;;;;;aAA4H;;;;;;;;;;;;oBA9DxwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUU,WAAA,gBAAM;;;;;;;;;;;;;EAgBf,WAAA,gBAAM,kBACE,gBACF;;;;;;;;;;;;;EAiBgB,wBAAA,gBAAM"}
@@ -1,2 +1,2 @@
1
- import { t as Manager } from "../manager-B32oi0dB.mjs";
2
- export { Manager };
1
+ import { t as createManager } from "../manager-C6kRM9IW.mjs";
2
+ export { createManager };