## Description This PR fixes inconsistencies in the authenticationStatus property for google sheets: - In case of google sheets datasource, when we authorise the datasource, but do not grant permissions, the authenticationStatus is being saved as `IN_PROGRESS`, instead it should be `FAILURE` as user failed to give permissions. - This PR adds 3 new statuses in AuthenticationStatus Enum, `IN_PROGRESS_PERMISSIONS_GRANTED`, `FAILURE_ACCESS_DENIED` and `FAILURE_NO_FILES_SELECTED`. - `IN_PROGRESS_PERMISSIONS_GRANTED` is used in case of specific sheets scope, so that we would know that users have granted permissions and selection of files is pending - `FAILURE_ACCESS_DENIED` denotes, for any of the scope, if user does not grant permissions. - `FAILURE_NO_FILES_SELECTED` denotes, for specific scope, if user grants permissions but files have not been selected yet. #### PR fixes following issue(s) Fixes #23877 > if no issue exists, please create an issue and ask the maintainers about this first > > #### 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 > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### 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 - [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 - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed Co-authored-by: “sneha122” <“sneha@appsmith.com”>
155 lines
3.5 KiB
TypeScript
155 lines
3.5 KiB
TypeScript
import type { APIResponseError } from "api/ApiResponses";
|
|
import type { ActionConfig, Property } from "entities/Action";
|
|
import _ from "lodash";
|
|
|
|
export enum AuthType {
|
|
OAUTH2 = "oAuth2",
|
|
DBAUTH = "dbAuth",
|
|
}
|
|
|
|
export enum AuthenticationStatus {
|
|
NONE = "NONE",
|
|
IN_PROGRESS = "IN_PROGRESS",
|
|
SUCCESS = "SUCCESS",
|
|
FAILURE = "FAILURE",
|
|
FAILURE_ACCESS_DENIED = "FAILURE_ACCESS_DENIED",
|
|
FAILURE_FILE_NOT_SELECTED = "FAILURE_FILE_NOT_SELECTED",
|
|
IN_PROGRESS_PERMISSIONS_GRANTED = "IN_PROGRESS_PERMISSIONS_GRANTED",
|
|
}
|
|
|
|
export enum FilePickerActionStatus {
|
|
CANCEL = "cancel",
|
|
PICKED = "picked",
|
|
LOADED = "loaded",
|
|
}
|
|
|
|
export enum ActionType {
|
|
AUTHORIZE = "authorize",
|
|
DOCUMENTATION = "documentation",
|
|
}
|
|
|
|
export interface DatasourceAuthentication {
|
|
authType?: string;
|
|
username?: string;
|
|
password?: string;
|
|
label?: string;
|
|
headerPrefix?: string;
|
|
value?: string;
|
|
addTo?: string;
|
|
bearerToken?: string;
|
|
authenticationStatus?: string;
|
|
authenticationType?: string;
|
|
secretExists?: Record<string, boolean>;
|
|
}
|
|
|
|
export interface DatasourceColumns {
|
|
name: string;
|
|
type: string;
|
|
}
|
|
|
|
export interface DatasourceKeys {
|
|
name: string;
|
|
type: string;
|
|
columnNames: string[];
|
|
}
|
|
|
|
export interface DatasourceStructure {
|
|
tables?: DatasourceTable[];
|
|
error?: APIResponseError;
|
|
}
|
|
|
|
export interface QueryTemplate {
|
|
actionConfiguration?: ActionConfig;
|
|
configuration: Record<string, unknown>;
|
|
title: string;
|
|
body: string;
|
|
pluginSpecifiedTemplates?: Array<{ key?: string; value?: unknown }>;
|
|
}
|
|
export interface DatasourceTable {
|
|
type: string;
|
|
name: string;
|
|
columns: DatasourceColumns[];
|
|
keys: DatasourceKeys[];
|
|
templates: QueryTemplate[];
|
|
}
|
|
|
|
// todo: check which fields are truly optional and move the common ones into base
|
|
interface BaseDatasource {
|
|
pluginId: string;
|
|
name: string;
|
|
type?: string;
|
|
workspaceId: string;
|
|
isValid: boolean;
|
|
isConfigured?: boolean;
|
|
userPermissions?: string[];
|
|
isDeleting?: boolean;
|
|
isMock?: boolean;
|
|
}
|
|
|
|
export const isEmbeddedRestDatasource = (
|
|
val: any,
|
|
): val is EmbeddedRestDatasource => {
|
|
if (!_.isObject(val)) return false;
|
|
if (!("datasourceConfiguration" in val)) return false;
|
|
val = <EmbeddedRestDatasource>val;
|
|
// Object should exist and have value
|
|
if (!val.datasourceConfiguration) return false;
|
|
//url might exist as a key but not have value, so we won't check value
|
|
if (!("url" in val.datasourceConfiguration)) return false;
|
|
return true;
|
|
};
|
|
|
|
export interface EmbeddedRestDatasource extends BaseDatasource {
|
|
datasourceConfiguration: { url: string };
|
|
invalids: Array<string>;
|
|
messages: Array<string>;
|
|
}
|
|
|
|
export interface DatasourceConfiguration {
|
|
url: string;
|
|
authentication?: DatasourceAuthentication;
|
|
properties?: Property[];
|
|
headers?: Property[];
|
|
queryParameters?: Property[];
|
|
databaseName?: string;
|
|
}
|
|
|
|
export interface Datasource extends BaseDatasource {
|
|
id: string;
|
|
datasourceConfiguration: DatasourceConfiguration;
|
|
invalids?: string[];
|
|
structure?: DatasourceStructure;
|
|
messages?: string[];
|
|
success?: boolean;
|
|
isMock?: boolean;
|
|
}
|
|
|
|
export interface TokenResponse {
|
|
datasource: Datasource;
|
|
token: string;
|
|
projectID: string;
|
|
}
|
|
|
|
export interface MockDatasource {
|
|
name: string;
|
|
description: string;
|
|
packageName: string;
|
|
pluginType: string;
|
|
pluginName?: string;
|
|
}
|
|
|
|
export const DEFAULT_DATASOURCE = (
|
|
pluginId: string,
|
|
workspaceId: string,
|
|
): EmbeddedRestDatasource => ({
|
|
name: "DEFAULT_REST_DATASOURCE",
|
|
datasourceConfiguration: {
|
|
url: "",
|
|
},
|
|
invalids: [],
|
|
isValid: true,
|
|
pluginId,
|
|
workspaceId,
|
|
messages: [],
|
|
});
|