chore(supabase): adopt CLI-generated database.types.ts; db:types scripts pipe through prettier
This commit is contained in:
1 parent
a2e33fe4a2
commit
8b233e5cf0
2 files changed
+54
-61
No files matched your search
+2
-2
@@ -24,8 +24,8 @@
|
||||
"db:stop": "supabase stop",
|
||||
"db:reset": "supabase db reset",
|
||||
"db:test": "supabase test db",
|
||||
"db:types": "supabase gen types typescript --local --schema public > packages/supabase/src/database.types.ts",
|
||||
"db:types:check": "supabase gen types typescript --local --schema public | diff - packages/supabase/src/database.types.ts"
|
||||
"db:types": "supabase gen types typescript --local --schema public | prettier --parser typescript > packages/supabase/src/database.types.ts",
|
||||
"db:types:check": "supabase gen types typescript --local --schema public | prettier --parser typescript | diff - packages/supabase/src/database.types.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"pnpm": "10.13.1",
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
// Database types in the `supabase gen types typescript` format.
|
||||
// Regenerate after every migration: `pnpm db:types` (needs the local stack);
|
||||
// CI runs `pnpm db:types:check`. packages/supabase/tests/db/schema-types.test.ts
|
||||
// checks tables, columns, enums and RPC names against the migrated schema.
|
||||
export type Json =
|
||||
| string
|
||||
| number
|
||||
@@ -11,11 +7,6 @@ export type Json =
|
||||
| Json[]
|
||||
|
||||
export type Database = {
|
||||
// Allows to automatically instantiate createClient with right options
|
||||
// instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
|
||||
__InternalSupabase: {
|
||||
PostgrestVersion: "13"
|
||||
}
|
||||
public: {
|
||||
Tables: {
|
||||
profile_roles: {
|
||||
@@ -26,9 +17,10 @@ export type Database = {
|
||||
revoke_reason: string | null
|
||||
revoked_at: string | null
|
||||
revoked_by: string | null
|
||||
role: Database["public"]["Enums"]["platform_role"]
|
||||
role: Database['public']['Enums']['platform_role']
|
||||
user_id: string
|
||||
}
|
||||
ComputedFields: never
|
||||
Insert: {
|
||||
granted_at?: string
|
||||
granted_by?: string | null
|
||||
@@ -36,7 +28,7 @@ export type Database = {
|
||||
revoke_reason?: string | null
|
||||
revoked_at?: string | null
|
||||
revoked_by?: string | null
|
||||
role: Database["public"]["Enums"]["platform_role"]
|
||||
role: Database['public']['Enums']['platform_role']
|
||||
user_id: string
|
||||
}
|
||||
Update: {
|
||||
@@ -46,30 +38,30 @@ export type Database = {
|
||||
revoke_reason?: string | null
|
||||
revoked_at?: string | null
|
||||
revoked_by?: string | null
|
||||
role?: Database["public"]["Enums"]["platform_role"]
|
||||
role?: Database['public']['Enums']['platform_role']
|
||||
user_id?: string
|
||||
}
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: "profile_roles_granted_by_fkey"
|
||||
columns: ["granted_by"]
|
||||
foreignKeyName: 'profile_roles_granted_by_fkey'
|
||||
columns: ['granted_by']
|
||||
isOneToOne: false
|
||||
referencedRelation: "profiles"
|
||||
referencedColumns: ["id"]
|
||||
referencedRelation: 'profiles'
|
||||
referencedColumns: ['id']
|
||||
},
|
||||
{
|
||||
foreignKeyName: "profile_roles_revoked_by_fkey"
|
||||
columns: ["revoked_by"]
|
||||
foreignKeyName: 'profile_roles_revoked_by_fkey'
|
||||
columns: ['revoked_by']
|
||||
isOneToOne: false
|
||||
referencedRelation: "profiles"
|
||||
referencedColumns: ["id"]
|
||||
referencedRelation: 'profiles'
|
||||
referencedColumns: ['id']
|
||||
},
|
||||
{
|
||||
foreignKeyName: "profile_roles_user_id_fkey"
|
||||
columns: ["user_id"]
|
||||
foreignKeyName: 'profile_roles_user_id_fkey'
|
||||
columns: ['user_id']
|
||||
isOneToOne: false
|
||||
referencedRelation: "profiles"
|
||||
referencedColumns: ["id"]
|
||||
referencedRelation: 'profiles'
|
||||
referencedColumns: ['id']
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -87,6 +79,7 @@ export type Database = {
|
||||
timezone: string
|
||||
updated_at: string
|
||||
}
|
||||
ComputedFields: never
|
||||
Insert: {
|
||||
active?: boolean
|
||||
created_at?: string
|
||||
@@ -122,7 +115,7 @@ export type Database = {
|
||||
Functions: {
|
||||
grant_platform_role: {
|
||||
Args: {
|
||||
role: Database["public"]["Enums"]["platform_role"]
|
||||
role: Database['public']['Enums']['platform_role']
|
||||
target_user_id: string
|
||||
}
|
||||
Returns: string
|
||||
@@ -130,14 +123,14 @@ export type Database = {
|
||||
revoke_platform_role: {
|
||||
Args: {
|
||||
reason?: string
|
||||
role: Database["public"]["Enums"]["platform_role"]
|
||||
role: Database['public']['Enums']['platform_role']
|
||||
target_user_id: string
|
||||
}
|
||||
Returns: string
|
||||
}
|
||||
}
|
||||
Enums: {
|
||||
platform_role: "owner" | "admin" | "moderator" | "support"
|
||||
platform_role: 'owner' | 'admin' | 'moderator' | 'support'
|
||||
}
|
||||
CompositeTypes: {
|
||||
[_ in never]: never
|
||||
@@ -145,33 +138,33 @@ export type Database = {
|
||||
}
|
||||
}
|
||||
|
||||
type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
|
||||
type DatabaseWithoutInternals = Omit<Database, '__InternalSupabase'>
|
||||
|
||||
type DefaultSchema = DatabaseWithoutInternals[Extract<keyof DatabaseWithoutInternals, "public">]
|
||||
type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, 'public'>]
|
||||
|
||||
export type Tables<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
|
||||
| keyof (DefaultSchema['Tables'] & DefaultSchema['Views'])
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
||||
? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables'] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Views'])
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
||||
? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables'] &
|
||||
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Views'])[TableName] extends {
|
||||
Row: infer R
|
||||
}
|
||||
? R
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
|
||||
DefaultSchema["Views"])
|
||||
? (DefaultSchema["Tables"] &
|
||||
DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
|
||||
: DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema['Tables'] &
|
||||
DefaultSchema['Views'])
|
||||
? (DefaultSchema['Tables'] &
|
||||
DefaultSchema['Views'])[DefaultSchemaTableNameOrOptions] extends {
|
||||
Row: infer R
|
||||
}
|
||||
? R
|
||||
@@ -180,23 +173,23 @@ export type Tables<
|
||||
|
||||
export type TablesInsert<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| keyof DefaultSchema['Tables']
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables']
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
||||
Insert: infer I
|
||||
}
|
||||
? I
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
|
||||
? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema['Tables']
|
||||
? DefaultSchema['Tables'][DefaultSchemaTableNameOrOptions] extends {
|
||||
Insert: infer I
|
||||
}
|
||||
? I
|
||||
@@ -205,23 +198,23 @@ export type TablesInsert<
|
||||
|
||||
export type TablesUpdate<
|
||||
DefaultSchemaTableNameOrOptions extends
|
||||
| keyof DefaultSchema["Tables"]
|
||||
| keyof DefaultSchema['Tables']
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables']
|
||||
: never = never,
|
||||
> = DefaultSchemaTableNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
||||
Update: infer U
|
||||
}
|
||||
? U
|
||||
: never
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
|
||||
? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
|
||||
: DefaultSchemaTableNameOrOptions extends keyof DefaultSchema['Tables']
|
||||
? DefaultSchema['Tables'][DefaultSchemaTableNameOrOptions] extends {
|
||||
Update: infer U
|
||||
}
|
||||
? U
|
||||
@@ -230,42 +223,42 @@ export type TablesUpdate<
|
||||
|
||||
export type Enums<
|
||||
DefaultSchemaEnumNameOrOptions extends
|
||||
| keyof DefaultSchema["Enums"]
|
||||
| keyof DefaultSchema['Enums']
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
EnumName extends DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
||||
? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions['schema']]['Enums']
|
||||
: never = never,
|
||||
> = DefaultSchemaEnumNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
||||
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
|
||||
? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
|
||||
? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions['schema']]['Enums'][EnumName]
|
||||
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema['Enums']
|
||||
? DefaultSchema['Enums'][DefaultSchemaEnumNameOrOptions]
|
||||
: never
|
||||
|
||||
export type CompositeTypes<
|
||||
PublicCompositeTypeNameOrOptions extends
|
||||
| keyof DefaultSchema["CompositeTypes"]
|
||||
| keyof DefaultSchema['CompositeTypes']
|
||||
| { schema: keyof DatabaseWithoutInternals },
|
||||
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
||||
? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes']
|
||||
: never = never,
|
||||
> = PublicCompositeTypeNameOrOptions extends {
|
||||
schema: keyof DatabaseWithoutInternals
|
||||
}
|
||||
? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
||||
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
|
||||
? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
|
||||
? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes'][CompositeTypeName]
|
||||
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema['CompositeTypes']
|
||||
? DefaultSchema['CompositeTypes'][PublicCompositeTypeNameOrOptions]
|
||||
: never
|
||||
|
||||
export const Constants = {
|
||||
public: {
|
||||
Enums: {
|
||||
platform_role: ["owner", "admin", "moderator", "support"],
|
||||
platform_role: ['owner', 'admin', 'moderator', 'support'],
|
||||
},
|
||||
},
|
||||
} as const
|
||||
Reference in new issue
Block a user