diff --git a/Cargo.toml b/Cargo.toml index ed92699..2159a46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "integrationos-domain" description = "Shared library for IntegrationOS" license = "GPL-3.0" -version = "3.1.0" +version = "3.1.1" edition = "2021" repository = "https://github.com/integration-os/integrationos-domain" diff --git a/src/domain/connection/mod.rs b/src/domain/connection/mod.rs index e3cd6cb..f505365 100644 --- a/src/domain/connection/mod.rs +++ b/src/domain/connection/mod.rs @@ -5,13 +5,12 @@ pub mod connection_model_schema; pub mod connection_oauth_definition; pub mod db_model_config; -use std::{hash::Hash, sync::Arc}; - +use crate::id::Id; use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::{hash::Hash, sync::Arc}; use strum::{AsRefStr, Display, EnumString}; -use crate::id::Id; - use self::{ connection_model_definition::ConnectionModelDefinition, connection_oauth_definition::ConnectionOAuthDefinition, db_model_config::DbModelConfig, @@ -52,6 +51,36 @@ pub struct Connection { pub record_metadata: RecordMetadata, } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct SanitizedConnection { + #[serde(rename = "_id")] + pub id: Id, + pub platform_version: String, + pub connection_definition_id: Id, + pub r#type: ConnectionType, + pub name: String, + pub key: Arc, + pub group: String, + pub environment: Environment, + pub platform: Arc, + pub secrets_service_id: String, + pub event_access_id: Id, + pub settings: Settings, + pub throughput: Throughput, + pub ownership: Ownership, + #[serde(default)] + pub oauth: Option, + #[serde(flatten, default)] + pub record_metadata: RecordMetadata, +} + +impl SanitizedConnection { + pub fn to_value(&self) -> Value { + serde_json::to_value(self).unwrap_or(Value::Null) + } +} + impl Hash for Connection { fn hash(&self, state: &mut H) { self.id.hash(state);