@playcademy/sdk 0.1.10 → 0.1.11
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 +28 -5
- package/dist/index.js +117 -50
- package/dist/types.d.ts +29 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3412,6 +3412,15 @@ interface BetterAuthApiKey {
|
|
|
3412
3412
|
lastRequest: string | null;
|
|
3413
3413
|
requestCount: number;
|
|
3414
3414
|
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Bucket file metadata
|
|
3417
|
+
*/
|
|
3418
|
+
interface BucketFile {
|
|
3419
|
+
key: string;
|
|
3420
|
+
size: number;
|
|
3421
|
+
uploaded: string;
|
|
3422
|
+
contentType?: string;
|
|
3423
|
+
}
|
|
3415
3424
|
|
|
3416
3425
|
/**
|
|
3417
3426
|
* OAuth 2.0 implementation for the Playcademy SDK
|
|
@@ -3706,11 +3715,17 @@ declare class PlaycademyClient {
|
|
|
3706
3715
|
*
|
|
3707
3716
|
* @param path - API endpoint path
|
|
3708
3717
|
* @param method - HTTP method
|
|
3709
|
-
* @param
|
|
3710
|
-
* @param
|
|
3711
|
-
* @
|
|
3718
|
+
* @param options - Optional request configuration
|
|
3719
|
+
* @param options.body - Request body
|
|
3720
|
+
* @param options.headers - Additional headers
|
|
3721
|
+
* @param options.raw - If true, returns raw Response instead of parsing
|
|
3722
|
+
* @returns Promise resolving to the response data or raw Response
|
|
3712
3723
|
*/
|
|
3713
|
-
protected request<T>(path: string, method: Method,
|
|
3724
|
+
protected request<T>(path: string, method: Method, options?: {
|
|
3725
|
+
body?: unknown;
|
|
3726
|
+
headers?: Record<string, string>;
|
|
3727
|
+
raw?: boolean;
|
|
3728
|
+
}): Promise<T>;
|
|
3714
3729
|
/**
|
|
3715
3730
|
* Makes an authenticated HTTP request to the game's backend Worker.
|
|
3716
3731
|
* Uses gameUrl if set, otherwise falls back to platform API.
|
|
@@ -3862,6 +3877,12 @@ declare class PlaycademyClient {
|
|
|
3862
3877
|
get: (slug: string) => Promise<Record<string, string>>;
|
|
3863
3878
|
delete: (slug: string, key: string) => Promise<void>;
|
|
3864
3879
|
};
|
|
3880
|
+
bucket: {
|
|
3881
|
+
list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
|
|
3882
|
+
get: (slug: string, key: string) => Promise<ArrayBuffer>;
|
|
3883
|
+
put: (slug: string, key: string, content: Blob | ArrayBuffer | Uint8Array, contentType?: string) => Promise<void>;
|
|
3884
|
+
delete: (slug: string, key: string) => Promise<void>;
|
|
3885
|
+
};
|
|
3865
3886
|
};
|
|
3866
3887
|
items: {
|
|
3867
3888
|
create: (gameId: string, slug: string, itemData: Omit<InsertItemInput, "slug" | "gameId">) => Promise<Item>;
|
|
@@ -4076,7 +4097,9 @@ declare class PlaycademyClient {
|
|
|
4076
4097
|
}) => Promise<TodayXpResponse>;
|
|
4077
4098
|
total: () => Promise<TotalXpResponse>;
|
|
4078
4099
|
history: (options?: {
|
|
4079
|
-
startDate
|
|
4100
|
+
startDate
|
|
4101
|
+
/** Auto-initializes a PlaycademyClient with context from the environment */
|
|
4102
|
+
?: string;
|
|
4080
4103
|
endDate?: string;
|
|
4081
4104
|
}) => Promise<XpHistoryResponse>;
|
|
4082
4105
|
summary: (options?: {
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ var isBrowser = () => {
|
|
|
20
20
|
return typeof process !== "undefined" && true;
|
|
21
21
|
}, isInteractiveTTY = () => {
|
|
22
22
|
return typeof process !== "undefined" && Boolean(process.stdout && process.stdout.isTTY);
|
|
23
|
+
}, isSilent = () => {
|
|
24
|
+
return typeof process !== "undefined" && process.env.LOG_SILENT === "true";
|
|
23
25
|
}, detectOutputFormat = () => {
|
|
24
26
|
if (isBrowser()) {
|
|
25
27
|
return "browser";
|
|
@@ -117,6 +119,8 @@ var isBrowser = () => {
|
|
|
117
119
|
}
|
|
118
120
|
return isProduction() ? "info" : "debug";
|
|
119
121
|
}, shouldLog = (level) => {
|
|
122
|
+
if (isSilent())
|
|
123
|
+
return false;
|
|
120
124
|
const minLevel = getMinimumLogLevel();
|
|
121
125
|
return levelPriority[level] >= levelPriority[minLevel];
|
|
122
126
|
}, performLog = (level, message, context) => {
|
|
@@ -299,7 +303,7 @@ function createAuthNamespace(client) {
|
|
|
299
303
|
return {
|
|
300
304
|
login: async (credentials) => {
|
|
301
305
|
try {
|
|
302
|
-
const response = await client["request"]("/auth/sign-in/email", "POST", credentials);
|
|
306
|
+
const response = await client["request"]("/auth/sign-in/email", "POST", { body: credentials });
|
|
303
307
|
client.setToken(response.token, "session");
|
|
304
308
|
return {
|
|
305
309
|
success: true,
|
|
@@ -323,12 +327,14 @@ function createAuthNamespace(client) {
|
|
|
323
327
|
apiKeys: {
|
|
324
328
|
create: async (options) => {
|
|
325
329
|
return client["request"]("/dev/api-keys", "POST", {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
body: {
|
|
331
|
+
name: options?.name || `SDK Key - ${new Date().toISOString()}`,
|
|
332
|
+
expiresIn: options?.expiresIn !== undefined ? options.expiresIn : null,
|
|
333
|
+
permissions: options?.permissions || {
|
|
334
|
+
games: ["read", "write", "delete"],
|
|
335
|
+
users: ["read:self", "write:self"],
|
|
336
|
+
dev: ["read", "write"]
|
|
337
|
+
}
|
|
332
338
|
}
|
|
333
339
|
});
|
|
334
340
|
},
|
|
@@ -336,7 +342,9 @@ function createAuthNamespace(client) {
|
|
|
336
342
|
return client["request"]("/auth/api-key/list", "GET");
|
|
337
343
|
},
|
|
338
344
|
revoke: async (keyId) => {
|
|
339
|
-
await client["request"]("/auth/api-key/revoke", "POST", {
|
|
345
|
+
await client["request"]("/auth/api-key/revoke", "POST", {
|
|
346
|
+
body: { id: keyId }
|
|
347
|
+
});
|
|
340
348
|
}
|
|
341
349
|
}
|
|
342
350
|
};
|
|
@@ -1046,7 +1054,7 @@ function createGamesNamespace(client) {
|
|
|
1046
1054
|
},
|
|
1047
1055
|
saveState: async (state) => {
|
|
1048
1056
|
const gameId = client["_ensureGameId"]();
|
|
1049
|
-
await client["request"](`/games/${gameId}/state`, "POST", state);
|
|
1057
|
+
await client["request"](`/games/${gameId}/state`, "POST", { body: state });
|
|
1050
1058
|
},
|
|
1051
1059
|
loadState: async () => {
|
|
1052
1060
|
const gameId = client["_ensureGameId"]();
|
|
@@ -1156,7 +1164,7 @@ function createUsersNamespace(client) {
|
|
|
1156
1164
|
get: async () => client["request"](`/inventory`, "GET"),
|
|
1157
1165
|
add: async (identifier, qty) => {
|
|
1158
1166
|
const itemId = await resolveItemId(identifier);
|
|
1159
|
-
const res = await client["request"](`/inventory/add`, "POST", { itemId, qty });
|
|
1167
|
+
const res = await client["request"](`/inventory/add`, "POST", { body: { itemId, qty } });
|
|
1160
1168
|
client["emit"]("inventoryChange", {
|
|
1161
1169
|
itemId,
|
|
1162
1170
|
delta: qty,
|
|
@@ -1166,7 +1174,7 @@ function createUsersNamespace(client) {
|
|
|
1166
1174
|
},
|
|
1167
1175
|
remove: async (identifier, qty) => {
|
|
1168
1176
|
const itemId = await resolveItemId(identifier);
|
|
1169
|
-
const res = await client["request"](`/inventory/remove`, "POST", { itemId, qty });
|
|
1177
|
+
const res = await client["request"](`/inventory/remove`, "POST", { body: { itemId, qty } });
|
|
1170
1178
|
client["emit"]("inventoryChange", {
|
|
1171
1179
|
itemId,
|
|
1172
1180
|
delta: -qty,
|
|
@@ -1227,14 +1235,18 @@ function createDevNamespace(client) {
|
|
|
1227
1235
|
deploy: {
|
|
1228
1236
|
frontend: async (slug, metadata, file, hooks) => {
|
|
1229
1237
|
hooks?.onEvent?.({ type: "init" });
|
|
1230
|
-
const game = await client["request"](`/games/${slug}`, "PUT",
|
|
1238
|
+
const game = await client["request"](`/games/${slug}`, "PUT", {
|
|
1239
|
+
body: metadata
|
|
1240
|
+
});
|
|
1231
1241
|
if (metadata.gameType === "external" || file === null) {
|
|
1232
1242
|
return game;
|
|
1233
1243
|
}
|
|
1234
1244
|
const fileName = file instanceof File ? file.name : "game.zip";
|
|
1235
1245
|
const initiateResponse = await client["request"]("/games/uploads/initiate/", "POST", {
|
|
1236
|
-
|
|
1237
|
-
|
|
1246
|
+
body: {
|
|
1247
|
+
fileName,
|
|
1248
|
+
gameId: game.id
|
|
1249
|
+
}
|
|
1238
1250
|
});
|
|
1239
1251
|
if (hooks?.onEvent && typeof XMLHttpRequest !== "undefined") {
|
|
1240
1252
|
await new Promise((resolve, reject) => {
|
|
@@ -1365,7 +1377,7 @@ function createDevNamespace(client) {
|
|
|
1365
1377
|
throw new Error("Upload completed but no final game data received");
|
|
1366
1378
|
},
|
|
1367
1379
|
backend: async (slug, bundle) => {
|
|
1368
|
-
return client["request"](`/games/${slug}/backend/deploy`, "POST", bundle);
|
|
1380
|
+
return client["request"](`/games/${slug}/backend/deploy`, "POST", { body: bundle });
|
|
1369
1381
|
}
|
|
1370
1382
|
},
|
|
1371
1383
|
upsert: async (slug, metadata) => {
|
|
@@ -1374,7 +1386,7 @@ function createDevNamespace(client) {
|
|
|
1374
1386
|
delete: (gameId) => client["request"](`/games/${gameId}`, "DELETE"),
|
|
1375
1387
|
secrets: {
|
|
1376
1388
|
set: async (slug, secrets) => {
|
|
1377
|
-
const result = await client["request"](`/games/${slug}/secrets`, "POST", secrets);
|
|
1389
|
+
const result = await client["request"](`/games/${slug}/secrets`, "POST", { body: secrets });
|
|
1378
1390
|
return result.keys;
|
|
1379
1391
|
},
|
|
1380
1392
|
list: async (slug) => {
|
|
@@ -1388,14 +1400,50 @@ function createDevNamespace(client) {
|
|
|
1388
1400
|
delete: async (slug, key) => {
|
|
1389
1401
|
await client["request"](`/games/${slug}/secrets/${key}`, "DELETE");
|
|
1390
1402
|
}
|
|
1403
|
+
},
|
|
1404
|
+
bucket: {
|
|
1405
|
+
list: async (slug, prefix) => {
|
|
1406
|
+
const params = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
|
|
1407
|
+
const result = await client["request"](`/games/${slug}/bucket${params}`, "GET");
|
|
1408
|
+
return result.files;
|
|
1409
|
+
},
|
|
1410
|
+
get: async (slug, key) => {
|
|
1411
|
+
const res = await client["request"](`/games/${slug}/bucket/${encodeURIComponent(key)}`, "GET", { raw: true });
|
|
1412
|
+
if (!res.ok) {
|
|
1413
|
+
let errorMessage = res.statusText;
|
|
1414
|
+
try {
|
|
1415
|
+
const errorData = await res.json();
|
|
1416
|
+
if (errorData.error) {
|
|
1417
|
+
errorMessage = errorData.error;
|
|
1418
|
+
} else if (errorData.message) {
|
|
1419
|
+
errorMessage = errorData.message;
|
|
1420
|
+
}
|
|
1421
|
+
} catch {}
|
|
1422
|
+
throw new Error(errorMessage);
|
|
1423
|
+
}
|
|
1424
|
+
return res.arrayBuffer();
|
|
1425
|
+
},
|
|
1426
|
+
put: async (slug, key, content, contentType) => {
|
|
1427
|
+
await client["request"](`/games/${slug}/bucket/${encodeURIComponent(key)}`, "PUT", {
|
|
1428
|
+
body: content,
|
|
1429
|
+
headers: contentType ? { "Content-Type": contentType } : undefined
|
|
1430
|
+
});
|
|
1431
|
+
},
|
|
1432
|
+
delete: async (slug, key) => {
|
|
1433
|
+
await client["request"](`/games/${slug}/bucket/${encodeURIComponent(key)}`, "DELETE");
|
|
1434
|
+
}
|
|
1391
1435
|
}
|
|
1392
1436
|
},
|
|
1393
1437
|
items: {
|
|
1394
1438
|
create: (gameId, slug, itemData) => client["request"](`/games/${gameId}/items`, "POST", {
|
|
1395
|
-
|
|
1396
|
-
|
|
1439
|
+
body: {
|
|
1440
|
+
slug,
|
|
1441
|
+
...itemData
|
|
1442
|
+
}
|
|
1443
|
+
}),
|
|
1444
|
+
update: (gameId, itemId, updates) => client["request"](`/games/${gameId}/items/${itemId}`, "PATCH", {
|
|
1445
|
+
body: updates
|
|
1397
1446
|
}),
|
|
1398
|
-
update: (gameId, itemId, updates) => client["request"](`/games/${gameId}/items/${itemId}`, "PATCH", updates),
|
|
1399
1447
|
list: (gameId) => client["request"](`/games/${gameId}/items`, "GET"),
|
|
1400
1448
|
get: (gameId, slug) => {
|
|
1401
1449
|
const queryParams = new URLSearchParams({ slug, gameId });
|
|
@@ -1404,13 +1452,13 @@ function createDevNamespace(client) {
|
|
|
1404
1452
|
delete: (gameId, itemId) => client["request"](`/games/${gameId}/items/${itemId}`, "DELETE"),
|
|
1405
1453
|
shop: {
|
|
1406
1454
|
create: (gameId, itemId, listingData) => {
|
|
1407
|
-
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "POST", listingData);
|
|
1455
|
+
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "POST", { body: listingData });
|
|
1408
1456
|
},
|
|
1409
1457
|
get: (gameId, itemId) => {
|
|
1410
1458
|
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "GET");
|
|
1411
1459
|
},
|
|
1412
1460
|
update: (gameId, itemId, updates) => {
|
|
1413
|
-
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "PATCH", updates);
|
|
1461
|
+
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "PATCH", { body: updates });
|
|
1414
1462
|
},
|
|
1415
1463
|
delete: (gameId, itemId) => {
|
|
1416
1464
|
return client["request"](`/games/${gameId}/items/${itemId}/shop-listing`, "DELETE");
|
|
@@ -1438,7 +1486,9 @@ function createMapsNamespace(client) {
|
|
|
1438
1486
|
elements: (mapId, options) => mapElementsCache.get(mapId, () => client["request"](`/map/elements?mapId=${mapId}`, "GET"), options),
|
|
1439
1487
|
objects: {
|
|
1440
1488
|
list: (mapId) => client["request"](`/maps/${mapId}/objects`, "GET"),
|
|
1441
|
-
create: (mapId, objectData) => client["request"](`/maps/${mapId}/objects`, "POST",
|
|
1489
|
+
create: (mapId, objectData) => client["request"](`/maps/${mapId}/objects`, "POST", {
|
|
1490
|
+
body: objectData
|
|
1491
|
+
}),
|
|
1442
1492
|
delete: (mapId, objectId) => client["request"](`/maps/${mapId}/objects/${objectId}`, "DELETE")
|
|
1443
1493
|
}
|
|
1444
1494
|
};
|
|
@@ -1453,24 +1503,26 @@ function createAdminNamespace(client) {
|
|
|
1453
1503
|
resumeGame: (gameId) => client["request"](`/admin/games/${gameId}/resume`, "POST")
|
|
1454
1504
|
},
|
|
1455
1505
|
items: {
|
|
1456
|
-
create: (props) => client["request"]("/items", "POST", props),
|
|
1506
|
+
create: (props) => client["request"]("/items", "POST", { body: props }),
|
|
1457
1507
|
get: (itemId) => client["request"](`/items/${itemId}`, "GET"),
|
|
1458
1508
|
list: () => client["request"]("/items", "GET"),
|
|
1459
|
-
update: (itemId, props) => client["request"](`/items/${itemId}`, "PATCH", props),
|
|
1509
|
+
update: (itemId, props) => client["request"](`/items/${itemId}`, "PATCH", { body: props }),
|
|
1460
1510
|
delete: (itemId) => client["request"](`/items/${itemId}`, "DELETE")
|
|
1461
1511
|
},
|
|
1462
1512
|
currencies: {
|
|
1463
|
-
create: (props) => client["request"]("/currencies", "POST", props),
|
|
1513
|
+
create: (props) => client["request"]("/currencies", "POST", { body: props }),
|
|
1464
1514
|
get: (currencyId) => client["request"](`/currencies/${currencyId}`, "GET"),
|
|
1465
1515
|
list: () => client["request"]("/currencies", "GET"),
|
|
1466
|
-
update: (currencyId, props) => client["request"](`/currencies/${currencyId}`, "PATCH", props),
|
|
1516
|
+
update: (currencyId, props) => client["request"](`/currencies/${currencyId}`, "PATCH", { body: props }),
|
|
1467
1517
|
delete: (currencyId) => client["request"](`/currencies/${currencyId}`, "DELETE")
|
|
1468
1518
|
},
|
|
1469
1519
|
shopListings: {
|
|
1470
|
-
create: (props) => client["request"]("/shop-listings", "POST", props),
|
|
1520
|
+
create: (props) => client["request"]("/shop-listings", "POST", { body: props }),
|
|
1471
1521
|
get: (listingId) => client["request"](`/shop-listings/${listingId}`, "GET"),
|
|
1472
1522
|
list: () => client["request"]("/shop-listings", "GET"),
|
|
1473
|
-
update: (listingId, props) => client["request"](`/shop-listings/${listingId}`, "PATCH",
|
|
1523
|
+
update: (listingId, props) => client["request"](`/shop-listings/${listingId}`, "PATCH", {
|
|
1524
|
+
body: props
|
|
1525
|
+
}),
|
|
1474
1526
|
delete: (listingId) => client["request"](`/shop-listings/${listingId}`, "DELETE")
|
|
1475
1527
|
}
|
|
1476
1528
|
};
|
|
@@ -1488,7 +1540,7 @@ function createShopNamespace(client) {
|
|
|
1488
1540
|
// src/core/namespaces/telemetry.ts
|
|
1489
1541
|
function createTelemetryNamespace(client) {
|
|
1490
1542
|
return {
|
|
1491
|
-
pushMetrics: (metrics) => client["request"](`/telemetry/metrics`, "POST", metrics)
|
|
1543
|
+
pushMetrics: (metrics) => client["request"](`/telemetry/metrics`, "POST", { body: metrics })
|
|
1492
1544
|
};
|
|
1493
1545
|
}
|
|
1494
1546
|
|
|
@@ -1665,8 +1717,10 @@ function createCreditsNamespace(client) {
|
|
|
1665
1717
|
}
|
|
1666
1718
|
const creditsItemId = await getCreditsItemId();
|
|
1667
1719
|
const result = await client["request"]("/inventory/add", "POST", {
|
|
1668
|
-
|
|
1669
|
-
|
|
1720
|
+
body: {
|
|
1721
|
+
itemId: creditsItemId,
|
|
1722
|
+
qty: amount
|
|
1723
|
+
}
|
|
1670
1724
|
});
|
|
1671
1725
|
client["emit"]("inventoryChange", {
|
|
1672
1726
|
itemId: creditsItemId,
|
|
@@ -1681,8 +1735,10 @@ function createCreditsNamespace(client) {
|
|
|
1681
1735
|
}
|
|
1682
1736
|
const creditsItemId = await getCreditsItemId();
|
|
1683
1737
|
const result = await client["request"]("/inventory/remove", "POST", {
|
|
1684
|
-
|
|
1685
|
-
|
|
1738
|
+
body: {
|
|
1739
|
+
itemId: creditsItemId,
|
|
1740
|
+
qty: amount
|
|
1741
|
+
}
|
|
1686
1742
|
});
|
|
1687
1743
|
client["emit"]("inventoryChange", {
|
|
1688
1744
|
itemId: creditsItemId,
|
|
@@ -1722,8 +1778,10 @@ function createScoresNamespace(client) {
|
|
|
1722
1778
|
return {
|
|
1723
1779
|
submit: async (gameId, score, metadata) => {
|
|
1724
1780
|
return client["request"](`/games/${gameId}/scores`, "POST", {
|
|
1725
|
-
|
|
1726
|
-
|
|
1781
|
+
body: {
|
|
1782
|
+
score,
|
|
1783
|
+
metadata
|
|
1784
|
+
}
|
|
1727
1785
|
});
|
|
1728
1786
|
},
|
|
1729
1787
|
getByUser: async (gameId, userId, options) => {
|
|
@@ -1759,10 +1817,10 @@ function createCharacterNamespace(client) {
|
|
|
1759
1817
|
}
|
|
1760
1818
|
},
|
|
1761
1819
|
create: async (characterData) => {
|
|
1762
|
-
return client["request"]("/character", "POST", characterData);
|
|
1820
|
+
return client["request"]("/character", "POST", { body: characterData });
|
|
1763
1821
|
},
|
|
1764
1822
|
update: async (updates) => {
|
|
1765
|
-
return client["request"]("/character", "PATCH", updates);
|
|
1823
|
+
return client["request"]("/character", "PATCH", { body: updates });
|
|
1766
1824
|
},
|
|
1767
1825
|
components: {
|
|
1768
1826
|
list: async (options) => {
|
|
@@ -1778,7 +1836,7 @@ function createCharacterNamespace(client) {
|
|
|
1778
1836
|
},
|
|
1779
1837
|
accessories: {
|
|
1780
1838
|
equip: async (slot, componentId) => {
|
|
1781
|
-
return client["request"]("/character/accessories/equip", "POST", { slot, accessoryComponentId: componentId });
|
|
1839
|
+
return client["request"]("/character/accessories/equip", "POST", { body: { slot, accessoryComponentId: componentId } });
|
|
1782
1840
|
},
|
|
1783
1841
|
remove: async (slot) => {
|
|
1784
1842
|
return client["request"](`/character/accessories/${slot}`, "DELETE");
|
|
@@ -2080,7 +2138,7 @@ function createAchievementsNamespace(client) {
|
|
|
2080
2138
|
},
|
|
2081
2139
|
progress: {
|
|
2082
2140
|
submit: async (achievementId) => client["request"]("/achievements/progress", "POST", {
|
|
2083
|
-
achievementId
|
|
2141
|
+
body: { achievementId }
|
|
2084
2142
|
})
|
|
2085
2143
|
}
|
|
2086
2144
|
};
|
|
@@ -2155,7 +2213,9 @@ function createTimebackNamespace(client) {
|
|
|
2155
2213
|
},
|
|
2156
2214
|
management: {
|
|
2157
2215
|
setup: (request2) => {
|
|
2158
|
-
return client["request"]("/timeback/setup", "POST",
|
|
2216
|
+
return client["request"]("/timeback/setup", "POST", {
|
|
2217
|
+
body: request2
|
|
2218
|
+
});
|
|
2159
2219
|
},
|
|
2160
2220
|
verify: (gameId) => {
|
|
2161
2221
|
return client["request"](`/timeback/verify/${gameId}`, "GET");
|
|
@@ -2244,24 +2304,30 @@ function createNotificationsNamespace(client) {
|
|
|
2244
2304
|
},
|
|
2245
2305
|
markAsSeen: async (notificationId) => {
|
|
2246
2306
|
const result = await client["request"](`/notifications/${notificationId}/status`, "PATCH", {
|
|
2247
|
-
|
|
2248
|
-
|
|
2307
|
+
body: {
|
|
2308
|
+
id: notificationId,
|
|
2309
|
+
status: "seen"
|
|
2310
|
+
}
|
|
2249
2311
|
});
|
|
2250
2312
|
notificationsListCache.clear();
|
|
2251
2313
|
return result;
|
|
2252
2314
|
},
|
|
2253
2315
|
markAsClicked: async (notificationId) => {
|
|
2254
2316
|
const result = await client["request"](`/notifications/${notificationId}/status`, "PATCH", {
|
|
2255
|
-
|
|
2256
|
-
|
|
2317
|
+
body: {
|
|
2318
|
+
id: notificationId,
|
|
2319
|
+
status: "clicked"
|
|
2320
|
+
}
|
|
2257
2321
|
});
|
|
2258
2322
|
notificationsListCache.clear();
|
|
2259
2323
|
return result;
|
|
2260
2324
|
},
|
|
2261
2325
|
dismiss: async (notificationId) => {
|
|
2262
2326
|
const result = await client["request"](`/notifications/${notificationId}/status`, "PATCH", {
|
|
2263
|
-
|
|
2264
|
-
|
|
2327
|
+
body: {
|
|
2328
|
+
id: notificationId,
|
|
2329
|
+
status: "dismissed"
|
|
2330
|
+
}
|
|
2265
2331
|
});
|
|
2266
2332
|
notificationsListCache.clear();
|
|
2267
2333
|
return result;
|
|
@@ -2574,17 +2640,18 @@ var init_client = __esm(() => {
|
|
|
2574
2640
|
listener(payload);
|
|
2575
2641
|
});
|
|
2576
2642
|
}
|
|
2577
|
-
async request(path, method,
|
|
2643
|
+
async request(path, method, options) {
|
|
2578
2644
|
const effectiveHeaders = {
|
|
2579
|
-
...headers,
|
|
2645
|
+
...options?.headers,
|
|
2580
2646
|
...this.authStrategy.getHeaders()
|
|
2581
2647
|
};
|
|
2582
2648
|
return request({
|
|
2583
2649
|
path,
|
|
2584
2650
|
method,
|
|
2585
|
-
body,
|
|
2651
|
+
body: options?.body,
|
|
2586
2652
|
baseUrl: this.baseUrl,
|
|
2587
|
-
extraHeaders: effectiveHeaders
|
|
2653
|
+
extraHeaders: effectiveHeaders,
|
|
2654
|
+
raw: options?.raw
|
|
2588
2655
|
});
|
|
2589
2656
|
}
|
|
2590
2657
|
async requestGameBackend(path, method, body, headers, raw) {
|
package/dist/types.d.ts
CHANGED
|
@@ -4394,11 +4394,17 @@ declare class PlaycademyClient {
|
|
|
4394
4394
|
*
|
|
4395
4395
|
* @param path - API endpoint path
|
|
4396
4396
|
* @param method - HTTP method
|
|
4397
|
-
* @param
|
|
4398
|
-
* @param
|
|
4399
|
-
* @
|
|
4397
|
+
* @param options - Optional request configuration
|
|
4398
|
+
* @param options.body - Request body
|
|
4399
|
+
* @param options.headers - Additional headers
|
|
4400
|
+
* @param options.raw - If true, returns raw Response instead of parsing
|
|
4401
|
+
* @returns Promise resolving to the response data or raw Response
|
|
4400
4402
|
*/
|
|
4401
|
-
protected request<T>(path: string, method: Method,
|
|
4403
|
+
protected request<T>(path: string, method: Method, options?: {
|
|
4404
|
+
body?: unknown;
|
|
4405
|
+
headers?: Record<string, string>;
|
|
4406
|
+
raw?: boolean;
|
|
4407
|
+
}): Promise<T>;
|
|
4402
4408
|
/**
|
|
4403
4409
|
* Makes an authenticated HTTP request to the game's backend Worker.
|
|
4404
4410
|
* Uses gameUrl if set, otherwise falls back to platform API.
|
|
@@ -4550,6 +4556,12 @@ declare class PlaycademyClient {
|
|
|
4550
4556
|
get: (slug: string) => Promise<Record<string, string>>;
|
|
4551
4557
|
delete: (slug: string, key: string) => Promise<void>;
|
|
4552
4558
|
};
|
|
4559
|
+
bucket: {
|
|
4560
|
+
list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
|
|
4561
|
+
get: (slug: string, key: string) => Promise<ArrayBuffer>;
|
|
4562
|
+
put: (slug: string, key: string, content: Blob | ArrayBuffer | Uint8Array, contentType?: string) => Promise<void>;
|
|
4563
|
+
delete: (slug: string, key: string) => Promise<void>;
|
|
4564
|
+
};
|
|
4553
4565
|
};
|
|
4554
4566
|
items: {
|
|
4555
4567
|
create: (gameId: string, slug: string, itemData: Omit<InsertItemInput, "slug" | "gameId">) => Promise<Item>;
|
|
@@ -4764,7 +4776,9 @@ declare class PlaycademyClient {
|
|
|
4764
4776
|
}) => Promise<TodayXpResponse>;
|
|
4765
4777
|
total: () => Promise<TotalXpResponse>;
|
|
4766
4778
|
history: (options?: {
|
|
4767
|
-
startDate
|
|
4779
|
+
startDate
|
|
4780
|
+
/** Auto-initializes a PlaycademyClient with context from the environment */
|
|
4781
|
+
?: string;
|
|
4768
4782
|
endDate?: string;
|
|
4769
4783
|
}) => Promise<XpHistoryResponse>;
|
|
4770
4784
|
summary: (options?: {
|
|
@@ -5128,6 +5142,15 @@ interface BetterAuthApiKey {
|
|
|
5128
5142
|
lastRequest: string | null;
|
|
5129
5143
|
requestCount: number;
|
|
5130
5144
|
}
|
|
5145
|
+
/**
|
|
5146
|
+
* Bucket file metadata
|
|
5147
|
+
*/
|
|
5148
|
+
interface BucketFile {
|
|
5149
|
+
key: string;
|
|
5150
|
+
size: number;
|
|
5151
|
+
uploaded: string;
|
|
5152
|
+
contentType?: string;
|
|
5153
|
+
}
|
|
5131
5154
|
|
|
5132
5155
|
export { PlaycademyClient };
|
|
5133
|
-
export type { Achievement, AchievementCurrent, AchievementProgressResponse, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, CharacterComponent, CharacterComponentWithSpriteUrl, ClientConfig, ClientEvents, Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusResponse, EventListeners, ExternalGame, Game, GameContextPayload, GameLeaderboardEntry, GameSession, GameStateData, GameTokenResponse, GameUser, HostedGame, HostedGameWithManifest, InitPayload, InventoryItem, InventoryItemWithItem, InventoryMutationResponse, Item, KeyEventPayload, LeaderboardEntry, LevelConfig, LoginResponse, ManifestV1, Map, MapElement, MapElementWithGame, MapObject, MapObjectWithItem, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacter, ShopCurrency, ShopDisplayItem, ShopViewResponse, SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, User, UserInfo, UserLevel, UserLevelWithConfig, UserRank, UserRankResponse, UserRoleEnumType, UserScore$1 as UserScore, XpHistoryResponse };
|
|
5156
|
+
export type { Achievement, AchievementCurrent, AchievementProgressResponse, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, CharacterComponent, CharacterComponentWithSpriteUrl, ClientConfig, ClientEvents, Currency, DevUploadEvent, DevUploadHooks, DeveloperStatusResponse, EventListeners, ExternalGame, Game, GameContextPayload, GameLeaderboardEntry, GameSession, GameStateData, GameTokenResponse, GameUser, HostedGame, HostedGameWithManifest, InitPayload, InventoryItem, InventoryItemWithItem, InventoryMutationResponse, Item, KeyEventPayload, LeaderboardEntry, LevelConfig, LoginResponse, ManifestV1, Map, MapElement, MapElementWithGame, MapObject, MapObjectWithItem, PlaycademyServerClientConfig, PlaycademyServerClientState, PlayerCharacter, ShopCurrency, ShopDisplayItem, ShopViewResponse, SpriteTemplate, SpriteTemplateData, StartSessionResponse, TelemetryPayload, TodayXpResponse, TokenRefreshPayload, TokenType, TotalXpResponse, User, UserInfo, UserLevel, UserLevelWithConfig, UserRank, UserRankResponse, UserRoleEnumType, UserScore$1 as UserScore, XpHistoryResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@playcademy/timeback": "0.0.1",
|
|
43
43
|
"@playcademy/utils": "0.0.1",
|
|
44
44
|
"@types/bun": "latest",
|
|
45
|
-
"playcademy": "0.13.
|
|
45
|
+
"playcademy": "0.13.22",
|
|
46
46
|
"rollup": "^4.50.2",
|
|
47
47
|
"rollup-plugin-dts": "^6.2.3",
|
|
48
48
|
"typescript": "^5.7.2",
|