rhythia-api 101.0.0 → 103.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.
@@ -3,7 +3,6 @@ import z from "zod";
3
3
  import { Database } from "../types/database";
4
4
  import { protectedApi, validUser } from "../utils/requestUtils";
5
5
  import { supabase } from "../utils/supabase";
6
-
7
6
  export const Schema = {
8
7
  input: z.strictObject({
9
8
  session: z.string(),
@@ -30,6 +29,24 @@ export async function POST(request: Request): Promise<NextResponse> {
30
29
  export async function handler(
31
30
  data: (typeof Schema)["input"]["_type"]
32
31
  ): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
32
+ if (data.data.username !== undefined && data.data.username.length === 0) {
33
+ return NextResponse.json(
34
+ {
35
+ error: "Username can't be empty",
36
+ },
37
+ { status: 404 }
38
+ );
39
+ }
40
+
41
+ if (data.data.username && data.data.username.length > 20) {
42
+ return NextResponse.json(
43
+ {
44
+ error: "Username too long.",
45
+ },
46
+ { status: 404 }
47
+ );
48
+ }
49
+
33
50
  const user = (await supabase.auth.getUser(data.session)).data.user!;
34
51
  let userData: Database["public"]["Tables"]["profiles"]["Update"];
35
52
 
@@ -53,6 +70,7 @@ export async function handler(
53
70
 
54
71
  const upsertPayload: Database["public"]["Tables"]["profiles"]["Update"] = {
55
72
  id: userData.id,
73
+ computedUsername: data.data.username?.toLowerCase(),
56
74
  ...data.data,
57
75
  };
58
76
 
@@ -61,7 +79,7 @@ export async function handler(
61
79
  .upsert(upsertPayload)
62
80
  .select();
63
81
 
64
- if (upsertResult.status == 409) {
82
+ if (upsertResult.error) {
65
83
  return NextResponse.json(
66
84
  {
67
85
  error: "Can't update, username might be used by someone else!",
@@ -0,0 +1,55 @@
1
+ import { NextResponse } from "next/server";
2
+ import z from "zod";
3
+ import { protectedApi, validUser } from "../utils/requestUtils";
4
+ import { supabase } from "../utils/supabase";
5
+
6
+ import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
7
+ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
8
+
9
+ const s3Client = new S3Client({
10
+ region: "us-east-1",
11
+ credentials: {
12
+ secretAccessKey: "0036dd2cb06d730015861d27ce0796cccb5031123e",
13
+ accessKeyId: "c245e893e806",
14
+ },
15
+ });
16
+
17
+ export const Schema = {
18
+ input: z.strictObject({
19
+ session: z.string(),
20
+ }),
21
+ output: z.strictObject({
22
+ url: z.string(),
23
+ }),
24
+ };
25
+
26
+ export async function POST(request: Request): Promise<NextResponse> {
27
+ return protectedApi({
28
+ request,
29
+ schema: Schema,
30
+ authorization: validUser,
31
+ activity: handler,
32
+ });
33
+ }
34
+
35
+ export async function handler({
36
+ session,
37
+ }: (typeof Schema)["input"]["_type"]): Promise<
38
+ NextResponse<(typeof Schema)["output"]["_type"]>
39
+ > {
40
+ const user = (await supabase.auth.getUser(session)).data.user!;
41
+
42
+ const command = new PutObjectCommand({
43
+ Bucket: "rhythia-avatars",
44
+ Key: `user-avatar-${Date.now()}-${user.id}`,
45
+ ContentLength: 5000000,
46
+ });
47
+
48
+ const presigned = await getSignedUrl(s3Client, command, {
49
+ expiresIn: 3600,
50
+ });
51
+ return NextResponse.json({
52
+ url: presigned,
53
+ objectKey: `user-avatar-${Date.now()}-${user.id}`,
54
+ });
55
+ }
@@ -45,7 +45,7 @@ export async function handler(
45
45
  return NextResponse.json(result);
46
46
  }
47
47
 
48
- const VIEW_PER_PAGE = 100;
48
+ const VIEW_PER_PAGE = 50;
49
49
 
50
50
  export async function getLeaderboard(page = 1, session: string) {
51
51
  const getUserData = await getUser({ session });
package/api/getProfile.ts CHANGED
@@ -2,7 +2,7 @@ import { geolocation } from "@vercel/edge";
2
2
  import { NextResponse } from "next/server";
3
3
  import z from "zod";
4
4
  import { Database } from "../types/database";
5
- import { protectedApi, validUser } from "../utils/requestUtils";
5
+ import { protectedApi } from "../utils/requestUtils";
6
6
  import { supabase } from "../utils/supabase";
7
7
 
8
8
  export const Schema = {
@@ -77,7 +77,6 @@ export async function handler(
77
77
  .select("*")
78
78
  .eq("uid", user.id);
79
79
 
80
- console.log(profiles, error);
81
80
  if (!queryData?.length) {
82
81
  const geo = geolocation(req);
83
82
  const data = await supabase
@@ -87,7 +86,13 @@ export async function handler(
87
86
  about_me: "",
88
87
  avatar_url: user.user_metadata.avatar_url,
89
88
  badges: ["Early Bird"],
90
- username: user.user_metadata.full_name,
89
+ username: `${user.user_metadata.full_name.slice(0, 20)}${Math.round(
90
+ Math.random() * 900000 + 100000
91
+ )}`,
92
+ computedUsername: `${user.user_metadata.full_name.slice(
93
+ 0,
94
+ 20
95
+ )}${Math.round(Math.random() * 900000 + 100000)}`.toLowerCase(),
91
96
  flag: (geo.country || "US").toUpperCase(),
92
97
  created_at: Date.now(),
93
98
  })
package/api/getScore.ts CHANGED
@@ -18,7 +18,6 @@ export const Schema = {
18
18
  id: z.number(),
19
19
  misses: z.number().nullable(),
20
20
  passed: z.boolean().nullable(),
21
- rank: z.string().nullable(),
22
21
  songId: z.string().nullable(),
23
22
  userId: z.number().nullable(),
24
23
  beatmapDifficulty: z.number().optional().nullable(),
@@ -72,7 +71,6 @@ export async function handler(
72
71
  awarded_sp: score.awarded_sp,
73
72
  beatmapHash: score.beatmapHash,
74
73
  misses: score.misses,
75
- rank: score.rank,
76
74
  songId: score.songId,
77
75
  beatmapDifficulty: score.beatmaps?.difficulty,
78
76
  beatmapNotes: score.beatmaps?.noteCount,
@@ -19,7 +19,6 @@ export const Schema = {
19
19
  id: z.number(),
20
20
  misses: z.number().nullable(),
21
21
  passed: z.boolean().nullable(),
22
- rank: z.string().nullable(),
23
22
  songId: z.string().nullable(),
24
23
  userId: z.number().nullable(),
25
24
  beatmapDifficulty: z.number().optional().nullable(),
@@ -94,8 +93,27 @@ export async function handler(
94
93
  .eq("userId", data.id)
95
94
  .neq("awarded_sp", 0)
96
95
  .eq("passed", true)
97
- .order("awarded_sp", { ascending: false })
98
- .limit(10);
96
+ .order("awarded_sp", { ascending: false });
97
+
98
+ if (scores2 == null) return NextResponse.json({ error: "No scores" });
99
+
100
+ let hashMap: Record<string, { awarded_sp: number; score: any }> = {};
101
+
102
+ for (const score of scores2) {
103
+ const { beatmapHash, awarded_sp } = score;
104
+
105
+ if (!beatmapHash || !awarded_sp) continue;
106
+
107
+ if (!hashMap[beatmapHash] || hashMap[beatmapHash].awarded_sp < awarded_sp) {
108
+ hashMap[beatmapHash] = { awarded_sp, score };
109
+ }
110
+ }
111
+
112
+ const values = Object.values(hashMap);
113
+ let vals = values
114
+ .sort((a, b) => b.awarded_sp - a.awarded_sp)
115
+ .slice(0, 10)
116
+ .map((e) => e.score);
99
117
 
100
118
  return NextResponse.json({
101
119
  lastDay: scores1?.map((s) => ({
@@ -106,13 +124,12 @@ export async function handler(
106
124
  awarded_sp: s.awarded_sp,
107
125
  beatmapHash: s.beatmapHash,
108
126
  misses: s.misses,
109
- rank: s.rank,
110
127
  songId: s.songId,
111
128
  beatmapDifficulty: s.beatmaps?.difficulty,
112
129
  beatmapNotes: s.beatmaps?.noteCount,
113
130
  beatmapTitle: s.beatmaps?.title,
114
131
  })),
115
- top: scores2?.map((s) => ({
132
+ top: vals?.map((s) => ({
116
133
  created_at: s.created_at,
117
134
  id: s.id,
118
135
  passed: s.passed,
@@ -10,13 +10,14 @@ export const Schema = {
10
10
  token: z.string(),
11
11
  relayHwid: z.string(),
12
12
  songId: z.string(),
13
- noteResults: z.record(z.boolean()),
14
- triggers: z.array(z.array(z.number())),
13
+ misses: z.number(),
14
+ squareHits: z.number(),
15
15
  mapHash: z.string(),
16
16
  mapTitle: z.string(),
17
17
  mapDifficulty: z.number(),
18
18
  mapNoteCount: z.number(),
19
19
  mapLength: z.number(),
20
+ passed: z.boolean(),
20
21
  sspp: z.number(),
21
22
  }),
22
23
  }),
@@ -69,8 +70,7 @@ export async function handler({
69
70
  newPlaycount = (beatmaps.playcount || 1) + 1;
70
71
  }
71
72
 
72
- console.log(newPlaycount);
73
- const p1 = await supabase.from("beatmaps").upsert({
73
+ await supabase.from("beatmaps").upsert({
74
74
  beatmapHash: data.mapHash,
75
75
  title: data.mapTitle,
76
76
  playcount: newPlaycount,
@@ -80,26 +80,57 @@ export async function handler({
80
80
  });
81
81
 
82
82
  console.log("p1");
83
- const p2 = await supabase.from("scores").upsert({
83
+ await supabase.from("scores").upsert({
84
84
  beatmapHash: data.mapHash,
85
- noteResults: data.noteResults,
86
85
  replayHwid: data.relayHwid,
87
86
  songId: data.songId,
88
- triggers: data.triggers,
89
87
  userId: userData.id,
90
- passed: data.mapNoteCount == Object.keys(data.noteResults).length,
91
- misses: Object.values(data.noteResults).filter((e) => !e).length,
92
- awarded_sp: data.sspp,
93
- rank: "A",
88
+ passed: data.passed,
89
+ misses: data.misses,
90
+ awarded_sp: Math.round(data.sspp * 100) / 100,
94
91
  });
95
92
  console.log("p2");
96
93
 
97
- const p3 = await supabase.from("profiles").upsert({
94
+ let totalSp = 0;
95
+ let { data: scores2, error: errorsp } = await supabase
96
+ .from("scores")
97
+ .select(`awarded_sp,beatmapHash`)
98
+ .eq("userId", userData.id)
99
+ .neq("awarded_sp", 0)
100
+ .eq("passed", true)
101
+ .order("awarded_sp", { ascending: false });
102
+
103
+ if (scores2 == null) return NextResponse.json({ error: "No scores" });
104
+
105
+ let hashMap: Record<string, number> = {};
106
+
107
+ for (const score of scores2) {
108
+ const { beatmapHash, awarded_sp } = score;
109
+
110
+ if (!beatmapHash || !awarded_sp) continue;
111
+
112
+ if (!hashMap[beatmapHash] || hashMap[beatmapHash] < awarded_sp) {
113
+ hashMap[beatmapHash] = awarded_sp;
114
+ }
115
+ }
116
+ let weight = 100;
117
+ const values = Object.values(hashMap);
118
+ values.sort((a, b) => b - a);
119
+
120
+ for (const score of values) {
121
+ totalSp += ((score || 0) * weight) / 100;
122
+ weight -= 1;
123
+
124
+ if (weight == 0) {
125
+ break;
126
+ }
127
+ }
128
+
129
+ await supabase.from("profiles").upsert({
98
130
  id: userData.id,
99
131
  play_count: (userData.play_count || 0) + 1,
100
- squares_hit:
101
- (userData.squares_hit || 0) +
102
- Object.values(data.noteResults).filter((e) => e).length,
132
+ skill_points: Math.round(totalSp * 100) / 100,
133
+ squares_hit: (userData.squares_hit || 0) + data.squareHits,
103
134
  });
104
135
  console.log("p3");
105
136
 
package/index.ts CHANGED
@@ -5,6 +5,11 @@ import { Schema as EditProfile } from "./api/editProfile"
5
5
  export { Schema as SchemaEditProfile } from "./api/editProfile"
6
6
  export const editProfile = handleApi({url:"/api/editProfile",...EditProfile})
7
7
 
8
+ // ./api/getAvatarUploadUrl.ts API
9
+ import { Schema as GetAvatarUploadUrl } from "./api/getAvatarUploadUrl"
10
+ export { Schema as SchemaGetAvatarUploadUrl } from "./api/getAvatarUploadUrl"
11
+ export const getAvatarUploadUrl = handleApi({url:"/api/getAvatarUploadUrl",...GetAvatarUploadUrl})
12
+
8
13
  // ./api/getLeaderboard.ts API
9
14
  import { Schema as GetLeaderboard } from "./api/getLeaderboard"
10
15
  export { Schema as SchemaGetLeaderboard } from "./api/getLeaderboard"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "101.0.0",
3
+ "version": "103.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",
@@ -12,6 +12,8 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
+ "@aws-sdk/client-s3": "^3.637.0",
16
+ "@aws-sdk/s3-request-presigner": "^3.637.0",
15
17
  "@netlify/zip-it-and-ship-it": "^9.37.9",
16
18
  "@supabase/supabase-js": "^2.45.1",
17
19
  "@types/aws-lambda": "^8.10.143",
@@ -21,6 +23,7 @@
21
23
  "@vercel/edge": "^1.1.2",
22
24
  "@vercel/node": "^3.2.8",
23
25
  "aws-lambda": "^1.0.7",
26
+ "badwords-list": "^2.0.1-4",
24
27
  "bufferutil": "^4.0.8",
25
28
  "bun": "^1.1.22",
26
29
  "esbuild": "^0.23.0",
@@ -28,7 +31,7 @@
28
31
  "lodash": "^4.17.21",
29
32
  "next": "^14.2.5",
30
33
  "simple-git": "^3.25.0",
31
- "supabase": "^1.190.0",
34
+ "supabase": "^1.191.3",
32
35
  "tsx": "^4.17.0",
33
36
  "utf-8-validate": "^6.0.4",
34
37
  "zod": "^3.23.8"
package/types/database.ts CHANGED
@@ -1,254 +1,251 @@
1
- export type Json =
2
- | string
3
- | number
4
- | boolean
5
- | null
6
- | { [key: string]: Json | undefined }
7
- | Json[]
8
-
9
- export type Database = {
10
- public: {
11
- Tables: {
12
- beatmaps: {
13
- Row: {
14
- beatmapHash: string
15
- created_at: string
16
- difficulty: number | null
17
- length: number | null
18
- noteCount: number | null
19
- playcount: number | null
20
- title: string | null
21
- }
22
- Insert: {
23
- beatmapHash: string
24
- created_at?: string
25
- difficulty?: number | null
26
- length?: number | null
27
- noteCount?: number | null
28
- playcount?: number | null
29
- title?: string | null
30
- }
31
- Update: {
32
- beatmapHash?: string
33
- created_at?: string
34
- difficulty?: number | null
35
- length?: number | null
36
- noteCount?: number | null
37
- playcount?: number | null
38
- title?: string | null
39
- }
40
- Relationships: []
41
- }
42
- profiles: {
43
- Row: {
44
- about_me: string | null
45
- avatar_url: string | null
46
- badges: Json | null
47
- created_at: number | null
48
- flag: string | null
49
- id: number
50
- play_count: number | null
51
- skill_points: number | null
52
- squares_hit: number | null
53
- total_score: number | null
54
- uid: string | null
55
- username: string | null
56
- verified: boolean | null
57
- }
58
- Insert: {
59
- about_me?: string | null
60
- avatar_url?: string | null
61
- badges?: Json | null
62
- created_at?: number | null
63
- flag?: string | null
64
- id?: number
65
- play_count?: number | null
66
- skill_points?: number | null
67
- squares_hit?: number | null
68
- total_score?: number | null
69
- uid?: string | null
70
- username?: string | null
71
- verified?: boolean | null
72
- }
73
- Update: {
74
- about_me?: string | null
75
- avatar_url?: string | null
76
- badges?: Json | null
77
- created_at?: number | null
78
- flag?: string | null
79
- id?: number
80
- play_count?: number | null
81
- skill_points?: number | null
82
- squares_hit?: number | null
83
- total_score?: number | null
84
- uid?: string | null
85
- username?: string | null
86
- verified?: boolean | null
87
- }
88
- Relationships: [
89
- {
90
- foreignKeyName: "profiles_uid_fkey"
91
- columns: ["uid"]
92
- isOneToOne: true
93
- referencedRelation: "users"
94
- referencedColumns: ["id"]
95
- },
96
- ]
97
- }
98
- scores: {
99
- Row: {
100
- awarded_sp: number | null
101
- beatmapHash: string | null
102
- created_at: string
103
- id: number
104
- misses: number | null
105
- noteResults: Json | null
106
- passed: boolean | null
107
- rank: string | null
108
- replayHwid: string | null
109
- songId: string | null
110
- triggers: Json | null
111
- userId: number | null
112
- }
113
- Insert: {
114
- awarded_sp?: number | null
115
- beatmapHash?: string | null
116
- created_at?: string
117
- id?: number
118
- misses?: number | null
119
- noteResults?: Json | null
120
- passed?: boolean | null
121
- rank?: string | null
122
- replayHwid?: string | null
123
- songId?: string | null
124
- triggers?: Json | null
125
- userId?: number | null
126
- }
127
- Update: {
128
- awarded_sp?: number | null
129
- beatmapHash?: string | null
130
- created_at?: string
131
- id?: number
132
- misses?: number | null
133
- noteResults?: Json | null
134
- passed?: boolean | null
135
- rank?: string | null
136
- replayHwid?: string | null
137
- songId?: string | null
138
- triggers?: Json | null
139
- userId?: number | null
140
- }
141
- Relationships: [
142
- {
143
- foreignKeyName: "scores_beatmapHash_fkey"
144
- columns: ["beatmapHash"]
145
- isOneToOne: false
146
- referencedRelation: "beatmaps"
147
- referencedColumns: ["beatmapHash"]
148
- },
149
- {
150
- foreignKeyName: "scores_userId_fkey"
151
- columns: ["userId"]
152
- isOneToOne: false
153
- referencedRelation: "profiles"
154
- referencedColumns: ["id"]
155
- },
156
- ]
157
- }
158
- }
159
- Views: {
160
- [_ in never]: never
161
- }
162
- Functions: {
163
- [_ in never]: never
164
- }
165
- Enums: {
166
- [_ in never]: never
167
- }
168
- CompositeTypes: {
169
- [_ in never]: never
170
- }
171
- }
172
- }
173
-
174
- type PublicSchema = Database[Extract<keyof Database, "public">]
175
-
176
- export type Tables<
177
- PublicTableNameOrOptions extends
178
- | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
179
- | { schema: keyof Database },
180
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
181
- ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
182
- Database[PublicTableNameOrOptions["schema"]]["Views"])
183
- : never = never,
184
- > = PublicTableNameOrOptions extends { schema: keyof Database }
185
- ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
186
- Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
187
- Row: infer R
188
- }
189
- ? R
190
- : never
191
- : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
192
- PublicSchema["Views"])
193
- ? (PublicSchema["Tables"] &
194
- PublicSchema["Views"])[PublicTableNameOrOptions] extends {
195
- Row: infer R
196
- }
197
- ? R
198
- : never
199
- : never
200
-
201
- export type TablesInsert<
202
- PublicTableNameOrOptions extends
203
- | keyof PublicSchema["Tables"]
204
- | { schema: keyof Database },
205
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
206
- ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
207
- : never = never,
208
- > = PublicTableNameOrOptions extends { schema: keyof Database }
209
- ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
210
- Insert: infer I
211
- }
212
- ? I
213
- : never
214
- : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
215
- ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
216
- Insert: infer I
217
- }
218
- ? I
219
- : never
220
- : never
221
-
222
- export type TablesUpdate<
223
- PublicTableNameOrOptions extends
224
- | keyof PublicSchema["Tables"]
225
- | { schema: keyof Database },
226
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
227
- ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
228
- : never = never,
229
- > = PublicTableNameOrOptions extends { schema: keyof Database }
230
- ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
231
- Update: infer U
232
- }
233
- ? U
234
- : never
235
- : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
236
- ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
237
- Update: infer U
238
- }
239
- ? U
240
- : never
241
- : never
242
-
243
- export type Enums<
244
- PublicEnumNameOrOptions extends
245
- | keyof PublicSchema["Enums"]
246
- | { schema: keyof Database },
247
- EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
248
- ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
249
- : never = never,
250
- > = PublicEnumNameOrOptions extends { schema: keyof Database }
251
- ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
252
- : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
253
- ? PublicSchema["Enums"][PublicEnumNameOrOptions]
254
- : never
1
+ export type Json =
2
+ | string
3
+ | number
4
+ | boolean
5
+ | null
6
+ | { [key: string]: Json | undefined }
7
+ | Json[]
8
+
9
+ export type Database = {
10
+ public: {
11
+ Tables: {
12
+ beatmaps: {
13
+ Row: {
14
+ beatmapHash: string
15
+ created_at: string
16
+ difficulty: number | null
17
+ length: number | null
18
+ noteCount: number | null
19
+ playcount: number | null
20
+ ranked: boolean | null
21
+ title: string | null
22
+ }
23
+ Insert: {
24
+ beatmapHash: string
25
+ created_at?: string
26
+ difficulty?: number | null
27
+ length?: number | null
28
+ noteCount?: number | null
29
+ playcount?: number | null
30
+ ranked?: boolean | null
31
+ title?: string | null
32
+ }
33
+ Update: {
34
+ beatmapHash?: string
35
+ created_at?: string
36
+ difficulty?: number | null
37
+ length?: number | null
38
+ noteCount?: number | null
39
+ playcount?: number | null
40
+ ranked?: boolean | null
41
+ title?: string | null
42
+ }
43
+ Relationships: []
44
+ }
45
+ profiles: {
46
+ Row: {
47
+ about_me: string | null
48
+ avatar_url: string | null
49
+ badges: Json | null
50
+ computedUsername: string | null
51
+ created_at: number | null
52
+ flag: string | null
53
+ id: number
54
+ play_count: number | null
55
+ skill_points: number | null
56
+ squares_hit: number | null
57
+ total_score: number | null
58
+ uid: string | null
59
+ username: string | null
60
+ verified: boolean | null
61
+ }
62
+ Insert: {
63
+ about_me?: string | null
64
+ avatar_url?: string | null
65
+ badges?: Json | null
66
+ computedUsername?: string | null
67
+ created_at?: number | null
68
+ flag?: string | null
69
+ id?: number
70
+ play_count?: number | null
71
+ skill_points?: number | null
72
+ squares_hit?: number | null
73
+ total_score?: number | null
74
+ uid?: string | null
75
+ username?: string | null
76
+ verified?: boolean | null
77
+ }
78
+ Update: {
79
+ about_me?: string | null
80
+ avatar_url?: string | null
81
+ badges?: Json | null
82
+ computedUsername?: string | null
83
+ created_at?: number | null
84
+ flag?: string | null
85
+ id?: number
86
+ play_count?: number | null
87
+ skill_points?: number | null
88
+ squares_hit?: number | null
89
+ total_score?: number | null
90
+ uid?: string | null
91
+ username?: string | null
92
+ verified?: boolean | null
93
+ }
94
+ Relationships: [
95
+ {
96
+ foreignKeyName: "profiles_uid_fkey"
97
+ columns: ["uid"]
98
+ isOneToOne: true
99
+ referencedRelation: "users"
100
+ referencedColumns: ["id"]
101
+ },
102
+ ]
103
+ }
104
+ scores: {
105
+ Row: {
106
+ awarded_sp: number | null
107
+ beatmapHash: string | null
108
+ created_at: string
109
+ id: number
110
+ misses: number | null
111
+ passed: boolean | null
112
+ replayHwid: string | null
113
+ songId: string | null
114
+ userId: number | null
115
+ }
116
+ Insert: {
117
+ awarded_sp?: number | null
118
+ beatmapHash?: string | null
119
+ created_at?: string
120
+ id?: number
121
+ misses?: number | null
122
+ passed?: boolean | null
123
+ replayHwid?: string | null
124
+ songId?: string | null
125
+ userId?: number | null
126
+ }
127
+ Update: {
128
+ awarded_sp?: number | null
129
+ beatmapHash?: string | null
130
+ created_at?: string
131
+ id?: number
132
+ misses?: number | null
133
+ passed?: boolean | null
134
+ replayHwid?: string | null
135
+ songId?: string | null
136
+ userId?: number | null
137
+ }
138
+ Relationships: [
139
+ {
140
+ foreignKeyName: "scores_beatmapHash_fkey"
141
+ columns: ["beatmapHash"]
142
+ isOneToOne: false
143
+ referencedRelation: "beatmaps"
144
+ referencedColumns: ["beatmapHash"]
145
+ },
146
+ {
147
+ foreignKeyName: "scores_userId_fkey"
148
+ columns: ["userId"]
149
+ isOneToOne: false
150
+ referencedRelation: "profiles"
151
+ referencedColumns: ["id"]
152
+ },
153
+ ]
154
+ }
155
+ }
156
+ Views: {
157
+ [_ in never]: never
158
+ }
159
+ Functions: {
160
+ [_ in never]: never
161
+ }
162
+ Enums: {
163
+ [_ in never]: never
164
+ }
165
+ CompositeTypes: {
166
+ [_ in never]: never
167
+ }
168
+ }
169
+ }
170
+
171
+ type PublicSchema = Database[Extract<keyof Database, "public">]
172
+
173
+ export type Tables<
174
+ PublicTableNameOrOptions extends
175
+ | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
176
+ | { schema: keyof Database },
177
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
178
+ ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
179
+ Database[PublicTableNameOrOptions["schema"]]["Views"])
180
+ : never = never,
181
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
182
+ ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
183
+ Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
184
+ Row: infer R
185
+ }
186
+ ? R
187
+ : never
188
+ : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
189
+ PublicSchema["Views"])
190
+ ? (PublicSchema["Tables"] &
191
+ PublicSchema["Views"])[PublicTableNameOrOptions] extends {
192
+ Row: infer R
193
+ }
194
+ ? R
195
+ : never
196
+ : never
197
+
198
+ export type TablesInsert<
199
+ PublicTableNameOrOptions extends
200
+ | keyof PublicSchema["Tables"]
201
+ | { schema: keyof Database },
202
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
203
+ ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
204
+ : never = never,
205
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
206
+ ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
207
+ Insert: infer I
208
+ }
209
+ ? I
210
+ : never
211
+ : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
212
+ ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
213
+ Insert: infer I
214
+ }
215
+ ? I
216
+ : never
217
+ : never
218
+
219
+ export type TablesUpdate<
220
+ PublicTableNameOrOptions extends
221
+ | keyof PublicSchema["Tables"]
222
+ | { schema: keyof Database },
223
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
224
+ ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
225
+ : never = never,
226
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
227
+ ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
228
+ Update: infer U
229
+ }
230
+ ? U
231
+ : never
232
+ : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
233
+ ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
234
+ Update: infer U
235
+ }
236
+ ? U
237
+ : never
238
+ : never
239
+
240
+ export type Enums<
241
+ PublicEnumNameOrOptions extends
242
+ | keyof PublicSchema["Enums"]
243
+ | { schema: keyof Database },
244
+ EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
245
+ ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
246
+ : never = never,
247
+ > = PublicEnumNameOrOptions extends { schema: keyof Database }
248
+ ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
249
+ : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
250
+ ? PublicSchema["Enums"][PublicEnumNameOrOptions]
251
+ : never