From 60cdf8b821a624b55fb023276dfdcccc55f8dbef Mon Sep 17 00:00:00 2001 From: Samuel Gomez Date: Mon, 15 Apr 2024 17:41:23 +0100 Subject: [PATCH] Implement refresh full template support --- Cargo.lock | 6 ++++-- Cargo.toml | 2 +- src/algebra/refresh.rs | 6 +++--- src/algebra/trigger.rs | 12 ++++++++++-- src/service/mod.rs | 6 +++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68f09f7..b34feb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1592,9 +1592,9 @@ dependencies = [ [[package]] name = "integrationos-domain" -version = "1.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc08bc095761357574216a564449339a1af1f234188781f2fd41b917e8de288" +checksum = "76a78a0dd3ee18eb766eb3dc833ef334f8f25f8fd160102a16b503016fa146db" dependencies = [ "actix-web", "aes", @@ -1633,6 +1633,8 @@ dependencies = [ "thiserror", "tokio", "tracing", + "tracing-bunyan-formatter", + "tracing-log 0.2.0", "tracing-subscriber", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index ecd07fa..d268f52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ dotenvy = "0.15.7" envconfig = "0.10.0" futures = "0.3.30" handlebars = "5.1.1" -integrationos-domain = { version = "1.3.0", features = ["dummy", "actix-error"] } +integrationos-domain = { version = "2.1.0", features = ["dummy", "actix-error"] } jsonwebtoken = "9.2.0" moka = { version = "0.12.5", features = ["future"] } mongodb = "2.8.0" diff --git a/src/algebra/refresh.rs b/src/algebra/refresh.rs index 7936c72..a82f735 100644 --- a/src/algebra/refresh.rs +++ b/src/algebra/refresh.rs @@ -5,9 +5,9 @@ use actix::prelude::*; use chrono::{Duration, Utc}; use futures::lock::Mutex; use integrationos_domain::{ - algebra::MongoStore, connection_oauth_definition::ConnectionOAuthDefinition, - error::IntegrationOSError as Error, service::secrets_client::SecretsClient, Connection, - InternalError, + algebra::MongoStore, client::secrets_client::SecretsClient, + connection_oauth_definition::ConnectionOAuthDefinition, error::IntegrationOSError as Error, + Connection, InternalError, }; use reqwest::Client; use std::sync::Arc; diff --git a/src/algebra/trigger.rs b/src/algebra/trigger.rs index 22fcda1..9f75dc8 100644 --- a/src/algebra/trigger.rs +++ b/src/algebra/trigger.rs @@ -5,12 +5,12 @@ use chrono::Duration; use integrationos_domain::{ algebra::{MongoStore, StoreExt}, api_model_config::ContentType, + client::secrets_client::SecretsClient, connection_oauth_definition::{Computation, ConnectionOAuthDefinition, OAuthResponse}, error::IntegrationOSError as Error, get_secret_request::GetSecretRequest, oauth_secret::OAuthSecret, - service::secrets_client::SecretsClient, - ApplicationError, Connection, Id, InternalError, OAuth, + ApplicationError, Connection, DefaultTemplate, Id, InternalError, OAuth, TemplateExt, }; use mongodb::bson::{self, doc}; use reqwest::Client; @@ -75,6 +75,8 @@ impl Handler for TriggerActor { let request_id = self.request_id.map(|id| id.to_string()); let future = async move { + let template = DefaultTemplate::default(); + let ask = || async { let conn_id = match &msg.connection().oauth { Some(OAuth::Enabled { @@ -123,6 +125,12 @@ impl Handler for TriggerActor { InternalError::serialize_error("Failed to serialize secret", None) })?; + let conn_oauth_definition = if conn_oauth_definition.is_full_template_enabled { + template.render_as(&conn_oauth_definition, Some(&compute_payload))? + } else { + conn_oauth_definition + }; + let computation = conn_oauth_definition .compute .refresh diff --git a/src/service/mod.rs b/src/service/mod.rs index f5da017..9df8c66 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -7,9 +7,9 @@ pub use http::*; use crate::prelude::RefreshActor; use actix::{Addr, Supervisor}; use integrationos_domain::{ - algebra::MongoStore, connection_oauth_definition::ConnectionOAuthDefinition, - error::IntegrationOSError as Error, event_access::EventAccess, - service::secrets_client::SecretsClient, Connection, InternalError, Store, + algebra::MongoStore, client::secrets_client::SecretsClient, + connection_oauth_definition::ConnectionOAuthDefinition, error::IntegrationOSError as Error, + event_access::EventAccess, Connection, InternalError, Store, }; use moka::future::Cache; use mongodb::options::FindOptions;