From 7a941016a9e395ae573a2fe1bcfafa4a0f4e7243 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 1 Oct 2024 11:02:38 -0700 Subject: [PATCH] Fix plugin types --- plugin-runtime-types/package.json | 2 +- plugin-runtime-types/src/bindings/events.ts | 44 +++++++++++++++------ plugin-runtime-types/src/plugins/Context.ts | 2 - 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/plugin-runtime-types/package.json b/plugin-runtime-types/package.json index 58dd5604..501e336d 100644 --- a/plugin-runtime-types/package.json +++ b/plugin-runtime-types/package.json @@ -1,6 +1,6 @@ { "name": "@yaakapp/api", - "version": "0.2.11", + "version": "0.2.13", "main": "lib/index.js", "typings": "./lib/index.d.ts", "files": [ diff --git a/plugin-runtime-types/src/bindings/events.ts b/plugin-runtime-types/src/bindings/events.ts index 1db06ae0..24dd4f75 100644 --- a/plugin-runtime-types/src/bindings/events.ts +++ b/plugin-runtime-types/src/bindings/events.ts @@ -33,7 +33,7 @@ export type FilterRequest = { content: string, filter: string, }; export type FilterResponse = { content: string, }; -export type FindHttpResponsesRequest = { requestId: string, limit: number | null, }; +export type FindHttpResponsesRequest = { requestId: string, limit?: number, }; export type FindHttpResponsesResponse = { httpResponses: Array, }; @@ -47,9 +47,9 @@ export type GetHttpRequestByIdResponse = { httpRequest: HttpRequest | null, }; export type GetTemplateFunctionsResponse = { functions: Array, pluginRefId: string, }; -export type HttpRequestAction = { key: string, label: string, icon: string | null, }; +export type HttpRequestAction = { key: string, label: string, icon?: Icon, }; -export type Icon = "copy" | "info" | "check_circle" | "alert_triangle"; +export type Icon = "copy" | "info" | "check_circle" | "alert_triangle" | "_unknown"; export type ImportRequest = { content: string, }; @@ -59,7 +59,9 @@ export type ImportResponse = { resources: ImportResources, }; export type InternalEvent = { id: string, pluginRefId: string, replyId: string | null, payload: InternalEventPayload, windowContext: WindowContext, }; -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": "template_render_request" } & TemplateRenderRequest | { "type": "template_render_response" } & TemplateRenderResponse | { "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": "template_render_request" } & TemplateRenderRequest | { "type": "template_render_response" } & TemplateRenderResponse | { "type": "show_toast_request" } & ShowToastRequest | { "type": "show_prompt_request" } & ShowPromptRequest | { "type": "show_prompt_response" } & ShowPromptResponse | { "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 OpenFileFilter = { name: string, extensions: Array, }; export type RenderHttpRequestRequest = { httpRequest: HttpRequest, purpose: RenderPurpose, }; @@ -71,23 +73,41 @@ export type SendHttpRequestRequest = { httpRequest: HttpRequest, }; export type SendHttpRequestResponse = { httpResponse: HttpResponse, }; -export type ShowToastRequest = { message: string, color?: Color | null, icon?: Icon | null, }; +export type ShowPromptRequest = { 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 + */ +require?: boolean, }; -export type TemplateFunction = { name: string, aliases: Array, args: Array, }; +export type ShowPromptResponse = { value: string, }; -export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg; +export type ShowToastRequest = { message: string, color?: Color, icon?: Icon, }; -export type TemplateFunctionBaseArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, }; +export type TemplateFunction = { name: string, aliases?: Array, args: Array, }; -export type TemplateFunctionCheckboxArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, }; +export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg | { "type": "file" } & TemplateFunctionFileArg; -export type TemplateFunctionHttpRequestArg = { name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, }; +export type TemplateFunctionBaseArg = { name: string, optional?: boolean, label?: string, defaultValue?: string, }; -export type TemplateFunctionSelectArg = { options: Array, name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, }; +export type TemplateFunctionCheckboxArg = { name: string, optional?: boolean, label?: string, defaultValue?: string, }; + +export type TemplateFunctionFileArg = { title: string, multiple?: boolean, directory?: boolean, defaultPath?: string, filters?: Array, name: string, optional?: boolean, label?: string, defaultValue?: string, }; + +export type TemplateFunctionHttpRequestArg = { name: string, optional?: boolean, label?: string, defaultValue?: string, }; + +export type TemplateFunctionSelectArg = { options: Array, name: string, optional?: boolean, label?: string, defaultValue?: string, }; export type TemplateFunctionSelectOption = { name: string, value: string, }; -export type TemplateFunctionTextArg = { placeholder?: string | null, name: string, optional?: boolean | null, label?: string | null, defaultValue?: string | null, }; +export type TemplateFunctionTextArg = { placeholder?: string, name: string, optional?: boolean, label?: string, defaultValue?: string, }; export type TemplateRenderRequest = { data: JsonValue, purpose: RenderPurpose, }; diff --git a/plugin-runtime-types/src/plugins/Context.ts b/plugin-runtime-types/src/plugins/Context.ts index fa85e68d..4f019322 100644 --- a/plugin-runtime-types/src/plugins/Context.ts +++ b/plugin-runtime-types/src/plugins/Context.ts @@ -3,8 +3,6 @@ import { ShowPromptResponse, TemplateRenderRequest, TemplateRenderResponse, -} from '@yaakapp-internal/plugin'; -import { FindHttpResponsesRequest, FindHttpResponsesResponse, GetHttpRequestByIdRequest,