mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2905 Primitives | Epic | Foundation for primitives (#2098)
Co-authored-by: Evgenii Kozlov <enklave.mare.balticum@protonmail.com>
This commit is contained in:
parent
88aa30d64b
commit
4bc1e060f3
153 changed files with 10877 additions and 1616 deletions
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.middleware.block
|
|||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.CBTextStyle
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.core_models.Command.ObjectTypeConflictingFields
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.CreateBlockLinkWithObjectResult
|
||||
import com.anytypeio.anytype.core_models.CreateObjectResult
|
||||
|
@ -263,10 +264,12 @@ class BlockMiddleware(
|
|||
|
||||
override suspend fun createSet(
|
||||
space: Id,
|
||||
objectType: String?
|
||||
objectType: String?,
|
||||
details: Struct?
|
||||
): Response.Set.Create = middleware.objectCreateSet(
|
||||
space = space,
|
||||
objectType = objectType
|
||||
objectType = objectType,
|
||||
details = details
|
||||
)
|
||||
|
||||
override suspend fun setDataViewViewerPosition(
|
||||
|
@ -1075,4 +1078,16 @@ class BlockMiddleware(
|
|||
override suspend fun setDeviceNetworkState(type: DeviceNetworkType) {
|
||||
middleware.setDeviceNetworkState(type)
|
||||
}
|
||||
|
||||
override suspend fun objectTypeListConflictingRelations(command: ObjectTypeConflictingFields): List<Id> {
|
||||
return middleware.objectTypeListConflictingRelations(command)
|
||||
}
|
||||
|
||||
override suspend fun objectTypeSetRecommendedHeaderFields(command: Command.ObjectTypeSetRecommendedHeaderFields) {
|
||||
middleware.objectTypeSetRecommendedHeaderFields(command)
|
||||
}
|
||||
|
||||
override suspend fun objectTypeSetRecommendedFields(command: Command.ObjectTypeSetRecommendedFields) {
|
||||
middleware.objectTypeSetRecommendedFields(command)
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_models.AccountSetup
|
|||
import com.anytypeio.anytype.core_models.AccountStatus
|
||||
import com.anytypeio.anytype.core_models.CBTextStyle
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.core_models.Command.ObjectTypeConflictingFields
|
||||
import com.anytypeio.anytype.core_models.Config
|
||||
import com.anytypeio.anytype.core_models.CreateBlockLinkWithObjectResult
|
||||
import com.anytypeio.anytype.core_models.CreateObjectResult
|
||||
|
@ -1023,7 +1024,8 @@ class Middleware @Inject constructor(
|
|||
@Throws(Exception::class)
|
||||
fun objectCreateSet(
|
||||
space: Id,
|
||||
objectType: String?
|
||||
objectType: String?,
|
||||
details: Struct?
|
||||
): Response.Set.Create {
|
||||
val source = if (objectType != null) {
|
||||
listOf(objectType)
|
||||
|
@ -1033,7 +1035,8 @@ class Middleware @Inject constructor(
|
|||
|
||||
val request = Rpc.Object.CreateSet.Request(
|
||||
source = source,
|
||||
spaceId = space
|
||||
spaceId = space,
|
||||
details = details
|
||||
)
|
||||
|
||||
logRequestIfDebug(request)
|
||||
|
@ -1041,9 +1044,9 @@ class Middleware @Inject constructor(
|
|||
logResponseIfDebug(response, time)
|
||||
|
||||
return Response.Set.Create(
|
||||
targetId = response.objectId,
|
||||
objectId = response.objectId,
|
||||
payload = response.event.toPayload(),
|
||||
blockId = null
|
||||
details = response.details.orEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2894,6 +2897,40 @@ class Middleware @Inject constructor(
|
|||
return response.path
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeListConflictingRelations(command: ObjectTypeConflictingFields): List<Id> {
|
||||
val request = Rpc.ObjectType.ListConflictingRelations.Request(
|
||||
spaceId = command.spaceId,
|
||||
typeObjectId = command.objectTypeId
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.objectTypeListConflictingRelations(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
return response.relationIds
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeSetRecommendedHeaderFields(command: Command.ObjectTypeSetRecommendedHeaderFields) {
|
||||
val request = Rpc.ObjectType.Recommended.FeaturedRelationsSet.Request(
|
||||
typeObjectId = command.objectTypeId,
|
||||
relationObjectIds = command.fields
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.objectTypeHeaderRecommendedFieldsSet(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeSetRecommendedFields(command: Command.ObjectTypeSetRecommendedFields) {
|
||||
val request = Rpc.ObjectType.Recommended.RelationsSet.Request(
|
||||
typeObjectId = command.objectTypeId,
|
||||
relationObjectIds = command.fields
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.objectTypeRecommendedFieldsSet(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
}
|
||||
|
||||
private fun logRequestIfDebug(request: Any) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
logger.logRequest(request).also {
|
||||
|
|
|
@ -621,4 +621,13 @@ interface MiddlewareService {
|
|||
|
||||
@Throws(Exception::class)
|
||||
fun debugExportLogs(request: Rpc.Debug.ExportLog.Request): Rpc.Debug.ExportLog.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeListConflictingRelations(request: Rpc.ObjectType.ListConflictingRelations.Request) : Rpc.ObjectType.ListConflictingRelations.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeHeaderRecommendedFieldsSet(request: Rpc.ObjectType.Recommended.FeaturedRelationsSet.Request) : Rpc.ObjectType.Recommended.FeaturedRelationsSet.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeRecommendedFieldsSet(request: Rpc.ObjectType.Recommended.RelationsSet.Request) : Rpc.ObjectType.Recommended.RelationsSet.Response
|
||||
}
|
|
@ -2508,4 +2508,43 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun objectTypeListConflictingRelations(request: Rpc.ObjectType.ListConflictingRelations.Request): Rpc.ObjectType.ListConflictingRelations.Response {
|
||||
val encoded = Service.objectTypeListConflictingRelations(
|
||||
Rpc.ObjectType.ListConflictingRelations.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.ObjectType.ListConflictingRelations.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.ObjectType.ListConflictingRelations.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun objectTypeHeaderRecommendedFieldsSet(request: Rpc.ObjectType.Recommended.FeaturedRelationsSet.Request): Rpc.ObjectType.Recommended.FeaturedRelationsSet.Response {
|
||||
val encoded = Service.objectTypeRecommendedFeaturedRelationsSet(
|
||||
Rpc.ObjectType.Recommended.FeaturedRelationsSet.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.ObjectType.Recommended.FeaturedRelationsSet.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.ObjectType.Recommended.FeaturedRelationsSet.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun objectTypeRecommendedFieldsSet(request: Rpc.ObjectType.Recommended.RelationsSet.Request): Rpc.ObjectType.Recommended.RelationsSet.Response {
|
||||
val encoded = Service.objectTypeRecommendedRelationsSet(
|
||||
Rpc.ObjectType.Recommended.RelationsSet.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.ObjectType.Recommended.RelationsSet.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.ObjectType.Recommended.RelationsSet.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue