rhythia-api 179.0.0 → 181.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/editCollection.ts +6 -0
- package/api/getCollection.ts +17 -1
- package/api/getCollections.ts +27 -2
- package/index.ts +7 -0
- package/package.json +1 -1
- package/types/database.ts +44 -0
package/api/editCollection.ts
CHANGED
|
@@ -59,6 +59,12 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
if (data.description.length > 128) {
|
|
63
|
+
return NextResponse.json({
|
|
64
|
+
error: "Description too long",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
await supabase.from("beatmapCollections").upsert({
|
|
63
69
|
id: data.collection,
|
|
64
70
|
title: data.title,
|
package/api/getCollection.ts
CHANGED
|
@@ -12,6 +12,10 @@ export const Schema = {
|
|
|
12
12
|
collection: z.object({
|
|
13
13
|
title: z.string(),
|
|
14
14
|
description: z.string(),
|
|
15
|
+
owner: z.object({
|
|
16
|
+
id: z.number(),
|
|
17
|
+
username: z.string(),
|
|
18
|
+
}),
|
|
15
19
|
beatmaps: z.array(
|
|
16
20
|
z.object({
|
|
17
21
|
id: z.number(),
|
|
@@ -47,7 +51,15 @@ export async function POST(request: Request) {
|
|
|
47
51
|
export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
48
52
|
let { data: queryCollectionData, error: collectionError } = await supabase
|
|
49
53
|
.from("beatmapCollections")
|
|
50
|
-
.select(
|
|
54
|
+
.select(
|
|
55
|
+
`
|
|
56
|
+
*,
|
|
57
|
+
profiles!inner(
|
|
58
|
+
id,
|
|
59
|
+
username
|
|
60
|
+
)
|
|
61
|
+
`
|
|
62
|
+
)
|
|
51
63
|
.eq("id", data.collection)
|
|
52
64
|
.single();
|
|
53
65
|
|
|
@@ -104,6 +116,10 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
104
116
|
|
|
105
117
|
return NextResponse.json({
|
|
106
118
|
collection: {
|
|
119
|
+
owner: {
|
|
120
|
+
username: queryCollectionData.profiles.username,
|
|
121
|
+
id: queryCollectionData.profiles.id,
|
|
122
|
+
},
|
|
107
123
|
title: queryCollectionData.title,
|
|
108
124
|
description: queryCollectionData.description,
|
|
109
125
|
beatmaps: formattedBeatmaps,
|
package/api/getCollections.ts
CHANGED
|
@@ -15,6 +15,9 @@ export const Schema = {
|
|
|
15
15
|
id: z.number(),
|
|
16
16
|
title: z.string(),
|
|
17
17
|
description: z.string(),
|
|
18
|
+
owner: z.number(),
|
|
19
|
+
ownerUsername: z.string(),
|
|
20
|
+
ownerAvatarUrl: z.string(),
|
|
18
21
|
beatmapCount: z.number(),
|
|
19
22
|
starRatingDistribution: z.array(
|
|
20
23
|
z.object({
|
|
@@ -41,7 +44,7 @@ export async function POST(request: Request) {
|
|
|
41
44
|
|
|
42
45
|
export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
43
46
|
const { data: collections, error } = await supabase
|
|
44
|
-
.rpc("
|
|
47
|
+
.rpc("get_collections_v2", {
|
|
45
48
|
page_number: data.page,
|
|
46
49
|
items_per_page: data.itemsPerPage,
|
|
47
50
|
})
|
|
@@ -51,6 +54,9 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
51
54
|
title: string;
|
|
52
55
|
description: string;
|
|
53
56
|
created_at: string;
|
|
57
|
+
owner: number;
|
|
58
|
+
owner_username: string;
|
|
59
|
+
owner_avatar_url: string;
|
|
54
60
|
beatmap_count: number;
|
|
55
61
|
star1: number;
|
|
56
62
|
star2: number;
|
|
@@ -62,12 +68,20 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
62
68
|
star8: number;
|
|
63
69
|
star9: number;
|
|
64
70
|
star10: number;
|
|
71
|
+
star11: number;
|
|
72
|
+
star12: number;
|
|
73
|
+
star13: number;
|
|
74
|
+
star14: number;
|
|
75
|
+
star15: number;
|
|
76
|
+
star16: number;
|
|
77
|
+
star17: number;
|
|
78
|
+
star18: number;
|
|
65
79
|
total_pages: number;
|
|
66
80
|
}[]
|
|
67
81
|
>();
|
|
68
82
|
|
|
69
83
|
if (error) {
|
|
70
|
-
return NextResponse.json({ error
|
|
84
|
+
return NextResponse.json({ error });
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
// Get the total pages from the first row (all rows will have the same value)
|
|
@@ -78,6 +92,9 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
78
92
|
id: collection.id,
|
|
79
93
|
title: collection.title,
|
|
80
94
|
description: collection.description,
|
|
95
|
+
owner: collection.owner,
|
|
96
|
+
ownerUsername: collection.owner_username,
|
|
97
|
+
ownerAvatarUrl: collection.owner_avatar_url,
|
|
81
98
|
beatmapCount: collection.beatmap_count,
|
|
82
99
|
starRatingDistribution: [
|
|
83
100
|
{ stars: 1, count: collection.star1 },
|
|
@@ -90,6 +107,14 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
90
107
|
{ stars: 8, count: collection.star8 },
|
|
91
108
|
{ stars: 9, count: collection.star9 },
|
|
92
109
|
{ stars: 10, count: collection.star10 },
|
|
110
|
+
{ stars: 11, count: collection.star11 },
|
|
111
|
+
{ stars: 12, count: collection.star12 },
|
|
112
|
+
{ stars: 13, count: collection.star13 },
|
|
113
|
+
{ stars: 14, count: collection.star14 },
|
|
114
|
+
{ stars: 15, count: collection.star15 },
|
|
115
|
+
{ stars: 16, count: collection.star16 },
|
|
116
|
+
{ stars: 17, count: collection.star17 },
|
|
117
|
+
{ stars: 18, count: collection.star18 },
|
|
93
118
|
],
|
|
94
119
|
createdAt: collection.created_at,
|
|
95
120
|
})) || [];
|
package/index.ts
CHANGED
|
@@ -511,6 +511,10 @@ export const Schema = {
|
|
|
511
511
|
collection: z.object({
|
|
512
512
|
title: z.string(),
|
|
513
513
|
description: z.string(),
|
|
514
|
+
owner: z.object({
|
|
515
|
+
id: z.number(),
|
|
516
|
+
username: z.string(),
|
|
517
|
+
}),
|
|
514
518
|
beatmaps: z.array(
|
|
515
519
|
z.object({
|
|
516
520
|
id: z.number(),
|
|
@@ -552,6 +556,9 @@ export const Schema = {
|
|
|
552
556
|
id: z.number(),
|
|
553
557
|
title: z.string(),
|
|
554
558
|
description: z.string(),
|
|
559
|
+
owner: z.number(),
|
|
560
|
+
ownerUsername: z.string(),
|
|
561
|
+
ownerAvatarUrl: z.string(),
|
|
555
562
|
beatmapCount: z.number(),
|
|
556
563
|
starRatingDistribution: z.array(
|
|
557
564
|
z.object({
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -515,6 +515,42 @@ export type Database = {
|
|
|
515
515
|
title: string
|
|
516
516
|
description: string
|
|
517
517
|
created_at: string
|
|
518
|
+
owner: number
|
|
519
|
+
beatmap_count: number
|
|
520
|
+
star1: number
|
|
521
|
+
star2: number
|
|
522
|
+
star3: number
|
|
523
|
+
star4: number
|
|
524
|
+
star5: number
|
|
525
|
+
star6: number
|
|
526
|
+
star7: number
|
|
527
|
+
star8: number
|
|
528
|
+
star9: number
|
|
529
|
+
star10: number
|
|
530
|
+
star11: number
|
|
531
|
+
star12: number
|
|
532
|
+
star13: number
|
|
533
|
+
star14: number
|
|
534
|
+
star15: number
|
|
535
|
+
star16: number
|
|
536
|
+
star17: number
|
|
537
|
+
star18: number
|
|
538
|
+
total_pages: number
|
|
539
|
+
}[]
|
|
540
|
+
}
|
|
541
|
+
get_collections_v2: {
|
|
542
|
+
Args: {
|
|
543
|
+
page_number?: number
|
|
544
|
+
items_per_page?: number
|
|
545
|
+
}
|
|
546
|
+
Returns: {
|
|
547
|
+
id: number
|
|
548
|
+
title: string
|
|
549
|
+
description: string
|
|
550
|
+
created_at: string
|
|
551
|
+
owner: number
|
|
552
|
+
owner_username: string
|
|
553
|
+
owner_avatar_url: string
|
|
518
554
|
beatmap_count: number
|
|
519
555
|
star1: number
|
|
520
556
|
star2: number
|
|
@@ -526,6 +562,14 @@ export type Database = {
|
|
|
526
562
|
star8: number
|
|
527
563
|
star9: number
|
|
528
564
|
star10: number
|
|
565
|
+
star11: number
|
|
566
|
+
star12: number
|
|
567
|
+
star13: number
|
|
568
|
+
star14: number
|
|
569
|
+
star15: number
|
|
570
|
+
star16: number
|
|
571
|
+
star17: number
|
|
572
|
+
star18: number
|
|
529
573
|
total_pages: number
|
|
530
574
|
}[]
|
|
531
575
|
}
|