@playcademy/sandbox 0.3.11 → 0.3.12
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/cli.js +24 -15
- package/dist/server.js +24 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1225,7 +1225,7 @@ var package_default;
|
|
|
1225
1225
|
var init_package = __esm(() => {
|
|
1226
1226
|
package_default = {
|
|
1227
1227
|
name: "@playcademy/sandbox",
|
|
1228
|
-
version: "0.3.
|
|
1228
|
+
version: "0.3.12",
|
|
1229
1229
|
description: "Local development server for Playcademy game development",
|
|
1230
1230
|
type: "module",
|
|
1231
1231
|
exports: {
|
|
@@ -1676,7 +1676,7 @@ function createHandle(buildContext) {
|
|
|
1676
1676
|
try {
|
|
1677
1677
|
const ctx = await buildContext(c);
|
|
1678
1678
|
const result = await controller(ctx);
|
|
1679
|
-
if (options?.status === 204 || result === undefined
|
|
1679
|
+
if (options?.status === 204 || result === undefined) {
|
|
1680
1680
|
return new Response(null, { status: options?.status ?? 204 });
|
|
1681
1681
|
}
|
|
1682
1682
|
return new Response(JSON.stringify(result), {
|
|
@@ -13915,6 +13915,20 @@ class GameService {
|
|
|
13915
13915
|
orderBy: [desc(games.createdAt)]
|
|
13916
13916
|
});
|
|
13917
13917
|
}
|
|
13918
|
+
async getSubjects() {
|
|
13919
|
+
const db2 = this.ctx.db;
|
|
13920
|
+
const integrations = await db2.query.gameTimebackIntegrations.findMany({
|
|
13921
|
+
columns: { gameId: true, subject: true },
|
|
13922
|
+
orderBy: [asc(gameTimebackIntegrations.createdAt)]
|
|
13923
|
+
});
|
|
13924
|
+
const subjectMap = {};
|
|
13925
|
+
for (const integration of integrations) {
|
|
13926
|
+
if (!(integration.gameId in subjectMap)) {
|
|
13927
|
+
subjectMap[integration.gameId] = integration.subject;
|
|
13928
|
+
}
|
|
13929
|
+
}
|
|
13930
|
+
return subjectMap;
|
|
13931
|
+
}
|
|
13918
13932
|
async getById(gameId) {
|
|
13919
13933
|
const db2 = this.ctx.db;
|
|
13920
13934
|
const game = await db2.query.games.findFirst({
|
|
@@ -14909,13 +14923,13 @@ class LevelService {
|
|
|
14909
14923
|
throw new BadRequestError("Level must be at least 1");
|
|
14910
14924
|
}
|
|
14911
14925
|
if (levelConfigCache?.has(level)) {
|
|
14912
|
-
return levelConfigCache.get(level)
|
|
14926
|
+
return levelConfigCache.get(level) ?? null;
|
|
14913
14927
|
}
|
|
14914
14928
|
const [config2] = await this.ctx.db.select().from(levelConfigs).where(eq(levelConfigs.level, level)).limit(1);
|
|
14915
14929
|
if (levelConfigCache && config2) {
|
|
14916
14930
|
levelConfigCache.set(level, config2);
|
|
14917
14931
|
}
|
|
14918
|
-
return config2
|
|
14932
|
+
return config2 ?? null;
|
|
14919
14933
|
}
|
|
14920
14934
|
async listConfigs() {
|
|
14921
14935
|
return this.ctx.db.select().from(levelConfigs).orderBy(levelConfigs.level);
|
|
@@ -92876,7 +92890,7 @@ var init_domain_controller = __esm(() => {
|
|
|
92876
92890
|
});
|
|
92877
92891
|
|
|
92878
92892
|
// ../api-core/src/controllers/game.controller.ts
|
|
92879
|
-
var logger43, list3, getById2, getBySlug, upsertBySlug, remove3, games2;
|
|
92893
|
+
var logger43, list3, getSubjects, getById2, getBySlug, upsertBySlug, remove3, games2;
|
|
92880
92894
|
var init_game_controller = __esm(() => {
|
|
92881
92895
|
init_esm();
|
|
92882
92896
|
init_schemas_index();
|
|
@@ -92889,6 +92903,10 @@ var init_game_controller = __esm(() => {
|
|
|
92889
92903
|
logger43.debug("Listing games", { userId: ctx.user.id });
|
|
92890
92904
|
return ctx.services.game.list();
|
|
92891
92905
|
});
|
|
92906
|
+
getSubjects = requireAuth(async (ctx) => {
|
|
92907
|
+
logger43.debug("Getting game subjects", { userId: ctx.user.id });
|
|
92908
|
+
return ctx.services.game.getSubjects();
|
|
92909
|
+
});
|
|
92892
92910
|
getById2 = requireAuth(async (ctx) => {
|
|
92893
92911
|
const gameId = ctx.params.gameId;
|
|
92894
92912
|
if (!gameId) {
|
|
@@ -92941,6 +92959,7 @@ var init_game_controller = __esm(() => {
|
|
|
92941
92959
|
});
|
|
92942
92960
|
games2 = {
|
|
92943
92961
|
list: list3,
|
|
92962
|
+
getSubjects,
|
|
92944
92963
|
getById: getById2,
|
|
92945
92964
|
getBySlug,
|
|
92946
92965
|
upsertBySlug,
|
|
@@ -93324,7 +93343,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93324
93343
|
init_esm();
|
|
93325
93344
|
init_schemas_index();
|
|
93326
93345
|
init_src2();
|
|
93327
|
-
init_src4();
|
|
93328
93346
|
init_errors();
|
|
93329
93347
|
init_utils11();
|
|
93330
93348
|
logger47 = log.scope("LeaderboardController");
|
|
@@ -93413,9 +93431,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93413
93431
|
if (!gameId || !userId) {
|
|
93414
93432
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
93415
93433
|
}
|
|
93416
|
-
if (!isValidUUID(userId)) {
|
|
93417
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93418
|
-
}
|
|
93419
93434
|
logger47.debug("Getting user rank", {
|
|
93420
93435
|
requesterId: ctx.user.id,
|
|
93421
93436
|
gameId,
|
|
@@ -93428,9 +93443,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93428
93443
|
if (!userId) {
|
|
93429
93444
|
throw ApiError.badRequest("User ID is required");
|
|
93430
93445
|
}
|
|
93431
|
-
if (!isValidUUID(userId)) {
|
|
93432
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93433
|
-
}
|
|
93434
93446
|
const url = ctx.url;
|
|
93435
93447
|
const limit = Math.min(Number(url.searchParams.get("limit") || "50"), 100);
|
|
93436
93448
|
const gameId = url.searchParams.get("gameId") || undefined;
|
|
@@ -93447,9 +93459,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93447
93459
|
if (!gameId || !userId) {
|
|
93448
93460
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
93449
93461
|
}
|
|
93450
|
-
if (!isValidUUID(userId)) {
|
|
93451
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93452
|
-
}
|
|
93453
93462
|
const url = ctx.url;
|
|
93454
93463
|
const limit = Math.min(Number(url.searchParams.get("limit") || "10"), 100);
|
|
93455
93464
|
logger47.debug("Getting user scores", {
|
package/dist/server.js
CHANGED
|
@@ -1224,7 +1224,7 @@ var package_default;
|
|
|
1224
1224
|
var init_package = __esm(() => {
|
|
1225
1225
|
package_default = {
|
|
1226
1226
|
name: "@playcademy/sandbox",
|
|
1227
|
-
version: "0.3.
|
|
1227
|
+
version: "0.3.12",
|
|
1228
1228
|
description: "Local development server for Playcademy game development",
|
|
1229
1229
|
type: "module",
|
|
1230
1230
|
exports: {
|
|
@@ -1675,7 +1675,7 @@ function createHandle(buildContext) {
|
|
|
1675
1675
|
try {
|
|
1676
1676
|
const ctx = await buildContext(c);
|
|
1677
1677
|
const result = await controller(ctx);
|
|
1678
|
-
if (options?.status === 204 || result === undefined
|
|
1678
|
+
if (options?.status === 204 || result === undefined) {
|
|
1679
1679
|
return new Response(null, { status: options?.status ?? 204 });
|
|
1680
1680
|
}
|
|
1681
1681
|
return new Response(JSON.stringify(result), {
|
|
@@ -13914,6 +13914,20 @@ class GameService {
|
|
|
13914
13914
|
orderBy: [desc(games.createdAt)]
|
|
13915
13915
|
});
|
|
13916
13916
|
}
|
|
13917
|
+
async getSubjects() {
|
|
13918
|
+
const db2 = this.ctx.db;
|
|
13919
|
+
const integrations = await db2.query.gameTimebackIntegrations.findMany({
|
|
13920
|
+
columns: { gameId: true, subject: true },
|
|
13921
|
+
orderBy: [asc(gameTimebackIntegrations.createdAt)]
|
|
13922
|
+
});
|
|
13923
|
+
const subjectMap = {};
|
|
13924
|
+
for (const integration of integrations) {
|
|
13925
|
+
if (!(integration.gameId in subjectMap)) {
|
|
13926
|
+
subjectMap[integration.gameId] = integration.subject;
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
return subjectMap;
|
|
13930
|
+
}
|
|
13917
13931
|
async getById(gameId) {
|
|
13918
13932
|
const db2 = this.ctx.db;
|
|
13919
13933
|
const game = await db2.query.games.findFirst({
|
|
@@ -14908,13 +14922,13 @@ class LevelService {
|
|
|
14908
14922
|
throw new BadRequestError("Level must be at least 1");
|
|
14909
14923
|
}
|
|
14910
14924
|
if (levelConfigCache?.has(level)) {
|
|
14911
|
-
return levelConfigCache.get(level)
|
|
14925
|
+
return levelConfigCache.get(level) ?? null;
|
|
14912
14926
|
}
|
|
14913
14927
|
const [config2] = await this.ctx.db.select().from(levelConfigs).where(eq(levelConfigs.level, level)).limit(1);
|
|
14914
14928
|
if (levelConfigCache && config2) {
|
|
14915
14929
|
levelConfigCache.set(level, config2);
|
|
14916
14930
|
}
|
|
14917
|
-
return config2
|
|
14931
|
+
return config2 ?? null;
|
|
14918
14932
|
}
|
|
14919
14933
|
async listConfigs() {
|
|
14920
14934
|
return this.ctx.db.select().from(levelConfigs).orderBy(levelConfigs.level);
|
|
@@ -92875,7 +92889,7 @@ var init_domain_controller = __esm(() => {
|
|
|
92875
92889
|
});
|
|
92876
92890
|
|
|
92877
92891
|
// ../api-core/src/controllers/game.controller.ts
|
|
92878
|
-
var logger43, list3, getById2, getBySlug, upsertBySlug, remove3, games2;
|
|
92892
|
+
var logger43, list3, getSubjects, getById2, getBySlug, upsertBySlug, remove3, games2;
|
|
92879
92893
|
var init_game_controller = __esm(() => {
|
|
92880
92894
|
init_esm();
|
|
92881
92895
|
init_schemas_index();
|
|
@@ -92888,6 +92902,10 @@ var init_game_controller = __esm(() => {
|
|
|
92888
92902
|
logger43.debug("Listing games", { userId: ctx.user.id });
|
|
92889
92903
|
return ctx.services.game.list();
|
|
92890
92904
|
});
|
|
92905
|
+
getSubjects = requireAuth(async (ctx) => {
|
|
92906
|
+
logger43.debug("Getting game subjects", { userId: ctx.user.id });
|
|
92907
|
+
return ctx.services.game.getSubjects();
|
|
92908
|
+
});
|
|
92891
92909
|
getById2 = requireAuth(async (ctx) => {
|
|
92892
92910
|
const gameId = ctx.params.gameId;
|
|
92893
92911
|
if (!gameId) {
|
|
@@ -92940,6 +92958,7 @@ var init_game_controller = __esm(() => {
|
|
|
92940
92958
|
});
|
|
92941
92959
|
games2 = {
|
|
92942
92960
|
list: list3,
|
|
92961
|
+
getSubjects,
|
|
92943
92962
|
getById: getById2,
|
|
92944
92963
|
getBySlug,
|
|
92945
92964
|
upsertBySlug,
|
|
@@ -93323,7 +93342,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93323
93342
|
init_esm();
|
|
93324
93343
|
init_schemas_index();
|
|
93325
93344
|
init_src2();
|
|
93326
|
-
init_src4();
|
|
93327
93345
|
init_errors();
|
|
93328
93346
|
init_utils11();
|
|
93329
93347
|
logger47 = log.scope("LeaderboardController");
|
|
@@ -93412,9 +93430,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93412
93430
|
if (!gameId || !userId) {
|
|
93413
93431
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
93414
93432
|
}
|
|
93415
|
-
if (!isValidUUID(userId)) {
|
|
93416
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93417
|
-
}
|
|
93418
93433
|
logger47.debug("Getting user rank", {
|
|
93419
93434
|
requesterId: ctx.user.id,
|
|
93420
93435
|
gameId,
|
|
@@ -93427,9 +93442,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93427
93442
|
if (!userId) {
|
|
93428
93443
|
throw ApiError.badRequest("User ID is required");
|
|
93429
93444
|
}
|
|
93430
|
-
if (!isValidUUID(userId)) {
|
|
93431
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93432
|
-
}
|
|
93433
93445
|
const url = ctx.url;
|
|
93434
93446
|
const limit = Math.min(Number(url.searchParams.get("limit") || "50"), 100);
|
|
93435
93447
|
const gameId = url.searchParams.get("gameId") || undefined;
|
|
@@ -93446,9 +93458,6 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
93446
93458
|
if (!gameId || !userId) {
|
|
93447
93459
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
93448
93460
|
}
|
|
93449
|
-
if (!isValidUUID(userId)) {
|
|
93450
|
-
throw ApiError.unprocessableEntity("userId must be a valid UUID format");
|
|
93451
|
-
}
|
|
93452
93461
|
const url = ctx.url;
|
|
93453
93462
|
const limit = Math.min(Number(url.searchParams.get("limit") || "10"), 100);
|
|
93454
93463
|
logger47.debug("Getting user scores", {
|