# =renewals <path>: vendor and contract renewals from a CSV, soonest first.
#
# What this app teaches, in three lines:
# 1. `mode: list_data` lets one chart pane draw every row, here annual cost by vendor.
# 2. A row field computed in the script (days to renewal, flag text) keeps the manifest declarative.
# 3. A composer action with `primary: true` makes Enter copy a ready-to-send message.
#
# Point it at a CSV with the columns vendor, annual cost, renewal date
# (YYYY-MM-DD), owner. The list is the timeline, sorted by days to renewal
# (passed dates first). Anything under 30 days says "under 30 days" in plain
# words. Enter copies a renewal-reminder message for that row.
#
# Sample data: `=renewals demo`, or no path at all, shows fabricated vendors
# with dates relative to today. Every sample row says SAMPLE DATA. Typing
# nothing opens those sample rows directly rather than a separate prompt row,
# because the chart pane draws every row and a prompt row would be a bogus bar.
# This app reads one file and never writes anywhere.
schema_version: 1
runtime: bridge
id: renewals
chip: renewals
title: Renewals
icon: calendar-clock
description: "Contract renewals from a CSV: timeline, cost by vendor, reminders. =renewals demo shows sample data"
placeholder_examples: ["~/Downloads/contracts.csv", "demo"]
emits: Generic

bridge:
  command:
    macos: "python3 {{scripts_dir}}/bolt-renewals.py {{query}}"
    linux: "python3 {{scripts_dir}}/bolt-renewals.py {{query}}"
    windows: "python {{scripts_dir}}/bolt-renewals.py {{query}}"
  parse: json
  timeout_seconds: 10

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  right_widget:
    kind: table
    mode: list_data
    bind:
      columns:
        - { field: title, label: Vendor }
        - { field: value, label: "Cost/yr", align: right, total: sum, format: currency, unit: "$" }
        - { field: renews_in, label: Renews }
      totals_label: Total

actions:
  - { id: copy-reminder, kind: composer, target: row, label: Copy reminder, insert: "{{row.reminder}}", primary: true }
  - { id: copy-line, kind: composer, target: row, label: Copy line, insert: "{{row.title}}: {{row.cost}} a year, renews {{row.renews}}, owner {{row.owner}}" }
