export type Workspace = { id: number; name: string; }; export type WorkspaceEntryType = "Request" | "Collection"; export type WorkspaceEntry = WorkspaceEntryBase | WorkspaceRequest; export type WorkspaceEntryBase = { // Values from models id: number; workspace_id: number; parent_id: number | null; name: string; type: WorkspaceEntryType; auth: number | null; auth_inherit: boolean; // UI values, open?: boolean; }; export type WorkspaceRequest = WorkspaceEntryBase & { method: string; url: string; body: RequestBody | null; headers: RequestHeader[]; path: RequestPathParam[]; auth: number | null; auth_inherit: boolean; // Display fields workingUrl?: RequestUrl; expandedUrl?: RequestUrl; }; export type RequestUrl = { scheme: string; host: string; path: PathSegment[]; query_params: string[][]; has_query: boolean; }; export type UrlErrorType = "Parse" | "DuplicatePath" | "Db"; export type UrlError = { type: UrlErrorType; error: string; }; export type RequestHeader = { id: number; name: string; value: string; }; export type RequestPathParam = { position: number; name: string; value: string; }; export type PathSegment = { type: "Static" | "Dynamic"; value: string; }; export type WorkspaceCreateCollection = { name: string; workspace_id: number; parent_id?: number; }; export type WorkspaceCreateRequest = { name: string; workspace_id: number; parent_id?: number; method: string; url: string; }; export type RequestBody = { id: number; content: string; ty: string; }; export type WorkspaceEnvironment = { id: number; name: string; workspace_id: number; variables: EnvVariable[]; }; export type EnvVariable = { id: number; name: string; value: string; secret: boolean; }; export type Authentication = { id: number; workspace_id: number; name: string; params: AuthParams; }; export type AuthParams = | { type: "Token"; value: { name: string; placement: "Header" | "Query"; value: string; }; } | { type: "Basic"; value: { user: string; password: string } } | { type: "OAuth"; value: { token_name: string; callback_url: string; auth_url: string; token_url: string; refresh_url: string | null; client_id: string; client_secret: string; scope: string | null; state: string | null; grant_type: | { type: "AuthorizationCode"; } | { type: "AuthorizationCodePKCE"; value: { verifier: string | null }; } | { type: "ClientCredentials" }; }; }; export type AuthType = "Token" | "Basic" | "OAuth"; export type HttpResponse = { status: number; headers: string[][]; body: HttpResponseBody | null; }; export type HttpResponseBody = | { type: "TextPlain"; content: string; } | { type: "TextHtml"; content: string; } | { type: "Json"; content: string; }; export type ResponseResult = | { type: "Ok"; data: HttpResponse; } | { type: "Err"; data: string };