@fzgame/sdk 0.1.0 → 0.3.1

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.
package/dist/index.d.ts CHANGED
@@ -79,7 +79,144 @@ interface paths {
79
79
  responses: {
80
80
  200: {
81
81
  content: {
82
- "application/json": components["schemas"]["AppGameInstance"];
82
+ "application/json": components["schemas"]["PublicGameInstance"];
83
+ };
84
+ };
85
+ 401: components["responses"]["Unauthorized"];
86
+ 403: components["responses"]["Forbidden"];
87
+ };
88
+ };
89
+ };
90
+ "/pub/categories": {
91
+ /** Public game category feed */
92
+ get: {
93
+ responses: {
94
+ 200: {
95
+ content: {
96
+ "application/json": components["schemas"]["CategoryFeed"];
97
+ };
98
+ };
99
+ 401: components["responses"]["Unauthorized"];
100
+ 403: components["responses"]["Forbidden"];
101
+ };
102
+ };
103
+ };
104
+ "/pub/categories/{id}/games": {
105
+ /** Public games in a category */
106
+ get: {
107
+ parameters: {
108
+ query?: {
109
+ page?: string;
110
+ cursor?: string;
111
+ limit?: string;
112
+ order?: string;
113
+ sortBy?: string;
114
+ cursorField?: string;
115
+ search?: string;
116
+ filter?: string;
117
+ include?: string;
118
+ searchField?: string;
119
+ };
120
+ path: {
121
+ id: string;
122
+ };
123
+ };
124
+ responses: {
125
+ 200: {
126
+ content: {
127
+ "application/json": components["schemas"]["PagedGame"];
128
+ };
129
+ };
130
+ 401: components["responses"]["Unauthorized"];
131
+ 403: components["responses"]["Forbidden"];
132
+ };
133
+ };
134
+ };
135
+ "/pub/game-instances/{id}/leaderboard/players": {
136
+ /** Public top score per player for a published game instance */
137
+ get: {
138
+ parameters: {
139
+ query?: {
140
+ page?: number;
141
+ limit?: number;
142
+ };
143
+ path: {
144
+ id: string;
145
+ };
146
+ };
147
+ responses: {
148
+ 200: {
149
+ content: {
150
+ "application/json": components["schemas"]["PagedPlayerLeaderboard"];
151
+ };
152
+ };
153
+ 401: components["responses"]["Unauthorized"];
154
+ 403: components["responses"]["Forbidden"];
155
+ };
156
+ };
157
+ };
158
+ "/pub/game-instances/{id}/leaderboard/sessions": {
159
+ /** Public top scoring play sessions for a published game instance */
160
+ get: {
161
+ parameters: {
162
+ query?: {
163
+ page?: number;
164
+ limit?: number;
165
+ };
166
+ path: {
167
+ id: string;
168
+ };
169
+ };
170
+ responses: {
171
+ 200: {
172
+ content: {
173
+ "application/json": components["schemas"]["PagedSessionLeaderboard"];
174
+ };
175
+ };
176
+ 401: components["responses"]["Unauthorized"];
177
+ 403: components["responses"]["Forbidden"];
178
+ };
179
+ };
180
+ };
181
+ "/pub/games/{id}/leaderboard/players": {
182
+ /** Public top score per player across the published instances of a game */
183
+ get: {
184
+ parameters: {
185
+ query?: {
186
+ page?: number;
187
+ limit?: number;
188
+ };
189
+ path: {
190
+ id: string;
191
+ };
192
+ };
193
+ responses: {
194
+ 200: {
195
+ content: {
196
+ "application/json": components["schemas"]["PagedPlayerLeaderboard"];
197
+ };
198
+ };
199
+ 401: components["responses"]["Unauthorized"];
200
+ 403: components["responses"]["Forbidden"];
201
+ };
202
+ };
203
+ };
204
+ "/pub/games/{id}/leaderboard/sessions": {
205
+ /** Public top scoring play sessions across the published instances of a game */
206
+ get: {
207
+ parameters: {
208
+ query?: {
209
+ page?: number;
210
+ limit?: number;
211
+ };
212
+ path: {
213
+ id: string;
214
+ };
215
+ };
216
+ responses: {
217
+ 200: {
218
+ content: {
219
+ "application/json": components["schemas"]["PagedSessionLeaderboard"];
83
220
  };
84
221
  };
85
222
  401: components["responses"]["Unauthorized"];
@@ -96,6 +233,11 @@ interface paths {
96
233
  };
97
234
  };
98
235
  responses: {
236
+ 201: {
237
+ content: {
238
+ "application/json": components["schemas"]["PlayerLoginResponse"];
239
+ };
240
+ };
99
241
  401: components["responses"]["Unauthorized"];
100
242
  403: components["responses"]["Forbidden"];
101
243
  };
@@ -110,6 +252,11 @@ interface paths {
110
252
  };
111
253
  };
112
254
  responses: {
255
+ 200: {
256
+ content: {
257
+ "application/json": components["schemas"]["AppPlayer"];
258
+ };
259
+ };
113
260
  401: components["responses"]["Unauthorized"];
114
261
  403: components["responses"]["Forbidden"];
115
262
  };
@@ -127,6 +274,11 @@ interface paths {
127
274
  };
128
275
  };
129
276
  responses: {
277
+ 200: {
278
+ content: {
279
+ "application/json": components["schemas"]["AppPlayer"];
280
+ };
281
+ };
130
282
  401: components["responses"]["Unauthorized"];
131
283
  403: components["responses"]["Forbidden"];
132
284
  };
@@ -139,6 +291,11 @@ interface paths {
139
291
  };
140
292
  };
141
293
  responses: {
294
+ 200: {
295
+ content: {
296
+ "application/json": components["schemas"]["AppPlayer"];
297
+ };
298
+ };
142
299
  401: components["responses"]["Unauthorized"];
143
300
  403: components["responses"]["Forbidden"];
144
301
  };
@@ -153,12 +310,17 @@ interface paths {
153
310
  };
154
311
  };
155
312
  responses: {
313
+ 201: {
314
+ content: {
315
+ "application/json": components["schemas"]["PlayerLogoutResponse"];
316
+ };
317
+ };
156
318
  401: components["responses"]["Unauthorized"];
157
319
  403: components["responses"]["Forbidden"];
158
320
  };
159
321
  };
160
322
  };
161
- "/sessions": {
323
+ "/sdk/sessions": {
162
324
  /** Create a play session (SDK) */
163
325
  post: {
164
326
  requestBody?: {
@@ -167,12 +329,37 @@ interface paths {
167
329
  };
168
330
  };
169
331
  responses: {
332
+ 201: {
333
+ content: {
334
+ "application/json": components["schemas"]["AppPlaySession"];
335
+ };
336
+ };
337
+ 401: components["responses"]["Unauthorized"];
338
+ 403: components["responses"]["Forbidden"];
339
+ };
340
+ };
341
+ };
342
+ "/sdk/sessions/active": {
343
+ /** Get the newest live session of a player (SDK) */
344
+ get: {
345
+ parameters: {
346
+ query?: {
347
+ playerId?: string;
348
+ gameInstanceId?: string;
349
+ };
350
+ };
351
+ responses: {
352
+ 200: {
353
+ content: {
354
+ "application/json": components["schemas"]["ActivePlaySession"];
355
+ };
356
+ };
170
357
  401: components["responses"]["Unauthorized"];
171
358
  403: components["responses"]["Forbidden"];
172
359
  };
173
360
  };
174
361
  };
175
- "/sessions/{token}": {
362
+ "/sdk/sessions/{token}": {
176
363
  /** Get play session by token (SDK / iframe) */
177
364
  get: {
178
365
  parameters: {
@@ -181,6 +368,11 @@ interface paths {
181
368
  };
182
369
  };
183
370
  responses: {
371
+ 200: {
372
+ content: {
373
+ "application/json": components["schemas"]["AppPlaySession"];
374
+ };
375
+ };
184
376
  401: components["responses"]["Unauthorized"];
185
377
  403: components["responses"]["Forbidden"];
186
378
  };
@@ -193,39 +385,59 @@ interface paths {
193
385
  };
194
386
  };
195
387
  responses: {
388
+ 200: {
389
+ content: {
390
+ "application/json": components["schemas"]["AppPlaySession"];
391
+ };
392
+ };
196
393
  401: components["responses"]["Unauthorized"];
197
394
  403: components["responses"]["Forbidden"];
198
395
  };
199
396
  };
200
397
  };
201
- "/sessions/{token}/pause": {
398
+ "/sdk/sessions/{token}/pause": {
202
399
  /** Pause a playing session */
203
400
  post: {
204
401
  responses: {
402
+ 201: {
403
+ content: {
404
+ "application/json": components["schemas"]["AppPlaySession"];
405
+ };
406
+ };
205
407
  401: components["responses"]["Unauthorized"];
206
408
  403: components["responses"]["Forbidden"];
207
409
  };
208
410
  };
209
411
  };
210
- "/sessions/{token}/resume": {
412
+ "/sdk/sessions/{token}/resume": {
211
413
  /** Resume a paused session */
212
414
  post: {
213
415
  responses: {
416
+ 201: {
417
+ content: {
418
+ "application/json": components["schemas"]["AppPlaySession"];
419
+ };
420
+ };
214
421
  401: components["responses"]["Unauthorized"];
215
422
  403: components["responses"]["Forbidden"];
216
423
  };
217
424
  };
218
425
  };
219
- "/sessions/{token}/start": {
426
+ "/sdk/sessions/{token}/start": {
220
427
  /** Start play session */
221
428
  post: {
222
429
  responses: {
430
+ 201: {
431
+ content: {
432
+ "application/json": components["schemas"]["AppPlaySession"];
433
+ };
434
+ };
223
435
  401: components["responses"]["Unauthorized"];
224
436
  403: components["responses"]["Forbidden"];
225
437
  };
226
438
  };
227
439
  };
228
- "/sessions/{token}/finish": {
440
+ "/sdk/sessions/{token}/finish": {
229
441
  /** Finish play session */
230
442
  post: {
231
443
  requestBody?: {
@@ -234,21 +446,31 @@ interface paths {
234
446
  };
235
447
  };
236
448
  responses: {
449
+ 201: {
450
+ content: {
451
+ "application/json": components["schemas"]["AppPlaySession"];
452
+ };
453
+ };
237
454
  401: components["responses"]["Unauthorized"];
238
455
  403: components["responses"]["Forbidden"];
239
456
  };
240
457
  };
241
458
  };
242
- "/sessions/{token}/abort": {
459
+ "/sdk/sessions/{token}/abort": {
243
460
  /** Abort play session */
244
461
  post: {
245
462
  responses: {
463
+ 201: {
464
+ content: {
465
+ "application/json": components["schemas"]["AppPlaySession"];
466
+ };
467
+ };
246
468
  401: components["responses"]["Unauthorized"];
247
469
  403: components["responses"]["Forbidden"];
248
470
  };
249
471
  };
250
472
  };
251
- "/sessions/{token}/score": {
473
+ "/sdk/sessions/{token}/score": {
252
474
  /** Update session score */
253
475
  post: {
254
476
  requestBody?: {
@@ -257,13 +479,18 @@ interface paths {
257
479
  };
258
480
  };
259
481
  responses: {
482
+ 201: {
483
+ content: {
484
+ "application/json": components["schemas"]["AppPlaySession"];
485
+ };
486
+ };
260
487
  401: components["responses"]["Unauthorized"];
261
488
  403: components["responses"]["Forbidden"];
262
489
  };
263
490
  };
264
491
  };
265
492
  "/games/runtime/sessions": {
266
- /** Fetch or create a play session from gameInstanceId + player token */
493
+ /** Fetch or create a play session from gameInstanceId + player access token */
267
494
  post: {
268
495
  requestBody?: {
269
496
  content: {
@@ -271,6 +498,11 @@ interface paths {
271
498
  };
272
499
  };
273
500
  responses: {
501
+ 201: {
502
+ content: {
503
+ "application/json": components["schemas"]["AppPlaySession"];
504
+ };
505
+ };
274
506
  401: components["responses"]["Unauthorized"];
275
507
  403: components["responses"]["Forbidden"];
276
508
  };
@@ -285,6 +517,11 @@ interface paths {
285
517
  };
286
518
  };
287
519
  responses: {
520
+ 200: {
521
+ content: {
522
+ "application/json": components["schemas"]["AppPlaySession"];
523
+ };
524
+ };
288
525
  401: components["responses"]["Unauthorized"];
289
526
  403: components["responses"]["Forbidden"];
290
527
  };
@@ -304,6 +541,11 @@ interface paths {
304
541
  };
305
542
  };
306
543
  responses: {
544
+ 201: {
545
+ content: {
546
+ "application/json": components["schemas"]["AppPlaySession"];
547
+ };
548
+ };
307
549
  401: components["responses"]["Unauthorized"];
308
550
  403: components["responses"]["Forbidden"];
309
551
  };
@@ -322,6 +564,25 @@ interface paths {
322
564
  "application/json": components["schemas"]["RuntimeSnapshotDto"];
323
565
  };
324
566
  };
567
+ responses: {
568
+ 200: {
569
+ content: {
570
+ "application/json": components["schemas"]["AppPlaySession"];
571
+ };
572
+ };
573
+ 401: components["responses"]["Unauthorized"];
574
+ 403: components["responses"]["Forbidden"];
575
+ };
576
+ };
577
+ };
578
+ "/games/runtime/handler": {
579
+ /** Run a game handler against a finish payload (studio testing; no play session) */
580
+ post: {
581
+ requestBody?: {
582
+ content: {
583
+ "application/json": components["schemas"]["RuntimeHandlerDto"];
584
+ };
585
+ };
325
586
  responses: {
326
587
  401: components["responses"]["Unauthorized"];
327
588
  403: components["responses"]["Forbidden"];
@@ -384,6 +645,7 @@ interface components {
384
645
  gitConnectors?: components["schemas"]["GitConnector"][];
385
646
  gitSources?: components["schemas"]["GitSource"][];
386
647
  deployments?: components["schemas"]["Deployment"][];
648
+ ciRunners?: components["schemas"]["CiRunner"][];
387
649
  };
388
650
  Users: {
389
651
  id: string;
@@ -445,6 +707,11 @@ interface components {
445
707
  backupCodes: string;
446
708
  userId: string;
447
709
  users?: components["schemas"]["Users"];
710
+ verified: boolean;
711
+ /** Format: int32 */
712
+ failedVerificationCount: number;
713
+ /** Format: date-time */
714
+ lockedUntil: string | null;
448
715
  };
449
716
  UserSpace: {
450
717
  id: string;
@@ -607,6 +874,8 @@ interface components {
607
874
  /** @enum {string} */
608
875
  origin: "OFFICAL" | "DEVELOPER" | "SPACE_PRIVATE";
609
876
  configSchema: Record<string, unknown> | null;
877
+ categoryId: string | null;
878
+ category?: components["schemas"]["GameCategory"];
610
879
  creatorId: string | null;
611
880
  creator?: components["schemas"]["Users"];
612
881
  spaceId: string | null;
@@ -617,6 +886,21 @@ interface components {
617
886
  instances?: components["schemas"]["AppGameInstance"][];
618
887
  gitSources?: components["schemas"]["GitSource"][];
619
888
  };
889
+ GameCategory: {
890
+ id: string;
891
+ /** Format: date-time */
892
+ createdAt: string;
893
+ /** Format: date-time */
894
+ updatedAt: string;
895
+ /** Format: date-time */
896
+ deletedAt: string | null;
897
+ name: string;
898
+ slug: string;
899
+ description: string | null;
900
+ /** Format: int32 */
901
+ sortOrder: number;
902
+ games?: components["schemas"]["Game"][];
903
+ };
620
904
  Deployment: {
621
905
  id: string;
622
906
  /** Format: date-time */
@@ -752,6 +1036,8 @@ interface components {
752
1036
  version: string | null;
753
1037
  creatorId: string | null;
754
1038
  creator?: components["schemas"]["Users"];
1039
+ spaceId: string | null;
1040
+ space?: components["schemas"]["Space"];
755
1041
  deployments?: components["schemas"]["Deployment"][];
756
1042
  };
757
1043
  Webhook: {
@@ -855,6 +1141,79 @@ interface components {
855
1141
  */
856
1142
  hasPreviousPage: boolean;
857
1143
  };
1144
+ PublicGameInstance: {
1145
+ id: string;
1146
+ /** Format: date-time */
1147
+ createdAt: string;
1148
+ /** Format: date-time */
1149
+ updatedAt: string;
1150
+ spaceId: string;
1151
+ appId: string;
1152
+ name: string;
1153
+ /** @enum {string} */
1154
+ status: "DRAFT" | "PUBLISHED" | "ARCHIVED";
1155
+ resolvedUrl: string | null;
1156
+ /** Format: date-time */
1157
+ resolvedAt: string | null;
1158
+ overrides: Record<string, unknown> | null;
1159
+ gameId: string;
1160
+ game: components["schemas"]["Game"];
1161
+ editorUrl: string | null;
1162
+ };
1163
+ CategoryFeed: {
1164
+ data: components["schemas"]["CategorySummary"][];
1165
+ };
1166
+ CategorySummary: {
1167
+ id: string;
1168
+ name: string;
1169
+ slug: string;
1170
+ description?: string | null;
1171
+ sortOrder: number;
1172
+ /** @description Published games in this category */
1173
+ gameCount: number;
1174
+ };
1175
+ PagedGame: {
1176
+ /** @description Page info */
1177
+ pageInfo: components["schemas"]["PageInfo"];
1178
+ /** @description Array of resource items for the current page */
1179
+ data: components["schemas"]["Game"][];
1180
+ };
1181
+ PagedPlayerLeaderboard: {
1182
+ /** @description Page info */
1183
+ pageInfo: components["schemas"]["PageInfo"];
1184
+ /** @description Array of resource items for the current page */
1185
+ data: components["schemas"]["PlayerLeaderboardEntry"][];
1186
+ };
1187
+ PlayerLeaderboardEntry: {
1188
+ /** @description Rank on the requested page (1-based) */
1189
+ rank: number;
1190
+ player: components["schemas"]["LeaderboardPlayer"];
1191
+ score: number;
1192
+ /** @description Session that holds the player best score */
1193
+ sessionId: string;
1194
+ /** Format: date-time */
1195
+ finishedAt: string | null;
1196
+ };
1197
+ LeaderboardPlayer: {
1198
+ id: string;
1199
+ displayName: string | null;
1200
+ avatarUrl: string | null;
1201
+ };
1202
+ PagedSessionLeaderboard: {
1203
+ /** @description Page info */
1204
+ pageInfo: components["schemas"]["PageInfo"];
1205
+ /** @description Array of resource items for the current page */
1206
+ data: components["schemas"]["SessionLeaderboardEntry"][];
1207
+ };
1208
+ SessionLeaderboardEntry: {
1209
+ /** @description Rank on the requested page (1-based) */
1210
+ rank: number;
1211
+ sessionId: string;
1212
+ player: components["schemas"]["LeaderboardPlayer"];
1213
+ score: number;
1214
+ /** Format: date-time */
1215
+ finishedAt: string | null;
1216
+ };
858
1217
  IdentifyPlayerDto: {
859
1218
  identity?: string;
860
1219
  /** @enum {string} */
@@ -864,12 +1223,22 @@ interface components {
864
1223
  avatarUrl?: string;
865
1224
  metadata?: Record<string, unknown>;
866
1225
  };
1226
+ PlayerLoginResponse: {
1227
+ player: components["schemas"]["AppPlayer"];
1228
+ /** @description Signed player access token (JWT). Pass it to the game as the `playerAccessToken` query parameter; `POST /games/runtime/sessions` verifies it. */
1229
+ playerAccessToken: string;
1230
+ };
867
1231
  UpdatePlayerDto: {
868
1232
  externalId?: string;
869
1233
  displayName?: string;
870
1234
  avatarUrl?: string;
871
1235
  metadata?: Record<string, unknown>;
872
1236
  };
1237
+ PlayerLogoutResponse: {
1238
+ playerId: string;
1239
+ /** @description Live play sessions expired by the logout */
1240
+ revokedSessions: number;
1241
+ };
873
1242
  CreatePlaySessionDto: {
874
1243
  playerId: string;
875
1244
  gameInstanceId: string;
@@ -880,6 +1249,10 @@ interface components {
880
1249
  */
881
1250
  expiresAt?: string;
882
1251
  };
1252
+ ActivePlaySession: {
1253
+ /** @description The newest live session, or null when the player has none. */
1254
+ session?: components["schemas"]["AppPlaySession"];
1255
+ };
883
1256
  UpdatePlaySessionDto: {
884
1257
  /**
885
1258
  * @description Only transitions allowed by the session lifecycle are accepted
@@ -896,7 +1269,8 @@ interface components {
896
1269
  };
897
1270
  CreateRuntimeSessionDto: {
898
1271
  gameInstanceId: string;
899
- playerToken: string;
1272
+ /** @description The `playerAccessToken` returned by `POST /sdk/login`. */
1273
+ playerAccessToken: string;
900
1274
  };
901
1275
  RuntimeEmitDto: {
902
1276
  /** @description Session event. The lifecycle names (`LIFECYCLE_EVENTS` in `src/game/lifecycle.ts`: ready, start, pause, finish, abort, score, snapshot) move the session status; any other string is accepted as a custom event, leaves the status alone, and is stored as the session `lastEvent`. */
@@ -906,6 +1280,14 @@ interface components {
906
1280
  RuntimeSnapshotDto: {
907
1281
  state: Record<string, unknown>;
908
1282
  };
1283
+ RuntimeHandlerDto: {
1284
+ /** @description Published game id. Loads handler/index.js from the registry. */
1285
+ gameId?: string;
1286
+ /** @description Handler source for local studio testing. Takes precedence over gameId. */
1287
+ source?: string;
1288
+ /** @description Finish payload: { score, result, config } */
1289
+ payload?: Record<string, unknown>;
1290
+ };
909
1291
  };
910
1292
  responses: {
911
1293
  /** @description Unauthorized access */
@@ -977,5 +1359,23 @@ declare function createSdkClient(options: InitOptions): Client<paths>;
977
1359
  declare const fetchClient: Client<paths>;
978
1360
  /** Configure the process-wide client and return it. */
979
1361
  declare function initializeSDK(options: InitOptions): Client<paths>;
1362
+ /** A game instance from `GET /sdk/game-instances`, as generated from the OpenAPI document. */
1363
+ type GameInstance = components['schemas']['AppGameInstance'];
1364
+ type ResolveGameUrlOptions = {
1365
+ /** API base URL the frame calls. Defaults to the `apiUrl` passed to `initializeSDK`. */
1366
+ apiUrl?: string;
1367
+ /** Config to hand the game as `gameSetting`. Defaults to the instance overrides. */
1368
+ config?: Record<string, unknown> | null;
1369
+ };
1370
+ /**
1371
+ * Build the URL the host loads in an iframe or webview from the game instance
1372
+ * and the token `POST /sdk/login` returned. It appends `apiUrl`,
1373
+ * `gameInstanceId`, `playerAccessToken`, and `gameSetting`.
1374
+ *
1375
+ * `apiUrl` defaults to the one given to `initializeSDK`. A caller that uses
1376
+ * `createSdkClient` instead must pass `{ apiUrl }`, because that client is not
1377
+ * the process-wide one.
1378
+ */
1379
+ declare function resolveGameURL(gameInstance: GameInstance, playerAccessToken: string, options?: ResolveGameUrlOptions): string;
980
1380
 
981
- export { APP_KEY_HEADER, APP_SECRET_HEADER, type InitOptions, SdkConfigError, SdkNotInitializedError, type components, createSdkClient, fetchClient, initializeSDK, type operations, type paths };
1381
+ export { APP_KEY_HEADER, APP_SECRET_HEADER, type GameInstance, type InitOptions, type ResolveGameUrlOptions, SdkConfigError, SdkNotInitializedError, type components, createSdkClient, fetchClient, initializeSDK, type operations, type paths, resolveGameURL };