@playcademy/sdk 0.2.11 → 0.2.13

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.
@@ -1,8 +1,8 @@
1
+ import { SchemaInfo } from '@playcademy/cloudflare';
1
2
  import { InferSelectModel } from 'drizzle-orm';
2
3
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
3
4
  import * as drizzle_zod from 'drizzle-zod';
4
5
  import { z } from 'zod';
5
- import { SchemaInfo } from '@playcademy/cloudflare';
6
6
  import { AUTH_PROVIDER_IDS } from '@playcademy/constants';
7
7
 
8
8
  /**
@@ -583,6 +583,56 @@ interface PopulateStudentResponse {
583
583
  status: string;
584
584
  message?: string;
585
585
  }
586
+ interface TimebackSetupRequest {
587
+ gameId: string;
588
+ config: {
589
+ organization: {
590
+ name: string;
591
+ type: string;
592
+ identifier: string;
593
+ };
594
+ course: {
595
+ title: string;
596
+ subjects: string[];
597
+ grades: number[];
598
+ courseCode: string;
599
+ level: string;
600
+ gradingScheme: string;
601
+ metadata?: Record<string, unknown>;
602
+ };
603
+ component: {
604
+ title: string;
605
+ sortOrder: number;
606
+ prerequisites: string[];
607
+ prerequisiteCriteria: string;
608
+ };
609
+ resource: {
610
+ title: string;
611
+ vendorResourceId: string;
612
+ vendorId: string;
613
+ applicationId: string;
614
+ roles: string[];
615
+ importance: string;
616
+ metadata: {
617
+ type?: string;
618
+ launchUrl?: string;
619
+ toolProvider?: string;
620
+ instructionalMethod?: string;
621
+ subject?: string;
622
+ grades?: number[];
623
+ language?: string;
624
+ xp?: number;
625
+ [key: string]: unknown;
626
+ };
627
+ };
628
+ componentResource: {
629
+ title: string;
630
+ sortOrder: number;
631
+ lessonType: string | null;
632
+ };
633
+ };
634
+ verbose?: boolean;
635
+ }
586
636
  interface PlatformTimebackSetupRequest {
587
637
  gameId: string;
588
638
  courses: DerivedPlatformCourseConfig[];
@@ -928,7 +978,7 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
928
978
  tableName: "user";
929
979
  dataType: "string";
930
980
  columnType: "PgEnumColumn";
931
- data: "admin" | "developer" | "player";
981
+ data: "admin" | "player" | "developer";
932
982
  driverParam: string;
933
983
  notNull: true;
934
984
  hasDefault: true;
@@ -945,7 +995,7 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
945
995
  tableName: "user";
946
996
  dataType: "string";
947
997
  columnType: "PgEnumColumn";
948
- data: "approved" | "none" | "pending";
998
+ data: "none" | "pending" | "approved";
949
999
  driverParam: string;
950
1000
  notNull: true;
951
1001
  hasDefault: true;
@@ -1134,7 +1184,7 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
1134
1184
  tableName: "games";
1135
1185
  dataType: "string";
1136
1186
  columnType: "PgEnumColumn";
1137
- data: "external" | "hosted";
1187
+ data: "hosted" | "external";
1138
1188
  driverParam: string;
1139
1189
  notNull: true;
1140
1190
  hasDefault: true;
@@ -1185,7 +1235,7 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
1185
1235
  tableName: "games";
1186
1236
  dataType: "string";
1187
1237
  columnType: "PgEnumColumn";
1188
- data: "godot" | "unity" | "web";
1238
+ data: "web" | "godot" | "unity";
1189
1239
  driverParam: string;
1190
1240
  notNull: true;
1191
1241
  hasDefault: true;
@@ -1461,7 +1511,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1461
1511
  tableName: "game_custom_hostnames";
1462
1512
  dataType: "string";
1463
1513
  columnType: "PgEnumColumn";
1464
- data: "production" | "staging";
1514
+ data: "staging" | "production";
1465
1515
  driverParam: string;
1466
1516
  notNull: true;
1467
1517
  hasDefault: true;
@@ -1478,7 +1528,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1478
1528
  tableName: "game_custom_hostnames";
1479
1529
  dataType: "string";
1480
1530
  columnType: "PgEnumColumn";
1481
- data: "active" | "blocked" | "deleted" | "pending" | "pending_deletion" | "pending_deployment" | "pending_validation";
1531
+ data: "pending" | "active" | "pending_validation" | "pending_deployment" | "pending_deletion" | "blocked" | "deleted";
1482
1532
  driverParam: string;
1483
1533
  notNull: true;
1484
1534
  hasDefault: true;
@@ -1495,7 +1545,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1495
1545
  tableName: "game_custom_hostnames";
1496
1546
  dataType: "string";
1497
1547
  columnType: "PgEnumColumn";
1498
- data: "active" | "deleted" | "initializing" | "pending_deployment" | "pending_issuance" | "pending_validation";
1548
+ data: "active" | "pending_validation" | "pending_deployment" | "deleted" | "initializing" | "pending_issuance";
1499
1549
  driverParam: string;
1500
1550
  notNull: true;
1501
1551
  hasDefault: true;
@@ -1657,7 +1707,7 @@ declare const items: drizzle_orm_pg_core.PgTableWithColumns<{
1657
1707
  tableName: "items";
1658
1708
  dataType: "string";
1659
1709
  columnType: "PgEnumColumn";
1660
- data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
1710
+ data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
1661
1711
  driverParam: string;
1662
1712
  notNull: true;
1663
1713
  hasDefault: true;
@@ -2348,7 +2398,7 @@ declare const mapElements: drizzle_orm_pg_core.PgTableWithColumns<{
2348
2398
  tableName: "map_elements";
2349
2399
  dataType: "string";
2350
2400
  columnType: "PgEnumColumn";
2351
- data: "door_in" | "door_out" | "game_entry" | "game_registry" | "info" | "npc_interaction" | "quest_trigger" | "teleport";
2401
+ data: "info" | "game_entry" | "game_registry" | "teleport" | "door_in" | "door_out" | "npc_interaction" | "quest_trigger";
2352
2402
  driverParam: string;
2353
2403
  notNull: true;
2354
2404
  hasDefault: false;
@@ -2901,7 +2951,7 @@ declare const characterComponents: drizzle_orm_pg_core.PgTableWithColumns<{
2901
2951
  tableName: "character_components";
2902
2952
  dataType: "string";
2903
2953
  columnType: "PgEnumColumn";
2904
- data: "accessory" | "body" | "eyes" | "hairstyle" | "outfit";
2954
+ data: "accessory" | "body" | "outfit" | "hairstyle" | "eyes";
2905
2955
  driverParam: string;
2906
2956
  notNull: true;
2907
2957
  hasDefault: false;
@@ -3427,7 +3477,7 @@ declare const notifications: drizzle_orm_pg_core.PgTableWithColumns<{
3427
3477
  tableName: "notifications";
3428
3478
  dataType: "string";
3429
3479
  columnType: "PgEnumColumn";
3430
- data: "high" | "low" | "normal" | "urgent";
3480
+ data: "low" | "normal" | "high" | "urgent";
3431
3481
  driverParam: string;
3432
3482
  notNull: true;
3433
3483
  hasDefault: true;
@@ -3444,7 +3494,7 @@ declare const notifications: drizzle_orm_pg_core.PgTableWithColumns<{
3444
3494
  tableName: "notifications";
3445
3495
  dataType: "string";
3446
3496
  columnType: "PgEnumColumn";
3447
- data: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
3497
+ data: "pending" | "delivered" | "seen" | "clicked" | "dismissed" | "expired";
3448
3498
  driverParam: string;
3449
3499
  notNull: true;
3450
3500
  hasDefault: true;
@@ -3605,33 +3655,33 @@ declare const UpsertGameMetadataSchema: z.ZodEffects<z.ZodObject<{
3605
3655
  gameType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["hosted", "external"]>>>;
3606
3656
  externalUrl: z.ZodOptional<z.ZodString>;
3607
3657
  }, "strip", z.ZodTypeAny, {
3608
- displayName: string;
3609
- mapElementId?: string | null | undefined;
3610
- platform: "godot" | "unity" | "web";
3611
3658
  metadata: Record<string, unknown>;
3612
- gameType: "external" | "hosted";
3659
+ displayName: string;
3660
+ gameType: "hosted" | "external";
3661
+ platform: "web" | "godot" | "unity";
3613
3662
  externalUrl?: string | undefined;
3663
+ mapElementId?: string | null | undefined;
3614
3664
  }, {
3615
3665
  displayName: string;
3616
- mapElementId?: string | null | undefined;
3617
- platform: "godot" | "unity" | "web";
3666
+ platform: "web" | "godot" | "unity";
3618
3667
  metadata?: Record<string, unknown> | undefined;
3619
- gameType?: "external" | "hosted" | undefined;
3668
+ gameType?: "hosted" | "external" | undefined;
3620
3669
  externalUrl?: string | undefined;
3621
- }>, {
3622
- displayName: string;
3623
3670
  mapElementId?: string | null | undefined;
3624
- platform: "godot" | "unity" | "web";
3671
+ }>, {
3625
3672
  metadata: Record<string, unknown>;
3626
- gameType: "external" | "hosted";
3673
+ displayName: string;
3674
+ gameType: "hosted" | "external";
3675
+ platform: "web" | "godot" | "unity";
3627
3676
  externalUrl?: string | undefined;
3677
+ mapElementId?: string | null | undefined;
3628
3678
  }, {
3629
3679
  displayName: string;
3630
- mapElementId?: string | null | undefined;
3631
- platform: "godot" | "unity" | "web";
3680
+ platform: "web" | "godot" | "unity";
3632
3681
  metadata?: Record<string, unknown> | undefined;
3633
- gameType?: "external" | "hosted" | undefined;
3682
+ gameType?: "hosted" | "external" | undefined;
3634
3683
  externalUrl?: string | undefined;
3684
+ mapElementId?: string | null | undefined;
3635
3685
  }>;
3636
3686
 
3637
3687
  declare const InsertItemSchema: drizzle_zod.BuildSchema<"insert", {
@@ -3725,7 +3775,7 @@ declare const InsertItemSchema: drizzle_zod.BuildSchema<"insert", {
3725
3775
  tableName: "items";
3726
3776
  dataType: "string";
3727
3777
  columnType: "PgEnumColumn";
3728
- data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
3778
+ data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
3729
3779
  driverParam: string;
3730
3780
  notNull: true;
3731
3781
  hasDefault: true;
@@ -3820,24 +3870,24 @@ declare const UpdateItemSchema: z.ZodObject<Omit<{
3820
3870
  imageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3821
3871
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3822
3872
  createdAt: z.ZodOptional<z.ZodDate>;
3823
- }, "createdAt" | "id">, "strip", z.ZodTypeAny, {
3873
+ }, "id" | "createdAt">, "strip", z.ZodTypeAny, {
3874
+ description?: string | null | undefined;
3875
+ metadata?: Record<string, unknown> | undefined;
3876
+ type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3824
3877
  slug?: string | undefined;
3825
- gameId?: string | null | undefined;
3826
3878
  displayName?: string | undefined;
3827
- description?: string | null | undefined;
3828
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
3879
+ gameId?: string | null | undefined;
3829
3880
  isPlaceable?: boolean | undefined;
3830
3881
  imageUrl?: string | null | undefined;
3831
- metadata?: Record<string, unknown> | undefined;
3832
3882
  }, {
3883
+ description?: string | null | undefined;
3884
+ metadata?: Record<string, unknown> | undefined;
3885
+ type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3833
3886
  slug?: string | undefined;
3834
- gameId?: string | null | undefined;
3835
3887
  displayName?: string | undefined;
3836
- description?: string | null | undefined;
3837
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
3888
+ gameId?: string | null | undefined;
3838
3889
  isPlaceable?: boolean | undefined;
3839
3890
  imageUrl?: string | null | undefined;
3840
- metadata?: Record<string, unknown> | undefined;
3841
3891
  }>;
3842
3892
  declare const InsertCurrencySchema: drizzle_zod.BuildSchema<"insert", {
3843
3893
  id: drizzle_orm_pg_core.PgColumn<{
@@ -3947,16 +3997,16 @@ declare const InsertCurrencySchema: drizzle_zod.BuildSchema<"insert", {
3947
3997
  isPrimary: z.ZodDefault<z.ZodBoolean>;
3948
3998
  }>;
3949
3999
  declare const UpdateCurrencySchema: z.ZodObject<{
3950
- itemId: z.ZodOptional<z.ZodString>;
3951
4000
  symbol: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
4001
+ itemId: z.ZodOptional<z.ZodString>;
3952
4002
  isPrimary: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
3953
4003
  }, "strip", z.ZodTypeAny, {
3954
- itemId?: string | undefined;
3955
4004
  symbol?: string | null | undefined;
4005
+ itemId?: string | undefined;
3956
4006
  isPrimary?: boolean | undefined;
3957
4007
  }, {
3958
- itemId?: string | undefined;
3959
4008
  symbol?: string | null | undefined;
4009
+ itemId?: string | undefined;
3960
4010
  isPrimary?: boolean | undefined;
3961
4011
  }>;
3962
4012
  declare const InsertShopListingSchema: drizzle_zod.BuildSchema<"insert", {
@@ -4167,28 +4217,28 @@ declare const UpdateShopListingSchema: z.ZodObject<{
4167
4217
  updatedAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodDate>>>;
4168
4218
  }, "strip", z.ZodTypeAny, {
4169
4219
  id?: string | undefined;
4220
+ createdAt?: Date | undefined;
4221
+ updatedAt?: Date | null | undefined;
4222
+ isActive?: boolean | undefined;
4170
4223
  itemId?: string | undefined;
4171
4224
  currencyId?: string | undefined;
4172
4225
  price?: number | undefined;
4173
4226
  sellBackPercentage?: number | null | undefined;
4174
4227
  stock?: number | null | undefined;
4175
- isActive?: boolean | undefined;
4176
4228
  availableFrom?: Date | null | undefined;
4177
4229
  availableUntil?: Date | null | undefined;
4178
- createdAt?: Date | undefined;
4179
- updatedAt?: Date | null | undefined;
4180
4230
  }, {
4181
4231
  id?: string | undefined;
4232
+ createdAt?: Date | undefined;
4233
+ updatedAt?: Date | null | undefined;
4234
+ isActive?: boolean | undefined;
4182
4235
  itemId?: string | undefined;
4183
4236
  currencyId?: string | undefined;
4184
4237
  price?: number | undefined;
4185
4238
  sellBackPercentage?: number | null | undefined;
4186
4239
  stock?: number | null | undefined;
4187
- isActive?: boolean | undefined;
4188
4240
  availableFrom?: Date | null | undefined;
4189
4241
  availableUntil?: Date | null | undefined;
4190
- createdAt?: Date | undefined;
4191
- updatedAt?: Date | null | undefined;
4192
4242
  }>;
4193
4243
 
4194
4244
  type GameRow = typeof games.$inferSelect;
@@ -5569,71 +5619,6 @@ declare class PlaycademyMessaging {
5569
5619
  */
5570
5620
  declare const messaging: PlaycademyMessaging;
5571
5621
 
5572
- /**
5573
- * Auto-initializes a PlaycademyClient with context from the environment.
5574
- * Works in both iframe mode (production/development) and standalone mode (local dev).
5575
- *
5576
- * This is the recommended way to initialize the SDK as it automatically:
5577
- * - Detects the runtime environment (iframe vs standalone)
5578
- * - Configures the client with the appropriate context
5579
- * - Sets up event listeners for token refresh
5580
- * - Exposes the client for debugging in development mode
5581
- *
5582
- * @param options - Optional configuration overrides
5583
- * @param options.baseUrl - Override the base URL for API requests
5584
- * @returns Promise resolving to a fully initialized PlaycademyClient
5585
- * @throws Error if not running in a browser context
5586
- *
5587
- * @example
5588
- * ```typescript
5589
- * // Default initialization
5590
- * const client = await PlaycademyClient.init()
5591
- *
5592
- * // With custom base URL
5593
- * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
5594
- * ```
5595
- */
5596
- declare function init<T extends PlaycademyClient = PlaycademyClient>(this: new (...args: ConstructorParameters<typeof PlaycademyClient>) => T, options?: {
5597
- baseUrl?: string;
5598
- allowedParentOrigins?: string[];
5599
- onDisconnect?: DisconnectHandler;
5600
- enableConnectionMonitoring?: boolean;
5601
- }): Promise<T>;
5602
-
5603
- /**
5604
- * Authenticates a user with email and password.
5605
- *
5606
- * This is a standalone authentication method that doesn't require an initialized client.
5607
- * Use this for login flows before creating a client instance.
5608
- *
5609
- * @deprecated Use client.auth.login() instead for better error handling and automatic token management
5610
- *
5611
- * @param baseUrl - The base URL of the Playcademy API
5612
- * @param email - User's email address
5613
- * @param password - User's password
5614
- * @returns Promise resolving to authentication response with token
5615
- * @throws PlaycademyError if authentication fails or network error occurs
5616
- *
5617
- * @example
5618
- * ```typescript
5619
- * // Preferred approach:
5620
- * const client = new PlaycademyClient({ baseUrl: '/api' })
5621
- * const result = await client.auth.login({
5622
- * email: 'user@example.com',
5623
- * password: 'password'
5624
- * })
5625
- *
5626
- * // Legacy approach (still works):
5627
- * try {
5628
- * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
5629
- * const client = new PlaycademyClient({ token: response.token })
5630
- * } catch (error) {
5631
- * console.error('Login failed:', error.message)
5632
- * }
5633
- * ```
5634
- */
5635
- declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
5636
-
5637
5622
  /**
5638
5623
  * @fileoverview Authentication Strategy Pattern
5639
5624
  *
@@ -5768,6 +5753,9 @@ declare abstract class PlaycademyBaseClient {
5768
5753
  * Initializes connection monitoring if enabled.
5769
5754
  */
5770
5755
  private _initializeConnectionMonitor;
5756
+ /**
5757
+ * Initializes an internal game session for automatic session management.
5758
+ */
5771
5759
  private _initializeInternalSession;
5772
5760
  /**
5773
5761
  * Current user data and inventory management.
@@ -5788,144 +5776,81 @@ declare abstract class PlaycademyBaseClient {
5788
5776
  }
5789
5777
 
5790
5778
  /**
5791
- * Playcademy SDK client for game developers.
5792
- * Provides namespaced access to platform features for games running inside Cademy.
5793
- */
5794
- declare class PlaycademyClient extends PlaycademyBaseClient {
5795
- /**
5796
- * Connect external identity providers to the user's Playcademy account.
5797
- * - `connect(provider)` - Link Discord, Google, etc. via OAuth popup
5798
- */
5799
- identity: {
5800
- connect: (options: AuthOptions) => Promise<AuthResult>;
5801
- _getContext: () => {
5802
- isInIframe: boolean;
5803
- };
5804
- };
5805
- /**
5806
- * Game runtime lifecycle and asset loading.
5807
- * - `exit()` - Return to Cademy hub
5808
- * - `getGameToken()` - Get short-lived auth token
5809
- * - `assets.url()`, `assets.json()`, `assets.fetch()` - Load game assets
5810
- * - `on('pause')`, `on('resume')` - Handle visibility changes
5811
- */
5812
- runtime: {
5813
- getGameToken: (gameId: string, options?: {
5814
- apply?: boolean | undefined;
5815
- } | undefined) => Promise<GameTokenResponse>;
5816
- exit: () => Promise<void>;
5817
- onInit: (handler: (context: GameContextPayload) => void) => void;
5818
- onTokenRefresh: (handler: (data: {
5819
- token: string;
5820
- exp: number;
5821
- }) => void) => void;
5822
- onPause: (handler: () => void) => void;
5823
- onResume: (handler: () => void) => void;
5824
- onForceExit: (handler: () => void) => void;
5825
- onOverlay: (handler: (isVisible: boolean) => void) => void;
5826
- ready: () => void;
5827
- sendTelemetry: (data: {
5828
- fps: number;
5829
- mem: number;
5830
- }) => void;
5831
- removeListener: (eventType: MessageEvents, handler: ((context: GameContextPayload) => void) | ((data: {
5832
- token: string;
5833
- exp: number;
5834
- }) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
5835
- removeAllListeners: () => void;
5836
- getListenerCounts: () => Record<string, number>;
5837
- assets: {
5838
- url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
5839
- fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
5840
- json: <T = unknown>(path: string) => Promise<T>;
5841
- blob: (path: string) => Promise<Blob>;
5842
- text: (path: string) => Promise<string>;
5843
- arrayBuffer: (path: string) => Promise<ArrayBuffer>;
5844
- };
5845
- };
5846
- /**
5847
- * TimeBack integration for activity tracking and user context.
5848
- *
5849
- * User context (cached from init, refreshable):
5850
- * - `user.role` - User's role (student, parent, teacher, etc.)
5851
- * - `user.enrollments` - Courses the player is enrolled in for this game
5852
- * - `user.organizations` - Schools/districts the player belongs to
5853
- * - `user.fetch()` - Refresh user context from server
5854
- *
5855
- * Activity tracking:
5856
- * - `startActivity(metadata)` - Begin tracking an activity
5857
- * - `pauseActivity()` / `resumeActivity()` - Pause/resume timer
5858
- * - `endActivity(scoreData)` - Submit activity results to TimeBack
5859
- */
5860
- timeback: {
5861
- readonly user: TimebackUser;
5862
- startActivity: (metadata: ActivityData) => void;
5863
- pauseActivity: () => void;
5864
- resumeActivity: () => void;
5865
- endActivity: (data: EndActivityScoreData) => Promise<EndActivityResponse>;
5866
- };
5867
- /**
5868
- * Playcademy Credits (platform currency) management.
5869
- * - `get()` - Get user's credit balance
5870
- * - `add(amount)` - Award credits to user
5871
- */
5872
- credits: {
5873
- balance: () => Promise<number>;
5874
- add: (amount: number) => Promise<number>;
5875
- spend: (amount: number) => Promise<number>;
5876
- };
5877
- /**
5878
- * Game score submission and leaderboards.
5879
- * - `submit(gameId, score, metadata?)` - Record a game score
5880
- */
5881
- scores: {
5882
- submit: (gameId: string, score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
5883
- };
5884
- /**
5885
- * Realtime multiplayer authentication.
5886
- * - `getToken()` - Get token for WebSocket/realtime connections
5887
- */
5888
- realtime: {
5889
- token: {
5890
- get: () => Promise<RealtimeTokenResponse>;
5891
- };
5892
- };
5893
- /**
5894
- * Make requests to your game's custom backend API routes.
5895
- * - `get(path)`, `post(path, body)`, `put()`, `delete()` - HTTP methods
5896
- * - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
5897
- */
5898
- backend: {
5899
- get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
5900
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5901
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5902
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5903
- delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
5904
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5905
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
5906
- url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
5907
- };
5908
- /** Auto-initializes a PlaycademyClient with context from the environment */
5909
- static init: typeof init;
5910
- /** Authenticates a user with email and password */
5911
- static login: typeof login;
5912
- /** Static identity utilities for OAuth operations */
5913
- static identity: {
5914
- parseOAuthState: typeof parseOAuthState;
5915
- };
5916
- }
5917
-
5918
- /**
5919
- * Type definitions for the game timeback namespace.
5779
+ * Auto-initializes a PlaycademyClient with context from the environment.
5780
+ * Works in both iframe mode (production/development) and standalone mode (local dev).
5920
5781
  *
5921
- * SDK-specific types like TimebackInitContext that wrap the core types
5922
- * from @playcademy/types/user (which are re-exported via types/data.ts).
5923
- */
5924
-
5925
- /**
5926
- * A TimeBack enrollment for the current game session.
5927
- * Alias for UserEnrollment without the optional gameId.
5928
- */
5782
+ * This is the recommended way to initialize the SDK as it automatically:
5783
+ * - Detects the runtime environment (iframe vs standalone)
5784
+ * - Configures the client with the appropriate context
5785
+ * - Sets up event listeners for token refresh
5786
+ * - Exposes the client for debugging in development mode
5787
+ *
5788
+ * @param options - Optional configuration overrides
5789
+ * @param options.baseUrl - Override the base URL for API requests
5790
+ * @returns Promise resolving to a fully initialized PlaycademyClient
5791
+ * @throws Error if not running in a browser context
5792
+ *
5793
+ * @example
5794
+ * ```typescript
5795
+ * // Default initialization
5796
+ * const client = await PlaycademyClient.init()
5797
+ *
5798
+ * // With custom base URL
5799
+ * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
5800
+ * ```
5801
+ */
5802
+ declare function init<T extends PlaycademyBaseClient = PlaycademyBaseClient>(this: new (config?: Partial<ClientConfig>) => T, options?: {
5803
+ baseUrl?: string;
5804
+ allowedParentOrigins?: string[];
5805
+ onDisconnect?: DisconnectHandler;
5806
+ enableConnectionMonitoring?: boolean;
5807
+ }): Promise<T>;
5808
+
5809
+ /**
5810
+ * Authenticates a user with email and password.
5811
+ *
5812
+ * This is a standalone authentication method that doesn't require an initialized client.
5813
+ * Use this for login flows before creating a client instance.
5814
+ *
5815
+ * @deprecated Use client.auth.login() instead for better error handling and automatic token management
5816
+ *
5817
+ * @param baseUrl - The base URL of the Playcademy API
5818
+ * @param email - User's email address
5819
+ * @param password - User's password
5820
+ * @returns Promise resolving to authentication response with token
5821
+ * @throws PlaycademyError if authentication fails or network error occurs
5822
+ *
5823
+ * @example
5824
+ * ```typescript
5825
+ * // Preferred approach:
5826
+ * const client = new PlaycademyClient({ baseUrl: '/api' })
5827
+ * const result = await client.auth.login({
5828
+ * email: 'user@example.com',
5829
+ * password: 'password'
5830
+ * })
5831
+ *
5832
+ * // Legacy approach (still works):
5833
+ * try {
5834
+ * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
5835
+ * const client = new PlaycademyClient({ token: response.token })
5836
+ * } catch (error) {
5837
+ * console.error('Login failed:', error.message)
5838
+ * }
5839
+ * ```
5840
+ */
5841
+ declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
5842
+
5843
+ /**
5844
+ * Type definitions for the game timeback namespace.
5845
+ *
5846
+ * SDK-specific types like TimebackInitContext that wrap the core types
5847
+ * from @playcademy/types/user (which are re-exported via types/data.ts).
5848
+ */
5849
+
5850
+ /**
5851
+ * A TimeBack enrollment for the current game session.
5852
+ * Alias for UserEnrollment without the optional gameId.
5853
+ */
5929
5854
  type TimebackEnrollment = Omit<UserEnrollment, 'gameId'>;
5930
5855
  /**
5931
5856
  * A TimeBack organization (school/district) for the current user.
@@ -5960,6 +5885,45 @@ interface TimebackUserContext {
5960
5885
  /** User's organizations (schools/districts) */
5961
5886
  organizations: TimebackOrganization[];
5962
5887
  }
5888
+ /**
5889
+ * XP data access for the current user.
5890
+ * Results are cached for 5 seconds to avoid redundant network requests.
5891
+ */
5892
+ interface TimebackUserXp {
5893
+ /**
5894
+ * Fetch XP data from the server.
5895
+ * Returns XP for all courses in this game, or filter by grade/subject.
5896
+ * Results are cached for 5 seconds (use `force: true` to bypass).
5897
+ *
5898
+ * @param options - Query options
5899
+ * @param options.grade - Grade level to filter (must be used with subject)
5900
+ * @param options.subject - Subject to filter (must be used with grade)
5901
+ * @param options.include - Additional data to include: 'perCourse', 'today'
5902
+ * @param options.force - Bypass cache and fetch fresh data (default: false)
5903
+ * @returns Promise resolving to XP data
5904
+ *
5905
+ * @example
5906
+ * ```typescript
5907
+ * // Get total XP for all game courses
5908
+ * const xp = await client.timeback.user.xp.fetch()
5909
+ *
5910
+ * // Get XP for a specific grade/subject
5911
+ * const xp = await client.timeback.user.xp.fetch({
5912
+ * grade: 3,
5913
+ * subject: 'Math'
5914
+ * })
5915
+ *
5916
+ * // Get XP with per-course breakdown
5917
+ * const xp = await client.timeback.user.xp.fetch({
5918
+ * include: ['perCourse', 'today']
5919
+ * })
5920
+ *
5921
+ * // Force fresh data
5922
+ * const xp = await client.timeback.user.xp.fetch({ force: true })
5923
+ * ```
5924
+ */
5925
+ fetch(options?: GetXpOptions): Promise<XpResponse>;
5926
+ }
5963
5927
  /**
5964
5928
  * TimeBack user object with both cached getters and fetch method.
5965
5929
  */
@@ -5973,6 +5937,42 @@ interface TimebackUser extends TimebackUserContext {
5973
5937
  fetch(options?: {
5974
5938
  force?: boolean;
5975
5939
  }): Promise<TimebackUserContext>;
5940
+ /**
5941
+ * XP data for the current user.
5942
+ * Call `xp.fetch()` to get XP from the server.
5943
+ */
5944
+ xp: TimebackUserXp;
5945
+ }
5946
+ /**
5947
+ * Options for querying student XP.
5948
+ */
5949
+ interface GetXpOptions {
5950
+ /** Grade level to filter (must be used with subject) */
5951
+ grade?: TimebackGrade;
5952
+ /** Subject to filter (must be used with grade) */
5953
+ subject?: TimebackSubject;
5954
+ /** Additional data to include: 'perCourse', 'today' */
5955
+ include?: ('perCourse' | 'today')[];
5956
+ /** Bypass cache and fetch fresh data (default: false) */
5957
+ force?: boolean;
5958
+ }
5959
+ /**
5960
+ * XP data for a single course.
5961
+ */
5962
+ interface CourseXp {
5963
+ grade: TimebackGrade;
5964
+ subject: TimebackSubject;
5965
+ title: string;
5966
+ totalXp: number;
5967
+ todayXp?: number;
5968
+ }
5969
+ /**
5970
+ * Response from XP query.
5971
+ */
5972
+ interface XpResponse {
5973
+ totalXp: number;
5974
+ todayXp?: number;
5975
+ courses?: CourseXp[];
5976
5976
  }
5977
5977
 
5978
5978
  /**
@@ -6497,6 +6497,9 @@ interface CustomRoutesIntegration {
6497
6497
  interface DatabaseIntegration {
6498
6498
  /** Database directory (defaults to 'db') */
6499
6499
  directory?: string;
6500
+ /** Schema strategy: 'push' uses drizzle-kit push-style diffing, 'migrate' uses migration files.
6501
+ * When omitted, auto-detects based on presence of a migrations directory with _journal.json. */
6502
+ strategy?: 'push' | 'migrate';
6500
6503
  }
6501
6504
  /**
6502
6505
  * Integrations configuration
@@ -6703,8 +6706,8 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
6703
6706
  */
6704
6707
  runtime: {
6705
6708
  getGameToken: (gameId: string, options?: {
6706
- apply?: boolean | undefined;
6707
- } | undefined) => Promise<GameTokenResponse>;
6709
+ apply?: boolean;
6710
+ }) => Promise<GameTokenResponse>;
6708
6711
  exit: () => Promise<void>;
6709
6712
  onInit: (handler: (context: GameContextPayload) => void) => void;
6710
6713
  onTokenRefresh: (handler: (data: {
@@ -6728,7 +6731,7 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
6728
6731
  getListenerCounts: () => Record<string, number>;
6729
6732
  assets: {
6730
6733
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
6731
- fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
6734
+ fetch: (path: string, options?: RequestInit) => Promise<Response>;
6732
6735
  json: <T = unknown>(path: string) => Promise<T>;
6733
6736
  blob: (path: string) => Promise<Blob>;
6734
6737
  text: (path: string) => Promise<string>;
@@ -6759,13 +6762,13 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
6759
6762
  * - `get(path)`, `post(path, body)`, `put()`, `delete()` - HTTP methods
6760
6763
  */
6761
6764
  backend: {
6762
- get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
6763
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
6764
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
6765
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
6766
- delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
6767
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
6768
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
6765
+ get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
6766
+ post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
6767
+ put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
6768
+ patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
6769
+ delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
6770
+ request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
6771
+ download(path: string, method?: Method, body?: unknown, headers?: Record<string, string>): Promise<Response>;
6769
6772
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
6770
6773
  };
6771
6774
  /**
@@ -6780,21 +6783,28 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
6780
6783
  password: string;
6781
6784
  }) => Promise<{
6782
6785
  success: boolean;
6783
- token?: string | undefined;
6786
+ token?: string;
6784
6787
  user?: {
6785
6788
  id: string;
6786
6789
  email: string;
6787
- } | undefined;
6788
- expiresAt?: string | undefined;
6789
- error?: string | undefined;
6790
+ };
6791
+ expiresAt?: string;
6792
+ error?: string;
6790
6793
  }>;
6791
6794
  logout: () => Promise<void>;
6792
6795
  apiKeys: {
6793
6796
  create: (options?: {
6794
- name?: string | undefined;
6795
- expiresIn?: number | null | undefined;
6796
- permissions?: Record<string, string[]> | undefined;
6797
- } | undefined) => Promise<BetterAuthApiKeyResponse>;
6797
+ name?: string;
6798
+ expiresIn
6799
+ /**
6800
+ * Platform-wide achievements system.
6801
+ * - `list()` - Get all achievements
6802
+ * - `getUserAchievements()` - Get user's earned achievements
6803
+ * - `award(achievementId)` - Grant achievement to user
6804
+ */
6805
+ ?: number | null;
6806
+ permissions?: Record<string, string[]>;
6807
+ }) => Promise<BetterAuthApiKeyResponse>;
6798
6808
  list: () => Promise<BetterAuthApiKey[]>;
6799
6809
  revoke: (keyId: string) => Promise<void>;
6800
6810
  };
@@ -6811,198 +6821,143 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
6811
6821
  resumeGame: (gameId: string) => Promise<void>;
6812
6822
  };
6813
6823
  items: {
6814
- create: (props: {
6815
- id?: string | undefined;
6824
+ create: (props: InsertItemInput) => Promise<{
6825
+ gameId: string | null;
6826
+ id: string;
6816
6827
  slug: string;
6817
- gameId?: string | null | undefined;
6818
6828
  displayName: string;
6819
- description?: string | null | undefined;
6820
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
6821
- isPlaceable?: boolean | undefined;
6822
- imageUrl?: string | null | undefined;
6823
- metadata?: Record<string, unknown> | undefined;
6824
- createdAt?: Date | undefined;
6825
- }) => Promise<{
6826
- createdAt: Date;
6827
6829
  description: string | null;
6828
- displayName: string;
6829
- gameId: string | null;
6830
- id: string;
6831
- imageUrl: string | null;
6830
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
6832
6831
  isPlaceable: boolean;
6832
+ imageUrl: string | null;
6833
6833
  metadata: unknown;
6834
- slug: string;
6835
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
6834
+ createdAt: Date;
6836
6835
  }>;
6837
6836
  get: (itemId: string) => Promise<{
6838
- createdAt: Date;
6839
- description: string | null;
6840
- displayName: string;
6841
6837
  gameId: string | null;
6842
6838
  id: string;
6843
- imageUrl: string | null;
6839
+ slug: string;
6840
+ displayName: string;
6841
+ description: string | null;
6842
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
6844
6843
  isPlaceable: boolean;
6844
+ imageUrl: string | null;
6845
6845
  metadata: unknown;
6846
- slug: string;
6847
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
6846
+ createdAt: Date;
6848
6847
  }>;
6849
6848
  list: () => Promise<{
6850
- createdAt: Date;
6851
- description: string | null;
6852
- displayName: string;
6853
6849
  gameId: string | null;
6854
6850
  id: string;
6855
- imageUrl: string | null;
6851
+ slug: string;
6852
+ displayName: string;
6853
+ description: string | null;
6854
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
6856
6855
  isPlaceable: boolean;
6856
+ imageUrl: string | null;
6857
6857
  metadata: unknown;
6858
- slug: string;
6859
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
6860
- }[]>;
6861
- update: (itemId: string, props: {
6862
- slug?: string | undefined;
6863
- gameId?: string | null | undefined;
6864
- displayName?: string | undefined;
6865
- description?: string | null | undefined;
6866
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
6867
- isPlaceable?: boolean | undefined;
6868
- imageUrl?: string | null | undefined;
6869
- metadata?: Record<string, unknown> | undefined;
6870
- }) => Promise<{
6871
6858
  createdAt: Date;
6872
- description: string | null;
6873
- displayName: string;
6859
+ }[]>;
6860
+ update: (itemId: string, props: UpdateItemInput) => Promise<{
6874
6861
  gameId: string | null;
6875
6862
  id: string;
6876
- imageUrl: string | null;
6863
+ slug: string;
6864
+ displayName: string;
6865
+ description: string | null;
6866
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
6877
6867
  isPlaceable: boolean;
6868
+ imageUrl: string | null;
6878
6869
  metadata: unknown;
6879
- slug: string;
6880
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
6870
+ createdAt: Date;
6881
6871
  }>;
6882
6872
  delete: (itemId: string) => Promise<void>;
6883
6873
  };
6884
6874
  currencies: {
6885
- create: (props: {
6886
- id?: string | undefined;
6887
- itemId: string;
6888
- symbol?: string | null | undefined;
6889
- isPrimary: boolean;
6890
- createdAt?: Date | undefined;
6891
- updatedAt?: Date | null | undefined;
6892
- }) => Promise<{
6893
- createdAt: Date;
6875
+ create: (props: InsertCurrencyInput) => Promise<{
6876
+ symbol: string | null;
6894
6877
  id: string;
6895
- isPrimary: boolean;
6878
+ createdAt: Date;
6896
6879
  itemId: string;
6897
- symbol: string | null;
6898
6880
  updatedAt: Date | null;
6881
+ isPrimary: boolean;
6899
6882
  }>;
6900
6883
  get: (currencyId: string) => Promise<{
6901
- createdAt: Date;
6884
+ symbol: string | null;
6902
6885
  id: string;
6903
- isPrimary: boolean;
6886
+ createdAt: Date;
6904
6887
  itemId: string;
6905
- symbol: string | null;
6906
6888
  updatedAt: Date | null;
6889
+ isPrimary: boolean;
6907
6890
  }>;
6908
6891
  list: () => Promise<{
6909
- createdAt: Date;
6892
+ symbol: string | null;
6910
6893
  id: string;
6911
- isPrimary: boolean;
6894
+ createdAt: Date;
6912
6895
  itemId: string;
6913
- symbol: string | null;
6914
6896
  updatedAt: Date | null;
6897
+ isPrimary: boolean;
6915
6898
  }[]>;
6916
- update: (currencyId: string, props: {
6917
- itemId?: string | undefined;
6918
- symbol?: string | null | undefined;
6919
- isPrimary?: boolean | undefined;
6920
- }) => Promise<{
6921
- createdAt: Date;
6899
+ update: (currencyId: string, props: UpdateCurrencyInput) => Promise<{
6900
+ symbol: string | null;
6922
6901
  id: string;
6923
- isPrimary: boolean;
6902
+ createdAt: Date;
6924
6903
  itemId: string;
6925
- symbol: string | null;
6926
6904
  updatedAt: Date | null;
6905
+ isPrimary: boolean;
6927
6906
  }>;
6928
6907
  delete: (currencyId: string) => Promise<void>;
6929
6908
  };
6930
6909
  shopListings: {
6931
- create: (props: {
6932
- id?: string | undefined;
6910
+ create: (props: InsertShopListingInput) => Promise<{
6911
+ id: string;
6912
+ createdAt: Date;
6933
6913
  itemId: string;
6914
+ updatedAt: Date | null;
6934
6915
  currencyId: string;
6935
6916
  price: number;
6936
- sellBackPercentage?: number | null | undefined;
6937
- stock?: number | null | undefined;
6917
+ sellBackPercentage: number | null;
6918
+ stock: number | null;
6938
6919
  isActive: boolean;
6939
- availableFrom?: Date | null | undefined;
6940
- availableUntil?: Date | null | undefined;
6941
- createdAt?: Date | undefined;
6942
- updatedAt?: Date | null | undefined;
6943
- }) => Promise<{
6944
6920
  availableFrom: Date | null;
6945
6921
  availableUntil: Date | null;
6946
- createdAt: Date;
6947
- currencyId: string;
6948
- id: string;
6949
- isActive: boolean;
6950
- itemId: string;
6951
- price: number;
6952
- sellBackPercentage: number | null;
6953
- stock: number | null;
6954
- updatedAt: Date | null;
6955
6922
  }>;
6956
6923
  get: (listingId: string) => Promise<{
6957
- availableFrom: Date | null;
6958
- availableUntil: Date | null;
6959
- createdAt: Date;
6960
- currencyId: string;
6961
6924
  id: string;
6962
- isActive: boolean;
6925
+ createdAt: Date;
6963
6926
  itemId: string;
6927
+ updatedAt: Date | null;
6928
+ currencyId: string;
6964
6929
  price: number;
6965
6930
  sellBackPercentage: number | null;
6966
6931
  stock: number | null;
6967
- updatedAt: Date | null;
6968
- }>;
6969
- list: () => Promise<{
6932
+ isActive: boolean;
6970
6933
  availableFrom: Date | null;
6971
6934
  availableUntil: Date | null;
6972
- createdAt: Date;
6973
- currencyId: string;
6935
+ }>;
6936
+ list: () => Promise<{
6974
6937
  id: string;
6975
- isActive: boolean;
6938
+ createdAt: Date;
6976
6939
  itemId: string;
6940
+ updatedAt: Date | null;
6941
+ currencyId: string;
6977
6942
  price: number;
6978
6943
  sellBackPercentage: number | null;
6979
6944
  stock: number | null;
6980
- updatedAt: Date | null;
6981
- }[]>;
6982
- update: (listingId: string, props: {
6983
- id?: string | undefined;
6984
- itemId?: string | undefined;
6985
- currencyId?: string | undefined;
6986
- price?: number | undefined;
6987
- sellBackPercentage?: number | null | undefined;
6988
- stock?: number | null | undefined;
6989
- isActive?: boolean | undefined;
6990
- availableFrom?: Date | null | undefined;
6991
- availableUntil?: Date | null | undefined;
6992
- createdAt?: Date | undefined;
6993
- updatedAt?: Date | null | undefined;
6994
- }) => Promise<{
6945
+ isActive: boolean;
6995
6946
  availableFrom: Date | null;
6996
6947
  availableUntil: Date | null;
6997
- createdAt: Date;
6998
- currencyId: string;
6948
+ }[]>;
6949
+ update: (listingId: string, props: UpdateShopListingInput) => Promise<{
6999
6950
  id: string;
7000
- isActive: boolean;
6951
+ createdAt: Date;
7001
6952
  itemId: string;
6953
+ updatedAt: Date | null;
6954
+ currencyId: string;
7002
6955
  price: number;
7003
6956
  sellBackPercentage: number | null;
7004
6957
  stock: number | null;
7005
- updatedAt: Date | null;
6958
+ isActive: boolean;
6959
+ availableFrom: Date | null;
6960
+ availableUntil: Date | null;
7006
6961
  }>;
7007
6962
  delete: (listingId: string) => Promise<void>;
7008
6963
  };
@@ -7016,31 +6971,17 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7016
6971
  dev: {
7017
6972
  status: {
7018
6973
  apply: () => Promise<void>;
7019
- get: () => Promise<DeveloperStatusEnumType>;
6974
+ get: () => Promise<DeveloperStatusValue>;
7020
6975
  };
7021
6976
  games: {
7022
6977
  deploy: (slug: string, options: {
7023
- metadata?: {
7024
- displayName: string;
7025
- mapElementId?: string | null | undefined;
7026
- platform: "godot" | "unity" | "web";
7027
- metadata: Record<string, unknown>;
7028
- gameType: "external" | "hosted";
7029
- externalUrl?: string | undefined;
7030
- } | undefined;
7031
- file?: Blob | File | null | undefined;
7032
- backend?: BackendDeploymentBundle | undefined;
7033
- hooks?: DevUploadHooks | undefined;
7034
- }) => Promise<Game>;
7035
- seed: (slug: string, code: string, environment?: "production" | "staging" | undefined, secrets?: Record<string, string> | undefined) => Promise<SeedResponse>;
7036
- upsert: (slug: string, metadata: {
7037
- displayName: string;
7038
- mapElementId?: string | null | undefined;
7039
- platform: "godot" | "unity" | "web";
7040
- metadata: Record<string, unknown>;
7041
- gameType: "external" | "hosted";
7042
- externalUrl?: string | undefined;
6978
+ metadata?: UpsertGameMetadataInput;
6979
+ file?: File | Blob | null;
6980
+ backend?: BackendDeploymentBundle;
6981
+ hooks?: DevUploadHooks;
7043
6982
  }) => Promise<Game>;
6983
+ seed: (slug: string, code: string, environment?: "staging" | "production", secrets?: Record<string, string>) => Promise<SeedResponse>;
6984
+ upsert: (slug: string, metadata: UpsertGameMetadataInput) => Promise<Game>;
7044
6985
  delete: (gameId: string) => Promise<void>;
7045
6986
  secrets: {
7046
6987
  set: (slug: string, secrets: Record<string, string>) => Promise<string[]>;
@@ -7051,7 +6992,7 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7051
6992
  reset: (slug: string, schema?: {
7052
6993
  sql: string;
7053
6994
  hash: string;
7054
- } | undefined) => Promise<{
6995
+ }) => Promise<{
7055
6996
  success: boolean;
7056
6997
  deploymentId: string;
7057
6998
  resetAt: string;
@@ -7059,13 +7000,13 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7059
7000
  }>;
7060
7001
  };
7061
7002
  bucket: {
7062
- list: (slug: string, prefix?: string | undefined) => Promise<BucketFile[]>;
7003
+ list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
7063
7004
  get: (slug: string, key: string) => Promise<ArrayBuffer>;
7064
- put: (slug: string, key: string, content: ArrayBuffer | Blob | Uint8Array<ArrayBufferLike>, contentType?: string | undefined) => Promise<void>;
7005
+ put: (slug: string, key: string, content: Blob | ArrayBuffer | Uint8Array, contentType?: string) => Promise<void>;
7065
7006
  delete: (slug: string, key: string) => Promise<void>;
7066
7007
  };
7067
7008
  kv: {
7068
- list: (slug: string, prefix?: string | undefined) => Promise<KVKeyEntry[]>;
7009
+ list: (slug: string, prefix?: string) => Promise<KVKeyEntry[]>;
7069
7010
  get: (slug: string, key: string) => Promise<string | null>;
7070
7011
  set: (slug: string, key: string, value: string) => Promise<void>;
7071
7012
  delete: (slug: string, key: string) => Promise<void>;
@@ -7077,177 +7018,30 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7077
7018
  domains: {
7078
7019
  add: (slug: string, hostname: string) => Promise<GameCustomHostname>;
7079
7020
  list: (slug: string) => Promise<GameCustomHostname[]>;
7080
- status: (slug: string, hostname: string, refresh?: boolean | undefined) => Promise<GameCustomHostname>;
7021
+ status: (slug: string, hostname: string, refresh?: boolean) => Promise<GameCustomHostname>;
7081
7022
  delete: (slug: string, hostname: string) => Promise<void>;
7082
7023
  };
7083
7024
  logs: {
7084
- getToken: (slug: string, environment: "production" | "staging") => Promise<{
7025
+ getToken: (slug: string, environment: "staging" | "production") => Promise<{
7085
7026
  token: string;
7086
7027
  workerId: string;
7087
7028
  }>;
7088
7029
  };
7089
7030
  };
7090
7031
  items: {
7091
- create: (gameId: string, slug: string, itemData: Omit<{
7092
- id?: string | undefined;
7093
- slug: string;
7094
- gameId?: string | null | undefined;
7095
- displayName: string;
7096
- description?: string | null | undefined;
7097
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
7098
- isPlaceable?: boolean | undefined;
7099
- imageUrl?: string | null | undefined;
7100
- metadata?: Record<string, unknown> | undefined;
7101
- createdAt?: Date | undefined;
7102
- }, "gameId" | "slug">) => Promise<{
7103
- createdAt: Date;
7104
- description: string | null;
7105
- displayName: string;
7106
- gameId: string | null;
7107
- id: string;
7108
- imageUrl: string | null;
7109
- isPlaceable: boolean;
7110
- metadata: unknown;
7111
- slug: string;
7112
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
7113
- }>;
7114
- update: (gameId: string, itemId: string, updates: {
7115
- slug?: string | undefined;
7116
- gameId?: string | null | undefined;
7117
- displayName?: string | undefined;
7118
- description?: string | null | undefined;
7119
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
7120
- isPlaceable?: boolean | undefined;
7121
- imageUrl?: string | null | undefined;
7122
- metadata?: Record<string, unknown> | undefined;
7123
- }) => Promise<{
7124
- createdAt: Date;
7125
- description: string | null;
7126
- displayName: string;
7127
- gameId: string | null;
7128
- id: string;
7129
- imageUrl: string | null;
7130
- isPlaceable: boolean;
7131
- metadata: unknown;
7132
- slug: string;
7133
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
7134
- }>;
7135
- list: (gameId: string) => Promise<{
7136
- createdAt: Date;
7137
- description: string | null;
7138
- displayName: string;
7139
- gameId: string | null;
7140
- id: string;
7141
- imageUrl: string | null;
7142
- isPlaceable: boolean;
7143
- metadata: unknown;
7144
- slug: string;
7145
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
7146
- }[]>;
7147
- get: (gameId: string, slug: string) => Promise<{
7148
- createdAt: Date;
7149
- description: string | null;
7150
- displayName: string;
7151
- gameId: string | null;
7152
- id: string;
7153
- imageUrl: string | null;
7154
- isPlaceable: boolean;
7155
- metadata: unknown;
7156
- slug: string;
7157
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
7158
- }>;
7032
+ create: (gameId: string, slug: string, itemData: Omit<InsertItemInput, "slug" | "gameId">) => Promise<ItemRow>;
7033
+ update: (gameId: string, itemId: string, updates: UpdateItemInput) => Promise<ItemRow>;
7034
+ list: (gameId: string) => Promise<Array<ItemRow>>;
7035
+ get: (gameId: string, slug: string) => Promise<ItemRow>;
7159
7036
  delete: (gameId: string, itemId: string) => Promise<void>;
7160
7037
  shop: {
7161
- create: (gameId: string, itemId: string, listingData: Omit<{
7162
- id?: string | undefined;
7163
- itemId: string;
7164
- currencyId: string;
7165
- price: number;
7166
- sellBackPercentage?: number | null | undefined;
7167
- stock?: number | null | undefined;
7168
- isActive: boolean;
7169
- availableFrom?: Date | null | undefined;
7170
- availableUntil?: Date | null | undefined;
7171
- createdAt?: Date | undefined;
7172
- updatedAt?: Date | null | undefined;
7173
- }, "itemId">) => Promise<{
7174
- availableFrom: Date | null;
7175
- availableUntil: Date | null;
7176
- createdAt: Date;
7177
- currencyId: string;
7178
- id: string;
7179
- isActive: boolean;
7180
- itemId: string;
7181
- price: number;
7182
- sellBackPercentage: number | null;
7183
- stock: number | null;
7184
- updatedAt: Date | null;
7185
- }>;
7186
- get: (gameId: string, itemId: string) => Promise<{
7187
- availableFrom: Date | null;
7188
- availableUntil: Date | null;
7189
- createdAt: Date;
7190
- currencyId: string;
7191
- id: string;
7192
- isActive: boolean;
7193
- itemId: string;
7194
- price: number;
7195
- sellBackPercentage: number | null;
7196
- stock: number | null;
7197
- updatedAt: Date | null;
7198
- } | null>;
7199
- update: (gameId: string, itemId: string, updates: {
7200
- id?: string | undefined;
7201
- itemId?: string | undefined;
7202
- currencyId?: string | undefined;
7203
- price?: number | undefined;
7204
- sellBackPercentage?: number | null | undefined;
7205
- stock?: number | null | undefined;
7206
- isActive?: boolean | undefined;
7207
- availableFrom?: Date | null | undefined;
7208
- availableUntil?: Date | null | undefined;
7209
- createdAt?: Date | undefined;
7210
- updatedAt?: Date | null | undefined;
7211
- }) => Promise<{
7212
- availableFrom: Date | null;
7213
- availableUntil: Date | null;
7214
- createdAt: Date;
7215
- currencyId: string;
7216
- id: string;
7217
- isActive: boolean;
7218
- itemId: string;
7219
- price: number;
7220
- sellBackPercentage: number | null;
7221
- stock: number | null;
7222
- updatedAt: Date | null;
7223
- }>;
7038
+ create: (gameId: string, itemId: string, listingData: Omit<InsertShopListingInput, "itemId">) => Promise<ShopListingRow>;
7039
+ get: (gameId: string, itemId: string) => Promise<ShopListingRow | null>;
7040
+ update: (gameId: string, itemId: string, updates: UpdateShopListingInput) => Promise<ShopListingRow>;
7224
7041
  delete: (gameId: string, itemId: string) => Promise<void>;
7225
- list: (gameId: string) => Promise<({
7226
- availableFrom: Date | null;
7227
- availableUntil: Date | null;
7228
- createdAt: Date;
7229
- currencyId: string;
7230
- id: string;
7231
- isActive: boolean;
7232
- itemId: string;
7233
- price: number;
7234
- sellBackPercentage: number | null;
7235
- stock: number | null;
7236
- updatedAt: Date | null;
7237
- } & {
7238
- item: {
7239
- createdAt: Date;
7240
- description: string | null;
7241
- displayName: string;
7242
- gameId: string | null;
7243
- id: string;
7244
- imageUrl: string | null;
7245
- isPlaceable: boolean;
7246
- metadata: unknown;
7247
- slug: string;
7248
- type: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
7249
- };
7250
- })[]>;
7042
+ list: (gameId: string) => Promise<Array<ShopListingRow & {
7043
+ item: ItemRow;
7044
+ }>>;
7251
7045
  };
7252
7046
  };
7253
7047
  };
@@ -7259,21 +7053,21 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7259
7053
  * - `getGameToken(gameId)` - Get short-lived game auth token
7260
7054
  */
7261
7055
  games: {
7262
- fetch: (gameIdOrSlug: string, options?: TTLCacheConfig | undefined) => Promise<FetchedGame>;
7263
- list: (options?: TTLCacheConfig | undefined) => Promise<Game[]>;
7056
+ fetch: (gameIdOrSlug: string, options?: TTLCacheConfig) => Promise<FetchedGame>;
7057
+ list: (options?: TTLCacheConfig) => Promise<Array<Game>>;
7264
7058
  getSubjects: () => Promise<Record<string, string | null>>;
7265
- startSession: (gameId?: string | undefined) => Promise<StartSessionResponse>;
7266
- endSession: (sessionId: string, gameId?: string | undefined) => Promise<void>;
7059
+ startSession: (gameId?: string) => Promise<StartSessionResponse>;
7060
+ endSession: (sessionId: string, gameId?: string) => Promise<void>;
7267
7061
  token: {
7268
7062
  create: (gameId: string, options?: {
7269
- apply?: boolean | undefined;
7270
- } | undefined) => Promise<GameTokenResponse>;
7063
+ apply?: boolean;
7064
+ }) => Promise<GameTokenResponse>;
7271
7065
  };
7272
7066
  leaderboard: {
7273
7067
  get: (gameId: string, options?: {
7274
- limit?: number | undefined;
7275
- offset?: number | undefined;
7276
- } | undefined) => Promise<LeaderboardEntry[]>;
7068
+ limit?: number;
7069
+ offset?: number;
7070
+ }) => Promise<LeaderboardEntry[]>;
7277
7071
  };
7278
7072
  };
7279
7073
  /**
@@ -7282,34 +7076,20 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7282
7076
  * - `update(config)` - Update avatar appearance
7283
7077
  */
7284
7078
  character: {
7285
- get: (userId?: string | undefined) => Promise<PlayerCharacterRow | null>;
7079
+ get: (userId?: string) => Promise<PlayerCharacterRow | null>;
7286
7080
  create: (characterData: CreateCharacterData) => Promise<PlayerCharacterRow>;
7287
7081
  update: (updates: UpdateCharacterData) => Promise<PlayerCharacterRow>;
7288
7082
  components: {
7289
- list: (options?: (CharacterComponentsOptions & TTLCacheConfig) | undefined) => Promise<CharacterComponentWithSpriteUrl[]>;
7290
- clearCache: (key?: string | undefined) => void;
7083
+ list: (options?: CharacterComponentsOptions & TTLCacheConfig) => Promise<CharacterComponentWithSpriteUrl[]>;
7084
+ clearCache: (key?: string) => void;
7291
7085
  getCacheKeys: () => string[];
7292
7086
  };
7293
7087
  accessories: {
7294
- equip: (slot: string, componentId: string) => Promise<{
7295
- accessoryComponentId: string;
7296
- equippedAt: Date;
7297
- id: string;
7298
- playerCharacterId: string;
7299
- slot: string;
7300
- updatedAt: Date;
7301
- }>;
7088
+ equip: (slot: string, componentId: string) => Promise<PlayerCharacterAccessoryRow>;
7302
7089
  remove: (slot: string) => Promise<{
7303
7090
  success: boolean;
7304
7091
  }>;
7305
- list: () => Promise<{
7306
- accessoryComponentId: string;
7307
- equippedAt: Date;
7308
- id: string;
7309
- playerCharacterId: string;
7310
- slot: string;
7311
- updatedAt: Date;
7312
- }[]>;
7092
+ list: () => Promise<PlayerCharacterAccessoryRow[]>;
7313
7093
  };
7314
7094
  };
7315
7095
  /**
@@ -7319,11 +7099,11 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7319
7099
  * - `award(achievementId)` - Grant achievement to user
7320
7100
  */
7321
7101
  achievements: {
7322
- list: (options?: TTLCacheConfig | undefined) => Promise<AchievementCurrent[]>;
7102
+ list: (options?: TTLCacheConfig) => Promise<AchievementCurrent[]>;
7323
7103
  history: {
7324
7104
  list: (queryOptions?: {
7325
- limit?: number | undefined;
7326
- } | undefined, cacheOptions?: TTLCacheConfig | undefined) => Promise<AchievementHistoryEntry[]>;
7105
+ limit?: number;
7106
+ }, cacheOptions?: TTLCacheConfig) => Promise<AchievementHistoryEntry[]>;
7327
7107
  };
7328
7108
  progress: {
7329
7109
  submit: (achievementId: string) => Promise<AchievementProgressResponse>;
@@ -7335,7 +7115,7 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7335
7115
  * - `submit(leaderboardId, score)` - Submit score to leaderboard
7336
7116
  */
7337
7117
  leaderboard: {
7338
- fetch: (options?: LeaderboardOptions | undefined) => Promise<GameLeaderboardEntry[]>;
7118
+ fetch: (options?: LeaderboardOptions) => Promise<GameLeaderboardEntry[]>;
7339
7119
  getUserRank: (gameId: string, userId: string) => Promise<UserRank | null>;
7340
7120
  };
7341
7121
  /**
@@ -7344,36 +7124,16 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7344
7124
  * - `addXp(amount)` - Award XP to user
7345
7125
  */
7346
7126
  levels: {
7347
- get: () => Promise<{
7348
- createdAt: Date;
7349
- currentLevel: number;
7350
- currentXp: number;
7351
- lastLevelUpAt: Date | null;
7352
- totalXP: number;
7353
- updatedAt: Date | null;
7354
- userId: string;
7355
- }>;
7356
- progress: (options?: CooldownCacheConfig | undefined) => Promise<{
7127
+ get: () => Promise<UserLevelRow>;
7128
+ progress: (options?: CooldownCacheConfig) => Promise<{
7357
7129
  level: number;
7358
7130
  currentXp: number;
7359
7131
  xpToNextLevel: number;
7360
7132
  totalXP: number;
7361
7133
  }>;
7362
7134
  config: {
7363
- list: () => Promise<{
7364
- createdAt: Date;
7365
- creditsReward: number;
7366
- id: string;
7367
- level: number;
7368
- xpRequired: number;
7369
- }[]>;
7370
- get: (level: number) => Promise<{
7371
- createdAt: Date;
7372
- creditsReward: number;
7373
- id: string;
7374
- level: number;
7375
- xpRequired: number;
7376
- } | null>;
7135
+ list: () => Promise<LevelConfigRow[]>;
7136
+ get: (level: number) => Promise<LevelConfigRow | null>;
7377
7137
  };
7378
7138
  };
7379
7139
  /**
@@ -7391,108 +7151,23 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7391
7151
  */
7392
7152
  notifications: {
7393
7153
  list: (queryOptions?: {
7394
- status?: NotificationStatus | undefined;
7395
- type?: NotificationType | undefined;
7396
- limit?: number | undefined;
7397
- offset?: number | undefined;
7398
- } | undefined, cacheOptions?: TTLCacheConfig | undefined) => Promise<{
7399
- clickUrl: string | null;
7400
- clickedAt: Date | null;
7401
- createdAt: Date;
7402
- data: unknown;
7403
- deliveredAt: Date | null;
7404
- expiresAt: Date | null;
7405
- id: string;
7406
- message: string;
7407
- metadata: unknown;
7408
- method: string | null;
7409
- priority: "high" | "low" | "normal" | "urgent";
7410
- seenAt: Date | null;
7411
- status: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
7412
- title: string;
7413
- type: string;
7414
- userId: string;
7415
- }[]>;
7416
- markAsSeen: (notificationId: string) => Promise<{
7417
- clickUrl: string | null;
7418
- clickedAt: Date | null;
7419
- createdAt: Date;
7420
- data: unknown;
7421
- deliveredAt: Date | null;
7422
- expiresAt: Date | null;
7423
- id: string;
7424
- message: string;
7425
- metadata: unknown;
7426
- method: string | null;
7427
- priority: "high" | "low" | "normal" | "urgent";
7428
- seenAt: Date | null;
7429
- status: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
7430
- title: string;
7431
- type: string;
7432
- userId: string;
7433
- }>;
7434
- markAsClicked: (notificationId: string) => Promise<{
7435
- clickUrl: string | null;
7436
- clickedAt: Date | null;
7437
- createdAt: Date;
7438
- data: unknown;
7439
- deliveredAt: Date | null;
7440
- expiresAt: Date | null;
7441
- id: string;
7442
- message: string;
7443
- metadata: unknown;
7444
- method: string | null;
7445
- priority: "high" | "low" | "normal" | "urgent";
7446
- seenAt: Date | null;
7447
- status: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
7448
- title: string;
7449
- type: string;
7450
- userId: string;
7451
- }>;
7452
- dismiss: (notificationId: string) => Promise<{
7453
- clickUrl: string | null;
7454
- clickedAt: Date | null;
7455
- createdAt: Date;
7456
- data: unknown;
7457
- deliveredAt: Date | null;
7458
- expiresAt: Date | null;
7459
- id: string;
7460
- message: string;
7461
- metadata: unknown;
7462
- method: string | null;
7463
- priority: "high" | "low" | "normal" | "urgent";
7464
- seenAt: Date | null;
7465
- status: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
7466
- title: string;
7467
- type: string;
7468
- userId: string;
7469
- }>;
7470
- markAsDelivered: (notificationId: string, method?: NotificationMethod) => Promise<{
7471
- clickUrl: string | null;
7472
- clickedAt: Date | null;
7473
- createdAt: Date;
7474
- data: unknown;
7475
- deliveredAt: Date | null;
7476
- expiresAt: Date | null;
7477
- id: string;
7478
- message: string;
7479
- metadata: unknown;
7480
- method: string | null;
7481
- priority: "high" | "low" | "normal" | "urgent";
7482
- seenAt: Date | null;
7483
- status: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
7484
- title: string;
7485
- type: string;
7486
- userId: string;
7487
- }>;
7154
+ status?: NotificationStatus;
7155
+ type?: NotificationType;
7156
+ limit?: number;
7157
+ offset?: number;
7158
+ }, cacheOptions?: TTLCacheConfig) => Promise<NotificationRow[]>;
7159
+ markAsSeen: (notificationId: string) => Promise<NotificationRow>;
7160
+ markAsClicked: (notificationId: string) => Promise<NotificationRow>;
7161
+ dismiss: (notificationId: string) => Promise<NotificationRow>;
7162
+ markAsDelivered: (notificationId: string, method?: NotificationMethod) => Promise<NotificationRow>;
7488
7163
  deliverPending: () => Promise<{
7489
7164
  success: boolean;
7490
7165
  }>;
7491
7166
  stats: {
7492
7167
  get: (queryOptions?: {
7493
- from?: string | undefined;
7494
- to?: string | undefined;
7495
- } | undefined, cacheOptions?: TTLCacheConfig | undefined) => Promise<NotificationStats>;
7168
+ from?: string;
7169
+ to?: string;
7170
+ }, cacheOptions?: TTLCacheConfig) => Promise<NotificationStats>;
7496
7171
  };
7497
7172
  };
7498
7173
  /**
@@ -7501,8 +7176,8 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7501
7176
  * - `unlock(areaId)` - Unlock a new map area
7502
7177
  */
7503
7178
  maps: {
7504
- get: (identifier: string, options?: TTLCacheConfig | undefined) => Promise<MapData>;
7505
- elements: (mapId: string, options?: TTLCacheConfig | undefined) => Promise<MapElementWithGame[]>;
7179
+ get: (identifier: string, options?: TTLCacheConfig) => Promise<MapData>;
7180
+ elements: (mapId: string, options?: TTLCacheConfig) => Promise<MapElementWithGame[]>;
7506
7181
  objects: {
7507
7182
  list: (mapId: string) => Promise<MapObjectWithItem[]>;
7508
7183
  create: (mapId: string, objectData: CreateMapObjectData) => Promise<MapObjectWithItem>;
@@ -7533,10 +7208,10 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7533
7208
  * - `getByUser(userId)` - Get all scores for a user
7534
7209
  */
7535
7210
  scores: {
7536
- submit: (gameId: string, score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
7537
7211
  getByUser: (gameId: string, userId: string, options?: {
7538
- limit?: number | undefined;
7539
- } | undefined) => Promise<UserScore[]>;
7212
+ limit?: number;
7213
+ }) => Promise<UserScore[]>;
7214
+ submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
7540
7215
  };
7541
7216
  /**
7542
7217
  * TimeBack integration for user context, XP tracking, and course management.
@@ -7557,9 +7232,9 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7557
7232
  timeback: {
7558
7233
  readonly user: PlatformTimebackUser;
7559
7234
  populateStudent: (names?: {
7560
- firstName?: string | undefined;
7561
- lastName?: string | undefined;
7562
- } | undefined) => Promise<PopulateStudentResponse>;
7235
+ firstName?: string;
7236
+ lastName?: string;
7237
+ }) => Promise<PopulateStudentResponse>;
7563
7238
  startActivity: (_metadata: ActivityData) => void;
7564
7239
  pauseActivity: () => void;
7565
7240
  resumeActivity: () => void;
@@ -7569,71 +7244,26 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7569
7244
  verify: (gameId: string) => Promise<TimebackVerifyAllResponse>;
7570
7245
  cleanup: (gameId: string) => Promise<void>;
7571
7246
  get: (gameId: string) => Promise<GameTimebackIntegration[]>;
7572
- getConfig: (gameId: string) => Promise<{
7573
- organization: {
7574
- name: string;
7575
- type: string;
7576
- identifier: string;
7577
- };
7578
- course: {
7579
- title: string;
7580
- subjects: string[];
7581
- grades: number[];
7582
- courseCode: string;
7583
- level: string;
7584
- gradingScheme: string;
7585
- metadata?: Record<string, unknown> | undefined;
7586
- };
7587
- component: {
7588
- title: string;
7589
- sortOrder: number;
7590
- prerequisites: string[];
7591
- prerequisiteCriteria: string;
7592
- };
7593
- resource: {
7594
- title: string;
7595
- vendorResourceId: string;
7596
- vendorId: string;
7597
- applicationId: string;
7598
- roles: string[];
7599
- importance: string;
7600
- metadata: {
7601
- [key: string]: unknown;
7602
- type?: string | undefined;
7603
- launchUrl?: string | undefined;
7604
- toolProvider?: string | undefined;
7605
- instructionalMethod?: string | undefined;
7606
- subject?: string | undefined;
7607
- grades?: number[] | undefined;
7608
- language?: string | undefined;
7609
- xp?: number | undefined;
7610
- };
7611
- };
7612
- componentResource: {
7613
- title: string;
7614
- sortOrder: number;
7615
- lessonType: string | null;
7616
- };
7617
- }>;
7247
+ getConfig: (gameId: string) => Promise<TimebackSetupRequest["config"]>;
7618
7248
  };
7619
7249
  xp: {
7620
7250
  today: (options?: {
7621
- date?: string | undefined;
7622
- timezone?: string | undefined;
7623
- } | undefined) => Promise<TodayXpResponse>;
7251
+ date?: string;
7252
+ timezone?: string;
7253
+ }) => Promise<TodayXpResponse>;
7624
7254
  total: () => Promise<TotalXpResponse>;
7625
7255
  history: (options?: {
7626
- startDate?: string | undefined;
7627
- endDate?: string | undefined;
7628
- } | undefined) => Promise<XpHistoryResponse>;
7256
+ startDate?: string;
7257
+ endDate?: string;
7258
+ }) => Promise<XpHistoryResponse>;
7629
7259
  summary: (options?: {
7630
- date?: string | undefined;
7631
- timezone?: string | undefined;
7632
- } | undefined) => Promise<XpSummaryResponse>;
7260
+ date?: string;
7261
+ timezone?: string;
7262
+ }) => Promise<XpSummaryResponse>;
7633
7263
  };
7634
7264
  students: {
7635
- get: (timebackId: string, options?: TTLCacheConfig | undefined) => Promise<PlatformTimebackUserContext>;
7636
- clearCache: (timebackId?: string | undefined) => void;
7265
+ get: (timebackId: string, options?: TTLCacheConfig) => Promise<PlatformTimebackUserContext>;
7266
+ clearCache: (timebackId?: string) => void;
7637
7267
  };
7638
7268
  };
7639
7269
  /** Auto-initializes a PlaycademyInternalClient with context from the environment */
@@ -7647,4 +7277,4 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7647
7277
  }
7648
7278
 
7649
7279
  export { AchievementCompletionType, ApiError, ConnectionManager, ConnectionMonitor, MessageEvents, NotificationStatus, NotificationType, PlaycademyInternalClient as PlaycademyClient, PlaycademyError, PlaycademyInternalClient, extractApiErrorInfo, messaging };
7650
- export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, ApiErrorCode, ApiErrorInfo, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionMonitorConfig, ConnectionState, ConnectionStatePayload, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, ErrorResponseBody, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameCustomHostname, GameInitUser, GameLeaderboardEntry, MapRow as GameMap, GamePlatform, GameRow as GameRecord, GameSessionRow as GameSession, GameTimebackIntegration, GameTokenResponse, GameType, GameUser, HostedGame, InitPayload, InsertCurrencyInput, InsertItemInput, InsertShopListingInput, InteractionType, InventoryItemRow as InventoryItem, InventoryItemWithItem, InventoryMutationResponse, ItemRow as Item, ItemType, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LevelConfigRow as LevelConfig, LevelProgressResponse, LevelUpCheckResult, LoginResponse, ManifestV1, MapData, MapElementRow as MapElement, MapElementMetadata, MapElementWithGame, MapObjectRow as MapObject, MapObjectWithItem, NotificationRow as Notification, NotificationStats, PlaceableItemMetadata, PlatformTimebackUser, PlatformTimebackUserContext, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacterRow as PlayerCharacter, PlayerCharacterAccessoryRow as PlayerCharacterAccessory, PlayerCurrency, PlayerInventoryItem, PlayerProfile, PlayerSessionPayload, PopulateStudentResponse, RealtimeTokenResponse, ScoreSubmission, ShopCurrency, ShopDisplayItem, ShopListingRow as ShopListing, ShopViewResponse, SpriteAnimationFrame, SpriteConfigWithDimensions, SpriteTemplateRow as SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TimebackEnrollment, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, UpdateCharacterData, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput, UpsertGameMetadataInput, UserRow as User, UserEnrollment, UserInfo, UserLevelRow as UserLevel, UserLevelWithConfig, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData, XPAddResult, XpHistoryResponse, XpSummaryResponse };
7280
+ export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, ApiErrorCode, ApiErrorInfo, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionMonitorConfig, ConnectionState, ConnectionStatePayload, CourseXp, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, ErrorResponseBody, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameCustomHostname, GameInitUser, GameLeaderboardEntry, MapRow as GameMap, GamePlatform, GameRow as GameRecord, GameSessionRow as GameSession, GameTimebackIntegration, GameTokenResponse, GameType, GameUser, GetXpOptions, HostedGame, InitPayload, InsertCurrencyInput, InsertItemInput, InsertShopListingInput, InteractionType, InventoryItemRow as InventoryItem, InventoryItemWithItem, InventoryMutationResponse, ItemRow as Item, ItemType, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LevelConfigRow as LevelConfig, LevelProgressResponse, LevelUpCheckResult, LoginResponse, ManifestV1, MapData, MapElementRow as MapElement, MapElementMetadata, MapElementWithGame, MapObjectRow as MapObject, MapObjectWithItem, NotificationRow as Notification, NotificationStats, PlaceableItemMetadata, PlatformTimebackUser, PlatformTimebackUserContext, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacterRow as PlayerCharacter, PlayerCharacterAccessoryRow as PlayerCharacterAccessory, PlayerCurrency, PlayerInventoryItem, PlayerProfile, PlayerSessionPayload, PopulateStudentResponse, RealtimeTokenResponse, ScoreSubmission, ShopCurrency, ShopDisplayItem, ShopListingRow as ShopListing, ShopViewResponse, SpriteAnimationFrame, SpriteConfigWithDimensions, SpriteTemplateRow as SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TimebackEnrollment, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TimebackUserXp, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, UpdateCharacterData, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput, UpsertGameMetadataInput, UserRow as User, UserEnrollment, UserInfo, UserLevelRow as UserLevel, UserLevelWithConfig, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData, XPAddResult, XpHistoryResponse, XpResponse, XpSummaryResponse };