chore: CE changes for linting (#28542)
## Description #### PR fixes following issue(s) Fixes # (issue number) #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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 - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] 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
This commit is contained in:
parent
284e658854
commit
30163933a9
78
app/client/src/ce/plugins/Linting/lib/entity/index.ts
Normal file
78
app/client/src/ce/plugins/Linting/lib/entity/index.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
import type {
|
||||||
|
WidgetEntity as TWidgetEntity,
|
||||||
|
AppsmithEntity as TAppsmithEntity,
|
||||||
|
DataTreeEntityConfig,
|
||||||
|
WidgetEntityConfig as TWidgetEntityConfig,
|
||||||
|
JSActionEntity as TJSActionEntity,
|
||||||
|
ActionEntity as TActionEntity,
|
||||||
|
ActionEntityConfig as TActionEntityConfig,
|
||||||
|
JSActionEntityConfig as TJSActionEntityConfig,
|
||||||
|
} from "@appsmith/entities/DataTree/types";
|
||||||
|
import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes";
|
||||||
|
import type { EntityClassLoader } from "plugins/Linting/lib/entity/EntityTree";
|
||||||
|
import {
|
||||||
|
ENTITY_TYPE,
|
||||||
|
type IEntity,
|
||||||
|
} from "@appsmith/plugins/Linting/lib/entity/types";
|
||||||
|
import { JSEntity } from "plugins/Linting/lib/entity/JSActionEntity";
|
||||||
|
import { ActionEntity } from "plugins/Linting/lib/entity/ActionEntity";
|
||||||
|
import { AppsmithEntity } from "plugins/Linting/lib/entity/AppsmithEntity";
|
||||||
|
import { WidgetEntity } from "plugins/Linting/lib/entity/WidgetEntity";
|
||||||
|
import {
|
||||||
|
isAction,
|
||||||
|
isJSAction,
|
||||||
|
isWidget,
|
||||||
|
} from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||||
|
|
||||||
|
export default class EntityFactory {
|
||||||
|
static getEntity<
|
||||||
|
T extends DataTreeEntity,
|
||||||
|
K extends DataTreeEntityConfig | undefined,
|
||||||
|
>(entity: T, config: K, classLoader: EntityClassLoader): IEntity {
|
||||||
|
const { DiffGenerator, Parser } = classLoader.load(
|
||||||
|
entity as DataTreeEntity,
|
||||||
|
);
|
||||||
|
if (isWidget(entity)) {
|
||||||
|
return new WidgetEntity(
|
||||||
|
entity as TWidgetEntity,
|
||||||
|
config as TWidgetEntityConfig,
|
||||||
|
new Parser(),
|
||||||
|
new DiffGenerator(),
|
||||||
|
);
|
||||||
|
} else if (isJSAction(entity)) {
|
||||||
|
return new JSEntity(
|
||||||
|
entity as TJSActionEntity,
|
||||||
|
config as TJSActionEntityConfig,
|
||||||
|
new Parser(),
|
||||||
|
new DiffGenerator(),
|
||||||
|
);
|
||||||
|
} else if (isAction(entity)) {
|
||||||
|
return new ActionEntity(
|
||||||
|
entity as TActionEntity,
|
||||||
|
config as TActionEntityConfig,
|
||||||
|
new Parser(),
|
||||||
|
new DiffGenerator(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new AppsmithEntity(
|
||||||
|
entity as TAppsmithEntity,
|
||||||
|
undefined,
|
||||||
|
new Parser(),
|
||||||
|
new DiffGenerator(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isJSEntity(entity: IEntity): entity is JSEntity {
|
||||||
|
return entity.getType() === ENTITY_TYPE.JSACTION;
|
||||||
|
}
|
||||||
|
export function isActionEntity(entity: IEntity): entity is ActionEntity {
|
||||||
|
return entity.getType() === ENTITY_TYPE.ACTION;
|
||||||
|
}
|
||||||
|
export function isAppsmithEntity(entity: IEntity): entity is AppsmithEntity {
|
||||||
|
return entity.getType() === ENTITY_TYPE.APPSMITH;
|
||||||
|
}
|
||||||
|
export function isWidgetEntity(entity: IEntity): entity is WidgetEntity {
|
||||||
|
return entity.getType() === ENTITY_TYPE.WIDGET;
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
import type { Diff } from "deep-diff";
|
import type { Diff } from "deep-diff";
|
||||||
|
|
||||||
export enum ENTITY_TYPE {
|
export const ENTITY_TYPE = {
|
||||||
ACTION = "ACTION",
|
ACTION: "ACTION",
|
||||||
WIDGET = "WIDGET",
|
WIDGET: "WIDGET",
|
||||||
APPSMITH = "APPSMITH",
|
APPSMITH: "APPSMITH",
|
||||||
JSACTION = "JSACTION",
|
JSACTION: "JSACTION",
|
||||||
}
|
};
|
||||||
|
|
||||||
|
type ValueOf<T> = T[keyof T];
|
||||||
|
export type EntityTypeValue = ValueOf<typeof ENTITY_TYPE>;
|
||||||
|
|
||||||
export interface IEntity {
|
export interface IEntity {
|
||||||
getName(): string;
|
getName(): string;
|
||||||
getId(): string;
|
getId(): string;
|
||||||
getType(): ENTITY_TYPE;
|
getType(): EntityTypeValue;
|
||||||
getRawEntity(): unknown;
|
getRawEntity(): unknown;
|
||||||
getConfig(): unknown;
|
getConfig(): unknown;
|
||||||
computeDifference(entity?: IEntity): Diff<unknown>[] | undefined;
|
computeDifference(entity?: IEntity): Diff<unknown>[] | undefined;
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import type { DependencyMap as TDependencyMap } from "utils/DynamicBindingUtils"
|
||||||
import { getPropertyPath } from "utils/DynamicBindingUtils";
|
import { getPropertyPath } from "utils/DynamicBindingUtils";
|
||||||
import { getDynamicBindings } from "utils/DynamicBindingUtils";
|
import { getDynamicBindings } from "utils/DynamicBindingUtils";
|
||||||
import { getEntityDynamicBindingPathList } from "utils/DynamicBindingUtils";
|
import { getEntityDynamicBindingPathList } from "utils/DynamicBindingUtils";
|
||||||
import { mergeMaps } from "./mergeMaps";
|
import { mergeMaps } from "plugins/Linting/utils/mergeMaps";
|
||||||
import { flatten, get, has, isString, toPath, union, uniq } from "lodash";
|
import { flatten, get, has, isString, toPath, union, uniq } from "lodash";
|
||||||
import { extractIdentifierInfoFromCode } from "@shared/ast";
|
import { extractIdentifierInfoFromCode } from "@shared/ast";
|
||||||
import { PathUtils } from "./pathUtils";
|
import { PathUtils } from "plugins/Linting/utils/pathUtils";
|
||||||
|
|
||||||
import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes";
|
import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes";
|
||||||
import type { ActionEntity } from "plugins/Linting/lib/entity/ActionEntity";
|
import type { ActionEntity } from "plugins/Linting/lib/entity/ActionEntity";
|
||||||
|
|
@ -99,7 +99,7 @@ function getActionDependencies(actionEntity: ActionEntity): TDependencyMap {
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDependencyFromEntityPath(
|
export function getDependencyFromEntityPath(
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
entity: IEntity,
|
entity: IEntity,
|
||||||
): TDependencyMap {
|
): TDependencyMap {
|
||||||
3
app/client/src/ee/plugins/Linting/lib/entity/index.ts
Normal file
3
app/client/src/ee/plugins/Linting/lib/entity/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export * from "ce/plugins/Linting/lib/entity/index";
|
||||||
|
import EntityFactory from "ce/plugins/Linting/lib/entity";
|
||||||
|
export default EntityFactory;
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "ce/plugins/Linting/utils/getEntityDependencies";
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from "@appsmith/workers/Evaluation/evaluationUtils";
|
} from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||||
import { AppsmithFunctionsWithFields } from "components/editorComponents/ActionCreator/constants";
|
import { AppsmithFunctionsWithFields } from "components/editorComponents/ActionCreator/constants";
|
||||||
import { PathUtils } from "plugins/Linting/utils/pathUtils";
|
import { PathUtils } from "plugins/Linting/utils/pathUtils";
|
||||||
import { extractReferencesFromPath } from "plugins/Linting/utils/getEntityDependencies";
|
import { extractReferencesFromPath } from "@appsmith/plugins/Linting/utils/getEntityDependencies";
|
||||||
import { groupDifferencesByType } from "plugins/Linting/utils/groupDifferencesByType";
|
import { groupDifferencesByType } from "plugins/Linting/utils/groupDifferencesByType";
|
||||||
import type {
|
import type {
|
||||||
LintTreeRequestPayload,
|
LintTreeRequestPayload,
|
||||||
|
|
@ -17,7 +17,7 @@ import type {
|
||||||
TJSPropertiesState,
|
TJSPropertiesState,
|
||||||
TJSpropertyState,
|
TJSpropertyState,
|
||||||
} from "workers/Evaluation/JSObject/jsPropertiesState";
|
} from "workers/Evaluation/JSObject/jsPropertiesState";
|
||||||
import { isJSEntity } from "plugins/Linting/lib/entity";
|
import { isJSEntity } from "@appsmith/plugins/Linting/lib/entity";
|
||||||
import DependencyMap from "entities/DependencyMap";
|
import DependencyMap from "entities/DependencyMap";
|
||||||
import {
|
import {
|
||||||
LintEntityTree,
|
LintEntityTree,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
} from "entities/DataTree/dataTreeTypes";
|
} from "entities/DataTree/dataTreeTypes";
|
||||||
import type { IEntity } from "@appsmith/plugins/Linting/lib/entity/types";
|
import type { IEntity } from "@appsmith/plugins/Linting/lib/entity/types";
|
||||||
import type { Diff } from "deep-diff";
|
import type { Diff } from "deep-diff";
|
||||||
import EntityFactory from ".";
|
import EntityFactory from "@appsmith/plugins/Linting/lib/entity";
|
||||||
import { PathUtils } from "plugins/Linting/utils/pathUtils";
|
import { PathUtils } from "plugins/Linting/utils/pathUtils";
|
||||||
import { isJSAction } from "@appsmith/workers/Evaluation/evaluationUtils";
|
import { isJSAction } from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||||
import type { EntityParser } from "plugins/Linting/utils/entityParser";
|
import type { EntityParser } from "plugins/Linting/utils/entityParser";
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export class WidgetEntity implements IEntity {
|
||||||
this.entityParser = entityParser;
|
this.entityParser = entityParser;
|
||||||
this.diffGenerator = diffGenerator;
|
this.diffGenerator = diffGenerator;
|
||||||
}
|
}
|
||||||
getType(): ENTITY_TYPE {
|
getType() {
|
||||||
return ENTITY_TYPE.WIDGET;
|
return ENTITY_TYPE.WIDGET;
|
||||||
}
|
}
|
||||||
getRawEntity() {
|
getRawEntity() {
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
import type { DataTreeEntityConfig } from "@appsmith/entities/DataTree/types";
|
|
||||||
import type { DataTreeEntity } from "entities/DataTree/dataTreeTypes";
|
|
||||||
import type { EntityClassLoader } from "./EntityTree";
|
|
||||||
import {
|
|
||||||
ENTITY_TYPE,
|
|
||||||
type IEntity,
|
|
||||||
} from "@appsmith/plugins/Linting/lib/entity/types";
|
|
||||||
import { entityConstructorMap } from "@appsmith/plugins/Linting/lib/entity/entityConstructorMap";
|
|
||||||
import type { JSEntity } from "./JSActionEntity";
|
|
||||||
import type { ActionEntity } from "./ActionEntity";
|
|
||||||
import type { AppsmithEntity } from "./AppsmithEntity";
|
|
||||||
import type { WidgetEntity } from "./WidgetEntity";
|
|
||||||
|
|
||||||
export default class EntityFactory {
|
|
||||||
static getEntity<
|
|
||||||
T extends DataTreeEntity,
|
|
||||||
K extends DataTreeEntityConfig | undefined,
|
|
||||||
>(entity: T, config: K, classLoader: EntityClassLoader): IEntity {
|
|
||||||
const { DiffGenerator, Parser } = classLoader.load(
|
|
||||||
entity as DataTreeEntity,
|
|
||||||
);
|
|
||||||
return entityConstructorMap[entity.ENTITY_TYPE]({
|
|
||||||
entity,
|
|
||||||
config,
|
|
||||||
Parser,
|
|
||||||
DiffGenerator,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isJSEntity(entity: IEntity): entity is JSEntity {
|
|
||||||
return entity.getType() === ENTITY_TYPE.JSACTION;
|
|
||||||
}
|
|
||||||
export function isActionEntity(entity: IEntity): entity is ActionEntity {
|
|
||||||
return entity.getType() === ENTITY_TYPE.ACTION;
|
|
||||||
}
|
|
||||||
export function isAppsmithEntity(entity: IEntity): entity is AppsmithEntity {
|
|
||||||
return entity.getType() === ENTITY_TYPE.APPSMITH;
|
|
||||||
}
|
|
||||||
export function isWidgetEntity(entity: IEntity): entity is WidgetEntity {
|
|
||||||
return entity.getType() === ENTITY_TYPE.WIDGET;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { isWidgetEntity } from "plugins/Linting/lib/entity";
|
import { isWidgetEntity } from "@appsmith/plugins/Linting/lib/entity";
|
||||||
import {
|
import {
|
||||||
convertPathToString,
|
convertPathToString,
|
||||||
getEntityNameAndPropertyPath,
|
getEntityNameAndPropertyPath,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user