diff --git a/src/lib/server/supabase.ts b/src/lib/server/supabase.ts index dc75f06..2ab6b89 100644 --- a/src/lib/server/supabase.ts +++ b/src/lib/server/supabase.ts @@ -5,19 +5,21 @@ import type { Database } from "$lib/types/database"; import Tokens from "./tokens"; -async function Supabase (cookies: Cookies) { +async function Supabase(cookies: Cookies) { const supabase = createServerClient(process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!, { cookies: { get: (key) => cookies.get(key), set: (key, value, options) => cookies.set(key, value, { ...options, secure: process.env.ENV! !== 'DEV' }), remove: (key, options) => cookies.delete(key, { ...options, secure: process.env.ENV! !== 'DEV' }) - } + }, + db: { schema: 'optiscape' } + }) return supabase } -export function Service () { +export function Service() { return createServerClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!, { cookies: { get: undefined, @@ -27,4 +29,4 @@ export function Service () { }) } -export default Supabase \ No newline at end of file +export default Supabase diff --git a/src/lib/types/database.ts b/src/lib/types/database.ts index 29a5d79..584e501 100644 --- a/src/lib/types/database.ts +++ b/src/lib/types/database.ts @@ -7,26 +7,14 @@ export type Json = | Json[] export type Database = { - public: { + optiscape: { Tables: { - books: { - Row: { - id: string - } - Insert: { - id?: string - } - Update: { - id?: string - } - Relationships: [] - } keyframes: { Row: { book_id: string - category: Database["public"]["Enums"]["AUDIO_CATEGORY"] + category: "sfx" | "ambience" | "music" end: string | null - end_percentage: number + end_percentage: number | null id: number source: string start: string @@ -34,9 +22,9 @@ export type Database = { } Insert: { book_id: string - category: Database["public"]["Enums"]["AUDIO_CATEGORY"] + category: "sfx" | "ambience" | "music" end?: string | null - end_percentage: number + end_percentage?: number | null id?: number source: string start: string @@ -44,23 +32,15 @@ export type Database = { } Update: { book_id?: string - category?: Database["public"]["Enums"]["AUDIO_CATEGORY"] + category?: "sfx" | "ambience" | "music" end?: string | null - end_percentage?: number + end_percentage?: number | null id?: number source?: string start?: string start_percentage?: number } - Relationships: [ - { - foreignKeyName: "keyframes_book_id_fkey" - columns: ["book_id"] - isOneToOne: false - referencedRelation: "books" - referencedColumns: ["id"] - }, - ] + Relationships: [] } } Views: { @@ -70,7 +50,7 @@ export type Database = { [_ in never]: never } Enums: { - AUDIO_CATEGORY: "sfx" | "ambience" | "music" + [_ in never]: never } CompositeTypes: { [_ in never]: never @@ -82,80 +62,80 @@ type PublicSchema = Database[Extract] export type Tables< PublicTableNameOrOptions extends - | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) - | { schema: keyof Database }, + | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"]) - : never = never, + ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"]) + : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { Row: infer R } - ? R - : never + ? R + : never : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & - PublicSchema["Views"]) - ? (PublicSchema["Tables"] & - PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R - } - ? R - : never - : never + PublicSchema["Views"]) + ? (PublicSchema["Tables"] & + PublicSchema["Views"])[PublicTableNameOrOptions] extends { + Row: infer R + } + ? R + : never + : never export type TablesInsert< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] - | { schema: keyof Database }, + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] - : never = never, + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I - } - ? I - : never + Insert: infer I + } + ? I + : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I - } - ? I - : never - : never + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never + : never export type TablesUpdate< PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] - | { schema: keyof Database }, + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] - : never = never, + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U - } - ? U - : never + Update: infer U + } + ? U + : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U - } - ? U - : never - : never + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Update: infer U + } + ? U + : never + : never export type Enums< PublicEnumNameOrOptions extends - | keyof PublicSchema["Enums"] - | { schema: keyof Database }, + | keyof PublicSchema["Enums"] + | { schema: keyof Database }, EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] - : never = never, + ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + : never = never, > = PublicEnumNameOrOptions extends { schema: keyof Database } ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] - ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never + ? PublicSchema["Enums"][PublicEnumNameOrOptions] + : never