PromucFlow_constructor/app/client/src/entities/Datasource/RestAPIForm.ts
Ayush Pahwa bf62dc9695
chore: poc to merge DS editor data flows (#22920)
## Description

POC to merge the DS editors for 3 different types of datasources
- Databases and SAAS
- G sheets
- Authenticated API and Graphql

This PR will not merge the G sheets editor since it is tied to a lot of
places in testing and URL. This will be picked in another iteration.

Fixes #22860 
Fixes #23424 
Fixes #21580 
(#1367 from EE)


Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video


## Type of change

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


## How Has This Been Tested?

- Manual
- Jest
- Cypress

### Test Plan
-
[PostGreSQL](https://github.com/appsmithorg/TestSmith/issues?q=is%3Aopen+is%3Aissue+label%3APostgres)
[Regression Cases to be executed]
-
[Mongo](https://github.com/appsmithorg/TestSmith/issues?q=is%3Aopen+is%3Aissue+label%3AMongo)
- GraphQL and Rest -
[link](https://docs.google.com/spreadsheets/d/1ak1Fj5vXYEk3WkV-4eZI-r8Lg3X2IKtUcrXpzawbtjk/edit#gid=1177791628)

### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)


## Checklist:
### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
- [x] 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-05-22 19:05:59 +07:00

111 lines
2.3 KiB
TypeScript

import type { Property } from "entities/Action";
export enum AuthType {
NONE = "dbAuth",
OAuth2 = "oAuth2",
basic = "basic",
apiKey = "apiKey",
bearerToken = "bearerToken",
}
export enum SSLType {
DEFAULT = "DEFAULT",
SELF_SIGNED_CERTIFICATE = "SELF_SIGNED_CERTIFICATE",
}
export enum ApiKeyAuthType {
QueryParams = "queryParams",
Header = "header",
}
export enum GrantType {
ClientCredentials = "client_credentials",
AuthorizationCode = "authorization_code",
}
export type Authentication =
| ClientCredentials
| AuthorizationCode
| Basic
| ApiKey
| BearerToken;
export interface Connection {
ssl: SSL;
}
export interface SSL {
authType: SSLType;
certificateFile: Certificate;
}
export interface Certificate {
name: string;
base64Content: string | ArrayBuffer | null;
}
export interface ApiDatasourceForm {
datasourceId: string;
pluginId: string;
workspaceId: string;
isValid: boolean;
url: string;
headers?: Property[];
queryParameters?: Property[];
isSendSessionEnabled: boolean;
sessionSignatureKey: string;
authType: AuthType;
authentication?: Authentication;
connection?: Connection;
userPermissions?: string[];
name?: string;
}
export interface Oauth2Common {
authenticationType: AuthType.OAuth2;
accessTokenUrl: string;
clientId: string;
clientSecret: string;
headerPrefix: string;
scopeString: string;
isTokenHeader: boolean;
isAuthorizationHeader: boolean;
audience: string;
resource: string;
sendScopeWithRefreshToken: boolean;
refreshTokenClientCredentialsLocation: string;
useSelfSignedCert?: boolean;
}
export interface ClientCredentials extends Oauth2Common {
grantType: GrantType.ClientCredentials;
customTokenParameters: Property[];
}
export interface AuthorizationCode extends Oauth2Common {
grantType: GrantType.AuthorizationCode;
authorizationUrl: string;
customAuthenticationParameters: Property[];
isAuthorized: boolean;
}
export interface Basic {
authenticationType: AuthType.basic;
username: string;
password: string;
secretExists?: Record<string, boolean>;
}
export interface ApiKey {
authenticationType: AuthType.apiKey;
label: string;
headerPrefix: string;
value: string;
addTo: string;
}
export interface BearerToken {
authenticationType: AuthType.bearerToken;
bearerToken: string;
}