pub struct SqlWidget {
pub title: String,
pub description: Option<String>,
pub query: String,
pub render: RenderSpec,
pub refresh: Option<String>,
pub placement: Placement,
}Expand description
#vuln-roadmap PR3: a SQL-backed, materialized widget on a View.
Where an AggregateWidget encodes an obs_events rollup in structured
YAML fields, a SqlWidget carries a raw read-only SELECT/WITH over the
projector’s tables (inventory explode: tables, feeds, check_status,
…) — the correlation that powers a vulnerability / EOL / license dashboard
is just a JOIN, far more expressive than a YAML DSL. The backend runs the
query in the read-only sandbox (api::query), caches the result on the
refresh cadence, and maps it to the same render-ready shape the existing
widget components consume, via RenderSpec. See View::sql_widgets.
Fields§
§title: StringWidget heading. Required, validated non-empty.
description: Option<String>Optional muted subtitle (a unit, a caveat). Rejected if present-blank.
query: StringThe read-only SQL. Executed in the api::query sandbox: a single
SELECT/WITH on a SQLITE_OPEN_READONLY connection, row-capped and
time-bounded. The backend validates it read-only at view create and
again at run time; a write verb / stacked statement is rejected.
render: RenderSpecHow the query’s result columns map to a visual — see RenderSpec.
refresh: Option<String>Materialization cadence as a humantime duration ("6h", "30m").
Absent ⇒ DEFAULT_VIEW_REFRESH. The backend re-runs the query at
most this often; reads in between hit the cache.
placement: PlacementWhere the widget surfaces — an Analytics tab and/or a pinned Dashboard card. At least one must be set (else it renders nowhere).
Implementations§
Source§impl SqlWidget
impl SqlWidget
Sourcepub fn refresh_interval(&self) -> Duration
pub fn refresh_interval(&self) -> Duration
The effective refresh cadence — the parsed refresh or
DEFAULT_VIEW_REFRESH. Falls back to the default on an unparseable
value rather than panicking on the read path (validation already
rejected a bad value at view create).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SqlWidget
impl<'de> Deserialize<'de> for SqlWidget
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for SqlWidget
impl JsonSchema for SqlWidget
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more