# =dns <domain>: A, AAAA, MX, TXT, NS, CNAME records, one row per type, with
# the whole answer in a table on the right.
# Network call (DNS queries via the system dig binary, or the system resolver
# for A and AAAA when dig is missing). Only the typed name is sent. The script
# accepts a plain hostname only: no scheme, path, port or spaces, and nothing
# that starts with a dash.
#
# Sample data: `=dns demo` always shows fabricated rows. With no domain typed
# the list opens on a "Try with sample data" row followed by the same rows.
# Every sample row says SAMPLE DATA. A typed name that fails gets honest error
# rows, never sample data.
schema_version: 1
runtime: bridge
id: dns
chip: dns
title: DNS records
icon: globe
description: "Network call: A, AAAA, MX, TXT, NS and CNAME records for a domain in one table. =dns demo shows sample data"
placeholder_examples: ["sparcle.app", "github.com", "demo"]
emits: Generic

bridge:
  command:
    macos: "python3 {{scripts_dir}}/bolt-dns.py {{domain}}"
    linux: "python3 {{scripts_dir}}/bolt-dns.py {{domain}}"
    windows: "python {{scripts_dir}}/bolt-dns.py {{domain}}"
  parse: json
  timeout_seconds: 30

args:
  - { name: domain, from: "query.word(0)", default: "" }

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  searchable: true
  # One table of every record type at a glance. The list on the left keeps the
  # per-type rows; Tab on a row copies its values.
  right_widget:
    kind: table
    mode: list_data
    bind:
      columns:
        - { field: rtype, label: Type }
        - { field: count, label: Records, align: right }
        - { field: preview, label: Values }

actions:
  - { id: copy-values, kind: composer, target: row, label: Copy records, insert: "{{values}}" }
  - { id: copy-domain, kind: composer, target: row, label: Copy domain, insert: "{{domain}}" }
