2021-01-04 10:16:08 +00:00
|
|
|
import {
|
|
|
|
|
actionChannel,
|
2022-06-21 13:57:34 +00:00
|
|
|
ActionPattern,
|
2021-12-23 14:17:20 +00:00
|
|
|
all,
|
2021-01-04 10:16:08 +00:00
|
|
|
call,
|
2022-01-28 11:10:05 +00:00
|
|
|
delay,
|
2021-01-04 10:16:08 +00:00
|
|
|
fork,
|
|
|
|
|
put,
|
|
|
|
|
select,
|
2021-12-23 14:17:20 +00:00
|
|
|
spawn,
|
2021-01-04 10:16:08 +00:00
|
|
|
take,
|
|
|
|
|
} from "redux-saga/effects";
|
2020-12-28 08:42:43 +00:00
|
|
|
|
2020-10-21 04:25:32 +00:00
|
|
|
import {
|
2020-11-03 10:16:11 +00:00
|
|
|
EvaluationReduxAction,
|
2022-02-17 04:31:59 +00:00
|
|
|
AnyReduxAction,
|
2020-10-21 04:25:32 +00:00
|
|
|
ReduxAction,
|
2021-11-10 07:11:23 +00:00
|
|
|
ReduxActionType,
|
2020-10-21 04:25:32 +00:00
|
|
|
ReduxActionTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2021-07-20 05:04:12 +00:00
|
|
|
import {
|
|
|
|
|
getDataTree,
|
|
|
|
|
getUnevaluatedDataTree,
|
|
|
|
|
} from "selectors/dataTreeSelectors";
|
2021-09-21 07:55:56 +00:00
|
|
|
import { getWidgets } from "sagas/selectors";
|
2022-04-12 10:50:01 +00:00
|
|
|
import WidgetFactory, { WidgetTypeConfigMap } from "utils/WidgetFactory";
|
2021-02-22 05:00:16 +00:00
|
|
|
import { GracefulWorkerService } from "utils/WorkerUtil";
|
2020-10-21 04:25:32 +00:00
|
|
|
import Worker from "worker-loader!../workers/evaluation.worker";
|
2021-08-29 03:50:16 +00:00
|
|
|
import {
|
2022-06-21 13:57:34 +00:00
|
|
|
EvalError,
|
2021-08-29 03:50:16 +00:00
|
|
|
EVAL_WORKER_ACTIONS,
|
|
|
|
|
PropertyEvaluationErrorType,
|
|
|
|
|
} from "utils/DynamicBindingUtils";
|
2020-10-21 04:25:32 +00:00
|
|
|
import log from "loglevel";
|
2021-02-22 05:00:16 +00:00
|
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
2020-11-03 10:16:11 +00:00
|
|
|
import PerformanceTracker, {
|
|
|
|
|
PerformanceTransactionName,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "utils/PerformanceTracker";
|
2020-11-11 11:32:14 +00:00
|
|
|
import * as Sentry from "@sentry/react";
|
2020-12-30 13:26:44 +00:00
|
|
|
import { Action } from "redux";
|
2021-06-04 07:09:36 +00:00
|
|
|
import {
|
2021-07-20 10:02:56 +00:00
|
|
|
EVALUATE_REDUX_ACTIONS,
|
|
|
|
|
FIRST_EVAL_REDUX_ACTIONS,
|
|
|
|
|
setDependencyMap,
|
|
|
|
|
setEvaluatedTree,
|
|
|
|
|
shouldProcessBatchedAction,
|
|
|
|
|
} from "actions/evaluationActions";
|
2021-03-13 14:24:45 +00:00
|
|
|
import {
|
2021-07-20 10:02:56 +00:00
|
|
|
evalErrorHandler,
|
2022-06-30 07:21:20 +00:00
|
|
|
handleJSFunctionExecutionErrorLog,
|
2021-07-20 10:02:56 +00:00
|
|
|
logSuccessfulBindings,
|
|
|
|
|
postEvalActionDispatcher,
|
|
|
|
|
updateTernDefinitions,
|
|
|
|
|
} from "./PostEvaluationSagas";
|
2021-11-08 06:49:22 +00:00
|
|
|
import { JSAction } from "entities/JSCollection";
|
2021-07-30 10:24:22 +00:00
|
|
|
import { getAppMode } from "selectors/applicationSelectors";
|
2021-08-06 09:17:56 +00:00
|
|
|
import { APP_MODE } from "entities/App";
|
2021-09-24 13:49:59 +00:00
|
|
|
import { get, isUndefined } from "lodash";
|
2021-08-29 03:50:16 +00:00
|
|
|
import {
|
|
|
|
|
setEvaluatedArgument,
|
|
|
|
|
setEvaluatedSnippet,
|
|
|
|
|
setGlobalSearchFilterContext,
|
|
|
|
|
} from "actions/globalSearchActions";
|
2021-12-23 14:17:20 +00:00
|
|
|
import {
|
|
|
|
|
executeActionTriggers,
|
|
|
|
|
TriggerMeta,
|
|
|
|
|
} from "./ActionExecution/ActionExecutionSagas";
|
2021-08-29 03:50:16 +00:00
|
|
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
|
|
|
|
import { Toaster } from "components/ads/Toast";
|
|
|
|
|
import { Variant } from "components/ads/common";
|
|
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
SNIPPET_EXECUTION_FAILED,
|
|
|
|
|
SNIPPET_EXECUTION_SUCCESS,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2021-08-29 03:50:16 +00:00
|
|
|
import { validate } from "workers/validations";
|
2021-08-24 12:10:25 +00:00
|
|
|
import { diff } from "deep-diff";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { REPLAY_DELAY } from "entities/Replay/replayUtils";
|
2021-11-10 07:11:23 +00:00
|
|
|
import { EvaluationVersion } from "api/ApplicationApi";
|
2021-11-08 06:49:22 +00:00
|
|
|
import { makeUpdateJSCollection } from "sagas/JSPaneSagas";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
|
|
|
|
import { Replayable } from "entities/Replay/ReplayEntity/ReplayEditor";
|
2021-12-23 14:17:20 +00:00
|
|
|
import {
|
|
|
|
|
logActionExecutionError,
|
|
|
|
|
UncaughtPromiseError,
|
|
|
|
|
} from "sagas/ActionExecution/errorUtils";
|
|
|
|
|
import { Channel } from "redux-saga";
|
|
|
|
|
import { ActionDescription } from "entities/DataTree/actionTriggers";
|
2022-01-06 10:49:01 +00:00
|
|
|
import { FormEvaluationState } from "reducers/evaluationReducers/formEvaluationReducer";
|
|
|
|
|
import { FormEvalActionPayload } from "./FormEvaluationSaga";
|
2022-05-04 09:45:57 +00:00
|
|
|
import { getSelectedAppTheme } from "selectors/appThemingSelectors";
|
2022-02-17 04:31:59 +00:00
|
|
|
import { updateMetaState } from "actions/metaActions";
|
2022-01-27 09:50:05 +00:00
|
|
|
import { getAllActionValidationConfig } from "selectors/entitiesSelector";
|
2022-05-25 09:46:14 +00:00
|
|
|
import { DataTree } from "entities/DataTree/dataTreeFactory";
|
|
|
|
|
import { EvalMetaUpdates } from "workers/DataTreeEvaluator/types";
|
|
|
|
|
import { JSUpdate } from "utils/JSPaneUtils";
|
|
|
|
|
import { DataTreeDiff } from "workers/evaluationUtils";
|
2022-06-21 13:57:34 +00:00
|
|
|
import { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
|
|
|
|
|
import { AppTheme } from "entities/AppTheming";
|
|
|
|
|
import { ActionValidationConfigMap } from "constants/PropertyControlConstants";
|
2022-09-04 11:58:05 +00:00
|
|
|
import { LogObject, UserLogObject } from "workers/UserLog";
|
2022-09-07 06:23:47 +00:00
|
|
|
import { storeLogs, updateTriggerMeta } from "./DebuggerSagas";
|
2021-11-10 07:11:23 +00:00
|
|
|
|
2020-10-21 04:25:32 +00:00
|
|
|
let widgetTypeConfigMap: WidgetTypeConfigMap;
|
|
|
|
|
|
2020-12-28 08:42:43 +00:00
|
|
|
const worker = new GracefulWorkerService(Worker);
|
2020-10-21 04:25:32 +00:00
|
|
|
|
2022-06-24 11:59:30 +00:00
|
|
|
export type EvalTreePayload = {
|
|
|
|
|
dataTree: DataTree;
|
|
|
|
|
dependencies: Record<string, string[]>;
|
|
|
|
|
errors: EvalError[];
|
|
|
|
|
evalMetaUpdates: EvalMetaUpdates;
|
|
|
|
|
evaluationOrder: string[];
|
|
|
|
|
jsUpdates: Record<string, JSUpdate>;
|
|
|
|
|
logs: any[];
|
2022-09-04 11:58:05 +00:00
|
|
|
userLogs?: UserLogObject[];
|
2022-06-24 11:59:30 +00:00
|
|
|
unEvalUpdates: DataTreeDiff[];
|
|
|
|
|
isCreateFirstTree: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-26 05:41:32 +00:00
|
|
|
function* evaluateTreeSaga(
|
2022-02-17 04:31:59 +00:00
|
|
|
postEvalActions?: Array<AnyReduxAction>,
|
2021-09-21 07:55:56 +00:00
|
|
|
shouldReplay?: boolean,
|
2021-04-26 05:41:32 +00:00
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const allActionValidationConfig: {
|
|
|
|
|
[actionId: string]: ActionValidationConfigMap;
|
|
|
|
|
} = yield select(getAllActionValidationConfig);
|
|
|
|
|
const unevalTree: DataTree = yield select(getUnevaluatedDataTree);
|
|
|
|
|
const widgets: CanvasWidgetsReduxState = yield select(getWidgets);
|
|
|
|
|
const theme: AppTheme = yield select(getSelectedAppTheme);
|
2022-01-27 09:50:05 +00:00
|
|
|
|
2021-03-31 07:40:59 +00:00
|
|
|
log.debug({ unevalTree });
|
2020-11-03 10:16:11 +00:00
|
|
|
PerformanceTracker.startAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.DATA_TREE_EVALUATION,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
|
|
|
|
|
// @ts-expect-error: Worker Response is unknown
|
2020-12-28 08:42:43 +00:00
|
|
|
const workerResponse = yield call(
|
|
|
|
|
worker.request,
|
|
|
|
|
EVAL_WORKER_ACTIONS.EVAL_TREE,
|
|
|
|
|
{
|
2021-01-04 10:16:08 +00:00
|
|
|
unevalTree,
|
2020-12-28 08:42:43 +00:00
|
|
|
widgetTypeConfigMap,
|
2021-09-21 07:55:56 +00:00
|
|
|
widgets,
|
2022-05-04 09:45:57 +00:00
|
|
|
theme,
|
2021-09-21 07:55:56 +00:00
|
|
|
shouldReplay,
|
2022-01-27 09:50:05 +00:00
|
|
|
allActionValidationConfig,
|
2020-12-28 08:42:43 +00:00
|
|
|
},
|
|
|
|
|
);
|
2022-01-27 09:50:05 +00:00
|
|
|
|
2021-06-04 07:09:36 +00:00
|
|
|
const {
|
|
|
|
|
dataTree,
|
|
|
|
|
dependencies,
|
|
|
|
|
errors,
|
2022-06-07 06:36:27 +00:00
|
|
|
evalMetaUpdates = [],
|
2021-06-04 07:09:36 +00:00
|
|
|
evaluationOrder,
|
2021-11-08 06:49:22 +00:00
|
|
|
jsUpdates,
|
2021-06-04 07:09:36 +00:00
|
|
|
logs,
|
2022-09-04 11:58:05 +00:00
|
|
|
userLogs,
|
2021-08-04 05:34:44 +00:00
|
|
|
unEvalUpdates,
|
2022-06-24 11:59:30 +00:00
|
|
|
isCreateFirstTree = false,
|
|
|
|
|
}: EvalTreePayload = workerResponse;
|
2021-03-31 07:40:59 +00:00
|
|
|
PerformanceTracker.stopAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.DATA_TREE_EVALUATION,
|
|
|
|
|
);
|
|
|
|
|
PerformanceTracker.startAsyncTracking(
|
|
|
|
|
PerformanceTransactionName.SET_EVALUATED_TREE,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
const oldDataTree: DataTree = yield select(getDataTree);
|
2021-08-24 12:10:25 +00:00
|
|
|
|
|
|
|
|
const updates = diff(oldDataTree, dataTree) || [];
|
|
|
|
|
|
2022-05-25 09:46:14 +00:00
|
|
|
yield put(setEvaluatedTree(updates));
|
2021-04-23 11:34:33 +00:00
|
|
|
PerformanceTracker.stopAsyncTracking(
|
2021-03-31 07:40:59 +00:00
|
|
|
PerformanceTransactionName.SET_EVALUATED_TREE,
|
|
|
|
|
);
|
2022-05-25 09:46:14 +00:00
|
|
|
// if evalMetaUpdates are present only then dispatch updateMetaState
|
|
|
|
|
if (evalMetaUpdates.length) {
|
|
|
|
|
yield put(updateMetaState(evalMetaUpdates));
|
|
|
|
|
}
|
2022-06-25 05:30:54 +00:00
|
|
|
log.debug({ evalMetaUpdatesLength: evalMetaUpdates.length });
|
2021-07-20 05:04:12 +00:00
|
|
|
|
2022-05-25 09:46:14 +00:00
|
|
|
const updatedDataTree: DataTree = yield select(getDataTree);
|
2022-09-07 06:23:47 +00:00
|
|
|
if (
|
|
|
|
|
!(!isCreateFirstTree && Object.keys(jsUpdates).length > 0) &&
|
|
|
|
|
!!userLogs &&
|
|
|
|
|
userLogs.length > 0
|
|
|
|
|
) {
|
2022-09-04 11:58:05 +00:00
|
|
|
yield all(
|
|
|
|
|
userLogs.map((log: UserLogObject) => {
|
2022-09-07 06:23:47 +00:00
|
|
|
return call(
|
2022-09-04 11:58:05 +00:00
|
|
|
storeLogs,
|
|
|
|
|
log.logObject,
|
|
|
|
|
log.source.name,
|
|
|
|
|
log.source.type,
|
|
|
|
|
log.source.id,
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-11-08 06:49:22 +00:00
|
|
|
log.debug({ jsUpdates: jsUpdates });
|
2021-07-20 05:04:12 +00:00
|
|
|
log.debug({ dataTree: updatedDataTree });
|
2021-12-03 06:48:37 +00:00
|
|
|
logs?.forEach((evalLog: any) => log.debug(evalLog));
|
2022-05-25 09:46:14 +00:00
|
|
|
// Added type as any due to https://github.com/redux-saga/redux-saga/issues/1482
|
|
|
|
|
yield call(evalErrorHandler as any, errors, updatedDataTree, evaluationOrder);
|
|
|
|
|
|
2022-06-21 13:57:34 +00:00
|
|
|
const appMode: APP_MODE | undefined = yield select(getAppMode);
|
2021-07-30 10:24:22 +00:00
|
|
|
if (appMode !== APP_MODE.PUBLISHED) {
|
2021-11-08 06:49:22 +00:00
|
|
|
yield call(makeUpdateJSCollection, jsUpdates);
|
2021-07-30 10:24:22 +00:00
|
|
|
yield fork(
|
|
|
|
|
logSuccessfulBindings,
|
|
|
|
|
unevalTree,
|
|
|
|
|
updatedDataTree,
|
|
|
|
|
evaluationOrder,
|
2022-06-24 11:59:30 +00:00
|
|
|
isCreateFirstTree,
|
2021-07-30 10:24:22 +00:00
|
|
|
);
|
|
|
|
|
|
2021-08-04 05:34:44 +00:00
|
|
|
yield fork(updateTernDefinitions, updatedDataTree, unEvalUpdates);
|
2021-07-30 10:24:22 +00:00
|
|
|
}
|
2021-07-20 05:04:12 +00:00
|
|
|
|
2021-07-20 10:02:56 +00:00
|
|
|
yield put(setDependencyMap(dependencies));
|
2020-11-03 10:16:11 +00:00
|
|
|
if (postEvalActions && postEvalActions.length) {
|
|
|
|
|
yield call(postEvalActionDispatcher, postEvalActions);
|
|
|
|
|
}
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-14 14:37:21 +00:00
|
|
|
export function* evaluateActionBindings(
|
|
|
|
|
bindings: string[],
|
|
|
|
|
executionParams: Record<string, any> | string = {},
|
2020-12-14 18:48:13 +00:00
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const workerResponse: { errors: EvalError[]; values: unknown } = yield call(
|
2020-12-28 08:42:43 +00:00
|
|
|
worker.request,
|
2021-01-14 14:37:21 +00:00
|
|
|
EVAL_WORKER_ACTIONS.EVAL_ACTION_BINDINGS,
|
2020-12-28 08:42:43 +00:00
|
|
|
{
|
2021-01-14 14:37:21 +00:00
|
|
|
bindings,
|
|
|
|
|
executionParams,
|
2020-12-28 08:42:43 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2021-01-14 14:37:21 +00:00
|
|
|
const { errors, values } = workerResponse;
|
2020-12-28 08:42:43 +00:00
|
|
|
|
2021-06-04 07:09:36 +00:00
|
|
|
yield call(evalErrorHandler, errors);
|
2021-01-14 14:37:21 +00:00
|
|
|
return values;
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
/*
|
|
|
|
|
* Used to evaluate and execute dynamic trigger end to end
|
|
|
|
|
* Widget action fields and JS Object run triggers this flow
|
|
|
|
|
*
|
|
|
|
|
* We start a duplex request with the worker and wait till the time we get a 'finished' event from the
|
|
|
|
|
* worker. Worker will evaluate a block of code and ask the main thread to execute it. The result of this
|
|
|
|
|
* execution is returned to the worker where it can resolve/reject the current promise.
|
|
|
|
|
*/
|
2022-09-30 01:31:05 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
export function* evaluateAndExecuteDynamicTrigger(
|
2020-10-21 04:25:32 +00:00
|
|
|
dynamicTrigger: string,
|
2021-12-23 14:17:20 +00:00
|
|
|
eventType: EventType,
|
|
|
|
|
triggerMeta: TriggerMeta,
|
2020-11-20 09:30:50 +00:00
|
|
|
callbackData?: Array<any>,
|
2022-03-02 06:37:20 +00:00
|
|
|
globalContext?: Record<string, unknown>,
|
2020-10-21 04:25:32 +00:00
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const unEvalTree: DataTree = yield select(getUnevaluatedDataTree);
|
2021-12-23 14:17:20 +00:00
|
|
|
log.debug({ execute: dynamicTrigger });
|
2022-09-30 01:31:05 +00:00
|
|
|
const { isFinishedChannel } = yield call(
|
2021-12-23 14:17:20 +00:00
|
|
|
worker.duplexRequest,
|
2020-12-28 08:42:43 +00:00
|
|
|
EVAL_WORKER_ACTIONS.EVAL_TRIGGER,
|
2022-09-30 01:31:05 +00:00
|
|
|
{
|
|
|
|
|
dataTree: unEvalTree,
|
|
|
|
|
dynamicTrigger,
|
|
|
|
|
callbackData,
|
|
|
|
|
globalContext,
|
|
|
|
|
},
|
2020-12-28 08:42:43 +00:00
|
|
|
);
|
2022-09-30 01:31:05 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
let keepAlive = true;
|
2020-12-28 08:42:43 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
while (keepAlive) {
|
2022-09-30 01:31:05 +00:00
|
|
|
const { requestData } = yield take(isFinishedChannel);
|
2022-09-04 11:58:05 +00:00
|
|
|
log.debug({ requestData, eventType, triggerMeta, dynamicTrigger });
|
2022-09-30 01:31:05 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
if (requestData.finished) {
|
|
|
|
|
keepAlive = false;
|
2022-09-04 11:58:05 +00:00
|
|
|
|
|
|
|
|
const { result } = requestData;
|
2022-09-07 06:23:47 +00:00
|
|
|
yield call(updateTriggerMeta, triggerMeta, dynamicTrigger);
|
2022-09-04 11:58:05 +00:00
|
|
|
|
|
|
|
|
// Check for any logs in the response and store them in the redux store
|
|
|
|
|
if (
|
|
|
|
|
!!result &&
|
|
|
|
|
result.hasOwnProperty("logs") &&
|
|
|
|
|
!!result.logs &&
|
|
|
|
|
result.logs.length
|
|
|
|
|
) {
|
|
|
|
|
yield call(
|
2022-09-07 06:23:47 +00:00
|
|
|
storeLogs,
|
2022-09-04 11:58:05 +00:00
|
|
|
result.logs,
|
2022-09-07 06:23:47 +00:00
|
|
|
triggerMeta.source?.name || triggerMeta.triggerPropertyName || "",
|
|
|
|
|
eventType === EventType.ON_JS_FUNCTION_EXECUTE
|
|
|
|
|
? ENTITY_TYPE.JSACTION
|
|
|
|
|
: ENTITY_TYPE.WIDGET,
|
|
|
|
|
triggerMeta.source?.id || "",
|
2022-09-04 11:58:05 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
/* Handle errors during evaluation
|
|
|
|
|
* A finish event with errors means that the error was not caught by the user code.
|
2022-01-28 11:10:05 +00:00
|
|
|
* We raise an error telling the user that an uncaught error has occurred
|
2021-12-23 14:17:20 +00:00
|
|
|
* */
|
2022-09-04 11:58:05 +00:00
|
|
|
if (
|
|
|
|
|
!!result &&
|
|
|
|
|
result.hasOwnProperty("errors") &&
|
|
|
|
|
!!result.errors &&
|
|
|
|
|
result.errors.length
|
|
|
|
|
) {
|
2022-03-17 12:05:17 +00:00
|
|
|
if (
|
2022-09-04 11:58:05 +00:00
|
|
|
result.errors[0].errorMessage !==
|
2022-03-17 12:05:17 +00:00
|
|
|
"UncaughtPromiseRejection: User cancelled action execution"
|
|
|
|
|
) {
|
2022-09-04 11:58:05 +00:00
|
|
|
throw new UncaughtPromiseError(result.errors[0].errorMessage);
|
2022-03-17 12:05:17 +00:00
|
|
|
}
|
2021-12-23 14:17:20 +00:00
|
|
|
}
|
2022-09-04 11:58:05 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
// It is possible to get a few triggers here if the user
|
|
|
|
|
// still uses the old way of action runs and not promises. For that we
|
|
|
|
|
// need to manually execute these triggers outside the promise flow
|
2022-09-04 11:58:05 +00:00
|
|
|
const { triggers } = result;
|
2021-12-23 14:17:20 +00:00
|
|
|
if (triggers && triggers.length) {
|
|
|
|
|
log.debug({ triggers });
|
|
|
|
|
yield all(
|
|
|
|
|
triggers.map((trigger: ActionDescription) =>
|
|
|
|
|
call(executeActionTriggers, trigger, eventType, triggerMeta),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// Return value of a promise is returned
|
2022-09-30 01:31:05 +00:00
|
|
|
isFinishedChannel.close();
|
2022-09-04 11:58:05 +00:00
|
|
|
return result;
|
2021-12-23 14:17:20 +00:00
|
|
|
}
|
|
|
|
|
yield call(evalErrorHandler, requestData.errors);
|
2022-09-30 01:31:05 +00:00
|
|
|
isFinishedChannel.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* executeDynamicTriggerRequest(
|
|
|
|
|
mainThreadRequestChannel: Channel<any>,
|
|
|
|
|
) {
|
|
|
|
|
while (true) {
|
|
|
|
|
const { mainThreadResponseChannel, requestData, requestId } = yield take(
|
|
|
|
|
mainThreadRequestChannel,
|
|
|
|
|
);
|
|
|
|
|
log.debug({ requestData });
|
|
|
|
|
if (requestData?.trigger) {
|
2021-12-23 14:17:20 +00:00
|
|
|
// if we have found a trigger, we need to execute it and respond back
|
|
|
|
|
log.debug({ trigger: requestData.trigger });
|
|
|
|
|
yield spawn(
|
|
|
|
|
executeTriggerRequestSaga,
|
2022-09-30 01:31:05 +00:00
|
|
|
requestId,
|
2021-12-23 14:17:20 +00:00
|
|
|
requestData,
|
2022-09-30 01:31:05 +00:00
|
|
|
requestData.eventType,
|
|
|
|
|
mainThreadResponseChannel,
|
|
|
|
|
requestData.triggerMeta,
|
2021-12-23 14:17:20 +00:00
|
|
|
);
|
|
|
|
|
}
|
2022-09-30 01:31:05 +00:00
|
|
|
|
|
|
|
|
if (requestData?.errors) {
|
|
|
|
|
yield call(evalErrorHandler, requestData.errors);
|
|
|
|
|
}
|
2021-12-23 14:17:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-15 05:11:13 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
interface ResponsePayload {
|
|
|
|
|
data: {
|
|
|
|
|
subRequestId: string;
|
|
|
|
|
reason?: string;
|
|
|
|
|
resolve?: unknown;
|
|
|
|
|
};
|
|
|
|
|
success: boolean;
|
|
|
|
|
}
|
2021-09-15 05:11:13 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
/*
|
|
|
|
|
* It is necessary to respond back as the worker is waiting with a pending promise and wanting to know if it should
|
|
|
|
|
* resolve or reject it with the data the execution has provided
|
|
|
|
|
*/
|
|
|
|
|
function* executeTriggerRequestSaga(
|
2022-09-30 01:31:05 +00:00
|
|
|
requestId: string,
|
2021-12-23 14:17:20 +00:00
|
|
|
requestData: { trigger: ActionDescription; subRequestId: string },
|
|
|
|
|
eventType: EventType,
|
2022-09-30 01:31:05 +00:00
|
|
|
responseFromExecutionChannel: Channel<unknown>,
|
2021-12-23 14:17:20 +00:00
|
|
|
triggerMeta: TriggerMeta,
|
|
|
|
|
) {
|
|
|
|
|
const responsePayload: ResponsePayload = {
|
|
|
|
|
data: {
|
|
|
|
|
resolve: undefined,
|
|
|
|
|
reason: undefined,
|
|
|
|
|
subRequestId: requestData.subRequestId,
|
|
|
|
|
},
|
|
|
|
|
success: false,
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
responsePayload.data.resolve = yield call(
|
|
|
|
|
executeActionTriggers,
|
|
|
|
|
requestData.trigger,
|
|
|
|
|
eventType,
|
|
|
|
|
triggerMeta,
|
|
|
|
|
);
|
|
|
|
|
responsePayload.success = true;
|
2022-06-21 13:57:34 +00:00
|
|
|
} catch (error) {
|
2021-12-23 14:17:20 +00:00
|
|
|
// When error occurs in execution of triggers,
|
|
|
|
|
// a success: false is sent to reject the promise
|
2022-06-21 13:57:34 +00:00
|
|
|
|
|
|
|
|
// @ts-expect-error: reason is of type string
|
2022-08-23 06:02:31 +00:00
|
|
|
responsePayload.data.reason = { message: error.message };
|
2021-12-23 14:17:20 +00:00
|
|
|
responsePayload.success = false;
|
|
|
|
|
}
|
2022-09-30 01:31:05 +00:00
|
|
|
responseFromExecutionChannel.put({
|
2021-12-23 14:17:20 +00:00
|
|
|
method: EVAL_WORKER_ACTIONS.PROCESS_TRIGGER,
|
2022-09-30 01:31:05 +00:00
|
|
|
requestId: requestId,
|
2021-12-23 14:17:20 +00:00
|
|
|
...responsePayload,
|
|
|
|
|
});
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* clearEvalCache() {
|
2020-12-28 08:42:43 +00:00
|
|
|
yield call(worker.request, EVAL_WORKER_ACTIONS.CLEAR_CACHE);
|
|
|
|
|
|
|
|
|
|
return true;
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-30 07:21:20 +00:00
|
|
|
export function* executeFunction(
|
|
|
|
|
collectionName: string,
|
|
|
|
|
action: JSAction,
|
|
|
|
|
collectionId: string,
|
|
|
|
|
) {
|
2021-12-23 14:17:20 +00:00
|
|
|
const functionCall = `${collectionName}.${action.name}()`;
|
|
|
|
|
const { isAsync } = action.actionConfiguration;
|
2022-05-11 10:20:33 +00:00
|
|
|
let response: {
|
|
|
|
|
errors: any[];
|
|
|
|
|
result: any;
|
2022-09-04 11:58:05 +00:00
|
|
|
logs?: LogObject[];
|
2022-05-11 10:20:33 +00:00
|
|
|
};
|
|
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
if (isAsync) {
|
|
|
|
|
try {
|
|
|
|
|
response = yield call(
|
|
|
|
|
evaluateAndExecuteDynamicTrigger,
|
|
|
|
|
functionCall,
|
|
|
|
|
EventType.ON_JS_FUNCTION_EXECUTE,
|
|
|
|
|
{},
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e instanceof UncaughtPromiseError) {
|
|
|
|
|
logActionExecutionError(e.message);
|
|
|
|
|
}
|
|
|
|
|
response = { errors: [e], result: undefined };
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
response = yield call(worker.request, EVAL_WORKER_ACTIONS.EXECUTE_SYNC_JS, {
|
|
|
|
|
functionCall,
|
|
|
|
|
});
|
2022-09-04 11:58:05 +00:00
|
|
|
|
|
|
|
|
const { logs } = response;
|
|
|
|
|
// Check for any logs in the response and store them in the redux store
|
|
|
|
|
if (!!logs && logs.length > 0) {
|
|
|
|
|
yield call(
|
|
|
|
|
storeLogs,
|
|
|
|
|
logs,
|
|
|
|
|
collectionName + "." + action.name,
|
|
|
|
|
ENTITY_TYPE.JSACTION,
|
|
|
|
|
collectionId,
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-12-23 14:17:20 +00:00
|
|
|
}
|
2021-09-08 17:32:22 +00:00
|
|
|
|
2021-12-23 14:17:20 +00:00
|
|
|
const { errors, result } = response;
|
2022-09-04 11:58:05 +00:00
|
|
|
|
2022-05-11 10:20:33 +00:00
|
|
|
const isDirty = !!errors.length;
|
|
|
|
|
|
2022-06-30 07:21:20 +00:00
|
|
|
yield call(
|
|
|
|
|
handleJSFunctionExecutionErrorLog,
|
|
|
|
|
collectionId,
|
|
|
|
|
collectionName,
|
|
|
|
|
action,
|
|
|
|
|
errors,
|
|
|
|
|
);
|
2022-05-11 10:20:33 +00:00
|
|
|
return { result, isDirty };
|
2021-09-08 17:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-21 04:25:32 +00:00
|
|
|
export function* validateProperty(
|
|
|
|
|
property: string,
|
|
|
|
|
value: any,
|
|
|
|
|
props: WidgetProps,
|
|
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const unevalTree: DataTree = yield select(getUnevaluatedDataTree);
|
|
|
|
|
// @ts-expect-error: We have a typeMismatch for validationPaths
|
2021-04-21 14:34:25 +00:00
|
|
|
const validation = unevalTree[props.widgetName].validationPaths[property];
|
2022-06-21 13:57:34 +00:00
|
|
|
const response: unknown = yield call(
|
|
|
|
|
worker.request,
|
|
|
|
|
EVAL_WORKER_ACTIONS.VALIDATE_PROPERTY,
|
|
|
|
|
{
|
|
|
|
|
property,
|
|
|
|
|
value,
|
|
|
|
|
props,
|
|
|
|
|
validation,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return response;
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
2020-12-30 13:26:44 +00:00
|
|
|
function evalQueueBuffer() {
|
2021-01-04 10:16:08 +00:00
|
|
|
let canTake = false;
|
2022-02-17 04:31:59 +00:00
|
|
|
let collectedPostEvalActions: any = [];
|
2020-12-30 13:26:44 +00:00
|
|
|
const take = () => {
|
2021-01-04 10:16:08 +00:00
|
|
|
if (canTake) {
|
2022-02-17 04:31:59 +00:00
|
|
|
const resp = collectedPostEvalActions;
|
|
|
|
|
collectedPostEvalActions = [];
|
2021-01-04 10:16:08 +00:00
|
|
|
canTake = false;
|
|
|
|
|
return { postEvalActions: resp, type: "BUFFERED_ACTION" };
|
2020-12-30 13:26:44 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const flush = () => {
|
2021-01-04 10:16:08 +00:00
|
|
|
if (canTake) {
|
2020-12-30 13:26:44 +00:00
|
|
|
return [take() as Action];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const put = (action: EvaluationReduxAction<unknown | unknown[]>) => {
|
2021-07-20 10:02:56 +00:00
|
|
|
if (!shouldProcessBatchedAction(action)) {
|
2021-01-14 11:15:25 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2021-01-04 10:16:08 +00:00
|
|
|
canTake = true;
|
2021-01-14 11:15:25 +00:00
|
|
|
|
2022-02-17 04:31:59 +00:00
|
|
|
const postEvalActions = getPostEvalActions(action);
|
|
|
|
|
collectedPostEvalActions.push(...postEvalActions);
|
2020-12-30 13:26:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
take,
|
|
|
|
|
put,
|
|
|
|
|
isEmpty: () => {
|
2021-01-04 10:16:08 +00:00
|
|
|
return !canTake;
|
2020-12-30 13:26:44 +00:00
|
|
|
},
|
|
|
|
|
flush,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-17 04:31:59 +00:00
|
|
|
/**
|
|
|
|
|
* Extract the post eval actions from an evaluation action
|
|
|
|
|
* Batched actions have post eval actions inside them, extract that
|
|
|
|
|
*
|
|
|
|
|
* **/
|
|
|
|
|
function getPostEvalActions(
|
|
|
|
|
action: EvaluationReduxAction<unknown | unknown[]>,
|
|
|
|
|
): AnyReduxAction[] {
|
|
|
|
|
const postEvalActions: AnyReduxAction[] = [];
|
|
|
|
|
if (action.postEvalActions) {
|
|
|
|
|
postEvalActions.push(...action.postEvalActions);
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
action.type === ReduxActionTypes.BATCH_UPDATES_SUCCESS &&
|
|
|
|
|
Array.isArray(action.payload)
|
|
|
|
|
) {
|
|
|
|
|
action.payload.forEach((batchedAction) => {
|
|
|
|
|
if (batchedAction.postEvalActions) {
|
|
|
|
|
postEvalActions.push(
|
|
|
|
|
...(batchedAction.postEvalActions as AnyReduxAction[]),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return postEvalActions;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-30 13:26:44 +00:00
|
|
|
function* evaluationChangeListenerSaga() {
|
|
|
|
|
// Explicitly shutdown old worker if present
|
|
|
|
|
yield call(worker.shutdown);
|
2022-09-30 01:31:05 +00:00
|
|
|
const { mainThreadRequestChannel } = yield call(worker.start);
|
|
|
|
|
|
2021-10-11 12:55:03 +00:00
|
|
|
yield call(worker.request, EVAL_WORKER_ACTIONS.SETUP);
|
2022-09-30 01:31:05 +00:00
|
|
|
yield spawn(executeDynamicTriggerRequest, mainThreadRequestChannel);
|
|
|
|
|
|
2020-12-30 13:26:44 +00:00
|
|
|
widgetTypeConfigMap = WidgetFactory.getWidgetTypeConfigMap();
|
2022-06-21 13:57:34 +00:00
|
|
|
const initAction: {
|
|
|
|
|
postEvalActions: Array<ReduxAction<unknown>>;
|
|
|
|
|
} = yield take(FIRST_EVAL_REDUX_ACTIONS);
|
2021-08-04 05:34:44 +00:00
|
|
|
yield fork(evaluateTreeSaga, initAction.postEvalActions);
|
2022-06-21 13:57:34 +00:00
|
|
|
const evtActionChannel: ActionPattern<Action<any>> = yield actionChannel(
|
2020-12-30 13:26:44 +00:00
|
|
|
EVALUATE_REDUX_ACTIONS,
|
|
|
|
|
evalQueueBuffer(),
|
|
|
|
|
);
|
|
|
|
|
while (true) {
|
|
|
|
|
const action: EvaluationReduxAction<unknown | unknown[]> = yield take(
|
|
|
|
|
evtActionChannel,
|
|
|
|
|
);
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2021-08-04 05:34:44 +00:00
|
|
|
if (shouldProcessBatchedAction(action)) {
|
2022-02-17 04:31:59 +00:00
|
|
|
const postEvalActions = getPostEvalActions(action);
|
2021-09-21 07:55:56 +00:00
|
|
|
yield call(
|
|
|
|
|
evaluateTreeSaga,
|
2022-02-17 04:31:59 +00:00
|
|
|
postEvalActions,
|
2021-09-21 07:55:56 +00:00
|
|
|
get(action, "payload.shouldReplay"),
|
|
|
|
|
);
|
2021-01-14 11:15:25 +00:00
|
|
|
}
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-29 03:50:16 +00:00
|
|
|
export function* evaluateSnippetSaga(action: any) {
|
|
|
|
|
try {
|
|
|
|
|
let { expression } = action.payload;
|
|
|
|
|
const { dataType, isTrigger } = action.payload;
|
|
|
|
|
if (isTrigger) {
|
|
|
|
|
expression = `function() { ${expression} }`;
|
|
|
|
|
}
|
2021-09-24 13:49:59 +00:00
|
|
|
const workerResponse: {
|
|
|
|
|
errors: any;
|
|
|
|
|
result: any;
|
|
|
|
|
triggers: any;
|
|
|
|
|
} = yield call(worker.request, EVAL_WORKER_ACTIONS.EVAL_EXPRESSION, {
|
|
|
|
|
expression,
|
|
|
|
|
dataType,
|
|
|
|
|
isTrigger,
|
|
|
|
|
});
|
2021-08-29 03:50:16 +00:00
|
|
|
const { errors, result, triggers } = workerResponse;
|
|
|
|
|
if (triggers && triggers.length > 0) {
|
2021-09-24 13:49:59 +00:00
|
|
|
yield all(
|
|
|
|
|
triggers.map((trigger: any) =>
|
|
|
|
|
call(
|
|
|
|
|
executeActionTriggers,
|
|
|
|
|
trigger,
|
|
|
|
|
EventType.ON_SNIPPET_EXECUTE,
|
|
|
|
|
{},
|
|
|
|
|
),
|
|
|
|
|
),
|
2021-08-29 03:50:16 +00:00
|
|
|
);
|
2021-09-24 13:49:59 +00:00
|
|
|
//Result is when trigger is present. Following code will hide the evaluated snippet section
|
|
|
|
|
yield put(setEvaluatedSnippet(result));
|
2021-08-29 03:50:16 +00:00
|
|
|
} else {
|
2021-10-11 12:55:03 +00:00
|
|
|
/*
|
2021-09-24 13:49:59 +00:00
|
|
|
JSON.stringify(undefined) is undefined.
|
|
|
|
|
We need to set it manually to "undefined" for codeEditor to display it.
|
|
|
|
|
*/
|
2021-08-29 03:50:16 +00:00
|
|
|
yield put(
|
|
|
|
|
setEvaluatedSnippet(
|
2021-09-24 13:49:59 +00:00
|
|
|
errors?.length
|
2021-08-29 03:50:16 +00:00
|
|
|
? JSON.stringify(errors, null, 2)
|
2021-09-24 13:49:59 +00:00
|
|
|
: isUndefined(result)
|
|
|
|
|
? "undefined"
|
|
|
|
|
: JSON.stringify(result),
|
2021-08-29 03:50:16 +00:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Toaster.show({
|
|
|
|
|
text: createMessage(
|
2021-09-24 13:49:59 +00:00
|
|
|
errors?.length ? SNIPPET_EXECUTION_FAILED : SNIPPET_EXECUTION_SUCCESS,
|
2021-08-29 03:50:16 +00:00
|
|
|
),
|
2021-09-24 13:49:59 +00:00
|
|
|
variant: errors?.length ? Variant.danger : Variant.success,
|
2021-08-29 03:50:16 +00:00
|
|
|
});
|
|
|
|
|
yield put(
|
|
|
|
|
setGlobalSearchFilterContext({
|
|
|
|
|
executionInProgress: false,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
yield put(
|
|
|
|
|
setGlobalSearchFilterContext({
|
|
|
|
|
executionInProgress: false,
|
|
|
|
|
}),
|
|
|
|
|
);
|
2021-09-24 13:49:59 +00:00
|
|
|
Toaster.show({
|
|
|
|
|
text: createMessage(SNIPPET_EXECUTION_FAILED),
|
|
|
|
|
variant: Variant.danger,
|
|
|
|
|
});
|
2021-08-29 03:50:16 +00:00
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* evaluateArgumentSaga(action: any) {
|
|
|
|
|
const { name, type, value } = action.payload;
|
|
|
|
|
try {
|
2022-06-21 13:57:34 +00:00
|
|
|
const workerResponse: {
|
|
|
|
|
errors: Array<unknown>;
|
|
|
|
|
result: unknown;
|
|
|
|
|
} = yield call(worker.request, EVAL_WORKER_ACTIONS.EVAL_EXPRESSION, {
|
|
|
|
|
expression: value,
|
|
|
|
|
});
|
2021-08-29 03:50:16 +00:00
|
|
|
const lintErrors = (workerResponse.errors || []).filter(
|
|
|
|
|
(error: any) => error.errorType !== PropertyEvaluationErrorType.LINT,
|
|
|
|
|
);
|
|
|
|
|
if (workerResponse.result) {
|
feat: JSON Form widget (#8472)
* initial layout
* updated parser to support nested array
* array field rendering
* changes
* ts fix
* minor revert FormWidget
* modified schema structure
* select and switch fields
* added checkbox field
* added RadioGroupField
* partial DateField and defaults, typing refactoring
* added label and field type change
* minor ts changes
* changes
* modified widget/utils for nested panelConfig, modified schema to object approach
* array/object label support
* hide field configuration when children not present
* added tooltip
* field visibility option
* disabled state
* upgraded tslib, form initial values
* custom field configuration - add/hide/edit
* field configuration - label change
* return input when field configuration reaches max depth
* minor changes
* form - scroll, fixedfooter, enitity defn and other minior changes
* form title
* unregister on unmount
* fixes
* zero state
* fix field padding
* patched updating form values, removed linting warnings
* configured action buttons
* minor fix
* minor change
* property pane - sort fields in field configuration
* refactor include all properties
* checkbox properties
* date properties
* refactor typings and radio group properties
* switch, multselect, select, array, object properties
* minor changes
* default value
* ts fixes
* checkbox field properties implementation
* date field prop implementation
* switch field
* select field and fix deep nested meta properties
* multiselect implementation
* minor change
* input field implementation
* fix position jump on field type change
* initial accordian
* field state property and auto-complete of JSONFormComputeControl
* merge fixes
* renamed FormBuilder to JSONForm
* source data validation minor change
* custom field default value fix
* Editable keys for custom field
* minor fixes
* replaced useFieldArray with custom logic, added widget icon
* array and object accordian with border/background styling
* minor change
* disabled states for array and objects
* default value minor fix
* form level styles
* modified logic for isDisabled for array and object, added disabledWhenInvalid, exposed isValid to fieldState for text input, removed useDisableChildren
* added isValid for all field types
* fixed reset to default values
* debounce form values update
* minor change
* minor change
* fix crash - source data change multi-select to array, fix crash - change of options
* fix positioning
* detect date type in source data
* fix crash - when object is passed to regex input field
* fixed default sourceData path for fields
* accodion keep children mounted on collapse
* jest test for schemaParser
* widget/helper and useRegisterFieldInvalid test
* tests for property config helper and generatePanelPropertyConfig
* fix input field validation not appearing
* fix date field type detection
* rename data -> formData
* handle null/undefined field value change in sourceData
* added null/undefined as valid values for defaultValue text field
* auto detect email field
* set formData default value on initial load
* switch field inline positioning
* field margin fix for row direction
* select full width
* fiex date field default value - out of range
* fix any field type to array
* array default value logic change
* base cypress test changes
* initial json form render cy test
* key sanitization
* fix fieldState update logic
* required design, object/array background color, accordion changes, fix - add new custom field
* minor change
* cypress tests
* fix date formatted value, field state cypress test
* cypress - field properties test and fixes
* rename test file
* fix accessort change to blank value, cypress tests
* fix array field default value for modified accessor
* minor fix
* added animate loading
* fix empty state, add new custom field
* test data fix
* fix warnings
* fix timePrecision visibility
* button styling
* ported input v2
* fix jest tests
* fix cypress tests
* perf changes
* perf improvement
* added comments
* multiselect changes
* input field perf refactor
* array field, object field refactor performance
* checkbox field refactor
* refectored date, radio, select and switch
* fixes
* test fixes
* fixes
* minor fix
* rename field renderer
* remove tracked fieldRenderer field
* cypress test fixes
* cypress changes
* array default value fixes
* arrayfield passedDefaultValue
* auto enabled JS mode for few properties, reverted swith and date property controls
* cypress changes
* added widget sniping mode and fixed object passedDefaultValue
* multiselect v2
* select v2
* fix jest tests
* test fixes
* field limit
* rename field type dropdown texts
* field type changes fixes
* jest fixes
* loading state submit button
* default source data for new widget
* modify limit message
* multiseelct default value changes and cypress fix
* select default value
* keep default value intact on field type change
* TextTable cypress text fix
* review changes
* fixed footer changes
* collapse styles section by default
* fixed footer changes
* form modes
* custom field key rentention
* fixed footer fix in view mode
* non ascii characters
* fix meta merge in dataTreeWidget
* minor fixes
* rename useRegisterFieldInvalid.ts -> useRegisterFieldValidity.ts
* modified dependency injection into evaluated values
* refactored fixedfooter logic
* minor change
* accessor update
* minor change
* fixes
* QA fixes date field, scroll content
* fix phone number field, removed visiblity option from array item
* fix sourceData autocomplete
* reset logic
* fix multiselect reset
* form values hydration on widget drag
* code review changes
* reverted order of merge dataTreeWidget
* fixes
* added button titles, fixed hydration issue
* default value fixes
* upgraded react hook form, modified array-level/field-level default value logic
* fixed select validation
* added icon entity explorer, modified icon align control
* modify accessor validation for mongo db _id
* update email field regex
* review changes
* explicitly handle empty source data validation
2022-03-24 07:13:25 +00:00
|
|
|
const validation = validate({ type }, workerResponse.result, {}, "");
|
2021-08-29 03:50:16 +00:00
|
|
|
if (!validation.isValid)
|
2021-09-29 12:03:11 +00:00
|
|
|
validation.messages?.map((message) => {
|
|
|
|
|
lintErrors.unshift({
|
|
|
|
|
...validation,
|
|
|
|
|
...{
|
|
|
|
|
errorType: PropertyEvaluationErrorType.VALIDATION,
|
|
|
|
|
errorMessage: message,
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-08-29 03:50:16 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
yield put(
|
|
|
|
|
setEvaluatedArgument({
|
|
|
|
|
[name]: {
|
|
|
|
|
type,
|
|
|
|
|
value: workerResponse.result,
|
|
|
|
|
name,
|
|
|
|
|
errors: lintErrors,
|
|
|
|
|
isInvalid: lintErrors.length > 0,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 09:45:18 +00:00
|
|
|
export function* updateReplayEntitySaga(
|
|
|
|
|
actionPayload: ReduxAction<{
|
|
|
|
|
entityId: string;
|
|
|
|
|
entity: Replayable;
|
|
|
|
|
entityType: ENTITY_TYPE;
|
|
|
|
|
}>,
|
|
|
|
|
) {
|
|
|
|
|
//Delay updates to replay object to not persist every keystroke
|
|
|
|
|
yield delay(REPLAY_DELAY);
|
|
|
|
|
const { entity, entityId, entityType } = actionPayload.payload;
|
2022-06-21 13:57:34 +00:00
|
|
|
const workerResponse: unknown = yield call(
|
|
|
|
|
worker.request,
|
|
|
|
|
EVAL_WORKER_ACTIONS.UPDATE_REPLAY_OBJECT,
|
|
|
|
|
{
|
|
|
|
|
entityId,
|
|
|
|
|
entity,
|
|
|
|
|
entityType,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return workerResponse;
|
2021-12-07 09:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* workerComputeUndoRedo(operation: string, entityId: string) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const workerResponse: unknown = yield call(worker.request, operation, {
|
2021-12-07 09:45:18 +00:00
|
|
|
entityId,
|
|
|
|
|
});
|
2022-06-21 13:57:34 +00:00
|
|
|
return workerResponse;
|
2021-12-07 09:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
2022-01-06 10:49:01 +00:00
|
|
|
// Type to represent the state of the evaluation reducer
|
|
|
|
|
export interface FormEvaluationConfig
|
|
|
|
|
extends ReduxAction<FormEvalActionPayload> {
|
|
|
|
|
currentEvalState: FormEvaluationState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Function to trigger the form eval job in the worker
|
|
|
|
|
export function* evalFormConfig(formEvaluationConfigObj: FormEvaluationConfig) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const workerResponse: unknown = yield call(
|
2022-01-06 10:49:01 +00:00
|
|
|
worker.request,
|
|
|
|
|
EVAL_WORKER_ACTIONS.INIT_FORM_EVAL,
|
|
|
|
|
formEvaluationConfigObj,
|
|
|
|
|
);
|
2022-06-21 13:57:34 +00:00
|
|
|
|
|
|
|
|
return workerResponse;
|
2022-01-06 10:49:01 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-10 07:11:23 +00:00
|
|
|
export function* setAppVersionOnWorkerSaga(action: {
|
|
|
|
|
type: ReduxActionType;
|
|
|
|
|
payload: EvaluationVersion;
|
|
|
|
|
}) {
|
|
|
|
|
const version: EvaluationVersion = action.payload;
|
|
|
|
|
yield call(worker.request, EVAL_WORKER_ACTIONS.SET_EVALUATION_VERSION, {
|
|
|
|
|
version,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 04:25:32 +00:00
|
|
|
export default function* evaluationSagaListeners() {
|
2020-12-30 13:26:44 +00:00
|
|
|
yield take(ReduxActionTypes.START_EVALUATION);
|
|
|
|
|
while (true) {
|
|
|
|
|
try {
|
|
|
|
|
yield call(evaluationChangeListenerSaga);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(e);
|
|
|
|
|
Sentry.captureException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-21 04:25:32 +00:00
|
|
|
}
|