## Description
This PR adds the values to jsArguments. The logic for this is
- If the value is string then it is kept as is
- For non-strings they are wrapped with `{{ }}` do maintain the data
type integrity when evaluated.
This property is currently not used anywhere in the platform and this is
intended to be used by js modules to identify the default values of
parameters and provide support to alter then in a UI in the app.
This PR also splits `workers/Evaluation/getJSActionForEvalContext.ts` to
override in the EE for modules
PR for https://github.com/appsmithorg/appsmith-ee/pull/4612
## Automation
/ok-to-test tags="@tag.All"
### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9919551354>
> Commit: c6ab372477fb3fd2f1ce171729af4fa64ac2a487
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9919551354&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Sat, 13 Jul 2024 12:16:08 UTC
<!-- end of auto-generated comment: Cypress test results -->
## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added support for additional node types (`RestElement`,
`ObjectPattern`, `ArrayPattern`) in our AST processing.
- Introduced `addPropertiesToJSObjectCode` function to enhance
JavaScript object property management.
- **Updates**
- Enhanced `myFun2` function with new parameters and default values to
improve flexibility and usage.
- Improved `parseJSObject` function with additional parameters for
better functionality.
- **Tests**
- Added a new test suite for `addPropertiesToJSObjectCode` function to
ensure robust property management in JavaScript objects.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
148 lines
3.3 KiB
TypeScript
148 lines
3.3 KiB
TypeScript
import type {
|
|
ObjectExpression,
|
|
PropertyNode,
|
|
MemberExpressionData,
|
|
IdentifierInfo,
|
|
AssignmentExpressionData,
|
|
CallExpressionData,
|
|
MemberCallExpressionData,
|
|
} from "./src";
|
|
import {
|
|
isIdentifierNode,
|
|
isVariableDeclarator,
|
|
isObjectExpression,
|
|
isLiteralNode,
|
|
isPropertyNode,
|
|
isPropertyAFunctionNode,
|
|
isCallExpressionNode,
|
|
getAST,
|
|
extractIdentifierInfoFromCode,
|
|
entityRefactorFromCode,
|
|
extractExpressionsFromCode,
|
|
getFunctionalParamsFromNode,
|
|
isTypeOfFunction,
|
|
isFunctionPresent,
|
|
getMemberExpressionObjectFromProperty,
|
|
} from "./src";
|
|
|
|
// constants
|
|
import { ECMA_VERSION, SourceType, NodeTypes } from "./src/constants";
|
|
|
|
// JSObjects
|
|
import type {
|
|
TParsedJSProperty,
|
|
JSPropertyPosition,
|
|
JSVarProperty,
|
|
JSFunctionProperty,
|
|
} from "./src/jsObject";
|
|
import {
|
|
parseJSObject,
|
|
isJSFunctionProperty,
|
|
addPropertiesToJSObjectCode,
|
|
} from "./src/jsObject";
|
|
|
|
// action creator
|
|
import {
|
|
getTextArgumentAtPosition,
|
|
setTextArgumentAtPosition,
|
|
getEnumArgumentAtPosition,
|
|
setEnumArgumentAtPosition,
|
|
getModalName,
|
|
setModalName,
|
|
getFuncExpressionAtPosition,
|
|
getFunction,
|
|
replaceActionInQuery,
|
|
setCallbackFunctionField,
|
|
getActionBlocks,
|
|
getFunctionBodyStatements,
|
|
getMainAction,
|
|
getFunctionName,
|
|
setObjectAtPosition,
|
|
getThenCatchBlocksFromQuery,
|
|
setThenBlockInQuery,
|
|
setCatchBlockInQuery,
|
|
getFunctionArguments,
|
|
getFunctionNameFromJsObjectExpression,
|
|
getCallExpressions,
|
|
canTranslateToUI,
|
|
getFunctionParams,
|
|
getQueryParam,
|
|
setQueryParam,
|
|
checkIfCatchBlockExists,
|
|
checkIfThenBlockExists,
|
|
checkIfArgumentExistAtPosition,
|
|
} from "./src/actionCreator";
|
|
|
|
// peekOverlay
|
|
import type { PeekOverlayExpressionIdentifierOptions } from "./src/peekOverlay";
|
|
import { PeekOverlayExpressionIdentifier } from "./src/peekOverlay";
|
|
|
|
// types or interfaces should be exported with type keyword, while enums can be exported like normal functions
|
|
export type {
|
|
ObjectExpression,
|
|
PropertyNode,
|
|
MemberExpressionData,
|
|
IdentifierInfo,
|
|
TParsedJSProperty,
|
|
JSPropertyPosition,
|
|
PeekOverlayExpressionIdentifierOptions,
|
|
AssignmentExpressionData,
|
|
JSVarProperty,
|
|
JSFunctionProperty,
|
|
CallExpressionData,
|
|
MemberCallExpressionData,
|
|
};
|
|
|
|
export {
|
|
isIdentifierNode,
|
|
isVariableDeclarator,
|
|
isObjectExpression,
|
|
isLiteralNode,
|
|
isPropertyNode,
|
|
isPropertyAFunctionNode,
|
|
isCallExpressionNode,
|
|
getAST,
|
|
extractIdentifierInfoFromCode,
|
|
entityRefactorFromCode,
|
|
extractExpressionsFromCode,
|
|
getFunctionalParamsFromNode,
|
|
isTypeOfFunction,
|
|
parseJSObject,
|
|
ECMA_VERSION,
|
|
SourceType,
|
|
NodeTypes,
|
|
getTextArgumentAtPosition,
|
|
getEnumArgumentAtPosition,
|
|
getModalName,
|
|
setModalName,
|
|
setTextArgumentAtPosition,
|
|
setEnumArgumentAtPosition,
|
|
getFuncExpressionAtPosition,
|
|
getFunction,
|
|
replaceActionInQuery,
|
|
setCallbackFunctionField,
|
|
getActionBlocks,
|
|
getFunctionBodyStatements,
|
|
getMainAction,
|
|
getFunctionName,
|
|
setObjectAtPosition,
|
|
getThenCatchBlocksFromQuery,
|
|
setThenBlockInQuery,
|
|
setCatchBlockInQuery,
|
|
getFunctionArguments,
|
|
getFunctionNameFromJsObjectExpression,
|
|
getCallExpressions,
|
|
canTranslateToUI,
|
|
getFunctionParams,
|
|
getQueryParam,
|
|
setQueryParam,
|
|
checkIfThenBlockExists,
|
|
checkIfCatchBlockExists,
|
|
checkIfArgumentExistAtPosition,
|
|
isJSFunctionProperty,
|
|
isFunctionPresent,
|
|
PeekOverlayExpressionIdentifier,
|
|
getMemberExpressionObjectFromProperty,
|
|
addPropertiesToJSObjectCode,
|
|
};
|