@playcademy/sdk 0.0.1-beta.28 → 0.0.1-beta.29
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/README.md +500 -136
- package/dist/core/client.d.ts +104 -16
- package/dist/core/namespaces/admin.d.ts +16 -12
- package/dist/core/namespaces/character.d.ts +146 -0
- package/dist/core/namespaces/dev.d.ts +8 -8
- package/dist/core/namespaces/games.d.ts +55 -2
- package/dist/core/namespaces/index.d.ts +5 -0
- package/dist/core/namespaces/leaderboard.d.ts +48 -0
- package/dist/core/namespaces/maps.d.ts +68 -1
- package/dist/core/namespaces/realtime.d.ts +40 -0
- package/dist/core/namespaces/runtime.d.ts +180 -2
- package/dist/core/namespaces/scores.d.ts +55 -0
- package/dist/core/namespaces/sprites.d.ts +32 -0
- package/dist/core/namespaces/users.d.ts +52 -0
- package/dist/index.js +713 -265
- package/dist/messaging.d.ts +13 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +450 -259
- package/package.json +3 -2
package/dist/core/client.d.ts
CHANGED
|
@@ -92,6 +92,26 @@ export declare class PlaycademyClient {
|
|
|
92
92
|
apply?: boolean;
|
|
93
93
|
}) => Promise<import("../types").GameTokenResponse>;
|
|
94
94
|
exit: () => Promise<void>;
|
|
95
|
+
onInit: (handler: (context: import("../types").GameContextPayload) => void) => void;
|
|
96
|
+
onTokenRefresh: (handler: (data: {
|
|
97
|
+
token: string;
|
|
98
|
+
exp: number;
|
|
99
|
+
}) => void) => void;
|
|
100
|
+
onPause: (handler: () => void) => void;
|
|
101
|
+
onResume: (handler: () => void) => void;
|
|
102
|
+
onForceExit: (handler: () => void) => void;
|
|
103
|
+
onOverlay: (handler: (isVisible: boolean) => void) => void;
|
|
104
|
+
ready: () => void;
|
|
105
|
+
sendTelemetry: (data: {
|
|
106
|
+
fps: number;
|
|
107
|
+
mem: number;
|
|
108
|
+
}) => void;
|
|
109
|
+
removeListener: (eventType: import("..").MessageEvents, handler: ((context: import("../types").GameContextPayload) => void) | ((data: {
|
|
110
|
+
token: string;
|
|
111
|
+
exp: number;
|
|
112
|
+
}) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
|
|
113
|
+
removeAllListeners: () => void;
|
|
114
|
+
getListenerCounts: () => Record<string, number>;
|
|
95
115
|
};
|
|
96
116
|
/** Game management methods (fetch, list, saveState, loadState, sessions) */
|
|
97
117
|
games: {
|
|
@@ -101,6 +121,17 @@ export declare class PlaycademyClient {
|
|
|
101
121
|
loadState: () => Promise<import("@playcademy/data/types").GameStateData>;
|
|
102
122
|
startSession: (gameId?: string) => Promise<import("../types").StartSessionResponse>;
|
|
103
123
|
endSession: (sessionId: string, gameId?: string) => Promise<void>;
|
|
124
|
+
token: {
|
|
125
|
+
create: (gameId: string, options?: {
|
|
126
|
+
apply?: boolean;
|
|
127
|
+
}) => Promise<import("../types").GameTokenResponse>;
|
|
128
|
+
};
|
|
129
|
+
leaderboard: {
|
|
130
|
+
get: (gameId: string, options?: {
|
|
131
|
+
limit?: number;
|
|
132
|
+
offset?: number;
|
|
133
|
+
}) => Promise<import("@playcademy/data/types").LeaderboardEntry[]>;
|
|
134
|
+
};
|
|
104
135
|
};
|
|
105
136
|
/** User methods (me, inventory management) */
|
|
106
137
|
users: {
|
|
@@ -113,6 +144,7 @@ export declare class PlaycademyClient {
|
|
|
113
144
|
image: string | null;
|
|
114
145
|
role: "admin" | "player" | "developer";
|
|
115
146
|
developerStatus: "none" | "pending" | "approved";
|
|
147
|
+
characterCreated: boolean;
|
|
116
148
|
createdAt: Date;
|
|
117
149
|
updatedAt: Date;
|
|
118
150
|
}>;
|
|
@@ -123,12 +155,21 @@ export declare class PlaycademyClient {
|
|
|
123
155
|
quantity: (identifier: string) => Promise<number>;
|
|
124
156
|
has: (identifier: string, minQuantity?: number) => Promise<boolean>;
|
|
125
157
|
};
|
|
158
|
+
scores: {
|
|
159
|
+
get: (userIdOrOptions?: string | {
|
|
160
|
+
limit?: number;
|
|
161
|
+
gameId?: string;
|
|
162
|
+
}, options?: {
|
|
163
|
+
limit?: number;
|
|
164
|
+
gameId?: string;
|
|
165
|
+
}) => Promise<import("./namespaces/users").UserScore[]>;
|
|
166
|
+
};
|
|
126
167
|
};
|
|
127
168
|
/** Developer tools (auth, games, keys management) */
|
|
128
169
|
dev: {
|
|
129
170
|
auth: {
|
|
130
171
|
applyForDeveloper: () => Promise<void>;
|
|
131
|
-
|
|
172
|
+
getStatus: () => Promise<import("@playcademy/data/types").DeveloperStatusValue>;
|
|
132
173
|
};
|
|
133
174
|
games: {
|
|
134
175
|
upsert: (slug: string, metadata: import("@playcademy/data/types").UpsertGameMetadataInput, file: File | Blob) => Promise<import("@playcademy/data/types").Game>;
|
|
@@ -136,21 +177,21 @@ export declare class PlaycademyClient {
|
|
|
136
177
|
delete: (gameId: string) => Promise<void>;
|
|
137
178
|
};
|
|
138
179
|
keys: {
|
|
139
|
-
|
|
180
|
+
create: (label?: string) => Promise<{
|
|
140
181
|
id: string;
|
|
141
182
|
createdAt: Date;
|
|
142
183
|
userId: string;
|
|
143
184
|
label: string | null;
|
|
144
185
|
keyHash: string;
|
|
145
186
|
}>;
|
|
146
|
-
|
|
187
|
+
list: () => Promise<{
|
|
147
188
|
id: string;
|
|
148
189
|
createdAt: Date;
|
|
149
190
|
userId: string;
|
|
150
191
|
label: string | null;
|
|
151
192
|
keyHash: string;
|
|
152
193
|
}[]>;
|
|
153
|
-
|
|
194
|
+
revoke: (keyId: string) => Promise<void>;
|
|
154
195
|
};
|
|
155
196
|
items: {
|
|
156
197
|
create: (gameId: string, slug: string, itemData: Omit<import("@playcademy/data/types").InsertItemInput, "slug" | "gameId">) => Promise<import("@playcademy/data/types").Item>;
|
|
@@ -171,7 +212,13 @@ export declare class PlaycademyClient {
|
|
|
171
212
|
};
|
|
172
213
|
/** Map methods (elements) */
|
|
173
214
|
maps: {
|
|
215
|
+
get: (identifier: string) => Promise<import("@playcademy/data/types").MapData>;
|
|
174
216
|
elements: (mapId: string) => Promise<import("@playcademy/data/types").MapElementWithGame[]>;
|
|
217
|
+
objects: {
|
|
218
|
+
list: (mapId: string) => Promise<import("@playcademy/data/types").MapObjectWithItem[]>;
|
|
219
|
+
create: (mapId: string, objectData: import("@playcademy/data/types").CreateMapObjectData) => Promise<import("@playcademy/data/types").MapObjectWithItem>;
|
|
220
|
+
delete: (mapId: string, objectId: string) => Promise<void>;
|
|
221
|
+
};
|
|
175
222
|
};
|
|
176
223
|
/** Admin methods (games, items, currencies, shop listings) */
|
|
177
224
|
admin: {
|
|
@@ -183,45 +230,49 @@ export declare class PlaycademyClient {
|
|
|
183
230
|
create: (props: import("@playcademy/data/types").InsertItemInput) => Promise<{
|
|
184
231
|
id: string;
|
|
185
232
|
createdAt: Date;
|
|
186
|
-
displayName: string;
|
|
187
|
-
description: string | null;
|
|
188
233
|
slug: string;
|
|
234
|
+
displayName: string;
|
|
189
235
|
metadata: unknown;
|
|
190
236
|
gameId: string | null;
|
|
191
|
-
|
|
237
|
+
description: string | null;
|
|
238
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
239
|
+
isPlaceable: boolean;
|
|
192
240
|
imageUrl: string | null;
|
|
193
241
|
}>;
|
|
194
242
|
get: (itemId: string) => Promise<{
|
|
195
243
|
id: string;
|
|
196
244
|
createdAt: Date;
|
|
197
|
-
displayName: string;
|
|
198
|
-
description: string | null;
|
|
199
245
|
slug: string;
|
|
246
|
+
displayName: string;
|
|
200
247
|
metadata: unknown;
|
|
201
248
|
gameId: string | null;
|
|
202
|
-
|
|
249
|
+
description: string | null;
|
|
250
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
251
|
+
isPlaceable: boolean;
|
|
203
252
|
imageUrl: string | null;
|
|
204
253
|
}>;
|
|
205
254
|
list: () => Promise<{
|
|
206
255
|
id: string;
|
|
207
256
|
createdAt: Date;
|
|
208
|
-
displayName: string;
|
|
209
|
-
description: string | null;
|
|
210
257
|
slug: string;
|
|
258
|
+
displayName: string;
|
|
211
259
|
metadata: unknown;
|
|
212
260
|
gameId: string | null;
|
|
213
|
-
|
|
261
|
+
description: string | null;
|
|
262
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
263
|
+
isPlaceable: boolean;
|
|
214
264
|
imageUrl: string | null;
|
|
215
265
|
}[]>;
|
|
216
266
|
update: (itemId: string, props: import("@playcademy/data/types").UpdateItemInput) => Promise<{
|
|
217
267
|
id: string;
|
|
218
268
|
createdAt: Date;
|
|
219
|
-
displayName: string;
|
|
220
|
-
description: string | null;
|
|
221
269
|
slug: string;
|
|
270
|
+
displayName: string;
|
|
222
271
|
metadata: unknown;
|
|
223
272
|
gameId: string | null;
|
|
224
|
-
|
|
273
|
+
description: string | null;
|
|
274
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
275
|
+
isPlaceable: boolean;
|
|
225
276
|
imageUrl: string | null;
|
|
226
277
|
}>;
|
|
227
278
|
delete: (itemId: string) => Promise<void>;
|
|
@@ -346,6 +397,43 @@ export declare class PlaycademyClient {
|
|
|
346
397
|
add: (amount: number) => Promise<number>;
|
|
347
398
|
spend: (amount: number) => Promise<number>;
|
|
348
399
|
};
|
|
400
|
+
/** Platform-wide leaderboard methods (fetch, getUserRank) */
|
|
401
|
+
leaderboard: {
|
|
402
|
+
fetch: (options?: import("@playcademy/data/types").LeaderboardOptions) => Promise<import("@playcademy/data/types").GameLeaderboardEntry[]>;
|
|
403
|
+
getUserRank: (gameId: string, userId: string) => Promise<import("@playcademy/data/types").UserRankResponse>;
|
|
404
|
+
};
|
|
405
|
+
/** Platform-wide scores methods (submit, getUserScores) */
|
|
406
|
+
scores: {
|
|
407
|
+
submit: (gameId: string, score: number, metadata?: Record<string, unknown>) => Promise<import("./namespaces/scores").ScoreSubmission>;
|
|
408
|
+
getByUser: (gameId: string, userId: string, options?: {
|
|
409
|
+
limit?: number;
|
|
410
|
+
}) => Promise<import("@playcademy/data/types").UserScore[]>;
|
|
411
|
+
};
|
|
412
|
+
/** Character methods (get, create, update, components) */
|
|
413
|
+
character: {
|
|
414
|
+
get: (userId?: string) => Promise<import("@playcademy/data/types").PlayerCharacter | null>;
|
|
415
|
+
create: (characterData: import("./namespaces/character").CreateCharacterData) => Promise<import("@playcademy/data/types").PlayerCharacter>;
|
|
416
|
+
update: (updates: import("./namespaces/character").UpdateCharacterData) => Promise<import("@playcademy/data/types").PlayerCharacter>;
|
|
417
|
+
components: {
|
|
418
|
+
list: (options?: import("./namespaces/character").CharacterComponentsOptions & {
|
|
419
|
+
skipCache?: boolean;
|
|
420
|
+
}) => Promise<import("@playcademy/data/types").CharacterComponentWithSpriteUrl[]>;
|
|
421
|
+
clearCache: () => void;
|
|
422
|
+
getCacheKeys: () => string[];
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
/** Sprites methods (templates) */
|
|
426
|
+
sprites: {
|
|
427
|
+
templates: {
|
|
428
|
+
get: (slug: string) => Promise<import("@playcademy/data/types").SpriteTemplateData>;
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
/** Realtime methods (token) */
|
|
432
|
+
realtime: {
|
|
433
|
+
token: {
|
|
434
|
+
get: () => Promise<import("./namespaces/realtime").RealtimeTokenResponse>;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
349
437
|
/** Auto-initializes a PlaycademyClient with context from the environment */
|
|
350
438
|
static init: typeof init;
|
|
351
439
|
/** Authenticates a user with email and password */
|
|
@@ -62,12 +62,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
62
62
|
create: (props: InsertItemInput) => Promise<{
|
|
63
63
|
id: string;
|
|
64
64
|
createdAt: Date;
|
|
65
|
-
displayName: string;
|
|
66
|
-
description: string | null;
|
|
67
65
|
slug: string;
|
|
66
|
+
displayName: string;
|
|
68
67
|
metadata: unknown;
|
|
69
68
|
gameId: string | null;
|
|
70
|
-
|
|
69
|
+
description: string | null;
|
|
70
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
71
|
+
isPlaceable: boolean;
|
|
71
72
|
imageUrl: string | null;
|
|
72
73
|
}>;
|
|
73
74
|
/**
|
|
@@ -85,12 +86,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
85
86
|
get: (itemId: string) => Promise<{
|
|
86
87
|
id: string;
|
|
87
88
|
createdAt: Date;
|
|
88
|
-
displayName: string;
|
|
89
|
-
description: string | null;
|
|
90
89
|
slug: string;
|
|
90
|
+
displayName: string;
|
|
91
91
|
metadata: unknown;
|
|
92
92
|
gameId: string | null;
|
|
93
|
-
|
|
93
|
+
description: string | null;
|
|
94
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
95
|
+
isPlaceable: boolean;
|
|
94
96
|
imageUrl: string | null;
|
|
95
97
|
}>;
|
|
96
98
|
/**
|
|
@@ -107,12 +109,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
107
109
|
list: () => Promise<{
|
|
108
110
|
id: string;
|
|
109
111
|
createdAt: Date;
|
|
110
|
-
displayName: string;
|
|
111
|
-
description: string | null;
|
|
112
112
|
slug: string;
|
|
113
|
+
displayName: string;
|
|
113
114
|
metadata: unknown;
|
|
114
115
|
gameId: string | null;
|
|
115
|
-
|
|
116
|
+
description: string | null;
|
|
117
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
118
|
+
isPlaceable: boolean;
|
|
116
119
|
imageUrl: string | null;
|
|
117
120
|
}[]>;
|
|
118
121
|
/**
|
|
@@ -132,12 +135,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
132
135
|
update: (itemId: string, props: UpdateItemInput) => Promise<{
|
|
133
136
|
id: string;
|
|
134
137
|
createdAt: Date;
|
|
135
|
-
displayName: string;
|
|
136
|
-
description: string | null;
|
|
137
138
|
slug: string;
|
|
139
|
+
displayName: string;
|
|
138
140
|
metadata: unknown;
|
|
139
141
|
gameId: string | null;
|
|
140
|
-
|
|
142
|
+
description: string | null;
|
|
143
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
144
|
+
isPlaceable: boolean;
|
|
141
145
|
imageUrl: string | null;
|
|
142
146
|
}>;
|
|
143
147
|
/**
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { CharacterComponentWithSpriteUrl, PlayerCharacter } from '@playcademy/data/types';
|
|
2
|
+
import type { PlaycademyClient } from '../../types';
|
|
3
|
+
export interface CharacterComponentsOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Optional level filter for components
|
|
6
|
+
* When provided, only components available at this level or below are returned
|
|
7
|
+
*/
|
|
8
|
+
level?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to bypass the cache and force a fresh API request
|
|
11
|
+
* Default: false (use cache when available)
|
|
12
|
+
*/
|
|
13
|
+
skipCache?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateCharacterData {
|
|
16
|
+
bodyComponentId: string;
|
|
17
|
+
eyesComponentId: string;
|
|
18
|
+
hairstyleComponentId: string;
|
|
19
|
+
outfitComponentId: string;
|
|
20
|
+
accessoryComponentId?: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface UpdateCharacterData {
|
|
23
|
+
bodyComponentId?: string;
|
|
24
|
+
eyesComponentId?: string;
|
|
25
|
+
hairstyleComponentId?: string;
|
|
26
|
+
outfitComponentId?: string;
|
|
27
|
+
accessoryComponentId?: string | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates the character namespace for the PlaycademyClient.
|
|
31
|
+
* Provides methods for managing player character configuration and components.
|
|
32
|
+
*
|
|
33
|
+
* @param client - The PlaycademyClient instance
|
|
34
|
+
* @returns Character namespace with get, create, update, and components methods
|
|
35
|
+
*/
|
|
36
|
+
export declare function createCharacterNamespace(client: PlaycademyClient): {
|
|
37
|
+
/**
|
|
38
|
+
* Gets a player character configuration.
|
|
39
|
+
*
|
|
40
|
+
* @param userId - Optional user ID. If omitted, gets the current user's character
|
|
41
|
+
* @returns Promise resolving to player character data or null if no character exists
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Get current user's character
|
|
46
|
+
* const myCharacter = await client.character.get()
|
|
47
|
+
*
|
|
48
|
+
* // Get a specific user's character
|
|
49
|
+
* const otherCharacter = await client.character.get('user-123')
|
|
50
|
+
*
|
|
51
|
+
* if (myCharacter) {
|
|
52
|
+
* console.log('My character body:', myCharacter.bodyComponentId)
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
get: (userId?: string) => Promise<PlayerCharacter | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new player character.
|
|
59
|
+
*
|
|
60
|
+
* @param characterData - The character configuration data
|
|
61
|
+
* @returns Promise resolving to the created player character
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const character = await client.character.create({
|
|
66
|
+
* bodyComponentId: 'body-1',
|
|
67
|
+
* eyesComponentId: 'eyes-2',
|
|
68
|
+
* hairstyleComponentId: 'hair-3',
|
|
69
|
+
* outfitComponentId: 'outfit-4',
|
|
70
|
+
* accessoryComponentId: 'accessory-5'
|
|
71
|
+
* })
|
|
72
|
+
* console.log('Character created:', character.id)
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
create: (characterData: CreateCharacterData) => Promise<PlayerCharacter>;
|
|
76
|
+
/**
|
|
77
|
+
* Updates an existing player character.
|
|
78
|
+
*
|
|
79
|
+
* @param updates - Partial character data to update
|
|
80
|
+
* @returns Promise resolving to the updated player character
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const updatedCharacter = await client.character.update({
|
|
85
|
+
* hairstyleComponentId: 'new-hair-style',
|
|
86
|
+
* outfitComponentId: 'new-outfit'
|
|
87
|
+
* })
|
|
88
|
+
* console.log('Character updated:', updatedCharacter.id)
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
update: (updates: UpdateCharacterData) => Promise<PlayerCharacter>;
|
|
92
|
+
/**
|
|
93
|
+
* Character components sub-namespace
|
|
94
|
+
*/
|
|
95
|
+
components: {
|
|
96
|
+
/**
|
|
97
|
+
* Lists available character components with optional level filtering.
|
|
98
|
+
* Results are cached in-memory by level to reduce API calls.
|
|
99
|
+
*
|
|
100
|
+
* @param options - Optional filtering options
|
|
101
|
+
* @param options.level - Filter components by required level
|
|
102
|
+
* @param options.skipCache - Bypass the cache and force fresh data (default: false)
|
|
103
|
+
* @returns Promise resolving to array of character components with sprite URLs
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Get all components (cached if available)
|
|
108
|
+
* const allComponents = await client.character.components.list()
|
|
109
|
+
*
|
|
110
|
+
* // Get components for level 5+ (cached if available)
|
|
111
|
+
* const levelComponents = await client.character.components.list({ level: 5 })
|
|
112
|
+
*
|
|
113
|
+
* // Force fresh data from API
|
|
114
|
+
* const freshComponents = await client.character.components.list({ skipCache: true })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
list: (options?: CharacterComponentsOptions & {
|
|
118
|
+
skipCache?: boolean;
|
|
119
|
+
}) => Promise<CharacterComponentWithSpriteUrl[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Clears the component cache.
|
|
122
|
+
* Useful when you know the component data has changed and want to force fresh data.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Clear all cached component data
|
|
127
|
+
* client.character.components.clearCache()
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
clearCache: () => void;
|
|
131
|
+
/**
|
|
132
|
+
* Returns a list of all the component cache keys currently stored.
|
|
133
|
+
* Primarily useful for debugging and cache inspection.
|
|
134
|
+
*
|
|
135
|
+
* @returns Array of cache keys (e.g., ['all', '1', '5'])
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // List all cache keys
|
|
140
|
+
* const cacheKeys = client.character.components.getCacheKeys()
|
|
141
|
+
* console.log('Cached levels:', cacheKeys)
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
getCacheKeys: () => string[];
|
|
145
|
+
};
|
|
146
|
+
};
|
|
@@ -31,13 +31,13 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
|
-
* const status = await client.dev.auth.
|
|
34
|
+
* const status = await client.dev.auth.getStatus()
|
|
35
35
|
* if (status === 'approved') {
|
|
36
36
|
* console.log('Developer access granted')
|
|
37
37
|
* }
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
getStatus: () => Promise<DeveloperStatusValue>;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Game management methods for developers.
|
|
@@ -104,11 +104,11 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
104
104
|
*
|
|
105
105
|
* @example
|
|
106
106
|
* ```typescript
|
|
107
|
-
* const key = await client.dev.keys.
|
|
107
|
+
* const key = await client.dev.keys.create('Production Key')
|
|
108
108
|
* console.log('API Key:', key.apiKey)
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
create: (label?: string) => Promise<{
|
|
112
112
|
id: string;
|
|
113
113
|
createdAt: Date;
|
|
114
114
|
userId: string;
|
|
@@ -122,11 +122,11 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
122
122
|
*
|
|
123
123
|
* @example
|
|
124
124
|
* ```typescript
|
|
125
|
-
* const keys = await client.dev.keys.
|
|
125
|
+
* const keys = await client.dev.keys.list()
|
|
126
126
|
* keys.forEach(key => console.log(`${key.label}: ${key.id}`))
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
-
|
|
129
|
+
list: () => Promise<{
|
|
130
130
|
id: string;
|
|
131
131
|
createdAt: Date;
|
|
132
132
|
userId: string;
|
|
@@ -141,11 +141,11 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
141
141
|
*
|
|
142
142
|
* @example
|
|
143
143
|
* ```typescript
|
|
144
|
-
* await client.dev.keys.
|
|
144
|
+
* await client.dev.keys.revoke('key-456')
|
|
145
145
|
* console.log('API key revoked')
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
|
-
|
|
148
|
+
revoke: (keyId: string) => Promise<void>;
|
|
149
149
|
};
|
|
150
150
|
/**
|
|
151
151
|
* Item management methods for developers.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Game, GameStateData, GameWithManifest } from '@playcademy/data/types';
|
|
2
|
-
import type { PlaycademyClient, StartSessionResponse } from '../../types';
|
|
1
|
+
import type { Game, GameStateData, GameWithManifest, LeaderboardEntry } from '@playcademy/data/types';
|
|
2
|
+
import type { GameTokenResponse, PlaycademyClient, StartSessionResponse } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Creates the games namespace for the PlaycademyClient.
|
|
5
5
|
* Provides methods for managing games, game state, and game sessions.
|
|
@@ -93,4 +93,57 @@ export declare function createGamesNamespace(client: PlaycademyClient): {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
endSession: (sessionId: string, gameId?: string) => Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Token management sub-namespace
|
|
98
|
+
*/
|
|
99
|
+
token: {
|
|
100
|
+
/**
|
|
101
|
+
* Creates a game token for the specified game.
|
|
102
|
+
* This method replaces the old runtime.getGameToken() method.
|
|
103
|
+
*
|
|
104
|
+
* @param gameId - The ID of the game to create a token for
|
|
105
|
+
* @param options - Optional configuration
|
|
106
|
+
* @param options.apply - Whether to automatically apply the token to this client
|
|
107
|
+
* @returns Promise resolving to game token response
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Create token without applying it
|
|
112
|
+
* const tokenResponse = await client.games.token.create('game-123')
|
|
113
|
+
*
|
|
114
|
+
* // Create token and apply it to current client
|
|
115
|
+
* const tokenResponse = await client.games.token.create('game-123', { apply: true })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
create: (gameId: string, options?: {
|
|
119
|
+
apply?: boolean;
|
|
120
|
+
}) => Promise<GameTokenResponse>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Leaderboard sub-namespace
|
|
124
|
+
*/
|
|
125
|
+
leaderboard: {
|
|
126
|
+
/**
|
|
127
|
+
* Gets the leaderboard for a specific game.
|
|
128
|
+
*
|
|
129
|
+
* @param gameId - The ID of the game to get leaderboard for
|
|
130
|
+
* @param options - Optional query parameters
|
|
131
|
+
* @param options.limit - Maximum number of entries to return
|
|
132
|
+
* @param options.offset - Number of entries to skip
|
|
133
|
+
* @returns Promise resolving to array of leaderboard entries
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* // Get top 10 scores
|
|
138
|
+
* const leaderboard = await client.games.leaderboard.get('game-123', { limit: 10 })
|
|
139
|
+
*
|
|
140
|
+
* // Get next 10 scores
|
|
141
|
+
* const moreScores = await client.games.leaderboard.get('game-123', { limit: 10, offset: 10 })
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
get: (gameId: string, options?: {
|
|
145
|
+
limit?: number;
|
|
146
|
+
offset?: number;
|
|
147
|
+
}) => Promise<LeaderboardEntry[]>;
|
|
148
|
+
};
|
|
96
149
|
};
|
|
@@ -9,3 +9,8 @@ export { createShopNamespace } from './shop';
|
|
|
9
9
|
export { createTelemetryNamespace } from './telemetry';
|
|
10
10
|
export { createLevelsNamespace } from './levels';
|
|
11
11
|
export { createCreditsNamespace } from './credits';
|
|
12
|
+
export { createLeaderboardNamespace } from './leaderboard';
|
|
13
|
+
export { createScoresNamespace } from './scores';
|
|
14
|
+
export { createCharacterNamespace } from './character';
|
|
15
|
+
export { createSpritesNamespace } from './sprites';
|
|
16
|
+
export { createRealtimeNamespace } from './realtime';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { GameLeaderboardEntry, LeaderboardOptions, UserRankResponse } from '@playcademy/data/types';
|
|
2
|
+
import type { PlaycademyClient } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the leaderboard namespace for the PlaycademyClient.
|
|
5
|
+
* Provides methods for accessing game-specific leaderboards.
|
|
6
|
+
*
|
|
7
|
+
* @param client - The PlaycademyClient instance
|
|
8
|
+
* @returns Leaderboard namespace with fetch methods
|
|
9
|
+
*/
|
|
10
|
+
export declare function createLeaderboardNamespace(client: PlaycademyClient): {
|
|
11
|
+
/**
|
|
12
|
+
* Fetches the leaderboard for a specific game.
|
|
13
|
+
* Note: gameId is required as cross-game score comparisons are not meaningful.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Query options for the leaderboard (gameId is required)
|
|
16
|
+
* @returns Promise resolving to array of leaderboard entries
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Get top 10 players for a specific game
|
|
21
|
+
* const gameTop10 = await client.leaderboard.fetch({
|
|
22
|
+
* gameId: 'game-123',
|
|
23
|
+
* limit: 10
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Get weekly leaderboard for a specific game
|
|
27
|
+
* const weeklyGameLeaderboard = await client.leaderboard.fetch({
|
|
28
|
+
* timeframe: 'weekly',
|
|
29
|
+
* gameId: 'game-123'
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
fetch: (options?: LeaderboardOptions) => Promise<GameLeaderboardEntry[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the rank of a specific user within a game's leaderboard.
|
|
36
|
+
*
|
|
37
|
+
* @param gameId - The game ID to get the user's rank for
|
|
38
|
+
* @param userId - The user ID to get the rank for
|
|
39
|
+
* @returns Promise resolving to user rank information
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const userRank = await client.leaderboard.getUserRank('game-123', 'user-456')
|
|
44
|
+
* console.log(`User is rank ${userRank.rank} with score ${userRank.score}`)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
getUserRank: (gameId: string, userId: string) => Promise<UserRankResponse>;
|
|
48
|
+
};
|