Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 4dbbce9

Browse files
committed
feat(daf, dal): Readd the JSON representation of component materialized view
1 parent 6922a39 commit 4dbbce9

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

lib/dal/src/component/diff.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,19 @@ impl Component {
9898
diffs,
9999
})
100100
}
101+
102+
pub async fn get_json_representation(
103+
ctx: &DalContext,
104+
component_id: ComponentId,
105+
) -> ComponentResult<ComponentProperties> {
106+
let component = Self::get_by_id(ctx, component_id).await?;
107+
let materialized_view = component.materialized_view(ctx).await?;
108+
109+
if let Some(view) = materialized_view {
110+
let properties = ComponentProperties::try_from(view)?;
111+
return Ok(properties);
112+
}
113+
114+
Ok(ComponentProperties::default())
115+
}
101116
}

lib/sdf-server/src/server/service/component.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@ use thiserror::Error;
1414

1515
use crate::server::state::AppState;
1616

17+
pub mod delete_property_editor_value;
18+
pub mod get_diff;
1719
pub mod get_property_editor_schema;
1820
pub mod get_property_editor_validations;
1921
pub mod get_property_editor_values;
2022
pub mod update_property_editor_value;
21-
22-
// pub mod debug;
23-
pub mod delete_property_editor_value;
24-
pub mod get_diff;
2523
// pub mod get_resource;
26-
pub mod insert_property_editor_value;
27-
// pub mod json;
2824
pub mod get_actions;
25+
pub mod insert_property_editor_value;
26+
pub mod json;
2927
pub mod list_qualifications;
3028
// pub mod list_resources;
3129
// pub mod refresh;
@@ -176,5 +174,5 @@ pub fn routes() -> Router<AppState> {
176174
// .route("/refresh", post(refresh::refresh))
177175
// .route("/resource_domain_diff", get(resource_domain_diff::get_diff))
178176
.route("/debug", get(debug::debug_component))
179-
// .route("/json", get(json::json))
177+
.route("/json", get(json::json))
180178
}

lib/sdf-server/src/server/service/component/json.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use axum::{extract::Query, Json};
2-
use dal::{ComponentId, ComponentView, ComponentViewProperties, Visibility};
2+
use dal::component::properties::ComponentProperties;
3+
use dal::{Component, ComponentId, Visibility};
34
use serde::{Deserialize, Serialize};
45

56
use super::ComponentResult;
@@ -16,7 +17,7 @@ pub struct JsonRequest {
1617
#[derive(Deserialize, Serialize, Debug)]
1718
#[serde(rename_all = "camelCase")]
1819
pub struct JsonResponse {
19-
pub json: ComponentViewProperties,
20+
pub json: ComponentProperties,
2021
}
2122

2223
pub async fn json(
@@ -26,14 +27,7 @@ pub async fn json(
2627
) -> ComponentResult<Json<JsonResponse>> {
2728
let ctx = builder.build(request_ctx.build(request.visibility)).await?;
2829

29-
let curr_component_view = ComponentView::new(&ctx, request.component_id).await?;
30-
if curr_component_view.properties.is_null() {
31-
return Ok(Json(JsonResponse {
32-
json: ComponentViewProperties::default(),
33-
}));
34-
}
35-
36-
let json = ComponentViewProperties::try_from(curr_component_view)?;
30+
let json = Component::get_json_representation(&ctx, request.component_id).await?;
3731

3832
Ok(Json(JsonResponse { json }))
3933
}

0 commit comments

Comments
 (0)