mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 17:39:12 +01:00
Fix xpath filtering
This commit is contained in:
@@ -59,6 +59,7 @@ use yaak_models::queries::{
|
||||
upsert_cookie_jar, upsert_environment, upsert_folder, upsert_grpc_connection,
|
||||
upsert_grpc_event, upsert_grpc_request, upsert_http_request, upsert_workspace,
|
||||
};
|
||||
use yaak_plugin_runtime::events::FilterResponse;
|
||||
|
||||
mod analytics;
|
||||
mod export_resources;
|
||||
@@ -720,8 +721,7 @@ async fn cmd_filter_response(
|
||||
response_id: &str,
|
||||
plugin_manager: State<'_, Mutex<PluginManager>>,
|
||||
filter: &str,
|
||||
) -> Result<Vec<Value>, String> {
|
||||
println!("FILTERING? {filter}");
|
||||
) -> Result<FilterResponse, String> {
|
||||
let response = get_http_response(&w, response_id)
|
||||
.await
|
||||
.expect("Failed to get response");
|
||||
@@ -746,7 +746,6 @@ async fn cmd_filter_response(
|
||||
.await
|
||||
.run_filter(filter, &body, &content_type)
|
||||
.await
|
||||
.map(|r| r.items)
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ pub async fn upsert_workspace(window: &WebviewWindow, workspace: Workspace) -> R
|
||||
CurrentTimestamp.into(),
|
||||
trimmed_name.into(),
|
||||
workspace.description.into(),
|
||||
serde_json::to_string(&workspace.variables).unwrap().into(),
|
||||
serde_json::to_string(&workspace.variables)?.into(),
|
||||
workspace.setting_request_timeout.into(),
|
||||
workspace.setting_follow_redirects.into(),
|
||||
workspace.setting_validate_certificates.into(),
|
||||
@@ -350,10 +350,8 @@ pub async fn upsert_grpc_request(
|
||||
.as_ref()
|
||||
.map(|s| s.as_str())
|
||||
.into(),
|
||||
serde_json::to_string(&request.authentication)
|
||||
.unwrap()
|
||||
.into(),
|
||||
serde_json::to_string(&request.metadata).unwrap().into(),
|
||||
serde_json::to_string(&request.authentication)?.into(),
|
||||
serde_json::to_string(&request.metadata)?.into(),
|
||||
])
|
||||
.on_conflict(
|
||||
OnConflict::column(GrpcRequestIden::Id)
|
||||
@@ -447,7 +445,7 @@ pub async fn upsert_grpc_connection(
|
||||
connection.elapsed.into(),
|
||||
connection.status.into(),
|
||||
connection.error.as_ref().map(|s| s.as_str()).into(),
|
||||
serde_json::to_string(&connection.trailers).unwrap().into(),
|
||||
serde_json::to_string(&connection.trailers)?.into(),
|
||||
connection.url.as_str().into(),
|
||||
])
|
||||
.on_conflict(
|
||||
@@ -555,8 +553,8 @@ pub async fn upsert_grpc_event(window: &WebviewWindow, event: &GrpcEvent) -> Res
|
||||
event.request_id.as_str().into(),
|
||||
event.connection_id.as_str().into(),
|
||||
event.content.as_str().into(),
|
||||
serde_json::to_string(&event.event_type).unwrap().into(),
|
||||
serde_json::to_string(&event.metadata).unwrap().into(),
|
||||
serde_json::to_string(&event.event_type)?.into(),
|
||||
serde_json::to_string(&event.metadata)?.into(),
|
||||
event.status.into(),
|
||||
event.error.as_ref().map(|s| s.as_str()).into(),
|
||||
])
|
||||
@@ -639,7 +637,7 @@ pub async fn upsert_cookie_jar(
|
||||
CurrentTimestamp.into(),
|
||||
cookie_jar.workspace_id.as_str().into(),
|
||||
trimmed_name.into(),
|
||||
serde_json::to_string(&cookie_jar.cookies).unwrap().into(),
|
||||
serde_json::to_string(&cookie_jar.cookies)?.into(),
|
||||
])
|
||||
.on_conflict(
|
||||
OnConflict::column(GrpcEventIden::Id)
|
||||
@@ -681,7 +679,7 @@ pub async fn delete_environment(window: &WebviewWindow, id: &str) -> Result<Envi
|
||||
|
||||
let dbm = &*window.app_handle().state::<SqliteConnection>();
|
||||
let db = dbm.0.lock().await.get().unwrap();
|
||||
|
||||
|
||||
let (sql, params) = Query::delete()
|
||||
.from_table(EnvironmentIden::Table)
|
||||
.cond_where(Expr::col(EnvironmentIden::Id).eq(id))
|
||||
@@ -807,9 +805,7 @@ pub async fn upsert_environment(
|
||||
CurrentTimestamp.into(),
|
||||
environment.workspace_id.as_str().into(),
|
||||
trimmed_name.into(),
|
||||
serde_json::to_string(&environment.variables)
|
||||
.unwrap()
|
||||
.into(),
|
||||
serde_json::to_string(&environment.variables)?.into(),
|
||||
])
|
||||
.on_conflict(
|
||||
OnConflict::column(GrpcEventIden::Id)
|
||||
@@ -871,7 +867,7 @@ pub async fn list_folders(mgr: &impl Manager<Wry>, workspace_id: &str) -> Result
|
||||
|
||||
pub async fn delete_folder(window: &WebviewWindow, id: &str) -> Result<Folder> {
|
||||
let folder = get_folder(window, id).await?;
|
||||
|
||||
|
||||
let dbm = &*window.app_handle().state::<SqliteConnection>();
|
||||
let db = dbm.0.lock().await.get().unwrap();
|
||||
|
||||
@@ -975,13 +971,13 @@ pub async fn upsert_http_request(window: &WebviewWindow, r: HttpRequest) -> Resu
|
||||
r.folder_id.as_ref().map(|s| s.as_str()).into(),
|
||||
trimmed_name.into(),
|
||||
r.url.as_str().into(),
|
||||
serde_json::to_string(&r.url_parameters).unwrap().into(),
|
||||
serde_json::to_string(&r.url_parameters)?.into(),
|
||||
r.method.as_str().into(),
|
||||
serde_json::to_string(&r.body).unwrap().into(),
|
||||
serde_json::to_string(&r.body)?.into(),
|
||||
r.body_type.as_ref().map(|s| s.as_str()).into(),
|
||||
serde_json::to_string(&r.authentication).unwrap().into(),
|
||||
serde_json::to_string(&r.authentication)?.into(),
|
||||
r.authentication_type.as_ref().map(|s| s.as_str()).into(),
|
||||
serde_json::to_string(&r.headers).unwrap().into(),
|
||||
serde_json::to_string(&r.headers)?.into(),
|
||||
r.sort_priority.into(),
|
||||
])
|
||||
.on_conflict(
|
||||
@@ -1110,7 +1106,7 @@ pub async fn create_http_response(
|
||||
status_reason.into(),
|
||||
content_length.into(),
|
||||
body_path.into(),
|
||||
serde_json::to_string(&headers).unwrap().into(),
|
||||
serde_json::to_string(&headers)?.into(),
|
||||
version.into(),
|
||||
remote_addr.into(),
|
||||
])
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use ts_rs::TS;
|
||||
|
||||
use yaak_models::models::{Environment, Folder, GrpcConnection, GrpcEvent, GrpcRequest, HttpRequest, HttpResponse, KeyValue, Workspace};
|
||||
@@ -79,7 +78,7 @@ pub struct FilterRequest {
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct FilterResponse {
|
||||
pub items: Vec<Value>,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod error;
|
||||
mod events;
|
||||
pub mod events;
|
||||
pub mod manager;
|
||||
mod nodejs;
|
||||
pub mod plugin;
|
||||
|
||||
Reference in New Issue
Block a user