diff --git a/packages/plugin-runtime-types/src/plugins/Context.ts b/packages/plugin-runtime-types/src/plugins/Context.ts index 5d8918e8..a1edb7e3 100644 --- a/packages/plugin-runtime-types/src/plugins/Context.ts +++ b/packages/plugin-runtime-types/src/plugins/Context.ts @@ -68,10 +68,6 @@ export interface Context { templates: { render(args: TemplateRenderRequest & { data: T }): Promise; }; - file: { - writeText(filePath: string, content: string): Promise; - readText(filePath: string): Promise; - }; plugin: { reload(): void; }; diff --git a/packages/plugin-runtime/src/PluginInstance.ts b/packages/plugin-runtime/src/PluginInstance.ts index 4bea594e..284941f9 100644 --- a/packages/plugin-runtime/src/PluginInstance.ts +++ b/packages/plugin-runtime/src/PluginInstance.ts @@ -689,24 +689,6 @@ export class PluginInstance { return result.data as any; }, }, - file: { - writeText: async (filePath: string, content: string) => { - const payload: InternalEventPayload = { - type: 'write_text_file_request', - filePath, - content, - } as any; - await this.#sendForReply(context, payload); - }, - readText: async (filePath: string) => { - const payload: InternalEventPayload = { - type: 'read_text_file_request', - filePath, - } as any; - const result = await this.#sendForReply(context, payload); - return result.content; - }, - }, store: { get: async (key: string) => { const payload = { type: 'get_key_value_request', key } as const; diff --git a/src-tauri/src/plugin_events.rs b/src-tauri/src/plugin_events.rs index 5d20eff7..45774153 100644 --- a/src-tauri/src/plugin_events.rs +++ b/src-tauri/src/plugin_events.rs @@ -21,10 +21,10 @@ use yaak_plugins::error::Error::PluginErr; use yaak_plugins::events::{ Color, DeleteKeyValueResponse, EmptyPayload, ErrorResponse, FindHttpResponsesResponse, GetCookieValueResponse, GetHttpRequestByIdResponse, GetKeyValueResponse, Icon, InternalEvent, - ListHttpRequestsResponse, - InternalEventPayload, ListCookieNamesResponse, RenderGrpcRequestResponse, - RenderHttpRequestResponse, SendHttpRequestResponse, SetKeyValueResponse, ShowToastRequest, - TemplateRenderResponse, WindowInfoResponse, WindowNavigateEvent, + InternalEventPayload, ListCookieNamesResponse, ListHttpRequestsResponse, + RenderGrpcRequestResponse, RenderHttpRequestResponse, SendHttpRequestResponse, + SetKeyValueResponse, ShowToastRequest, TemplateRenderResponse, WindowInfoResponse, + WindowNavigateEvent, }; use yaak_plugins::plugin_handle::PluginHandle; use yaak_plugins::template_callback::PluginTemplateCallback; @@ -65,9 +65,8 @@ pub(crate) async fn handle_plugin_event( InternalEventPayload::ListHttpRequestsRequest(req) => { let mut http_requests = Vec::new(); if let Some(folder_id) = req.folder_id { - http_requests = app_handle - .db() - .list_http_requests_for_folder_recursive(&folder_id)?; + http_requests = + app_handle.db().list_http_requests_for_folder_recursive(&folder_id)?; } else if let Some(workspace_id) = req.workspace_id { http_requests = app_handle.db().list_http_requests(&workspace_id)?; } @@ -380,26 +379,7 @@ pub(crate) async fn handle_plugin_event( environment_id, }))) } - InternalEventPayload::WriteTextFileRequest(req) => { - use std::fs; - use std::path::Path; - - // Ensure the directory exists - if let Some(parent) = Path::new(&req.file_path).parent() { - fs::create_dir_all(parent)?; - } - - fs::write(&req.file_path, &req.content)?; - Ok(Some(InternalEventPayload::WriteTextFileResponse(EmptyPayload {}))) - } - InternalEventPayload::ReadTextFileRequest(req) => { - use std::fs; - - let content = fs::read_to_string(&req.file_path)?; - Ok(Some(InternalEventPayload::ReadTextFileResponse( - yaak_plugins::events::ReadTextFileResponse { content }, - ))) - } + _ => Ok(None), } } diff --git a/src-tauri/yaak-plugins/src/events.rs b/src-tauri/yaak-plugins/src/events.rs index 91ab124b..f6d2d368 100644 --- a/src-tauri/yaak-plugins/src/events.rs +++ b/src-tauri/yaak-plugins/src/events.rs @@ -163,11 +163,6 @@ pub enum InternalEventPayload { GetThemesRequest(GetThemesRequest), GetThemesResponse(GetThemesResponse), - WriteTextFileRequest(WriteTextFileRequest), - WriteTextFileResponse(EmptyPayload), - ReadTextFileRequest(ReadTextFileRequest), - ReadTextFileResponse(ReadTextFileResponse), - /// Returned when a plugin doesn't get run, just so the server /// has something to listen for EmptyResponse(EmptyPayload), @@ -1319,25 +1314,3 @@ pub struct DeleteKeyValueRequest { pub struct DeleteKeyValueResponse { pub deleted: bool, } - -#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)] -#[serde(default, rename_all = "camelCase")] -#[ts(export, export_to = "gen_events.ts")] -pub struct WriteTextFileRequest { - pub file_path: String, - pub content: String, -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)] -#[serde(default, rename_all = "camelCase")] -#[ts(export, export_to = "gen_events.ts")] -pub struct ReadTextFileRequest { - pub file_path: String, -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)] -#[serde(default, rename_all = "camelCase")] -#[ts(export, export_to = "gen_events.ts")] -pub struct ReadTextFileResponse { - pub content: String, -}