@playcademy/sdk 0.3.0 → 0.3.2
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 +26 -30
- package/dist/index.js +264 -204
- package/dist/internal.d.ts +4347 -4026
- package/dist/internal.js +517 -449
- package/dist/server.d.ts +4 -11
- package/dist/server.js +40 -22
- package/dist/types.d.ts +3077 -3080
- package/package.json +8 -7
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: "
|
|
637
|
+
data: "accessory" | "badge" | "collectible" | "consumable" | "currency" | "other" | "trophy" | "unlock" | "upgrade";
|
|
639
638
|
driverParam: string;
|
|
640
639
|
notNull: true;
|
|
641
640
|
hasDefault: true;
|
|
@@ -951,9 +950,6 @@ declare abstract class PlaycademyBaseClient {
|
|
|
951
950
|
* Initializes connection monitoring if enabled.
|
|
952
951
|
*/
|
|
953
952
|
private _initializeConnectionMonitor;
|
|
954
|
-
/**
|
|
955
|
-
* Initializes an internal game session for automatic session management.
|
|
956
|
-
*/
|
|
957
953
|
private _initializeInternalSession;
|
|
958
954
|
/**
|
|
959
955
|
* Current user data and inventory management.
|
|
@@ -1062,8 +1058,8 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1062
1058
|
*/
|
|
1063
1059
|
runtime: {
|
|
1064
1060
|
getGameToken: (gameId: string, options?: {
|
|
1065
|
-
apply?: boolean;
|
|
1066
|
-
}) => Promise<GameTokenResponse>;
|
|
1061
|
+
apply?: boolean | undefined;
|
|
1062
|
+
} | undefined) => Promise<GameTokenResponse>;
|
|
1067
1063
|
exit: () => Promise<void>;
|
|
1068
1064
|
onInit: (handler: (context: GameContextPayload) => void) => void;
|
|
1069
1065
|
onTokenRefresh: (handler: (data: {
|
|
@@ -1087,7 +1083,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1087
1083
|
getListenerCounts: () => Record<string, number>;
|
|
1088
1084
|
assets: {
|
|
1089
1085
|
url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
|
|
1090
|
-
fetch: (path: string, options?: RequestInit) => Promise<Response>;
|
|
1086
|
+
fetch: (path: string, options?: RequestInit | undefined) => Promise<Response>;
|
|
1091
1087
|
json: <T = unknown>(path: string) => Promise<T>;
|
|
1092
1088
|
blob: (path: string) => Promise<Blob>;
|
|
1093
1089
|
text: (path: string) => Promise<string>;
|
|
@@ -1130,7 +1126,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1130
1126
|
* - `submit(gameId, score, metadata?)` - Record a game score
|
|
1131
1127
|
*/
|
|
1132
1128
|
scores: {
|
|
1133
|
-
submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<ScoreSubmission>;
|
|
1129
|
+
submit: (gameId: string, score: number, metadata?: Record<string, unknown> | undefined) => Promise<ScoreSubmission>;
|
|
1134
1130
|
};
|
|
1135
1131
|
/**
|
|
1136
1132
|
* Realtime multiplayer authentication.
|
|
@@ -1147,13 +1143,13 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1147
1143
|
* - Routes are relative to your game's deployment (e.g., '/hello' → your-game.playcademy.gg/api/hello)
|
|
1148
1144
|
*/
|
|
1149
1145
|
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>;
|
|
1146
|
+
get<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1147
|
+
post<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1148
|
+
put<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1149
|
+
patch<T = unknown>(path: string, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1150
|
+
delete<T = unknown>(path: string, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1151
|
+
request<T = unknown>(path: string, method: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<T>;
|
|
1152
|
+
download(path: string, method?: Method, body?: unknown, headers?: Record<string, string> | undefined): Promise<Response>;
|
|
1157
1153
|
url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
|
|
1158
1154
|
};
|
|
1159
1155
|
/** Auto-initializes a PlaycademyClient with context from the environment */
|
|
@@ -1351,15 +1347,15 @@ interface InitPayload {
|
|
|
1351
1347
|
/** Timeback context (if user has a Timeback account) */
|
|
1352
1348
|
timeback?: TimebackInitContext;
|
|
1353
1349
|
}
|
|
1354
|
-
|
|
1350
|
+
interface GameContextPayload {
|
|
1355
1351
|
token: string;
|
|
1356
1352
|
baseUrl: string;
|
|
1357
1353
|
realtimeUrl: string;
|
|
1358
1354
|
gameId: string;
|
|
1359
1355
|
forwardKeys?: string[];
|
|
1360
|
-
}
|
|
1356
|
+
}
|
|
1361
1357
|
type EventListeners = {
|
|
1362
|
-
[E in keyof ClientEvents]?:
|
|
1358
|
+
[E in keyof ClientEvents]?: ((payload: ClientEvents[E]) => void)[];
|
|
1363
1359
|
};
|
|
1364
1360
|
interface ClientEvents {
|
|
1365
1361
|
authChange: {
|
|
@@ -1465,16 +1461,16 @@ interface ConnectionStatePayload {
|
|
|
1465
1461
|
/**
|
|
1466
1462
|
* SDK-specific API response types
|
|
1467
1463
|
*/
|
|
1468
|
-
|
|
1464
|
+
interface LoginResponse {
|
|
1469
1465
|
token: string;
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1466
|
+
}
|
|
1467
|
+
interface GameTokenResponse {
|
|
1472
1468
|
token: string;
|
|
1473
1469
|
exp: number;
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1470
|
+
}
|
|
1471
|
+
interface InventoryMutationResponse {
|
|
1476
1472
|
newTotal: number;
|
|
1477
|
-
}
|
|
1473
|
+
}
|
|
1478
1474
|
|
|
1479
1475
|
/**
|
|
1480
1476
|
* Realtime namespace types
|
|
@@ -1561,10 +1557,10 @@ type DevUploadEvent = {
|
|
|
1561
1557
|
} | {
|
|
1562
1558
|
type: 'close';
|
|
1563
1559
|
};
|
|
1564
|
-
|
|
1560
|
+
interface DevUploadHooks {
|
|
1565
1561
|
onEvent?: (e: DevUploadEvent) => void;
|
|
1566
1562
|
onClose?: () => void;
|
|
1567
|
-
}
|
|
1563
|
+
}
|
|
1568
1564
|
|
|
1569
1565
|
/**
|
|
1570
1566
|
* Connection Manager
|
|
@@ -1908,7 +1904,7 @@ type MessageHandler<T = unknown> = (payload: T) => void;
|
|
|
1908
1904
|
* })
|
|
1909
1905
|
* ```
|
|
1910
1906
|
*/
|
|
1911
|
-
|
|
1907
|
+
interface MessageEventMap {
|
|
1912
1908
|
/** Game initialization context with API endpoint, auth token, and game ID */
|
|
1913
1909
|
[MessageEvents.INIT]: GameContextPayload;
|
|
1914
1910
|
/** Token refresh data with new token and expiration timestamp */
|
|
@@ -1937,7 +1933,7 @@ type MessageEventMap = {
|
|
|
1937
1933
|
[MessageEvents.AUTH_STATE_CHANGE]: AuthStateChangePayload;
|
|
1938
1934
|
/** OAuth callback data from popup/new-tab windows */
|
|
1939
1935
|
[MessageEvents.AUTH_CALLBACK]: AuthCallbackPayload;
|
|
1940
|
-
}
|
|
1936
|
+
}
|
|
1941
1937
|
/**
|
|
1942
1938
|
* **PlaycademyMessaging Class**
|
|
1943
1939
|
*
|