Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Feb 23, 2024
1 parent a9b3f1a commit d164b17
Show file tree
Hide file tree
Showing 68 changed files with 171 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ kotlin {
jvm {
jvmToolchain(11)
}
js {
browser()
}
}
16 changes: 8 additions & 8 deletions rsocket-engine/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id(libs.plugins.conventions.multiplatform.library.get().pluginId)
alias(libs.plugins.kotlinx.serialization)
//alias(libs.plugins.timemates.rsproto)
alias(libs.plugins.timemates.rsproto)
}

kotlin {
Expand All @@ -23,13 +23,13 @@ dependencies {
commonMainImplementation(libs.rsocket.client)
}

//rsproto {
// protoSourcePath = "src/main/proto/"
// generationOutputPath = "generated/rsproto/kotlin"
//
// clientGeneration = true
// serverGeneration = false
//}
rsproto {
protoSourcePath = "src/main/proto/"
generationOutputPath = "build/generated/rsproto/kotlin"

clientGeneration = true
serverGeneration = false
}

tasks.withType<Test> {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.timemates.api.rsocket.authorizations

import io.ktor.utils.io.core.toByteArray
import org.timemates.api.authorizations.types.Metadata
import org.timemates.sdk.authorization.sessions.types.value.ApplicationName
import org.timemates.sdk.authorization.sessions.types.value.ClientIpAddress
Expand All @@ -21,10 +22,10 @@ internal fun Metadata.sdk(): SdkAuth.Metadata {
}

internal fun SdkAuth.Metadata.rs(): Metadata {
return Metadata(
clientName = applicationName.string,
clientVersion = clientVersion.double,
)
return Metadata {
clientName = applicationName.string
clientVersion = this@rs.clientVersion.double
}
}

internal fun RSAuthorization.sdk(): SdkAuth {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import org.timemates.api.users.requests.CreateProfileRequest as RSCreateProfileR
internal object ConfigureNewAccountCommand : RSocketCommand<ConfigureNewAccountRequest, ConfigureNewAccountRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: ConfigureNewAccountRequest): ConfigureNewAccountRequest.Result {
return apis.auth.createProfile(
message = RSCreateProfileRequest(
verificationHash = input.verificationHash.string,
name = input.name.string,
description = input.description?.string.orEmpty(),
)
message = RSCreateProfileRequest {
verificationHash = input.verificationHash.string
name = input.name.string
description = input.description?.string.orEmpty()
}
).let { result ->
ConfigureNewAccountRequest.Result(
authorization = result.authorization!!.sdk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import org.timemates.api.authorizations.requests.ConfirmAuthorizationRequest as
internal object ConfirmAuthorizationCommand : RSocketCommand<ConfirmAuthorizationRequest, ConfirmAuthorizationRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: ConfirmAuthorizationRequest): ConfirmAuthorizationRequest.Result {
return apis.auth.confirmAuthorization(
message = RSConfirmAuthorizationRequest(
input.verificationHash.string, input.confirmationCode.string
)
message = RSConfirmAuthorizationRequest {
verificationHash = input.verificationHash.string
confirmationCode = input.confirmationCode.string
}
).let { result ->
ConfirmAuthorizationRequest.Result(
isNewAccount = result.isNewAccount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import org.timemates.api.authorizations.requests.GetAuthorizationsRequest as RSG
internal object GetAuthorizationSessionsCommand : RSocketCommand<GetAuthorizationSessionsRequest, Page<Authorization>> {
override suspend fun execute(apis: ApiContainer, input: GetAuthorizationSessionsRequest): Page<Authorization> {
return apis.auth.getAuthorizations(
message = RSGetAuthorizationsRequest(input.nextPageToken?.string.orEmpty()),
message = RSGetAuthorizationsRequest {
pageToken = input.nextPageToken?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { result ->
Page(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import org.timemates.api.authorizations.requests.RenewAuthorizationRequest as RS
internal object RenewAuthorizationCommand : RSocketCommand<RenewAuthorizationRequest, RenewAuthorizationRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: RenewAuthorizationRequest): RenewAuthorizationRequest.Result {
return apis.auth.renewAuthorization(
message = RSRenewAuthorizationRequest(input.refreshHash.string),
message = RSRenewAuthorizationRequest {
refreshHash = input.refreshHash.string
},
).let { result ->
RenewAuthorizationRequest.Result(
authorization = result.authorization!!.sdk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ internal object StartAuthorizationCommand : RSocketCommand<StartAuthorizationReq
input: StartAuthorizationRequest,
): StartAuthorizationRequest.Result {
return apis.auth.startAuthorization(
message = RSStartAuthorizationRequest(
input.emailAddress.string,
input.metadata.rs(),
)
message = RSStartAuthorizationRequest {
input.emailAddress.string
input.metadata.rs()
}
).let { result ->
StartAuthorizationRequest.Result(
verificationHash = VerificationHash.createOrThrow(result.verificationHash),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.rsocket.kotlin.RSocket
import org.timemates.api.rsocket.ApiContainer
import org.timemates.sdk.common.types.TimeMatesEntity
import org.timemates.sdk.common.types.TimeMatesRequest
import kotlin.jvm.JvmInline

/**
* An inline class that encapsulates a set of RSocket commands for executing TimeMates requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.timemates.api.rsocket.common.commands

import org.timemates.sdk.common.types.TimeMatesEntity
import org.timemates.sdk.common.types.TimeMatesRequest
import kotlin.jvm.JvmInline

@RSocketCommandsDsl
@JvmInline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ internal fun RSTimer.Settings.sdk(): SdkTimerSettings {
}

internal fun SdkTimerSettings.rs(): RSTimer.Settings {
return RSTimer.Settings(
workTime = workTime.toInt(DurationUnit.MINUTES),
restTime = restTime.toInt(DurationUnit.MINUTES),
bigRestEnabled = bigRestEnabled,
bigRestTime = bigRestTime.toInt(DurationUnit.MINUTES),
isConfirmationRequired = isConfirmationRequired,
)
return RSTimer.Settings {
workTime = this@rs.workTime.toInt(DurationUnit.MINUTES)
restTime = this@rs.restTime.toInt(DurationUnit.MINUTES)
bigRestEnabled = this@rs.bigRestEnabled
bigRestTime = this@rs.bigRestTime.toInt(DurationUnit.MINUTES)
isConfirmationRequired = this@rs.isConfirmationRequired
}
}

internal fun RSInvite.sdk(): SdkInvite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import org.timemates.api.timers.requests.CreateTimerRequest as RSCreateTimerRequ
internal object CreateTimerCommand : RSocketCommand<CreateTimerRequest, CreateTimerRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: CreateTimerRequest): CreateTimerRequest.Result {
return apis.timers.createTimer(
message = RSCreateTimerRequest(
name = input.name.string,
description = input.description.string,
settings = input.settings.rs(),
),
message = RSCreateTimerRequest {
name = input.name.string
description = input.description.string
settings = input.settings.rs()
},
extra = input.accessHash.toExtra(),
).let { result ->
CreateTimerRequest.Result(TimerId.createOrThrow(result.timerId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import org.timemates.api.timers.requests.EditTimerRequest as RSEditTimerRequest
internal object EditTimerCommand : RSocketCommand<EditTimerRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: EditTimerRequest): Empty {
return apis.timers.editTimer(
message = RSEditTimerRequest(
timerId = input.timerId.long,
name = input.name?.string.orEmpty(),
),
message = RSEditTimerRequest {
timerId = input.timerId.long
name = input.name?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.timemates.api.timers.requests.GetTimerRequest as RSGetTimerRequest
internal object GetTimerCommand : RSocketCommand<GetTimerRequest, GetTimerRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: GetTimerRequest): GetTimerRequest.Result {
return apis.timers.getTimer(
message = RSGetTimerRequest(
timerId = input.timerId.long,
),
message = RSGetTimerRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { result ->
GetTimerRequest.Result(result.sdk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import org.timemates.api.timers.requests.GetTimersRequest as RSGetTimersRequest
internal object GetUserTimersCommand : RSocketCommand<GetUserTimersRequest, Page<Timer>> {
override suspend fun execute(apis: ApiContainer, input: GetUserTimersRequest): Page<Timer> {
return apis.timers.getTimers(
message = RSGetTimersRequest(
nextPageToken = input.pageToken?.string.orEmpty(),
),
message = RSGetTimersRequest {
nextPageToken = input.pageToken?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { result ->
Page(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.timemates.api.timers.requests.RemoveTimerRequest as RSRemoveTimerRequ
internal object RemoveTimerCommand : RSocketCommand<RemoveTimerRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: RemoveTimerRequest): Empty {
return apis.timers.removeTimer(
message = RSRemoveTimerRequest(input.timerId.long),
message = RSRemoveTimerRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import org.timemates.api.timers.members.requests.GetMembersRequest as RSGetMembe
internal object GetTimerMembersCommand : RSocketCommand<GetMembersRequest, Page<User>> {
override suspend fun execute(apis: ApiContainer, input: GetMembersRequest): Page<User> {
return apis.timers.getMembers(
message = RSGetMembersRequest(
timerId = input.timerId.long,
nextPageToken = input.pageToken?.string.orEmpty(),
),
message = RSGetMembersRequest {
timerId = input.timerId.long
nextPageToken = input.pageToken?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { result ->
Page(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.timemates.api.timers.members.requests.KickMemberRequest as RSKickMemb
internal object KickTimerMemberCommand : RSocketCommand<KickMemberRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: KickMemberRequest): Empty {
return apis.timers.kickMember(
message = RSKickMemberRequest(timerId = input.timerId.long),
message = RSKickMemberRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import org.timemates.sdk.timers.members.invites.types.value.InviteCode
internal object CreateInviteCommand : RSocketCommand<CreateInviteRequest, CreateInviteRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: CreateInviteRequest): CreateInviteRequest.Result {
return apis.timers.createInvite(
message = InviteMemberRequest(
timerId = input.timerId.long,
maxJoiners = input.maxJoinersCount.int,
),
message = InviteMemberRequest {
timerId = input.timerId.long
maxJoiners = input.maxJoinersCount.int
},
extra = input.accessHash.toExtra(),
).let { result ->
CreateInviteRequest.Result(InviteCode.createOrThrow(result.inviteCode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import org.timemates.api.timers.members.invites.requests.GetInvitesRequest as RS
internal object GetInvitesCommand : RSocketCommand<GetInvitesRequest, Page<Invite>> {
override suspend fun execute(apis: ApiContainer, input: GetInvitesRequest): Page<Invite> {
return apis.timers.getInvites(
message = RSGetInvitesRequest(
timerId = input.timerId.long,
nextPageToken = input.pageToken?.string.orEmpty(),
),
message = RSGetInvitesRequest {
timerId = input.timerId.long
nextPageToken = input.pageToken?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { result ->
Page(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.timemates.api.timers.requests.JoinTimerByInviteCodeRequest as RSJoinT
internal object JoinTimerByCodeCommand : RSocketCommand<JoinTimerByCodeRequest, JoinTimerByCodeRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: JoinTimerByCodeRequest): JoinTimerByCodeRequest.Result {
return apis.timers.joinByInvite(
message = RSJoinTimerByInviteCodeRequest(
inviteCode = input.code.string,
),
message = RSJoinTimerByInviteCodeRequest {
inviteCode = input.code.string
},
extra = input.accessHash.toExtra(),
).let { result ->
JoinTimerByCodeRequest.Result(result.timer!!.sdk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import org.timemates.api.timers.members.invites.requests.RemoveInviteRequest as
internal object RemoveInviteCommand : RSocketCommand<RemoveInviteRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: RemoveInviteRequest): Empty {
return apis.timers.removeInvite(
message = RSRemoveInviteRequest(
timerId = input.timerId.long,
inviteCode = input.inviteCode.string,
),
message = RSRemoveInviteRequest {
timerId = input.timerId.long
inviteCode = input.inviteCode.string
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import org.timemates.api.timers.sessions.requests.GetTimerStateRequest as RSGetT
internal object GetTimerStateCommand : RSocketCommand<GetTimerStateRequest, GetTimerStateRequest.Result> {
override suspend fun execute(apis: ApiContainer, input: GetTimerStateRequest): GetTimerStateRequest.Result {
return apis.timerSessions.getState(
message = RSGetTimerStateRequest(timerId = input.timerId.long),
message = RSGetTimerStateRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { result ->
GetTimerStateRequest.Result(result.map { it.sdk() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.timemates.api.timers.sessions.requests.JoinTimerSessionRequest as RSJ
internal object JoinSessionCommand : RSocketCommand<JoinTimerSessionRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: JoinTimerSessionRequest): Empty {
return apis.timerSessions.joinSession(
message = RSJoinTimerSessionRequest(
timerId = input.timerId.long,
),
message = RSJoinTimerSessionRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.timemates.api.timers.sessions.requests.StartTimerRequest as RSStartTi
internal object StartSessionCommand : RSocketCommand<StartTimerRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: StartTimerRequest): Empty {
return apis.timerSessions.startTimer(
message = RSStartTimerRequest(
timerId = input.timerId.long,
),
message = RSStartTimerRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.timemates.api.timers.sessions.requests.StopTimerRequest as RSStopTime
internal object StopSessionCommand : RSocketCommand<StopTimerRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: StopTimerRequest): Empty {
return apis.timerSessions.stopTimer(
message = RSStopTimerRequest(
timerId = input.timerId.long,
),
message = RSStopTimerRequest {
timerId = input.timerId.long
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import org.timemates.api.users.requests.EditEmailRequest as RSEditEmailRequest
internal object EditEmailCommand : RSocketCommand<EditEmailRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: EditEmailRequest): Empty {
return apis.users.setEmail(
message = RSEditEmailRequest(email = input.newEmail.string),
message = RSEditEmailRequest {
email = input.newEmail.string
},
extra = input.accessHash.toExtra()
).let { _ -> Empty }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import org.timemates.api.users.requests.EditUserRequest as RSEditUserRequest
internal object EditProfileCommand : RSocketCommand<EditProfileRequest, Empty> {
override suspend fun execute(apis: ApiContainer, input: EditProfileRequest): Empty {
return apis.users.setUser(
message = RSEditUserRequest(
gravatarId = (input.avatar as? Avatar.GravatarId)?.string.orEmpty(),
name = input.name?.string.orEmpty(),
description = input.description?.string.orEmpty(),
),
message = RSEditUserRequest {
gravatarId = (input.avatar as? Avatar.GravatarId)?.string.orEmpty()
name = input.name?.string.orEmpty()
description = input.description?.string.orEmpty()
},
extra = input.accessHash.toExtra(),
).let { _ -> Empty }
}
Expand Down
Loading

0 comments on commit d164b17

Please sign in to comment.