@playcademy/sandbox 0.3.17-beta.13 → 0.3.17-beta.15
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 +191 -89
- package/dist/constants.d.ts +28 -0
- package/dist/constants.js +21 -3
- package/dist/server.d.ts +6 -0
- package/dist/server.js +191 -89
- package/dist/test.d.ts +2 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -300,7 +300,7 @@ var init_achievements = __esm(() => {
|
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
// ../constants/src/auth.ts
|
|
303
|
-
var AUTH_PROVIDER_IDS;
|
|
303
|
+
var AUTH_PROVIDER_IDS, DEMO_DISPLAY_NAME_PLACEHOLDER = "Demo Player";
|
|
304
304
|
var init_auth = __esm(() => {
|
|
305
305
|
AUTH_PROVIDER_IDS = {
|
|
306
306
|
TIMEBACK: "timeback",
|
|
@@ -387,7 +387,8 @@ var init_overworld = __esm(() => {
|
|
|
387
387
|
ERROR: 4000
|
|
388
388
|
};
|
|
389
389
|
CORE_GAME_UUIDS = {
|
|
390
|
-
PLAYGROUND: "00000000-0000-0000-0000-000000000001"
|
|
390
|
+
PLAYGROUND: "00000000-0000-0000-0000-000000000001",
|
|
391
|
+
DEMO: "00000000-0000-0000-0000-000000000002"
|
|
391
392
|
};
|
|
392
393
|
});
|
|
393
394
|
|
|
@@ -465,13 +466,15 @@ var init_src = __esm(() => {
|
|
|
465
466
|
// src/constants/demo-users.ts
|
|
466
467
|
var now, DEMO_USER_IDS, DEMO_USERS, DEMO_USER;
|
|
467
468
|
var init_demo_users = __esm(() => {
|
|
469
|
+
init_src();
|
|
468
470
|
now = new Date;
|
|
469
471
|
DEMO_USER_IDS = {
|
|
470
472
|
player: "00000000-0000-0000-0000-000000000001",
|
|
471
473
|
developer: "00000000-0000-0000-0000-000000000002",
|
|
472
474
|
admin: "00000000-0000-0000-0000-000000000003",
|
|
473
475
|
pendingDeveloper: "00000000-0000-0000-0000-000000000004",
|
|
474
|
-
unverifiedPlayer: "00000000-0000-0000-0000-000000000005"
|
|
476
|
+
unverifiedPlayer: "00000000-0000-0000-0000-000000000005",
|
|
477
|
+
anonymousPlayer: "00000000-0000-0000-0000-000000000006"
|
|
475
478
|
};
|
|
476
479
|
DEMO_USERS = {
|
|
477
480
|
admin: {
|
|
@@ -533,6 +536,19 @@ var init_demo_users = __esm(() => {
|
|
|
533
536
|
developerStatus: "none",
|
|
534
537
|
createdAt: now,
|
|
535
538
|
updatedAt: now
|
|
539
|
+
},
|
|
540
|
+
anonymousPlayer: {
|
|
541
|
+
id: DEMO_USER_IDS.anonymousPlayer,
|
|
542
|
+
name: DEMO_DISPLAY_NAME_PLACEHOLDER,
|
|
543
|
+
username: "anonymous_demo_player",
|
|
544
|
+
email: "player@anon.demo.playcademy.gg",
|
|
545
|
+
emailVerified: false,
|
|
546
|
+
image: null,
|
|
547
|
+
isAnonymous: true,
|
|
548
|
+
role: "player",
|
|
549
|
+
developerStatus: "none",
|
|
550
|
+
createdAt: now,
|
|
551
|
+
updatedAt: now
|
|
536
552
|
}
|
|
537
553
|
};
|
|
538
554
|
DEMO_USER = DEMO_USERS.player;
|
|
@@ -546,6 +562,7 @@ var init_demo_tokens = __esm(() => {
|
|
|
546
562
|
"sandbox-demo-token": DEMO_USERS.player,
|
|
547
563
|
"sandbox-admin-token": DEMO_USERS.admin,
|
|
548
564
|
"sandbox-player-token": DEMO_USERS.player,
|
|
565
|
+
"sandbox-anonymous-token": DEMO_USERS.anonymousPlayer,
|
|
549
566
|
"sandbox-developer-token": DEMO_USERS.developer,
|
|
550
567
|
"sandbox-pending-dev-token": DEMO_USERS.pendingDeveloper,
|
|
551
568
|
"sandbox-unverified-token": DEMO_USERS.unverifiedPlayer,
|
|
@@ -554,6 +571,7 @@ var init_demo_tokens = __esm(() => {
|
|
|
554
571
|
};
|
|
555
572
|
SANDBOX_TOKENS = {
|
|
556
573
|
player: "sandbox-player-token",
|
|
574
|
+
anonymous: "sandbox-anonymous-token",
|
|
557
575
|
developer: "sandbox-developer-token",
|
|
558
576
|
admin: "sandbox-admin-token",
|
|
559
577
|
pendingDeveloper: "sandbox-pending-dev-token",
|
|
@@ -1311,7 +1329,7 @@ var package_default;
|
|
|
1311
1329
|
var init_package = __esm(() => {
|
|
1312
1330
|
package_default = {
|
|
1313
1331
|
name: "@playcademy/sandbox",
|
|
1314
|
-
version: "0.3.17-beta.
|
|
1332
|
+
version: "0.3.17-beta.15",
|
|
1315
1333
|
description: "Local development server for Playcademy game development",
|
|
1316
1334
|
type: "module",
|
|
1317
1335
|
exports: {
|
|
@@ -11560,6 +11578,7 @@ var init_table6 = __esm(() => {
|
|
|
11560
11578
|
name: text("name").notNull(),
|
|
11561
11579
|
username: text("username").unique(),
|
|
11562
11580
|
email: text("email").notNull().unique(),
|
|
11581
|
+
isAnonymous: boolean("is_anonymous").notNull().default(false),
|
|
11563
11582
|
timebackId: text("timeback_id").unique(),
|
|
11564
11583
|
emailVerified: boolean("email_verified").notNull().default(false),
|
|
11565
11584
|
image: text("image"),
|
|
@@ -32597,7 +32616,7 @@ class LeaderboardService {
|
|
|
32597
32616
|
constructor(deps) {
|
|
32598
32617
|
this.deps = deps;
|
|
32599
32618
|
}
|
|
32600
|
-
async submitScore(gameId, userId, input, sessionId) {
|
|
32619
|
+
async submitScore(gameId, userId, input, isAnonymousUser, sessionId) {
|
|
32601
32620
|
const db2 = this.deps.db;
|
|
32602
32621
|
const game = await db2.select({ displayName: games.displayName }).from(games).where(eq(games.id, gameId)).limit(1).then((rows) => rows[0]);
|
|
32603
32622
|
if (!game) {
|
|
@@ -32608,7 +32627,7 @@ class LeaderboardService {
|
|
|
32608
32627
|
const prevBestScore = prevBestScoreRows[0]?.score ?? null;
|
|
32609
32628
|
let prevRank = null;
|
|
32610
32629
|
if (prevBestScore !== null && prevBestScore !== undefined) {
|
|
32611
|
-
const higherCountRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${prevBestScore}`));
|
|
32630
|
+
const higherCountRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${prevBestScore}`));
|
|
32612
32631
|
const higherCount = higherCountRows[0]?.count ?? 0;
|
|
32613
32632
|
prevRank = Number(higherCount) + 1;
|
|
32614
32633
|
}
|
|
@@ -32625,13 +32644,13 @@ class LeaderboardService {
|
|
|
32625
32644
|
}
|
|
32626
32645
|
const bestScoreRows = await db2.select({ score: sql`MAX(${gameScores.score})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId)));
|
|
32627
32646
|
const bestScore = bestScoreRows[0]?.score ?? input.score;
|
|
32628
|
-
const higherCountNowRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${bestScore}`));
|
|
32647
|
+
const higherCountNowRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${bestScore}`));
|
|
32629
32648
|
const higherCountNow = higherCountNowRows[0]?.count ?? 0;
|
|
32630
32649
|
const newRank = Number(higherCountNow) + 1;
|
|
32631
|
-
const totalPlayersRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(eq(gameScores.gameId, gameId));
|
|
32650
|
+
const totalPlayersRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser)));
|
|
32632
32651
|
const totalPlayers = Number(totalPlayersRows[0]?.count ?? 1);
|
|
32633
32652
|
const { shouldNotify, crossedIntoTop3, movedUpWithinTop3, isFirstScore, isPersonalBest } = shouldNotifyRankChange(prevRank, newRank, prevBestScore, input.score);
|
|
32634
|
-
if (shouldNotify) {
|
|
32653
|
+
if (shouldNotify && !isAnonymousUser) {
|
|
32635
32654
|
await this.publishScoreNotifications({
|
|
32636
32655
|
userId,
|
|
32637
32656
|
gameId,
|
|
@@ -32651,6 +32670,7 @@ class LeaderboardService {
|
|
|
32651
32670
|
logger21.info("Score submitted", {
|
|
32652
32671
|
gameId,
|
|
32653
32672
|
userId,
|
|
32673
|
+
isAnonymousUser,
|
|
32654
32674
|
score: input.score,
|
|
32655
32675
|
newRank,
|
|
32656
32676
|
isFirstScore,
|
|
@@ -32727,7 +32747,7 @@ class LeaderboardService {
|
|
|
32727
32747
|
logger21.warn("Failed to publish notification", { error });
|
|
32728
32748
|
}
|
|
32729
32749
|
}
|
|
32730
|
-
async getLeaderboard(gameId, query) {
|
|
32750
|
+
async getLeaderboard(gameId, query, isAnonymousUser) {
|
|
32731
32751
|
const { timeframe, limit, offset } = query;
|
|
32732
32752
|
const db2 = this.deps.db;
|
|
32733
32753
|
const dateFilter = getTimeframeFilter(timeframe);
|
|
@@ -32739,31 +32759,35 @@ class LeaderboardService {
|
|
|
32739
32759
|
score: gameScores.score,
|
|
32740
32760
|
achievedAt: gameScores.achievedAt,
|
|
32741
32761
|
metadata: gameScores.metadata
|
|
32742
|
-
}).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), dateFilter)).orderBy(desc(gameScores.score)).limit(limit).offset(offset);
|
|
32762
|
+
}).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), dateFilter, eq(users.isAnonymous, isAnonymousUser))).orderBy(desc(gameScores.score)).limit(limit).offset(offset);
|
|
32743
32763
|
return scores.map((score, index2) => ({
|
|
32744
32764
|
rank: offset + index2 + 1,
|
|
32745
32765
|
userId: score.userId,
|
|
32746
|
-
username: score.
|
|
32766
|
+
username: score.name || score.username || "Unknown User",
|
|
32747
32767
|
userImage: score.userImage,
|
|
32748
32768
|
score: score.score,
|
|
32749
32769
|
achievedAt: score.achievedAt,
|
|
32750
32770
|
metadata: score.metadata
|
|
32751
32771
|
}));
|
|
32752
32772
|
}
|
|
32753
|
-
async getGlobalLeaderboard(gameId, query) {
|
|
32773
|
+
async getGlobalLeaderboard(gameId, query, isAnonymousUser) {
|
|
32754
32774
|
if (!gameId) {
|
|
32755
32775
|
return [];
|
|
32756
32776
|
}
|
|
32757
32777
|
const { timeframe, limit, offset } = query;
|
|
32758
32778
|
const db2 = this.deps.db;
|
|
32759
32779
|
const dateFilter = getTimeframeFilter(timeframe);
|
|
32760
|
-
const conditions2 = [
|
|
32780
|
+
const conditions2 = [
|
|
32781
|
+
dateFilter,
|
|
32782
|
+
eq(gameScores.gameId, gameId),
|
|
32783
|
+
eq(users.isAnonymous, isAnonymousUser)
|
|
32784
|
+
];
|
|
32761
32785
|
const bestScoresSubquery = db2.select({
|
|
32762
32786
|
userId: gameScores.userId,
|
|
32763
32787
|
gameId: gameScores.gameId,
|
|
32764
32788
|
score: sql`MAX(${gameScores.score})`.as("max_score"),
|
|
32765
32789
|
achievedAt: sql`MAX(${gameScores.achievedAt})`.as("max_achieved_at")
|
|
32766
|
-
}).from(gameScores).where(and(...conditions2)).groupBy(gameScores.userId, gameScores.gameId).as("best_scores");
|
|
32790
|
+
}).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(...conditions2)).groupBy(gameScores.userId, gameScores.gameId).as("best_scores");
|
|
32767
32791
|
const scores = await db2.select({
|
|
32768
32792
|
userId: users.id,
|
|
32769
32793
|
username: users.username,
|
|
@@ -32779,7 +32803,7 @@ class LeaderboardService {
|
|
|
32779
32803
|
return scores.map((score, index2) => ({
|
|
32780
32804
|
rank: offset + index2 + 1,
|
|
32781
32805
|
userId: score.userId,
|
|
32782
|
-
username: score.
|
|
32806
|
+
username: score.name || score.username || "Unknown User",
|
|
32783
32807
|
userImage: score.userImage,
|
|
32784
32808
|
score: score.score,
|
|
32785
32809
|
achievedAt: score.achievedAt,
|
|
@@ -32789,15 +32813,15 @@ class LeaderboardService {
|
|
|
32789
32813
|
gameSlug: score.gameSlug || ""
|
|
32790
32814
|
}));
|
|
32791
32815
|
}
|
|
32792
|
-
async getUserRank(gameId, userId) {
|
|
32816
|
+
async getUserRank(gameId, userId, isAnonymousUser) {
|
|
32793
32817
|
const db2 = this.deps.db;
|
|
32794
|
-
const userScoreResult = await db2.select({ score: gameScores.score }).from(gameScores).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId))).orderBy(desc(gameScores.score)).limit(1);
|
|
32818
|
+
const userScoreResult = await db2.select({ score: gameScores.score }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId), eq(users.isAnonymous, isAnonymousUser))).orderBy(desc(gameScores.score)).limit(1);
|
|
32795
32819
|
if (!userScoreResult.length || !userScoreResult[0]) {
|
|
32796
32820
|
return null;
|
|
32797
32821
|
}
|
|
32798
32822
|
const score = userScoreResult[0].score;
|
|
32799
|
-
const countResult = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.score} > ${score}`));
|
|
32800
|
-
const totalResult = await db2.select({ total: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(eq(gameScores.gameId, gameId));
|
|
32823
|
+
const countResult = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.score} > ${score}`));
|
|
32824
|
+
const totalResult = await db2.select({ total: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser)));
|
|
32801
32825
|
const count = Number(countResult[0]?.count ?? 0);
|
|
32802
32826
|
const total = Number(totalResult[0]?.total ?? 0);
|
|
32803
32827
|
const rank = count + 1;
|
|
@@ -34250,6 +34274,35 @@ class UserService {
|
|
|
34250
34274
|
timeback: timeback2
|
|
34251
34275
|
};
|
|
34252
34276
|
}
|
|
34277
|
+
async getDemoProfile(userId) {
|
|
34278
|
+
const userData = await this.deps.db.query.users.findFirst({
|
|
34279
|
+
where: eq(users.id, userId),
|
|
34280
|
+
columns: { name: true }
|
|
34281
|
+
});
|
|
34282
|
+
if (!userData) {
|
|
34283
|
+
logger32.error("Demo user not found", { userId });
|
|
34284
|
+
throw new NotFoundError("User", userId);
|
|
34285
|
+
}
|
|
34286
|
+
return {
|
|
34287
|
+
displayName: userData.name,
|
|
34288
|
+
isDefault: userData.name === DEMO_DISPLAY_NAME_PLACEHOLDER
|
|
34289
|
+
};
|
|
34290
|
+
}
|
|
34291
|
+
async updateDemoProfile(userId, displayName) {
|
|
34292
|
+
const [updatedUser] = await this.deps.db.update(users).set({
|
|
34293
|
+
name: displayName,
|
|
34294
|
+
updatedAt: new Date
|
|
34295
|
+
}).where(eq(users.id, userId)).returning({ name: users.name });
|
|
34296
|
+
if (!updatedUser) {
|
|
34297
|
+
logger32.error("Demo user not found for profile update", { userId });
|
|
34298
|
+
throw new NotFoundError("User", userId);
|
|
34299
|
+
}
|
|
34300
|
+
logger32.debug("Updated demo profile", { userId, displayName });
|
|
34301
|
+
return {
|
|
34302
|
+
displayName: updatedUser.name,
|
|
34303
|
+
isDefault: updatedUser.name === DEMO_DISPLAY_NAME_PLACEHOLDER
|
|
34304
|
+
};
|
|
34305
|
+
}
|
|
34253
34306
|
async fetchTimebackData(timebackId, gameId) {
|
|
34254
34307
|
const [{ role, organizations: allOrganizations }, allEnrollments] = await Promise.all([
|
|
34255
34308
|
this.fetchStudentProfile(timebackId),
|
|
@@ -34342,6 +34395,7 @@ class UserService {
|
|
|
34342
34395
|
var logger32;
|
|
34343
34396
|
var init_user_service = __esm(() => {
|
|
34344
34397
|
init_drizzle_orm();
|
|
34398
|
+
init_src();
|
|
34345
34399
|
init_tables_index();
|
|
34346
34400
|
init_src2();
|
|
34347
34401
|
init_errors();
|
|
@@ -93410,7 +93464,10 @@ var init_drizzle_zod = __esm(() => {
|
|
|
93410
93464
|
});
|
|
93411
93465
|
|
|
93412
93466
|
// ../data/src/domains/user/schemas.ts
|
|
93413
|
-
|
|
93467
|
+
function normalizeDisplayName(value) {
|
|
93468
|
+
return value.trim().replace(/\s+/g, " ");
|
|
93469
|
+
}
|
|
93470
|
+
var InsertUserSchema, DemoProfileSchema;
|
|
93414
93471
|
var init_schemas = __esm(() => {
|
|
93415
93472
|
init_drizzle_zod();
|
|
93416
93473
|
init_esm();
|
|
@@ -93419,6 +93476,9 @@ var init_schemas = __esm(() => {
|
|
|
93419
93476
|
email: exports_external.string().email(),
|
|
93420
93477
|
name: exports_external.string().optional()
|
|
93421
93478
|
});
|
|
93479
|
+
DemoProfileSchema = exports_external.object({
|
|
93480
|
+
displayName: exports_external.string().transform(normalizeDisplayName).refine((value) => value.length >= 2, "Display name must be at least 2 characters").refine((value) => value.length <= 12, "Display name must be 12 characters or fewer")
|
|
93481
|
+
});
|
|
93422
93482
|
});
|
|
93423
93483
|
|
|
93424
93484
|
// ../data/src/domains/game/schemas.ts
|
|
@@ -94036,6 +94096,28 @@ function requireAuth(handler) {
|
|
|
94036
94096
|
return handler(ctx);
|
|
94037
94097
|
};
|
|
94038
94098
|
}
|
|
94099
|
+
function requireNonAnonymous(handler) {
|
|
94100
|
+
return async (ctx) => {
|
|
94101
|
+
if (!isAuthenticated(ctx)) {
|
|
94102
|
+
throw ApiError.unauthorized("Valid session or bearer token required");
|
|
94103
|
+
}
|
|
94104
|
+
if (ctx.user.isAnonymous) {
|
|
94105
|
+
throw ApiError.forbidden("This operation is not available for demo/anonymous users");
|
|
94106
|
+
}
|
|
94107
|
+
return handler(ctx);
|
|
94108
|
+
};
|
|
94109
|
+
}
|
|
94110
|
+
function requireAnonymous(handler) {
|
|
94111
|
+
return async (ctx) => {
|
|
94112
|
+
if (!isAuthenticated(ctx)) {
|
|
94113
|
+
throw ApiError.unauthorized("Valid session or bearer token required");
|
|
94114
|
+
}
|
|
94115
|
+
if (!ctx.user.isAnonymous) {
|
|
94116
|
+
throw ApiError.forbidden("This operation is only available for demo/anonymous users");
|
|
94117
|
+
}
|
|
94118
|
+
return handler(ctx);
|
|
94119
|
+
};
|
|
94120
|
+
}
|
|
94039
94121
|
function requireRole(roles2, handler) {
|
|
94040
94122
|
return async (ctx) => {
|
|
94041
94123
|
if (!isAuthenticated(ctx)) {
|
|
@@ -94276,16 +94358,16 @@ var init_achievement_controller = __esm(() => {
|
|
|
94276
94358
|
init_errors();
|
|
94277
94359
|
init_utils11();
|
|
94278
94360
|
logger37 = log.scope("AchievementController");
|
|
94279
|
-
listCurrent =
|
|
94361
|
+
listCurrent = requireNonAnonymous(async (ctx) => {
|
|
94280
94362
|
logger37.debug("Listing current achievements", { userId: ctx.user.id, gameId: ctx.gameId });
|
|
94281
94363
|
return ctx.services.achievement.listCurrent(ctx.user, ctx.gameId);
|
|
94282
94364
|
});
|
|
94283
|
-
listHistory =
|
|
94365
|
+
listHistory = requireNonAnonymous(async (ctx) => {
|
|
94284
94366
|
const limit = Math.max(1, Math.min(100, Number(ctx.url.searchParams.get("limit")) || 20));
|
|
94285
94367
|
logger37.debug("Listing achievement history", { userId: ctx.user.id, limit });
|
|
94286
94368
|
return ctx.services.achievement.listHistory(ctx.user, limit);
|
|
94287
94369
|
});
|
|
94288
|
-
postProgress =
|
|
94370
|
+
postProgress = requireNonAnonymous(async (ctx) => {
|
|
94289
94371
|
let body2;
|
|
94290
94372
|
try {
|
|
94291
94373
|
const json4 = await ctx.request.json();
|
|
@@ -94439,11 +94521,11 @@ var init_character_controller = __esm(() => {
|
|
|
94439
94521
|
init_errors();
|
|
94440
94522
|
init_utils11();
|
|
94441
94523
|
logger40 = log.scope("CharacterController");
|
|
94442
|
-
get =
|
|
94524
|
+
get = requireNonAnonymous(async (ctx) => {
|
|
94443
94525
|
logger40.debug("Getting character", { userId: ctx.user.id });
|
|
94444
94526
|
return ctx.services.character.getByUser(ctx.user);
|
|
94445
94527
|
});
|
|
94446
|
-
getByUserId =
|
|
94528
|
+
getByUserId = requireNonAnonymous(async (ctx) => {
|
|
94447
94529
|
const userId = ctx.params.userId;
|
|
94448
94530
|
if (!userId) {
|
|
94449
94531
|
throw ApiError.badRequest("User ID is required in the URL path");
|
|
@@ -94451,7 +94533,7 @@ var init_character_controller = __esm(() => {
|
|
|
94451
94533
|
logger40.debug("Getting character by user ID", { requestedUserId: userId });
|
|
94452
94534
|
return ctx.services.character.getByUserId(userId);
|
|
94453
94535
|
});
|
|
94454
|
-
create =
|
|
94536
|
+
create = requireNonAnonymous(async (ctx) => {
|
|
94455
94537
|
let body2;
|
|
94456
94538
|
try {
|
|
94457
94539
|
const json4 = await ctx.request.json();
|
|
@@ -94471,7 +94553,7 @@ var init_character_controller = __esm(() => {
|
|
|
94471
94553
|
});
|
|
94472
94554
|
return ctx.services.character.create(body2, ctx.user);
|
|
94473
94555
|
});
|
|
94474
|
-
update2 =
|
|
94556
|
+
update2 = requireNonAnonymous(async (ctx) => {
|
|
94475
94557
|
let body2;
|
|
94476
94558
|
try {
|
|
94477
94559
|
const json4 = await ctx.request.json();
|
|
@@ -94492,7 +94574,7 @@ var init_character_controller = __esm(() => {
|
|
|
94492
94574
|
});
|
|
94493
94575
|
return ctx.services.character.update(body2, ctx.user);
|
|
94494
94576
|
});
|
|
94495
|
-
equipAccessory =
|
|
94577
|
+
equipAccessory = requireNonAnonymous(async (ctx) => {
|
|
94496
94578
|
let body2;
|
|
94497
94579
|
try {
|
|
94498
94580
|
const json4 = await ctx.request.json();
|
|
@@ -94512,7 +94594,7 @@ var init_character_controller = __esm(() => {
|
|
|
94512
94594
|
});
|
|
94513
94595
|
return ctx.services.character.equipAccessory(body2.slot, body2.accessoryComponentId, ctx.user);
|
|
94514
94596
|
});
|
|
94515
|
-
removeAccessory =
|
|
94597
|
+
removeAccessory = requireNonAnonymous(async (ctx) => {
|
|
94516
94598
|
const slot = ctx.params.slot;
|
|
94517
94599
|
if (!slot) {
|
|
94518
94600
|
throw ApiError.badRequest("Slot is required in the URL path");
|
|
@@ -94542,11 +94624,11 @@ var init_currency_controller = __esm(() => {
|
|
|
94542
94624
|
init_errors();
|
|
94543
94625
|
init_utils11();
|
|
94544
94626
|
logger41 = log.scope("CurrencyController");
|
|
94545
|
-
list =
|
|
94627
|
+
list = requireNonAnonymous(async (ctx) => {
|
|
94546
94628
|
logger41.debug("Listing currencies", { userId: ctx.user.id });
|
|
94547
94629
|
return ctx.services.currency.list();
|
|
94548
94630
|
});
|
|
94549
|
-
getById =
|
|
94631
|
+
getById = requireNonAnonymous(async (ctx) => {
|
|
94550
94632
|
const currencyId = ctx.params.currencyId;
|
|
94551
94633
|
if (!currencyId) {
|
|
94552
94634
|
throw ApiError.badRequest("Missing currency ID");
|
|
@@ -94721,11 +94803,11 @@ var init_developer_controller = __esm(() => {
|
|
|
94721
94803
|
init_src2();
|
|
94722
94804
|
init_utils11();
|
|
94723
94805
|
logger44 = log.scope("DeveloperController");
|
|
94724
|
-
apply =
|
|
94806
|
+
apply = requireNonAnonymous(async (ctx) => {
|
|
94725
94807
|
logger44.debug("Applying for developer status", { userId: ctx.user.id });
|
|
94726
94808
|
await ctx.services.developer.apply(ctx.user);
|
|
94727
94809
|
});
|
|
94728
|
-
getStatus =
|
|
94810
|
+
getStatus = requireNonAnonymous(async (ctx) => {
|
|
94729
94811
|
logger44.debug("Getting developer status", { userId: ctx.user.id });
|
|
94730
94812
|
const status = await ctx.services.developer.getStatus(ctx.user.id);
|
|
94731
94813
|
return { status };
|
|
@@ -94827,19 +94909,19 @@ var init_game_controller = __esm(() => {
|
|
|
94827
94909
|
init_errors();
|
|
94828
94910
|
init_utils11();
|
|
94829
94911
|
logger46 = log.scope("GameController");
|
|
94830
|
-
list3 =
|
|
94912
|
+
list3 = requireNonAnonymous(async (ctx) => {
|
|
94831
94913
|
logger46.debug("Listing games", { userId: ctx.user.id });
|
|
94832
94914
|
return ctx.services.game.list(ctx.user);
|
|
94833
94915
|
});
|
|
94834
|
-
listManageable =
|
|
94916
|
+
listManageable = requireNonAnonymous(async (ctx) => {
|
|
94835
94917
|
logger46.debug("Listing manageable games", { userId: ctx.user.id });
|
|
94836
94918
|
return ctx.services.game.listManageable(ctx.user);
|
|
94837
94919
|
});
|
|
94838
|
-
getSubjects =
|
|
94920
|
+
getSubjects = requireNonAnonymous(async (ctx) => {
|
|
94839
94921
|
logger46.debug("Getting game subjects", { userId: ctx.user.id });
|
|
94840
94922
|
return ctx.services.game.getSubjects();
|
|
94841
94923
|
});
|
|
94842
|
-
getById2 =
|
|
94924
|
+
getById2 = requireNonAnonymous(async (ctx) => {
|
|
94843
94925
|
const gameId = ctx.params.gameId;
|
|
94844
94926
|
if (!gameId) {
|
|
94845
94927
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -94850,7 +94932,7 @@ var init_game_controller = __esm(() => {
|
|
|
94850
94932
|
logger46.debug("Getting game by ID", { userId: ctx.user.id, gameId, launchId: ctx.launchId });
|
|
94851
94933
|
return ctx.services.game.getById(gameId, ctx.user);
|
|
94852
94934
|
});
|
|
94853
|
-
getBySlug =
|
|
94935
|
+
getBySlug = requireNonAnonymous(async (ctx) => {
|
|
94854
94936
|
const slug2 = ctx.params.slug;
|
|
94855
94937
|
if (!slug2) {
|
|
94856
94938
|
throw ApiError.badRequest("Missing game slug");
|
|
@@ -94858,7 +94940,7 @@ var init_game_controller = __esm(() => {
|
|
|
94858
94940
|
logger46.debug("Getting game by slug", { userId: ctx.user.id, slug: slug2, launchId: ctx.launchId });
|
|
94859
94941
|
return ctx.services.game.getBySlug(slug2, ctx.user);
|
|
94860
94942
|
});
|
|
94861
|
-
getManifest =
|
|
94943
|
+
getManifest = requireNonAnonymous(async (ctx) => {
|
|
94862
94944
|
const gameId = ctx.params.gameId;
|
|
94863
94945
|
if (!gameId) {
|
|
94864
94946
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -94873,7 +94955,7 @@ var init_game_controller = __esm(() => {
|
|
|
94873
94955
|
});
|
|
94874
94956
|
return ctx.services.game.getManifest(gameId, ctx.user);
|
|
94875
94957
|
});
|
|
94876
|
-
upsertBySlug =
|
|
94958
|
+
upsertBySlug = requireNonAnonymous(async (ctx) => {
|
|
94877
94959
|
const slug2 = ctx.params.slug;
|
|
94878
94960
|
if (!slug2) {
|
|
94879
94961
|
throw ApiError.badRequest("Missing game slug");
|
|
@@ -94893,7 +94975,7 @@ var init_game_controller = __esm(() => {
|
|
|
94893
94975
|
logger46.debug("Upserting game", { userId: ctx.user.id, slug: slug2, displayName: body2.displayName });
|
|
94894
94976
|
return ctx.services.game.upsertBySlug(slug2, body2, ctx.user);
|
|
94895
94977
|
});
|
|
94896
|
-
remove3 =
|
|
94978
|
+
remove3 = requireNonAnonymous(async (ctx) => {
|
|
94897
94979
|
const gameId = ctx.params.gameId;
|
|
94898
94980
|
if (!gameId) {
|
|
94899
94981
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -94925,11 +95007,11 @@ var init_inventory_controller = __esm(() => {
|
|
|
94925
95007
|
init_errors();
|
|
94926
95008
|
init_utils11();
|
|
94927
95009
|
logger47 = log.scope("InventoryController");
|
|
94928
|
-
list4 =
|
|
95010
|
+
list4 = requireNonAnonymous(async (ctx) => {
|
|
94929
95011
|
logger47.debug("Listing inventory", { userId: ctx.user.id });
|
|
94930
95012
|
return ctx.services.inventory.list(ctx.user);
|
|
94931
95013
|
});
|
|
94932
|
-
addItem =
|
|
95014
|
+
addItem = requireNonAnonymous(async (ctx) => {
|
|
94933
95015
|
let body2;
|
|
94934
95016
|
try {
|
|
94935
95017
|
const json4 = await ctx.request.json();
|
|
@@ -94949,7 +95031,7 @@ var init_inventory_controller = __esm(() => {
|
|
|
94949
95031
|
});
|
|
94950
95032
|
return ctx.services.inventory.addItem(body2.itemId, body2.qty, ctx.user);
|
|
94951
95033
|
});
|
|
94952
|
-
removeItem =
|
|
95034
|
+
removeItem = requireNonAnonymous(async (ctx) => {
|
|
94953
95035
|
let body2;
|
|
94954
95036
|
try {
|
|
94955
95037
|
const json4 = await ctx.request.json();
|
|
@@ -94986,12 +95068,12 @@ var init_item_controller = __esm(() => {
|
|
|
94986
95068
|
init_errors();
|
|
94987
95069
|
init_utils11();
|
|
94988
95070
|
logger48 = log.scope("ItemController");
|
|
94989
|
-
list5 =
|
|
95071
|
+
list5 = requireNonAnonymous(async (ctx) => {
|
|
94990
95072
|
const gameId = ctx.url.searchParams.get("gameId") || undefined;
|
|
94991
95073
|
logger48.debug("Listing items", { userId: ctx.user.id, gameId });
|
|
94992
95074
|
return ctx.services.item.list(gameId);
|
|
94993
95075
|
});
|
|
94994
|
-
getById3 =
|
|
95076
|
+
getById3 = requireNonAnonymous(async (ctx) => {
|
|
94995
95077
|
const itemId = ctx.params.itemId;
|
|
94996
95078
|
if (!itemId) {
|
|
94997
95079
|
throw ApiError.badRequest("Missing item ID");
|
|
@@ -95002,7 +95084,7 @@ var init_item_controller = __esm(() => {
|
|
|
95002
95084
|
logger48.debug("Getting item", { userId: ctx.user.id, itemId });
|
|
95003
95085
|
return ctx.services.item.getById(itemId);
|
|
95004
95086
|
});
|
|
95005
|
-
resolve2 =
|
|
95087
|
+
resolve2 = requireNonAnonymous(async (ctx) => {
|
|
95006
95088
|
const slug2 = ctx.url.searchParams.get("slug");
|
|
95007
95089
|
const gameId = ctx.url.searchParams.get("gameId") || undefined;
|
|
95008
95090
|
if (!slug2) {
|
|
@@ -95077,7 +95159,7 @@ var init_item_controller = __esm(() => {
|
|
|
95077
95159
|
logger48.debug("Deleting item", { userId: ctx.user.id, itemId });
|
|
95078
95160
|
await ctx.services.item.delete(itemId);
|
|
95079
95161
|
});
|
|
95080
|
-
listByGame =
|
|
95162
|
+
listByGame = requireNonAnonymous(async (ctx) => {
|
|
95081
95163
|
const gameId = ctx.params.gameId;
|
|
95082
95164
|
if (!gameId) {
|
|
95083
95165
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -95088,7 +95170,7 @@ var init_item_controller = __esm(() => {
|
|
|
95088
95170
|
logger48.debug("Listing game items", { userId: ctx.user.id, gameId });
|
|
95089
95171
|
return ctx.services.item.listByGame(gameId);
|
|
95090
95172
|
});
|
|
95091
|
-
createForGame =
|
|
95173
|
+
createForGame = requireNonAnonymous(async (ctx) => {
|
|
95092
95174
|
const gameId = ctx.params.gameId;
|
|
95093
95175
|
if (!gameId) {
|
|
95094
95176
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -95116,7 +95198,7 @@ var init_item_controller = __esm(() => {
|
|
|
95116
95198
|
});
|
|
95117
95199
|
return ctx.services.item.createForGame(gameId, body2, ctx.user);
|
|
95118
95200
|
});
|
|
95119
|
-
updateForGame =
|
|
95201
|
+
updateForGame = requireNonAnonymous(async (ctx) => {
|
|
95120
95202
|
const gameId = ctx.params.gameId;
|
|
95121
95203
|
const itemId = ctx.params.itemId;
|
|
95122
95204
|
if (!gameId || !itemId) {
|
|
@@ -95153,7 +95235,7 @@ var init_item_controller = __esm(() => {
|
|
|
95153
95235
|
});
|
|
95154
95236
|
return ctx.services.item.updateForGame(gameId, itemId, body2, ctx.user);
|
|
95155
95237
|
});
|
|
95156
|
-
deleteForGame =
|
|
95238
|
+
deleteForGame = requireNonAnonymous(async (ctx) => {
|
|
95157
95239
|
const gameId = ctx.params.gameId;
|
|
95158
95240
|
const itemId = ctx.params.itemId;
|
|
95159
95241
|
if (!gameId || !itemId) {
|
|
@@ -95317,7 +95399,7 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
95317
95399
|
gameId,
|
|
95318
95400
|
score: body2.score
|
|
95319
95401
|
});
|
|
95320
|
-
return ctx.services.leaderboard.submitScore(gameId, ctx.user.id, { score: body2.score, metadata: body2.metadata }, ctx.params.sessionId);
|
|
95402
|
+
return ctx.services.leaderboard.submitScore(gameId, ctx.user.id, { score: body2.score, metadata: body2.metadata }, ctx.user.isAnonymous, ctx.params.sessionId);
|
|
95321
95403
|
});
|
|
95322
95404
|
getGlobalLeaderboard = requireAuth(async (ctx) => {
|
|
95323
95405
|
const url = ctx.url;
|
|
@@ -95345,7 +95427,7 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
95345
95427
|
gameId,
|
|
95346
95428
|
...query
|
|
95347
95429
|
});
|
|
95348
|
-
return ctx.services.leaderboard.getGlobalLeaderboard(gameId, query);
|
|
95430
|
+
return ctx.services.leaderboard.getGlobalLeaderboard(gameId, query, ctx.user.isAnonymous);
|
|
95349
95431
|
});
|
|
95350
95432
|
getLeaderboard = requireAuth(async (ctx) => {
|
|
95351
95433
|
const gameId = ctx.params.gameId;
|
|
@@ -95373,9 +95455,9 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
95373
95455
|
gameId,
|
|
95374
95456
|
...query
|
|
95375
95457
|
});
|
|
95376
|
-
return ctx.services.leaderboard.getLeaderboard(gameId, query);
|
|
95458
|
+
return ctx.services.leaderboard.getLeaderboard(gameId, query, ctx.user.isAnonymous);
|
|
95377
95459
|
});
|
|
95378
|
-
getUserRank =
|
|
95460
|
+
getUserRank = requireNonAnonymous(async (ctx) => {
|
|
95379
95461
|
const { gameId, userId } = ctx.params;
|
|
95380
95462
|
if (!gameId || !userId) {
|
|
95381
95463
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
@@ -95385,9 +95467,9 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
95385
95467
|
gameId,
|
|
95386
95468
|
targetUserId: userId
|
|
95387
95469
|
});
|
|
95388
|
-
return ctx.services.leaderboard.getUserRank(gameId, userId);
|
|
95470
|
+
return ctx.services.leaderboard.getUserRank(gameId, userId, ctx.user.isAnonymous);
|
|
95389
95471
|
});
|
|
95390
|
-
getUserAllScores =
|
|
95472
|
+
getUserAllScores = requireNonAnonymous(async (ctx) => {
|
|
95391
95473
|
const userId = ctx.params.userId;
|
|
95392
95474
|
if (!userId) {
|
|
95393
95475
|
throw ApiError.badRequest("User ID is required");
|
|
@@ -95403,7 +95485,7 @@ var init_leaderboard_controller = __esm(() => {
|
|
|
95403
95485
|
});
|
|
95404
95486
|
return ctx.services.leaderboard.getUserAllScores(userId, { limit, gameId });
|
|
95405
95487
|
});
|
|
95406
|
-
getUserScores =
|
|
95488
|
+
getUserScores = requireNonAnonymous(async (ctx) => {
|
|
95407
95489
|
const { gameId, userId } = ctx.params;
|
|
95408
95490
|
if (!gameId || !userId) {
|
|
95409
95491
|
throw ApiError.badRequest("Game ID and User ID are required");
|
|
@@ -95451,11 +95533,11 @@ var init_level_controller = __esm(() => {
|
|
|
95451
95533
|
init_errors();
|
|
95452
95534
|
init_utils11();
|
|
95453
95535
|
logger51 = log.scope("LevelController");
|
|
95454
|
-
getByUser =
|
|
95536
|
+
getByUser = requireNonAnonymous(async (ctx) => {
|
|
95455
95537
|
logger51.debug("Getting user level", { userId: ctx.user.id });
|
|
95456
95538
|
return ctx.services.level.getByUser(ctx.user);
|
|
95457
95539
|
});
|
|
95458
|
-
getProgress =
|
|
95540
|
+
getProgress = requireNonAnonymous(async (ctx) => {
|
|
95459
95541
|
logger51.debug("Getting level progress", { userId: ctx.user.id });
|
|
95460
95542
|
return ctx.services.level.getProgress(ctx.user);
|
|
95461
95543
|
});
|
|
@@ -95510,7 +95592,7 @@ var init_lti_controller = __esm(() => {
|
|
|
95510
95592
|
init_src2();
|
|
95511
95593
|
init_utils11();
|
|
95512
95594
|
logger53 = log.scope("LtiController");
|
|
95513
|
-
getStatus3 =
|
|
95595
|
+
getStatus3 = requireNonAnonymous(async (ctx) => {
|
|
95514
95596
|
logger53.debug("Getting status", { userId: ctx.user.id });
|
|
95515
95597
|
return ctx.services.lti.getStatus(ctx.user);
|
|
95516
95598
|
});
|
|
@@ -95529,7 +95611,7 @@ var init_map_controller = __esm(() => {
|
|
|
95529
95611
|
init_errors();
|
|
95530
95612
|
init_utils11();
|
|
95531
95613
|
logger54 = log.scope("MapController");
|
|
95532
|
-
getByIdentifier =
|
|
95614
|
+
getByIdentifier = requireNonAnonymous(async (ctx) => {
|
|
95533
95615
|
const identifier = ctx.params.identifier;
|
|
95534
95616
|
if (!identifier) {
|
|
95535
95617
|
throw ApiError.badRequest("Missing map identifier");
|
|
@@ -95537,7 +95619,7 @@ var init_map_controller = __esm(() => {
|
|
|
95537
95619
|
logger54.debug("Getting map", { userId: ctx.user.id, identifier });
|
|
95538
95620
|
return ctx.services.map.getByIdentifier(identifier);
|
|
95539
95621
|
});
|
|
95540
|
-
getElements =
|
|
95622
|
+
getElements = requireNonAnonymous(async (ctx) => {
|
|
95541
95623
|
const mapId = ctx.url.searchParams.get("mapId");
|
|
95542
95624
|
if (!mapId) {
|
|
95543
95625
|
throw ApiError.badRequest("Missing required query parameter: mapId");
|
|
@@ -95548,7 +95630,7 @@ var init_map_controller = __esm(() => {
|
|
|
95548
95630
|
logger54.debug("Getting map elements", { userId: ctx.user.id, mapId });
|
|
95549
95631
|
return ctx.services.map.getElements(mapId);
|
|
95550
95632
|
});
|
|
95551
|
-
getObjects =
|
|
95633
|
+
getObjects = requireNonAnonymous(async (ctx) => {
|
|
95552
95634
|
const mapId = ctx.params.mapId;
|
|
95553
95635
|
if (!mapId) {
|
|
95554
95636
|
throw ApiError.badRequest("Missing mapId");
|
|
@@ -95559,7 +95641,7 @@ var init_map_controller = __esm(() => {
|
|
|
95559
95641
|
logger54.debug("Getting map objects", { userId: ctx.user.id, mapId });
|
|
95560
95642
|
return ctx.services.map.getObjects(mapId, ctx.user.id);
|
|
95561
95643
|
});
|
|
95562
|
-
createObject =
|
|
95644
|
+
createObject = requireNonAnonymous(async (ctx) => {
|
|
95563
95645
|
const mapId = ctx.params.mapId;
|
|
95564
95646
|
if (!mapId) {
|
|
95565
95647
|
throw ApiError.badRequest("Missing mapId");
|
|
@@ -95593,7 +95675,7 @@ var init_map_controller = __esm(() => {
|
|
|
95593
95675
|
const { mapId: _mapId, ...data } = body2;
|
|
95594
95676
|
return ctx.services.map.createObject(mapId, data, ctx.user);
|
|
95595
95677
|
});
|
|
95596
|
-
deleteObject =
|
|
95678
|
+
deleteObject = requireNonAnonymous(async (ctx) => {
|
|
95597
95679
|
const { mapId, objectId } = ctx.params;
|
|
95598
95680
|
if (!mapId) {
|
|
95599
95681
|
throw ApiError.badRequest("Missing mapId");
|
|
@@ -95628,7 +95710,7 @@ var init_notification_controller = __esm(() => {
|
|
|
95628
95710
|
init_errors();
|
|
95629
95711
|
init_utils11();
|
|
95630
95712
|
logger55 = log.scope("NotificationController");
|
|
95631
|
-
list6 =
|
|
95713
|
+
list6 = requireNonAnonymous(async (ctx) => {
|
|
95632
95714
|
const query = {
|
|
95633
95715
|
status: ctx.url.searchParams.get("status") || undefined,
|
|
95634
95716
|
type: ctx.url.searchParams.get("type") || undefined,
|
|
@@ -95644,7 +95726,7 @@ var init_notification_controller = __esm(() => {
|
|
|
95644
95726
|
logger55.debug("Listing notifications", { userId: ctx.user.id, ...result.data });
|
|
95645
95727
|
return ctx.services.notification.list(ctx.user, result.data);
|
|
95646
95728
|
});
|
|
95647
|
-
updateStatus =
|
|
95729
|
+
updateStatus = requireNonAnonymous(async (ctx) => {
|
|
95648
95730
|
const notificationId = ctx.params.notificationId;
|
|
95649
95731
|
if (!notificationId) {
|
|
95650
95732
|
throw ApiError.badRequest("Notification ID required");
|
|
@@ -95668,7 +95750,7 @@ var init_notification_controller = __esm(() => {
|
|
|
95668
95750
|
});
|
|
95669
95751
|
return ctx.services.notification.updateStatus(notificationId, body2.status, body2.method);
|
|
95670
95752
|
});
|
|
95671
|
-
getStats2 =
|
|
95753
|
+
getStats2 = requireNonAnonymous(async (ctx) => {
|
|
95672
95754
|
const startDate = ctx.url.searchParams.get("startDate");
|
|
95673
95755
|
const endDate = ctx.url.searchParams.get("endDate");
|
|
95674
95756
|
logger55.debug("Getting stats", { userId: ctx.user.id, startDate, endDate });
|
|
@@ -95677,7 +95759,7 @@ var init_notification_controller = __esm(() => {
|
|
|
95677
95759
|
endDate: endDate ? new Date(endDate) : undefined
|
|
95678
95760
|
});
|
|
95679
95761
|
});
|
|
95680
|
-
create4 =
|
|
95762
|
+
create4 = requireNonAnonymous(async (ctx) => {
|
|
95681
95763
|
let body2;
|
|
95682
95764
|
try {
|
|
95683
95765
|
const json4 = await ctx.request.json();
|
|
@@ -95707,7 +95789,7 @@ var init_notification_controller = __esm(() => {
|
|
|
95707
95789
|
metadata: body2.metadata
|
|
95708
95790
|
});
|
|
95709
95791
|
});
|
|
95710
|
-
deliver =
|
|
95792
|
+
deliver = requireNonAnonymous(async (ctx) => {
|
|
95711
95793
|
logger55.debug("Delivering notifications", { userId: ctx.user.id });
|
|
95712
95794
|
try {
|
|
95713
95795
|
await ctx.services.notification.deliverPending(ctx.user.id);
|
|
@@ -95732,7 +95814,7 @@ var init_realtime_controller = __esm(() => {
|
|
|
95732
95814
|
init_src2();
|
|
95733
95815
|
init_utils11();
|
|
95734
95816
|
logger56 = log.scope("RealtimeController");
|
|
95735
|
-
generateToken2 =
|
|
95817
|
+
generateToken2 = requireNonAnonymous(async (ctx) => {
|
|
95736
95818
|
const gameIdOrSlug = ctx.params.gameId;
|
|
95737
95819
|
logger56.debug("Generating token", {
|
|
95738
95820
|
userId: ctx.user.id,
|
|
@@ -95898,7 +95980,7 @@ var init_shop_controller = __esm(() => {
|
|
|
95898
95980
|
init_src2();
|
|
95899
95981
|
init_utils11();
|
|
95900
95982
|
logger60 = log.scope("ShopController");
|
|
95901
|
-
getShopView =
|
|
95983
|
+
getShopView = requireNonAnonymous(async (ctx) => {
|
|
95902
95984
|
logger60.debug("Getting shop view", { userId: ctx.user.id });
|
|
95903
95985
|
return ctx.services.shop.getShopView(ctx.user);
|
|
95904
95986
|
});
|
|
@@ -95993,7 +96075,7 @@ var init_shop_listing_controller = __esm(() => {
|
|
|
95993
96075
|
logger61.debug("Deleting listing", { userId: ctx.user.id, listingId });
|
|
95994
96076
|
await ctx.services.shopListing.delete(listingId);
|
|
95995
96077
|
});
|
|
95996
|
-
listByGame2 =
|
|
96078
|
+
listByGame2 = requireNonAnonymous(async (ctx) => {
|
|
95997
96079
|
const gameId = ctx.params.gameId;
|
|
95998
96080
|
if (!gameId) {
|
|
95999
96081
|
throw ApiError.badRequest("Missing game ID");
|
|
@@ -96004,7 +96086,7 @@ var init_shop_listing_controller = __esm(() => {
|
|
|
96004
96086
|
logger61.debug("Listing game listings", { userId: ctx.user.id, gameId });
|
|
96005
96087
|
return ctx.services.shopListing.listByGame(gameId, ctx.user);
|
|
96006
96088
|
});
|
|
96007
|
-
getByGameItem =
|
|
96089
|
+
getByGameItem = requireNonAnonymous(async (ctx) => {
|
|
96008
96090
|
const gameId = ctx.params.gameId;
|
|
96009
96091
|
const itemId = ctx.params.itemId;
|
|
96010
96092
|
if (!gameId || !itemId) {
|
|
@@ -96019,7 +96101,7 @@ var init_shop_listing_controller = __esm(() => {
|
|
|
96019
96101
|
logger61.debug("Getting game item listing", { userId: ctx.user.id, gameId, itemId });
|
|
96020
96102
|
return ctx.services.shopListing.getByGameItem(gameId, itemId, ctx.user);
|
|
96021
96103
|
});
|
|
96022
|
-
createForGameItem =
|
|
96104
|
+
createForGameItem = requireNonAnonymous(async (ctx) => {
|
|
96023
96105
|
const gameId = ctx.params.gameId;
|
|
96024
96106
|
const itemId = ctx.params.itemId;
|
|
96025
96107
|
if (!gameId || !itemId) {
|
|
@@ -96052,7 +96134,7 @@ var init_shop_listing_controller = __esm(() => {
|
|
|
96052
96134
|
});
|
|
96053
96135
|
return ctx.services.shopListing.createForGameItem(gameId, itemId, body2, ctx.user);
|
|
96054
96136
|
});
|
|
96055
|
-
updateForGameItem =
|
|
96137
|
+
updateForGameItem = requireNonAnonymous(async (ctx) => {
|
|
96056
96138
|
const gameId = ctx.params.gameId;
|
|
96057
96139
|
const itemId = ctx.params.itemId;
|
|
96058
96140
|
if (!gameId || !itemId) {
|
|
@@ -96086,7 +96168,7 @@ var init_shop_listing_controller = __esm(() => {
|
|
|
96086
96168
|
});
|
|
96087
96169
|
return ctx.services.shopListing.updateForGameItem(gameId, itemId, body2, ctx.user);
|
|
96088
96170
|
});
|
|
96089
|
-
deleteForGameItem =
|
|
96171
|
+
deleteForGameItem = requireNonAnonymous(async (ctx) => {
|
|
96090
96172
|
const gameId = ctx.params.gameId;
|
|
96091
96173
|
const itemId = ctx.params.itemId;
|
|
96092
96174
|
if (!gameId || !itemId) {
|
|
@@ -96148,17 +96230,17 @@ var init_timeback_controller = __esm(() => {
|
|
|
96148
96230
|
init_errors();
|
|
96149
96231
|
init_utils11();
|
|
96150
96232
|
logger63 = log.scope("TimebackController");
|
|
96151
|
-
getTodayXp =
|
|
96233
|
+
getTodayXp = requireNonAnonymous(async (ctx) => {
|
|
96152
96234
|
const date4 = ctx.url.searchParams.get("date") || undefined;
|
|
96153
96235
|
const tz = ctx.url.searchParams.get("tz") || undefined;
|
|
96154
96236
|
logger63.debug("Getting today XP", { userId: ctx.user.id, date: date4, tz });
|
|
96155
96237
|
return ctx.services.timeback.getTodayXp(ctx.user.id, date4, tz);
|
|
96156
96238
|
});
|
|
96157
|
-
getTotalXp =
|
|
96239
|
+
getTotalXp = requireNonAnonymous(async (ctx) => {
|
|
96158
96240
|
logger63.debug("Getting total XP", { userId: ctx.user.id });
|
|
96159
96241
|
return ctx.services.timeback.getTotalXp(ctx.user.id);
|
|
96160
96242
|
});
|
|
96161
|
-
updateTodayXp =
|
|
96243
|
+
updateTodayXp = requireNonAnonymous(async (ctx) => {
|
|
96162
96244
|
let body2;
|
|
96163
96245
|
try {
|
|
96164
96246
|
const json4 = await ctx.request.json();
|
|
@@ -96174,13 +96256,13 @@ var init_timeback_controller = __esm(() => {
|
|
|
96174
96256
|
logger63.debug("Updating today XP", { userId: ctx.user.id, xp: body2.xp });
|
|
96175
96257
|
return ctx.services.timeback.updateTodayXp(ctx.user.id, body2);
|
|
96176
96258
|
});
|
|
96177
|
-
getXpHistory =
|
|
96259
|
+
getXpHistory = requireNonAnonymous(async (ctx) => {
|
|
96178
96260
|
const startDate = ctx.url.searchParams.get("startDate") || undefined;
|
|
96179
96261
|
const endDate = ctx.url.searchParams.get("endDate") || undefined;
|
|
96180
96262
|
logger63.debug("Getting XP history", { userId: ctx.user.id, startDate, endDate });
|
|
96181
96263
|
return ctx.services.timeback.getXpHistory(ctx.user.id, startDate, endDate);
|
|
96182
96264
|
});
|
|
96183
|
-
populateStudent =
|
|
96265
|
+
populateStudent = requireNonAnonymous(async (ctx) => {
|
|
96184
96266
|
let providedNames;
|
|
96185
96267
|
try {
|
|
96186
96268
|
const json4 = await ctx.request.json();
|
|
@@ -96198,11 +96280,11 @@ var init_timeback_controller = __esm(() => {
|
|
|
96198
96280
|
});
|
|
96199
96281
|
return ctx.services.timeback.populateStudent(ctx.user, providedNames);
|
|
96200
96282
|
});
|
|
96201
|
-
getUser =
|
|
96283
|
+
getUser = requireNonAnonymous(async (ctx) => {
|
|
96202
96284
|
logger63.debug("Getting user", { userId: ctx.user.id, gameId: ctx.gameId });
|
|
96203
96285
|
return ctx.services.timeback.getUserData(ctx.user.id, ctx.gameId);
|
|
96204
96286
|
});
|
|
96205
|
-
getUserById =
|
|
96287
|
+
getUserById = requireNonAnonymous(async (ctx) => {
|
|
96206
96288
|
const timebackId = ctx.params.timebackId;
|
|
96207
96289
|
if (!timebackId) {
|
|
96208
96290
|
throw ApiError.badRequest("Missing timebackId parameter");
|
|
@@ -96601,17 +96683,32 @@ var init_upload_controller = __esm(() => {
|
|
|
96601
96683
|
});
|
|
96602
96684
|
|
|
96603
96685
|
// ../api-core/src/controllers/user.controller.ts
|
|
96604
|
-
var logger65, getMe, users2;
|
|
96686
|
+
var logger65, getMe, getDemoProfile, updateDemoProfile, users2;
|
|
96605
96687
|
var init_user_controller = __esm(() => {
|
|
96688
|
+
init_schemas_index();
|
|
96606
96689
|
init_src2();
|
|
96607
96690
|
init_utils11();
|
|
96608
96691
|
logger65 = log.scope("UserController");
|
|
96609
|
-
getMe =
|
|
96692
|
+
getMe = requireNonAnonymous(async (ctx) => {
|
|
96610
96693
|
logger65.debug("Getting current user", { userId: ctx.user.id, gameId: ctx.gameId });
|
|
96611
96694
|
return ctx.services.user.getMe(ctx.user, ctx.gameId);
|
|
96612
96695
|
});
|
|
96696
|
+
getDemoProfile = requireAnonymous(async (ctx) => {
|
|
96697
|
+
logger65.debug("Getting demo profile", { userId: ctx.user.id });
|
|
96698
|
+
return ctx.services.user.getDemoProfile(ctx.user.id);
|
|
96699
|
+
});
|
|
96700
|
+
updateDemoProfile = requireAnonymous(async (ctx) => {
|
|
96701
|
+
const body2 = await parseRequestBody(ctx.request, DemoProfileSchema);
|
|
96702
|
+
logger65.debug("Updating demo profile", {
|
|
96703
|
+
userId: ctx.user.id,
|
|
96704
|
+
displayName: body2.displayName
|
|
96705
|
+
});
|
|
96706
|
+
return ctx.services.user.updateDemoProfile(ctx.user.id, body2.displayName);
|
|
96707
|
+
});
|
|
96613
96708
|
users2 = {
|
|
96614
|
-
getMe
|
|
96709
|
+
getMe,
|
|
96710
|
+
getDemoProfile,
|
|
96711
|
+
updateDemoProfile
|
|
96615
96712
|
};
|
|
96616
96713
|
});
|
|
96617
96714
|
|
|
@@ -96819,6 +96916,8 @@ var init_users = __esm(() => {
|
|
|
96819
96916
|
}
|
|
96820
96917
|
return handle2(users2.getMe)(c2);
|
|
96821
96918
|
});
|
|
96919
|
+
usersRouter.get("/demo-profile", handle2(users2.getDemoProfile));
|
|
96920
|
+
usersRouter.patch("/demo-profile", handle2(users2.updateDemoProfile));
|
|
96822
96921
|
usersRouter.get("/level", handle2(levels.getByUser));
|
|
96823
96922
|
usersRouter.get("/level/progress", handle2(levels.getProgress));
|
|
96824
96923
|
usersRouter.get("/:userId/scores", handle2(leaderboard.getUserAllScores));
|
|
@@ -97163,6 +97262,8 @@ var init_scores = __esm(() => {
|
|
|
97163
97262
|
init_api();
|
|
97164
97263
|
gameScoresRouter = new Hono2;
|
|
97165
97264
|
gameScoresRouter.post("/:gameId/scores", handle2(leaderboard.submitScore, { status: 201 }));
|
|
97265
|
+
gameScoresRouter.get("/:gameId/leaderboard", handle2(leaderboard.getLeaderboard));
|
|
97266
|
+
gameScoresRouter.get("/:gameId/users/:userId/rank", handle2(leaderboard.getUserRank));
|
|
97166
97267
|
gameScoresRouter.get("/:gameId/users/:userId/scores", handle2(leaderboard.getUserScores));
|
|
97167
97268
|
});
|
|
97168
97269
|
|
|
@@ -97906,6 +98007,7 @@ async function startServer(port, project, options = {}) {
|
|
|
97906
98007
|
const mainServer = serve({ fetch: app.fetch, port });
|
|
97907
98008
|
return {
|
|
97908
98009
|
main: mainServer,
|
|
98010
|
+
db: db2,
|
|
97909
98011
|
gameId,
|
|
97910
98012
|
timebackMode: getTimebackDisplayMode(),
|
|
97911
98013
|
setRole: (role) => {
|