|
| 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 | + // Allows to automatically instantiate createClient with right options |
| 11 | + // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY) |
| 12 | + __InternalSupabase: { |
| 13 | + PostgrestVersion: "13.0.4" |
| 14 | + } |
| 15 | + public: { |
| 16 | + Tables: { |
| 17 | + [_ in never]: never |
| 18 | + } |
| 19 | + Views: { |
| 20 | + [_ in never]: never |
| 21 | + } |
| 22 | + Functions: { |
| 23 | + [_ in never]: never |
| 24 | + } |
| 25 | + Enums: { |
| 26 | + [_ in never]: never |
| 27 | + } |
| 28 | + CompositeTypes: { |
| 29 | + [_ in never]: never |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase"> |
| 35 | + |
| 36 | +type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">] |
| 37 | + |
| 38 | +export type Tables< |
| 39 | + DefaultSchemaTableNameOrOptions extends |
| 40 | + | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) |
| 41 | + | { schema: keyof DatabaseWithoutInternals }, |
| 42 | + TableName extends DefaultSchemaTableNameOrOptions extends { |
| 43 | + schema: keyof DatabaseWithoutInternals |
| 44 | + } |
| 45 | + ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & |
| 46 | + DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) |
| 47 | + : never = never, |
| 48 | +> = DefaultSchemaTableNameOrOptions extends { |
| 49 | + schema: keyof DatabaseWithoutInternals |
| 50 | +} |
| 51 | + ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & |
| 52 | + DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { |
| 53 | + Row: infer R |
| 54 | + } |
| 55 | + ? R |
| 56 | + : never |
| 57 | + : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & |
| 58 | + DefaultSchema["Views"]) |
| 59 | + ? (DefaultSchema["Tables"] & |
| 60 | + DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { |
| 61 | + Row: infer R |
| 62 | + } |
| 63 | + ? R |
| 64 | + : never |
| 65 | + : never |
| 66 | + |
| 67 | +export type TablesInsert< |
| 68 | + DefaultSchemaTableNameOrOptions extends |
| 69 | + | keyof DefaultSchema["Tables"] |
| 70 | + | { schema: keyof DatabaseWithoutInternals }, |
| 71 | + TableName extends DefaultSchemaTableNameOrOptions extends { |
| 72 | + schema: keyof DatabaseWithoutInternals |
| 73 | + } |
| 74 | + ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] |
| 75 | + : never = never, |
| 76 | +> = DefaultSchemaTableNameOrOptions extends { |
| 77 | + schema: keyof DatabaseWithoutInternals |
| 78 | +} |
| 79 | + ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { |
| 80 | + Insert: infer I |
| 81 | + } |
| 82 | + ? I |
| 83 | + : never |
| 84 | + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] |
| 85 | + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { |
| 86 | + Insert: infer I |
| 87 | + } |
| 88 | + ? I |
| 89 | + : never |
| 90 | + : never |
| 91 | + |
| 92 | +export type TablesUpdate< |
| 93 | + DefaultSchemaTableNameOrOptions extends |
| 94 | + | keyof DefaultSchema["Tables"] |
| 95 | + | { schema: keyof DatabaseWithoutInternals }, |
| 96 | + TableName extends DefaultSchemaTableNameOrOptions extends { |
| 97 | + schema: keyof DatabaseWithoutInternals |
| 98 | + } |
| 99 | + ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] |
| 100 | + : never = never, |
| 101 | +> = DefaultSchemaTableNameOrOptions extends { |
| 102 | + schema: keyof DatabaseWithoutInternals |
| 103 | +} |
| 104 | + ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { |
| 105 | + Update: infer U |
| 106 | + } |
| 107 | + ? U |
| 108 | + : never |
| 109 | + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] |
| 110 | + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { |
| 111 | + Update: infer U |
| 112 | + } |
| 113 | + ? U |
| 114 | + : never |
| 115 | + : never |
| 116 | + |
| 117 | +export type Enums< |
| 118 | + DefaultSchemaEnumNameOrOptions extends |
| 119 | + | keyof DefaultSchema["Enums"] |
| 120 | + | { schema: keyof DatabaseWithoutInternals }, |
| 121 | + EnumName extends DefaultSchemaEnumNameOrOptions extends { |
| 122 | + schema: keyof DatabaseWithoutInternals |
| 123 | + } |
| 124 | + ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] |
| 125 | + : never = never, |
| 126 | +> = DefaultSchemaEnumNameOrOptions extends { |
| 127 | + schema: keyof DatabaseWithoutInternals |
| 128 | +} |
| 129 | + ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] |
| 130 | + : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] |
| 131 | + ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] |
| 132 | + : never |
| 133 | + |
| 134 | +export type CompositeTypes< |
| 135 | + PublicCompositeTypeNameOrOptions extends |
| 136 | + | keyof DefaultSchema["CompositeTypes"] |
| 137 | + | { schema: keyof DatabaseWithoutInternals }, |
| 138 | + CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { |
| 139 | + schema: keyof DatabaseWithoutInternals |
| 140 | + } |
| 141 | + ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] |
| 142 | + : never = never, |
| 143 | +> = PublicCompositeTypeNameOrOptions extends { |
| 144 | + schema: keyof DatabaseWithoutInternals |
| 145 | +} |
| 146 | + ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] |
| 147 | + : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] |
| 148 | + ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] |
| 149 | + : never |
| 150 | + |
| 151 | +export const Constants = { |
| 152 | + public: { |
| 153 | + Enums: {}, |
| 154 | + }, |
| 155 | +} as const |
0 commit comments