diff --git a/plugin-runtime-types/package.json b/plugin-runtime-types/package.json index d9cb6a91..8d30049f 100644 --- a/plugin-runtime-types/package.json +++ b/plugin-runtime-types/package.json @@ -7,7 +7,8 @@ "lib" ], "scripts": { - "prepublish": "tsc" + "build": "tsc", + "prepublish": "npm run build" }, "dependencies": { "@types/node": "^22.0.0" diff --git a/plugin-runtime-types/src/helpers.ts b/plugin-runtime-types/src/helpers.ts index be548943..eaf85448 100644 --- a/plugin-runtime-types/src/helpers.ts +++ b/plugin-runtime-types/src/helpers.ts @@ -1,2 +1,2 @@ export type AtLeast = Partial & Pick; -export type SingleOrArray = T[] | T; +export type OneOrMany = T[] | T; diff --git a/plugin-runtime-types/src/plugins/filter.ts b/plugin-runtime-types/src/plugins/filter.ts new file mode 100644 index 00000000..80a223c2 --- /dev/null +++ b/plugin-runtime-types/src/plugins/filter.ts @@ -0,0 +1,13 @@ +import { YaakContext } from './context'; + +export type FilterPluginResponse = string[]; + +export type FilterPlugin = { + name: string; + description?: string; + canFilter(ctx: YaakContext, args: { mimeType: string }): Promise; + onFilter( + ctx: YaakContext, + args: { payload: string; mimeType: string }, + ): Promise; +}; diff --git a/plugin-runtime-types/src/plugins/httpRequestAction.ts b/plugin-runtime-types/src/plugins/httpRequestAction.ts new file mode 100644 index 00000000..547396e9 --- /dev/null +++ b/plugin-runtime-types/src/plugins/httpRequestAction.ts @@ -0,0 +1,8 @@ +import { HttpRequest } from '../models'; +import { YaakContext } from './context'; + +export type HttpRequestActionPlugin = { + key: string; + label: string; + onSelect(ctx: YaakContext, args: { httpRequest: HttpRequest }): void; +}; diff --git a/plugin-runtime-types/src/plugins/import.ts b/plugin-runtime-types/src/plugins/import.ts index 6868ef3f..51873486 100644 --- a/plugin-runtime-types/src/plugins/import.ts +++ b/plugin-runtime-types/src/plugins/import.ts @@ -3,14 +3,14 @@ import { Environment, Folder, HttpRequest, Workspace } from '../models'; import { YaakContext } from './context'; export type ImportPluginResponse = null | { - resources: Partial<{ - workspaces: AtLeast[]; - environments: AtLeast[]; - httpRequests: AtLeast[]; - folders: AtLeast[]; - }>; + workspaces: AtLeast[]; + environments: AtLeast[]; + httpRequests: AtLeast[]; + folders: AtLeast[]; }; export type ImporterPlugin = { - onImport(ctx: YaakContext, fileContents: string): Promise; + name: string; + description?: string; + onImport(ctx: YaakContext, args: { text: string }): Promise; }; diff --git a/plugin-runtime-types/src/plugins/index.ts b/plugin-runtime-types/src/plugins/index.ts index e6716db9..db1da8e2 100644 --- a/plugin-runtime-types/src/plugins/index.ts +++ b/plugin-runtime-types/src/plugins/index.ts @@ -1,4 +1,6 @@ -import { SingleOrArray } from '../helpers'; +import { OneOrMany } from '../helpers'; +import { FilterPlugin } from './filter'; +import { HttpRequestActionPlugin } from './httpRequestAction'; import { ImporterPlugin } from './import'; import { ThemePlugin } from './theme'; @@ -6,8 +8,8 @@ import { ThemePlugin } from './theme'; * The global structure of a Yaak plugin */ export type YaakPlugin = { - /** One or many plugins to import data into Yaak */ - importers?: SingleOrArray; - /** One or many themes to customize the Yaak UI */ - themes?: SingleOrArray; + importer?: OneOrMany; + theme?: OneOrMany; + filter?: OneOrMany; + httpRequestAction?: OneOrMany; }; diff --git a/plugin-runtime-types/src/plugins/theme.ts b/plugin-runtime-types/src/plugins/theme.ts index fb8b2312..3b1efb7f 100644 --- a/plugin-runtime-types/src/plugins/theme.ts +++ b/plugin-runtime-types/src/plugins/theme.ts @@ -1,5 +1,8 @@ import { Theme } from '../themes'; +import { YaakContext } from './context'; export type ThemePlugin = { - theme: Theme; + name: string; + description?: string; + getTheme(ctx: YaakContext, fileContents: string): Promise; };