rhythia-api 101.0.0 → 102.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
 
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
  })
@@ -94,8 +94,27 @@ export async function handler(
94
94
  .eq("userId", data.id)
95
95
  .neq("awarded_sp", 0)
96
96
  .eq("passed", true)
97
- .order("awarded_sp", { ascending: false })
98
- .limit(10);
97
+ .order("awarded_sp", { ascending: false });
98
+
99
+ if (scores2 == null) return NextResponse.json({ error: "No scores" });
100
+
101
+ let hashMap: Record<string, { awarded_sp: number; score: any }> = {};
102
+
103
+ for (const score of scores2) {
104
+ const { beatmapHash, awarded_sp } = score;
105
+
106
+ if (!beatmapHash || !awarded_sp) continue;
107
+
108
+ if (!hashMap[beatmapHash] || hashMap[beatmapHash].awarded_sp < awarded_sp) {
109
+ hashMap[beatmapHash] = { awarded_sp, score };
110
+ }
111
+ }
112
+
113
+ const values = Object.values(hashMap);
114
+ let vals = values
115
+ .sort((a, b) => b.awarded_sp - a.awarded_sp)
116
+ .slice(0, 10)
117
+ .map((e) => e.score);
99
118
 
100
119
  return NextResponse.json({
101
120
  lastDay: scores1?.map((s) => ({
@@ -112,7 +131,7 @@ export async function handler(
112
131
  beatmapNotes: s.beatmaps?.noteCount,
113
132
  beatmapTitle: s.beatmaps?.title,
114
133
  })),
115
- top: scores2?.map((s) => ({
134
+ top: vals?.map((s) => ({
116
135
  created_at: s.created_at,
117
136
  id: s.id,
118
137
  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,59 @@ 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,
85
+ noteResults: [],
86
86
  replayHwid: data.relayHwid,
87
87
  songId: data.songId,
88
- triggers: data.triggers,
89
88
  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,
89
+ passed: data.passed,
90
+ misses: data.misses,
91
+ awarded_sp: Math.round(data.sspp * 100) / 100,
93
92
  rank: "A",
94
93
  });
95
94
  console.log("p2");
96
95
 
97
- const p3 = await supabase.from("profiles").upsert({
96
+ let totalSp = 0;
97
+ let { data: scores2, error: errorsp } = await supabase
98
+ .from("scores")
99
+ .select(`awarded_sp,beatmapHash`)
100
+ .eq("userId", userData.id)
101
+ .neq("awarded_sp", 0)
102
+ .eq("passed", true)
103
+ .order("awarded_sp", { ascending: false });
104
+
105
+ if (scores2 == null) return NextResponse.json({ error: "No scores" });
106
+
107
+ let hashMap: Record<string, number> = {};
108
+
109
+ for (const score of scores2) {
110
+ const { beatmapHash, awarded_sp } = score;
111
+
112
+ if (!beatmapHash || !awarded_sp) continue;
113
+
114
+ if (!hashMap[beatmapHash] || hashMap[beatmapHash] < awarded_sp) {
115
+ hashMap[beatmapHash] = awarded_sp;
116
+ }
117
+ }
118
+ let weight = 100;
119
+ const values = Object.values(hashMap);
120
+ values.sort((a, b) => b - a);
121
+
122
+ for (const score of values) {
123
+ totalSp += ((score || 0) * weight) / 100;
124
+ weight -= 1;
125
+
126
+ if (weight == 0) {
127
+ break;
128
+ }
129
+ }
130
+
131
+ await supabase.from("profiles").upsert({
98
132
  id: userData.id,
99
133
  play_count: (userData.play_count || 0) + 1,
100
- squares_hit:
101
- (userData.squares_hit || 0) +
102
- Object.values(data.noteResults).filter((e) => e).length,
134
+ skill_points: Math.round(totalSp * 100) / 100,
135
+ squares_hit: (userData.squares_hit || 0) + data.squareHits,
103
136
  });
104
137
  console.log("p3");
105
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "101.0.0",
3
+ "version": "102.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",
@@ -21,6 +21,7 @@
21
21
  "@vercel/edge": "^1.1.2",
22
22
  "@vercel/node": "^3.2.8",
23
23
  "aws-lambda": "^1.0.7",
24
+ "badwords-list": "^2.0.1-4",
24
25
  "bufferutil": "^4.0.8",
25
26
  "bun": "^1.1.22",
26
27
  "esbuild": "^0.23.0",
@@ -28,7 +29,7 @@
28
29
  "lodash": "^4.17.21",
29
30
  "next": "^14.2.5",
30
31
  "simple-git": "^3.25.0",
31
- "supabase": "^1.190.0",
32
+ "supabase": "^1.191.3",
32
33
  "tsx": "^4.17.0",
33
34
  "utf-8-validate": "^6.0.4",
34
35
  "zod": "^3.23.8"
package/types/database.ts CHANGED
@@ -1,254 +1,260 @@
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
+ noteResults: Json | null
112
+ passed: boolean | null
113
+ rank: string | null
114
+ replayHwid: string | null
115
+ songId: string | null
116
+ triggers: Json | null
117
+ userId: number | null
118
+ }
119
+ Insert: {
120
+ awarded_sp?: number | null
121
+ beatmapHash?: string | null
122
+ created_at?: string
123
+ id?: number
124
+ misses?: number | null
125
+ noteResults?: Json | null
126
+ passed?: boolean | null
127
+ rank?: string | null
128
+ replayHwid?: string | null
129
+ songId?: string | null
130
+ triggers?: Json | null
131
+ userId?: number | null
132
+ }
133
+ Update: {
134
+ awarded_sp?: number | null
135
+ beatmapHash?: string | null
136
+ created_at?: string
137
+ id?: number
138
+ misses?: number | null
139
+ noteResults?: Json | null
140
+ passed?: boolean | null
141
+ rank?: string | null
142
+ replayHwid?: string | null
143
+ songId?: string | null
144
+ triggers?: Json | null
145
+ userId?: number | null
146
+ }
147
+ Relationships: [
148
+ {
149
+ foreignKeyName: "scores_beatmapHash_fkey"
150
+ columns: ["beatmapHash"]
151
+ isOneToOne: false
152
+ referencedRelation: "beatmaps"
153
+ referencedColumns: ["beatmapHash"]
154
+ },
155
+ {
156
+ foreignKeyName: "scores_userId_fkey"
157
+ columns: ["userId"]
158
+ isOneToOne: false
159
+ referencedRelation: "profiles"
160
+ referencedColumns: ["id"]
161
+ },
162
+ ]
163
+ }
164
+ }
165
+ Views: {
166
+ [_ in never]: never
167
+ }
168
+ Functions: {
169
+ [_ in never]: never
170
+ }
171
+ Enums: {
172
+ [_ in never]: never
173
+ }
174
+ CompositeTypes: {
175
+ [_ in never]: never
176
+ }
177
+ }
178
+ }
179
+
180
+ type PublicSchema = Database[Extract<keyof Database, "public">]
181
+
182
+ export type Tables<
183
+ PublicTableNameOrOptions extends
184
+ | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
185
+ | { schema: keyof Database },
186
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
187
+ ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
188
+ Database[PublicTableNameOrOptions["schema"]]["Views"])
189
+ : never = never,
190
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
191
+ ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
192
+ Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
193
+ Row: infer R
194
+ }
195
+ ? R
196
+ : never
197
+ : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
198
+ PublicSchema["Views"])
199
+ ? (PublicSchema["Tables"] &
200
+ PublicSchema["Views"])[PublicTableNameOrOptions] extends {
201
+ Row: infer R
202
+ }
203
+ ? R
204
+ : never
205
+ : never
206
+
207
+ export type TablesInsert<
208
+ PublicTableNameOrOptions extends
209
+ | keyof PublicSchema["Tables"]
210
+ | { schema: keyof Database },
211
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
212
+ ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
213
+ : never = never,
214
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
215
+ ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
216
+ Insert: infer I
217
+ }
218
+ ? I
219
+ : never
220
+ : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
221
+ ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
222
+ Insert: infer I
223
+ }
224
+ ? I
225
+ : never
226
+ : never
227
+
228
+ export type TablesUpdate<
229
+ PublicTableNameOrOptions extends
230
+ | keyof PublicSchema["Tables"]
231
+ | { schema: keyof Database },
232
+ TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
233
+ ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
234
+ : never = never,
235
+ > = PublicTableNameOrOptions extends { schema: keyof Database }
236
+ ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
237
+ Update: infer U
238
+ }
239
+ ? U
240
+ : never
241
+ : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
242
+ ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
243
+ Update: infer U
244
+ }
245
+ ? U
246
+ : never
247
+ : never
248
+
249
+ export type Enums<
250
+ PublicEnumNameOrOptions extends
251
+ | keyof PublicSchema["Enums"]
252
+ | { schema: keyof Database },
253
+ EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
254
+ ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
255
+ : never = never,
256
+ > = PublicEnumNameOrOptions extends { schema: keyof Database }
257
+ ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
258
+ : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
259
+ ? PublicSchema["Enums"][PublicEnumNameOrOptions]
260
+ : never