mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 23:31:21 +02:00
Updated plugin APIs
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "tsc"
|
"build": "tsc",
|
||||||
|
"prepublish": "npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^22.0.0"
|
"@types/node": "^22.0.0"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
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 SingleOrArray<T> = T[] | T;
|
export type OneOrMany<T> = T[] | T;
|
||||||
|
|||||||
13
plugin-runtime-types/src/plugins/filter.ts
Normal file
13
plugin-runtime-types/src/plugins/filter.ts
Normal file
@@ -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<boolean>;
|
||||||
|
onFilter(
|
||||||
|
ctx: YaakContext,
|
||||||
|
args: { payload: string; mimeType: string },
|
||||||
|
): Promise<FilterPluginResponse>;
|
||||||
|
};
|
||||||
8
plugin-runtime-types/src/plugins/httpRequestAction.ts
Normal file
8
plugin-runtime-types/src/plugins/httpRequestAction.ts
Normal file
@@ -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;
|
||||||
|
};
|
||||||
@@ -3,14 +3,14 @@ import { Environment, Folder, HttpRequest, Workspace } from '../models';
|
|||||||
import { YaakContext } from './context';
|
import { YaakContext } from './context';
|
||||||
|
|
||||||
export type ImportPluginResponse = null | {
|
export type ImportPluginResponse = null | {
|
||||||
resources: Partial<{
|
workspaces: AtLeast<Workspace, 'name' | 'id' | 'model'>[];
|
||||||
workspaces: AtLeast<Workspace, 'name' | 'id' | 'model'>[];
|
environments: AtLeast<Environment, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||||
environments: AtLeast<Environment, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
httpRequests: AtLeast<HttpRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||||
httpRequests: AtLeast<HttpRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||||
folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
|
||||||
}>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImporterPlugin = {
|
export type ImporterPlugin = {
|
||||||
onImport(ctx: YaakContext, fileContents: string): Promise<ImportPluginResponse>;
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
onImport(ctx: YaakContext, args: { text: string }): Promise<ImportPluginResponse>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 { ImporterPlugin } from './import';
|
||||||
import { ThemePlugin } from './theme';
|
import { ThemePlugin } from './theme';
|
||||||
|
|
||||||
@@ -6,8 +8,8 @@ import { ThemePlugin } from './theme';
|
|||||||
* The global structure of a Yaak plugin
|
* The global structure of a Yaak plugin
|
||||||
*/
|
*/
|
||||||
export type YaakPlugin = {
|
export type YaakPlugin = {
|
||||||
/** One or many plugins to import data into Yaak */
|
importer?: OneOrMany<ImporterPlugin>;
|
||||||
importers?: SingleOrArray<ImporterPlugin>;
|
theme?: OneOrMany<ThemePlugin>;
|
||||||
/** One or many themes to customize the Yaak UI */
|
filter?: OneOrMany<FilterPlugin>;
|
||||||
themes?: SingleOrArray<ThemePlugin>;
|
httpRequestAction?: OneOrMany<HttpRequestActionPlugin>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Theme } from '../themes';
|
import { Theme } from '../themes';
|
||||||
|
import { YaakContext } from './context';
|
||||||
|
|
||||||
export type ThemePlugin = {
|
export type ThemePlugin = {
|
||||||
theme: Theme;
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
getTheme(ctx: YaakContext, fileContents: string): Promise<Theme>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user