/** * BoostMedia AI Content Generator Admin - TypeScript Types * * @package BoostMedia_AI * @license GPL-2.0-or-later */ // =========================== // Onboarding // =========================== export interface OnboardingState { usageSeen: boolean contentTypesSeen: boolean linksSeen: boolean reportersSeen: boolean settingsSeen: boolean autoPublishSeen: boolean smartLinkingSeen: boolean helpSeen: boolean setupComplete: boolean firstActivation: string lastStepCompleted: string } // =========================== // WordPress Settings // =========================== export interface BMAISettings { nonce: string apiUrl: string adminUrl: string homeUrl: string pluginUrl: string version: string locale: string dataLanguage: string isRtl: boolean onboardingState: OnboardingState } declare global { interface Window { bmaiSettings?: BMAISettings } } // =========================== // Post Structure // =========================== export interface MetaField { name: string type: string title: string required: boolean description?: string source?: string default?: unknown is_repeater?: boolean sub_fields?: MetaField[] options?: Array<{ value: string label: string }> } export interface Taxonomy { name: string slug: string label: string hierarchical: boolean terms_count: number } export interface PostStructure { id: number post_type: string post_type_label: string jetengine_id: number | null meta_fields: MetaField[] taxonomies: Taxonomy[] sample_count: number analyzed_at: string | null structure_hash?: string created_at: string updated_at: string } // =========================== // Content Analysis // =========================== export interface WritingStyle { tone: string formality: string avg_length: number avg_paragraphs: number } export interface AIAnalysis { tone?: { primary: string formality_level: string description?: string } structure?: { opening_pattern?: string body_pattern?: string closing_pattern?: string uses_headings?: boolean uses_lists?: boolean typical_sections?: string[] } field_patterns?: Record seo_patterns?: { title_format?: string description_style?: string keyword_placement?: string } common_phrases?: string[] unique_style?: string writing_guidelines?: string[] } export interface FieldPatternAnalysis { field_name: string field_title: string field_type: string sample_count: number fill_rate: number has_data: boolean data_type?: 'text' | 'numeric' | 'array' avg_length?: number avg_words?: number detected_pattern?: string[] examples?: unknown[] } export interface ContentAnalysis { id: number post_structure_id: number taxonomy_slug: string | null writing_style: WritingStyle common_patterns: string[] field_patterns: Record seo_patterns: Record ai_analysis?: AIAnalysis sample_count: number analyzed_at: string } // =========================== // Reporters // =========================== export type ReporterWritingStyle = string export type ReporterDepthLevel = string export type ReporterTone = string export type ReporterPerspective = string export type ReporterGender = 'male' | 'female' | 'neutral' export type ReporterSourceMode = 'manual' | 'ai_builder' | 'ai_refined' export type ReporterStatus = 'active' | 'archived' export interface Reporter { id: number uuid: string name: string slug: string language: string writing_language: string is_default: number status: ReporterStatus specializations: string[] writing_style: ReporterWritingStyle depth_level: ReporterDepthLevel tone: ReporterTone perspective: ReporterPerspective gender: ReporterGender language_quirks: string[] audience: string custom_instructions: string source_mode: ReporterSourceMode builder_summary: string last_used_at: string | null created_at: string updated_at: string | null } // =========================== // Conversational Generation // =========================== export interface ConversationMessage { role: 'assistant' | 'user' content: string } export interface ResearchScope { directive: string languages: string[] regions: string[] source_preferences: string[] freshness: string } export interface TopicTreeArticle { id: string angle: string status: string research_queries: string[] } export interface TopicTreeCluster { id: string title: string article_count: number articles: TopicTreeArticle[] } export interface TopicTreePillar { id: string title: string article_count: number clusters: TopicTreeCluster[] } export interface TopicTree { total_articles: number pillars: TopicTreePillar[] } export interface ContentPlan { audience: { primary: string secondary: string[] } goal: { primary: string cta: string } focus_areas: string[] tone_adjustments: string[] standards_to_reference: string[] must_include: string[] avoid: string[] cta_style: string outline_preferences: { intro_angle: string section_priority: string[] faq: boolean } reporter_adjustments: { keep_reporter_defaults: boolean override_tone: string override_depth: string } research_enabled: boolean research_scope: ResearchScope topic_tree: TopicTree summary: string } export interface SavedTechnicalRules { id: number structure_hash: string still_valid: boolean summary: string rules: Record[] updated_at: string | null source_session_id: number | null session_id: string | null } export type ContentPlanGenerationType = 'one_time' | 'repeating' export type ContentPlanRepeatFrequency = 'daily' | 'weekly' | 'monthly' export type ContentPlanScheduleUnit = 'day' | 'week' | 'month' export interface ContentPlanScheduleConfig { interval: number unit: ContentPlanScheduleUnit weekdays: number[] hour: number stop_after_months: number | null max_total_runs: number | null max_total_posts: number | null } export interface ContentPlanScheduleCounters { anchor_at: string | null runs_completed: number posts_generated: number remaining_runs: number | null remaining_posts: number | null } export interface SavedContentPlan { id: number name: string post_type: string taxonomy_scope: string | null term_scope: string | null language: string reporter_id: number reporter_name: string structure_hash: string still_valid: boolean summary: string content_plan: ContentPlan content_answers: Record[] topic: string keywords: string[] post_count: number post_length: 'short' | 'medium' | 'long' | 'auto' publishing_schedule: 'none' | 'immediate' | 'daily' | 'weekly' count_per_category: boolean generation_type: ContentPlanGenerationType repeat_frequency: ContentPlanRepeatFrequency | null is_active: boolean schedule_config: ContentPlanScheduleConfig | null schedule_counters: ContentPlanScheduleCounters | null technical_session_id: string | null content_session_id: string | null last_used_at: string | null last_run_at: string | null next_run_at: string | null source_session_id: number | null technical_rules: SavedTechnicalRules | null } export interface PostTypeRulesResponse { post_type: string language: string technical_rules: SavedTechnicalRules | null content_plan: SavedContentPlan | null } // =========================== // Sprint / Research 2.0 // =========================== export type SprintJobStatus = 'queued' | 'running' | 'forming_articles' | 'complete' | 'failed' export interface SprintResult { runId: string rounds: number findings: number costUsd: number articleCount: number jobs?: string[] } export interface SprintStatusResponse { sprint_job_id: string status: SprintJobStatus rounds_used: number rounds_max: number findings_count: number articles_formed: number cost_usd: number cost_coins: number error_message?: string articles?: SprintArticle[] jobs?: string[] } export interface SprintArticle { angle: string hook: string confidence: 'high' | 'medium' | 'low' backingFindings: string[] branchName?: string branchId?: string } // =========================== // Jobs List // =========================== export interface JobListItem { id: string type: 'sprint' | 'generation' status: string plan_id: number | null plan_name: string execution_type?: 'scheduled' | 'one_time' | 'manual' articles_total: number articles_completed: number findings_count: number rounds_used: number rounds_max: number cost_coins: number error_message: string | null started_at: string completed_at: string | null generation_jobs: { id: string; status: string; topic: string; credits: number }[] } export interface JobSummary { active_count: number completed_today: number articles_today: number coins_today: number } export interface JobsListResponse { jobs: JobListItem[] summary: JobSummary total: number limit: number next_cursor: string | null has_more: boolean } // =========================== // Upcoming Plans // =========================== export interface UpcomingPlan { plan_id: number plan_name: string next_run_at: string | null schedule_text: string article_count: number reporter_name: string is_active: boolean last_run_at: string | null } // =========================== // Generated Posts // =========================== export type GeneratedPostStatus = 'draft' | 'pending' | 'scheduled' | 'published' | 'failed' export interface GeneratedPost { id: number wp_post_id: number | null post_type: string taxonomy_slug: string | null language?: string title?: string excerpt?: string prompt_used: string generated_content: string | Record content?: Record meta_values: Record status: GeneratedPostStatus scheduled_at: string | null published_at: string | null error_message: string | null created_at: string updated_at: string featured_image_url?: string featured_image_thumbnail?: string image_prompt?: string copyscape_status?: 'clean' | 'improved' | 'needs_review' | 'error' | 'not_checked' copyscape_match?: number copyscape_rewritten?: number plan_id?: number } // =========================== // Generation Logs // =========================== export type LogActionType = 'scan' | 'analyze' | 'generate' | 'publish' export type LogStatus = 'success' | 'error' | 'warning' export interface GenerationLog { id: number action_type: LogActionType post_type: string | null details: Record tokens_used: number duration_ms: number status: LogStatus error_message: string | null created_at: string } // =========================== // Stats // =========================== export interface DashboardStats { total_post_types: number total_generated: number pending_publish: number total_errors: number last_scan: string | null last_generation: string | null } // =========================== // API Response // =========================== export interface ApiResponse { success: boolean data: T message?: string } export interface ApiError { code: string message: string status: number }