mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 13:31:14 -05:00
Refactor: Update audit log functions
This commit is contained in:
209
src/types/audit-relational.ts
Normal file
209
src/types/audit-relational.ts
Normal file
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* TypeScript types for relational audit tables
|
||||
* Replaces JSONB columns with proper relational structures
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
// ADMIN AUDIT DETAILS (replaces admin_audit_log.details)
|
||||
// ============================================================================
|
||||
|
||||
export interface AdminAuditDetail {
|
||||
id: string;
|
||||
audit_log_id: string;
|
||||
detail_key: string;
|
||||
detail_value: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface AdminAuditDetailInsert {
|
||||
audit_log_id: string;
|
||||
detail_key: string;
|
||||
detail_value: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// MODERATION AUDIT METADATA (replaces moderation_audit_log.metadata)
|
||||
// ============================================================================
|
||||
|
||||
export interface ModerationAuditMetadata {
|
||||
id: string;
|
||||
audit_log_id: string;
|
||||
metadata_key: string;
|
||||
metadata_value: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ModerationAuditMetadataInsert {
|
||||
audit_log_id: string;
|
||||
metadata_key: string;
|
||||
metadata_value: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PROFILE CHANGE FIELDS (replaces profile_audit_log.changes)
|
||||
// ============================================================================
|
||||
|
||||
export interface ProfileChangeField {
|
||||
id: string;
|
||||
audit_log_id: string;
|
||||
field_name: string;
|
||||
old_value: string | null;
|
||||
new_value: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ProfileChangeFieldInsert {
|
||||
audit_log_id: string;
|
||||
field_name: string;
|
||||
old_value?: string | null;
|
||||
new_value?: string | null;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ITEM CHANGE FIELDS (replaces item_edit_history.changes)
|
||||
// ============================================================================
|
||||
|
||||
export interface ItemChangeField {
|
||||
id: string;
|
||||
edit_history_id: string;
|
||||
field_name: string;
|
||||
old_value: string | null;
|
||||
new_value: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ItemChangeFieldInsert {
|
||||
edit_history_id: string;
|
||||
field_name: string;
|
||||
old_value?: string | null;
|
||||
new_value?: string | null;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// REQUEST BREADCRUMBS (replaces request_metadata.breadcrumbs)
|
||||
// ============================================================================
|
||||
|
||||
export interface RequestBreadcrumb {
|
||||
id: string;
|
||||
request_id: string;
|
||||
timestamp: string;
|
||||
category: string;
|
||||
message: string;
|
||||
level: 'debug' | 'info' | 'warn' | 'error';
|
||||
sequence_order: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface RequestBreadcrumbInsert {
|
||||
request_id: string;
|
||||
timestamp: string;
|
||||
category: string;
|
||||
message: string;
|
||||
level?: 'debug' | 'info' | 'warn' | 'error';
|
||||
sequence_order: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// SUBMISSION METADATA (replaces content_submissions.content)
|
||||
// ============================================================================
|
||||
|
||||
export interface SubmissionMetadata {
|
||||
id: string;
|
||||
submission_id: string;
|
||||
metadata_key: string;
|
||||
metadata_value: string;
|
||||
value_type: 'string' | 'number' | 'boolean' | 'date' | 'url' | 'json';
|
||||
display_order: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface SubmissionMetadataInsert {
|
||||
submission_id: string;
|
||||
metadata_key: string;
|
||||
metadata_value: string;
|
||||
value_type?: 'string' | 'number' | 'boolean' | 'date' | 'url' | 'json';
|
||||
display_order?: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// REVIEW PHOTOS (replaces reviews.photos)
|
||||
// ============================================================================
|
||||
|
||||
export interface ReviewPhoto {
|
||||
id: string;
|
||||
review_id: string;
|
||||
cloudflare_image_id: string;
|
||||
cloudflare_image_url: string;
|
||||
caption: string | null;
|
||||
order_index: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface ReviewPhotoInsert {
|
||||
review_id: string;
|
||||
cloudflare_image_id: string;
|
||||
cloudflare_image_url: string;
|
||||
caption?: string | null;
|
||||
order_index?: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// NOTIFICATION EVENT DATA (replaces notification_logs.payload)
|
||||
// ============================================================================
|
||||
|
||||
export interface NotificationEventData {
|
||||
id: string;
|
||||
notification_log_id: string;
|
||||
event_key: string;
|
||||
event_value: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface NotificationEventDataInsert {
|
||||
notification_log_id: string;
|
||||
event_key: string;
|
||||
event_value: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// CONFLICT DETAIL FIELDS (replaces conflict_resolutions.conflict_details)
|
||||
// ============================================================================
|
||||
|
||||
export interface ConflictDetailField {
|
||||
id: string;
|
||||
conflict_resolution_id: string;
|
||||
field_name: string;
|
||||
conflicting_value_1: string | null;
|
||||
conflicting_value_2: string | null;
|
||||
resolved_value: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ConflictDetailFieldInsert {
|
||||
conflict_resolution_id: string;
|
||||
field_name: string;
|
||||
conflicting_value_1?: string | null;
|
||||
conflicting_value_2?: string | null;
|
||||
resolved_value?: string | null;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HELPER TYPES
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Generic key-value structure for reading audit details
|
||||
*/
|
||||
export type AuditDetailsRecord = Record<string, string>;
|
||||
|
||||
/**
|
||||
* Generic change structure for reading change fields
|
||||
*/
|
||||
export interface ChangeRecord {
|
||||
old_value: string | null;
|
||||
new_value: string | null;
|
||||
}
|
||||
|
||||
export type ChangesRecord = Record<string, ChangeRecord>;
|
||||
Reference in New Issue
Block a user