@playcademy/sdk 0.0.1-beta.24 → 0.0.1-beta.26
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 +4 -6
- package/dist/core/client.d.ts +67 -47
- package/dist/core/namespaces/admin.d.ts +24 -20
- package/dist/core/namespaces/auth.d.ts +1 -1
- package/dist/core/namespaces/credits.d.ts +1 -1
- package/dist/core/namespaces/dev.d.ts +185 -15
- package/dist/core/namespaces/games.d.ts +8 -4
- package/dist/core/namespaces/levels.d.ts +2 -2
- package/dist/core/namespaces/maps.d.ts +4 -9
- package/dist/core/namespaces/runtime.d.ts +1 -2
- package/dist/core/namespaces/shop.d.ts +1 -2
- package/dist/core/namespaces/telemetry.d.ts +1 -1
- package/dist/core/namespaces/users.d.ts +18 -18
- package/dist/core/request.d.ts +1 -1
- package/dist/core/static/init.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +575 -97
- package/dist/types.d.ts +3 -36
- package/dist/types.js +363 -8
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -36,7 +36,9 @@ const client = await initFromWindow() // initFromWindow is async
|
|
|
36
36
|
For server-side code, UI applications, or other environments where you manage configuration manually:
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import { PlaycademyClient
|
|
39
|
+
import { PlaycademyClient } from '@playcademy/sdk'
|
|
40
|
+
|
|
41
|
+
import type { LoginResponse } from '@playcademy/sdk'
|
|
40
42
|
|
|
41
43
|
async function initializeAndUseClient() {
|
|
42
44
|
const baseUrl = 'https://api.playcademy.com' // Or your local /api endpoint
|
|
@@ -44,11 +46,7 @@ async function initializeAndUseClient() {
|
|
|
44
46
|
|
|
45
47
|
try {
|
|
46
48
|
// 1. Authenticate to get a token
|
|
47
|
-
loginResponse = await PlaycademyClient.login(
|
|
48
|
-
baseUrl,
|
|
49
|
-
'user@example.com',
|
|
50
|
-
'password',
|
|
51
|
-
)
|
|
49
|
+
loginResponse = await PlaycademyClient.login(baseUrl, 'user@example.com', 'password')
|
|
52
50
|
} catch (error) {
|
|
53
51
|
console.error('Login failed:', error)
|
|
54
52
|
return
|
package/dist/core/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Method } from './request';
|
|
2
1
|
import { init, login } from './static';
|
|
3
2
|
import type { ClientConfig, ClientEvents } from '../types';
|
|
3
|
+
import type { Method } from './request';
|
|
4
4
|
/**
|
|
5
5
|
* Main Playcademy SDK client for interacting with the platform API.
|
|
6
6
|
* Provides namespaced access to all platform features including games, users, inventory, and more.
|
|
@@ -90,24 +90,27 @@ export declare class PlaycademyClient {
|
|
|
90
90
|
runtime: {
|
|
91
91
|
getGameToken: (gameId: string, options?: {
|
|
92
92
|
apply?: boolean;
|
|
93
|
-
}) => Promise<import("
|
|
93
|
+
}) => Promise<import("../types").GameTokenResponse>;
|
|
94
94
|
exit: () => Promise<void>;
|
|
95
95
|
};
|
|
96
96
|
/** Game management methods (fetch, list, saveState, loadState, sessions) */
|
|
97
97
|
games: {
|
|
98
|
-
fetch: (gameIdOrSlug: string) => Promise<import("@playcademy/types").GameWithManifest>;
|
|
99
|
-
list: () => Promise<Array<import("@playcademy/types").Game>>;
|
|
98
|
+
fetch: (gameIdOrSlug: string) => Promise<import("@playcademy/data/types").GameWithManifest>;
|
|
99
|
+
list: () => Promise<Array<import("@playcademy/data/types").Game>>;
|
|
100
100
|
saveState: (state: Record<string, unknown>) => Promise<void>;
|
|
101
|
-
loadState: () => Promise<
|
|
102
|
-
|
|
101
|
+
loadState: () => Promise<{
|
|
102
|
+
data: unknown;
|
|
103
|
+
updatedAt: Date | null;
|
|
104
|
+
userId: string;
|
|
105
|
+
gameId: string;
|
|
106
|
+
}>;
|
|
107
|
+
startSession: (gameId?: string) => Promise<import("../types").StartSessionResponse>;
|
|
103
108
|
endSession: (sessionId: string, gameId?: string) => Promise<void>;
|
|
104
109
|
};
|
|
105
110
|
/** User methods (me, inventory management) */
|
|
106
111
|
users: {
|
|
107
112
|
me: () => Promise<{
|
|
108
113
|
id: string;
|
|
109
|
-
createdAt: Date;
|
|
110
|
-
updatedAt: Date;
|
|
111
114
|
name: string;
|
|
112
115
|
username: string | null;
|
|
113
116
|
email: string;
|
|
@@ -115,11 +118,13 @@ export declare class PlaycademyClient {
|
|
|
115
118
|
image: string | null;
|
|
116
119
|
role: "admin" | "player" | "developer";
|
|
117
120
|
developerStatus: "none" | "pending" | "approved";
|
|
121
|
+
createdAt: Date;
|
|
122
|
+
updatedAt: Date;
|
|
118
123
|
}>;
|
|
119
124
|
inventory: {
|
|
120
|
-
get: () => Promise<import("@playcademy/types").InventoryItemWithItem[]>;
|
|
121
|
-
add: (identifier: string, qty: number) => Promise<import("
|
|
122
|
-
remove: (identifier: string, qty: number) => Promise<import("
|
|
125
|
+
get: () => Promise<import("@playcademy/data/types").InventoryItemWithItem[]>;
|
|
126
|
+
add: (identifier: string, qty: number) => Promise<import("../types").InventoryMutationResponse>;
|
|
127
|
+
remove: (identifier: string, qty: number) => Promise<import("../types").InventoryMutationResponse>;
|
|
123
128
|
quantity: (identifier: string) => Promise<number>;
|
|
124
129
|
has: (identifier: string, minQuantity?: number) => Promise<boolean>;
|
|
125
130
|
};
|
|
@@ -128,22 +133,22 @@ export declare class PlaycademyClient {
|
|
|
128
133
|
dev: {
|
|
129
134
|
auth: {
|
|
130
135
|
applyForDeveloper: () => Promise<void>;
|
|
131
|
-
getDeveloperStatus: () => Promise<import("
|
|
136
|
+
getDeveloperStatus: () => Promise<import("@playcademy/data/types").DeveloperStatusValue>;
|
|
132
137
|
};
|
|
133
138
|
games: {
|
|
134
|
-
upsert: (slug: string, metadata: import("@playcademy/types").UpsertGameMetadataInput, file: File | Blob) => Promise<import("@playcademy/types").Game>;
|
|
135
|
-
update: (gameId: string, props: Partial<import("@playcademy/types").Game>) => Promise<void>;
|
|
139
|
+
upsert: (slug: string, metadata: import("@playcademy/data/types").UpsertGameMetadataInput, file: File | Blob) => Promise<import("@playcademy/data/types").Game>;
|
|
140
|
+
update: (gameId: string, props: Partial<import("@playcademy/data/types").Game>) => Promise<void>;
|
|
136
141
|
delete: (gameId: string) => Promise<void>;
|
|
137
142
|
};
|
|
138
143
|
keys: {
|
|
139
|
-
createKey: (
|
|
144
|
+
createKey: (label?: string) => Promise<{
|
|
140
145
|
id: string;
|
|
141
146
|
createdAt: Date;
|
|
142
147
|
userId: string;
|
|
143
148
|
label: string | null;
|
|
144
149
|
keyHash: string;
|
|
145
150
|
}>;
|
|
146
|
-
listKeys: (
|
|
151
|
+
listKeys: () => Promise<{
|
|
147
152
|
id: string;
|
|
148
153
|
createdAt: Date;
|
|
149
154
|
userId: string;
|
|
@@ -152,21 +157,32 @@ export declare class PlaycademyClient {
|
|
|
152
157
|
}[]>;
|
|
153
158
|
revokeKey: (keyId: string) => Promise<void>;
|
|
154
159
|
};
|
|
160
|
+
items: {
|
|
161
|
+
create: (gameId: string, slug: string, itemData: Omit<import("@playcademy/data/types").InsertItemInput, "slug" | "gameId">) => Promise<import("@playcademy/data/types").Item>;
|
|
162
|
+
update: (gameId: string, itemId: string, updates: import("@playcademy/data/types").UpdateItemInput) => Promise<import("@playcademy/data/types").Item>;
|
|
163
|
+
list: (gameId: string) => Promise<Array<import("@playcademy/data/types").Item>>;
|
|
164
|
+
get: (gameId: string, slug: string) => Promise<import("@playcademy/data/types").Item>;
|
|
165
|
+
delete: (gameId: string, itemId: string) => Promise<void>;
|
|
166
|
+
shop: {
|
|
167
|
+
create: (gameId: string, itemId: string, listingData: Omit<import("@playcademy/data/types").InsertShopListingInput, "itemId">) => Promise<import("@playcademy/data/types").ShopListing>;
|
|
168
|
+
get: (gameId: string, itemId: string) => Promise<import("@playcademy/data/types").ShopListing | null>;
|
|
169
|
+
update: (gameId: string, itemId: string, updates: import("@playcademy/data/types").UpdateShopListingInput) => Promise<import("@playcademy/data/types").ShopListing>;
|
|
170
|
+
delete: (gameId: string, itemId: string) => Promise<void>;
|
|
171
|
+
list: (gameId: string) => Promise<Array<import("@playcademy/data/types").ShopListing & {
|
|
172
|
+
item: import("@playcademy/data/types").Item;
|
|
173
|
+
}>>;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
155
176
|
};
|
|
156
177
|
/** Map methods (elements) */
|
|
157
178
|
maps: {
|
|
158
179
|
elements: (mapId: string) => Promise<{
|
|
159
180
|
id: string;
|
|
160
|
-
metadata: ({
|
|
161
|
-
description?: string | undefined;
|
|
162
|
-
sourceTiledObjects?: Record<string, unknown>[] | undefined;
|
|
163
|
-
} & {
|
|
164
|
-
[k: string]: unknown;
|
|
165
|
-
}) | null;
|
|
166
|
-
gameId: string | null;
|
|
167
181
|
mapId: string | null;
|
|
168
182
|
elementSlug: string;
|
|
169
|
-
interactionType: "
|
|
183
|
+
interactionType: "info" | "game_entry" | "game_registry" | "teleport" | "door_in" | "door_out" | "npc_interaction" | "quest_trigger";
|
|
184
|
+
metadata: Record<string, unknown> | null;
|
|
185
|
+
gameId: string | null;
|
|
170
186
|
}[]>;
|
|
171
187
|
};
|
|
172
188
|
/** Admin methods (games, items, currencies, shop listings) */
|
|
@@ -176,50 +192,54 @@ export declare class PlaycademyClient {
|
|
|
176
192
|
resumeGame: (gameId: string) => Promise<void>;
|
|
177
193
|
};
|
|
178
194
|
items: {
|
|
179
|
-
create: (props: import("@playcademy/types").
|
|
195
|
+
create: (props: import("@playcademy/data/types").InsertItemInput) => Promise<{
|
|
180
196
|
id: string;
|
|
181
|
-
displayName: string;
|
|
182
|
-
metadata: unknown;
|
|
183
197
|
createdAt: Date;
|
|
184
|
-
|
|
198
|
+
displayName: string;
|
|
185
199
|
description: string | null;
|
|
200
|
+
slug: string;
|
|
201
|
+
metadata: unknown;
|
|
202
|
+
gameId: string | null;
|
|
186
203
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
187
204
|
imageUrl: string | null;
|
|
188
205
|
}>;
|
|
189
206
|
get: (itemId: string) => Promise<{
|
|
190
207
|
id: string;
|
|
191
|
-
displayName: string;
|
|
192
|
-
metadata: unknown;
|
|
193
208
|
createdAt: Date;
|
|
194
|
-
|
|
209
|
+
displayName: string;
|
|
195
210
|
description: string | null;
|
|
211
|
+
slug: string;
|
|
212
|
+
metadata: unknown;
|
|
213
|
+
gameId: string | null;
|
|
196
214
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
197
215
|
imageUrl: string | null;
|
|
198
216
|
}>;
|
|
199
217
|
list: () => Promise<{
|
|
200
218
|
id: string;
|
|
201
|
-
displayName: string;
|
|
202
|
-
metadata: unknown;
|
|
203
219
|
createdAt: Date;
|
|
204
|
-
|
|
220
|
+
displayName: string;
|
|
205
221
|
description: string | null;
|
|
222
|
+
slug: string;
|
|
223
|
+
metadata: unknown;
|
|
224
|
+
gameId: string | null;
|
|
206
225
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
207
226
|
imageUrl: string | null;
|
|
208
227
|
}[]>;
|
|
209
|
-
update: (itemId: string, props: import("@playcademy/types").
|
|
228
|
+
update: (itemId: string, props: import("@playcademy/data/types").UpdateItemInput) => Promise<{
|
|
210
229
|
id: string;
|
|
211
|
-
displayName: string;
|
|
212
|
-
metadata: unknown;
|
|
213
230
|
createdAt: Date;
|
|
214
|
-
|
|
231
|
+
displayName: string;
|
|
215
232
|
description: string | null;
|
|
233
|
+
slug: string;
|
|
234
|
+
metadata: unknown;
|
|
235
|
+
gameId: string | null;
|
|
216
236
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
217
237
|
imageUrl: string | null;
|
|
218
238
|
}>;
|
|
219
239
|
delete: (itemId: string) => Promise<void>;
|
|
220
240
|
};
|
|
221
241
|
currencies: {
|
|
222
|
-
create: (props: import("@playcademy/types").
|
|
242
|
+
create: (props: import("@playcademy/data/types").InsertCurrencyInput) => Promise<{
|
|
223
243
|
symbol: string | null;
|
|
224
244
|
id: string;
|
|
225
245
|
createdAt: Date;
|
|
@@ -243,7 +263,7 @@ export declare class PlaycademyClient {
|
|
|
243
263
|
itemId: string;
|
|
244
264
|
isPrimary: boolean;
|
|
245
265
|
}[]>;
|
|
246
|
-
update: (currencyId: string, props: import("@playcademy/types").
|
|
266
|
+
update: (currencyId: string, props: import("@playcademy/data/types").UpdateCurrencyInput) => Promise<{
|
|
247
267
|
symbol: string | null;
|
|
248
268
|
id: string;
|
|
249
269
|
createdAt: Date;
|
|
@@ -254,7 +274,7 @@ export declare class PlaycademyClient {
|
|
|
254
274
|
delete: (currencyId: string) => Promise<void>;
|
|
255
275
|
};
|
|
256
276
|
shopListings: {
|
|
257
|
-
create: (props: import("@playcademy/types").
|
|
277
|
+
create: (props: import("@playcademy/data/types").InsertShopListingInput) => Promise<{
|
|
258
278
|
id: string;
|
|
259
279
|
createdAt: Date;
|
|
260
280
|
updatedAt: Date | null;
|
|
@@ -293,7 +313,7 @@ export declare class PlaycademyClient {
|
|
|
293
313
|
availableFrom: Date | null;
|
|
294
314
|
availableUntil: Date | null;
|
|
295
315
|
}[]>;
|
|
296
|
-
update: (listingId: string, props: import("@playcademy/types").
|
|
316
|
+
update: (listingId: string, props: import("@playcademy/data/types").UpdateShopListingInput) => Promise<{
|
|
297
317
|
id: string;
|
|
298
318
|
createdAt: Date;
|
|
299
319
|
updatedAt: Date | null;
|
|
@@ -311,21 +331,21 @@ export declare class PlaycademyClient {
|
|
|
311
331
|
};
|
|
312
332
|
/** Shop methods (view) */
|
|
313
333
|
shop: {
|
|
314
|
-
view: () => Promise<import("
|
|
334
|
+
view: () => Promise<import("@playcademy/data/types").ShopViewResponse>;
|
|
315
335
|
};
|
|
316
336
|
/** Level methods (levels) */
|
|
317
337
|
levels: {
|
|
318
|
-
get: () => Promise<import("@playcademy/types").UserLevel>;
|
|
338
|
+
get: () => Promise<import("@playcademy/data/types").UserLevel>;
|
|
319
339
|
progress: () => Promise<{
|
|
320
340
|
level: number;
|
|
321
341
|
currentXp: number;
|
|
322
342
|
xpToNextLevel: number;
|
|
323
343
|
totalXP: number;
|
|
324
344
|
}>;
|
|
325
|
-
addXP: (amount: number) => Promise<import("@playcademy/types").XPAddResult>;
|
|
345
|
+
addXP: (amount: number) => Promise<import("@playcademy/data/types").XPAddResult>;
|
|
326
346
|
config: {
|
|
327
|
-
list: () => Promise<import("@playcademy/types").LevelConfig[]>;
|
|
328
|
-
get: (level: number) => Promise<import("@playcademy/types").LevelConfig | null>;
|
|
347
|
+
list: () => Promise<import("@playcademy/data/types").LevelConfig[]>;
|
|
348
|
+
get: (level: number) => Promise<import("@playcademy/data/types").LevelConfig | null>;
|
|
329
349
|
};
|
|
330
350
|
};
|
|
331
351
|
/** Telemetry methods (pushMetrics) */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { InsertCurrencyInput, InsertItemInput, InsertShopListingInput, UpdateCurrencyInput, UpdateItemInput, UpdateShopListingInput } from '@playcademy/data/types';
|
|
2
|
+
import type { PlaycademyClient } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Creates the admin namespace for the PlaycademyClient.
|
|
5
5
|
* Provides administrative methods for managing games, items, currencies, and shop listings.
|
|
@@ -59,13 +59,14 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
59
59
|
* })
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
create: (props:
|
|
62
|
+
create: (props: InsertItemInput) => Promise<{
|
|
63
63
|
id: string;
|
|
64
|
-
displayName: string;
|
|
65
|
-
metadata: unknown;
|
|
66
64
|
createdAt: Date;
|
|
67
|
-
|
|
65
|
+
displayName: string;
|
|
68
66
|
description: string | null;
|
|
67
|
+
slug: string;
|
|
68
|
+
metadata: unknown;
|
|
69
|
+
gameId: string | null;
|
|
69
70
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
70
71
|
imageUrl: string | null;
|
|
71
72
|
}>;
|
|
@@ -83,11 +84,12 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
83
84
|
*/
|
|
84
85
|
get: (itemId: string) => Promise<{
|
|
85
86
|
id: string;
|
|
86
|
-
displayName: string;
|
|
87
|
-
metadata: unknown;
|
|
88
87
|
createdAt: Date;
|
|
89
|
-
|
|
88
|
+
displayName: string;
|
|
90
89
|
description: string | null;
|
|
90
|
+
slug: string;
|
|
91
|
+
metadata: unknown;
|
|
92
|
+
gameId: string | null;
|
|
91
93
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
92
94
|
imageUrl: string | null;
|
|
93
95
|
}>;
|
|
@@ -104,11 +106,12 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
104
106
|
*/
|
|
105
107
|
list: () => Promise<{
|
|
106
108
|
id: string;
|
|
107
|
-
displayName: string;
|
|
108
|
-
metadata: unknown;
|
|
109
109
|
createdAt: Date;
|
|
110
|
-
|
|
110
|
+
displayName: string;
|
|
111
111
|
description: string | null;
|
|
112
|
+
slug: string;
|
|
113
|
+
metadata: unknown;
|
|
114
|
+
gameId: string | null;
|
|
112
115
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
113
116
|
imageUrl: string | null;
|
|
114
117
|
}[]>;
|
|
@@ -126,13 +129,14 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
126
129
|
* })
|
|
127
130
|
* ```
|
|
128
131
|
*/
|
|
129
|
-
update: (itemId: string, props:
|
|
132
|
+
update: (itemId: string, props: UpdateItemInput) => Promise<{
|
|
130
133
|
id: string;
|
|
131
|
-
displayName: string;
|
|
132
|
-
metadata: unknown;
|
|
133
134
|
createdAt: Date;
|
|
134
|
-
|
|
135
|
+
displayName: string;
|
|
135
136
|
description: string | null;
|
|
137
|
+
slug: string;
|
|
138
|
+
metadata: unknown;
|
|
139
|
+
gameId: string | null;
|
|
136
140
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
137
141
|
imageUrl: string | null;
|
|
138
142
|
}>;
|
|
@@ -169,7 +173,7 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
169
173
|
* })
|
|
170
174
|
* ```
|
|
171
175
|
*/
|
|
172
|
-
create: (props:
|
|
176
|
+
create: (props: InsertCurrencyInput) => Promise<{
|
|
173
177
|
symbol: string | null;
|
|
174
178
|
id: string;
|
|
175
179
|
createdAt: Date;
|
|
@@ -230,7 +234,7 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
230
234
|
* })
|
|
231
235
|
* ```
|
|
232
236
|
*/
|
|
233
|
-
update: (currencyId: string, props:
|
|
237
|
+
update: (currencyId: string, props: UpdateCurrencyInput) => Promise<{
|
|
234
238
|
symbol: string | null;
|
|
235
239
|
id: string;
|
|
236
240
|
createdAt: Date;
|
|
@@ -271,7 +275,7 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
271
275
|
* })
|
|
272
276
|
* ```
|
|
273
277
|
*/
|
|
274
|
-
create: (props:
|
|
278
|
+
create: (props: InsertShopListingInput) => Promise<{
|
|
275
279
|
id: string;
|
|
276
280
|
createdAt: Date;
|
|
277
281
|
updatedAt: Date | null;
|
|
@@ -347,7 +351,7 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
|
|
|
347
351
|
* })
|
|
348
352
|
* ```
|
|
349
353
|
*/
|
|
350
|
-
update: (listingId: string, props:
|
|
354
|
+
update: (listingId: string, props: UpdateShopListingInput) => Promise<{
|
|
351
355
|
id: string;
|
|
352
356
|
createdAt: Date;
|
|
353
357
|
updatedAt: Date | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlaycademyClient } from '
|
|
1
|
+
import type { PlaycademyClient } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Creates the credits namespace for the PlaycademyClient.
|
|
4
4
|
* Provides convenient methods for working with Playcademy Credits (the primary platform currency).
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { DeveloperStatusValue } from '../../types';
|
|
1
|
+
import type { DeveloperStatusValue, Game, InsertItemInput, InsertShopListingInput, Item, ShopListing, UpdateItemInput, UpdateShopListingInput, UpsertGameMetadataInput } from '@playcademy/data/types';
|
|
2
|
+
import type { PlaycademyClient } from '../../types';
|
|
4
3
|
/**
|
|
5
4
|
* Creates the developer namespace for the PlaycademyClient.
|
|
6
|
-
* Provides methods for developer account management, game publishing,
|
|
5
|
+
* Provides methods for developer account management, game publishing, API key management, and item management.
|
|
7
6
|
*
|
|
8
7
|
* @param client - The PlaycademyClient instance
|
|
9
|
-
* @returns Developer namespace with auth, games, and
|
|
8
|
+
* @returns Developer namespace with auth, games, keys, and items methods
|
|
10
9
|
*/
|
|
11
10
|
export declare function createDevNamespace(client: PlaycademyClient): {
|
|
12
11
|
/**
|
|
@@ -97,19 +96,18 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
97
96
|
*/
|
|
98
97
|
keys: {
|
|
99
98
|
/**
|
|
100
|
-
* Creates a new API key for
|
|
99
|
+
* Creates a new API key for the developer.
|
|
101
100
|
*
|
|
102
|
-
* @param gameId - The game ID to create a key for
|
|
103
101
|
* @param label - Optional label for the key
|
|
104
102
|
* @returns Promise resolving to the created API key
|
|
105
103
|
*
|
|
106
104
|
* @example
|
|
107
105
|
* ```typescript
|
|
108
|
-
* const key = await client.dev.keys.createKey('
|
|
109
|
-
* console.log('API Key:', key.
|
|
106
|
+
* const key = await client.dev.keys.createKey('Production Key')
|
|
107
|
+
* console.log('API Key:', key.apiKey)
|
|
110
108
|
* ```
|
|
111
109
|
*/
|
|
112
|
-
createKey: (
|
|
110
|
+
createKey: (label?: string) => Promise<{
|
|
113
111
|
id: string;
|
|
114
112
|
createdAt: Date;
|
|
115
113
|
userId: string;
|
|
@@ -117,18 +115,17 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
117
115
|
keyHash: string;
|
|
118
116
|
}>;
|
|
119
117
|
/**
|
|
120
|
-
* Lists all API keys for
|
|
118
|
+
* Lists all API keys for the developer.
|
|
121
119
|
*
|
|
122
|
-
* @param gameId - The game ID to list keys for
|
|
123
120
|
* @returns Promise resolving to array of API keys
|
|
124
121
|
*
|
|
125
122
|
* @example
|
|
126
123
|
* ```typescript
|
|
127
|
-
* const keys = await client.dev.keys.listKeys(
|
|
128
|
-
* keys.forEach(key => console.log(`${key.label}: ${key.
|
|
124
|
+
* const keys = await client.dev.keys.listKeys()
|
|
125
|
+
* keys.forEach(key => console.log(`${key.label}: ${key.id}`))
|
|
129
126
|
* ```
|
|
130
127
|
*/
|
|
131
|
-
listKeys: (
|
|
128
|
+
listKeys: () => Promise<{
|
|
132
129
|
id: string;
|
|
133
130
|
createdAt: Date;
|
|
134
131
|
userId: string;
|
|
@@ -149,4 +146,177 @@ export declare function createDevNamespace(client: PlaycademyClient): {
|
|
|
149
146
|
*/
|
|
150
147
|
revokeKey: (keyId: string) => Promise<void>;
|
|
151
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Item management methods for developers.
|
|
151
|
+
* Allows developers to create and manage game-specific items.
|
|
152
|
+
*/
|
|
153
|
+
items: {
|
|
154
|
+
/**
|
|
155
|
+
* Creates a new game-scoped item.
|
|
156
|
+
*
|
|
157
|
+
* @param gameId - The game ID to create the item for
|
|
158
|
+
* @param slug - The item slug (unique within the game)
|
|
159
|
+
* @param itemData - Item properties (displayName, description, type, etc.)
|
|
160
|
+
* @returns Promise resolving to the created item
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const item = await client.dev.items.create('game-123', 'MAGIC_SWORD', {
|
|
165
|
+
* displayName: 'Magic Sword',
|
|
166
|
+
* description: 'A powerful enchanted blade',
|
|
167
|
+
* type: 'unlock',
|
|
168
|
+
* metadata: { rarity: 'epic' }
|
|
169
|
+
* })
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
create: (gameId: string, slug: string, itemData: Omit<InsertItemInput, "slug" | "gameId">) => Promise<Item>;
|
|
173
|
+
/**
|
|
174
|
+
* Updates an existing game-scoped item.
|
|
175
|
+
*
|
|
176
|
+
* @param gameId - The game ID
|
|
177
|
+
* @param itemId - The item ID to update
|
|
178
|
+
* @param updates - Partial item properties to update
|
|
179
|
+
* @returns Promise resolving to the updated item
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const updated = await client.dev.items.update('game-123', 'item-456', {
|
|
184
|
+
* displayName: 'Super Magic Sword',
|
|
185
|
+
* metadata: { rarity: 'legendary' }
|
|
186
|
+
* })
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
update: (gameId: string, itemId: string, updates: UpdateItemInput) => Promise<Item>;
|
|
190
|
+
/**
|
|
191
|
+
* Lists all items for a specific game.
|
|
192
|
+
*
|
|
193
|
+
* @param gameId - The game ID to list items for
|
|
194
|
+
* @returns Promise resolving to array of game-scoped items
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const items = await client.dev.items.list('game-123')
|
|
199
|
+
* items.forEach(item => console.log(`${item.slug}: ${item.displayName}`))
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
list: (gameId: string) => Promise<Array<Item>>;
|
|
203
|
+
/**
|
|
204
|
+
* Gets a specific item by slug within a game context.
|
|
205
|
+
* Uses the resolution endpoint to find the item.
|
|
206
|
+
*
|
|
207
|
+
* @param gameId - The game ID context
|
|
208
|
+
* @param slug - The item slug to retrieve
|
|
209
|
+
* @returns Promise resolving to the item
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const item = await client.dev.items.get('game-123', 'MAGIC_SWORD')
|
|
214
|
+
* console.log('Item:', item.displayName)
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
get: (gameId: string, slug: string) => Promise<Item>;
|
|
218
|
+
/**
|
|
219
|
+
* Deletes a game-scoped item.
|
|
220
|
+
*
|
|
221
|
+
* @param gameId - The game ID
|
|
222
|
+
* @param itemId - The item ID to delete
|
|
223
|
+
* @returns Promise that resolves when item is deleted
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* await client.dev.items.delete('game-123', 'item-456')
|
|
228
|
+
* console.log('Item deleted successfully')
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
delete: (gameId: string, itemId: string) => Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Shop listing management for game items.
|
|
234
|
+
* Allows developers to control if and how their items are sold.
|
|
235
|
+
*/
|
|
236
|
+
shop: {
|
|
237
|
+
/**
|
|
238
|
+
* Creates a shop listing for a game item.
|
|
239
|
+
*
|
|
240
|
+
* @param gameId - The game ID
|
|
241
|
+
* @param itemId - The item ID to list for sale
|
|
242
|
+
* @param listingData - Shop listing properties (price, currency, etc.)
|
|
243
|
+
* @returns Promise resolving to the created shop listing
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const listing = await client.dev.items.shop.create('game-123', 'item-456', {
|
|
248
|
+
* currencyId: 'credits-currency-id',
|
|
249
|
+
* price: 100,
|
|
250
|
+
* sellBackPercentage: 50,
|
|
251
|
+
* isActive: true
|
|
252
|
+
* })
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
create: (gameId: string, itemId: string, listingData: Omit<InsertShopListingInput, "itemId">) => Promise<ShopListing>;
|
|
256
|
+
/**
|
|
257
|
+
* Gets the shop listing for a specific game item.
|
|
258
|
+
*
|
|
259
|
+
* @param gameId - The game ID
|
|
260
|
+
* @param itemId - The item ID
|
|
261
|
+
* @returns Promise resolving to the shop listing, or null if no listing exists
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const listing = await client.dev.items.shop.get('game-123', 'item-456')
|
|
266
|
+
* if (listing) {
|
|
267
|
+
* console.log(`Item is listed for ${listing.price} credits`)
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
get: (gameId: string, itemId: string) => Promise<ShopListing | null>;
|
|
272
|
+
/**
|
|
273
|
+
* Updates an existing shop listing for a game item.
|
|
274
|
+
*
|
|
275
|
+
* @param gameId - The game ID
|
|
276
|
+
* @param itemId - The item ID
|
|
277
|
+
* @param updates - Partial shop listing properties to update
|
|
278
|
+
* @returns Promise resolving to the updated shop listing
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const updated = await client.dev.items.shop.update('game-123', 'item-456', {
|
|
283
|
+
* price: 150,
|
|
284
|
+
* isActive: false
|
|
285
|
+
* })
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
update: (gameId: string, itemId: string, updates: UpdateShopListingInput) => Promise<ShopListing>;
|
|
289
|
+
/**
|
|
290
|
+
* Removes the shop listing for a game item.
|
|
291
|
+
*
|
|
292
|
+
* @param gameId - The game ID
|
|
293
|
+
* @param itemId - The item ID
|
|
294
|
+
* @returns Promise that resolves when listing is removed
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* await client.dev.items.shop.delete('game-123', 'item-456')
|
|
299
|
+
* console.log('Item removed from shop')
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
delete: (gameId: string, itemId: string) => Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Lists all shop listings for a game.
|
|
305
|
+
*
|
|
306
|
+
* @param gameId - The game ID
|
|
307
|
+
* @returns Promise resolving to array of shop listings for the game
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const listings = await client.dev.items.shop.list('game-123')
|
|
312
|
+
* listings.forEach(listing => {
|
|
313
|
+
* console.log(`${listing.item.displayName}: ${listing.price}`)
|
|
314
|
+
* })
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
list: (gameId: string) => Promise<Array<ShopListing & {
|
|
318
|
+
item: Item;
|
|
319
|
+
}>>;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
152
322
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { GameState, StartSessionResponse } from '../../types';
|
|
1
|
+
import type { Game, GameWithManifest } from '@playcademy/data/types';
|
|
2
|
+
import type { PlaycademyClient, StartSessionResponse } from '../../types';
|
|
4
3
|
/**
|
|
5
4
|
* Creates the games namespace for the PlaycademyClient.
|
|
6
5
|
* Provides methods for managing games, game state, and game sessions.
|
|
@@ -65,7 +64,12 @@ export declare function createGamesNamespace(client: PlaycademyClient): {
|
|
|
65
64
|
* console.log('Current level:', state.level)
|
|
66
65
|
* ```
|
|
67
66
|
*/
|
|
68
|
-
loadState: () => Promise<
|
|
67
|
+
loadState: () => Promise<{
|
|
68
|
+
data: unknown;
|
|
69
|
+
updatedAt: Date | null;
|
|
70
|
+
userId: string;
|
|
71
|
+
gameId: string;
|
|
72
|
+
}>;
|
|
69
73
|
/**
|
|
70
74
|
* Starts a new game session.
|
|
71
75
|
*
|