Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Compute default value for jsaction params #34708

Open
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

ashit-rath
Copy link
Contributor

@ashit-rath ashit-rath commented Jul 4, 2024

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

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9850866889
Commit: 28b6f52
Cypress dashboard.
Tags: @tag.All
Spec:


Tue, 09 Jul 2024 05:18:59 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced additional default parameters in an asynchronous function to enhance flexibility and usage.
  • Refactor

    • Updated import paths for consistency across the project.
  • Code Enhancements

    • Added new properties and parameters to improve function and interface definitions.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

The changes primarily involve enhancements to the functionality of an asynchronous function myFun2 by introducing multiple parameters with default values. Additionally, various functions and interfaces are updated to accommodate new parameters and properties. Import paths are also updated for consistency. These updates collectively aim to improve code readability, maintainability, and functionality.

Changes

File/Path Change Summary
app/client/packages/ast/src/index.test.ts Added multiple parameters with default values to myFun2 function. Updated default values for existing parameters.
app/client/packages/ast/src/index.ts Added right: ArgumentTypes property to AssignmentPatternNode interface. Added code = "" parameter to getFunctionalParamsFromNode function.
app/client/packages/ast/src/jsObject/index.ts Updated parseJSObject function to include additional boolean parameter true and code argument in getFunctionalParamsFromNode call.
app/client/src/ce/workers/Evaluation/getEntityForEvalContextMap.ts Updated import path for the getJSActionForEvalContext function.
app/client/src/ee/workers/Evaluation/getJSActionForEvalContext.ts Introduced a new file to re-export all entities related to fetching JavaScript actions for evaluation context.

Poem

🐇 In the land of code tonight,
We've added new defaults, things feel right.
Functions grow, now more complete,
With extra params, they can't be beat.
Paths aligned and context fetched,
Now our code's more finely etched. 🎨✍️


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jul 4, 2024
@ashit-rath
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@ashit-rath ashit-rath self-assigned this Jul 4, 2024
Copy link

github-actions bot commented Jul 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9791119261.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34708.
recreate: .

@ashit-rath ashit-rath added Frontend This label marks the issue or pull request to reference client code Task A simple Todo Package Issues related to packages ok-to-test Required label for CI labels Jul 4, 2024
Copy link

github-actions bot commented Jul 4, 2024

Deploy-Preview-URL: https://ce-34708.dp.appsmith.com

@ashit-rath ashit-rath added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 9, 2024
@ashit-rath ashit-rath marked this pull request as ready for review July 9, 2024 06:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3264ac3 and 28b6f52.

Files selected for processing (5)
  • app/client/packages/ast/src/index.test.ts (3 hunks)
  • app/client/packages/ast/src/index.ts (3 hunks)
  • app/client/packages/ast/src/jsObject/index.ts (1 hunks)
  • app/client/src/ce/workers/Evaluation/getEntityForEvalContextMap.ts (1 hunks)
  • app/client/src/ee/workers/Evaluation/getJSActionForEvalContext.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/ee/workers/Evaluation/getJSActionForEvalContext.ts
Additional comments not posted (5)
app/client/src/ce/workers/Evaluation/getEntityForEvalContextMap.ts (1)

3-3: Verify the new import path.

Ensure that the new import path "@appsmith/workers/Evaluation/getJSActionForEvalContext" is correct and consistent with the updated module structure.

app/client/packages/ast/src/jsObject/index.ts (1)

125-125: Verify the additional parameters in the function call.

Ensure that the additional parameters true and code passed to getFunctionalParamsFromNode are correct and consistent with the function's signature.

app/client/packages/ast/src/index.test.ts (1)

Line range hint 571-612:
Verify the new parameters and default values for myFun2.

Ensure that the new parameters and their default values added to myFun2 are correct and consistent with the function's intended usage.

app/client/packages/ast/src/index.ts (2)

107-107: Verify the new property in the AssignmentPatternNode interface.

Ensure that the new property right: ArgumentTypes is correctly added and consistent with the intended functionality.


523-523: Verify the additional parameter in the function signature.

Ensure that the additional parameter code = "" in the getFunctionalParamsFromNode function is correctly added and consistent with the function's intended functionality.

Comment on lines +542 to +546
const defaultValue =
paramNode.right.type === "Literal" &&
typeof paramNode.right.value === "string"
? paramNode.right.value
: `{{${defaultValueInString}}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on how adding {{ }} helps to maintain datatype integrity as mentioned in the description?

// if in future we need default values of each param, we could implement that in getFunctionalParamsFromNode
// currently we don't consume it anywhere hence avoiding to calculate that.
const params = getFunctionalParamsFromNode(node.value);
const params = getFunctionalParamsFromNode(node.value, true, code);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the defaultValue that will be configured here? I would like to understand how it will be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend This label marks the issue or pull request to reference client code ok-to-test Required label for CI Package Issues related to packages skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants