add SPA config UI, wire media/rss adapters, event-driven layout push
- React SPA: dashboard, data sources CRUD, widgets CRUD, layout builder, presets. TanStack Router + Query, shadcn/ui, Vite proxy to :3000 - wire media + rss adapters into polling loop, remove xtb source type - media adapter: read username/password from headers, proper subsonic auth - event handler: subscribe to LayoutChanged, push screen update to clients - fix clippy warnings across workspace (Default impls, collapsible ifs, redundant closures, is_none_or, unused imports)
This commit is contained in:
@@ -6,7 +6,6 @@ pub type DataSourceId = u16;
|
||||
pub enum DataSourceType {
|
||||
Weather,
|
||||
Media,
|
||||
Xtb,
|
||||
Rss,
|
||||
HttpJson,
|
||||
Webhook,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
mod widget_config;
|
||||
mod data_source;
|
||||
mod layout_preset;
|
||||
mod widget_config;
|
||||
|
||||
pub use widget_config::{WidgetConfig, WidgetId};
|
||||
pub use data_source::{DataSource, DataSourceId, DataSourceType, DataSourceConfig, DataSourceValidationError};
|
||||
pub use data_source::{
|
||||
DataSource, DataSourceConfig, DataSourceId, DataSourceType, DataSourceValidationError,
|
||||
};
|
||||
pub use layout_preset::{LayoutPreset, LayoutPresetId};
|
||||
pub use widget_config::{WidgetConfig, WidgetId};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use crate::value_objects::{DisplayHint, KeyMapping, Value, WidgetState};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub type WidgetId = u16;
|
||||
pub type DataSourceId = u16;
|
||||
@@ -58,7 +58,8 @@ impl WidgetConfig {
|
||||
fn truncate_value(value: Value, max_bytes: usize) -> Value {
|
||||
match value {
|
||||
Value::String(s) if s.len() > max_bytes => {
|
||||
let truncated: String = s.char_indices()
|
||||
let truncated: String = s
|
||||
.char_indices()
|
||||
.take_while(|(i, _)| *i < max_bytes)
|
||||
.map(|(_, c)| c)
|
||||
.collect();
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#![allow(async_fn_in_trait)]
|
||||
|
||||
pub mod entities;
|
||||
pub mod value_objects;
|
||||
pub mod events;
|
||||
pub mod ports;
|
||||
pub mod value_objects;
|
||||
|
||||
pub use entities::{
|
||||
WidgetConfig, WidgetId,
|
||||
DataSource, DataSourceId, DataSourceType, DataSourceConfig, DataSourceValidationError,
|
||||
LayoutPreset, LayoutPresetId,
|
||||
};
|
||||
pub use value_objects::{
|
||||
Value, KeyMapping,
|
||||
WidgetState, WidgetError, DisplayHint,
|
||||
Layout, LayoutNode, LayoutChild, ContainerNode, Direction, Sizing, LayoutValidationError,
|
||||
DataSource, DataSourceConfig, DataSourceId, DataSourceType, DataSourceValidationError,
|
||||
LayoutPreset, LayoutPresetId, WidgetConfig, WidgetId,
|
||||
};
|
||||
pub use events::DomainEvent;
|
||||
pub use ports::{ConfigRepository, DataSourcePort, BroadcastPort, EventPublisher};
|
||||
pub use ports::{BroadcastPort, ConfigRepository, DataSourcePort, EventPublisher};
|
||||
pub use value_objects::{
|
||||
ContainerNode, Direction, DisplayHint, KeyMapping, Layout, LayoutChild, LayoutNode,
|
||||
LayoutValidationError, Sizing, Value, WidgetError, WidgetState,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::WidgetId;
|
||||
use crate::value_objects::{Layout, WidgetState};
|
||||
use std::future::Future;
|
||||
|
||||
pub trait BroadcastPort {
|
||||
type Error;
|
||||
|
||||
@@ -1,27 +1,53 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::{
|
||||
DataSource, DataSourceId, LayoutPreset, LayoutPresetId, WidgetConfig, WidgetId,
|
||||
};
|
||||
use crate::value_objects::Layout;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait ConfigRepository {
|
||||
type Error;
|
||||
|
||||
fn get_widget(&self, id: WidgetId) -> impl Future<Output = Result<Option<WidgetConfig>, Self::Error>> + Send;
|
||||
fn get_widget(
|
||||
&self,
|
||||
id: WidgetId,
|
||||
) -> impl Future<Output = Result<Option<WidgetConfig>, Self::Error>> + Send;
|
||||
fn list_widgets(&self) -> impl Future<Output = Result<Vec<WidgetConfig>, Self::Error>> + Send;
|
||||
fn save_widget(&self, config: &WidgetConfig) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn save_widget(
|
||||
&self,
|
||||
config: &WidgetConfig,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_widget(&self, id: WidgetId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_data_source(&self, id: DataSourceId) -> impl Future<Output = Result<Option<DataSource>, Self::Error>> + Send;
|
||||
fn list_data_sources(&self) -> impl Future<Output = Result<Vec<DataSource>, Self::Error>> + Send;
|
||||
fn save_data_source(&self, source: &DataSource) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_data_source(&self, id: DataSourceId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn get_data_source(
|
||||
&self,
|
||||
id: DataSourceId,
|
||||
) -> impl Future<Output = Result<Option<DataSource>, Self::Error>> + Send;
|
||||
fn list_data_sources(
|
||||
&self,
|
||||
) -> impl Future<Output = Result<Vec<DataSource>, Self::Error>> + Send;
|
||||
fn save_data_source(
|
||||
&self,
|
||||
source: &DataSource,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_data_source(
|
||||
&self,
|
||||
id: DataSourceId,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_layout(&self) -> impl Future<Output = Result<Option<Layout>, Self::Error>> + Send;
|
||||
fn save_layout(&self, layout: &Layout) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
|
||||
fn get_preset(&self, id: LayoutPresetId) -> impl Future<Output = Result<Option<LayoutPreset>, Self::Error>> + Send;
|
||||
fn get_preset(
|
||||
&self,
|
||||
id: LayoutPresetId,
|
||||
) -> impl Future<Output = Result<Option<LayoutPreset>, Self::Error>> + Send;
|
||||
fn list_presets(&self) -> impl Future<Output = Result<Vec<LayoutPreset>, Self::Error>> + Send;
|
||||
fn save_preset(&self, preset: &LayoutPreset) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_preset(&self, id: LayoutPresetId) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn save_preset(
|
||||
&self,
|
||||
preset: &LayoutPreset,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
fn delete_preset(
|
||||
&self,
|
||||
id: LayoutPresetId,
|
||||
) -> impl Future<Output = Result<(), Self::Error>> + Send;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::future::Future;
|
||||
use crate::entities::DataSource;
|
||||
use crate::value_objects::Value;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait DataSourcePort {
|
||||
type Error;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::future::Future;
|
||||
use crate::events::DomainEvent;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait EventPublisher {
|
||||
type Error;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
mod broadcast;
|
||||
mod config_repository;
|
||||
mod data_source_port;
|
||||
mod broadcast;
|
||||
mod event;
|
||||
|
||||
pub use broadcast::BroadcastPort;
|
||||
pub use config_repository::ConfigRepository;
|
||||
pub use data_source_port::DataSourcePort;
|
||||
pub use broadcast::BroadcastPort;
|
||||
pub use event::EventPublisher;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeSet;
|
||||
use crate::entities::WidgetId;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Sizing {
|
||||
@@ -81,7 +81,9 @@ impl Layout {
|
||||
|
||||
fn collect_ids(node: &LayoutNode, ids: &mut BTreeSet<WidgetId>) {
|
||||
match node {
|
||||
LayoutNode::Leaf(id) => { ids.insert(*id); }
|
||||
LayoutNode::Leaf(id) => {
|
||||
ids.insert(*id);
|
||||
}
|
||||
LayoutNode::Container(c) => {
|
||||
for child in &c.children {
|
||||
Self::collect_ids(&child.node, ids);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
mod value;
|
||||
mod key_mapping;
|
||||
mod widget_state;
|
||||
mod layout;
|
||||
mod value;
|
||||
mod widget_state;
|
||||
|
||||
pub use value::Value;
|
||||
pub use key_mapping::KeyMapping;
|
||||
pub use widget_state::{WidgetState, WidgetError, DisplayHint};
|
||||
pub use layout::{
|
||||
Layout, LayoutNode, LayoutChild, ContainerNode, Direction, Sizing, LayoutValidationError,
|
||||
ContainerNode, Direction, Layout, LayoutChild, LayoutNode, LayoutValidationError, Sizing,
|
||||
};
|
||||
pub use value::Value;
|
||||
pub use widget_state::{DisplayHint, WidgetError, WidgetState};
|
||||
|
||||
@@ -17,10 +17,7 @@ impl Value {
|
||||
Value::Number(_) => 8,
|
||||
Value::String(s) => s.len(),
|
||||
Value::Array(arr) => arr.iter().map(|v| v.estimated_size()).sum(),
|
||||
Value::Object(map) => map
|
||||
.iter()
|
||||
.map(|(k, v)| k.len() + v.estimated_size())
|
||||
.sum(),
|
||||
Value::Object(map) => map.iter().map(|(k, v)| k.len() + v.estimated_size()).sum(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use super::Value;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct WidgetState {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::time::Duration;
|
||||
use domain::{DataSource, DataSourceConfig, DataSourceType, DataSourceValidationError};
|
||||
use std::time::Duration;
|
||||
|
||||
fn make_source(source_type: DataSourceType, url: Option<&str>, poll: Duration) -> DataSource {
|
||||
DataSource {
|
||||
@@ -38,14 +38,22 @@ fn webhook_with_zero_interval_is_valid() {
|
||||
|
||||
#[test]
|
||||
fn poll_based_source_requires_nonzero_interval() {
|
||||
let source = make_source(DataSourceType::Weather, Some("https://api.weather.com"), Duration::ZERO);
|
||||
let source = make_source(
|
||||
DataSourceType::Weather,
|
||||
Some("https://api.weather.com"),
|
||||
Duration::ZERO,
|
||||
);
|
||||
let errors = source.validate();
|
||||
assert!(errors.contains(&DataSourceValidationError::PollIntervalRequired));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_poll_source_has_no_errors() {
|
||||
let source = make_source(DataSourceType::Rss, Some("https://feed.example.com"), Duration::from_secs(300));
|
||||
let source = make_source(
|
||||
DataSourceType::Rss,
|
||||
Some("https://feed.example.com"),
|
||||
Duration::from_secs(300),
|
||||
);
|
||||
let errors = source.validate();
|
||||
assert!(errors.is_empty());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use domain::{KeyMapping, Value};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[test]
|
||||
fn extracts_value_at_path_and_renames_key() {
|
||||
@@ -8,11 +8,10 @@ fn extracts_value_at_path_and_renames_key() {
|
||||
target_key: "temperature".into(),
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("main".into(), Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]))),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([(
|
||||
"main".into(),
|
||||
Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))])),
|
||||
)]));
|
||||
|
||||
let result = mapping.extract(&raw);
|
||||
assert_eq!(result, Some(("temperature".into(), Value::Number(5.4))));
|
||||
@@ -25,9 +24,7 @@ fn returns_none_when_path_does_not_match() {
|
||||
target_key: "value".into(),
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("other".into(), Value::Number(1.0)),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([("other".into(), Value::Number(1.0))]));
|
||||
|
||||
assert_eq!(mapping.extract(&raw), None);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::collections::BTreeSet;
|
||||
use domain::{
|
||||
ContainerNode, Direction, Layout, LayoutChild, LayoutNode, LayoutValidationError, Sizing,
|
||||
WidgetId,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
fn leaf(id: WidgetId) -> LayoutChild {
|
||||
LayoutChild {
|
||||
@@ -22,14 +22,18 @@ fn row(children: Vec<LayoutChild>) -> LayoutNode {
|
||||
|
||||
#[test]
|
||||
fn validate_returns_empty_when_all_widgets_exist() {
|
||||
let layout = Layout { root: row(vec![leaf(1), leaf(2)]) };
|
||||
let layout = Layout {
|
||||
root: row(vec![leaf(1), leaf(2)]),
|
||||
};
|
||||
let known = BTreeSet::from([1, 2]);
|
||||
assert!(layout.validate(&known).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_reports_unknown_widget_ids() {
|
||||
let layout = Layout { root: row(vec![leaf(1), leaf(99)]) };
|
||||
let layout = Layout {
|
||||
root: row(vec![leaf(1), leaf(99)]),
|
||||
};
|
||||
let known = BTreeSet::from([1]);
|
||||
let errors = layout.validate(&known);
|
||||
assert_eq!(errors, vec![LayoutValidationError::UnknownWidget(99)]);
|
||||
@@ -49,7 +53,9 @@ fn validate_checks_nested_containers() {
|
||||
sizing: Sizing::Flex(1),
|
||||
node: row(vec![leaf(1), leaf(42)]),
|
||||
};
|
||||
let layout = Layout { root: row(vec![inner, leaf(2)]) };
|
||||
let layout = Layout {
|
||||
root: row(vec![inner, leaf(2)]),
|
||||
};
|
||||
let known = BTreeSet::from([1, 2]);
|
||||
let errors = layout.validate(&known);
|
||||
assert_eq!(errors, vec![LayoutValidationError::UnknownWidget(42)]);
|
||||
@@ -61,6 +67,8 @@ fn widget_ids_collects_all_leaf_ids() {
|
||||
sizing: Sizing::Flex(1),
|
||||
node: row(vec![leaf(3)]),
|
||||
};
|
||||
let layout = Layout { root: row(vec![leaf(1), inner, leaf(2)]) };
|
||||
let layout = Layout {
|
||||
root: row(vec![leaf(1), inner, leaf(2)]),
|
||||
};
|
||||
assert_eq!(layout.widget_ids(), BTreeSet::from([1, 2, 3]));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use domain::Value;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[test]
|
||||
fn estimated_size_of_string_is_its_byte_length() {
|
||||
@@ -29,37 +29,31 @@ fn estimated_size_of_nested_structure_sums_recursively() {
|
||||
|
||||
#[test]
|
||||
fn estimated_size_of_array_sums_elements() {
|
||||
let v = Value::Array(vec![
|
||||
Value::String("abc".into()),
|
||||
Value::Number(1.0),
|
||||
]);
|
||||
let v = Value::Array(vec![Value::String("abc".into()), Value::Number(1.0)]);
|
||||
assert_eq!(v.estimated_size(), 11);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_path_returns_none_for_missing_key() {
|
||||
let data = Value::Object(BTreeMap::from([
|
||||
("main".into(), Value::Number(1.0)),
|
||||
]));
|
||||
let data = Value::Object(BTreeMap::from([("main".into(), Value::Number(1.0))]));
|
||||
assert_eq!(data.get_path("$.missing"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_path_returns_none_when_traversing_non_object() {
|
||||
let data = Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]));
|
||||
let data = Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))]));
|
||||
assert_eq!(data.get_path("$.temp.nested"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_path_accesses_array_by_index() {
|
||||
let data = Value::Object(BTreeMap::from([
|
||||
("items".into(), Value::Array(vec![
|
||||
let data = Value::Object(BTreeMap::from([(
|
||||
"items".into(),
|
||||
Value::Array(vec![
|
||||
Value::String("first".into()),
|
||||
Value::String("second".into()),
|
||||
])),
|
||||
]));
|
||||
]),
|
||||
)]));
|
||||
assert_eq!(
|
||||
data.get_path("$.items[1]"),
|
||||
Some(&Value::String("second".into()))
|
||||
@@ -68,10 +62,9 @@ fn get_path_accesses_array_by_index() {
|
||||
|
||||
#[test]
|
||||
fn get_path_traverses_nested_object() {
|
||||
let data = Value::Object(BTreeMap::from([
|
||||
("main".into(), Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]))),
|
||||
]));
|
||||
let data = Value::Object(BTreeMap::from([(
|
||||
"main".into(),
|
||||
Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))])),
|
||||
)]));
|
||||
assert_eq!(data.get_path("$.main.temp"), Some(&Value::Number(5.4)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use domain::{DisplayHint, KeyMapping, Value, WidgetConfig};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[test]
|
||||
fn extract_applies_all_mappings_to_produce_widget_state() {
|
||||
@@ -9,27 +9,39 @@ fn extract_applies_all_mappings_to_produce_widget_state() {
|
||||
display_hint: DisplayHint::IconValue,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.main.temp".into(), target_key: "temperature".into() },
|
||||
KeyMapping { source_path: "$.weather[0].icon".into(), target_key: "icon".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.main.temp".into(),
|
||||
target_key: "temperature".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.weather[0].icon".into(),
|
||||
target_key: "icon".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 2048,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("main".into(), Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]))),
|
||||
("weather".into(), Value::Array(vec![
|
||||
Value::Object(BTreeMap::from([
|
||||
("icon".into(), Value::String("cloud_rain".into())),
|
||||
])),
|
||||
])),
|
||||
(
|
||||
"main".into(),
|
||||
Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))])),
|
||||
),
|
||||
(
|
||||
"weather".into(),
|
||||
Value::Array(vec![Value::Object(BTreeMap::from([(
|
||||
"icon".into(),
|
||||
Value::String("cloud_rain".into()),
|
||||
)]))]),
|
||||
),
|
||||
]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
|
||||
assert_eq!(state.data.get("temperature"), Some(&Value::Number(5.4)));
|
||||
assert_eq!(state.data.get("icon"), Some(&Value::String("cloud_rain".into())));
|
||||
assert_eq!(
|
||||
state.data.get("icon"),
|
||||
Some(&Value::String("cloud_rain".into()))
|
||||
);
|
||||
assert_eq!(state.error, None);
|
||||
}
|
||||
|
||||
@@ -41,15 +53,14 @@ fn extract_truncates_string_values_exceeding_max_data_size() {
|
||||
name: "news".into(),
|
||||
display_hint: DisplayHint::TextBlock,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.text".into(), target_key: "body".into() },
|
||||
],
|
||||
mappings: vec![KeyMapping {
|
||||
source_path: "$.text".into(),
|
||||
target_key: "body".into(),
|
||||
}],
|
||||
max_data_size: 100,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("text".into(), Value::String(long_text)),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([("text".into(), Value::String(long_text))]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
match state.data.get("body") {
|
||||
@@ -66,9 +77,18 @@ fn extract_respects_max_data_size_across_total_state() {
|
||||
display_hint: DisplayHint::TextBlock,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.a".into(), target_key: "a".into() },
|
||||
KeyMapping { source_path: "$.b".into(), target_key: "b".into() },
|
||||
KeyMapping { source_path: "$.c".into(), target_key: "c".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.a".into(),
|
||||
target_key: "a".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.b".into(),
|
||||
target_key: "b".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.c".into(),
|
||||
target_key: "c".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 50,
|
||||
};
|
||||
@@ -92,15 +112,19 @@ fn extract_skips_mappings_that_dont_match() {
|
||||
display_hint: DisplayHint::IconValue,
|
||||
data_source_id: 1,
|
||||
mappings: vec![
|
||||
KeyMapping { source_path: "$.temp".into(), target_key: "temperature".into() },
|
||||
KeyMapping { source_path: "$.missing".into(), target_key: "gone".into() },
|
||||
KeyMapping {
|
||||
source_path: "$.temp".into(),
|
||||
target_key: "temperature".into(),
|
||||
},
|
||||
KeyMapping {
|
||||
source_path: "$.missing".into(),
|
||||
target_key: "gone".into(),
|
||||
},
|
||||
],
|
||||
max_data_size: 2048,
|
||||
};
|
||||
|
||||
let raw = Value::Object(BTreeMap::from([
|
||||
("temp".into(), Value::Number(5.4)),
|
||||
]));
|
||||
let raw = Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))]));
|
||||
|
||||
let state = config.extract(&raw);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user