mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 08:48:26 +02:00
Fix xpath filtering
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -26,7 +26,7 @@
|
|||||||
"@tauri-apps/plugin-fs": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-fs": "^2.0.0-rc.0",
|
||||||
"@tauri-apps/plugin-os": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-os": "^2.0.0-rc.0",
|
||||||
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
|
||||||
"@yaakapp/api": "^0.1.2",
|
"@yaakapp/api": "^0.1.3",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
"cm6-graphql": "^0.0.9",
|
"cm6-graphql": "^0.0.9",
|
||||||
@@ -2981,9 +2981,9 @@
|
|||||||
"integrity": "sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ=="
|
"integrity": "sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@yaakapp/api": {
|
"node_modules/@yaakapp/api": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.3.tgz",
|
||||||
"integrity": "sha512-VEs+H9ZJjp/MFHKbqTdG/eGtvjDZ36P1pmzEYm6VYGIN2Bfw3OyXzkn7vgIg1savX0LU/U5kI88AYXGMr5Fjdw==",
|
"integrity": "sha512-y5zYlyfJkO2bqDRBZFB6DCI+MJzDIjslnApsiW6F0fQHa4QP/gGXEbpjBRa32O4K/CfjziGBpW/yAzYuwBCYDQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^22.0.0"
|
"@types/node": "^22.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
"@tauri-apps/plugin-fs": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-fs": "^2.0.0-rc.0",
|
||||||
"@tauri-apps/plugin-os": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-os": "^2.0.0-rc.0",
|
||||||
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
|
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
|
||||||
"@yaakapp/api": "^0.1.2",
|
"@yaakapp/api": "^0.1.3",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.3.2",
|
||||||
"cm6-graphql": "^0.0.9",
|
"cm6-graphql": "^0.0.9",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@yaakapp/api",
|
"name": "@yaakapp/api",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "./lib/index.d.ts",
|
"typings": "./lib/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { JsonValue } from "./serde_json/JsonValue";
|
|
||||||
|
|
||||||
export type FilterResponse = { items: Array<JsonValue>, };
|
export type FilterResponse = { content: string, };
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
||||||
|
|
||||||
export type JsonValue = number | string | Array<JsonValue> | { [key: string]: JsonValue };
|
|
||||||
@@ -81,7 +81,7 @@ new Promise<void>(async (resolve, reject) => {
|
|||||||
);
|
);
|
||||||
const replyPayload: InternalEventPayload = {
|
const replyPayload: InternalEventPayload = {
|
||||||
type: 'filter_response',
|
type: 'filter_response',
|
||||||
items: JSON.parse(reply),
|
content: reply,
|
||||||
};
|
};
|
||||||
sendToServer({ id: genId(), pluginRefId, replyId, payload: replyPayload });
|
sendToServer({ id: genId(), pluginRefId, replyId, payload: replyPayload });
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ use yaak_models::queries::{
|
|||||||
upsert_cookie_jar, upsert_environment, upsert_folder, upsert_grpc_connection,
|
upsert_cookie_jar, upsert_environment, upsert_folder, upsert_grpc_connection,
|
||||||
upsert_grpc_event, upsert_grpc_request, upsert_http_request, upsert_workspace,
|
upsert_grpc_event, upsert_grpc_request, upsert_http_request, upsert_workspace,
|
||||||
};
|
};
|
||||||
|
use yaak_plugin_runtime::events::FilterResponse;
|
||||||
|
|
||||||
mod analytics;
|
mod analytics;
|
||||||
mod export_resources;
|
mod export_resources;
|
||||||
@@ -720,8 +721,7 @@ async fn cmd_filter_response(
|
|||||||
response_id: &str,
|
response_id: &str,
|
||||||
plugin_manager: State<'_, Mutex<PluginManager>>,
|
plugin_manager: State<'_, Mutex<PluginManager>>,
|
||||||
filter: &str,
|
filter: &str,
|
||||||
) -> Result<Vec<Value>, String> {
|
) -> Result<FilterResponse, String> {
|
||||||
println!("FILTERING? {filter}");
|
|
||||||
let response = get_http_response(&w, response_id)
|
let response = get_http_response(&w, response_id)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to get response");
|
.expect("Failed to get response");
|
||||||
@@ -746,7 +746,6 @@ async fn cmd_filter_response(
|
|||||||
.await
|
.await
|
||||||
.run_filter(filter, &body, &content_type)
|
.run_filter(filter, &body, &content_type)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.items)
|
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ pub async fn upsert_workspace(window: &WebviewWindow, workspace: Workspace) -> R
|
|||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
workspace.description.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_request_timeout.into(),
|
||||||
workspace.setting_follow_redirects.into(),
|
workspace.setting_follow_redirects.into(),
|
||||||
workspace.setting_validate_certificates.into(),
|
workspace.setting_validate_certificates.into(),
|
||||||
@@ -350,10 +350,8 @@ pub async fn upsert_grpc_request(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.as_str())
|
.map(|s| s.as_str())
|
||||||
.into(),
|
.into(),
|
||||||
serde_json::to_string(&request.authentication)
|
serde_json::to_string(&request.authentication)?.into(),
|
||||||
.unwrap()
|
serde_json::to_string(&request.metadata)?.into(),
|
||||||
.into(),
|
|
||||||
serde_json::to_string(&request.metadata).unwrap().into(),
|
|
||||||
])
|
])
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
OnConflict::column(GrpcRequestIden::Id)
|
OnConflict::column(GrpcRequestIden::Id)
|
||||||
@@ -447,7 +445,7 @@ pub async fn upsert_grpc_connection(
|
|||||||
connection.elapsed.into(),
|
connection.elapsed.into(),
|
||||||
connection.status.into(),
|
connection.status.into(),
|
||||||
connection.error.as_ref().map(|s| s.as_str()).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(),
|
connection.url.as_str().into(),
|
||||||
])
|
])
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
@@ -555,8 +553,8 @@ pub async fn upsert_grpc_event(window: &WebviewWindow, event: &GrpcEvent) -> Res
|
|||||||
event.request_id.as_str().into(),
|
event.request_id.as_str().into(),
|
||||||
event.connection_id.as_str().into(),
|
event.connection_id.as_str().into(),
|
||||||
event.content.as_str().into(),
|
event.content.as_str().into(),
|
||||||
serde_json::to_string(&event.event_type).unwrap().into(),
|
serde_json::to_string(&event.event_type)?.into(),
|
||||||
serde_json::to_string(&event.metadata).unwrap().into(),
|
serde_json::to_string(&event.metadata)?.into(),
|
||||||
event.status.into(),
|
event.status.into(),
|
||||||
event.error.as_ref().map(|s| s.as_str()).into(),
|
event.error.as_ref().map(|s| s.as_str()).into(),
|
||||||
])
|
])
|
||||||
@@ -639,7 +637,7 @@ pub async fn upsert_cookie_jar(
|
|||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
cookie_jar.workspace_id.as_str().into(),
|
cookie_jar.workspace_id.as_str().into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
serde_json::to_string(&cookie_jar.cookies).unwrap().into(),
|
serde_json::to_string(&cookie_jar.cookies)?.into(),
|
||||||
])
|
])
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
OnConflict::column(GrpcEventIden::Id)
|
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 dbm = &*window.app_handle().state::<SqliteConnection>();
|
||||||
let db = dbm.0.lock().await.get().unwrap();
|
let db = dbm.0.lock().await.get().unwrap();
|
||||||
|
|
||||||
let (sql, params) = Query::delete()
|
let (sql, params) = Query::delete()
|
||||||
.from_table(EnvironmentIden::Table)
|
.from_table(EnvironmentIden::Table)
|
||||||
.cond_where(Expr::col(EnvironmentIden::Id).eq(id))
|
.cond_where(Expr::col(EnvironmentIden::Id).eq(id))
|
||||||
@@ -807,9 +805,7 @@ pub async fn upsert_environment(
|
|||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
environment.workspace_id.as_str().into(),
|
environment.workspace_id.as_str().into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
serde_json::to_string(&environment.variables)
|
serde_json::to_string(&environment.variables)?.into(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
])
|
])
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
OnConflict::column(GrpcEventIden::Id)
|
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> {
|
pub async fn delete_folder(window: &WebviewWindow, id: &str) -> Result<Folder> {
|
||||||
let folder = get_folder(window, id).await?;
|
let folder = get_folder(window, id).await?;
|
||||||
|
|
||||||
let dbm = &*window.app_handle().state::<SqliteConnection>();
|
let dbm = &*window.app_handle().state::<SqliteConnection>();
|
||||||
let db = dbm.0.lock().await.get().unwrap();
|
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(),
|
r.folder_id.as_ref().map(|s| s.as_str()).into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
r.url.as_str().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(),
|
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(),
|
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(),
|
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(),
|
r.sort_priority.into(),
|
||||||
])
|
])
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
@@ -1110,7 +1106,7 @@ pub async fn create_http_response(
|
|||||||
status_reason.into(),
|
status_reason.into(),
|
||||||
content_length.into(),
|
content_length.into(),
|
||||||
body_path.into(),
|
body_path.into(),
|
||||||
serde_json::to_string(&headers).unwrap().into(),
|
serde_json::to_string(&headers)?.into(),
|
||||||
version.into(),
|
version.into(),
|
||||||
remote_addr.into(),
|
remote_addr.into(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
use yaak_models::models::{Environment, Folder, GrpcConnection, GrpcEvent, GrpcRequest, HttpRequest, HttpResponse, KeyValue, Workspace};
|
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")]
|
#[serde(default, rename_all = "camelCase")]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
pub struct FilterResponse {
|
pub struct FilterResponse {
|
||||||
pub items: Vec<Value>,
|
pub content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
pub mod error;
|
pub mod error;
|
||||||
mod events;
|
pub mod events;
|
||||||
pub mod manager;
|
pub mod manager;
|
||||||
mod nodejs;
|
mod nodejs;
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function useCreateHttpRequest() {
|
|||||||
if (patch.sortPriority === undefined) {
|
if (patch.sortPriority === undefined) {
|
||||||
if (activeRequest != null) {
|
if (activeRequest != null) {
|
||||||
// Place above currently-active request
|
// Place above currently-active request
|
||||||
patch.sortPriority = activeRequest.sortPriority + 0.0001;
|
patch.sortPriority = activeRequest.sortPriority - 0.0001;
|
||||||
} else {
|
} else {
|
||||||
// Place at the very top
|
// Place at the very top
|
||||||
patch.sortPriority = -Date.now();
|
patch.sortPriority = -Date.now();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import type { JsonValue } from '@yaakapp/api/lib/gen/serde_json/JsonValue';
|
import type { FilterResponse } from '@yaakapp/api';
|
||||||
import { invokeCmd } from '../lib/tauri';
|
import { invokeCmd } from '../lib/tauri';
|
||||||
|
|
||||||
export function useFilterResponse({
|
export function useFilterResponse({
|
||||||
@@ -16,8 +16,12 @@ export function useFilterResponse({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = (await invokeCmd('cmd_filter_response', { responseId, filter })) as JsonValue[];
|
const result = (await invokeCmd('cmd_filter_response', {
|
||||||
return JSON.stringify(items, null, 2);
|
responseId,
|
||||||
|
filter,
|
||||||
|
})) as FilterResponse;
|
||||||
|
|
||||||
|
return result.content;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user