// lib/schema.ts // AUTO-GENERATED by scripts/generate-schema.ts — DO NOT EDIT. // Source: businesskit-files/*.ts (copies of app-side schema). // Regenerate: npm run schema:gen // // What this gives you: // - One `interface ` per UserDB table // - Enum literal unions for columns with `-- 'a'|'b'|'c'` comment hints // - `TABLES` const for typo-safe table references // // Rows returned by libSQL's Client are `Record` — cast via // `as unknown as ` at the call site after SELECT. // ── agent.ts ──────────────────────────────────────────────────── export interface Agents { id: string | null profile_id: string display_name: string title: string | null reports_to: string | null capabilities: string | null instructions: 'claude-code-local' | 'claude-api' | 'openai' | 'gemini' | null thinking_effort: 'auto' | 'low' | 'medium' | 'high' timeout_sec: number interrupt_grace_sec: number enable_chrome: number skip_permissions: number extra_args: string | null env_vars: string heartbeat_interval_sec: number can_assign_tasks: number auto_approve: number is_paused: number paused_until: number | null status: 'idle' | 'running' | 'paused' | 'error' last_run_at: number | null last_run_status: string | null created_at: number updated_at: number } export interface AgentSkills { id: number | null profile_id: string name: string slug: string description: string | null tags: string content: string source: 'manual' | 'generated' approval_status: string embedding: Uint8Array | null version: number updated_at: string } export interface SkillFiles { id: number | null skill_id: number path: string category: string content: string updated_at: string } export interface AgentMemory { id: number | null profile_id: string session_date: string agent: string action: string metadata: string created_at: string } export interface AgentNotes { id: string | null profile_id: string content: string thought: 'user' | 'agent' } export interface AgentFiles { id: string | null profile_id: string file_name: string file_path: string size_bytes: number content: string | null agent_types: string created_at: string } export interface AgentTasks { id: string | null profile_id: string agent: string title: string description: string | null command: 'weeklyBriefing' | 'runPublishQueue' | 'hotLeads' source: 'user' | 'agent' run_once: 'pending' | 'active' | 'running' | 'done' | 'paused' | 'failed' | 'cancelled' last_run_at: number | null last_run_status: string | null next_run_at: number | null hidden: number created_at: number updated_at: number } export interface AgentReports { id: string | null profile_id: string agent: string title: string type: 'briefing' | 'audit' | 'revenue' | 'seo' | 'crm' | 'analytics' | 'general' summary: string | null created_at: string } export interface AgentKb { id: string | null profile_id: string entry_type: string framework: string slug: 'convertkit' | 'email-deliverability' | 'icp-match' stale: number agent: string hidden: number created_at: string updated_at: string } export interface AgentConversations { id: string | null profile_id: string title: string | null agent: string | null harness_type: string | null harness_status: string current_phase: number messages: string deep_mode: number todos: string workspace_ids: string hidden: number created_at: number updated_at: number } export interface AgentAudit { id: string | null ts: number agent_type: string table_name: string row_id: string action: string diff: string | null idempotency_key: string | null } // ── content.ts ────────────────────────────────────────────────── export interface Content { id: string | null cms_id: string | null category_id: string | null profile_id: string media_id: string | null user_id: string slug: string title: string subtitle: string | null content: string | null excerpt: string | null hero_image_url: string | null cta_button_url: string | null cta_button_text: string | null additional_details: string published: number hidden: number date: string | null collection_id: string | null hide_author: number image_ads: string add_product: string add_people: string video_url: string | null files_url: string faqs: string ai_summary: string | null custom_design: string | null seo_title: string | null seo_description: string | null seo_keywords: string | null word_count: number | null reading_time_mins: number | null internal_links: number | null external_links: number | null sources: string | null sent_count: number location: string | null social_links: string website: string | null logo_url: string | null name: string | null tagline: string | null highlights: string hide_info: number created_at: string updated_at: string } export interface ContentReaction { id: string | null content_id: string profile_id: string user_id: string | null reaction_type: string created_at: string } export interface ContentComment { id: string | null content_id: string profile_id: string user_id: string | null author_name: string | null author_email: string | null content: string parent_id: string | null status: string created_at: string updated_at: string } export interface Cms { id: string | null profile_id: string | null slug: string title: string description: string | null category_id: string | null nav_active: number menu_active: number footer_active: number section: string | null subscribe_form: number ads_code_sidebar: string | null ads_code_top: string | null ads_code_bottom: string | null hide_info: number created_at: string updated_at: string } export interface ContentViews { id: string | null content_id: string | null doc_id: number | null product_id: string | null form_id: string | null job_listing_id: string | null community_id: string | null page_id: string | null profile_id: string viewer_id: string | null ip_address: string | null user_agent: string | null device: string | null os: string | null browser: string | null referrer: string | null country: string | null city: string | null timezone: string | null is_bot: number viewed_at: string } export interface ContentAnalytics { id: string | null content_id: string profile_id: string bot_views: number total_views: number total_reactions: number total_comments: number device_breakdown: string os_breakdown: string browser_breakdown: string country_breakdown: string city_breakdown: string referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string last_aggregated_at: string } export interface CmsAnalytics { id: string | null cms_id: string profile_id: string total_posts: number total_draft: number total_published: number bot_views: number total_views: number total_reactions: number total_comments: number total_submissions: number total_applications: number device_breakdown: string os_breakdown: string browser_breakdown: string country_breakdown: string city_breakdown: string referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string last_aggregated_at: string created_at: string updated_at: string } export interface DocAnalytics { id: string | null doc_id: number profile_id: string bot_views: number total_views: number sad: number neutral: number happy: number total_reactions: number total_comments: number device_breakdown: string os_breakdown: string browser_breakdown: string country_breakdown: string city_breakdown: string referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string last_aggregated_at: string } export interface DocCollections { id: number | null slug: string title: string description: string | null icon: string | null sort_order: number is_default: number created_at: string } export interface DocArticles { id: number | null collection_id: number profile_id: string user_id: string slug: string title: string excerpt: string | null body: string published: number hidden: number hide_author: number image_ads: string add_product: string add_people: string video_url: string | null files_url: string faqs: string views: number votes_json: string ai_summary: string | null custom_design: string | null sources: string | null created_at: string updated_at: string } // ── crm.ts ────────────────────────────────────────────────────── export interface CrmContacts { id: string | null profile_id: string user_id: string | null last_name: string | null email: string | null phone: string | null avatar_url: string | null company: string | null job_title: string | null website: string | null contact_type: 'brand' | 'agency' | 'influencer' | 'professional' country: string | null timezone: string | null recent_post: string | null recent_post_url: string | null recent_post_at: number | null pain_point: 'solo' | '2-10' | '11-50' | '51-200' | null business_model: 'b2b' | 'b2c' | 'marketplace' | null lead_score_reason: string | null icp_match: 'strong' | 'moderate' | 'weak' | 'unknown' next_follow_up_at: number | null follow_up_count: number next_action: string | null dm_sent: number dm_sent_at: number | null conversation_thread: string last_reply_channel: 'dm' | 'email' | null email_draft: string | null email_sent: number email_sent_at: 'lead' | 'prospect' | 'customer' | 'churned' | 'archived' | null tags: string custom_fields: string notes: string | null message: string | null os: string | null browser: string | null referrer: string | null utm_source: string | null utm_medium: string | null utm_campaign: string | null utm_term: string | null utm_content: string | null total_purchases: number last_purchase_at: 'active' | 'cancelled' | 'paused' | 'trial' | null subscription_value_cents: number subscription_renewal_at: number | null mrr_cents: number last_activity_at: number | null unread_count: 'pending' | 'researching' | 'enriched' | 'outreach_ready' | 'closed' agent_confidence: number | null agent_error: string | null agent_retry_count: number agent_last_run_at: number | null agent_next_run_at: number | null agent_context: string agent_paused_until: number | null auto_approve: 'new_post' | 'replied' | 'opened_email' | 'purchase' | 'form_submit' | 'n8n_trigger' signal_data: string enrichment_source: string | null duplicate_of: string | null disqualified: number disqualified_reason: string | null merged_into: string | null merged_at: number | null created_at: number updated_at: number } export interface CrmDeals { id: string | null profile_id: string contact_id: string title: string value_cents: number currency: string stage: string expected_close_at: number | null closed_at: number | null lost_reason: string | null notes: string | null product_id: string | null line_items: string updated_at: number } export interface CrmActivities { id: string | null profile_id: string contact_id: string deal_id: string | null type: 'dm' | 'email' | 'call' | 'meeting' | 'note' | 'task_done' sender: string subject: string | null body: string | null outcome: string | null metadata: string searchable_context: 'pending_approval' | 'approved' | 'rejected' | 'auto_sent' | null approved_at: number | null read_at: number | null created_at: number } export interface CrmTasks { id: string | null profile_id: string contact_id: string | null deal_id: string | null title: string description: string | null due_at: number | null priority: string status: string completed_at: number | null created_at: number updated_at: number } export interface CrmNotes { id: string | null profile_id: string contact_id: string deal_id: string | null body: string pinned: number created_at: number updated_at: number } export interface CrmGroups { id: string | null profile_id: string name: string icon: string | null color: string | null contact_count: number created_at: number } export interface CrmContactGroups { contact_id: string group_id: string added_at: number } export interface CrmTemplates { id: string | null profile_id: string name: string type: 'dm' | 'email' | 'follow_up' | 'proposal' body: string platform: 'twitter' | 'linkedin' | null use_count: number reply_rate_pct: number created_at: number updated_at: number } export interface CrmProposals { id: string | null profile_id: string contact_id: string | null deal_id: string | null title: string body: string excerpt: string | null public_slug: string status: 'draft' | 'sent' | 'viewed' | 'signed' | 'paid' | 'expired' | 'declined' view_count: number click: string | null client_name: string | null client_email: string | null client_company: string | null signed_name: string | null signed_email: string | null signed_at: number | null signature_data: string | null signature_type: 'draw' | 'type' | null signature_ua: string | null payment_required: number payment_amount_cents: number | null payment_currency: string payment_processor: string | null payment_reference: string | null payment_status: string | null payment_url: string | null payment_url_expires_at: number | null paid_at: number | null deposit_required: number deposit_amount_cents: number | null deposit_paid_at: number | null deposit_reference: string | null cta_label: string | null cta_url: string | null reminder_count: number last_reminder_at: number | null next_reminder_at: number | null template_id: string | null ai_generated: number hidden: number created_at: number updated_at: number } export interface CrmInvoices { id: string | null profile_id: string contact_id: string | null deal_id: string | null proposal_id: string | null invoice_number: string public_slug: string status: 'draft' | 'sent' | 'viewed' | 'paid' | 'overdue' | 'cancelled' | 'refunded' client_email: string | null client_company: string | null client_address: string | null line_items: string discount_cents: number tax_cents: number total_cents: number currency: string issued_at: number | null due_at: number | null sent_at: number | null view_count: number overdue_notified_at: number | null payment_processor: string | null payment_reference: string | null payment_status: string | null payment_link: string | null payment_method: string | null reminder_count: number last_reminder_at: number | null next_reminder_at: number | null notes: string | null memo: string | null hidden: number created_at: number updated_at: number } export interface CrmImports { id: string | null profile_id: string filename: string | null source: 'csv' | 'linkedin' | 'twitter' | 'apollo' | 'agent' | null imported: number skipped: number failed: number status: string error: string | null created_at: number } export interface CrmAnalytics { profile_id: string | null total_contacts: number total_leads: number total_prospects: number total_customers: number total_archived: number total_converted: number total_deals: number open_deals: number won_deals: number lost_deals: number total_deal_value_cents: number won_deal_value_cents: number forecast_this_month_cents: number forecast_next_month_cents: number total_outreach_sent: number total_replies: number total_calls_booked: number reply_rate_pct: number conversion_rate_pct: number total_agent_actions: number total_pending_approvals: number total_approved: number total_rejected: number avg_lead_score: number contacts_7d: string contacts_30d: string contacts_12m: string contacts_lifetime: string utm_source_breakdown: string utm_medium_breakdown: string utm_campaign_breakdown: string referrer_breakdown: string device_breakdown: string country_breakdown: string source_breakdown: string stage_breakdown: string channel_breakdown: string updated_at: number last_aggregated_at: number } // ── forms.ts ──────────────────────────────────────────────────── export interface Forms { id: string | null profile_id: string media_id: string | null title: string slug: string published: number hidden: number thank_you_settings: string | null collection_id: string | null created_at: string } export interface Questions { id: string | null form_id: string type: string title: string description: string | null position: number options: string | null embed_url: string | null required: number settings: string | null } export interface Submissions { id: string | null form_id: string answers: string last_question_index: number status: string device: string | null os: string | null browser: string | null referrer: string | null city: string | null country: string | null timezone: string | null ip_address: string | null user_agent: string | null utm_source: string | null utm_medium: string | null utm_campaign: string | null started_at: string | null submitted_at: string | null duration_ms: number | null created_at: string } export interface FormAnalytics { id: string | null form_id: string bot_views: number views: number total_views: number views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string visits: number starts: number partials: number submissions: number avg_completion_ms: number trends_7d: string trends_30d: string trends_12m: string lifetime: string device: string os: string browser: string referrer: string country: string city: string utm_source: string utm_medium: string utm_campaign: string last_aggregated_at: number | null updated_at: string } // ── jobs.ts ───────────────────────────────────────────────────── export interface JobListings { id: string | null profile_id: string media_id: string | null user_id: string ai_summary: string | null title: string company: string location: string location_type: string employment_type: string salary_min: number | null salary_max: number | null salary_currency: string excerpt: string | null description: string requirements: string | null slug: string published: number hidden: number image_url: string | null additional_details: string | null total_applicants: number created_at: string updated_at: string expires_at: string | null collection_id: string | null form_settings: string } export interface JobApplications { id: string | null job_id: string profile_id: string resume_url: string | null resume_filename: string | null resume_size_mb: number | null resume_type: string | null full_name: string email: string phone: string | null city: string | null country: string | null date_of_birth: string | null country_of_residence: string | null physical_location: string | null timezone: string | null weekly_availability: string | null linkedin: string | null leetcode: string | null github: string | null codechef: string | null codeforces: string | null summary: string | null education: string work_experience: string projects: string publications: string certifications: string awards: string portfolio: string | null other_links: string skills: string terms_accepted: number resume_updated: number status: string duration_ms: number | null cf_country: string | null cf_city: string | null os: string | null device: string | null browser: string | null ip_address: string | null referrer: string | null utm_source: string | null utm_medium: string | null utm_campaign: string | null created_at: string updated_at: string } export interface JobAnalytics { id: string | null job_id: string profile_id: string bot_views: number total_views: number total_visits: number total_applications: number device_breakdown: string os_breakdown: string browser_breakdown: string country_breakdown: string city_breakdown: string referrer_breakdown: string utm_source_breakdown: string utm_medium_breakdown: string utm_campaign_breakdown: string views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string applications_7d: string applications_30d: string applications_12m: string applications_lifetime: string last_aggregated_at: number | null updated_at: string } // ── provision.ts ──────────────────────────────────────────────── export interface SchemaMigrations { id: string | null applied_at: number duration_ms: number | null error: string | null } export interface Users { id: string | null workos_id: string | null email: string first_name: string | null last_name: string | null username: string | null bio: string | null location: string | null website: string | null social_links: string profile_picture_url: string | null created_at: number updated_at: number last_login: number | null is_active: number } export interface Credentials { id: string | null profile_id: string | null ses_access_key: string | null ses_secret_key: string | null ses_region: string | null ses_from_email: string | null openai_api_key: string | null anthropic_api_key: string | null resend_api_key: string | null n8n_webhook_url: string | null created_at: number updated_at: number } export interface Settings { id: string | null profile_id: string site_title: string | null tagline: string | null site_description: string | null logo_url: string | null favicon: string | null og_title: string | null og_description: string | null og_image: string | null canonical_url: string | null robots: string google_tag_manager_id: string | null ga_tracking_id: string | null google_site_verification: string | null timezone: string | null location: string | null industry: string | null theme: string working_hours: string crm_auto_approve: number pipeline_stages: string invoice_sequence: number proposal_sequence: number created_at: number updated_at: number } export interface Categories { id: string | null name: string slug: string description: string | null created_at: number order_index: number } export interface Profiles { id: string | null user_id: string slug: string title: string bio: string | null navigation_menu: string created_at: number updated_at: number enabled_categories: string home_visibility: string category_visibility: string avatar_url: string | null home_page: string | null about: string | null profile_theme: string collect_emails: string collect_emails_enabled: number social_links: string about_visibility: string landing_visibility: string cover_images: string info_visibility: string chat_agent_enabled: number chat_agent_model: string chat_agent_greeting: string | null chat_agent_personality: string | null chat_agent_accent_color: string voice_agent_enabled: number voice_agent_show_circle: number voice_agent_personality: string | null support_email: string | null from_email: string | null chat_widget_tab: string page_visibility: string type: string | null niche: string | null minimum_age: number resume: string | null } export interface Links { id: string | null profile_id: string media_id: string | null category_id: string title: string url: string description: string | null image_url: string | null order_index: number is_active: number created_at: number updated_at: number keywords: string hidden_from_profile: number sale_price: string | null price: string | null button_text: string | null location: string | null date: string | null collection_name: string | null video_url: string | null logo_url: string | null post_url: string | null platform_name: string | null collection_id: string | null slug: string | null in_app: number geo_redirect: string } export interface LinkAnalytics { id: string | null link_id: string profile_id: string total_clicks: number device_clicks: string os_clicks: string browser_clicks: string country_clicks: string city_clicks: string referrer_clicks: string analytics_lifetime: string analytics_24h: string analytics_7d: string analytics_30d: string analytics_12m: string utm_source_clicks: string utm_medium_clicks: string utm_campaign_clicks: string created_at: number updated_at: number last_aggregated_at: number bot_clicks: number } export interface LinkAnalyticsByCategory { id: string | null profile_id: string category_id: string total_links: number active_links: number total_clicks: number bot_clicks: number bot_views: number total_views: number views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string device_clicks: string os_clicks: string browser_clicks: string country_clicks: string city_clicks: string referrer_clicks: string analytics_lifetime: string analytics_7d: string analytics_30d: string analytics_12m: string last_aggregated_at: string created_at: string updated_at: string } export interface ClicksAnalytics { id: string | null link_id: string profile_id: string device: string | null os: string | null browser: string | null country: string | null city: string | null referrer: string | null utm_source: string | null utm_medium: string | null utm_campaign: string | null clicked_at: number is_bot: number } export interface ProfileData { id: string | null profile_id: string data: string created_at: number updated_at: number } export interface Collections { id: string | null profile_id: string media_id: string | null title: string slug: string description: string | null icon: string | null sort_order: number type: string | null category_id: string | null category_slug: string | null seo_title: string | null seo_description: string | null seo_og_image: string | null seo_robots: string | null seo_block_indexing: number created_at: string updated_at: string } export interface CategoryPages { id: string | null profile_id: string media_id: string | null category_id: string | null category_slug: string seo_title: string | null seo_description: string | null seo_og_image: string | null seo_robots: string | null seo_block_indexing: number title: string | null description: string | null ads_code_sidebar: string | null ads_code_top: string | null ads_code_bottom: string | null published: number hidden: number image_ads: string is_active: number nav_active: number menu_active: number footer_active: number section: string created_at: number updated_at: number } export interface Products { id: string | null profile_id: string media_id: string | null slider_id: string | null external_product_id: string | null user_id: string community_id: string | null type: string title: string excerpt: string | null description: string | null price_cents: number sale_price_cents: number | null currency: string is_active: number thumbnail_url: string | null hero_image_url: string | null slug: string | null file_url: string | null lessons: string | null total_lessons: number add_people: string location_map: string | null media_url: string forms_id: string | null duration_minutes: number | null calendar_link: string | null scheduling_provider: string | null scheduling_metadata: string | null webinar_link: string | null webinar_platform: string | null webinar_schedule: string | null billing_interval: string | null features: string | null tags: string | null settings: string | null visibility: string max_sales: number | null created_at: number updated_at: number published_at: number | null archived_at: number | null cover_video_url: string | null product_rating: string additional_details: string show_total_sales: number meeting_settings: string | null button_text: string | null webinar_settings: string | null category_id: string | null cta_clicks: number platform_name: string | null platform_url: string | null post_frequency: string | null event_settings: string | null cta_button: string unit: number published: number hidden: number hide_author: number image_ads: string collection_id: string | null confirmation_email_subject: string | null confirmation_email_body: string | null up_sell: string ai_summary: string | null course_access_type: string course_access_config: string seo_title: string | null seo_description: string | null seo_og_image: string | null seo_robots: string | null seo_block_indexing: number } export interface ProductAnalytics { id: string | null product_id: string profile_id: string total_sales: number total_revenue_cents: number bot_views: number total_views: number views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string device_breakdown: string os_breakdown: string browser_breakdown: string country_breakdown: string city_breakdown: string referrer_breakdown: string sales_7d: string sales_30d: string sales_12m: string sales_lifetime: string created_at: number updated_at: number revenue_7d: string revenue_30d: string revenue_12m: string revenue_lifetime: string sales_utm_source: string sales_utm_medium: string sales_utm_campaign: string email_opens: number email_clicks: number last_aggregated_at: number } export interface ProfileAnalytics { id: string profile_id: string bot_views: number total_views: number views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string total_clicks: number total_sales: number total_earnings: number bot_clicks: number device_clicks: string os_clicks: string browser_clicks: string country_clicks: string city_clicks: string referrer_clicks: string analytics_lifetime: string analytics_24h: string analytics_7d: string analytics_30d: string analytics_12m: string created_at: number updated_at: number sales_7d: string sales_30d: string sales_12m: string sales_lifetime: string sales_device: string sales_os: string sales_browser: string sales_countries: string sales_cities: string sales_referrer: string revenue_7d: string revenue_30d: string revenue_12m: string revenue_lifetime: string utm_source_clicks: string utm_medium_clicks: string utm_campaign_clicks: string sales_utm_source: string sales_utm_medium: string sales_utm_campaign: string total_products: number total_links: number active_links: number product_email_opens: number product_email_clicks: number last_aggregated_at: number } export interface Purchases { id: string | null profile_id: string user_id: string product_id: string community_member_id: string | null transaction_id: string | null email: string customer_name: string | null amount_cents: number platform_fee_cents: number currency: string payment_processor: string payment_reference: string | null payment_status: string status: string access_token: string access_token_secret: string | null access_token_expires_at: number | null last_accessed_at: number | null access_count: number course_progress: string | null course_completed: number review_reply: string | null course_completion_date: number | null consultancy_scheduled_at: number | null consultancy_meeting_link: string | null consultancy_status: string | null subscription_id: string | null subscription_status: string | null subscription_current_period_end: number | null webinar_access_link: string | null webinar_scheduled_at: number | null ip_address: string | null user_agent: string | null metadata: string | null created_at: number updated_at: number rating_star: number | null rating_review: string | null rated_at: number | null buyer_avatar_url: string | null slots: string | null meeting_link: string | null customer_message: string | null rating_reply: string | null approval_status: string device: string | null os: string | null browser: string | null referrer: string | null city: string | null country: string | null timezone: string | null utm_source: string | null utm_medium: string | null utm_campaign: string | null refunded_at: number | null refund_reason: string | null } export interface Sessions { id: string | null user_id: string session_token: string expires_at: string created_at: string | null ip_address: string | null user_agent: string | null } export interface Subscribers { id: string | null profile_id: string email: string name: string | null phone: string | null referrer_domain: string | null timezone: string | null browser_name: string | null os_name: string | null device_type: string | null ip_address: string | null country: string | null city: string | null is_blocked: string is_unsubscribed: string blocked_at: number | null unsubscribed_at: number | null block_reason: string | null signup_timestamp: number } export interface Gateways { id: string | null profile_id: string provider: string is_active: number is_test_mode: number credentials: string created_at: number } export interface Pages { id: string | null profile_id: string media_id: string | null user_id: string title: string slug: string excerpt: string | null text_field: string | null hero_slider: string | null hero_section: string | null testimonials: string | null pricing: string | null faq: string | null trusted_by: string | null intro_section: string | null heighlights: string | null category_visibility: string | null curriculum: string | null people_section: string | null about_section: string | null cta_section: string | null nav_active: number menu_active: number footer_active: number published: number hidden: number is_active: number order_index: number ai_summary: string | null lead_magnet: string | null text_area: string | null subscribe_chat: string | null content_list: string | null custom_design_a: string | null custom_design_b: string | null custom_design_c: string | null section_a: string | null section_b: string | null section_c: string | null section_d: string | null section_e: string | null section_f: string | null section_g: string | null section_h: string | null section_i: string | null section_j: string | null contact_us: string | null subscribe: string | null slider: string | null created_at: number updated_at: number } export interface PageAnalytics { id: string | null page_id: string profile_id: string bot_views: number total_views: number views_device_breakdown: string views_os_breakdown: string views_browser_breakdown: string views_country_breakdown: string views_city_breakdown: string views_referrer_breakdown: string views_7d: string views_30d: string views_12m: string views_lifetime: string last_aggregated_at: string updated_at: string } export interface CmsTables { id: string | null profile_id: string user_id: string slug: string title: string subtitle: string | null content: string | null excerpt: string | null hero_image_url: string | null cta_button_url: string | null cta_button_text: string | null faqs: string additional_details: string published: number hidden: number date: string | null collection_id: string | null hide_author: number image_ads: string ai_summary: string | null custom_design: string | null seo_title: string | null seo_description: string | null seo_keywords: string | null word_count: number | null reading_time_mins: number | null internal_links: number | null external_links: number | null sources: string | null social_links: string website: string | null logo_url: string | null name: string | null tagline: string | null highlights: string hide_info: number cms_id: string | null location: string | null created_at: string updated_at: string } export interface Media { id: string | null profile_id: string name: string media_type: string url: string alt_text: string | null thumbnail_url: string | null size_bytes: number | null mime_type: string | null created_at: number } export interface Sliders { id: string | null profile_id: string title: string created_at: number } export interface SliderItems { id: string | null profile_id: string slider_id: string media_id: string | null position: number caption: string | null link: string | null created_at: number } // ── social.ts ─────────────────────────────────────────────────── export interface Connections { id: string | null profile_id: string name: 'zernio' | 'twitter_direct' | 'instagram_direct' | 'facebook_direct' url: string | null username: string | null password: string | null is_active: number is_verified: number last_error: string | null error_count: number created_at: number updated_at: number } export interface SocialAccounts { id: string | null profile_id: string connection_id: string connection_mode: 'zernio_platform' | 'zernio_byok' | 'direct' | 'n8n' zernio_profile_id: 'twitter' | 'instagram' | 'facebook' | 'linkedin' | 'tiktok' | null } export interface SocialPostGroups { id: string | null profile_id: string created_at: number } export interface SocialPosts { id: string | null profile_id: string account_id: 'twitter' | 'instagram' | 'facebook' | 'linkedin' | 'tiktok' direct: string | null or: string | null platform_post_url: string | null zernio_account_id: string | null media_items: string link_title: string | null link_description: string | null link_thumbnail_url: 'draft' | 'scheduled' | 'queued' | 'publishing' | 'published' | null publish_now: number use_queue: number queue_slot_id: string | null set: 'pending' | 'approved' | 'rejected' | 'auto_sent' approved_at: 'manual' | 'agent' | 'blog_crosspost' | 'product_launch' | null ai_prompt: string | null NULL: string ai_label: 'promotional' | 'educational' | 'engagement' | 'testimonial' | 'announcement' | null } export interface SocialPostAnalytics { id: string | null post_id: string comments: number shares: number reposts: number reach: number clicks: number completion_rate_pct: number | null same: string | null post_city_breakdown: string | null post_age_breakdown: string | null post_gender_breakdown: string | null post_device_breakdown: string | null analytics_synced_at: number | null created_at: number updated_at: number } export interface SocialAnalytics { id: string | null profile_id: string account_id: string follower_change_7d: number follower_change_30d: number total_comments: number total_shares: number total_impressions: number total_reach: number total_clicks: number total_saves: number total_views: number avg_engagement_rate: number posts_30d: string posts_12m: string impressions_7d: string impressions_30d: string impressions_12m: string engagement_7d: string engagement_30d: string engagement_12m: string follower_7d: string follower_30d: string best_time_breakdown: string content_type_breakdown: string last_aggregated_at: number | null last_synced_at: number | null updated_at: number } export interface SocialMediaKit { id: string | null profile_id: string total_followers: number total_reach_30d: number avg_engagement_rate: number follower_growth_30d: number platform_breakdown: string audience_country_breakdown: string audience_city_breakdown: string audience_gender_breakdown: string audience_age_breakdown: string audience_language_breakdown: string audience_interest_breakdown: string audience_device_breakdown: string top_posts: string content_type_breakdown: string best_time_breakdown: string show_country: number show_city: number show_gender: number show_age: number show_platform_breakdown: number show_engagement_rate: number last_computed_at: number | null created_at: number updated_at: number } export interface SocialQueue { id: string | null profile_id: string account_id: string zernio_slot_id: string | null day_of_week: number is_active: number last_used_at: number | null next_scheduled_at: number | null created_at: number updated_at: number } export interface SocialInbox { id: string | null profile_id: string account_id: string inbox_source: 'zernio' | 'direct' | 'n8n' | 'manual' zernio_message_id: 'dm' | 'comment' | 'review' | null sender_username: string | null sender_display_name: string | null sender_avatar_url: string | null sender_profile_url: string | null sender_follower_count: number | null media_urls: string review_title: 'unread' | 'read' | 'replied' | 'archived' | 'spam' | null is_pinned: number sentiment: 'positive' | 'neutral' | 'negative' | null replied_at: number | null replied_by: 'agent' | 'user' | null agent_sentiment: string | null agent_suggested_action: 'reply' | 'archive' | 'escalate' | 'add_to_crm' | 'ignore' | null approval_status: 'pending' | 'approved' | 'rejected' | 'auto_sent' created_at: number updated_at: number } export interface SocialLabels { id: string | null profile_id: string name: string color: string icon: string | null usage_count: number created_at: number } export interface SocialAutomations { id: string | null profile_id: string account_id: string | null description: string | null automation_family: 'content' | 'engagement' ai_prompt_template: string | null use_queue: number is_active: number last_triggered_at: number | null trigger_count: number dm_sent_count: number crm_leads_created: number last_error: string | null created_at: number updated_at: number } export interface SocialAutomationLogs { id: string | null profile_id: string automation_id: string trigger_type: string triggered_at: number commenter_username: string | null commenter_display_name: string | null comment_content: string | null keyword_matched: 'sent' | 'failed' | 'skipped' | null comment_reply_sent: number created_at: number } export interface SocialSequences { id: string | null profile_id: string account_id: string zernio_sequence_id: string | null name: string description: string | null platform: string status: 'draft' | 'active' | 'paused' | 'archived' total_completed: number total_unsubscribed: number total_replied: number reply_rate_pct: number is_active: number activated_at: number | null created_at: number updated_at: number } export interface SocialSequenceSteps { id: string | null sequence_id: string profile_id: string step_order: number delay_minutes: number message_text: string media_urls: string created_at: number } export interface SocialSequenceEnrollments { id: string | null sequence_id: string profile_id: string zernio_enrollment_id: string | null zernio_contact_id: string | null contact_platform_id: string contact_username: string | null contact_display_name: string | null crm_contact_id: string | null status: 'active' | 'completed' | 'unsubscribed' | 'failed' | 'paused' last_message_sent_at: number | null next_message_at: number | null replied: number replied_at: number | null enrolled_at: number completed_at: number | null created_at: number updated_at: number } export interface SocialBroadcasts { id: string | null profile_id: string account_id: string zernio_broadcast_id: string | null name: string platform: string message_text: string media_urls: string status: 'draft' | 'scheduled' | 'sending' | 'sent' | 'cancelled' | 'failed' sent_at: number | null recipient_count: number delivered_count: number failed_count: number reply_count: number segment_config: string | null created_at: number updated_at: number } export interface SocialCompetitors { id: string | null profile_id: string platform: string display_name: string | null avatar_url: string | null bio: string | null platform_url: string | null website: string | null category: string | null is_verified: number following_count: number platform_post_count: number avg_engagement_rate: number avg_comments_per_post: number avg_views_per_post: number audience_age_breakdown: string | null audience_gender_breakdown: 'competitor' | 'inspiration' | 'partner' | 'client' | 'influencer' | 'watch' | null last_analyzed_at: number | null track_posts: number created_at: number updated_at: number } export interface SocialCompetitorPosts { id: string | null profile_id: string competitor_id: string platform_post_id: string } export const TABLES = { agents: 'agents' as const, agent_skills: 'agent_skills' as const, skill_files: 'skill_files' as const, agent_memory: 'agent_memory' as const, agent_notes: 'agent_notes' as const, agent_files: 'agent_files' as const, agent_tasks: 'agent_tasks' as const, agent_reports: 'agent_reports' as const, agent_kb: 'agent_kb' as const, agent_conversations: 'agent_conversations' as const, agent_audit: 'agent_audit' as const, content: 'content' as const, content_reaction: 'content_reaction' as const, content_comment: 'content_comment' as const, cms: 'cms' as const, content_views: 'content_views' as const, content_analytics: 'content_analytics' as const, cms_analytics: 'cms_analytics' as const, doc_analytics: 'doc_analytics' as const, doc_collections: 'doc_collections' as const, doc_articles: 'doc_articles' as const, crm_contacts: 'crm_contacts' as const, crm_deals: 'crm_deals' as const, crm_activities: 'crm_activities' as const, crm_tasks: 'crm_tasks' as const, crm_notes: 'crm_notes' as const, crm_groups: 'crm_groups' as const, crm_contact_groups: 'crm_contact_groups' as const, crm_templates: 'crm_templates' as const, crm_proposals: 'crm_proposals' as const, crm_invoices: 'crm_invoices' as const, crm_imports: 'crm_imports' as const, crm_analytics: 'crm_analytics' as const, forms: 'forms' as const, questions: 'questions' as const, submissions: 'submissions' as const, form_analytics: 'form_analytics' as const, job_listings: 'job_listings' as const, job_applications: 'job_applications' as const, job_analytics: 'job_analytics' as const, _schema_migrations: '_schema_migrations' as const, users: 'users' as const, credentials: 'credentials' as const, settings: 'settings' as const, categories: 'categories' as const, profiles: 'profiles' as const, links: 'links' as const, link_analytics: 'link_analytics' as const, link_analytics_by_category: 'link_analytics_by_category' as const, clicks_analytics: 'clicks_analytics' as const, profile_data: 'profile_data' as const, collections: 'collections' as const, category_pages: 'category_pages' as const, products: 'products' as const, product_analytics: 'product_analytics' as const, profile_analytics: 'profile_analytics' as const, purchases: 'purchases' as const, sessions: 'sessions' as const, subscribers: 'subscribers' as const, gateways: 'gateways' as const, pages: 'pages' as const, page_analytics: 'page_analytics' as const, cms_tables: 'cms_tables' as const, media: 'media' as const, sliders: 'sliders' as const, slider_items: 'slider_items' as const, connections: 'connections' as const, social_accounts: 'social_accounts' as const, social_post_groups: 'social_post_groups' as const, social_posts: 'social_posts' as const, social_post_analytics: 'social_post_analytics' as const, social_analytics: 'social_analytics' as const, social_media_kit: 'social_media_kit' as const, social_queue: 'social_queue' as const, social_inbox: 'social_inbox' as const, social_labels: 'social_labels' as const, social_automations: 'social_automations' as const, social_automation_logs: 'social_automation_logs' as const, social_sequences: 'social_sequences' as const, social_sequence_steps: 'social_sequence_steps' as const, social_sequence_enrollments: 'social_sequence_enrollments' as const, social_broadcasts: 'social_broadcasts' as const, social_competitors: 'social_competitors' as const, social_competitor_posts: 'social_competitor_posts' as const, } export type TableName = keyof typeof TABLES