Database reorganize, protocol version bump, migrations
This commit is contained in:
@@ -11,6 +11,8 @@ val partialsDirectory = layout.buildDirectory.dir("generated/sources/partials")
|
||||
val versionDirectory = layout.buildDirectory.dir("generated/sources/version")
|
||||
val requestsDirectory = layout.projectDirectory.dir("src/commonMain/kotlin/com/jaytux/phoebench/common/")
|
||||
|
||||
version = rootProject.version as PhoebenchVersion
|
||||
|
||||
val generatePartials = tasks.register<Exec>("generatePartials") {
|
||||
group = "generation"
|
||||
description = "Generate Partial classes (requests with all-nullable fields)"
|
||||
@@ -37,7 +39,7 @@ val generateVersion = tasks.register<Task>("protocolVersion") {
|
||||
package com.jaytux.phoebench.common
|
||||
|
||||
object ProtocolVersion {
|
||||
const val VERSION="${rootProject.version}"
|
||||
const val VERSION="${version}"
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
@@ -42,6 +42,15 @@ sealed class ProjectEvent {
|
||||
@Serializable
|
||||
data class Updated(val changes: HomeResponse.ProjectSummary) : ProjectEvent()
|
||||
|
||||
@Serializable
|
||||
data class NewBenchmark(val benchmark: BenchmarkResponse) : ProjectEvent()
|
||||
|
||||
@Serializable
|
||||
data class BenchmarkChanged(val benchmark: BenchmarkSummary) : ProjectEvent()
|
||||
|
||||
@Serializable
|
||||
data class BenchmarkDeleted(val id: Uuid) : ProjectEvent()
|
||||
|
||||
@Serializable
|
||||
data class NewVersion(val label: VersionResponse) : ProjectEvent()
|
||||
|
||||
@@ -55,5 +64,5 @@ sealed class ProjectEvent {
|
||||
data class NewEntry(val entry: EntryResponse) : ProjectEvent()
|
||||
|
||||
@Serializable
|
||||
data class EntryDeleted(val id: Uuid) : ProjectEvent()
|
||||
data class EntryDeleted(val id: Uuid, val benchmarkId: Uuid) : ProjectEvent()
|
||||
}
|
||||
@@ -19,13 +19,16 @@ class EmptyRequest
|
||||
data class RefreshRequest(val refreshToken: Uuid)
|
||||
|
||||
@Serializable @ToPartialize
|
||||
data class ProjectRequest(val name: String, var isPublic: Boolean)
|
||||
data class ProjectRequest(val name: String, val isPublic: Boolean)
|
||||
|
||||
@Serializable @ToPartialize
|
||||
data class VersionRequest(val name: String, val color: String, val meta: String, val projectId: Uuid)
|
||||
data class BenchmarkRequest(val name: String, val projectId: Uuid)
|
||||
|
||||
@Serializable @ToPartialize
|
||||
data class EntryRequest(val version: Uuid, val timestamp: Instant, val projectId: Uuid, val warmups: List<Float>,
|
||||
data class VersionRequest(val name: String, val color: String, val meta: String, val benchmarkId: Uuid)
|
||||
|
||||
@Serializable @ToPartialize
|
||||
data class EntryRequest(val version: Uuid, val timestamp: Instant, val benchmarkId: Uuid, val warmups: List<Float>,
|
||||
val measurements: List<Float>, val unit: TimeUnit, val input: String, val hardware: String)
|
||||
|
||||
@Serializable
|
||||
@@ -35,4 +38,10 @@ data class LogoutRequest(val refresh: Uuid)
|
||||
data class UserUpdateRequest(val projectLimit: Int? = null, val isAdmin: Boolean? = null)
|
||||
|
||||
@Serializable
|
||||
data class InviteRequest(val asAdmin: Boolean)
|
||||
data class InviteRequest(val asAdmin: Boolean)
|
||||
|
||||
@Serializable
|
||||
data class Migrate0To1Request(val conversions: List<MigrateProject>) {
|
||||
@Serializable
|
||||
data class MigrateProject(val newProjectName: String, val isPublic: Boolean, val oldProjectsAsBenchmarks: List<Uuid>)
|
||||
}
|
||||
@@ -32,20 +32,35 @@ data class UserListResponse(val users: List<UserData>) {
|
||||
data class NamedID(val name: String, val id: Uuid)
|
||||
|
||||
@Serializable
|
||||
data class HomeResponse(val username: String, val isAdmin: Boolean, val projectLimit: Int, val ownProjects: List<ProjectSummary>, val publicProjects: List<ProjectSummary>) {
|
||||
data class HomeResponse(val username: String, val isAdmin: Boolean, val projectLimit: Int, val ownProjects: List<ProjectSummary>, val publicProjects: List<ProjectSummary>, val neededMigrations: List<NeededMigration>) {
|
||||
@Serializable
|
||||
data class ProjectSummary(val id: Uuid, val name: String, val isPublic: Boolean, val owner: NamedID)
|
||||
|
||||
@Serializable
|
||||
sealed class NeededMigration {
|
||||
@Serializable
|
||||
data class Migrate0To1(val projects: List<OldProject>) : NeededMigration() {
|
||||
@Serializable
|
||||
data class OldProject(val id: Uuid, val name: String, val versions: List<VersionResponse>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ProjectResponse(val id: Uuid, val name: String, val owner: NamedID, val isPublic: Boolean, val isEditable: Boolean,
|
||||
val usedLabels: List<VersionResponse>, val entries: List<EntryResponse>)
|
||||
val benchmarks: List<BenchmarkResponse>, val versions: List<VersionResponse>)
|
||||
|
||||
@Serializable
|
||||
data class BenchmarkSummary(val id: Uuid, val name: String)
|
||||
|
||||
@Serializable
|
||||
data class BenchmarkResponse(val id: Uuid, val name: String, val entries: List<EntryResponse>)
|
||||
|
||||
@Serializable
|
||||
data class VersionResponse(val id: Uuid, val name: String, val color: String, val meta: String)
|
||||
|
||||
@Serializable
|
||||
data class EntryResponse(val id: Uuid, val labelId: Uuid, val timestamp: Instant, val warmups: List<Float>,
|
||||
data class EntryResponse(val id: Uuid, val benchmarkId: Uuid, val versionId: Uuid, val timestamp: Instant, val warmups: List<Float>,
|
||||
val measurements: List<Float>, val unit: TimeUnit, val input: String, val hardware: String)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -22,6 +22,7 @@ object Routes {
|
||||
|
||||
val handshake = ApiRoute.get<HandshakeResponse>("/", Elevation.UN_AUTH)
|
||||
val home = ApiRoute.get<HomeResponse>("/home", Elevation.AUTH)
|
||||
val migrate0To1 = ApiRoute.post<Migrate0To1Request, HomeResponse>("/migrate/0-1", Elevation.AUTH)
|
||||
|
||||
object Project {
|
||||
val new = ApiRoute.post<ProjectRequest, ProjectResponse>("/project", Elevation.AUTH)
|
||||
@@ -30,6 +31,12 @@ object Routes {
|
||||
val delete = ApiRoute.deleteUuidNoRes("/project", Elevation.AUTH)
|
||||
}
|
||||
|
||||
object Benchmark {
|
||||
val new = ApiRoute.post<BenchmarkRequest, BenchmarkResponse>("/benchmark", Elevation.AUTH)
|
||||
val update = ApiRoute.patchUuidNoRes<PartialBenchmarkRequest>("/benchmark", Elevation.AUTH)
|
||||
val delete = ApiRoute.deleteUuidNoRes("/benchmark", Elevation.AUTH)
|
||||
}
|
||||
|
||||
object Version {
|
||||
val new = ApiRoute.post<VersionRequest, VersionResponse>("/version", Elevation.AUTH)
|
||||
val update = ApiRoute.patchUuidNoRes<PartialVersionRequest>("/version", Elevation.AUTH)
|
||||
|
||||
Reference in New Issue
Block a user