mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 18:51:11 -05:00
122 lines
2.9 KiB
TypeScript
122 lines
2.9 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
/**
|
|
* Validation schemas for data export
|
|
*/
|
|
|
|
/**
|
|
* User statistics schema
|
|
*/
|
|
export const userStatisticsSchema = z.object({
|
|
ride_count: z.number().int().min(0),
|
|
coaster_count: z.number().int().min(0),
|
|
park_count: z.number().int().min(0),
|
|
review_count: z.number().int().min(0),
|
|
reputation_score: z.number().int().min(0),
|
|
photo_count: z.number().int().min(0),
|
|
list_count: z.number().int().min(0),
|
|
submission_count: z.number().int().min(0),
|
|
account_created: z.string(),
|
|
last_updated: z.string()
|
|
});
|
|
|
|
/**
|
|
* Activity log entry schema
|
|
*/
|
|
export const activityLogEntrySchema = z.object({
|
|
id: z.string().uuid(),
|
|
action: z.string(),
|
|
changes: z.record(z.string(), z.any()),
|
|
created_at: z.string(),
|
|
changed_by: z.string().uuid(),
|
|
ip_address_hash: z.string().optional(),
|
|
user_agent: z.string().optional()
|
|
});
|
|
|
|
/**
|
|
* Export options schema
|
|
*/
|
|
export const exportOptionsSchema = z.object({
|
|
include_reviews: z.boolean(),
|
|
include_lists: z.boolean(),
|
|
include_activity_log: z.boolean(),
|
|
include_preferences: z.boolean(),
|
|
format: z.literal('json')
|
|
});
|
|
|
|
/**
|
|
* Export profile data schema
|
|
*/
|
|
export const exportProfileDataSchema = z.object({
|
|
username: z.string(),
|
|
display_name: z.string().nullable(),
|
|
bio: z.string().nullable(),
|
|
preferred_pronouns: z.string().nullable(),
|
|
personal_location: z.string().nullable(),
|
|
timezone: z.string(),
|
|
preferred_language: z.string(),
|
|
theme_preference: z.string(),
|
|
privacy_level: z.string(),
|
|
created_at: z.string(),
|
|
updated_at: z.string()
|
|
});
|
|
|
|
/**
|
|
* Export review data schema
|
|
*/
|
|
export const exportReviewDataSchema = z.object({
|
|
id: z.string().uuid(),
|
|
rating: z.number().min(1).max(5),
|
|
review_text: z.string().nullable(),
|
|
ride_name: z.string().optional(),
|
|
park_name: z.string().optional(),
|
|
created_at: z.string()
|
|
});
|
|
|
|
/**
|
|
* Export list data schema
|
|
*/
|
|
export const exportListDataSchema = z.object({
|
|
id: z.string().uuid(),
|
|
name: z.string(),
|
|
description: z.string().nullable(),
|
|
is_public: z.boolean(),
|
|
item_count: z.number().int().min(0),
|
|
created_at: z.string()
|
|
});
|
|
|
|
/**
|
|
* Complete export data structure schema
|
|
*/
|
|
export const exportDataSchema = z.object({
|
|
export_date: z.string(),
|
|
user_id: z.string().uuid(),
|
|
profile: exportProfileDataSchema,
|
|
statistics: userStatisticsSchema,
|
|
reviews: z.array(exportReviewDataSchema),
|
|
lists: z.array(exportListDataSchema),
|
|
activity_log: z.array(activityLogEntrySchema),
|
|
preferences: z.object({
|
|
unit_preferences: z.any(),
|
|
accessibility_options: z.any(),
|
|
notification_preferences: z.any(),
|
|
privacy_settings: z.any()
|
|
}),
|
|
metadata: z.object({
|
|
export_version: z.string(),
|
|
data_retention_info: z.string(),
|
|
instructions: z.string()
|
|
})
|
|
});
|
|
|
|
/**
|
|
* Default export options
|
|
*/
|
|
export const DEFAULT_EXPORT_OPTIONS = {
|
|
include_reviews: true,
|
|
include_lists: true,
|
|
include_activity_log: true,
|
|
include_preferences: true,
|
|
format: 'json' as const
|
|
};
|