/** * Declared alerts into the chart's watched conditions. * * An `alert()` call site is lifted by the compiler into one declared entry: a * boolean channel carrying the chain of guards that reaches the call, a string * channel carrying the message, a stable key and a title (`stdlib.md` 16.1). The * chart's own watched condition is a row with a stable id, a title and a * predicate it evaluates per bar, so the mapping is the boolean channel: it * rides the values table as a column, and the predicate reads that column at the * bar it is judging. * * **Nothing fires for history, and the chart is what applies that.** It judges * only bars that are new since it last looked, so a study added at noon to a * chart holding two years announces none of them, and a settings change, which * recomputes the whole history without adding a bar, announces nothing either. * That is `stdlib.md` 16.2 reached from the host's side rather than the engine's, * and it is the rule the descriptor's own slot already carries. * * **An absent condition is not a true one.** The column holds a number where the * channel published `true` and `null` everywhere else, so an alert under a guard * that was absent during warmup does not fire. That is `language.md` 6.6's three * valued logic reaching a surface, and it is the most common reason a new alert * looks dead. * * **The message is computed on the bar that fired, and it travels.** It is a * string per bar, so it cannot ride the table of numbers the calculation * returns, and the entry's own field takes a function of the same context the * predicate was judged on: the bars, the columns, the settings and the bar's * index. The settings are the study instance (`produced.ts`), so the message * reads the run's own string channel there, at the one bar it is asked about, * and the alert a user receives carries the numbers the script put in it. * * **The bar it is asked about is the run's, found through the table.** The * index the chart hands the hook is a position in the table it holds, and that * is not always a position in the run: a chart that transforms its series into * elements that are not one per bar can run a study on the host's bars and read * the table onto its elements, so element 7 may hold bar 12's values. The * condition is a column and is read across with the rest; the message channel * is not, so the table also carries each row's bar index (`columns.ts`), which * the chart reads across like any other column, and the message is read at the * bar that names. On a chart that draws the bars it computed on, which is every * chart before that option existed, the column is the index itself. * * A message the bar published nothing for falls back to the declared title, * which is what the chart itself does for an entry that states no message. That * is the honest answer for the one case that reaches it: `message` is a required * argument, so the string is absent only where the expression that built it was, * and absence reaching a surface draws nothing of its own (`language.md` 6.7). * * **One thing a declared alert carries still has no field on the chart's entry** * and is left out rather than approximated. The **frequency** (`stdlib.md` 16.2) * has nowhere to land: the chart evaluates each entry once for each new bar, * which is `"oncePerBar"`; `"once"` would need state that lives as long as the * study instance and `"everyUpdate"` would need the entry to be evaluated again * on a bar that is still moving, and the entry is handed neither. It is recorded * with its reason in `spec/chart-narrowings.json`, which * `scripts/check-chart-surface.mjs` refuses to let grow in silence. */ import type { CompiledProgram } from '../../core/emit/index.js'; import type { ColumnSpec } from './columns.js'; import type { InputLookup } from './fields.js'; import type { MessageColumn } from './produced.js'; import type { Columns } from './run.js'; import type { ChartAlertSpec } from './surfaces.js'; /** The key one alert's condition column travels under. */ export declare function alertKey(index: number): string; export interface AlertBuild { readonly alerts: readonly ChartAlertSpec[]; readonly columns: readonly ColumnSpec[]; } /** * Each declared alert's message channel, as the run left it. * * Indexed by the alert's position in `outputs.alerts`, so an entry the program * declares without a message channel holds an empty column rather than shifting * the ones after it. */ export declare function alertMessages(program: CompiledProgram, columns: Columns): readonly MessageColumn[]; /** The rows a user subscribes to, fixed before the first bar. */ export declare function buildAlerts(program: CompiledProgram, lookup: InputLookup): AlertBuild; //# sourceMappingURL=alerts.d.ts.map