# File: projects.object.yml
# Object name is inferred from filename as 'projects'
label: Project
icon: building-line

ai_context:
  intent: "Track and manage software development projects"
  domain: project_management
  aliases: [project, initiative]
  common_queries:
    - "Find active projects"
    - "Show projects by priority"
    - "List projects with high budget"

fields:
  name:
    type: text
    required: true
    label: Project Name
    index: true # Field-level index
    ai_context:
      intent: "Primary identifier for the project"
      examples: ["Website Redesign", "Mobile App v2.0"]

  status:
    type: select
    label: Project Status
    options:
      - label: Planned
        value: planned
      - label: In Progress
        value: in_progress
      - label: Completed
        value: completed
    defaultValue: planned
    index: true
    ai_context:
      intent: "Track project lifecycle stage"
      is_state_machine: true
      transitions:
        planned: [in_progress, completed]
        in_progress: [completed, planned]
        completed: []

  priority:
    type: select
    label: Priority Level
    options:
      - label: Low
        value: low
      - label: Normal
        value: normal
      - label: High
        value: high
    defaultValue: normal
    ai_context:
      intent: "Prioritize project execution order"
      selection_guidance: "High priority for urgent or critical projects"

  description:
    type: textarea
    label: Project Description
    ai_context:
      intent: "Detailed project overview and objectives"

  owner:
    type: text
    label: Project Owner
    ai_context:
      intent: "Person responsible for project success"
      semantic_type: ownership

  budget:
    type: currency
    label: Project Budget
    ai_context:
      intent: "Allocated financial resources"
      validation_notes: "Must be non-negative; >$10k requires detailed description"

  start_date:
    type: date
    label: Start Date
    ai_context:
      intent: "Project commencement date"

  end_date:
    type: date
    label: End Date
    ai_context:
      intent: "Target completion date"
      validation_notes: "Must be on or after start_date"
  
  approved_by:
    type: text
    label: Approved By
    ai_context:
      intent: "Approver identity for audit trail"
  
  approved_at:
    type: datetime
    label: Approval Timestamp
  
  approval_comment:
    type: textarea
    label: Approval Comment

indexes:
  # Composite index for reporting
  status_priority_idx:
    fields: [status, priority]

ai:
  search:
    enabled: true
    fields: [name, description]
    model: text-embedding-3-small

actions:
  # Record Actions (operate on specific records)
  complete:
    type: record
    label: Complete Project
    icon: checkbox-circle-line
    confirm_text: "Are you sure you want to complete this project?"
    params:
      comment:
        type: textarea
        label: Completion Comment
      completion_date:
        type: date
        label: Completion Date
  
  approve:
    type: record
    label: Approve Project
    icon: shield-check-line
    confirm_text: "Are you sure you want to approve this project?"
    params:
      comment:
        type: textarea
        required: true
        label: Approval Comment
        help_text: "Provide a reason for approving this project"
  
  clone:
    type: record
    label: Clone Project
    icon: file-copy-line
    description: Create a copy of this project
    params:
      new_name:
        type: text
        required: true
        label: New Project Name
      copy_tasks:
        type: checkbox
        label: Copy Associated Tasks
        defaultValue: false

  # Global Actions (operate on collections)
  import_projects:
    type: global
    label: Import Projects
    icon: download-line
    internal: false
    description: Import multiple projects from various sources
    params:
      source:
        required: true
        label: Import Source
        options:
          - csv
          - json
          - api
      data:
        type: textarea
        label: JSON Data
        help_text: "Paste JSON array of projects (optional if using file_url)"
      file_url:
        type: text
        label: File URL
        help_text: "URL to fetch data from (optional if using data field)"
  
  bulk_update_status:
    type: global
    label: Bulk Update Status
    icon: edit-box-line
    description: Update status for multiple projects at once
    params:
      project_ids:
        type: textarea
        required: true
        label: Project IDs
        help_text: "List of project IDs"
      new_status:
        required: true
        label: New Status
        options:
          - planned
          - in_progress
          - completed
  
  generate_report:
    type: global
    label: Generate Project Report
    icon: file-chart-line
    description: Generate statistical report of all projects
