From 99a494608f2dc390ebc810f0f5661e94169b2300 Mon Sep 17 00:00:00 2001 From: Thomas Boksberger Date: Fri, 3 Apr 2026 15:04:11 +0200 Subject: [PATCH] add properties to typeResponse --- CLAUDE.md | 2 ++ httpClient/anyType.http | 15 +++++++++++++++ .../kotlin/ch/ergon/anytask/api/AnyTypeApi.kt | 11 +++++++++++ src/main/kotlin/ch/ergon/anytask/api/dto/Icon.kt | 12 ++++++++++++ .../ch/ergon/anytask/api/dto/ObjectType.kt | 16 ++++++++++++++++ .../kotlin/ch/ergon/anytask/api/dto/Property.kt | 12 ++++++++++++ .../ch/ergon/anytask/api/dto/TypesResponse.kt | 8 ++++++++ 7 files changed, 76 insertions(+) create mode 100644 src/main/kotlin/ch/ergon/anytask/api/dto/Icon.kt create mode 100644 src/main/kotlin/ch/ergon/anytask/api/dto/ObjectType.kt create mode 100644 src/main/kotlin/ch/ergon/anytask/api/dto/Property.kt create mode 100644 src/main/kotlin/ch/ergon/anytask/api/dto/TypesResponse.kt diff --git a/CLAUDE.md b/CLAUDE.md index ea62adb..5ed0a5a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,6 +17,8 @@ Always stage newly created files that permanently belong to the project with `gi ## Architecture **AnyTask** is a Kotlin/Compose desktop app that runs in the background and shows a task creation window via a global hotkey (Ctrl+Shift+Space). +**AnyType** is a private, offline-first digital workspace and collaboration tool that gives users full ownership of their data through local encryption and peer-to-peer sync — with no servers or gatekeepers involved. Everything in Anytype is built around Objects — the universal unit for any piece of content — each assigned a Type (e.g. Note, Task, Book) that defines its structure, and connected via Relations (typed properties like due date, assignee, or tags) that link objects together into a queryable, graph-like knowledge model. +**API** the Anytype API is documented [here](https://developers.anytype.io/docs/reference). ### Components diff --git a/httpClient/anyType.http b/httpClient/anyType.http index dbe5a2c..5c2790b 100644 --- a/httpClient/anyType.http +++ b/httpClient/anyType.http @@ -2,6 +2,21 @@ GET http://localhost:31009/v1/spaces Authorization: Bearer {{apiKey}} +### Get Types +GET http://localhost:31009/v1/spaces/{{spaceId}}/types +Authorization: Bearer {{apiKey}} +Anytype-Version: 0.1 + +### Get Type +GET http://localhost:31009/v1/spaces/{{spaceId}}/types/bafyreidtsobmbfmf6gl7bfwyd3ik3zs4m7t6e7p46y4lonsz3chkgeeabi +Authorization: Bearer {{apiKey}} +Anytype-Version: 0.1 + +### Get Property +GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/bafyreibs7xr3zphtvjt3t4bk3jhcxlllo6jskrsatnuvkrcs65k3kfuany +Authorization: Bearer {{apiKey}} +Anytype-Version: 0.1 + ### Create Task POST http://localhost:31009/v1/spaces/{{spaceId}}/objects Authorization: Bearer {{apiKey}} diff --git a/src/main/kotlin/ch/ergon/anytask/api/AnyTypeApi.kt b/src/main/kotlin/ch/ergon/anytask/api/AnyTypeApi.kt index 70e7c23..175c54a 100644 --- a/src/main/kotlin/ch/ergon/anytask/api/AnyTypeApi.kt +++ b/src/main/kotlin/ch/ergon/anytask/api/AnyTypeApi.kt @@ -2,8 +2,10 @@ package ch.ergon.anytask.api import ch.ergon.anytask.api.dto.CreateObjectRequest import ch.ergon.anytask.api.dto.CreateObjectResponse +import ch.ergon.anytask.api.dto.ObjectType import ch.ergon.anytask.api.dto.Space import ch.ergon.anytask.api.dto.SpacesResponse +import ch.ergon.anytask.api.dto.TypesResponse import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.engine.cio.* @@ -60,6 +62,15 @@ class AnyTypeApi( response.body().data } + suspend fun getTypes(): Result> = + runCatching { + val response = http.get("$baseUrl/v1/spaces/$spaceId/types") { + header("Anytype-Version", "0.1") + bearerAuth(apiKey) + } + response.body().data + } + suspend fun createTask(title: String, details: String = ""): Result = runCatching { val response = http.post("$baseUrl/v1/spaces/$spaceId/objects") { diff --git a/src/main/kotlin/ch/ergon/anytask/api/dto/Icon.kt b/src/main/kotlin/ch/ergon/anytask/api/dto/Icon.kt new file mode 100644 index 0000000..a067838 --- /dev/null +++ b/src/main/kotlin/ch/ergon/anytask/api/dto/Icon.kt @@ -0,0 +1,12 @@ +package ch.ergon.anytask.api.dto + +import kotlinx.serialization.Serializable + +@Serializable +data class Icon( + val format: String = "", + val emoji: String = "", + val file: String = "", + val name: String = "", + val color: String = "", +) \ No newline at end of file diff --git a/src/main/kotlin/ch/ergon/anytask/api/dto/ObjectType.kt b/src/main/kotlin/ch/ergon/anytask/api/dto/ObjectType.kt new file mode 100644 index 0000000..4430e6e --- /dev/null +++ b/src/main/kotlin/ch/ergon/anytask/api/dto/ObjectType.kt @@ -0,0 +1,16 @@ +package ch.ergon.anytask.api.dto + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ObjectType( + val id: String, + val key: String = "", + val name: String, + val icon: Icon = Icon(), + val layout: String = "", + val archived: Boolean = false, + @SerialName("plural_name") val pluralName: String = "", + val properties: List = emptyList(), +) \ No newline at end of file diff --git a/src/main/kotlin/ch/ergon/anytask/api/dto/Property.kt b/src/main/kotlin/ch/ergon/anytask/api/dto/Property.kt new file mode 100644 index 0000000..0d1838f --- /dev/null +++ b/src/main/kotlin/ch/ergon/anytask/api/dto/Property.kt @@ -0,0 +1,12 @@ +package ch.ergon.anytask.api.dto + +import kotlinx.serialization.Serializable + +@Serializable +data class Property( + val id: String, + val key: String = "", + val name: String, + val format: String = "", + val `object`: String = "", +) \ No newline at end of file diff --git a/src/main/kotlin/ch/ergon/anytask/api/dto/TypesResponse.kt b/src/main/kotlin/ch/ergon/anytask/api/dto/TypesResponse.kt new file mode 100644 index 0000000..f049134 --- /dev/null +++ b/src/main/kotlin/ch/ergon/anytask/api/dto/TypesResponse.kt @@ -0,0 +1,8 @@ +package ch.ergon.anytask.api.dto + +import kotlinx.serialization.Serializable + +@Serializable +data class TypesResponse( + val data: List, +) \ No newline at end of file