rhythia-api 188.0.0 → 190.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.
- package/api/getBeatmapPage.ts +43 -0
- package/api/getBeatmapPageById.ts +43 -0
- package/api/getClan.ts +2 -1
- package/api/getClans.ts +2 -1
- package/index.ts +39 -0
- package/package.json +1 -1
- package/types/database.ts +20 -0
package/api/getBeatmapPage.ts
CHANGED
|
@@ -10,6 +10,25 @@ export const Schema = {
|
|
|
10
10
|
}),
|
|
11
11
|
output: z.object({
|
|
12
12
|
error: z.string().optional(),
|
|
13
|
+
scores: z
|
|
14
|
+
.array(
|
|
15
|
+
z.object({
|
|
16
|
+
id: z.number(),
|
|
17
|
+
awarded_sp: z.number().nullable(),
|
|
18
|
+
created_at: z.string(), // Assuming Supabase returns timestamps as strings
|
|
19
|
+
misses: z.number().nullable(),
|
|
20
|
+
mods: z.record(z.unknown()), // JSONB data, can be any object
|
|
21
|
+
passed: z.boolean().nullable(),
|
|
22
|
+
replayHwid: z.string().nullable(),
|
|
23
|
+
songId: z.string().nullable(),
|
|
24
|
+
speed: z.number().nullable(),
|
|
25
|
+
spin: z.boolean(),
|
|
26
|
+
userId: z.number().nullable(),
|
|
27
|
+
username: z.string().nullable(),
|
|
28
|
+
avatar_url: z.string().nullable(),
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
13
32
|
beatmap: z
|
|
14
33
|
.object({
|
|
15
34
|
id: z.number().nullable().optional(),
|
|
@@ -77,9 +96,33 @@ export async function handler(
|
|
|
77
96
|
.eq("id", data.id)
|
|
78
97
|
.single();
|
|
79
98
|
|
|
99
|
+
const { data: scoreData, error } = await supabase.rpc(
|
|
100
|
+
"get_top_scores_for_beatmap",
|
|
101
|
+
{ beatmap_hash: beatmapPage?.latestBeatmapHash || "" }
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (error) {
|
|
105
|
+
return NextResponse.json({ error: JSON.stringify(error) });
|
|
106
|
+
}
|
|
107
|
+
|
|
80
108
|
if (!beatmapPage) return NextResponse.json({});
|
|
81
109
|
|
|
82
110
|
return NextResponse.json({
|
|
111
|
+
scores: scoreData.map((score: any) => ({
|
|
112
|
+
id: score.id,
|
|
113
|
+
awarded_sp: score.awarded_sp,
|
|
114
|
+
created_at: score.created_at,
|
|
115
|
+
misses: score.misses,
|
|
116
|
+
mods: score.mods,
|
|
117
|
+
passed: score.passed,
|
|
118
|
+
replayHwid: score.replayhwid,
|
|
119
|
+
songId: score.songid,
|
|
120
|
+
speed: score.speed,
|
|
121
|
+
spin: score.spin,
|
|
122
|
+
userId: score.userid,
|
|
123
|
+
username: score.username,
|
|
124
|
+
avatar_url: score.avatar_url,
|
|
125
|
+
})),
|
|
83
126
|
beatmap: {
|
|
84
127
|
playcount: beatmapPage.beatmaps?.playcount,
|
|
85
128
|
created_at: beatmapPage.created_at,
|
|
@@ -10,6 +10,25 @@ export const Schema = {
|
|
|
10
10
|
}),
|
|
11
11
|
output: z.object({
|
|
12
12
|
error: z.string().optional(),
|
|
13
|
+
scores: z
|
|
14
|
+
.array(
|
|
15
|
+
z.object({
|
|
16
|
+
id: z.number(),
|
|
17
|
+
awarded_sp: z.number().nullable(),
|
|
18
|
+
created_at: z.string(), // Assuming Supabase returns timestamps as strings
|
|
19
|
+
misses: z.number().nullable(),
|
|
20
|
+
mods: z.record(z.unknown()), // JSONB data, can be any object
|
|
21
|
+
passed: z.boolean().nullable(),
|
|
22
|
+
replayHwid: z.string().nullable(),
|
|
23
|
+
songId: z.string().nullable(),
|
|
24
|
+
speed: z.number().nullable(),
|
|
25
|
+
spin: z.boolean(),
|
|
26
|
+
userId: z.number().nullable(),
|
|
27
|
+
username: z.string().nullable(),
|
|
28
|
+
avatar_url: z.string().nullable(),
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
13
32
|
beatmap: z
|
|
14
33
|
.object({
|
|
15
34
|
id: z.number().nullable().optional(),
|
|
@@ -75,7 +94,31 @@ export async function handler(
|
|
|
75
94
|
|
|
76
95
|
if (!beatmapPage) return NextResponse.json({});
|
|
77
96
|
|
|
97
|
+
const { data: scoreData, error } = await supabase.rpc(
|
|
98
|
+
"get_top_scores_for_beatmap",
|
|
99
|
+
{ beatmap_hash: beatmapPage?.latestBeatmapHash || "" }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (error) {
|
|
103
|
+
return NextResponse.json({ error: JSON.stringify(error) });
|
|
104
|
+
}
|
|
105
|
+
|
|
78
106
|
return NextResponse.json({
|
|
107
|
+
scores: scoreData.map((score: any) => ({
|
|
108
|
+
id: score.id,
|
|
109
|
+
awarded_sp: score.awarded_sp,
|
|
110
|
+
created_at: score.created_at,
|
|
111
|
+
misses: score.misses,
|
|
112
|
+
mods: score.mods,
|
|
113
|
+
passed: score.passed,
|
|
114
|
+
replayHwid: score.replayhwid,
|
|
115
|
+
songId: score.songid,
|
|
116
|
+
speed: score.speed,
|
|
117
|
+
spin: score.spin,
|
|
118
|
+
userId: score.userid,
|
|
119
|
+
username: score.username,
|
|
120
|
+
avatar_url: score.avatar_url,
|
|
121
|
+
})),
|
|
79
122
|
beatmap: {
|
|
80
123
|
playcount: beatmapPage.beatmaps?.playcount,
|
|
81
124
|
created_at: beatmapPage.created_at,
|
package/api/getClan.ts
CHANGED
|
@@ -62,7 +62,8 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
62
62
|
let { data: queryUsers, error: usersError } = await supabase
|
|
63
63
|
.from("profiles")
|
|
64
64
|
.select("*")
|
|
65
|
-
.eq("clan", queryClanData.id)
|
|
65
|
+
.eq("clan", queryClanData.id)
|
|
66
|
+
.neq("ban", "excluded");
|
|
66
67
|
|
|
67
68
|
return NextResponse.json({
|
|
68
69
|
acronym: queryClanData.acronym,
|
package/api/getClans.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { User } from "@supabase/supabase-js";
|
|
|
8
8
|
export const Schema = {
|
|
9
9
|
input: z.strictObject({
|
|
10
10
|
page: z.number(),
|
|
11
|
+
session: z.any(),
|
|
11
12
|
}),
|
|
12
13
|
output: z.object({
|
|
13
14
|
clanData: z.array(
|
|
@@ -40,5 +41,5 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
40
41
|
page_number: data.page,
|
|
41
42
|
items_per_page: 25,
|
|
42
43
|
});
|
|
43
|
-
return NextResponse.json({ clanData });
|
|
44
|
+
return NextResponse.json({ clanData, error });
|
|
44
45
|
}
|
package/index.ts
CHANGED
|
@@ -344,6 +344,25 @@ export const Schema = {
|
|
|
344
344
|
}),
|
|
345
345
|
output: z.object({
|
|
346
346
|
error: z.string().optional(),
|
|
347
|
+
scores: z
|
|
348
|
+
.array(
|
|
349
|
+
z.object({
|
|
350
|
+
id: z.number(),
|
|
351
|
+
awarded_sp: z.number().nullable(),
|
|
352
|
+
created_at: z.string(), // Assuming Supabase returns timestamps as strings
|
|
353
|
+
misses: z.number().nullable(),
|
|
354
|
+
mods: z.record(z.unknown()), // JSONB data, can be any object
|
|
355
|
+
passed: z.boolean().nullable(),
|
|
356
|
+
replayHwid: z.string().nullable(),
|
|
357
|
+
songId: z.string().nullable(),
|
|
358
|
+
speed: z.number().nullable(),
|
|
359
|
+
spin: z.boolean(),
|
|
360
|
+
userId: z.number().nullable(),
|
|
361
|
+
username: z.string().nullable(),
|
|
362
|
+
avatar_url: z.string().nullable(),
|
|
363
|
+
})
|
|
364
|
+
)
|
|
365
|
+
.optional(),
|
|
347
366
|
beatmap: z
|
|
348
367
|
.object({
|
|
349
368
|
id: z.number().nullable().optional(),
|
|
@@ -384,6 +403,25 @@ export const Schema = {
|
|
|
384
403
|
}),
|
|
385
404
|
output: z.object({
|
|
386
405
|
error: z.string().optional(),
|
|
406
|
+
scores: z
|
|
407
|
+
.array(
|
|
408
|
+
z.object({
|
|
409
|
+
id: z.number(),
|
|
410
|
+
awarded_sp: z.number().nullable(),
|
|
411
|
+
created_at: z.string(), // Assuming Supabase returns timestamps as strings
|
|
412
|
+
misses: z.number().nullable(),
|
|
413
|
+
mods: z.record(z.unknown()), // JSONB data, can be any object
|
|
414
|
+
passed: z.boolean().nullable(),
|
|
415
|
+
replayHwid: z.string().nullable(),
|
|
416
|
+
songId: z.string().nullable(),
|
|
417
|
+
speed: z.number().nullable(),
|
|
418
|
+
spin: z.boolean(),
|
|
419
|
+
userId: z.number().nullable(),
|
|
420
|
+
username: z.string().nullable(),
|
|
421
|
+
avatar_url: z.string().nullable(),
|
|
422
|
+
})
|
|
423
|
+
)
|
|
424
|
+
.optional(),
|
|
387
425
|
beatmap: z
|
|
388
426
|
.object({
|
|
389
427
|
id: z.number().nullable().optional(),
|
|
@@ -530,6 +568,7 @@ export const getClan = handleApi({url:"/api/getClan",...GetClan})
|
|
|
530
568
|
export const Schema = {
|
|
531
569
|
input: z.strictObject({
|
|
532
570
|
page: z.number(),
|
|
571
|
+
session: z.any(),
|
|
533
572
|
}),
|
|
534
573
|
output: z.object({
|
|
535
574
|
clanData: z.array(
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -734,6 +734,26 @@ export type Database = {
|
|
|
734
734
|
total_pages: number
|
|
735
735
|
}[]
|
|
736
736
|
}
|
|
737
|
+
get_top_scores_for_beatmap: {
|
|
738
|
+
Args: {
|
|
739
|
+
beatmap_hash: string
|
|
740
|
+
}
|
|
741
|
+
Returns: {
|
|
742
|
+
id: number
|
|
743
|
+
awarded_sp: number
|
|
744
|
+
created_at: string
|
|
745
|
+
misses: number
|
|
746
|
+
mods: Json
|
|
747
|
+
passed: boolean
|
|
748
|
+
replayhwid: string
|
|
749
|
+
songid: string
|
|
750
|
+
speed: number
|
|
751
|
+
spin: boolean
|
|
752
|
+
userid: number
|
|
753
|
+
username: string
|
|
754
|
+
avatar_url: string
|
|
755
|
+
}[]
|
|
756
|
+
}
|
|
737
757
|
}
|
|
738
758
|
Enums: {
|
|
739
759
|
banTypes: "cool" | "silenced" | "restricted" | "excluded"
|