Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated to kotlinx.datetime #13

Merged
merged 1 commit into from
Mar 18, 2024
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Example:

```
ktorVersion=2.3.6
dateTimeVersion=0.6.0-RC.2
logbackVersion=1.5.1
tursoSdkVersion=0.1.11 // currently published version
```
Expand All @@ -29,6 +30,7 @@ Add dependencies to `build.gradle.kts`
```Kotlin
// define version variables
val ktorVersion: String by project
val dateTimeVersion: String by project
val logbackVersion: String by project
val tursoSdkVersion: String by project

Expand All @@ -44,6 +46,7 @@ dependencies {
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime-jvm:$dateTimeVersion")
implementation ("ch.qos.logback:logback-classic:$logbackVersion")
implementation("com.jeliuc:turso-sdk-jvm:$tursoSdkVersion")
// ...
Expand Down Expand Up @@ -99,7 +102,7 @@ client.close()

## Future Plans

* [ ] Use `kotlinx.datetime` for date and time handling
* [x] Use `kotlinx.datetime` for date and time handling
* [ ] Transform into a multiplatform library (KMP) - and support JVM, JS, and Native
* [ ] HRANA3 protocol implementation (WIP)
* [ ] libSQL JDBC driver (WIP)
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import org.jetbrains.dokka.versioning.VersioningConfiguration
import org.jetbrains.dokka.versioning.VersioningPlugin

val ktorVersion: String by project
val dateTimeVersion: String by project

val spaceUsername: String? by project
val spacePassword: String? by project
val sdkVersion: String by project
val spaceMavenRepositoryUrl: String by project
val sonatypeUsername: String by project
val sonatypePassword: String by project
val sdkVersion: String by project

group = "com.jeliuc"
version = System.getenv("SDK_VERSION") ?: sdkVersion
Expand Down Expand Up @@ -48,6 +49,7 @@ dependencies {
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime-jvm:$dateTimeVersion")
}

tasks.test {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
kotlin.code.style=official
ktorVersion=2.3.6
dateTimeVersion=0.6.0-RC.2
sdkVersion=0.1.11
spaceUsername=
spacePassword=
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/model/AuditLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

package com.jeliuc.turso.sdk.model

import com.jeliuc.turso.sdk.serializer.LocalDateTimeSerializer
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import java.time.LocalDateTime

@Serializable
data class ListAuditLogsResponse(
Expand All @@ -21,7 +20,7 @@ data class ListAuditLogsResponse(
data class AuditLog(
@SerialName("author") val author: String,
@SerialName("code") val code: String,
@SerialName("created_at") @Serializable(with = LocalDateTimeSerializer::class) val createdAt: LocalDateTime,
@SerialName("created_at") val createdAt: Instant,
@SerialName("data") val data: JsonElement,
@SerialName("message") val message: String,
@SerialName("origin") val origin: String,
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/model/Organization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

package com.jeliuc.turso.sdk.model

import com.jeliuc.turso.sdk.serializer.LocalDateTimeSerializer
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.time.LocalDateTime

@Serializable
data class Organization(
Expand Down Expand Up @@ -94,15 +93,15 @@ data class ListInvitesResponse(
@Serializable
data class Invite(
@SerialName("Accepted") val accepted: Boolean,
@SerialName("CreatedAt") @Serializable(with = LocalDateTimeSerializer::class) val createdAt: LocalDateTime,
@SerialName("DeletedAt") @Serializable(with = LocalDateTimeSerializer::class) val deletedAt: LocalDateTime,
@SerialName("CreatedAt") val createdAt: Instant,
@SerialName("DeletedAt") val deletedAt: Instant,
@SerialName("Email") val email: String,
@SerialName("ID") val id: Int,
@SerialName("Organization") val organization: Organization,
@SerialName("OrganizationID") val organizationID: Int,
@SerialName("Role") val role: MemberRole,
@SerialName("Token") val token: String,
@SerialName("UpdatedAt") @Serializable(with = LocalDateTimeSerializer::class) val updatedAt: LocalDateTime,
@SerialName("UpdatedAt") val updatedAt: Instant,
)

@Serializable
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/resource/Databases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import io.ktor.http.ContentType
import io.ktor.http.Headers
import io.ktor.http.HttpHeaders
import io.ktor.http.contentType
import kotlinx.datetime.LocalDateTime
import java.io.File
import java.time.LocalDateTime

val TursoClient.databases: Databases
get() = Databases(this)
Expand Down
29 changes: 0 additions & 29 deletions src/main/kotlin/serializer/LocalDateTimeSerializer.kt

This file was deleted.

Loading