mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Markdown documentation for HTTP requests (#145)
This commit is contained in:
8
src-tauri/migrations/20241217204951_docs.sql
Normal file
8
src-tauri/migrations/20241217204951_docs.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE http_requests
|
||||
ADD COLUMN description TEXT DEFAULT '' NOT NULL;
|
||||
|
||||
ALTER TABLE grpc_requests
|
||||
ADD COLUMN description TEXT DEFAULT '' NOT NULL;
|
||||
|
||||
ALTER TABLE folders
|
||||
ADD COLUMN description TEXT DEFAULT '' NOT NULL;
|
||||
@@ -903,7 +903,7 @@ async fn cmd_import_data<R: Runtime>(
|
||||
v.workspace_id =
|
||||
maybe_gen_id(v.workspace_id.as_str(), ModelType::TypeWorkspace, &mut id_map);
|
||||
v.folder_id = maybe_gen_id_opt(v.folder_id, ModelType::TypeFolder, &mut id_map);
|
||||
let x = upsert_grpc_request(&window, &v).await.map_err(|e| e.to_string())?;
|
||||
let x = upsert_grpc_request(&window, v).await.map_err(|e| e.to_string())?;
|
||||
imported_resources.grpc_requests.push(x.clone());
|
||||
}
|
||||
info!("Imported {} grpc_requests", imported_resources.grpc_requests.len());
|
||||
@@ -1225,7 +1225,7 @@ async fn cmd_create_grpc_request(
|
||||
) -> Result<GrpcRequest, String> {
|
||||
upsert_grpc_request(
|
||||
&w,
|
||||
&GrpcRequest {
|
||||
GrpcRequest {
|
||||
workspace_id: workspace_id.to_string(),
|
||||
name: name.to_string(),
|
||||
folder_id: folder_id.map(|s| s.to_string()),
|
||||
@@ -1273,7 +1273,7 @@ async fn cmd_update_grpc_request(
|
||||
request: GrpcRequest,
|
||||
w: WebviewWindow,
|
||||
) -> Result<GrpcRequest, String> {
|
||||
upsert_grpc_request(&w, &request).await.map_err(|e| e.to_string())
|
||||
upsert_grpc_request(&w, request).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@@ -14,7 +14,7 @@ export type Environment = { model: "environment", id: string, workspaceId: strin
|
||||
|
||||
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
|
||||
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, description: string, sortPriority: number, };
|
||||
|
||||
export type GrpcConnection = { model: "grpc_connection", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, elapsed: number, error: string | null, method: string, service: string, status: number, state: GrpcConnectionState, trailers: { [key in string]?: string }, url: string, };
|
||||
|
||||
@@ -26,9 +26,9 @@ export type GrpcEventType = "info" | "error" | "client_message" | "server_messag
|
||||
|
||||
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
||||
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, description: string, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
||||
|
||||
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
||||
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, description: string, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
||||
|
||||
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
|
||||
@@ -310,6 +310,7 @@ pub struct Folder {
|
||||
pub folder_id: Option<String>,
|
||||
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub sort_priority: f32,
|
||||
}
|
||||
|
||||
@@ -325,6 +326,7 @@ pub enum FolderIden {
|
||||
UpdatedAt,
|
||||
|
||||
Name,
|
||||
Description,
|
||||
SortPriority,
|
||||
}
|
||||
|
||||
@@ -341,6 +343,7 @@ impl<'s> TryFrom<&Row<'s>> for Folder {
|
||||
updated_at: r.get("updated_at")?,
|
||||
folder_id: r.get("folder_id")?,
|
||||
name: r.get("name")?,
|
||||
description: r.get("description")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -385,6 +388,7 @@ pub struct HttpRequest {
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub body: BTreeMap<String, Value>,
|
||||
pub body_type: Option<String>,
|
||||
pub description: String,
|
||||
pub headers: Vec<HttpRequestHeader>,
|
||||
#[serde(default = "default_http_request_method")]
|
||||
pub method: String,
|
||||
@@ -409,6 +413,7 @@ pub enum HttpRequestIden {
|
||||
AuthenticationType,
|
||||
Body,
|
||||
BodyType,
|
||||
Description,
|
||||
Headers,
|
||||
Method,
|
||||
Name,
|
||||
@@ -437,6 +442,7 @@ impl<'s> TryFrom<&Row<'s>> for HttpRequest {
|
||||
method: r.get("method")?,
|
||||
body: serde_json::from_str(body.as_str()).unwrap_or_default(),
|
||||
body_type: r.get("body_type")?,
|
||||
description: r.get("description")?,
|
||||
authentication: serde_json::from_str(authentication.as_str()).unwrap_or_default(),
|
||||
authentication_type: r.get("authentication_type")?,
|
||||
headers: serde_json::from_str(headers.as_str()).unwrap_or_default(),
|
||||
@@ -584,6 +590,7 @@ pub struct GrpcRequest {
|
||||
pub authentication_type: Option<String>,
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub authentication: BTreeMap<String, Value>,
|
||||
pub description: String,
|
||||
pub message: String,
|
||||
pub metadata: Vec<GrpcMetadataEntry>,
|
||||
pub method: Option<String>,
|
||||
@@ -606,6 +613,7 @@ pub enum GrpcRequestIden {
|
||||
|
||||
Authentication,
|
||||
AuthenticationType,
|
||||
Description,
|
||||
Message,
|
||||
Metadata,
|
||||
Method,
|
||||
@@ -629,6 +637,7 @@ impl<'s> TryFrom<&Row<'s>> for GrpcRequest {
|
||||
updated_at: r.get("updated_at")?,
|
||||
folder_id: r.get("folder_id")?,
|
||||
name: r.get("name")?,
|
||||
description: r.get("description")?,
|
||||
service: r.get("service")?,
|
||||
method: r.get("method")?,
|
||||
message: r.get("message")?,
|
||||
|
||||
@@ -307,7 +307,7 @@ pub async fn duplicate_grpc_request<R: Runtime>(
|
||||
}
|
||||
};
|
||||
request.id = "".to_string();
|
||||
upsert_grpc_request(window, &request).await
|
||||
upsert_grpc_request(window, request).await
|
||||
}
|
||||
|
||||
pub async fn delete_grpc_request<R: Runtime>(
|
||||
@@ -334,7 +334,7 @@ pub async fn delete_grpc_request<R: Runtime>(
|
||||
|
||||
pub async fn upsert_grpc_request<R: Runtime>(
|
||||
window: &WebviewWindow<R>,
|
||||
request: &GrpcRequest,
|
||||
request: GrpcRequest,
|
||||
) -> Result<GrpcRequest> {
|
||||
let id = match request.id.as_str() {
|
||||
"" => generate_model_id(ModelType::TypeGrpcRequest),
|
||||
@@ -351,6 +351,7 @@ pub async fn upsert_grpc_request<R: Runtime>(
|
||||
GrpcRequestIden::CreatedAt,
|
||||
GrpcRequestIden::UpdatedAt,
|
||||
GrpcRequestIden::Name,
|
||||
GrpcRequestIden::Description,
|
||||
GrpcRequestIden::WorkspaceId,
|
||||
GrpcRequestIden::FolderId,
|
||||
GrpcRequestIden::SortPriority,
|
||||
@@ -363,17 +364,18 @@ pub async fn upsert_grpc_request<R: Runtime>(
|
||||
GrpcRequestIden::Metadata,
|
||||
])
|
||||
.values_panic([
|
||||
id.as_str().into(),
|
||||
id.into(),
|
||||
CurrentTimestamp.into(),
|
||||
CurrentTimestamp.into(),
|
||||
trimmed_name.into(),
|
||||
request.workspace_id.as_str().into(),
|
||||
request.description.into(),
|
||||
request.workspace_id.into(),
|
||||
request.folder_id.as_ref().map(|s| s.as_str()).into(),
|
||||
request.sort_priority.into(),
|
||||
request.url.as_str().into(),
|
||||
request.url.into(),
|
||||
request.service.as_ref().map(|s| s.as_str()).into(),
|
||||
request.method.as_ref().map(|s| s.as_str()).into(),
|
||||
request.message.as_str().into(),
|
||||
request.message.into(),
|
||||
request.authentication_type.as_ref().map(|s| s.as_str()).into(),
|
||||
serde_json::to_string(&request.authentication)?.into(),
|
||||
serde_json::to_string(&request.metadata)?.into(),
|
||||
@@ -384,6 +386,7 @@ pub async fn upsert_grpc_request<R: Runtime>(
|
||||
GrpcRequestIden::UpdatedAt,
|
||||
GrpcRequestIden::WorkspaceId,
|
||||
GrpcRequestIden::Name,
|
||||
GrpcRequestIden::Description,
|
||||
GrpcRequestIden::FolderId,
|
||||
GrpcRequestIden::SortPriority,
|
||||
GrpcRequestIden::Url,
|
||||
@@ -1064,6 +1067,7 @@ pub async fn upsert_folder<R: Runtime>(window: &WebviewWindow<R>, r: Folder) ->
|
||||
FolderIden::WorkspaceId,
|
||||
FolderIden::FolderId,
|
||||
FolderIden::Name,
|
||||
FolderIden::Description,
|
||||
FolderIden::SortPriority,
|
||||
])
|
||||
.values_panic([
|
||||
@@ -1073,6 +1077,7 @@ pub async fn upsert_folder<R: Runtime>(window: &WebviewWindow<R>, r: Folder) ->
|
||||
r.workspace_id.as_str().into(),
|
||||
r.folder_id.as_ref().map(|s| s.as_str()).into(),
|
||||
trimmed_name.into(),
|
||||
r.description.into(),
|
||||
r.sort_priority.into(),
|
||||
])
|
||||
.on_conflict(
|
||||
@@ -1080,6 +1085,7 @@ pub async fn upsert_folder<R: Runtime>(window: &WebviewWindow<R>, r: Folder) ->
|
||||
.update_columns([
|
||||
FolderIden::UpdatedAt,
|
||||
FolderIden::Name,
|
||||
FolderIden::Description,
|
||||
FolderIden::FolderId,
|
||||
FolderIden::SortPriority,
|
||||
])
|
||||
@@ -1127,6 +1133,7 @@ pub async fn upsert_http_request<R: Runtime>(
|
||||
HttpRequestIden::WorkspaceId,
|
||||
HttpRequestIden::FolderId,
|
||||
HttpRequestIden::Name,
|
||||
HttpRequestIden::Description,
|
||||
HttpRequestIden::Url,
|
||||
HttpRequestIden::UrlParameters,
|
||||
HttpRequestIden::Method,
|
||||
@@ -1141,12 +1148,13 @@ pub async fn upsert_http_request<R: Runtime>(
|
||||
id.as_str().into(),
|
||||
CurrentTimestamp.into(),
|
||||
CurrentTimestamp.into(),
|
||||
r.workspace_id.as_str().into(),
|
||||
r.workspace_id.into(),
|
||||
r.folder_id.as_ref().map(|s| s.as_str()).into(),
|
||||
trimmed_name.into(),
|
||||
r.url.as_str().into(),
|
||||
r.description.into(),
|
||||
r.url.into(),
|
||||
serde_json::to_string(&r.url_parameters)?.into(),
|
||||
r.method.as_str().into(),
|
||||
r.method.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)?.into(),
|
||||
@@ -1160,6 +1168,7 @@ pub async fn upsert_http_request<R: Runtime>(
|
||||
HttpRequestIden::UpdatedAt,
|
||||
HttpRequestIden::WorkspaceId,
|
||||
HttpRequestIden::Name,
|
||||
HttpRequestIden::Description,
|
||||
HttpRequestIden::FolderId,
|
||||
HttpRequestIden::Method,
|
||||
HttpRequestIden::Headers,
|
||||
|
||||
Reference in New Issue
Block a user