chore: regenerate Supabase types (includes matrix_credentials + matrix_space_id), remove db() cast workarounds
This commit is contained in:
@@ -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: {
|
org_google_calendars: {
|
||||||
Row: {
|
Row: {
|
||||||
calendar_id: string
|
calendar_id: string
|
||||||
@@ -748,6 +792,13 @@ export type Database = {
|
|||||||
referencedRelation: "org_roles"
|
referencedRelation: "org_roles"
|
||||||
referencedColumns: ["id"]
|
referencedColumns: ["id"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
foreignKeyName: "org_members_user_id_profiles_fk"
|
||||||
|
columns: ["user_id"]
|
||||||
|
isOneToOne: false
|
||||||
|
referencedRelation: "profiles"
|
||||||
|
referencedColumns: ["id"]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
org_roles: {
|
org_roles: {
|
||||||
@@ -803,6 +854,7 @@ export type Database = {
|
|||||||
created_at: string | null
|
created_at: string | null
|
||||||
icon_url: string | null
|
icon_url: string | null
|
||||||
id: string
|
id: string
|
||||||
|
matrix_space_id: string | null
|
||||||
name: string
|
name: string
|
||||||
slug: string
|
slug: string
|
||||||
theme_color: string | null
|
theme_color: string | null
|
||||||
@@ -813,6 +865,7 @@ export type Database = {
|
|||||||
created_at?: string | null
|
created_at?: string | null
|
||||||
icon_url?: string | null
|
icon_url?: string | null
|
||||||
id?: string
|
id?: string
|
||||||
|
matrix_space_id?: string | null
|
||||||
name: string
|
name: string
|
||||||
slug: string
|
slug: string
|
||||||
theme_color?: string | null
|
theme_color?: string | null
|
||||||
@@ -823,6 +876,7 @@ export type Database = {
|
|||||||
created_at?: string | null
|
created_at?: string | null
|
||||||
icon_url?: string | null
|
icon_url?: string | null
|
||||||
id?: string
|
id?: string
|
||||||
|
matrix_space_id?: string | null
|
||||||
name?: string
|
name?: string
|
||||||
slug?: string
|
slug?: string
|
||||||
theme_color?: string | null
|
theme_color?: string | null
|
||||||
@@ -1148,7 +1202,7 @@ export const Constants = {
|
|||||||
},
|
},
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
// ── Convenience type aliases ──────────────────────────
|
// ── Convenience type aliases ─────────────────────────────────────────
|
||||||
export type MemberRole = 'owner' | 'admin' | 'editor' | 'viewer';
|
export type MemberRole = 'owner' | 'admin' | 'editor' | 'viewer';
|
||||||
type PublicTables = Database['public']['Tables']
|
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 OrgGoogleCalendar = PublicTables['org_google_calendars']['Row']
|
||||||
export type ActivityLog = PublicTables['activity_log']['Row']
|
export type ActivityLog = PublicTables['activity_log']['Row']
|
||||||
export type UserPreferences = PublicTables['user_preferences']['Row']
|
export type UserPreferences = PublicTables['user_preferences']['Row']
|
||||||
|
export type MatrixCredentials = PublicTables['matrix_credentials']['Row']
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
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 }) => {
|
export const GET: RequestHandler = async ({ url, locals }) => {
|
||||||
const session = await locals.safeGetSession();
|
const session = await locals.safeGetSession();
|
||||||
if (!session.user) {
|
if (!session.user) {
|
||||||
@@ -17,7 +12,7 @@ export const GET: RequestHandler = async ({ url, locals }) => {
|
|||||||
return json({ error: 'org_id is required' }, { status: 400 });
|
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')
|
.from('matrix_credentials')
|
||||||
.select('homeserver_url, matrix_user_id, access_token, device_id')
|
.select('homeserver_url, matrix_user_id, access_token, device_id')
|
||||||
.eq('user_id', session.user.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 });
|
return json({ error: 'Missing required fields' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error } = await db(locals.supabase)
|
const { error } = await locals.supabase
|
||||||
.from('matrix_credentials')
|
.from('matrix_credentials')
|
||||||
.upsert(
|
.upsert(
|
||||||
{
|
{
|
||||||
@@ -76,7 +71,7 @@ export const DELETE: RequestHandler = async ({ url, locals }) => {
|
|||||||
return json({ error: 'org_id is required' }, { status: 400 });
|
return json({ error: 'org_id is required' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error } = await db(locals.supabase)
|
const { error } = await locals.supabase
|
||||||
.from('matrix_credentials')
|
.from('matrix_credentials')
|
||||||
.delete()
|
.delete()
|
||||||
.eq('user_id', session.user.id)
|
.eq('user_id', session.user.id)
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
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
|
* 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 });
|
return json({ error: 'org_id is required' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, error } = await db(locals.supabase)
|
const { data, error } = await locals.supabase
|
||||||
.from('organizations')
|
.from('organizations')
|
||||||
.select('matrix_space_id')
|
.select('matrix_space_id')
|
||||||
.eq('id', orgId)
|
.eq('id', orgId)
|
||||||
@@ -134,7 +130,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store space ID in org record
|
// Store space ID in org record
|
||||||
const { error: updateError } = await db(locals.supabase)
|
const { error: updateError } = await locals.supabase
|
||||||
.from('organizations')
|
.from('organizations')
|
||||||
.update({ matrix_space_id: spaceId })
|
.update({ matrix_space_id: spaceId })
|
||||||
.eq('id', org_id);
|
.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 });
|
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')
|
.from('organizations')
|
||||||
.update({ matrix_space_id: space_id })
|
.update({ matrix_space_id: space_id })
|
||||||
.eq('id', org_id);
|
.eq('id', org_id);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
|
|
||||||
const db = (supabase: any) => supabase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST: Invite a user to the org's Matrix Space (and its child rooms).
|
* 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
|
// Get org's Matrix Space ID
|
||||||
const { data: org } = await db(locals.supabase)
|
const { data: org } = await locals.supabase
|
||||||
.from('organizations')
|
.from('organizations')
|
||||||
.select('matrix_space_id')
|
.select('matrix_space_id')
|
||||||
.eq('id', org_id)
|
.eq('id', org_id)
|
||||||
@@ -102,7 +100,7 @@ export const DELETE: RequestHandler = async ({ url, locals }) => {
|
|||||||
return json({ error: 'Missing required fields' }, { status: 400 });
|
return json({ error: 'Missing required fields' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: org } = await db(locals.supabase)
|
const { data: org } = await locals.supabase
|
||||||
.from('organizations')
|
.from('organizations')
|
||||||
.select('matrix_space_id')
|
.select('matrix_space_id')
|
||||||
.eq('id', org_id)
|
.eq('id', org_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user