Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A web application serving as both a user-friendly web interface and a REST API f
## Getting Started

### Prerequisites
- java 17 (GraalVM for native image)
- java 21 (GraalVM for native image)
- maven 3.8.3
- or Docker/Podman (optional)

Expand Down
23 changes: 10 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.19.1</quarkus.platform.version>

<closure-compiler.version>v20240317</closure-compiler.version>
<closure-compiler.version>v20250407</closure-compiler.version>
<commons-io.version>2.18.0</commons-io.version>

<surefire-plugin.version>3.5.0</surefire-plugin.version>
Expand Down Expand Up @@ -114,6 +114,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down Expand Up @@ -251,24 +259,13 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>${maven.fmt.plugin}</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<MAX_DOWNLOAD_FILE_SIZE>20971520</MAX_DOWNLOAD_FILE_SIZE>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,45 @@
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.treblereel.javascript.compiler.validation.MaxPayloadSize;
import org.treblereel.javascript.compiler.validation.ValidFileName;


@Schema(name = "CompileRequest",
description = "CompileRequest is a request to compile JavaScript code.")
public class CompileRequest {

@Schema(description = "Compilation level. Possible values: WHITESPACE, SIMPLE, ADVANCED.", enumeration = "WHITESPACE, SIMPLE, ADVANCED")
private String compilationLevel;
@Schema(description = "Warning level. Possible values: QUIET, DEFAULT, VERBOSE.", enumeration = "QUIET, DEFAULT, VERBOSE")
private String warningLevel;

@NotNull @ValidFileName private String outputFileName;
@NotNull
@ValidFileName
@Schema(description = "Output file name. Must be a valid file name.")
private String outputFileName;

@Schema(description = "Language input and output",
implementation = LanguageInOut.class)
private LanguageInOut language;

@MaxPayloadSize private String payload;
@MaxPayloadSize
@Schema(description = "JavaScript code to be compiled.",
type = SchemaType.STRING)
private String payload;

@Schema(description = "Formatting options.", implementation = Formatting.class)
private Formatting formatting;

@Valid private ExternalScripts externalScripts;
@Valid
@Schema(description = "External scripts to be included in the compilation.",
implementation = ExternalScripts.class)
private ExternalScripts externalScripts;

public CompileRequest() {}
public CompileRequest() {
}

public String getCompilationLevel() {
return compilationLevel;
Expand Down Expand Up @@ -85,45 +109,37 @@ public void setExternalScripts(ExternalScripts externalScripts) {
this.externalScripts = externalScripts;
}

public String toString() {
return "CompileRequest{"
+ "compilationLevel='"
+ compilationLevel
+ '\''
+ ", warningLevel='"
+ warningLevel
+ '\''
+ ", outputFileName='"
+ outputFileName
+ '\''
+ ", formatting='"
+ formatting
+ '\''
+ ", workload='"
+ payload
+ '\''
+ ", externalScripts='"
+ externalScripts
+ '\''
+ '}';
public LanguageInOut getLanguage() {
return language;
}

public void setLanguage(LanguageInOut language) {
this.language = language;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CompileRequest that = (CompileRequest) o;
return Objects.equals(compilationLevel, that.compilationLevel)
&& Objects.equals(warningLevel, that.warningLevel)
&& Objects.equals(outputFileName, that.outputFileName)
&& Objects.equals(payload, that.payload)
&& Objects.equals(formatting, that.formatting)
&& Objects.equals(externalScripts, that.externalScripts);
return Objects.equals(compilationLevel, that.compilationLevel) && Objects.equals(warningLevel, that.warningLevel) && Objects.equals(outputFileName, that.outputFileName) && Objects.equals(language, that.language) && Objects.equals(payload, that.payload) && Objects.equals(formatting, that.formatting) && Objects.equals(externalScripts, that.externalScripts);
}

@Override
public int hashCode() {
return Objects.hash(
compilationLevel, warningLevel, outputFileName, payload, formatting, externalScripts);
return Objects.hash(compilationLevel, warningLevel, outputFileName, language, payload, formatting, externalScripts);
}

@Override
public String toString() {
return "CompileRequest{" +
"compilationLevel='" + compilationLevel + '\'' +
", warningLevel='" + warningLevel + '\'' +
", outputFileName='" + outputFileName + '\'' +
", language='" + language + '\'' +
", payload='" + payload + '\'' +
", formatting=" + formatting +
", externalScripts=" + externalScripts +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,32 @@
import java.util.Objects;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

@RegisterForReflection
@Schema(name = "CompileResponse", description = "CompileResponse is a response to the compilation request. It contains the compiled code, download ID, warnings, errors, and statistics.")
public class CompileResponse {

@Schema(description = "Compiled JavaScript code.", type = SchemaType.STRING)
private String compiledCode;

@Schema(description = "Download ID for the compiled code.", type = SchemaType.STRING)
private String downloadId;

@Schema(description = "List of warnings generated during compilation.", type = SchemaType.ARRAY, implementation = String.class)
private List<String> warnings;

@Schema(description = "List of errors generated during compilation.", type = SchemaType.ARRAY, implementation = String.class)
private List<String> errors;

@Schema(description = "Compilation statistics.", implementation = Statistics.class)
private Statistics statistics;

public CompileResponse() {}
public CompileResponse() {
}

public CompileResponse(
String compiledCode,
String downloadId,
List<String> warnings,
List<String> errors,
Statistics statistics) {
public CompileResponse(String compiledCode, String downloadId, List<String> warnings, List<String> errors, Statistics statistics) {
this.compiledCode = compiledCode;
this.downloadId = downloadId;
this.warnings = warnings;
Expand Down Expand Up @@ -91,11 +98,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CompileResponse that = (CompileResponse) o;
return Objects.equals(compiledCode, that.compiledCode)
&& Objects.equals(downloadId, that.downloadId)
&& Objects.equals(warnings, that.warnings)
&& Objects.equals(errors, that.errors)
&& Objects.equals(statistics, that.statistics);
return Objects.equals(compiledCode, that.compiledCode) && Objects.equals(downloadId, that.downloadId) && Objects.equals(warnings, that.warnings) && Objects.equals(errors, that.errors) && Objects.equals(statistics, that.statistics);
}

@Override
Expand All @@ -105,19 +108,6 @@ public int hashCode() {

@Override
public String toString() {
return "CompileResponse{"
+ "compiledCode='"
+ compiledCode
+ '\''
+ ", downloadId='"
+ downloadId
+ '\''
+ ", warnings="
+ warnings
+ ", errors="
+ errors
+ ", statistics="
+ statistics
+ '}';
return "CompileResponse{" + "compiledCode='" + compiledCode + '\'' + ", downloadId='" + downloadId + '\'' + ", warnings=" + warnings + ", errors=" + errors + ", statistics=" + statistics + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@
import java.util.List;
import java.util.Objects;

import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.treblereel.javascript.compiler.validation.MaxExternalUrls;

@Schema(
name = "ExternalScripts",
description =
"ExternalScripts is a class that represents the external scripts to be included in the compilation.")
public class ExternalScripts {

@MaxExternalUrls private List<String> urls;
@MaxExternalUrls
@Schema(
description = "List of external scripts to be included in the compilation.",
type = SchemaType.ARRAY,
implementation = String.class)
private List<String> urls;

public ExternalScripts() {
urls = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@

import java.util.Objects;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(
name = "Formatting",
description =
"Formatting is a class that represents the formatting options for JavaScript compilation.")
public class Formatting {

@Schema(
description = "If true, the output will be pretty-printed.",
defaultValue = "false")
public boolean prettyPrint;

@Schema(
description = "If true, the input delimiter will be printed.",
defaultValue = "false")
public boolean printInputDelimiter;

public Formatting() {}
public Formatting() {
}

public Formatting(boolean prettyPrint, boolean printInputDelimiter) {
this.prettyPrint = prettyPrint;
Expand All @@ -48,11 +62,11 @@ public void setPrintInputDelimiter(boolean printInputDelimiter) {

public String toString() {
return "Formatting{"
+ "prettyPrint="
+ prettyPrint
+ ", printInputDelimiter="
+ printInputDelimiter
+ '}';
+ "prettyPrint="
+ prettyPrint
+ ", printInputDelimiter="
+ printInputDelimiter
+ '}';
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright © 2025 Treblereel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.treblereel.javascript.compiler.domain;

import java.util.Objects;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(name = "LanguageInOut",
description = "LanguageInOut is a class that represents the input and output languages for JavaScript compilation.")
public class LanguageInOut {


@Schema(description = "Input language. Possible values: ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT5_STRICT, ECMASCRIPT_2015, ECMASCRIPT_2016, ECMASCRIPT_2017, ECMASCRIPT_2018, ECMASCRIPT_2019, ECMASCRIPT_2020, ECMASCRIPT_2021, ECMASCRIPT_NEXT and STABLE",
enumeration = {"ECMASCRIPT3", "ECMASCRIPT5", "ECMASCRIPT5_STRICT", "ECMASCRIPT_2015", "ECMASCRIPT_2016", "ECMASCRIPT_2017", "ECMASCRIPT_2018", "ECMASCRIPT_2019", "ECMASCRIPT_2020", "ECMASCRIPT_2021", "ECMASCRIPT_NEXT", "STABLE"})
private String languageIn;

@Schema(description = "Output language. Possible values: ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT5_STRICT, ECMASCRIPT_2015, ECMASCRIPT_2016, ECMASCRIPT_2017, ECMASCRIPT_2018, ECMASCRIPT_2019, ECMASCRIPT_2020, ECMASCRIPT_2021, ECMASCRIPT_NEXT and STABLE",
enumeration = {"ECMASCRIPT3", "ECMASCRIPT5", "ECMASCRIPT5_STRICT", "ECMASCRIPT_2015", "ECMASCRIPT_2016", "ECMASCRIPT_2017", "ECMASCRIPT_2018", "ECMASCRIPT_2019", "ECMASCRIPT_2020", "ECMASCRIPT_2021", "ECMASCRIPT_NEXT", "STABLE"})
private String languageOut;

public LanguageInOut() {
}

public LanguageInOut(String languageIn, String languageOut) {
this.languageIn = languageIn;
this.languageOut = languageOut;
}

public String getLanguageIn() {
return languageIn;
}

public void setLanguageIn(String languageIn) {
this.languageIn = languageIn;
}

public String getLanguageOut() {
return languageOut;
}

public void setLanguageOut(String languageOut) {
this.languageOut = languageOut;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LanguageInOut that = (LanguageInOut) o;
return Objects.equals(languageIn, that.languageIn) && Objects.equals(languageOut, that.languageOut);
}

@Override
public int hashCode() {
return Objects.hash(languageIn, languageOut);
}

@Override
public String toString() {
return "LanguageInOut{" +
"languageIn='" + languageIn + '\'' +
", languageOut='" + languageOut + '\'' +
'}';
}
}
Loading