mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Update middleware to 0.5.0 (#354)
This commit is contained in:
parent
9ead509c41
commit
d38d490430
23 changed files with 523 additions and 235 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -1,5 +1,24 @@
|
|||
# Change log for Android @Anytype app.
|
||||
|
||||
## Version 0.0.27 (WIP)
|
||||
|
||||
### New features 🚀
|
||||
|
||||
*
|
||||
|
||||
### Design 🔳
|
||||
|
||||
*
|
||||
|
||||
### Fixes & tech 🚒
|
||||
|
||||
*
|
||||
|
||||
### Middleware ⚙️
|
||||
|
||||
* Updated middleware to `0.5.0` (#339)
|
||||
* Added `blockSetDetails` command (#339)
|
||||
|
||||
## Version 0.0.26
|
||||
|
||||
### New features 🚀
|
||||
|
|
|
@ -73,6 +73,10 @@ fun BlockEntity.toDomain(): Block {
|
|||
)
|
||||
}
|
||||
|
||||
fun BlockEntity.Details.toDomain(): Block.Details = Block.Details(
|
||||
details = details.map { (id, fields) -> id to Block.Fields(map = fields.map) }.toMap()
|
||||
)
|
||||
|
||||
fun BlockEntity.Content.toDomain(): Block.Content = when (this) {
|
||||
is BlockEntity.Content.Text -> toDomain()
|
||||
is BlockEntity.Content.Dashboard -> toDomain()
|
||||
|
@ -329,7 +333,7 @@ fun Command.UpdateTextColor.toEntity(): CommandEntity.UpdateTextColor =
|
|||
fun Command.UpdateBackgroundColor.toEntity(): CommandEntity.UpdateBackgroundColor =
|
||||
CommandEntity.UpdateBackgroundColor(
|
||||
context = context,
|
||||
target = target,
|
||||
targets = targets,
|
||||
color = color
|
||||
)
|
||||
|
||||
|
@ -432,9 +436,10 @@ fun EventEntity.toDomain(): Event {
|
|||
return when (this) {
|
||||
is EventEntity.Command.ShowBlock -> {
|
||||
Event.Command.ShowBlock(
|
||||
rootId = rootId,
|
||||
root = root,
|
||||
blocks = blocks.map { it.toDomain() },
|
||||
context = context
|
||||
context = context,
|
||||
details = details.toDomain()
|
||||
)
|
||||
}
|
||||
is EventEntity.Command.AddBlock -> {
|
||||
|
|
|
@ -10,6 +10,7 @@ data class BlockEntity(
|
|||
val fields: Fields
|
||||
) {
|
||||
data class Fields(val map: MutableMap<String?, Any?> = mutableMapOf())
|
||||
data class Details(val details: Map<String, Fields>)
|
||||
|
||||
sealed class Content {
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class CommandEntity {
|
|||
|
||||
data class UpdateBackgroundColor(
|
||||
val context: String,
|
||||
val target: String,
|
||||
val targets: List<String>,
|
||||
val color: String
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ sealed class EventEntity {
|
|||
|
||||
data class ShowBlock(
|
||||
override val context: String,
|
||||
val rootId: String,
|
||||
val root: String,
|
||||
val details: BlockEntity.Details = BlockEntity.Details(emptyMap()),
|
||||
val blocks: List<BlockEntity>
|
||||
) : Command()
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ open class UpdateBackgroundColor(
|
|||
repo.updateBackgroundColor(
|
||||
command = Command.UpdateBackgroundColor(
|
||||
context = params.context,
|
||||
target = params.target,
|
||||
targets = params.targets,
|
||||
color = params.color
|
||||
)
|
||||
).let {
|
||||
|
@ -30,12 +30,12 @@ open class UpdateBackgroundColor(
|
|||
/**
|
||||
* Params for updating background color for the whole block.
|
||||
* @property context context id
|
||||
* @property target id of the target block, whose background color we need to update.
|
||||
* @property targets id of the target block, whose background color we need to update.
|
||||
* @property color new color (hex)
|
||||
*/
|
||||
data class Params(
|
||||
val context: Id,
|
||||
val target: Id,
|
||||
val targets: List<Id>,
|
||||
val color: String
|
||||
)
|
||||
}
|
|
@ -41,6 +41,12 @@ data class Block(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Document metadata
|
||||
* @property details maps id of the block to its details (contained as fields)
|
||||
*/
|
||||
data class Details(val details: Map<Id, Fields>)
|
||||
|
||||
/**
|
||||
* Block's content.
|
||||
*/
|
||||
|
|
|
@ -54,12 +54,12 @@ sealed class Command {
|
|||
/**
|
||||
* Command for updating background color for the whole block.
|
||||
* @property context context id
|
||||
* @property target id of the target block, whose background color we need to update.
|
||||
* @property targets id of the target blocks, whose background color we need to update.
|
||||
* @property color new color (hex)
|
||||
*/
|
||||
data class UpdateBackgroundColor(
|
||||
val context: Id,
|
||||
val target: Id,
|
||||
val targets: List<Id>,
|
||||
val color: String
|
||||
)
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ sealed class Event {
|
|||
sealed class Command : Event() {
|
||||
|
||||
data class ShowBlock(
|
||||
override val context: String,
|
||||
val rootId: Id,
|
||||
override val context: Id,
|
||||
val root: Id,
|
||||
val details: Block.Details = Block.Details(emptyMap()),
|
||||
val blocks: List<Block>
|
||||
) : Command()
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ fun Block.text(): BlockEntity.Content.Text = BlockEntity.Content.Text(
|
|||
style = text.style.entity(),
|
||||
isChecked = text.checked,
|
||||
color = if (text.color.isNotEmpty()) text.color else null,
|
||||
backgroundColor = if (text.backgroundColor.isNotEmpty()) text.backgroundColor else null
|
||||
backgroundColor = if (backgroundColor.isNotEmpty()) backgroundColor else null
|
||||
)
|
||||
|
||||
fun List<Block.Content.Text.Mark>.marks(): List<BlockEntity.Content.Text.Mark> = map { mark ->
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.agileburo.anytype.middleware.model.CreateAccountResponse;
|
|||
import com.agileburo.anytype.middleware.model.CreateWalletResponse;
|
||||
import com.agileburo.anytype.middleware.model.SelectAccountResponse;
|
||||
import com.agileburo.anytype.middleware.service.MiddlewareService;
|
||||
import com.google.protobuf.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -22,6 +23,8 @@ import timber.log.Timber;
|
|||
|
||||
public class Middleware {
|
||||
|
||||
private final String iconKey = "icon";
|
||||
|
||||
private final MiddlewareService service;
|
||||
private final MiddlewareFactory factory;
|
||||
private final MiddlewareMapper mapper;
|
||||
|
@ -142,20 +145,9 @@ public class Middleware {
|
|||
}
|
||||
|
||||
public String createPage(String parentId) throws Exception {
|
||||
Models.Block.Content.Page page = Models.Block.Content.Page
|
||||
.newBuilder()
|
||||
.setStyle(Models.Block.Content.Page.Style.Empty)
|
||||
.build();
|
||||
|
||||
Models.Block block = Models.Block
|
||||
.newBuilder()
|
||||
.setPage(page)
|
||||
.build();
|
||||
|
||||
Block.CreatePage.Request request = Block.CreatePage.Request
|
||||
.newBuilder()
|
||||
.setContextId(parentId)
|
||||
.setBlock(block)
|
||||
.setPosition(Models.Block.Position.Inner)
|
||||
.build();
|
||||
|
||||
|
@ -254,10 +246,10 @@ public class Middleware {
|
|||
}
|
||||
|
||||
public void updateBackgroundColor(CommandEntity.UpdateBackgroundColor command) throws Exception {
|
||||
Block.Set.Text.BackgroundColor.Request request = Block.Set.Text.BackgroundColor.Request
|
||||
BlockList.Set.BackgroundColor.Request request = BlockList.Set.BackgroundColor.Request
|
||||
.newBuilder()
|
||||
.setContextId(command.getContext())
|
||||
.setBlockId(command.getTarget())
|
||||
.addAllBlockIds(command.getTargets())
|
||||
.setColor(command.getColor())
|
||||
.build();
|
||||
|
||||
|
@ -328,22 +320,11 @@ public class Middleware {
|
|||
|
||||
Models.Block.Position position = mapper.toMiddleware(command.getPosition());
|
||||
|
||||
Models.Block.Content.Page page = Models.Block.Content.Page
|
||||
.newBuilder()
|
||||
.setStyle(Models.Block.Content.Page.Style.Empty)
|
||||
.build();
|
||||
|
||||
Models.Block block = Models.Block
|
||||
.newBuilder()
|
||||
.setPage(page)
|
||||
.build();
|
||||
|
||||
Block.CreatePage.Request request = Block.CreatePage.Request
|
||||
.newBuilder()
|
||||
.setContextId(command.getContext())
|
||||
.setTargetId(command.getTarget())
|
||||
.setPosition(position)
|
||||
.setBlock(block)
|
||||
.build();
|
||||
|
||||
Timber.d("Creating new document with the following request:\n%s", request.toString());
|
||||
|
@ -424,16 +405,24 @@ public class Middleware {
|
|||
}
|
||||
|
||||
public void setIconName(CommandEntity.SetIconName command) throws Exception {
|
||||
Block.Set.Icon.Name.Request request = Block.Set.Icon.Name.Request
|
||||
|
||||
Value value = Value.newBuilder().setStringValue(command.getName()).build();
|
||||
|
||||
Block.Set.Details.Detail details = Block.Set.Details.Detail
|
||||
.newBuilder()
|
||||
.setBlockId(command.getTarget())
|
||||
.setContextId(command.getContext())
|
||||
.setName(command.getName())
|
||||
.setKey(iconKey)
|
||||
.setValue(value)
|
||||
.build();
|
||||
|
||||
Timber.d("Setting icon name with the following request:\n%s", request.toString());
|
||||
Block.Set.Details.Request request = Block.Set.Details.Request
|
||||
.newBuilder()
|
||||
.setContextId(command.getContext())
|
||||
.addDetails(details)
|
||||
.build();
|
||||
|
||||
service.blockSetIconName(request);
|
||||
Timber.d("Setting icon details with the following request:\n%s", request.toString());
|
||||
|
||||
service.blockSetDetails(request);
|
||||
}
|
||||
|
||||
public void setupBookmark(CommandEntity.SetupBookmark command) throws Exception {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.agileburo.anytype.middleware.interactor
|
|||
|
||||
import anytype.Events
|
||||
import com.agileburo.anytype.data.auth.event.EventRemoteChannel
|
||||
import com.agileburo.anytype.data.auth.model.BlockEntity
|
||||
import com.agileburo.anytype.data.auth.model.EventEntity
|
||||
import com.agileburo.anytype.middleware.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
@ -21,6 +22,7 @@ class MiddlewareEventChannel(
|
|||
Events.Event.Message.ValueCase.BLOCKADD,
|
||||
Events.Event.Message.ValueCase.BLOCKSETTEXT,
|
||||
Events.Event.Message.ValueCase.BLOCKSETCHILDRENIDS,
|
||||
Events.Event.Message.ValueCase.BLOCKSETBACKGROUNDCOLOR,
|
||||
Events.Event.Message.ValueCase.BLOCKDELETE,
|
||||
Events.Event.Message.ValueCase.BLOCKSETLINK,
|
||||
Events.Event.Message.ValueCase.BLOCKSETFILE,
|
||||
|
@ -53,8 +55,13 @@ class MiddlewareEventChannel(
|
|||
Events.Event.Message.ValueCase.BLOCKSHOW -> {
|
||||
EventEntity.Command.ShowBlock(
|
||||
context = context,
|
||||
rootId = event.blockShow.rootId,
|
||||
blocks = event.blockShow.blocksList.blocks()
|
||||
root = event.blockShow.rootId,
|
||||
blocks = event.blockShow.blocksList.blocks(),
|
||||
details = BlockEntity.Details(
|
||||
event.blockShow.detailsList.associate { details ->
|
||||
details.id to details.details.fields()
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
Events.Event.Message.ValueCase.BLOCKSETTEXT -> {
|
||||
|
@ -72,16 +79,19 @@ class MiddlewareEventChannel(
|
|||
event.blockSetText.color.value
|
||||
else
|
||||
null,
|
||||
backgroundColor = if (event.blockSetText.hasBackgroundColor())
|
||||
event.blockSetText.backgroundColor.value
|
||||
else
|
||||
null,
|
||||
marks = if (event.blockSetText.hasMarks())
|
||||
event.blockSetText.marks.value.marksList.marks()
|
||||
else
|
||||
null
|
||||
)
|
||||
}
|
||||
Events.Event.Message.ValueCase.BLOCKSETBACKGROUNDCOLOR -> {
|
||||
EventEntity.Command.GranularChange(
|
||||
context = context,
|
||||
id = event.blockSetBackgroundColor.id,
|
||||
backgroundColor = event.blockSetBackgroundColor.backgroundColor
|
||||
)
|
||||
}
|
||||
Events.Event.Message.ValueCase.BLOCKDELETE -> {
|
||||
EventEntity.Command.DeleteBlock(
|
||||
context = context,
|
||||
|
|
|
@ -4,7 +4,6 @@ import anytype.Commands.Rpc.Account;
|
|||
import anytype.Commands.Rpc.Block;
|
||||
import anytype.Commands.Rpc.BlockList;
|
||||
import anytype.Commands.Rpc.Config;
|
||||
import anytype.Commands.Rpc.Ipfs.Image;
|
||||
import anytype.Commands.Rpc.Wallet;
|
||||
import lib.Lib;
|
||||
|
||||
|
@ -87,17 +86,6 @@ public class DefaultMiddlewareService implements MiddlewareService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image.Get.Blob.Response imageGet(Image.Get.Blob.Request request) throws Exception {
|
||||
byte[] encoded = Lib.imageGetBlob(request.toByteArray());
|
||||
Image.Get.Blob.Response response = Image.Get.Blob.Response.parseFrom(encoded);
|
||||
if (response.getError() != null && response.getError().getCode() != Image.Get.Blob.Response.Error.Code.NULL) {
|
||||
throw new Exception(response.getError().getDescription());
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.Open.Response blockOpen(Block.Open.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockOpen(request.toByteArray());
|
||||
|
@ -187,10 +175,10 @@ public class DefaultMiddlewareService implements MiddlewareService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Block.Set.Text.BackgroundColor.Response blockSetTextBackgroundColor(Block.Set.Text.BackgroundColor.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockSetTextBackgroundColor(request.toByteArray());
|
||||
Block.Set.Text.BackgroundColor.Response response = Block.Set.Text.BackgroundColor.Response.parseFrom(encoded);
|
||||
if (response.getError() != null && response.getError().getCode() != Block.Set.Text.BackgroundColor.Response.Error.Code.NULL) {
|
||||
public BlockList.Set.BackgroundColor.Response blockSetTextBackgroundColor(BlockList.Set.BackgroundColor.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockListSetBackgroundColor(request.toByteArray());
|
||||
BlockList.Set.BackgroundColor.Response response = BlockList.Set.BackgroundColor.Response.parseFrom(encoded);
|
||||
if (response.getError() != null && response.getError().getCode() != BlockList.Set.BackgroundColor.Response.Error.Code.NULL) {
|
||||
throw new Exception(response.getError().getDescription());
|
||||
} else {
|
||||
return response;
|
||||
|
@ -263,17 +251,6 @@ public class DefaultMiddlewareService implements MiddlewareService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.Set.Icon.Name.Response blockSetIconName(Block.Set.Icon.Name.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockSetIconName(request.toByteArray());
|
||||
Block.Set.Icon.Name.Response response = Block.Set.Icon.Name.Response.parseFrom(encoded);
|
||||
if (response.getError() != null && response.getError().getCode() != Block.Set.Icon.Name.Response.Error.Code.NULL) {
|
||||
throw new Exception(response.getError().getDescription());
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.Bookmark.Fetch.Response blockBookmarkFetch(Block.Bookmark.Fetch.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockBookmarkFetch(request.toByteArray());
|
||||
|
@ -317,4 +294,15 @@ public class DefaultMiddlewareService implements MiddlewareService {
|
|||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.Set.Details.Response blockSetDetails(Block.Set.Details.Request request) throws Exception {
|
||||
byte[] encoded = Lib.blockSetDetails(request.toByteArray());
|
||||
Block.Set.Details.Response response = Block.Set.Details.Response.parseFrom(encoded);
|
||||
if (response.getError() != null && response.getError().getCode() != Block.Set.Details.Response.Error.Code.NULL) {
|
||||
throw new Exception(response.getError().getDescription());
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import anytype.Commands.Rpc.Account;
|
|||
import anytype.Commands.Rpc.Block;
|
||||
import anytype.Commands.Rpc.BlockList;
|
||||
import anytype.Commands.Rpc.Config;
|
||||
import anytype.Commands.Rpc.Ipfs.Image;
|
||||
import anytype.Commands.Rpc.Wallet;
|
||||
|
||||
/**
|
||||
|
@ -25,8 +24,6 @@ public interface MiddlewareService {
|
|||
|
||||
Account.Stop.Response accountStop(Account.Stop.Request request) throws Exception;
|
||||
|
||||
Image.Get.Blob.Response imageGet(Image.Get.Blob.Request request) throws Exception;
|
||||
|
||||
Block.Open.Response blockOpen(Block.Open.Request request) throws Exception;
|
||||
|
||||
Block.Close.Response blockClose(Block.Close.Request request) throws Exception;
|
||||
|
@ -41,7 +38,7 @@ public interface MiddlewareService {
|
|||
|
||||
Block.Set.Text.Color.Response blockSetTextColor(Block.Set.Text.Color.Request request) throws Exception;
|
||||
|
||||
Block.Set.Text.BackgroundColor.Response blockSetTextBackgroundColor(Block.Set.Text.BackgroundColor.Request request) throws Exception;
|
||||
BlockList.Set.BackgroundColor.Response blockSetTextBackgroundColor(BlockList.Set.BackgroundColor.Request request) throws Exception;
|
||||
|
||||
Block.Set.Text.Style.Response blockSetTextStyle(Block.Set.Text.Style.Request request) throws Exception;
|
||||
|
||||
|
@ -55,8 +52,6 @@ public interface MiddlewareService {
|
|||
|
||||
BlockList.Duplicate.Response blockListDuplicate(BlockList.Duplicate.Request request) throws Exception;
|
||||
|
||||
Block.Set.Icon.Name.Response blockSetIconName(Block.Set.Icon.Name.Request request) throws Exception;
|
||||
|
||||
Block.Bookmark.Fetch.Response blockBookmarkFetch(Block.Bookmark.Fetch.Request request) throws Exception;
|
||||
|
||||
Block.Upload.Response blockUpload(Block.Upload.Request request) throws Exception;
|
||||
|
@ -66,4 +61,6 @@ public interface MiddlewareService {
|
|||
Block.Redo.Response blockRedo(Block.Redo.Request request) throws Exception;
|
||||
|
||||
Block.Set.Page.IsArchived.Response blockSetPageIsArchived(Block.Set.Page.IsArchived.Request request) throws Exception;
|
||||
|
||||
Block.Set.Details.Response blockSetDetails(Block.Set.Details.Request request) throws Exception;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class MiddlewareEventChannelTest {
|
|||
|
||||
val expected = listOf(
|
||||
EventEntity.Command.ShowBlock(
|
||||
rootId = context,
|
||||
root = context,
|
||||
blocks = emptyList(),
|
||||
context = context
|
||||
)
|
||||
|
@ -137,7 +137,7 @@ class MiddlewareEventChannelTest {
|
|||
|
||||
val expected = listOf(
|
||||
EventEntity.Command.ShowBlock(
|
||||
rootId = context,
|
||||
root = context,
|
||||
blocks = emptyList(),
|
||||
context = context
|
||||
)
|
||||
|
@ -257,4 +257,50 @@ class MiddlewareEventChannelTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should return granular change with background colour`() {
|
||||
|
||||
val context = MockDataFactory.randomUuid()
|
||||
val id = MockDataFactory.randomUuid()
|
||||
val color = MockDataFactory.randomString()
|
||||
|
||||
val msg = Message
|
||||
.newBuilder()
|
||||
.blockSetBackgroundColorBuilder
|
||||
.setId(id)
|
||||
.setBackgroundColor(color)
|
||||
.build()
|
||||
|
||||
val message = Message
|
||||
.newBuilder()
|
||||
.setBlockSetBackgroundColor(msg)
|
||||
|
||||
val event = Event
|
||||
.newBuilder()
|
||||
.setContextId(context)
|
||||
.addMessages(message)
|
||||
.build()
|
||||
|
||||
proxy.stub {
|
||||
on { flow() } doReturn flowOf(event)
|
||||
}
|
||||
|
||||
val expected = listOf(
|
||||
EventEntity.Command.GranularChange(
|
||||
context = context,
|
||||
id = id,
|
||||
backgroundColor = color
|
||||
)
|
||||
)
|
||||
|
||||
runBlocking {
|
||||
channel.observeEvents(context = context).collect { events ->
|
||||
assertEquals(
|
||||
expected = expected,
|
||||
actual = events
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.agileburo.anytype.middleware.interactor.Middleware
|
|||
import com.agileburo.anytype.middleware.interactor.MiddlewareFactory
|
||||
import com.agileburo.anytype.middleware.interactor.MiddlewareMapper
|
||||
import com.agileburo.anytype.middleware.service.MiddlewareService
|
||||
import com.google.protobuf.Value
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
@ -67,14 +68,6 @@ class MiddlewareTest {
|
|||
.setContextId(command.context)
|
||||
.setTargetId(command.target)
|
||||
.setPosition(Models.Block.Position.Inner)
|
||||
.setBlock(
|
||||
Models.Block.newBuilder()
|
||||
.setPage(
|
||||
Models.Block.Content.Page
|
||||
.newBuilder()
|
||||
.setStyle(Models.Block.Content.Page.Style.Empty)
|
||||
)
|
||||
)
|
||||
.build()
|
||||
|
||||
service.stub {
|
||||
|
@ -141,4 +134,38 @@ class MiddlewareTest {
|
|||
actual = result
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should set emoji icon by updating document details`() {
|
||||
|
||||
val command = CommandEntity.SetIconName(
|
||||
context = MockDataFactory.randomUuid(),
|
||||
target = MockDataFactory.randomUuid(),
|
||||
name = MockDataFactory.randomString()
|
||||
)
|
||||
|
||||
val response = Block.Set.Details.Response.getDefaultInstance()
|
||||
|
||||
val key = "icon"
|
||||
|
||||
val value = Value.newBuilder().setStringValue(command.name)
|
||||
|
||||
val details = Block.Set.Details.Detail.newBuilder()
|
||||
.setKey(key)
|
||||
.setValue(value)
|
||||
|
||||
val request = Block.Set.Details.Request.newBuilder()
|
||||
.setContextId(command.context)
|
||||
.addDetails(details)
|
||||
.build()
|
||||
|
||||
service.stub {
|
||||
on { blockSetDetails(any()) } doReturn response
|
||||
}
|
||||
|
||||
middleware.setIconName(command)
|
||||
|
||||
verify(service, times(1)).blockSetDetails(request)
|
||||
verifyNoMoreInteractions(service)
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ class HomeDashboardViewModel(
|
|||
)
|
||||
)
|
||||
is Event.Command.ShowBlock -> {
|
||||
if (event.rootId == context) {
|
||||
if (event.root == context) {
|
||||
machine.onEvent(
|
||||
Machine.Event.OnDashboardLoaded(
|
||||
dashboard = event.blocks.toHomeDashboard(id = context)
|
||||
|
|
|
@ -755,7 +755,7 @@ class PageViewModel(
|
|||
scope = viewModelScope,
|
||||
params = UpdateBackgroundColor.Params(
|
||||
context = context,
|
||||
target = focus,
|
||||
targets = listOf(focus),
|
||||
color = color
|
||||
)
|
||||
) { result ->
|
||||
|
@ -1039,6 +1039,8 @@ class PageViewModel(
|
|||
Timber.d("Outside-click has been ignored.")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addNewBlockAtTheEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ class HomeDashboardViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = config.home,
|
||||
root = config.home,
|
||||
context = config.home,
|
||||
blocks = listOf(dashboard, page)
|
||||
)
|
||||
|
@ -308,7 +308,7 @@ class HomeDashboardViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = config.home,
|
||||
root = config.home,
|
||||
context = config.home,
|
||||
blocks = listOf(dashboard) + pages
|
||||
)
|
||||
|
@ -655,7 +655,7 @@ class HomeDashboardViewModelTest {
|
|||
)
|
||||
|
||||
val showDashboardEvent = Event.Command.ShowBlock(
|
||||
rootId = config.home,
|
||||
root = config.home,
|
||||
context = config.home,
|
||||
blocks = listOf(dashboard, page)
|
||||
)
|
||||
|
|
|
@ -196,7 +196,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -390,7 +390,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -493,7 +493,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -600,7 +600,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -740,7 +740,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -876,7 +876,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -967,7 +967,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -1065,7 +1065,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -1149,7 +1149,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = blocks,
|
||||
context = root
|
||||
)
|
||||
|
@ -1213,7 +1213,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1260,7 +1260,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1343,7 +1343,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = listOf(page, paragraph),
|
||||
context = root
|
||||
)
|
||||
|
@ -1413,7 +1413,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1480,7 +1480,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1591,7 +1591,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = listOf(page, paragraph),
|
||||
context = root
|
||||
)
|
||||
|
@ -1678,7 +1678,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1721,7 +1721,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1764,7 +1764,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1823,7 +1823,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1901,7 +1901,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1947,7 +1947,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -1988,7 +1988,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2040,7 +2040,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2093,7 +2093,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2137,7 +2137,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2191,7 +2191,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2238,7 +2238,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2294,7 +2294,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2355,7 +2355,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2416,7 +2416,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2479,7 +2479,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2534,7 +2534,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2592,7 +2592,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2657,7 +2657,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2709,7 +2709,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2768,7 +2768,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2820,7 +2820,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2888,7 +2888,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -2958,7 +2958,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3028,7 +3028,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3096,7 +3096,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3164,7 +3164,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3220,7 +3220,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3276,7 +3276,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3335,7 +3335,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3410,7 +3410,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3487,7 +3487,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3574,7 +3574,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
@ -3620,7 +3620,7 @@ class PageViewModelTest {
|
|||
emit(
|
||||
listOf(
|
||||
Event.Command.ShowBlock(
|
||||
rootId = root,
|
||||
root = root,
|
||||
blocks = page,
|
||||
context = root
|
||||
)
|
||||
|
|
|
@ -17,8 +17,9 @@ message Rpc {
|
|||
message Files {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
string focusedBlockId = 2; // can be null
|
||||
repeated string localFilePaths = 3;
|
||||
string dropTargetId = 2;
|
||||
anytype.model.Block.Position position = 3;
|
||||
repeated string localFilePaths = 4;
|
||||
}
|
||||
|
||||
message Response {
|
||||
|
@ -91,6 +92,33 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message MoveToNewPage {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated string blockIds = 2;
|
||||
anytype.model.Block block = 3;
|
||||
string dropTargetId = 4; // id of the block in Page(contextId) to create a link near that block
|
||||
anytype.model.Block.Position position = 5;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string linkId = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Makes blocks copy by given ids and paste it to shown place
|
||||
*/
|
||||
|
@ -168,26 +196,50 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
}
|
||||
message BackgroundColor {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated string blockIds = 2;
|
||||
string color = 3;
|
||||
}
|
||||
|
||||
message BackgroundColor {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated string blockIds = 2;
|
||||
string color = 3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
message Align {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated string blockIds = 2;
|
||||
anytype.model.Block.Align align = 3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,11 +302,13 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
message Split {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
string blockId = 2;
|
||||
int32 cursorPosition = 3;
|
||||
anytype.model.Block.Content.Text.Style style = 4;
|
||||
}
|
||||
|
||||
message Response {
|
||||
|
@ -303,14 +357,12 @@ message Rpc {
|
|||
message Copy {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated string blockIds = 2;
|
||||
repeated anytype.model.Block blocks = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string clipboardText = 2;
|
||||
string clipboardHtml = 3;
|
||||
// string clipboardAny = 4; Client already knows blockIds
|
||||
string html = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
|
@ -340,6 +392,57 @@ message Rpc {
|
|||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
repeated string blockIds = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Cut {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated anytype.model.Block blocks = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string textSlot = 2;
|
||||
string htmlSlot = 3;
|
||||
repeated anytype.model.Block anySlot = 4;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Export {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated anytype.model.Block blocks = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string path = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
|
@ -427,6 +530,31 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
}
|
||||
message Details {
|
||||
message Detail {
|
||||
string key = 1;
|
||||
google.protobuf.Value value = 2; // NUll - removes key
|
||||
}
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
repeated Detail details = 2;
|
||||
}
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
message Restrictions {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
|
@ -527,29 +655,6 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message BackgroundColor {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
string blockId = 2;
|
||||
string color = 3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Style {
|
||||
message Request {
|
||||
|
@ -726,32 +831,6 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message Icon {
|
||||
message Name {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
string blockId = 2;
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Link {
|
||||
message TargetBlockId {
|
||||
message Request {
|
||||
|
@ -1011,7 +1090,7 @@ message Rpc {
|
|||
message Request {
|
||||
string contextId = 1; // id of the context block
|
||||
string targetId = 2; // id of the closest block
|
||||
anytype.model.Block block = 3; // page block
|
||||
google.protobuf.Struct details = 3; // page details
|
||||
anytype.model.Block.Position position = 4;
|
||||
}
|
||||
|
||||
|
@ -1513,6 +1592,30 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message Process {
|
||||
message Cancel {
|
||||
message Request {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message LinkPreview {
|
||||
message Request {
|
||||
string url = 1;
|
||||
|
@ -1535,6 +1638,30 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message UploadFile {
|
||||
message Request {
|
||||
string url = 1;
|
||||
string localPath = 2;
|
||||
anytype.model.Block.Content.File.Type type = 3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string hash = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message Empty {
|
||||
|
|
|
@ -25,12 +25,14 @@ message Event {
|
|||
Block.Set.Fields blockSetFields = 6;
|
||||
Block.Set.ChildrenIds blockSetChildrenIds = 7;
|
||||
Block.Set.Restrictions blockSetRestrictions = 8;
|
||||
Block.Set.BackgroundColor blockSetBackgroundColor = 9;
|
||||
|
||||
Block.Set.Text blockSetText = 10;
|
||||
Block.Set.File blockSetFile = 11;
|
||||
Block.Set.Icon blockSetIcon = 12;
|
||||
Block.Set.Link blockSetLink = 13;
|
||||
Block.Set.Bookmark blockSetBookmark = 14;
|
||||
Block.Set.Align blockSetAlign = 15;
|
||||
Block.Set.Details blockSetDetails = 16;
|
||||
|
||||
Block.Show blockShow = 20;
|
||||
User.Block.Join userBlockJoin = 21;
|
||||
|
@ -39,6 +41,10 @@ message Event {
|
|||
User.Block.TextRange userBlockTextRange = 24;
|
||||
|
||||
Ping ping = 100;
|
||||
|
||||
Process.New processNew = 101;
|
||||
Process.Update processUpdate = 102;
|
||||
Process.Done processDone = 103;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +81,7 @@ message Event {
|
|||
message Show {
|
||||
string rootId = 1; // Root block id
|
||||
repeated anytype.model.Block blocks = 2; // dependent blocks (descendants)
|
||||
repeated Block.Set.Details details = 3; // details for current and dependent smart blocks
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +93,6 @@ message Event {
|
|||
message FilesUpload {
|
||||
string blockId = 1; // if empty => create new blocks
|
||||
repeated string filePath = 2; // filepaths to the files
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -102,6 +108,11 @@ message Event {
|
|||
|
||||
message Set {
|
||||
|
||||
message Details {
|
||||
string id = 1;
|
||||
google.protobuf.Struct details = 2;
|
||||
}
|
||||
|
||||
message Fields {
|
||||
string id = 1;
|
||||
google.protobuf.Struct fields = 2;
|
||||
|
@ -117,6 +128,16 @@ message Event {
|
|||
anytype.model.Block.Restrictions restrictions = 2;
|
||||
}
|
||||
|
||||
message BackgroundColor {
|
||||
string id = 1;
|
||||
string backgroundColor = 2;
|
||||
}
|
||||
|
||||
message Align {
|
||||
string id = 1;
|
||||
anytype.model.Block.Align align = 2;
|
||||
}
|
||||
|
||||
|
||||
message Text {
|
||||
string id = 1;
|
||||
|
@ -125,7 +146,6 @@ message Event {
|
|||
Marks marks = 4;
|
||||
Checked checked = 5;
|
||||
Color color = 6;
|
||||
BackgroundColor backgroundColor = 7;
|
||||
|
||||
message TText {
|
||||
string value = 1;
|
||||
|
@ -147,9 +167,6 @@ message Event {
|
|||
string value = 1;
|
||||
}
|
||||
|
||||
message BackgroundColor {
|
||||
string value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message File {
|
||||
|
@ -190,14 +207,6 @@ message Event {
|
|||
}
|
||||
}
|
||||
|
||||
message Icon {
|
||||
string id = 1;
|
||||
Name name = 2;
|
||||
|
||||
message Name {
|
||||
string value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message Link {
|
||||
string id = 1;
|
||||
|
@ -307,4 +316,43 @@ message Event {
|
|||
message Ping {
|
||||
int32 index = 1;
|
||||
}
|
||||
|
||||
message Process {
|
||||
message New {
|
||||
Model.Process process = 1;
|
||||
}
|
||||
message Update {
|
||||
Model.Process process = 1;
|
||||
}
|
||||
message Done {
|
||||
Model.Process process = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message Model {
|
||||
message Process {
|
||||
string id = 1;
|
||||
Type type = 2;
|
||||
State state = 3;
|
||||
Progress progress = 4;
|
||||
|
||||
enum Type {
|
||||
DropFiles = 0;
|
||||
}
|
||||
|
||||
enum State {
|
||||
None = 0;
|
||||
Running = 1;
|
||||
Done = 2;
|
||||
Canceled = 3;
|
||||
Error = 4;
|
||||
}
|
||||
|
||||
message Progress {
|
||||
int64 total = 1;
|
||||
int64 done = 2;
|
||||
}
|
||||
}
|
||||
}
|
27
protobuf/src/main/proto/models.proto
Normal file → Executable file
27
protobuf/src/main/proto/models.proto
Normal file → Executable file
|
@ -4,12 +4,25 @@ option go_package = "github.com/anytypeio/go-anytype-library/pb/model";
|
|||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
message SmartBlock {
|
||||
string id = 1;
|
||||
Type type = 2;
|
||||
enum Type {
|
||||
Dashboard = 0;
|
||||
Page = 1;
|
||||
Archive = 2;
|
||||
Breadcrumbs = 3;
|
||||
Dataview = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Block {
|
||||
string id = 1;
|
||||
google.protobuf.Struct fields = 2;
|
||||
Restrictions restrictions = 3;
|
||||
repeated string childrenIds = 4;
|
||||
|
||||
string backgroundColor = 5;
|
||||
Align align = 6;
|
||||
|
||||
oneof content {
|
||||
Content.Dashboard dashboard = 11;
|
||||
|
@ -44,6 +57,12 @@ message Block {
|
|||
Replace = 6;
|
||||
}
|
||||
|
||||
enum Align {
|
||||
AlignLeft = 0;
|
||||
AlignCenter = 1;
|
||||
AlignRight = 2;
|
||||
}
|
||||
|
||||
message Content {
|
||||
/*
|
||||
* Layout have no visual representation, but affects on blocks, that it contains.
|
||||
|
@ -125,7 +144,6 @@ message Block {
|
|||
Marks marks = 3; // list of marks to apply to the text
|
||||
bool checked = 4;
|
||||
string color = 5;
|
||||
string backgroundColor = 6;
|
||||
|
||||
message Marks {
|
||||
repeated Mark marks = 1;
|
||||
|
@ -194,7 +212,10 @@ message Block {
|
|||
Empty = 0; // Ordinary page, without additional fields
|
||||
Task = 1; // Page with a task fields
|
||||
Set = 2; // Page, that organize a set of blocks by a specific criterio
|
||||
Breadcrumbs = 3;
|
||||
Profile = 3;
|
||||
|
||||
Breadcrumbs = 101;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue