@playcademy/sdk 0.0.1-beta.16 → 0.0.1-beta.17
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 -0
- package/dist/core/client.d.ts +112 -35
- package/dist/core/namespaces/admin.d.ts +377 -0
- package/dist/core/namespaces/auth.d.ts +23 -0
- package/dist/core/namespaces/dev.d.ts +152 -0
- package/dist/core/namespaces/games.d.ts +97 -0
- package/dist/core/namespaces/index.d.ts +9 -0
- package/dist/core/namespaces/maps.d.ts +37 -0
- package/dist/core/namespaces/runtime.d.ts +45 -0
- package/dist/core/namespaces/shop.d.ts +26 -0
- package/dist/core/namespaces/telemetry.d.ts +28 -0
- package/dist/core/namespaces/users.d.ts +84 -0
- package/dist/core/static/index.d.ts +2 -0
- package/dist/core/static/init.d.ts +21 -0
- package/dist/core/static/login.d.ts +24 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +550 -0
- package/dist/types.d.ts +8 -2
- package/package.json +8 -7
- package/dist/runtime.d.ts +0 -7
- package/dist/runtime.js +0 -396
package/README.md
CHANGED
|
@@ -158,6 +158,10 @@ All methods returning data are strongly typed.
|
|
|
158
158
|
- **`dev.keys`**: Create, list, revoke API keys for games.
|
|
159
159
|
- **`admin.games`**: Pause/resume games.
|
|
160
160
|
- **`admin.items`**: CRUD operations for items.
|
|
161
|
+
- **`admin.currencies`**: CRUD operations for currencies.
|
|
162
|
+
- **`admin.shopListings`**: CRUD operations for shop listings.
|
|
163
|
+
- **`shop`**: Player-facing shop operations.
|
|
164
|
+
- `view()`: Get shop items and currency information.
|
|
161
165
|
- **`telemetry`**: Push metrics.
|
|
162
166
|
|
|
163
167
|
## Contributing
|
package/dist/core/client.d.ts
CHANGED
|
@@ -1,38 +1,108 @@
|
|
|
1
1
|
import { type Method } from './request';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
2
|
+
import { init, login } from './static';
|
|
3
|
+
import type { ClientConfig, ClientEvents } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Main Playcademy SDK client for interacting with the platform API.
|
|
6
|
+
* Provides namespaced access to all platform features including games, users, inventory, and more.
|
|
7
|
+
*/
|
|
4
8
|
export declare class PlaycademyClient {
|
|
5
9
|
private baseUrl;
|
|
6
10
|
private token?;
|
|
7
11
|
private gameId?;
|
|
8
12
|
private listeners;
|
|
9
13
|
private internalClientSessionId?;
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new PlaycademyClient instance.
|
|
16
|
+
*
|
|
17
|
+
* @param config - Optional configuration object
|
|
18
|
+
* @param config.baseUrl - Base URL for API requests (defaults to '/api')
|
|
19
|
+
* @param config.token - Authentication token
|
|
20
|
+
* @param config.gameId - Game ID for automatic session management
|
|
21
|
+
*/
|
|
22
|
+
constructor(config?: Partial<ClientConfig>);
|
|
23
|
+
/**
|
|
24
|
+
* Gets the effective base URL for API requests.
|
|
25
|
+
* Converts relative URLs to absolute URLs in browser environments.
|
|
26
|
+
*
|
|
27
|
+
* @returns The complete base URL for API requests
|
|
28
|
+
*/
|
|
12
29
|
getBaseUrl(): string;
|
|
13
|
-
|
|
14
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Simple ping method for testing connectivity.
|
|
32
|
+
*
|
|
33
|
+
* @returns 'pong' string response
|
|
34
|
+
*/
|
|
35
|
+
ping(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the authentication token for API requests.
|
|
38
|
+
* Emits an 'authChange' event when the token changes.
|
|
39
|
+
*
|
|
40
|
+
* @param token - The authentication token, or null to clear
|
|
41
|
+
*/
|
|
15
42
|
setToken(token: string | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Registers a callback to be called when authentication state changes.
|
|
45
|
+
*
|
|
46
|
+
* @param callback - Function to call when auth state changes
|
|
47
|
+
*/
|
|
16
48
|
onAuthChange(callback: (token: string | null) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* Registers an event listener for client events.
|
|
51
|
+
*
|
|
52
|
+
* @param event - The event type to listen for
|
|
53
|
+
* @param callback - Function to call when the event is emitted
|
|
54
|
+
*/
|
|
55
|
+
on<E extends keyof ClientEvents>(event: E, callback: (payload: ClientEvents[E]) => void): void;
|
|
56
|
+
/**
|
|
57
|
+
* Emits an event to all registered listeners.
|
|
58
|
+
*
|
|
59
|
+
* @param event - The event type to emit
|
|
60
|
+
* @param payload - The event payload
|
|
61
|
+
*/
|
|
62
|
+
private emit;
|
|
63
|
+
/**
|
|
64
|
+
* Makes an authenticated HTTP request to the API.
|
|
65
|
+
*
|
|
66
|
+
* @param path - API endpoint path
|
|
67
|
+
* @param method - HTTP method
|
|
68
|
+
* @param body - Request body (optional)
|
|
69
|
+
* @param headers - Additional headers (optional)
|
|
70
|
+
* @returns Promise resolving to the response data
|
|
71
|
+
*/
|
|
17
72
|
protected request<T>(path: string, method: Method, body?: unknown, headers?: Record<string, string>): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Ensures a gameId is available, throwing an error if not.
|
|
75
|
+
*
|
|
76
|
+
* @returns The gameId
|
|
77
|
+
* @throws PlaycademyError if no gameId is configured
|
|
78
|
+
*/
|
|
18
79
|
private _ensureGameId;
|
|
80
|
+
/**
|
|
81
|
+
* Initializes an internal game session for automatic session management.
|
|
82
|
+
* Called automatically when a gameId is provided in the constructor.
|
|
83
|
+
*/
|
|
84
|
+
private _initializeInternalSession;
|
|
85
|
+
/** Authentication methods (logout) */
|
|
19
86
|
auth: {
|
|
20
87
|
logout: () => Promise<void>;
|
|
21
88
|
};
|
|
89
|
+
/** Runtime methods (getGameToken, exit) */
|
|
22
90
|
runtime: {
|
|
23
91
|
getGameToken: (gameId: string, options?: {
|
|
24
92
|
apply?: boolean;
|
|
25
|
-
}) => Promise<GameTokenResponse>;
|
|
93
|
+
}) => Promise<import("..").GameTokenResponse>;
|
|
26
94
|
exit: () => Promise<void>;
|
|
27
95
|
};
|
|
96
|
+
/** Game management methods (fetch, list, saveState, loadState, sessions) */
|
|
28
97
|
games: {
|
|
29
|
-
fetch: (gameIdOrSlug: string) => Promise<GameWithManifest>;
|
|
30
|
-
list: () => Promise<Array<Game>>;
|
|
98
|
+
fetch: (gameIdOrSlug: string) => Promise<import("@playcademy/types").GameWithManifest>;
|
|
99
|
+
list: () => Promise<Array<import("@playcademy/types").Game>>;
|
|
31
100
|
saveState: (state: Record<string, unknown>) => Promise<void>;
|
|
32
|
-
loadState: () => Promise<GameState>;
|
|
33
|
-
startSession: (gameId?: string) => Promise<StartSessionResponse>;
|
|
101
|
+
loadState: () => Promise<import("..").GameState>;
|
|
102
|
+
startSession: (gameId?: string) => Promise<import("..").StartSessionResponse>;
|
|
34
103
|
endSession: (sessionId: string, gameId?: string) => Promise<void>;
|
|
35
104
|
};
|
|
105
|
+
/** User methods (me, inventory management) */
|
|
36
106
|
users: {
|
|
37
107
|
me: () => Promise<{
|
|
38
108
|
id: string;
|
|
@@ -47,19 +117,20 @@ export declare class PlaycademyClient {
|
|
|
47
117
|
developerStatus: "none" | "pending" | "approved";
|
|
48
118
|
}>;
|
|
49
119
|
inventory: {
|
|
50
|
-
get: () => Promise<InventoryItemWithItem[]>;
|
|
51
|
-
add: (itemId: string, qty: number) => Promise<InventoryMutationResponse>;
|
|
52
|
-
spend: (itemId: string, qty: number) => Promise<InventoryMutationResponse>;
|
|
120
|
+
get: () => Promise<import("@playcademy/types").InventoryItemWithItem[]>;
|
|
121
|
+
add: (itemId: string, qty: number) => Promise<import("..").InventoryMutationResponse>;
|
|
122
|
+
spend: (itemId: string, qty: number) => Promise<import("..").InventoryMutationResponse>;
|
|
53
123
|
};
|
|
54
124
|
};
|
|
125
|
+
/** Developer tools (auth, games, keys management) */
|
|
55
126
|
dev: {
|
|
56
127
|
auth: {
|
|
57
128
|
applyForDeveloper: () => Promise<void>;
|
|
58
|
-
getDeveloperStatus: () => Promise<DeveloperStatusValue>;
|
|
129
|
+
getDeveloperStatus: () => Promise<import("..").DeveloperStatusValue>;
|
|
59
130
|
};
|
|
60
131
|
games: {
|
|
61
|
-
upsert: (slug: string, metadata: UpsertGameMetadataInput, file: File | Blob) => Promise<Game>;
|
|
62
|
-
update: (gameId: string, props: Partial<Game>) => Promise<void>;
|
|
132
|
+
upsert: (slug: string, metadata: import("@playcademy/types").UpsertGameMetadataInput, file: File | Blob) => Promise<import("@playcademy/types").Game>;
|
|
133
|
+
update: (gameId: string, props: Partial<import("@playcademy/types").Game>) => Promise<void>;
|
|
63
134
|
delete: (gameId: string) => Promise<void>;
|
|
64
135
|
};
|
|
65
136
|
keys: {
|
|
@@ -80,6 +151,7 @@ export declare class PlaycademyClient {
|
|
|
80
151
|
revokeKey: (keyId: string) => Promise<void>;
|
|
81
152
|
};
|
|
82
153
|
};
|
|
154
|
+
/** Map methods (elements) */
|
|
83
155
|
maps: {
|
|
84
156
|
elements: (mapId: string) => Promise<{
|
|
85
157
|
id: string;
|
|
@@ -95,13 +167,14 @@ export declare class PlaycademyClient {
|
|
|
95
167
|
interactionType: "game_entry" | "game_registry" | "info" | "teleport" | "door_in" | "door_out" | "npc_interaction" | "quest_trigger";
|
|
96
168
|
}[]>;
|
|
97
169
|
};
|
|
170
|
+
/** Admin methods (games, items, currencies, shop listings) */
|
|
98
171
|
admin: {
|
|
99
172
|
games: {
|
|
100
173
|
pauseGame: (gameId: string) => Promise<void>;
|
|
101
174
|
resumeGame: (gameId: string) => Promise<void>;
|
|
102
175
|
};
|
|
103
176
|
items: {
|
|
104
|
-
|
|
177
|
+
create: (props: import("@playcademy/types").InsertItem) => Promise<{
|
|
105
178
|
id: string;
|
|
106
179
|
displayName: string;
|
|
107
180
|
metadata: unknown;
|
|
@@ -111,7 +184,7 @@ export declare class PlaycademyClient {
|
|
|
111
184
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
112
185
|
imageUrl: string | null;
|
|
113
186
|
}>;
|
|
114
|
-
|
|
187
|
+
get: (itemId: string) => Promise<{
|
|
115
188
|
id: string;
|
|
116
189
|
displayName: string;
|
|
117
190
|
metadata: unknown;
|
|
@@ -121,7 +194,7 @@ export declare class PlaycademyClient {
|
|
|
121
194
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
122
195
|
imageUrl: string | null;
|
|
123
196
|
}>;
|
|
124
|
-
|
|
197
|
+
list: () => Promise<{
|
|
125
198
|
id: string;
|
|
126
199
|
displayName: string;
|
|
127
200
|
metadata: unknown;
|
|
@@ -131,7 +204,7 @@ export declare class PlaycademyClient {
|
|
|
131
204
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
132
205
|
imageUrl: string | null;
|
|
133
206
|
}[]>;
|
|
134
|
-
|
|
207
|
+
update: (itemId: string, props: import("@playcademy/types").UpdateItem) => Promise<{
|
|
135
208
|
id: string;
|
|
136
209
|
displayName: string;
|
|
137
210
|
metadata: unknown;
|
|
@@ -141,10 +214,10 @@ export declare class PlaycademyClient {
|
|
|
141
214
|
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
142
215
|
imageUrl: string | null;
|
|
143
216
|
}>;
|
|
144
|
-
|
|
217
|
+
delete: (itemId: string) => Promise<void>;
|
|
145
218
|
};
|
|
146
219
|
currencies: {
|
|
147
|
-
|
|
220
|
+
create: (props: import("@playcademy/types").InsertCurrency) => Promise<{
|
|
148
221
|
symbol: string | null;
|
|
149
222
|
id: string;
|
|
150
223
|
createdAt: Date;
|
|
@@ -152,7 +225,7 @@ export declare class PlaycademyClient {
|
|
|
152
225
|
itemId: string;
|
|
153
226
|
isPrimary: boolean;
|
|
154
227
|
}>;
|
|
155
|
-
|
|
228
|
+
get: (currencyId: string) => Promise<{
|
|
156
229
|
symbol: string | null;
|
|
157
230
|
id: string;
|
|
158
231
|
createdAt: Date;
|
|
@@ -160,7 +233,7 @@ export declare class PlaycademyClient {
|
|
|
160
233
|
itemId: string;
|
|
161
234
|
isPrimary: boolean;
|
|
162
235
|
}>;
|
|
163
|
-
|
|
236
|
+
list: () => Promise<{
|
|
164
237
|
symbol: string | null;
|
|
165
238
|
id: string;
|
|
166
239
|
createdAt: Date;
|
|
@@ -168,7 +241,7 @@ export declare class PlaycademyClient {
|
|
|
168
241
|
itemId: string;
|
|
169
242
|
isPrimary: boolean;
|
|
170
243
|
}[]>;
|
|
171
|
-
|
|
244
|
+
update: (currencyId: string, props: import("@playcademy/types").UpdateCurrency) => Promise<{
|
|
172
245
|
symbol: string | null;
|
|
173
246
|
id: string;
|
|
174
247
|
createdAt: Date;
|
|
@@ -176,10 +249,10 @@ export declare class PlaycademyClient {
|
|
|
176
249
|
itemId: string;
|
|
177
250
|
isPrimary: boolean;
|
|
178
251
|
}>;
|
|
179
|
-
|
|
252
|
+
delete: (currencyId: string) => Promise<void>;
|
|
180
253
|
};
|
|
181
254
|
shopListings: {
|
|
182
|
-
|
|
255
|
+
create: (props: import("@playcademy/types").InsertShopListing) => Promise<{
|
|
183
256
|
id: string;
|
|
184
257
|
createdAt: Date;
|
|
185
258
|
updatedAt: Date | null;
|
|
@@ -192,7 +265,7 @@ export declare class PlaycademyClient {
|
|
|
192
265
|
availableFrom: Date | null;
|
|
193
266
|
availableUntil: Date | null;
|
|
194
267
|
}>;
|
|
195
|
-
|
|
268
|
+
get: (listingId: string) => Promise<{
|
|
196
269
|
id: string;
|
|
197
270
|
createdAt: Date;
|
|
198
271
|
updatedAt: Date | null;
|
|
@@ -205,7 +278,7 @@ export declare class PlaycademyClient {
|
|
|
205
278
|
availableFrom: Date | null;
|
|
206
279
|
availableUntil: Date | null;
|
|
207
280
|
}>;
|
|
208
|
-
|
|
281
|
+
list: () => Promise<{
|
|
209
282
|
id: string;
|
|
210
283
|
createdAt: Date;
|
|
211
284
|
updatedAt: Date | null;
|
|
@@ -218,7 +291,7 @@ export declare class PlaycademyClient {
|
|
|
218
291
|
availableFrom: Date | null;
|
|
219
292
|
availableUntil: Date | null;
|
|
220
293
|
}[]>;
|
|
221
|
-
|
|
294
|
+
update: (listingId: string, props: import("@playcademy/types").UpdateShopListing) => Promise<{
|
|
222
295
|
id: string;
|
|
223
296
|
createdAt: Date;
|
|
224
297
|
updatedAt: Date | null;
|
|
@@ -231,15 +304,19 @@ export declare class PlaycademyClient {
|
|
|
231
304
|
availableFrom: Date | null;
|
|
232
305
|
availableUntil: Date | null;
|
|
233
306
|
}>;
|
|
234
|
-
|
|
307
|
+
delete: (listingId: string) => Promise<void>;
|
|
235
308
|
};
|
|
236
309
|
};
|
|
310
|
+
/** Shop methods (view) */
|
|
237
311
|
shop: {
|
|
238
|
-
view: () => Promise<ShopViewResponse>;
|
|
312
|
+
view: () => Promise<import("..").ShopViewResponse>;
|
|
239
313
|
};
|
|
314
|
+
/** Telemetry methods (pushMetrics) */
|
|
240
315
|
telemetry: {
|
|
241
316
|
pushMetrics: (metrics: Record<string, number>) => Promise<void>;
|
|
242
317
|
};
|
|
243
|
-
|
|
244
|
-
static
|
|
318
|
+
/** Auto-initializes a PlaycademyClient with context from the environment */
|
|
319
|
+
static init: typeof init;
|
|
320
|
+
/** Authenticates a user with email and password */
|
|
321
|
+
static login: typeof login;
|
|
245
322
|
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import type { PlaycademyClient } from '../client';
|
|
2
|
+
import type { InsertItem, UpdateItem, InsertCurrency, UpdateCurrency, InsertShopListing, UpdateShopListing } 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: InsertItem) => Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
displayName: string;
|
|
65
|
+
metadata: unknown;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
internalName: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
70
|
+
imageUrl: string | null;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves a specific item by ID.
|
|
74
|
+
*
|
|
75
|
+
* @param itemId - The ID of the item to retrieve
|
|
76
|
+
* @returns Promise resolving to the item data
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const item = await client.admin.items.get('item-123')
|
|
81
|
+
* console.log('Item name:', item.name)
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
get: (itemId: string) => Promise<{
|
|
85
|
+
id: string;
|
|
86
|
+
displayName: string;
|
|
87
|
+
metadata: unknown;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
internalName: string;
|
|
90
|
+
description: string | null;
|
|
91
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
92
|
+
imageUrl: string | null;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Lists all items in the system.
|
|
96
|
+
*
|
|
97
|
+
* @returns Promise resolving to array of all items
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const items = await client.admin.items.list()
|
|
102
|
+
* console.log(`Found ${items.length} items`)
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
list: () => Promise<{
|
|
106
|
+
id: string;
|
|
107
|
+
displayName: string;
|
|
108
|
+
metadata: unknown;
|
|
109
|
+
createdAt: Date;
|
|
110
|
+
internalName: string;
|
|
111
|
+
description: string | null;
|
|
112
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
113
|
+
imageUrl: string | null;
|
|
114
|
+
}[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Updates an existing item.
|
|
117
|
+
*
|
|
118
|
+
* @param itemId - The ID of the item to update
|
|
119
|
+
* @param props - Properties to update
|
|
120
|
+
* @returns Promise resolving to the updated item
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const updatedItem = await client.admin.items.update('item-123', {
|
|
125
|
+
* name: 'Enhanced Magic Sword'
|
|
126
|
+
* })
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
update: (itemId: string, props: UpdateItem) => Promise<{
|
|
130
|
+
id: string;
|
|
131
|
+
displayName: string;
|
|
132
|
+
metadata: unknown;
|
|
133
|
+
createdAt: Date;
|
|
134
|
+
internalName: string;
|
|
135
|
+
description: string | null;
|
|
136
|
+
type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
|
|
137
|
+
imageUrl: string | null;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Deletes an item from the system.
|
|
141
|
+
*
|
|
142
|
+
* @param itemId - The ID of the item to delete
|
|
143
|
+
* @returns Promise that resolves when item is deleted
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* await client.admin.items.delete('item-123')
|
|
148
|
+
* console.log('Item deleted')
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
delete: (itemId: string) => Promise<void>;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Currency management methods for administrators.
|
|
155
|
+
*/
|
|
156
|
+
currencies: {
|
|
157
|
+
/**
|
|
158
|
+
* Creates a new currency in the system.
|
|
159
|
+
*
|
|
160
|
+
* @param props - Currency properties for creation
|
|
161
|
+
* @returns Promise resolving to the created currency
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const currency = await client.admin.currencies.create({
|
|
166
|
+
* name: 'Gold Coins',
|
|
167
|
+
* symbol: 'GC',
|
|
168
|
+
* decimals: 0
|
|
169
|
+
* })
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
create: (props: InsertCurrency) => Promise<{
|
|
173
|
+
symbol: string | null;
|
|
174
|
+
id: string;
|
|
175
|
+
createdAt: Date;
|
|
176
|
+
updatedAt: Date | null;
|
|
177
|
+
itemId: string;
|
|
178
|
+
isPrimary: boolean;
|
|
179
|
+
}>;
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves a specific currency by ID.
|
|
182
|
+
*
|
|
183
|
+
* @param currencyId - The ID of the currency to retrieve
|
|
184
|
+
* @returns Promise resolving to the currency data
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const currency = await client.admin.currencies.get('currency-123')
|
|
189
|
+
* console.log('Currency symbol:', currency.symbol)
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
get: (currencyId: string) => Promise<{
|
|
193
|
+
symbol: string | null;
|
|
194
|
+
id: string;
|
|
195
|
+
createdAt: Date;
|
|
196
|
+
updatedAt: Date | null;
|
|
197
|
+
itemId: string;
|
|
198
|
+
isPrimary: boolean;
|
|
199
|
+
}>;
|
|
200
|
+
/**
|
|
201
|
+
* Lists all currencies in the system.
|
|
202
|
+
*
|
|
203
|
+
* @returns Promise resolving to array of all currencies
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const currencies = await client.admin.currencies.list()
|
|
208
|
+
* currencies.forEach(c => console.log(`${c.name}: ${c.symbol}`))
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
list: () => Promise<{
|
|
212
|
+
symbol: string | null;
|
|
213
|
+
id: string;
|
|
214
|
+
createdAt: Date;
|
|
215
|
+
updatedAt: Date | null;
|
|
216
|
+
itemId: string;
|
|
217
|
+
isPrimary: boolean;
|
|
218
|
+
}[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Updates an existing currency.
|
|
221
|
+
*
|
|
222
|
+
* @param currencyId - The ID of the currency to update
|
|
223
|
+
* @param props - Properties to update
|
|
224
|
+
* @returns Promise resolving to the updated currency
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const updatedCurrency = await client.admin.currencies.update('currency-123', {
|
|
229
|
+
* name: 'Premium Gold Coins'
|
|
230
|
+
* })
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
update: (currencyId: string, props: UpdateCurrency) => Promise<{
|
|
234
|
+
symbol: string | null;
|
|
235
|
+
id: string;
|
|
236
|
+
createdAt: Date;
|
|
237
|
+
updatedAt: Date | null;
|
|
238
|
+
itemId: string;
|
|
239
|
+
isPrimary: boolean;
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* Deletes a currency from the system.
|
|
243
|
+
*
|
|
244
|
+
* @param currencyId - The ID of the currency to delete
|
|
245
|
+
* @returns Promise that resolves when currency is deleted
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* await client.admin.currencies.delete('currency-123')
|
|
250
|
+
* console.log('Currency deleted')
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
delete: (currencyId: string) => Promise<void>;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Shop listing management methods for administrators.
|
|
257
|
+
*/
|
|
258
|
+
shopListings: {
|
|
259
|
+
/**
|
|
260
|
+
* Creates a new shop listing.
|
|
261
|
+
*
|
|
262
|
+
* @param props - Shop listing properties for creation
|
|
263
|
+
* @returns Promise resolving to the created shop listing
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const listing = await client.admin.shopListings.create({
|
|
268
|
+
* itemId: 'item-123',
|
|
269
|
+
* price: 100,
|
|
270
|
+
* currencyId: 'currency-456'
|
|
271
|
+
* })
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
create: (props: InsertShopListing) => Promise<{
|
|
275
|
+
id: string;
|
|
276
|
+
createdAt: Date;
|
|
277
|
+
updatedAt: Date | null;
|
|
278
|
+
itemId: string;
|
|
279
|
+
currencyId: string;
|
|
280
|
+
price: number;
|
|
281
|
+
sellBackPercentage: number | null;
|
|
282
|
+
stock: number | null;
|
|
283
|
+
isActive: boolean;
|
|
284
|
+
availableFrom: Date | null;
|
|
285
|
+
availableUntil: Date | null;
|
|
286
|
+
}>;
|
|
287
|
+
/**
|
|
288
|
+
* Retrieves a specific shop listing by ID.
|
|
289
|
+
*
|
|
290
|
+
* @param listingId - The ID of the shop listing to retrieve
|
|
291
|
+
* @returns Promise resolving to the shop listing data
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const listing = await client.admin.shopListings.get('listing-123')
|
|
296
|
+
* console.log('Listing price:', listing.price)
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
get: (listingId: string) => Promise<{
|
|
300
|
+
id: string;
|
|
301
|
+
createdAt: Date;
|
|
302
|
+
updatedAt: Date | null;
|
|
303
|
+
itemId: string;
|
|
304
|
+
currencyId: string;
|
|
305
|
+
price: number;
|
|
306
|
+
sellBackPercentage: number | null;
|
|
307
|
+
stock: number | null;
|
|
308
|
+
isActive: boolean;
|
|
309
|
+
availableFrom: Date | null;
|
|
310
|
+
availableUntil: Date | null;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* Lists all shop listings in the system.
|
|
314
|
+
*
|
|
315
|
+
* @returns Promise resolving to array of all shop listings
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const listings = await client.admin.shopListings.list()
|
|
320
|
+
* console.log(`Found ${listings.length} shop listings`)
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
list: () => Promise<{
|
|
324
|
+
id: string;
|
|
325
|
+
createdAt: Date;
|
|
326
|
+
updatedAt: Date | null;
|
|
327
|
+
itemId: string;
|
|
328
|
+
currencyId: string;
|
|
329
|
+
price: number;
|
|
330
|
+
sellBackPercentage: number | null;
|
|
331
|
+
stock: number | null;
|
|
332
|
+
isActive: boolean;
|
|
333
|
+
availableFrom: Date | null;
|
|
334
|
+
availableUntil: Date | null;
|
|
335
|
+
}[]>;
|
|
336
|
+
/**
|
|
337
|
+
* Updates an existing shop listing.
|
|
338
|
+
*
|
|
339
|
+
* @param listingId - The ID of the shop listing to update
|
|
340
|
+
* @param props - Properties to update
|
|
341
|
+
* @returns Promise resolving to the updated shop listing
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const updatedListing = await client.admin.shopListings.update('listing-123', {
|
|
346
|
+
* price: 150
|
|
347
|
+
* })
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
update: (listingId: string, props: UpdateShopListing) => Promise<{
|
|
351
|
+
id: string;
|
|
352
|
+
createdAt: Date;
|
|
353
|
+
updatedAt: Date | null;
|
|
354
|
+
itemId: string;
|
|
355
|
+
currencyId: string;
|
|
356
|
+
price: number;
|
|
357
|
+
sellBackPercentage: number | null;
|
|
358
|
+
stock: number | null;
|
|
359
|
+
isActive: boolean;
|
|
360
|
+
availableFrom: Date | null;
|
|
361
|
+
availableUntil: Date | null;
|
|
362
|
+
}>;
|
|
363
|
+
/**
|
|
364
|
+
* Deletes a shop listing from the system.
|
|
365
|
+
*
|
|
366
|
+
* @param listingId - The ID of the shop listing to delete
|
|
367
|
+
* @returns Promise that resolves when shop listing is deleted
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* await client.admin.shopListings.delete('listing-123')
|
|
372
|
+
* console.log('Shop listing deleted')
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
delete: (listingId: string) => Promise<void>;
|
|
376
|
+
};
|
|
377
|
+
};
|