/**
 * Settings validation schema for Database
 * Auto-generated from baseline.json
 * 
 * @module Performance/Database
 * @since 0.1.0
 */

import { z } from 'zod';

/**
 * Settings schema for Database
 */
export const DatabaseSchema = z.object({
  enable_db_optimization: z.boolean().default(false),  // Enable database optimization
  auto_cleanup_schedule: z.enum(['disabled', 'daily', 'weekly', 'monthly']).default('weekly'),  // Automatic cleanup schedule
  cleanup_revisions: z.boolean().default(true),  // Clean up post revisions
  revisions_to_keep: z.number().int().min(0).max(50).default(3),  // Number of revisions to keep per post
  cleanup_auto_drafts: z.boolean().default(true),  // Clean up auto-draft posts
  cleanup_trash: z.boolean().default(true),  // Empty trash automatically
  trash_days: z.number().int().min(0).max(365).default(30),  // Days to keep items in trash
  cleanup_spam_comments: z.boolean().default(true),  // Remove spam comments
  cleanup_transients: z.boolean().default(true),  // Clean expired transients
  optimize_tables: z.boolean().default(false),  // Optimize database tables
  enable_query_monitor: z.boolean().default(false),  // Monitor slow database queries
  slow_query_threshold: z.number().min(0.1).max(5).default(0.5),  // Slow query threshold in seconds
});

/**
 * TypeScript type for Database settings
 */
export type DatabaseSettings = z.infer<typeof DatabaseSchema>;

/**
 * Default values for Database settings
 */
export const DatabaseDefaults: DatabaseSettings = DatabaseSchema.parse({});

/**
 * Validate Database settings
 */
export function validateDatabaseSettings(data: unknown): DatabaseSettings {
  return DatabaseSchema.parse(data);
}

/**
 * Safely validate Database settings (returns validation result)
 */
export function safeValidateDatabaseSettings(data: unknown) {
  return DatabaseSchema.safeParse(data);
}
