chore: regenerate Supabase types (includes matrix_credentials + matrix_space_id), remove db() cast workarounds

This commit is contained in:
AlacrisDevs
2026-02-07 09:25:33 +02:00
parent 45ab939b7f
commit 13cdb605ca
4 changed files with 64 additions and 20 deletions

View File

@@ -613,6 +613,50 @@ export type Database = {
},
]
}
matrix_credentials: {
Row: {
access_token: string
created_at: string
device_id: string | null
homeserver_url: string
id: string
matrix_user_id: string
org_id: string
updated_at: string
user_id: string
}
Insert: {
access_token: string
created_at?: string
device_id?: string | null
homeserver_url: string
id?: string
matrix_user_id: string
org_id: string
updated_at?: string
user_id: string
}
Update: {
access_token?: string
created_at?: string
device_id?: string | null
homeserver_url?: string
id?: string
matrix_user_id?: string
org_id?: string
updated_at?: string
user_id?: string
}
Relationships: [
{
foreignKeyName: "matrix_credentials_org_id_fkey"
columns: ["org_id"]
isOneToOne: false
referencedRelation: "organizations"
referencedColumns: ["id"]
},
]
}
org_google_calendars: {
Row: {
calendar_id: string
@@ -748,6 +792,13 @@ export type Database = {
referencedRelation: "org_roles"
referencedColumns: ["id"]
},
{
foreignKeyName: "org_members_user_id_profiles_fk"
columns: ["user_id"]
isOneToOne: false
referencedRelation: "profiles"
referencedColumns: ["id"]
},
]
}
org_roles: {
@@ -803,6 +854,7 @@ export type Database = {
created_at: string | null
icon_url: string | null
id: string
matrix_space_id: string | null
name: string
slug: string
theme_color: string | null
@@ -813,6 +865,7 @@ export type Database = {
created_at?: string | null
icon_url?: string | null
id?: string
matrix_space_id?: string | null
name: string
slug: string
theme_color?: string | null
@@ -823,6 +876,7 @@ export type Database = {
created_at?: string | null
icon_url?: string | null
id?: string
matrix_space_id?: string | null
name?: string
slug?: string
theme_color?: string | null
@@ -1148,7 +1202,7 @@ export const Constants = {
},
} as const
// ── Convenience type aliases ──────────────────────────
// ── Convenience type aliases ─────────────────────────────────────────
export type MemberRole = 'owner' | 'admin' | 'editor' | 'viewer';
type PublicTables = Database['public']['Tables']
@@ -1171,3 +1225,4 @@ export type Team = PublicTables['teams']['Row']
export type OrgGoogleCalendar = PublicTables['org_google_calendars']['Row']
export type ActivityLog = PublicTables['activity_log']['Row']
export type UserPreferences = PublicTables['user_preferences']['Row']
export type MatrixCredentials = PublicTables['matrix_credentials']['Row']

View File

@@ -1,11 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
// Cast supabase to any to bypass typed client — matrix_credentials table
// was added in migration 020 but types haven't been regenerated yet.
// TODO: Remove casts after running `supabase gen types`
const db = (supabase: any) => supabase;
export const GET: RequestHandler = async ({ url, locals }) => {
const session = await locals.safeGetSession();
if (!session.user) {
@@ -17,7 +12,7 @@ export const GET: RequestHandler = async ({ url, locals }) => {
return json({ error: 'org_id is required' }, { status: 400 });
}
const { data, error } = await db(locals.supabase)
const { data, error } = await locals.supabase
.from('matrix_credentials')
.select('homeserver_url, matrix_user_id, access_token, device_id')
.eq('user_id', session.user.id)
@@ -44,7 +39,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
return json({ error: 'Missing required fields' }, { status: 400 });
}
const { error } = await db(locals.supabase)
const { error } = await locals.supabase
.from('matrix_credentials')
.upsert(
{
@@ -76,7 +71,7 @@ export const DELETE: RequestHandler = async ({ url, locals }) => {
return json({ error: 'org_id is required' }, { status: 400 });
}
const { error } = await db(locals.supabase)
const { error } = await locals.supabase
.from('matrix_credentials')
.delete()
.eq('user_id', session.user.id)

View File

@@ -1,10 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
// Cast supabase to any — matrix_space_id column added in migration 021
// TODO: Remove after running `supabase gen types`
const db = (supabase: any) => supabase;
/**
* GET: Retrieve the Matrix Space ID for an org
*/
@@ -19,7 +15,7 @@ export const GET: RequestHandler = async ({ url, locals }) => {
return json({ error: 'org_id is required' }, { status: 400 });
}
const { data, error } = await db(locals.supabase)
const { data, error } = await locals.supabase
.from('organizations')
.select('matrix_space_id')
.eq('id', orgId)
@@ -134,7 +130,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
}
// Store space ID in org record
const { error: updateError } = await db(locals.supabase)
const { error: updateError } = await locals.supabase
.from('organizations')
.update({ matrix_space_id: spaceId })
.eq('id', org_id);
@@ -156,7 +152,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
return json({ error: 'space_id is required for link action' }, { status: 400 });
}
const { error: updateError } = await db(locals.supabase)
const { error: updateError } = await locals.supabase
.from('organizations')
.update({ matrix_space_id: space_id })
.eq('id', org_id);

View File

@@ -1,8 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
const db = (supabase: any) => supabase;
/**
* POST: Invite a user to the org's Matrix Space (and its child rooms).
*
@@ -22,7 +20,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
}
// Get org's Matrix Space ID
const { data: org } = await db(locals.supabase)
const { data: org } = await locals.supabase
.from('organizations')
.select('matrix_space_id')
.eq('id', org_id)
@@ -102,7 +100,7 @@ export const DELETE: RequestHandler = async ({ url, locals }) => {
return json({ error: 'Missing required fields' }, { status: 400 });
}
const { data: org } = await db(locals.supabase)
const { data: org } = await locals.supabase
.from('organizations')
.select('matrix_space_id')
.eq('id', org_id)