feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { isRecord } from '@d3ro/core/guards'
|
||||
import { supabase } from '../../lib/supabase'
|
||||
import { requireUuidWith } from '../shared/service-guards'
|
||||
|
||||
export interface DashboardRecentEntry {
|
||||
id: string
|
||||
|
|
@ -28,9 +30,6 @@ export class DashboardServiceError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function nonNegativeNumber(value: unknown): number | null {
|
||||
const numeric = typeof value === 'number' ? value : Number(value)
|
||||
|
|
@ -104,9 +103,7 @@ export function normalizeDashboardStats(value: unknown): MobileDashboardStats {
|
|||
}
|
||||
|
||||
export async function loadDashboardStats(userId: string): Promise<MobileDashboardStats> {
|
||||
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(userId)) {
|
||||
throw new DashboardServiceError('auth')
|
||||
}
|
||||
requireUuidWith(userId, () => new DashboardServiceError('auth'))
|
||||
const { data, error } = await supabase.rpc('mobile_dashboard_stats')
|
||||
if (error) throw new DashboardServiceError('server')
|
||||
return normalizeDashboardStats(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue