From efebaf3cf739c772c8a1a638a1b98c8c620cb2fe Mon Sep 17 00:00:00 2001 From: Jonathan Grim Date: Sat, 9 Mar 2024 09:32:50 +0100 Subject: [PATCH] generate types --- src/typings/supabase.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/typings/supabase.ts b/src/typings/supabase.ts index 6be9c04..1b440e3 100644 --- a/src/typings/supabase.ts +++ b/src/typings/supabase.ts @@ -1079,9 +1079,11 @@ export type Database = { } } +type PublicSchema = Database[Extract] + export type Tables< PublicTableNameOrOptions extends - | keyof (Database["public"]["Tables"] & Database["public"]["Views"]) + | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & @@ -1094,10 +1096,10 @@ export type Tables< } ? R : never - : PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] & - Database["public"]["Views"]) - ? (Database["public"]["Tables"] & - Database["public"]["Views"])[PublicTableNameOrOptions] extends { + : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & + PublicSchema["Views"]) + ? (PublicSchema["Tables"] & + PublicSchema["Views"])[PublicTableNameOrOptions] extends { Row: infer R } ? R @@ -1106,7 +1108,7 @@ export type Tables< export type TablesInsert< PublicTableNameOrOptions extends - | keyof Database["public"]["Tables"] + | keyof PublicSchema["Tables"] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] @@ -1117,8 +1119,8 @@ export type TablesInsert< } ? I : never - : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] - ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { Insert: infer I } ? I @@ -1127,7 +1129,7 @@ export type TablesInsert< export type TablesUpdate< PublicTableNameOrOptions extends - | keyof Database["public"]["Tables"] + | keyof PublicSchema["Tables"] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] @@ -1138,8 +1140,8 @@ export type TablesUpdate< } ? U : never - : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] - ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { Update: infer U } ? U @@ -1148,14 +1150,14 @@ export type TablesUpdate< export type Enums< PublicEnumNameOrOptions extends - | keyof Database["public"]["Enums"] + | keyof PublicSchema["Enums"] | { schema: keyof Database }, EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] : never = never, > = PublicEnumNameOrOptions extends { schema: keyof Database } ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] - : PublicEnumNameOrOptions extends keyof Database["public"]["Enums"] - ? Database["public"]["Enums"][PublicEnumNameOrOptions] + : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] + ? PublicSchema["Enums"][PublicEnumNameOrOptions] : never