@dreamboard-games/api-client 0.1.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 (87) hide show
  1. package/LICENSE +89 -0
  2. package/NOTICE +1 -0
  3. package/dist/@tanstack/react-query.gen.d.ts +1037 -0
  4. package/dist/@tanstack/react-query.gen.d.ts.map +1 -0
  5. package/dist/@tanstack/react-query.gen.js +1016 -0
  6. package/dist/client/client.gen.d.ts +3 -0
  7. package/dist/client/client.gen.d.ts.map +1 -0
  8. package/dist/client/client.gen.js +235 -0
  9. package/dist/client/index.d.ts +9 -0
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +6 -0
  12. package/dist/client/types.gen.d.ts +118 -0
  13. package/dist/client/types.gen.d.ts.map +1 -0
  14. package/dist/client/types.gen.js +2 -0
  15. package/dist/client/utils.gen.d.ts +34 -0
  16. package/dist/client/utils.gen.d.ts.map +1 -0
  17. package/dist/client/utils.gen.js +233 -0
  18. package/dist/client.gen.d.ts +13 -0
  19. package/dist/client.gen.d.ts.map +1 -0
  20. package/dist/client.gen.js +3 -0
  21. package/dist/core/auth.gen.d.ts +19 -0
  22. package/dist/core/auth.gen.d.ts.map +1 -0
  23. package/dist/core/auth.gen.js +14 -0
  24. package/dist/core/bodySerializer.gen.d.ts +26 -0
  25. package/dist/core/bodySerializer.gen.d.ts.map +1 -0
  26. package/dist/core/bodySerializer.gen.js +57 -0
  27. package/dist/core/params.gen.d.ts +44 -0
  28. package/dist/core/params.gen.d.ts.map +1 -0
  29. package/dist/core/params.gen.js +100 -0
  30. package/dist/core/pathSerializer.gen.d.ts +34 -0
  31. package/dist/core/pathSerializer.gen.d.ts.map +1 -0
  32. package/dist/core/pathSerializer.gen.js +114 -0
  33. package/dist/core/queryKeySerializer.gen.d.ts +19 -0
  34. package/dist/core/queryKeySerializer.gen.d.ts.map +1 -0
  35. package/dist/core/queryKeySerializer.gen.js +99 -0
  36. package/dist/core/serverSentEvents.gen.d.ts +72 -0
  37. package/dist/core/serverSentEvents.gen.d.ts.map +1 -0
  38. package/dist/core/serverSentEvents.gen.js +136 -0
  39. package/dist/core/types.gen.d.ts +79 -0
  40. package/dist/core/types.gen.d.ts.map +1 -0
  41. package/dist/core/types.gen.js +2 -0
  42. package/dist/core/utils.gen.d.ts +20 -0
  43. package/dist/core/utils.gen.d.ts.map +1 -0
  44. package/dist/core/utils.gen.js +87 -0
  45. package/dist/generated/problem-types.gen.d.ts +26 -0
  46. package/dist/generated/problem-types.gen.d.ts.map +1 -0
  47. package/dist/generated/problem-types.gen.js +23 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +4 -0
  51. package/dist/sdk.gen.d.ts +364 -0
  52. package/dist/sdk.gen.d.ts.map +1 -0
  53. package/dist/sdk.gen.js +634 -0
  54. package/dist/source-revisions.d.ts +27 -0
  55. package/dist/source-revisions.d.ts.map +1 -0
  56. package/dist/source-revisions.js +174 -0
  57. package/dist/storage-paths.d.ts +17 -0
  58. package/dist/storage-paths.d.ts.map +1 -0
  59. package/dist/storage-paths.js +16 -0
  60. package/dist/types.gen.d.ts +5007 -0
  61. package/dist/types.gen.d.ts.map +1 -0
  62. package/dist/types.gen.js +2 -0
  63. package/dist/zod.gen.d.ts +37398 -0
  64. package/dist/zod.gen.d.ts.map +1 -0
  65. package/dist/zod.gen.js +2396 -0
  66. package/package.json +105 -0
  67. package/src/@tanstack/react-query.gen.ts +1114 -0
  68. package/src/client/client.gen.ts +311 -0
  69. package/src/client/index.ts +25 -0
  70. package/src/client/types.gen.ts +241 -0
  71. package/src/client/utils.gen.ts +332 -0
  72. package/src/client.gen.ts +16 -0
  73. package/src/core/auth.gen.ts +42 -0
  74. package/src/core/bodySerializer.gen.ts +100 -0
  75. package/src/core/params.gen.ts +176 -0
  76. package/src/core/pathSerializer.gen.ts +181 -0
  77. package/src/core/queryKeySerializer.gen.ts +136 -0
  78. package/src/core/serverSentEvents.gen.ts +265 -0
  79. package/src/core/types.gen.ts +118 -0
  80. package/src/core/utils.gen.ts +143 -0
  81. package/src/generated/problem-types.gen.ts +35 -0
  82. package/src/index.ts +7 -0
  83. package/src/sdk.gen.ts +709 -0
  84. package/src/source-revisions.ts +283 -0
  85. package/src/storage-paths.ts +19 -0
  86. package/src/types.gen.ts +5486 -0
  87. package/src/zod.gen.ts +2705 -0
@@ -0,0 +1,1114 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import { type DefaultError, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
4
+
5
+ import { client } from '../client.gen.js';
6
+ import { addSeat, assignSeat, cancelGameRun, createAuthoringState, createDemoGameSession, createGame, createGameRule, createGameRun, createSession, createSessionFromReducerSnapshot, createSourceBlobUploadSession, createSourceRevision, deleteGame, describePlayerAction, disconnectSessionEvents, downloadGameSources, ensureDevCompile, extractGameSpec, fetchUiBundle, findManifests, getActiveJob, getApiVersion, getAuthoringHead, getCompiledResult, getDemoGame, getDemoGameThumbnail, getGame, getGameBySlug, getGameRule, getGameScripts, getGameSources, getJob, getLatestCompiledResult, getLatestGameRule, getManifest, getPlayerActionTargets, getSessionByShortCode, getSessionSnapshot, healthCheck, listCompiledResults, listDemoGames, listGameRules, listGames, listPlayerActions, type Options, queryWorkshopRulebook, queueCompiledResultJob, removeSeat, restoreHistory, saveManifest, startGame, submitPlayerAction, unassignSeat, updateGame, updateSeat, validatePlayerAction } from '../sdk.gen.js';
7
+ import type { AddSeatData, AddSeatError, AddSeatResponse, AssignSeatData, AssignSeatError, AssignSeatResponse, CancelGameRunData, CancelGameRunError, CreateAuthoringStateData, CreateAuthoringStateError, CreateAuthoringStateResponse, CreateDemoGameSessionData, CreateDemoGameSessionError, CreateDemoGameSessionResponse, CreateGameData, CreateGameError, CreateGameResponse, CreateGameRuleData, CreateGameRuleError, CreateGameRuleResponse2, CreateGameRunData, CreateGameRunError, CreateGameRunResponse2, CreateSessionData, CreateSessionError, CreateSessionFromReducerSnapshotData, CreateSessionFromReducerSnapshotError, CreateSessionFromReducerSnapshotResponse, CreateSessionResponse2, CreateSourceBlobUploadSessionData, CreateSourceBlobUploadSessionError, CreateSourceBlobUploadSessionResponse, CreateSourceRevisionData, CreateSourceRevisionError, CreateSourceRevisionResponse, DeleteGameData, DeleteGameError, DeleteGameResponse2, DescribePlayerActionData, DescribePlayerActionError, DescribePlayerActionResponse, DisconnectSessionEventsData, DisconnectSessionEventsError, DownloadGameSourcesData, DownloadGameSourcesError, DownloadGameSourcesResponse, EnsureDevCompileData, EnsureDevCompileError, EnsureDevCompileResponse2, ExtractGameSpecData, ExtractGameSpecError, ExtractGameSpecResponse2, FetchUiBundleData, FetchUiBundleError, FetchUiBundleResponse, FindManifestsData, FindManifestsError, FindManifestsResponse2, GetActiveJobData, GetActiveJobError, GetActiveJobResponse, GetApiVersionData, GetApiVersionResponse, GetAuthoringHeadData, GetAuthoringHeadError, GetAuthoringHeadResponse, GetCompiledResultData, GetCompiledResultError, GetCompiledResultResponse, GetDemoGameData, GetDemoGameError, GetDemoGameResponse, GetDemoGameThumbnailData, GetDemoGameThumbnailError, GetDemoGameThumbnailResponse, GetGameBySlugData, GetGameBySlugError, GetGameBySlugResponse, GetGameData, GetGameError, GetGameResponse, GetGameRuleData, GetGameRuleError, GetGameRuleResponse, GetGameScriptsData, GetGameScriptsError, GetGameScriptsResponse, GetGameSourcesData, GetGameSourcesError, GetGameSourcesResponse, GetJobData, GetJobError, GetJobResponse, GetLatestCompiledResultData, GetLatestCompiledResultError, GetLatestCompiledResultResponse, GetLatestGameRuleData, GetLatestGameRuleError, GetLatestGameRuleResponse, GetManifestData, GetManifestError, GetManifestResponse, GetPlayerActionTargetsData, GetPlayerActionTargetsError, GetPlayerActionTargetsResponse, GetSessionByShortCodeData, GetSessionByShortCodeError, GetSessionByShortCodeResponse, GetSessionSnapshotData, GetSessionSnapshotError, GetSessionSnapshotResponse, HealthCheckData, HealthCheckResponse, ListCompiledResultsData, ListCompiledResultsError, ListCompiledResultsResponse2, ListDemoGamesData, ListDemoGamesError, ListDemoGamesResponse, ListGameRulesData, ListGameRulesError, ListGameRulesResponse2, ListGamesData, ListGamesError, ListGamesResponse, ListPlayerActionsData, ListPlayerActionsError, ListPlayerActionsResponse, QueryWorkshopRulebookData, QueryWorkshopRulebookError, QueryWorkshopRulebookResponse, QueueCompiledResultJobData, QueueCompiledResultJobError, QueueCompiledResultJobResponse2, RemoveSeatData, RemoveSeatError, RemoveSeatResponse, RestoreHistoryData, RestoreHistoryError, RestoreHistoryResponse2, SaveManifestData, SaveManifestError, SaveManifestResponse2, StartGameData, StartGameError, StartGameResponse, SubmitPlayerActionData, SubmitPlayerActionError, SubmitPlayerActionResponse, UnassignSeatData, UnassignSeatError, UnassignSeatResponse, UpdateGameData, UpdateGameError, UpdateGameResponse, UpdateSeatData, UpdateSeatError, UpdateSeatResponse, ValidatePlayerActionData, ValidatePlayerActionError, ValidatePlayerActionResponse } from '../types.gen.js';
8
+
9
+ export type QueryKey<TOptions extends Options> = [
10
+ Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
11
+ _id: string;
12
+ _infinite?: boolean;
13
+ tags?: ReadonlyArray<string>;
14
+ }
15
+ ];
16
+
17
+ const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
18
+ QueryKey<TOptions>[0]
19
+ ] => {
20
+ const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
21
+ if (infinite) {
22
+ params._infinite = infinite;
23
+ }
24
+ if (tags) {
25
+ params.tags = tags;
26
+ }
27
+ if (options?.body) {
28
+ params.body = options.body;
29
+ }
30
+ if (options?.headers) {
31
+ params.headers = options.headers;
32
+ }
33
+ if (options?.path) {
34
+ params.path = options.path;
35
+ }
36
+ if (options?.query) {
37
+ params.query = options.query;
38
+ }
39
+ return [params];
40
+ };
41
+
42
+ export const healthCheckQueryKey = (options?: Options<HealthCheckData>) => createQueryKey('healthCheck', options);
43
+
44
+ /**
45
+ * Health check endpoint
46
+ *
47
+ * Returns a simple health check message
48
+ */
49
+ export const healthCheckOptions = (options?: Options<HealthCheckData>) => queryOptions<HealthCheckResponse, DefaultError, HealthCheckResponse, ReturnType<typeof healthCheckQueryKey>>({
50
+ queryFn: async ({ queryKey, signal }) => {
51
+ const { data } = await healthCheck({
52
+ ...options,
53
+ ...queryKey[0],
54
+ signal,
55
+ throwOnError: true
56
+ });
57
+ return data;
58
+ },
59
+ queryKey: healthCheckQueryKey(options)
60
+ });
61
+
62
+ export const getApiVersionQueryKey = (options?: Options<GetApiVersionData>) => createQueryKey('getApiVersion', options);
63
+
64
+ /**
65
+ * Get backend version metadata
66
+ *
67
+ * Returns backend revision metadata and the UI SDK version expected by the backend runtime.
68
+ */
69
+ export const getApiVersionOptions = (options?: Options<GetApiVersionData>) => queryOptions<GetApiVersionResponse, DefaultError, GetApiVersionResponse, ReturnType<typeof getApiVersionQueryKey>>({
70
+ queryFn: async ({ queryKey, signal }) => {
71
+ const { data } = await getApiVersion({
72
+ ...options,
73
+ ...queryKey[0],
74
+ signal,
75
+ throwOnError: true
76
+ });
77
+ return data;
78
+ },
79
+ queryKey: getApiVersionQueryKey(options)
80
+ });
81
+
82
+ export const listGamesQueryKey = (options?: Options<ListGamesData>) => createQueryKey('listGames', options);
83
+
84
+ /**
85
+ * List user's games
86
+ *
87
+ * Retrieve a list of all games owned by the authenticated user
88
+ */
89
+ export const listGamesOptions = (options?: Options<ListGamesData>) => queryOptions<ListGamesResponse, ListGamesError, ListGamesResponse, ReturnType<typeof listGamesQueryKey>>({
90
+ queryFn: async ({ queryKey, signal }) => {
91
+ const { data } = await listGames({
92
+ ...options,
93
+ ...queryKey[0],
94
+ signal,
95
+ throwOnError: true
96
+ });
97
+ return data;
98
+ },
99
+ queryKey: listGamesQueryKey(options)
100
+ });
101
+
102
+ /**
103
+ * Create a new game
104
+ *
105
+ * Create a new game definition
106
+ */
107
+ export const createGameMutation = (options?: Partial<Options<CreateGameData>>): UseMutationOptions<CreateGameResponse, CreateGameError, Options<CreateGameData>> => {
108
+ const mutationOptions: UseMutationOptions<CreateGameResponse, CreateGameError, Options<CreateGameData>> = {
109
+ mutationFn: async (fnOptions) => {
110
+ const { data } = await createGame({
111
+ ...options,
112
+ ...fnOptions,
113
+ throwOnError: true
114
+ });
115
+ return data;
116
+ }
117
+ };
118
+ return mutationOptions;
119
+ };
120
+
121
+ /**
122
+ * Extract a structured game spec
123
+ *
124
+ * Extract a normalized structured game spec from pasted rule text.
125
+ */
126
+ export const extractGameSpecMutation = (options?: Partial<Options<ExtractGameSpecData>>): UseMutationOptions<ExtractGameSpecResponse2, ExtractGameSpecError, Options<ExtractGameSpecData>> => {
127
+ const mutationOptions: UseMutationOptions<ExtractGameSpecResponse2, ExtractGameSpecError, Options<ExtractGameSpecData>> = {
128
+ mutationFn: async (fnOptions) => {
129
+ const { data } = await extractGameSpec({
130
+ ...options,
131
+ ...fnOptions,
132
+ throwOnError: true
133
+ });
134
+ return data;
135
+ }
136
+ };
137
+ return mutationOptions;
138
+ };
139
+
140
+ /**
141
+ * Delete game
142
+ *
143
+ * Delete a game definition permanently
144
+ */
145
+ export const deleteGameMutation = (options?: Partial<Options<DeleteGameData>>): UseMutationOptions<DeleteGameResponse2, DeleteGameError, Options<DeleteGameData>> => {
146
+ const mutationOptions: UseMutationOptions<DeleteGameResponse2, DeleteGameError, Options<DeleteGameData>> = {
147
+ mutationFn: async (fnOptions) => {
148
+ const { data } = await deleteGame({
149
+ ...options,
150
+ ...fnOptions,
151
+ throwOnError: true
152
+ });
153
+ return data;
154
+ }
155
+ };
156
+ return mutationOptions;
157
+ };
158
+
159
+ export const getGameQueryKey = (options: Options<GetGameData>) => createQueryKey('getGame', options);
160
+
161
+ /**
162
+ * Get game by ID
163
+ *
164
+ * Retrieve a specific game definition by its ID
165
+ */
166
+ export const getGameOptions = (options: Options<GetGameData>) => queryOptions<GetGameResponse, GetGameError, GetGameResponse, ReturnType<typeof getGameQueryKey>>({
167
+ queryFn: async ({ queryKey, signal }) => {
168
+ const { data } = await getGame({
169
+ ...options,
170
+ ...queryKey[0],
171
+ signal,
172
+ throwOnError: true
173
+ });
174
+ return data;
175
+ },
176
+ queryKey: getGameQueryKey(options)
177
+ });
178
+
179
+ /**
180
+ * Update game
181
+ *
182
+ * Update an existing game definition
183
+ */
184
+ export const updateGameMutation = (options?: Partial<Options<UpdateGameData>>): UseMutationOptions<UpdateGameResponse, UpdateGameError, Options<UpdateGameData>> => {
185
+ const mutationOptions: UseMutationOptions<UpdateGameResponse, UpdateGameError, Options<UpdateGameData>> = {
186
+ mutationFn: async (fnOptions) => {
187
+ const { data } = await updateGame({
188
+ ...options,
189
+ ...fnOptions,
190
+ throwOnError: true
191
+ });
192
+ return data;
193
+ }
194
+ };
195
+ return mutationOptions;
196
+ };
197
+
198
+ export const getGameBySlugQueryKey = (options: Options<GetGameBySlugData>) => createQueryKey('getGameBySlug', options);
199
+
200
+ /**
201
+ * Get game by slug
202
+ *
203
+ * Retrieve a specific game definition by its slug
204
+ */
205
+ export const getGameBySlugOptions = (options: Options<GetGameBySlugData>) => queryOptions<GetGameBySlugResponse, GetGameBySlugError, GetGameBySlugResponse, ReturnType<typeof getGameBySlugQueryKey>>({
206
+ queryFn: async ({ queryKey, signal }) => {
207
+ const { data } = await getGameBySlug({
208
+ ...options,
209
+ ...queryKey[0],
210
+ signal,
211
+ throwOnError: true
212
+ });
213
+ return data;
214
+ },
215
+ queryKey: getGameBySlugQueryKey(options)
216
+ });
217
+
218
+ export const queryWorkshopRulebookQueryKey = (options: Options<QueryWorkshopRulebookData>) => createQueryKey('queryWorkshopRulebook', options);
219
+
220
+ /**
221
+ * Query rulebook text by title
222
+ *
223
+ * Search ranked rulebook candidates for the provided title, try up to the top 3 matches, and return extracted text from the first valid PDF found.
224
+ */
225
+ export const queryWorkshopRulebookOptions = (options: Options<QueryWorkshopRulebookData>) => queryOptions<QueryWorkshopRulebookResponse, QueryWorkshopRulebookError, QueryWorkshopRulebookResponse, ReturnType<typeof queryWorkshopRulebookQueryKey>>({
226
+ queryFn: async ({ queryKey, signal }) => {
227
+ const { data } = await queryWorkshopRulebook({
228
+ ...options,
229
+ ...queryKey[0],
230
+ signal,
231
+ throwOnError: true
232
+ });
233
+ return data;
234
+ },
235
+ queryKey: queryWorkshopRulebookQueryKey(options)
236
+ });
237
+
238
+ export const findManifestsQueryKey = (options: Options<FindManifestsData>) => createQueryKey('findManifests', options);
239
+
240
+ /**
241
+ * Find manifests for game
242
+ *
243
+ * Retrieve a list of manifest versions for a game, ordered by version descending (newest first)
244
+ */
245
+ export const findManifestsOptions = (options: Options<FindManifestsData>) => queryOptions<FindManifestsResponse2, FindManifestsError, FindManifestsResponse2, ReturnType<typeof findManifestsQueryKey>>({
246
+ queryFn: async ({ queryKey, signal }) => {
247
+ const { data } = await findManifests({
248
+ ...options,
249
+ ...queryKey[0],
250
+ signal,
251
+ throwOnError: true
252
+ });
253
+ return data;
254
+ },
255
+ queryKey: findManifestsQueryKey(options)
256
+ });
257
+
258
+ /**
259
+ * Save game manifest
260
+ *
261
+ * Create a new versioned manifest for a game. Each save creates a new version with automatic version numbering.
262
+ */
263
+ export const saveManifestMutation = (options?: Partial<Options<SaveManifestData>>): UseMutationOptions<SaveManifestResponse2, SaveManifestError, Options<SaveManifestData>> => {
264
+ const mutationOptions: UseMutationOptions<SaveManifestResponse2, SaveManifestError, Options<SaveManifestData>> = {
265
+ mutationFn: async (fnOptions) => {
266
+ const { data } = await saveManifest({
267
+ ...options,
268
+ ...fnOptions,
269
+ throwOnError: true
270
+ });
271
+ return data;
272
+ }
273
+ };
274
+ return mutationOptions;
275
+ };
276
+
277
+ export const getManifestQueryKey = (options: Options<GetManifestData>) => createQueryKey('getManifest', options);
278
+
279
+ /**
280
+ * Get manifest by ID
281
+ *
282
+ * Retrieve a specific manifest version by its ID with full board manifest details
283
+ */
284
+ export const getManifestOptions = (options: Options<GetManifestData>) => queryOptions<GetManifestResponse, GetManifestError, GetManifestResponse, ReturnType<typeof getManifestQueryKey>>({
285
+ queryFn: async ({ queryKey, signal }) => {
286
+ const { data } = await getManifest({
287
+ ...options,
288
+ ...queryKey[0],
289
+ signal,
290
+ throwOnError: true
291
+ });
292
+ return data;
293
+ },
294
+ queryKey: getManifestQueryKey(options)
295
+ });
296
+
297
+ export const getLatestCompiledResultQueryKey = (options: Options<GetLatestCompiledResultData>) => createQueryKey('getLatestCompiledResult', options);
298
+
299
+ /**
300
+ * Get latest compiled result for a game
301
+ *
302
+ * Return the most recent compiled result for the specified game.
303
+ */
304
+ export const getLatestCompiledResultOptions = (options: Options<GetLatestCompiledResultData>) => queryOptions<GetLatestCompiledResultResponse, GetLatestCompiledResultError, GetLatestCompiledResultResponse, ReturnType<typeof getLatestCompiledResultQueryKey>>({
305
+ queryFn: async ({ queryKey, signal }) => {
306
+ const { data } = await getLatestCompiledResult({
307
+ ...options,
308
+ ...queryKey[0],
309
+ signal,
310
+ throwOnError: true
311
+ });
312
+ return data;
313
+ },
314
+ queryKey: getLatestCompiledResultQueryKey(options)
315
+ });
316
+
317
+ export const listCompiledResultsQueryKey = (options: Options<ListCompiledResultsData>) => createQueryKey('listCompiledResults', options);
318
+
319
+ /**
320
+ * List compiled results for a game
321
+ *
322
+ * Retrieve a list of compiled results for a game, ordered by creation date descending (newest first). Includes both successful and failed compilations.
323
+ */
324
+ export const listCompiledResultsOptions = (options: Options<ListCompiledResultsData>) => queryOptions<ListCompiledResultsResponse2, ListCompiledResultsError, ListCompiledResultsResponse2, ReturnType<typeof listCompiledResultsQueryKey>>({
325
+ queryFn: async ({ queryKey, signal }) => {
326
+ const { data } = await listCompiledResults({
327
+ ...options,
328
+ ...queryKey[0],
329
+ signal,
330
+ throwOnError: true
331
+ });
332
+ return data;
333
+ },
334
+ queryKey: listCompiledResultsQueryKey(options)
335
+ });
336
+
337
+ /**
338
+ * Queue a compile job for an authoring state
339
+ *
340
+ * Queue an asynchronous compile for a specific authoring state. Poll `/api/jobs/{jobId}` and fetch the final compiled result by ID when the job completes.
341
+ */
342
+ export const queueCompiledResultJobMutation = (options?: Partial<Options<QueueCompiledResultJobData>>): UseMutationOptions<QueueCompiledResultJobResponse2, QueueCompiledResultJobError, Options<QueueCompiledResultJobData>> => {
343
+ const mutationOptions: UseMutationOptions<QueueCompiledResultJobResponse2, QueueCompiledResultJobError, Options<QueueCompiledResultJobData>> = {
344
+ mutationFn: async (fnOptions) => {
345
+ const { data } = await queueCompiledResultJob({
346
+ ...options,
347
+ ...fnOptions,
348
+ throwOnError: true
349
+ });
350
+ return data;
351
+ }
352
+ };
353
+ return mutationOptions;
354
+ };
355
+
356
+ /**
357
+ * Ensure a private dev compile exists
358
+ *
359
+ * Reuse or create a session-scoped dev compilation for the provided workspace fingerprint without advancing the canonical authored head.
360
+ */
361
+ export const ensureDevCompileMutation = (options?: Partial<Options<EnsureDevCompileData>>): UseMutationOptions<EnsureDevCompileResponse2, EnsureDevCompileError, Options<EnsureDevCompileData>> => {
362
+ const mutationOptions: UseMutationOptions<EnsureDevCompileResponse2, EnsureDevCompileError, Options<EnsureDevCompileData>> = {
363
+ mutationFn: async (fnOptions) => {
364
+ const { data } = await ensureDevCompile({
365
+ ...options,
366
+ ...fnOptions,
367
+ throwOnError: true
368
+ });
369
+ return data;
370
+ }
371
+ };
372
+ return mutationOptions;
373
+ };
374
+
375
+ export const getCompiledResultQueryKey = (options: Options<GetCompiledResultData>) => createQueryKey('getCompiledResult', options);
376
+
377
+ /**
378
+ * Get compiled result by ID
379
+ *
380
+ * Fetch a specific compiled result for a game, including failed results and diagnostics.
381
+ */
382
+ export const getCompiledResultOptions = (options: Options<GetCompiledResultData>) => queryOptions<GetCompiledResultResponse, GetCompiledResultError, GetCompiledResultResponse, ReturnType<typeof getCompiledResultQueryKey>>({
383
+ queryFn: async ({ queryKey, signal }) => {
384
+ const { data } = await getCompiledResult({
385
+ ...options,
386
+ ...queryKey[0],
387
+ signal,
388
+ throwOnError: true
389
+ });
390
+ return data;
391
+ },
392
+ queryKey: getCompiledResultQueryKey(options)
393
+ });
394
+
395
+ export const downloadGameSourcesQueryKey = (options: Options<DownloadGameSourcesData>) => createQueryKey('downloadGameSources', options);
396
+
397
+ /**
398
+ * Download authored game source files
399
+ *
400
+ * Download the authored source files for the current authoring head as a ZIP archive.
401
+ */
402
+ export const downloadGameSourcesOptions = (options: Options<DownloadGameSourcesData>) => queryOptions<DownloadGameSourcesResponse, DownloadGameSourcesError, DownloadGameSourcesResponse, ReturnType<typeof downloadGameSourcesQueryKey>>({
403
+ queryFn: async ({ queryKey, signal }) => {
404
+ const { data } = await downloadGameSources({
405
+ ...options,
406
+ ...queryKey[0],
407
+ signal,
408
+ throwOnError: true
409
+ });
410
+ return data;
411
+ },
412
+ queryKey: downloadGameSourcesQueryKey(options)
413
+ });
414
+
415
+ export const getGameSourcesQueryKey = (options: Options<GetGameSourcesData>) => createQueryKey('getGameSources', options);
416
+
417
+ /**
418
+ * Get authored game source files
419
+ *
420
+ * Retrieve authored source files as JSON for the selected authoring state. If no authoring state is provided, the current authoring head is used.
421
+ */
422
+ export const getGameSourcesOptions = (options: Options<GetGameSourcesData>) => queryOptions<GetGameSourcesResponse, GetGameSourcesError, GetGameSourcesResponse, ReturnType<typeof getGameSourcesQueryKey>>({
423
+ queryFn: async ({ queryKey, signal }) => {
424
+ const { data } = await getGameSources({
425
+ ...options,
426
+ ...queryKey[0],
427
+ signal,
428
+ throwOnError: true
429
+ });
430
+ return data;
431
+ },
432
+ queryKey: getGameSourcesQueryKey(options)
433
+ });
434
+
435
+ /**
436
+ * Create a source revision for a game
437
+ *
438
+ * Create a new authored source revision from a hash-addressed change set. The request must be based on the current head revision for the game.
439
+ */
440
+ export const createSourceRevisionMutation = (options?: Partial<Options<CreateSourceRevisionData>>): UseMutationOptions<CreateSourceRevisionResponse, CreateSourceRevisionError, Options<CreateSourceRevisionData>> => {
441
+ const mutationOptions: UseMutationOptions<CreateSourceRevisionResponse, CreateSourceRevisionError, Options<CreateSourceRevisionData>> = {
442
+ mutationFn: async (fnOptions) => {
443
+ const { data } = await createSourceRevision({
444
+ ...options,
445
+ ...fnOptions,
446
+ throwOnError: true
447
+ });
448
+ return data;
449
+ }
450
+ };
451
+ return mutationOptions;
452
+ };
453
+
454
+ /**
455
+ * Create direct-upload targets for source blobs
456
+ *
457
+ * Create a direct-upload session for one or more source blobs referenced by a forthcoming source revision.
458
+ */
459
+ export const createSourceBlobUploadSessionMutation = (options?: Partial<Options<CreateSourceBlobUploadSessionData>>): UseMutationOptions<CreateSourceBlobUploadSessionResponse, CreateSourceBlobUploadSessionError, Options<CreateSourceBlobUploadSessionData>> => {
460
+ const mutationOptions: UseMutationOptions<CreateSourceBlobUploadSessionResponse, CreateSourceBlobUploadSessionError, Options<CreateSourceBlobUploadSessionData>> = {
461
+ mutationFn: async (fnOptions) => {
462
+ const { data } = await createSourceBlobUploadSession({
463
+ ...options,
464
+ ...fnOptions,
465
+ throwOnError: true
466
+ });
467
+ return data;
468
+ }
469
+ };
470
+ return mutationOptions;
471
+ };
472
+
473
+ export const getAuthoringHeadQueryKey = (options: Options<GetAuthoringHeadData>) => createQueryKey('getAuthoringHead', options);
474
+
475
+ /**
476
+ * Get current authoring head for a game
477
+ *
478
+ * Retrieve the current remote authoring head for the specified game.
479
+ */
480
+ export const getAuthoringHeadOptions = (options: Options<GetAuthoringHeadData>) => queryOptions<GetAuthoringHeadResponse, GetAuthoringHeadError, GetAuthoringHeadResponse, ReturnType<typeof getAuthoringHeadQueryKey>>({
481
+ queryFn: async ({ queryKey, signal }) => {
482
+ const { data } = await getAuthoringHead({
483
+ ...options,
484
+ ...queryKey[0],
485
+ signal,
486
+ throwOnError: true
487
+ });
488
+ return data;
489
+ },
490
+ queryKey: getAuthoringHeadQueryKey(options)
491
+ });
492
+
493
+ /**
494
+ * Advance the authoring head for a game
495
+ *
496
+ * Create a new immutable authoring state and make it the current authoring head for the specified game.
497
+ */
498
+ export const createAuthoringStateMutation = (options?: Partial<Options<CreateAuthoringStateData>>): UseMutationOptions<CreateAuthoringStateResponse, CreateAuthoringStateError, Options<CreateAuthoringStateData>> => {
499
+ const mutationOptions: UseMutationOptions<CreateAuthoringStateResponse, CreateAuthoringStateError, Options<CreateAuthoringStateData>> = {
500
+ mutationFn: async (fnOptions) => {
501
+ const { data } = await createAuthoringState({
502
+ ...options,
503
+ ...fnOptions,
504
+ throwOnError: true
505
+ });
506
+ return data;
507
+ }
508
+ };
509
+ return mutationOptions;
510
+ };
511
+
512
+ export const getGameScriptsQueryKey = (options: Options<GetGameScriptsData>) => createQueryKey('getGameScripts', options);
513
+
514
+ /**
515
+ * Get game scripts
516
+ *
517
+ * Retrieve all compiled app and UI scripts for a specific manifest
518
+ */
519
+ export const getGameScriptsOptions = (options: Options<GetGameScriptsData>) => queryOptions<GetGameScriptsResponse, GetGameScriptsError, GetGameScriptsResponse, ReturnType<typeof getGameScriptsQueryKey>>({
520
+ queryFn: async ({ queryKey, signal }) => {
521
+ const { data } = await getGameScripts({
522
+ ...options,
523
+ ...queryKey[0],
524
+ signal,
525
+ throwOnError: true
526
+ });
527
+ return data;
528
+ },
529
+ queryKey: getGameScriptsQueryKey(options)
530
+ });
531
+
532
+ export const getActiveJobQueryKey = (options: Options<GetActiveJobData>) => createQueryKey('getActiveJob', options);
533
+
534
+ /**
535
+ * Get active job for a game
536
+ *
537
+ * Returns the currently active (PENDING or RUNNING) job for a game, if any. Jobs older than 15 minutes are considered stale and ignored.
538
+ */
539
+ export const getActiveJobOptions = (options: Options<GetActiveJobData>) => queryOptions<GetActiveJobResponse, GetActiveJobError, GetActiveJobResponse, ReturnType<typeof getActiveJobQueryKey>>({
540
+ queryFn: async ({ queryKey, signal }) => {
541
+ const { data } = await getActiveJob({
542
+ ...options,
543
+ ...queryKey[0],
544
+ signal,
545
+ throwOnError: true
546
+ });
547
+ return data;
548
+ },
549
+ queryKey: getActiveJobQueryKey(options)
550
+ });
551
+
552
+ export const getJobQueryKey = (options: Options<GetJobData>) => createQueryKey('getJob', options);
553
+
554
+ /**
555
+ * Get job details
556
+ *
557
+ * Fetch details for a specific async job, including ordered user-facing tasks.
558
+ */
559
+ export const getJobOptions = (options: Options<GetJobData>) => queryOptions<GetJobResponse, GetJobError, GetJobResponse, ReturnType<typeof getJobQueryKey>>({
560
+ queryFn: async ({ queryKey, signal }) => {
561
+ const { data } = await getJob({
562
+ ...options,
563
+ ...queryKey[0],
564
+ signal,
565
+ throwOnError: true
566
+ });
567
+ return data;
568
+ },
569
+ queryKey: getJobQueryKey(options)
570
+ });
571
+
572
+ /**
573
+ * Create a game build run
574
+ *
575
+ * Create a new game draft build job from a structured game spec.
576
+ */
577
+ export const createGameRunMutation = (options?: Partial<Options<CreateGameRunData>>): UseMutationOptions<CreateGameRunResponse2, CreateGameRunError, Options<CreateGameRunData>> => {
578
+ const mutationOptions: UseMutationOptions<CreateGameRunResponse2, CreateGameRunError, Options<CreateGameRunData>> = {
579
+ mutationFn: async (fnOptions) => {
580
+ const { data } = await createGameRun({
581
+ ...options,
582
+ ...fnOptions,
583
+ throwOnError: true
584
+ });
585
+ return data;
586
+ }
587
+ };
588
+ return mutationOptions;
589
+ };
590
+
591
+ /**
592
+ * Cancel a game build run
593
+ *
594
+ * Request cancellation of an active game draft build job.
595
+ */
596
+ export const cancelGameRunMutation = (options?: Partial<Options<CancelGameRunData>>): UseMutationOptions<unknown, CancelGameRunError, Options<CancelGameRunData>> => {
597
+ const mutationOptions: UseMutationOptions<unknown, CancelGameRunError, Options<CancelGameRunData>> = {
598
+ mutationFn: async (fnOptions) => {
599
+ const { data } = await cancelGameRun({
600
+ ...options,
601
+ ...fnOptions,
602
+ throwOnError: true
603
+ });
604
+ return data;
605
+ }
606
+ };
607
+ return mutationOptions;
608
+ };
609
+
610
+ export const listGameRulesQueryKey = (options: Options<ListGameRulesData>) => createQueryKey('listGameRules', options);
611
+
612
+ /**
613
+ * List game rules for a game
614
+ *
615
+ * Retrieve a list of rule versions for a game, ordered by version descending (newest first)
616
+ */
617
+ export const listGameRulesOptions = (options: Options<ListGameRulesData>) => queryOptions<ListGameRulesResponse2, ListGameRulesError, ListGameRulesResponse2, ReturnType<typeof listGameRulesQueryKey>>({
618
+ queryFn: async ({ queryKey, signal }) => {
619
+ const { data } = await listGameRules({
620
+ ...options,
621
+ ...queryKey[0],
622
+ signal,
623
+ throwOnError: true
624
+ });
625
+ return data;
626
+ },
627
+ queryKey: listGameRulesQueryKey(options)
628
+ });
629
+
630
+ /**
631
+ * Create a new game rule
632
+ *
633
+ * Create a new versioned rule for a game. Each save creates a new version with automatic version numbering.
634
+ */
635
+ export const createGameRuleMutation = (options?: Partial<Options<CreateGameRuleData>>): UseMutationOptions<CreateGameRuleResponse2, CreateGameRuleError, Options<CreateGameRuleData>> => {
636
+ const mutationOptions: UseMutationOptions<CreateGameRuleResponse2, CreateGameRuleError, Options<CreateGameRuleData>> = {
637
+ mutationFn: async (fnOptions) => {
638
+ const { data } = await createGameRule({
639
+ ...options,
640
+ ...fnOptions,
641
+ throwOnError: true
642
+ });
643
+ return data;
644
+ }
645
+ };
646
+ return mutationOptions;
647
+ };
648
+
649
+ export const getLatestGameRuleQueryKey = (options: Options<GetLatestGameRuleData>) => createQueryKey('getLatestGameRule', options);
650
+
651
+ /**
652
+ * Get the latest game rule
653
+ *
654
+ * Retrieve the most recent rule version for a game with full details including the complete rule text
655
+ */
656
+ export const getLatestGameRuleOptions = (options: Options<GetLatestGameRuleData>) => queryOptions<GetLatestGameRuleResponse, GetLatestGameRuleError, GetLatestGameRuleResponse, ReturnType<typeof getLatestGameRuleQueryKey>>({
657
+ queryFn: async ({ queryKey, signal }) => {
658
+ const { data } = await getLatestGameRule({
659
+ ...options,
660
+ ...queryKey[0],
661
+ signal,
662
+ throwOnError: true
663
+ });
664
+ return data;
665
+ },
666
+ queryKey: getLatestGameRuleQueryKey(options)
667
+ });
668
+
669
+ export const getGameRuleQueryKey = (options: Options<GetGameRuleData>) => createQueryKey('getGameRule', options);
670
+
671
+ /**
672
+ * Get game rule by ID
673
+ *
674
+ * Retrieve a specific game rule version by its ID with full details
675
+ */
676
+ export const getGameRuleOptions = (options: Options<GetGameRuleData>) => queryOptions<GetGameRuleResponse, GetGameRuleError, GetGameRuleResponse, ReturnType<typeof getGameRuleQueryKey>>({
677
+ queryFn: async ({ queryKey, signal }) => {
678
+ const { data } = await getGameRule({
679
+ ...options,
680
+ ...queryKey[0],
681
+ signal,
682
+ throwOnError: true
683
+ });
684
+ return data;
685
+ },
686
+ queryKey: getGameRuleQueryKey(options)
687
+ });
688
+
689
+ /**
690
+ * Create a new game session
691
+ *
692
+ * Create a new game session in lobby phase with initial seat configuration
693
+ */
694
+ export const createSessionMutation = (options?: Partial<Options<CreateSessionData>>): UseMutationOptions<CreateSessionResponse2, CreateSessionError, Options<CreateSessionData>> => {
695
+ const mutationOptions: UseMutationOptions<CreateSessionResponse2, CreateSessionError, Options<CreateSessionData>> = {
696
+ mutationFn: async (fnOptions) => {
697
+ const { data } = await createSession({
698
+ ...options,
699
+ ...fnOptions,
700
+ throwOnError: true
701
+ });
702
+ return data;
703
+ }
704
+ };
705
+ return mutationOptions;
706
+ };
707
+
708
+ /**
709
+ * Create a session from a reducer snapshot
710
+ *
711
+ * Create an auto-assigned gameplay session from a reducer-native snapshot produced by the CLI scenario harness.
712
+ */
713
+ export const createSessionFromReducerSnapshotMutation = (options?: Partial<Options<CreateSessionFromReducerSnapshotData>>): UseMutationOptions<CreateSessionFromReducerSnapshotResponse, CreateSessionFromReducerSnapshotError, Options<CreateSessionFromReducerSnapshotData>> => {
714
+ const mutationOptions: UseMutationOptions<CreateSessionFromReducerSnapshotResponse, CreateSessionFromReducerSnapshotError, Options<CreateSessionFromReducerSnapshotData>> = {
715
+ mutationFn: async (fnOptions) => {
716
+ const { data } = await createSessionFromReducerSnapshot({
717
+ ...options,
718
+ ...fnOptions,
719
+ throwOnError: true
720
+ });
721
+ return data;
722
+ }
723
+ };
724
+ return mutationOptions;
725
+ };
726
+
727
+ export const getSessionByShortCodeQueryKey = (options: Options<GetSessionByShortCodeData>) => createQueryKey('getSessionByShortCode', options);
728
+
729
+ /**
730
+ * Get session by short code
731
+ *
732
+ * Look up and hydrate a session using its memorable short code.
733
+ */
734
+ export const getSessionByShortCodeOptions = (options: Options<GetSessionByShortCodeData>) => queryOptions<GetSessionByShortCodeResponse, GetSessionByShortCodeError, GetSessionByShortCodeResponse, ReturnType<typeof getSessionByShortCodeQueryKey>>({
735
+ queryFn: async ({ queryKey, signal }) => {
736
+ const { data } = await getSessionByShortCode({
737
+ ...options,
738
+ ...queryKey[0],
739
+ signal,
740
+ throwOnError: true
741
+ });
742
+ return data;
743
+ },
744
+ queryKey: getSessionByShortCodeQueryKey(options)
745
+ });
746
+
747
+ export const getSessionSnapshotQueryKey = (options: Options<GetSessionSnapshotData>) => createQueryKey('getSessionSnapshot', options);
748
+
749
+ /**
750
+ * Get a session snapshot
751
+ *
752
+ * Return the canonical selected-perspective session snapshot for first render or explicit resync.
753
+ */
754
+ export const getSessionSnapshotOptions = (options: Options<GetSessionSnapshotData>) => queryOptions<GetSessionSnapshotResponse, GetSessionSnapshotError, GetSessionSnapshotResponse, ReturnType<typeof getSessionSnapshotQueryKey>>({
755
+ queryFn: async ({ queryKey, signal }) => {
756
+ const { data } = await getSessionSnapshot({
757
+ ...options,
758
+ ...queryKey[0],
759
+ signal,
760
+ throwOnError: true
761
+ });
762
+ return data;
763
+ },
764
+ queryKey: getSessionSnapshotQueryKey(options)
765
+ });
766
+
767
+ /**
768
+ * Release a session events stream slot
769
+ *
770
+ * Best-effort disconnect signal used by browser tabs during unload and reconnect transitions so stale event stream slots are released promptly.
771
+ */
772
+ export const disconnectSessionEventsMutation = (options?: Partial<Options<DisconnectSessionEventsData>>): UseMutationOptions<unknown, DisconnectSessionEventsError, Options<DisconnectSessionEventsData>> => {
773
+ const mutationOptions: UseMutationOptions<unknown, DisconnectSessionEventsError, Options<DisconnectSessionEventsData>> = {
774
+ mutationFn: async (fnOptions) => {
775
+ const { data } = await disconnectSessionEvents({
776
+ ...options,
777
+ ...fnOptions,
778
+ throwOnError: true
779
+ });
780
+ return data;
781
+ }
782
+ };
783
+ return mutationOptions;
784
+ };
785
+
786
+ /**
787
+ * Start the game
788
+ *
789
+ * Transition session from lobby to gameplay phase (host only)
790
+ */
791
+ export const startGameMutation = (options?: Partial<Options<StartGameData>>): UseMutationOptions<StartGameResponse, StartGameError, Options<StartGameData>> => {
792
+ const mutationOptions: UseMutationOptions<StartGameResponse, StartGameError, Options<StartGameData>> = {
793
+ mutationFn: async (fnOptions) => {
794
+ const { data } = await startGame({
795
+ ...options,
796
+ ...fnOptions,
797
+ throwOnError: true
798
+ });
799
+ return data;
800
+ }
801
+ };
802
+ return mutationOptions;
803
+ };
804
+
805
+ export const listPlayerActionsQueryKey = (options: Options<ListPlayerActionsData>) => createQueryKey('listPlayerActions', options);
806
+
807
+ /**
808
+ * List current actions for a selected player
809
+ *
810
+ * Returns the current server-authored descriptors and action-set revision for the selected player.
811
+ */
812
+ export const listPlayerActionsOptions = (options: Options<ListPlayerActionsData>) => queryOptions<ListPlayerActionsResponse, ListPlayerActionsError, ListPlayerActionsResponse, ReturnType<typeof listPlayerActionsQueryKey>>({
813
+ queryFn: async ({ queryKey, signal }) => {
814
+ const { data } = await listPlayerActions({
815
+ ...options,
816
+ ...queryKey[0],
817
+ signal,
818
+ throwOnError: true
819
+ });
820
+ return data;
821
+ },
822
+ queryKey: listPlayerActionsQueryKey(options)
823
+ });
824
+
825
+ export const describePlayerActionQueryKey = (options: Options<DescribePlayerActionData>) => createQueryKey('describePlayerAction', options);
826
+
827
+ /**
828
+ * Describe one current action
829
+ *
830
+ * Returns the full current descriptor and action-set revision for one selected-player interaction.
831
+ */
832
+ export const describePlayerActionOptions = (options: Options<DescribePlayerActionData>) => queryOptions<DescribePlayerActionResponse, DescribePlayerActionError, DescribePlayerActionResponse, ReturnType<typeof describePlayerActionQueryKey>>({
833
+ queryFn: async ({ queryKey, signal }) => {
834
+ const { data } = await describePlayerAction({
835
+ ...options,
836
+ ...queryKey[0],
837
+ signal,
838
+ throwOnError: true
839
+ });
840
+ return data;
841
+ },
842
+ queryKey: describePlayerActionQueryKey(options)
843
+ });
844
+
845
+ export const getPlayerActionTargetsQueryKey = (options: Options<GetPlayerActionTargetsData>) => createQueryKey('getPlayerActionTargets', options);
846
+
847
+ /**
848
+ * Describe the current valid target/domain values for one action input
849
+ *
850
+ * Returns the current server-authored input domain for a selected-player action input.
851
+ */
852
+ export const getPlayerActionTargetsOptions = (options: Options<GetPlayerActionTargetsData>) => queryOptions<GetPlayerActionTargetsResponse, GetPlayerActionTargetsError, GetPlayerActionTargetsResponse, ReturnType<typeof getPlayerActionTargetsQueryKey>>({
853
+ queryFn: async ({ queryKey, signal }) => {
854
+ const { data } = await getPlayerActionTargets({
855
+ ...options,
856
+ ...queryKey[0],
857
+ signal,
858
+ throwOnError: true
859
+ });
860
+ return data;
861
+ },
862
+ queryKey: getPlayerActionTargetsQueryKey(options)
863
+ });
864
+
865
+ /**
866
+ * Validate collector-shaped action inputs
867
+ *
868
+ * Validates one selected-player action using collector-shaped inputs. Path fields are authoritative; clients do not send a GameInput envelope.
869
+ */
870
+ export const validatePlayerActionMutation = (options?: Partial<Options<ValidatePlayerActionData>>): UseMutationOptions<ValidatePlayerActionResponse, ValidatePlayerActionError, Options<ValidatePlayerActionData>> => {
871
+ const mutationOptions: UseMutationOptions<ValidatePlayerActionResponse, ValidatePlayerActionError, Options<ValidatePlayerActionData>> = {
872
+ mutationFn: async (fnOptions) => {
873
+ const { data } = await validatePlayerAction({
874
+ ...options,
875
+ ...fnOptions,
876
+ throwOnError: true
877
+ });
878
+ return data;
879
+ }
880
+ };
881
+ return mutationOptions;
882
+ };
883
+
884
+ /**
885
+ * Submit collector-shaped action inputs
886
+ *
887
+ * Submits one selected-player action using collector-shaped inputs. Path fields are authoritative; clients do not send a GameInput envelope.
888
+ */
889
+ export const submitPlayerActionMutation = (options?: Partial<Options<SubmitPlayerActionData>>): UseMutationOptions<SubmitPlayerActionResponse, SubmitPlayerActionError, Options<SubmitPlayerActionData>> => {
890
+ const mutationOptions: UseMutationOptions<SubmitPlayerActionResponse, SubmitPlayerActionError, Options<SubmitPlayerActionData>> = {
891
+ mutationFn: async (fnOptions) => {
892
+ const { data } = await submitPlayerAction({
893
+ ...options,
894
+ ...fnOptions,
895
+ throwOnError: true
896
+ });
897
+ return data;
898
+ }
899
+ };
900
+ return mutationOptions;
901
+ };
902
+
903
+ /**
904
+ * Add a seat to the lobby
905
+ *
906
+ * Add a new seat to the lobby (host only, up to maxPlayers)
907
+ */
908
+ export const addSeatMutation = (options?: Partial<Options<AddSeatData>>): UseMutationOptions<AddSeatResponse, AddSeatError, Options<AddSeatData>> => {
909
+ const mutationOptions: UseMutationOptions<AddSeatResponse, AddSeatError, Options<AddSeatData>> = {
910
+ mutationFn: async (fnOptions) => {
911
+ const { data } = await addSeat({
912
+ ...options,
913
+ ...fnOptions,
914
+ throwOnError: true
915
+ });
916
+ return data;
917
+ }
918
+ };
919
+ return mutationOptions;
920
+ };
921
+
922
+ /**
923
+ * Remove a seat from the lobby
924
+ *
925
+ * Remove a seat from the lobby (host only, down to minPlayers)
926
+ */
927
+ export const removeSeatMutation = (options?: Partial<Options<RemoveSeatData>>): UseMutationOptions<RemoveSeatResponse, RemoveSeatError, Options<RemoveSeatData>> => {
928
+ const mutationOptions: UseMutationOptions<RemoveSeatResponse, RemoveSeatError, Options<RemoveSeatData>> = {
929
+ mutationFn: async (fnOptions) => {
930
+ const { data } = await removeSeat({
931
+ ...options,
932
+ ...fnOptions,
933
+ throwOnError: true
934
+ });
935
+ return data;
936
+ }
937
+ };
938
+ return mutationOptions;
939
+ };
940
+
941
+ /**
942
+ * Update seat settings
943
+ *
944
+ * Update seat display name and/or player color. User must be assigned to the seat.
945
+ */
946
+ export const updateSeatMutation = (options?: Partial<Options<UpdateSeatData>>): UseMutationOptions<UpdateSeatResponse, UpdateSeatError, Options<UpdateSeatData>> => {
947
+ const mutationOptions: UseMutationOptions<UpdateSeatResponse, UpdateSeatError, Options<UpdateSeatData>> = {
948
+ mutationFn: async (fnOptions) => {
949
+ const { data } = await updateSeat({
950
+ ...options,
951
+ ...fnOptions,
952
+ throwOnError: true
953
+ });
954
+ return data;
955
+ }
956
+ };
957
+ return mutationOptions;
958
+ };
959
+
960
+ /**
961
+ * Assign a seat to current user
962
+ *
963
+ * Assign the current authenticated user to a specific seat
964
+ */
965
+ export const assignSeatMutation = (options?: Partial<Options<AssignSeatData>>): UseMutationOptions<AssignSeatResponse, AssignSeatError, Options<AssignSeatData>> => {
966
+ const mutationOptions: UseMutationOptions<AssignSeatResponse, AssignSeatError, Options<AssignSeatData>> = {
967
+ mutationFn: async (fnOptions) => {
968
+ const { data } = await assignSeat({
969
+ ...options,
970
+ ...fnOptions,
971
+ throwOnError: true
972
+ });
973
+ return data;
974
+ }
975
+ };
976
+ return mutationOptions;
977
+ };
978
+
979
+ /**
980
+ * Restore game state from history
981
+ *
982
+ * Restore the game to a previous state from history (host only)
983
+ */
984
+ export const restoreHistoryMutation = (options?: Partial<Options<RestoreHistoryData>>): UseMutationOptions<RestoreHistoryResponse2, RestoreHistoryError, Options<RestoreHistoryData>> => {
985
+ const mutationOptions: UseMutationOptions<RestoreHistoryResponse2, RestoreHistoryError, Options<RestoreHistoryData>> = {
986
+ mutationFn: async (fnOptions) => {
987
+ const { data } = await restoreHistory({
988
+ ...options,
989
+ ...fnOptions,
990
+ throwOnError: true
991
+ });
992
+ return data;
993
+ }
994
+ };
995
+ return mutationOptions;
996
+ };
997
+
998
+ /**
999
+ * Unassign a seat
1000
+ *
1001
+ * Unassign the current user from a specific seat
1002
+ */
1003
+ export const unassignSeatMutation = (options?: Partial<Options<UnassignSeatData>>): UseMutationOptions<UnassignSeatResponse, UnassignSeatError, Options<UnassignSeatData>> => {
1004
+ const mutationOptions: UseMutationOptions<UnassignSeatResponse, UnassignSeatError, Options<UnassignSeatData>> = {
1005
+ mutationFn: async (fnOptions) => {
1006
+ const { data } = await unassignSeat({
1007
+ ...options,
1008
+ ...fnOptions,
1009
+ throwOnError: true
1010
+ });
1011
+ return data;
1012
+ }
1013
+ };
1014
+ return mutationOptions;
1015
+ };
1016
+
1017
+ export const fetchUiBundleQueryKey = (options?: Options<FetchUiBundleData>) => createQueryKey('fetchUiBundle', options);
1018
+
1019
+ /**
1020
+ * Fetch UI bundle
1021
+ *
1022
+ * Fetch and return the HTML content of a UI bundle from Supabase storage based on the last compiled UI result
1023
+ */
1024
+ export const fetchUiBundleOptions = (options?: Options<FetchUiBundleData>) => queryOptions<FetchUiBundleResponse, FetchUiBundleError, FetchUiBundleResponse, ReturnType<typeof fetchUiBundleQueryKey>>({
1025
+ queryFn: async ({ queryKey, signal }) => {
1026
+ const { data } = await fetchUiBundle({
1027
+ ...options,
1028
+ ...queryKey[0],
1029
+ signal,
1030
+ throwOnError: true
1031
+ });
1032
+ return data;
1033
+ },
1034
+ queryKey: fetchUiBundleQueryKey(options)
1035
+ });
1036
+
1037
+ export const listDemoGamesQueryKey = (options?: Options<ListDemoGamesData>) => createQueryKey('listDemoGames', options);
1038
+
1039
+ /**
1040
+ * List demo games
1041
+ *
1042
+ * List bundled demo games that can be opened without a normal user account.
1043
+ */
1044
+ export const listDemoGamesOptions = (options?: Options<ListDemoGamesData>) => queryOptions<ListDemoGamesResponse, ListDemoGamesError, ListDemoGamesResponse, ReturnType<typeof listDemoGamesQueryKey>>({
1045
+ queryFn: async ({ queryKey, signal }) => {
1046
+ const { data } = await listDemoGames({
1047
+ ...options,
1048
+ ...queryKey[0],
1049
+ signal,
1050
+ throwOnError: true
1051
+ });
1052
+ return data;
1053
+ },
1054
+ queryKey: listDemoGamesQueryKey(options)
1055
+ });
1056
+
1057
+ export const getDemoGameQueryKey = (options: Options<GetDemoGameData>) => createQueryKey('getDemoGame', options);
1058
+
1059
+ /**
1060
+ * Get demo game
1061
+ *
1062
+ * Return registration and playability metadata for a bundled demo game.
1063
+ */
1064
+ export const getDemoGameOptions = (options: Options<GetDemoGameData>) => queryOptions<GetDemoGameResponse, GetDemoGameError, GetDemoGameResponse, ReturnType<typeof getDemoGameQueryKey>>({
1065
+ queryFn: async ({ queryKey, signal }) => {
1066
+ const { data } = await getDemoGame({
1067
+ ...options,
1068
+ ...queryKey[0],
1069
+ signal,
1070
+ throwOnError: true
1071
+ });
1072
+ return data;
1073
+ },
1074
+ queryKey: getDemoGameQueryKey(options)
1075
+ });
1076
+
1077
+ export const getDemoGameThumbnailQueryKey = (options: Options<GetDemoGameThumbnailData>) => createQueryKey('getDemoGameThumbnail', options);
1078
+
1079
+ /**
1080
+ * Get demo game thumbnail
1081
+ *
1082
+ * Return the static thumbnail image for an active bundled demo game.
1083
+ */
1084
+ export const getDemoGameThumbnailOptions = (options: Options<GetDemoGameThumbnailData>) => queryOptions<GetDemoGameThumbnailResponse, GetDemoGameThumbnailError, GetDemoGameThumbnailResponse, ReturnType<typeof getDemoGameThumbnailQueryKey>>({
1085
+ queryFn: async ({ queryKey, signal }) => {
1086
+ const { data } = await getDemoGameThumbnail({
1087
+ ...options,
1088
+ ...queryKey[0],
1089
+ signal,
1090
+ throwOnError: true
1091
+ });
1092
+ return data;
1093
+ },
1094
+ queryKey: getDemoGameThumbnailQueryKey(options)
1095
+ });
1096
+
1097
+ /**
1098
+ * Create demo session
1099
+ *
1100
+ * Create a fresh guest-play session for a bundled demo game.
1101
+ */
1102
+ export const createDemoGameSessionMutation = (options?: Partial<Options<CreateDemoGameSessionData>>): UseMutationOptions<CreateDemoGameSessionResponse, CreateDemoGameSessionError, Options<CreateDemoGameSessionData>> => {
1103
+ const mutationOptions: UseMutationOptions<CreateDemoGameSessionResponse, CreateDemoGameSessionError, Options<CreateDemoGameSessionData>> = {
1104
+ mutationFn: async (fnOptions) => {
1105
+ const { data } = await createDemoGameSession({
1106
+ ...options,
1107
+ ...fnOptions,
1108
+ throwOnError: true
1109
+ });
1110
+ return data;
1111
+ }
1112
+ };
1113
+ return mutationOptions;
1114
+ };