chore: support flex response layout (#1215)

* chore: support flex response layout
This commit is contained in:
Nathan.fooo 2025-02-06 17:32:10 +08:00 committed by GitHub
parent a7dff1b7d8
commit c80157a687
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 15 deletions

View File

@ -91,7 +91,6 @@ APPFLOWY_S3_ACCESS_KEY=${AWS_ACCESS_KEY}
APPFLOWY_S3_SECRET_KEY=${AWS_SECRET} APPFLOWY_S3_SECRET_KEY=${AWS_SECRET}
APPFLOWY_S3_BUCKET=appflowy APPFLOWY_S3_BUCKET=appflowy
#APPFLOWY_S3_REGION=us-east-1 #APPFLOWY_S3_REGION=us-east-1
APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api
# AppFlowy Cloud Mailer # AppFlowy Cloud Mailer
# Note that smtps (TLS) is always required, even for ports other than 465 # Note that smtps (TLS) is always required, even for ports other than 465

View File

@ -44,11 +44,12 @@ pub struct ResponseFormat {
#[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr)] #[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr)]
#[repr(u8)] #[repr(u8)]
pub enum OutputLayout { pub enum OutputLayout {
#[default]
Paragraph = 0, Paragraph = 0,
BulletList = 1, BulletList = 1,
NumberedList = 2, NumberedList = 2,
SimpleTable = 3, SimpleTable = 3,
#[default]
Flex = 4,
} }
#[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr, Eq, PartialEq)] #[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr, Eq, PartialEq)]

View File

@ -2,6 +2,7 @@ use crate::client::{localhost_client, LOCALHOST_GOTRUE};
use crate::log::setup_log; use crate::log::setup_log;
use client_api::Client; use client_api::Client;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use tokio::sync::OnceCell;
use uuid::Uuid; use uuid::Uuid;
lazy_static! { lazy_static! {
@ -12,7 +13,6 @@ lazy_static! {
password: std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap_or("password".to_string()), password: std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap_or("password".to_string()),
} }
}; };
static ref ADMIN_SIGN_IN_MUTEX: tokio::sync::Mutex<()> = tokio::sync::Mutex::new(());
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -25,20 +25,20 @@ pub fn generate_unique_email() -> String {
format!("user_{}@appflowy.io", Uuid::new_v4()) format!("user_{}@appflowy.io", Uuid::new_v4())
} }
pub async fn admin_user_client() -> Client { static ADMIN_USER_CLIENT: OnceCell<Client> = OnceCell::const_new();
let admin_client = localhost_client();
#[cfg(target_arch = "wasm32")]
{
let msg = format!("{}", admin_client);
web_sys::console::log_1(&msg.into());
}
let _guard = ADMIN_SIGN_IN_MUTEX.lock().await; pub async fn admin_user_client() -> Client {
let _is_new = admin_client ADMIN_USER_CLIENT
.sign_in_password(&ADMIN_USER.email, &ADMIN_USER.password) .get_or_init(|| async {
let client = localhost_client();
client
.sign_in_password(&ADMIN_USER.email, &ADMIN_USER.password)
.await
.expect("Failed to sign in admin user");
client
})
.await .await
.unwrap(); .clone()
admin_client
} }
pub async fn generate_unique_registered_user() -> User { pub async fn generate_unique_registered_user() -> User {