2021-03-22 09:22:24 +00:00
|
|
|
import Api from "api/Api";
|
2019-11-29 05:22:49 +00:00
|
|
|
import { AxiosPromise } from "axios";
|
|
|
|
|
import { GenericApiResponse } from "api/ApiResponses";
|
2021-04-22 03:30:09 +00:00
|
|
|
import { PluginType } from "entities/Action";
|
2021-04-26 05:41:32 +00:00
|
|
|
import { DependencyMap } from "utils/DynamicBindingUtils";
|
2019-11-29 05:22:49 +00:00
|
|
|
|
2021-07-29 08:13:10 +00:00
|
|
|
export type PluginId = string;
|
|
|
|
|
export type PluginPackageName = string;
|
|
|
|
|
export type GenerateCRUDEnabledPluginMap = Record<PluginId, PluginPackageName>;
|
|
|
|
|
|
2019-11-29 05:22:49 +00:00
|
|
|
export interface Plugin {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
2021-04-22 03:30:09 +00:00
|
|
|
type: PluginType;
|
2020-04-14 12:34:14 +00:00
|
|
|
packageName: string;
|
2020-07-21 10:36:53 +00:00
|
|
|
iconLocation?: string;
|
2020-04-14 12:34:14 +00:00
|
|
|
uiComponent: "ApiEditorForm" | "RapidApiEditorForm" | "DbEditorForm";
|
2021-02-11 12:28:06 +00:00
|
|
|
datasourceComponent: "RestAPIDatasourceForm" | "AutoForm";
|
2020-05-05 09:03:03 +00:00
|
|
|
allowUserDatasources?: boolean;
|
2020-07-21 10:36:53 +00:00
|
|
|
templates: Record<string, string>;
|
|
|
|
|
responseType?: "TABLE" | "JSON";
|
|
|
|
|
documentationLink?: string;
|
2021-07-29 08:13:10 +00:00
|
|
|
generateCRUDPageComponent?: string;
|
2019-11-29 05:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-30 05:29:03 +00:00
|
|
|
export interface PluginFormPayload {
|
|
|
|
|
form: any[];
|
|
|
|
|
editor: any[];
|
|
|
|
|
setting: any[];
|
2021-04-26 05:41:32 +00:00
|
|
|
dependencies: DependencyMap;
|
2020-04-29 09:23:23 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-29 05:22:49 +00:00
|
|
|
class PluginsApi extends Api {
|
|
|
|
|
static url = "v1/plugins";
|
2020-06-17 10:19:56 +00:00
|
|
|
static fetchPlugins(
|
|
|
|
|
orgId: string,
|
|
|
|
|
): AxiosPromise<GenericApiResponse<Plugin[]>> {
|
|
|
|
|
return Api.get(PluginsApi.url, { organizationId: orgId });
|
2019-11-29 05:22:49 +00:00
|
|
|
}
|
2020-04-29 09:23:23 +00:00
|
|
|
|
|
|
|
|
static fetchFormConfig(
|
|
|
|
|
id: string,
|
2021-03-30 05:29:03 +00:00
|
|
|
): AxiosPromise<GenericApiResponse<PluginFormPayload>> {
|
2020-04-29 09:23:23 +00:00
|
|
|
return Api.get(PluginsApi.url + `/${id}/form`);
|
|
|
|
|
}
|
2019-11-29 05:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PluginsApi;
|