From dffd763da47669a88cafceec3eff7a084e7d2f97 Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Sat, 5 Jul 2025 15:48:12 +0200 Subject: [PATCH] Complete some work around the channel management --- api/src/database.types.ts | 429 ++++++++++--------- api/src/tablo.ts | 28 +- sql/12_update_tablos_id_to_random_string.sql | 9 +- ui/src/hooks/invite.ts | 4 +- ui/src/types/database.types.ts | 429 ++++++++++--------- 5 files changed, 499 insertions(+), 400 deletions(-) diff --git a/api/src/database.types.ts b/api/src/database.types.ts index 665cc26..c9294b8 100644 --- a/api/src/database.types.ts +++ b/api/src/database.types.ts @@ -4,298 +4,339 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[]; + | Json[] export type Database = { public: { Tables: { devis: { Row: { - client_email: string; - created_at: string; - date: string; - due_date: string; - id: string; - items: Json; - notes: string | null; - number: string; - status: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms: string | null; - total: number; - updated_at: string; - user_id: string; - }; + client_email: string + created_at: string + date: string + due_date: string + id: string + items: Json + notes: string | null + number: string + status: Database["public"]["Enums"]["devis_status"] + subtotal: number + tax: number + terms: string | null + total: number + updated_at: string + user_id: string + } Insert: { - client_email: string; - created_at?: string; - date: string; - due_date: string; - id?: string; - items?: Json; - notes?: string | null; - number: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms?: string | null; - total: number; - updated_at?: string; - user_id: string; - }; + client_email: string + created_at?: string + date: string + due_date: string + id?: string + items?: Json + notes?: string | null + number: string + status?: Database["public"]["Enums"]["devis_status"] + subtotal: number + tax: number + terms?: string | null + total: number + updated_at?: string + user_id: string + } Update: { - client_email?: string; - created_at?: string; - date?: string; - due_date?: string; - id?: string; - items?: Json; - notes?: string | null; - number?: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal?: number; - tax?: number; - terms?: string | null; - total?: number; - updated_at?: string; - user_id?: string; - }; - Relationships: []; - }; + client_email?: string + created_at?: string + date?: string + due_date?: string + id?: string + items?: Json + notes?: string | null + number?: string + status?: Database["public"]["Enums"]["devis_status"] + subtotal?: number + tax?: number + terms?: string | null + total?: number + updated_at?: string + user_id?: string + } + Relationships: [] + } feedbacks: { Row: { - created_at: string | null; - fd_type: string; - id: number; - message: string; - user_id: string; - }; + created_at: string | null + fd_type: string + id: number + message: string + user_id: string + } Insert: { - created_at?: string | null; - fd_type: string; - id?: number; - message: string; - user_id: string; - }; + created_at?: string | null + fd_type: string + id?: number + message: string + user_id: string + } Update: { - created_at?: string | null; - fd_type?: string; - id?: number; - message?: string; - user_id?: string; - }; - Relationships: []; - }; + created_at?: string | null + fd_type?: string + id?: number + message?: string + user_id?: string + } + Relationships: [] + } profiles: { Row: { - avatar_url: string | null; - email: string | null; - id: string; - name: string | null; - }; + avatar_url: string | null + email: string | null + id: string + name: string | null + } Insert: { - avatar_url?: string | null; - email?: string | null; - id: string; - name?: string | null; - }; + avatar_url?: string | null + email?: string | null + id: string + name?: string | null + } Update: { - avatar_url?: string | null; - email?: string | null; - id?: string; - name?: string | null; - }; - Relationships: []; - }; - tablo_invites: { + avatar_url?: string | null + email?: string | null + id?: string + name?: string | null + } + Relationships: [] + } + tablo_access: { Row: { - id: number; - invite_token: string; - invited_by: string; - invited_email: string; - tablo_id: string; - }; + created_at: string | null + granted_by: string + id: number + is_active: boolean | null + is_admin: boolean | null + tablo_id: string + user_id: string + } Insert: { - id?: number; - invite_token: string; - invited_by: string; - invited_email: string; - tablo_id: string; - }; + created_at?: string | null + granted_by: string + id?: number + is_active?: boolean | null + is_admin?: boolean | null + tablo_id: string + user_id: string + } Update: { - id?: number; - invite_token?: string; - invited_by?: string; - invited_email?: string; - tablo_id?: string; - }; + created_at?: string | null + granted_by?: string + id?: number + is_active?: boolean | null + is_admin?: boolean | null + tablo_id?: string + user_id?: string + } Relationships: [ { - foreignKeyName: "fk_tablo_invitations_tablo_id"; - columns: ["tablo_id"]; - isOneToOne: false; - referencedRelation: "tablos"; - referencedColumns: ["id"]; - } - ]; - }; + foreignKeyName: "fk_tablo_access_tablo_id" + columns: ["tablo_id"] + isOneToOne: false + referencedRelation: "tablos" + referencedColumns: ["id"] + }, + ] + } + tablo_invites: { + Row: { + id: number + invite_token: string + invited_by: string + invited_email: string + tablo_id: string + } + Insert: { + id?: number + invite_token: string + invited_by: string + invited_email: string + tablo_id: string + } + Update: { + id?: number + invite_token?: string + invited_by?: string + invited_email?: string + tablo_id?: string + } + Relationships: [ + { + foreignKeyName: "fk_tablo_invitations_tablo_id" + columns: ["tablo_id"] + isOneToOne: false + referencedRelation: "tablos" + referencedColumns: ["id"] + }, + ] + } tablos: { Row: { - color: string | null; - created_at: string | null; - deleted_at: string | null; - id: string; - image: string | null; - name: string; - owner_id: string; - position: number; - status: string; - }; + color: string | null + created_at: string | null + deleted_at: string | null + id: string + image: string | null + name: string + owner_id: string + position: number + status: string + } Insert: { - color?: string | null; - created_at?: string | null; - deleted_at?: string | null; - id?: string; - image?: string | null; - name: string; - owner_id: string; - position?: number; - status?: string; - }; + color?: string | null + created_at?: string | null + deleted_at?: string | null + id?: string + image?: string | null + name: string + owner_id: string + position?: number + status?: string + } Update: { - color?: string | null; - created_at?: string | null; - deleted_at?: string | null; - id?: string; - image?: string | null; - name?: string; - owner_id?: string; - position?: number; - status?: string; - }; - Relationships: []; - }; - }; + color?: string | null + created_at?: string | null + deleted_at?: string | null + id?: string + image?: string | null + name?: string + owner_id?: string + position?: number + status?: string + } + Relationships: [] + } + } Views: { - [_ in never]: never; - }; + [_ in never]: never + } Functions: { - [_ in never]: never; - }; + generate_random_string: { + Args: { length?: number } + Returns: string + } + } Enums: { - devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired"; - }; + devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired" + } CompositeTypes: { - [_ in never]: never; - }; - }; -}; + [_ in never]: never + } + } +} -type DefaultSchema = Database[Extract]; +type DefaultSchema = Database[Extract] export type Tables< DefaultSchemaTableNameOrOptions extends | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R; + Row: infer R } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & - DefaultSchema["Views"]) - ? (DefaultSchema["Tables"] & - DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { - Row: infer R; - } - ? R + DefaultSchema["Views"]) + ? (DefaultSchema["Tables"] & + DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { + Row: infer R + } + ? R + : never : never - : never; export type TablesInsert< DefaultSchemaTableNameOrOptions extends | keyof DefaultSchema["Tables"] | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I; + Insert: infer I } ? I : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Insert: infer I; - } - ? I + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never : never - : never; export type TablesUpdate< DefaultSchemaTableNameOrOptions extends | keyof DefaultSchema["Tables"] | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U; + Update: infer U } ? U : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Update: infer U; - } - ? U + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Update: infer U + } + ? U + : never : never - : never; export type Enums< DefaultSchemaEnumNameOrOptions extends | keyof DefaultSchema["Enums"] | { schema: keyof Database }, EnumName extends DefaultSchemaEnumNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] - : never = never + : never = never, > = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] - ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] - : never; + ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] + : never export type CompositeTypes< PublicCompositeTypeNameOrOptions extends | keyof DefaultSchema["CompositeTypes"] | { schema: keyof Database }, CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] - : never = never + : never = never, > = PublicCompositeTypeNameOrOptions extends { schema: keyof Database } ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] - ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] - : never; + ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never export const Constants = { public: { @@ -303,4 +344,4 @@ export const Constants = { devis_status: ["draft", "sent", "accepted", "rejected", "expired"], }, }, -} as const; +} as const diff --git a/api/src/tablo.ts b/api/src/tablo.ts index bf4d705..51bee56 100644 --- a/api/src/tablo.ts +++ b/api/src/tablo.ts @@ -43,15 +43,26 @@ tabloRouter.post("/create", async (c) => { return c.json({ error: error.message }, 500); } + // TODO: find a better way to get the tablo id + const { data: tabloData, error: tabloError } = await supabase + .from("tablos") + .select("id") + .eq("owner_id", user.id) + .eq("name", tablo.name) + .single(); + + if (tabloError) { + return c.json({ error: tabloError.message }, 500); + } + const streamServerClient = c.get("streamServerClient"); - const channel = streamServerClient.channel("messaging", tablo.name, { + const channel = streamServerClient.channel("messaging", tabloData.id, { // @ts-ignore name: tablo.name, created_by_id: user.id, members: [user.id], }); await channel.create(); - await channel.addMembers([user.id]); return c.json({ message: "Tablo created successfully" }); }); @@ -110,13 +121,14 @@ tabloRouter.post("/invite", async (c) => { }); }); -tabloRouter.post("/join-tablo", async (c) => { +tabloRouter.post("/join", async (c) => { const { token } = await c.req.json(); const joiner = c.get("user"); const supabase = c.get("supabase"); + const streamServerClient = c.get("streamServerClient"); - const { data, error } = await supabase + const { data: inviteData, error } = await supabase .from("tablo_invites") .select("id, tablo_id, invited_by") .eq("invite_token", token) @@ -127,11 +139,11 @@ tabloRouter.post("/join-tablo", async (c) => { return c.json({ error: error.message }, 500); } - if (!data) { + if (!inviteData) { return c.json({ error: "Invalid token or email" }, 400); } - const { id: invite_id, tablo_id, invited_by } = data; + const { id: invite_id, tablo_id, invited_by } = inviteData; const { error: tabloAccessError } = await supabase .from("tablo_access") @@ -150,5 +162,9 @@ tabloRouter.post("/join-tablo", async (c) => { } await supabase.from("tablo_invites").delete().eq("id", invite_id); + + const channel = streamServerClient.channel("messaging", tablo_id); + await channel.addMembers([joiner.id]); + return c.json({ message: "Tablo joined successfully" }); }); diff --git a/sql/12_update_tablos_id_to_random_string.sql b/sql/12_update_tablos_id_to_random_string.sql index eebf62b..3d46fd0 100644 --- a/sql/12_update_tablos_id_to_random_string.sql +++ b/sql/12_update_tablos_id_to_random_string.sql @@ -43,9 +43,10 @@ UPDATE tablo_access SET new_tablo_id = ( ); -- Step 7: Drop old columns -ALTER TABLE tablos DROP COLUMN id; -ALTER TABLE tablo_invites DROP COLUMN tablo_id; -ALTER TABLE tablo_access DROP COLUMN tablo_id; +ALTER TABLE tablo_invites DROP COLUMN tablo_id CASCADE; +ALTER TABLE tablo_access DROP COLUMN tablo_id CASCADE; +ALTER TABLE tablos DROP COLUMN id CASCADE; + -- Step 8: Rename new columns to original names ALTER TABLE tablos RENAME COLUMN new_id TO id; @@ -112,4 +113,4 @@ COMMENT ON COLUMN tablo_invites.tablo_id IS 'Foreign key reference to tablos.id (24-character string)'; COMMENT ON COLUMN tablo_access.tablo_id IS - 'Foreign key reference to tablos.id (24-character string)'; \ No newline at end of file + 'Foreign key reference to tablos.id (24-character string)'; diff --git a/ui/src/hooks/invite.ts b/ui/src/hooks/invite.ts index c4c5f7b..39885c0 100644 --- a/ui/src/hooks/invite.ts +++ b/ui/src/hooks/invite.ts @@ -14,7 +14,7 @@ export const useInviteUser = () => { tablo_id: number; }) => { const { data } = await api.post( - "/api/v1/users/invite", + "/api/v1/tablos/invite", { email, tablo_id, @@ -36,7 +36,7 @@ export const useJoinTablo = () => { const { mutate } = useMutation({ mutationFn: async ({ token }: { token: string }) => { const { data } = await api.post( - "/api/v1/users/join-tablo", + "/api/v1/tablos/join", { token }, { headers: { diff --git a/ui/src/types/database.types.ts b/ui/src/types/database.types.ts index 665cc26..c9294b8 100644 --- a/ui/src/types/database.types.ts +++ b/ui/src/types/database.types.ts @@ -4,298 +4,339 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[]; + | Json[] export type Database = { public: { Tables: { devis: { Row: { - client_email: string; - created_at: string; - date: string; - due_date: string; - id: string; - items: Json; - notes: string | null; - number: string; - status: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms: string | null; - total: number; - updated_at: string; - user_id: string; - }; + client_email: string + created_at: string + date: string + due_date: string + id: string + items: Json + notes: string | null + number: string + status: Database["public"]["Enums"]["devis_status"] + subtotal: number + tax: number + terms: string | null + total: number + updated_at: string + user_id: string + } Insert: { - client_email: string; - created_at?: string; - date: string; - due_date: string; - id?: string; - items?: Json; - notes?: string | null; - number: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal: number; - tax: number; - terms?: string | null; - total: number; - updated_at?: string; - user_id: string; - }; + client_email: string + created_at?: string + date: string + due_date: string + id?: string + items?: Json + notes?: string | null + number: string + status?: Database["public"]["Enums"]["devis_status"] + subtotal: number + tax: number + terms?: string | null + total: number + updated_at?: string + user_id: string + } Update: { - client_email?: string; - created_at?: string; - date?: string; - due_date?: string; - id?: string; - items?: Json; - notes?: string | null; - number?: string; - status?: Database["public"]["Enums"]["devis_status"]; - subtotal?: number; - tax?: number; - terms?: string | null; - total?: number; - updated_at?: string; - user_id?: string; - }; - Relationships: []; - }; + client_email?: string + created_at?: string + date?: string + due_date?: string + id?: string + items?: Json + notes?: string | null + number?: string + status?: Database["public"]["Enums"]["devis_status"] + subtotal?: number + tax?: number + terms?: string | null + total?: number + updated_at?: string + user_id?: string + } + Relationships: [] + } feedbacks: { Row: { - created_at: string | null; - fd_type: string; - id: number; - message: string; - user_id: string; - }; + created_at: string | null + fd_type: string + id: number + message: string + user_id: string + } Insert: { - created_at?: string | null; - fd_type: string; - id?: number; - message: string; - user_id: string; - }; + created_at?: string | null + fd_type: string + id?: number + message: string + user_id: string + } Update: { - created_at?: string | null; - fd_type?: string; - id?: number; - message?: string; - user_id?: string; - }; - Relationships: []; - }; + created_at?: string | null + fd_type?: string + id?: number + message?: string + user_id?: string + } + Relationships: [] + } profiles: { Row: { - avatar_url: string | null; - email: string | null; - id: string; - name: string | null; - }; + avatar_url: string | null + email: string | null + id: string + name: string | null + } Insert: { - avatar_url?: string | null; - email?: string | null; - id: string; - name?: string | null; - }; + avatar_url?: string | null + email?: string | null + id: string + name?: string | null + } Update: { - avatar_url?: string | null; - email?: string | null; - id?: string; - name?: string | null; - }; - Relationships: []; - }; - tablo_invites: { + avatar_url?: string | null + email?: string | null + id?: string + name?: string | null + } + Relationships: [] + } + tablo_access: { Row: { - id: number; - invite_token: string; - invited_by: string; - invited_email: string; - tablo_id: string; - }; + created_at: string | null + granted_by: string + id: number + is_active: boolean | null + is_admin: boolean | null + tablo_id: string + user_id: string + } Insert: { - id?: number; - invite_token: string; - invited_by: string; - invited_email: string; - tablo_id: string; - }; + created_at?: string | null + granted_by: string + id?: number + is_active?: boolean | null + is_admin?: boolean | null + tablo_id: string + user_id: string + } Update: { - id?: number; - invite_token?: string; - invited_by?: string; - invited_email?: string; - tablo_id?: string; - }; + created_at?: string | null + granted_by?: string + id?: number + is_active?: boolean | null + is_admin?: boolean | null + tablo_id?: string + user_id?: string + } Relationships: [ { - foreignKeyName: "fk_tablo_invitations_tablo_id"; - columns: ["tablo_id"]; - isOneToOne: false; - referencedRelation: "tablos"; - referencedColumns: ["id"]; - } - ]; - }; + foreignKeyName: "fk_tablo_access_tablo_id" + columns: ["tablo_id"] + isOneToOne: false + referencedRelation: "tablos" + referencedColumns: ["id"] + }, + ] + } + tablo_invites: { + Row: { + id: number + invite_token: string + invited_by: string + invited_email: string + tablo_id: string + } + Insert: { + id?: number + invite_token: string + invited_by: string + invited_email: string + tablo_id: string + } + Update: { + id?: number + invite_token?: string + invited_by?: string + invited_email?: string + tablo_id?: string + } + Relationships: [ + { + foreignKeyName: "fk_tablo_invitations_tablo_id" + columns: ["tablo_id"] + isOneToOne: false + referencedRelation: "tablos" + referencedColumns: ["id"] + }, + ] + } tablos: { Row: { - color: string | null; - created_at: string | null; - deleted_at: string | null; - id: string; - image: string | null; - name: string; - owner_id: string; - position: number; - status: string; - }; + color: string | null + created_at: string | null + deleted_at: string | null + id: string + image: string | null + name: string + owner_id: string + position: number + status: string + } Insert: { - color?: string | null; - created_at?: string | null; - deleted_at?: string | null; - id?: string; - image?: string | null; - name: string; - owner_id: string; - position?: number; - status?: string; - }; + color?: string | null + created_at?: string | null + deleted_at?: string | null + id?: string + image?: string | null + name: string + owner_id: string + position?: number + status?: string + } Update: { - color?: string | null; - created_at?: string | null; - deleted_at?: string | null; - id?: string; - image?: string | null; - name?: string; - owner_id?: string; - position?: number; - status?: string; - }; - Relationships: []; - }; - }; + color?: string | null + created_at?: string | null + deleted_at?: string | null + id?: string + image?: string | null + name?: string + owner_id?: string + position?: number + status?: string + } + Relationships: [] + } + } Views: { - [_ in never]: never; - }; + [_ in never]: never + } Functions: { - [_ in never]: never; - }; + generate_random_string: { + Args: { length?: number } + Returns: string + } + } Enums: { - devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired"; - }; + devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired" + } CompositeTypes: { - [_ in never]: never; - }; - }; -}; + [_ in never]: never + } + } +} -type DefaultSchema = Database[Extract]; +type DefaultSchema = Database[Extract] export type Tables< DefaultSchemaTableNameOrOptions extends | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R; + Row: infer R } ? R : never : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & - DefaultSchema["Views"]) - ? (DefaultSchema["Tables"] & - DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { - Row: infer R; - } - ? R + DefaultSchema["Views"]) + ? (DefaultSchema["Tables"] & + DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { + Row: infer R + } + ? R + : never : never - : never; export type TablesInsert< DefaultSchemaTableNameOrOptions extends | keyof DefaultSchema["Tables"] | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I; + Insert: infer I } ? I : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Insert: infer I; - } - ? I + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never : never - : never; export type TablesUpdate< DefaultSchemaTableNameOrOptions extends | keyof DefaultSchema["Tables"] | { schema: keyof Database }, TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never + : never = never, > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U; + Update: infer U } ? U : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Update: infer U; - } - ? U + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Update: infer U + } + ? U + : never : never - : never; export type Enums< DefaultSchemaEnumNameOrOptions extends | keyof DefaultSchema["Enums"] | { schema: keyof Database }, EnumName extends DefaultSchemaEnumNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] - : never = never + : never = never, > = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database } ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] - ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] - : never; + ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] + : never export type CompositeTypes< PublicCompositeTypeNameOrOptions extends | keyof DefaultSchema["CompositeTypes"] | { schema: keyof Database }, CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { - schema: keyof Database; + schema: keyof Database } ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] - : never = never + : never = never, > = PublicCompositeTypeNameOrOptions extends { schema: keyof Database } ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] - ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] - : never; + ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never export const Constants = { public: { @@ -303,4 +344,4 @@ export const Constants = { devis_status: ["draft", "sent", "accepted", "rejected", "expired"], }, }, -} as const; +} as const