mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 20:11:12 -05:00
Fix: Enable TypeScript strict mode
This commit is contained in:
84
src/types/company-data.ts
Normal file
84
src/types/company-data.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Company Data Types
|
||||
*
|
||||
* Type-safe interfaces for company database records and form data.
|
||||
* These types prevent `as any` casts when working with company entities.
|
||||
*/
|
||||
|
||||
export interface CompanyDatabaseRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description?: string | null;
|
||||
company_type: 'manufacturer' | 'designer' | 'operator' | 'property_owner';
|
||||
person_type: 'company' | 'individual' | 'firm' | 'organization';
|
||||
website_url?: string | null;
|
||||
founded_year?: number | null;
|
||||
headquarters_location?: string | null;
|
||||
logo_url?: string | null;
|
||||
banner_image_url?: string | null;
|
||||
card_image_url?: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
// Stats fields
|
||||
total_rides?: number;
|
||||
average_rating?: number;
|
||||
review_count?: number;
|
||||
}
|
||||
|
||||
export interface TimelineEventDatabaseRecord {
|
||||
id: string;
|
||||
entity_id: string;
|
||||
entity_type: 'park' | 'ride' | 'company' | 'ride_model';
|
||||
event_type: string;
|
||||
event_date: string;
|
||||
event_date_precision: 'day' | 'month' | 'year';
|
||||
title: string;
|
||||
description?: string | null;
|
||||
from_value?: string | null;
|
||||
to_value?: string | null;
|
||||
from_entity_id?: string | null;
|
||||
to_entity_id?: string | null;
|
||||
from_location_id?: string | null;
|
||||
to_location_id?: string | null;
|
||||
display_order: number;
|
||||
created_by?: string | null;
|
||||
approved_by?: string | null;
|
||||
submission_id?: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface LocationData {
|
||||
country?: string;
|
||||
state_province?: string;
|
||||
city?: string;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for company database records
|
||||
*/
|
||||
export function isCompanyRecord(data: unknown): data is CompanyDatabaseRecord {
|
||||
return (
|
||||
typeof data === 'object' &&
|
||||
data !== null &&
|
||||
'id' in data &&
|
||||
'name' in data &&
|
||||
'company_type' in data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for timeline event records
|
||||
*/
|
||||
export function isTimelineEventRecord(data: unknown): data is TimelineEventDatabaseRecord {
|
||||
return (
|
||||
typeof data === 'object' &&
|
||||
data !== null &&
|
||||
'id' in data &&
|
||||
'entity_type' in data &&
|
||||
'event_type' in data
|
||||
);
|
||||
}
|
||||
35
src/types/supabase-session.ts
Normal file
35
src/types/supabase-session.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Extended Supabase Session Types
|
||||
*
|
||||
* Supabase session objects contain additional properties not in the official types.
|
||||
* These extended types provide type safety for AAL (Authentication Assurance Level) and other fields.
|
||||
*/
|
||||
|
||||
import type { Session } from '@supabase/supabase-js';
|
||||
|
||||
export type AALLevel = 'aal1' | 'aal2';
|
||||
|
||||
/**
|
||||
* Extended session type with AAL property
|
||||
* Supabase auth sessions include this property but it's not in the official types
|
||||
*/
|
||||
export interface ExtendedSession extends Session {
|
||||
aal?: AALLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if session has AAL property
|
||||
*/
|
||||
export function hasAAL(session: Session | null): session is ExtendedSession {
|
||||
return session !== null && 'aal' in session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely extract AAL level from session
|
||||
*/
|
||||
export function getSessionAAL(session: Session | null): AALLevel {
|
||||
if (hasAAL(session) && session.aal) {
|
||||
return session.aal;
|
||||
}
|
||||
return 'aal1';
|
||||
}
|
||||
Reference in New Issue
Block a user