@playcademy/sdk 0.2.12 → 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/index.d.ts CHANGED
@@ -817,71 +817,6 @@ type InventoryItemWithItem = InventoryItemRow & {
817
817
  item: ItemRow;
818
818
  };
819
819
 
820
- /**
821
- * Auto-initializes a PlaycademyClient with context from the environment.
822
- * Works in both iframe mode (production/development) and standalone mode (local dev).
823
- *
824
- * This is the recommended way to initialize the SDK as it automatically:
825
- * - Detects the runtime environment (iframe vs standalone)
826
- * - Configures the client with the appropriate context
827
- * - Sets up event listeners for token refresh
828
- * - Exposes the client for debugging in development mode
829
- *
830
- * @param options - Optional configuration overrides
831
- * @param options.baseUrl - Override the base URL for API requests
832
- * @returns Promise resolving to a fully initialized PlaycademyClient
833
- * @throws Error if not running in a browser context
834
- *
835
- * @example
836
- * ```typescript
837
- * // Default initialization
838
- * const client = await PlaycademyClient.init()
839
- *
840
- * // With custom base URL
841
- * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
842
- * ```
843
- */
844
- declare function init<T extends PlaycademyClient = PlaycademyClient>(this: new (...args: ConstructorParameters<typeof PlaycademyClient>) => T, options?: {
845
- baseUrl?: string;
846
- allowedParentOrigins?: string[];
847
- onDisconnect?: DisconnectHandler;
848
- enableConnectionMonitoring?: boolean;
849
- }): Promise<T>;
850
-
851
- /**
852
- * Authenticates a user with email and password.
853
- *
854
- * This is a standalone authentication method that doesn't require an initialized client.
855
- * Use this for login flows before creating a client instance.
856
- *
857
- * @deprecated Use client.auth.login() instead for better error handling and automatic token management
858
- *
859
- * @param baseUrl - The base URL of the Playcademy API
860
- * @param email - User's email address
861
- * @param password - User's password
862
- * @returns Promise resolving to authentication response with token
863
- * @throws PlaycademyError if authentication fails or network error occurs
864
- *
865
- * @example
866
- * ```typescript
867
- * // Preferred approach:
868
- * const client = new PlaycademyClient({ baseUrl: '/api' })
869
- * const result = await client.auth.login({
870
- * email: 'user@example.com',
871
- * password: 'password'
872
- * })
873
- *
874
- * // Legacy approach (still works):
875
- * try {
876
- * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
877
- * const client = new PlaycademyClient({ token: response.token })
878
- * } catch (error) {
879
- * console.error('Login failed:', error.message)
880
- * }
881
- * ```
882
- */
883
- declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
884
-
885
820
  /**
886
821
  * @fileoverview Authentication Strategy Pattern
887
822
  *
@@ -1038,6 +973,71 @@ declare abstract class PlaycademyBaseClient {
1038
973
  };
1039
974
  }
1040
975
 
976
+ /**
977
+ * Auto-initializes a PlaycademyClient with context from the environment.
978
+ * Works in both iframe mode (production/development) and standalone mode (local dev).
979
+ *
980
+ * This is the recommended way to initialize the SDK as it automatically:
981
+ * - Detects the runtime environment (iframe vs standalone)
982
+ * - Configures the client with the appropriate context
983
+ * - Sets up event listeners for token refresh
984
+ * - Exposes the client for debugging in development mode
985
+ *
986
+ * @param options - Optional configuration overrides
987
+ * @param options.baseUrl - Override the base URL for API requests
988
+ * @returns Promise resolving to a fully initialized PlaycademyClient
989
+ * @throws Error if not running in a browser context
990
+ *
991
+ * @example
992
+ * ```typescript
993
+ * // Default initialization
994
+ * const client = await PlaycademyClient.init()
995
+ *
996
+ * // With custom base URL
997
+ * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
998
+ * ```
999
+ */
1000
+ declare function init<T extends PlaycademyBaseClient = PlaycademyBaseClient>(this: new (config?: Partial<ClientConfig>) => T, options?: {
1001
+ baseUrl?: string;
1002
+ allowedParentOrigins?: string[];
1003
+ onDisconnect?: DisconnectHandler;
1004
+ enableConnectionMonitoring?: boolean;
1005
+ }): Promise<T>;
1006
+
1007
+ /**
1008
+ * Authenticates a user with email and password.
1009
+ *
1010
+ * This is a standalone authentication method that doesn't require an initialized client.
1011
+ * Use this for login flows before creating a client instance.
1012
+ *
1013
+ * @deprecated Use client.auth.login() instead for better error handling and automatic token management
1014
+ *
1015
+ * @param baseUrl - The base URL of the Playcademy API
1016
+ * @param email - User's email address
1017
+ * @param password - User's password
1018
+ * @returns Promise resolving to authentication response with token
1019
+ * @throws PlaycademyError if authentication fails or network error occurs
1020
+ *
1021
+ * @example
1022
+ * ```typescript
1023
+ * // Preferred approach:
1024
+ * const client = new PlaycademyClient({ baseUrl: '/api' })
1025
+ * const result = await client.auth.login({
1026
+ * email: 'user@example.com',
1027
+ * password: 'password'
1028
+ * })
1029
+ *
1030
+ * // Legacy approach (still works):
1031
+ * try {
1032
+ * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
1033
+ * const client = new PlaycademyClient({ token: response.token })
1034
+ * } catch (error) {
1035
+ * console.error('Login failed:', error.message)
1036
+ * }
1037
+ * ```
1038
+ */
1039
+ declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
1040
+
1041
1041
  /**
1042
1042
  * Playcademy SDK client for game developers.
1043
1043
  * Provides namespaced access to platform features for games running inside Cademy.
package/dist/index.js CHANGED
@@ -1477,7 +1477,7 @@ function createTimebackNamespace(client) {
1477
1477
  const cacheKey = [
1478
1478
  options?.grade ?? "",
1479
1479
  options?.subject ?? "",
1480
- options?.include?.sort().join(",") ?? ""
1480
+ options?.include?.toSorted().join(",") ?? ""
1481
1481
  ].join(":");
1482
1482
  return xpCache.get(cacheKey, async () => {
1483
1483
  const params = new URLSearchParams;
@@ -5619,71 +5619,6 @@ declare class PlaycademyMessaging {
5619
5619
  */
5620
5620
  declare const messaging: PlaycademyMessaging;
5621
5621
 
5622
- /**
5623
- * Auto-initializes a PlaycademyClient with context from the environment.
5624
- * Works in both iframe mode (production/development) and standalone mode (local dev).
5625
- *
5626
- * This is the recommended way to initialize the SDK as it automatically:
5627
- * - Detects the runtime environment (iframe vs standalone)
5628
- * - Configures the client with the appropriate context
5629
- * - Sets up event listeners for token refresh
5630
- * - Exposes the client for debugging in development mode
5631
- *
5632
- * @param options - Optional configuration overrides
5633
- * @param options.baseUrl - Override the base URL for API requests
5634
- * @returns Promise resolving to a fully initialized PlaycademyClient
5635
- * @throws Error if not running in a browser context
5636
- *
5637
- * @example
5638
- * ```typescript
5639
- * // Default initialization
5640
- * const client = await PlaycademyClient.init()
5641
- *
5642
- * // With custom base URL
5643
- * const client = await PlaycademyClient.init({ baseUrl: 'https://custom.api.com' })
5644
- * ```
5645
- */
5646
- declare function init<T extends PlaycademyClient = PlaycademyClient>(this: new (...args: ConstructorParameters<typeof PlaycademyClient>) => T, options?: {
5647
- baseUrl?: string;
5648
- allowedParentOrigins?: string[];
5649
- onDisconnect?: DisconnectHandler;
5650
- enableConnectionMonitoring?: boolean;
5651
- }): Promise<T>;
5652
-
5653
- /**
5654
- * Authenticates a user with email and password.
5655
- *
5656
- * This is a standalone authentication method that doesn't require an initialized client.
5657
- * Use this for login flows before creating a client instance.
5658
- *
5659
- * @deprecated Use client.auth.login() instead for better error handling and automatic token management
5660
- *
5661
- * @param baseUrl - The base URL of the Playcademy API
5662
- * @param email - User's email address
5663
- * @param password - User's password
5664
- * @returns Promise resolving to authentication response with token
5665
- * @throws PlaycademyError if authentication fails or network error occurs
5666
- *
5667
- * @example
5668
- * ```typescript
5669
- * // Preferred approach:
5670
- * const client = new PlaycademyClient({ baseUrl: '/api' })
5671
- * const result = await client.auth.login({
5672
- * email: 'user@example.com',
5673
- * password: 'password'
5674
- * })
5675
- *
5676
- * // Legacy approach (still works):
5677
- * try {
5678
- * const response = await PlaycademyClient.login('/api', 'user@example.com', 'password')
5679
- * const client = new PlaycademyClient({ token: response.token })
5680
- * } catch (error) {
5681
- * console.error('Login failed:', error.message)
5682
- * }
5683
- * ```
5684
- */
5685
- declare function login(baseUrl: string, email: string, password: string): Promise<LoginResponse>;
5686
-
5687
5622
  /**
5688
5623
  * @fileoverview Authentication Strategy Pattern
5689
5624
  *
@@ -5841,132 +5776,69 @@ declare abstract class PlaycademyBaseClient {
5841
5776
  }
5842
5777
 
5843
5778
  /**
5844
- * Playcademy SDK client for game developers.
5845
- * Provides namespaced access to platform features for games running inside Cademy.
5779
+ * Auto-initializes a PlaycademyClient with context from the environment.
5780
+ * Works in both iframe mode (production/development) and standalone mode (local dev).
5781
+ *
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
+ * ```
5846
5801
  */
5847
- declare class PlaycademyClient extends PlaycademyBaseClient {
5848
- /**
5849
- * Connect external identity providers to the user's Playcademy account.
5850
- * - `connect(provider)` - Link Discord, Google, etc. via OAuth popup
5851
- */
5852
- identity: {
5853
- connect: (options: AuthOptions) => Promise<AuthResult>;
5854
- _getContext: () => {
5855
- isInIframe: boolean;
5856
- };
5857
- };
5858
- /**
5859
- * Game runtime lifecycle and asset loading.
5860
- * - `exit()` - Return to Cademy hub
5861
- * - `getGameToken()` - Get short-lived auth token
5862
- * - `assets.url()`, `assets.json()`, `assets.fetch()` - Load game assets
5863
- * - `on('pause')`, `on('resume')` - Handle visibility changes
5864
- */
5865
- runtime: {
5866
- getGameToken: (gameId: string, options?: {
5867
- apply?: boolean;
5868
- }) => Promise<GameTokenResponse>;
5869
- exit: () => Promise<void>;
5870
- onInit: (handler: (context: GameContextPayload) => void) => void;
5871
- onTokenRefresh: (handler: (data: {
5872
- token: string;
5873
- exp: number;
5874
- }) => void) => void;
5875
- onPause: (handler: () => void) => void;
5876
- onResume: (handler: () => void) => void;
5877
- onForceExit: (handler: () => void) => void;
5878
- onOverlay: (handler: (isVisible: boolean) => void) => void;
5879
- ready: () => void;
5880
- sendTelemetry: (data: {
5881
- fps: number;
5882
- mem: number;
5883
- }) => void;
5884
- removeListener: (eventType: MessageEvents, handler: ((context: GameContextPayload) => void) | ((data: {
5885
- token: string;
5886
- exp: number;
5887
- }) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
5888
- removeAllListeners: () => void;
5889
- getListenerCounts: () => Record<string, number>;
5890
- assets: {
5891
- url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
5892
- fetch: (path: string, options?: RequestInit) => Promise<Response>;
5893
- json: <T = unknown>(path: string) => Promise<T>;
5894
- blob: (path: string) => Promise<Blob>;
5895
- text: (path: string) => Promise<string>;
5896
- arrayBuffer: (path: string) => Promise<ArrayBuffer>;
5897
- };
5898
- };
5899
- /**
5900
- * TimeBack integration for activity tracking and user context.
5901
- *
5902
- * User context (cached from init, refreshable):
5903
- * - `user.role` - User's role (student, parent, teacher, etc.)
5904
- * - `user.enrollments` - Courses the player is enrolled in for this game
5905
- * - `user.organizations` - Schools/districts the player belongs to
5906
- * - `user.fetch()` - Refresh user context from server
5907
- *
5908
- * Activity tracking:
5909
- * - `startActivity(metadata)` - Begin tracking an activity
5910
- * - `pauseActivity()` / `resumeActivity()` - Pause/resume timer
5911
- * - `endActivity(scoreData)` - Submit activity results to TimeBack
5912
- */
5913
- timeback: {
5914
- readonly user: TimebackUser;
5915
- startActivity: (metadata: ActivityData) => void;
5916
- pauseActivity: () => void;
5917
- resumeActivity: () => void;
5918
- endActivity: (data: EndActivityScoreData) => Promise<EndActivityResponse>;
5919
- };
5920
- /**
5921
- * Playcademy Credits (platform currency) management.
5922
- * - `get()` - Get user's credit balance
5923
- * - `add(amount)` - Award credits to user
5924
- */
5925
- credits: {
5926
- balance: () => Promise<number>;
5927
- add: (amount: number) => Promise<number>;
5928
- spend: (amount: number) => Promise<number>;
5929
- };
5930
- /**
5931
- * Game score submission and leaderboards.
5932
- * - `submit(gameId, score, metadata?)` - Record a game score
5933
- */
5934
- scores: {
5935
- submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
5936
- };
5937
- /**
5938
- * Realtime multiplayer authentication.
5939
- * - `getToken()` - Get token for WebSocket/realtime connections
5940
- */
5941
- realtime: {
5942
- token: {
5943
- get: () => Promise<RealtimeTokenResponse>;
5944
- };
5945
- };
5946
- /**
5947
- * Make requests to your game's custom backend API routes.
5948
- * - `get(path)`, `post(path, body)`, `put()`, `delete()` - HTTP methods
5949
- * - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
5950
- */
5951
- backend: {
5952
- get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
5953
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5954
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5955
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
5956
- delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
5957
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
5958
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string>): Promise<Response>;
5959
- url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
5960
- };
5961
- /** Auto-initializes a PlaycademyClient with context from the environment */
5962
- static init: typeof init;
5963
- /** Authenticates a user with email and password */
5964
- static login: typeof login;
5965
- /** Static identity utilities for OAuth operations */
5966
- static identity: {
5967
- parseOAuthState: typeof parseOAuthState;
5968
- };
5969
- }
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>;
5970
5842
 
5971
5843
  /**
5972
5844
  * Type definitions for the game timeback namespace.
@@ -6625,6 +6497,9 @@ interface CustomRoutesIntegration {
6625
6497
  interface DatabaseIntegration {
6626
6498
  /** Database directory (defaults to 'db') */
6627
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';
6628
6503
  }
6629
6504
  /**
6630
6505
  * Integrations configuration
package/dist/internal.js CHANGED
@@ -1477,7 +1477,7 @@ function createTimebackNamespace(client) {
1477
1477
  const cacheKey = [
1478
1478
  options?.grade ?? "",
1479
1479
  options?.subject ?? "",
1480
- options?.include?.sort().join(",") ?? ""
1480
+ options?.include?.toSorted().join(",") ?? ""
1481
1481
  ].join(":");
1482
1482
  return xpCache.get(cacheKey, async () => {
1483
1483
  const params = new URLSearchParams;
package/dist/server.d.ts CHANGED
@@ -382,6 +382,9 @@ interface CustomRoutesIntegration {
382
382
  interface DatabaseIntegration {
383
383
  /** Database directory (defaults to 'db') */
384
384
  directory?: string;
385
+ /** Schema strategy: 'push' uses drizzle-kit push-style diffing, 'migrate' uses migration files.
386
+ * When omitted, auto-detects based on presence of a migrations directory with _journal.json. */
387
+ strategy?: 'push' | 'migrate';
385
388
  }
386
389
  /**
387
390
  * Integrations configuration
package/dist/types.d.ts CHANGED
@@ -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
  *
@@ -4895,6 +4830,71 @@ declare abstract class PlaycademyBaseClient {
4895
4830
  };
4896
4831
  }
4897
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
+
4898
4898
  /**
4899
4899
  * Playcademy SDK client for game developers.
4900
4900
  * Provides namespaced access to platform features for games running inside Cademy.
@@ -5680,6 +5680,9 @@ interface CustomRoutesIntegration {
5680
5680
  interface DatabaseIntegration {
5681
5681
  /** Database directory (defaults to 'db') */
5682
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';
5683
5686
  }
5684
5687
  /**
5685
5688
  * Integrations configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.2.12",
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.13",
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.5",
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"