generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fail build when schema includes external types (#1082)
Fixes #1066 Building a module now fails if an external type is included in the schema. Examples: - `time.Month` - `github.com/tbd54566975/web5-go/dids/did. PortableDID`
- Loading branch information
Showing
11 changed files
with
321 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//ftl:module external | ||
package external | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
type ExternalRequest struct{} | ||
type ExternalResponse struct { | ||
Month time.Month // external type should not be allowed | ||
} | ||
|
||
// External returns the current month as an external type. | ||
// | ||
//ftl:verb | ||
func Time(ctx context.Context, req ExternalRequest) (ExternalResponse, error) { | ||
return ExternalResponse{Month: time.Now().Month()}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "external" | ||
language = "go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ftl/external | ||
|
||
go 1.22.0 | ||
|
||
replace github.com/TBD54566975/ftl => ../../../.. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "externalkotlin" | ||
language = "kotlin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>ftl</groupId> | ||
<artifactId>external</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<ftl.version>1.0-SNAPSHOT</ftl.version> | ||
<java.version>1.8</java.version> | ||
<kotlin.version>1.9.22</kotlin.version> | ||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental> | ||
<maven.compiler.source>${java.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.version}</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>xyz.block</groupId> | ||
<artifactId>ftl-runtime</artifactId> | ||
<version>${ftl.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<version>42.7.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir> | ||
</sourceDirs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<executions> | ||
<!-- Copy all dependencies into the target directory --> | ||
<execution> | ||
<id>copy-dependencies</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/dependency</outputDirectory> | ||
<includeScope>runtime</includeScope> | ||
</configuration> | ||
</execution> | ||
<!-- Collect classpath --> | ||
<execution> | ||
<id>build-classpath</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>build-classpath</goal> | ||
</goals> | ||
<configuration> | ||
<outputFile>${project.build.directory}/classpath.txt</outputFile> | ||
<prefix>dependency</prefix> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>build-classpath-property</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>build-classpath</goal> | ||
</goals> | ||
<configuration> | ||
<outputProperty>generated.classpath</outputProperty> | ||
<prefix>${project.build.directory}/dependency</prefix> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- Add sources generated by the FTL tooling --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>${project.build.directory}/generated-sources/ftl</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.github.ozsie</groupId> | ||
<artifactId>detekt-maven-plugin</artifactId> | ||
<version>1.23.5</version> | ||
<configuration> | ||
<disableDefaultRuleSets>true</disableDefaultRuleSets> | ||
<classPath>${generated.classpath}</classPath> | ||
<jvmTarget>${java.version}</jvmTarget> | ||
<jdkHome>${java.home}</jdkHome> | ||
<config>${project.build.directory}/detekt.yml</config> | ||
<plugins> | ||
<plugin> | ||
${project.build.directory}/dependency/ftl-runtime-${ftl.version}.jar | ||
</plugin> | ||
</plugins> | ||
<input>${project.basedir}/src/main/kotlin,${project.build.directory}/generated-sources</input> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>check-with-type-resolution</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>xyz.block</groupId> | ||
<artifactId>ftl-runtime</artifactId> | ||
<version>${ftl.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
</plugin> | ||
<!-- Add generated sources to the classpath --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
</plugin> | ||
<!-- Extract schema --> | ||
<plugin> | ||
<groupId>com.github.ozsie</groupId> | ||
<artifactId>detekt-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
...gine/testdata/modules/externalkotlin/src/main/kotlin/ftl/externalkotlin/ExternalKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ftl.externalkotlin | ||
|
||
import com.google.type.DayOfWeek | ||
import xyz.block.ftl.Context | ||
import xyz.block.ftl.Verb | ||
import xyz.block.ftl.v1.schema.Optional | ||
|
||
class InvalidInput(val field: String) : Exception() | ||
|
||
data class ExternalRequest(val name: String?, val dayOfWeek: DayOfWeek) | ||
data class ExternalResponse(val message: String) | ||
|
||
@Throws(InvalidInput::class) | ||
@Verb | ||
fun external(context: Context, req: ExternalRequest): ExternalResponse { | ||
return ExternalResponse(message = "Hello, ${req.name ?: "anonymous"}!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters