mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 04:31:13 -05:00
Refactor versioning utility functions
This commit is contained in:
160
src/types/versioning.ts
Normal file
160
src/types/versioning.ts
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Universal Versioning System Types
|
||||
* Pure relational structure, no JSONB storage
|
||||
*/
|
||||
|
||||
export type EntityType = 'park' | 'ride' | 'company' | 'ride_model';
|
||||
|
||||
export type ChangeType = 'created' | 'updated' | 'deleted' | 'restored' | 'archived';
|
||||
|
||||
/**
|
||||
* Base version metadata common to all entity types
|
||||
* NOTE: Using version_id as the primary identifier (not 'id')
|
||||
* This matches the relational version table structure
|
||||
*/
|
||||
export interface BaseVersion {
|
||||
version_id: string;
|
||||
version_number: number;
|
||||
created_at: string;
|
||||
created_by: string | null;
|
||||
change_type: ChangeType;
|
||||
change_reason: string | null;
|
||||
submission_id: string | null;
|
||||
is_current: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extended version with profile data joined
|
||||
*/
|
||||
export interface BaseVersionWithProfile extends BaseVersion {
|
||||
profiles?: {
|
||||
username: string | null;
|
||||
display_name: string | null;
|
||||
avatar_url: string | null;
|
||||
} | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Park Version - exact mirror of parks table structure
|
||||
*/
|
||||
export interface ParkVersion extends BaseVersionWithProfile {
|
||||
park_id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string | null;
|
||||
park_type: string;
|
||||
status: string;
|
||||
location_id: string | null;
|
||||
operator_id: string | null;
|
||||
property_owner_id: string | null;
|
||||
opening_date: string | null;
|
||||
closing_date: string | null;
|
||||
opening_date_precision: string | null;
|
||||
closing_date_precision: string | null;
|
||||
website_url: string | null;
|
||||
phone: string | null;
|
||||
email: string | null;
|
||||
banner_image_url: string | null;
|
||||
banner_image_id: string | null;
|
||||
card_image_url: string | null;
|
||||
card_image_id: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ride Version - exact mirror of rides table structure
|
||||
*/
|
||||
export interface RideVersion extends BaseVersionWithProfile {
|
||||
ride_id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string | null;
|
||||
category: string;
|
||||
status: string;
|
||||
park_id: string | null;
|
||||
manufacturer_id: string | null;
|
||||
designer_id: string | null;
|
||||
ride_model_id: string | null;
|
||||
opening_date: string | null;
|
||||
closing_date: string | null;
|
||||
opening_date_precision: string | null;
|
||||
closing_date_precision: string | null;
|
||||
height_requirement_cm: number | null;
|
||||
max_speed_kmh: number | null;
|
||||
duration_seconds: number | null;
|
||||
capacity_per_hour: number | null;
|
||||
gforce_max: number | null;
|
||||
inversions_count: number | null;
|
||||
length_meters: number | null;
|
||||
height_meters: number | null;
|
||||
drop_meters: number | null;
|
||||
angle_degrees: number | null;
|
||||
former_names: any[] | null;
|
||||
banner_image_url: string | null;
|
||||
banner_image_id: string | null;
|
||||
card_image_url: string | null;
|
||||
card_image_id: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Company Version - exact mirror of companies table structure
|
||||
*/
|
||||
export interface CompanyVersion extends BaseVersionWithProfile {
|
||||
company_id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string | null;
|
||||
company_type: string;
|
||||
person_type: string | null;
|
||||
founded_year: number | null;
|
||||
founded_date: string | null;
|
||||
founded_date_precision: string | null;
|
||||
headquarters_location: string | null;
|
||||
website_url: string | null;
|
||||
logo_url: string | null;
|
||||
banner_image_url: string | null;
|
||||
banner_image_id: string | null;
|
||||
card_image_url: string | null;
|
||||
card_image_id: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ride Model Version - exact mirror of ride_models table structure
|
||||
*/
|
||||
export interface RideModelVersion extends BaseVersionWithProfile {
|
||||
ride_model_id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
manufacturer_id: string | null;
|
||||
category: string;
|
||||
description: string | null;
|
||||
technical_specs: Record<string, any> | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discriminated union of all entity version types
|
||||
*/
|
||||
export type EntityVersion = ParkVersion | RideVersion | CompanyVersion | RideModelVersion;
|
||||
|
||||
/**
|
||||
* Version comparison diff structure
|
||||
*/
|
||||
export interface VersionDiff {
|
||||
[fieldName: string]: {
|
||||
from: any;
|
||||
to: any;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Version summary for list display
|
||||
*/
|
||||
export interface VersionSummary {
|
||||
version_id: string;
|
||||
version_number: number;
|
||||
created_at: string;
|
||||
created_by: string | null;
|
||||
change_type: ChangeType;
|
||||
changed_by_username?: string;
|
||||
changed_by_display_name?: string;
|
||||
entity_name: string;
|
||||
}
|
||||
Reference in New Issue
Block a user