2021-01-12 04:17:28 +00:00
|
|
|
import { EmbeddedRestDatasource } from "entities/Datasource";
|
2020-11-12 11:23:32 +00:00
|
|
|
import { DynamicPath } from "../../utils/DynamicBindingUtils";
|
2021-01-12 04:17:28 +00:00
|
|
|
import _ from "lodash";
|
2020-06-04 13:49:22 +00:00
|
|
|
|
|
|
|
|
export enum PluginType {
|
|
|
|
|
API = "API",
|
|
|
|
|
DB = "DB",
|
2021-04-22 03:30:09 +00:00
|
|
|
SAAS = "SAAS",
|
2021-09-08 13:47:30 +00:00
|
|
|
JS = "JS",
|
2021-09-21 12:05:29 +00:00
|
|
|
REMOTE = "REMOTE",
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum PaginationType {
|
|
|
|
|
NONE = "NONE",
|
|
|
|
|
PAGE_NO = "PAGE_NO",
|
|
|
|
|
URL = "URL",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ActionConfig {
|
2021-01-12 04:17:28 +00:00
|
|
|
timeoutInMillisecond?: number;
|
2020-06-04 13:49:22 +00:00
|
|
|
paginationType?: PaginationType;
|
2021-08-23 07:34:44 +00:00
|
|
|
formData?: Record<string, unknown>;
|
2021-04-26 05:41:32 +00:00
|
|
|
pluginSpecifiedTemplates?: Array<{ key?: string; value?: unknown }>;
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ActionProvider {
|
|
|
|
|
name: string;
|
|
|
|
|
imageUrl: string;
|
|
|
|
|
url: string;
|
|
|
|
|
description: string;
|
|
|
|
|
credentialSteps: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Property {
|
|
|
|
|
key: string;
|
|
|
|
|
value: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface BodyFormData {
|
|
|
|
|
editable: boolean;
|
|
|
|
|
mandatory: boolean;
|
|
|
|
|
description: string;
|
|
|
|
|
key: string;
|
|
|
|
|
value?: string;
|
|
|
|
|
type: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ApiActionConfig extends ActionConfig {
|
|
|
|
|
headers: Property[];
|
|
|
|
|
httpMethod: string;
|
|
|
|
|
path?: string;
|
|
|
|
|
body?: JSON | string | Record<string, any> | null;
|
2021-02-16 15:01:35 +00:00
|
|
|
encodeParamsToggle: boolean;
|
2020-06-04 13:49:22 +00:00
|
|
|
queryParameters?: Property[];
|
|
|
|
|
bodyFormData?: BodyFormData[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface QueryActionConfig extends ActionConfig {
|
2021-01-12 04:17:28 +00:00
|
|
|
body?: string;
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-12 04:17:28 +00:00
|
|
|
export const isStoredDatasource = (val: any): val is StoredDatasource => {
|
|
|
|
|
if (!_.isObject(val)) return false;
|
|
|
|
|
if (!("id" in val)) return false;
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
export interface StoredDatasource {
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
export interface BaseAction {
|
2020-06-04 13:49:22 +00:00
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
organizationId: string;
|
|
|
|
|
pageId: string;
|
|
|
|
|
collectionId?: string;
|
|
|
|
|
pluginId: string;
|
|
|
|
|
executeOnLoad: boolean;
|
2020-11-12 11:23:32 +00:00
|
|
|
dynamicBindingPathList: DynamicPath[];
|
2020-06-04 13:49:22 +00:00
|
|
|
isValid: boolean;
|
|
|
|
|
invalids: string[];
|
|
|
|
|
jsonPathKeys: string[];
|
|
|
|
|
cacheResponse: string;
|
2020-09-08 04:57:13 +00:00
|
|
|
confirmBeforeExecute?: boolean;
|
2021-01-12 04:17:28 +00:00
|
|
|
eventData?: any;
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-12 04:17:28 +00:00
|
|
|
interface BaseApiAction extends BaseAction {
|
|
|
|
|
pluginType: PluginType.API;
|
|
|
|
|
actionConfiguration: ApiActionConfig;
|
|
|
|
|
}
|
2021-04-22 03:30:09 +00:00
|
|
|
export interface SaaSAction extends BaseAction {
|
|
|
|
|
pluginType: PluginType.SAAS;
|
|
|
|
|
actionConfiguration: any;
|
|
|
|
|
datasource: StoredDatasource;
|
|
|
|
|
}
|
2021-09-21 12:05:29 +00:00
|
|
|
export interface RemoteAction extends BaseAction {
|
|
|
|
|
pluginType: PluginType.REMOTE;
|
|
|
|
|
actionConfiguration: any;
|
|
|
|
|
datasource: StoredDatasource;
|
|
|
|
|
}
|
2021-01-12 04:17:28 +00:00
|
|
|
|
|
|
|
|
export interface EmbeddedApiAction extends BaseApiAction {
|
|
|
|
|
datasource: EmbeddedRestDatasource;
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-12 04:17:28 +00:00
|
|
|
export interface StoredDatasourceApiAction extends BaseApiAction {
|
|
|
|
|
datasource: StoredDatasource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type ApiAction = EmbeddedApiAction | StoredDatasourceApiAction;
|
|
|
|
|
|
|
|
|
|
export type RapidApiAction = ApiAction & {
|
2020-06-04 13:49:22 +00:00
|
|
|
templateId: string;
|
|
|
|
|
proverId: string;
|
|
|
|
|
provider: ActionProvider;
|
|
|
|
|
pluginId: string;
|
|
|
|
|
documentation: { text: string };
|
2021-01-12 04:17:28 +00:00
|
|
|
};
|
2020-06-04 13:49:22 +00:00
|
|
|
|
2021-01-12 04:17:28 +00:00
|
|
|
export interface QueryAction extends BaseAction {
|
|
|
|
|
pluginType: PluginType.DB;
|
|
|
|
|
actionConfiguration: QueryActionConfig;
|
|
|
|
|
datasource: StoredDatasource;
|
2020-06-04 13:49:22 +00:00
|
|
|
}
|
2021-01-12 04:17:28 +00:00
|
|
|
|
2021-01-26 03:12:52 +00:00
|
|
|
export type ActionViewMode = {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
pageId: string;
|
|
|
|
|
jsonPathKeys: string[];
|
|
|
|
|
confirmBeforeExecute?: boolean;
|
|
|
|
|
timeoutInMillisecond?: number;
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-21 12:05:29 +00:00
|
|
|
export type Action = ApiAction | QueryAction | SaaSAction | RemoteAction;
|