@playcademy/sdk 0.3.1 → 0.3.3

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
@@ -57,8 +57,6 @@ interface ErrorResponseBody {
57
57
  * ```
58
58
  */
59
59
  declare class ApiError extends Error {
60
- /** HTTP status code */
61
- readonly status: number;
62
60
  /**
63
61
  * API error code (e.g., "NOT_FOUND", "VALIDATION_FAILED").
64
62
  * Use this for programmatic error handling.
@@ -74,6 +72,7 @@ declare class ApiError extends Error {
74
72
  * @internal
75
73
  */
76
74
  readonly rawBody: unknown;
75
+ readonly status: number;
77
76
  constructor(
78
77
  /** HTTP status code */
79
78
  status: number,
@@ -635,7 +634,7 @@ declare const items: drizzle_orm_pg_core.PgTableWithColumns<{
635
634
  tableName: "items";
636
635
  dataType: "string";
637
636
  columnType: "PgEnumColumn";
638
- data: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
637
+ data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
639
638
  driverParam: string;
640
639
  notNull: true;
641
640
  hasDefault: true;
@@ -856,6 +855,7 @@ declare abstract class PlaycademyBaseClient {
856
855
  };
857
856
  protected initPayload?: InitPayload;
858
857
  protected connectionManager?: ConnectionManager;
858
+ protected launchId?: string;
859
859
  /**
860
860
  * Internal session manager for automatic session lifecycle.
861
861
  * @private
@@ -884,6 +884,7 @@ declare abstract class PlaycademyBaseClient {
884
884
  * Sets the authentication token for API requests.
885
885
  */
886
886
  setToken(token: string | null, tokenType?: TokenType): void;
887
+ setLaunchId(launchId: string | null | undefined): void;
887
888
  /**
888
889
  * Gets the current token type.
889
890
  */
@@ -951,9 +952,6 @@ declare abstract class PlaycademyBaseClient {
951
952
  * Initializes connection monitoring if enabled.
952
953
  */
953
954
  private _initializeConnectionMonitor;
954
- /**
955
- * Initializes an internal game session for automatic session management.
956
- */
957
955
  private _initializeInternalSession;
958
956
  /**
959
957
  * Current user data and inventory management.
@@ -1062,8 +1060,8 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1062
1060
  */
1063
1061
  runtime: {
1064
1062
  getGameToken: (gameId: string, options?: {
1065
- apply?: boolean;
1066
- }) => Promise<GameTokenResponse>;
1063
+ apply?: boolean | undefined;
1064
+ } | undefined) => Promise<GameTokenResponse>;
1067
1065
  exit: () => Promise<void>;
1068
1066
  onInit: (handler: (context: GameContextPayload) => void) => void;
1069
1067
  onTokenRefresh: (handler: (data: {
@@ -1087,7 +1085,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1087
1085
  getListenerCounts: () => Record<string, number>;
1088
1086
  assets: {
1089
1087
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
1090
- fetch: (path: string, options?: RequestInit) => Promise<Response>;
1088
+ fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
1091
1089
  json: <T = unknown>(path: string) => Promise<T>;
1092
1090
  blob: (path: string) => Promise<Blob>;
1093
1091
  text: (path: string) => Promise<string>;
@@ -1130,7 +1128,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1130
1128
  * - `submit(gameId, score, metadata?)` - Record a game score
1131
1129
  */
1132
1130
  scores: {
1133
- submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
1131
+ submit: (gameId: string, score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
1134
1132
  };
1135
1133
  /**
1136
1134
  * Realtime multiplayer authentication.
@@ -1147,13 +1145,13 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1147
1145
  * - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
1148
1146
  */
1149
1147
  backend: {
1150
- get<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
1151
- post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1152
- put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1153
- patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
1154
- delete<T = unknown>(path: string, headers?: Record<string, string>): Promise<T>;
1155
- request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
1156
- download(path: string, method?: Method, body?: unknown, headers?: Record<string, string>): Promise<Response>;
1148
+ get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
1149
+ post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1150
+ put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1151
+ patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1152
+ delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
1153
+ request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
1154
+ download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
1157
1155
  url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
1158
1156
  };
1159
1157
  /** Auto-initializes a PlaycademyClient with context from the environment */
@@ -1312,6 +1310,7 @@ interface ClientConfig {
1312
1310
  token?: string;
1313
1311
  tokenType?: TokenType;
1314
1312
  gameId?: string;
1313
+ launchId?: string;
1315
1314
  autoStartSession?: boolean;
1316
1315
  onDisconnect?: DisconnectHandler;
1317
1316
  enableConnectionMonitoring?: boolean;
@@ -1351,15 +1350,15 @@ interface InitPayload {
1351
1350
  /** Timeback context (if user has a Timeback account) */
1352
1351
  timeback?: TimebackInitContext;
1353
1352
  }
1354
- type GameContextPayload = {
1353
+ interface GameContextPayload {
1355
1354
  token: string;
1356
1355
  baseUrl: string;
1357
1356
  realtimeUrl: string;
1358
1357
  gameId: string;
1359
1358
  forwardKeys?: string[];
1360
- };
1359
+ }
1361
1360
  type EventListeners = {
1362
- [E in keyof ClientEvents]?: Array<(payload: ClientEvents[E]) => void>;
1361
+ [E in keyof ClientEvents]?: ((payload: ClientEvents[E]) => void)[];
1363
1362
  };
1364
1363
  interface ClientEvents {
1365
1364
  authChange: {
@@ -1465,16 +1464,16 @@ interface ConnectionStatePayload {
1465
1464
  /**
1466
1465
  * SDK-specific API response types
1467
1466
  */
1468
- type LoginResponse = {
1467
+ interface LoginResponse {
1469
1468
  token: string;
1470
- };
1471
- type GameTokenResponse = {
1469
+ }
1470
+ interface GameTokenResponse {
1472
1471
  token: string;
1473
1472
  exp: number;
1474
- };
1475
- type InventoryMutationResponse = {
1473
+ }
1474
+ interface InventoryMutationResponse {
1476
1475
  newTotal: number;
1477
- };
1476
+ }
1478
1477
 
1479
1478
  /**
1480
1479
  * Realtime namespace types
@@ -1561,10 +1560,10 @@ type DevUploadEvent = {
1561
1560
  } | {
1562
1561
  type: 'close';
1563
1562
  };
1564
- type DevUploadHooks = {
1563
+ interface DevUploadHooks {
1565
1564
  onEvent?: (e: DevUploadEvent) => void;
1566
1565
  onClose?: () => void;
1567
- };
1566
+ }
1568
1567
 
1569
1568
  /**
1570
1569
  * Connection Manager
@@ -1908,7 +1907,7 @@ type MessageHandler<T = unknown> = (payload: T) => void;
1908
1907
  * })
1909
1908
  * ```
1910
1909
  */
1911
- type MessageEventMap = {
1910
+ interface MessageEventMap {
1912
1911
  /** Game initialization context with API endpoint, auth token, and game ID */
1913
1912
  [MessageEvents.INIT]: GameContextPayload;
1914
1913
  /** Token refresh data with new token and expiration timestamp */
@@ -1937,7 +1936,7 @@ type MessageEventMap = {
1937
1936
  [MessageEvents.AUTH_STATE_CHANGE]: AuthStateChangePayload;
1938
1937
  /** OAuth callback data from popup/new-tab windows */
1939
1938
  [MessageEvents.AUTH_CALLBACK]: AuthCallbackPayload;
1940
- };
1939
+ }
1941
1940
  /**
1942
1941
  * **PlaycademyMessaging Class**
1943
1942
  *