# =skywatch [city]: a small sky dashboard from public sources that need no
# account, fetched in parallel and grouped by source:
#   ISS position (api.wheretheiss.at), next rocket launches (Launch Library 2,
#   ll.thespacedevs.com), earthquakes of M4.5 and up in the last day (USGS) and,
#   when a city is typed, weather and sunrise/sunset (Open-Meteo, no key).
# With no city the weather source is skipped and the first row says so.
#
# Launch Library 2 allows few requests per hour, so its answer is cached for 10
# minutes in <user-utils>/state/skywatch/launches.json (the app's own state
# folder). A live miss falls back to the older cache and says so on the row.
#
# Network and privacy: HTTPS only, fixed host list in scripts/bolt_safenet.py;
# the typed city is only percent-encoded into a query, never used as a host.
# No cookies, no sign-in, no tokens; User-Agent is "BoltSkywatch/<version>".
# Responses over 1 MB are ignored; fetched text is escaped before display.
#
# Sample data: `=skywatch demo`, and the case where no source answered, show
# fabricated rows marked SAMPLE DATA. A single failing source is named in its
# own row, never filled with sample data.
schema_version: 1
runtime: bridge
id: skywatch
chip: skywatch
title: Sky watch
icon: globe
description: "Network call: pressing Enter contacts api.wheretheiss.at, ll.thespacedevs.com and earthquake.usgs.gov, and if you type a city, sends that city to geocoding-api.open-meteo.com and api.open-meteo.com. Those sites see your IP address. Nothing is sent while you type. =skywatch demo shows sample data"
placeholder_examples: ["Berlin", "Tokyo", "demo (sample data)"]
emits: Generic

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

args: []

# Bridge apps run only on Enter (see pulse.yaml), so no request is made while typing.
dispatch:
  confirm_label: 'Sky watch for: {{query}}'
  confirm_hint: "Press Enter to contact api.wheretheiss.at, ll.thespacedevs.com and earthquake.usgs.gov; a typed city also goes to geocoding-api.open-meteo.com and api.open-meteo.com. They see your IP address. Empty = no weather. demo = sample data, nothing sent"

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  right_widget:
    kind: entity_preview
    mode: selected_row
    bind:
      title: "{{row.title}}"
      subtitle: "{{row.subtitle}}"
      fields:
        - { label: Source, value: "{{row.source}}" }
        - { label: When, value: "{{row.when}}" }
        - { label: Key figure, value: "{{row.figure}}" }
        - { label: Data, value: "{{row.data}}" }
      body: "{{row.body}}"
      actions: [open, copy]

actions:
  - { id: open, kind: url, target: row, label: Open source, url_template: "{{row.url}}" }
  - { id: copy, kind: composer, target: row, label: Copy summary, insert: "{{row.summary}}" }
