From cf01a331b87319d4be811a4cca53c587350e7e5f Mon Sep 17 00:00:00 2001 From: Brit Myers Date: Thu, 5 Dec 2024 16:59:14 -0500 Subject: [PATCH] Instrument more audit log events --- lib/dal/src/func/argument.rs | 15 + lib/dal/src/func/authoring.rs | 6 +- lib/dal/src/func/binding.rs | 25 +- .../src/service/diagram/create_connection.rs | 27 +- .../src/service/diagram/delete_connection.rs | 23 + lib/sdf-server/src/service/v2/func.rs | 4 +- .../v2/func/argument/create_argument.rs | 16 +- .../v2/func/argument/delete_argument.rs | 18 +- .../attribute/reset_attribute_binding.rs | 46 +- .../service/v2/func/binding/create_binding.rs | 131 +++- .../service/v2/func/binding/delete_binding.rs | 40 +- .../src/service/v2/func/create_func.rs | 199 ++++- .../service/v2/func/create_unlocked_copy.rs | 22 +- .../src/service/v2/func/delete_func.rs | 11 +- .../src/service/v2/func/execute_func.rs | 11 +- .../src/service/v2/func/test_execute.rs | 12 +- .../src/service/v2/func/update_func.rs | 17 +- .../src/service/v2/module/contribute.rs | 15 +- .../v2/variant/create_unlocked_copy.rs | 10 +- .../v2/variant/delete_unlocked_variant.rs | 9 + .../src/service/v2/view/create_view.rs | 12 +- .../src/service/v2/view/remove_view.rs | 7 + .../service/v2/view/set_component_parent.rs | 36 + .../src/service/v2/view/update_view.rs | 10 +- .../src/service/variant/create_variant.rs | 10 + .../src/service/variant/regenerate_variant.rs | 7 +- lib/si-events-rs/src/audit_log/v1.rs | 704 +++++++++++++++++- lib/si-events-rs/src/func_run.rs | 13 + lib/si-events-rs/src/lib.rs | 2 +- 29 files changed, 1372 insertions(+), 86 deletions(-) diff --git a/lib/dal/src/func/argument.rs b/lib/dal/src/func/argument.rs index f9e787bc53..b1b19d41f8 100644 --- a/lib/dal/src/func/argument.rs +++ b/lib/dal/src/func/argument.rs @@ -90,6 +90,21 @@ pub enum FuncArgumentKind { String, } +impl From for si_events::FuncArgumentKind { + fn from(func_argument_kind: FuncArgumentKind) -> Self { + match func_argument_kind { + FuncArgumentKind::Any => si_events::FuncArgumentKind::Any, + FuncArgumentKind::Array => si_events::FuncArgumentKind::Array, + FuncArgumentKind::Boolean => si_events::FuncArgumentKind::Boolean, + FuncArgumentKind::Integer => si_events::FuncArgumentKind::Integer, + FuncArgumentKind::Json => si_events::FuncArgumentKind::Json, + FuncArgumentKind::Map => si_events::FuncArgumentKind::Map, + FuncArgumentKind::Object => si_events::FuncArgumentKind::Object, + FuncArgumentKind::String => si_events::FuncArgumentKind::String, + } + } +} + impl From for FuncArgumentKind { fn from(prop_kind: PropKind) -> Self { match prop_kind { diff --git a/lib/dal/src/func/authoring.rs b/lib/dal/src/func/authoring.rs index 8e2a0fa7ad..882f5bac1c 100644 --- a/lib/dal/src/func/authoring.rs +++ b/lib/dal/src/func/authoring.rs @@ -344,7 +344,7 @@ impl FuncAuthoringClient { name: impl Into, kind: FuncArgumentKind, element_kind: Option, - ) -> FuncAuthoringResult<()> { + ) -> FuncAuthoringResult { let func = Func::get_by_id_or_error(ctx, id).await?; // don't create a func argument if the function is locked func.error_if_locked()?; @@ -354,9 +354,9 @@ impl FuncAuthoringClient { )); } - let _func_argument = FuncArgument::new(ctx, name, kind, element_kind, id).await?; + let func_argument = FuncArgument::new(ctx, name, kind, element_kind, id).await?; - Ok(()) + Ok(func_argument) } /// Deletes a [`FuncArgument`]. diff --git a/lib/dal/src/func/binding.rs b/lib/dal/src/func/binding.rs index 16f6fd370b..7b9ceb5039 100644 --- a/lib/dal/src/func/binding.rs +++ b/lib/dal/src/func/binding.rs @@ -31,8 +31,8 @@ use crate::{ FuncError, FuncId, PropId, SchemaVariantError, SchemaVariantId, }; use crate::{ - ComponentId, InputSocketId, OutputSocketId, SchemaError, SchemaId, SchemaVariant, - WorkspaceSnapshotError, WsEventError, + ComponentId, InputSocket, InputSocketId, OutputSocket, OutputSocketId, Prop, SchemaError, + SchemaId, SchemaVariant, WorkspaceSnapshotError, WsEventError, }; pub use attribute_argument::AttributeArgumentBinding; @@ -127,7 +127,7 @@ pub enum AttributeFuncDestination { } impl AttributeFuncDestination { - pub(crate) async fn find_schema_variant( + pub async fn find_schema_variant( &self, ctx: &DalContext, ) -> FuncBindingResult { @@ -144,6 +144,25 @@ impl AttributeFuncDestination { }; Ok(schema_variant_id) } + + pub async fn get_name_of_destination(&self, ctx: &DalContext) -> FuncBindingResult { + let name = match self { + AttributeFuncDestination::Prop(prop_id) => Prop::get_by_id(ctx, *prop_id).await?.name, + AttributeFuncDestination::OutputSocket(output_socket_id) => { + OutputSocket::get_by_id(ctx, *output_socket_id) + .await? + .name() + .to_string() + } + AttributeFuncDestination::InputSocket(input_socket_id) => { + InputSocket::get_by_id(ctx, *input_socket_id) + .await? + .name() + .to_string() + } + }; + Ok(name) + } } /// Represents at what level a given Prototype is attached to diff --git a/lib/sdf-server/src/service/diagram/create_connection.rs b/lib/sdf-server/src/service/diagram/create_connection.rs index 1efe6605f0..77a1d5e596 100644 --- a/lib/sdf-server/src/service/diagram/create_connection.rs +++ b/lib/sdf-server/src/service/diagram/create_connection.rs @@ -8,12 +8,13 @@ use axum::{ extract::{Host, OriginalUri}, Json, }; -use dal::diagram::SummaryDiagramInferredEdge; use dal::{ change_status::ChangeStatus, diagram::SummaryDiagramEdge, ChangeSet, Component, ComponentId, - InputSocketId, OutputSocketId, Visibility, WsEvent, + InputSocket, InputSocketId, OutputSocketId, Visibility, WsEvent, }; +use dal::{diagram::SummaryDiagramInferredEdge, OutputSocket}; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -112,6 +113,28 @@ pub async fn create_connection( .await?; } } + let to_component_name = to_component.name(&ctx).await?; + let to_socket_name = InputSocket::get_by_id(&ctx, request.to_socket_id) + .await? + .name() + .to_string(); + ctx.write_audit_log( + AuditLogKind::CreateConnection { + from_component_id: request.from_component_id, + from_component_name: from_component.name(&ctx).await?, + from_socket_id: request.from_socket_id, + from_socket_name: OutputSocket::get_by_id(&ctx, request.from_socket_id) + .await? + .name() + .to_string(), + to_component_id: request.to_component_id, + to_component_name: to_component_name.clone(), + to_socket_id: request.to_socket_id, + to_socket_name: to_socket_name.clone(), + }, + format!("{to_component_name} --- {to_socket_name}"), + ) + .await?; ctx.commit().await?; diff --git a/lib/sdf-server/src/service/diagram/delete_connection.rs b/lib/sdf-server/src/service/diagram/delete_connection.rs index 58676c96b0..3cac93b4b8 100644 --- a/lib/sdf-server/src/service/diagram/delete_connection.rs +++ b/lib/sdf-server/src/service/diagram/delete_connection.rs @@ -14,6 +14,7 @@ use dal::{ InputSocket, InputSocketId, OutputSocket, OutputSocketId, Visibility, WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -134,6 +135,28 @@ pub async fn delete_connection( let to_component_schema = Component::schema_for_component_id(&ctx, request.to_component_id).await?; + let to_component_name = to_component.name(&ctx).await?; + let to_socket_name = InputSocket::get_by_id(&ctx, request.to_socket_id) + .await? + .name() + .to_string(); + ctx.write_audit_log( + AuditLogKind::DeleteConnection { + from_component_id: request.from_component_id, + from_component_name: from_component.name(&ctx).await?, + from_socket_id: request.from_socket_id, + from_socket_name: OutputSocket::get_by_id(&ctx, request.from_socket_id) + .await? + .name() + .to_string(), + to_component_id: request.to_component_id, + to_component_name: to_component_name.clone(), + to_socket_id: request.to_socket_id, + to_socket_name: to_socket_name.clone(), + }, + format!("{0}-{1}", to_component_name, to_socket_name), + ) + .await?; track( &posthog_client, &ctx, diff --git a/lib/sdf-server/src/service/v2/func.rs b/lib/sdf-server/src/service/v2/func.rs index 4cadf59835..f7925958d3 100644 --- a/lib/sdf-server/src/service/v2/func.rs +++ b/lib/sdf-server/src/service/v2/func.rs @@ -12,7 +12,7 @@ use dal::{ runner::FuncRunnerError, }, workspace_snapshot::graph::WorkspaceSnapshotGraphError, - ChangeSetError, DalContext, Func, FuncError, FuncId, SchemaVariantError, + ChangeSetError, ComponentError, DalContext, Func, FuncError, FuncId, SchemaVariantError, WorkspaceSnapshotError, WsEventError, }; use si_frontend_types::FuncCode; @@ -51,6 +51,8 @@ pub enum FuncAPIError { CannotDeleteLockedFunc(FuncId), #[error("change set error: {0}")] ChangeSet(#[from] ChangeSetError), + #[error("component error: {0}")] + Component(#[from] ComponentError), #[error("func error: {0}")] Func(#[from] FuncError), #[error("func already unlocked: {0}")] diff --git a/lib/sdf-server/src/service/v2/func/argument/create_argument.rs b/lib/sdf-server/src/service/v2/func/argument/create_argument.rs index 12ef5fafd9..f1d3374479 100644 --- a/lib/sdf-server/src/service/v2/func/argument/create_argument.rs +++ b/lib/sdf-server/src/service/v2/func/argument/create_argument.rs @@ -7,6 +7,7 @@ use dal::{ WsEvent, }; use frontend_types::FuncSummary; +use si_events::audit_log::AuditLogKind; use si_frontend_types as frontend_types; use crate::{ @@ -29,10 +30,10 @@ pub async fn create_func_argument( .await?; let force_change_set_id = ChangeSet::force_new(&mut ctx).await?; - FuncAuthoringClient::create_func_argument( + let new_arg = FuncAuthoringClient::create_func_argument( &ctx, func_id, - request.name, + request.name.clone(), request.kind.into(), request.element_kind.map(Into::into), ) @@ -42,6 +43,17 @@ pub async fn create_func_argument( .await? .into_frontend_type(&ctx) .await?; + ctx.write_audit_log( + AuditLogKind::CreateFuncArgument { + func_id: func_summary.func_id, + func_display_name: func_summary.display_name.clone(), + func_name: func_summary.name.clone(), + kind: new_arg.kind.into(), + element_kind: new_arg.element_kind.map(|a| a.into()), + }, + request.name, + ) + .await?; WsEvent::func_updated(&ctx, func_summary.clone(), None) .await? .publish_on_commit(&ctx) diff --git a/lib/sdf-server/src/service/v2/func/argument/delete_argument.rs b/lib/sdf-server/src/service/v2/func/argument/delete_argument.rs index 00f21c5a1d..ea855a87de 100644 --- a/lib/sdf-server/src/service/v2/func/argument/delete_argument.rs +++ b/lib/sdf-server/src/service/v2/func/argument/delete_argument.rs @@ -1,8 +1,12 @@ use axum::extract::{Host, OriginalUri, Path}; use dal::{ - func::{argument::FuncArgumentId, authoring::FuncAuthoringClient}, + func::{ + argument::{FuncArgument, FuncArgumentId}, + authoring::FuncAuthoringClient, + }, ChangeSet, ChangeSetId, Func, FuncId, WorkspacePk, WsEvent, }; +use si_events::audit_log::AuditLogKind; use si_frontend_types::FuncSummary; use crate::{ @@ -28,6 +32,7 @@ pub async fn delete_func_argument( .build(access_builder.build(change_set_id.into())) .await?; let force_change_set_id = ChangeSet::force_new(&mut ctx).await?; + let func_arg = FuncArgument::get_by_id_or_error(&ctx, func_argument_id).await?; FuncAuthoringClient::delete_func_argument(&ctx, func_argument_id).await?; let func_summary = Func::get_by_id_or_error(&ctx, func_id) @@ -52,7 +57,16 @@ pub async fn delete_func_argument( "func_kind": func_summary.kind.clone(), }), ); - + ctx.write_audit_log( + AuditLogKind::DeleteFuncArgument { + func_id, + func_display_name: func_summary.display_name.clone(), + func_name: func_summary.name.clone(), + func_argument_id, + }, + func_arg.name, + ) + .await?; ctx.commit().await?; Ok(ForceChangeSetResponse::new( diff --git a/lib/sdf-server/src/service/v2/func/binding/attribute/reset_attribute_binding.rs b/lib/sdf-server/src/service/v2/func/binding/attribute/reset_attribute_binding.rs index b7be88a630..824ccbd2eb 100644 --- a/lib/sdf-server/src/service/v2/func/binding/attribute/reset_attribute_binding.rs +++ b/lib/sdf-server/src/service/v2/func/binding/attribute/reset_attribute_binding.rs @@ -4,8 +4,9 @@ use axum::{ }; use dal::{ func::binding::{attribute::AttributeBinding, EventualParent}, - ChangeSet, ChangeSetId, Func, FuncId, SchemaVariant, WorkspacePk, WsEvent, + ChangeSet, ChangeSetId, Component, Func, FuncId, SchemaVariant, WorkspacePk, WsEvent, }; +use si_events::audit_log::AuditLogKind; use si_frontend_types as frontend_types; use crate::{ @@ -51,15 +52,42 @@ pub async fn reset_attribute_binding( ) .await?; - if let EventualParent::SchemaVariant(schema_variant_id) = eventual_parent { - let schema = - SchemaVariant::schema_id_for_schema_variant_id(&ctx, schema_variant_id).await?; - let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - - WsEvent::schema_variant_updated(&ctx, schema, schema_variant) - .await? - .publish_on_commit(&ctx) + match eventual_parent { + EventualParent::SchemaVariant(schema_variant_id) => { + let schema = + SchemaVariant::schema_id_for_schema_variant_id(&ctx, schema_variant_id).await?; + let schema_variant = + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; + ctx.write_audit_log( + AuditLogKind::DetachFunc { + func_id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant.display_name().to_owned(), + }, + func.name.clone(), + ) + .await?; + WsEvent::schema_variant_updated(&ctx, schema, schema_variant) + .await? + .publish_on_commit(&ctx) + .await?; + } + EventualParent::Component(component_id) => { + let component = Component::get_by_id(&ctx, component_id).await?; + ctx.write_audit_log( + AuditLogKind::DetachFunc { + func_id, + func_display_name: func.display_name.clone(), + schema_variant_id: None, + component_id: Some(component_id), + subject_name: component.name(&ctx).await?.to_owned(), + }, + func.name.clone(), + ) .await?; + } } } diff --git a/lib/sdf-server/src/service/v2/func/binding/create_binding.rs b/lib/sdf-server/src/service/v2/func/binding/create_binding.rs index 9bb39708fc..71d733f1ae 100644 --- a/lib/sdf-server/src/service/v2/func/binding/create_binding.rs +++ b/lib/sdf-server/src/service/v2/func/binding/create_binding.rs @@ -8,8 +8,9 @@ use dal::{ leaf::LeafBinding, management::ManagementBinding, AttributeArgumentBinding, EventualParent, }, schema::variant::leaves::{LeafInputLocation, LeafKind}, - ChangeSet, ChangeSetId, Func, FuncId, SchemaVariant, WorkspacePk, WsEvent, + ChangeSet, ChangeSetId, Component, Func, FuncId, SchemaVariant, WorkspacePk, WsEvent, }; +use si_events::audit_log::AuditLogKind; use si_frontend_types as frontend_types; use crate::{ @@ -91,23 +92,56 @@ pub async fn create_binding( arguments, ) .await?; - if let Some(EventualParent::SchemaVariant(schema_variant_id)) = - eventual_parent - { - let schema = SchemaVariant::schema_id_for_schema_variant_id( - &ctx, - schema_variant_id, - ) + let (subject_name, component_id, schema_variant_id): ( + String, + Option, + Option, + ) = match eventual_parent { + Some(eventual_parent) => { + if let EventualParent::Component(component_id) = eventual_parent + { + ( + Component::get_by_id(&ctx, component_id) + .await? + .name(&ctx) + .await?, + Some(component_id), + None, + ) + } else { + return Err(FuncAPIError::MissingSchemaVariantAndFunc); + } + } + None => { + let schema_variant_id = + attribute_output_location.find_schema_variant(&ctx).await?; + ( + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) + .await? + .display_name() + .to_string(), + None, + Some(schema_variant_id), + ) + } + }; + let destination_name = attribute_output_location + .get_name_of_destination(&ctx) .await?; - let schema_variant = - SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) - .await?; - - WsEvent::schema_variant_updated(&ctx, schema, schema_variant) - .await? - .publish_on_commit(&ctx) - .await?; - } + ctx.write_audit_log( + AuditLogKind::AttachAttributeFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id, + component_id, + subject_name, + prop_id, + output_socket_id, + destination_name, + }, + func.name.clone(), + ) + .await?; } None => { return Err(FuncAPIError::MissingFuncId); @@ -134,7 +168,16 @@ pub async fn create_binding( .await?; let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - + let func = Func::get_by_id_or_error(&ctx, func_id).await?; + ctx.write_audit_log( + AuditLogKind::AttachAuthFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + }, + func.name.clone(), + ) + .await?; WsEvent::schema_variant_updated(&ctx, schema, schema_variant) .await? .publish_on_commit(&ctx) @@ -170,7 +213,18 @@ pub async fn create_binding( .await?; let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - + let func = Func::get_by_id_or_error(&ctx, func_id).await?; + ctx.write_audit_log( + AuditLogKind::AttachActionFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + action_kind: Some(action_kind), + }, + func.name.clone(), + ) + .await?; WsEvent::schema_variant_updated(&ctx, schema, schema_variant) .await? .publish_on_commit(&ctx) @@ -213,7 +267,18 @@ pub async fn create_binding( .await?; let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - + let func = Func::get_by_id_or_error(&ctx, func_id).await?; + ctx.write_audit_log( + AuditLogKind::AttachCodeGenFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant.display_name().to_owned(), + }, + func.name.clone(), + ) + .await?; WsEvent::schema_variant_updated(&ctx, schema, schema_variant) .await? .publish_on_commit(&ctx) @@ -249,7 +314,18 @@ pub async fn create_binding( .await?; let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - + let func = Func::get_by_id_or_error(&ctx, func_id).await?; + ctx.write_audit_log( + AuditLogKind::AttachQualificationFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant.display_name().to_owned(), + }, + func.name.clone(), + ) + .await?; WsEvent::schema_variant_updated(&ctx, schema, schema_variant) .await? .publish_on_commit(&ctx) @@ -288,7 +364,18 @@ pub async fn create_binding( .await?; let schema_variant = SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; - + let func = Func::get_by_id_or_error(&ctx, func_id).await?; + ctx.write_audit_log( + AuditLogKind::AttachManagementFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant.display_name().to_owned(), + }, + func.name.clone(), + ) + .await?; WsEvent::schema_variant_updated(&ctx, schema, schema_variant) .await? .publish_on_commit(&ctx) diff --git a/lib/sdf-server/src/service/v2/func/binding/delete_binding.rs b/lib/sdf-server/src/service/v2/func/binding/delete_binding.rs index 25b11c3a2a..e9edbb46ab 100644 --- a/lib/sdf-server/src/service/v2/func/binding/delete_binding.rs +++ b/lib/sdf-server/src/service/v2/func/binding/delete_binding.rs @@ -10,13 +10,17 @@ use axum::{ extract::{Host, OriginalUri, Path}, Json, }; -use dal::func::{binding::management::ManagementBinding, FuncKind}; use dal::{ func::binding::{ action::ActionBinding, authentication::AuthBinding, leaf::LeafBinding, EventualParent, }, ChangeSet, ChangeSetId, Func, FuncId, SchemaVariant, WorkspacePk, WsEvent, }; +use dal::{ + func::{binding::management::ManagementBinding, FuncKind}, + Component, +}; +use si_events::audit_log::AuditLogKind; use si_frontend_types as frontend_types; use std::collections::HashSet; @@ -112,9 +116,37 @@ pub async fn delete_binding( | FuncKind::SchemaVariantDefinition | FuncKind::Unknown => return Err(FuncAPIError::CannotDeleteBindingForFunc), }; - - if let EventualParent::SchemaVariant(schema_variant_id) = eventual_parent { - modified_sv_ids.insert(schema_variant_id); + match eventual_parent { + EventualParent::SchemaVariant(schema_variant_id) => { + let schema_variant = + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id).await?; + ctx.write_audit_log( + AuditLogKind::DetachFunc { + func_id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant.display_name().to_owned(), + }, + func.name.clone(), + ) + .await?; + modified_sv_ids.insert(schema_variant_id); + } + EventualParent::Component(component_id) => { + let component = Component::get_by_id(&ctx, component_id).await?; + ctx.write_audit_log( + AuditLogKind::DetachFunc { + func_id, + func_display_name: func.display_name.clone(), + schema_variant_id: None, + component_id: Some(component_id), + subject_name: component.name(&ctx).await?.to_owned(), + }, + func.name.clone(), + ) + .await?; + } } } diff --git a/lib/sdf-server/src/service/v2/func/create_func.rs b/lib/sdf-server/src/service/v2/func/create_func.rs index 51d1f09e3f..00a0c3bbb6 100644 --- a/lib/sdf-server/src/service/v2/func/create_func.rs +++ b/lib/sdf-server/src/service/v2/func/create_func.rs @@ -12,9 +12,10 @@ use dal::{ FuncKind, }, schema::variant::leaves::{LeafInputLocation, LeafKind}, - ChangeSet, ChangeSetId, SchemaVariant, WorkspacePk, WsEvent, + ChangeSet, ChangeSetId, Component, SchemaVariant, WorkspacePk, WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use si_frontend_types::{self as frontend_types, FuncBinding, FuncCode, FuncSummary}; use super::{get_code_response, FuncAPIError, FuncAPIResult}; @@ -70,13 +71,33 @@ pub async fn create_func( .. } = request.binding { - FuncAuthoringClient::create_new_action_func( + let func = FuncAuthoringClient::create_new_action_func( &ctx, request.name, kind.into(), schema_variant_id, ) - .await? + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + ctx.write_audit_log( + AuditLogKind::AttachActionFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + action_kind: Some(kind), + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } @@ -115,14 +136,69 @@ pub async fn create_func( }); } - FuncAuthoringClient::create_new_attribute_func( + let func = FuncAuthoringClient::create_new_attribute_func( &ctx, request.name, eventual_parent, output_location, arg_bindings, ) - .await? + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + let (subject_name, component_id, schema_variant_id): ( + String, + Option, + Option, + ) = match eventual_parent { + Some(eventual_parent) => { + if let EventualParent::Component(component_id) = eventual_parent { + ( + Component::get_by_id(&ctx, component_id) + .await? + .name(&ctx) + .await?, + Some(component_id), + None, + ) + } else { + return Err(FuncAPIError::MissingSchemaVariantAndFunc); + } + } + None => { + let schema_variant_id = output_location.find_schema_variant(&ctx).await?; + ( + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) + .await? + .display_name() + .to_string(), + None, + Some(schema_variant_id), + ) + } + }; + let destination_name = output_location.get_name_of_destination(&ctx).await?; + ctx.write_audit_log( + AuditLogKind::AttachAttributeFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id, + component_id, + subject_name, + prop_id, + output_socket_id, + destination_name, + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } @@ -133,8 +209,30 @@ pub async fn create_func( func_id: _, } = request.binding.clone() { - FuncAuthoringClient::create_new_auth_func(&ctx, request.name, schema_variant_id) - .await? + let func = FuncAuthoringClient::create_new_auth_func( + &ctx, + request.name, + schema_variant_id, + ) + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + ctx.write_audit_log( + AuditLogKind::AttachAuthFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } @@ -151,14 +249,39 @@ pub async fn create_func( } else { inputs.into_iter().map(|input| input.into()).collect() }; - FuncAuthoringClient::create_new_leaf_func( + let func = FuncAuthoringClient::create_new_leaf_func( &ctx, request.name, LeafKind::CodeGeneration, EventualParent::SchemaVariant(schema_variant_id), &inputs, ) - .await? + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + let schema_variant_name = + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) + .await? + .display_name() + .to_string(); + ctx.write_audit_log( + AuditLogKind::AttachCodeGenFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant_name, + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } @@ -176,14 +299,39 @@ pub async fn create_func( inputs.into_iter().map(|input| input.into()).collect() }; - FuncAuthoringClient::create_new_leaf_func( + let func = FuncAuthoringClient::create_new_leaf_func( &ctx, request.name, LeafKind::Qualification, EventualParent::SchemaVariant(schema_variant_id), &inputs, ) - .await? + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + let schema_variant_name = + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) + .await? + .display_name() + .to_string(); + ctx.write_audit_log( + AuditLogKind::AttachQualificationFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant_name, + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } @@ -194,12 +342,37 @@ pub async fn create_func( .. } = request.binding.clone() { - FuncAuthoringClient::create_new_management_func( + let func = FuncAuthoringClient::create_new_management_func( &ctx, request.name, schema_variant_id, ) - .await? + .await?; + ctx.write_audit_log( + AuditLogKind::CreateFunc { + func_display_name: func.display_name.clone(), + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; + let schema_variant_name = + SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) + .await? + .display_name() + .to_string(); + ctx.write_audit_log( + AuditLogKind::AttachManagementFunc { + func_id: func.id, + func_display_name: func.display_name.clone(), + schema_variant_id: Some(schema_variant_id), + component_id: None, + subject_name: schema_variant_name, + }, + func.name.clone(), + ) + .await?; + func } else { return Err(FuncAPIError::WrongFunctionKindForBinding); } diff --git a/lib/sdf-server/src/service/v2/func/create_unlocked_copy.rs b/lib/sdf-server/src/service/v2/func/create_unlocked_copy.rs index a3733e5444..8e3f7fec8c 100644 --- a/lib/sdf-server/src/service/v2/func/create_unlocked_copy.rs +++ b/lib/sdf-server/src/service/v2/func/create_unlocked_copy.rs @@ -3,10 +3,11 @@ use axum::{ Json, }; use dal::{ - func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, Func, FuncId, SchemaVariantId, - WorkspacePk, WsEvent, + func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, Func, FuncId, SchemaVariant, + SchemaVariantId, WorkspacePk, WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use si_frontend_types::{FuncCode, FuncSummary}; use super::{get_code_response, FuncAPIError, FuncAPIResult}; @@ -54,6 +55,11 @@ pub async fn create_unlocked_copy( let code = get_code_response(&ctx, new_func.id).await?; let summary = new_func.into_frontend_type(&ctx).await?; + let variant = if let Some(schema_variant_id) = request.schema_variant_id { + SchemaVariant::get_by_id(&ctx, schema_variant_id).await? + } else { + None + }; WsEvent::func_created(&ctx, summary.clone()) .await? .publish_on_commit(&ctx) @@ -72,7 +78,17 @@ pub async fn create_unlocked_copy( "func_kind": summary.kind, }), ); - + ctx.write_audit_log( + AuditLogKind::UnlockFunc { + func_id, + func_display_name: summary.display_name.clone(), + schema_variant_id: request.schema_variant_id, + component_id: None, + subject_name: variant.map(|v| v.display_name().to_owned()), + }, + summary.name.clone(), + ) + .await?; ctx.commit().await?; Ok(ForceChangeSetResponse::new( diff --git a/lib/sdf-server/src/service/v2/func/delete_func.rs b/lib/sdf-server/src/service/v2/func/delete_func.rs index 0d017d150d..b62e6ac44e 100644 --- a/lib/sdf-server/src/service/v2/func/delete_func.rs +++ b/lib/sdf-server/src/service/v2/func/delete_func.rs @@ -1,6 +1,7 @@ use axum::extract::{Host, OriginalUri, Path}; use dal::{func::binding::FuncBinding, ChangeSet, ChangeSetId, Func, FuncId, WorkspacePk, WsEvent}; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use super::{FuncAPIError, FuncAPIResult}; use crate::{ @@ -57,7 +58,15 @@ pub async fn delete_func( "func_kind": func.kind.clone(), }), ); - + ctx.write_audit_log( + AuditLogKind::DeleteFunc { + func_id, + func_display_name: func.display_name, + func_kind: func.kind.into(), + }, + func.name.clone(), + ) + .await?; ctx.commit().await?; Ok(ForceChangeSetResponse::new( diff --git a/lib/sdf-server/src/service/v2/func/execute_func.rs b/lib/sdf-server/src/service/v2/func/execute_func.rs index 0435e2d68d..4c8bba10d0 100644 --- a/lib/sdf-server/src/service/v2/func/execute_func.rs +++ b/lib/sdf-server/src/service/v2/func/execute_func.rs @@ -2,6 +2,7 @@ use axum::extract::{Host, OriginalUri, Path}; use dal::{ func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, Func, FuncId, WorkspacePk, }; +use si_events::audit_log::AuditLogKind; use super::FuncAPIResult; use crate::{ @@ -26,8 +27,14 @@ pub async fn execute_func( FuncAuthoringClient::execute_func(&ctx, func_id).await?; let func = Func::get_by_id_or_error(&ctx, func_id).await?; - // ws event? - + ctx.write_audit_log( + AuditLogKind::ExecuteFunc { + func_id, + func_display_name: func.display_name, + }, + func.name.to_owned(), + ) + .await?; track( &posthog_client, &ctx, diff --git a/lib/sdf-server/src/service/v2/func/test_execute.rs b/lib/sdf-server/src/service/v2/func/test_execute.rs index 8abad282d6..afaed6b554 100644 --- a/lib/sdf-server/src/service/v2/func/test_execute.rs +++ b/lib/sdf-server/src/service/v2/func/test_execute.rs @@ -6,7 +6,7 @@ use dal::{ func::authoring::FuncAuthoringClient, ChangeSetId, ComponentId, Func, FuncId, WorkspacePk, }; use serde::{Deserialize, Serialize}; -use si_events::FuncRunId; +use si_events::{audit_log::AuditLogKind, FuncRunId}; use super::FuncAPIResult; use crate::{ @@ -64,7 +64,15 @@ pub async fn test_execute( "component_id": request.component_id, }), ); - + ctx.write_audit_log( + AuditLogKind::TestFunction { + func_id, + func_display_name: func.display_name, + func_run_id, + }, + func.name.clone(), + ) + .await?; ctx.commit().await?; Ok(Json(TestExecuteFuncResponse { func_run_id })) diff --git a/lib/sdf-server/src/service/v2/func/update_func.rs b/lib/sdf-server/src/service/v2/func/update_func.rs index da3e42d7a5..4b5be8aacf 100644 --- a/lib/sdf-server/src/service/v2/func/update_func.rs +++ b/lib/sdf-server/src/service/v2/func/update_func.rs @@ -9,9 +9,11 @@ use axum::{ Json, }; use dal::{ - func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, FuncId, WorkspacePk, WsEvent, + func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, Func, FuncId, WorkspacePk, + WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use si_frontend_types::FuncSummary; use ulid::Ulid; @@ -36,7 +38,7 @@ pub async fn update_func( .build(access_builder.build(change_set_id.into())) .await?; let force_change_set_id = ChangeSet::force_new(&mut ctx).await?; - + let old_func = Func::get_by_id_or_error(&ctx, func_id).await?; let updated_func = FuncAuthoringClient::update_func(&ctx, func_id, request.display_name, request.description) .await? @@ -47,6 +49,17 @@ pub async fn update_func( .await? .publish_on_commit(&ctx) .await?; + ctx.write_audit_log( + AuditLogKind::UpdateFuncMetadata { + func_id, + old_display_name: old_func.display_name, + new_display_name: updated_func.display_name.clone(), + old_description: old_func.description, + new_description: updated_func.description.clone(), + }, + updated_func.name.clone(), + ) + .await?; track( &posthog_client, &ctx, diff --git a/lib/sdf-server/src/service/v2/module/contribute.rs b/lib/sdf-server/src/service/v2/module/contribute.rs index 8fd57897ae..af164b0ad3 100644 --- a/lib/sdf-server/src/service/v2/module/contribute.rs +++ b/lib/sdf-server/src/service/v2/module/contribute.rs @@ -5,6 +5,7 @@ use axum::{ }; use dal::{module::Module, ChangeSetId, WorkspacePk}; use module_index_client::ModuleIndexClient; +use si_events::audit_log::AuditLogKind; use si_frontend_types as frontend_types; use super::ModulesAPIError; @@ -60,11 +61,20 @@ pub async fn contribute( schema_id.map(|id| id.to_string()), payload, Some(request.schema_variant_id.to_string()), - Some(schema_variant_version), + Some(schema_variant_version.clone()), ) .await?; - ctx.commit().await?; + ctx.write_audit_log( + AuditLogKind::ContributeModule { + version: version.clone(), + schema_id: schema_id.map(Into::into), + schema_variant_id: request.schema_variant_id.into(), + schema_variant_version: Some(schema_variant_version.clone()), + }, + name.clone(), + ) + .await?; track( &posthog_client, @@ -83,6 +93,7 @@ pub async fn contribute( "pkg_hash": response.latest_hash, }), ); + ctx.commit().await?; Ok(axum::response::Response::builder().body(axum::body::Empty::new())?) } diff --git a/lib/sdf-server/src/service/v2/variant/create_unlocked_copy.rs b/lib/sdf-server/src/service/v2/variant/create_unlocked_copy.rs index bc617045c1..e6e52915dc 100644 --- a/lib/sdf-server/src/service/v2/variant/create_unlocked_copy.rs +++ b/lib/sdf-server/src/service/v2/variant/create_unlocked_copy.rs @@ -1,5 +1,6 @@ use axum::extract::{Host, OriginalUri, Path}; +use si_events::audit_log::AuditLogKind; use si_frontend_types::SchemaVariant as FrontendVariant; use dal::{ @@ -54,7 +55,14 @@ pub async fn create_unlocked_copy( let unlocked_variant = VariantAuthoringClient::create_unlocked_variant_copy(&ctx, original_variant.id()).await?; - + ctx.write_audit_log( + AuditLogKind::UnlockSchemaVariant { + schema_variant_id: unlocked_variant.id(), + schema_variant_display_name: unlocked_variant.display_name().to_owned(), + }, + schema.name().to_owned(), + ) + .await?; track( &posthog_client, &ctx, diff --git a/lib/sdf-server/src/service/v2/variant/delete_unlocked_variant.rs b/lib/sdf-server/src/service/v2/variant/delete_unlocked_variant.rs index 21178140ac..24e7b024e1 100644 --- a/lib/sdf-server/src/service/v2/variant/delete_unlocked_variant.rs +++ b/lib/sdf-server/src/service/v2/variant/delete_unlocked_variant.rs @@ -1,5 +1,6 @@ use axum::extract::{Host, OriginalUri, Path}; use dal::{ChangeSet, ChangeSetId, SchemaVariant, SchemaVariantId, WorkspacePk, WsEvent}; +use si_events::audit_log::AuditLogKind; use super::{SchemaVariantsAPIError, SchemaVariantsAPIResult}; use crate::{ @@ -51,6 +52,14 @@ pub async fn delete_unlocked_variant( "schema_variant_version": schema_variant.version(), }), ); + ctx.write_audit_log( + AuditLogKind::DeleteSchemaVariant { + schema_variant_id, + schema_id: schema.id(), + }, + schema_variant.display_name().to_owned(), + ) + .await?; ctx.commit().await?; Ok(ForceChangeSetResponse::new( diff --git a/lib/sdf-server/src/service/v2/view/create_view.rs b/lib/sdf-server/src/service/v2/view/create_view.rs index e36e8b7aeb..88cd8a2382 100644 --- a/lib/sdf-server/src/service/v2/view/create_view.rs +++ b/lib/sdf-server/src/service/v2/view/create_view.rs @@ -7,6 +7,7 @@ use axum::Json; use dal::diagram::view::{View, ViewView}; use dal::{ChangeSet, ChangeSetId, WorkspacePk, WsEvent}; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -33,8 +34,8 @@ pub async fn create_view( let force_change_set_id = ChangeSet::force_new(&mut ctx).await?; - let view = View::new(&ctx, name).await?; - + let view = View::new(&ctx, name.clone()).await?; + let view_id = view.clone().id(); track( &posthog_client, &ctx, @@ -43,14 +44,15 @@ pub async fn create_view( "create_view", serde_json::json!({ "how": "/diagram/create_view", - "view_id": view.id(), - "view_name": view.name(), + "view_id": view_id, + "view_name": name.to_owned(), "change_set_id": ctx.change_set_id(), }), ); let view_view = ViewView::from_view(&ctx, view).await?; - + ctx.write_audit_log(AuditLogKind::CreateView { view_id }, name.to_owned()) + .await?; WsEvent::view_created(&ctx, view_view.clone()) .await? .publish_on_commit(&ctx) diff --git a/lib/sdf-server/src/service/v2/view/remove_view.rs b/lib/sdf-server/src/service/v2/view/remove_view.rs index 93fbacc74f..435fdf528a 100644 --- a/lib/sdf-server/src/service/v2/view/remove_view.rs +++ b/lib/sdf-server/src/service/v2/view/remove_view.rs @@ -3,6 +3,7 @@ use dal::{ diagram::view::{View, ViewId}, ChangeSet, ChangeSetId, WorkspacePk, WsEvent, }; +use si_events::audit_log::AuditLogKind; use crate::{ extract::{AccessBuilder, HandlerContext, PosthogClient}, @@ -34,6 +35,12 @@ pub async fn remove_view( .publish_on_commit(&ctx) .await?; + ctx.write_audit_log( + AuditLogKind::DeleteView { view_id: view.id() }, + view.name().to_owned(), + ) + .await?; + track( &posthog_client, &ctx, diff --git a/lib/sdf-server/src/service/v2/view/set_component_parent.rs b/lib/sdf-server/src/service/v2/view/set_component_parent.rs index 4a1b399179..ef47563c55 100644 --- a/lib/sdf-server/src/service/v2/view/set_component_parent.rs +++ b/lib/sdf-server/src/service/v2/view/set_component_parent.rs @@ -10,6 +10,7 @@ use dal::{ component::frame::Frame, ChangeSet, ChangeSetId, Component, ComponentId, WorkspacePk, WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use std::collections::HashMap; use ulid::Ulid; @@ -45,8 +46,43 @@ pub async fn set_component_parent( let component = Component::get_by_id(&ctx, id).await?; if let Some(new_parent) = maybe_new_parent { + let old_parent_id = component.parent(&ctx).await?; + let old_parent_name = if let Some(old_parent_id) = old_parent_id { + let parent = Component::get_by_id(&ctx, old_parent_id).await?; + Some(parent.name(&ctx).await?) + } else { + None + }; Frame::upsert_parent(&ctx, component.id(), new_parent).await?; + let new_parent_name = Component::get_by_id(&ctx, new_parent) + .await? + .name(&ctx) + .await?; + ctx.write_audit_log( + AuditLogKind::UpdateComponentParent { + component_id: component.id(), + old_parent_id, + old_parent_name, + new_parent_id: new_parent, + new_parent_name, + }, + component.name(&ctx).await?, + ) + .await?; } else { + let old_parent_id = component.parent(&ctx).await?; + if let Some(old_parent_id) = old_parent_id { + let parent = Component::get_by_id(&ctx, old_parent_id).await?; + ctx.write_audit_log( + AuditLogKind::OrphanComponent { + component_id: component.id(), + previous_parent_id: old_parent_id, + previous_parent_name: parent.name(&ctx).await?, + }, + component.name(&ctx).await?.to_owned(), + ) + .await?; + } Frame::orphan_child(&ctx, component.id()).await?; } diff --git a/lib/sdf-server/src/service/v2/view/update_view.rs b/lib/sdf-server/src/service/v2/view/update_view.rs index c1eedcec1d..3b839ccfec 100644 --- a/lib/sdf-server/src/service/v2/view/update_view.rs +++ b/lib/sdf-server/src/service/v2/view/update_view.rs @@ -7,6 +7,7 @@ use axum::Json; use dal::diagram::view::{View, ViewId, ViewView}; use dal::{ChangeSet, ChangeSetId, WorkspacePk, WsEvent}; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] @@ -60,7 +61,14 @@ pub async fn update_view( "change_set_id": ctx.change_set_id(), }), ); - + ctx.write_audit_log( + AuditLogKind::UpdateView { + view_id, + old_name: old_view_name.clone(), + }, + view.name().to_owned(), + ) + .await?; let view_view = ViewView::from_view(&ctx, view).await?; WsEvent::view_updated(&ctx, view_view.clone()) diff --git a/lib/sdf-server/src/service/variant/create_variant.rs b/lib/sdf-server/src/service/variant/create_variant.rs index 8828c69c01..14d374a7f2 100644 --- a/lib/sdf-server/src/service/variant/create_variant.rs +++ b/lib/sdf-server/src/service/variant/create_variant.rs @@ -4,6 +4,7 @@ use axum::{ }; use dal::{schema::variant::authoring::VariantAuthoringClient, ChangeSet, Visibility, WsEvent}; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use si_frontend_types::SchemaVariant as FrontendVariant; use crate::{ @@ -63,6 +64,15 @@ pub async fn create_variant( .publish_on_commit(&ctx) .await?; + ctx.write_audit_log( + AuditLogKind::CreateSchemaVariant { + schema_id: schema.id(), + schema_variant_id: created_schema_variant.id(), + }, + created_schema_variant.display_name().to_string(), + ) + .await?; + ctx.commit().await?; let variant = created_schema_variant diff --git a/lib/sdf-server/src/service/variant/regenerate_variant.rs b/lib/sdf-server/src/service/variant/regenerate_variant.rs index 9c03c038a1..4f85867055 100644 --- a/lib/sdf-server/src/service/variant/regenerate_variant.rs +++ b/lib/sdf-server/src/service/variant/regenerate_variant.rs @@ -7,6 +7,7 @@ use dal::{ Visibility, WsEvent, }; use serde::{Deserialize, Serialize}; +use si_events::audit_log::AuditLogKind; use crate::{ extract::{AccessBuilder, HandlerContext, PosthogClient}, @@ -76,7 +77,11 @@ pub async fn regenerate_variant( "new_schema_variant_id": updated_schema_variant_id, }), ); - + ctx.write_audit_log( + AuditLogKind::RegenerateSchemaVariant { schema_variant_id }, + variant.display_name, + ) + .await?; let schema = SchemaVariant::schema_id_for_schema_variant_id(&ctx, updated_schema_variant_id).await?; let updated_schema_variant = diff --git a/lib/si-events-rs/src/audit_log/v1.rs b/lib/si-events-rs/src/audit_log/v1.rs index 87cceafbc2..d521f722f1 100644 --- a/lib/si-events-rs/src/audit_log/v1.rs +++ b/lib/si-events-rs/src/audit_log/v1.rs @@ -2,9 +2,10 @@ use serde::{Deserialize, Serialize}; use strum::{Display, EnumDiscriminants}; use crate::{ - ActionKind, ActionPrototypeId, Actor, AttributeValueId, ChangeSetId, ChangeSetStatus, - ComponentId, FuncId, InputSocketId, OutputSocketId, PropId, SchemaId, SchemaVariantId, - SecretId, WorkspacePk, + func_run::FuncArgumentKind, ActionKind, ActionPrototypeId, Actor, AttributeValueId, + ChangeSetId, ChangeSetStatus, ComponentId, FuncArgumentId, FuncId, FuncKind, FuncRunId, + InputSocketId, OutputSocketId, PropId, SchemaId, SchemaVariantId, SecretId, ViewId, + WorkspacePk, }; type MetadataDiscrim = AuditLogMetadataV1Discriminants; @@ -37,6 +38,49 @@ pub enum AuditLogKindV1 { ApproveChangeSetApply { from_status: ChangeSetStatus, }, + AttachActionFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + action_kind: Option, + }, + AttachAttributeFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + prop_id: Option, + output_socket_id: Option, + destination_name: String, + }, + AttachAuthFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + }, + AttachCodeGenFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + AttachManagementFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + AttachQualificationFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, CancelAction { prototype_id: ActionPrototypeId, action_kind: ActionKind, @@ -44,6 +88,12 @@ pub enum AuditLogKindV1 { func_display_name: Option, func_name: String, }, + ContributeModule { + version: String, + schema_id: Option, + schema_variant_id: Option, + schema_variant_version: Option, + }, CreateChangeSet, CreateComponent { name: String, @@ -51,20 +101,87 @@ pub enum AuditLogKindV1 { schema_variant_id: SchemaVariantId, schema_variant_name: String, }, + CreateConnection { + from_component_id: ComponentId, + from_component_name: String, + from_socket_id: OutputSocketId, + from_socket_name: String, + to_component_id: ComponentId, + to_component_name: String, + to_socket_id: InputSocketId, + to_socket_name: String, + }, + CreateFunc { + func_display_name: Option, + func_kind: FuncKind, + }, + CreateFuncArgument { + func_id: FuncId, + func_display_name: Option, + func_name: String, + kind: FuncArgumentKind, + element_kind: Option, + }, + CreateSchemaVariant { + schema_id: SchemaId, + schema_variant_id: SchemaVariantId, + }, CreateSecret { name: String, secret_id: SecretId, }, + CreateView { + view_id: ViewId, + }, DeleteComponent { name: String, component_id: ComponentId, schema_variant_id: SchemaVariantId, schema_variant_name: String, }, + DeleteConnection { + from_component_id: ComponentId, + from_component_name: String, + from_socket_id: OutputSocketId, + from_socket_name: String, + to_component_id: ComponentId, + to_component_name: String, + to_socket_id: InputSocketId, + to_socket_name: String, + }, + DeleteFunc { + func_id: FuncId, + func_display_name: Option, + func_kind: FuncKind, + }, + DeleteFuncArgument { + func_id: FuncId, + func_display_name: Option, + func_name: String, + func_argument_id: FuncArgumentId, + }, + DeleteSchemaVariant { + schema_variant_id: SchemaVariantId, + schema_id: SchemaId, + }, DeleteSecret { name: String, secret_id: SecretId, }, + DeleteView { + view_id: ViewId, + }, + DetachFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + ExecuteFunc { + func_id: FuncId, + func_display_name: Option, + }, ExportWorkspace { id: WorkspacePk, name: String, @@ -76,6 +193,12 @@ pub enum AuditLogKindV1 { version: String, }, Login, + OrphanComponent { + component_id: ComponentId, + previous_parent_id: ComponentId, + previous_parent_name: String, + }, + PutActionOnHold { prototype_id: ActionPrototypeId, action_kind: ActionKind, @@ -83,6 +206,9 @@ pub enum AuditLogKindV1 { func_display_name: Option, func_name: String, }, + RegenerateSchemaVariant { + schema_variant_id: SchemaVariantId, + }, RejectChangeSetApply { from_status: ChangeSetStatus, }, @@ -108,6 +234,29 @@ pub enum AuditLogKindV1 { func_name: String, run_status: bool, }, + TestFunction { + func_id: FuncId, + func_display_name: Option, + func_run_id: FuncRunId, + }, + UnlockFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: Option, + }, + UnlockSchemaVariant { + schema_variant_id: SchemaVariantId, + schema_variant_display_name: String, + }, + UpdateComponentParent { + component_id: ComponentId, + old_parent_id: Option, + old_parent_name: Option, + new_parent_id: ComponentId, + new_parent_name: String, + }, UpdateDependentInputSocket { input_socket_id: InputSocketId, input_socket_name: String, @@ -153,6 +302,13 @@ pub enum AuditLogKindV1 { before_value: Option, after_value: Option, }, + UpdateFuncMetadata { + func_id: FuncId, + old_display_name: Option, + new_display_name: Option, + old_description: Option, + new_description: Option, + }, UpdatePropertyEditorValue { component_id: ComponentId, component_name: String, @@ -177,10 +333,29 @@ pub enum AuditLogKindV1 { after_secret_name: Option, after_secret_id: Option, }, + UpdateSchemaVariant { + old_display_name: String, + new_display_name: String, + old_description: String, + new_description: String, + old_category: String, + new_category: String, + old_link: String, + new_link: String, + old_color: String, + new_color: String, + old_component_type: String, + new_component_type: String, + //todo: what to do about the code? + }, UpdateSecret { name: String, secret_id: SecretId, }, + UpdateView { + view_id: ViewId, + old_name: String, + }, UpgradeComponent { name: String, component_id: ComponentId, @@ -220,6 +395,55 @@ pub enum AuditLogMetadataV1 { #[serde(rename_all = "camelCase")] ApproveChangeSetApply { from_status: ChangeSetStatus }, #[serde(rename_all = "camelCase")] + AttachActionFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + action_kind: Option, + }, + #[serde(rename_all = "camelCase")] + AttachAttributeFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + prop_id: Option, + output_socket_id: Option, + destination_name: String, + }, + #[serde(rename_all = "camelCase")] + AttachAuthFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + }, + #[serde(rename_all = "camelCase")] + AttachCodeGenFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + #[serde(rename_all = "camelCase")] + AttachManagementFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + #[serde(rename_all = "camelCase")] + AttachQualificationFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + #[serde(rename_all = "camelCase")] CancelAction { prototype_id: ActionPrototypeId, action_kind: ActionKind, @@ -227,7 +451,13 @@ pub enum AuditLogMetadataV1 { func_display_name: Option, func_name: String, }, - + #[serde(rename_all = "camelCase")] + ContributeModule { + version: String, + schema_id: Option, + schema_variant_id: Option, + schema_variant_version: Option, + }, #[serde(rename_all = "camelCase")] CreateChangeSet, #[serde(rename_all = "camelCase")] @@ -238,8 +468,39 @@ pub enum AuditLogMetadataV1 { schema_variant_name: String, }, #[serde(rename_all = "camelCase")] + CreateConnection { + from_component_id: ComponentId, + from_component_name: String, + from_socket_id: OutputSocketId, + from_socket_name: String, + to_component_id: ComponentId, + to_component_name: String, + to_socket_id: InputSocketId, + to_socket_name: String, + }, + #[serde(rename_all = "camelCase")] + CreateFunc { + func_display_name: Option, + func_kind: FuncKind, + }, + #[serde(rename_all = "camelCase")] + CreateFuncArgument { + func_id: FuncId, + func_display_name: Option, + func_name: String, + kind: FuncArgumentKind, + element_kind: Option, + }, + #[serde(rename_all = "camelCase")] + CreateSchemaVariant { + schema_id: SchemaId, + schema_variant_id: SchemaVariantId, + }, + #[serde(rename_all = "camelCase")] CreateSecret { name: String, secret_id: SecretId }, #[serde(rename_all = "camelCase")] + CreateView { view_id: ViewId }, + #[serde(rename_all = "camelCase")] DeleteComponent { name: String, component_id: ComponentId, @@ -247,8 +508,52 @@ pub enum AuditLogMetadataV1 { schema_variant_name: String, }, #[serde(rename_all = "camelCase")] + DeleteConnection { + from_component_id: ComponentId, + from_component_name: String, + from_socket_id: OutputSocketId, + from_socket_name: String, + to_component_id: ComponentId, + to_component_name: String, + to_socket_id: InputSocketId, + to_socket_name: String, + }, + #[serde(rename_all = "camelCase")] + DeleteFunc { + func_id: FuncId, + func_display_name: Option, + func_kind: FuncKind, + }, + #[serde(rename_all = "camelCase")] + DeleteFuncArgument { + func_id: FuncId, + func_display_name: Option, + func_name: String, + func_argument_id: FuncArgumentId, + }, + #[serde(rename_all = "camelCase")] + DeleteSchemaVariant { + schema_variant_id: SchemaVariantId, + schema_id: SchemaId, + }, + #[serde(rename_all = "camelCase")] DeleteSecret { name: String, secret_id: SecretId }, #[serde(rename_all = "camelCase")] + DeleteView { view_id: ViewId }, + #[serde(rename_all = "camelCase")] + DetachFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: String, + }, + #[serde(rename_all = "camelCase")] + ExecuteFunc { + func_id: FuncId, + func_display_name: Option, + }, + #[serde(rename_all = "camelCase")] ExportWorkspace { id: WorkspacePk, name: String, @@ -263,6 +568,12 @@ pub enum AuditLogMetadataV1 { #[serde(rename_all = "camelCase")] Login, #[serde(rename_all = "camelCase")] + OrphanComponent { + component_id: ComponentId, + previous_parent_id: ComponentId, + previous_parent_name: String, + }, + #[serde(rename_all = "camelCase")] PutActionOnHold { prototype_id: ActionPrototypeId, action_kind: ActionKind, @@ -271,6 +582,8 @@ pub enum AuditLogMetadataV1 { func_name: String, }, #[serde(rename_all = "camelCase")] + RegenerateSchemaVariant { schema_variant_id: SchemaVariantId }, + #[serde(rename_all = "camelCase")] RejectChangeSetApply { from_status: ChangeSetStatus }, #[serde(rename_all = "camelCase")] ReopenChangeSet { from_status: ChangeSetStatus }, @@ -294,6 +607,33 @@ pub enum AuditLogMetadataV1 { run_status: bool, }, #[serde(rename_all = "camelCase")] + TestFunction { + func_id: FuncId, + func_display_name: Option, + func_run_id: FuncRunId, + }, + #[serde(rename_all = "camelCase")] + UnlockFunc { + func_id: FuncId, + func_display_name: Option, + schema_variant_id: Option, + component_id: Option, + subject_name: Option, + }, + #[serde(rename_all = "camelCase")] + UnlockSchemaVariant { + schema_variant_id: SchemaVariantId, + schema_variant_display_name: String, + }, + #[serde(rename_all = "camelCase")] + UpdateComponentParent { + component_id: ComponentId, + old_parent_id: Option, + old_parent_name: Option, + new_parent_id: ComponentId, + new_parent_name: String, + }, + #[serde(rename_all = "camelCase")] UpdateDependentInputSocket { input_socket_id: InputSocketId, input_socket_name: String, @@ -342,6 +682,14 @@ pub enum AuditLogMetadataV1 { after_value: Option, }, #[serde(rename_all = "camelCase")] + UpdateFuncMetadata { + func_id: FuncId, + old_display_name: Option, + new_display_name: Option, + old_description: Option, + new_description: Option, + }, + #[serde(rename_all = "camelCase")] UpdatePropertyEditorValue { component_id: ComponentId, component_name: String, @@ -368,8 +716,26 @@ pub enum AuditLogMetadataV1 { after_secret_id: Option, }, #[serde(rename_all = "camelCase")] + UpdateSchemaVariant { + old_display_name: String, + new_display_name: String, + old_description: String, + new_description: String, + old_category: String, + new_category: String, + old_link: String, + new_link: String, + old_color: String, + new_color: String, + old_component_type: String, + new_component_type: String, + //todo: what to do about the code? + }, + #[serde(rename_all = "camelCase")] UpdateSecret { name: String, secret_id: SecretId }, #[serde(rename_all = "camelCase")] + UpdateView { view_id: ViewId, old_name: String }, + #[serde(rename_all = "camelCase")] UpgradeComponent { name: String, component_id: ComponentId, @@ -394,16 +760,39 @@ impl AuditLogMetadataV1 { MetadataDiscrim::ApproveChangeSetApply => { ("Approved Request to Apply", Some("Change Set")) } + MetadataDiscrim::AttachActionFunc => ("Attached", Some("Action Function")), + MetadataDiscrim::AttachAttributeFunc => ("Attached", Some("Attribute Function")), + MetadataDiscrim::AttachAuthFunc => ("Attached", Some("Authentication Function")), + MetadataDiscrim::AttachCodeGenFunc => ("Attached", Some("Code Generation Function")), + MetadataDiscrim::AttachManagementFunc => ("Attached", Some("Management Function")), + MetadataDiscrim::AttachQualificationFunc => { + ("Attached", Some("Qualification Function")) + } MetadataDiscrim::CancelAction => ("Removed", Some("Action")), + MetadataDiscrim::ContributeModule => ("Contributed", Some("Module")), MetadataDiscrim::CreateChangeSet => ("Created", Some("Change Set")), MetadataDiscrim::CreateComponent => ("Created", Some("Component")), + MetadataDiscrim::CreateConnection => ("Created", Some("Connection")), + MetadataDiscrim::CreateFunc => ("Created", Some("Function")), + MetadataDiscrim::CreateFuncArgument => ("Created", Some("Function Argument")), + MetadataDiscrim::CreateSchemaVariant => ("Created", Some("Schema Variant")), MetadataDiscrim::CreateSecret => ("Created", Some("Secret")), + MetadataDiscrim::CreateView => ("Created", Some("View")), MetadataDiscrim::DeleteComponent => ("Deleted", Some("Component")), + MetadataDiscrim::DeleteConnection => ("Deleted", Some("Connection")), + MetadataDiscrim::DeleteFunc => ("Deleted", Some("Function")), + MetadataDiscrim::DeleteFuncArgument => ("Deleted", Some("Function Argument")), + MetadataDiscrim::DeleteSchemaVariant => ("Deleted", Some("Schema Variant")), MetadataDiscrim::DeleteSecret => ("Deleted", Some("Secret")), + MetadataDiscrim::DeleteView => ("Deleted", Some("View")), + MetadataDiscrim::DetachFunc => ("Detached", Some("Function")), + MetadataDiscrim::ExecuteFunc => ("Executed", Some("Function")), MetadataDiscrim::ExportWorkspace => ("Exported", Some("Workspace")), MetadataDiscrim::InstallWorkspace => ("Installed", Some("Workspace")), MetadataDiscrim::Login => ("Authenticated", None), + MetadataDiscrim::OrphanComponent => ("Orphaned", Some("Component")), MetadataDiscrim::PutActionOnHold => ("Paused", Some("Action")), + MetadataDiscrim::RegenerateSchemaVariant => ("Regenerated", Some("Schema Variant")), MetadataDiscrim::RejectChangeSetApply => { ("Rejected Request to Apply", Some("Change Set")) } @@ -411,16 +800,23 @@ impl AuditLogMetadataV1 { MetadataDiscrim::RequestChangeSetApproval => ("Requested to Apply", Some("Change Set")), MetadataDiscrim::RetryAction => ("Retried", Some("Action")), MetadataDiscrim::RunAction => ("Ran", Some("Action")), + MetadataDiscrim::TestFunction => ("Tested", Some("Function")), + MetadataDiscrim::UnlockFunc => ("Unlocked", Some("Function")), + MetadataDiscrim::UnlockSchemaVariant => ("Unlocked", Some("Schema Variant")), + MetadataDiscrim::UpdateComponentParent => ("Updated Parent", Some("Component")), MetadataDiscrim::UpdateDependentInputSocket => ("Set Dependent", Some("Input Socket")), MetadataDiscrim::UpdateDependentOutputSocket => { ("Set Dependent", Some("Output Socket")) } MetadataDiscrim::UpdateDependentProperty => ("Set Dependent", Some("Property")), + MetadataDiscrim::UpdateFuncMetadata => ("Updated Func", Some("Metadata")), MetadataDiscrim::UpdatePropertyEditorValue => ("Updated Component", Some("Property")), MetadataDiscrim::UpdatePropertyEditorValueForSecret => { ("Updated Component", Some("Property for Secret")) } MetadataDiscrim::UpdateSecret => ("Updated", Some("Secret")), + MetadataDiscrim::UpdateSchemaVariant => ("Updated", Some("Schema Variant")), + MetadataDiscrim::UpdateView => ("Updated", Some("View")), MetadataDiscrim::UpgradeComponent => ("Upgraded", Some("Component")), MetadataDiscrim::WithdrawRequestForChangeSetApply => { ("Withdrew Request to Apply", Some("Change Set")) @@ -452,6 +848,86 @@ impl From for Metadata { Kind::ApproveChangeSetApply { from_status } => { Self::ApproveChangeSetApply { from_status } } + Kind::AttachActionFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + action_kind, + } => Self::AttachActionFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + action_kind, + }, + Kind::AttachAttributeFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + prop_id, + output_socket_id, + destination_name, + } => Self::AttachAttributeFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + prop_id, + output_socket_id, + destination_name, + }, + Kind::AttachAuthFunc { + func_id, + func_display_name, + schema_variant_id, + } => Self::AttachAuthFunc { + func_id, + func_display_name, + schema_variant_id, + }, + Kind::AttachCodeGenFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + } => Self::AttachCodeGenFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + }, + Kind::AttachManagementFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + } => Self::AttachManagementFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + }, + Kind::AttachQualificationFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + } => Self::AttachQualificationFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + }, Kind::CancelAction { prototype_id, action_kind, @@ -465,6 +941,17 @@ impl From for Metadata { func_display_name, func_name, }, + Kind::ContributeModule { + version, + schema_id, + schema_variant_id, + schema_variant_version, + } => Self::ContributeModule { + version, + schema_id, + schema_variant_id, + schema_variant_version, + }, Kind::CreateChangeSet => Self::CreateChangeSet, Kind::CreateComponent { name, @@ -477,7 +964,54 @@ impl From for Metadata { schema_variant_id, schema_variant_name, }, + Kind::CreateConnection { + from_component_id, + from_component_name, + from_socket_id, + from_socket_name, + to_component_id, + to_component_name, + to_socket_id, + to_socket_name, + } => Self::CreateConnection { + from_component_id, + from_component_name, + from_socket_id, + from_socket_name, + to_component_id, + to_component_name, + to_socket_id, + to_socket_name, + }, + Kind::CreateFunc { + func_display_name, + func_kind, + } => Self::CreateFunc { + func_display_name, + func_kind, + }, + Kind::CreateFuncArgument { + func_id, + func_display_name, + func_name, + kind, + element_kind, + } => Self::CreateFuncArgument { + func_id, + func_display_name, + func_name, + kind, + element_kind, + }, + Kind::CreateSchemaVariant { + schema_id, + schema_variant_id, + } => Self::CreateSchemaVariant { + schema_id, + schema_variant_id, + }, Kind::CreateSecret { name, secret_id } => Self::CreateSecret { name, secret_id }, + Kind::CreateView { view_id } => Self::CreateView { view_id }, Kind::DeleteComponent { name, component_id, @@ -489,7 +1023,74 @@ impl From for Metadata { schema_variant_id, schema_variant_name, }, + Kind::DeleteConnection { + from_component_id, + from_component_name, + from_socket_id, + from_socket_name, + to_component_id, + to_component_name, + to_socket_id, + to_socket_name, + } => Self::DeleteConnection { + from_component_id, + from_component_name, + from_socket_id, + from_socket_name, + to_component_id, + to_component_name, + to_socket_id, + to_socket_name, + }, + Kind::DeleteFunc { + func_id, + func_display_name, + func_kind, + } => Self::DeleteFunc { + func_id, + func_display_name, + func_kind, + }, + Kind::DeleteFuncArgument { + func_id, + func_display_name, + func_name, + func_argument_id, + } => Self::DeleteFuncArgument { + func_id, + func_display_name, + func_name, + func_argument_id, + }, + Kind::DeleteSchemaVariant { + schema_variant_id, + schema_id, + } => Self::DeleteSchemaVariant { + schema_variant_id, + schema_id, + }, Kind::DeleteSecret { name, secret_id } => Self::DeleteSecret { name, secret_id }, + Kind::DeleteView { view_id } => Self::DeleteView { view_id }, + Kind::DetachFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + } => Self::DetachFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + }, + Kind::ExecuteFunc { + func_id, + func_display_name, + } => Self::ExecuteFunc { + func_id, + func_display_name, + }, Kind::ExportWorkspace { id, name, version } => { Self::ExportWorkspace { id, name, version } } @@ -497,6 +1098,15 @@ impl From for Metadata { Self::InstallWorkspace { id, name, version } } Kind::Login => Self::Login, + Kind::OrphanComponent { + component_id, + previous_parent_id, + previous_parent_name, + } => Self::OrphanComponent { + component_id, + previous_parent_id, + previous_parent_name, + }, Kind::PutActionOnHold { prototype_id, action_kind, @@ -510,6 +1120,9 @@ impl From for Metadata { func_display_name, func_name, }, + Kind::RegenerateSchemaVariant { schema_variant_id } => { + Self::RegenerateSchemaVariant { schema_variant_id } + } Kind::RejectChangeSetApply { from_status } => { Self::RejectChangeSetApply { from_status } } @@ -545,6 +1158,48 @@ impl From for Metadata { func_name, run_status, }, + Kind::TestFunction { + func_id, + func_display_name, + func_run_id, + } => Self::TestFunction { + func_id, + func_display_name, + func_run_id, + }, + Kind::UnlockFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + } => Self::UnlockFunc { + func_id, + func_display_name, + schema_variant_id, + component_id, + subject_name, + }, + Kind::UnlockSchemaVariant { + schema_variant_id, + schema_variant_display_name, + } => Self::UnlockSchemaVariant { + schema_variant_id, + schema_variant_display_name, + }, + Kind::UpdateComponentParent { + component_id, + old_parent_id, + old_parent_name, + new_parent_id, + new_parent_name, + } => Self::UpdateComponentParent { + component_id, + old_parent_id, + old_parent_name, + new_parent_id, + new_parent_name, + }, Kind::UpdateDependentInputSocket { input_socket_id, input_socket_name, @@ -632,6 +1287,19 @@ impl From for Metadata { before_value, after_value, }, + Kind::UpdateFuncMetadata { + func_id, + old_display_name, + new_display_name, + old_description, + new_description, + } => Self::UpdateFuncMetadata { + func_id, + old_display_name, + new_display_name, + old_description, + new_description, + }, Kind::UpdatePropertyEditorValue { component_id, component_name, @@ -678,7 +1346,35 @@ impl From for Metadata { after_secret_name, after_secret_id, }, + Kind::UpdateSchemaVariant { + old_display_name, + new_display_name, + old_description, + new_description, + old_category, + new_category, + old_link, + new_link, + old_color, + new_color, + old_component_type, + new_component_type, + } => Self::UpdateSchemaVariant { + old_display_name, + new_display_name, + old_description, + new_description, + old_category, + new_category, + old_link, + new_link, + old_color, + new_color, + old_component_type, + new_component_type, + }, Kind::UpdateSecret { name, secret_id } => Self::UpdateSecret { name, secret_id }, + Kind::UpdateView { view_id, old_name } => Self::UpdateView { view_id, old_name }, Kind::UpgradeComponent { name, component_id, diff --git a/lib/si-events-rs/src/func_run.rs b/lib/si-events-rs/src/func_run.rs index 5255a168d0..8028b8e2bc 100644 --- a/lib/si-events-rs/src/func_run.rs +++ b/lib/si-events-rs/src/func_run.rs @@ -42,6 +42,19 @@ pub enum FuncKind { Management, } +/// Describes the kind of [`FuncArgument`](crate::FuncArgument). +#[derive(AsRefStr, Deserialize, Display, Serialize, Debug, Eq, PartialEq, Clone, Copy, Hash)] +pub enum FuncArgumentKind { + Any, + Array, + Boolean, + Integer, + Json, + Map, + Object, + String, +} + // NOTE(nick,zack): do not add "remain::sorted" for postcard de/ser. We need the order to be // retained. #[derive( diff --git a/lib/si-events-rs/src/lib.rs b/lib/si-events-rs/src/lib.rs index dbd5629335..4badd2f3b8 100644 --- a/lib/si-events-rs/src/lib.rs +++ b/lib/si-events-rs/src/lib.rs @@ -38,7 +38,7 @@ pub use crate::{ func_execution::*, func_run::{ ActionId, ActionKind, ActionPrototypeId, ActionResultState, AttributePrototypeArgumentId, - AttributePrototypeId, AttributeValueId, ComponentId, FuncBackendKind, + AttributePrototypeId, AttributeValueId, ComponentId, FuncArgumentKind, FuncBackendKind, FuncBackendResponseType, FuncKind, FuncRun, FuncRunBuilder, FuncRunBuilderError, FuncRunId, FuncRunState, FuncRunValue, ManagementPrototypeId, ViewId, },