mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-08 00:43:46 +02:00
Start of plugin types refactor
This commit is contained in:
11
plugin-runtime-types/src/plugins/context.ts
Normal file
11
plugin-runtime-types/src/plugins/context.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { HttpRequest, HttpResponse } from '../models';
|
||||
|
||||
export type YaakContext = {
|
||||
metadata: {
|
||||
getVersion(): Promise<string>;
|
||||
};
|
||||
httpRequest: {
|
||||
send(id: string): Promise<HttpResponse>;
|
||||
getById(id: string): Promise<HttpRequest | null>;
|
||||
};
|
||||
};
|
||||
16
plugin-runtime-types/src/plugins/import.ts
Normal file
16
plugin-runtime-types/src/plugins/import.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { AtLeast } from '../helpers';
|
||||
import { Environment, Folder, HttpRequest, Workspace } from '../models';
|
||||
import { YaakContext } from './context';
|
||||
|
||||
export type ImportPluginResponse = null | {
|
||||
resources: Partial<{
|
||||
workspaces: AtLeast<Workspace, 'name' | 'id' | 'model'>[];
|
||||
environments: AtLeast<Environment, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||
httpRequests: AtLeast<HttpRequest, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||
folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];
|
||||
}>;
|
||||
};
|
||||
|
||||
export type ImporterPlugin = {
|
||||
onImport(ctx: YaakContext, fileContents: string): Promise<ImportPluginResponse>;
|
||||
};
|
||||
13
plugin-runtime-types/src/plugins/index.ts
Normal file
13
plugin-runtime-types/src/plugins/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { SingleOrArray } from '../helpers';
|
||||
import { ImporterPlugin } from './import';
|
||||
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<ImporterPlugin>;
|
||||
/** One or many themes to customize the Yaak UI */
|
||||
themes?: SingleOrArray<ThemePlugin>;
|
||||
};
|
||||
5
plugin-runtime-types/src/plugins/theme.ts
Normal file
5
plugin-runtime-types/src/plugins/theme.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Theme } from '../themes';
|
||||
|
||||
export type ThemePlugin = {
|
||||
theme: Theme;
|
||||
};
|
||||
Reference in New Issue
Block a user