@playcademy/sdk 0.0.1-beta.24 → 0.0.1-beta.25

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.
@@ -106,8 +106,6 @@ export declare class PlaycademyClient {
106
106
  users: {
107
107
  me: () => Promise<{
108
108
  id: string;
109
- createdAt: Date;
110
- updatedAt: Date;
111
109
  name: string;
112
110
  username: string | null;
113
111
  email: string;
@@ -115,6 +113,8 @@ export declare class PlaycademyClient {
115
113
  image: string | null;
116
114
  role: "admin" | "player" | "developer";
117
115
  developerStatus: "none" | "pending" | "approved";
116
+ createdAt: Date;
117
+ updatedAt: Date;
118
118
  }>;
119
119
  inventory: {
120
120
  get: () => Promise<import("@playcademy/types").InventoryItemWithItem[]>;
@@ -136,14 +136,14 @@ export declare class PlaycademyClient {
136
136
  delete: (gameId: string) => Promise<void>;
137
137
  };
138
138
  keys: {
139
- createKey: (gameId: string, label?: string) => Promise<{
139
+ createKey: (label?: string) => Promise<{
140
140
  id: string;
141
141
  createdAt: Date;
142
142
  userId: string;
143
143
  label: string | null;
144
144
  keyHash: string;
145
145
  }>;
146
- listKeys: (gameId: string) => Promise<{
146
+ listKeys: () => Promise<{
147
147
  id: string;
148
148
  createdAt: Date;
149
149
  userId: string;
@@ -152,6 +152,22 @@ export declare class PlaycademyClient {
152
152
  }[]>;
153
153
  revokeKey: (keyId: string) => Promise<void>;
154
154
  };
155
+ items: {
156
+ create: (gameId: string, slug: string, itemData: Omit<import("@playcademy/types").InsertItem, "slug" | "gameId">) => Promise<import("@playcademy/types").Item>;
157
+ update: (gameId: string, itemId: string, updates: import("@playcademy/types").UpdateItem) => Promise<import("@playcademy/types").Item>;
158
+ list: (gameId: string) => Promise<Array<import("@playcademy/types").Item>>;
159
+ get: (gameId: string, slug: string) => Promise<import("@playcademy/types").Item>;
160
+ delete: (gameId: string, itemId: string) => Promise<void>;
161
+ shop: {
162
+ create: (gameId: string, itemId: string, listingData: Omit<import("@playcademy/types").InsertShopListing, "itemId">) => Promise<import("@playcademy/types").ShopListing>;
163
+ get: (gameId: string, itemId: string) => Promise<import("@playcademy/types").ShopListing | null>;
164
+ update: (gameId: string, itemId: string, updates: import("@playcademy/types").UpdateShopListing) => Promise<import("@playcademy/types").ShopListing>;
165
+ delete: (gameId: string, itemId: string) => Promise<void>;
166
+ list: (gameId: string) => Promise<Array<import("@playcademy/types").ShopListing & {
167
+ item: import("@playcademy/types").Item;
168
+ }>>;
169
+ };
170
+ };
155
171
  };
156
172
  /** Map methods (elements) */
157
173
  maps: {
@@ -178,42 +194,46 @@ export declare class PlaycademyClient {
178
194
  items: {
179
195
  create: (props: import("@playcademy/types").InsertItem) => Promise<{
180
196
  id: string;
197
+ createdAt: Date;
198
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
199
+ slug: string;
181
200
  displayName: string;
182
201
  metadata: unknown;
183
- createdAt: Date;
184
- internalName: string;
202
+ gameId: string | null;
185
203
  description: string | null;
186
- 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;
208
+ createdAt: Date;
209
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
210
+ slug: string;
191
211
  displayName: string;
192
212
  metadata: unknown;
193
- createdAt: Date;
194
- internalName: string;
213
+ gameId: string | null;
195
214
  description: string | null;
196
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
197
215
  imageUrl: string | null;
198
216
  }>;
199
217
  list: () => Promise<{
200
218
  id: string;
219
+ createdAt: Date;
220
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
221
+ slug: string;
201
222
  displayName: string;
202
223
  metadata: unknown;
203
- createdAt: Date;
204
- internalName: string;
224
+ gameId: string | null;
205
225
  description: string | null;
206
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
207
226
  imageUrl: string | null;
208
227
  }[]>;
209
228
  update: (itemId: string, props: import("@playcademy/types").UpdateItem) => Promise<{
210
229
  id: string;
230
+ createdAt: Date;
231
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
232
+ slug: string;
211
233
  displayName: string;
212
234
  metadata: unknown;
213
- createdAt: Date;
214
- internalName: string;
235
+ gameId: string | null;
215
236
  description: string | null;
216
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
217
237
  imageUrl: string | null;
218
238
  }>;
219
239
  delete: (itemId: string) => Promise<void>;
@@ -61,12 +61,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
61
61
  */
62
62
  create: (props: InsertItem) => Promise<{
63
63
  id: string;
64
+ createdAt: Date;
65
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
66
+ slug: string;
64
67
  displayName: string;
65
68
  metadata: unknown;
66
- createdAt: Date;
67
- internalName: string;
69
+ gameId: string | null;
68
70
  description: string | null;
69
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
70
71
  imageUrl: string | null;
71
72
  }>;
72
73
  /**
@@ -83,12 +84,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
83
84
  */
84
85
  get: (itemId: string) => Promise<{
85
86
  id: string;
87
+ createdAt: Date;
88
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
89
+ slug: string;
86
90
  displayName: string;
87
91
  metadata: unknown;
88
- createdAt: Date;
89
- internalName: string;
92
+ gameId: string | null;
90
93
  description: string | null;
91
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
92
94
  imageUrl: string | null;
93
95
  }>;
94
96
  /**
@@ -104,12 +106,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
104
106
  */
105
107
  list: () => Promise<{
106
108
  id: string;
109
+ createdAt: Date;
110
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
111
+ slug: string;
107
112
  displayName: string;
108
113
  metadata: unknown;
109
- createdAt: Date;
110
- internalName: string;
114
+ gameId: string | null;
111
115
  description: string | null;
112
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
113
116
  imageUrl: string | null;
114
117
  }[]>;
115
118
  /**
@@ -128,12 +131,13 @@ export declare function createAdminNamespace(client: PlaycademyClient): {
128
131
  */
129
132
  update: (itemId: string, props: UpdateItem) => Promise<{
130
133
  id: string;
134
+ createdAt: Date;
135
+ type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
136
+ slug: string;
131
137
  displayName: string;
132
138
  metadata: unknown;
133
- createdAt: Date;
134
- internalName: string;
139
+ gameId: string | null;
135
140
  description: string | null;
136
- type: "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
137
141
  imageUrl: string | null;
138
142
  }>;
139
143
  /**
@@ -1,12 +1,12 @@
1
1
  import type { PlaycademyClient } from '../client';
2
- import type { Game, UpsertGameMetadataInput } from '@playcademy/types';
2
+ import type { Game, UpsertGameMetadataInput, Item, InsertItem, UpdateItem, ShopListing, InsertShopListing, UpdateShopListing } from '@playcademy/types';
3
3
  import type { DeveloperStatusValue } from '../../types';
4
4
  /**
5
5
  * Creates the developer namespace for the PlaycademyClient.
6
- * Provides methods for developer account management, game publishing, and API key management.
6
+ * Provides methods for developer account management, game publishing, API key management, and item management.
7
7
  *
8
8
  * @param client - The PlaycademyClient instance
9
- * @returns Developer namespace with auth, games, and keys methods
9
+ * @returns Developer namespace with auth, games, keys, and items methods
10
10
  */
11
11
  export declare function createDevNamespace(client: PlaycademyClient): {
12
12
  /**
@@ -97,19 +97,18 @@ export declare function createDevNamespace(client: PlaycademyClient): {
97
97
  */
98
98
  keys: {
99
99
  /**
100
- * Creates a new API key for a game.
100
+ * Creates a new API key for the developer.
101
101
  *
102
- * @param gameId - The game ID to create a key for
103
102
  * @param label - Optional label for the key
104
103
  * @returns Promise resolving to the created API key
105
104
  *
106
105
  * @example
107
106
  * ```typescript
108
- * const key = await client.dev.keys.createKey('game-123', 'Production Key')
109
- * console.log('API Key:', key.key)
107
+ * const key = await client.dev.keys.createKey('Production Key')
108
+ * console.log('API Key:', key.apiKey)
110
109
  * ```
111
110
  */
112
- createKey: (gameId: string, label?: string) => Promise<{
111
+ createKey: (label?: string) => Promise<{
113
112
  id: string;
114
113
  createdAt: Date;
115
114
  userId: string;
@@ -117,18 +116,17 @@ export declare function createDevNamespace(client: PlaycademyClient): {
117
116
  keyHash: string;
118
117
  }>;
119
118
  /**
120
- * Lists all API keys for a game.
119
+ * Lists all API keys for the developer.
121
120
  *
122
- * @param gameId - The game ID to list keys for
123
121
  * @returns Promise resolving to array of API keys
124
122
  *
125
123
  * @example
126
124
  * ```typescript
127
- * const keys = await client.dev.keys.listKeys('game-123')
128
- * keys.forEach(key => console.log(`${key.label}: ${key.key}`))
125
+ * const keys = await client.dev.keys.listKeys()
126
+ * keys.forEach(key => console.log(`${key.label}: ${key.id}`))
129
127
  * ```
130
128
  */
131
- listKeys: (gameId: string) => Promise<{
129
+ listKeys: () => Promise<{
132
130
  id: string;
133
131
  createdAt: Date;
134
132
  userId: string;
@@ -149,4 +147,177 @@ export declare function createDevNamespace(client: PlaycademyClient): {
149
147
  */
150
148
  revokeKey: (keyId: string) => Promise<void>;
151
149
  };
150
+ /**
151
+ * Item management methods for developers.
152
+ * Allows developers to create and manage game-specific items.
153
+ */
154
+ items: {
155
+ /**
156
+ * Creates a new game-scoped item.
157
+ *
158
+ * @param gameId - The game ID to create the item for
159
+ * @param slug - The item slug (unique within the game)
160
+ * @param itemData - Item properties (displayName, description, type, etc.)
161
+ * @returns Promise resolving to the created item
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const item = await client.dev.items.create('game-123', 'MAGIC_SWORD', {
166
+ * displayName: 'Magic Sword',
167
+ * description: 'A powerful enchanted blade',
168
+ * type: 'unlock',
169
+ * metadata: { rarity: 'epic' }
170
+ * })
171
+ * ```
172
+ */
173
+ create: (gameId: string, slug: string, itemData: Omit<InsertItem, "slug" | "gameId">) => Promise<Item>;
174
+ /**
175
+ * Updates an existing game-scoped item.
176
+ *
177
+ * @param gameId - The game ID
178
+ * @param itemId - The item ID to update
179
+ * @param updates - Partial item properties to update
180
+ * @returns Promise resolving to the updated item
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const updated = await client.dev.items.update('game-123', 'item-456', {
185
+ * displayName: 'Super Magic Sword',
186
+ * metadata: { rarity: 'legendary' }
187
+ * })
188
+ * ```
189
+ */
190
+ update: (gameId: string, itemId: string, updates: UpdateItem) => Promise<Item>;
191
+ /**
192
+ * Lists all items for a specific game.
193
+ *
194
+ * @param gameId - The game ID to list items for
195
+ * @returns Promise resolving to array of game-scoped items
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const items = await client.dev.items.list('game-123')
200
+ * items.forEach(item => console.log(`${item.slug}: ${item.displayName}`))
201
+ * ```
202
+ */
203
+ list: (gameId: string) => Promise<Array<Item>>;
204
+ /**
205
+ * Gets a specific item by slug within a game context.
206
+ * Uses the resolution endpoint to find the item.
207
+ *
208
+ * @param gameId - The game ID context
209
+ * @param slug - The item slug to retrieve
210
+ * @returns Promise resolving to the item
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * const item = await client.dev.items.get('game-123', 'MAGIC_SWORD')
215
+ * console.log('Item:', item.displayName)
216
+ * ```
217
+ */
218
+ get: (gameId: string, slug: string) => Promise<Item>;
219
+ /**
220
+ * Deletes a game-scoped item.
221
+ *
222
+ * @param gameId - The game ID
223
+ * @param itemId - The item ID to delete
224
+ * @returns Promise that resolves when item is deleted
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * await client.dev.items.delete('game-123', 'item-456')
229
+ * console.log('Item deleted successfully')
230
+ * ```
231
+ */
232
+ delete: (gameId: string, itemId: string) => Promise<void>;
233
+ /**
234
+ * Shop listing management for game items.
235
+ * Allows developers to control if and how their items are sold.
236
+ */
237
+ shop: {
238
+ /**
239
+ * Creates a shop listing for a game item.
240
+ *
241
+ * @param gameId - The game ID
242
+ * @param itemId - The item ID to list for sale
243
+ * @param listingData - Shop listing properties (price, currency, etc.)
244
+ * @returns Promise resolving to the created shop listing
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const listing = await client.dev.items.shop.create('game-123', 'item-456', {
249
+ * currencyId: 'credits-currency-id',
250
+ * price: 100,
251
+ * sellBackPercentage: 50,
252
+ * isActive: true
253
+ * })
254
+ * ```
255
+ */
256
+ create: (gameId: string, itemId: string, listingData: Omit<InsertShopListing, "itemId">) => Promise<ShopListing>;
257
+ /**
258
+ * Gets the shop listing for a specific game item.
259
+ *
260
+ * @param gameId - The game ID
261
+ * @param itemId - The item ID
262
+ * @returns Promise resolving to the shop listing, or null if no listing exists
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * const listing = await client.dev.items.shop.get('game-123', 'item-456')
267
+ * if (listing) {
268
+ * console.log(`Item is listed for ${listing.price} credits`)
269
+ * }
270
+ * ```
271
+ */
272
+ get: (gameId: string, itemId: string) => Promise<ShopListing | null>;
273
+ /**
274
+ * Updates an existing shop listing for a game item.
275
+ *
276
+ * @param gameId - The game ID
277
+ * @param itemId - The item ID
278
+ * @param updates - Partial shop listing properties to update
279
+ * @returns Promise resolving to the updated shop listing
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const updated = await client.dev.items.shop.update('game-123', 'item-456', {
284
+ * price: 150,
285
+ * isActive: false
286
+ * })
287
+ * ```
288
+ */
289
+ update: (gameId: string, itemId: string, updates: UpdateShopListing) => Promise<ShopListing>;
290
+ /**
291
+ * Removes the shop listing for a game item.
292
+ *
293
+ * @param gameId - The game ID
294
+ * @param itemId - The item ID
295
+ * @returns Promise that resolves when listing is removed
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * await client.dev.items.shop.delete('game-123', 'item-456')
300
+ * console.log('Item removed from shop')
301
+ * ```
302
+ */
303
+ delete: (gameId: string, itemId: string) => Promise<void>;
304
+ /**
305
+ * Lists all shop listings for a game.
306
+ *
307
+ * @param gameId - The game ID
308
+ * @returns Promise resolving to array of shop listings for the game
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * const listings = await client.dev.items.shop.list('game-123')
313
+ * listings.forEach(listing => {
314
+ * console.log(`${listing.item.displayName}: ${listing.price}`)
315
+ * })
316
+ * ```
317
+ */
318
+ list: (gameId: string) => Promise<Array<ShopListing & {
319
+ item: Item;
320
+ }>>;
321
+ };
322
+ };
152
323
  };
@@ -22,8 +22,6 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
22
22
  */
23
23
  me: () => Promise<{
24
24
  id: string;
25
- createdAt: Date;
26
- updatedAt: Date;
27
25
  name: string;
28
26
  username: string | null;
29
27
  email: string;
@@ -31,6 +29,8 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
31
29
  image: string | null;
32
30
  role: "admin" | "player" | "developer";
33
31
  developerStatus: "none" | "pending" | "approved";
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
34
  }>;
35
35
  /**
36
36
  * Inventory management methods for the current user.
@@ -52,17 +52,17 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
52
52
  get: () => Promise<InventoryItemWithItem[]>;
53
53
  /**
54
54
  * Adds items to the user's inventory.
55
- * Accepts either an item UUID or internal name.
55
+ * Accepts either an item UUID or slug.
56
56
  * Emits an 'inventoryChange' event when successful.
57
57
  *
58
- * @param identifier - The item UUID or internal name
58
+ * @param identifier - The item UUID or slug
59
59
  * @param qty - The quantity to add (must be positive)
60
60
  * @returns Promise resolving to mutation response with new total
61
61
  *
62
62
  * @example
63
63
  * ```typescript
64
- * // Using internal name
65
- * const result = await client.users.inventory.add('GOLD_COIN', 100)
64
+ * // Using slug
65
+ * const result = await client.users.inventory.add('gold-coin', 100)
66
66
  *
67
67
  * // Using UUID
68
68
  * const result = await client.users.inventory.add('550e8400-e29b-41d4-a716-446655440000', 100)
@@ -73,16 +73,16 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
73
73
  add: (identifier: string, qty: number) => Promise<InventoryMutationResponse>;
74
74
  /**
75
75
  * Removes items from the user's inventory.
76
- * Accepts either an item UUID or internal name.
76
+ * Accepts either an item UUID or slug.
77
77
  * Emits an 'inventoryChange' event when successful.
78
78
  *
79
- * @param identifier - The item UUID or internal name
79
+ * @param identifier - The item UUID or slug
80
80
  * @param qty - The quantity to remove (must be positive)
81
81
  * @returns Promise resolving to mutation response with new total
82
82
  *
83
83
  * @example
84
84
  * ```typescript
85
- * // Using internal name
85
+ * // Using slug
86
86
  * const result = await client.users.inventory.remove('HEALTH_POTION', 1)
87
87
  *
88
88
  * // Using UUID
@@ -94,14 +94,14 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
94
94
  remove: (identifier: string, qty: number) => Promise<InventoryMutationResponse>;
95
95
  /**
96
96
  * Gets the current quantity of an item.
97
- * Accepts either an item UUID or internal name.
97
+ * Accepts either an item UUID or slug.
98
98
  *
99
- * @param identifier - The item UUID or internal name
99
+ * @param identifier - The item UUID or slug
100
100
  * @returns Promise resolving to the current quantity (0 if not owned)
101
101
  *
102
102
  * @example
103
103
  * ```typescript
104
- * const qty = await client.users.inventory.quantity('HEALTH_POTION')
104
+ * const qty = await client.users.inventory.quantity('health-potion')
105
105
  * const qty2 = await client.users.inventory.quantity('uuid-123-456')
106
106
  * console.log('Health potions:', qty)
107
107
  * ```
@@ -109,16 +109,16 @@ export declare function createUsersNamespace(client: PlaycademyClient): {
109
109
  quantity: (identifier: string) => Promise<number>;
110
110
  /**
111
111
  * Checks if the user has at least the specified quantity of an item.
112
- * Accepts either an item UUID or internal name.
112
+ * Accepts either an item UUID or slug.
113
113
  *
114
- * @param identifier - The item UUID or internal name
114
+ * @param identifier - The item UUID or slug
115
115
  * @param minQuantity - Minimum quantity required (defaults to 1)
116
116
  * @returns Promise resolving to true if user has enough of the item
117
117
  *
118
118
  * @example
119
119
  * ```typescript
120
- * const hasKey = await client.users.inventory.has('DUNGEON_KEY')
121
- * const hasEnoughGold = await client.users.inventory.has('GOLD_COIN', 100)
120
+ * const hasKey = await client.users.inventory.has('gold-coin')
121
+ * const hasEnoughGold = await client.users.inventory.has('gold-coin', 100)
122
122
  * const hasPotion = await client.users.inventory.has('uuid-123-456', 5)
123
123
  *
124
124
  * if (hasKey && hasEnoughGold) {