Skip to content

Commit

Permalink
Merge pull request #16 from bklaing2/dev
Browse files Browse the repository at this point in the history
Moved to multi Supabase project
  • Loading branch information
bklaing2 authored Jun 23, 2024
2 parents 6fda8a2 + ac72706 commit 6850c74
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 39 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.svelte-kit
/supabase
playlist image jpeg 64.txt
playlist image png 64.txt
*.xcf
*.xcf
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
"format": "prettier --write .",
"db:types": "supabase gen types typescript --linked --schema autofy > src/lib/types.db.ts"
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
Expand All @@ -26,6 +27,7 @@
"eslint-plugin-svelte": "^2.30.0",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"supabase": "^1.172.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/server/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ENV, SUPABASE_ANON_KEY, SUPABASE_SERVICE_KEY, SUPABASE_URL } from "$env
import { redirect, type Cookies } from "@sveltejs/kit";
import { createServerClient } from "@supabase/ssr";

import type { Database } from "../types";
import type { Database } from "../types.db";
import Tokens from "./tokens";


Expand All @@ -12,7 +12,8 @@ async function Supabase(cookies: Cookies, authorizationCode?: string | null) {
get: (key) => cookies.get(key),
set: (key, value, options) => cookies.set(key, value, { ...options, secure: ENV !== 'DEV' }),
remove: (key, options) => cookies.delete(key, { ...options, secure: ENV !== 'DEV' })
}
},
db: { schema: 'autofy' }
})

if (authorizationCode) {
Expand Down
72 changes: 37 additions & 35 deletions src/lib/types.ts → src/lib/types.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export type Json =
| { [key: string]: Json | undefined }
| Json[]

export interface Database {
public: {
export type Database = {
autofy: {
Tables: {
playlists: {
Row: {
Expand Down Expand Up @@ -47,7 +47,7 @@ export interface Database {
isOneToOne: false
referencedRelation: "users"
referencedColumns: ["id"]
}
},
]
}
tokens: {
Expand All @@ -73,7 +73,7 @@ export interface Database {
isOneToOne: true
referencedRelation: "users"
referencedColumns: ["id"]
}
},
]
}
}
Expand All @@ -92,82 +92,84 @@ export interface Database {
}
}

type PublicSchema = Database[Extract<keyof Database, "public">]

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"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])
: never = never
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
Row: infer R
}
? R
: never
: PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] &
Database["public"]["Views"])
? (Database["public"]["Tables"] &
Database["public"]["Views"])[PublicTableNameOrOptions] extends {
Row: infer R
}
? R
: PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
PublicSchema["Views"])
? (PublicSchema["Tables"] &
PublicSchema["Views"])[PublicTableNameOrOptions] extends {
Row: infer R
}
? R
: never
: never
: never

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"]
: never = never
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Insert: infer I
}
? I
: never
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
Insert: infer I
}
? I
: PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
Insert: infer I
}
? I
: never
: never
: never

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"]
: never = never
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Update: infer U
}
? U
: never
: PublicTableNameOrOptions extends keyof Database["public"]["Tables"]
? Database["public"]["Tables"][PublicTableNameOrOptions] extends {
Update: infer U
}
? U
: PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
Update: infer U
}
? U
: never
: never
: never

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
: never = never,
> = PublicEnumNameOrOptions extends { schema: keyof Database }
? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
: PublicEnumNameOrOptions extends keyof Database["public"]["Enums"]
? Database["public"]["Enums"][PublicEnumNameOrOptions]
: never
: PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
? PublicSchema["Enums"][PublicEnumNameOrOptions]
: never

0 comments on commit 6850c74

Please sign in to comment.