PromucFlow_constructor/app/client/src/api/TemplatesApi.ts
Ankita Kinger 47c09cef92
chore: Code splitting FE files to support app level invites on Business edition (#21783)
## Description

> Code splitting FE files to support app level invites on Business
edition.

Fixes [#21018](https://github.com/appsmithorg/appsmith/issues/21018)
[#21015](https://github.com/appsmithorg/appsmith/issues/21015)

## Type of change

- Chore (housekeeping or task changes that don't impact user perception)


## How Has This Been Tested?
> Nothing is affected on CE by this change.

- Manual

## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-03-29 17:07:06 +00:00

88 lines
2.4 KiB
TypeScript

import type { AxiosPromise } from "axios";
import Api from "api/Api";
import type { ApiResponse } from "./ApiResponses";
import type { WidgetType } from "constants/WidgetConstants";
import type {
ApplicationResponsePayload,
ApplicationPagePayload,
} from "@appsmith/api/ApplicationApi";
import type { Datasource } from "entities/Datasource";
export interface Template {
id: string;
userPermissions: string[];
title: string;
description: string;
appUrl: string;
gifUrl: string;
screenshotUrls: string[];
widgets: WidgetType[];
functions: string[];
useCases: string[];
datasources: string[];
pages: ApplicationPagePayload[];
}
export type FetchTemplatesResponse = ApiResponse<Template[]>;
export type FilterKeys = "widgets" | "datasources";
export type FetchTemplateResponse = ApiResponse<Template>;
export type ImportTemplateResponse = ApiResponse<{
isPartialImport: boolean;
unConfiguredDatasourceList: Datasource[];
application: ApplicationResponsePayload;
}>;
export interface TemplateFiltersResponse extends ApiResponse {
data: {
functions: string[];
};
}
class TemplatesAPI extends Api {
static baseUrl = "v1";
static getAllTemplates(): AxiosPromise<FetchTemplatesResponse> {
return Api.get(TemplatesAPI.baseUrl + `/app-templates`);
}
static getTemplateInformation(
templateId: string,
): AxiosPromise<FetchTemplatesResponse> {
return Api.get(TemplatesAPI.baseUrl + `/app-templates/${templateId}`);
}
static getSimilarTemplates(
templateId: string,
): AxiosPromise<FetchTemplatesResponse> {
return Api.get(
TemplatesAPI.baseUrl + `/app-templates/${templateId}/similar`,
);
}
static importTemplate(
templateId: string,
workspaceId: string,
): AxiosPromise<ImportTemplateResponse> {
return Api.post(
TemplatesAPI.baseUrl +
`/app-templates/${templateId}/import/${workspaceId}`,
);
}
static importTemplateToApplication(
templateId: string,
applicationId: string,
organizationId: string,
body?: string[],
): AxiosPromise<ImportTemplateResponse> {
return Api.post(
TemplatesAPI.baseUrl +
`/app-templates/${templateId}/merge/${applicationId}/${organizationId}`,
body,
);
}
static getTemplateFilters(): AxiosPromise<TemplateFiltersResponse> {
return Api.get(TemplatesAPI.baseUrl + `/app-templates/filters`);
}
}
export default TemplatesAPI;