mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 14:33:18 +02:00
[WIP] Refactor to NPM workspaces (#104)
This commit is contained in:
1
src-tauri/yaak_models/.gitignore
vendored
Normal file
1
src-tauri/yaak_models/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -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 CookieDomain = { "HostOnly": string } | { "Suffix": string } | "NotPresent" | "Empty";
|
||||
@@ -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 CookieExpires = { "AtUtc": string } | "SessionEnd";
|
||||
@@ -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 GrpcEventType = "info" | "error" | "client_message" | "server_message" | "connection_start" | "connection_end";
|
||||
@@ -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 Settings = { id: string, model: "settings", createdAt: string, updatedAt: string, theme: string, appearance: string, themeDark: string, themeLight: string, updateChannel: string, interfaceFontSize: number, interfaceScale: number, editorFontSize: number, editorSoftWrap: boolean, telemetry: boolean, openWorkspaceNewWindow: boolean | null, };
|
||||
@@ -1,43 +1,45 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type AnyModel = CookieJar | Environment | Folder | GrpcConnection | GrpcEvent | GrpcRequest | HttpRequest | HttpResponse | Plugin | Settings | KeyValue | Workspace;
|
||||
|
||||
export type Cookie = { raw_cookie: string, domain: CookieDomain, expires: CookieExpires, path: [string, boolean], };
|
||||
|
||||
export type CookieDomain = { "HostOnly": string } | { "Suffix": string } | "NotPresent" | "Empty";
|
||||
|
||||
export type CookieExpires = { "AtUtc": string } | "SessionEnd";
|
||||
|
||||
export type CookieJar = { id: string, model: "cookie_jar", createdAt: string, updatedAt: string, workspaceId: string, name: string, cookies: Array<Cookie>, };
|
||||
export type CookieJar = { model: "cookie_jar", id: string, createdAt: string, updatedAt: string, workspaceId: string, cookies: Array<Cookie>, name: string, };
|
||||
|
||||
export type Environment = { id: string, workspaceId: string, model: "environment", createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
||||
export type Environment = { model: "environment", id: string, workspaceId: string, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
||||
|
||||
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type Folder = { createdAt: string, updatedAt: string, id: string, workspaceId: string, folderId: string | null, model: "folder", name: string, sortPriority: number, };
|
||||
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
|
||||
|
||||
export type GrpcConnection = { id: string, model: "grpc_connection", workspaceId: string, requestId: string, createdAt: string, updatedAt: string, service: string, method: string, elapsed: number, status: number, url: string, error: string | null, trailers: { [key in string]?: string }, };
|
||||
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, trailers: { [key in string]?: string }, url: string, };
|
||||
|
||||
export type GrpcEvent = { id: string, model: "grpc_event", workspaceId: string, requestId: string, connectionId: string, createdAt: string, updatedAt: string, content: string, eventType: GrpcEventType, metadata: { [key in string]?: string }, status: number | null, error: string | null, };
|
||||
export type GrpcEvent = { model: "grpc_event", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, connectionId: string, content: string, error: string | null, eventType: GrpcEventType, metadata: { [key in string]?: string }, status: number | null, };
|
||||
|
||||
export type GrpcEventType = "info" | "error" | "client_message" | "server_message" | "connection_start" | "connection_end";
|
||||
|
||||
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type GrpcRequest = { id: string, model: "grpc_request", workspaceId: string, createdAt: string, updatedAt: string, folderId: string | null, name: string, sortPriority: number, url: string, service: string | null, method: string | null, message: string, authenticationType: string | null, authentication: Record<string, any>, metadata: Array<GrpcMetadataEntry>, };
|
||||
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 HttpRequest = { createdAt: string, updatedAt: string, id: string, workspaceId: string, folderId: string | null, model: "http_request", sortPriority: number, name: string, url: string, urlParameters: Array<HttpUrlParameter>, method: string, body: Record<string, any>, bodyType: string | null, authentication: Record<string, any>, authenticationType: string | null, headers: Array<HttpRequestHeader>, };
|
||||
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 HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type HttpResponse = { id: string, model: "http_response", workspaceId: string, requestId: string, createdAt: string, updatedAt: string, error: string | null, url: string, contentLength: number | null, version: string | null, elapsed: number, elapsedHeaders: number, remoteAddr: string | null, status: number, statusReason: string | null, bodyPath: string | null, headers: Array<HttpResponseHeader>, };
|
||||
export type HttpResponse = { model: "http_response", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, bodyPath: string | null, contentLength: number | null, elapsed: number, elapsedHeaders: number, error: string | null, headers: Array<HttpResponseHeader>, remoteAddr: string | null, status: number, statusReason: string | null, url: string, version: string | null, };
|
||||
|
||||
export type HttpResponseHeader = { name: string, value: string, };
|
||||
|
||||
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };
|
||||
|
||||
export type KeyValue = { model: "key_value", createdAt: string, updatedAt: string, namespace: string, key: string, value: string, };
|
||||
export type KeyValue = { model: "key_value", createdAt: string, updatedAt: string, key: string, namespace: string, value: string, };
|
||||
|
||||
export type Plugin = { id: string, model: "plugin", createdAt: string, updatedAt: string, checkedAt: string | null, directory: string, url: string | null, enabled: boolean, };
|
||||
export type Plugin = { model: "plugin", id: string, createdAt: string, updatedAt: string, checkedAt: string | null, directory: string, enabled: boolean, url: string | null, };
|
||||
|
||||
export type Settings = { id: string, model: "settings", createdAt: string, updatedAt: string, theme: string, appearance: string, themeDark: string, themeLight: string, updateChannel: string, interfaceFontSize: number, interfaceScale: number, editorFontSize: number, editorSoftWrap: boolean, telemetry: boolean, openWorkspaceNewWindow: boolean | null, };
|
||||
export type Settings = { model: "settings", id: string, createdAt: string, updatedAt: string, appearance: string, editorFontSize: number, editorSoftWrap: boolean, interfaceFontSize: number, interfaceScale: number, openWorkspaceNewWindow: boolean | null, telemetry: boolean, theme: string, themeDark: string, themeLight: string, updateChannel: string, };
|
||||
|
||||
export type Workspace = { id: string, model: "workspace", createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
||||
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
||||
|
||||
1
src-tauri/yaak_models/index.ts
Normal file
1
src-tauri/yaak_models/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './bindings/models';
|
||||
10
src-tauri/yaak_models/package.json
Normal file
10
src-tauri/yaak_models/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@yaakapp-internal/models",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "lib/index.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
}
|
||||
}
|
||||
@@ -2,51 +2,53 @@ use chrono::NaiveDateTime;
|
||||
use rusqlite::Row;
|
||||
use sea_query::Iden;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Settings {
|
||||
pub id: String,
|
||||
#[ts(type = "\"settings\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub theme: String,
|
||||
|
||||
pub appearance: String,
|
||||
pub editor_font_size: i32,
|
||||
pub editor_soft_wrap: bool,
|
||||
pub interface_font_size: i32,
|
||||
pub interface_scale: f32,
|
||||
pub open_workspace_new_window: Option<bool>,
|
||||
pub telemetry: bool,
|
||||
pub theme: String,
|
||||
pub theme_dark: String,
|
||||
pub theme_light: String,
|
||||
pub update_channel: String,
|
||||
pub interface_font_size: i32,
|
||||
pub interface_scale: f32,
|
||||
pub editor_font_size: i32,
|
||||
pub editor_soft_wrap: bool,
|
||||
pub telemetry: bool,
|
||||
pub open_workspace_new_window: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum SettingsIden {
|
||||
#[iden = "settings"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Theme,
|
||||
|
||||
Appearance,
|
||||
UpdateChannel,
|
||||
ThemeDark,
|
||||
ThemeLight,
|
||||
InterfaceFontSize,
|
||||
InterfaceScale,
|
||||
EditorFontSize,
|
||||
EditorSoftWrap,
|
||||
Telemetry,
|
||||
InterfaceFontSize,
|
||||
InterfaceScale,
|
||||
OpenWorkspaceNewWindow,
|
||||
Telemetry,
|
||||
Theme,
|
||||
ThemeDark,
|
||||
ThemeLight,
|
||||
UpdateChannel,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for Settings {
|
||||
@@ -75,11 +77,11 @@ impl<'s> TryFrom<&Row<'s>> for Settings {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Workspace {
|
||||
pub id: String,
|
||||
#[ts(type = "\"workspace\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub name: String,
|
||||
@@ -98,16 +100,17 @@ pub struct Workspace {
|
||||
pub enum WorkspaceIden {
|
||||
#[iden = "workspaces"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Name,
|
||||
|
||||
Description,
|
||||
Variables,
|
||||
SettingValidateCertificates,
|
||||
Name,
|
||||
SettingFollowRedirects,
|
||||
SettingRequestTimeout,
|
||||
SettingValidateCertificates,
|
||||
Variables,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for Workspace {
|
||||
@@ -143,7 +146,7 @@ impl Workspace {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
enum CookieDomain {
|
||||
HostOnly(String),
|
||||
Suffix(String),
|
||||
@@ -152,14 +155,14 @@ enum CookieDomain {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
enum CookieExpires {
|
||||
AtUtc(String),
|
||||
SessionEnd,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Cookie {
|
||||
raw_cookie: String,
|
||||
domain: CookieDomain,
|
||||
@@ -169,16 +172,17 @@ pub struct Cookie {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct CookieJar {
|
||||
pub id: String,
|
||||
#[ts(type = "\"cookie_jar\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub workspace_id: String,
|
||||
pub name: String,
|
||||
|
||||
pub cookies: Vec<Cookie>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
@@ -190,8 +194,9 @@ pub enum CookieJarIden {
|
||||
WorkspaceId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Name,
|
||||
|
||||
Cookies,
|
||||
Name,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for CookieJar {
|
||||
@@ -213,14 +218,15 @@ impl<'s> TryFrom<&Row<'s>> for CookieJar {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Environment {
|
||||
pub id: String,
|
||||
pub workspace_id: String,
|
||||
#[ts(type = "\"environment\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub workspace_id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
|
||||
pub name: String,
|
||||
pub variables: Vec<EnvironmentVariable>,
|
||||
}
|
||||
@@ -229,11 +235,12 @@ pub struct Environment {
|
||||
pub enum EnvironmentIden {
|
||||
#[iden = "environments"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
WorkspaceId,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
WorkspaceId,
|
||||
|
||||
Name,
|
||||
Variables,
|
||||
}
|
||||
@@ -257,7 +264,7 @@ impl<'s> TryFrom<&Row<'s>> for Environment {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct EnvironmentVariable {
|
||||
#[serde(default = "default_true")]
|
||||
#[ts(optional, as = "Option<bool>")]
|
||||
@@ -268,15 +275,16 @@ pub struct EnvironmentVariable {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Folder {
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub id: String,
|
||||
pub workspace_id: String,
|
||||
pub folder_id: Option<String>,
|
||||
#[ts(type = "\"folder\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub workspace_id: String,
|
||||
pub folder_id: Option<String>,
|
||||
|
||||
pub name: String,
|
||||
pub sort_priority: f32,
|
||||
}
|
||||
@@ -291,6 +299,7 @@ pub enum FolderIden {
|
||||
FolderId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
|
||||
Name,
|
||||
SortPriority,
|
||||
}
|
||||
@@ -314,7 +323,7 @@ impl<'s> TryFrom<&Row<'s>> for Folder {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct HttpRequestHeader {
|
||||
#[serde(default = "default_true")]
|
||||
#[ts(optional, as = "Option<bool>")]
|
||||
@@ -325,7 +334,7 @@ pub struct HttpRequestHeader {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct HttpUrlParameter {
|
||||
#[serde(default = "default_true")]
|
||||
#[ts(optional, as = "Option<bool>")]
|
||||
@@ -336,28 +345,29 @@ pub struct HttpUrlParameter {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct HttpRequest {
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub id: String,
|
||||
pub workspace_id: String,
|
||||
pub folder_id: Option<String>,
|
||||
#[ts(type = "\"http_request\"")]
|
||||
pub model: String,
|
||||
pub sort_priority: f32,
|
||||
pub name: String,
|
||||
pub url: String,
|
||||
pub url_parameters: Vec<HttpUrlParameter>,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub workspace_id: String,
|
||||
pub folder_id: Option<String>,
|
||||
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub authentication: BTreeMap<String, Value>,
|
||||
pub authentication_type: Option<String>,
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub body: BTreeMap<String, Value>,
|
||||
pub body_type: Option<String>,
|
||||
pub headers: Vec<HttpRequestHeader>,
|
||||
#[serde(default = "default_http_request_method")]
|
||||
pub method: String,
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub body: HashMap<String, Value>,
|
||||
pub body_type: Option<String>,
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub authentication: HashMap<String, Value>,
|
||||
pub authentication_type: Option<String>,
|
||||
pub headers: Vec<HttpRequestHeader>,
|
||||
pub name: String,
|
||||
pub sort_priority: f32,
|
||||
pub url: String,
|
||||
pub url_parameters: Vec<HttpUrlParameter>,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
@@ -366,20 +376,21 @@ pub enum HttpRequestIden {
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
WorkspaceId,
|
||||
FolderId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
WorkspaceId,
|
||||
FolderId,
|
||||
|
||||
Authentication,
|
||||
AuthenticationType,
|
||||
Body,
|
||||
BodyType,
|
||||
Headers,
|
||||
Method,
|
||||
Name,
|
||||
SortPriority,
|
||||
Url,
|
||||
UrlParameters,
|
||||
Method,
|
||||
Body,
|
||||
BodyType,
|
||||
Authentication,
|
||||
AuthenticationType,
|
||||
Headers,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for HttpRequest {
|
||||
@@ -413,7 +424,7 @@ impl<'s> TryFrom<&Row<'s>> for HttpRequest {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct HttpResponseHeader {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
@@ -421,49 +432,51 @@ pub struct HttpResponseHeader {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct HttpResponse {
|
||||
pub id: String,
|
||||
#[ts(type = "\"http_response\"")]
|
||||
pub model: String,
|
||||
pub workspace_id: String,
|
||||
pub request_id: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub error: Option<String>,
|
||||
pub url: String,
|
||||
pub workspace_id: String,
|
||||
pub request_id: String,
|
||||
|
||||
pub body_path: Option<String>,
|
||||
pub content_length: Option<i32>,
|
||||
pub version: Option<String>,
|
||||
pub elapsed: i32,
|
||||
pub elapsed_headers: i32,
|
||||
pub error: Option<String>,
|
||||
pub headers: Vec<HttpResponseHeader>,
|
||||
pub remote_addr: Option<String>,
|
||||
pub status: i32,
|
||||
pub status_reason: Option<String>,
|
||||
pub body_path: Option<String>,
|
||||
pub headers: Vec<HttpResponseHeader>,
|
||||
pub url: String,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum HttpResponseIden {
|
||||
#[iden = "http_responses"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
WorkspaceId,
|
||||
RequestId,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Error,
|
||||
Url,
|
||||
WorkspaceId,
|
||||
RequestId,
|
||||
|
||||
BodyPath,
|
||||
ContentLength,
|
||||
Version,
|
||||
Elapsed,
|
||||
ElapsedHeaders,
|
||||
Error,
|
||||
Headers,
|
||||
RemoteAddr,
|
||||
Status,
|
||||
StatusReason,
|
||||
BodyPath,
|
||||
Headers,
|
||||
Url,
|
||||
Version,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for HttpResponse {
|
||||
@@ -504,7 +517,7 @@ impl HttpResponse {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct GrpcMetadataEntry {
|
||||
#[serde(default = "default_true")]
|
||||
#[ts(optional, as = "Option<bool>")]
|
||||
@@ -515,25 +528,26 @@ pub struct GrpcMetadataEntry {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct GrpcRequest {
|
||||
pub id: String,
|
||||
#[ts(type = "\"grpc_request\"")]
|
||||
pub model: String,
|
||||
pub workspace_id: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub workspace_id: String,
|
||||
pub folder_id: Option<String>,
|
||||
pub name: String,
|
||||
pub sort_priority: f32,
|
||||
pub url: String,
|
||||
pub service: Option<String>,
|
||||
pub method: Option<String>,
|
||||
pub message: String,
|
||||
|
||||
pub authentication_type: Option<String>,
|
||||
#[ts(type = "Record<string, any>")]
|
||||
pub authentication: HashMap<String, Value>,
|
||||
pub authentication: BTreeMap<String, Value>,
|
||||
pub message: String,
|
||||
pub metadata: Vec<GrpcMetadataEntry>,
|
||||
pub method: Option<String>,
|
||||
pub name: String,
|
||||
pub service: Option<String>,
|
||||
pub sort_priority: f32,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
@@ -542,19 +556,20 @@ pub enum GrpcRequestIden {
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
WorkspaceId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
WorkspaceId,
|
||||
FolderId,
|
||||
|
||||
Authentication,
|
||||
AuthenticationType,
|
||||
Message,
|
||||
Metadata,
|
||||
Method,
|
||||
Name,
|
||||
Service,
|
||||
SortPriority,
|
||||
Url,
|
||||
Service,
|
||||
Method,
|
||||
Message,
|
||||
AuthenticationType,
|
||||
Authentication,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for GrpcRequest {
|
||||
@@ -585,41 +600,43 @@ impl<'s> TryFrom<&Row<'s>> for GrpcRequest {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct GrpcConnection {
|
||||
pub id: String,
|
||||
#[ts(type = "\"grpc_connection\"")]
|
||||
pub model: String,
|
||||
pub workspace_id: String,
|
||||
pub request_id: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub service: String,
|
||||
pub method: String,
|
||||
pub workspace_id: String,
|
||||
pub request_id: String,
|
||||
|
||||
pub elapsed: i32,
|
||||
pub status: i32,
|
||||
pub url: String,
|
||||
pub error: Option<String>,
|
||||
pub trailers: HashMap<String, String>,
|
||||
pub method: String,
|
||||
pub service: String,
|
||||
pub status: i32,
|
||||
pub trailers: BTreeMap<String, String>,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum GrpcConnectionIden {
|
||||
#[iden = "grpc_connections"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
WorkspaceId,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
WorkspaceId,
|
||||
RequestId,
|
||||
Service,
|
||||
Method,
|
||||
|
||||
Elapsed,
|
||||
Status,
|
||||
Url,
|
||||
Error,
|
||||
Method,
|
||||
Service,
|
||||
Status,
|
||||
Trailers,
|
||||
Url,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for GrpcConnection {
|
||||
@@ -647,7 +664,7 @@ impl<'s> TryFrom<&Row<'s>> for GrpcConnection {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub enum GrpcEventType {
|
||||
Info,
|
||||
Error,
|
||||
@@ -665,39 +682,41 @@ impl Default for GrpcEventType {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct GrpcEvent {
|
||||
pub id: String,
|
||||
#[ts(type = "\"grpc_event\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub workspace_id: String,
|
||||
pub request_id: String,
|
||||
pub connection_id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
|
||||
pub content: String,
|
||||
pub event_type: GrpcEventType,
|
||||
pub metadata: HashMap<String, String>,
|
||||
pub status: Option<i32>,
|
||||
pub error: Option<String>,
|
||||
pub event_type: GrpcEventType,
|
||||
pub metadata: BTreeMap<String, String>,
|
||||
pub status: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum GrpcEventIden {
|
||||
#[iden = "grpc_events"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
WorkspaceId,
|
||||
RequestId,
|
||||
ConnectionId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
|
||||
Content,
|
||||
Error,
|
||||
EventType,
|
||||
Metadata,
|
||||
Status,
|
||||
Error,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for GrpcEvent {
|
||||
@@ -725,31 +744,33 @@ impl<'s> TryFrom<&Row<'s>> for GrpcEvent {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct Plugin {
|
||||
pub id: String,
|
||||
#[ts(type = "\"plugin\"")]
|
||||
pub model: String,
|
||||
pub id: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
|
||||
pub checked_at: Option<NaiveDateTime>,
|
||||
pub directory: String,
|
||||
pub url: Option<String>,
|
||||
pub enabled: bool,
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PluginIden {
|
||||
#[iden = "plugins"]
|
||||
Table,
|
||||
Id,
|
||||
Model,
|
||||
Id,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
|
||||
CheckedAt,
|
||||
Directory,
|
||||
Url,
|
||||
Enabled,
|
||||
Url,
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&Row<'s>> for Plugin {
|
||||
@@ -771,14 +792,15 @@ impl<'s> TryFrom<&Row<'s>> for Plugin {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
#[ts(export, export_to = "models.ts")]
|
||||
pub struct KeyValue {
|
||||
#[ts(type = "\"key_value\"")]
|
||||
pub model: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
pub namespace: String,
|
||||
|
||||
pub key: String,
|
||||
pub namespace: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
@@ -789,8 +811,9 @@ pub enum KeyValueIden {
|
||||
Model,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Namespace,
|
||||
|
||||
Key,
|
||||
Namespace,
|
||||
Value,
|
||||
}
|
||||
|
||||
@@ -847,3 +870,21 @@ impl ModelType {
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", untagged)]
|
||||
#[ts(export, export_to="models.ts")]
|
||||
pub enum AnyModel {
|
||||
CookieJar(CookieJar),
|
||||
Environment(Environment),
|
||||
Folder(Folder),
|
||||
GrpcConnection(GrpcConnection),
|
||||
GrpcEvent(GrpcEvent),
|
||||
GrpcRequest(GrpcRequest),
|
||||
HttpRequest(HttpRequest),
|
||||
HttpResponse(HttpResponse),
|
||||
Plugin(Plugin),
|
||||
Settings(Settings),
|
||||
KeyValue(KeyValue),
|
||||
Workspace(Workspace),
|
||||
}
|
||||
|
||||
15
src-tauri/yaak_models/tsconfig.json
Normal file
15
src-tauri/yaak_models/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "node16",
|
||||
"target": "es6",
|
||||
"lib": ["es2021"],
|
||||
"declaration": true,
|
||||
"declarationDir": "./lib",
|
||||
"outDir": "./lib",
|
||||
"strict": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"files": [
|
||||
"index.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user