@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.
package/dist/types.d.ts CHANGED
@@ -800,7 +800,7 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
800
800
  tableName: "user";
801
801
  dataType: "string";
802
802
  columnType: "PgEnumColumn";
803
- data: "admin" | "developer" | "player";
803
+ data: "admin" | "player" | "developer";
804
804
  driverParam: string;
805
805
  notNull: true;
806
806
  hasDefault: true;
@@ -817,7 +817,7 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
817
817
  tableName: "user";
818
818
  dataType: "string";
819
819
  columnType: "PgEnumColumn";
820
- data: "approved" | "none" | "pending";
820
+ data: "none" | "pending" | "approved";
821
821
  driverParam: string;
822
822
  notNull: true;
823
823
  hasDefault: true;
@@ -1006,7 +1006,7 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
1006
1006
  tableName: "games";
1007
1007
  dataType: "string";
1008
1008
  columnType: "PgEnumColumn";
1009
- data: "external" | "hosted";
1009
+ data: "hosted" | "external";
1010
1010
  driverParam: string;
1011
1011
  notNull: true;
1012
1012
  hasDefault: true;
@@ -1057,7 +1057,7 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
1057
1057
  tableName: "games";
1058
1058
  dataType: "string";
1059
1059
  columnType: "PgEnumColumn";
1060
- data: "godot" | "unity" | "web";
1060
+ data: "web" | "godot" | "unity";
1061
1061
  driverParam: string;
1062
1062
  notNull: true;
1063
1063
  hasDefault: true;
@@ -1333,7 +1333,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1333
1333
  tableName: "game_custom_hostnames";
1334
1334
  dataType: "string";
1335
1335
  columnType: "PgEnumColumn";
1336
- data: "production" | "staging";
1336
+ data: "staging" | "production";
1337
1337
  driverParam: string;
1338
1338
  notNull: true;
1339
1339
  hasDefault: true;
@@ -1350,7 +1350,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1350
1350
  tableName: "game_custom_hostnames";
1351
1351
  dataType: "string";
1352
1352
  columnType: "PgEnumColumn";
1353
- data: "active" | "blocked" | "deleted" | "pending" | "pending_deletion" | "pending_deployment" | "pending_validation";
1353
+ data: "pending" | "active" | "pending_validation" | "pending_deployment" | "pending_deletion" | "blocked" | "deleted";
1354
1354
  driverParam: string;
1355
1355
  notNull: true;
1356
1356
  hasDefault: true;
@@ -1367,7 +1367,7 @@ declare const gameCustomHostnames: drizzle_orm_pg_core.PgTableWithColumns<{
1367
1367
  tableName: "game_custom_hostnames";
1368
1368
  dataType: "string";
1369
1369
  columnType: "PgEnumColumn";
1370
- data: "active" | "deleted" | "initializing" | "pending_deployment" | "pending_issuance" | "pending_validation";
1370
+ data: "active" | "pending_validation" | "pending_deployment" | "deleted" | "initializing" | "pending_issuance";
1371
1371
  driverParam: string;
1372
1372
  notNull: true;
1373
1373
  hasDefault: true;
@@ -1529,7 +1529,7 @@ declare const items: drizzle_orm_pg_core.PgTableWithColumns<{
1529
1529
  tableName: "items";
1530
1530
  dataType: "string";
1531
1531
  columnType: "PgEnumColumn";
1532
- data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
1532
+ data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
1533
1533
  driverParam: string;
1534
1534
  notNull: true;
1535
1535
  hasDefault: true;
@@ -2220,7 +2220,7 @@ declare const mapElements: drizzle_orm_pg_core.PgTableWithColumns<{
2220
2220
  tableName: "map_elements";
2221
2221
  dataType: "string";
2222
2222
  columnType: "PgEnumColumn";
2223
- data: "door_in" | "door_out" | "game_entry" | "game_registry" | "info" | "npc_interaction" | "quest_trigger" | "teleport";
2223
+ data: "info" | "game_entry" | "game_registry" | "teleport" | "door_in" | "door_out" | "npc_interaction" | "quest_trigger";
2224
2224
  driverParam: string;
2225
2225
  notNull: true;
2226
2226
  hasDefault: false;
@@ -2773,7 +2773,7 @@ declare const characterComponents: drizzle_orm_pg_core.PgTableWithColumns<{
2773
2773
  tableName: "character_components";
2774
2774
  dataType: "string";
2775
2775
  columnType: "PgEnumColumn";
2776
- data: "accessory" | "body" | "eyes" | "hairstyle" | "outfit";
2776
+ data: "accessory" | "body" | "outfit" | "hairstyle" | "eyes";
2777
2777
  driverParam: string;
2778
2778
  notNull: true;
2779
2779
  hasDefault: false;
@@ -3299,7 +3299,7 @@ declare const notifications: drizzle_orm_pg_core.PgTableWithColumns<{
3299
3299
  tableName: "notifications";
3300
3300
  dataType: "string";
3301
3301
  columnType: "PgEnumColumn";
3302
- data: "high" | "low" | "normal" | "urgent";
3302
+ data: "low" | "normal" | "high" | "urgent";
3303
3303
  driverParam: string;
3304
3304
  notNull: true;
3305
3305
  hasDefault: true;
@@ -3316,7 +3316,7 @@ declare const notifications: drizzle_orm_pg_core.PgTableWithColumns<{
3316
3316
  tableName: "notifications";
3317
3317
  dataType: "string";
3318
3318
  columnType: "PgEnumColumn";
3319
- data: "clicked" | "delivered" | "dismissed" | "expired" | "pending" | "seen";
3319
+ data: "pending" | "delivered" | "seen" | "clicked" | "dismissed" | "expired";
3320
3320
  driverParam: string;
3321
3321
  notNull: true;
3322
3322
  hasDefault: true;
@@ -3477,33 +3477,33 @@ declare const UpsertGameMetadataSchema: z.ZodEffects<z.ZodObject<{
3477
3477
  gameType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["hosted", "external"]>>>;
3478
3478
  externalUrl: z.ZodOptional<z.ZodString>;
3479
3479
  }, "strip", z.ZodTypeAny, {
3480
- displayName: string;
3481
- mapElementId?: string | null | undefined;
3482
- platform: "godot" | "unity" | "web";
3483
3480
  metadata: Record<string, unknown>;
3484
- gameType: "external" | "hosted";
3481
+ displayName: string;
3482
+ gameType: "hosted" | "external";
3483
+ platform: "web" | "godot" | "unity";
3485
3484
  externalUrl?: string | undefined;
3485
+ mapElementId?: string | null | undefined;
3486
3486
  }, {
3487
3487
  displayName: string;
3488
- mapElementId?: string | null | undefined;
3489
- platform: "godot" | "unity" | "web";
3488
+ platform: "web" | "godot" | "unity";
3490
3489
  metadata?: Record<string, unknown> | undefined;
3491
- gameType?: "external" | "hosted" | undefined;
3490
+ gameType?: "hosted" | "external" | undefined;
3492
3491
  externalUrl?: string | undefined;
3493
- }>, {
3494
- displayName: string;
3495
3492
  mapElementId?: string | null | undefined;
3496
- platform: "godot" | "unity" | "web";
3493
+ }>, {
3497
3494
  metadata: Record<string, unknown>;
3498
- gameType: "external" | "hosted";
3495
+ displayName: string;
3496
+ gameType: "hosted" | "external";
3497
+ platform: "web" | "godot" | "unity";
3499
3498
  externalUrl?: string | undefined;
3499
+ mapElementId?: string | null | undefined;
3500
3500
  }, {
3501
3501
  displayName: string;
3502
- mapElementId?: string | null | undefined;
3503
- platform: "godot" | "unity" | "web";
3502
+ platform: "web" | "godot" | "unity";
3504
3503
  metadata?: Record<string, unknown> | undefined;
3505
- gameType?: "external" | "hosted" | undefined;
3504
+ gameType?: "hosted" | "external" | undefined;
3506
3505
  externalUrl?: string | undefined;
3506
+ mapElementId?: string | null | undefined;
3507
3507
  }>;
3508
3508
 
3509
3509
  declare const InsertItemSchema: drizzle_zod.BuildSchema<"insert", {
@@ -3597,7 +3597,7 @@ declare const InsertItemSchema: drizzle_zod.BuildSchema<"insert", {
3597
3597
  tableName: "items";
3598
3598
  dataType: "string";
3599
3599
  columnType: "PgEnumColumn";
3600
- data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
3600
+ data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
3601
3601
  driverParam: string;
3602
3602
  notNull: true;
3603
3603
  hasDefault: true;
@@ -3692,24 +3692,24 @@ declare const UpdateItemSchema: z.ZodObject<Omit<{
3692
3692
  imageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3693
3693
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3694
3694
  createdAt: z.ZodOptional<z.ZodDate>;
3695
- }, "createdAt" | "id">, "strip", z.ZodTypeAny, {
3695
+ }, "id" | "createdAt">, "strip", z.ZodTypeAny, {
3696
+ description?: string | null | undefined;
3697
+ metadata?: Record<string, unknown> | undefined;
3698
+ type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3696
3699
  slug?: string | undefined;
3697
- gameId?: string | null | undefined;
3698
3700
  displayName?: string | undefined;
3699
- description?: string | null | undefined;
3700
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
3701
+ gameId?: string | null | undefined;
3701
3702
  isPlaceable?: boolean | undefined;
3702
3703
  imageUrl?: string | null | undefined;
3703
- metadata?: Record<string, unknown> | undefined;
3704
3704
  }, {
3705
+ description?: string | null | undefined;
3706
+ metadata?: Record<string, unknown> | undefined;
3707
+ type?: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other" | undefined;
3705
3708
  slug?: string | undefined;
3706
- gameId?: string | null | undefined;
3707
3709
  displayName?: string | undefined;
3708
- description?: string | null | undefined;
3709
- type?: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade" | undefined;
3710
+ gameId?: string | null | undefined;
3710
3711
  isPlaceable?: boolean | undefined;
3711
3712
  imageUrl?: string | null | undefined;
3712
- metadata?: Record<string, unknown> | undefined;
3713
3713
  }>;
3714
3714
  declare const InsertCurrencySchema: drizzle_zod.BuildSchema<"insert", {
3715
3715
  id: drizzle_orm_pg_core.PgColumn<{
@@ -3819,16 +3819,16 @@ declare const InsertCurrencySchema: drizzle_zod.BuildSchema<"insert", {
3819
3819
  isPrimary: z.ZodDefault<z.ZodBoolean>;
3820
3820
  }>;
3821
3821
  declare const UpdateCurrencySchema: z.ZodObject<{
3822
- itemId: z.ZodOptional<z.ZodString>;
3823
3822
  symbol: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
3823
+ itemId: z.ZodOptional<z.ZodString>;
3824
3824
  isPrimary: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
3825
3825
  }, "strip", z.ZodTypeAny, {
3826
- itemId?: string | undefined;
3827
3826
  symbol?: string | null | undefined;
3827
+ itemId?: string | undefined;
3828
3828
  isPrimary?: boolean | undefined;
3829
3829
  }, {
3830
- itemId?: string | undefined;
3831
3830
  symbol?: string | null | undefined;
3831
+ itemId?: string | undefined;
3832
3832
  isPrimary?: boolean | undefined;
3833
3833
  }>;
3834
3834
  declare const InsertShopListingSchema: drizzle_zod.BuildSchema<"insert", {
@@ -4039,28 +4039,28 @@ declare const UpdateShopListingSchema: z.ZodObject<{
4039
4039
  updatedAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodDate>>>;
4040
4040
  }, "strip", z.ZodTypeAny, {
4041
4041
  id?: string | undefined;
4042
+ createdAt?: Date | undefined;
4043
+ updatedAt?: Date | null | undefined;
4044
+ isActive?: boolean | undefined;
4042
4045
  itemId?: string | undefined;
4043
4046
  currencyId?: string | undefined;
4044
4047
  price?: number | undefined;
4045
4048
  sellBackPercentage?: number | null | undefined;
4046
4049
  stock?: number | null | undefined;
4047
- isActive?: boolean | undefined;
4048
4050
  availableFrom?: Date | null | undefined;
4049
4051
  availableUntil?: Date | null | undefined;
4050
- createdAt?: Date | undefined;
4051
- updatedAt?: Date | null | undefined;
4052
4052
  }, {
4053
4053
  id?: string | undefined;
4054
+ createdAt?: Date | undefined;
4055
+ updatedAt?: Date | null | undefined;
4056
+ isActive?: boolean | undefined;
4054
4057
  itemId?: string | undefined;
4055
4058
  currencyId?: string | undefined;
4056
4059
  price?: number | undefined;
4057
4060
  sellBackPercentage?: number | null | undefined;
4058
4061
  stock?: number | null | undefined;
4059
- isActive?: boolean | undefined;
4060
4062
  availableFrom?: Date | null | undefined;
4061
4063
  availableUntil?: Date | null | undefined;
4062
- createdAt?: Date | undefined;
4063
- updatedAt?: Date | null | undefined;
4064
4064
  }>;
4065
4065
 
4066
4066
  type GameRow = typeof games.$inferSelect;
@@ -4674,71 +4674,6 @@ declare enum MessageEvents {
4674
4674
  AUTH_CALLBACK = "PLAYCADEMY_AUTH_CALLBACK"
4675
4675
  }
4676
4676
 
4677
- /**
4678
- * Auto-initializes a PlaycademyClient with context from the environment.
4679
- * Works in both iframe mode (production/development) and standalone mode (local dev).
4680
- *
4681
- * This is the recommended way to initialize the SDK as it automatically:
4682
- * - Detects the runtime environment (iframe vs standalone)
4683
- * - Configures the client with the appropriate context
4684
- * - Sets up event listeners for token refresh
4685
- * - Exposes the client for debugging in development mode
4686
- *
4687
- * @param options - Optional configuration overrides
4688
- * @param options.baseUrl - Override the base URL for API requests
4689
- * @returns Promise resolving to a fully initialized PlaycademyClient
4690
- * @throws Error if not running in a browser context
4691
- *
4692
- * @example
4693
- * ```typescript
4694
- * // Default initialization
4695
- * const client = await PlaycademyClient.init()
4696
- *
4697
- * // With custom base URL
4698
- * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
4699
- * ```
4700
- */
4701
- declare function init<T extends PlaycademyClient = PlaycademyClient>(this: new (...args: ConstructorParameters<typeof PlaycademyClient>) => T, options?: {
4702
- baseUrl?: string;
4703
- allowedParentOrigins?: string[];
4704
- onDisconnect?: DisconnectHandler;
4705
- enableConnectionMonitoring?: boolean;
4706
- }): Promise<T>;
4707
-
4708
- /**
4709
- * Authenticates a user with email and password.
4710
- *
4711
- * This is a standalone authentication method that doesn't require an initialized client.
4712
- * Use this for login flows before creating a client instance.
4713
- *
4714
- * @deprecated Use client.auth.login() instead for better error handling and automatic token management
4715
- *
4716
- * @param baseUrl - The base URL of the Playcademy API
4717
- * @param email - User's email address
4718
- * @param password - User's password
4719
- * @returns Promise resolving to authentication response with token
4720
- * @throws PlaycademyError if authentication fails or network error occurs
4721
- *
4722
- * @example
4723
- * ```typescript
4724
- * // Preferred approach:
4725
- * const client = new PlaycademyClient({ baseUrl: '/api' })
4726
- * const result = await client.auth.login({
4727
- * email: 'user@example.com',
4728
- * password: 'password'
4729
- * })
4730
- *
4731
- * // Legacy approach (still works):
4732
- * try {
4733
- * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
4734
- * const client = new PlaycademyClient({ token: response.token })
4735
- * } catch (error) {
4736
- * console.error('Login failed:', error.message)
4737
- * }
4738
- * ```
4739
- */
4740
- declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
4741
-
4742
4677
  /**
4743
4678
  * @fileoverview Authentication Strategy Pattern
4744
4679
  *
@@ -4873,6 +4808,9 @@ declare abstract class PlaycademyBaseClient {
4873
4808
  * Initializes connection monitoring if enabled.
4874
4809
  */
4875
4810
  private _initializeConnectionMonitor;
4811
+ /**
4812
+ * Initializes an internal game session for automatic session management.
4813
+ */
4876
4814
  private _initializeInternalSession;
4877
4815
  /**
4878
4816
  * Current user data and inventory management.
@@ -4892,6 +4830,71 @@ declare abstract class PlaycademyBaseClient {
4892
4830
  };
4893
4831
  }
4894
4832
 
4833
+ /**
4834
+ * Auto-initializes a PlaycademyClient with context from the environment.
4835
+ * Works in both iframe mode (production/development) and standalone mode (local dev).
4836
+ *
4837
+ * This is the recommended way to initialize the SDK as it automatically:
4838
+ * - Detects the runtime environment (iframe vs standalone)
4839
+ * - Configures the client with the appropriate context
4840
+ * - Sets up event listeners for token refresh
4841
+ * - Exposes the client for debugging in development mode
4842
+ *
4843
+ * @param options - Optional configuration overrides
4844
+ * @param options.baseUrl - Override the base URL for API requests
4845
+ * @returns Promise resolving to a fully initialized PlaycademyClient
4846
+ * @throws Error if not running in a browser context
4847
+ *
4848
+ * @example
4849
+ * ```typescript
4850
+ * // Default initialization
4851
+ * const client = await PlaycademyClient.init()
4852
+ *
4853
+ * // With custom base URL
4854
+ * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
4855
+ * ```
4856
+ */
4857
+ declare function init<T extends PlaycademyBaseClient = PlaycademyBaseClient>(this: new (config?: Partial<ClientConfig>) => T, options?: {
4858
+ baseUrl?: string;
4859
+ allowedParentOrigins?: string[];
4860
+ onDisconnect?: DisconnectHandler;
4861
+ enableConnectionMonitoring?: boolean;
4862
+ }): Promise<T>;
4863
+
4864
+ /**
4865
+ * Authenticates a user with email and password.
4866
+ *
4867
+ * This is a standalone authentication method that doesn't require an initialized client.
4868
+ * Use this for login flows before creating a client instance.
4869
+ *
4870
+ * @deprecated Use client.auth.login() instead for better error handling and automatic token management
4871
+ *
4872
+ * @param baseUrl - The base URL of the Playcademy API
4873
+ * @param email - User's email address
4874
+ * @param password - User's password
4875
+ * @returns Promise resolving to authentication response with token
4876
+ * @throws PlaycademyError if authentication fails or network error occurs
4877
+ *
4878
+ * @example
4879
+ * ```typescript
4880
+ * // Preferred approach:
4881
+ * const client = new PlaycademyClient({ baseUrl: '/api' })
4882
+ * const result = await client.auth.login({
4883
+ * email: 'user@example.com',
4884
+ * password: 'password'
4885
+ * })
4886
+ *
4887
+ * // Legacy approach (still works):
4888
+ * try {
4889
+ * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
4890
+ * const client = new PlaycademyClient({ token: response.token })
4891
+ * } catch (error) {
4892
+ * console.error('Login failed:', error.message)
4893
+ * }
4894
+ * ```
4895
+ */
4896
+ declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
4897
+
4895
4898
  /**
4896
4899
  * Playcademy SDK client for game developers.
4897
4900
  * Provides namespaced access to platform features for games running inside Cademy.
@@ -4916,8 +4919,8 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
4916
4919
  */
4917
4920
  runtime: {
4918
4921
  getGameToken: (gameId: string, options?: {
4919
- apply?: boolean | undefined;
4920
- } | undefined) => Promise<GameTokenResponse>;
4922
+ apply?: boolean;
4923
+ }) => Promise<GameTokenResponse>;
4921
4924
  exit: () => Promise<void>;
4922
4925
  onInit: (handler: (context: GameContextPayload) => void) => void;
4923
4926
  onTokenRefresh: (handler: (data: {
@@ -4941,7 +4944,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
4941
4944
  getListenerCounts: () => Record<string, number>;
4942
4945
  assets: {
4943
4946
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
4944
- fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
4947
+ fetch: (path: string, options?: RequestInit) => Promise<Response>;
4945
4948
  json: <T = unknown>(path: string) => Promise<T>;
4946
4949
  blob: (path: string) => Promise<Blob>;
4947
4950
  text: (path: string) => Promise<string>;
@@ -4984,7 +4987,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
4984
4987
  * - `submit(gameId, score, metadata?)` - Record a game score
4985
4988
  */
4986
4989
  scores: {
4987
- submit: (gameId: string, score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
4990
+ submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
4988
4991
  };
4989
4992
  /**
4990
4993
  * Realtime multiplayer authentication.
@@ -5001,13 +5004,13 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
5001
5004
  * - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
5002
5005
  */
5003
5006
  backend: {
5004
- get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
5005
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5006
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5007
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5008
- delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
5009
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
5010
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
5007
+ get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
5008
+ post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5009
+ put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5010
+ patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5011
+ delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
5012
+ request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
5013
+ download(path: string, method?: Method, body?: unknown, headers?: Record<string, string>): Promise<Response>;
5011
5014
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
5012
5015
  };
5013
5016
  /** Auto-initializes a PlaycademyClient with context from the environment */
@@ -5065,6 +5068,45 @@ interface TimebackUserContext {
5065
5068
  /** User's organizations (schools/districts) */
5066
5069
  organizations: TimebackOrganization[];
5067
5070
  }
5071
+ /**
5072
+ * XP data access for the current user.
5073
+ * Results are cached for 5 seconds to avoid redundant network requests.
5074
+ */
5075
+ interface TimebackUserXp {
5076
+ /**
5077
+ * Fetch XP data from the server.
5078
+ * Returns XP for all courses in this game, or filter by grade/subject.
5079
+ * Results are cached for 5 seconds (use `force: true` to bypass).
5080
+ *
5081
+ * @param options - Query options
5082
+ * @param options.grade - Grade level to filter (must be used with subject)
5083
+ * @param options.subject - Subject to filter (must be used with grade)
5084
+ * @param options.include - Additional data to include: 'perCourse', 'today'
5085
+ * @param options.force - Bypass cache and fetch fresh data (default: false)
5086
+ * @returns Promise resolving to XP data
5087
+ *
5088
+ * @example
5089
+ * ```typescript
5090
+ * // Get total XP for all game courses
5091
+ * const xp = await client.timeback.user.xp.fetch()
5092
+ *
5093
+ * // Get XP for a specific grade/subject
5094
+ * const xp = await client.timeback.user.xp.fetch({
5095
+ * grade: 3,
5096
+ * subject: 'Math'
5097
+ * })
5098
+ *
5099
+ * // Get XP with per-course breakdown
5100
+ * const xp = await client.timeback.user.xp.fetch({
5101
+ * include: ['perCourse', 'today']
5102
+ * })
5103
+ *
5104
+ * // Force fresh data
5105
+ * const xp = await client.timeback.user.xp.fetch({ force: true })
5106
+ * ```
5107
+ */
5108
+ fetch(options?: GetXpOptions): Promise<XpResponse>;
5109
+ }
5068
5110
  /**
5069
5111
  * TimeBack user object with both cached getters and fetch method.
5070
5112
  */
@@ -5078,6 +5120,42 @@ interface TimebackUser extends TimebackUserContext {
5078
5120
  fetch(options?: {
5079
5121
  force?: boolean;
5080
5122
  }): Promise<TimebackUserContext>;
5123
+ /**
5124
+ * XP data for the current user.
5125
+ * Call `xp.fetch()` to get XP from the server.
5126
+ */
5127
+ xp: TimebackUserXp;
5128
+ }
5129
+ /**
5130
+ * Options for querying student XP.
5131
+ */
5132
+ interface GetXpOptions {
5133
+ /** Grade level to filter (must be used with subject) */
5134
+ grade?: TimebackGrade;
5135
+ /** Subject to filter (must be used with grade) */
5136
+ subject?: TimebackSubject;
5137
+ /** Additional data to include: 'perCourse', 'today' */
5138
+ include?: ('perCourse' | 'today')[];
5139
+ /** Bypass cache and fetch fresh data (default: false) */
5140
+ force?: boolean;
5141
+ }
5142
+ /**
5143
+ * XP data for a single course.
5144
+ */
5145
+ interface CourseXp {
5146
+ grade: TimebackGrade;
5147
+ subject: TimebackSubject;
5148
+ title: string;
5149
+ totalXp: number;
5150
+ todayXp?: number;
5151
+ }
5152
+ /**
5153
+ * Response from XP query.
5154
+ */
5155
+ interface XpResponse {
5156
+ totalXp: number;
5157
+ todayXp?: number;
5158
+ courses?: CourseXp[];
5081
5159
  }
5082
5160
 
5083
5161
  /**
@@ -5602,6 +5680,9 @@ interface CustomRoutesIntegration {
5602
5680
  interface DatabaseIntegration {
5603
5681
  /** Database directory (defaults to 'db') */
5604
5682
  directory?: string;
5683
+ /** Schema strategy: 'push' uses drizzle-kit push-style diffing, 'migrate' uses migration files.
5684
+ * When omitted, auto-detects based on presence of a migrations directory with _journal.json. */
5685
+ strategy?: 'push' | 'migrate';
5605
5686
  }
5606
5687
  /**
5607
5688
  * Integrations configuration
@@ -5716,4 +5797,4 @@ interface PlaycademyServerClientState {
5716
5797
  }
5717
5798
 
5718
5799
  export { AchievementCompletionType, NotificationStatus, NotificationType, PlaycademyClient };
5719
- export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionStatePayload, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, 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 };
5800
+ export type { AchievementCurrent, AchievementHistoryEntry, AchievementProgressResponse, AchievementScopeType, AchievementWithStatus, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponentRow as CharacterComponent, CharacterComponentType, CharacterComponentWithSpriteUrl, CharacterComponentsOptions, ClientConfig, ClientEvents, ConnectionStatePayload, CourseXp, CreateCharacterData, CreateMapObjectData, CurrencyRow as Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DisconnectContext, DisconnectHandler, DisplayAlertPayload, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -44,12 +44,12 @@
44
44
  "@playcademy/data": "0.0.1",
45
45
  "@playcademy/logger": "0.0.1",
46
46
  "@playcademy/types": "0.0.1",
47
- "@playcademy/sandbox": "0.3.12",
47
+ "@playcademy/sandbox": "0.3.14",
48
48
  "@playcademy/test": "0.0.1",
49
49
  "@playcademy/timeback": "0.0.1",
50
50
  "@playcademy/utils": "0.0.1",
51
51
  "@types/bun": "latest",
52
- "playcademy": "0.16.3",
52
+ "playcademy": "0.16.9",
53
53
  "rollup": "^4.50.2",
54
54
  "rollup-plugin-dts": "^6.2.3",
55
55
  "typescript": "^5.7.2"