| 167 | } |
| 168 | |
| 169 | function querySection(): string { |
| 170 | return `## Query — Live Data Fetching |
| 171 | |
| 172 | Fetch data from available tools. Returns defaults instantly, swaps in real data when it arrives. |
| 173 | |
| 174 | \`\`\` |
| 175 | metrics = Query("tool_name", {arg1: value, arg2: $binding}, {defaultField: 0, defaultData: []}, refreshInterval?) |
| 176 | \`\`\` |
| 177 | |
| 178 | - First arg: tool name (string) |
| 179 | - Second arg: arguments object (may reference $bindings — re-fetches automatically on change) |
| 180 | - Third arg: default data (rendered immediately before fetch resolves) |
| 181 | - Fourth arg (optional): refresh interval in seconds (e.g. 30 for auto-refresh every 30s) |
| 182 | - Use dot access on results: metrics.totalEvents, metrics.data.day (array pluck) |
| 183 | - Query results must use regular identifiers: \`metrics = Query(...)\`, NOT \`$metrics = Query(...)\` |
| 184 | - Manual refresh: \`Button("Refresh", Action([@Run(query1), @Run(query2)]), "secondary")\` — re-fetches the listed queries |
| 185 | - Refresh all queries: create Action with @Run for each query`; |
| 186 | } |
| 187 | |
| 188 | function mutationSection(): string { |
| 189 | return `## Mutation — Write Operations |