PromucFlow_constructor/app/client/src/api/JSActionAPI.tsx
Arsalan Yaldram f58451aa5f
feat: upgrade to create react app 5 (#14000)
* Updated Typescript types.

* Typefixes after merge with release.

* chore: GenericApiResponse Removed alltogether.

* chore: resolved ApiResponse unknown errors removed PageListPayload.

* Added shouldBeDefined.

* fix: Resolved type errors.

* fix: Typescript upgrade to 4.5 and type fixes.

* feat: upgrade to cra 5

* feat: uncomment service worker registeration

* force secure websocket protocol

* jest test fixes

* fix: react function lint rule removed

* fix: klona test case.

* fix: typescirpt issues resolved

* fix: timeout for colorpicker test and change env.

* feat: update client-build.yml file

* fix: remove brotliplugin use compression plugin

* fix: build config fixed

* fix: upgrade webpack plugin

* fix: add branchbutton test to todo.

* fix: remove branch button test.

* fix: Add tailwind theme values, fix cypress tests

* fix: Typescript type fixes.

* feat: run jest tests in silent mode

* fix: cypress rgb values add branchbutton jest test

* fix: review comments, fixes for error.message

* fix: increase cache size for the workbox

* fix: remove OrgApi.ts file

* fix: cypress.json file remove credentials

* fix: downgrade react and react-dom packages

Co-authored-by: rahulramesha <rahul@appsmith.com>
2022-06-21 19:27:34 +05:30

122 lines
3.1 KiB
TypeScript

import API from "api/Api";
import { AxiosPromise } from "axios";
import { JSCollection } from "entities/JSCollection";
import { ApiResponse } from "./ApiResponses";
import { Variable, JSAction } from "entities/JSCollection";
import { PluginType } from "entities/Action";
export type JSCollectionCreateUpdateResponse = ApiResponse & {
id: string;
};
export interface MoveJSCollectionRequest {
collectionId: string;
destinationPageId: string;
name: string;
}
export interface UpdateJSObjectNameRequest {
pageId: string;
actionCollectionId: string;
layoutId: string;
newName: string;
oldName: string;
}
export interface CreateJSCollectionRequest {
name: string;
pageId: string;
workspaceId: string;
pluginId: string;
body: string;
variables: Array<Variable>;
actions: Array<Partial<JSAction>>;
applicationId: string;
pluginType: PluginType;
}
export type SetFunctionPropertyPayload = {
action: JSAction;
propertyName: string;
value: any;
};
export interface RefactorAction {
pageId: string;
actionId: string;
newName: string;
oldName: string;
collectionName: string;
}
export interface RefactorActionRequest extends RefactorAction {
layoutId: string;
}
export interface UpdateCollectionActionNameRequest {
refactorAction: RefactorActionRequest;
actionCollection: JSCollection;
}
class JSActionAPI extends API {
static url = "v1/collections/actions";
static fetchJSCollections(
applicationId: string,
): AxiosPromise<ApiResponse<JSCollection[]>> {
return API.get(JSActionAPI.url, { applicationId });
}
static createJSCollection(
jsConfig: CreateJSCollectionRequest,
): AxiosPromise<JSCollectionCreateUpdateResponse> {
return API.post(JSActionAPI.url, jsConfig);
}
static copyJSCollection(
jsConfig: Partial<JSCollection>,
): AxiosPromise<JSCollectionCreateUpdateResponse> {
return API.post(JSActionAPI.url, jsConfig);
}
static updateJSCollection(
jsConfig: JSCollection,
): AxiosPromise<JSCollectionCreateUpdateResponse> {
const jsAction = Object.assign({}, jsConfig);
return API.put(`${JSActionAPI.url}/${jsAction.id}`, jsAction);
}
static deleteJSCollection(id: string) {
return API.delete(`${JSActionAPI.url}/${id}`);
}
static moveJSCollection(moveRequest: MoveJSCollectionRequest) {
return API.put(JSActionAPI.url + "/move", moveRequest);
}
static fetchJSCollectionsByPageId(
pageId: string,
): AxiosPromise<ApiResponse<JSCollection[]>> {
return API.get(JSActionAPI.url, { pageId });
}
static fetchJSCollectionsForViewMode(
applicationId: string,
): AxiosPromise<ApiResponse<JSCollection[]>> {
return API.get(`${JSActionAPI.url}/view`, { applicationId });
}
static updateJSCollectionOrActionName(
updateJSObjectNameRequest: UpdateJSObjectNameRequest,
) {
return API.put(JSActionAPI.url + "/refactor", updateJSObjectNameRequest);
}
static updateJSCollectionActionRefactor(
updateJSCollectionActionName: UpdateCollectionActionNameRequest,
) {
return API.put(
JSActionAPI.url + "/refactorAction",
updateJSCollectionActionName,
);
}
}
export default JSActionAPI;