mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-20 07:51:20 +02:00
Fix editor selection/cursor and lint errors
This commit is contained in:
1356
package-lock.json
generated
1356
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,6 @@
|
|||||||
"cm6-graphql": "^0.0.9",
|
"cm6-graphql": "^0.0.9",
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"codemirror-json-schema": "^0.6.1",
|
"codemirror-json-schema": "^0.6.1",
|
||||||
"codemirror-json5": "^1.0.3",
|
|
||||||
"date-fns": "^3.3.1",
|
"date-fns": "^3.3.1",
|
||||||
"focus-trap-react": "^10.1.1",
|
"focus-trap-react": "^10.1.1",
|
||||||
"format-graphql": "^1.4.0",
|
"format-graphql": "^1.4.0",
|
||||||
@@ -94,7 +93,7 @@
|
|||||||
"react-devtools": "^4.28.5",
|
"react-devtools": "^4.28.5",
|
||||||
"tailwindcss": "^3.2.7",
|
"tailwindcss": "^3.2.7",
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.0.2",
|
||||||
"vite": "^4.0.0",
|
"vite": "^5.1.1",
|
||||||
"vite-plugin-svgr": "^2.4.0",
|
"vite-plugin-svgr": "^2.4.0",
|
||||||
"vite-plugin-top-level-await": "^1.2.4",
|
"vite-plugin-top-level-await": "^1.2.4",
|
||||||
"vitest": "^0.29.2"
|
"vitest": "^0.29.2"
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ use log::{error, info, warn};
|
|||||||
use reqwest::redirect::Policy;
|
use reqwest::redirect::Policy;
|
||||||
use reqwest::{multipart, Url};
|
use reqwest::{multipart, Url};
|
||||||
use sqlx::types::{Json, JsonValue};
|
use sqlx::types::{Json, JsonValue};
|
||||||
use tauri::AppHandle;
|
use tauri::{Manager, Window};
|
||||||
|
|
||||||
use crate::{models, render, response_err};
|
use crate::{models, render, response_err};
|
||||||
|
|
||||||
pub async fn send_http_request(
|
pub async fn send_http_request(
|
||||||
app_handle: &AppHandle,
|
window: &Window,
|
||||||
request: models::HttpRequest,
|
request: models::HttpRequest,
|
||||||
response: &models::HttpResponse,
|
response: &models::HttpResponse,
|
||||||
environment: Option<models::Environment>,
|
environment: Option<models::Environment>,
|
||||||
@@ -26,7 +26,7 @@ pub async fn send_http_request(
|
|||||||
download_path: Option<PathBuf>,
|
download_path: Option<PathBuf>,
|
||||||
) -> Result<models::HttpResponse, String> {
|
) -> Result<models::HttpResponse, String> {
|
||||||
let environment_ref = environment.as_ref();
|
let environment_ref = environment.as_ref();
|
||||||
let workspace = models::get_workspace(app_handle, &request.workspace_id)
|
let workspace = models::get_workspace(window, &request.workspace_id)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to get Workspace");
|
.expect("Failed to get Workspace");
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ pub async fn send_http_request(
|
|||||||
let url = match Url::from_str(url_string.as_str()) {
|
let url = match Url::from_str(url_string.as_str()) {
|
||||||
Ok(u) => u,
|
Ok(u) => u,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return response_err(response, e.to_string(), app_handle).await;
|
return response_err(response, e.to_string(), window).await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ pub async fn send_http_request(
|
|||||||
let sendable_req = match request_builder.build() {
|
let sendable_req = match request_builder.build() {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return response_err(response, e.to_string(), app_handle).await;
|
return response_err(response, e.to_string(), window).await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ pub async fn send_http_request(
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Write body to FS
|
// Write body to FS
|
||||||
let dir = app_handle.path_resolver().app_data_dir().unwrap();
|
let dir = window.app_handle().path_resolver().app_data_dir().unwrap();
|
||||||
let base_dir = dir.join("responses");
|
let base_dir = dir.join("responses");
|
||||||
create_dir_all(base_dir.clone()).expect("Failed to create responses dir");
|
create_dir_all(base_dir.clone()).expect("Failed to create responses dir");
|
||||||
let body_path = match response.id.is_empty() {
|
let body_path = match response.id.is_empty() {
|
||||||
@@ -360,7 +360,7 @@ pub async fn send_http_request(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
response = models::update_response_if_id(app_handle, &response)
|
response = models::update_response_if_id(window, &response)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to update response");
|
.expect("Failed to update response");
|
||||||
|
|
||||||
@@ -392,13 +392,13 @@ pub async fn send_http_request(
|
|||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
cookie_jar.cookies = json_cookies;
|
cookie_jar.cookies = json_cookies;
|
||||||
if let Err(e) = models::upsert_cookie_jar(&app_handle, &cookie_jar).await {
|
if let Err(e) = models::upsert_cookie_jar(window, &cookie_jar).await {
|
||||||
error!("Failed to update cookie jar: {}", e);
|
error!("Failed to update cookie jar: {}", e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
Err(e) => response_err(response, e.to_string(), app_handle).await,
|
Err(e) => response_err(response, e.to_string(), window).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use sqlx::types::chrono::NaiveDateTime;
|
use sqlx::types::chrono::NaiveDateTime;
|
||||||
use sqlx::types::{Json, JsonValue};
|
use sqlx::types::{Json, JsonValue};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager, Wry};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
fn default_true() -> bool {
|
fn default_true() -> bool {
|
||||||
@@ -260,32 +260,32 @@ pub struct KeyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_key_value_string(
|
pub async fn set_key_value_string(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> (KeyValue, bool) {
|
) -> (KeyValue, bool) {
|
||||||
let encoded = serde_json::to_string(value);
|
let encoded = serde_json::to_string(value);
|
||||||
set_key_value_raw(app_handle, namespace, key, &encoded.unwrap()).await
|
set_key_value_raw(mgr, namespace, key, &encoded.unwrap()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_key_value_int(
|
pub async fn set_key_value_int(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
value: i32,
|
value: i32,
|
||||||
) -> (KeyValue, bool) {
|
) -> (KeyValue, bool) {
|
||||||
let encoded = serde_json::to_string(&value);
|
let encoded = serde_json::to_string(&value);
|
||||||
set_key_value_raw(app_handle, namespace, key, &encoded.unwrap()).await
|
set_key_value_raw(mgr, namespace, key, &encoded.unwrap()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_key_value_string(
|
pub async fn get_key_value_string(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
default: &str,
|
default: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
match get_key_value_raw(app_handle, namespace, key).await {
|
match get_key_value_raw(mgr, namespace, key).await {
|
||||||
None => default.to_string(),
|
None => default.to_string(),
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let result = serde_json::from_str(&v.value);
|
let result = serde_json::from_str(&v.value);
|
||||||
@@ -301,12 +301,12 @@ pub async fn get_key_value_string(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_key_value_int(
|
pub async fn get_key_value_int(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
default: i32,
|
default: i32,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
match get_key_value_raw(app_handle, namespace, key).await {
|
match get_key_value_raw(mgr, namespace, key).await {
|
||||||
None => default.clone(),
|
None => default.clone(),
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let result = serde_json::from_str(&v.value);
|
let result = serde_json::from_str(&v.value);
|
||||||
@@ -322,13 +322,13 @@ pub async fn get_key_value_int(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_key_value_raw(
|
pub async fn set_key_value_raw(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> (KeyValue, bool) {
|
) -> (KeyValue, bool) {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let existing = get_key_value_raw(app_handle, namespace, key).await;
|
let existing = get_key_value_raw(mgr, namespace, key).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO key_values (namespace, key, value)
|
INSERT INTO key_values (namespace, key, value)
|
||||||
@@ -344,18 +344,18 @@ pub async fn set_key_value_raw(
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to insert key value");
|
.expect("Failed to insert key value");
|
||||||
|
|
||||||
let kv = get_key_value_raw(app_handle, namespace, key)
|
let kv = get_key_value_raw(mgr, namespace, key)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to get key value");
|
.expect("Failed to get key value");
|
||||||
(kv, existing.is_none())
|
(kv, existing.is_none())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_key_value_raw(
|
pub async fn get_key_value_raw(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
namespace: &str,
|
namespace: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Option<KeyValue> {
|
) -> Option<KeyValue> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
KeyValue,
|
KeyValue,
|
||||||
r#"
|
r#"
|
||||||
@@ -371,8 +371,8 @@ pub async fn get_key_value_raw(
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_workspaces(app_handle: &AppHandle) -> Result<Vec<Workspace>, sqlx::Error> {
|
pub async fn list_workspaces(mgr: &impl Manager<Wry>) -> Result<Vec<Workspace>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Workspace,
|
Workspace,
|
||||||
r#"
|
r#"
|
||||||
@@ -387,8 +387,8 @@ pub async fn list_workspaces(app_handle: &AppHandle) -> Result<Vec<Workspace>, s
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_workspace(app_handle: &AppHandle, id: &str) -> Result<Workspace, sqlx::Error> {
|
pub async fn get_workspace(mgr: &impl Manager<Wry>, id: &str) -> Result<Workspace, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Workspace,
|
Workspace,
|
||||||
r#"
|
r#"
|
||||||
@@ -404,9 +404,9 @@ pub async fn get_workspace(app_handle: &AppHandle, id: &str) -> Result<Workspace
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_workspace(app_handle: &AppHandle, id: &str) -> Result<Workspace, sqlx::Error> {
|
pub async fn delete_workspace(mgr: &impl Manager<Wry>, id: &str) -> Result<Workspace, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let workspace = get_workspace(app_handle, id).await?;
|
let workspace = get_workspace(mgr, id).await?;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM workspaces
|
DELETE FROM workspaces
|
||||||
@@ -417,15 +417,15 @@ pub async fn delete_workspace(app_handle: &AppHandle, id: &str) -> Result<Worksp
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
for r in list_responses_by_workspace_id(app_handle, id).await? {
|
for r in list_responses_by_workspace_id(mgr, id).await? {
|
||||||
delete_http_response(app_handle, &r.id).await?;
|
delete_http_response(mgr, &r.id).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_deleted_model(app_handle, workspace)
|
emit_deleted_model(mgr, workspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_cookie_jar(app_handle: &AppHandle, id: &str) -> Result<CookieJar, sqlx::Error> {
|
pub async fn get_cookie_jar(mgr: &impl Manager<Wry>, id: &str) -> Result<CookieJar, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
CookieJar,
|
CookieJar,
|
||||||
r#"
|
r#"
|
||||||
@@ -441,10 +441,10 @@ pub async fn get_cookie_jar(app_handle: &AppHandle, id: &str) -> Result<CookieJa
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_cookie_jars(
|
pub async fn list_cookie_jars(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<CookieJar>, sqlx::Error> {
|
) -> Result<Vec<CookieJar>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
CookieJar,
|
CookieJar,
|
||||||
r#"
|
r#"
|
||||||
@@ -459,9 +459,12 @@ pub async fn list_cookie_jars(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_cookie_jar(app_handle: &AppHandle, id: &str) -> Result<CookieJar, sqlx::Error> {
|
pub async fn delete_cookie_jar(
|
||||||
let cookie_jar = get_cookie_jar(app_handle, id).await?;
|
mgr: &impl Manager<Wry>,
|
||||||
let db = get_db(app_handle).await;
|
id: &str,
|
||||||
|
) -> Result<CookieJar, sqlx::Error> {
|
||||||
|
let cookie_jar = get_cookie_jar(mgr, id).await?;
|
||||||
|
let db = get_db(mgr).await;
|
||||||
|
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
@@ -473,23 +476,23 @@ pub async fn delete_cookie_jar(app_handle: &AppHandle, id: &str) -> Result<Cooki
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, cookie_jar)
|
emit_deleted_model(mgr, cookie_jar)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn duplicate_grpc_request(
|
pub async fn duplicate_grpc_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcRequest, sqlx::Error> {
|
) -> Result<GrpcRequest, sqlx::Error> {
|
||||||
let mut request = get_grpc_request(app_handle, id).await?.clone();
|
let mut request = get_grpc_request(mgr, id).await?.clone();
|
||||||
request.id = "".to_string();
|
request.id = "".to_string();
|
||||||
upsert_grpc_request(app_handle, &request).await
|
upsert_grpc_request(mgr, &request).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_grpc_request(
|
pub async fn upsert_grpc_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request: &GrpcRequest,
|
request: &GrpcRequest,
|
||||||
) -> Result<GrpcRequest, sqlx::Error> {
|
) -> Result<GrpcRequest, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let id = match request.id.as_str() {
|
let id = match request.id.as_str() {
|
||||||
"" => generate_id(Some("gr")),
|
"" => generate_id(Some("gr")),
|
||||||
_ => request.id.to_string(),
|
_ => request.id.to_string(),
|
||||||
@@ -527,17 +530,17 @@ pub async fn upsert_grpc_request(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_grpc_request(app_handle, &id).await {
|
match get_grpc_request(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_grpc_request(
|
pub async fn get_grpc_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcRequest, sqlx::Error> {
|
) -> Result<GrpcRequest, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcRequest,
|
GrpcRequest,
|
||||||
r#"
|
r#"
|
||||||
@@ -555,10 +558,10 @@ pub async fn get_grpc_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_grpc_requests(
|
pub async fn list_grpc_requests(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<GrpcRequest>, sqlx::Error> {
|
) -> Result<Vec<GrpcRequest>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcRequest,
|
GrpcRequest,
|
||||||
r#"
|
r#"
|
||||||
@@ -576,10 +579,10 @@ pub async fn list_grpc_requests(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_grpc_connection(
|
pub async fn upsert_grpc_connection(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
connection: &GrpcConnection,
|
connection: &GrpcConnection,
|
||||||
) -> Result<GrpcConnection, sqlx::Error> {
|
) -> Result<GrpcConnection, sqlx::Error> {
|
||||||
let db = get_db(&app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let id = match connection.id.as_str() {
|
let id = match connection.id.as_str() {
|
||||||
"" => generate_id(Some("gc")),
|
"" => generate_id(Some("gc")),
|
||||||
_ => connection.id.to_string(),
|
_ => connection.id.to_string(),
|
||||||
@@ -606,17 +609,17 @@ pub async fn upsert_grpc_connection(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_grpc_connection(app_handle, &id).await {
|
match get_grpc_connection(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_grpc_connection(
|
pub async fn get_grpc_connection(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcConnection, sqlx::Error> {
|
) -> Result<GrpcConnection, sqlx::Error> {
|
||||||
let db = get_db(&app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcConnection,
|
GrpcConnection,
|
||||||
r#"
|
r#"
|
||||||
@@ -633,10 +636,10 @@ pub async fn get_grpc_connection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_grpc_connections(
|
pub async fn list_grpc_connections(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
) -> Result<Vec<GrpcConnection>, sqlx::Error> {
|
) -> Result<Vec<GrpcConnection>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcConnection,
|
GrpcConnection,
|
||||||
r#"
|
r#"
|
||||||
@@ -654,10 +657,10 @@ pub async fn list_grpc_connections(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_grpc_message(
|
pub async fn upsert_grpc_message(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
message: &GrpcMessage,
|
message: &GrpcMessage,
|
||||||
) -> Result<GrpcMessage, sqlx::Error> {
|
) -> Result<GrpcMessage, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let id = match message.id.as_str() {
|
let id = match message.id.as_str() {
|
||||||
"" => generate_id(Some("gm")),
|
"" => generate_id(Some("gm")),
|
||||||
_ => message.id.to_string(),
|
_ => message.id.to_string(),
|
||||||
@@ -685,17 +688,17 @@ pub async fn upsert_grpc_message(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_grpc_message(app_handle, &id).await {
|
match get_grpc_message(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_grpc_message(
|
pub async fn get_grpc_message(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcMessage, sqlx::Error> {
|
) -> Result<GrpcMessage, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcMessage,
|
GrpcMessage,
|
||||||
r#"
|
r#"
|
||||||
@@ -712,10 +715,10 @@ pub async fn get_grpc_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_grpc_messages(
|
pub async fn list_grpc_messages(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
connection_id: &str,
|
connection_id: &str,
|
||||||
) -> Result<Vec<GrpcMessage>, sqlx::Error> {
|
) -> Result<Vec<GrpcMessage>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
GrpcMessage,
|
GrpcMessage,
|
||||||
r#"
|
r#"
|
||||||
@@ -732,7 +735,7 @@ pub async fn list_grpc_messages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_cookie_jar(
|
pub async fn upsert_cookie_jar(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
cookie_jar: &CookieJar,
|
cookie_jar: &CookieJar,
|
||||||
) -> Result<CookieJar, sqlx::Error> {
|
) -> Result<CookieJar, sqlx::Error> {
|
||||||
let id = match cookie_jar.id.as_str() {
|
let id = match cookie_jar.id.as_str() {
|
||||||
@@ -741,7 +744,7 @@ pub async fn upsert_cookie_jar(
|
|||||||
};
|
};
|
||||||
let trimmed_name = cookie_jar.name.trim();
|
let trimmed_name = cookie_jar.name.trim();
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO cookie_jars (
|
INSERT INTO cookie_jars (
|
||||||
@@ -761,17 +764,17 @@ pub async fn upsert_cookie_jar(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_cookie_jar(app_handle, &id).await {
|
match get_cookie_jar(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_environments(
|
pub async fn list_environments(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<Environment>, sqlx::Error> {
|
) -> Result<Vec<Environment>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Environment,
|
Environment,
|
||||||
r#"
|
r#"
|
||||||
@@ -787,11 +790,11 @@ pub async fn list_environments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_environment(
|
pub async fn delete_environment(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<Environment, sqlx::Error> {
|
) -> Result<Environment, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let env = get_environment(app_handle, id).await?;
|
let env = get_environment(mgr, id).await?;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM environments
|
DELETE FROM environments
|
||||||
@@ -802,11 +805,11 @@ pub async fn delete_environment(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, env)
|
emit_deleted_model(mgr, env)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_settings(app_handle: &AppHandle) -> Result<Settings, sqlx::Error> {
|
async fn get_settings(mgr: &impl Manager<Wry>) -> Result<Settings, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Settings,
|
Settings,
|
||||||
r#"
|
r#"
|
||||||
@@ -820,12 +823,12 @@ async fn get_settings(app_handle: &AppHandle) -> Result<Settings, sqlx::Error> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_or_create_settings(app_handle: &AppHandle) -> Settings {
|
pub async fn get_or_create_settings(mgr: &impl Manager<Wry>) -> Settings {
|
||||||
if let Ok(settings) = get_settings(app_handle).await {
|
if let Ok(settings) = get_settings(mgr).await {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO settings (id)
|
INSERT INTO settings (id)
|
||||||
@@ -836,16 +839,14 @@ pub async fn get_or_create_settings(app_handle: &AppHandle) -> Settings {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to insert settings");
|
.expect("Failed to insert settings");
|
||||||
|
|
||||||
get_settings(&app_handle)
|
get_settings(mgr).await.expect("Failed to get settings")
|
||||||
.await
|
|
||||||
.expect("Failed to get settings")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_settings(
|
pub async fn update_settings(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
) -> Result<Settings, sqlx::Error> {
|
) -> Result<Settings, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
UPDATE settings SET (
|
UPDATE settings SET (
|
||||||
@@ -859,14 +860,14 @@ pub async fn update_settings(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_settings(app_handle).await {
|
match get_settings(mgr).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_environment(
|
pub async fn upsert_environment(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
environment: Environment,
|
environment: Environment,
|
||||||
) -> Result<Environment, sqlx::Error> {
|
) -> Result<Environment, sqlx::Error> {
|
||||||
let id = match environment.id.as_str() {
|
let id = match environment.id.as_str() {
|
||||||
@@ -874,7 +875,7 @@ pub async fn upsert_environment(
|
|||||||
_ => environment.id.to_string(),
|
_ => environment.id.to_string(),
|
||||||
};
|
};
|
||||||
let trimmed_name = environment.name.trim();
|
let trimmed_name = environment.name.trim();
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO environments (
|
INSERT INTO environments (
|
||||||
@@ -894,14 +895,17 @@ pub async fn upsert_environment(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_environment(app_handle, &id).await {
|
match get_environment(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_environment(app_handle: &AppHandle, id: &str) -> Result<Environment, sqlx::Error> {
|
pub async fn get_environment(
|
||||||
let db = get_db(app_handle).await;
|
mgr: &impl Manager<Wry>,
|
||||||
|
id: &str,
|
||||||
|
) -> Result<Environment, sqlx::Error> {
|
||||||
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Environment,
|
Environment,
|
||||||
r#"
|
r#"
|
||||||
@@ -917,8 +921,8 @@ pub async fn get_environment(app_handle: &AppHandle, id: &str) -> Result<Environ
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_folder(app_handle: &AppHandle, id: &str) -> Result<Folder, sqlx::Error> {
|
pub async fn get_folder(mgr: &impl Manager<Wry>, id: &str) -> Result<Folder, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Folder,
|
Folder,
|
||||||
r#"
|
r#"
|
||||||
@@ -934,10 +938,10 @@ pub async fn get_folder(app_handle: &AppHandle, id: &str) -> Result<Folder, sqlx
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_folders(
|
pub async fn list_folders(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<Folder>, sqlx::Error> {
|
) -> Result<Vec<Folder>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Folder,
|
Folder,
|
||||||
r#"
|
r#"
|
||||||
@@ -952,9 +956,9 @@ pub async fn list_folders(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_folder(app_handle: &AppHandle, id: &str) -> Result<Folder, sqlx::Error> {
|
pub async fn delete_folder(mgr: &impl Manager<Wry>, id: &str) -> Result<Folder, sqlx::Error> {
|
||||||
let folder = get_folder(app_handle, id).await?;
|
let folder = get_folder(mgr, id).await?;
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM folders
|
DELETE FROM folders
|
||||||
@@ -965,17 +969,17 @@ pub async fn delete_folder(app_handle: &AppHandle, id: &str) -> Result<Folder, s
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, folder)
|
emit_deleted_model(mgr, folder)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_folder(app_handle: &AppHandle, r: Folder) -> Result<Folder, sqlx::Error> {
|
pub async fn upsert_folder(mgr: &impl Manager<Wry>, r: Folder) -> Result<Folder, sqlx::Error> {
|
||||||
let id = match r.id.as_str() {
|
let id = match r.id.as_str() {
|
||||||
"" => generate_id(Some("fl")),
|
"" => generate_id(Some("fl")),
|
||||||
_ => r.id.to_string(),
|
_ => r.id.to_string(),
|
||||||
};
|
};
|
||||||
let trimmed_name = r.name.trim();
|
let trimmed_name = r.name.trim();
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO folders (
|
INSERT INTO folders (
|
||||||
@@ -997,23 +1001,23 @@ pub async fn upsert_folder(app_handle: &AppHandle, r: Folder) -> Result<Folder,
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_folder(app_handle, &id).await {
|
match get_folder(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn duplicate_http_request(
|
pub async fn duplicate_http_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<HttpRequest, sqlx::Error> {
|
) -> Result<HttpRequest, sqlx::Error> {
|
||||||
let mut request = get_http_request(app_handle, id).await?.clone();
|
let mut request = get_http_request(mgr, id).await?.clone();
|
||||||
request.id = "".to_string();
|
request.id = "".to_string();
|
||||||
upsert_http_request(app_handle, request).await
|
upsert_http_request(mgr, request).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_http_request(
|
pub async fn upsert_http_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
r: HttpRequest,
|
r: HttpRequest,
|
||||||
) -> Result<HttpRequest, sqlx::Error> {
|
) -> Result<HttpRequest, sqlx::Error> {
|
||||||
let id = match r.id.as_str() {
|
let id = match r.id.as_str() {
|
||||||
@@ -1024,7 +1028,7 @@ pub async fn upsert_http_request(
|
|||||||
let auth_json = Json(r.authentication);
|
let auth_json = Json(r.authentication);
|
||||||
let trimmed_name = r.name.trim();
|
let trimmed_name = r.name.trim();
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
@@ -1064,17 +1068,17 @@ pub async fn upsert_http_request(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_http_request(app_handle, &id).await {
|
match get_http_request(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_requests(
|
pub async fn list_requests(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<HttpRequest>, sqlx::Error> {
|
) -> Result<Vec<HttpRequest>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
HttpRequest,
|
HttpRequest,
|
||||||
r#"
|
r#"
|
||||||
@@ -1095,10 +1099,10 @@ pub async fn list_requests(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_http_request(
|
pub async fn get_http_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<HttpRequest, sqlx::Error> {
|
) -> Result<HttpRequest, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
|
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
HttpRequest,
|
HttpRequest,
|
||||||
@@ -1120,15 +1124,15 @@ pub async fn get_http_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_http_request(
|
pub async fn delete_http_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<HttpRequest, sqlx::Error> {
|
) -> Result<HttpRequest, sqlx::Error> {
|
||||||
let req = get_http_request(app_handle, id).await?;
|
let req = get_http_request(mgr, id).await?;
|
||||||
|
|
||||||
// DB deletes will cascade but this will delete the files
|
// DB deletes will cascade but this will delete the files
|
||||||
delete_all_http_responses(app_handle, id).await?;
|
delete_all_http_responses(mgr, id).await?;
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM http_requests
|
DELETE FROM http_requests
|
||||||
@@ -1139,12 +1143,12 @@ pub async fn delete_http_request(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, req)
|
emit_deleted_model(mgr, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn create_response(
|
pub async fn create_response(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
elapsed: i64,
|
elapsed: i64,
|
||||||
elapsed_headers: i64,
|
elapsed_headers: i64,
|
||||||
@@ -1157,10 +1161,10 @@ pub async fn create_response(
|
|||||||
version: Option<&str>,
|
version: Option<&str>,
|
||||||
remote_addr: Option<&str>,
|
remote_addr: Option<&str>,
|
||||||
) -> Result<HttpResponse, sqlx::Error> {
|
) -> Result<HttpResponse, sqlx::Error> {
|
||||||
let req = get_http_request(app_handle, request_id).await?;
|
let req = get_http_request(mgr, request_id).await?;
|
||||||
let id = generate_id(Some("rp"));
|
let id = generate_id(Some("rp"));
|
||||||
let headers_json = Json(headers);
|
let headers_json = Json(headers);
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO http_responses (
|
INSERT INTO http_responses (
|
||||||
@@ -1186,11 +1190,11 @@ pub async fn create_response(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
get_http_response(app_handle, &id).await
|
get_http_response(mgr, &id).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cancel_pending_grpc_connections(app_handle: &AppHandle) -> Result<(), sqlx::Error> {
|
pub async fn cancel_pending_grpc_connections(mgr: &impl Manager<Wry>) -> Result<(), sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
UPDATE grpc_connections
|
UPDATE grpc_connections
|
||||||
@@ -1203,8 +1207,8 @@ pub async fn cancel_pending_grpc_connections(app_handle: &AppHandle) -> Result<(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cancel_pending_responses(app_handle: &AppHandle) -> Result<(), sqlx::Error> {
|
pub async fn cancel_pending_responses(mgr: &impl Manager<Wry>) -> Result<(), sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
UPDATE http_responses
|
UPDATE http_responses
|
||||||
@@ -1218,18 +1222,18 @@ pub async fn cancel_pending_responses(app_handle: &AppHandle) -> Result<(), sqlx
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_response_if_id(
|
pub async fn update_response_if_id(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
response: &HttpResponse,
|
response: &HttpResponse,
|
||||||
) -> Result<HttpResponse, sqlx::Error> {
|
) -> Result<HttpResponse, sqlx::Error> {
|
||||||
if response.id.is_empty() {
|
if response.id.is_empty() {
|
||||||
Ok(response.clone())
|
Ok(response.clone())
|
||||||
} else {
|
} else {
|
||||||
update_response(app_handle, response).await
|
update_response(mgr, response).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_workspace(
|
pub async fn upsert_workspace(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace: Workspace,
|
workspace: Workspace,
|
||||||
) -> Result<Workspace, sqlx::Error> {
|
) -> Result<Workspace, sqlx::Error> {
|
||||||
let id = match workspace.id.as_str() {
|
let id = match workspace.id.as_str() {
|
||||||
@@ -1238,7 +1242,7 @@ pub async fn upsert_workspace(
|
|||||||
};
|
};
|
||||||
let trimmed_name = workspace.name.trim();
|
let trimmed_name = workspace.name.trim();
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO workspaces (
|
INSERT INTO workspaces (
|
||||||
@@ -1266,18 +1270,18 @@ pub async fn upsert_workspace(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_workspace(app_handle, &id).await {
|
match get_workspace(mgr, &id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_response(
|
pub async fn update_response(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
response: &HttpResponse,
|
response: &HttpResponse,
|
||||||
) -> Result<HttpResponse, sqlx::Error> {
|
) -> Result<HttpResponse, sqlx::Error> {
|
||||||
let headers_json = Json(&response.headers);
|
let headers_json = Json(&response.headers);
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
UPDATE http_responses SET (
|
UPDATE http_responses SET (
|
||||||
@@ -1301,17 +1305,17 @@ pub async fn update_response(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match get_http_response(app_handle, &response.id).await {
|
match get_http_response(mgr, &response.id).await {
|
||||||
Ok(m) => Ok(emit_upserted_model(app_handle, m)),
|
Ok(m) => Ok(emit_upserted_model(mgr, m)),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_http_response(
|
pub async fn get_http_response(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<HttpResponse, sqlx::Error> {
|
) -> Result<HttpResponse, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
r#"
|
r#"
|
||||||
@@ -1330,12 +1334,12 @@ pub async fn get_http_response(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_responses(
|
pub async fn list_responses(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
) -> Result<Vec<HttpResponse>, sqlx::Error> {
|
) -> Result<Vec<HttpResponse>, sqlx::Error> {
|
||||||
let limit_unwrapped = limit.unwrap_or_else(|| i64::MAX);
|
let limit_unwrapped = limit.unwrap_or_else(|| i64::MAX);
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
r#"
|
r#"
|
||||||
@@ -1357,10 +1361,10 @@ pub async fn list_responses(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_responses_by_workspace_id(
|
pub async fn list_responses_by_workspace_id(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<HttpResponse>, sqlx::Error> {
|
) -> Result<Vec<HttpResponse>, sqlx::Error> {
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
r#"
|
r#"
|
||||||
@@ -1380,12 +1384,12 @@ pub async fn list_responses_by_workspace_id(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_grpc_request(
|
pub async fn delete_grpc_request(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcRequest, sqlx::Error> {
|
) -> Result<GrpcRequest, sqlx::Error> {
|
||||||
let req = get_grpc_request(app_handle, id).await?;
|
let req = get_grpc_request(mgr, id).await?;
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM grpc_requests
|
DELETE FROM grpc_requests
|
||||||
@@ -1396,16 +1400,16 @@ pub async fn delete_grpc_request(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, req)
|
emit_deleted_model(mgr, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_grpc_connection(
|
pub async fn delete_grpc_connection(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<GrpcConnection, sqlx::Error> {
|
) -> Result<GrpcConnection, sqlx::Error> {
|
||||||
let resp = get_grpc_connection(app_handle, id).await?;
|
let resp = get_grpc_connection(mgr, id).await?;
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM grpc_connections
|
DELETE FROM grpc_connections
|
||||||
@@ -1416,14 +1420,14 @@ pub async fn delete_grpc_connection(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, resp)
|
emit_deleted_model(mgr, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_http_response(
|
pub async fn delete_http_response(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<HttpResponse, sqlx::Error> {
|
) -> Result<HttpResponse, sqlx::Error> {
|
||||||
let resp = get_http_response(app_handle, id).await?;
|
let resp = get_http_response(mgr, id).await?;
|
||||||
|
|
||||||
// Delete the body file if it exists
|
// Delete the body file if it exists
|
||||||
if let Some(p) = resp.body_path.clone() {
|
if let Some(p) = resp.body_path.clone() {
|
||||||
@@ -1432,7 +1436,7 @@ pub async fn delete_http_response(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = get_db(app_handle).await;
|
let db = get_db(mgr).await;
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM http_responses
|
DELETE FROM http_responses
|
||||||
@@ -1443,25 +1447,25 @@ pub async fn delete_http_response(
|
|||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
emit_deleted_model(app_handle, resp)
|
emit_deleted_model(mgr, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_all_grpc_connections(
|
pub async fn delete_all_grpc_connections(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
) -> Result<(), sqlx::Error> {
|
) -> Result<(), sqlx::Error> {
|
||||||
for r in list_grpc_connections(app_handle, request_id).await? {
|
for r in list_grpc_connections(mgr, request_id).await? {
|
||||||
delete_grpc_connection(app_handle, &r.id).await?;
|
delete_grpc_connection(mgr, &r.id).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_all_http_responses(
|
pub async fn delete_all_http_responses(
|
||||||
app_handle: &AppHandle,
|
mgr: &impl Manager<Wry>,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
) -> Result<(), sqlx::Error> {
|
) -> Result<(), sqlx::Error> {
|
||||||
for r in list_responses(app_handle, request_id, None).await? {
|
for r in list_responses(mgr, request_id, None).await? {
|
||||||
delete_http_response(app_handle, &r.id).await?;
|
delete_http_response(mgr, &r.id).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1518,20 +1522,18 @@ pub async fn get_workspace_export_resources(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_upserted_model<S: Serialize + Clone>(app_handle: &AppHandle, model: S) -> S {
|
fn emit_upserted_model<S: Serialize + Clone>(mgr: &impl Manager<Wry>, model: S) -> S {
|
||||||
app_handle
|
mgr.emit_all("upserted_model", model.clone()).unwrap();
|
||||||
.emit_all("upserted_model", model.clone())
|
|
||||||
.unwrap();
|
|
||||||
model
|
model
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_deleted_model<S: Serialize + Clone, E>(app_handle: &AppHandle, model: S) -> Result<S, E> {
|
fn emit_deleted_model<S: Serialize + Clone, E>(mgr: &impl Manager<Wry>, model: S) -> Result<S, E> {
|
||||||
app_handle.emit_all("deleted_model", model.clone()).unwrap();
|
mgr.emit_all("deleted_model", model.clone()).unwrap();
|
||||||
Ok(model)
|
Ok(model)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_db(app_handle: &AppHandle) -> Pool<Sqlite> {
|
async fn get_db(w: &impl Manager<Wry>) -> Pool<Sqlite> {
|
||||||
let db_state = app_handle.state::<Mutex<Pool<Sqlite>>>();
|
let db_state = w.state::<Mutex<Pool<Sqlite>>>();
|
||||||
let db = &*db_state.lock().await;
|
let db = &*db_state.lock().await;
|
||||||
db.clone()
|
db.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ export function BasicAuth({ requestId, authentication }: Props) {
|
|||||||
<VStack className="my-2" space={2}>
|
<VStack className="my-2" space={2}>
|
||||||
<Input
|
<Input
|
||||||
useTemplating
|
useTemplating
|
||||||
|
autocompleteVariables
|
||||||
|
forceUpdateKey={requestId}
|
||||||
|
placeholder="username"
|
||||||
label="Username"
|
label="Username"
|
||||||
name="username"
|
name="username"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -28,6 +31,9 @@ export function BasicAuth({ requestId, authentication }: Props) {
|
|||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
useTemplating
|
useTemplating
|
||||||
|
autocompleteVariables
|
||||||
|
forceUpdateKey={requestId}
|
||||||
|
placeholder="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
name="password"
|
name="password"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export function BearerAuth({ requestId, authentication }: Props) {
|
|||||||
<Input
|
<Input
|
||||||
useTemplating
|
useTemplating
|
||||||
autocompleteVariables
|
autocompleteVariables
|
||||||
|
placeholder="token"
|
||||||
type="password"
|
type="password"
|
||||||
label="Token"
|
label="Token"
|
||||||
name="token"
|
name="token"
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export function CookieDropdown() {
|
|||||||
),
|
),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
|
placeholder: 'New name',
|
||||||
defaultValue: activeCookieJar?.name,
|
defaultValue: activeCookieJar?.name,
|
||||||
});
|
});
|
||||||
updateCookieJar.mutate({ name });
|
updateCookieJar.mutate({ name });
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ const EnvironmentEditor = function ({
|
|||||||
),
|
),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
|
placeholder: 'New Name',
|
||||||
defaultValue: environment.name,
|
defaultValue: environment.name,
|
||||||
});
|
});
|
||||||
updateEnvironment.mutate({ name });
|
updateEnvironment.mutate({ name });
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { formatDistanceToNowStrict } from 'date-fns';
|
|||||||
import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection';
|
import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection';
|
||||||
import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections';
|
import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections';
|
||||||
import type { GrpcConnection } from '../lib/models';
|
import type { GrpcConnection } from '../lib/models';
|
||||||
import { count, pluralize } from '../lib/pluralize';
|
import { count } from '../lib/pluralize';
|
||||||
import { Dropdown } from './core/Dropdown';
|
import { Dropdown } from './core/Dropdown';
|
||||||
import { Icon } from './core/Icon';
|
import { Icon } from './core/Icon';
|
||||||
import { IconButton } from './core/IconButton';
|
import { IconButton } from './core/IconButton';
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { CSSProperties, MouseEvent as ReactMouseEvent } from 'react';
|
import type { CSSProperties, MouseEvent as ReactMouseEvent } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Separator } from './core/Separator';
|
|
||||||
|
|
||||||
interface ResizeBarProps {
|
interface ResizeBarProps {
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
className?: string;
|
className?: string;
|
||||||
barClassName?: string;
|
|
||||||
isResizing: boolean;
|
isResizing: boolean;
|
||||||
onResizeStart: (e: ReactMouseEvent<HTMLDivElement>) => void;
|
onResizeStart: (e: ReactMouseEvent<HTMLDivElement>) => void;
|
||||||
onReset?: () => void;
|
onReset?: () => void;
|
||||||
@@ -18,7 +16,6 @@ export function ResizeHandle({
|
|||||||
style,
|
style,
|
||||||
justify,
|
justify,
|
||||||
className,
|
className,
|
||||||
barClassName,
|
|
||||||
onResizeStart,
|
onResizeStart,
|
||||||
onReset,
|
onReset,
|
||||||
isResizing,
|
isResizing,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export const SettingsDialog = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
name="requestTimeout"
|
name="requestTimeout"
|
||||||
label="Request Timeout (ms)"
|
label="Request Timeout (ms)"
|
||||||
|
placeholder="0"
|
||||||
labelPosition="left"
|
labelPosition="left"
|
||||||
labelClassName="w-1/3"
|
labelClassName="w-1/3"
|
||||||
containerClassName="col-span-2"
|
containerClassName="col-span-2"
|
||||||
|
|||||||
@@ -660,6 +660,7 @@ const SidebarItem = forwardRef(function SidebarItem(
|
|||||||
),
|
),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
|
placeholder: 'New Name',
|
||||||
defaultValue: itemName,
|
defaultValue: itemName,
|
||||||
});
|
});
|
||||||
updateAnyFolder.mutate({ id: itemId, update: (f) => ({ ...f, name }) });
|
updateAnyFolder.mutate({ id: itemId, update: (f) => ({ ...f, name }) });
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { Simulate } from 'react-dom/test-utils';
|
|
||||||
import { useCreateFolder } from '../hooks/useCreateFolder';
|
import { useCreateFolder } from '../hooks/useCreateFolder';
|
||||||
import { useCreateGrpcRequest } from '../hooks/useCreateGrpcRequest';
|
import { useCreateGrpcRequest } from '../hooks/useCreateGrpcRequest';
|
||||||
import { useCreateHttpRequest } from '../hooks/useCreateHttpRequest';
|
import { useCreateHttpRequest } from '../hooks/useCreateHttpRequest';
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
|
|||||||
),
|
),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
|
placeholder: 'New Name',
|
||||||
defaultValue: activeWorkspace?.name,
|
defaultValue: activeWorkspace?.name,
|
||||||
});
|
});
|
||||||
updateWorkspace.mutate({ name });
|
updateWorkspace.mutate({ name });
|
||||||
@@ -142,6 +143,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
|
|||||||
defaultValue: 'My Workspace',
|
defaultValue: 'My Workspace',
|
||||||
title: 'New Workspace',
|
title: 'New Workspace',
|
||||||
confirmLabel: 'Create',
|
confirmLabel: 'Create',
|
||||||
|
placeholder: 'My Workspace',
|
||||||
});
|
});
|
||||||
createWorkspace.mutate({ name });
|
createWorkspace.mutate({ name });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
} from '@codemirror/view';
|
} from '@codemirror/view';
|
||||||
import { tags as t } from '@lezer/highlight';
|
import { tags as t } from '@lezer/highlight';
|
||||||
import { graphql, graphqlLanguageSupport } from 'cm6-graphql';
|
import { graphql, graphqlLanguageSupport } from 'cm6-graphql';
|
||||||
|
import { EditorView } from 'codemirror';
|
||||||
import { jsonSchema } from 'codemirror-json-schema';
|
import { jsonSchema } from 'codemirror-json-schema';
|
||||||
import type { Environment, Workspace } from '../../../lib/models';
|
import type { Environment, Workspace } from '../../../lib/models';
|
||||||
import type { EditorProps } from './index';
|
import type { EditorProps } from './index';
|
||||||
@@ -60,6 +61,8 @@ export const myHighlightStyle = HighlightStyle.define([
|
|||||||
{ tag: [t.keyword, t.meta, t.operator], color: 'hsl(var(--color-red-600))' },
|
{ tag: [t.keyword, t.meta, t.operator], color: 'hsl(var(--color-red-600))' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const myTheme = EditorView.theme({}, { dark: true });
|
||||||
|
|
||||||
// export const defaultHighlightStyle = HighlightStyle.define([
|
// export const defaultHighlightStyle = HighlightStyle.define([
|
||||||
// { tag: t.meta, color: '#404740' },
|
// { tag: t.meta, color: '#404740' },
|
||||||
// { tag: t.link, textDecoration: 'underline' },
|
// { tag: t.link, textDecoration: 'underline' },
|
||||||
@@ -83,7 +86,7 @@ export const myHighlightStyle = HighlightStyle.define([
|
|||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
const syntaxExtensions: Record<string, LanguageSupport> = {
|
const syntaxExtensions: Record<string, LanguageSupport> = {
|
||||||
'application/grpc': jsonSchema() as any, // TODO: Fix this
|
'application/grpc': jsonSchema() as unknown as LanguageSupport, // TODO: Fix this
|
||||||
'application/graphql': graphqlLanguageSupport(),
|
'application/graphql': graphqlLanguageSupport(),
|
||||||
'application/json': json(),
|
'application/json': json(),
|
||||||
'application/javascript': javascript(),
|
'application/javascript': javascript(),
|
||||||
@@ -131,6 +134,7 @@ export const baseExtensions = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
syntaxHighlighting(myHighlightStyle),
|
syntaxHighlighting(myHighlightStyle),
|
||||||
|
myTheme,
|
||||||
EditorState.allowMultipleSelections.of(true),
|
EditorState.allowMultipleSelections.of(true),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export type InputProps = Omit<
|
|||||||
rightSlot?: ReactNode;
|
rightSlot?: ReactNode;
|
||||||
size?: 'xs' | 'sm' | 'md' | 'auto';
|
size?: 'xs' | 'sm' | 'md' | 'auto';
|
||||||
className?: string;
|
className?: string;
|
||||||
placeholder?: string;
|
placeholder: string;
|
||||||
validate?: (v: string) => boolean;
|
validate?: (v: string) => boolean;
|
||||||
require?: boolean;
|
require?: boolean;
|
||||||
wrapLines?: boolean;
|
wrapLines?: boolean;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Icon } from './Icon';
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
depth?: number;
|
depth?: number;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
attrValue: any;
|
attrValue: any;
|
||||||
attrKey?: string | number;
|
attrKey?: string | number;
|
||||||
attrKeyJsonPath?: string;
|
attrKeyJsonPath?: string;
|
||||||
@@ -44,7 +45,8 @@ export const JsonAttributeTree = ({ depth = 0, attrKey, attrValue, attrKeyJsonPa
|
|||||||
} else if (jsonType === '[object Array]') {
|
} else if (jsonType === '[object Array]') {
|
||||||
return {
|
return {
|
||||||
children: isExpanded
|
children: isExpanded
|
||||||
? attrValue.flatMap((v: any, i: number) => (
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
attrValue.flatMap((v: any, i: number) => (
|
||||||
<JsonAttributeTree
|
<JsonAttributeTree
|
||||||
depth={depth + 1}
|
depth={depth + 1}
|
||||||
attrValue={v}
|
attrValue={v}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export function SplitLayout({
|
|||||||
/ ${1 - width}fr 0 ${width}fr
|
/ ${1 - width}fr 0 ${width}fr
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
}, [style, vertical, height, minHeightPx, width]);
|
}, [forceVertical, style, vertical, height, minHeightPx, width]);
|
||||||
|
|
||||||
const unsub = () => {
|
const unsub = () => {
|
||||||
if (moveState.current !== null) {
|
if (moveState.current !== null) {
|
||||||
@@ -154,7 +154,6 @@ export function SplitLayout({
|
|||||||
<ResizeHandle
|
<ResizeHandle
|
||||||
style={areaD}
|
style={areaD}
|
||||||
isResizing={isResizing}
|
isResizing={isResizing}
|
||||||
barClassName={'bg-red-300'}
|
|
||||||
className={classNames(vertical ? 'translate-y-0.5' : 'translate-x-0.5')}
|
className={classNames(vertical ? 'translate-y-0.5' : 'translate-x-0.5')}
|
||||||
onResizeStart={handleResizeStart}
|
onResizeStart={handleResizeStart}
|
||||||
onReset={handleReset}
|
onReset={handleReset}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export interface PromptProps {
|
|||||||
onResult: (value: string) => void;
|
onResult: (value: string) => void;
|
||||||
label: InputProps['label'];
|
label: InputProps['label'];
|
||||||
name: InputProps['name'];
|
name: InputProps['name'];
|
||||||
defaultValue?: InputProps['defaultValue'];
|
defaultValue: InputProps['defaultValue'];
|
||||||
placeholder?: InputProps['placeholder'];
|
placeholder: InputProps['placeholder'];
|
||||||
confirmLabel?: string;
|
confirmLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { r } from 'vitest/dist/types-94cfe4b4';
|
|
||||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
||||||
import { useActiveRequestId } from './useActiveRequestId';
|
import { useActiveRequestId } from './useActiveRequestId';
|
||||||
import { useGrpcRequests } from './useGrpcRequests';
|
import { useGrpcRequests } from './useGrpcRequests';
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export function useCreateCookieJar() {
|
|||||||
id: 'new-cookie-jar',
|
id: 'new-cookie-jar',
|
||||||
name: 'name',
|
name: 'name',
|
||||||
title: 'New CookieJar',
|
title: 'New CookieJar',
|
||||||
|
placeholder: 'My Jar',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
defaultValue: 'My Jar',
|
defaultValue: 'My Jar',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export function useCreateEnvironment() {
|
|||||||
name: 'name',
|
name: 'name',
|
||||||
title: 'New Environment',
|
title: 'New Environment',
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
|
placeholder: 'My Environment',
|
||||||
defaultValue: 'My Environment',
|
defaultValue: 'My Environment',
|
||||||
});
|
});
|
||||||
return invoke('cmd_create_environment', { name, variables: [], workspaceId });
|
return invoke('cmd_create_environment', { name, variables: [], workspaceId });
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import { trackEvent } from '../lib/analytics';
|
import { trackEvent } from '../lib/analytics';
|
||||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
import type { GrpcRequest } from '../lib/models';
|
||||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||||
import { useActiveRequest } from './useActiveRequest';
|
|
||||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||||
import { useAppRoutes } from './useAppRoutes';
|
import { useAppRoutes } from './useAppRoutes';
|
||||||
import { grpcRequestsQueryKey } from './useGrpcRequests';
|
import { grpcRequestsQueryKey } from './useGrpcRequests';
|
||||||
import { httpRequestsQueryKey } from './useHttpRequests';
|
|
||||||
|
|
||||||
export function useCreateGrpcRequest() {
|
export function useCreateGrpcRequest() {
|
||||||
const workspaceId = useActiveWorkspaceId();
|
const workspaceId = useActiveWorkspaceId();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import type { GrpcRequest } from '../lib/models';
|
import type { GrpcRequest } from '../lib/models';
|
||||||
import { sleep } from '../lib/sleep';
|
|
||||||
import { getGrpcRequest } from '../lib/store';
|
import { getGrpcRequest } from '../lib/store';
|
||||||
import { grpcRequestsQueryKey } from './useGrpcRequests';
|
import { grpcRequestsQueryKey } from './useGrpcRequests';
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ export async function minPromiseMillis<T>(promise: Promise<T>, millis: number) {
|
|||||||
result = await promise;
|
result = await promise;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
err = e;
|
err = e;
|
||||||
|
const delayFor = millis - (Date.now() - start);
|
||||||
|
await sleep(delayFor);
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
const delayFor = millis - (Date.now() - start);
|
const delayFor = millis - (Date.now() - start);
|
||||||
await sleep(delayFor);
|
await sleep(delayFor);
|
||||||
if (err) throw err;
|
return result;
|
||||||
else return result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user