> Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description There are multiple refactors and split for query module's creator flow changes which involves module input -- it's a new entity introduced as part of modules project #### PR fixes following issue(s) Fixes # (issue number) Part of https://app.zenhub.com/workspaces/modules-pod-63e0d668a7fea03850c89c6f/issues/gh/appsmithorg/appsmith/27352 #### 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
87 lines
2.5 KiB
TypeScript
87 lines
2.5 KiB
TypeScript
import type { DependencyMap, DynamicPath } from "utils/DynamicBindingUtils";
|
|
import { ENTITY_TYPE_VALUE } from "entities/DataTree/dataTreeFactory";
|
|
import type { ActionData } from "@appsmith/reducers/entityReducers/actionsReducer";
|
|
import {
|
|
getBindingAndReactivePathsOfAction,
|
|
getDataTreeActionConfigPath,
|
|
} from "entities/Action/actionProperties";
|
|
import type {
|
|
ActionEntity,
|
|
ActionEntityConfig,
|
|
} from "@appsmith/entities/DataTree/types";
|
|
|
|
export const generateDataTreeAction = (
|
|
action: ActionData,
|
|
editorConfig: any[],
|
|
dependencyConfig: DependencyMap = {},
|
|
): {
|
|
unEvalEntity: ActionEntity;
|
|
configEntity: ActionEntityConfig;
|
|
} => {
|
|
let dynamicBindingPathList: DynamicPath[] = [];
|
|
let datasourceUrl = "";
|
|
|
|
// update paths
|
|
if (
|
|
action.config.dynamicBindingPathList &&
|
|
action.config.dynamicBindingPathList.length
|
|
) {
|
|
dynamicBindingPathList = action.config.dynamicBindingPathList.map((d) => ({
|
|
...d,
|
|
key: d.key === "datasourceUrl" ? d.key : `config.${d.key}`,
|
|
}));
|
|
}
|
|
|
|
if (
|
|
action.config.datasource &&
|
|
"datasourceConfiguration" in action.config.datasource
|
|
) {
|
|
datasourceUrl = action.config.datasource.datasourceConfiguration?.url ?? "";
|
|
}
|
|
|
|
const dependencyMap: DependencyMap = {};
|
|
Object.entries(dependencyConfig).forEach(([dependent, dependencies]) => {
|
|
dependencyMap[getDataTreeActionConfigPath(dependent)] = dependencies.map(
|
|
getDataTreeActionConfigPath,
|
|
);
|
|
});
|
|
|
|
const { bindingPaths, reactivePaths } = getBindingAndReactivePathsOfAction(
|
|
action.config,
|
|
editorConfig,
|
|
dynamicBindingPathList,
|
|
);
|
|
|
|
return {
|
|
unEvalEntity: {
|
|
actionId: action.config.id,
|
|
run: {},
|
|
clear: {},
|
|
// Data is always set to undefined in the unevalTree
|
|
// Action data is updated directly to the dataTree (see updateActionData.ts)
|
|
data: undefined,
|
|
isLoading: action.isLoading,
|
|
responseMeta: {
|
|
statusCode: action.data?.statusCode,
|
|
isExecutionSuccess: action.data?.isExecutionSuccess || false,
|
|
headers: action.data?.headers,
|
|
},
|
|
config: action.config.actionConfiguration,
|
|
ENTITY_TYPE: ENTITY_TYPE_VALUE.ACTION,
|
|
datasourceUrl,
|
|
},
|
|
configEntity: {
|
|
actionId: action.config.id,
|
|
name: action.config.name,
|
|
pluginId: action.config.pluginId,
|
|
pluginType: action.config.pluginType,
|
|
dynamicBindingPathList,
|
|
ENTITY_TYPE: ENTITY_TYPE_VALUE.ACTION,
|
|
bindingPaths,
|
|
reactivePaths,
|
|
dependencyMap,
|
|
logBlackList: {},
|
|
},
|
|
};
|
|
};
|