[WIP] Refactor to NPM workspaces (#104)

This commit is contained in:
Gregory Schier
2024-09-22 21:27:10 -07:00
committed by GitHub
parent 93633875ac
commit 101b6284d6
176 changed files with 1983 additions and 1249 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
node_modules/ node_modules/
dist/ dist/
.prettierrc.cjs
.eslintrc.cjs .eslintrc.cjs
env.d.ts .prettierrc.cjs
src-web/postcss.config.cjs
src-web/vite.config.ts
+2 -3
View File
@@ -17,9 +17,8 @@ module.exports = {
'plugin-runtime/**/*', 'plugin-runtime/**/*',
'plugin-runtime-types/**/*', 'plugin-runtime-types/**/*',
'src-tauri/**/*', 'src-tauri/**/*',
'plugins/**/*', 'src-web/tailwind.config.cjs',
'tailwind.config.cjs', 'src-web/vite.config.ts',
'vite.config.ts',
], ],
settings: { settings: {
react: { react: {
+4 -14
View File
@@ -16,10 +16,10 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- platform: 'macos-latest' # for Arm-based macs (M1 and above). - platform: 'macos-latest' # for Arm-based Macs (M1 and above).
args: '--target aarch64-apple-darwin' args: '--target aarch64-apple-darwin'
yaak_arch: 'arm64' yaak_arch: 'arm64'
- platform: 'macos-latest' # for Intel-based macs. - platform: 'macos-latest' # for Intel-based Macs.
args: '--target x86_64-apple-darwin' args: '--target x86_64-apple-darwin'
yaak_arch: 'x64' yaak_arch: 'x64'
- platform: 'ubuntu-22.04' # for Tauri v1, you could replace this with ubuntu-20.04. - platform: 'ubuntu-22.04' # for Tauri v1, you could replace this with ubuntu-20.04.
@@ -36,7 +36,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 22
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
@@ -66,12 +66,7 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Node dependencies - name: Install NPM Dependencies
run: |
npm ci
- name: Install plugin-runtime Node dependencies
working-directory: plugin-runtime
run: | run: |
npm ci npm ci
@@ -80,11 +75,6 @@ jobs:
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install yaak CLI
run: |
npm install -g @yaakapp/cli
yaakcli --version
- name: Run lint - name: Run lint
run: npm run lint run: npm run lint
-1
View File
@@ -1 +0,0 @@
_
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
+1185 -690
View File
File diff suppressed because it is too large Load Diff
+14 -92
View File
@@ -2,120 +2,42 @@
"name": "yaak-app", "name": "yaak-app",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/yaakapp/app.git" "url": "git+https://github.com/yaakapp/app.git"
}, },
"workspaces": [
"src-tauri/yaak_plugin_runtime",
"src-tauri/yaak_models",
"src-tauri/yaak_templates",
"src-web",
"plugin-runtime",
"plugin-runtime-types"
],
"scripts": { "scripts": {
"start": "npm run tauri-dev:desktop", "app-build": "tauri build",
"tauri-dev:desktop": "tauri dev --no-watch --config ./src-tauri/tauri-dev.conf.json", "app-dev": "tauri dev --no-watch --config ./src-tauri/tauri-dev.conf.json",
"tauri-dev:ios": "tauri ios dev --force-ip-prompt --config ./src-tauri/tauri-dev.conf.json", "tauri-before-build": "npm run --workspaces --if-present build",
"tauri-build": "tauri build", "tauri-before-dev": "npm run --workspaces --if-present dev",
"tauri": "tauri", "lint": "npm run --workspaces --if-present lint",
"dev:js": "vite dev",
"lint": "tsc && eslint . --ext .ts,.tsx",
"build": "run-p build:*",
"build:icon:release": "tauri icon ./src-tauri/icons/icon.png --output ./src-tauri/icons/release",
"build:icon:dev": "tauri icon ./src-tauri/icons/icon-dev.png --output ./src-tauri/icons/dev",
"build:js": "vite build",
"build:plugin-runtime": "npm run --prefix plugin-runtime build",
"build:vendor-protoc": "node scripts/vendor-protoc.cjs", "build:vendor-protoc": "node scripts/vendor-protoc.cjs",
"build:vendor-plugins": "node scripts/vendor-plugins.cjs", "build:vendor-plugins": "node scripts/vendor-plugins.cjs",
"build:vendor-node": "node scripts/vendor-node.cjs", "build:vendor-node": "node scripts/vendor-node.cjs",
"prepare": "husky install",
"replace-version": "node scripts/replace-version.cjs" "replace-version": "node scripts/replace-version.cjs"
}, },
"dependencies": {
"@codemirror/commands": "^6",
"@codemirror/lang-javascript": "^6",
"@codemirror/lang-json": "^6",
"@codemirror/lang-xml": "^6",
"@codemirror/language": "^6",
"@codemirror/search": "^6",
"@lezer/generator": "^1.7.1",
"@lezer/highlight": "^1.2.1",
"@lezer/lr": "^1.4.2",
"@react-hook/resize-observer": "^2.0.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^5.55.4",
"@tauri-apps/api": "^2.0.0-rc.5",
"@tauri-apps/plugin-clipboard-manager": "^2.0.0-rc.2",
"@tauri-apps/plugin-dialog": "^2.0.0-rc.1",
"@tauri-apps/plugin-fs": "^2.0.0-rc.2",
"@tauri-apps/plugin-log": "^2.0.0-rc.1",
"@tauri-apps/plugin-os": "^2.0.0-rc.1",
"@tauri-apps/plugin-shell": "^2.0.0-rc.1",
"@yaakapp/api": "^0.2.4",
"buffer": "^6.0.3",
"classnames": "^2.5.1",
"cm6-graphql": "^0.0.9",
"codemirror": "^6.0.1",
"codemirror-json-schema": "^0.7.8",
"date-fns": "^3.6.0",
"eventemitter3": "^5.0.1",
"fast-fuzzy": "^1.12.0",
"focus-trap-react": "^10.2.3",
"format-graphql": "^1.5.0",
"framer-motion": "^11.5.4",
"jotai": "^2.9.3",
"lucide-react": "^0.439.0",
"mime": "^4.0.4",
"papaparse": "^5.4.1",
"parse-color": "^1.0.0",
"react": "^18.3.1",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.3.1",
"react-helmet-async": "^2.0.5",
"react-pdf": "^9.1.0",
"react-router-dom": "^6.26.2",
"react-use": "^17.5.1",
"slugify": "^1.6.6",
"uuid": "^10.0.0",
"xml-formatter": "^3.6.3"
},
"devDependencies": { "devDependencies": {
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
"@tanstack/react-query-devtools": "^5.55.4",
"@tauri-apps/cli": "^2.0.0-rc.16", "@tauri-apps/cli": "^2.0.0-rc.16",
"@types/node": "^22.5.4",
"@types/papaparse": "^5.3.14",
"@types/parse-color": "^1.0.3",
"@types/parse-json": "^4.0.2",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.5.0", "@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0", "@typescript-eslint/parser": "^8.5.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"decompress": "^4.2.1",
"eslint": "^8", "eslint": "^8",
"eslint-config-prettier": "^8", "eslint-config-prettier": "^8",
"eslint-plugin-import": "^2.30.0", "eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0", "eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.35.2", "eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-hooks": "^4.6.2",
"husky": "^9.1.5",
"internal-ip": "^8.0.0",
"lint-staged": "^15.2.10",
"nodejs-file-downloader": "^4.13.0", "nodejs-file-downloader": "^4.13.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"postcss": "^8.4.45",
"postcss-nesting": "^13.0.0",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"react-devtools": "^5.3.1", "typescript": "^5.6.0"
"rimraf": "^6.0.1",
"tailwindcss": "^3.4.10",
"typescript": "^5.6.0",
"vite": "^5.4.6",
"vite-plugin-static-copy": "^1.0.6",
"vite-plugin-svgr": "^4.2.0",
"vite-plugin-top-level-await": "^1.4.4"
},
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*.{js,css,md}": "prettier --write"
} }
} }
+7 -3
View File
@@ -1,19 +1,23 @@
{ {
"name": "@yaakapp/api", "name": "@yaakapp/api",
"version": "0.2.5", "version": "0.2.7",
"main": "lib/index.js", "main": "lib/index.js",
"typings": "./lib/index.d.ts", "typings": "./lib/index.d.ts",
"files": [ "files": [
"lib" "lib/**/*"
], ],
"scripts": { "scripts": {
"build": "tsc", "build": "run-s build:copy-types build:tsc",
"build:tsc": "tsc",
"build:copy-types": "cpy --flat ../src-tauri/yaak_plugin_runtime/bindings/*.ts ./src/bindings/",
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
}, },
"devDependencies": { "devDependencies": {
"cpy-cli": "^5.0.0",
"npm-run-all": "^4.1.5",
"typescript": "^5.6.2" "typescript": "^5.6.2"
} }
} }
@@ -1,15 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { CookieJar } from "./models";
import type { Environment } from "./models"; import type { Environment } from "./models";
import type { Folder } from "./models"; import type { Folder } from "./models";
import type { GrpcConnection } from "./models";
import type { GrpcEvent } from "./models";
import type { GrpcRequest } from "./models"; import type { GrpcRequest } from "./models";
import type { HttpRequest } from "./models"; import type { HttpRequest } from "./models";
import type { HttpResponse } from "./models"; import type { HttpResponse } from "./models";
import type { KeyValue } from "./models";
import type { Plugin } from "./models";
import type { Settings } from "./models";
import type { Workspace } from "./models"; import type { Workspace } from "./models";
export type BootRequest = { dir: string, }; export type BootRequest = { dir: string, };
@@ -66,8 +60,6 @@ export type InternalEvent = { id: string, pluginRefId: string, replyId: string |
export type InternalEventPayload = { "type": "boot_request" } & BootRequest | { "type": "boot_response" } & BootResponse | { "type": "reload_request" } | { "type": "reload_response" } | { "type": "terminate_request" } | { "type": "terminate_response" } | { "type": "import_request" } & ImportRequest | { "type": "import_response" } & ImportResponse | { "type": "filter_request" } & FilterRequest | { "type": "filter_response" } & FilterResponse | { "type": "export_http_request_request" } & ExportHttpRequestRequest | { "type": "export_http_request_response" } & ExportHttpRequestResponse | { "type": "send_http_request_request" } & SendHttpRequestRequest | { "type": "send_http_request_response" } & SendHttpRequestResponse | { "type": "get_http_request_actions_request" } & GetHttpRequestActionsRequest | { "type": "get_http_request_actions_response" } & GetHttpRequestActionsResponse | { "type": "call_http_request_action_request" } & CallHttpRequestActionRequest | { "type": "get_template_functions_request" } | { "type": "get_template_functions_response" } & GetTemplateFunctionsResponse | { "type": "call_template_function_request" } & CallTemplateFunctionRequest | { "type": "call_template_function_response" } & CallTemplateFunctionResponse | { "type": "copy_text_request" } & CopyTextRequest | { "type": "render_http_request_request" } & RenderHttpRequestRequest | { "type": "render_http_request_response" } & RenderHttpRequestResponse | { "type": "show_toast_request" } & ShowToastRequest | { "type": "get_http_request_by_id_request" } & GetHttpRequestByIdRequest | { "type": "get_http_request_by_id_response" } & GetHttpRequestByIdResponse | { "type": "find_http_responses_request" } & FindHttpResponsesRequest | { "type": "find_http_responses_response" } & FindHttpResponsesResponse | { "type": "empty_response" }; export type InternalEventPayload = { "type": "boot_request" } & BootRequest | { "type": "boot_response" } & BootResponse | { "type": "reload_request" } | { "type": "reload_response" } | { "type": "terminate_request" } | { "type": "terminate_response" } | { "type": "import_request" } & ImportRequest | { "type": "import_response" } & ImportResponse | { "type": "filter_request" } & FilterRequest | { "type": "filter_response" } & FilterResponse | { "type": "export_http_request_request" } & ExportHttpRequestRequest | { "type": "export_http_request_response" } & ExportHttpRequestResponse | { "type": "send_http_request_request" } & SendHttpRequestRequest | { "type": "send_http_request_response" } & SendHttpRequestResponse | { "type": "get_http_request_actions_request" } & GetHttpRequestActionsRequest | { "type": "get_http_request_actions_response" } & GetHttpRequestActionsResponse | { "type": "call_http_request_action_request" } & CallHttpRequestActionRequest | { "type": "get_template_functions_request" } | { "type": "get_template_functions_response" } & GetTemplateFunctionsResponse | { "type": "call_template_function_request" } & CallTemplateFunctionRequest | { "type": "call_template_function_response" } & CallTemplateFunctionResponse | { "type": "copy_text_request" } & CopyTextRequest | { "type": "render_http_request_request" } & RenderHttpRequestRequest | { "type": "render_http_request_response" } & RenderHttpRequestResponse | { "type": "show_toast_request" } & ShowToastRequest | { "type": "get_http_request_by_id_request" } & GetHttpRequestByIdRequest | { "type": "get_http_request_by_id_response" } & GetHttpRequestByIdResponse | { "type": "find_http_responses_request" } & FindHttpResponsesRequest | { "type": "find_http_responses_response" } & FindHttpResponsesResponse | { "type": "empty_response" };
export type Model = Environment | Folder | GrpcConnection | GrpcEvent | GrpcRequest | HttpRequest | HttpResponse | KeyValue | Workspace | CookieJar | Settings | Plugin;
export type RenderHttpRequestRequest = { httpRequest: HttpRequest, purpose: RenderPurpose, }; export type RenderHttpRequestRequest = { httpRequest: HttpRequest, purpose: RenderPurpose, };
export type RenderHttpRequestResponse = { httpRequest: HttpRequest, }; export type RenderHttpRequestResponse = { httpRequest: HttpRequest, };
@@ -0,0 +1,23 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
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 = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
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 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 = { 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 Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
-43
View File
@@ -1,43 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
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 Environment = { id: string, workspaceId: string, model: "environment", 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 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 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 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 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 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 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 Plugin = { id: string, model: "plugin", createdAt: string, updatedAt: string, checkedAt: string | null, directory: string, url: string | null, enabled: boolean, };
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 Workspace = { id: string, model: "workspace", createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
-1
View File
@@ -1,2 +1 @@
export type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>; export type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
export type OneOrMany<T> = T[] | T;
+2 -2
View File
@@ -1,5 +1,5 @@
export type * from './plugins'; export type * from './plugins';
export type * from './themes'; export type * from './themes';
export * from './gen/model_util'; export * from './bindings/models';
export * from './gen/events'; export * from './bindings/events';
+1 -1
View File
@@ -8,7 +8,7 @@ import {
SendHttpRequestRequest, SendHttpRequestRequest,
SendHttpRequestResponse, SendHttpRequestResponse,
ShowToastRequest, ShowToastRequest,
} from '../gen/events'; } from '..';
export type Context = { export type Context = {
clipboard: { clipboard: {
@@ -1,4 +1,4 @@
import { CallHttpRequestActionArgs, HttpRequestAction } from '../gen/events'; import { CallHttpRequestActionArgs, HttpRequestAction } from '..';
import { Context } from './Context'; import { Context } from './Context';
export type HttpRequestActionPlugin = HttpRequestAction & { export type HttpRequestActionPlugin = HttpRequestAction & {
@@ -1,4 +1,4 @@
import { Environment, Folder, HttpRequest, Workspace } from '../gen/model_util'; import { Environment, Folder, HttpRequest, Workspace } from '..';
import { AtLeast } from '../helpers'; import { AtLeast } from '../helpers';
import { Context } from './Context'; import { Context } from './Context';
@@ -1,4 +1,4 @@
import { CallTemplateFunctionArgs, TemplateFunction } from '../gen/events'; import { CallTemplateFunctionArgs, TemplateFunction } from '..';
import { Context } from './Context'; import { Context } from './Context';
export type TemplateFunctionPlugin = TemplateFunction & { export type TemplateFunctionPlugin = TemplateFunction & {
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "@yaak/plugin-runtime", "name": "@yaakapp-internal/plugin-runtime",
"scripts": { "scripts": {
"dev": "nodemon", "dev": "nodemon",
"build": "run-p build:*", "build": "run-p build:*",
+3 -3
View File
@@ -1,11 +1,11 @@
use std::collections::HashMap; use std::collections::BTreeMap;
use KeyAndValueRef::{Ascii, Binary}; use KeyAndValueRef::{Ascii, Binary};
use yaak_grpc::{KeyAndValueRef, MetadataMap}; use yaak_grpc::{KeyAndValueRef, MetadataMap};
pub fn metadata_to_map(metadata: MetadataMap) -> HashMap<String, String> { pub fn metadata_to_map(metadata: MetadataMap) -> BTreeMap<String, String> {
let mut entries = HashMap::new(); let mut entries = BTreeMap::new();
for r in metadata.iter() { for r in metadata.iter() {
match r { match r {
Ascii(k, v) => entries.insert(k.to_string(), v.to_str().unwrap().to_string()), Ascii(k, v) => entries.insert(k.to_string(), v.to_str().unwrap().to_string()),
+2 -2
View File
@@ -1,4 +1,4 @@
use std::collections::HashMap; use std::collections::BTreeMap;
use std::fs; use std::fs;
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};
use std::io::Write; use std::io::Write;
@@ -487,7 +487,7 @@ fn get_str<'a>(v: &'a Value, key: &str) -> &'a str {
} }
} }
fn get_str_h<'a>(v: &'a HashMap<String, Value>, key: &str) -> &'a str { fn get_str_h<'a>(v: &'a BTreeMap<String, Value>, key: &str) -> &'a str {
match v.get(key) { match v.get(key) {
None => "", None => "",
Some(v) => v.as_str().unwrap_or_default(), Some(v) => v.as_str().unwrap_or_default(),
+5 -5
View File
@@ -2,7 +2,7 @@ extern crate core;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
extern crate objc; extern crate objc;
use std::collections::HashMap; use std::collections::{BTreeMap};
use std::fs; use std::fs;
use std::fs::{create_dir_all, read_to_string, File}; use std::fs::{create_dir_all, read_to_string, File};
use std::path::PathBuf; use std::path::PathBuf;
@@ -210,7 +210,7 @@ async fn cmd_grpc_go(
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
let req = let req =
render_grpc_request(window.app_handle(), &req, &workspace, environment.as_ref()).await; render_grpc_request(window.app_handle(), &req, &workspace, environment.as_ref()).await;
let mut metadata = HashMap::new(); let mut metadata = BTreeMap::new();
// Add the rest of metadata // Add the rest of metadata
for h in req.clone().metadata { for h in req.clone().metadata {
@@ -794,9 +794,9 @@ async fn cmd_import_data(
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
let mut imported_resources = WorkspaceExportResources::default(); let mut imported_resources = WorkspaceExportResources::default();
let mut id_map: HashMap<String, String> = HashMap::new(); let mut id_map: BTreeMap<String, String> = BTreeMap::new();
fn maybe_gen_id(id: &str, model: ModelType, ids: &mut HashMap<String, String>) -> String { fn maybe_gen_id(id: &str, model: ModelType, ids: &mut BTreeMap<String, String>) -> String {
if !id.starts_with("GENERATE_ID::") { if !id.starts_with("GENERATE_ID::") {
return id.to_string(); return id.to_string();
} }
@@ -814,7 +814,7 @@ async fn cmd_import_data(
fn maybe_gen_id_opt( fn maybe_gen_id_opt(
id: Option<String>, id: Option<String>,
model: ModelType, model: ModelType,
ids: &mut HashMap<String, String>, ids: &mut BTreeMap<String, String>,
) -> Option<String> { ) -> Option<String> {
match id { match id {
Some(id) => Some(maybe_gen_id(id.as_str(), model, ids)), Some(id) => Some(maybe_gen_id(id.as_str(), model, ids)),
+15 -12
View File
@@ -1,6 +1,6 @@
use crate::template_callback::PluginTemplateCallback; use crate::template_callback::PluginTemplateCallback;
use serde_json::{json, Map, Value}; use serde_json::{json, Map, Value};
use std::collections::HashMap; use std::collections::{BTreeMap, HashMap};
use tauri::{AppHandle, Manager, Runtime}; use tauri::{AppHandle, Manager, Runtime};
use yaak_models::models::{ use yaak_models::models::{
Environment, EnvironmentVariable, GrpcMetadataEntry, GrpcRequest, HttpRequest, Environment, EnvironmentVariable, GrpcMetadataEntry, GrpcRequest, HttpRequest,
@@ -37,7 +37,7 @@ pub async fn render_grpc_request<R: Runtime>(
}) })
} }
let mut authentication = HashMap::new(); let mut authentication = BTreeMap::new();
for (k, v) in r.authentication.clone() { for (k, v) in r.authentication.clone() {
authentication.insert(k, render_json_value(v, vars, cb).await); authentication.insert(k, render_json_value(v, vars, cb).await);
} }
@@ -78,12 +78,12 @@ pub async fn render_http_request(
}) })
} }
let mut body = HashMap::new(); let mut body = BTreeMap::new();
for (k, v) in r.body.clone() { for (k, v) in r.body.clone() {
body.insert(k, render_json_value(v, vars, cb).await); body.insert(k, render_json_value(v, vars, cb).await);
} }
let mut authentication = HashMap::new(); let mut authentication = BTreeMap::new();
for (k, v) in r.authentication.clone() { for (k, v) in r.authentication.clone() {
authentication.insert(k, render_json_value(v, vars, cb).await); authentication.insert(k, render_json_value(v, vars, cb).await);
} }
@@ -250,13 +250,16 @@ mod tests {
vars.insert("a".to_string(), "aaa".to_string()); vars.insert("a".to_string(), "aaa".to_string());
let result = super::render_json_value(v, &vars, &EmptyCB {}).await; let result = super::render_json_value(v, &vars, &EmptyCB {}).await;
assert_eq!(result, json!([ assert_eq!(
123, result,
{"aaa": "aaa"}, json!([
null, 123,
"aaa", {"aaa": "aaa"},
false, null,
{"x": ["aaa"]} "aaa",
])) false,
{"x": ["aaa"]}
])
)
} }
} }
+2 -2
View File
@@ -3,8 +3,8 @@
"version": "0.0.0", "version": "0.0.0",
"identifier": "app.yaak.desktop", "identifier": "app.yaak.desktop",
"build": { "build": {
"beforeBuildCommand": "npm run build", "beforeBuildCommand": "npm run tauri-before-build",
"beforeDevCommand": "npm run dev:js", "beforeDevCommand": "npm run tauri-before-dev",
"devUrl": "http://localhost:1420", "devUrl": "http://localhost:1420",
"frontendDist": "../dist" "frontendDist": "../dist"
}, },
+8 -8
View File
@@ -1,4 +1,4 @@
use std::collections::HashMap; use std::collections::BTreeMap;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
@@ -75,7 +75,7 @@ impl GrpcConnection {
service: &str, service: &str,
method: &str, method: &str,
message: &str, message: &str,
metadata: HashMap<String, String>, metadata: BTreeMap<String, String>,
) -> Result<Response<DynamicMessage>, StreamError> { ) -> Result<Response<DynamicMessage>, StreamError> {
let method = &self.method(&service, &method)?; let method = &self.method(&service, &method)?;
let input_message = method.input(); let input_message = method.input();
@@ -102,7 +102,7 @@ impl GrpcConnection {
service: &str, service: &str,
method: &str, method: &str,
stream: ReceiverStream<DynamicMessage>, stream: ReceiverStream<DynamicMessage>,
metadata: HashMap<String, String>, metadata: BTreeMap<String, String>,
) -> Result<Response<Streaming<DynamicMessage>>, StreamError> { ) -> Result<Response<Streaming<DynamicMessage>>, StreamError> {
let method = &self.method(&service, &method)?; let method = &self.method(&service, &method)?;
let mut client = tonic::client::Grpc::with_origin(self.conn.clone(), self.uri.clone()); let mut client = tonic::client::Grpc::with_origin(self.conn.clone(), self.uri.clone());
@@ -122,7 +122,7 @@ impl GrpcConnection {
service: &str, service: &str,
method: &str, method: &str,
stream: ReceiverStream<DynamicMessage>, stream: ReceiverStream<DynamicMessage>,
metadata: HashMap<String, String>, metadata: BTreeMap<String, String>,
) -> Result<Response<DynamicMessage>, StreamError> { ) -> Result<Response<DynamicMessage>, StreamError> {
let method = &self.method(&service, &method)?; let method = &self.method(&service, &method)?;
let mut client = tonic::client::Grpc::with_origin(self.conn.clone(), self.uri.clone()); let mut client = tonic::client::Grpc::with_origin(self.conn.clone(), self.uri.clone());
@@ -146,7 +146,7 @@ impl GrpcConnection {
service: &str, service: &str,
method: &str, method: &str,
message: &str, message: &str,
metadata: HashMap<String, String>, metadata: BTreeMap<String, String>,
) -> Result<Response<Streaming<DynamicMessage>>, StreamError> { ) -> Result<Response<Streaming<DynamicMessage>>, StreamError> {
let method = &self.method(&service, &method)?; let method = &self.method(&service, &method)?;
let input_message = method.input(); let input_message = method.input();
@@ -170,12 +170,12 @@ impl GrpcConnection {
pub struct GrpcHandle { pub struct GrpcHandle {
app_handle: AppHandle, app_handle: AppHandle,
pools: HashMap<String, DescriptorPool>, pools: BTreeMap<String, DescriptorPool>,
} }
impl GrpcHandle { impl GrpcHandle {
pub fn new(app_handle: &AppHandle) -> Self { pub fn new(app_handle: &AppHandle) -> Self {
let pools = HashMap::new(); let pools = BTreeMap::new();
Self { Self {
pools, pools,
app_handle: app_handle.clone(), app_handle: app_handle.clone(),
@@ -268,7 +268,7 @@ impl GrpcHandle {
} }
} }
fn decorate_req<T>(metadata: HashMap<String, String>, req: &mut Request<T>) -> Result<(), String> { fn decorate_req<T>(metadata: BTreeMap<String, String>, req: &mut Request<T>) -> Result<(), String> {
for (k, v) in metadata { for (k, v) in metadata {
req.metadata_mut().insert( req.metadata_mut().insert(
MetadataKey::from_str(k.as_str()).map_err(|e| e.to_string())?, MetadataKey::from_str(k.as_str()).map_err(|e| e.to_string())?,
+1
View 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 GrpcEventType = "info" | "error" | "client_message" | "server_message" | "connection_start" | "connection_end";
-3
View File
@@ -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, };
+14 -12
View File
@@ -1,43 +1,45 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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 Cookie = { raw_cookie: string, domain: CookieDomain, expires: CookieExpires, path: [string, boolean], };
export type CookieDomain = { "HostOnly": string } | { "Suffix": string } | "NotPresent" | "Empty"; export type CookieDomain = { "HostOnly": string } | { "Suffix": string } | "NotPresent" | "Empty";
export type CookieExpires = { "AtUtc": string } | "SessionEnd"; 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 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 GrpcEventType = "info" | "error" | "client_message" | "server_message" | "connection_start" | "connection_end";
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, }; 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 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 HttpResponseHeader = { name: string, value: string, };
export type HttpUrlParameter = { enabled?: boolean, 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
View File
@@ -0,0 +1 @@
export * from './bindings/models';
+10
View 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"
}
}
+182 -141
View File
@@ -2,51 +2,53 @@ use chrono::NaiveDateTime;
use rusqlite::Row; use rusqlite::Row;
use sea_query::Iden; use sea_query::Iden;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use serde_json::Value; use serde_json::Value;
use std::collections::BTreeMap;
use ts_rs::TS; use ts_rs::TS;
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Settings { pub struct Settings {
pub id: String,
#[ts(type = "\"settings\"")] #[ts(type = "\"settings\"")]
pub model: String, pub model: String,
pub id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub theme: String,
pub appearance: 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_dark: String,
pub theme_light: String, pub theme_light: String,
pub update_channel: 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)] #[derive(Iden)]
pub enum SettingsIden { pub enum SettingsIden {
#[iden = "settings"] #[iden = "settings"]
Table, Table,
Id,
Model, Model,
Id,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Theme,
Appearance, Appearance,
UpdateChannel,
ThemeDark,
ThemeLight,
InterfaceFontSize,
InterfaceScale,
EditorFontSize, EditorFontSize,
EditorSoftWrap, EditorSoftWrap,
Telemetry, InterfaceFontSize,
InterfaceScale,
OpenWorkspaceNewWindow, OpenWorkspaceNewWindow,
Telemetry,
Theme,
ThemeDark,
ThemeLight,
UpdateChannel,
} }
impl<'s> TryFrom<&Row<'s>> for Settings { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Workspace { pub struct Workspace {
pub id: String,
#[ts(type = "\"workspace\"")] #[ts(type = "\"workspace\"")]
pub model: String, pub model: String,
pub id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub name: String, pub name: String,
@@ -98,16 +100,17 @@ pub struct Workspace {
pub enum WorkspaceIden { pub enum WorkspaceIden {
#[iden = "workspaces"] #[iden = "workspaces"]
Table, Table,
Id,
Model, Model,
Id,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Name,
Description, Description,
Variables, Name,
SettingValidateCertificates,
SettingFollowRedirects, SettingFollowRedirects,
SettingRequestTimeout, SettingRequestTimeout,
SettingValidateCertificates,
Variables,
} }
impl<'s> TryFrom<&Row<'s>> for Workspace { impl<'s> TryFrom<&Row<'s>> for Workspace {
@@ -143,7 +146,7 @@ impl Workspace {
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
enum CookieDomain { enum CookieDomain {
HostOnly(String), HostOnly(String),
Suffix(String), Suffix(String),
@@ -152,14 +155,14 @@ enum CookieDomain {
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
enum CookieExpires { enum CookieExpires {
AtUtc(String), AtUtc(String),
SessionEnd, SessionEnd,
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Cookie { pub struct Cookie {
raw_cookie: String, raw_cookie: String,
domain: CookieDomain, domain: CookieDomain,
@@ -169,16 +172,17 @@ pub struct Cookie {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct CookieJar { pub struct CookieJar {
pub id: String,
#[ts(type = "\"cookie_jar\"")] #[ts(type = "\"cookie_jar\"")]
pub model: String, pub model: String,
pub id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub workspace_id: String, pub workspace_id: String,
pub name: String,
pub cookies: Vec<Cookie>, pub cookies: Vec<Cookie>,
pub name: String,
} }
#[derive(Iden)] #[derive(Iden)]
@@ -190,8 +194,9 @@ pub enum CookieJarIden {
WorkspaceId, WorkspaceId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Name,
Cookies, Cookies,
Name,
} }
impl<'s> TryFrom<&Row<'s>> for CookieJar { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Environment { pub struct Environment {
pub id: String,
pub workspace_id: String,
#[ts(type = "\"environment\"")] #[ts(type = "\"environment\"")]
pub model: String, pub model: String,
pub id: String,
pub workspace_id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub name: String, pub name: String,
pub variables: Vec<EnvironmentVariable>, pub variables: Vec<EnvironmentVariable>,
} }
@@ -229,11 +235,12 @@ pub struct Environment {
pub enum EnvironmentIden { pub enum EnvironmentIden {
#[iden = "environments"] #[iden = "environments"]
Table, Table,
Id,
Model, Model,
WorkspaceId, Id,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
WorkspaceId,
Name, Name,
Variables, Variables,
} }
@@ -257,7 +264,7 @@ impl<'s> TryFrom<&Row<'s>> for Environment {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct EnvironmentVariable { pub struct EnvironmentVariable {
#[serde(default = "default_true")] #[serde(default = "default_true")]
#[ts(optional, as = "Option<bool>")] #[ts(optional, as = "Option<bool>")]
@@ -268,15 +275,16 @@ pub struct EnvironmentVariable {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Folder { 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\"")] #[ts(type = "\"folder\"")]
pub model: String, 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 name: String,
pub sort_priority: f32, pub sort_priority: f32,
} }
@@ -291,6 +299,7 @@ pub enum FolderIden {
FolderId, FolderId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Name, Name,
SortPriority, SortPriority,
} }
@@ -314,7 +323,7 @@ impl<'s> TryFrom<&Row<'s>> for Folder {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct HttpRequestHeader { pub struct HttpRequestHeader {
#[serde(default = "default_true")] #[serde(default = "default_true")]
#[ts(optional, as = "Option<bool>")] #[ts(optional, as = "Option<bool>")]
@@ -325,7 +334,7 @@ pub struct HttpRequestHeader {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct HttpUrlParameter { pub struct HttpUrlParameter {
#[serde(default = "default_true")] #[serde(default = "default_true")]
#[ts(optional, as = "Option<bool>")] #[ts(optional, as = "Option<bool>")]
@@ -336,28 +345,29 @@ pub struct HttpUrlParameter {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct HttpRequest { 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\"")] #[ts(type = "\"http_request\"")]
pub model: String, pub model: String,
pub sort_priority: f32, pub id: String,
pub name: String, pub created_at: NaiveDateTime,
pub url: String, pub updated_at: NaiveDateTime,
pub url_parameters: Vec<HttpUrlParameter>, 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")] #[serde(default = "default_http_request_method")]
pub method: String, pub method: String,
#[ts(type = "Record<string, any>")] pub name: String,
pub body: HashMap<String, Value>, pub sort_priority: f32,
pub body_type: Option<String>, pub url: String,
#[ts(type = "Record<string, any>")] pub url_parameters: Vec<HttpUrlParameter>,
pub authentication: HashMap<String, Value>,
pub authentication_type: Option<String>,
pub headers: Vec<HttpRequestHeader>,
} }
#[derive(Iden)] #[derive(Iden)]
@@ -366,20 +376,21 @@ pub enum HttpRequestIden {
Table, Table,
Id, Id,
Model, Model,
WorkspaceId,
FolderId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
WorkspaceId,
FolderId,
Authentication,
AuthenticationType,
Body,
BodyType,
Headers,
Method,
Name, Name,
SortPriority, SortPriority,
Url, Url,
UrlParameters, UrlParameters,
Method,
Body,
BodyType,
Authentication,
AuthenticationType,
Headers,
} }
impl<'s> TryFrom<&Row<'s>> for HttpRequest { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct HttpResponseHeader { pub struct HttpResponseHeader {
pub name: String, pub name: String,
pub value: String, pub value: String,
@@ -421,49 +432,51 @@ pub struct HttpResponseHeader {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct HttpResponse { pub struct HttpResponse {
pub id: String,
#[ts(type = "\"http_response\"")] #[ts(type = "\"http_response\"")]
pub model: String, pub model: String,
pub workspace_id: String, pub id: String,
pub request_id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub error: Option<String>, pub workspace_id: String,
pub url: String, pub request_id: String,
pub body_path: Option<String>,
pub content_length: Option<i32>, pub content_length: Option<i32>,
pub version: Option<String>,
pub elapsed: i32, pub elapsed: i32,
pub elapsed_headers: i32, pub elapsed_headers: i32,
pub error: Option<String>,
pub headers: Vec<HttpResponseHeader>,
pub remote_addr: Option<String>, pub remote_addr: Option<String>,
pub status: i32, pub status: i32,
pub status_reason: Option<String>, pub status_reason: Option<String>,
pub body_path: Option<String>, pub url: String,
pub headers: Vec<HttpResponseHeader>, pub version: Option<String>,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum HttpResponseIden { pub enum HttpResponseIden {
#[iden = "http_responses"] #[iden = "http_responses"]
Table, Table,
Id,
Model, Model,
WorkspaceId, Id,
RequestId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Error, WorkspaceId,
Url, RequestId,
BodyPath,
ContentLength, ContentLength,
Version,
Elapsed, Elapsed,
ElapsedHeaders, ElapsedHeaders,
Error,
Headers,
RemoteAddr, RemoteAddr,
Status, Status,
StatusReason, StatusReason,
BodyPath, Url,
Headers, Version,
} }
impl<'s> TryFrom<&Row<'s>> for HttpResponse { impl<'s> TryFrom<&Row<'s>> for HttpResponse {
@@ -504,7 +517,7 @@ impl HttpResponse {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct GrpcMetadataEntry { pub struct GrpcMetadataEntry {
#[serde(default = "default_true")] #[serde(default = "default_true")]
#[ts(optional, as = "Option<bool>")] #[ts(optional, as = "Option<bool>")]
@@ -515,25 +528,26 @@ pub struct GrpcMetadataEntry {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct GrpcRequest { pub struct GrpcRequest {
pub id: String,
#[ts(type = "\"grpc_request\"")] #[ts(type = "\"grpc_request\"")]
pub model: String, pub model: String,
pub workspace_id: String, pub id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub workspace_id: String,
pub folder_id: Option<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>, pub authentication_type: Option<String>,
#[ts(type = "Record<string, any>")] #[ts(type = "Record<string, any>")]
pub authentication: HashMap<String, Value>, pub authentication: BTreeMap<String, Value>,
pub message: String,
pub metadata: Vec<GrpcMetadataEntry>, pub metadata: Vec<GrpcMetadataEntry>,
pub method: Option<String>,
pub name: String,
pub service: Option<String>,
pub sort_priority: f32,
pub url: String,
} }
#[derive(Iden)] #[derive(Iden)]
@@ -542,19 +556,20 @@ pub enum GrpcRequestIden {
Table, Table,
Id, Id,
Model, Model,
WorkspaceId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
WorkspaceId,
FolderId, FolderId,
Authentication,
AuthenticationType,
Message,
Metadata,
Method,
Name, Name,
Service,
SortPriority, SortPriority,
Url, Url,
Service,
Method,
Message,
AuthenticationType,
Authentication,
Metadata,
} }
impl<'s> TryFrom<&Row<'s>> for GrpcRequest { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct GrpcConnection { pub struct GrpcConnection {
pub id: String,
#[ts(type = "\"grpc_connection\"")] #[ts(type = "\"grpc_connection\"")]
pub model: String, pub model: String,
pub workspace_id: String, pub id: String,
pub request_id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub service: String, pub workspace_id: String,
pub method: String, pub request_id: String,
pub elapsed: i32, pub elapsed: i32,
pub status: i32,
pub url: String,
pub error: Option<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)] #[derive(Iden)]
pub enum GrpcConnectionIden { pub enum GrpcConnectionIden {
#[iden = "grpc_connections"] #[iden = "grpc_connections"]
Table, Table,
Id,
Model, Model,
WorkspaceId, Id,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
WorkspaceId,
RequestId, RequestId,
Service,
Method,
Elapsed, Elapsed,
Status,
Url,
Error, Error,
Method,
Service,
Status,
Trailers, Trailers,
Url,
} }
impl<'s> TryFrom<&Row<'s>> for GrpcConnection { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, TS)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub enum GrpcEventType { pub enum GrpcEventType {
Info, Info,
Error, Error,
@@ -665,39 +682,41 @@ impl Default for GrpcEventType {
#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct GrpcEvent { pub struct GrpcEvent {
pub id: String,
#[ts(type = "\"grpc_event\"")] #[ts(type = "\"grpc_event\"")]
pub model: String, pub model: String,
pub id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub workspace_id: String, pub workspace_id: String,
pub request_id: String, pub request_id: String,
pub connection_id: String, pub connection_id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub content: String, pub content: String,
pub event_type: GrpcEventType,
pub metadata: HashMap<String, String>,
pub status: Option<i32>,
pub error: Option<String>, pub error: Option<String>,
pub event_type: GrpcEventType,
pub metadata: BTreeMap<String, String>,
pub status: Option<i32>,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum GrpcEventIden { pub enum GrpcEventIden {
#[iden = "grpc_events"] #[iden = "grpc_events"]
Table, Table,
Id,
Model, Model,
Id,
CreatedAt,
UpdatedAt,
WorkspaceId, WorkspaceId,
RequestId, RequestId,
ConnectionId, ConnectionId,
CreatedAt,
UpdatedAt,
Content, Content,
Error,
EventType, EventType,
Metadata, Metadata,
Status, Status,
Error,
} }
impl<'s> TryFrom<&Row<'s>> for GrpcEvent { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct Plugin { pub struct Plugin {
pub id: String,
#[ts(type = "\"plugin\"")] #[ts(type = "\"plugin\"")]
pub model: String, pub model: String,
pub id: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub checked_at: Option<NaiveDateTime>, pub checked_at: Option<NaiveDateTime>,
pub directory: String, pub directory: String,
pub url: Option<String>,
pub enabled: bool, pub enabled: bool,
pub url: Option<String>,
} }
#[derive(Iden)] #[derive(Iden)]
pub enum PluginIden { pub enum PluginIden {
#[iden = "plugins"] #[iden = "plugins"]
Table, Table,
Id,
Model, Model,
Id,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
CheckedAt, CheckedAt,
Directory, Directory,
Url,
Enabled, Enabled,
Url,
} }
impl<'s> TryFrom<&Row<'s>> for Plugin { 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)] #[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="models.ts")] #[ts(export, export_to = "models.ts")]
pub struct KeyValue { pub struct KeyValue {
#[ts(type = "\"key_value\"")] #[ts(type = "\"key_value\"")]
pub model: String, pub model: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
pub namespace: String,
pub key: String, pub key: String,
pub namespace: String,
pub value: String, pub value: String,
} }
@@ -789,8 +811,9 @@ pub enum KeyValueIden {
Model, Model,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,
Namespace,
Key, Key,
Namespace,
Value, Value,
} }
@@ -847,3 +870,21 @@ impl ModelType {
.to_string() .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
View 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"
]
}
+1
View File
@@ -0,0 +1 @@
lib
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,89 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Environment } from "./models";
import type { Folder } from "./models";
import type { GrpcRequest } from "./models";
import type { HttpRequest } from "./models";
import type { HttpResponse } from "./models";
import type { Workspace } from "./models";
export type BootRequest = { dir: string, };
export type BootResponse = { name: string, version: string, capabilities: Array<string>, };
export type CallHttpRequestActionArgs = { httpRequest: HttpRequest, };
export type CallHttpRequestActionRequest = { key: string, pluginRefId: string, args: CallHttpRequestActionArgs, };
export type CallTemplateFunctionArgs = { purpose: RenderPurpose, values: { [key in string]?: string }, };
export type CallTemplateFunctionRequest = { name: string, args: CallTemplateFunctionArgs, };
export type CallTemplateFunctionResponse = { value: string | null, };
export type Color = "custom" | "default" | "primary" | "secondary" | "info" | "success" | "notice" | "warning" | "danger";
export type CopyTextRequest = { text: string, };
export type ExportHttpRequestRequest = { httpRequest: HttpRequest, };
export type ExportHttpRequestResponse = { content: string, };
export type FilterRequest = { content: string, filter: string, };
export type FilterResponse = { content: string, };
export type FindHttpResponsesRequest = { requestId: string, limit: number | null, };
export type FindHttpResponsesResponse = { httpResponses: Array<HttpResponse>, };
export type GetHttpRequestActionsRequest = Record<string, never>;
export type GetHttpRequestActionsResponse = { actions: Array<HttpRequestAction>, pluginRefId: string, };
export type GetHttpRequestByIdRequest = { id: string, };
export type GetHttpRequestByIdResponse = { httpRequest: HttpRequest | null, };
export type GetTemplateFunctionsResponse = { functions: Array<TemplateFunction>, pluginRefId: string, };
export type HttpRequestAction = { key: string, label: string, icon: string | null, };
export type Icon = "copy" | "info" | "check_circle" | "alert_triangle";
export type ImportRequest = { content: string, };
export type ImportResources = { workspaces: Array<Workspace>, environments: Array<Environment>, folders: Array<Folder>, httpRequests: Array<HttpRequest>, grpcRequests: Array<GrpcRequest>, };
export type ImportResponse = { resources: ImportResources, };
export type InternalEvent = { id: string, pluginRefId: string, replyId: string | null, payload: InternalEventPayload, };
export type InternalEventPayload = { "type": "boot_request" } & BootRequest | { "type": "boot_response" } & BootResponse | { "type": "reload_request" } | { "type": "reload_response" } | { "type": "terminate_request" } | { "type": "terminate_response" } | { "type": "import_request" } & ImportRequest | { "type": "import_response" } & ImportResponse | { "type": "filter_request" } & FilterRequest | { "type": "filter_response" } & FilterResponse | { "type": "export_http_request_request" } & ExportHttpRequestRequest | { "type": "export_http_request_response" } & ExportHttpRequestResponse | { "type": "send_http_request_request" } & SendHttpRequestRequest | { "type": "send_http_request_response" } & SendHttpRequestResponse | { "type": "get_http_request_actions_request" } & GetHttpRequestActionsRequest | { "type": "get_http_request_actions_response" } & GetHttpRequestActionsResponse | { "type": "call_http_request_action_request" } & CallHttpRequestActionRequest | { "type": "get_template_functions_request" } | { "type": "get_template_functions_response" } & GetTemplateFunctionsResponse | { "type": "call_template_function_request" } & CallTemplateFunctionRequest | { "type": "call_template_function_response" } & CallTemplateFunctionResponse | { "type": "copy_text_request" } & CopyTextRequest | { "type": "render_http_request_request" } & RenderHttpRequestRequest | { "type": "render_http_request_response" } & RenderHttpRequestResponse | { "type": "show_toast_request" } & ShowToastRequest | { "type": "get_http_request_by_id_request" } & GetHttpRequestByIdRequest | { "type": "get_http_request_by_id_response" } & GetHttpRequestByIdResponse | { "type": "find_http_responses_request" } & FindHttpResponsesRequest | { "type": "find_http_responses_response" } & FindHttpResponsesResponse | { "type": "empty_response" };
export type RenderHttpRequestRequest = { httpRequest: HttpRequest, purpose: RenderPurpose, };
export type RenderHttpRequestResponse = { httpRequest: HttpRequest, };
export type RenderPurpose = "send" | "preview";
export type SendHttpRequestRequest = { httpRequest: HttpRequest, };
export type SendHttpRequestResponse = { httpResponse: HttpResponse, };
export type ShowToastRequest = { message: string, color?: Color | null, icon?: Icon | null, };
export type TemplateFunction = { name: string, args: Array<TemplateFunctionArg>, };
export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg;
export type TemplateFunctionBaseArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, };
export type TemplateFunctionCheckboxArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, };
export type TemplateFunctionHttpRequestArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, };
export type TemplateFunctionSelectArg = { options: Array<TemplateFunctionSelectOption>, name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, };
export type TemplateFunctionSelectOption = { name: string, value: string, };
export type TemplateFunctionTextArg = { placeholder?: string | null, name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, };
@@ -1,3 +1,3 @@
"use strict";
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
Object.defineProperty(exports, "__esModule", { value: true });
export type CookieExpires = { "AtUtc": string } | "SessionEnd";
@@ -0,0 +1,23 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
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 = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
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 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 = { 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 Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
-3
View File
@@ -1,7 +1,4 @@
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
// Tell ts-rs where to generate types to
println!("cargo:rustc-env=TS_RS_EXPORT_DIR=../../plugin-runtime-types/src/gen");
// Compile protobuf types // Compile protobuf types
tonic_build::compile_protos("../../proto/plugins/runtime.proto")?; tonic_build::compile_protos("../../proto/plugins/runtime.proto")?;
+2
View File
@@ -0,0 +1,2 @@
export * from './bindings/models';
export * from './bindings/events';
@@ -0,0 +1,10 @@
{
"name": "@yaakapp-internal/plugin",
"private": true,
"version": "1.0.0",
"main": "lib/index.js",
"typings": "./lib/index.d.ts",
"scripts": {
"build": "tsc"
}
}
+2 -20
View File
@@ -3,8 +3,8 @@ use std::collections::HashMap;
use ts_rs::TS; use ts_rs::TS;
use yaak_models::models::{ use yaak_models::models::{
CookieJar, Environment, Folder, GrpcConnection, GrpcEvent, GrpcRequest, HttpRequest, Environment, Folder, GrpcRequest, HttpRequest,
HttpResponse, KeyValue, Plugin, Settings, Workspace, HttpResponse, Workspace,
}; };
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
@@ -402,21 +402,3 @@ pub struct ImportResources {
pub http_requests: Vec<HttpRequest>, pub http_requests: Vec<HttpRequest>,
pub grpc_requests: Vec<GrpcRequest>, pub grpc_requests: Vec<GrpcRequest>,
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase", untagged)]
#[ts(export, export_to="events.ts")]
pub enum Model {
Environment(Environment),
Folder(Folder),
GrpcConnection(GrpcConnection),
GrpcEvent(GrpcEvent),
GrpcRequest(GrpcRequest),
HttpRequest(HttpRequest),
HttpResponse(HttpResponse),
KeyValue(KeyValue),
Workspace(Workspace),
CookieJar(CookieJar),
Settings(Settings),
Plugin(Plugin),
}
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "node16",
"target": "es6",
"lib": ["es2021"],
"declaration": true,
"declarationDir": "./lib",
"outDir": "./lib",
"strict": true,
"types": ["node"]
},
"files": [
"index.ts"
]
}
@@ -1,4 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FnArg } from "./FnArg";
export type FnArg = { name: string, value: Val, };
export type Token = { "type": "raw", text: string, } | { "type": "tag", val: Val, } | { "type": "eof" };
export type Tokens = { tokens: Array<Token>, };
export type Val = { "type": "str", text: string, } | { "type": "var", name: string, } | { "type": "bool", value: boolean, } | { "type": "fn", name: string, args: Array<FnArg>, } | { "type": "null" }; export type Val = { "type": "str", text: string, } | { "type": "var", name: string, } | { "type": "bool", value: boolean, } | { "type": "fn", name: string, args: Array<FnArg>, } | { "type": "null" };
-6
View File
@@ -1,6 +0,0 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Tell ts-rs where to generate types to
println!("cargo:rustc-env=TS_RS_EXPORT_DIR=../../src-web/gen");
Ok(())
}
+1
View File
@@ -0,0 +1 @@
export * from './bindings/parser';
+32
View File
@@ -0,0 +1,32 @@
export type FnArg = {
name: string;
value: Val;
};
export type Token = {
"type": "raw";
text: string;
} | {
"type": "tag";
val: Val;
} | {
"type": "eof";
};
export type Tokens = {
tokens: Array<Token>;
};
export type Val = {
"type": "str";
text: string;
} | {
"type": "var";
name: string;
} | {
"type": "bool";
value: boolean;
} | {
"type": "fn";
name: string;
args: Array<FnArg>;
} | {
"type": "null";
};
@@ -1,4 +1,3 @@
"use strict";
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Val } from "./Val"; Object.defineProperty(exports, "__esModule", { value: true });
export type FnArg = { name: string, value: Val, };
+1
View File
@@ -0,0 +1 @@
export * from './bindings/parser';
+17
View File
@@ -0,0 +1,17 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./bindings/parser"), exports);
+10
View File
@@ -0,0 +1,10 @@
{
"name": "@yaakapp-internal/template",
"private": true,
"version": "1.0.0",
"main": "lib/index.js",
"typings": "./lib/index.d.ts",
"scripts": {
"build": "tsc"
}
}
+4 -4
View File
@@ -3,7 +3,7 @@ use std::fmt::Display;
use ts_rs::TS; use ts_rs::TS;
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)] #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
#[ts(export)] #[ts(export, export_to="parser.ts")]
pub struct Tokens { pub struct Tokens {
pub tokens: Vec<Token>, pub tokens: Vec<Token>,
} }
@@ -21,7 +21,7 @@ impl Display for Tokens {
} }
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)] #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
#[ts(export)] #[ts(export, export_to="parser.ts")]
pub struct FnArg { pub struct FnArg {
pub name: String, pub name: String,
pub value: Val, pub value: Val,
@@ -36,7 +36,7 @@ impl Display for FnArg {
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)] #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
#[serde(rename_all = "snake_case", tag = "type")] #[serde(rename_all = "snake_case", tag = "type")]
#[ts(export)] #[ts(export, export_to="parser.ts")]
pub enum Val { pub enum Val {
Str { text: String }, Str { text: String },
Var { name: String }, Var { name: String },
@@ -71,7 +71,7 @@ impl Display for Val {
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)] #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, TS)]
#[serde(rename_all = "snake_case", tag = "type")] #[serde(rename_all = "snake_case", tag = "type")]
#[ts(export)] #[ts(export, export_to="parser.ts")]
pub enum Token { pub enum Token {
Raw { text: String }, Raw { text: String },
Tag { val: Val }, Tag { val: Val },
+15
View 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"
]
}
+1 -1
View File
@@ -1,6 +1,6 @@
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest'; import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest'; import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
import type { GrpcRequest, HttpRequest } from '@yaakapp/api'; import type { GrpcRequest, HttpRequest } from '@yaakapp-internal/models';
import { Input } from './core/Input'; import { Input } from './core/Input';
import { VStack } from './core/Stacks'; import { VStack } from './core/Stacks';
+1 -1
View File
@@ -1,6 +1,6 @@
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest'; import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest'; import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
import type { GrpcRequest, HttpRequest } from '@yaakapp/api'; import type { GrpcRequest, HttpRequest } from '@yaakapp-internal/models';
import { Input } from './core/Input'; import { Input } from './core/Input';
import { VStack } from './core/Stacks'; import { VStack } from './core/Stacks';
+1 -1
View File
@@ -1,6 +1,6 @@
import mime from 'mime'; import mime from 'mime';
import { useKeyValue } from '../hooks/useKeyValue'; import { useKeyValue } from '../hooks/useKeyValue';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import { Banner } from './core/Banner'; import { Banner } from './core/Banner';
import { Button } from './core/Button'; import { Button } from './core/Button';
import { InlineCode } from './core/InlineCode'; import { InlineCode } from './core/InlineCode';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Cookie } from '@yaakapp/api'; import type { Cookie } from '@yaakapp-internal/models';
import { useCookieJars } from '../hooks/useCookieJars'; import { useCookieJars } from '../hooks/useCookieJars';
import { useUpdateCookieJar } from '../hooks/useUpdateCookieJar'; import { useUpdateCookieJar } from '../hooks/useUpdateCookieJar';
import { cookieDomain } from '../lib/model_util'; import { cookieDomain } from '../lib/model_util';
+1 -1
View File
@@ -9,7 +9,7 @@ import { useKeyValue } from '../hooks/useKeyValue';
import { usePrompt } from '../hooks/usePrompt'; import { usePrompt } from '../hooks/usePrompt';
import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment'; import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment';
import { useUpdateWorkspace } from '../hooks/useUpdateWorkspace'; import { useUpdateWorkspace } from '../hooks/useUpdateWorkspace';
import type { Environment, Workspace } from '@yaakapp/api'; import type { Environment, Workspace } from '@yaakapp-internal/models';
import { Button } from './core/Button'; import { Button } from './core/Button';
import { ContextMenu } from './core/Dropdown'; import { ContextMenu } from './core/Dropdown';
import type { import type {
+1 -1
View File
@@ -1,7 +1,7 @@
import { save } from '@tauri-apps/plugin-dialog'; import { save } from '@tauri-apps/plugin-dialog';
import { useCallback, useMemo, useState } from 'react'; import { useCallback, useMemo, useState } from 'react';
import slugify from 'slugify'; import slugify from 'slugify';
import type { Workspace } from '@yaakapp/api'; import type { Workspace } from '@yaakapp-internal/models';
import { count } from '../lib/pluralize'; import { count } from '../lib/pluralize';
import { invokeCmd } from '../lib/tauri'; import { invokeCmd } from '../lib/tauri';
import { Button } from './core/Button'; import { Button } from './core/Button';
+1 -1
View File
@@ -1,5 +1,5 @@
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import type { Pair, PairEditorProps } from './core/PairEditor'; import type { Pair, PairEditorProps } from './core/PairEditor';
import { PairEditor } from './core/PairEditor'; import { PairEditor } from './core/PairEditor';
+1 -1
View File
@@ -1,5 +1,5 @@
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import type { Pair, PairEditorProps } from './core/PairEditor'; import type { Pair, PairEditorProps } from './core/PairEditor';
import { PairOrBulkEditor } from './core/PairOrBulkEditor'; import { PairOrBulkEditor } from './core/PairOrBulkEditor';
+5 -5
View File
@@ -1,6 +1,6 @@
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'; import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import type { Model } from '@yaakapp/api'; import type { AnyModel } from '@yaakapp-internal/models';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useEnsureActiveCookieJar, useMigrateActiveCookieJarId } from '../hooks/useActiveCookieJar'; import { useEnsureActiveCookieJar, useMigrateActiveCookieJarId } from '../hooks/useActiveCookieJar';
@@ -62,7 +62,7 @@ export function GlobalHooks() {
const { wasUpdatedExternally } = useRequestUpdateKey(null); const { wasUpdatedExternally } = useRequestUpdateKey(null);
interface ModelPayload { interface ModelPayload {
model: Model; model: AnyModel;
windowLabel: string; windowLabel: string;
} }
@@ -94,7 +94,7 @@ export function GlobalHooks() {
wasUpdatedExternally(model.id); wasUpdatedExternally(model.id);
} }
const pushToFront = (['http_response', 'grpc_connection'] as Model['model'][]).includes( const pushToFront = (['http_response', 'grpc_connection'] as AnyModel['model'][]).includes(
model.model, model.model,
); );
@@ -197,7 +197,7 @@ export function GlobalHooks() {
return null; return null;
} }
function updateModelList<T extends Model>(model: T, pushToFront: boolean) { function updateModelList<T extends AnyModel>(model: T, pushToFront: boolean) {
return (current: T[]): T[] => { return (current: T[]): T[] => {
const index = current.findIndex((v) => modelsEq(v, model)) ?? -1; const index = current.findIndex((v) => modelsEq(v, model)) ?? -1;
if (index >= 0) { if (index >= 0) {
@@ -212,7 +212,7 @@ function removeById<T extends { id: string }>(model: T) {
return (entries: T[] | undefined) => entries?.filter((e) => e.id !== model.id) ?? []; return (entries: T[] | undefined) => entries?.filter((e) => e.id !== model.id) ?? [];
} }
const shouldIgnoreModel = (payload: Model, windowLabel: string) => { const shouldIgnoreModel = (payload: AnyModel, windowLabel: string) => {
if (windowLabel === getCurrentWebviewWindow().label) { if (windowLabel === getCurrentWebviewWindow().label) {
// Never ignore same-window updates // Never ignore same-window updates
return false; return false;
+1 -1
View File
@@ -2,7 +2,7 @@ import type { EditorView } from 'codemirror';
import { useCallback, useEffect, useMemo, useRef } from 'react'; import { useCallback, useEffect, useMemo, useRef } from 'react';
import { useIntrospectGraphQL } from '../hooks/useIntrospectGraphQL'; import { useIntrospectGraphQL } from '../hooks/useIntrospectGraphQL';
import { tryFormatJson } from '../lib/formatters'; import { tryFormatJson } from '../lib/formatters';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import { Button } from './core/Button'; import { Button } from './core/Button';
import type { EditorProps } from './core/Editor'; import type { EditorProps } from './core/Editor';
import { Editor, formatGraphQL } from './core/Editor'; import { Editor, formatGraphQL } from './core/Editor';
@@ -5,7 +5,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import { useGrpcEvents } from '../hooks/useGrpcEvents'; import { useGrpcEvents } from '../hooks/useGrpcEvents';
import { usePinnedGrpcConnection } from '../hooks/usePinnedGrpcConnection'; import { usePinnedGrpcConnection } from '../hooks/usePinnedGrpcConnection';
import { useStateWithDeps } from '../hooks/useStateWithDeps'; import { useStateWithDeps } from '../hooks/useStateWithDeps';
import type { GrpcEvent, GrpcRequest } from '@yaakapp/api'; import type { GrpcEvent, GrpcRequest } from '@yaakapp-internal/models';
import { isResponseLoading } from '../lib/model_util'; import { isResponseLoading } from '../lib/model_util';
import { Banner } from './core/Banner'; import { Banner } from './core/Banner';
import { Button } from './core/Button'; import { Button } from './core/Button';
@@ -6,7 +6,7 @@ import { createGlobalState } from 'react-use';
import type { ReflectResponseService } from '../hooks/useGrpc'; import type { ReflectResponseService } from '../hooks/useGrpc';
import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey'; import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey';
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest'; import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
import type { GrpcMetadataEntry, GrpcRequest } from '@yaakapp/api'; import type { GrpcMetadataEntry, GrpcRequest } from '@yaakapp-internal/models';
import { AUTH_TYPE_BASIC, AUTH_TYPE_BEARER, AUTH_TYPE_NONE } from '../lib/model_util'; import { AUTH_TYPE_BASIC, AUTH_TYPE_BEARER, AUTH_TYPE_NONE } from '../lib/model_util';
import { BasicAuth } from './BasicAuth'; import { BasicAuth } from './BasicAuth';
import { BearerAuth } from './BearerAuth'; import { BearerAuth } from './BearerAuth';
+1 -1
View File
@@ -15,7 +15,7 @@ import { useEffect, useMemo, useRef } from 'react';
import { useAlert } from '../hooks/useAlert'; import { useAlert } from '../hooks/useAlert';
import type { ReflectResponseService } from '../hooks/useGrpc'; import type { ReflectResponseService } from '../hooks/useGrpc';
import { tryFormatJson } from '../lib/formatters'; import { tryFormatJson } from '../lib/formatters';
import type { GrpcRequest } from '@yaakapp/api'; import type { GrpcRequest } from '@yaakapp-internal/models';
import { count } from '../lib/pluralize'; import { count } from '../lib/pluralize';
import { Button } from './core/Button'; import { Button } from './core/Button';
import type { EditorProps } from './core/Editor'; import type { EditorProps } from './core/Editor';
+1 -1
View File
@@ -3,7 +3,7 @@ import { connections } from '../lib/data/connections';
import { encodings } from '../lib/data/encodings'; import { encodings } from '../lib/data/encodings';
import { headerNames } from '../lib/data/headerNames'; import { headerNames } from '../lib/data/headerNames';
import { mimeTypes } from '../lib/data/mimetypes'; import { mimeTypes } from '../lib/data/mimetypes';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import type { GenericCompletionConfig } from './core/Editor/genericCompletion'; import type { GenericCompletionConfig } from './core/Editor/genericCompletion';
import type { PairEditorProps } from './core/PairEditor'; import type { PairEditorProps } from './core/PairEditor';
import { PairOrBulkEditor } from './core/PairOrBulkEditor'; import { PairOrBulkEditor } from './core/PairOrBulkEditor';
+1 -1
View File
@@ -1,6 +1,6 @@
import type { CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import React from 'react'; import React from 'react';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import { SplitLayout } from './core/SplitLayout'; import { SplitLayout } from './core/SplitLayout';
import { RequestPane } from './RequestPane'; import { RequestPane } from './RequestPane';
import { ResponsePane } from './ResponsePane'; import { ResponsePane } from './ResponsePane';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { GrpcRequest, HttpRequest } from '@yaakapp/api'; import type { GrpcRequest, HttpRequest } from '@yaakapp-internal/models';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useAppRoutes } from '../hooks/useAppRoutes'; import { useAppRoutes } from '../hooks/useAppRoutes';
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest'; import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
+1 -1
View File
@@ -2,7 +2,7 @@ import { useState } from 'react';
import { useOpenWorkspace } from '../hooks/useOpenWorkspace'; import { useOpenWorkspace } from '../hooks/useOpenWorkspace';
import { useSettings } from '../hooks/useSettings'; import { useSettings } from '../hooks/useSettings';
import { useUpdateSettings } from '../hooks/useUpdateSettings'; import { useUpdateSettings } from '../hooks/useUpdateSettings';
import type { Workspace } from '@yaakapp/api'; import type { Workspace } from '@yaakapp-internal/models';
import { Button } from './core/Button'; import { Button } from './core/Button';
import { Checkbox } from './core/Checkbox'; import { Checkbox } from './core/Checkbox';
import { Icon } from './core/Icon'; import { Icon } from './core/Icon';
@@ -1,7 +1,7 @@
import { formatDistanceToNowStrict } from 'date-fns'; 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 '@yaakapp/api'; import type { GrpcConnection } from '@yaakapp-internal/models';
import { count } 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';
@@ -1,4 +1,4 @@
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { useCopyHttpResponse } from '../hooks/useCopyHttpResponse'; import { useCopyHttpResponse } from '../hooks/useCopyHttpResponse';
import { useDeleteHttpResponse } from '../hooks/useDeleteHttpResponse'; import { useDeleteHttpResponse } from '../hooks/useDeleteHttpResponse';
import { useDeleteHttpResponses } from '../hooks/useDeleteHttpResponses'; import { useDeleteHttpResponses } from '../hooks/useDeleteHttpResponses';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { HttpRequest, HttpRequestHeader, HttpUrlParameter } from '@yaakapp/api'; import type { HttpRequest, HttpRequestHeader, HttpUrlParameter } from '@yaakapp-internal/models';
import classNames from 'classnames'; import classNames from 'classnames';
import type { CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import React, { memo, useCallback, useMemo, useState } from 'react'; import React, { memo, useCallback, useMemo, useState } from 'react';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { KeyValueRow, KeyValueRows } from './core/KeyValueRow'; import { KeyValueRow, KeyValueRows } from './core/KeyValueRow';
interface Props { interface Props {
+1 -1
View File
@@ -1,5 +1,5 @@
import { open } from '@tauri-apps/plugin-shell'; import { open } from '@tauri-apps/plugin-shell';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { IconButton } from './core/IconButton'; import { IconButton } from './core/IconButton';
import { KeyValueRow, KeyValueRows } from './core/KeyValueRow'; import { KeyValueRow, KeyValueRows } from './core/KeyValueRow';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import classNames from 'classnames'; import classNames from 'classnames';
import type { CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import { memo, useCallback, useMemo } from 'react'; import { memo, useCallback, useMemo } from 'react';
@@ -1,4 +1,4 @@
import type { Plugin } from '@yaakapp/api'; import type { Plugin } from '@yaakapp-internal/models';
import { open } from '@tauri-apps/plugin-shell'; import { open } from '@tauri-apps/plugin-shell';
import React from 'react'; import React from 'react';
import { useInstallPlugin } from '../../hooks/useInstallPlugin'; import { useInstallPlugin } from '../../hooks/useInstallPlugin';
+8 -2
View File
@@ -1,4 +1,10 @@
import type { Folder, GrpcRequest, HttpRequest, Model, Workspace } from '@yaakapp/api'; import type {
AnyModel,
Folder,
GrpcRequest,
HttpRequest,
Workspace,
} from '@yaakapp-internal/models';
import classNames from 'classnames'; import classNames from 'classnames';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import React, { Fragment, useCallback, useMemo, useRef, useState } from 'react'; import React, { Fragment, useCallback, useMemo, useRef, useState } from 'react';
@@ -575,7 +581,7 @@ type SidebarItemProps = {
itemId: string; itemId: string;
itemName: string; itemName: string;
itemFallbackName: string; itemFallbackName: string;
itemModel: Model['model']; itemModel: AnyModel['model'];
itemPrefix: ReactNode; itemPrefix: ReactNode;
useProminentStyles?: boolean; useProminentStyles?: boolean;
selected: boolean; selected: boolean;
@@ -5,10 +5,9 @@ import type {
TemplateFunctionHttpRequestArg, TemplateFunctionHttpRequestArg,
TemplateFunctionSelectArg, TemplateFunctionSelectArg,
TemplateFunctionTextArg, TemplateFunctionTextArg,
} from '@yaakapp/api'; } from '@yaakapp-internal/plugin';
import type { FnArg, Tokens } from '@yaakapp-internal/template';
import { useCallback, useMemo, useState } from 'react'; import { useCallback, useMemo, useState } from 'react';
import type { FnArg } from '../gen/FnArg';
import type { Tokens } from '../gen/Tokens';
import { useActiveRequest } from '../hooks/useActiveRequest'; import { useActiveRequest } from '../hooks/useActiveRequest';
import { useDebouncedValue } from '../hooks/useDebouncedValue'; import { useDebouncedValue } from '../hooks/useDebouncedValue';
import { useHttpRequests } from '../hooks/useHttpRequests'; import { useHttpRequests } from '../hooks/useHttpRequests';
@@ -62,8 +61,8 @@ export function TemplateFunctionDialog({ templateFunction, hide, initialTokens,
argValues[name] === NULL_ARG argValues[name] === NULL_ARG
? { type: 'null' } ? { type: 'null' }
: typeof argValues[name] === 'boolean' : typeof argValues[name] === 'boolean'
? { type: 'bool', value: argValues[name] === true } ? { type: 'bool', value: argValues[name] === true }
: { type: 'str', text: String(argValues[name] ?? '') }, : { type: 'str', text: String(argValues[name] ?? '') },
})); }));
return { return {
@@ -1,5 +1,5 @@
import type { Tokens } from '@yaakapp-internal/template';
import { useCallback, useMemo, useState } from 'react'; import { useCallback, useMemo, useState } from 'react';
import type { Tokens } from '../gen/Tokens';
import { useActiveEnvironmentVariables } from '../hooks/useActiveEnvironmentVariables'; import { useActiveEnvironmentVariables } from '../hooks/useActiveEnvironmentVariables';
import { useRenderTemplate } from '../hooks/useRenderTemplate'; import { useRenderTemplate } from '../hooks/useRenderTemplate';
import { useTemplateTokensToString } from '../hooks/useTemplateTokensToString'; import { useTemplateTokensToString } from '../hooks/useTemplateTokensToString';
+1 -1
View File
@@ -1,7 +1,7 @@
import type { ShowToastRequest } from '@yaakapp-internal/plugin';
import { AnimatePresence } from 'framer-motion'; import { AnimatePresence } from 'framer-motion';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import React, { createContext, useContext, useMemo, useRef, useState } from 'react'; import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
import type { ShowToastRequest } from '@yaakapp/api';
import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent'; import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { generateId } from '../lib/generateId'; import { generateId } from '../lib/generateId';
import type { ToastProps } from './core/Toast'; import type { ToastProps } from './core/Toast';
+1 -1
View File
@@ -3,7 +3,7 @@ import type { EditorView } from 'codemirror';
import type { FormEvent, ReactNode } from 'react'; import type { FormEvent, ReactNode } from 'react';
import { memo, useRef, useState } from 'react'; import { memo, useRef, useState } from 'react';
import { useHotKey } from '../hooks/useHotKey'; import { useHotKey } from '../hooks/useHotKey';
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import type { IconProps } from './core/Icon'; import type { IconProps } from './core/Icon';
import { IconButton } from './core/IconButton'; import { IconButton } from './core/IconButton';
import type { InputProps } from './core/Input'; import type { InputProps } from './core/Input';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { HttpRequest } from '@yaakapp/api'; import type { HttpRequest } from '@yaakapp-internal/models';
import { useRequestEditor, useRequestEditorEvent } from '../hooks/useRequestEditor'; import { useRequestEditor, useRequestEditorEvent } from '../hooks/useRequestEditor';
import type { PairEditorRef } from './core/PairEditor'; import type { PairEditorRef } from './core/PairEditor';
import { PairOrBulkEditor } from './core/PairOrBulkEditor'; import { PairOrBulkEditor } from './core/PairOrBulkEditor';
+2 -1
View File
@@ -2,7 +2,8 @@ import { defaultKeymap } from '@codemirror/commands';
import { forceParsing } from '@codemirror/language'; import { forceParsing } from '@codemirror/language';
import { Compartment, EditorState, type Extension } from '@codemirror/state'; import { Compartment, EditorState, type Extension } from '@codemirror/state';
import { keymap, placeholder as placeholderExt, tooltips } from '@codemirror/view'; import { keymap, placeholder as placeholderExt, tooltips } from '@codemirror/view';
import type { EnvironmentVariable, TemplateFunction } from '@yaakapp/api'; import type { EnvironmentVariable } from '@yaakapp-internal/models';
import type { TemplateFunction } from '@yaakapp-internal/plugin';
import classNames from 'classnames'; import classNames from 'classnames';
import { EditorView } from 'codemirror'; import { EditorView } from 'codemirror';
import type { MutableRefObject, ReactNode } from 'react'; import type { MutableRefObject, ReactNode } from 'react';
+2 -1
View File
@@ -31,7 +31,8 @@ import {
rectangularSelection, rectangularSelection,
} from '@codemirror/view'; } from '@codemirror/view';
import { tags as t } from '@lezer/highlight'; import { tags as t } from '@lezer/highlight';
import type { EnvironmentVariable, TemplateFunction } from '@yaakapp/api'; import type { EnvironmentVariable } from '@yaakapp-internal/models';
import type { TemplateFunction } from '@yaakapp-internal/plugin';
import { graphql } from 'cm6-graphql'; import { graphql } from 'cm6-graphql';
import { EditorView } from 'codemirror'; import { EditorView } from 'codemirror';
import type { EditorProps } from './index'; import type { EditorProps } from './index';
@@ -1,7 +1,8 @@
import type { LanguageSupport } from '@codemirror/language'; import type { LanguageSupport } from '@codemirror/language';
import { LRLanguage } from '@codemirror/language'; import { LRLanguage } from '@codemirror/language';
import { parseMixed } from '@lezer/common'; import { parseMixed } from '@lezer/common';
import type { EnvironmentVariable, TemplateFunction } from '@yaakapp/api'; import type { EnvironmentVariable } from '@yaakapp-internal/models';
import type { TemplateFunction } from '@yaakapp-internal/plugin';
import type { GenericCompletionConfig } from '../genericCompletion'; import type { GenericCompletionConfig } from '../genericCompletion';
import { genericCompletion } from '../genericCompletion'; import { genericCompletion } from '../genericCompletion';
import { textLanguageName } from '../text/extension'; import { textLanguageName } from '../text/extension';
+3 -3
View File
@@ -1,5 +1,5 @@
import classNames from 'classnames'; import classNames from 'classnames';
import type { GrpcRequest, HttpRequest } from '@yaakapp/api'; import type { GrpcRequest, HttpRequest } from '@yaakapp-internal/models';
interface Props { interface Props {
request: HttpRequest | GrpcRequest; request: HttpRequest | GrpcRequest;
@@ -34,8 +34,8 @@ export function HttpMethodTag({ shortNames, request, className }: Props) {
request.model === 'http_request' && request.bodyType === 'graphql' request.model === 'http_request' && request.bodyType === 'graphql'
? 'GQL' ? 'GQL'
: request.model === 'grpc_request' : request.model === 'grpc_request'
? 'GRPC' ? 'GRPC'
: request.method; : request.method;
const m = method.toLowerCase(); const m = method.toLowerCase();
const methodMap: Record<string, string> = shortNames ? shortMethodMap : longMethodMap; const methodMap: Record<string, string> = shortNames ? shortMethodMap : longMethodMap;
+1 -1
View File
@@ -1,5 +1,5 @@
import classNames from 'classnames'; import classNames from 'classnames';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: Pick<HttpResponse, 'status' | 'statusReason' | 'error'>; response: Pick<HttpResponse, 'status' | 'statusReason' | 'error'>;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ShowToastRequest } from '@yaakapp/api'; import type { ShowToastRequest } from '@yaakapp-internal/plugin';
import classNames from 'classnames'; import classNames from 'classnames';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
@@ -1,6 +1,6 @@
import { convertFileSrc } from '@tauri-apps/api/core'; import { convertFileSrc } from '@tauri-apps/api/core';
import React from 'react'; import React from 'react';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: HttpResponse; response: HttpResponse;
@@ -1,5 +1,5 @@
import { useSaveResponse } from '../../hooks/useSaveResponse'; import { useSaveResponse } from '../../hooks/useSaveResponse';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { getContentTypeHeader } from '../../lib/model_util'; import { getContentTypeHeader } from '../../lib/model_util';
import { Banner } from '../core/Banner'; import { Banner } from '../core/Banner';
import { Button } from '../core/Button'; import { Button } from '../core/Button';
@@ -2,7 +2,7 @@ import classNames from 'classnames';
import Papa from 'papaparse'; import Papa from 'papaparse';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useResponseBodyText } from '../../hooks/useResponseBodyText'; import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: HttpResponse; response: HttpResponse;
@@ -1,4 +1,4 @@
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { useContentTypeFromHeaders } from '../../hooks/useContentTypeFromHeaders'; import { useContentTypeFromHeaders } from '../../hooks/useContentTypeFromHeaders';
import { useResponseBodyText } from '../../hooks/useResponseBodyText'; import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import { isJSON, languageFromContentType } from '../../lib/contentType'; import { isJSON, languageFromContentType } from '../../lib/contentType';
@@ -1,7 +1,7 @@
import { convertFileSrc } from '@tauri-apps/api/core'; import { convertFileSrc } from '@tauri-apps/api/core';
import classNames from 'classnames'; import classNames from 'classnames';
import { useState } from 'react'; import { useState } from 'react';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: HttpResponse; response: HttpResponse;
@@ -1,6 +1,6 @@
import classNames from 'classnames'; import classNames from 'classnames';
import { useResponseBodyText } from '../../hooks/useResponseBodyText'; import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import { JsonAttributeTree } from '../core/JsonAttributeTree'; import { JsonAttributeTree } from '../core/JsonAttributeTree';
interface Props { interface Props {
@@ -6,7 +6,7 @@ import type { PDFDocumentProxy } from 'pdfjs-dist';
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { Document, Page } from 'react-pdf'; import { Document, Page } from 'react-pdf';
import { useDebouncedState } from '../../hooks/useDebouncedState'; import { useDebouncedState } from '../../hooks/useDebouncedState';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import './PdfViewer.css'; import './PdfViewer.css';
interface Props { interface Props {
@@ -1,4 +1,4 @@
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
import classNames from 'classnames'; import classNames from 'classnames';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
@@ -161,8 +161,8 @@ export function TextViewer({ response, pretty, className }: Props) {
pretty && language === 'json' pretty && language === 'json'
? tryFormatJson(rawBody.data) ? tryFormatJson(rawBody.data)
: pretty && (language === 'xml' || language === 'html') : pretty && (language === 'xml' || language === 'html')
? tryFormatXml(rawBody.data) ? tryFormatXml(rawBody.data)
: rawBody.data; : rawBody.data;
let body; let body;
if (isSearching && filterText?.length > 0) { if (isSearching && filterText?.length > 0) {
@@ -1,6 +1,6 @@
import { convertFileSrc } from '@tauri-apps/api/core'; import { convertFileSrc } from '@tauri-apps/api/core';
import React from 'react'; import React from 'react';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: HttpResponse; response: HttpResponse;
@@ -1,6 +1,6 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useResponseBodyText } from '../../hooks/useResponseBodyText'; import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import type { HttpResponse } from '@yaakapp/api'; import type { HttpResponse } from '@yaakapp-internal/models';
interface Props { interface Props {
response: HttpResponse; response: HttpResponse;
-4
View File
@@ -1,4 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Val } from "./Val";
export type Token = { "type": "raw", text: string, } | { "type": "tag", val: Val, } | { "type": "eof" };

Some files were not shown because too many files have changed in this diff Show More