Markdown documentation for HTTP requests (#145)

This commit is contained in:
Gregory Schier
2024-12-19 05:57:40 -08:00
committed by GitHub
parent 42d350ef27
commit 833dc7d3f7
30 changed files with 2274 additions and 251 deletions

View File

@@ -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")?,

View File

@@ -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,