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";
|
2022-01-13 08:07:30 +00:00
|
|
|
import { DropdownOption } from "components/ads/Dropdown";
|
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>;
|
|
|
|
|
|
2021-08-26 05:37:07 +00:00
|
|
|
export enum UIComponentTypes {
|
|
|
|
|
DbEditorForm = "DbEditorForm",
|
|
|
|
|
UQIDbEditorForm = "UQIDbEditorForm",
|
|
|
|
|
ApiEditorForm = "ApiEditorForm",
|
|
|
|
|
RapidApiEditorForm = "RapidApiEditorForm",
|
2021-09-08 17:32:22 +00:00
|
|
|
JsEditorForm = "JsEditorForm",
|
2021-08-26 05:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum DatasourceComponentTypes {
|
|
|
|
|
RestAPIDatasourceForm = "RestAPIDatasourceForm",
|
|
|
|
|
AutoForm = "AutoForm",
|
|
|
|
|
}
|
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;
|
2021-08-26 05:37:07 +00:00
|
|
|
uiComponent: UIComponentTypes;
|
|
|
|
|
datasourceComponent: DatasourceComponentTypes;
|
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`);
|
|
|
|
|
}
|
2022-01-13 08:07:30 +00:00
|
|
|
|
|
|
|
|
// Definition to fetch the dynamic data via the URL passed in the config
|
|
|
|
|
static fetchDynamicFormValues(
|
|
|
|
|
url: string,
|
|
|
|
|
): AxiosPromise<GenericApiResponse<DropdownOption[]>> {
|
|
|
|
|
return Api.get(url);
|
|
|
|
|
}
|
2019-11-29 05:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PluginsApi;
|