Start of plugin types refactor

This commit is contained in:
Gregory Schier
2024-07-31 14:56:55 -07:00
parent a3988188f3
commit 5639e358bc
18 changed files with 331 additions and 154 deletions

View 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>;
};
};

View 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>;
};

View 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>;
};

View File

@@ -0,0 +1,5 @@
import { Theme } from '../themes';
export type ThemePlugin = {
theme: Theme;
};