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: Add separate request/response views #32448

Merged
merged 14 commits into from
Apr 16, 2024
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.appsmith.external.models;

import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -12,5 +15,6 @@
@ToString
@NoArgsConstructor
public class AnalyticsInfo {
@JsonView({Views.Public.class, FromRequest.class})
private Map<String, Object> analyticsData;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.appsmith.external.models;

import com.appsmith.external.helpers.Identifiable;
import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
Expand Down Expand Up @@ -37,7 +38,7 @@ public abstract class BaseDomain implements Persistable<String>, AppsmithDomain,
private static final long serialVersionUID = 7459916000501322517L;

@Id
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
private String id;

@JsonView(Views.Internal.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.appsmith.external.models;

import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -29,38 +29,37 @@ public class Datasource extends BranchAwareDomain {
@Transient
public static final String DEFAULT_NAME_PREFIX = "Untitled datasource";

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String name;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String pluginId;

// name of the plugin. used to log analytics events where pluginName is a required attribute
// It'll be null if not set
@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String pluginName;

// Organizations migrated to workspaces, kept the field as deprecated to support the old migration
@Deprecated
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String organizationId;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String workspaceId;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String templateName;

// This is only kept public for embedded datasource
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
DatasourceConfiguration datasourceConfiguration;

@Transient
@JsonView(Views.Public.class)
Map<String, DatasourceStorageDTO> datasourceStorages = new HashMap<>();

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Set<String> invalids;

Expand All @@ -69,7 +68,6 @@ public class Datasource extends BranchAwareDomain {
* - These messages are generated by the API server based on the other datasource attributes.
*/
@Transient
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Set<String> messages = new HashSet<>();

Expand All @@ -90,22 +88,22 @@ public class Datasource extends BranchAwareDomain {
Boolean isConfigured;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean isRecentlyCreated;

/*
* This field is meant to indicate whether the datasource is part of a template, or a copy of the same.
* The field is not used anywhere in the codebase because templates are created directly in the DB, and the field
* serves only as a DTO property.
*/
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean isTemplate;

/*
* This field is meant to indicate whether the datasource is part of a mock DB, or a copy of the same.
* The field is set during the creation of the mock db
*/
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean isMock;

@JsonView(Views.Internal.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import com.appsmith.external.models.PluginType;
import com.appsmith.external.models.Policy;
import com.appsmith.external.models.Property;
import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -40,88 +40,83 @@
public class ActionCE_DTO implements Identifiable, Executable {

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
private String id;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String applicationId;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String workspaceId;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
PluginType pluginType;

// name of the plugin. used to log analytics events where pluginName is a required attribute
// It'll be null if not set
@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String pluginName;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String pluginId;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String name;

// The FQN for an action will also include any collection it is a part of as collectionName.actionName
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String fullyQualifiedName;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Datasource datasource;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String pageId;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
CreatorContextType contextType;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
String collectionId;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
ActionConfiguration actionConfiguration;

// this attribute carries error messages while processing the actionCollection
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@Transient
@JsonView(Views.Public.class)
List<ErrorDTO> errorReports;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean executeOnLoad;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean clientSideExecution;

/*
* This is a list of fields specified by the client to signify which fields have dynamic bindings in them.
* TODO: The server can use this field to simplify our Mustache substitutions in the future
*/
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
List<Property> dynamicBindingPathList;

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Boolean isValid;

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Set<String> invalids;

@Transient
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Set<String> messages = new HashSet<>();

// This is a list of keys that the client whose values the client needs to send during action execution.
// These are the Mustache keys that the server will replace before invoking the API
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Set<String> jsonPathKeys;

Expand All @@ -131,28 +126,28 @@ public class ActionCE_DTO implements Identifiable, Executable {
@JsonView(Views.Internal.class)
Boolean userSetOnLoad = false;

@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Boolean confirmBeforeExecute = false;

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Documentation documentation;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC")
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Instant deletedAt = null;

@Deprecated
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC")
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
Instant archivedAt = null;

@Transient
@JsonView(Views.Internal.class)
protected Set<Policy> policies = new HashSet<>();

@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
public Set<String> userPermissions = new HashSet<>();

// This field will be used to store the default/root actionId and applicationId for actions generated for git
Expand All @@ -162,7 +157,7 @@ public class ActionCE_DTO implements Identifiable, Executable {

// This field will be used to store analytics data related to this specific domain object. It's been introduced in
// order to track success metrics of modules. Learn more on GitHub issue#24734
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
AnalyticsInfo eventData;

@JsonView(Views.Internal.class)
Expand All @@ -175,7 +170,7 @@ public class ActionCE_DTO implements Identifiable, Executable {
// click binding etc
// Used in logging create action event
@Transient
@JsonView(Views.Public.class)
@JsonView({Views.Public.class, FromRequest.class})
ActionCreationSourceTypeEnum source;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.appsmith.external.views;

/**
* Intended to annotate fields that can be set by HTTP request payloads, but should NOT be included
* in HTTP responses sent back to the client.
*/
public interface FromRequest {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
import com.appsmith.server.refactors.applications.RefactoringService;
import com.appsmith.server.services.LayoutActionService;
import com.appsmith.server.solutions.ActionExecutionSolution;
import io.micrometer.observation.ObservationRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(Url.ACTION_URL)
@Slf4j
public class ActionController extends ActionControllerCE {

public ActionController(
LayoutActionService layoutActionService,
NewActionService newActionService,
RefactoringService refactoringService,
ActionExecutionSolution actionExecutionSolution,
ObservationRegistry observationRegistry) {
ActionExecutionSolution actionExecutionSolution) {

super(layoutActionService, newActionService, refactoringService, actionExecutionSolution, observationRegistry);
super(layoutActionService, newActionService, refactoringService, actionExecutionSolution);
}
}
Loading
Loading