2025-03-31 10:13:18 +00:00
|
|
|
import omit from "lodash/omit";
|
|
|
|
|
import merge from "lodash/merge";
|
2024-08-06 14:52:22 +00:00
|
|
|
import type { CreateNewActionKeyInterface } from "ee/entities/Engine/actionHelpers";
|
|
|
|
|
import { CreateNewActionKey } from "ee/entities/Engine/actionHelpers";
|
2024-04-11 06:06:48 +00:00
|
|
|
import type { DeleteErrorLogPayload } from "actions/debuggerActions";
|
2024-01-17 10:04:50 +00:00
|
|
|
import type { Action } from "entities/Action";
|
2024-04-11 06:06:48 +00:00
|
|
|
import type { Log } from "entities/AppsmithConsole";
|
2024-07-23 07:49:29 +00:00
|
|
|
import type { EvaluationError } from "utils/DynamicBindingUtils";
|
2025-03-31 10:13:18 +00:00
|
|
|
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
|
|
|
|
|
import type { getConfigInitialValues } from "components/formControls/utils";
|
|
|
|
|
import type { CreateDatasourceConfig } from "ee/api/DatasourcesApi";
|
|
|
|
|
import type { Datasource } from "entities/Datasource";
|
2024-01-17 10:04:50 +00:00
|
|
|
|
|
|
|
|
export interface ResolveParentEntityMetadataReturnType {
|
|
|
|
|
parentEntityId?: string;
|
|
|
|
|
parentEntityKey?: CreateNewActionKeyInterface;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-24 08:31:00 +00:00
|
|
|
// This function is extended in EE. Please check the EE implementation before any modification.
|
|
|
|
|
export interface GenerateDestinationIdInfoReturnType {
|
|
|
|
|
pageId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This function is extended in EE. Please check the EE implementation before any modification.
|
|
|
|
|
export function generateDestinationIdInfoForQueryDuplication(
|
|
|
|
|
destinationEntityId: string,
|
|
|
|
|
parentEntityKey: CreateNewActionKeyInterface,
|
|
|
|
|
): GenerateDestinationIdInfoReturnType {
|
|
|
|
|
if (parentEntityKey === CreateNewActionKey.PAGE) {
|
|
|
|
|
return { pageId: destinationEntityId };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-17 10:04:50 +00:00
|
|
|
// This function is extended in EE. Please check the EE implementation before any modification.
|
|
|
|
|
export const resolveParentEntityMetadata = (
|
|
|
|
|
action: Partial<Action>,
|
|
|
|
|
): ResolveParentEntityMetadataReturnType => {
|
|
|
|
|
if (action.pageId) {
|
|
|
|
|
return {
|
|
|
|
|
parentEntityId: action.pageId,
|
|
|
|
|
parentEntityKey: CreateNewActionKey.PAGE,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { parentEntityId: undefined, parentEntityKey: undefined };
|
|
|
|
|
};
|
2024-04-11 06:06:48 +00:00
|
|
|
|
|
|
|
|
export function* transformAddErrorLogsSaga(logs: Log[]) {
|
|
|
|
|
return logs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* transformDeleteErrorLogsSaga(payload: DeleteErrorLogPayload) {
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
2024-07-23 07:49:29 +00:00
|
|
|
|
|
|
|
|
export function* transformTriggerEvalErrors(errors: EvaluationError[]) {
|
|
|
|
|
return errors;
|
|
|
|
|
}
|
2025-03-31 10:13:18 +00:00
|
|
|
|
|
|
|
|
interface CreateDatasourcePayloadFromActionParams {
|
|
|
|
|
currentEnvId: string;
|
|
|
|
|
actionPayload: Datasource | CreateDatasourceConfig;
|
|
|
|
|
initialValues: ReturnType<typeof getConfigInitialValues>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createDatasourceAPIPayloadFromAction = (
|
|
|
|
|
props: CreateDatasourcePayloadFromActionParams,
|
|
|
|
|
) => {
|
|
|
|
|
const { actionPayload, currentEnvId, initialValues } = props;
|
|
|
|
|
|
|
|
|
|
let datasourceStoragePayload = actionPayload.datasourceStorages[currentEnvId];
|
|
|
|
|
|
|
|
|
|
datasourceStoragePayload = merge(initialValues, datasourceStoragePayload);
|
|
|
|
|
|
|
|
|
|
// in the datasourcestorages, we only need one key, the currentEnvironment
|
|
|
|
|
// we need to remove any other keys present
|
|
|
|
|
const datasourceStorages = {
|
|
|
|
|
[currentEnvId]: datasourceStoragePayload,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const payload = omit(
|
|
|
|
|
{
|
|
|
|
|
...actionPayload,
|
|
|
|
|
datasourceStorages,
|
|
|
|
|
},
|
|
|
|
|
["id", "new", "type", "datasourceConfiguration"],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (payload.datasourceStorages) datasourceStoragePayload.isConfigured = true;
|
|
|
|
|
|
|
|
|
|
// remove datasourceId from payload if it is equal to TEMP_DATASOURCE_ID
|
|
|
|
|
if (datasourceStoragePayload.datasourceId === TEMP_DATASOURCE_ID)
|
|
|
|
|
datasourceStoragePayload.datasourceId = "";
|
|
|
|
|
|
|
|
|
|
return payload;
|
|
|
|
|
};
|