Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import static org.lowcoder.sdk.util.ExceptionUtils.ofError;

import java.time.Instant;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -366,8 +363,8 @@ public Mono<ApplicationView> publish(String applicationId) {
}

public Mono<Boolean> grantPermission(String applicationId,
Set<String> userIds,
Set<String> groupIds, ResourceRole role) {
Set<String> userIds,
Set<String> groupIds, ResourceRole role) {
if (userIds.isEmpty() && groupIds.isEmpty()) {
return Mono.just(true);
}
Expand Down Expand Up @@ -502,11 +499,48 @@ private Map<String, Object> sanitizeDsl(Map<String, Object> applicationDsl) {
if (applicationDsl.get("queries") instanceof List<?> queries) {
List<Map<String, Object>> list = queries.stream().map(this::doSanitizeQuery).toList();
applicationDsl.put("queries", list);
removeTestVariablesFromProductionView(applicationDsl);
return applicationDsl;
}
removeTestVariablesFromProductionView(applicationDsl);
return applicationDsl;
}

private void removeTestVariablesFromProductionView(Map<String, Object> applicationDsl) {
// Remove "test" object if it exists within "applicationDSL"
if (applicationDsl.containsKey("ui")) {
Map<String, Object> dataObject = (Map<String, Object>) applicationDsl.get("ui");
if (dataObject.containsKey("comp")) {
Map<String, Object> applicationDSL = (Map<String, Object>) dataObject.get("comp");
doRemoveTestVariablesFromProductionView(applicationDSL);
}
}
}

private void doRemoveTestVariablesFromProductionView(Map<String, Object> map) {
if (map.containsKey("io")) {
Map<String, Object> io = (Map<String, Object>) map.get("io");
if (io.containsKey("inputs")) {
List<Map<String, Object>> inputs = (List<Map<String, Object>>) io.get("inputs");
for (Map<String, Object> inputMap : inputs) {
if (inputMap.containsKey("test")) {
inputMap.remove("test");
}
}
}

if (io.containsKey("outputs")) {
List<Map<String, Object>> outputs = (List<Map<String, Object>>) io.get("outputs");
for (Map<String, Object> inputMap : outputs) {
if (inputMap.containsKey("test")) {
inputMap.remove("test");
}
}
}
}
}


@SuppressWarnings("unchecked")
private Map<String, Object> doSanitizeQuery(Object query) {
if (!(query instanceof Map)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ common:
product: lowcoder
domain:
default-value: skipCheck
js-executor:
host: ${LOWCODER_NODE_SERVICE_URL:http://127.0.0.1:6060}
encrypt:
password: lowcoder
salt: lowcoder
Expand Down