rhythia-api 148.0.0 → 150.0.0

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.
@@ -28,6 +28,8 @@ export const Schema = {
28
28
  ownerUsername: z.string().nullable().optional(),
29
29
  ownerAvatar: z.string().nullable().optional(),
30
30
  status: z.string().nullable().optional(),
31
+ description: z.string().nullable().optional(),
32
+ tags: z.string().nullable().optional(),
31
33
  })
32
34
  .optional(),
33
35
  }),
@@ -92,6 +94,8 @@ export async function handler(
92
94
  id: beatmapPage.id,
93
95
  status: beatmapPage.status,
94
96
  nominations: beatmapPage.nominations as number[],
97
+ description: beatmapPage.description,
98
+ tags: beatmapPage.tags,
95
99
  },
96
100
  });
97
101
  }
@@ -63,6 +63,7 @@ export async function getLeaderboard(page = 1, session: string) {
63
63
  const { count: playersWithMorePoints, error: rankError } = await supabase
64
64
  .from("profiles")
65
65
  .select("*", { count: "exact", head: true })
66
+ .neq("ban", "excluded")
66
67
  .gt("skill_points", queryData.skill_points);
67
68
 
68
69
  leaderPosition = (playersWithMorePoints || 0) + 1;
@@ -7,9 +7,9 @@ export const Schema = {
7
7
  input: z.strictObject({
8
8
  session: z.string(),
9
9
  id: z.number(),
10
- beatmapHash: z.string(),
11
- tags: z.string(),
12
- description: z.string(),
10
+ beatmapHash: z.string().optional(),
11
+ tags: z.string().optional(),
12
+ description: z.string().optional(),
13
13
  }),
14
14
  output: z.strictObject({
15
15
  error: z.string().optional(),
@@ -47,14 +47,17 @@ export async function handler({
47
47
  .eq("id", id)
48
48
  .single();
49
49
 
50
+ if (!userData) return NextResponse.json({ error: "No user." });
51
+
50
52
  let { data: beatmapData, error: bmPageError } = await supabase
51
53
  .from("beatmaps")
52
54
  .select("*")
53
- .eq("beatmapHash", beatmapHash)
55
+ .eq("beatmapHash", beatmapHash || "")
54
56
  .single();
55
57
 
56
- if (!userData) return NextResponse.json({ error: "No user." });
57
- if (!beatmapData) return NextResponse.json({ error: "No beatmap." });
58
+ if (!beatmapData && beatmapHash) {
59
+ return NextResponse.json({ error: "No beatmap." });
60
+ }
58
61
 
59
62
  if (userData.id !== pageData?.owner)
60
63
  return NextResponse.json({ error: "Non-authz user." });
@@ -62,19 +65,24 @@ export async function handler({
62
65
  if (pageData?.status !== "UNRANKED")
63
66
  return NextResponse.json({ error: "Only unranked maps can be updated" });
64
67
 
68
+ const upsertPayload = {
69
+ id,
70
+ latestBeatmapHash: beatmapHash ? beatmapHash : pageData.latestBeatmapHash,
71
+ genre: "",
72
+ status: "UNRANKED",
73
+ owner: userData.id,
74
+ description: description ? description : pageData.description,
75
+ tags: tags ? tags : pageData.tags,
76
+ nominations: [],
77
+ };
78
+
79
+ if (beatmapHash && beatmapData) {
80
+ upsertPayload["title"] = beatmapData.title;
81
+ }
82
+
65
83
  const upserted = await supabase
66
84
  .from("beatmapPages")
67
- .upsert({
68
- id,
69
- latestBeatmapHash: beatmapHash,
70
- genre: "",
71
- title: beatmapData.title,
72
- status: "UNRANKED",
73
- owner: userData.id,
74
- description,
75
- tags,
76
- nominations: [],
77
- })
85
+ .upsert(upsertPayload)
78
86
  .select("*")
79
87
  .single();
80
88
 
package/index.ts CHANGED
@@ -203,6 +203,8 @@ export const Schema = {
203
203
  ownerUsername: z.string().nullable().optional(),
204
204
  ownerAvatar: z.string().nullable().optional(),
205
205
  status: z.string().nullable().optional(),
206
+ description: z.string().nullable().optional(),
207
+ tags: z.string().nullable().optional(),
206
208
  })
207
209
  .optional(),
208
210
  }),
@@ -591,9 +593,9 @@ export const Schema = {
591
593
  input: z.strictObject({
592
594
  session: z.string(),
593
595
  id: z.number(),
594
- beatmapHash: z.string(),
595
- tags: z.string(),
596
- description: z.string(),
596
+ beatmapHash: z.string().optional(),
597
+ tags: z.string().optional(),
598
+ description: z.string().optional(),
597
599
  }),
598
600
  output: z.strictObject({
599
601
  error: z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "148.0.0",
3
+ "version": "150.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",