From f678593903fdc142357f5e0b3cedaa34274bcff1 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 26 Jan 2025 13:13:45 -0800 Subject: [PATCH] OAuth 2 (#158) --- package-lock.json | 88 +-- package.json | 2 +- .../src/bindings/events.ts | 290 -------- .../src/bindings/gen_events.ts | 405 +++++++++++ .../src/bindings/{models.ts => gen_models.ts} | 0 packages/plugin-runtime-types/src/helpers.ts | 1 + packages/plugin-runtime-types/src/index.ts | 4 +- .../src/plugins/AuthenticationPlugin.ts | 24 +- .../src/plugins/Context.ts | 35 +- .../src/plugins/HttpRequestActionPlugin.ts | 2 +- .../src/plugins/ImporterPlugin.ts | 31 +- .../src/plugins/TemplateFunctionPlugin.ts | 2 +- packages/plugin-runtime/src/index.worker.ts | 188 ++++- packages/plugin-runtime/src/migrations.ts | 25 + src-tauri/Cargo.lock | 61 +- src-tauri/Cargo.toml | 3 +- src-tauri/capabilities/capabilities.json | 13 +- src-tauri/gen/schemas/capabilities.json | 2 +- .../migrations/20250123192023_plugin-kv.sql | 11 + src-tauri/src/http_request.rs | 22 +- src-tauri/src/lib.rs | 419 +++-------- src-tauri/src/plugin_events.rs | 265 +++++++ src-tauri/src/template_callback.rs | 8 +- src-tauri/src/window.rs | 129 ++++ src-tauri/src/window_menu.rs | 6 +- .../plugins/auth-basic/build/index.js | 6 +- .../plugins/auth-bearer/build/index.js | 6 +- .../vendored/plugins/auth-jwt/build/index.js | 13 +- .../plugins/auth-oauth2/build/index.js | 673 ++++++++++++++++++ .../vendored/plugins/auth-oauth2/package.json | 9 + .../plugins/exporter-curl/build/index.js | 6 +- .../template-function-response/build/index.js | 4 +- src-tauri/yaak-license/bindings/gen_models.ts | 3 + src-tauri/yaak-license/src/license.rs | 2 +- src-tauri/yaak-models/Cargo.toml | 4 +- .../bindings/{models.ts => gen_models.ts} | 0 src-tauri/yaak-models/index.ts | 2 +- src-tauri/yaak-models/src/models.rs | 102 ++- src-tauri/yaak-models/src/queries.rs | 97 ++- src-tauri/yaak-plugins/Cargo.toml | 13 +- src-tauri/yaak-plugins/bindings/events.ts | 290 -------- src-tauri/yaak-plugins/bindings/gen_events.ts | 405 +++++++++++ .../bindings/{models.ts => gen_models.ts} | 0 src-tauri/yaak-plugins/index.ts | 4 +- src-tauri/yaak-plugins/src/error.rs | 3 + src-tauri/yaak-plugins/src/events.rs | 404 +++++++++-- src-tauri/yaak-plugins/src/manager.rs | 198 ++++-- src-tauri/yaak-plugins/src/plugin_handle.rs | 14 +- src-tauri/yaak-plugins/src/server_ws.rs | 3 +- .../bindings/{models.ts => gen_models.ts} | 0 .../bindings/{sync.ts => gen_sync.ts} | 4 +- .../bindings/{watch.ts => gen_watch.ts} | 0 src-tauri/yaak-sync/index.ts | 4 +- src-tauri/yaak-sync/src/commands.rs | 2 +- src-tauri/yaak-sync/src/models.rs | 2 +- src-tauri/yaak-sync/src/sync.rs | 4 +- src-tauri/yaak-sync/src/watch.rs | 2 +- src-web/components/CommandPaletteDialog.tsx | 5 +- src-web/components/CookieDropdown.tsx | 1 - src-web/components/DynamicForm.tsx | 176 +++-- src-web/components/EnvironmentEditDialog.tsx | 8 +- src-web/components/GlobalHooks.tsx | 30 +- src-web/components/GraphQLEditor.tsx | 3 - .../components/GrpcConnectionSetupPane.tsx | 5 +- src-web/components/HeadersEditor.tsx | 3 +- .../components/HttpAuthenticationEditor.tsx | 58 +- src-web/components/Markdown.tsx | 27 + src-web/components/MarkdownEditor.tsx | 27 +- src-web/components/Prose.css | 5 + .../components/RecentConnectionsDropdown.tsx | 3 - src-web/components/RecentRequestsDropdown.tsx | 1 - .../components/RecentResponsesDropdown.tsx | 6 - src-web/components/RequestPane.tsx | 10 +- src-web/components/SettingsDropdown.tsx | 7 - src-web/components/SidebarItemContextMenu.tsx | 10 - src-web/components/TemplateFunctionDialog.tsx | 6 +- .../components/WorkspaceActionsDropdown.tsx | 5 - src-web/components/core/Banner.tsx | 4 +- src-web/components/core/Checkbox.tsx | 14 +- src-web/components/core/Dropdown.tsx | 10 +- src-web/components/core/Editor/Editor.css | 4 +- src-web/components/core/Editor/Editor.tsx | 74 +- src-web/components/core/Editor/extensions.ts | 9 +- .../core/Editor/genericCompletion.ts | 13 +- src-web/components/core/Input.tsx | 33 +- src-web/components/core/Label.tsx | 18 +- src-web/components/core/PairEditor.tsx | 7 +- src-web/components/core/PlainInput.tsx | 33 +- src-web/components/core/Prompt.tsx | 5 +- src-web/components/core/Select.tsx | 9 +- src-web/components/core/Toast.tsx | 6 +- src-web/hooks/useCreateDropdownItems.tsx | 8 +- src-web/hooks/useHttpAuthentication.ts | 23 +- src-web/hooks/useHttpAuthenticationConfig.ts | 59 ++ src-web/hooks/useHttpRequestActions.ts | 9 +- src-web/hooks/useNotificationToast.tsx | 1 - src-web/hooks/useTemplateFunctions.ts | 7 +- src-web/lib/data/headerNames.ts | 2 +- src-web/lib/tauri.ts | 16 +- 99 files changed, 3492 insertions(+), 1583 deletions(-) delete mode 100644 packages/plugin-runtime-types/src/bindings/events.ts create mode 100644 packages/plugin-runtime-types/src/bindings/gen_events.ts rename packages/plugin-runtime-types/src/bindings/{models.ts => gen_models.ts} (100%) create mode 100644 packages/plugin-runtime/src/migrations.ts create mode 100644 src-tauri/migrations/20250123192023_plugin-kv.sql create mode 100644 src-tauri/src/plugin_events.rs create mode 100644 src-tauri/src/window.rs create mode 100644 src-tauri/vendored/plugins/auth-oauth2/build/index.js create mode 100644 src-tauri/vendored/plugins/auth-oauth2/package.json create mode 100644 src-tauri/yaak-license/bindings/gen_models.ts rename src-tauri/yaak-models/bindings/{models.ts => gen_models.ts} (100%) delete mode 100644 src-tauri/yaak-plugins/bindings/events.ts create mode 100644 src-tauri/yaak-plugins/bindings/gen_events.ts rename src-tauri/yaak-plugins/bindings/{models.ts => gen_models.ts} (100%) rename src-tauri/yaak-sync/bindings/{models.ts => gen_models.ts} (100%) rename src-tauri/yaak-sync/bindings/{sync.ts => gen_sync.ts} (85%) rename src-tauri/yaak-sync/bindings/{watch.ts => gen_watch.ts} (100%) create mode 100644 src-web/components/Markdown.tsx create mode 100644 src-web/hooks/useHttpAuthenticationConfig.ts diff --git a/package-lock.json b/package-lock.json index dbdce182..44f05b52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "src-web" ], "devDependencies": { - "@tauri-apps/cli": "^2.2.4", + "@tauri-apps/cli": "^2.2.5", "@typescript-eslint/eslint-plugin": "^8.18.1", "@typescript-eslint/parser": "^8.18.1", "eslint": "^8", @@ -2709,9 +2709,9 @@ } }, "node_modules/@tauri-apps/cli": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.2.4.tgz", - "integrity": "sha512-pihbuHEWJa9SEcN7JdEbMa0oq28MTTbk0nNNnRG8/irNQTKcjwM+KzxG2wuYZYbsXQVqwSu7PstdIEAnXqYHkw==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.2.5.tgz", + "integrity": "sha512-PaefTQUCYYqvZWdH8EhXQkyJEjQwtoy/OHGoPcZx7Gk3D3K6AtGSxZ9OlHIz3Bu5LDGgVBk36vKtHW0WYsWnbw==", "dev": true, "license": "Apache-2.0 OR MIT", "bin": { @@ -2725,22 +2725,22 @@ "url": "https://opencollective.com/tauri" }, "optionalDependencies": { - "@tauri-apps/cli-darwin-arm64": "2.2.4", - "@tauri-apps/cli-darwin-x64": "2.2.4", - "@tauri-apps/cli-linux-arm-gnueabihf": "2.2.4", - "@tauri-apps/cli-linux-arm64-gnu": "2.2.4", - "@tauri-apps/cli-linux-arm64-musl": "2.2.4", - "@tauri-apps/cli-linux-x64-gnu": "2.2.4", - "@tauri-apps/cli-linux-x64-musl": "2.2.4", - "@tauri-apps/cli-win32-arm64-msvc": "2.2.4", - "@tauri-apps/cli-win32-ia32-msvc": "2.2.4", - "@tauri-apps/cli-win32-x64-msvc": "2.2.4" + "@tauri-apps/cli-darwin-arm64": "2.2.5", + "@tauri-apps/cli-darwin-x64": "2.2.5", + "@tauri-apps/cli-linux-arm-gnueabihf": "2.2.5", + "@tauri-apps/cli-linux-arm64-gnu": "2.2.5", + "@tauri-apps/cli-linux-arm64-musl": "2.2.5", + "@tauri-apps/cli-linux-x64-gnu": "2.2.5", + "@tauri-apps/cli-linux-x64-musl": "2.2.5", + "@tauri-apps/cli-win32-arm64-msvc": "2.2.5", + "@tauri-apps/cli-win32-ia32-msvc": "2.2.5", + "@tauri-apps/cli-win32-x64-msvc": "2.2.5" } }, "node_modules/@tauri-apps/cli-darwin-arm64": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.2.4.tgz", - "integrity": "sha512-+sMLkQBFebn/UENyaXpyQqRkdFQie8RdEvYVz0AGthm2p0lMVlWiBmc4ImBJmfo8569zVeDX8B+5OWt4/AuZzA==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.2.5.tgz", + "integrity": "sha512-qdPmypQE7qj62UJy3Wl/ccCJZwsv5gyBByOrAaG7u5c/PB3QSxhNPegice2k4EHeIuApaVJOoe/CEYVgm/og2Q==", "cpu": [ "arm64" ], @@ -2755,9 +2755,9 @@ } }, "node_modules/@tauri-apps/cli-darwin-x64": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.2.4.tgz", - "integrity": "sha512-6fJvXVtQJh7H8q9sll2XC2wO5bpn7bzeh+MQxpcLq6F8SE02sFuNDLN+AqX0DQnuYV0V6jdzM2+bTYOlc1FBsw==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.2.5.tgz", + "integrity": "sha512-8JVlCAb2c3n0EcGW7n/1kU4Rq831SsoLDD/0hNp85Um8HGIH2Mg/qos/MLOc8Qv2mOaoKcRKf4hd0I1y0Rl9Cg==", "cpu": [ "x64" ], @@ -2772,9 +2772,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.2.4.tgz", - "integrity": "sha512-QU6Ac6tx79iqkxsDUQesCBNq8RrVSkP9HhVzS2reKthK3xbdTCwNUXoRlfhudKMVrIxV4K7uTwUV99eAnwbm5Q==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.2.5.tgz", + "integrity": "sha512-mzxQCqZg7ljRVgekPpXQ5TOehCNgnXh/DNWU6kFjALaBvaw4fGzc369/hV94wOt29htNFyxf8ty2DaQaYljEHw==", "cpu": [ "arm" ], @@ -2789,9 +2789,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm64-gnu": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.2.4.tgz", - "integrity": "sha512-uZhp312s6VgJJDgUg+HuHZnhjGg93OT+q/aZMoccdZVQ6dvwH8kJzIkKt9zL1U126AXXoesb1EyYmsAruxaUKA==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.2.5.tgz", + "integrity": "sha512-M9nkzx5jsSJSNpp7aSza0qv0/N13SUNzH8ysYSZ7IaCN8coGeMg2KgQ5qC6tqUVij2rbg8A/X1n0pPo/gtLx0A==", "cpu": [ "arm64" ], @@ -2806,9 +2806,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm64-musl": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.4.tgz", - "integrity": "sha512-k6JCXd9E+XU0J48nVcFr3QO//bzKg/gp8ZKagBfI2wBpHOk14CnHNBQKNs11nMQUwko4bnPeqj4llcdkbmwIbw==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.5.tgz", + "integrity": "sha512-tFhZu950HNRLR1RM5Q9Xj5gAlA6AhyyiZgeoXGFAWto+s2jpWmmA3Qq2GUxnVDr7Xui8PF4UY5kANDIOschuwg==", "cpu": [ "arm64" ], @@ -2823,9 +2823,9 @@ } }, "node_modules/@tauri-apps/cli-linux-x64-gnu": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.2.4.tgz", - "integrity": "sha512-bUBPU46OF1pNfM6SsGbUlkCBh/pTzvFlEdUpDISsS40v9NVt+kqCy3tHzLGB412E3lSlA6FnshB6HxkdRRdTtg==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.2.5.tgz", + "integrity": "sha512-eaGhTQLr3EKeksGsp2tK/Ndi7/oyo3P53Pye6kg0zqXiqu8LQjg1CgvDm1l+5oit04S60zR4AqlDFpoeEtDGgw==", "cpu": [ "x64" ], @@ -2840,9 +2840,9 @@ } }, "node_modules/@tauri-apps/cli-linux-x64-musl": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.4.tgz", - "integrity": "sha512-vOrpsQDiMtP8q/ZeXfXqgNi3G4Yv5LVX2vI5XkB2yvVuVF1Dvky/hcCJfi9tZQD+IpeiYxjuj7+SxHp82eQ/kA==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.5.tgz", + "integrity": "sha512-NLAO/SymDxeGuOWWQZCpwoED1K1jaHUvW+u9ip+rTetnxFPLvf3zXthx4QVKfCZLdj2WLQz4cLjHyQdMDXAM+w==", "cpu": [ "x64" ], @@ -2857,9 +2857,9 @@ } }, "node_modules/@tauri-apps/cli-win32-arm64-msvc": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.2.4.tgz", - "integrity": "sha512-iEP/Cq0ts4Ln4Zh2NSC01lkYEAhr+LotbG4U2z+gxHfCdMrtYYtYdG05C2mpeIxShzL7uEIQb/lhVRBMd7robg==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.2.5.tgz", + "integrity": "sha512-yG5KFbqrHfGjkAQAaaCD4i7cJklBjmMxZ2C92DEnqCOujSsEuLxrwwoKxQ4+hqEHOmF3lyX0vfqhgZcS03H38w==", "cpu": [ "arm64" ], @@ -2874,9 +2874,9 @@ } }, "node_modules/@tauri-apps/cli-win32-ia32-msvc": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.2.4.tgz", - "integrity": "sha512-YBbqF0wyHUT00zAGZTTbEbz/C5JDGPnT1Nodor96+tzEU6qAPRYfe5eFe/rpRARbalkpw1UkcVP0Ay8gnksAiA==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.2.5.tgz", + "integrity": "sha512-G5lq+2EdxOc8ttg3uhME5t9U3hMGTxwaKz0X4DplTG2Iv4lcNWqw/AESIJVHa5a+EB+ZCC8I+yOfIykp/Cd5mQ==", "cpu": [ "ia32" ], @@ -2891,9 +2891,9 @@ } }, "node_modules/@tauri-apps/cli-win32-x64-msvc": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.2.4.tgz", - "integrity": "sha512-MMago/SfWZbUFrwFmPCXmmbb42h7u8Y5jvLvnK2mOpOfCAsei2tLO4hx+Inoai0l2DByuYO4Ef1xDyP6shCsZQ==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.2.5.tgz", + "integrity": "sha512-vw4fPVOo0rIQIlqw6xUvK2nwiRFBHNgayDE2Z/SomJlQJAJ1q4VgpHOPl12ouuicmTjK1gWKm7RTouQe3Nig0Q==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 9734ce07..98ef0054 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "tauri-before-dev": "npm run --workspaces --if-present dev" }, "devDependencies": { - "@tauri-apps/cli": "^2.2.4", + "@tauri-apps/cli": "^2.2.5", "@typescript-eslint/eslint-plugin": "^8.18.1", "@typescript-eslint/parser": "^8.18.1", "eslint": "^8", diff --git a/packages/plugin-runtime-types/src/bindings/events.ts b/packages/plugin-runtime-types/src/bindings/events.ts deleted file mode 100644 index 5b043002..00000000 --- a/packages/plugin-runtime-types/src/bindings/events.ts +++ /dev/null @@ -1,290 +0,0 @@ -// 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.js"; -import type { Folder } from "./models.js"; -import type { GrpcRequest } from "./models.js"; -import type { HttpRequest } from "./models.js"; -import type { HttpResponse } from "./models.js"; -import type { JsonValue } from "./serde_json/JsonValue.js"; -import type { Workspace } from "./models.js"; - -export type BootRequest = { dir: string, watch: boolean, }; - -export type BootResponse = { name: string, version: string, }; - -export type CallHttpAuthenticationRequest = { config: { [key in string]?: JsonValue }, method: string, url: string, headers: Array, }; - -export type CallHttpAuthenticationResponse = { -/** - * HTTP headers to add to the request. Existing headers will be replaced, while - * new headers will be added. - */ -setHeaders: Array, }; - -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 EditorLanguage = "text" | "javascript" | "json" | "html" | "xml" | "graphql" | "markdown"; - -export type EmptyPayload = {}; - -export type ErrorResponse = { error: string, }; - -export type ExportHttpRequestRequest = { httpRequest: HttpRequest, }; - -export type ExportHttpRequestResponse = { content: string, }; - -export type FileFilter = { name: string, -/** - * File extensions to require - */ -extensions: Array, }; - -export type FilterRequest = { content: string, filter: string, }; - -export type FilterResponse = { content: string, }; - -export type FindHttpResponsesRequest = { requestId: string, limit?: number, }; - -export type FindHttpResponsesResponse = { httpResponses: Array, }; - -export type FormInput = { "type": "text" } & FormInputText | { "type": "editor" } & FormInputEditor | { "type": "select" } & FormInputSelect | { "type": "checkbox" } & FormInputCheckbox | { "type": "file" } & FormInputFile | { "type": "http_request" } & FormInputHttpRequest; - -export type FormInputBase = { name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputCheckbox = { name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputEditor = { -/** - * Placeholder for the text input - */ -placeholder?: string | null, -/** - * Don't show the editor gutter (line numbers, folds, etc.) - */ -hideGutter?: boolean, -/** - * Language for syntax highlighting - */ -language?: EditorLanguage, name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputFile = { -/** - * The title of the file selection window - */ -title: string, -/** - * Allow selecting multiple files - */ -multiple?: boolean, directory?: boolean, defaultPath?: string, filters?: Array, name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputHttpRequest = { name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputSelect = { -/** - * The options that will be available in the select input - */ -options: Array, name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type FormInputSelectOption = { name: string, value: string, }; - -export type FormInputText = { -/** - * Placeholder for the text input - */ -placeholder?: string | null, -/** - * Placeholder for the text input - */ -password?: boolean, name: string, -/** - * Whether the user must fill in the argument - */ -optional?: boolean, -/** - * The label of the input - */ -label?: string, -/** - * Visually hide the label of the input - */ -hideLabel?: boolean, -/** - * The default value - */ -defaultValue?: string, }; - -export type GetHttpAuthenticationResponse = { name: string, label: string, shortLabel: string, config: Array, }; - -export type GetHttpRequestActionsRequest = Record; - -export type GetHttpRequestActionsResponse = { actions: Array, pluginRefId: string, }; - -export type GetHttpRequestByIdRequest = { id: string, }; - -export type GetHttpRequestByIdResponse = { httpRequest: HttpRequest | null, }; - -export type GetTemplateFunctionsResponse = { functions: Array, pluginRefId: string, }; - -export type HttpHeader = { name: string, value: string, }; - -export type HttpRequestAction = { key: string, label: string, icon?: Icon, }; - -export type Icon = "copy" | "info" | "check_circle" | "alert_triangle" | "_unknown"; - -export type ImportRequest = { content: string, }; - -export type ImportResources = { workspaces: Array, environments: Array, folders: Array, httpRequests: Array, grpcRequests: Array, }; - -export type ImportResponse = { resources: ImportResources, }; - -export type InternalEvent = { id: string, pluginRefId: string, pluginName: string, replyId: string | null, windowContext: WindowContext, payload: InternalEventPayload, }; - -export type InternalEventPayload = { "type": "boot_request" } & BootRequest | { "type": "boot_response" } & BootResponse | { "type": "reload_request" } & EmptyPayload | { "type": "reload_response" } & EmptyPayload | { "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" } & EmptyPayload | { "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": "get_http_authentication_request" } & EmptyPayload | { "type": "get_http_authentication_response" } & GetHttpAuthenticationResponse | { "type": "call_http_authentication_request" } & CallHttpAuthenticationRequest | { "type": "call_http_authentication_response" } & CallHttpAuthenticationResponse | { "type": "copy_text_request" } & CopyTextRequest | { "type": "render_http_request_request" } & RenderHttpRequestRequest | { "type": "render_http_request_response" } & RenderHttpRequestResponse | { "type": "template_render_request" } & TemplateRenderRequest | { "type": "template_render_response" } & TemplateRenderResponse | { "type": "show_toast_request" } & ShowToastRequest | { "type": "prompt_text_request" } & PromptTextRequest | { "type": "prompt_text_response" } & PromptTextResponse | { "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" } & EmptyPayload | { "type": "error_response" } & ErrorResponse; - -export type PromptTextRequest = { id: string, title: string, label: string, description?: string, defaultValue?: string, placeholder?: string, -/** - * Text to add to the confirmation button - */ -confirmText?: string, -/** - * Text to add to the cancel button - */ -cancelText?: string, -/** - * Require the user to enter a non-empty value - */ -required?: boolean, }; - -export type PromptTextResponse = { value: string | null, }; - -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, icon?: Icon, }; - -export type TemplateFunction = { name: string, description?: string, -/** - * Also support alternative names. This is useful for not breaking existing - * tags when changing the `name` property - */ -aliases?: Array, args: Array, }; - -export type TemplateRenderRequest = { data: JsonValue, purpose: RenderPurpose, }; - -export type TemplateRenderResponse = { data: JsonValue, }; - -export type WindowContext = { "type": "none" } | { "type": "label", label: string, }; diff --git a/packages/plugin-runtime-types/src/bindings/gen_events.ts b/packages/plugin-runtime-types/src/bindings/gen_events.ts new file mode 100644 index 00000000..f33ed345 --- /dev/null +++ b/packages/plugin-runtime-types/src/bindings/gen_events.ts @@ -0,0 +1,405 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Environment } from "./gen_models.js"; +import type { Folder } from "./gen_models.js"; +import type { GrpcRequest } from "./gen_models.js"; +import type { HttpRequest } from "./gen_models.js"; +import type { HttpResponse } from "./gen_models.js"; +import type { JsonValue } from "./serde_json/JsonValue.js"; +import type { Workspace } from "./gen_models.js"; + +export type BootRequest = { dir: string, watch: boolean, }; + +export type BootResponse = { name: string, version: string, }; + +export type CallHttpAuthenticationActionArgs = { contextId: string, values: { [key in string]?: JsonPrimitive }, }; + +export type CallHttpAuthenticationActionRequest = { index: number, pluginRefId: string, args: CallHttpAuthenticationActionArgs, }; + +export type CallHttpAuthenticationRequest = { contextId: string, values: { [key in string]?: JsonPrimitive }, method: string, url: string, headers: Array, }; + +export type CallHttpAuthenticationResponse = { +/** + * HTTP headers to add to the request. Existing headers will be replaced, while + * new headers will be added. + */ +setHeaders: Array, }; + +export type CallHttpRequestActionArgs = { httpRequest: HttpRequest, }; + +export type CallHttpRequestActionRequest = { index: number, 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 CloseWindowRequest = { label: string, }; + +export type Color = "primary" | "secondary" | "info" | "success" | "notice" | "warning" | "danger"; + +export type CompletionOptionType = "constant" | "variable"; + +export type Content = { "type": "text", content: string, } | { "type": "markdown", content: string, }; + +export type CopyTextRequest = { text: string, }; + +export type DeleteKeyValueRequest = { key: string, }; + +export type DeleteKeyValueResponse = { deleted: boolean, }; + +export type EditorLanguage = "text" | "javascript" | "json" | "html" | "xml" | "graphql" | "markdown"; + +export type EmptyPayload = {}; + +export type ErrorResponse = { error: string, }; + +export type ExportHttpRequestRequest = { httpRequest: HttpRequest, }; + +export type ExportHttpRequestResponse = { content: string, }; + +export type FileFilter = { name: string, +/** + * File extensions to require + */ +extensions: Array, }; + +export type FilterRequest = { content: string, filter: string, }; + +export type FilterResponse = { content: string, }; + +export type FindHttpResponsesRequest = { requestId: string, limit?: number, }; + +export type FindHttpResponsesResponse = { httpResponses: Array, }; + +export type FormInput = { "type": "text" } & FormInputText | { "type": "editor" } & FormInputEditor | { "type": "select" } & FormInputSelect | { "type": "checkbox" } & FormInputCheckbox | { "type": "file" } & FormInputFile | { "type": "http_request" } & FormInputHttpRequest | { "type": "accordion" } & FormInputAccordion | { "type": "banner" } & FormInputBanner | { "type": "markdown" } & FormInputMarkdown; + +export type FormInputAccordion = { label: string, inputs?: Array, hidden?: boolean, }; + +export type FormInputBanner = { inputs?: Array, hidden?: boolean, color?: Color, }; + +export type FormInputBase = { +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputCheckbox = { +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputEditor = { +/** + * Placeholder for the text input + */ +placeholder?: string | null, +/** + * Don't show the editor gutter (line numbers, folds, etc.) + */ +hideGutter?: boolean, +/** + * Language for syntax highlighting + */ +language?: EditorLanguage, readOnly?: boolean, completionOptions?: Array, +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputFile = { +/** + * The title of the file selection window + */ +title: string, +/** + * Allow selecting multiple files + */ +multiple?: boolean, directory?: boolean, defaultPath?: string, filters?: Array, +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputHttpRequest = { +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputMarkdown = { content: string, hidden?: boolean, }; + +export type FormInputSelect = { +/** + * The options that will be available in the select input + */ +options: Array, +/** + * The name of the input. The value will be stored at this object attribute in the resulting data + */ +name: string, +/** + * Whether this input is visible for the given configuration. Use this to + * make branching forms. + */ +hidden?: boolean, +/** + * Whether the user must fill in the argument + */ +optional?: boolean, +/** + * The label of the input + */ +label?: string, +/** + * Visually hide the label of the input + */ +hideLabel?: boolean, +/** + * The default value + */ +defaultValue?: string, disabled?: boolean, }; + +export type FormInputSelectOption = { label: string, value: string, }; + +export type FormInputText = { +/** + * Placeholder for the text input + */ +placeholder?: string | null, +/** + * Placeholder for the text input + */ +password?: boolean, +/** + * Whether to allow newlines in the input, like a