diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b50c2c4..cb90b66 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ kotest = "6.0.0.M10" kotlin = "2.1.20" kotlinBinaryCompatibilityPlugin = "0.18.1" kotlinLogging = "3.0.5" +kotlixSerialization = "1.9.0" mockk = "1.14.5" quiver = "1.0.0" reflections = "0.10.2" @@ -27,6 +28,7 @@ kotestJunitRunnerJvm = { module = "io.kotest:kotest-runner-junit5-jvm", version. kotestProperty = { module = "io.kotest:kotest-property", version.ref = "kotest" } kotlinLoggingJvm = { module = "io.github.microutils:kotlin-logging-jvm", version.ref = "kotlinLogging" } kotlinReflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +kotlinxSerializationCore = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlixSerialization" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } quiver = { module = "app.cash.quiver:lib", version.ref = "quiver" } reflections = { module = "org.reflections:reflections", version.ref = "reflections" } diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index da13743..93c1ad1 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -25,6 +25,7 @@ dependencies { implementation(libs.arrow) implementation(libs.jooq) implementation(libs.kfsm) + implementation(libs.kotlinxSerializationCore) implementation(libs.quiver) // Test dependencies diff --git a/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt b/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt index 4e237ac..9d8c3fd 100644 --- a/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt +++ b/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt @@ -1,6 +1,7 @@ package xyz.block.domainapi import java.time.LocalDate +import kotlinx.serialization.Serializable /** * Interface of a service that executes a business process, for example, withdraw Bitcoin on-chain. It has the following @@ -143,6 +144,7 @@ data class UpdateResponse( /** * Represent information sent from the server to the client. */ +@Serializable sealed class UserInteraction { /** * An indication sent from the server to the client indicating that user action is required, e.g., @@ -150,6 +152,7 @@ sealed class UserInteraction { * * @param id The id of the requirement. The parametrised type is typically an enumeration. */ + @Serializable open class Hurdle(val id: REQUIREMENT_ID) : UserInteraction() /** @@ -158,6 +161,7 @@ sealed class UserInteraction { * * @param id The id of the requirement. The parametrised type is typically an enumeration. */ + @Serializable open class Notification(val id: REQUIREMENT_ID) : UserInteraction() } @@ -165,6 +169,7 @@ sealed class UserInteraction { /** * Represents an input into the system for a requirement. */ +@Serializable sealed class Input(val id: REQUIREMENT_ID, val result: ResultCode) { /** * Represents the response to a server sent to the client. @@ -172,6 +177,7 @@ sealed class Input(val id: REQUIREMENT_ID, val result: ResultCod * @param id The id of the requirement. This is typically an enumeration. * @param code The result of attempting to overcome the hurdle. */ + @Serializable open class HurdleResponse(id: REQUIREMENT_ID, code: ResultCode) : Input(id, code) @@ -183,6 +189,7 @@ sealed class Input(val id: REQUIREMENT_ID, val result: ResultCod * * @param id The id of the requirement whose result is needed to resume the process. */ + @Serializable open class ResumeResult(id: REQUIREMENT_ID) : Input(id, ResultCode.CLEARED) }