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

Do PoC on module action entering into action execution flow (#24645) #2

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

dakshgup
Copy link

@dakshgup dakshgup commented Nov 21, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

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

  • Yes
  • No

Greptile Summary

This PR introduces module functionality to support action execution flow in Appsmith, with significant architectural changes across multiple layers.

  • Added new Module domain model and corresponding ModuleDTO with proper MongoDB mapping and JSON serialization
  • Added complete repository layer for modules with CE pattern (ModuleRepository, CustomModuleRepository and implementations)
  • Added module service layer with hardcoded permission groups that need to be made configurable
  • Modified ActionDTO and NewAction to include moduleId field but missing export/import handling
  • Added module controller endpoints for module and action creation with basic validation

@dakshgup
Copy link
Author

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

21 file(s) reviewed, 25 comment(s)
Edit PR Review Bot Settings | Greptile

@JsonView(Views.Public.class)
private String publicActionId;

@Transient
Copy link

Choose a reason for hiding this comment

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

style: Several fields (packageId through pluginId) lack private access modifier - should be explicitly marked as private for better encapsulation

Comment on lines +78 to +82
@JsonView(Views.Public.class)
Boolean executeOnLoad;

@JsonView(Views.Public.class)
Boolean clientSideExecution;
Copy link

Choose a reason for hiding this comment

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

logic: Boolean fields executeOnLoad and clientSideExecution should be primitive boolean to avoid potential null pointer exceptions since no default values are set

Comment on lines +171 to +178
@JsonView(Views.Public.class)
public Datasource getDatasource() {
if (this.datasource == null) {
this.datasource = new Datasource();
this.datasource.setIsAutoGenerated(true);
}
return datasource;
}
Copy link

Choose a reason for hiding this comment

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

logic: getDatasource() creates a new Datasource object if null - this mutates state during a getter which violates principle of least surprise

Comment on lines +189 to +202
public void sanitiseToExportDBObject() {
this.setDefaultResources(null);
this.setCacheResponse(null);
if (this.getDatasource() != null) {
this.getDatasource().setCreatedAt(null);
this.getDatasource().setDatasourceStorages(null);
}
if (this.getUserPermissions() != null) {
this.getUserPermissions().clear();
}
if (this.getPolicies() != null) {
this.getPolicies().clear();
}
}
Copy link

Choose a reason for hiding this comment

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

logic: sanitiseToExportDBObject() method calls getDatasource() which may create a new object just to check if it's null - should access field directly

Comment on lines +3 to +12
import com.appsmith.server.constants.Url;
import com.appsmith.server.controllers.ce.ActionControllerCE;
import com.appsmith.server.controllers.ce.ModuleControllerCE;
import com.appsmith.server.repositories.CustomModuleRepository;
import com.appsmith.server.repositories.ModuleRepository;
import com.appsmith.server.services.LayoutActionService;
import com.appsmith.server.services.ModuleService;
import com.appsmith.server.services.NewActionService;
import com.appsmith.server.solutions.ActionExecutionSolution;
import com.appsmith.server.solutions.RefactoringSolution;
Copy link

Choose a reason for hiding this comment

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

style: Remove unused imports: Url, ActionControllerCE, CustomModuleRepository, NewActionService, ActionExecutionSolution, RefactoringSolution

import reactor.core.publisher.Mono;

public interface ModuleServiceCE extends CrudService<Module, String> {
Mono<ModuleDTO> createModule(ModuleDTO moduleDTO);
Copy link

Choose a reason for hiding this comment

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

style: Consider adding validation annotations like @Valid and @NotNull to moduleDTO parameter to enforce input validation at the interface level

Comment on lines +72 to +73
moduleDTO.setId(module.getId());
moduleDTO.setPublicActionId(moduleAction.getId());
Copy link

Choose a reason for hiding this comment

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

logic: Using moduleAction.getId() instead of savedAction.getId() may cause inconsistency since moduleAction hasn't been saved yet

Comment on lines +64 to +76
return moduleRepository.save(module)
.flatMap(savedModule -> {
moduleAction.setModuleId(savedModule.getId());
return Mono.just(moduleAction);
}).flatMap(mAction -> {
return newActionService.save(mAction)
.flatMap(savedAction-> {
module.setPublicActionId(savedAction.getId());
moduleDTO.setId(module.getId());
moduleDTO.setPublicActionId(moduleAction.getId());
return moduleRepository.save(module).thenReturn(moduleDTO);
});
});
Copy link

Choose a reason for hiding this comment

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

style: Consider using Mono.zip() to combine the parallel save operations and reduce sequential database calls

Comment on lines +180 to +182
for(DefaultEdge e : graph.edgeSet()){
System.out.println(graph.getEdgeSource(e) + " --> " + graph.getEdgeTarget(e));
}
Copy link

Choose a reason for hiding this comment

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

style: Debug logging should use proper logger instead of System.out.println to follow logging best practices and enable log level control

int level = bfsIterator.getDepth(vertex);
System.out.println(String.format("%s : Level %s", vertex, level));
Copy link

Choose a reason for hiding this comment

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

style: Debug logging should use proper logger instead of System.out.println to follow logging best practices and enable log level control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants