chore: Import debugger fixes (#31080)
## Description
To add debugger error for import path for module instance on EE, this PR
enables code to be extended on EE
#### PR fixes following issue(s)
Fixes # (issue number)
> 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)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- Chore (housekeeping or task changes that don't impact user perception)
- This change requires a documentation update
>
>
>
## 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 is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Refactor**
- Updated import paths and references for `ENTITY_TYPE` to
`EntityTypeValue` across various components and utilities for improved
code consistency.
- Reorganized import statements related to `AppsmithConsole` utilities
and constants to enhance code maintainability.
- Adjusted usage of enums and types, specifically for entity and
platform error handling, to align with updated import paths.
- **New Features**
- Introduced utility functions for handling entity types and platform
errors in AppsmithConsole, including new constants and error retrieval
functions.
- Added a new enum value `MISSING_MODULE` to better categorize log types
in debugging scenarios.
- **Bug Fixes**
- Implemented changes to error logging and handling mechanisms,
including the addition of new case handling for
`LOG_TYPE.MISSING_MODULE` in debugger logs, to improve the debugging
experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-14 06:30:18 +00:00
|
|
|
import {
|
|
|
|
|
ENTITY_TYPE,
|
|
|
|
|
PLATFORM_ERROR,
|
|
|
|
|
} from "@appsmith/entities/AppsmithConsole/utils";
|
2023-10-16 09:23:47 +00:00
|
|
|
import type {
|
|
|
|
|
WidgetEntity,
|
|
|
|
|
WidgetEntityConfig,
|
|
|
|
|
} from "@appsmith/entities/DataTree/types";
|
2023-03-20 11:04:02 +00:00
|
|
|
import type {
|
|
|
|
|
ConfigTree,
|
|
|
|
|
DataTree,
|
|
|
|
|
UnEvalTree,
|
2023-10-10 12:32:17 +00:00
|
|
|
} from "entities/DataTree/dataTreeTypes";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [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:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { DataTreeDiff } from "@appsmith/workers/Evaluation/evaluationUtils";
|
2021-07-20 10:02:56 +00:00
|
|
|
import {
|
2021-08-04 05:34:44 +00:00
|
|
|
DataTreeDiffEvent,
|
2023-02-14 16:07:31 +00:00
|
|
|
getDataTreeForAutocomplete,
|
2021-07-20 10:02:56 +00:00
|
|
|
getEntityNameAndPropertyPath,
|
|
|
|
|
isAction,
|
|
|
|
|
isWidget,
|
2022-12-22 06:34:28 +00:00
|
|
|
} from "@appsmith/workers/Evaluation/evaluationUtils";
|
2023-11-16 13:54:48 +00:00
|
|
|
import type { EvaluationError } from "utils/DynamicBindingUtils";
|
|
|
|
|
import { getEvalErrorPath } from "utils/DynamicBindingUtils";
|
2021-08-16 11:03:27 +00:00
|
|
|
import { find, get, some } from "lodash";
|
2022-04-12 10:50:01 +00:00
|
|
|
import LOG_TYPE from "entities/AppsmithConsole/logtype";
|
2023-06-09 13:58:45 +00:00
|
|
|
import { call, put, select } from "redux-saga/effects";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [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:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { AnyReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
2022-04-12 10:50:01 +00:00
|
|
|
import AppsmithConsole from "utils/AppsmithConsole";
|
|
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2021-07-20 10:02:56 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
2023-05-31 06:44:07 +00:00
|
|
|
JS_EXECUTION_FAILURE,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2021-07-20 10:02:56 +00:00
|
|
|
import log from "loglevel";
|
2023-03-29 17:07:06 +00:00
|
|
|
import { getAppMode } from "@appsmith/selectors/applicationSelectors";
|
2021-08-06 09:17:56 +00:00
|
|
|
import { APP_MODE } from "entities/App";
|
2021-07-20 10:02:56 +00:00
|
|
|
import { dataTreeTypeDefCreator } from "utils/autocomplete/dataTreeTypeDefCreator";
|
2024-01-04 09:56:18 +00:00
|
|
|
import CodemirrorTernService from "utils/autocomplete/CodemirrorTernService";
|
2023-12-06 19:18:52 +00:00
|
|
|
import type { JSAction, JSCollection } from "entities/JSCollection";
|
2022-08-10 05:20:08 +00:00
|
|
|
import { isWidgetPropertyNamePath } from "utils/widgetEvalUtils";
|
2023-09-29 10:42:14 +00:00
|
|
|
import type { ActionEntityConfig } from "@appsmith/entities/DataTree/types";
|
2023-03-24 10:15:11 +00:00
|
|
|
import type { SuccessfulBindings } from "utils/SuccessfulBindingsMap";
|
2023-05-31 06:44:07 +00:00
|
|
|
import SuccessfulBindingMap from "utils/SuccessfulBindingsMap";
|
|
|
|
|
import { logActionExecutionError } from "./ActionExecution/errorUtils";
|
2024-01-25 13:41:48 +00:00
|
|
|
import { getCurrentWorkspaceId } from "@appsmith/selectors/selectedWorkspaceSelectors";
|
2023-06-15 09:11:43 +00:00
|
|
|
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
|
2023-06-23 10:42:27 +00:00
|
|
|
import type {
|
|
|
|
|
EvalTreeResponseData,
|
|
|
|
|
JSVarMutatedEvents,
|
|
|
|
|
} from "workers/Evaluation/types";
|
2023-12-05 05:32:03 +00:00
|
|
|
import { endSpan, startRootSpan } from "UITelemetry/generateTraces";
|
2024-02-07 11:06:01 +00:00
|
|
|
import { getCollectionNameToDisplay } from "@appsmith/utils/actionExecutionUtils";
|
2023-03-24 10:15:11 +00:00
|
|
|
|
|
|
|
|
let successfulBindingsMap: SuccessfulBindingMap | undefined;
|
2021-07-20 10:02:56 +00:00
|
|
|
|
2023-06-23 10:42:27 +00:00
|
|
|
export function* logJSVarCreatedEvent(
|
|
|
|
|
jsVarsCreatedEvent: EvalTreeResponseData["jsVarsCreatedEvent"],
|
|
|
|
|
) {
|
|
|
|
|
if (!jsVarsCreatedEvent) return;
|
|
|
|
|
|
|
|
|
|
jsVarsCreatedEvent.forEach(({ path, type }) => {
|
|
|
|
|
AnalyticsUtil.logEvent("JS_VARIABLE_CREATED", {
|
|
|
|
|
path,
|
|
|
|
|
type,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* logJSVarMutationEvent(
|
|
|
|
|
jsVarsMutationEvent: JSVarMutatedEvents,
|
|
|
|
|
) {
|
|
|
|
|
Object.values(jsVarsMutationEvent).forEach(({ path, type }) => {
|
|
|
|
|
AnalyticsUtil.logEvent("JS_VARIABLE_MUTATED", {
|
|
|
|
|
path,
|
|
|
|
|
type,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 06:44:07 +00:00
|
|
|
export function* dynamicTriggerErrorHandler(errors: any[]) {
|
|
|
|
|
if (errors.length > 0) {
|
|
|
|
|
for (const error of errors) {
|
|
|
|
|
const errorMessage =
|
|
|
|
|
error.errorMessage.message.message || error.errorMessage.message;
|
2023-06-09 13:58:45 +00:00
|
|
|
yield call(logActionExecutionError, errorMessage, true);
|
2023-05-31 06:44:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-20 10:02:56 +00:00
|
|
|
export function* logSuccessfulBindings(
|
2022-12-02 12:45:11 +00:00
|
|
|
unEvalTree: UnEvalTree,
|
2021-07-20 10:02:56 +00:00
|
|
|
dataTree: DataTree,
|
|
|
|
|
evaluationOrder: string[],
|
2022-06-24 11:59:30 +00:00
|
|
|
isCreateFirstTree: boolean,
|
2023-03-24 10:15:11 +00:00
|
|
|
isNewWidgetAdded: boolean,
|
2023-03-20 11:04:02 +00:00
|
|
|
configTree: ConfigTree,
|
2023-05-16 10:46:40 +00:00
|
|
|
undefinedEvalValuesMap: Record<string, boolean>,
|
2021-07-20 10:02:56 +00:00
|
|
|
) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const appMode: APP_MODE | undefined = yield select(getAppMode);
|
2021-07-20 10:02:56 +00:00
|
|
|
if (appMode === APP_MODE.PUBLISHED) return;
|
|
|
|
|
if (!evaluationOrder) return;
|
2022-06-24 11:59:30 +00:00
|
|
|
|
2023-03-24 10:15:11 +00:00
|
|
|
const successfulBindingPaths: SuccessfulBindings = !successfulBindingsMap
|
|
|
|
|
? {}
|
|
|
|
|
: { ...successfulBindingsMap.get() };
|
|
|
|
|
|
2023-06-15 09:11:43 +00:00
|
|
|
const workspaceId: string = yield select(getCurrentWorkspaceId);
|
|
|
|
|
const instanceId: string = yield select(getInstanceId);
|
|
|
|
|
|
2021-07-20 10:02:56 +00:00
|
|
|
evaluationOrder.forEach((evaluatedPath) => {
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [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:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
const { entityName, propertyPath } =
|
|
|
|
|
getEntityNameAndPropertyPath(evaluatedPath);
|
2021-07-20 10:02:56 +00:00
|
|
|
const entity = dataTree[entityName];
|
2023-03-20 11:04:02 +00:00
|
|
|
const entityConfig = configTree[entityName] as
|
|
|
|
|
| WidgetEntityConfig
|
|
|
|
|
| ActionEntityConfig;
|
2021-07-20 10:02:56 +00:00
|
|
|
if (isAction(entity) || isWidget(entity)) {
|
2021-08-16 11:03:27 +00:00
|
|
|
const unevalValue = get(unEvalTree, evaluatedPath);
|
2023-05-16 10:46:40 +00:00
|
|
|
let isUndefined = false;
|
|
|
|
|
|
|
|
|
|
isUndefined = get(undefinedEvalValuesMap, evaluatedPath) || false;
|
|
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
const entityType = isAction(entity)
|
|
|
|
|
? entityConfig.pluginType
|
|
|
|
|
: entity.type;
|
|
|
|
|
const isABinding = find(entityConfig.dynamicBindingPathList, {
|
2021-07-20 10:02:56 +00:00
|
|
|
key: propertyPath,
|
|
|
|
|
});
|
2022-06-24 11:59:30 +00:00
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
const logBlackList = entityConfig.logBlackList;
|
2023-03-24 10:15:11 +00:00
|
|
|
|
|
|
|
|
if (!isABinding || propertyPath in logBlackList) {
|
|
|
|
|
/**Remove the binding from the map so that in case it is added again, we log it*/
|
|
|
|
|
if (successfulBindingPaths[evaluatedPath]) {
|
|
|
|
|
delete successfulBindingPaths[evaluatedPath];
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** All the paths that are added when a new widget is added needs to be added to the map so that
|
|
|
|
|
* we don't log them again unless they are changed by the user.
|
|
|
|
|
*/
|
|
|
|
|
if (isNewWidgetAdded) {
|
|
|
|
|
successfulBindingPaths[evaluatedPath] = unevalValue;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 11:03:27 +00:00
|
|
|
const errors: EvaluationError[] = get(
|
2021-07-20 10:02:56 +00:00
|
|
|
dataTree,
|
|
|
|
|
getEvalErrorPath(evaluatedPath),
|
|
|
|
|
[],
|
|
|
|
|
) as EvaluationError[];
|
2022-11-03 09:23:15 +00:00
|
|
|
|
|
|
|
|
const hasErrors = errors.length > 0;
|
2023-03-24 10:15:11 +00:00
|
|
|
if (!hasErrors) {
|
|
|
|
|
if (!isCreateFirstTree) {
|
|
|
|
|
/**Log the binding only if it doesn't already exist */
|
|
|
|
|
if (
|
|
|
|
|
!successfulBindingPaths[evaluatedPath] ||
|
|
|
|
|
(successfulBindingPaths[evaluatedPath] &&
|
|
|
|
|
successfulBindingPaths[evaluatedPath] !== unevalValue)
|
|
|
|
|
) {
|
|
|
|
|
AnalyticsUtil.logEvent("ENTITY_BINDING_SUCCESS", {
|
|
|
|
|
unevalValue,
|
|
|
|
|
entityType,
|
|
|
|
|
propertyPath,
|
2023-05-16 10:46:40 +00:00
|
|
|
isUndefined,
|
2023-06-15 09:11:43 +00:00
|
|
|
orgId: workspaceId,
|
|
|
|
|
instanceId,
|
2023-03-24 10:15:11 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-16 10:46:40 +00:00
|
|
|
|
2023-03-24 10:15:11 +00:00
|
|
|
successfulBindingPaths[evaluatedPath] = unevalValue;
|
|
|
|
|
} else {
|
|
|
|
|
/**Remove the binding from the map so that in case it is added again, we log it*/
|
|
|
|
|
if (successfulBindingPaths[evaluatedPath]) {
|
|
|
|
|
delete successfulBindingPaths[evaluatedPath];
|
|
|
|
|
}
|
2021-07-20 10:02:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-03-24 10:15:11 +00:00
|
|
|
|
|
|
|
|
if (!successfulBindingsMap) {
|
|
|
|
|
successfulBindingsMap = new SuccessfulBindingMap(successfulBindingPaths);
|
|
|
|
|
} else {
|
|
|
|
|
successfulBindingsMap.set(successfulBindingPaths);
|
|
|
|
|
}
|
2021-07-20 10:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-17 04:31:59 +00:00
|
|
|
export function* postEvalActionDispatcher(actions: Array<AnyReduxAction>) {
|
2021-07-20 10:02:56 +00:00
|
|
|
for (const action of actions) {
|
|
|
|
|
yield put(action);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 05:34:44 +00:00
|
|
|
// We update the data tree definition after every eval so that autocomplete
|
|
|
|
|
// is accurate
|
2021-07-20 10:02:56 +00:00
|
|
|
export function* updateTernDefinitions(
|
|
|
|
|
dataTree: DataTree,
|
2023-03-20 11:04:02 +00:00
|
|
|
configTree: ConfigTree,
|
2022-11-27 06:11:01 +00:00
|
|
|
updates: DataTreeDiff[],
|
|
|
|
|
isCreateFirstTree: boolean,
|
2023-01-17 07:12:16 +00:00
|
|
|
jsData: Record<string, unknown> = {},
|
2021-07-20 10:02:56 +00:00
|
|
|
) {
|
2023-12-05 05:32:03 +00:00
|
|
|
const span = startRootSpan("updateTernDefinitions");
|
2022-11-27 06:11:01 +00:00
|
|
|
const shouldUpdate: boolean =
|
|
|
|
|
isCreateFirstTree ||
|
|
|
|
|
some(updates, (update) => {
|
|
|
|
|
if (update.event === DataTreeDiffEvent.NEW) return true;
|
|
|
|
|
if (update.event === DataTreeDiffEvent.DELETE) return true;
|
|
|
|
|
if (update.event === DataTreeDiffEvent.EDIT) return false;
|
|
|
|
|
const { entityName } = getEntityNameAndPropertyPath(
|
|
|
|
|
update.payload.propertyPath,
|
|
|
|
|
);
|
|
|
|
|
const entity = dataTree[entityName];
|
|
|
|
|
if (!entity || !isWidget(entity)) return false;
|
2023-10-16 09:23:47 +00:00
|
|
|
return isWidgetPropertyNamePath(
|
|
|
|
|
entity as WidgetEntity,
|
|
|
|
|
update.payload.propertyPath,
|
|
|
|
|
);
|
2021-07-20 10:02:56 +00:00
|
|
|
});
|
2022-11-27 06:11:01 +00:00
|
|
|
|
2023-12-05 05:32:03 +00:00
|
|
|
if (!shouldUpdate) {
|
|
|
|
|
endSpan(span);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-11-27 06:11:01 +00:00
|
|
|
const start = performance.now();
|
2023-03-20 11:04:02 +00:00
|
|
|
|
2023-02-14 16:07:31 +00:00
|
|
|
// remove private and suppressAutoComplete widgets from dataTree used for autocompletion
|
2023-03-20 11:04:02 +00:00
|
|
|
const dataTreeForAutocomplete = getDataTreeForAutocomplete(
|
|
|
|
|
dataTree,
|
|
|
|
|
configTree,
|
|
|
|
|
);
|
2022-11-27 06:11:01 +00:00
|
|
|
const { def, entityInfo } = dataTreeTypeDefCreator(
|
2023-02-14 16:07:31 +00:00
|
|
|
dataTreeForAutocomplete,
|
2023-01-17 07:12:16 +00:00
|
|
|
jsData,
|
2023-03-20 11:04:02 +00:00
|
|
|
configTree,
|
2022-11-27 06:11:01 +00:00
|
|
|
);
|
2024-01-04 09:56:18 +00:00
|
|
|
CodemirrorTernService.updateDef("DATA_TREE", def, entityInfo);
|
2022-11-27 06:11:01 +00:00
|
|
|
const end = performance.now();
|
|
|
|
|
log.debug("Tern", { updates });
|
|
|
|
|
log.debug("Tern definitions updated took ", (end - start).toFixed(2));
|
2023-12-05 05:32:03 +00:00
|
|
|
endSpan(span);
|
2021-07-20 10:02:56 +00:00
|
|
|
}
|
2022-06-30 07:21:20 +00:00
|
|
|
|
|
|
|
|
export function* handleJSFunctionExecutionErrorLog(
|
|
|
|
|
action: JSAction,
|
2023-12-06 19:18:52 +00:00
|
|
|
collection: JSCollection,
|
2022-06-30 07:21:20 +00:00
|
|
|
errors: any[],
|
|
|
|
|
) {
|
2023-12-06 19:18:52 +00:00
|
|
|
const { id: collectionId, name: collectionName } = collection;
|
|
|
|
|
|
2024-02-07 11:06:01 +00:00
|
|
|
const collectionNameToDisplay = getCollectionNameToDisplay(
|
|
|
|
|
action,
|
|
|
|
|
collectionName,
|
|
|
|
|
);
|
|
|
|
|
|
2022-06-30 07:21:20 +00:00
|
|
|
errors.length
|
2022-12-07 10:28:29 +00:00
|
|
|
? AppsmithConsole.addErrors([
|
|
|
|
|
{
|
|
|
|
|
payload: {
|
|
|
|
|
id: `${collectionId}-${action.id}`,
|
|
|
|
|
logType: LOG_TYPE.EVAL_ERROR,
|
2024-02-07 11:06:01 +00:00
|
|
|
text: `${createMessage(
|
|
|
|
|
JS_EXECUTION_FAILURE,
|
|
|
|
|
)}: ${collectionNameToDisplay}.${action.name}`,
|
2023-02-18 12:55:46 +00:00
|
|
|
messages: errors.map((error) => {
|
|
|
|
|
// TODO: Remove this check once we address uncaught promise errors
|
|
|
|
|
let errorMessage = error.errorMessage;
|
|
|
|
|
if (!errorMessage) {
|
|
|
|
|
const errMsgArr = error.message.split(":");
|
|
|
|
|
errorMessage = errMsgArr.length
|
|
|
|
|
? {
|
|
|
|
|
name: errMsgArr[0],
|
|
|
|
|
message: errMsgArr.slice(1).join(":"),
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
name: "ValidationError",
|
|
|
|
|
message: error.message,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
message: errorMessage,
|
|
|
|
|
type: PLATFORM_ERROR.JS_FUNCTION_EXECUTION,
|
|
|
|
|
subType: error.errorType,
|
|
|
|
|
};
|
|
|
|
|
}),
|
2022-12-07 10:28:29 +00:00
|
|
|
source: {
|
2023-02-18 12:55:46 +00:00
|
|
|
id: action.collectionId ? action.collectionId : action.id,
|
2024-02-07 11:06:01 +00:00
|
|
|
name: collectionNameToDisplay,
|
2022-12-07 10:28:29 +00:00
|
|
|
type: ENTITY_TYPE.JSACTION,
|
2023-08-17 13:47:56 +00:00
|
|
|
propertyPath: `${action.name}`,
|
2022-12-07 10:28:29 +00:00
|
|
|
},
|
|
|
|
|
},
|
2022-06-30 07:21:20 +00:00
|
|
|
},
|
2022-12-07 10:28:29 +00:00
|
|
|
])
|
|
|
|
|
: AppsmithConsole.deleteErrors([{ id: `${collectionId}-${action.id}` }]);
|
2022-06-30 07:21:20 +00:00
|
|
|
}
|