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

@@ -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)