1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00
anytype-heart/docs/proto.md
2019-11-06 20:37:55 +03:00

54 KiB
Raw Blame History

Protocol Documentation

Table of Contents

Top

service/service.proto

ClientCommands

Method Name Request Type Response Type Description
WalletCreate Rpc.Wallet.Create.Request Rpc.Wallet.Create.Response
WalletRecover Rpc.Wallet.Recover.Request Rpc.Wallet.Recover.Response
AccountRecover Rpc.Account.Recover.Request Rpc.Account.Recover.Response
AccountCreate Rpc.Account.Create.Request Rpc.Account.Create.Response
AccountSelect Rpc.Account.Select.Request Rpc.Account.Select.Response
ImageGetBlob Rpc.Image.Get.Blob.Request Rpc.Image.Get.Blob.Response
VersionGet Rpc.Version.Get.Request Rpc.Version.Get.Response
LogSend Rpc.Log.Send.Request Rpc.Log.Send.Response
BlockOpen Rpc.Block.Open.Request Rpc.Block.Open.Response
BlockCreate Rpc.Block.Create.Request Rpc.Block.Create.Response
BlockUpdate Rpc.Block.Update.Request Rpc.Block.Update.Response
BlockHistoryMove Rpc.Block.History.Move.Request Rpc.Block.History.Move.Response rpc BlockFilesUpload (Block Rpc.History.Move.Request) returns (BlockRpc..History Move.Response);

Top

changes.proto

BlockChanges

Field Type Label Description
changes BlocksListSingleChange repeated

BlocksListSingleChange

Field Type Label Description
id string repeated
text Change.Block.Content.Text
blockHeader Change.Block.Header
blockChildren Change.Block.Children
page Change.Block.Content.Page
dashboard Change.Block.Content.Dashboard
media Change.Block.Content.Media

Change

Change.Block

Change.Block.Children

Field Type Label Description
children string repeated

Change.Block.Content

Change.Block.Content.Dashboard

Field Type Label Description
style Model.Block.Content.Dashboard.Style
header Model.Block.Header not a dashboard header  one of children

Change.Block.Content.Media

Field Type Label Description
link string
state Model.Block.Content.Media.State

Change.Block.Content.Page

Field Type Label Description
style Model.Block.Content.Page.Style
block Model.Block

Change.Block.Content.Text

Field Type Label Description
text string
style Model.Block.Content.Text.Style
marks Model.Block.Content.Text.Marks
toggleable bool
markerType Model.Block.Content.Text.MarkerType
checkable bool
checked bool

Change.Block.Header

Field Type Label Description
id string
type Model.Block.Header.Type
name string
icon string
permissions Model.Block.Header.Permissions

Top

commands.proto

Rpc

Rpc.Account

Rpc.Account.Create

Rpc.Account.Create.Request

Front end to middleware request-to-create-an account

Field Type Label Description
name string Account name
avatarLocalPath string Path to an image, that will be used as an avatar of this account
avatarColor string Avatar color as an alternative for avatar image

Rpc.Account.Create.Response

Middleware-to-front-end response for an account creation request, that can contain a NULL error and created account or a non-NULL error and an empty account

Field Type Label Description
error Rpc.Account.Create.Response.Error Error while trying to create an account
account Model.Account A newly created account; In case of a failure, i.e. error is non-NULL, the account model should contain empty/default-value fields

Rpc.Account.Create.Response.Error

Field Type Label Description
code Rpc.Account.Create.Response.Error.Code
description string

Rpc.Account.Recover

Rpc.Account.Recover.Request

Front end to middleware request-to-start-search of an accounts for a recovered mnemonic. Each of an account that would be found will come with an AccountAdd event

Rpc.Account.Recover.Response

Middleware-to-front-end response to an account recover request, that can contain a NULL error and created account or a non-NULL error and an empty account

Field Type Label Description
error Rpc.Account.Recover.Response.Error Error while trying to recover an account

Rpc.Account.Recover.Response.Error

Field Type Label Description
code Rpc.Account.Recover.Response.Error.Code
description string

Rpc.Account.Select

Rpc.Account.Select.Request

Front end to middleware request-to-launch-a specific account using account id and a root path User can select an account from those, that came with an AccountAdd events

Field Type Label Description
id string Id of a selected account
rootPath string Root path is optional, set if this is a first request

Rpc.Account.Select.Response

Middleware-to-front-end response for an account select request, that can contain a NULL error and selected account or a non-NULL error and an empty account

Field Type Label Description
error Rpc.Account.Select.Response.Error Error while trying to launch/select an account
account Model.Account Selected account

Rpc.Account.Select.Response.Error

Field Type Label Description
code Rpc.Account.Select.Response.Error.Code
description string

Rpc.Block

Rpc.Block.Create

Rpc.Block.Create.Request

Field Type Label Description
type Model.Block.Header.Type
contextBlockId string

Rpc.Block.Create.Response

Field Type Label Description
error Rpc.Block.Create.Response.Error

Rpc.Block.Create.Response.Error

Field Type Label Description
code Rpc.Block.Create.Response.Error.Code
description string

Rpc.Block.History

Rpc.Block.History.Move

Rpc.Block.History.Move.Request

Field Type Label Description
id string
contextBlockId string
moveForward bool

Rpc.Block.History.Move.Response

Field Type Label Description
error Rpc.Block.History.Move.Response.Error

Rpc.Block.History.Move.Response.Error

Field Type Label Description
code Rpc.Block.History.Move.Response.Error.Code
description string

Rpc.Block.Open

Rpc.Block.Open.Request

Field Type Label Description
id string

Rpc.Block.Open.Response

Field Type Label Description
error Rpc.Block.Open.Response.Error
blockHeader Model.Block.Header

Rpc.Block.Open.Response.Error

Field Type Label Description
code Rpc.Block.Open.Response.Error.Code
description string

Rpc.Block.Update

Rpc.Block.Update.Request

Field Type Label Description
changes BlockChanges

Rpc.Block.Update.Response

Field Type Label Description
error Rpc.Block.Update.Response.Error

Rpc.Block.Update.Response.Error

Field Type Label Description
code Rpc.Block.Update.Response.Error.Code
description string

Rpc.Image

Rpc.Image.Get

Rpc.Image.Get.Blob

Rpc.Image.Get.Blob.Request

Field Type Label Description
id string
size Model.Image.Size

Rpc.Image.Get.Blob.Response

Field Type Label Description
error Rpc.Image.Get.Blob.Response.Error
blob bytes

Rpc.Image.Get.Blob.Response.Error

Field Type Label Description
code Rpc.Image.Get.Blob.Response.Error.Code
description string

Rpc.Image.Get.File

Rpc.Image.Get.File.Request

Field Type Label Description
id string
size Model.Image.Size

Rpc.Image.Get.File.Response

Field Type Label Description
error Rpc.Image.Get.File.Response.Error
localPath string

Rpc.Image.Get.File.Response.Error

Field Type Label Description
code Rpc.Image.Get.File.Response.Error.Code
description string

Rpc.Ipfs

Rpc.Ipfs.Get

Rpc.Ipfs.Get.File

Rpc.Ipfs.Get.File.Request

Field Type Label Description
id string

Rpc.Ipfs.Get.File.Response

Field Type Label Description
error Rpc.Ipfs.Get.File.Response.Error
data bytes
media string
name string

Rpc.Ipfs.Get.File.Response.Error

Field Type Label Description
code Rpc.Ipfs.Get.File.Response.Error.Code
description string

Rpc.Log

Rpc.Log.Send

Rpc.Log.Send.Request

Field Type Label Description
message string
level Rpc.Log.Send.Request.Level

Rpc.Log.Send.Response

Field Type Label Description
error Rpc.Log.Send.Response.Error

Rpc.Log.Send.Response.Error

Field Type Label Description
code Rpc.Log.Send.Response.Error.Code
description string

Rpc.Version

Rpc.Version.Get

Rpc.Version.Get.Request

Rpc.Version.Get.Response

Field Type Label Description
error Rpc.Version.Get.Response.Error
version string

Rpc.Version.Get.Response.Error

Field Type Label Description
code Rpc.Version.Get.Response.Error.Code
description string

Rpc.Wallet

Rpc.Wallet.Create

Rpc.Wallet.Create.Request

Front-end-to-middleware request to create a new wallet

Field Type Label Description
rootPath string Path to a wallet directory

Rpc.Wallet.Create.Response

Middleware-to-front-end response, that can contain mnemonic of a created account and a NULL error or an empty mnemonic and a non-NULL error

Field Type Label Description
error Rpc.Wallet.Create.Response.Error
mnemonic string Mnemonic of a new account (sequence of words, divided by spaces)

Rpc.Wallet.Create.Response.Error

Field Type Label Description
code Rpc.Wallet.Create.Response.Error.Code
description string

Rpc.Wallet.Recover

Rpc.Wallet.Recover.Request

Front end to middleware request-to-recover-a wallet with this mnemonic and a rootPath

Field Type Label Description
rootPath string Path to a wallet directory
mnemonic string Mnemonic of a wallet to recover

Rpc.Wallet.Recover.Response

Middleware-to-front-end response, that can contain a NULL error or a non-NULL error

Field Type Label Description
error Rpc.Wallet.Recover.Response.Error Error while trying to recover a wallet

Rpc.Wallet.Recover.Response.Error

Field Type Label Description
code Rpc.Wallet.Recover.Response.Error.Code
description string

Rpc.Account.Create.Response.Error.Code

Name Number Description
NULL 0 No error; Account should be non-empty
UNKNOWN_ERROR 1 Any other errors
BAD_INPUT 2 Avatar or name is not correct
ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE 101
ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME 102
ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR 103

Rpc.Account.Recover.Response.Error.Code

Name Number Description
NULL 0 No error;
UNKNOWN_ERROR 1 Any other errors
BAD_INPUT 2
NO_ACCOUNTS_FOUND 101
NEED_TO_RECOVER_WALLET_FIRST 102
FAILED_TO_CREATE_LOCAL_REPO 103
LOCAL_REPO_EXISTS_BUT_CORRUPTED 104
FAILED_TO_RUN_NODE 105
WALLET_RECOVER_NOT_PERFORMED 106

Rpc.Account.Select.Response.Error.Code

Name Number Description
NULL 0 No error
UNKNOWN_ERROR 1 Any other errors
BAD_INPUT 2 Id or root path is wrong
FAILED_TO_CREATE_LOCAL_REPO 101
LOCAL_REPO_EXISTS_BUT_CORRUPTED 102
FAILED_TO_RUN_NODE 103
FAILED_TO_FIND_ACCOUNT_INFO 104
LOCAL_REPO_NOT_EXISTS_AND_MNEMONIC_NOT_SET 105

Rpc.Block.Create.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...

Rpc.Block.History.Move.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2
CAN_NOT_MOVE 3 ...

Rpc.Block.Open.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...

Rpc.Block.Update.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...

Rpc.Image.Get.Blob.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...
NOT_FOUND 101
TIMEOUT 102

Rpc.Image.Get.File.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...
NOT_FOUND 101
TIMEOUT 102

Rpc.Ipfs.Get.File.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2 ...
NOT_FOUND 101
TIMEOUT 102

Rpc.Log.Send.Request.Level

Name Number Description
DEBUG 0
ERROR 1
FATAL 2
INFO 3
PANIC 4
WARNING 5

Rpc.Log.Send.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2
NOT_FOUND 101
TIMEOUT 102

Rpc.Version.Get.Response.Error.Code

Name Number Description
NULL 0
UNKNOWN_ERROR 1
BAD_INPUT 2
VERSION_IS_EMPTY 3
NOT_FOUND 101
TIMEOUT 102

Rpc.Wallet.Create.Response.Error.Code

Name Number Description
NULL 0 No error; mnemonic should be non-empty
UNKNOWN_ERROR 1 Any other errors
BAD_INPUT 2 Root path is wrong
FAILED_TO_CREATE_LOCAL_REPO 101 ...

Rpc.Wallet.Recover.Response.Error.Code

Name Number Description
NULL 0 No error; wallet successfully recovered
UNKNOWN_ERROR 1 Any other errors
BAD_INPUT 2 Root path or mnemonic is wrong
FAILED_TO_CREATE_LOCAL_REPO 101

Top

events.proto

Event

Field Type Label Description
accountShow Event.Account.Show show wallet's accounts that were loaded from local or remote source
blockShow Event.Block.Show
blockUpdate Event.Block.Update
blockCreate Event.Block.Create
userBlockTextRange Event.User.Block.TextRange
userBlockJoin Event.User.Block.Join
userBlockLeft Event.User.Block.Left
userBlockSelectRange Event.User.Block.SelectRange
filesUpload Event.Block.FilesUpload

Event.Account

Event.Account.Show

Message, that will be sent to the front on each account found after an AccountRecoverRequest

Field Type Label Description
index int64 Number of an account in an all found accounts list
account Model.Account An Account, that has been found for the mnemonic

Event.Block

Event.Block.Create

Field Type Label Description
block Model.Block

Event.Block.FilesUpload

Middleware to front end event message, that will be sent on one of this scenarios: Precondition: user A opened a block

  1. User A drops a set of files/pictures/videos
  2. User A creates a MediaBlock and drops a single media, that corresponds to its type.
Field Type Label Description
filePath string repeated filepaths to the files
blockId string if empty => create new blocks

Event.Block.Show

Field Type Label Description
block Model.Block

Event.Block.Update

Field Type Label Description
changes BlockChanges

Event.User

Event.User.Block

Event.User.Block.Join

Middleware to front end event message, that will be sent in this scenario: Precondition: user A opened a block

  1. User B opens the same block
  2. User A receives a message about p.1
Field Type Label Description
account Event.Account Account of the user, that opened a block

Event.User.Block.Left

Middleware to front end event message, that will be sent in this scenario: Precondition: user A and user B opened the same block

  1. User B closes the block
  2. User A receives a message about p.1
Field Type Label Description
account Event.Account Account of the user, that left the block

Event.User.Block.SelectRange

Middleware to front end event message, that will be sent in this scenario: Precondition: user A and user B opened the same block

  1. User B selects some inner blocks
  2. User A receives a message about p.1
Field Type Label Description
account Event.Account Account of the user, that selected blocks
blockIdsArray string repeated Ids of selected blocks.

Event.User.Block.TextRange

Middleware to front end event message, that will be sent in this scenario: Precondition: user A and user B opened the same block

  1. User B sets cursor or selects a text region into a text block
  2. User A receives a message about p.1
Field Type Label Description
account Event.Account Account of the user, that selected a text
blockId string Id of the text block, that have a selection
range Model.Range Range of the selection

Top

models.proto

Model

Model.Account

Contains basic information about user account

Field Type Label Description
id string User's thread id
name string User name, that associated with this account
avatar Model.Account.Avatar Avatar of a user's account

Model.Account.Avatar

Avatar of a user's account. It could be an image or color

Field Type Label Description
image Model.Image Image of the avatar. Contains hash and size
color string Color of the avatar, if no image

Model.Block

Field Type Label Description
header Model.Block.Header
children string repeated
dashboard Model.Block.Content.Dashboard
page Model.Block.Content.Page
dataview Model.Block.Content.Dataview
text Model.Block.Content.Text
media Model.Block.Content.Media
layout Model.Block.Content.Layout
div Model.Block.Content.Div

Model.Block.Content

Model.Block.Content.Dashboard

Field Type Label Description
style Model.Block.Content.Dashboard.Style
headers Model.Block.Header repeated

Model.Block.Content.Dataview

...

Model.Block.Content.Div

Model.Block.Content.Layout

Field Type Label Description
style Model.Block.Content.Layout.Style

Model.Block.Content.Media

Field Type Label Description
content bytes
state Model.Block.Content.Media.State
video Model.Block.Content.Media.VideoPreview
image Model.Block.Content.Media.ImagePreview
file Model.Block.Content.Media.FilePreview

Model.Block.Content.Media.FilePreview

Field Type Label Description
name string
icon string

Model.Block.Content.Media.ImagePreview

Field Type Label Description
thumbnail bytes
name string
width int32

Model.Block.Content.Media.VideoPreview

Field Type Label Description
thumbnail bytes
name string
width int32

Model.Block.Content.Page

Field Type Label Description
style Model.Block.Content.Page.Style

Model.Block.Content.Text

Field Type Label Description
text string
style Model.Block.Content.Text.Style
marksList Model.Block.Content.Text.Marks
toggleable bool
markerType Model.Block.Content.Text.MarkerType
checkable bool
checked bool

Model.Block.Content.Text.Mark

Field Type Label Description
range Model.Range
type Model.Block.Content.Text.Mark.Type
param string link, color, etc

Model.Block.Content.Text.Marks

Field Type Label Description
marks Model.Block.Content.Text.Mark repeated

Model.Block.Header

Field Type Label Description
id string
type Model.Block.Header.Type
fields Model.Struct
permissions Model.Block.Header.Permissions

Model.Block.Header.Permissions

Field Type Label Description
read bool
edit bool
remove bool
drag bool
dropOn bool

Model.Image

Field Type Label Description
id string
sizes Model.Image.Size repeated

Model.Preview

Field Type Label Description
title string
description string
imageUrl string
url string
faviconUrl string
type Model.Preview.Link.Type

Model.Range

Field Type Label Description
from int32
to int32

Model.Struct

Field Type Label Description
fields Model.Struct.FieldsEntry repeated Unordered map of dynamically typed values.

Model.Struct.FieldsEntry

Field Type Label Description
key string
value Model.Struct.Value

Model.Struct.ListValue

ListValue is a wrapper around a repeated field of values.

Field Type Label Description
values Model.Struct.Value repeated

Model.Struct.Value

Value represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. A producer of value is expected to set one of that variants, absence of any variant indicates an error.

Field Type Label Description
null_value Model.Struct.NullValue Represents a null value.
number_value double Represents a double value.
string_value string Represents a string value.
bool_value bool Represents a boolean value.
struct_value Model.Struct Represents a structured value.
list_value Model.Struct.ListValue Represents a repeated Value.

Model.Video

Field Type Label Description
id string
sizes Model.Video.Size repeated

Model.Block.Content.Dashboard.Style

Name Number Description
MAIN_SCREEN 0 ...

Model.Block.Content.Layout.Style

Name Number Description
ROW 0
COLUMN 1

Model.Block.Content.Media.State

Name Number Description
EMPTY 0
UPLOADING 1
PREVIEW 2
DOWNLOADING 3
DONE 4

Model.Block.Content.Page.Style

Name Number Description
EMPTY 0
TASK 1
BOOKMARK 2
SET 3 ...

Model.Block.Content.Text.Mark.Type

Name Number Description
STRIKETHROUGH 0
KEYBOARD 1
ITALIC 2
BOLD 3
LINK 4

Model.Block.Content.Text.MarkerType

Name Number Description
none 0
number 1
bullet 2

Model.Block.Content.Text.Style

Name Number Description
p 0
h1 1
h2 2
h3 3
h4 4
quote 5
code 6

Model.Block.Header.Type

Name Number Description
DASHBOARD 0
PAGE 1
DATAVIEW 2
TEXT 3
FILE 4
PICTURE 5
VIDEO 6
BOOKMARK 7
LAYOUT 8
DIV 9

Model.Image.Size

Name Number Description
LARGE 0
SMALL 1
THUMB 2

Name Number Description
PAGE 0
IMAGE 1
TEXT 2
UNEXPECTED 3

Model.Struct.NullValue

NullValue is a singleton enumeration to represent the null value for the

Name Number Description
NULL_VALUE 0

Model.Video.Size

Name Number Description
SD_360p 0
SD_480p 1
HD_720p 2
HD_1080p 3
UHD_1440p 4
UHD_2160p 5

Scalar Value Types

.proto Type Notes C++ Type Java Type Python Type
double double double float
float float float float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers if your field is likely to have negative values, use sint32 instead. int32 int int
int64 Uses variable-length encoding. Inefficient for encoding negative numbers if your field is likely to have negative values, use sint64 instead. int64 long int/long
uint32 Uses variable-length encoding. uint32 int int/long
uint64 Uses variable-length encoding. uint64 long int/long
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long
sfixed32 Always four bytes. int32 int int
sfixed64 Always eight bytes. int64 long int/long
bool bool boolean boolean
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode
bytes May contain any arbitrary sequence of bytes. string ByteString str