Skip to content
Merged
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: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation(libs.arrow)
implementation(libs.jooq)
implementation(libs.kfsm)
implementation(libs.kotlinxSerializationCore)
implementation(libs.quiver)

// Test dependencies
Expand Down
7 changes: 7 additions & 0 deletions lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -143,13 +144,15 @@ data class UpdateResponse<REQUIREMENT_ID, ATTRIBUTE_ID>(
/**
* Represent information sent from the server to the client.
*/
@Serializable
sealed class UserInteraction<REQUIREMENT_ID> {
/**
* An indication sent from the server to the client indicating that user action is required, e.g.,
* fill out a form.
*
* @param id The id of the requirement. The parametrised type is typically an enumeration.
*/
@Serializable
open class Hurdle<REQUIREMENT_ID>(val id: REQUIREMENT_ID) : UserInteraction<REQUIREMENT_ID>()

/**
Expand All @@ -158,20 +161,23 @@ sealed class UserInteraction<REQUIREMENT_ID> {
*
* @param id The id of the requirement. The parametrised type is typically an enumeration.
*/
@Serializable
open class Notification<REQUIREMENT_ID>(val id: REQUIREMENT_ID) :
UserInteraction<REQUIREMENT_ID>()
}

/**
* Represents an input into the system for a requirement.
*/
@Serializable
sealed class Input<REQUIREMENT_ID>(val id: REQUIREMENT_ID, val result: ResultCode) {
/**
* Represents the response to a server sent to the client.
*
* @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<REQUIREMENT_ID>(id: REQUIREMENT_ID, code: ResultCode) :
Input<REQUIREMENT_ID>(id, code)

Expand All @@ -183,6 +189,7 @@ sealed class Input<REQUIREMENT_ID>(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<REQUIREMENT_ID>(id: REQUIREMENT_ID) :
Input<REQUIREMENT_ID>(id, ResultCode.CLEARED)
}
Expand Down