From 815e7d6a543fbcac80985b7fed15fd1719f19430 Mon Sep 17 00:00:00 2001 From: John Obelenus Date: Wed, 18 Dec 2024 15:52:41 -0500 Subject: [PATCH] BUG-700: adding WsEvent::FuncUpdated to component created endpoints We were correctly calling these events in `install_module.rs`, just didn't have them here --- lib/dal/src/diagram.rs | 3 +++ lib/sdf-server/src/service/diagram.rs | 6 ++++-- lib/sdf-server/src/service/diagram/create_component.rs | 10 +++++++++- lib/sdf-server/src/service/v2/view.rs | 6 ++++-- lib/sdf-server/src/service/v2/view/create_component.rs | 9 +++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/dal/src/diagram.rs b/lib/dal/src/diagram.rs index f469a0cf87..e4fbf6341e 100644 --- a/lib/dal/src/diagram.rs +++ b/lib/dal/src/diagram.rs @@ -13,6 +13,7 @@ use std::{ use telemetry::prelude::*; use thiserror::Error; +use crate::FuncError; use crate::{ attribute::{ prototype::argument::{AttributePrototypeArgumentError, AttributePrototypeArgumentId}, @@ -76,6 +77,8 @@ pub enum DiagramError { DiagramObjectNotFoundForView(ViewId), #[error("edge not found")] EdgeNotFound, + #[error("func error: {0}")] + Func(#[from] FuncError), #[error("geometry can't represent: {0}")] GeometryCannotRepresentNodeWeight(NodeWeightDiscriminants), #[error("geometry not found: {0}")] diff --git a/lib/sdf-server/src/service/diagram.rs b/lib/sdf-server/src/service/diagram.rs index 81980a4f07..45a5b9a945 100644 --- a/lib/sdf-server/src/service/diagram.rs +++ b/lib/sdf-server/src/service/diagram.rs @@ -15,8 +15,8 @@ use dal::{ slow_rt::SlowRuntimeError, socket::{input::InputSocketError, output::OutputSocketError}, workspace_snapshot::WorkspaceSnapshotError, - ChangeSetError, SchemaError, SchemaId, SchemaVariantId, StandardModelError, TransactionsError, - WsEventError, + ChangeSetError, FuncError, SchemaError, SchemaId, SchemaVariantId, StandardModelError, + TransactionsError, WsEventError, }; use std::num::{ParseFloatError, ParseIntError}; use telemetry::prelude::*; @@ -75,6 +75,8 @@ pub enum DiagramError { EdgeNotFound, #[error("frame socket not found for schema variant id: {0}")] FrameSocketNotFound(SchemaVariantId), + #[error("func error: {0}")] + Func(#[from] FuncError), #[error("invalid header name {0}")] Hyper(#[from] hyper::http::Error), #[error("InferredConnectionGraph error: {0}")] diff --git a/lib/sdf-server/src/service/diagram/create_component.rs b/lib/sdf-server/src/service/diagram/create_component.rs index b1e1c4c2ca..d1f0d8255d 100644 --- a/lib/sdf-server/src/service/diagram/create_component.rs +++ b/lib/sdf-server/src/service/diagram/create_component.rs @@ -6,11 +6,11 @@ use axum::{ }; use serde::{Deserialize, Serialize}; -use dal::diagram::view::View; use dal::{ change_status::ChangeStatus, component::frame::Frame, generate_name, ChangeSet, Component, ComponentId, Schema, SchemaId, SchemaVariant, SchemaVariantId, Visibility, WsEvent, }; +use dal::{diagram::view::View, Func}; use si_events::audit_log::AuditLogKind; use si_frontend_types::SchemaVariant as FrontendVariant; @@ -94,6 +94,14 @@ pub async fn create_component( .await? .publish_on_commit(&ctx) .await?; + for func_id in front_end_variant.func_ids.iter() { + let func = Func::get_by_id_or_error(&ctx, *func_id).await?; + let front_end_func = func.into_frontend_type(&ctx).await?; + WsEvent::func_updated(&ctx, front_end_func, None) + .await? + .publish_on_commit(&ctx) + .await?; + } (variant_id, Some(front_end_variant)) } diff --git a/lib/sdf-server/src/service/v2/view.rs b/lib/sdf-server/src/service/v2/view.rs index 737def92e1..3936fa04b1 100644 --- a/lib/sdf-server/src/service/v2/view.rs +++ b/lib/sdf-server/src/service/v2/view.rs @@ -13,8 +13,8 @@ use dal::{ pkg::PkgError, slow_rt::SlowRuntimeError, workspace_snapshot::graph::WorkspaceSnapshotGraphError, - ChangeSetError, ComponentError, SchemaError, SchemaId, SchemaVariantError, TransactionsError, - WorkspaceSnapshotError, WsEventError, + ChangeSetError, ComponentError, FuncError, SchemaError, SchemaId, SchemaVariantError, + TransactionsError, WorkspaceSnapshotError, WsEventError, }; use thiserror::Error; use tokio::task::JoinError; @@ -46,6 +46,8 @@ pub enum ViewError { DalDiagram(#[from] dal::diagram::DiagramError), #[error("frame error: {0}")] Frame(#[from] FrameError), + #[error("func error: {0}")] + Func(#[from] FuncError), #[error("inferred connection graph error: {0}")] InferredConnectionGraph(#[from] InferredConnectionGraphError), #[error("invalid request: {0}")] diff --git a/lib/sdf-server/src/service/v2/view/create_component.rs b/lib/sdf-server/src/service/v2/view/create_component.rs index 77a96f8e13..dfd3d1c08b 100644 --- a/lib/sdf-server/src/service/v2/view/create_component.rs +++ b/lib/sdf-server/src/service/v2/view/create_component.rs @@ -6,6 +6,7 @@ use axum::{ Json, }; use dal::diagram::geometry::Geometry; +use dal::Func; use serde::{Deserialize, Serialize}; use dal::diagram::view::ViewId; @@ -120,6 +121,14 @@ pub async fn create_component( .await? .publish_on_commit(&ctx) .await?; + for func_id in front_end_variant.func_ids.iter() { + let func = Func::get_by_id_or_error(&ctx, *func_id).await?; + let front_end_func = func.into_frontend_type(&ctx).await?; + WsEvent::func_updated(&ctx, front_end_func, None) + .await? + .publish_on_commit(&ctx) + .await?; + } ( variant_id,