Skip to content

Commit

Permalink
Merge pull request #2 from bklaing2/change-supabase-project
Browse files Browse the repository at this point in the history
changed Supabase schema
  • Loading branch information
bklaing2 authored Jun 28, 2024
2 parents 8c6be27 + d952fce commit d3658c0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 83 deletions.
10 changes: 6 additions & 4 deletions src/lib/server/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>(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<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!, {
cookies: {
get: undefined,
Expand All @@ -27,4 +29,4 @@ export function Service () {
})
}

export default Supabase
export default Supabase
138 changes: 59 additions & 79 deletions src/lib/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,40 @@ 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
start_percentage: number
}
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
start_percentage: number
}
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: {
Expand All @@ -70,7 +50,7 @@ export type Database = {
[_ in never]: never
}
Enums: {
AUDIO_CATEGORY: "sfx" | "ambience" | "music"
[_ in never]: never
}
CompositeTypes: {
[_ in never]: never
Expand All @@ -82,80 +62,80 @@ type PublicSchema = Database[Extract<keyof Database, "public">]

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

0 comments on commit d3658c0

Please sign in to comment.