1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

Tech | MW 0.17.0 (#1861)

This commit is contained in:
Konstantin Ivanov 2021-10-21 12:22:24 +03:00 committed by GitHub
parent 56b6631268
commit 7a92f3aac3
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 242 additions and 179 deletions

View file

@ -139,7 +139,9 @@ data class Block(
LINK,
TEXT_COLOR,
BACKGROUND_COLOR,
MENTION
MENTION,
EMOJI,
OBJECT
}
}

View file

@ -32,6 +32,7 @@ data class ObjectType(
DASHBOARD(7),
IMAGE(8),
NOTE(9),
SPACE(10),
DATABASE(20)
}

View file

@ -272,6 +272,7 @@ fun ObjectLayoutView.getIconSize24(): Int? = when (this) {
is ObjectLayoutView.File -> null
is ObjectLayoutView.ObjectType -> null
is ObjectLayoutView.Relation -> null
is ObjectLayoutView.Space -> null
}
fun ObjectLayoutView.getName(): Int? = when (this) {
@ -286,4 +287,5 @@ fun ObjectLayoutView.getName(): Int? = when (this) {
is ObjectLayoutView.File -> null
is ObjectLayoutView.ObjectType -> null
is ObjectLayoutView.Relation -> null
is ObjectLayoutView.Space -> null
}

View file

@ -87,7 +87,7 @@ ext {
// Anytype
middleware_version = 'v0.16.3'
middleware_version = 'v0.17.0'
mainApplication = [
kotlin: "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",

View file

@ -301,6 +301,8 @@ fun MBMarkType.toCoreModels(): Block.Content.Text.Mark.Type = when (this) {
MBMarkType.TextColor -> Block.Content.Text.Mark.Type.TEXT_COLOR
MBMarkType.BackgroundColor -> Block.Content.Text.Mark.Type.BACKGROUND_COLOR
MBMarkType.Mention -> Block.Content.Text.Mark.Type.MENTION
MBMarkType.Emoji -> Block.Content.Text.Mark.Type.EMOJI
MBMarkType.Object -> Block.Content.Text.Mark.Type.OBJECT
}
@ -423,6 +425,7 @@ fun MOTypeLayout.toCoreModels(): ObjectType.Layout = when (this) {
MOTypeLayout.database -> ObjectType.Layout.DATABASE
MOTypeLayout.image -> ObjectType.Layout.IMAGE
MOTypeLayout.note -> ObjectType.Layout.NOTE
MOTypeLayout.space -> ObjectType.Layout.SPACE
}
fun MRelationDataSource.source(): Relation.Source = when (this) {

View file

@ -314,6 +314,7 @@ fun ObjectType.Layout.toMiddlewareModel(): MOTypeLayout = when (this) {
ObjectType.Layout.DATABASE -> MOTypeLayout.database
ObjectType.Layout.IMAGE -> MOTypeLayout.image
ObjectType.Layout.NOTE -> MOTypeLayout.note
ObjectType.Layout.SPACE -> MOTypeLayout.space
}
fun Relation.Format.toMiddlewareModel(): MRelationFormat = when (this) {

View file

@ -93,9 +93,6 @@ interface MiddlewareService {
@Throws(Exception::class)
fun blockRedo(request: Block.Redo.Request): Block.Redo.Response
@Throws(Exception::class)
fun blockListSetPageIsArchived(request: BlockList.Set.Page.IsArchived.Request): BlockList.Set.Page.IsArchived.Response
@Throws(Exception::class)
fun blockSetDetails(request: Block.Set.Details.Request): Block.Set.Details.Response

View file

@ -350,19 +350,6 @@ class MiddlewareServiceImplementation : MiddlewareService {
}
}
override fun blockListSetPageIsArchived(request: BlockList.Set.Page.IsArchived.Request): BlockList.Set.Page.IsArchived.Response {
val encoded = Service.blockListSetPageIsArchived(
BlockList.Set.Page.IsArchived.Request.ADAPTER.encode(request)
)
val response = BlockList.Set.Page.IsArchived.Response.ADAPTER.decode(encoded)
val error = response.error
if (error != null && error.code != BlockList.Set.Page.IsArchived.Response.Error.Code.NULL) {
throw Exception(error.description)
} else {
return response
}
}
override fun blockSetDetails(request: Block.Set.Details.Request): Block.Set.Details.Response {
val encoded = Service.blockSetDetails(Block.Set.Details.Request.ADAPTER.encode(request))
val response = Block.Set.Details.Response.ADAPTER.decode(encoded)

View file

@ -721,5 +721,6 @@ fun List<ObjectType.Layout>.toView(): List<ObjectLayoutView> = map { layout ->
ObjectType.Layout.IMAGE -> ObjectLayoutView.Image(id = layout.code, isSelected = false)
ObjectType.Layout.NOTE -> ObjectLayoutView.Note(id = layout.code, isSelected = false)
ObjectType.Layout.DATABASE -> ObjectLayoutView.Database(id = layout.code, isSelected = false)
ObjectType.Layout.SPACE -> ObjectLayoutView.Space(id = layout.code, isSelected = false)
}
}

View file

@ -87,4 +87,11 @@ sealed class ObjectLayoutView {
) : ObjectLayoutView() {
override fun copy(isSelected: Boolean) = copy(id = id, isSelected = isSelected)
}
data class Space(
override val id: Int,
override val isSelected: Boolean
) : ObjectLayoutView() {
override fun copy(isSelected: Boolean) = copy(id = id, isSelected = isSelected)
}
}

View file

@ -180,55 +180,6 @@ message Rpc {
}
message Set {
message Page {
message IsArchived {
message Request {
string contextId = 1;
repeated string blockIds = 2;
bool isArchived = 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 IsFavorite {
message Request {
string contextId = 1;
repeated string blockIds = 2;
bool isFavorite = 3;
}
message Response {
Error error = 1;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
}
}
}
}
}
// commands acceptable only for text blocks, others will be ignored
message Text {
message Style {
@ -409,32 +360,6 @@ message Rpc {
}
message Delete {
// Deletes the page, keys and all records from the local store and unsubscribe from remote changes
message Page {
message Request {
repeated string blockIds = 1; // pages to remove
}
message Response {
Error error = 1;
ResponseEvent event = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
}
}
}
}
}
message TurnInto {
message Request {
@ -1702,6 +1627,29 @@ message Rpc {
}
}
message SetSource {
message Request {
string contextId = 1;
string blockId = 2;
repeated string source = 3;
}
message Response {
Error error = 1;
ResponseEvent event = 4;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
}
}
}
}
}
message Get {
@ -2091,7 +2039,7 @@ message Rpc {
}
message Workspace {
message Create {
message GetCurrent {
message Request {
}
@ -2113,6 +2061,74 @@ message Rpc {
}
}
message GetAll {
message Request {
}
message Response {
Error error = 1;
repeated string workspaceIds = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
}
}
}
}
message Create {
message Request {
string name = 1;
}
message Response {
Error error = 1;
string workspaceId = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
}
}
}
}
message SetIsHighlighted {
message Request {
string objectId = 1;
bool isHighlighted = 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 Select {
message Request {
string workspaceId = 1;
@ -2458,98 +2474,60 @@ message Rpc {
}
}
/*
* Namespace, that agregates subtopics and actions to work with IPFS directly (get files, blobs, images, etc)
*/
message Ipfs {
message File {
message Get {
message Request {
string id = 1;
message File {
message Offload {
message Request {
string id = 1;
bool includeNotPinned = 2;
}
message Response {
Error error = 1;
uint64 bytesOffloaded = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
NODE_NOT_STARTED = 103;
FILE_NOT_YET_PINNED = 104;
}
}
}
}
}
message FileList {
message Offload {
message Request {
repeated string onlyIds = 1; // empty means all
bool includeNotPinned = 2; // false mean not-yet-pinned files will be not
}
message Response {
Error error = 1;
bytes data = 2;
string media = 3;
string name = 4;
message Error {
Code code = 1;
string description = 2;
message Response {
Error error = 1;
int32 filesOffloaded = 2;
uint64 bytesOffloaded = 3;
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;
// ...
NODE_NOT_STARTED = 103;
NOT_FOUND = 101;
TIMEOUT = 102;
}
}
}
}
}
message Image {
message Get {
message Blob {
message Request {
string hash = 1;
int32 wantWidth = 2;
}
message Response {
Error error = 1;
bytes blob = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
NOT_FOUND = 101;
TIMEOUT = 102;
NODE_NOT_STARTED = 103;
}
}
}
}
message File {
message Request {
string hash = 1;
int32 wantWidth = 2;
}
message Response {
Error error = 1;
string localPath = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
NOT_FOUND = 101;
TIMEOUT = 102;
NODE_NOT_STARTED = 103;
}
}
}
}
}
}
}
message Shutdown {
@ -3093,9 +3071,10 @@ message Rpc {
}
}
message AddWithShareLink {
message AddWithObjectId {
message Request {
string link = 1;
string objectId = 1;
string payload = 2;
}
message Response {
@ -3510,6 +3489,77 @@ message Rpc {
}
}
message ObjectList {
message Delete {
// Deletes the object, keys from the local store and unsubscribe from remote changes. Also offloads all orphan files
message Request {
repeated string objectIds = 1; // objects to remove
}
message Response {
Error error = 1;
ResponseEvent event = 2;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
// ...
}
}
}
}
message Set {
message IsArchived {
message Request {
repeated string objectIds = 1;
bool isArchived = 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 IsFavorite {
message Request {
repeated string objectIds = 1;
bool isFavorite = 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 Export {
message Request {
// the path where export files will place

View file

@ -74,12 +74,20 @@ message Block {
enum Position {
None = 0;
// above target block
Top = 1;
// under target block
Bottom = 2;
// to left of target block
Left = 3;
// to right of target block
Right = 4;
// inside target block, as last block
Inner = 5;
// replace target block
Replace = 6;
// inside target block, as first block
InnerFirst = 7;
}
enum Align {
@ -178,6 +186,8 @@ message Block {
TextColor = 6;
BackgroundColor = 7;
Mention = 8;
Emoji = 9;
Object = 10;
}
}
@ -453,6 +463,7 @@ message ObjectType {
dashboard = 7;
image = 8;
note = 9;
space = 10;
database = 20; // to be released later
}
@ -521,6 +532,7 @@ message Relation {
details = 0; // default, stored inside the object's details
derived = 1; // stored locally, e.g. in badger or generated on the fly
account = 2; // stored in the account DB. means existing only for specific anytype account
local = 3; // stored locally
}
}