@playcademy/sdk 0.0.4 → 0.0.6
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 +3998 -7
- package/dist/index.js +1770 -1750
- package/dist/types.d.ts +4224 -28
- package/dist/types.js +1 -748
- package/package.json +5 -3
- package/dist/core/auth/flows/popup.d.ts +0 -14
- package/dist/core/auth/flows/redirect.d.ts +0 -15
- package/dist/core/auth/flows/unified.d.ts +0 -11
- package/dist/core/auth/login.d.ts +0 -20
- package/dist/core/auth/oauth.d.ts +0 -115
- package/dist/core/auth/utils.d.ts +0 -23
- package/dist/core/cache/cooldown-cache.d.ts +0 -31
- package/dist/core/cache/index.d.ts +0 -14
- package/dist/core/cache/permanent-cache.d.ts +0 -39
- package/dist/core/cache/singleton-cache.d.ts +0 -29
- package/dist/core/cache/ttl-cache.d.ts +0 -54
- package/dist/core/cache/types.d.ts +0 -23
- package/dist/core/client.d.ts +0 -520
- package/dist/core/errors.d.ts +0 -11
- package/dist/core/namespaces/achievements.d.ts +0 -84
- package/dist/core/namespaces/admin.d.ts +0 -385
- package/dist/core/namespaces/auth.d.ts +0 -54
- package/dist/core/namespaces/character.d.ts +0 -205
- package/dist/core/namespaces/credits.d.ts +0 -51
- package/dist/core/namespaces/dev.d.ts +0 -323
- package/dist/core/namespaces/games.d.ts +0 -173
- package/dist/core/namespaces/identity.d.ts +0 -91
- package/dist/core/namespaces/index.d.ts +0 -19
- package/dist/core/namespaces/leaderboard.d.ts +0 -48
- package/dist/core/namespaces/levels.d.ts +0 -90
- package/dist/core/namespaces/maps.d.ts +0 -93
- package/dist/core/namespaces/realtime.client.d.ts +0 -129
- package/dist/core/namespaces/realtime.d.ts +0 -90
- package/dist/core/namespaces/runtime.d.ts +0 -222
- package/dist/core/namespaces/scores.d.ts +0 -55
- package/dist/core/namespaces/shop.d.ts +0 -25
- package/dist/core/namespaces/sprites.d.ts +0 -35
- package/dist/core/namespaces/telemetry.d.ts +0 -28
- package/dist/core/namespaces/timeback.d.ts +0 -111
- package/dist/core/namespaces/users.d.ts +0 -172
- package/dist/core/request.d.ts +0 -24
- package/dist/core/static/identity.d.ts +0 -37
- package/dist/core/static/index.d.ts +0 -3
- package/dist/core/static/init.d.ts +0 -21
- package/dist/core/static/login.d.ts +0 -34
- package/dist/messaging.d.ts +0 -544
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import type { InsertCurrencyInput, InsertItemInput, InsertShopListingInput, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput } from '@playcademy/data/types';
|
|
2
|
-
import type { PlaycademyClient } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* Creates the admin namespace for the PlaycademyClient.
|
|
5
|
-
* Provides administrative methods for managing games, items, currencies, and shop listings.
|
|
6
|
-
* Requires admin privileges to access these endpoints.
|
|
7
|
-
*
|
|
8
|
-
* @param client - The PlaycademyClient instance
|
|
9
|
-
* @returns Admin namespace with game, item, currency, and shop listing management methods
|
|
10
|
-
*/
|
|
11
|
-
export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
12
|
-
/**
|
|
13
|
-
* Game administration methods.
|
|
14
|
-
*/
|
|
15
|
-
games: {
|
|
16
|
-
/**
|
|
17
|
-
* Pauses a game, preventing new sessions from starting.
|
|
18
|
-
*
|
|
19
|
-
* @param gameId - The ID of the game to pause
|
|
20
|
-
* @returns Promise that resolves when game is paused
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* await client.admin.games.pauseGame('game-123')
|
|
25
|
-
* console.log('Game paused for maintenance')
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
pauseGame: (gameId: string) => Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Resumes a paused game, allowing new sessions to start.
|
|
31
|
-
*
|
|
32
|
-
* @param gameId - The ID of the game to resume
|
|
33
|
-
* @returns Promise that resolves when game is resumed
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* await client.admin.games.resumeGame('game-123')
|
|
38
|
-
* console.log('Game resumed')
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
resumeGame: (gameId: string) => Promise<void>;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Item management methods for administrators.
|
|
45
|
-
*/
|
|
46
|
-
items: {
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new item in the system.
|
|
49
|
-
*
|
|
50
|
-
* @param props - Item properties for creation
|
|
51
|
-
* @returns Promise resolving to the created item
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* const item = await client.admin.items.create({
|
|
56
|
-
* name: 'Magic Sword',
|
|
57
|
-
* description: 'A powerful weapon',
|
|
58
|
-
* rarity: 'legendary'
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
create: (props: InsertItemInput) => Promise<{
|
|
63
|
-
description: string | null;
|
|
64
|
-
id: string;
|
|
65
|
-
createdAt: Date;
|
|
66
|
-
slug: string;
|
|
67
|
-
displayName: string;
|
|
68
|
-
metadata: unknown;
|
|
69
|
-
gameId: string | null;
|
|
70
|
-
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
71
|
-
isPlaceable: boolean;
|
|
72
|
-
imageUrl: string | null;
|
|
73
|
-
}>;
|
|
74
|
-
/**
|
|
75
|
-
* Retrieves a specific item by ID.
|
|
76
|
-
*
|
|
77
|
-
* @param itemId - The ID of the item to retrieve
|
|
78
|
-
* @returns Promise resolving to the item data
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const item = await client.admin.items.get('item-123')
|
|
83
|
-
* console.log('Item name:', item.name)
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
get: (itemId: string) => Promise<{
|
|
87
|
-
description: string | null;
|
|
88
|
-
id: string;
|
|
89
|
-
createdAt: Date;
|
|
90
|
-
slug: string;
|
|
91
|
-
displayName: string;
|
|
92
|
-
metadata: unknown;
|
|
93
|
-
gameId: string | null;
|
|
94
|
-
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
95
|
-
isPlaceable: boolean;
|
|
96
|
-
imageUrl: string | null;
|
|
97
|
-
}>;
|
|
98
|
-
/**
|
|
99
|
-
* Lists all items in the system.
|
|
100
|
-
*
|
|
101
|
-
* @returns Promise resolving to array of all items
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* const items = await client.admin.items.list()
|
|
106
|
-
* console.log(`Found ${items.length} items`)
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
list: () => Promise<{
|
|
110
|
-
description: string | null;
|
|
111
|
-
id: string;
|
|
112
|
-
createdAt: Date;
|
|
113
|
-
slug: string;
|
|
114
|
-
displayName: string;
|
|
115
|
-
metadata: unknown;
|
|
116
|
-
gameId: string | null;
|
|
117
|
-
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
118
|
-
isPlaceable: boolean;
|
|
119
|
-
imageUrl: string | null;
|
|
120
|
-
}[]>;
|
|
121
|
-
/**
|
|
122
|
-
* Updates an existing item.
|
|
123
|
-
*
|
|
124
|
-
* @param itemId - The ID of the item to update
|
|
125
|
-
* @param props - Properties to update
|
|
126
|
-
* @returns Promise resolving to the updated item
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const updatedItem = await client.admin.items.update('item-123', {
|
|
131
|
-
* name: 'Enhanced Magic Sword'
|
|
132
|
-
* })
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
update: (itemId: string, props: UpdateItemInput) => Promise<{
|
|
136
|
-
description: string | null;
|
|
137
|
-
id: string;
|
|
138
|
-
createdAt: Date;
|
|
139
|
-
slug: string;
|
|
140
|
-
displayName: string;
|
|
141
|
-
metadata: unknown;
|
|
142
|
-
gameId: string | null;
|
|
143
|
-
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "accessory" | "other";
|
|
144
|
-
isPlaceable: boolean;
|
|
145
|
-
imageUrl: string | null;
|
|
146
|
-
}>;
|
|
147
|
-
/**
|
|
148
|
-
* Deletes an item from the system.
|
|
149
|
-
*
|
|
150
|
-
* @param itemId - The ID of the item to delete
|
|
151
|
-
* @returns Promise that resolves when item is deleted
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```typescript
|
|
155
|
-
* await client.admin.items.delete('item-123')
|
|
156
|
-
* console.log('Item deleted')
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
delete: (itemId: string) => Promise<void>;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Currency management methods for administrators.
|
|
163
|
-
*/
|
|
164
|
-
currencies: {
|
|
165
|
-
/**
|
|
166
|
-
* Creates a new currency in the system.
|
|
167
|
-
*
|
|
168
|
-
* @param props - Currency properties for creation
|
|
169
|
-
* @returns Promise resolving to the created currency
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```typescript
|
|
173
|
-
* const currency = await client.admin.currencies.create({
|
|
174
|
-
* name: 'Gold Coins',
|
|
175
|
-
* symbol: 'GC',
|
|
176
|
-
* decimals: 0
|
|
177
|
-
* })
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
create: (props: InsertCurrencyInput) => Promise<{
|
|
181
|
-
symbol: string | null;
|
|
182
|
-
id: string;
|
|
183
|
-
createdAt: Date;
|
|
184
|
-
updatedAt: Date | null;
|
|
185
|
-
itemId: string;
|
|
186
|
-
isPrimary: boolean;
|
|
187
|
-
}>;
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves a specific currency by ID.
|
|
190
|
-
*
|
|
191
|
-
* @param currencyId - The ID of the currency to retrieve
|
|
192
|
-
* @returns Promise resolving to the currency data
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```typescript
|
|
196
|
-
* const currency = await client.admin.currencies.get('currency-123')
|
|
197
|
-
* console.log('Currency symbol:', currency.symbol)
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
get: (currencyId: string) => Promise<{
|
|
201
|
-
symbol: string | null;
|
|
202
|
-
id: string;
|
|
203
|
-
createdAt: Date;
|
|
204
|
-
updatedAt: Date | null;
|
|
205
|
-
itemId: string;
|
|
206
|
-
isPrimary: boolean;
|
|
207
|
-
}>;
|
|
208
|
-
/**
|
|
209
|
-
* Lists all currencies in the system.
|
|
210
|
-
*
|
|
211
|
-
* @returns Promise resolving to array of all currencies
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const currencies = await client.admin.currencies.list()
|
|
216
|
-
* currencies.forEach(c => console.log(`${c.name}: ${c.symbol}`))
|
|
217
|
-
* ```
|
|
218
|
-
*/
|
|
219
|
-
list: () => Promise<{
|
|
220
|
-
symbol: string | null;
|
|
221
|
-
id: string;
|
|
222
|
-
createdAt: Date;
|
|
223
|
-
updatedAt: Date | null;
|
|
224
|
-
itemId: string;
|
|
225
|
-
isPrimary: boolean;
|
|
226
|
-
}[]>;
|
|
227
|
-
/**
|
|
228
|
-
* Updates an existing currency.
|
|
229
|
-
*
|
|
230
|
-
* @param currencyId - The ID of the currency to update
|
|
231
|
-
* @param props - Properties to update
|
|
232
|
-
* @returns Promise resolving to the updated currency
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```typescript
|
|
236
|
-
* const updatedCurrency = await client.admin.currencies.update('currency-123', {
|
|
237
|
-
* name: 'Premium Gold Coins'
|
|
238
|
-
* })
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
update: (currencyId: string, props: UpdateCurrencyInput) => Promise<{
|
|
242
|
-
symbol: string | null;
|
|
243
|
-
id: string;
|
|
244
|
-
createdAt: Date;
|
|
245
|
-
updatedAt: Date | null;
|
|
246
|
-
itemId: string;
|
|
247
|
-
isPrimary: boolean;
|
|
248
|
-
}>;
|
|
249
|
-
/**
|
|
250
|
-
* Deletes a currency from the system.
|
|
251
|
-
*
|
|
252
|
-
* @param currencyId - The ID of the currency to delete
|
|
253
|
-
* @returns Promise that resolves when currency is deleted
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```typescript
|
|
257
|
-
* await client.admin.currencies.delete('currency-123')
|
|
258
|
-
* console.log('Currency deleted')
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
|
-
delete: (currencyId: string) => Promise<void>;
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Shop listing management methods for administrators.
|
|
265
|
-
*/
|
|
266
|
-
shopListings: {
|
|
267
|
-
/**
|
|
268
|
-
* Creates a new shop listing.
|
|
269
|
-
*
|
|
270
|
-
* @param props - Shop listing properties for creation
|
|
271
|
-
* @returns Promise resolving to the created shop listing
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* const listing = await client.admin.shopListings.create({
|
|
276
|
-
* itemId: 'item-123',
|
|
277
|
-
* price: 100,
|
|
278
|
-
* currencyId: 'currency-456'
|
|
279
|
-
* })
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
create: (props: InsertShopListingInput) => Promise<{
|
|
283
|
-
id: string;
|
|
284
|
-
createdAt: Date;
|
|
285
|
-
updatedAt: Date | null;
|
|
286
|
-
itemId: string;
|
|
287
|
-
currencyId: string;
|
|
288
|
-
price: number;
|
|
289
|
-
sellBackPercentage: number | null;
|
|
290
|
-
stock: number | null;
|
|
291
|
-
isActive: boolean;
|
|
292
|
-
availableFrom: Date | null;
|
|
293
|
-
availableUntil: Date | null;
|
|
294
|
-
}>;
|
|
295
|
-
/**
|
|
296
|
-
* Retrieves a specific shop listing by ID.
|
|
297
|
-
*
|
|
298
|
-
* @param listingId - The ID of the shop listing to retrieve
|
|
299
|
-
* @returns Promise resolving to the shop listing data
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```typescript
|
|
303
|
-
* const listing = await client.admin.shopListings.get('listing-123')
|
|
304
|
-
* console.log('Listing price:', listing.price)
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
get: (listingId: string) => Promise<{
|
|
308
|
-
id: string;
|
|
309
|
-
createdAt: Date;
|
|
310
|
-
updatedAt: Date | null;
|
|
311
|
-
itemId: string;
|
|
312
|
-
currencyId: string;
|
|
313
|
-
price: number;
|
|
314
|
-
sellBackPercentage: number | null;
|
|
315
|
-
stock: number | null;
|
|
316
|
-
isActive: boolean;
|
|
317
|
-
availableFrom: Date | null;
|
|
318
|
-
availableUntil: Date | null;
|
|
319
|
-
}>;
|
|
320
|
-
/**
|
|
321
|
-
* Lists all shop listings in the system.
|
|
322
|
-
*
|
|
323
|
-
* @returns Promise resolving to array of all shop listings
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* ```typescript
|
|
327
|
-
* const listings = await client.admin.shopListings.list()
|
|
328
|
-
* console.log(`Found ${listings.length} shop listings`)
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
list: () => Promise<{
|
|
332
|
-
id: string;
|
|
333
|
-
createdAt: Date;
|
|
334
|
-
updatedAt: Date | null;
|
|
335
|
-
itemId: string;
|
|
336
|
-
currencyId: string;
|
|
337
|
-
price: number;
|
|
338
|
-
sellBackPercentage: number | null;
|
|
339
|
-
stock: number | null;
|
|
340
|
-
isActive: boolean;
|
|
341
|
-
availableFrom: Date | null;
|
|
342
|
-
availableUntil: Date | null;
|
|
343
|
-
}[]>;
|
|
344
|
-
/**
|
|
345
|
-
* Updates an existing shop listing.
|
|
346
|
-
*
|
|
347
|
-
* @param listingId - The ID of the shop listing to update
|
|
348
|
-
* @param props - Properties to update
|
|
349
|
-
* @returns Promise resolving to the updated shop listing
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```typescript
|
|
353
|
-
* const updatedListing = await client.admin.shopListings.update('listing-123', {
|
|
354
|
-
* price: 150
|
|
355
|
-
* })
|
|
356
|
-
* ```
|
|
357
|
-
*/
|
|
358
|
-
update: (listingId: string, props: UpdateShopListingInput) => Promise<{
|
|
359
|
-
id: string;
|
|
360
|
-
createdAt: Date;
|
|
361
|
-
updatedAt: Date | null;
|
|
362
|
-
itemId: string;
|
|
363
|
-
currencyId: string;
|
|
364
|
-
price: number;
|
|
365
|
-
sellBackPercentage: number | null;
|
|
366
|
-
stock: number | null;
|
|
367
|
-
isActive: boolean;
|
|
368
|
-
availableFrom: Date | null;
|
|
369
|
-
availableUntil: Date | null;
|
|
370
|
-
}>;
|
|
371
|
-
/**
|
|
372
|
-
* Deletes a shop listing from the system.
|
|
373
|
-
*
|
|
374
|
-
* @param listingId - The ID of the shop listing to delete
|
|
375
|
-
* @returns Promise that resolves when shop listing is deleted
|
|
376
|
-
*
|
|
377
|
-
* @example
|
|
378
|
-
* ```typescript
|
|
379
|
-
* await client.admin.shopListings.delete('listing-123')
|
|
380
|
-
* console.log('Shop listing deleted')
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
delete: (listingId: string) => Promise<void>;
|
|
384
|
-
};
|
|
385
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { PlaycademyClient } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the authentication namespace for the PlaycademyClient.
|
|
4
|
-
* Provides methods for platform API authentication.
|
|
5
|
-
*
|
|
6
|
-
* @param client - The PlaycademyClient instance
|
|
7
|
-
* @returns Authentication namespace with platform auth methods
|
|
8
|
-
*/
|
|
9
|
-
export declare function createAuthNamespace(client: PlaycademyClient): {
|
|
10
|
-
/**
|
|
11
|
-
* Authenticates with the Playcademy platform API using email and password.
|
|
12
|
-
* This is for server-side/CLI usage to obtain an API token.
|
|
13
|
-
*
|
|
14
|
-
* Note: This is different from client.identity.connect() which facilitates
|
|
15
|
-
* OAuth identity linking for end users.
|
|
16
|
-
*
|
|
17
|
-
* @param credentials - Email and password for platform authentication
|
|
18
|
-
* @returns Promise resolving to authentication result with token
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const result = await client.auth.login({
|
|
23
|
-
* email: 'developer@example.com',
|
|
24
|
-
* password: 'secure-password'
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* if (result.success) {
|
|
28
|
-
* // Token is automatically set on the client
|
|
29
|
-
* const games = await client.games.list()
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
login: (credentials: {
|
|
34
|
-
email: string;
|
|
35
|
-
password: string;
|
|
36
|
-
}) => Promise<{
|
|
37
|
-
success: boolean;
|
|
38
|
-
token?: string;
|
|
39
|
-
error?: string;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Logs out from the Playcademy platform API and clears the API token.
|
|
43
|
-
* This revokes the current API token on the server.
|
|
44
|
-
*
|
|
45
|
-
* @returns Promise that resolves when logout is complete
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* await client.auth.logout()
|
|
50
|
-
* console.log('Logged out from platform API')
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
logout: () => Promise<void>;
|
|
54
|
-
};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import type { CharacterComponentWithSpriteUrl, PlayerCharacter, PlayerCharacterAccessory } from '@playcademy/data/types';
|
|
2
|
-
import type { PlaycademyClient } from '../../types';
|
|
3
|
-
import type { TTLCacheConfig } from '../cache/types';
|
|
4
|
-
export interface CharacterComponentsOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Optional level filter for components
|
|
7
|
-
* When provided, only components available at this level or below are returned
|
|
8
|
-
*/
|
|
9
|
-
level?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Whether to bypass the cache and force a fresh API request
|
|
12
|
-
* Default: false (use cache when available)
|
|
13
|
-
*/
|
|
14
|
-
skipCache?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface CreateCharacterData {
|
|
17
|
-
bodyComponentId: string;
|
|
18
|
-
eyesComponentId: string;
|
|
19
|
-
hairstyleComponentId: string;
|
|
20
|
-
outfitComponentId: string;
|
|
21
|
-
}
|
|
22
|
-
export interface UpdateCharacterData {
|
|
23
|
-
bodyComponentId?: string;
|
|
24
|
-
eyesComponentId?: string;
|
|
25
|
-
hairstyleComponentId?: string;
|
|
26
|
-
outfitComponentId?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates the character namespace for the PlaycademyClient.
|
|
30
|
-
* Provides methods for managing player character configuration and components.
|
|
31
|
-
*
|
|
32
|
-
* @param client - The PlaycademyClient instance
|
|
33
|
-
* @returns Character namespace with get, create, update, and components methods
|
|
34
|
-
*/
|
|
35
|
-
export declare function createCharacterNamespace(client: PlaycademyClient): {
|
|
36
|
-
/**
|
|
37
|
-
* Gets a player character configuration.
|
|
38
|
-
*
|
|
39
|
-
* @param userId - Optional user ID. If omitted, gets the current user's character
|
|
40
|
-
* @returns Promise resolving to player character data or null if no character exists
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* // Get current user's character
|
|
45
|
-
* const myCharacter = await client.character.get()
|
|
46
|
-
*
|
|
47
|
-
* // Get a specific user's character
|
|
48
|
-
* const otherCharacter = await client.character.get('user-123')
|
|
49
|
-
*
|
|
50
|
-
* if (myCharacter) {
|
|
51
|
-
* console.log('My character body:', myCharacter.bodyComponentId)
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
get: (userId?: string) => Promise<PlayerCharacter | null>;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a new player character.
|
|
58
|
-
*
|
|
59
|
-
* @param characterData - The character configuration data
|
|
60
|
-
* @returns Promise resolving to the created player character
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const character = await client.character.create({
|
|
65
|
-
* bodyComponentId: 'body-1',
|
|
66
|
-
* eyesComponentId: 'eyes-2',
|
|
67
|
-
* hairstyleComponentId: 'hair-3',
|
|
68
|
-
* outfitComponentId: 'outfit-4',
|
|
69
|
-
* accessoryComponentId: 'accessory-5'
|
|
70
|
-
* })
|
|
71
|
-
* console.log('Character created:', character.id)
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
create: (characterData: CreateCharacterData) => Promise<PlayerCharacter>;
|
|
75
|
-
/**
|
|
76
|
-
* Updates an existing player character.
|
|
77
|
-
*
|
|
78
|
-
* @param updates - Partial character data to update
|
|
79
|
-
* @returns Promise resolving to the updated player character
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const updatedCharacter = await client.character.update({
|
|
84
|
-
* hairstyleComponentId: 'new-hair-style',
|
|
85
|
-
* outfitComponentId: 'new-outfit'
|
|
86
|
-
* })
|
|
87
|
-
* console.log('Character updated:', updatedCharacter.id)
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
update: (updates: UpdateCharacterData) => Promise<PlayerCharacter>;
|
|
91
|
-
/**
|
|
92
|
-
* Character components sub-namespace
|
|
93
|
-
*/
|
|
94
|
-
components: {
|
|
95
|
-
/**
|
|
96
|
-
* Lists available character components with optional level filtering.
|
|
97
|
-
* Results are cached for 5 minutes by default.
|
|
98
|
-
*
|
|
99
|
-
* @param options - Optional filtering and cache configuration
|
|
100
|
-
* @param options.level - Filter components by required level
|
|
101
|
-
* @param options.ttl - Custom TTL in milliseconds (0 to disable caching)
|
|
102
|
-
* @param options.skipCache - Bypass the cache and force fresh data
|
|
103
|
-
* @returns Promise resolving to array of character components with sprite URLs
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* // Use default 5 minute cache
|
|
108
|
-
* const allComponents = await client.character.components.list()
|
|
109
|
-
*
|
|
110
|
-
* // Get components for level 5+ with custom 10 minute cache
|
|
111
|
-
* const levelComponents = await client.character.components.list({
|
|
112
|
-
* level: 5,
|
|
113
|
-
* ttl: 600_000
|
|
114
|
-
* })
|
|
115
|
-
*
|
|
116
|
-
* // Force fresh data from API
|
|
117
|
-
* const freshComponents = await client.character.components.list({ skipCache: true })
|
|
118
|
-
*
|
|
119
|
-
* // Disable caching for this call
|
|
120
|
-
* const uncached = await client.character.components.list({ ttl: 0 })
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
list: (options?: CharacterComponentsOptions & TTLCacheConfig) => Promise<CharacterComponentWithSpriteUrl[]>;
|
|
124
|
-
/**
|
|
125
|
-
* Clears the component cache.
|
|
126
|
-
* Useful when you know the component data has changed and want to force fresh data.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```typescript
|
|
130
|
-
* // Clear all cached component data
|
|
131
|
-
* client.character.components.clearCache()
|
|
132
|
-
*
|
|
133
|
-
* // Clear cache for specific level
|
|
134
|
-
* client.character.components.clearCache('5')
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
clearCache: (key?: string) => void;
|
|
138
|
-
/**
|
|
139
|
-
* Returns a list of all the component cache keys currently stored.
|
|
140
|
-
* Primarily useful for debugging and cache inspection.
|
|
141
|
-
*
|
|
142
|
-
* @returns Array of cache keys (e.g., ['all', '1', '5'])
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```typescript
|
|
146
|
-
* // List all cache keys
|
|
147
|
-
* const cacheKeys = client.character.components.getCacheKeys()
|
|
148
|
-
* console.log('Cached levels:', cacheKeys)
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
getCacheKeys: () => string[];
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Accessory management sub-namespace
|
|
155
|
-
*/
|
|
156
|
-
accessories: {
|
|
157
|
-
/**
|
|
158
|
-
* Equip an accessory to a specific slot.
|
|
159
|
-
*
|
|
160
|
-
* @param slot - The slot to equip to ('head', 'face', 'hands', 'back')
|
|
161
|
-
* @param componentId - The accessory component ID to equip
|
|
162
|
-
* @returns Promise resolving to the equipped accessory data
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* // Equip glasses to the face slot
|
|
167
|
-
* const equipped = await client.character.accessories.equip('face', 'glasses-uuid')
|
|
168
|
-
* console.log('Equipped:', equipped)
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
equip: (slot: string, componentId: string) => Promise<PlayerCharacterAccessory>;
|
|
172
|
-
/**
|
|
173
|
-
* Remove an accessory from a specific slot.
|
|
174
|
-
*
|
|
175
|
-
* @param slot - The slot to remove from ('head', 'face', 'hands', 'back')
|
|
176
|
-
* @returns Promise resolving to success status
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* ```typescript
|
|
180
|
-
* // Remove glasses from face slot
|
|
181
|
-
* const result = await client.character.accessories.remove('face')
|
|
182
|
-
* console.log('Removed:', result.success)
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
remove: (slot: string) => Promise<{
|
|
186
|
-
success: boolean;
|
|
187
|
-
}>;
|
|
188
|
-
/**
|
|
189
|
-
* Get all equipped accessories for the current player.
|
|
190
|
-
* Note: This is included automatically in character.get() with relations.
|
|
191
|
-
*
|
|
192
|
-
* @returns Promise resolving to array of equipped accessories
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```typescript
|
|
196
|
-
* // Get all equipped accessories
|
|
197
|
-
* const accessories = await client.character.accessories.list()
|
|
198
|
-
* accessories.forEach(acc => {
|
|
199
|
-
* console.log(`Slot ${acc.slot}: ${acc.accessoryComponent.displayName}`)
|
|
200
|
-
* })
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
list: () => Promise<PlayerCharacterAccessory[]>;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { PlaycademyClient } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the credits namespace for the PlaycademyClient.
|
|
4
|
-
* Provides convenient methods for working with Playcademy Credits (the primary platform currency).
|
|
5
|
-
*
|
|
6
|
-
* @param client - The PlaycademyClient instance
|
|
7
|
-
* @returns Credits namespace with balance and transaction methods
|
|
8
|
-
*/
|
|
9
|
-
export declare function createCreditsNamespace(client: PlaycademyClient): {
|
|
10
|
-
/**
|
|
11
|
-
* Gets the current balance of Playcademy Credits for the authenticated user.
|
|
12
|
-
* This is a convenience method that finds the primary currency in the user's inventory.
|
|
13
|
-
*
|
|
14
|
-
* @returns Promise resolving to the current credits balance
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const balance = await client.credits.balance()
|
|
19
|
-
* console.log('Current credits:', balance)
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
balance: () => Promise<number>;
|
|
23
|
-
/**
|
|
24
|
-
* Adds Playcademy Credits to the user's inventory.
|
|
25
|
-
* This is a convenience method that automatically finds the credits item ID.
|
|
26
|
-
*
|
|
27
|
-
* @param amount - The amount of credits to add (must be positive)
|
|
28
|
-
* @returns Promise resolving to the new total balance
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const newBalance = await client.credits.add(100)
|
|
33
|
-
* console.log('New balance after adding 100 credits:', newBalance)
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
add: (amount: number) => Promise<number>;
|
|
37
|
-
/**
|
|
38
|
-
* Spends (removes) Playcademy Credits from the user's inventory.
|
|
39
|
-
* This is a convenience method that automatically finds the credits item ID.
|
|
40
|
-
*
|
|
41
|
-
* @param amount - The amount of credits to spend (must be positive)
|
|
42
|
-
* @returns Promise resolving to the new total balance
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const newBalance = await client.credits.spend(50)
|
|
47
|
-
* console.log('New balance after spending 50 credits:', newBalance)
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
spend: (amount: number) => Promise<number>;
|
|
51
|
-
};
|