Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(dcs): remove macros (#1091)

Will Hutchinson0cee382e00a8
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/create_macro.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/create_macro.rs
deleted file mode 100644
index 239b3587b5..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/create_macro.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-use crate::{api::context::ApiContext, model::request::macros::CreateMacroRequest};
-use axum::{
- Json,
- extract::{self, Extension, State},
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use model::{response::StringIDResponse, user::UserContext};
-use models_permissions::share_permission::SharePermissionV2;
-use sqlx::PgPool;
-
-#[utoipa::path(
- post,
- path = "/macros",
- responses(
- (status = 201, body=StringIDResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
- )]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub(in crate::api) async fn create_macro_handler(
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
- extract::Json(req): extract::Json<CreateMacroRequest>,
-) -> Result<Response, Response> {
- let string_id_response = create_macro_v2(&db, user_context, req)
- .await
- .map_err(|(status_code, message)| (status_code, message).into_response())?;
-
- Ok((StatusCode::OK, Json(string_id_response)).into_response())
-}
-
-#[tracing::instrument(skip(db, user_context, req), fields(user_id=user_context.user_id))]
-async fn create_macro_v2(
- db: &PgPool,
- user_context: Extension<UserContext>,
- req: CreateMacroRequest,
-) -> Result<StringIDResponse, (StatusCode, String)> {
- let share_permission: SharePermissionV2 = SharePermissionV2::new_chat_share_permission();
-
- let macro_item = macro_db_client::macros::create::create_macro(
- db,
- user_context.user_id.as_str(),
- req.title.as_str(),
- req.prompt.as_str(),
- req.icon.as_str(),
- req.color.as_str(),
- req.required_docs,
- &share_permission,
- )
- .await
- .map_err(|err| {
- tracing::error!(error=%err, "failed to create macro in database");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to create macro".to_string(),
- )
- })?;
-
- Ok(StringIDResponse { id: macro_item })
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/delete_macro.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/delete_macro.rs
deleted file mode 100644
index 71a52f0b07..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/delete_macro.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use crate::api::context::ApiContext;
-use axum::{
- Extension,
- extract::{Path, State},
- http::StatusCode,
- response::IntoResponse,
-};
-use macro_db_client::dcs::delete_macro::delete_macro;
-use macro_middleware::cloud_storage::ensure_access::macros::MacrosAccessLevelExtractor;
-use model::user::UserContext;
-use models_permissions::share_permission::access_level::EditAccessLevel;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub macro_prompt_id: String,
-}
-
-/// Deletes a particular macro by its id
-#[utoipa::path(
- delete,
- path = "/macros/{macro_prompt_id}",
- responses(
- (status = 200),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- ),
- params( ("macro_prompt_id" = String, Path, description = "id of the macro"))
- )]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub async fn delete_macro_handler(
- _access: MacrosAccessLevelExtractor<EditAccessLevel>,
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
- Path(Params { macro_prompt_id }): Path<Params>,
-) -> impl IntoResponse {
- if let Err(e) = delete_macro(&db, &macro_prompt_id).await {
- tracing::error!(
- error = %e,
-
- user_id = ?user_context.user_id,
- macro_prompt_id = %macro_prompt_id,
- "Failed to delete macro"
- );
- return Err((StatusCode::INTERNAL_SERVER_ERROR, "unable to delete macro").into_response());
- }
-
- Ok(StatusCode::OK)
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro.rs
deleted file mode 100644
index e8c9226cbc..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro.rs
+++ /dev/null
@@ -1,69 +0,0 @@
-use crate::{api::context::ApiContext, model::response::macros::GetMacroResponse};
-use axum::{
- Extension, Json,
- extract::{Path, State},
- http::StatusCode,
- response::IntoResponse,
-};
-use macro_db_client::dcs::get_macro::get_macro;
-use macro_middleware::cloud_storage::ensure_access::macros::MacrosAccessLevelExtractor;
-use model::user::UserContext;
-use models_permissions::share_permission::access_level::ViewAccessLevel;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub macro_prompt_id: String,
-}
-
-/// Gets a particular macro by its id
-#[utoipa::path(
- get,
- path = "/macros/{macro_prompt_id}",
- responses(
- (status = 200, body=GetMacroResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- ),
- params( ("macro_prompt_id" = String, Path, description = "id of the macro"))
-)]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub async fn get_macro_handler(
- MacrosAccessLevelExtractor { access_level, .. }: MacrosAccessLevelExtractor<ViewAccessLevel>,
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
- Path(Params { macro_prompt_id }): Path<Params>,
-) -> impl IntoResponse {
- let macro_item = match get_macro(&db, &macro_prompt_id).await {
- Ok(macro_item) => macro_item,
- Err(sqlx::Error::RowNotFound) => {
- tracing::error!(
- macro_prompt_id = %macro_prompt_id,
- user_id = %user_context.user_id,
- "macro not found"
- );
- return Err((StatusCode::NOT_FOUND, "macro not found"));
- }
- Err(err) => {
- tracing::error!(
- error = %err,
- macro_prompt_id = %macro_prompt_id,
- user_id = %user_context.user_id,
- "failed to get macro from database"
- );
- return Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to get macro permissions",
- ));
- }
- };
-
- let get_macro_response = GetMacroResponse {
- macro_item,
- user_access_level: access_level,
- };
-
- Ok((StatusCode::OK, Json(get_macro_response)))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro_permissions.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro_permissions.rs
deleted file mode 100644
index 93026a78d6..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macro_permissions.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use crate::{api::context::ApiContext, model::response::macros::GetMacroPermissionsResponseV2};
-
-use axum::{
- Extension, Json,
- extract::{Path, State},
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use macro_middleware::cloud_storage::ensure_access::macros::MacrosAccessLevelExtractor;
-use model::user::UserContext;
-use models_permissions::share_permission::access_level::EditAccessLevel;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub macro_prompt_id: String,
-}
-
-/// Gets the current macro share permissions
-#[utoipa::path(
- get,
- path = "/macros/{macro_prompt_id}/permissions",
- responses(
- (status = 200, body=GetMacroPermissionsResponseV2),
- (status = 404, body=String),
- (status = 500, body=String),
- ),
- params( ("macro_prompt_id" = String, Path, description = "id of the macro"))
- )]
-#[tracing::instrument(skip(db, _user_context), fields(user_id=?_user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub async fn get_macro_permissions_handler(
- _access: MacrosAccessLevelExtractor<EditAccessLevel>,
- State(db): State<PgPool>,
- _user_context: Extension<UserContext>,
- Path(Params { macro_prompt_id }): Path<Params>,
-) -> impl IntoResponse {
- get_macro_permissions_v2(&db, &macro_prompt_id).await
-}
-
-#[tracing::instrument(skip(db))]
-async fn get_macro_permissions_v2(
- db: &PgPool,
- macro_prompt_id: &str,
-) -> Result<Response, Response> {
- let macro_permissions =
- macro_db_client::share_permission::get::get_macro_share_permission(db, macro_prompt_id)
- .await
- .map_err(|e| {
- tracing::error!(error=?e, macro_prompt_id, "Failed to get macro permissions");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to get macro permissions",
- )
- .into_response()
- })?;
-
- let res = GetMacroPermissionsResponseV2 {
- permissions: macro_permissions,
- };
-
- Ok((StatusCode::OK, Json(res)).into_response())
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macros.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/get_macros.rs
deleted file mode 100644
index f28515f7c3..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/get_macros.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use crate::api::context::ApiContext;
-use macro_db_client::dcs::get_macros::get_macros;
-
-use axum::{Extension, Json, extract::State, http::StatusCode, response::IntoResponse};
-use model::{macros::MacrosResponse, user::UserContext};
-use sqlx::PgPool;
-
-/// Gets all the macros for a user.
-#[utoipa::path(
- get,
- path = "/macros",
- responses(
- (status = 200, body=MacrosResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
- )]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub async fn get_macros_handler(
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
-) -> impl IntoResponse {
- let macros = match get_macros(&db, &user_context.user_id).await {
- Ok(macros) => macros,
- Err(err) => {
- tracing::error!(error=?err, user_id=%user_context.user_id, "unable to get macros");
- return (StatusCode::INTERNAL_SERVER_ERROR, "unable to get macros").into_response();
- }
- };
-
- let macros_response = MacrosResponse { macros };
-
- (StatusCode::OK, Json(&macros_response)).into_response()
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/mod.rs
deleted file mode 100644
index e7ccfafe31..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/mod.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-pub mod create_macro;
-pub mod delete_macro;
-pub mod get_macro;
-pub mod get_macro_permissions;
-pub mod get_macros;
-pub mod patch_macro;
-
-use crate::api::context::ApiContext;
-use axum::{
- Router,
- routing::{delete, get, patch, post},
-};
-use tower::ServiceBuilder;
-
-pub fn router() -> Router<ApiContext> {
- Router::new()
- .route(
- "/",
- post(create_macro::create_macro_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
- .route(
- "/",
- get(get_macros::get_macros_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
- .route("/:macro_prompt_id", get(get_macro::get_macro_handler))
- .route(
- "/:macro_prompt_id/permissions",
- get(get_macro_permissions::get_macro_permissions_handler).layer(
- ServiceBuilder::new().layer(axum::middleware::from_fn(
- macro_middleware::auth::ensure_user_exists::handler,
- )),
- ),
- )
- .route(
- "/:macro_prompt_id",
- patch(patch_macro::patch_macro_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
- .route(
- "/:macro_prompt_id",
- delete(delete_macro::delete_macro_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/macros/patch_macro.rs b/rust/cloud-storage/document_cognition_service/src/api/macros/patch_macro.rs
deleted file mode 100644
index 9ee1c9c5d6..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/macros/patch_macro.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-use crate::{api::context::ApiContext, model::request::macros::PatchMacroRequest};
-use axum::{
- extract::{self, Extension, Path, State},
- http::StatusCode,
- response::IntoResponse,
-};
-use macro_db_client::dcs::patch_macro::patch_macro;
-use macro_middleware::cloud_storage::ensure_access::macros::MacrosAccessLevelExtractor;
-use model::user::UserContext;
-use models_permissions::share_permission::access_level::EditAccessLevel;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub macro_prompt_id: String,
-}
-
-#[utoipa::path(
- patch,
- path = "/macros/{macro_prompt_id}",
- responses(
- (status = 200),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- ),
- params( ("macro_prompt_id" = String, Path, description = "id of the macro"))
- )]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-#[axum::debug_handler(state = ApiContext)]
-pub(in crate::api) async fn patch_macro_handler(
- _access: MacrosAccessLevelExtractor<EditAccessLevel>,
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
- Path(Params { macro_prompt_id }): Path<Params>,
- extract::Json(req): extract::Json<PatchMacroRequest>,
-) -> impl IntoResponse {
- if let Err(e) = patch_macro(
- &db,
- &macro_prompt_id,
- req.title.as_deref(),
- req.prompt.as_deref(),
- req.icon.as_deref(),
- req.color.as_deref(),
- req.required_docs.as_ref(),
- )
- .await
- {
- tracing::error!(error = %e, macro_prompt_id = %macro_prompt_id, user_id = %user_context.user_id, "Failed to patch macro");
- return Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to patch macro".to_string(),
- ));
- }
- Ok(StatusCode::OK)
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/mod.rs
index 4aca39cec9..6e7ce6f81a 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/mod.rs
@@ -25,7 +25,6 @@ mod ws;
mod attachments;
mod chats;
-mod macros;
mod notification;
#[tracing::instrument(err, skip(state))]
@@ -79,7 +78,6 @@ fn api_router(api_context: ApiContext) -> Router {
"/internal",
internal::router(api_context.clone()).nest("/notifications", notification::router()),
)
- .nest("/macros", macros::router())
.nest("/document_text", document_text::router())
.nest("/attachments", attachments::router())
.nest("/citations", citations::router())
diff --git a/rust/cloud-storage/document_cognition_service/src/api/swagger.rs b/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
index e233df1232..a4c2da07be 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
@@ -18,9 +18,6 @@ use crate::{
},
document_text::upsert_document_text,
health,
- macros::{
- create_macro, delete_macro, get_macro, get_macro_permissions, get_macros, patch_macro,
- },
models::get_models,
preview::get_batch_preview,
ws::{self},
@@ -32,12 +29,10 @@ use crate::{
PatchChatRequest, PatchChatRequestV2,
},
document_text::{CreateTextRequestBody, CreateTextRequestParams},
- macros::{CreateMacroRequest, GetMacroPathParams, PatchMacroRequest},
},
response::{
attachments::GetChatsForAttachmentResponse,
chats::{GetChatPermissionsResponseV2, GetChatResponse, GetModelsResponse},
- macros::GetMacroResponse,
models::AIModel,
},
ws::{
@@ -60,7 +55,6 @@ use model::{
ChatHistory, ChatMessage, ChatMessageWithAttachments, ConversationRecord,
MessageWithAttachments, NewChatMessage, NewMessageAttachment,
},
- macros::{Macro, MacroResponse, MacrosResponse},
response::{GenericErrorResponse, StringIDResponse},
version::DocumentCognitionServiceApiVersion,
};
@@ -90,12 +84,6 @@ use utoipa::OpenApi;
delete_chat::permanently_delete_chat_handler,
get_models::get_models_handler,
get_chats::get_chats_handler,
- get_macro::get_macro_handler,
- get_macros::get_macros_handler,
- get_macro_permissions::get_macro_permissions_handler,
- delete_macro::delete_macro_handler,
- create_macro::create_macro_handler,
- patch_macro::patch_macro_handler,
upsert_document_text::upsert_text_handler,
get_chats_for_attachment::get_chats_for_attachment_handler,
verify_attachments::verify_attachments_handler,
@@ -160,16 +148,6 @@ use utoipa::OpenApi;
CreateTextRequestBody,
CreateTextRequestParams,
- // Macro Prompt
- Macro,
- MacroResponse,
- CreateMacroRequest,
- GetMacroPathParams,
- GetMacroResponse,
- MacrosResponse,
- PatchMacroRequest,
-
-
// Share Permission
UpdateOperation,
diff --git a/rust/cloud-storage/document_cognition_service/src/model/request/macros.rs b/rust/cloud-storage/document_cognition_service/src/model/request/macros.rs
deleted file mode 100644
index 1948384fc0..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/model/request/macros.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct CreateMacroRequest {
- pub title: String,
- pub prompt: String,
- pub icon: String,
- pub color: String,
- pub required_docs: Option<i32>,
-}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct PatchMacroRequest {
- pub title: Option<String>,
- pub prompt: Option<String>,
- pub icon: Option<String>,
- pub color: Option<String>,
- pub required_docs: Option<i32>,
-}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-pub struct GetMacroPathParams {
- pub macro_prompt_id: String,
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs b/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
index 6607280314..6710743086 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
@@ -1,3 +1,2 @@
pub mod chats;
pub mod document_text;
-pub mod macros;
diff --git a/rust/cloud-storage/document_cognition_service/src/model/response/macros.rs b/rust/cloud-storage/document_cognition_service/src/model/response/macros.rs
deleted file mode 100644
index 96ddf51864..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/model/response/macros.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-use model::macros::MacroResponse;
-use models_permissions::share_permission::access_level::AccessLevel;
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(serde::Serialize, serde::Deserialize, Debug, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct GetMacroPermissionsResponseV2 {
- pub permissions: models_permissions::share_permission::SharePermissionV2,
-}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct GetMacroResponse {
- pub macro_item: MacroResponse,
- pub user_access_level: AccessLevel,
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/model/response/mod.rs b/rust/cloud-storage/document_cognition_service/src/model/response/mod.rs
index d93e76ee1b..e99f3d0875 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/response/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/response/mod.rs
@@ -1,4 +1,3 @@
pub mod attachments;
pub mod chats;
-pub mod macros;
pub mod models;
diff --git a/rust/cloud-storage/email_db_client/src/messages/insert.rs b/rust/cloud-storage/email_db_client/src/messages/insert.rs
index 35ef546962..dfed651813 100644
--- a/rust/cloud-storage/email_db_client/src/messages/insert.rs
+++ b/rust/cloud-storage/email_db_client/src/messages/insert.rs
@@ -314,13 +314,13 @@ async fn process_scheduled_message(
send_time: Option<chrono::DateTime<Utc>>,
message_db_id: Uuid,
) -> anyhow::Result<()> {
- if send_time.is_some() {
+ if let Some(send_time) = send_time {
upsert_scheduled_message(
tx,
ScheduledMessage {
link_id: service_message.link_id,
message_id: message_db_id,
- send_time: send_time.unwrap(),
+ send_time,
sent: false,
processing: false,
},
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-22597f9d367b63adb282279201462576b538ae5d1dac0aa2fe7afce28b6ecf79.json b/rust/cloud-storage/macro_db_client/.sqlx/query-22597f9d367b63adb282279201462576b538ae5d1dac0aa2fe7afce28b6ecf79.json
deleted file mode 100644
index c31603e9c6..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-22597f9d367b63adb282279201462576b538ae5d1dac0aa2fe7afce28b6ecf79.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM \"MacroPrompt\"\n WHERE id = $1",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "22597f9d367b63adb282279201462576b538ae5d1dac0aa2fe7afce28b6ecf79"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-301b9378cdbb4c58c804f7792da7665350d8e8c9db835f63201a2569f5bc08a1.json b/rust/cloud-storage/macro_db_client/.sqlx/query-301b9378cdbb4c58c804f7792da7665350d8e8c9db835f63201a2569f5bc08a1.json
deleted file mode 100644
index 81f43d38d3..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-301b9378cdbb4c58c804f7792da7665350d8e8c9db835f63201a2569f5bc08a1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"icon\" = $1\n WHERE id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "301b9378cdbb4c58c804f7792da7665350d8e8c9db835f63201a2569f5bc08a1"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-401e3192c36244f366e2a05df29d9edff223e47f022a9b222bd8a0eebe4685eb.json b/rust/cloud-storage/macro_db_client/.sqlx/query-401e3192c36244f366e2a05df29d9edff223e47f022a9b222bd8a0eebe4685eb.json
deleted file mode 100644
index c6d6636515..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-401e3192c36244f366e2a05df29d9edff223e47f022a9b222bd8a0eebe4685eb.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"prompt\" = $1\n WHERE id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "401e3192c36244f366e2a05df29d9edff223e47f022a9b222bd8a0eebe4685eb"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-4852c5b8bf296ed37ad04de7ebcc3480041948b61cde10dd5a45c7a9f85161c2.json b/rust/cloud-storage/macro_db_client/.sqlx/query-4852c5b8bf296ed37ad04de7ebcc3480041948b61cde10dd5a45c7a9f85161c2.json
deleted file mode 100644
index 5a3f841c32..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-4852c5b8bf296ed37ad04de7ebcc3480041948b61cde10dd5a45c7a9f85161c2.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n t.id,\n t.title,\n t.prompt,\n t.icon,\n t.color,\n t.required_docs,\n t.user_id,\n t.created_at::timestamptz,\n t.updated_at::timestamptz\n FROM \"MacroPrompt\" t\n WHERE t.user_id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "title",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "prompt",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "icon",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "color",
- "type_info": "Text"
- },
- {
- "ordinal": 5,
- "name": "required_docs",
- "type_info": "Int4"
- },
- {
- "ordinal": 6,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 7,
- "name": "created_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "updated_at",
- "type_info": "Timestamptz"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- true,
- false,
- null,
- null
- ]
- },
- "hash": "4852c5b8bf296ed37ad04de7ebcc3480041948b61cde10dd5a45c7a9f85161c2"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-5300a456971a0b0438e84f3467f9be915db9b86ea1434b97072008c2001e1993.json b/rust/cloud-storage/macro_db_client/.sqlx/query-5300a456971a0b0438e84f3467f9be915db9b86ea1434b97072008c2001e1993.json
deleted file mode 100644
index f15cbf06aa..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-5300a456971a0b0438e84f3467f9be915db9b86ea1434b97072008c2001e1993.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"required_docs\" = $1\n WHERE id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Int4",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "5300a456971a0b0438e84f3467f9be915db9b86ea1434b97072008c2001e1993"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-7c507b48ea60feff0a84111c68fd5bdfafca988a940fcca7bfac6675cac6f42c.json b/rust/cloud-storage/macro_db_client/.sqlx/query-7c507b48ea60feff0a84111c68fd5bdfafca988a940fcca7bfac6675cac6f42c.json
deleted file mode 100644
index 6a32be6f7a..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-7c507b48ea60feff0a84111c68fd5bdfafca988a940fcca7bfac6675cac6f42c.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n t.id,\n t.user_id,\n t.title,\n t.prompt,\n t.icon,\n t.color,\n t.required_docs,\n t.created_at::timestamptz,\n t.updated_at::timestamptz\n FROM \"MacroPrompt\" t\n WHERE t.id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "title",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "prompt",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "icon",
- "type_info": "Text"
- },
- {
- "ordinal": 5,
- "name": "color",
- "type_info": "Text"
- },
- {
- "ordinal": 6,
- "name": "required_docs",
- "type_info": "Int4"
- },
- {
- "ordinal": 7,
- "name": "created_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "updated_at",
- "type_info": "Timestamptz"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- true,
- null,
- null
- ]
- },
- "hash": "7c507b48ea60feff0a84111c68fd5bdfafca988a940fcca7bfac6675cac6f42c"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-85d2ea7b896c9ce364ffeb0c45e4f40dd89a027085cb9bceabd62a38cfa107dc.json b/rust/cloud-storage/macro_db_client/.sqlx/query-85d2ea7b896c9ce364ffeb0c45e4f40dd89a027085cb9bceabd62a38cfa107dc.json
deleted file mode 100644
index bd02e26bab..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-85d2ea7b896c9ce364ffeb0c45e4f40dd89a027085cb9bceabd62a38cfa107dc.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT \"share_permission_id\"\n FROM \"MacroPromptPermission\"\n WHERE \"macro_prompt_id\"=$1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "share_permission_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "85d2ea7b896c9ce364ffeb0c45e4f40dd89a027085cb9bceabd62a38cfa107dc"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-b2420c8ba84f5e86124a5cf016fa61f4d3d1f5618763b2cdfc2c87d6088f609a.json b/rust/cloud-storage/macro_db_client/.sqlx/query-b2420c8ba84f5e86124a5cf016fa61f4d3d1f5618763b2cdfc2c87d6088f609a.json
deleted file mode 100644
index ee4401053b..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-b2420c8ba84f5e86124a5cf016fa61f4d3d1f5618763b2cdfc2c87d6088f609a.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"title\" = $1\n WHERE id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "b2420c8ba84f5e86124a5cf016fa61f4d3d1f5618763b2cdfc2c87d6088f609a"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-b3e2a44702deda40db145663d32c776da0e9099cc2d3293aa20575304a042855.json b/rust/cloud-storage/macro_db_client/.sqlx/query-b3e2a44702deda40db145663d32c776da0e9099cc2d3293aa20575304a042855.json
deleted file mode 100644
index 641c8dc06b..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-b3e2a44702deda40db145663d32c776da0e9099cc2d3293aa20575304a042855.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"updated_at\" = NOW()\n WHERE id = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "b3e2a44702deda40db145663d32c776da0e9099cc2d3293aa20575304a042855"
-}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-f1a0bd4d50dbe6459a1c372fb28af3c70edd9d6eab95d6b38964344cdbfd975e.json b/rust/cloud-storage/macro_db_client/.sqlx/query-f1a0bd4d50dbe6459a1c372fb28af3c70edd9d6eab95d6b38964344cdbfd975e.json
deleted file mode 100644
index 3f08677a7e..0000000000
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-f1a0bd4d50dbe6459a1c372fb28af3c70edd9d6eab95d6b38964344cdbfd975e.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE \"MacroPrompt\" SET \"color\" = $1\n WHERE id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "f1a0bd4d50dbe6459a1c372fb28af3c70edd9d6eab95d6b38964344cdbfd975e"
-}
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/create_macro.rs b/rust/cloud-storage/macro_db_client/src/dcs/create_macro.rs
deleted file mode 100644
index 02e013fa70..0000000000
--- a/rust/cloud-storage/macro_db_client/src/dcs/create_macro.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-use crate::share_permission::create::create_macro_permission;
-use model::StringID;
-use models_permissions::share_permission::SharePermissionV2;
-use sqlx::{Pool, Postgres};
-
-#[tracing::instrument(skip(db))]
-#[expect(clippy::too_many_arguments, reason = "too annoying to fix")]
-pub async fn create_macro(
- db: Pool<Postgres>,
- user_id: &str,
- title: &str,
- prompt: &str,
- icon: &str,
- color: &str,
- required_docs: Option<i32>,
- share_permission: SharePermissionV2,
-) -> anyhow::Result<String> {
- let mut transaction = db.begin().await?;
-
- let macro_item = sqlx::query_as!(
- StringID,
- r#"
- INSERT INTO "MacroPrompt" (user_id, title, prompt, icon, color, required_docs)
- VALUES ($1, $2, $3, $4, $5, $6)
- RETURNING id;
- "#,
- &user_id,
- &title,
- &prompt,
- &icon,
- &color,
- required_docs,
- )
- .fetch_one(&mut *transaction)
- .await?;
-
- create_macro_permission(&mut transaction, macro_item.id.as_str(), &share_permission).await?;
-
- transaction.commit().await.map_err(|e| {
- tracing::error!(error=?e, "create_macro transaction error");
- anyhow::Error::from(e)
- })?;
-
- Ok(macro_item.id)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use sqlx::{Pool, Postgres};
-
- use crate::dcs::get_macro::get_macro;
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("dcs_basic_user_with_documents")))]
- async fn test_create_macro(pool: Pool<Postgres>) {
- let macro_prompt_id = create_macro(
- pool.clone(),
- "test macro title",
- "test macro prompt",
- "icon",
- "red",
- Some(3),
- SharePermissionV2::new_chat_share_permission(),
- )
- .await
- .unwrap();
-
- assert_eq!(macro_prompt_id.is_empty(), false);
- let macro_item = get_macro(&pool, macro_prompt_id.as_str()).await.unwrap();
-
- assert_eq!(macro_item.id, macro_prompt_id);
- assert_eq!(macro_item.user_id, "macro|[email protected]".to_string());
- assert_eq!(macro_item.title, "test macro title".to_string());
- assert_eq!(macro_item.prompt, "test macro prompt".to_string());
- assert_eq!(macro_item.color, "red".to_string());
- assert_eq!(macro_item.required_docs, Some(3));
- }
-}
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/delete_macro.rs b/rust/cloud-storage/macro_db_client/src/dcs/delete_macro.rs
deleted file mode 100644
index fd97aa59e1..0000000000
--- a/rust/cloud-storage/macro_db_client/src/dcs/delete_macro.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-#[tracing::instrument(skip(db))]
-pub async fn delete_macro(db: &sqlx::PgPool, macro_prompt_id: &str) -> anyhow::Result<()> {
- let mut transaction = db.begin().await?;
-
- // Get share permission if present
- let share_permission: Option<String> = sqlx::query!(
- r#"
- SELECT "share_permission_id"
- FROM "MacroPromptPermission"
- WHERE "macro_prompt_id"=$1"#,
- macro_prompt_id
- )
- .map(|row| row.share_permission_id)
- .fetch_optional(&mut *transaction)
- .await?;
-
- // Delete share permission
- if let Some(share_permission) = share_permission {
- sqlx::query!(
- r#"
- DELETE FROM "SharePermission" WHERE id = $1"#,
- share_permission
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- // Delete the macro prompt
- sqlx::query!(
- r#"
- DELETE FROM "MacroPrompt"
- WHERE id = $1"#,
- macro_prompt_id
- )
- .execute(&mut *transaction)
- .await?;
-
- transaction.commit().await?;
-
- Ok(())
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use sqlx::{Pool, Postgres};
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("macro_example")))]
- async fn test_delete_macro(pool: Pool<Postgres>) -> anyhow::Result<()> {
- delete_macro(&pool, "prompt-three").await?;
- let macro_prompt = sqlx::query!(
- r#"
- SELECT id
- FROM "MacroPrompt"
- WHERE id = $1
- "#,
- "prompt-three"
- )
- .fetch_one(&pool)
- .await;
-
- assert!(macro_prompt.is_err());
- Ok(())
- }
-}
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/get_macro.rs b/rust/cloud-storage/macro_db_client/src/dcs/get_macro.rs
deleted file mode 100644
index ce2ffa3573..0000000000
--- a/rust/cloud-storage/macro_db_client/src/dcs/get_macro.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use model::macros::{Macro, MacroResponse};
-use sqlx::{Pool, Postgres};
-
-#[tracing::instrument(skip(db))]
-pub async fn get_macro(
- db: &Pool<Postgres>,
- macro_prompt_id: &str,
-) -> anyhow::Result<MacroResponse, sqlx::Error> {
- let macro_item = sqlx::query_as!(
- Macro,
- r#"
- SELECT
- t.id,
- t.user_id,
- t.title,
- t.prompt,
- t.icon,
- t.color,
- t.required_docs,
- t.created_at::timestamptz,
- t.updated_at::timestamptz
- FROM "MacroPrompt" t
- WHERE t.id = $1
- "#,
- macro_prompt_id,
- )
- .fetch_one(db)
- .await?;
-
- let response: MacroResponse = macro_item.into();
- Ok(response)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use sqlx::{Pool, Postgres};
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("macro_example")))]
- async fn test_get_macro(pool: Pool<Postgres>) {
- let macro_item = get_macro(&pool, "prompt-three").await.unwrap();
-
- assert_eq!(macro_item.id, "prompt-three".to_string());
- assert_eq!(macro_item.user_id, "macro|[email protected]".to_string());
- assert_eq!(macro_item.title, "Test Prompt 3".to_string());
- assert_eq!(macro_item.prompt, "This is a test prompt 3".to_string());
- assert_eq!(macro_item.icon, "icon3".to_string());
- assert_eq!(macro_item.color, "green".to_string());
- assert_eq!(macro_item.required_docs, Some(1));
- }
-}
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/get_macros.rs b/rust/cloud-storage/macro_db_client/src/dcs/get_macros.rs
deleted file mode 100644
index a7dbee60da..0000000000
--- a/rust/cloud-storage/macro_db_client/src/dcs/get_macros.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use model::macros::Macro;
-use sqlx::{Pool, Postgres};
-
-#[tracing::instrument(skip(db))]
-pub async fn get_macros(db: &Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Macro>> {
- let mut macros: Vec<Macro> = Vec::new();
- macros.extend(
- sqlx::query_as!(
- Macro,
- r#"
- SELECT
- t.id,
- t.title,
- t.prompt,
- t.icon,
- t.color,
- t.required_docs,
- t.user_id,
- t.created_at::timestamptz,
- t.updated_at::timestamptz
- FROM "MacroPrompt" t
- WHERE t.user_id = $1
- "#,
- user_id,
- )
- .fetch_all(db)
- .await?,
- );
-
- Ok(macros)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use sqlx::{Pool, Postgres};
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("macro_example")))]
- async fn test_get_macros(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let macros = get_macros(&pool, "macro|[email protected]").await?;
- assert_eq!(macros.len(), 2);
- Ok(())
- }
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("macro_example")))]
- async fn test_get_macros_with_document_id(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let macros = get_macros(&pool, "macro|[email protected]").await?;
- assert_eq!(macros.len(), 3);
- Ok(())
- }
-}
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/mod.rs b/rust/cloud-storage/macro_db_client/src/dcs/mod.rs
index c064de4a3f..bba389fc8a 100644
--- a/rust/cloud-storage/macro_db_client/src/dcs/mod.rs
+++ b/rust/cloud-storage/macro_db_client/src/dcs/mod.rs
@@ -20,13 +20,6 @@ pub mod get_document_name_and_type;
pub mod get_documents;
pub mod get_documents_count;
-// Macro queries
-pub mod create_macro;
-pub mod delete_macro;
-pub mod get_macro;
-pub mod get_macros;
-pub mod patch_macro;
-
// Text queries
pub mod batch_verify;
pub mod get_document_text;
diff --git a/rust/cloud-storage/macro_db_client/src/dcs/patch_macro.rs b/rust/cloud-storage/macro_db_client/src/dcs/patch_macro.rs
deleted file mode 100644
index 4fc151a433..0000000000
--- a/rust/cloud-storage/macro_db_client/src/dcs/patch_macro.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-use sqlx::{Pool, Postgres};
-
-#[tracing::instrument(skip(db))]
-pub async fn patch_macro(
- db: &Pool<Postgres>,
- macro_prompt_id: &str,
- title: Option<&str>,
- prompt: Option<&str>,
- icon: Option<&str>,
- color: Option<&str>,
- required_docs: Option<&i32>,
-) -> anyhow::Result<()> {
- let mut transaction = db.begin().await?;
-
- // Update macro updated_at time
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "updated_at" = NOW()
- WHERE id = $1
- "#,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
-
- if let Some(title) = title {
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "title" = $1
- WHERE id = $2
- "#,
- title,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- if let Some(prompt) = prompt {
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "prompt" = $1
- WHERE id = $2
- "#,
- prompt,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- if let Some(icon) = icon {
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "icon" = $1
- WHERE id = $2
- "#,
- icon,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- if let Some(color) = color {
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "color" = $1
- WHERE id = $2
- "#,
- color,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- if let Some(required_docs) = required_docs {
- sqlx::query!(
- r#"
- UPDATE "MacroPrompt" SET "required_docs" = $1
- WHERE id = $2
- "#,
- required_docs,
- macro_prompt_id,
- )
- .execute(&mut *transaction)
- .await?;
- }
-
- transaction.commit().await?;
-
- Ok(())
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use crate::dcs::get_macro::get_macro;
- use sqlx::{Pool, Postgres};
-
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("macro_example")))]
- async fn test_patch_macro(pool: Pool<Postgres>) -> anyhow::Result<()> {
- patch_macro(
- &pool,
- "prompt-three",
- Some("Updated Title"),
- Some("Updated Prompt"),
- Some("new-icon"),
- Some("blue"),
- Some(&2),
- )
- .await?;
-
- let macro_item = get_macro(&pool, "prompt-three").await?;
-
- assert_eq!(macro_item.title, "Updated Title".to_string());
- assert_eq!(macro_item.prompt, "Updated Prompt".to_string());
- assert_eq!(macro_item.icon, "new-icon".to_string());
- assert_eq!(macro_item.color, "blue".to_string());
- assert_eq!(macro_item.required_docs, Some(2));
-
- Ok(())
- }
-}
diff --git a/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/macros.rs b/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/macros.rs
deleted file mode 100644
index 7c3f4be11b..0000000000
--- a/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/macros.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use super::get_users_access_level_v2;
-use crate::cloud_storage::ensure_access::{AccessLevelErr, BuildAccessLevel};
-use axum::{
- Extension, async_trait,
- extract::{FromRef, FromRequestParts, Path},
- http::request::Parts,
-};
-use model::user::UserContext;
-use models_permissions::share_permission::access_level::AccessLevel;
-use serde::Deserialize;
-use sqlx::PgPool;
-use std::marker::PhantomData;
-
-#[derive(Deserialize)]
-pub struct Params {
- pub macro_prompt_id: String,
-}
-
-/// Validates the user has the desired access level to the item
-/// Returns the [AccessLevel] for the user to the handler
-#[derive(Debug)]
-#[must_use]
-pub struct MacrosAccessLevelExtractor<T> {
- /// The access level for the user
- pub access_level: AccessLevel,
- desired: PhantomData<T>,
-}
-
-#[async_trait]
-impl<T, S> FromRequestParts<S> for MacrosAccessLevelExtractor<T>
-where
- T: BuildAccessLevel,
- PgPool: FromRef<S>,
- S: Send + Sync + 'static,
-{
- type Rejection = AccessLevelErr;
-
- #[tracing::instrument(ret, err, skip(parts, state))]
- async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
- let db = PgPool::from_ref(state);
- let Extension(user_context) = <Extension<UserContext>>::from_request_parts(parts, state)
- .await
- .map_err(|_| AccessLevelErr::UnAuthorized)?;
- let Path(Params { macro_prompt_id }) = <Path<Params>>::from_request_parts(parts, state)
- .await
- .map_err(|_| AccessLevelErr::BadRequest)?;
-
- let access_level: Option<AccessLevel> =
- get_users_access_level_v2(&db, &user_context.user_id, &macro_prompt_id, "macro")
- .await
- .map_err(AccessLevelErr::DbErr)?;
-
- let desired_level = T::into_access_level();
-
- match access_level {
- Some(access_level) if access_level >= desired_level => Ok(Self {
- access_level,
- desired: PhantomData,
- }),
- None | Some(_) => Err(AccessLevelErr::UnAuthorized),
- }
- }
-}
diff --git a/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/mod.rs b/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/mod.rs
index ad9d180de9..4bbd24d9fe 100644
--- a/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/mod.rs
+++ b/rust/cloud-storage/macro_middleware/src/cloud_storage/ensure_access/mod.rs
@@ -1,7 +1,6 @@
pub mod chat;
pub mod document;
pub mod history;
-pub mod macros;
pub mod pin;
pub mod project;
pub mod thread;
diff --git a/rust/cloud-storage/model/src/lib.rs b/rust/cloud-storage/model/src/lib.rs
index b390ff6e8a..93a6a3d796 100644
--- a/rust/cloud-storage/model/src/lib.rs
+++ b/rust/cloud-storage/model/src/lib.rs
@@ -13,7 +13,6 @@ pub mod document_storage_service_internal;
pub mod experiment;
pub mod folder;
pub mod item;
-pub mod macros;
pub mod organization;
pub mod pin;
pub mod project;
diff --git a/rust/cloud-storage/model/src/macros/mod.rs b/rust/cloud-storage/model/src/macros/mod.rs
deleted file mode 100644
index 3fe4f0fbff..0000000000
--- a/rust/cloud-storage/model/src/macros/mod.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-use chrono::serde::ts_seconds_option;
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(sqlx::FromRow, Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct Macro {
- /// The macro uuid
- pub id: String,
- /// Who the macro belongs to
- pub user_id: String,
- /// The title of the macro prompt
- pub title: String,
- /// The prompt used in the macro
- pub prompt: String,
- /// The icon of the macro
- pub icon: String,
- /// The color of the macro
- pub color: String,
- /// The required number of documents to use the macro
- pub required_docs: Option<i32>,
- /// The time the macro was created
- #[serde(with = "ts_seconds_option")]
- #[schema(value_type = i64, nullable=false)]
- pub created_at: Option<chrono::DateTime<chrono::Utc>>,
- /// The time the macro was last updated
- #[serde(with = "ts_seconds_option")]
- #[schema(value_type = i64, nullable=false)]
- pub updated_at: Option<chrono::DateTime<chrono::Utc>>,
-}
-
-// TODO: support macro attachments
-// for now this is the same as a Macro. When we add attachments this will differ.
-#[derive(sqlx::FromRow, Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct MacroResponse {
- /// The macro uuid
- pub id: String,
- /// The title of the macro prompt
- pub title: String,
- /// Who the macro belongs to
- pub user_id: String,
- /// The prompt used in the macro
- pub prompt: String,
- /// The icon of the macro
- pub icon: String,
- /// The color of the macro
- pub color: String,
- /// The required number of documents to use the macro
- pub required_docs: Option<i32>,
- /// The time the macro was created
- #[serde(with = "ts_seconds_option")]
- #[schema(value_type = i64, nullable=false)]
- pub created_at: Option<chrono::DateTime<chrono::Utc>>,
- /// The time the macro was last updated
- #[serde(with = "ts_seconds_option")]
- #[schema(value_type = i64, nullable=false)]
- pub updated_at: Option<chrono::DateTime<chrono::Utc>>,
-}
-
-impl From<Macro> for MacroResponse {
- fn from(m: Macro) -> Self {
- MacroResponse {
- id: m.id,
- user_id: m.user_id,
- title: m.title,
- prompt: m.prompt,
- icon: m.icon,
- color: m.color,
- required_docs: m.required_docs,
- created_at: m.created_at,
- updated_at: m.updated_at,
- }
- }
-}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-#[serde(rename_all = "camelCase", transparent)]
-pub struct MacrosResponse {
- pub macros: Vec<Macro>,
-}