@playcademy/sdk 0.1.17 → 0.2.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.
package/dist/types.d.ts CHANGED
@@ -1,12 +1,24 @@
1
- import { AUTH_PROVIDER_IDS } from '@playcademy/constants';
2
- import { InferSelectModel } from 'drizzle-orm';
1
+ import * as _playcademy_realtime_server_types from '@playcademy/realtime/server/types';
3
2
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
4
- import * as drizzle_zod from 'drizzle-zod';
5
3
  import { z } from 'zod';
6
- import * as _playcademy_realtime_server_types from '@playcademy/realtime/server/types';
7
4
  import * as _playcademy_timeback_types from '@playcademy/timeback/types';
8
- import { OrganizationConfig, CourseConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
9
- import { SchemaInfo } from '@playcademy/cloudflare';
5
+ import { CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
6
+ import { AUTH_PROVIDER_IDS } from '@playcademy/constants';
7
+
8
+ /**
9
+ * OAuth 2.0 implementation for the Playcademy SDK
10
+ */
11
+
12
+ /**
13
+ * Parses an OAuth state parameter to extract CSRF token and any encoded data.
14
+ *
15
+ * @param state - The OAuth state parameter to parse
16
+ * @returns Object containing CSRF token and optional decoded data
17
+ */
18
+ declare function parseOAuthState(state: string): {
19
+ csrfToken: string;
20
+ data?: Record<string, string>;
21
+ };
10
22
 
11
23
  declare const userRoleEnum: drizzle_orm_pg_core.PgEnum<["admin", "player", "developer"]>;
12
24
  declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
@@ -226,23 +238,6 @@ type GameMetadata = {
226
238
  emoji?: string;
227
239
  [key: string]: unknown;
228
240
  };
229
- /**
230
- * DNS validation records for custom hostname
231
- * Structure for the validationRecords JSON field in game_custom_hostnames table
232
- */
233
- type CustomHostnameValidationRecords = {
234
- /** TXT record for ownership verification */
235
- ownership?: {
236
- name?: string;
237
- value?: string;
238
- type?: string;
239
- };
240
- /** TXT records for SSL certificate validation */
241
- ssl?: Array<{
242
- txt_name?: string;
243
- txt_value?: string;
244
- }>;
245
- };
246
241
  declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
247
242
  name: "games";
248
243
  schema: undefined;
@@ -571,207 +566,6 @@ declare const gameSessions: drizzle_orm_pg_core.PgTableWithColumns<{
571
566
  };
572
567
  dialect: "pg";
573
568
  }>;
574
- /**
575
- * Custom hostnames table
576
- *
577
- * Stores custom domain mappings for games with SSL provisioning via Cloudflare.
578
- */
579
- declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
580
- name: "game_custom_hostnames";
581
- schema: undefined;
582
- columns: {
583
- id: drizzle_orm_pg_core.PgColumn<{
584
- name: "id";
585
- tableName: "game_custom_hostnames";
586
- dataType: "string";
587
- columnType: "PgUUID";
588
- data: string;
589
- driverParam: string;
590
- notNull: true;
591
- hasDefault: true;
592
- isPrimaryKey: true;
593
- isAutoincrement: false;
594
- hasRuntimeDefault: false;
595
- enumValues: undefined;
596
- baseColumn: never;
597
- identity: undefined;
598
- generated: undefined;
599
- }, {}, {}>;
600
- gameId: drizzle_orm_pg_core.PgColumn<{
601
- name: "game_id";
602
- tableName: "game_custom_hostnames";
603
- dataType: "string";
604
- columnType: "PgUUID";
605
- data: string;
606
- driverParam: string;
607
- notNull: true;
608
- hasDefault: false;
609
- isPrimaryKey: false;
610
- isAutoincrement: false;
611
- hasRuntimeDefault: false;
612
- enumValues: undefined;
613
- baseColumn: never;
614
- identity: undefined;
615
- generated: undefined;
616
- }, {}, {}>;
617
- userId: drizzle_orm_pg_core.PgColumn<{
618
- name: "user_id";
619
- tableName: "game_custom_hostnames";
620
- dataType: "string";
621
- columnType: "PgText";
622
- data: string;
623
- driverParam: string;
624
- notNull: true;
625
- hasDefault: false;
626
- isPrimaryKey: false;
627
- isAutoincrement: false;
628
- hasRuntimeDefault: false;
629
- enumValues: [string, ...string[]];
630
- baseColumn: never;
631
- identity: undefined;
632
- generated: undefined;
633
- }, {}, {}>;
634
- hostname: drizzle_orm_pg_core.PgColumn<{
635
- name: "hostname";
636
- tableName: "game_custom_hostnames";
637
- dataType: "string";
638
- columnType: "PgText";
639
- data: string;
640
- driverParam: string;
641
- notNull: true;
642
- hasDefault: false;
643
- isPrimaryKey: false;
644
- isAutoincrement: false;
645
- hasRuntimeDefault: false;
646
- enumValues: [string, ...string[]];
647
- baseColumn: never;
648
- identity: undefined;
649
- generated: undefined;
650
- }, {}, {}>;
651
- cloudflareId: drizzle_orm_pg_core.PgColumn<{
652
- name: "cloudflare_id";
653
- tableName: "game_custom_hostnames";
654
- dataType: "string";
655
- columnType: "PgText";
656
- data: string;
657
- driverParam: string;
658
- notNull: true;
659
- hasDefault: false;
660
- isPrimaryKey: false;
661
- isAutoincrement: false;
662
- hasRuntimeDefault: false;
663
- enumValues: [string, ...string[]];
664
- baseColumn: never;
665
- identity: undefined;
666
- generated: undefined;
667
- }, {}, {}>;
668
- environment: drizzle_orm_pg_core.PgColumn<{
669
- name: "environment";
670
- tableName: "game_custom_hostnames";
671
- dataType: "string";
672
- columnType: "PgEnumColumn";
673
- data: "staging" | "production";
674
- driverParam: string;
675
- notNull: true;
676
- hasDefault: true;
677
- isPrimaryKey: false;
678
- isAutoincrement: false;
679
- hasRuntimeDefault: false;
680
- enumValues: ["staging", "production"];
681
- baseColumn: never;
682
- identity: undefined;
683
- generated: undefined;
684
- }, {}, {}>;
685
- status: drizzle_orm_pg_core.PgColumn<{
686
- name: "status";
687
- tableName: "game_custom_hostnames";
688
- dataType: "string";
689
- columnType: "PgEnumColumn";
690
- data: "pending" | "pending_validation" | "pending_deployment" | "pending_deletion" | "active" | "blocked" | "deleted";
691
- driverParam: string;
692
- notNull: true;
693
- hasDefault: true;
694
- isPrimaryKey: false;
695
- isAutoincrement: false;
696
- hasRuntimeDefault: false;
697
- enumValues: ["pending", "pending_validation", "pending_deployment", "pending_deletion", "active", "blocked", "deleted"];
698
- baseColumn: never;
699
- identity: undefined;
700
- generated: undefined;
701
- }, {}, {}>;
702
- sslStatus: drizzle_orm_pg_core.PgColumn<{
703
- name: "ssl_status";
704
- tableName: "game_custom_hostnames";
705
- dataType: "string";
706
- columnType: "PgEnumColumn";
707
- data: "pending_validation" | "pending_deployment" | "active" | "deleted" | "initializing" | "pending_issuance";
708
- driverParam: string;
709
- notNull: true;
710
- hasDefault: true;
711
- isPrimaryKey: false;
712
- isAutoincrement: false;
713
- hasRuntimeDefault: false;
714
- enumValues: ["initializing", "pending_validation", "pending_issuance", "pending_deployment", "active", "deleted"];
715
- baseColumn: never;
716
- identity: undefined;
717
- generated: undefined;
718
- }, {}, {}>;
719
- validationRecords: drizzle_orm_pg_core.PgColumn<{
720
- name: "validation_records";
721
- tableName: "game_custom_hostnames";
722
- dataType: "json";
723
- columnType: "PgJsonb";
724
- data: CustomHostnameValidationRecords;
725
- driverParam: unknown;
726
- notNull: false;
727
- hasDefault: false;
728
- isPrimaryKey: false;
729
- isAutoincrement: false;
730
- hasRuntimeDefault: false;
731
- enumValues: undefined;
732
- baseColumn: never;
733
- identity: undefined;
734
- generated: undefined;
735
- }, {}, {
736
- $type: CustomHostnameValidationRecords;
737
- }>;
738
- createdAt: drizzle_orm_pg_core.PgColumn<{
739
- name: "created_at";
740
- tableName: "game_custom_hostnames";
741
- dataType: "date";
742
- columnType: "PgTimestamp";
743
- data: Date;
744
- driverParam: string;
745
- notNull: true;
746
- hasDefault: true;
747
- isPrimaryKey: false;
748
- isAutoincrement: false;
749
- hasRuntimeDefault: false;
750
- enumValues: undefined;
751
- baseColumn: never;
752
- identity: undefined;
753
- generated: undefined;
754
- }, {}, {}>;
755
- updatedAt: drizzle_orm_pg_core.PgColumn<{
756
- name: "updated_at";
757
- tableName: "game_custom_hostnames";
758
- dataType: "date";
759
- columnType: "PgTimestamp";
760
- data: Date;
761
- driverParam: string;
762
- notNull: true;
763
- hasDefault: true;
764
- isPrimaryKey: false;
765
- isAutoincrement: false;
766
- hasRuntimeDefault: false;
767
- enumValues: undefined;
768
- baseColumn: never;
769
- identity: undefined;
770
- generated: undefined;
771
- }, {}, {}>;
772
- };
773
- dialect: "pg";
774
- }>;
775
569
  declare const items: drizzle_orm_pg_core.PgTableWithColumns<{
776
570
  name: "items";
777
571
  schema: undefined;
@@ -1150,13 +944,13 @@ declare const currencies: drizzle_orm_pg_core.PgTableWithColumns<{
1150
944
  };
1151
945
  dialect: "pg";
1152
946
  }>;
1153
- declare const shopListings: drizzle_orm_pg_core.PgTableWithColumns<{
1154
- name: "shop_listings";
947
+ declare const maps: drizzle_orm_pg_core.PgTableWithColumns<{
948
+ name: "maps";
1155
949
  schema: undefined;
1156
950
  columns: {
1157
951
  id: drizzle_orm_pg_core.PgColumn<{
1158
952
  name: "id";
1159
- tableName: "shop_listings";
953
+ tableName: "maps";
1160
954
  dataType: "string";
1161
955
  columnType: "PgUUID";
1162
956
  data: string;
@@ -1171,11 +965,11 @@ declare const shopListings: drizzle_orm_pg_core.PgTableWithColumns<{
1171
965
  identity: undefined;
1172
966
  generated: undefined;
1173
967
  }, {}, {}>;
1174
- itemId: drizzle_orm_pg_core.PgColumn<{
1175
- name: "item_id";
1176
- tableName: "shop_listings";
968
+ identifier: drizzle_orm_pg_core.PgColumn<{
969
+ name: "identifier";
970
+ tableName: "maps";
1177
971
  dataType: "string";
1178
- columnType: "PgUUID";
972
+ columnType: "PgVarchar";
1179
973
  data: string;
1180
974
  driverParam: string;
1181
975
  notNull: true;
@@ -1183,16 +977,18 @@ declare const shopListings: drizzle_orm_pg_core.PgTableWithColumns<{
1183
977
  isPrimaryKey: false;
1184
978
  isAutoincrement: false;
1185
979
  hasRuntimeDefault: false;
1186
- enumValues: undefined;
980
+ enumValues: [string, ...string[]];
1187
981
  baseColumn: never;
1188
982
  identity: undefined;
1189
983
  generated: undefined;
1190
- }, {}, {}>;
1191
- currencyId: drizzle_orm_pg_core.PgColumn<{
1192
- name: "currency_id";
1193
- tableName: "shop_listings";
984
+ }, {}, {
985
+ length: 255;
986
+ }>;
987
+ displayName: drizzle_orm_pg_core.PgColumn<{
988
+ name: "display_name";
989
+ tableName: "maps";
1194
990
  dataType: "string";
1195
- columnType: "PgUUID";
991
+ columnType: "PgVarchar";
1196
992
  data: string;
1197
993
  driverParam: string;
1198
994
  notNull: true;
@@ -1200,241 +996,45 @@ declare const shopListings: drizzle_orm_pg_core.PgTableWithColumns<{
1200
996
  isPrimaryKey: false;
1201
997
  isAutoincrement: false;
1202
998
  hasRuntimeDefault: false;
1203
- enumValues: undefined;
999
+ enumValues: [string, ...string[]];
1204
1000
  baseColumn: never;
1205
1001
  identity: undefined;
1206
1002
  generated: undefined;
1207
- }, {}, {}>;
1208
- price: drizzle_orm_pg_core.PgColumn<{
1209
- name: "price";
1210
- tableName: "shop_listings";
1211
- dataType: "number";
1212
- columnType: "PgInteger";
1213
- data: number;
1214
- driverParam: string | number;
1003
+ }, {}, {
1004
+ length: 255;
1005
+ }>;
1006
+ filePath: drizzle_orm_pg_core.PgColumn<{
1007
+ name: "file_path";
1008
+ tableName: "maps";
1009
+ dataType: "string";
1010
+ columnType: "PgVarchar";
1011
+ data: string;
1012
+ driverParam: string;
1215
1013
  notNull: true;
1216
1014
  hasDefault: false;
1217
1015
  isPrimaryKey: false;
1218
1016
  isAutoincrement: false;
1219
1017
  hasRuntimeDefault: false;
1220
- enumValues: undefined;
1018
+ enumValues: [string, ...string[]];
1221
1019
  baseColumn: never;
1222
1020
  identity: undefined;
1223
1021
  generated: undefined;
1224
- }, {}, {}>;
1225
- sellBackPercentage: drizzle_orm_pg_core.PgColumn<{
1226
- name: "sell_back_percentage";
1227
- tableName: "shop_listings";
1228
- dataType: "number";
1229
- columnType: "PgInteger";
1230
- data: number;
1231
- driverParam: string | number;
1232
- notNull: false;
1233
- hasDefault: false;
1022
+ }, {}, {
1023
+ length: 255;
1024
+ }>;
1025
+ tilesetBasePath: drizzle_orm_pg_core.PgColumn<{
1026
+ name: "tileset_base_path";
1027
+ tableName: "maps";
1028
+ dataType: "string";
1029
+ columnType: "PgVarchar";
1030
+ data: string;
1031
+ driverParam: string;
1032
+ notNull: true;
1033
+ hasDefault: true;
1234
1034
  isPrimaryKey: false;
1235
1035
  isAutoincrement: false;
1236
1036
  hasRuntimeDefault: false;
1237
- enumValues: undefined;
1238
- baseColumn: never;
1239
- identity: undefined;
1240
- generated: undefined;
1241
- }, {}, {}>;
1242
- stock: drizzle_orm_pg_core.PgColumn<{
1243
- name: "stock";
1244
- tableName: "shop_listings";
1245
- dataType: "number";
1246
- columnType: "PgInteger";
1247
- data: number;
1248
- driverParam: string | number;
1249
- notNull: false;
1250
- hasDefault: false;
1251
- isPrimaryKey: false;
1252
- isAutoincrement: false;
1253
- hasRuntimeDefault: false;
1254
- enumValues: undefined;
1255
- baseColumn: never;
1256
- identity: undefined;
1257
- generated: undefined;
1258
- }, {}, {}>;
1259
- isActive: drizzle_orm_pg_core.PgColumn<{
1260
- name: "is_active";
1261
- tableName: "shop_listings";
1262
- dataType: "boolean";
1263
- columnType: "PgBoolean";
1264
- data: boolean;
1265
- driverParam: boolean;
1266
- notNull: true;
1267
- hasDefault: true;
1268
- isPrimaryKey: false;
1269
- isAutoincrement: false;
1270
- hasRuntimeDefault: false;
1271
- enumValues: undefined;
1272
- baseColumn: never;
1273
- identity: undefined;
1274
- generated: undefined;
1275
- }, {}, {}>;
1276
- availableFrom: drizzle_orm_pg_core.PgColumn<{
1277
- name: "available_from";
1278
- tableName: "shop_listings";
1279
- dataType: "date";
1280
- columnType: "PgTimestamp";
1281
- data: Date;
1282
- driverParam: string;
1283
- notNull: false;
1284
- hasDefault: false;
1285
- isPrimaryKey: false;
1286
- isAutoincrement: false;
1287
- hasRuntimeDefault: false;
1288
- enumValues: undefined;
1289
- baseColumn: never;
1290
- identity: undefined;
1291
- generated: undefined;
1292
- }, {}, {}>;
1293
- availableUntil: drizzle_orm_pg_core.PgColumn<{
1294
- name: "available_until";
1295
- tableName: "shop_listings";
1296
- dataType: "date";
1297
- columnType: "PgTimestamp";
1298
- data: Date;
1299
- driverParam: string;
1300
- notNull: false;
1301
- hasDefault: false;
1302
- isPrimaryKey: false;
1303
- isAutoincrement: false;
1304
- hasRuntimeDefault: false;
1305
- enumValues: undefined;
1306
- baseColumn: never;
1307
- identity: undefined;
1308
- generated: undefined;
1309
- }, {}, {}>;
1310
- createdAt: drizzle_orm_pg_core.PgColumn<{
1311
- name: "created_at";
1312
- tableName: "shop_listings";
1313
- dataType: "date";
1314
- columnType: "PgTimestamp";
1315
- data: Date;
1316
- driverParam: string;
1317
- notNull: true;
1318
- hasDefault: true;
1319
- isPrimaryKey: false;
1320
- isAutoincrement: false;
1321
- hasRuntimeDefault: false;
1322
- enumValues: undefined;
1323
- baseColumn: never;
1324
- identity: undefined;
1325
- generated: undefined;
1326
- }, {}, {}>;
1327
- updatedAt: drizzle_orm_pg_core.PgColumn<{
1328
- name: "updated_at";
1329
- tableName: "shop_listings";
1330
- dataType: "date";
1331
- columnType: "PgTimestamp";
1332
- data: Date;
1333
- driverParam: string;
1334
- notNull: false;
1335
- hasDefault: true;
1336
- isPrimaryKey: false;
1337
- isAutoincrement: false;
1338
- hasRuntimeDefault: false;
1339
- enumValues: undefined;
1340
- baseColumn: never;
1341
- identity: undefined;
1342
- generated: undefined;
1343
- }, {}, {}>;
1344
- };
1345
- dialect: "pg";
1346
- }>;
1347
- declare const maps: drizzle_orm_pg_core.PgTableWithColumns<{
1348
- name: "maps";
1349
- schema: undefined;
1350
- columns: {
1351
- id: drizzle_orm_pg_core.PgColumn<{
1352
- name: "id";
1353
- tableName: "maps";
1354
- dataType: "string";
1355
- columnType: "PgUUID";
1356
- data: string;
1357
- driverParam: string;
1358
- notNull: true;
1359
- hasDefault: true;
1360
- isPrimaryKey: true;
1361
- isAutoincrement: false;
1362
- hasRuntimeDefault: false;
1363
- enumValues: undefined;
1364
- baseColumn: never;
1365
- identity: undefined;
1366
- generated: undefined;
1367
- }, {}, {}>;
1368
- identifier: drizzle_orm_pg_core.PgColumn<{
1369
- name: "identifier";
1370
- tableName: "maps";
1371
- dataType: "string";
1372
- columnType: "PgVarchar";
1373
- data: string;
1374
- driverParam: string;
1375
- notNull: true;
1376
- hasDefault: false;
1377
- isPrimaryKey: false;
1378
- isAutoincrement: false;
1379
- hasRuntimeDefault: false;
1380
- enumValues: [string, ...string[]];
1381
- baseColumn: never;
1382
- identity: undefined;
1383
- generated: undefined;
1384
- }, {}, {
1385
- length: 255;
1386
- }>;
1387
- displayName: drizzle_orm_pg_core.PgColumn<{
1388
- name: "display_name";
1389
- tableName: "maps";
1390
- dataType: "string";
1391
- columnType: "PgVarchar";
1392
- data: string;
1393
- driverParam: string;
1394
- notNull: true;
1395
- hasDefault: false;
1396
- isPrimaryKey: false;
1397
- isAutoincrement: false;
1398
- hasRuntimeDefault: false;
1399
- enumValues: [string, ...string[]];
1400
- baseColumn: never;
1401
- identity: undefined;
1402
- generated: undefined;
1403
- }, {}, {
1404
- length: 255;
1405
- }>;
1406
- filePath: drizzle_orm_pg_core.PgColumn<{
1407
- name: "file_path";
1408
- tableName: "maps";
1409
- dataType: "string";
1410
- columnType: "PgVarchar";
1411
- data: string;
1412
- driverParam: string;
1413
- notNull: true;
1414
- hasDefault: false;
1415
- isPrimaryKey: false;
1416
- isAutoincrement: false;
1417
- hasRuntimeDefault: false;
1418
- enumValues: [string, ...string[]];
1419
- baseColumn: never;
1420
- identity: undefined;
1421
- generated: undefined;
1422
- }, {}, {
1423
- length: 255;
1424
- }>;
1425
- tilesetBasePath: drizzle_orm_pg_core.PgColumn<{
1426
- name: "tileset_base_path";
1427
- tableName: "maps";
1428
- dataType: "string";
1429
- columnType: "PgVarchar";
1430
- data: string;
1431
- driverParam: string;
1432
- notNull: true;
1433
- hasDefault: true;
1434
- isPrimaryKey: false;
1435
- isAutoincrement: false;
1436
- hasRuntimeDefault: false;
1437
- enumValues: [string, ...string[]];
1037
+ enumValues: [string, ...string[]];
1438
1038
  baseColumn: never;
1439
1039
  identity: undefined;
1440
1040
  generated: undefined;
@@ -2576,6 +2176,57 @@ declare const gameTimebackIntegrations: drizzle_orm_pg_core.PgTableWithColumns<{
2576
2176
  identity: undefined;
2577
2177
  generated: undefined;
2578
2178
  }, {}, {}>;
2179
+ grade: drizzle_orm_pg_core.PgColumn<{
2180
+ name: "grade";
2181
+ tableName: "game_timeback_integrations";
2182
+ dataType: "number";
2183
+ columnType: "PgInteger";
2184
+ data: number;
2185
+ driverParam: string | number;
2186
+ notNull: true;
2187
+ hasDefault: false;
2188
+ isPrimaryKey: false;
2189
+ isAutoincrement: false;
2190
+ hasRuntimeDefault: false;
2191
+ enumValues: undefined;
2192
+ baseColumn: never;
2193
+ identity: undefined;
2194
+ generated: undefined;
2195
+ }, {}, {}>;
2196
+ subject: drizzle_orm_pg_core.PgColumn<{
2197
+ name: "subject";
2198
+ tableName: "game_timeback_integrations";
2199
+ dataType: "string";
2200
+ columnType: "PgText";
2201
+ data: string;
2202
+ driverParam: string;
2203
+ notNull: true;
2204
+ hasDefault: false;
2205
+ isPrimaryKey: false;
2206
+ isAutoincrement: false;
2207
+ hasRuntimeDefault: false;
2208
+ enumValues: [string, ...string[]];
2209
+ baseColumn: never;
2210
+ identity: undefined;
2211
+ generated: undefined;
2212
+ }, {}, {}>;
2213
+ totalXp: drizzle_orm_pg_core.PgColumn<{
2214
+ name: "total_xp";
2215
+ tableName: "game_timeback_integrations";
2216
+ dataType: "number";
2217
+ columnType: "PgInteger";
2218
+ data: number;
2219
+ driverParam: string | number;
2220
+ notNull: false;
2221
+ hasDefault: false;
2222
+ isPrimaryKey: false;
2223
+ isAutoincrement: false;
2224
+ hasRuntimeDefault: false;
2225
+ enumValues: undefined;
2226
+ baseColumn: never;
2227
+ identity: undefined;
2228
+ generated: undefined;
2229
+ }, {}, {}>;
2579
2230
  lastVerifiedAt: drizzle_orm_pg_core.PgColumn<{
2580
2231
  name: "last_verified_at";
2581
2232
  tableName: "game_timeback_integrations";
@@ -2849,291 +2500,6 @@ declare const achievements: drizzle_orm_pg_core.PgTableWithColumns<{
2849
2500
  };
2850
2501
  dialect: "pg";
2851
2502
  }>;
2852
- declare const notifications: drizzle_orm_pg_core.PgTableWithColumns<{
2853
- name: "notifications";
2854
- schema: undefined;
2855
- columns: {
2856
- id: drizzle_orm_pg_core.PgColumn<{
2857
- name: "id";
2858
- tableName: "notifications";
2859
- dataType: "string";
2860
- columnType: "PgUUID";
2861
- data: string;
2862
- driverParam: string;
2863
- notNull: true;
2864
- hasDefault: true;
2865
- isPrimaryKey: true;
2866
- isAutoincrement: false;
2867
- hasRuntimeDefault: false;
2868
- enumValues: undefined;
2869
- baseColumn: never;
2870
- identity: undefined;
2871
- generated: undefined;
2872
- }, {}, {}>;
2873
- userId: drizzle_orm_pg_core.PgColumn<{
2874
- name: "user_id";
2875
- tableName: "notifications";
2876
- dataType: "string";
2877
- columnType: "PgText";
2878
- data: string;
2879
- driverParam: string;
2880
- notNull: true;
2881
- hasDefault: false;
2882
- isPrimaryKey: false;
2883
- isAutoincrement: false;
2884
- hasRuntimeDefault: false;
2885
- enumValues: [string, ...string[]];
2886
- baseColumn: never;
2887
- identity: undefined;
2888
- generated: undefined;
2889
- }, {}, {}>;
2890
- type: drizzle_orm_pg_core.PgColumn<{
2891
- name: "type";
2892
- tableName: "notifications";
2893
- dataType: "string";
2894
- columnType: "PgVarchar";
2895
- data: string;
2896
- driverParam: string;
2897
- notNull: true;
2898
- hasDefault: false;
2899
- isPrimaryKey: false;
2900
- isAutoincrement: false;
2901
- hasRuntimeDefault: false;
2902
- enumValues: [string, ...string[]];
2903
- baseColumn: never;
2904
- identity: undefined;
2905
- generated: undefined;
2906
- }, {}, {
2907
- length: 50;
2908
- }>;
2909
- title: drizzle_orm_pg_core.PgColumn<{
2910
- name: "title";
2911
- tableName: "notifications";
2912
- dataType: "string";
2913
- columnType: "PgVarchar";
2914
- data: string;
2915
- driverParam: string;
2916
- notNull: true;
2917
- hasDefault: false;
2918
- isPrimaryKey: false;
2919
- isAutoincrement: false;
2920
- hasRuntimeDefault: false;
2921
- enumValues: [string, ...string[]];
2922
- baseColumn: never;
2923
- identity: undefined;
2924
- generated: undefined;
2925
- }, {}, {
2926
- length: 255;
2927
- }>;
2928
- message: drizzle_orm_pg_core.PgColumn<{
2929
- name: "message";
2930
- tableName: "notifications";
2931
- dataType: "string";
2932
- columnType: "PgText";
2933
- data: string;
2934
- driverParam: string;
2935
- notNull: true;
2936
- hasDefault: false;
2937
- isPrimaryKey: false;
2938
- isAutoincrement: false;
2939
- hasRuntimeDefault: false;
2940
- enumValues: [string, ...string[]];
2941
- baseColumn: never;
2942
- identity: undefined;
2943
- generated: undefined;
2944
- }, {}, {}>;
2945
- data: drizzle_orm_pg_core.PgColumn<{
2946
- name: "data";
2947
- tableName: "notifications";
2948
- dataType: "json";
2949
- columnType: "PgJsonb";
2950
- data: unknown;
2951
- driverParam: unknown;
2952
- notNull: true;
2953
- hasDefault: true;
2954
- isPrimaryKey: false;
2955
- isAutoincrement: false;
2956
- hasRuntimeDefault: false;
2957
- enumValues: undefined;
2958
- baseColumn: never;
2959
- identity: undefined;
2960
- generated: undefined;
2961
- }, {}, {}>;
2962
- priority: drizzle_orm_pg_core.PgColumn<{
2963
- name: "priority";
2964
- tableName: "notifications";
2965
- dataType: "string";
2966
- columnType: "PgEnumColumn";
2967
- data: "low" | "normal" | "high" | "urgent";
2968
- driverParam: string;
2969
- notNull: true;
2970
- hasDefault: true;
2971
- isPrimaryKey: false;
2972
- isAutoincrement: false;
2973
- hasRuntimeDefault: false;
2974
- enumValues: ["low", "normal", "high", "urgent"];
2975
- baseColumn: never;
2976
- identity: undefined;
2977
- generated: undefined;
2978
- }, {}, {}>;
2979
- status: drizzle_orm_pg_core.PgColumn<{
2980
- name: "status";
2981
- tableName: "notifications";
2982
- dataType: "string";
2983
- columnType: "PgEnumColumn";
2984
- data: "pending" | "delivered" | "seen" | "clicked" | "dismissed" | "expired";
2985
- driverParam: string;
2986
- notNull: true;
2987
- hasDefault: true;
2988
- isPrimaryKey: false;
2989
- isAutoincrement: false;
2990
- hasRuntimeDefault: false;
2991
- enumValues: ["pending", "delivered", "seen", "clicked", "dismissed", "expired"];
2992
- baseColumn: never;
2993
- identity: undefined;
2994
- generated: undefined;
2995
- }, {}, {}>;
2996
- createdAt: drizzle_orm_pg_core.PgColumn<{
2997
- name: "created_at";
2998
- tableName: "notifications";
2999
- dataType: "date";
3000
- columnType: "PgTimestamp";
3001
- data: Date;
3002
- driverParam: string;
3003
- notNull: true;
3004
- hasDefault: true;
3005
- isPrimaryKey: false;
3006
- isAutoincrement: false;
3007
- hasRuntimeDefault: false;
3008
- enumValues: undefined;
3009
- baseColumn: never;
3010
- identity: undefined;
3011
- generated: undefined;
3012
- }, {}, {}>;
3013
- deliveredAt: drizzle_orm_pg_core.PgColumn<{
3014
- name: "delivered_at";
3015
- tableName: "notifications";
3016
- dataType: "date";
3017
- columnType: "PgTimestamp";
3018
- data: Date;
3019
- driverParam: string;
3020
- notNull: false;
3021
- hasDefault: false;
3022
- isPrimaryKey: false;
3023
- isAutoincrement: false;
3024
- hasRuntimeDefault: false;
3025
- enumValues: undefined;
3026
- baseColumn: never;
3027
- identity: undefined;
3028
- generated: undefined;
3029
- }, {}, {}>;
3030
- seenAt: drizzle_orm_pg_core.PgColumn<{
3031
- name: "seen_at";
3032
- tableName: "notifications";
3033
- dataType: "date";
3034
- columnType: "PgTimestamp";
3035
- data: Date;
3036
- driverParam: string;
3037
- notNull: false;
3038
- hasDefault: false;
3039
- isPrimaryKey: false;
3040
- isAutoincrement: false;
3041
- hasRuntimeDefault: false;
3042
- enumValues: undefined;
3043
- baseColumn: never;
3044
- identity: undefined;
3045
- generated: undefined;
3046
- }, {}, {}>;
3047
- clickedAt: drizzle_orm_pg_core.PgColumn<{
3048
- name: "clicked_at";
3049
- tableName: "notifications";
3050
- dataType: "date";
3051
- columnType: "PgTimestamp";
3052
- data: Date;
3053
- driverParam: string;
3054
- notNull: false;
3055
- hasDefault: false;
3056
- isPrimaryKey: false;
3057
- isAutoincrement: false;
3058
- hasRuntimeDefault: false;
3059
- enumValues: undefined;
3060
- baseColumn: never;
3061
- identity: undefined;
3062
- generated: undefined;
3063
- }, {}, {}>;
3064
- expiresAt: drizzle_orm_pg_core.PgColumn<{
3065
- name: "expires_at";
3066
- tableName: "notifications";
3067
- dataType: "date";
3068
- columnType: "PgTimestamp";
3069
- data: Date;
3070
- driverParam: string;
3071
- notNull: false;
3072
- hasDefault: false;
3073
- isPrimaryKey: false;
3074
- isAutoincrement: false;
3075
- hasRuntimeDefault: false;
3076
- enumValues: undefined;
3077
- baseColumn: never;
3078
- identity: undefined;
3079
- generated: undefined;
3080
- }, {}, {}>;
3081
- method: drizzle_orm_pg_core.PgColumn<{
3082
- name: "method";
3083
- tableName: "notifications";
3084
- dataType: "string";
3085
- columnType: "PgVarchar";
3086
- data: string;
3087
- driverParam: string;
3088
- notNull: false;
3089
- hasDefault: false;
3090
- isPrimaryKey: false;
3091
- isAutoincrement: false;
3092
- hasRuntimeDefault: false;
3093
- enumValues: [string, ...string[]];
3094
- baseColumn: never;
3095
- identity: undefined;
3096
- generated: undefined;
3097
- }, {}, {
3098
- length: 50;
3099
- }>;
3100
- clickUrl: drizzle_orm_pg_core.PgColumn<{
3101
- name: "click_url";
3102
- tableName: "notifications";
3103
- dataType: "string";
3104
- columnType: "PgText";
3105
- data: string;
3106
- driverParam: string;
3107
- notNull: false;
3108
- hasDefault: false;
3109
- isPrimaryKey: false;
3110
- isAutoincrement: false;
3111
- hasRuntimeDefault: false;
3112
- enumValues: [string, ...string[]];
3113
- baseColumn: never;
3114
- identity: undefined;
3115
- generated: undefined;
3116
- }, {}, {}>;
3117
- metadata: drizzle_orm_pg_core.PgColumn<{
3118
- name: "metadata";
3119
- tableName: "notifications";
3120
- dataType: "json";
3121
- columnType: "PgJsonb";
3122
- data: unknown;
3123
- driverParam: unknown;
3124
- notNull: true;
3125
- hasDefault: true;
3126
- isPrimaryKey: false;
3127
- isAutoincrement: false;
3128
- hasRuntimeDefault: false;
3129
- enumValues: undefined;
3130
- baseColumn: never;
3131
- identity: undefined;
3132
- generated: undefined;
3133
- }, {}, {}>;
3134
- };
3135
- dialect: "pg";
3136
- }>;
3137
2503
  declare const DeveloperStatusResponseSchema: z.ZodObject<{
3138
2504
  status: z.ZodEnum<["none", "pending", "approved"]>;
3139
2505
  }, "strip", z.ZodTypeAny, {
@@ -3141,42 +2507,6 @@ declare const DeveloperStatusResponseSchema: z.ZodObject<{
3141
2507
  }, {
3142
2508
  status: "none" | "pending" | "approved";
3143
2509
  }>;
3144
- declare const UpsertGameMetadataSchema: z.ZodEffects<z.ZodObject<{
3145
- displayName: z.ZodString;
3146
- mapElementId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
3147
- platform: z.ZodEnum<["web", "godot", "unity"]>;
3148
- metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
3149
- gameType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["hosted", "external"]>>>;
3150
- externalUrl: z.ZodOptional<z.ZodString>;
3151
- }, "strip", z.ZodTypeAny, {
3152
- displayName: string;
3153
- gameType: "hosted" | "external";
3154
- platform: "web" | "godot" | "unity";
3155
- metadata: Record<string, unknown>;
3156
- externalUrl?: string | undefined;
3157
- mapElementId?: string | null | undefined;
3158
- }, {
3159
- displayName: string;
3160
- platform: "web" | "godot" | "unity";
3161
- gameType?: "hosted" | "external" | undefined;
3162
- externalUrl?: string | undefined;
3163
- mapElementId?: string | null | undefined;
3164
- metadata?: Record<string, unknown> | undefined;
3165
- }>, {
3166
- displayName: string;
3167
- gameType: "hosted" | "external";
3168
- platform: "web" | "godot" | "unity";
3169
- metadata: Record<string, unknown>;
3170
- externalUrl?: string | undefined;
3171
- mapElementId?: string | null | undefined;
3172
- }, {
3173
- displayName: string;
3174
- platform: "web" | "godot" | "unity";
3175
- gameType?: "hosted" | "external" | undefined;
3176
- externalUrl?: string | undefined;
3177
- mapElementId?: string | null | undefined;
3178
- metadata?: Record<string, unknown> | undefined;
3179
- }>;
3180
2510
  /**
3181
2511
  * Simplified game manifest for Cloudflare Workers deployments
3182
2512
  *
@@ -3204,299 +2534,6 @@ declare const ManifestV1Schema: z.ZodObject<{
3204
2534
  version: string;
3205
2535
  platform: string;
3206
2536
  }>;
3207
- declare const InsertItemSchema: drizzle_zod.BuildSchema<"insert", {
3208
- id: drizzle_orm_pg_core.PgColumn<{
3209
- name: "id";
3210
- tableName: "items";
3211
- dataType: "string";
3212
- columnType: "PgUUID";
3213
- data: string;
3214
- driverParam: string;
3215
- notNull: true;
3216
- hasDefault: true;
3217
- isPrimaryKey: true;
3218
- isAutoincrement: false;
3219
- hasRuntimeDefault: false;
3220
- enumValues: undefined;
3221
- baseColumn: never;
3222
- identity: undefined;
3223
- generated: undefined;
3224
- }, {}, {}>;
3225
- slug: drizzle_orm_pg_core.PgColumn<{
3226
- name: "slug";
3227
- tableName: "items";
3228
- dataType: "string";
3229
- columnType: "PgText";
3230
- data: string;
3231
- driverParam: string;
3232
- notNull: true;
3233
- hasDefault: false;
3234
- isPrimaryKey: false;
3235
- isAutoincrement: false;
3236
- hasRuntimeDefault: false;
3237
- enumValues: [string, ...string[]];
3238
- baseColumn: never;
3239
- identity: undefined;
3240
- generated: undefined;
3241
- }, {}, {}>;
3242
- gameId: drizzle_orm_pg_core.PgColumn<{
3243
- name: "game_id";
3244
- tableName: "items";
3245
- dataType: "string";
3246
- columnType: "PgUUID";
3247
- data: string;
3248
- driverParam: string;
3249
- notNull: false;
3250
- hasDefault: false;
3251
- isPrimaryKey: false;
3252
- isAutoincrement: false;
3253
- hasRuntimeDefault: false;
3254
- enumValues: undefined;
3255
- baseColumn: never;
3256
- identity: undefined;
3257
- generated: undefined;
3258
- }, {}, {}>;
3259
- displayName: drizzle_orm_pg_core.PgColumn<{
3260
- name: "display_name";
3261
- tableName: "items";
3262
- dataType: "string";
3263
- columnType: "PgText";
3264
- data: string;
3265
- driverParam: string;
3266
- notNull: true;
3267
- hasDefault: false;
3268
- isPrimaryKey: false;
3269
- isAutoincrement: false;
3270
- hasRuntimeDefault: false;
3271
- enumValues: [string, ...string[]];
3272
- baseColumn: never;
3273
- identity: undefined;
3274
- generated: undefined;
3275
- }, {}, {}>;
3276
- description: drizzle_orm_pg_core.PgColumn<{
3277
- name: "description";
3278
- tableName: "items";
3279
- dataType: "string";
3280
- columnType: "PgText";
3281
- data: string;
3282
- driverParam: string;
3283
- notNull: false;
3284
- hasDefault: false;
3285
- isPrimaryKey: false;
3286
- isAutoincrement: false;
3287
- hasRuntimeDefault: false;
3288
- enumValues: [string, ...string[]];
3289
- baseColumn: never;
3290
- identity: undefined;
3291
- generated: undefined;
3292
- }, {}, {}>;
3293
- type: drizzle_orm_pg_core.PgColumn<{
3294
- name: "type";
3295
- tableName: "items";
3296
- dataType: "string";
3297
- columnType: "PgEnumColumn";
3298
- data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
3299
- driverParam: string;
3300
- notNull: true;
3301
- hasDefault: true;
3302
- isPrimaryKey: false;
3303
- isAutoincrement: false;
3304
- hasRuntimeDefault: false;
3305
- enumValues: ["currency", "badge", "trophy", "collectible", "consumable", "unlock", "upgrade", "accessory", "other"];
3306
- baseColumn: never;
3307
- identity: undefined;
3308
- generated: undefined;
3309
- }, {}, {}>;
3310
- isPlaceable: drizzle_orm_pg_core.PgColumn<{
3311
- name: "is_placeable";
3312
- tableName: "items";
3313
- dataType: "boolean";
3314
- columnType: "PgBoolean";
3315
- data: boolean;
3316
- driverParam: boolean;
3317
- notNull: true;
3318
- hasDefault: true;
3319
- isPrimaryKey: false;
3320
- isAutoincrement: false;
3321
- hasRuntimeDefault: false;
3322
- enumValues: undefined;
3323
- baseColumn: never;
3324
- identity: undefined;
3325
- generated: undefined;
3326
- }, {}, {}>;
3327
- imageUrl: drizzle_orm_pg_core.PgColumn<{
3328
- name: "image_url";
3329
- tableName: "items";
3330
- dataType: "string";
3331
- columnType: "PgText";
3332
- data: string;
3333
- driverParam: string;
3334
- notNull: false;
3335
- hasDefault: false;
3336
- isPrimaryKey: false;
3337
- isAutoincrement: false;
3338
- hasRuntimeDefault: false;
3339
- enumValues: [string, ...string[]];
3340
- baseColumn: never;
3341
- identity: undefined;
3342
- generated: undefined;
3343
- }, {}, {}>;
3344
- metadata: drizzle_orm_pg_core.PgColumn<{
3345
- name: "metadata";
3346
- tableName: "items";
3347
- dataType: "json";
3348
- columnType: "PgJsonb";
3349
- data: unknown;
3350
- driverParam: unknown;
3351
- notNull: false;
3352
- hasDefault: true;
3353
- isPrimaryKey: false;
3354
- isAutoincrement: false;
3355
- hasRuntimeDefault: false;
3356
- enumValues: undefined;
3357
- baseColumn: never;
3358
- identity: undefined;
3359
- generated: undefined;
3360
- }, {}, {}>;
3361
- createdAt: drizzle_orm_pg_core.PgColumn<{
3362
- name: "created_at";
3363
- tableName: "items";
3364
- dataType: "date";
3365
- columnType: "PgTimestamp";
3366
- data: Date;
3367
- driverParam: string;
3368
- notNull: true;
3369
- hasDefault: true;
3370
- isPrimaryKey: false;
3371
- isAutoincrement: false;
3372
- hasRuntimeDefault: false;
3373
- enumValues: undefined;
3374
- baseColumn: never;
3375
- identity: undefined;
3376
- generated: undefined;
3377
- }, {}, {}>;
3378
- }, {
3379
- imageUrl: z.ZodNullable<z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>>;
3380
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3381
- }>;
3382
- declare const UpdateItemSchema: z.ZodObject<Omit<{
3383
- id: z.ZodOptional<z.ZodString>;
3384
- slug: z.ZodOptional<z.ZodString>;
3385
- gameId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3386
- displayName: z.ZodOptional<z.ZodString>;
3387
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3388
- type: z.ZodOptional<z.ZodEnum<["currency", "badge", "trophy", "collectible", "consumable", "unlock", "upgrade", "accessory", "other"]>>;
3389
- isPlaceable: z.ZodOptional<z.ZodBoolean>;
3390
- imageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3391
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3392
- createdAt: z.ZodOptional<z.ZodDate>;
3393
- }, "id" | "createdAt">, "strip", z.ZodTypeAny, {
3394
- slug?: string | undefined;
3395
- description?: string | null | undefined;
3396
- displayName?: string | undefined;
3397
- metadata?: Record<string, unknown> | undefined;
3398
- gameId?: string | null | undefined;
3399
- type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3400
- isPlaceable?: boolean | undefined;
3401
- imageUrl?: string | null | undefined;
3402
- }, {
3403
- slug?: string | undefined;
3404
- description?: string | null | undefined;
3405
- displayName?: string | undefined;
3406
- metadata?: Record<string, unknown> | undefined;
3407
- gameId?: string | null | undefined;
3408
- type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3409
- isPlaceable?: boolean | undefined;
3410
- imageUrl?: string | null | undefined;
3411
- }>;
3412
- declare const InsertCurrencySchema: z.ZodObject<Omit<{
3413
- id: z.ZodOptional<z.ZodString>;
3414
- itemId: z.ZodString;
3415
- symbol: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3416
- isPrimary: z.ZodDefault<z.ZodBoolean>;
3417
- createdAt: z.ZodOptional<z.ZodDate>;
3418
- updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3419
- }, "id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
3420
- itemId: string;
3421
- isPrimary: boolean;
3422
- symbol?: string | null | undefined;
3423
- }, {
3424
- itemId: string;
3425
- symbol?: string | null | undefined;
3426
- isPrimary?: boolean | undefined;
3427
- }>;
3428
- declare const UpdateCurrencySchema: z.ZodObject<{
3429
- symbol: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3430
- itemId: z.ZodOptional<z.ZodString>;
3431
- isPrimary: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
3432
- }, "strip", z.ZodTypeAny, {
3433
- symbol?: string | null | undefined;
3434
- itemId?: string | undefined;
3435
- isPrimary?: boolean | undefined;
3436
- }, {
3437
- symbol?: string | null | undefined;
3438
- itemId?: string | undefined;
3439
- isPrimary?: boolean | undefined;
3440
- }>;
3441
- declare const InsertShopListingSchema: z.ZodObject<Omit<{
3442
- id: z.ZodOptional<z.ZodString>;
3443
- itemId: z.ZodString;
3444
- currencyId: z.ZodString;
3445
- price: z.ZodNumber;
3446
- sellBackPercentage: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
3447
- stock: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
3448
- isActive: z.ZodDefault<z.ZodBoolean>;
3449
- availableFrom: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3450
- availableUntil: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3451
- createdAt: z.ZodOptional<z.ZodDate>;
3452
- updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
3453
- }, "id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
3454
- isActive: boolean;
3455
- itemId: string;
3456
- currencyId: string;
3457
- price: number;
3458
- sellBackPercentage?: number | null | undefined;
3459
- stock?: number | null | undefined;
3460
- availableFrom?: Date | null | undefined;
3461
- availableUntil?: Date | null | undefined;
3462
- }, {
3463
- itemId: string;
3464
- currencyId: string;
3465
- price: number;
3466
- isActive?: boolean | undefined;
3467
- sellBackPercentage?: number | null | undefined;
3468
- stock?: number | null | undefined;
3469
- availableFrom?: Date | null | undefined;
3470
- availableUntil?: Date | null | undefined;
3471
- }>;
3472
- declare const UpdateShopListingSchema: z.ZodObject<{
3473
- isActive: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
3474
- itemId: z.ZodOptional<z.ZodString>;
3475
- currencyId: z.ZodOptional<z.ZodString>;
3476
- price: z.ZodOptional<z.ZodNumber>;
3477
- sellBackPercentage: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
3478
- stock: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
3479
- availableFrom: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodDate>>>;
3480
- availableUntil: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodDate>>>;
3481
- }, "strip", z.ZodTypeAny, {
3482
- isActive?: boolean | undefined;
3483
- itemId?: string | undefined;
3484
- currencyId?: string | undefined;
3485
- price?: number | undefined;
3486
- sellBackPercentage?: number | null | undefined;
3487
- stock?: number | null | undefined;
3488
- availableFrom?: Date | null | undefined;
3489
- availableUntil?: Date | null | undefined;
3490
- }, {
3491
- isActive?: boolean | undefined;
3492
- itemId?: string | undefined;
3493
- currencyId?: string | undefined;
3494
- price?: number | undefined;
3495
- sellBackPercentage?: number | null | undefined;
3496
- stock?: number | null | undefined;
3497
- availableFrom?: Date | null | undefined;
3498
- availableUntil?: Date | null | undefined;
3499
- }>;
3500
2537
 
3501
2538
  declare enum AchievementCompletionType {
3502
2539
  TIME_PLAYED_SESSION = "time_played_session",
@@ -3528,17 +2565,6 @@ interface AchievementCurrent {
3528
2565
  windowStart: string;
3529
2566
  windowEnd: string;
3530
2567
  }
3531
- /**
3532
- * Achievement claim history entry
3533
- * Used in GET /api/achievements/history
3534
- */
3535
- interface AchievementHistoryEntry {
3536
- achievementId: string;
3537
- title: string;
3538
- rewardCredits: number;
3539
- createdAt: string;
3540
- scopeKey: string;
3541
- }
3542
2568
  /**
3543
2569
  * Achievement progress submission response
3544
2570
  * Used in POST /api/achievements/progress
@@ -3551,30 +2577,6 @@ interface AchievementProgressResponse {
3551
2577
  createdAt: string;
3552
2578
  }
3553
2579
 
3554
- declare enum NotificationType {
3555
- ACHIEVEMENT = "achievement",
3556
- SYSTEM = "system",
3557
- PROMO = "promo"
3558
- }
3559
- declare enum NotificationStatus {
3560
- PENDING = "pending",
3561
- DELIVERED = "delivered",
3562
- SEEN = "seen",
3563
- CLICKED = "clicked",
3564
- DISMISSED = "dismissed",
3565
- EXPIRED = "expired"
3566
- }
3567
- type Notification = InferSelectModel<typeof notifications>;
3568
- interface NotificationStats {
3569
- total: number;
3570
- delivered: number;
3571
- seen: number;
3572
- clicked: number;
3573
- dismissed: number;
3574
- expired: number;
3575
- clickThroughRate: number;
3576
- }
3577
-
3578
2580
  type CharacterComponent = typeof characterComponents.$inferSelect;
3579
2581
  type PlayerCharacter = typeof playerCharacters.$inferSelect & {
3580
2582
  accessories?: PlayerCharacterAccessory[];
@@ -3595,18 +2597,9 @@ type ExternalGame = BaseGame & {
3595
2597
  type Game = HostedGame | ExternalGame;
3596
2598
  type GameSession = typeof gameSessions.$inferSelect;
3597
2599
  type GameStateData = Record<string, unknown>;
3598
- type GameCustomHostname = typeof gameCustomHostnames.$inferSelect;
3599
- type UpsertGameMetadataInput = z.infer<typeof UpsertGameMetadataSchema>;
3600
2600
  type Item = typeof items.$inferSelect;
3601
2601
  type InventoryItem = typeof inventoryItems.$inferSelect;
3602
2602
  type Currency = typeof currencies.$inferSelect;
3603
- type ShopListing = typeof shopListings.$inferSelect;
3604
- type InsertItemInput = z.infer<typeof InsertItemSchema>;
3605
- type UpdateItemInput = z.infer<typeof UpdateItemSchema>;
3606
- type InsertCurrencyInput = z.infer<typeof InsertCurrencySchema>;
3607
- type UpdateCurrencyInput = z.infer<typeof UpdateCurrencySchema>;
3608
- type InsertShopListingInput = z.infer<typeof InsertShopListingSchema>;
3609
- type UpdateShopListingInput = z.infer<typeof UpdateShopListingSchema>;
3610
2603
  interface PlaceableItemMetadata {
3611
2604
  tilesWide?: number;
3612
2605
  tilesHigh?: number;
@@ -3616,28 +2609,10 @@ interface PlaceableItemMetadata {
3616
2609
  type Map = typeof maps.$inferSelect;
3617
2610
  type MapElement = typeof mapElements.$inferSelect;
3618
2611
  type MapObject = typeof mapObjects.$inferSelect;
3619
- interface MapData {
3620
- id: string;
3621
- identifier: string;
3622
- displayName: string;
3623
- description?: string;
3624
- metadata?: Record<string, unknown>;
3625
- }
3626
- interface CreateMapObjectData {
3627
- itemId: string;
3628
- worldX: number;
3629
- worldY: number;
3630
- width?: number;
3631
- height?: number;
3632
- rotation?: number;
3633
- scale?: number;
3634
- metadata?: Record<string, unknown>;
3635
- }
3636
2612
 
3637
2613
  type User = typeof users.$inferSelect;
3638
2614
  type UserRoleEnumType = (typeof userRoleEnum.enumValues)[number];
3639
2615
  type DeveloperStatusResponse = z.infer<typeof DeveloperStatusResponseSchema>;
3640
- type DeveloperStatusValue = DeveloperStatusResponse['status'];
3641
2616
  /**
3642
2617
  * User data with authentication provider information.
3643
2618
  * Returned by the /users/me endpoint with additional auth context.
@@ -3749,12 +2724,6 @@ type UserLevelWithConfig = UserLevel & {
3749
2724
  xpToNextLevel: number;
3750
2725
  nextLevelConfig?: LevelConfig;
3751
2726
  };
3752
- interface LeaderboardOptions {
3753
- timeframe?: 'all_time' | 'monthly' | 'weekly' | 'daily';
3754
- limit?: number;
3755
- offset?: number;
3756
- gameId?: string;
3757
- }
3758
2727
  interface LeaderboardEntry {
3759
2728
  rank: number;
3760
2729
  userId: string;
@@ -3778,15 +2747,6 @@ interface UserRankResponse {
3778
2747
  score: number;
3779
2748
  userId: string;
3780
2749
  }
3781
- interface UserScore$1 {
3782
- id: string;
3783
- score: number;
3784
- achievedAt: Date;
3785
- metadata?: Record<string, unknown>;
3786
- gameId: string;
3787
- gameTitle: string;
3788
- gameSlug: string;
3789
- }
3790
2750
 
3791
2751
  type SpriteTemplate = typeof spriteTemplates.$inferSelect;
3792
2752
  interface SpriteTemplateData {
@@ -3934,379 +2894,194 @@ type TimebackSetupRequest = {
3934
2894
  };
3935
2895
  verbose?: boolean;
3936
2896
  };
3937
- type TimebackSetupResponse = {
3938
- integration: GameTimebackIntegration;
3939
- courseId: string;
3940
- verbose?: {
3941
- course: unknown;
3942
- component: unknown;
3943
- resource: unknown;
3944
- componentResource: unknown;
3945
- };
2897
+ /**
2898
+ * Minimal course configuration for TimeBack integration (used in user-facing config).
2899
+ *
2900
+ * NOTE: Per-course overrides (title, courseCode, level, metadata) are defined
2901
+ * in @playcademy/sdk/server as TimebackCourseConfigWithOverrides.
2902
+ * This base type only includes the minimal required fields.
2903
+ *
2904
+ * For totalXp, use metadata.metrics.totalXp (aligns with upstream TimeBack structure).
2905
+ */
2906
+ type TimebackCourseConfig = {
2907
+ subject: string;
2908
+ grade: number;
3946
2909
  };
3947
- type TimebackVerifyResponse = {
3948
- status: 'success' | 'error';
3949
- integration: GameTimebackIntegration;
3950
- resources: {
3951
- course: {
3952
- found: boolean;
3953
- data?: unknown;
2910
+ /**
2911
+ * Derived course configuration after merging base + per-course overrides + templating.
2912
+ * This is what the CLI sends to the Platform API in PlatformTimebackSetupRequest.
2913
+ */
2914
+ type DerivedPlatformCourseConfig = TimebackCourseConfig & {
2915
+ title: string;
2916
+ courseCode: string;
2917
+ level: string;
2918
+ metadata?: Record<string, unknown>;
2919
+ totalXp?: number | null;
2920
+ masterableUnits?: number | null;
2921
+ };
2922
+ type PlatformTimebackSetupRequest = {
2923
+ gameId: string;
2924
+ courses: DerivedPlatformCourseConfig[];
2925
+ baseConfig: {
2926
+ organization: {
2927
+ name: string;
2928
+ type: string;
2929
+ identifier: string;
3954
2930
  };
3955
2931
  component: {
3956
- found: boolean;
3957
- data?: unknown;
2932
+ title: string;
2933
+ titleSuffix?: string;
2934
+ sortOrder: number;
2935
+ prerequisites: string[];
2936
+ prerequisiteCriteria: string;
3958
2937
  };
3959
2938
  resource: {
3960
- found: boolean;
3961
- data?: unknown;
2939
+ title: string;
2940
+ titleSuffix?: string;
2941
+ vendorResourceId: string;
2942
+ vendorId: string;
2943
+ applicationId: string;
2944
+ roles: string[];
2945
+ importance: string;
2946
+ metadata: {
2947
+ type?: string;
2948
+ launchUrl?: string;
2949
+ toolProvider?: string;
2950
+ instructionalMethod?: string;
2951
+ language?: string;
2952
+ [key: string]: unknown;
2953
+ };
3962
2954
  };
3963
2955
  componentResource: {
3964
- found: boolean;
3965
- data?: unknown;
2956
+ title: string;
2957
+ titleSuffix?: string;
2958
+ sortOrder: number;
2959
+ lessonType: string | null;
2960
+ };
2961
+ };
2962
+ verbose?: boolean;
2963
+ };
2964
+ type PlatformTimebackSetupResponse = {
2965
+ integrations: GameTimebackIntegration[];
2966
+ verbose?: Array<{
2967
+ integration: GameTimebackIntegration;
2968
+ config: {
2969
+ course: unknown;
2970
+ component: unknown;
2971
+ resource: unknown;
2972
+ componentResource: unknown;
3966
2973
  };
2974
+ }>;
2975
+ };
2976
+ type TimebackVerificationResources = {
2977
+ course: {
2978
+ found: boolean;
2979
+ data?: unknown;
3967
2980
  };
2981
+ component: {
2982
+ found: boolean;
2983
+ data?: unknown;
2984
+ };
2985
+ resource: {
2986
+ found: boolean;
2987
+ data?: unknown;
2988
+ };
2989
+ componentResource: {
2990
+ found: boolean;
2991
+ data?: unknown;
2992
+ };
2993
+ };
2994
+ type TimebackVerifyCourseResult = {
2995
+ integration: GameTimebackIntegration;
2996
+ resources: TimebackVerificationResources;
2997
+ status: 'success' | 'error';
3968
2998
  errors?: string[];
3969
2999
  };
3000
+ type TimebackVerifyAllResponse = {
3001
+ status: 'success' | 'error';
3002
+ results: TimebackVerifyCourseResult[];
3003
+ };
3970
3004
  type EndActivityResponse = {
3971
3005
  status: 'ok';
3972
3006
  courseId: string;
3973
3007
  xpAwarded: number;
3008
+ masteredUnits?: number;
3009
+ pctCompleteApp?: number;
3010
+ scoreStatus?: string;
3011
+ inProgress?: string;
3974
3012
  };
3975
3013
 
3976
- /**
3977
- * OAuth 2.0 implementation for the Playcademy SDK
3978
- */
3979
-
3980
- /**
3981
- * Parses an OAuth state parameter to extract CSRF token and any encoded data.
3982
- *
3983
- * @param state - The OAuth state parameter to parse
3984
- * @returns Object containing CSRF token and optional decoded data
3985
- */
3986
- declare function parseOAuthState(state: string): {
3987
- csrfToken: string;
3988
- data?: Record<string, string>;
3989
- };
3990
-
3991
- /**
3992
- * Response type for the realtime token API
3993
- */
3994
- interface RealtimeTokenResponse {
3995
- token: string;
3996
- }
3997
-
3998
- /**
3999
- * Cache configuration types for runtime customization
4000
- */
4001
- /**
4002
- * Runtime configuration for TTL cache behavior
4003
- */
4004
- interface TTLCacheConfig {
4005
- /** Time-to-live in milliseconds. Set to 0 to disable caching for this call. */
4006
- ttl?: number;
4007
- /** Force refresh, bypassing cache */
4008
- force?: boolean;
4009
- /** Skip cache and fetch fresh data (alias for force) */
4010
- skipCache?: boolean;
4011
- }
4012
- /**
4013
- * Runtime configuration for cooldown cache behavior
4014
- */
4015
- interface CooldownCacheConfig {
4016
- /** Cooldown period in milliseconds. Set to 0 to disable cooldown for this call. */
4017
- cooldown?: number;
4018
- /** Force refresh, bypassing cooldown */
4019
- force?: boolean;
4020
- }
4021
-
4022
- interface CharacterComponentsOptions {
4023
- /**
4024
- * Optional level filter for components
4025
- * When provided, only components available at this level or below are returned
4026
- */
4027
- level?: number;
4028
- /**
4029
- * Whether to bypass the cache and force a fresh API request
4030
- * Default: false (use cache when available)
4031
- */
4032
- skipCache?: boolean;
4033
- }
4034
- interface CreateCharacterData {
4035
- bodyComponentId: string;
4036
- eyesComponentId: string;
4037
- hairstyleComponentId: string;
4038
- outfitComponentId: string;
4039
- }
4040
- interface UpdateCharacterData {
4041
- bodyComponentId?: string;
4042
- eyesComponentId?: string;
4043
- hairstyleComponentId?: string;
4044
- outfitComponentId?: string;
4045
- }
4046
-
4047
- interface ScoreSubmission {
4048
- id: string;
4049
- score: number;
4050
- achievedAt: Date;
4051
- }
4052
-
4053
3014
  /**
4054
3015
  * Combined response type for summary method
4055
3016
  */
4056
- type XpSummaryResponse = {
3017
+ type XpSummaryResponse$1 = {
4057
3018
  today: TodayXpResponse;
4058
3019
  total: TotalXpResponse;
4059
3020
  };
4060
3021
 
4061
3022
  /**
4062
- * @fileoverview Server SDK Type Definitions
3023
+ * Connection monitoring types
4063
3024
  *
4064
- * TypeScript type definitions for the server-side Playcademy SDK.
4065
- * Includes configuration types, client state, and re-exported TimeBack types.
4066
- */
4067
-
4068
- /**
4069
- * TimeBack integration configuration for Playcademy config file
4070
- */
4071
- interface TimebackIntegrationConfig {
4072
- /** Organization overrides */
4073
- organization?: Partial<OrganizationConfig>;
4074
- /** Course configuration (subjects and grades REQUIRED) */
4075
- course: CourseConfig;
4076
- /** Component overrides */
4077
- component?: Partial<ComponentConfig>;
4078
- /** Resource overrides */
4079
- resource?: Partial<ResourceConfig>;
4080
- /** Component-Resource link overrides */
4081
- componentResource?: Partial<ComponentResourceConfig>;
4082
- }
4083
- /**
4084
- * Custom API routes integration
4085
- */
4086
- interface CustomRoutesIntegration {
4087
- /** Directory for custom API routes (defaults to 'server/api') */
4088
- directory?: string;
4089
- }
4090
- /**
4091
- * Database integration
3025
+ * Type definitions for connection state, configuration, and callbacks.
4092
3026
  */
4093
- interface DatabaseIntegration {
4094
- /** Database directory (defaults to 'db') */
4095
- directory?: string;
4096
- }
4097
3027
  /**
4098
- * Integrations configuration
4099
- * All backend features (database, custom routes, external services) are configured here
3028
+ * Possible connection states.
3029
+ *
3030
+ * - **online**: Connection is stable and healthy
3031
+ * - **offline**: Complete loss of network connectivity
3032
+ * - **degraded**: Connection is slow or experiencing intermittent issues
4100
3033
  */
4101
- interface IntegrationsConfig {
4102
- /** TimeBack integration (optional) */
4103
- timeback?: TimebackIntegrationConfig;
4104
- /** Custom API routes (optional) */
4105
- customRoutes?: CustomRoutesIntegration | boolean;
4106
- /** Database (optional) */
4107
- database?: DatabaseIntegration | boolean;
4108
- /** Key-Value storage (optional) */
4109
- kv?: boolean;
4110
- /** Bucket storage (optional) */
4111
- bucket?: boolean;
4112
- /** Authentication (optional) */
4113
- auth?: boolean;
4114
- }
3034
+ type ConnectionState = 'online' | 'offline' | 'degraded';
3035
+
4115
3036
  /**
4116
- * Unified Playcademy configuration
4117
- * Used for playcademy.config.{js,json}
3037
+ * @fileoverview Playcademy Messaging System
3038
+ *
3039
+ * This file implements a unified messaging system for the Playcademy platform that handles
3040
+ * communication between different contexts:
3041
+ *
3042
+ * 1. **Iframe-to-Parent Communication**: When games run inside iframes (production/development),
3043
+ * they need to communicate with the parent window using postMessage API
3044
+ *
3045
+ * 2. **Local Communication**: When games run in the same context (local development),
3046
+ * they use CustomEvents for internal messaging
3047
+ *
3048
+ * The system automatically detects the runtime environment and chooses the appropriate
3049
+ * transport method, abstracting this complexity from the developer.
3050
+ *
3051
+ * **Architecture Overview**:
3052
+ * - Games run in iframes for security and isolation
3053
+ * - Parent window (Playcademy shell) manages game lifecycle
3054
+ * - Messages flow bidirectionally between parent and iframe
3055
+ * - Local development mode simulates this architecture without iframes
4118
3056
  */
4119
- interface PlaycademyConfig {
4120
- /** Game name */
4121
- name: string;
4122
- /** Game description */
4123
- description?: string;
4124
- /** Game emoji icon */
4125
- emoji?: string;
4126
- /** Build command to run before deployment */
4127
- buildCommand?: string[];
4128
- /** Path to build output */
4129
- buildPath?: string;
4130
- /** Game type */
4131
- gameType?: 'hosted' | 'external';
4132
- /** External URL (for external games) */
4133
- externalUrl?: string;
4134
- /** Game platform */
4135
- platform?: 'web' | 'unity' | 'godot';
4136
- /** Integrations (database, custom routes, external services) */
4137
- integrations?: IntegrationsConfig;
4138
- }
4139
3057
 
4140
3058
  /**
4141
- * Configuration options for initializing a PlaycademyClient instance.
3059
+ * Enumeration of all message types used in the Playcademy messaging system.
4142
3060
  *
4143
- * @example
4144
- * ```typescript
4145
- * const config: PlaycademyServerClientConfig = {
4146
- * apiKey: process.env.PLAYCADEMY_API_KEY!,
4147
- * gameId: 'my-math-game',
4148
- * configPath: './playcademy.config.js'
4149
- * }
4150
- * ```
3061
+ * **Message Flow Patterns**:
3062
+ *
3063
+ * **Parent Game (Overworld → Game)**:
3064
+ * - INIT: Provides game with authentication token and configuration
3065
+ * - TOKEN_REFRESH: Updates game's authentication token before expiry
3066
+ * - PAUSE/RESUME: Controls game execution state
3067
+ * - FORCE_EXIT: Immediately terminates the game
3068
+ * - OVERLAY: Shows/hides UI overlays over the game
3069
+ *
3070
+ * **Game → Parent (Game → Overworld)**:
3071
+ * - READY: Game has loaded and is ready to receive messages
3072
+ * - EXIT: Game requests to be closed (user clicked exit, game ended, etc.)
3073
+ * - TELEMETRY: Game reports performance metrics (FPS, memory usage, etc.)
4151
3074
  */
4152
- interface PlaycademyServerClientConfig {
3075
+ declare enum MessageEvents {
4153
3076
  /**
4154
- * Playcademy API key for server-to-server authentication.
4155
- * Obtain from the Playcademy developer dashboard.
3077
+ * Initializes the game with authentication context and configuration.
3078
+ * Sent immediately after game iframe loads.
3079
+ * Payload:
3080
+ * - `baseUrl`: string
3081
+ * - `token`: string
3082
+ * - `gameId`: string
4156
3083
  */
4157
- apiKey: string;
4158
- /**
4159
- * Optional path to playcademy.config.js file.
4160
- * If not provided, searches current directory and up to 3 parent directories.
4161
- * Ignored if `config` is provided directly.
4162
- *
4163
- * @example './config/playcademy.config.js'
4164
- */
4165
- configPath?: string;
4166
- /**
4167
- * Optional config object (for edge environments without filesystem).
4168
- * If provided, skips filesystem-based config loading.
4169
- *
4170
- * @example { name: 'My Game', integrations: { timeback: {...} } }
4171
- */
4172
- config?: PlaycademyConfig;
4173
- /**
4174
- * Optional base URL for Playcademy API.
4175
- * Defaults to environment variables or 'https://hub.playcademy.net'.
4176
- *
4177
- * @example 'http://localhost:3000' for local development
4178
- */
4179
- baseUrl?: string;
4180
- /**
4181
- * Optional game ID.
4182
- * If not provided, will attempt to fetch from API using the API token.
4183
- *
4184
- * @example 'my-math-game'
4185
- */
4186
- gameId?: string;
4187
- }
4188
- /**
4189
- * Internal state maintained by the PlaycademyClient instance.
4190
- *
4191
- * @internal
4192
- */
4193
- interface PlaycademyServerClientState {
4194
- /** API key for authentication */
4195
- apiKey: string;
4196
- /** Base URL for API requests */
4197
- baseUrl: string;
4198
- /** Game identifier */
4199
- gameId: string;
4200
- /** Loaded game configuration from playcademy.config.js */
4201
- config: PlaycademyConfig;
4202
- /**
4203
- * TimeBack course ID fetched from the Playcademy API.
4204
- * Used for all TimeBack event recording.
4205
- */
4206
- courseId?: string;
4207
- }
4208
-
4209
- /**
4210
- * Resource bindings for backend deployment
4211
- * Provider-agnostic abstraction for cloud resources
4212
- */
4213
- interface BackendResourceBindings {
4214
- /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
4215
- database?: string[];
4216
- /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
4217
- keyValue?: string[];
4218
- /** Object storage buckets to bind (maps to R2 on Cloudflare) */
4219
- bucket?: string[];
4220
- }
4221
- /**
4222
- * Backend deployment bundle for uploading to Playcademy platform
4223
- */
4224
- interface BackendDeploymentBundle {
4225
- /** Bundled JavaScript code ready for deployment */
4226
- code: string;
4227
- /** Game configuration */
4228
- config: PlaycademyConfig;
4229
- /** Optional resource bindings (database, storage, etc.) */
4230
- bindings?: BackendResourceBindings;
4231
- /** Optional schema information for database setup */
4232
- schema?: SchemaInfo;
4233
- /** Optional game secrets */
4234
- secrets?: Record<string, string>;
4235
- }
4236
-
4237
- interface UserScore {
4238
- id: string;
4239
- score: number;
4240
- achievedAt: Date;
4241
- metadata?: Record<string, unknown>;
4242
- gameId: string;
4243
- gameTitle: string;
4244
- gameSlug: string;
4245
- }
4246
-
4247
- /**
4248
- * Connection monitoring types
4249
- *
4250
- * Type definitions for connection state, configuration, and callbacks.
4251
- */
4252
- /**
4253
- * Possible connection states.
4254
- *
4255
- * - **online**: Connection is stable and healthy
4256
- * - **offline**: Complete loss of network connectivity
4257
- * - **degraded**: Connection is slow or experiencing intermittent issues
4258
- */
4259
- type ConnectionState = 'online' | 'offline' | 'degraded';
4260
-
4261
- /**
4262
- * @fileoverview Playcademy Messaging System
4263
- *
4264
- * This file implements a unified messaging system for the Playcademy platform that handles
4265
- * communication between different contexts:
4266
- *
4267
- * 1. **Iframe-to-Parent Communication**: When games run inside iframes (production/development),
4268
- * they need to communicate with the parent window using postMessage API
4269
- *
4270
- * 2. **Local Communication**: When games run in the same context (local development),
4271
- * they use CustomEvents for internal messaging
4272
- *
4273
- * The system automatically detects the runtime environment and chooses the appropriate
4274
- * transport method, abstracting this complexity from the developer.
4275
- *
4276
- * **Architecture Overview**:
4277
- * - Games run in iframes for security and isolation
4278
- * - Parent window (Playcademy shell) manages game lifecycle
4279
- * - Messages flow bidirectionally between parent and iframe
4280
- * - Local development mode simulates this architecture without iframes
4281
- */
4282
-
4283
- /**
4284
- * Enumeration of all message types used in the Playcademy messaging system.
4285
- *
4286
- * **Message Flow Patterns**:
4287
- *
4288
- * **Parent → Game (Overworld → Game)**:
4289
- * - INIT: Provides game with authentication token and configuration
4290
- * - TOKEN_REFRESH: Updates game's authentication token before expiry
4291
- * - PAUSE/RESUME: Controls game execution state
4292
- * - FORCE_EXIT: Immediately terminates the game
4293
- * - OVERLAY: Shows/hides UI overlays over the game
4294
- *
4295
- * **Game → Parent (Game → Overworld)**:
4296
- * - READY: Game has loaded and is ready to receive messages
4297
- * - EXIT: Game requests to be closed (user clicked exit, game ended, etc.)
4298
- * - TELEMETRY: Game reports performance metrics (FPS, memory usage, etc.)
4299
- */
4300
- declare enum MessageEvents {
4301
- /**
4302
- * Initializes the game with authentication context and configuration.
4303
- * Sent immediately after game iframe loads.
4304
- * Payload:
4305
- * - `baseUrl`: string
4306
- * - `token`: string
4307
- * - `gameId`: string
4308
- */
4309
- INIT = "PLAYCADEMY_INIT",
3084
+ INIT = "PLAYCADEMY_INIT",
4310
3085
  /**
4311
3086
  * Updates the game's authentication token before it expires.
4312
3087
  * Sent periodically to maintain valid authentication.
@@ -4381,7 +3156,7 @@ declare enum MessageEvents {
4381
3156
  * Sent when connection issues are detected or other important events occur.
4382
3157
  * Payload:
4383
3158
  * - `message`: string
4384
- * - `options`: { type?: 'info' | 'warning' | 'error', duration?: number }
3159
+ * - `options`: `{ type?: 'info' | 'warning' | 'error', duration?: number }`
4385
3160
  */
4386
3161
  DISPLAY_ALERT = "PLAYCADEMY_DISPLAY_ALERT",
4387
3162
  /**
@@ -4428,12 +3203,12 @@ declare enum MessageEvents {
4428
3203
  * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
4429
3204
  * ```
4430
3205
  */
4431
- declare function init(options?: {
3206
+ declare function init<T extends PlaycademyClient = PlaycademyClient>(this: new (...args: ConstructorParameters<typeof PlaycademyClient>) => T, options?: {
4432
3207
  baseUrl?: string;
4433
3208
  allowedParentOrigins?: string[];
4434
3209
  onDisconnect?: DisconnectHandler;
4435
3210
  enableConnectionMonitoring?: boolean;
4436
- }): Promise<PlaycademyClient>;
3211
+ }): Promise<T>;
4437
3212
 
4438
3213
  /**
4439
3214
  * Authenticates a user with email and password.
@@ -4487,6 +3262,17 @@ declare class PlaycademyClient {
4487
3262
  private authContext?;
4488
3263
  private initPayload?;
4489
3264
  private connectionManager?;
3265
+ /**
3266
+ * Internal session manager for automatic session lifecycle.
3267
+ *
3268
+ * This manager handles starting and ending game sessions automatically.
3269
+ * Game developers don't need to call these methods directly - they're managed
3270
+ * by the SDK during initialization and cleanup.
3271
+ *
3272
+ * @private
3273
+ * @internal
3274
+ */
3275
+ private _sessionManager;
4490
3276
  /**
4491
3277
  * Creates a new PlaycademyClient instance.
4492
3278
  *
@@ -4608,7 +3394,7 @@ declare class PlaycademyClient {
4608
3394
  * // Later: cleanup() to unregister
4609
3395
  * ```
4610
3396
  *
4611
- * @see {@link DISCONNECT_HANDLING.md} for detailed usage examples
3397
+ * @see Connection monitoring documentation in SDK Browser docs for detailed usage examples
4612
3398
  * @see {@link ConnectionManager.onDisconnect} for the underlying implementation
4613
3399
  */
4614
3400
  onDisconnect(callback: (context: DisconnectContext) => void | Promise<void>): () => void;
@@ -4732,32 +3518,6 @@ declare class PlaycademyClient {
4732
3518
  * 3. autoStartSession is enabled (defaults to false)
4733
3519
  */
4734
3520
  private _initializeInternalSession;
4735
- /** Platform API authentication methods (login, logout) */
4736
- auth: {
4737
- login: (credentials: {
4738
- email: string;
4739
- password: string;
4740
- }) => Promise<{
4741
- success: boolean;
4742
- token?: string;
4743
- user?: {
4744
- id: string;
4745
- email: string;
4746
- };
4747
- expiresAt?: string;
4748
- error?: string;
4749
- }>;
4750
- logout: () => Promise<void>;
4751
- apiKeys: {
4752
- create: (options?: {
4753
- name?: string;
4754
- expiresIn?: number | null;
4755
- permissions?: Record<string, string[]>;
4756
- }) => Promise<BetterAuthApiKeyResponse>;
4757
- list: () => Promise<BetterAuthApiKey[]>;
4758
- revoke: (keyId: string) => Promise<void>;
4759
- };
4760
- };
4761
3521
  /** Identity provider connection methods (connect external accounts) */
4762
3522
  identity: {
4763
3523
  connect: (options: AuthOptions) => Promise<AuthResult>;
@@ -4800,26 +3560,6 @@ declare class PlaycademyClient {
4800
3560
  arrayBuffer: (path: string) => Promise<ArrayBuffer>;
4801
3561
  };
4802
3562
  };
4803
- /** Game management methods (fetch, list, saveState, loadState, sessions) */
4804
- games: {
4805
- fetch: (gameIdOrSlug: string, options?: TTLCacheConfig) => Promise<FetchedGame>;
4806
- list: (options?: TTLCacheConfig) => Promise<Array<Game>>;
4807
- saveState: (state: Record<string, unknown>) => Promise<void>;
4808
- loadState: () => Promise<GameStateData>;
4809
- startSession: (gameId?: string) => Promise<StartSessionResponse>;
4810
- endSession: (sessionId: string, gameId?: string) => Promise<void>;
4811
- token: {
4812
- create: (gameId: string, options?: {
4813
- apply?: boolean;
4814
- }) => Promise<GameTokenResponse>;
4815
- };
4816
- leaderboard: {
4817
- get: (gameId: string, options?: {
4818
- limit?: number;
4819
- offset?: number;
4820
- }) => Promise<LeaderboardEntry[]>;
4821
- };
4822
- };
4823
3563
  /** User methods (me, inventory management) */
4824
3564
  users: {
4825
3565
  me: () => Promise<AuthenticatedUser>;
@@ -4830,258 +3570,6 @@ declare class PlaycademyClient {
4830
3570
  quantity: (identifier: string) => Promise<number>;
4831
3571
  has: (identifier: string, minQuantity?: number) => Promise<boolean>;
4832
3572
  };
4833
- scores: {
4834
- get: (userIdOrOptions?: string | {
4835
- limit?: number;
4836
- gameId?: string;
4837
- }, options?: {
4838
- limit?: number;
4839
- gameId?: string;
4840
- }) => Promise<UserScore[]>;
4841
- };
4842
- };
4843
- /** Developer tools (auth, games, keys management) */
4844
- dev: {
4845
- status: {
4846
- apply: () => Promise<void>;
4847
- get: () => Promise<DeveloperStatusValue>;
4848
- };
4849
- games: {
4850
- deploy: (slug: string, options: {
4851
- metadata?: UpsertGameMetadataInput;
4852
- file?: File | Blob | null;
4853
- backend?: BackendDeploymentBundle;
4854
- hooks?: DevUploadHooks;
4855
- }) => Promise<Game>;
4856
- seed: (slug: string, code: string, environment?: "staging" | "production") => Promise<{
4857
- success: boolean;
4858
- deploymentId: string;
4859
- executedAt: string;
4860
- }>;
4861
- upsert: (slug: string, metadata: UpsertGameMetadataInput) => Promise<Game>;
4862
- delete: (gameId: string) => Promise<void>;
4863
- secrets: {
4864
- set: (slug: string, secrets: Record<string, string>) => Promise<string[]>;
4865
- list: (slug: string) => Promise<string[]>;
4866
- get: (slug: string) => Promise<Record<string, string>>;
4867
- delete: (slug: string, key: string) => Promise<void>;
4868
- };
4869
- database: {
4870
- reset: (slug: string, schema?: {
4871
- sql: string;
4872
- hash: string;
4873
- }) => Promise<{
4874
- success: boolean;
4875
- deploymentId: string;
4876
- resetAt: string;
4877
- schemaPushed: boolean;
4878
- }>;
4879
- };
4880
- bucket: {
4881
- list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
4882
- get: (slug: string, key: string) => Promise<ArrayBuffer>;
4883
- put: (slug: string, key: string, content: Blob | ArrayBuffer | Uint8Array, contentType?: string) => Promise<void>;
4884
- delete: (slug: string, key: string) => Promise<void>;
4885
- };
4886
- domains: {
4887
- add: (slug: string, hostname: string) => Promise<GameCustomHostname>;
4888
- list: (slug: string) => Promise<GameCustomHostname[]>;
4889
- status: (slug: string, hostname: string, refresh?: boolean) => Promise<GameCustomHostname>;
4890
- delete: (slug: string, hostname: string) => Promise<void>;
4891
- };
4892
- };
4893
- items: {
4894
- create: (gameId: string, slug: string, itemData: Omit<InsertItemInput, "slug" | "gameId">) => Promise<Item>;
4895
- update: (gameId: string, itemId: string, updates: UpdateItemInput) => Promise<Item>;
4896
- list: (gameId: string) => Promise<Array<Item>>;
4897
- get: (gameId: string, slug: string) => Promise<Item>;
4898
- delete: (gameId: string, itemId: string) => Promise<void>;
4899
- shop: {
4900
- create: (gameId: string, itemId: string, listingData: Omit<InsertShopListingInput, "itemId">) => Promise<ShopListing>;
4901
- get: (gameId: string, itemId: string) => Promise<ShopListing | null>;
4902
- update: (gameId: string, itemId: string, updates: UpdateShopListingInput) => Promise<ShopListing>;
4903
- delete: (gameId: string, itemId: string) => Promise<void>;
4904
- list: (gameId: string) => Promise<Array<ShopListing & {
4905
- item: Item;
4906
- }>>;
4907
- };
4908
- };
4909
- };
4910
- /** Map methods (elements) */
4911
- maps: {
4912
- get: (identifier: string, options?: TTLCacheConfig) => Promise<MapData>;
4913
- elements: (mapId: string, options?: TTLCacheConfig) => Promise<MapElementWithGame[]>;
4914
- objects: {
4915
- list: (mapId: string) => Promise<MapObjectWithItem[]>;
4916
- create: (mapId: string, objectData: CreateMapObjectData) => Promise<MapObjectWithItem>;
4917
- delete: (mapId: string, objectId: string) => Promise<void>;
4918
- };
4919
- };
4920
- /** Admin methods (games, items, currencies, shop listings) */
4921
- admin: {
4922
- games: {
4923
- pauseGame: (gameId: string) => Promise<void>;
4924
- resumeGame: (gameId: string) => Promise<void>;
4925
- };
4926
- items: {
4927
- create: (props: InsertItemInput) => Promise<{
4928
- id: string;
4929
- createdAt: Date;
4930
- gameId: string | null;
4931
- slug: string;
4932
- displayName: string;
4933
- metadata: unknown;
4934
- description: string | null;
4935
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4936
- isPlaceable: boolean;
4937
- imageUrl: string | null;
4938
- }>;
4939
- get: (itemId: string) => Promise<{
4940
- id: string;
4941
- createdAt: Date;
4942
- gameId: string | null;
4943
- slug: string;
4944
- displayName: string;
4945
- metadata: unknown;
4946
- description: string | null;
4947
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4948
- isPlaceable: boolean;
4949
- imageUrl: string | null;
4950
- }>;
4951
- list: () => Promise<{
4952
- id: string;
4953
- createdAt: Date;
4954
- gameId: string | null;
4955
- slug: string;
4956
- displayName: string;
4957
- metadata: unknown;
4958
- description: string | null;
4959
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4960
- isPlaceable: boolean;
4961
- imageUrl: string | null;
4962
- }[]>;
4963
- update: (itemId: string, props: UpdateItemInput) => Promise<{
4964
- id: string;
4965
- createdAt: Date;
4966
- gameId: string | null;
4967
- slug: string;
4968
- displayName: string;
4969
- metadata: unknown;
4970
- description: string | null;
4971
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4972
- isPlaceable: boolean;
4973
- imageUrl: string | null;
4974
- }>;
4975
- delete: (itemId: string) => Promise<void>;
4976
- };
4977
- currencies: {
4978
- create: (props: InsertCurrencyInput) => Promise<{
4979
- symbol: string | null;
4980
- id: string;
4981
- createdAt: Date;
4982
- updatedAt: Date | null;
4983
- itemId: string;
4984
- isPrimary: boolean;
4985
- }>;
4986
- get: (currencyId: string) => Promise<{
4987
- symbol: string | null;
4988
- id: string;
4989
- createdAt: Date;
4990
- updatedAt: Date | null;
4991
- itemId: string;
4992
- isPrimary: boolean;
4993
- }>;
4994
- list: () => Promise<{
4995
- symbol: string | null;
4996
- id: string;
4997
- createdAt: Date;
4998
- updatedAt: Date | null;
4999
- itemId: string;
5000
- isPrimary: boolean;
5001
- }[]>;
5002
- update: (currencyId: string, props: UpdateCurrencyInput) => Promise<{
5003
- symbol: string | null;
5004
- id: string;
5005
- createdAt: Date;
5006
- updatedAt: Date | null;
5007
- itemId: string;
5008
- isPrimary: boolean;
5009
- }>;
5010
- delete: (currencyId: string) => Promise<void>;
5011
- };
5012
- shopListings: {
5013
- create: (props: InsertShopListingInput) => Promise<{
5014
- id: string;
5015
- createdAt: Date;
5016
- updatedAt: Date | null;
5017
- itemId: string;
5018
- currencyId: string;
5019
- price: number;
5020
- sellBackPercentage: number | null;
5021
- stock: number | null;
5022
- isActive: boolean;
5023
- availableFrom: Date | null;
5024
- availableUntil: Date | null;
5025
- }>;
5026
- get: (listingId: string) => Promise<{
5027
- id: string;
5028
- createdAt: Date;
5029
- updatedAt: Date | null;
5030
- itemId: string;
5031
- currencyId: string;
5032
- price: number;
5033
- sellBackPercentage: number | null;
5034
- stock: number | null;
5035
- isActive: boolean;
5036
- availableFrom: Date | null;
5037
- availableUntil: Date | null;
5038
- }>;
5039
- list: () => Promise<{
5040
- id: string;
5041
- createdAt: Date;
5042
- updatedAt: Date | null;
5043
- itemId: string;
5044
- currencyId: string;
5045
- price: number;
5046
- sellBackPercentage: number | null;
5047
- stock: number | null;
5048
- isActive: boolean;
5049
- availableFrom: Date | null;
5050
- availableUntil: Date | null;
5051
- }[]>;
5052
- update: (listingId: string, props: UpdateShopListingInput) => Promise<{
5053
- id: string;
5054
- createdAt: Date;
5055
- updatedAt: Date | null;
5056
- itemId: string;
5057
- currencyId: string;
5058
- price: number;
5059
- sellBackPercentage: number | null;
5060
- stock: number | null;
5061
- isActive: boolean;
5062
- availableFrom: Date | null;
5063
- availableUntil: Date | null;
5064
- }>;
5065
- delete: (listingId: string) => Promise<void>;
5066
- };
5067
- };
5068
- /** Shop methods (view) */
5069
- shop: {
5070
- view: () => Promise<ShopViewResponse>;
5071
- };
5072
- /** Level methods (levels) */
5073
- levels: {
5074
- get: () => Promise<UserLevel>;
5075
- progress: (options?: CooldownCacheConfig) => Promise<{
5076
- level: number;
5077
- currentXp: number;
5078
- xpToNextLevel: number;
5079
- totalXP: number;
5080
- }>;
5081
- config: {
5082
- list: () => Promise<LevelConfig[]>;
5083
- get: (level: number) => Promise<LevelConfig | null>;
5084
- };
5085
3573
  };
5086
3574
  /** TimeBack XP methods (today, total, history) */
5087
3575
  timeback: {
@@ -5090,10 +3578,10 @@ declare class PlaycademyClient {
5090
3578
  resumeActivity: () => void;
5091
3579
  endActivity: (data: _playcademy_timeback_types.EndActivityScoreData) => Promise<EndActivityResponse>;
5092
3580
  management: {
5093
- setup: (request: TimebackSetupRequest) => Promise<TimebackSetupResponse>;
5094
- verify: (gameId: string) => Promise<TimebackVerifyResponse>;
3581
+ setup: (request: PlatformTimebackSetupRequest) => Promise<PlatformTimebackSetupResponse>;
3582
+ verify: (gameId: string) => Promise<TimebackVerifyAllResponse>;
5095
3583
  cleanup: (gameId: string) => Promise<void>;
5096
- get: (gameId: string) => Promise<GameTimebackIntegration | null>;
3584
+ get: (gameId: string) => Promise<GameTimebackIntegration[]>;
5097
3585
  getConfig: (gameId: string) => Promise<TimebackSetupRequest["config"]>;
5098
3586
  };
5099
3587
  xp: {
@@ -5109,54 +3597,18 @@ declare class PlaycademyClient {
5109
3597
  summary: (options?: {
5110
3598
  date?: string;
5111
3599
  timezone?: string;
5112
- }) => Promise<XpSummaryResponse>;
3600
+ }) => Promise<XpSummaryResponse$1>;
5113
3601
  };
5114
3602
  };
5115
- /** Telemetry methods (pushMetrics) */
5116
- telemetry: {
5117
- pushMetrics: (metrics: Record<string, number>) => Promise<void>;
5118
- };
5119
3603
  /** Credits methods (credits management) */
5120
3604
  credits: {
5121
3605
  balance: () => Promise<number>;
5122
3606
  add: (amount: number) => Promise<number>;
5123
3607
  spend: (amount: number) => Promise<number>;
5124
3608
  };
5125
- /** Platform-wide leaderboard methods (fetch, getUserRank) */
5126
- leaderboard: {
5127
- fetch: (options?: LeaderboardOptions) => Promise<GameLeaderboardEntry[]>;
5128
- getUserRank: (gameId: string, userId: string) => Promise<UserRankResponse>;
5129
- };
5130
3609
  /** Platform-wide scores methods (submit, getUserScores) */
5131
3610
  scores: {
5132
3611
  submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
5133
- getByUser: (gameId: string, userId: string, options?: {
5134
- limit?: number;
5135
- }) => Promise<UserScore$1[]>;
5136
- };
5137
- /** Character methods (get, create, update, components) */
5138
- character: {
5139
- get: (userId?: string) => Promise<PlayerCharacter | null>;
5140
- create: (characterData: CreateCharacterData) => Promise<PlayerCharacter>;
5141
- update: (updates: UpdateCharacterData) => Promise<PlayerCharacter>;
5142
- components: {
5143
- list: (options?: CharacterComponentsOptions & TTLCacheConfig) => Promise<CharacterComponentWithSpriteUrl[]>;
5144
- clearCache: (key?: string) => void;
5145
- getCacheKeys: () => string[];
5146
- };
5147
- accessories: {
5148
- equip: (slot: string, componentId: string) => Promise<PlayerCharacterAccessory>;
5149
- remove: (slot: string) => Promise<{
5150
- success: boolean;
5151
- }>;
5152
- list: () => Promise<PlayerCharacterAccessory[]>;
5153
- };
5154
- };
5155
- /** Sprites methods (templates) */
5156
- sprites: {
5157
- templates: {
5158
- get: (slug: string) => Promise<SpriteTemplateData>;
5159
- };
5160
3612
  };
5161
3613
  /** Realtime methods (token) */
5162
3614
  realtime: {
@@ -5165,36 +3617,6 @@ declare class PlaycademyClient {
5165
3617
  };
5166
3618
  open(channel?: string, url?: string): Promise<_playcademy_realtime_server_types.RealtimeChannel>;
5167
3619
  };
5168
- /** Achievements methods (list, history, progress) */
5169
- achievements: {
5170
- list: (options?: TTLCacheConfig) => Promise<AchievementCurrent[]>;
5171
- history: {
5172
- list: (queryOptions?: {
5173
- limit?: number;
5174
- }, cacheOptions?: TTLCacheConfig) => Promise<AchievementHistoryEntry[]>;
5175
- };
5176
- progress: {
5177
- submit: (achievementId: string) => Promise<AchievementProgressResponse>;
5178
- };
5179
- };
5180
- /** Notifications methods (list, update status, stats) */
5181
- notifications: {
5182
- list: (queryOptions?: {
5183
- status?: NotificationStatus;
5184
- type?: NotificationType;
5185
- limit?: number;
5186
- offset?: number;
5187
- }, cacheOptions?: TTLCacheConfig) => Promise<Notification[]>;
5188
- markAsSeen: (notificationId: string) => Promise<Notification>;
5189
- markAsClicked: (notificationId: string) => Promise<Notification>;
5190
- dismiss: (notificationId: string) => Promise<Notification>;
5191
- stats: {
5192
- get: (queryOptions?: {
5193
- from?: string;
5194
- to?: string;
5195
- }, cacheOptions?: TTLCacheConfig) => Promise<NotificationStats>;
5196
- };
5197
- };
5198
3620
  /** Backend methods for calling custom game API routes */
5199
3621
  backend: {
5200
3622
  get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
@@ -5216,6 +3638,9 @@ declare class PlaycademyClient {
5216
3638
  };
5217
3639
  }
5218
3640
 
3641
+ /**
3642
+ * Core client configuration and lifecycle types
3643
+ */
5219
3644
  type TokenType = 'session' | 'apiKey' | 'gameJwt';
5220
3645
  interface ClientConfig {
5221
3646
  baseUrl: string;
@@ -5260,46 +3685,6 @@ interface InitPayload {
5260
3685
  /** Realtime WebSocket URL */
5261
3686
  realtimeUrl?: string;
5262
3687
  }
5263
- type AuthProviderType = (typeof AUTH_PROVIDER_IDS)[keyof typeof AUTH_PROVIDER_IDS];
5264
- interface AuthOptions {
5265
- /** The identity provider to use for authentication */
5266
- provider: AuthProviderType;
5267
- /** The OAuth callback URL where your server handles the callback */
5268
- callbackUrl: string;
5269
- /** Authentication mode - auto detects best option based on context */
5270
- mode?: 'auto' | 'popup' | 'redirect';
5271
- /** Callback for authentication state changes */
5272
- onStateChange?: (state: AuthStateUpdate) => void;
5273
- /** Custom OAuth configuration (for users embedding the SDK outside of the Playcademy platform) */
5274
- oauth?: {
5275
- clientId: string;
5276
- authorizationEndpoint?: string;
5277
- tokenEndpoint?: string;
5278
- scope?: string;
5279
- };
5280
- /**
5281
- * Optional custom data to encode in OAuth state parameter.
5282
- * By default, the SDK automatically includes playcademy_user_id and game_id.
5283
- * Use this to add additional custom data if needed.
5284
- */
5285
- stateData?: Record<string, string>;
5286
- }
5287
- interface AuthStateUpdate {
5288
- /** Current status of the authentication flow */
5289
- status: 'opening_popup' | 'exchanging_token' | 'complete' | 'error';
5290
- /** Human-readable message about the current state */
5291
- message: string;
5292
- /** Error details if status is 'error' */
5293
- error?: Error;
5294
- }
5295
- interface AuthResult {
5296
- /** Whether authentication was successful */
5297
- success: boolean;
5298
- /** User information if authentication was successful */
5299
- user?: UserInfo;
5300
- /** Error if authentication failed */
5301
- error?: Error;
5302
- }
5303
3688
  /**
5304
3689
  * Simplified user data passed to games via InitPayload
5305
3690
  * This is a subset of AuthenticatedUser suitable for external game consumption
@@ -5318,8 +3703,54 @@ interface GameUser {
5318
3703
  /** Whether the user has a Timeback account */
5319
3704
  hasTimebackAccount: boolean;
5320
3705
  }
3706
+ type GameContextPayload = {
3707
+ token: string;
3708
+ baseUrl: string;
3709
+ realtimeUrl: string;
3710
+ gameId: string;
3711
+ forwardKeys?: string[];
3712
+ };
3713
+ type EventListeners = {
3714
+ [E in keyof ClientEvents]?: Array<(payload: ClientEvents[E]) => void>;
3715
+ };
3716
+ interface ClientEvents {
3717
+ authChange: {
3718
+ token: string | null;
3719
+ };
3720
+ inventoryChange: {
3721
+ itemId: string;
3722
+ delta: number;
3723
+ newTotal: number;
3724
+ };
3725
+ levelUp: {
3726
+ oldLevel: number;
3727
+ newLevel: number;
3728
+ creditsAwarded: number;
3729
+ };
3730
+ xpGained: {
3731
+ amount: number;
3732
+ totalXP: number;
3733
+ leveledUp: boolean;
3734
+ };
3735
+ connectionChange: {
3736
+ state: 'online' | 'offline' | 'degraded';
3737
+ reason: string;
3738
+ };
3739
+ }
3740
+
5321
3741
  /**
5322
- * Authentication state change event payload.
3742
+ * Event and message payload types for SDK messaging system
3743
+ */
3744
+
3745
+ interface DisplayAlertPayload {
3746
+ message: string;
3747
+ options?: {
3748
+ type?: 'info' | 'warning' | 'error';
3749
+ duration?: number;
3750
+ };
3751
+ }
3752
+ /**
3753
+ * Authentication state change event payload.
5323
3754
  * Used when authentication state changes in the application.
5324
3755
  */
5325
3756
  interface AuthStateChangePayload {
@@ -5392,24 +3823,6 @@ interface KeyEventPayload {
5392
3823
  /** Event type */
5393
3824
  type: 'keydown' | 'keyup';
5394
3825
  }
5395
- interface DisplayAlertPayload {
5396
- message: string;
5397
- options?: {
5398
- type?: 'info' | 'warning' | 'error';
5399
- duration?: number;
5400
- };
5401
- }
5402
- /**
5403
- * Display alert payload.
5404
- * Request from game to show platform-level alert.
5405
- */
5406
- interface DisplayAlertPayload {
5407
- message: string;
5408
- options?: {
5409
- type?: 'info' | 'warning' | 'error';
5410
- duration?: number;
5411
- };
5412
- }
5413
3826
  /**
5414
3827
  * Connection state payload.
5415
3828
  * Broadcast from platform to games when connection changes.
@@ -5418,40 +3831,10 @@ interface ConnectionStatePayload {
5418
3831
  state: 'online' | 'offline' | 'degraded';
5419
3832
  reason: string;
5420
3833
  }
5421
- interface ClientEvents {
5422
- authChange: {
5423
- token: string | null;
5424
- };
5425
- inventoryChange: {
5426
- itemId: string;
5427
- delta: number;
5428
- newTotal: number;
5429
- };
5430
- levelUp: {
5431
- oldLevel: number;
5432
- newLevel: number;
5433
- creditsAwarded: number;
5434
- };
5435
- xpGained: {
5436
- amount: number;
5437
- totalXP: number;
5438
- leveledUp: boolean;
5439
- };
5440
- connectionChange: {
5441
- state: 'online' | 'offline' | 'degraded';
5442
- reason: string;
5443
- };
5444
- }
5445
- type GameContextPayload = {
5446
- token: string;
5447
- baseUrl: string;
5448
- realtimeUrl: string;
5449
- gameId: string;
5450
- forwardKeys?: string[];
5451
- };
5452
- type EventListeners = {
5453
- [E in keyof ClientEvents]?: Array<(payload: ClientEvents[E]) => void>;
5454
- };
3834
+
3835
+ /**
3836
+ * SDK-specific API response types
3837
+ */
5455
3838
  type LoginResponse = {
5456
3839
  token: string;
5457
3840
  };
@@ -5465,29 +3848,96 @@ type StartSessionResponse = {
5465
3848
  type InventoryMutationResponse = {
5466
3849
  newTotal: number;
5467
3850
  };
5468
- type DevUploadEvent = {
5469
- type: 'init';
5470
- } | {
5471
- type: 's3Progress';
5472
- loaded: number;
5473
- total: number;
5474
- percent: number;
5475
- } | {
5476
- type: 'finalizeStart';
5477
- } | {
5478
- type: 'finalizeProgress';
5479
- percent: number;
5480
- currentFileLabel?: string;
5481
- } | {
5482
- type: 'finalizeStatus';
5483
- message: string;
5484
- } | {
5485
- type: 'close';
5486
- };
5487
- type DevUploadHooks = {
5488
- onEvent?: (e: DevUploadEvent) => void;
5489
- onClose?: () => void;
3851
+
3852
+ /**
3853
+ * Realtime namespace types
3854
+ */
3855
+ /**
3856
+ * Response type for the realtime token API
3857
+ */
3858
+ interface RealtimeTokenResponse {
3859
+ token: string;
3860
+ }
3861
+
3862
+ /**
3863
+ * Scores namespace types
3864
+ */
3865
+ interface ScoreSubmission {
3866
+ id: string;
3867
+ score: number;
3868
+ achievedAt: Date;
3869
+ }
3870
+
3871
+ /**
3872
+ * TimeBack namespace types
3873
+ */
3874
+
3875
+ /**
3876
+ * Combined response type for summary method
3877
+ */
3878
+ type XpSummaryResponse = {
3879
+ today: TodayXpResponse;
3880
+ total: TotalXpResponse;
3881
+ history: XpHistoryResponse;
5490
3882
  };
3883
+
3884
+ /**
3885
+ * Users namespace types
3886
+ */
3887
+ interface UserScore {
3888
+ id: string;
3889
+ score: number;
3890
+ achievedAt: Date;
3891
+ metadata?: Record<string, unknown>;
3892
+ gameId: string;
3893
+ gameTitle: string;
3894
+ gameSlug: string;
3895
+ }
3896
+
3897
+ /**
3898
+ * Authentication namespace types
3899
+ */
3900
+
3901
+ type AuthProviderType = (typeof AUTH_PROVIDER_IDS)[keyof typeof AUTH_PROVIDER_IDS];
3902
+ interface AuthOptions {
3903
+ /** The identity provider to use for authentication */
3904
+ provider: AuthProviderType;
3905
+ /** The OAuth callback URL where your server handles the callback */
3906
+ callbackUrl: string;
3907
+ /** Authentication mode - auto detects best option based on context */
3908
+ mode?: 'auto' | 'popup' | 'redirect';
3909
+ /** Callback for authentication state changes */
3910
+ onStateChange?: (state: AuthStateUpdate) => void;
3911
+ /** Custom OAuth configuration (for users embedding the SDK outside of the Playcademy platform) */
3912
+ oauth?: {
3913
+ clientId: string;
3914
+ authorizationEndpoint?: string;
3915
+ tokenEndpoint?: string;
3916
+ scope?: string;
3917
+ };
3918
+ /**
3919
+ * Optional custom data to encode in OAuth state parameter.
3920
+ * By default, the SDK automatically includes playcademy_user_id and game_id.
3921
+ * Use this to add additional custom data if needed.
3922
+ */
3923
+ stateData?: Record<string, string>;
3924
+ }
3925
+ interface AuthStateUpdate {
3926
+ /** Current status of the authentication flow */
3927
+ status: 'opening_popup' | 'exchanging_token' | 'complete' | 'error';
3928
+ /** Human-readable message about the current state */
3929
+ message: string;
3930
+ /** Error details if status is 'error' */
3931
+ error?: Error;
3932
+ }
3933
+ interface AuthResult {
3934
+ /** Whether authentication was successful */
3935
+ success: boolean;
3936
+ /** User information if authentication was successful */
3937
+ user?: UserInfo;
3938
+ /** Error if authentication failed */
3939
+ error?: Error;
3940
+ }
5491
3941
  /**
5492
3942
  * Better-auth sign-in response
5493
3943
  */
@@ -5525,6 +3975,38 @@ interface BetterAuthApiKey {
5525
3975
  lastRequest: string | null;
5526
3976
  requestCount: number;
5527
3977
  }
3978
+
3979
+ /**
3980
+ * Character namespace types
3981
+ */
3982
+ interface CharacterComponentsOptions {
3983
+ /**
3984
+ * Optional level filter for components
3985
+ * When provided, only components available at this level or below are returned
3986
+ */
3987
+ level?: number;
3988
+ /**
3989
+ * Whether to bypass the cache and force a fresh API request
3990
+ * Default: false (use cache when available)
3991
+ */
3992
+ skipCache?: boolean;
3993
+ }
3994
+ interface CreateCharacterData {
3995
+ bodyComponentId: string;
3996
+ eyesComponentId: string;
3997
+ hairstyleComponentId: string;
3998
+ outfitComponentId: string;
3999
+ }
4000
+ interface UpdateCharacterData {
4001
+ bodyComponentId?: string;
4002
+ eyesComponentId?: string;
4003
+ hairstyleComponentId?: string;
4004
+ outfitComponentId?: string;
4005
+ }
4006
+
4007
+ /**
4008
+ * Developer namespace types
4009
+ */
5528
4010
  /**
5529
4011
  * Bucket file metadata
5530
4012
  */
@@ -5534,6 +4016,207 @@ interface BucketFile {
5534
4016
  uploaded: string;
5535
4017
  contentType?: string;
5536
4018
  }
4019
+ type DevUploadEvent = {
4020
+ type: 'init';
4021
+ } | {
4022
+ type: 's3Progress';
4023
+ loaded: number;
4024
+ total: number;
4025
+ percent: number;
4026
+ } | {
4027
+ type: 'finalizeStart';
4028
+ } | {
4029
+ type: 'finalizeProgress';
4030
+ percent: number;
4031
+ currentFileLabel?: string;
4032
+ } | {
4033
+ type: 'finalizeStatus';
4034
+ message: string;
4035
+ } | {
4036
+ type: 'close';
4037
+ };
4038
+ type DevUploadHooks = {
4039
+ onEvent?: (e: DevUploadEvent) => void;
4040
+ onClose?: () => void;
4041
+ };
4042
+
4043
+ /**
4044
+ * @fileoverview Server SDK Type Definitions
4045
+ *
4046
+ * TypeScript type definitions for the server-side Playcademy SDK.
4047
+ * Includes configuration types, client state, and re-exported TimeBack types.
4048
+ */
4049
+
4050
+ /**
4051
+ * Base configuration for TimeBack integration (shared across all courses).
4052
+ * References upstream TimeBack types from @playcademy/timeback.
4053
+ *
4054
+ * All fields are optional and support template variables: {grade}, {subject}, {gameSlug}
4055
+ */
4056
+ interface TimebackBaseConfig {
4057
+ /** Organization configuration (shared across all courses) */
4058
+ organization?: Partial<OrganizationConfig>;
4059
+ /** Course defaults (can be overridden per-course) */
4060
+ course?: Partial<CourseConfig>;
4061
+ /** Component defaults */
4062
+ component?: Partial<ComponentConfig>;
4063
+ /** Resource defaults */
4064
+ resource?: Partial<ResourceConfig>;
4065
+ /** ComponentResource defaults */
4066
+ componentResource?: Partial<ComponentResourceConfig>;
4067
+ }
4068
+ /**
4069
+ * Extended course configuration that merges TimebackCourseConfig with per-course overrides.
4070
+ * Used in playcademy.config.* to allow per-course customization.
4071
+ */
4072
+ interface TimebackCourseConfigWithOverrides extends TimebackCourseConfig {
4073
+ title?: string;
4074
+ courseCode?: string;
4075
+ level?: string;
4076
+ metadata?: CourseConfig['metadata'];
4077
+ totalXp?: number | null;
4078
+ masterableUnits?: number | null;
4079
+ }
4080
+ /**
4081
+ * TimeBack integration configuration for Playcademy config file.
4082
+ *
4083
+ * Supports two levels of customization:
4084
+ * 1. `base`: Shared defaults for all courses (organization, course, component, resource, componentResource)
4085
+ * 2. Per-course overrides in the `courses` array (title, courseCode, level, gradingScheme, metadata)
4086
+ *
4087
+ * Template variables ({grade}, {subject}, {gameSlug}) can be used in string fields.
4088
+ */
4089
+ interface TimebackIntegrationConfig {
4090
+ /** Multi-grade course configuration (array of grade/subject/totalXp with optional per-course overrides) */
4091
+ courses: TimebackCourseConfigWithOverrides[];
4092
+ /** Optional base configuration (shared across all courses, can be overridden per-course) */
4093
+ base?: TimebackBaseConfig;
4094
+ }
4095
+ /**
4096
+ * Custom API routes integration
4097
+ */
4098
+ interface CustomRoutesIntegration {
4099
+ /** Directory for custom API routes (defaults to 'server/api') */
4100
+ directory?: string;
4101
+ }
4102
+ /**
4103
+ * Database integration
4104
+ */
4105
+ interface DatabaseIntegration {
4106
+ /** Database directory (defaults to 'db') */
4107
+ directory?: string;
4108
+ }
4109
+ /**
4110
+ * Integrations configuration
4111
+ * All backend features (database, custom routes, external services) are configured here
4112
+ */
4113
+ interface IntegrationsConfig {
4114
+ /** TimeBack integration (optional) */
4115
+ timeback?: TimebackIntegrationConfig | null;
4116
+ /** Custom API routes (optional) */
4117
+ customRoutes?: CustomRoutesIntegration | boolean;
4118
+ /** Database (optional) */
4119
+ database?: DatabaseIntegration | boolean;
4120
+ /** Key-Value storage (optional) */
4121
+ kv?: boolean;
4122
+ /** Bucket storage (optional) */
4123
+ bucket?: boolean;
4124
+ /** Authentication (optional) */
4125
+ auth?: boolean;
4126
+ }
4127
+ /**
4128
+ * Unified Playcademy configuration
4129
+ * Used for playcademy.config.{js,json}
4130
+ */
4131
+ interface PlaycademyConfig {
4132
+ /** Game name */
4133
+ name: string;
4134
+ /** Game description */
4135
+ description?: string;
4136
+ /** Game emoji icon */
4137
+ emoji?: string;
4138
+ /** Build command to run before deployment */
4139
+ buildCommand?: string[];
4140
+ /** Path to build output */
4141
+ buildPath?: string;
4142
+ /** Game type */
4143
+ gameType?: 'hosted' | 'external';
4144
+ /** External URL (for external games) */
4145
+ externalUrl?: string;
4146
+ /** Game platform */
4147
+ platform?: 'web' | 'unity' | 'godot';
4148
+ /** Integrations (database, custom routes, external services) */
4149
+ integrations?: IntegrationsConfig;
4150
+ }
4151
+
4152
+ /**
4153
+ * Configuration options for initializing a PlaycademyClient instance.
4154
+ *
4155
+ * @example
4156
+ * ```typescript
4157
+ * const config: PlaycademyServerClientConfig = {
4158
+ * apiKey: process.env.PLAYCADEMY_API_KEY!,
4159
+ * gameId: 'my-math-game',
4160
+ * configPath: './playcademy.config.js'
4161
+ * }
4162
+ * ```
4163
+ */
4164
+ interface PlaycademyServerClientConfig {
4165
+ /**
4166
+ * Playcademy API key for server-to-server authentication.
4167
+ * Obtain from the Playcademy developer dashboard.
4168
+ */
4169
+ apiKey: string;
4170
+ /**
4171
+ * Optional path to playcademy.config.js file.
4172
+ * If not provided, searches current directory and up to 3 parent directories.
4173
+ * Ignored if `config` is provided directly.
4174
+ *
4175
+ * @example './config/playcademy.config.js'
4176
+ */
4177
+ configPath?: string;
4178
+ /**
4179
+ * Optional config object (for edge environments without filesystem).
4180
+ * If provided, skips filesystem-based config loading.
4181
+ *
4182
+ * @example { name: 'My Game', integrations: { timeback: {...} } }
4183
+ */
4184
+ config?: PlaycademyConfig;
4185
+ /**
4186
+ * Optional base URL for Playcademy API.
4187
+ * Defaults to environment variables or 'https://hub.playcademy.net'.
4188
+ *
4189
+ * @example 'http://localhost:3000' for local development
4190
+ */
4191
+ baseUrl?: string;
4192
+ /**
4193
+ * Optional game ID.
4194
+ * If not provided, will attempt to fetch from API using the API token.
4195
+ *
4196
+ * @example 'my-math-game'
4197
+ */
4198
+ gameId?: string;
4199
+ }
4200
+ /**
4201
+ * Internal state maintained by the PlaycademyClient instance.
4202
+ *
4203
+ * @internal
4204
+ */
4205
+ interface PlaycademyServerClientState {
4206
+ /** API key for authentication */
4207
+ apiKey: string;
4208
+ /** Base URL for API requests */
4209
+ baseUrl: string;
4210
+ /** Game identifier */
4211
+ gameId: string;
4212
+ /** Loaded game configuration from playcademy.config.js */
4213
+ config: PlaycademyConfig;
4214
+ /**
4215
+ * TimeBack course ID fetched from the Playcademy API.
4216
+ * Used for all TimeBack event recording.
4217
+ */
4218
+ courseId?: string;
4219
+ }
5537
4220
 
5538
4221
  export { PlaycademyClient };
5539
- export type { Achievement, AchievementCurrent, AchievementProgressResponse, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponent, CharacterComponentWithSpriteUrl, ClientConfig, ClientEvents, ConnectionStatePayload, Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusResponse, DisconnectContext, DisconnectHandler, DisplayAlertPayload, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameLeaderboardEntry, GameSession, GameStateData, GameTokenResponse, GameUser, HostedGame, InitPayload, InventoryItem, InventoryItemWithItem, InventoryMutationResponse, Item, KeyEventPayload, LeaderboardEntry, LevelConfig, LoginResponse, ManifestV1, Map, MapElement, MapElementWithGame, MapObject, MapObjectWithItem, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacter, ShopCurrency, ShopDisplayItem, ShopViewResponse, SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, User, UserInfo, UserLevel, UserLevelWithConfig, UserRank, UserRankResponse, UserRoleEnumType, UserScore$1 as UserScore, XpHistoryResponse };
4222
+ export type { Achievement, AchievementCurrent, AchievementProgressResponse, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponent, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionStatePayload, CreateCharacterData, Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusResponse, DisconnectContext, DisconnectHandler, DisplayAlertPayload, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameLeaderboardEntry, GameSession, GameStateData, GameTokenResponse, GameUser, HostedGame, InitPayload, InventoryItem, InventoryItemWithItem, InventoryMutationResponse, Item, KeyEventPayload, LeaderboardEntry, LevelConfig, LoginResponse, ManifestV1, Map, MapElement, MapElementWithGame, MapObject, MapObjectWithItem, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacter, RealtimeTokenResponse, ScoreSubmission, ShopCurrency, ShopDisplayItem, ShopViewResponse, SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, UpdateCharacterData, User, UserInfo, UserLevel, UserLevelWithConfig, UserRank, UserRankResponse, UserRoleEnumType, UserScore, XpHistoryResponse, XpSummaryResponse };