mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
Rework proto: move models from middleware
This commit is contained in:
parent
f38d3a69d3
commit
c9b19512c0
19 changed files with 3094 additions and 1226 deletions
3
Makefile
3
Makefile
|
@ -17,4 +17,5 @@ protos:
|
|||
$(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types)
|
||||
$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types)
|
||||
$(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT))
|
||||
cd pb/protos; GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):.. *.proto
|
||||
GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./pb/ pb/model/protos/*.proto; mv pb/github.com/anytypeio/go-anytype-library/pb/model/*.go pb/model/; rm -rf pb/github.com
|
||||
GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./pb/ pb/storage/protos/*.proto; mv pb/github.com/anytypeio/go-anytype-library/pb/storage/*.go pb/storage/; rm -rf pb/github.com
|
||||
|
|
|
@ -3,10 +3,9 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/gogo/protobuf/types"
|
||||
tcore "github.com/textileio/go-textile/core"
|
||||
)
|
||||
|
||||
|
@ -19,7 +18,7 @@ type Block interface {
|
|||
GetCurrentVersion() (BlockVersion, error)
|
||||
// AddVersion adds the new version of block's
|
||||
// if arg is nil it will be taken from the last version
|
||||
AddVersion(dependentBlocks map[string]BlockVersion, fields *structpb.Struct, children []string, content pb.IsBlockContent) error
|
||||
AddVersion(dependentBlocks map[string]BlockVersion, fields *types.Struct, children []string, content model.IsBlockContent) error
|
||||
// SubscribeForEvents provide a way to subscribe for the block and its children events
|
||||
SubscribeClientEvents(event chan<- proto.Message) (cancelFunc func())
|
||||
// PublishClientEvent gives a way to push the new client-side event e.g. carriage position change
|
||||
|
@ -31,17 +30,17 @@ type BlockVersion interface {
|
|||
GetBlockId() string
|
||||
GetVersionId() string
|
||||
GetUser() string
|
||||
GetDate() *timestamp.Timestamp
|
||||
GetDate() *types.Timestamp
|
||||
// GetChildrenIds returns IDs of children blocks
|
||||
GetChildrenIds() []string
|
||||
// GetPermissions returns permissions
|
||||
GetPermissions() *pb.BlockPermissions
|
||||
GetPermissions() *model.BlockPermissions
|
||||
// GetExternalFields returns fields supposed to be viewable when block not opened
|
||||
GetExternalFields() *structpb.Struct
|
||||
GetExternalFields() *types.Struct
|
||||
// GetFields returns all block fields
|
||||
GetFields() *structpb.Struct
|
||||
GetFields() *types.Struct
|
||||
// GetContent returns the content interface
|
||||
GetContent() pb.IsBlockContent
|
||||
GetContent() model.IsBlockContent
|
||||
// GetDependentBlocks gives the initial version of dependent blocks
|
||||
// it can contain blocks in the not fully loaded state, e.g. images in the state of DOWNLOADING
|
||||
GetDependentBlocks() map[string]BlockVersion
|
||||
|
@ -52,9 +51,9 @@ type BlockVersion interface {
|
|||
|
||||
var ErrorNotSmartBlock = fmt.Errorf("can't retrieve thread for not smart block")
|
||||
|
||||
func (anytype *Anytype) getThreadForBlock(b *pb.Block) (*tcore.Thread, error) {
|
||||
func (anytype *Anytype) getThreadForBlock(b *model.Block) (*tcore.Thread, error) {
|
||||
switch b.Content.(type) {
|
||||
case *pb.BlockContentOfPage, *pb.BlockContentOfDashboard:
|
||||
case *model.BlockContentOfPage, *model.BlockContentOfDashboard:
|
||||
return anytype.Textile.Node().Thread(b.Id), nil
|
||||
default:
|
||||
return nil, ErrorNotSmartBlock
|
||||
|
|
|
@ -3,7 +3,7 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/anytypeio/go-anytype-library/schema"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
@ -14,15 +14,15 @@ type CreateBlockTargetPosition string
|
|||
const CreateBlockTargetPositionAfter CreateBlockTargetPosition = "after"
|
||||
const CreateBlockTargetPositionBefore CreateBlockTargetPosition = "before"
|
||||
|
||||
func (a *Anytype) CreateBlock(content pb.IsBlockContent) (Block, error) {
|
||||
func (a *Anytype) CreateBlock(content model.IsBlockContent) (Block, error) {
|
||||
switch content.(type) {
|
||||
case *pb.BlockContentOfPage:
|
||||
case *model.BlockContentOfPage:
|
||||
thrd, err := a.newBlockThread(schema.Page)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Page{SmartBlock{thread: thrd, node: a}}, nil
|
||||
case *pb.BlockContentOfDashboard:
|
||||
case *model.BlockContentOfDashboard:
|
||||
thrd, err := a.newBlockThread(schema.Dashboard)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -37,8 +37,9 @@ func (a *Anytype) CreateBlock(content pb.IsBlockContent) (Block, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *Anytype) AddBlock(target string, targetPosition CreateBlockTargetPosition, content pb.IsBlockContent) (*Block, error) {
|
||||
func (a *Anytype) AddBlock(target string, targetPosition CreateBlockTargetPosition, content model.IsBlockContent) (*Block, error) {
|
||||
// todo: to be implemented
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *Anytype) GetBlock(id string) (Block, error) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/anytypeio/go-anytype-library/pb/storage"
|
||||
"github.com/anytypeio/go-anytype-library/util"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type Dashboard struct {
|
||||
|
@ -14,28 +15,12 @@ type Dashboard struct {
|
|||
}
|
||||
|
||||
func (dashboard *Dashboard) GetVersion(id string) (BlockVersion, error) {
|
||||
files, err := dashboard.node.Textile.Node().File(id)
|
||||
file, block, err := dashboard.SmartBlock.GetVersionBlock(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("GetVersionBlock error: %s", err.Error())
|
||||
}
|
||||
|
||||
if len(files.Files) == 0 {
|
||||
return nil, errors.New("version block not found")
|
||||
}
|
||||
|
||||
blockVersion := &pb.Block{}
|
||||
|
||||
plaintext, err := readFile(dashboard.node.Textile.Node(), files.Files[0].File)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("readFile error: %s", err.Error())
|
||||
}
|
||||
|
||||
err = proto.Unmarshal(plaintext, blockVersion)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dashboard version proto unmarshal error: %s", err.Error())
|
||||
}
|
||||
|
||||
version := &DashboardVersion{pb: blockVersion, VersionId: files.Block, Date: files.Date, User: files.User.Address}
|
||||
version := &DashboardVersion{pb: block, VersionId: file.Block, Date: util.CastTimestampToGogo(file.Date), User: file.User.Address}
|
||||
|
||||
return version, nil
|
||||
}
|
||||
|
@ -66,7 +51,7 @@ func (dashboard *Dashboard) GetVersions(offset string, limit int, metaOnly bool)
|
|||
}
|
||||
|
||||
for index, item := range files {
|
||||
version := &DashboardVersion{VersionId: item.Block, Date: item.Date, User: item.User.Address}
|
||||
version := &DashboardVersion{VersionId: item.Block, Date: util.CastTimestampToGogo(item.Date), User: item.User.Address}
|
||||
|
||||
if metaOnly {
|
||||
versions = append(versions, version)
|
||||
|
@ -80,13 +65,13 @@ func (dashboard *Dashboard) GetVersions(offset string, limit int, metaOnly bool)
|
|||
return versions, nil
|
||||
}
|
||||
|
||||
func (dashboard *Dashboard) AddVersion(dependentBlocks map[string]BlockVersion, fields *structpb.Struct, children []string, content pb.IsBlockContent) error {
|
||||
newVersion := &DashboardVersion{pb: &pb.Block{}}
|
||||
func (dashboard *Dashboard) AddVersion(dependentBlocks map[string]BlockVersion, fields *types.Struct, children []string, content model.IsBlockContent) error {
|
||||
newVersion := &DashboardVersion{pb: &storage.BlockWithDependentBlocks{}}
|
||||
|
||||
if newVersionContent, ok := content.(*pb.BlockContentOfDashboard); !ok {
|
||||
if newVersionContent, ok := content.(*model.BlockContentOfDashboard); !ok {
|
||||
return fmt.Errorf("unxpected smartblock type")
|
||||
} else {
|
||||
newVersion.pb.Content = newVersionContent
|
||||
newVersion.pb.Block.Content = newVersionContent
|
||||
}
|
||||
|
||||
lastVersion, err := dashboard.GetCurrentVersion()
|
||||
|
@ -107,8 +92,8 @@ func (dashboard *Dashboard) AddVersion(dependentBlocks map[string]BlockVersion,
|
|||
children = lastVersion.GetChildrenIds()
|
||||
}
|
||||
|
||||
lastVersionB, _ := proto.Marshal(lastVersion.(*DashboardVersion).pb.Content.(*pb.BlockContentOfDashboard).Dashboard)
|
||||
newVersionB, _ := proto.Marshal(newVersion.pb.Content.(*pb.BlockContentOfDashboard).Dashboard)
|
||||
lastVersionB, _ := proto.Marshal(lastVersion.(*DashboardVersion).pb.Block.Content.(*model.BlockContentOfDashboard).Dashboard)
|
||||
newVersionB, _ := proto.Marshal(newVersion.pb.Block.Content.(*model.BlockContentOfDashboard).Dashboard)
|
||||
if string(lastVersionB) == string(newVersionB) {
|
||||
log.Debugf("[MERGE] new version has the same blocks as the last version - ignore it")
|
||||
// do not insert the new version if no blocks have changed
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/anytypeio/go-anytype-library/pb/storage"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type DashboardVersion struct {
|
||||
pb *pb.Block
|
||||
pb *storage.BlockWithDependentBlocks
|
||||
VersionId string
|
||||
User string
|
||||
Date *timestamp.Timestamp
|
||||
Date *types.Timestamp
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetVersionId() string {
|
||||
|
@ -18,14 +18,14 @@ func (ver *DashboardVersion) GetVersionId() string {
|
|||
}
|
||||
|
||||
func (ver *DashboardVersion) GetBlockId() string {
|
||||
return ver.pb.Id
|
||||
return ver.pb.Block.Id
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetUser() string {
|
||||
return ver.User
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetDate() *timestamp.Timestamp {
|
||||
func (ver *DashboardVersion) GetDate() *types.Timestamp {
|
||||
return ver.Date
|
||||
}
|
||||
|
||||
|
@ -38,30 +38,35 @@ func (ver *DashboardVersion) GetNewVersionsOfBlocks(blocks chan<- []BlockVersion
|
|||
func (ver *DashboardVersion) GetDependentBlocks() map[string]BlockVersion {
|
||||
var m = make(map[string]BlockVersion, len(ver.pb.BlockById))
|
||||
for blockId, block := range ver.pb.BlockById {
|
||||
m[blockId] = &DashboardVersion{pb: block, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
switch block.Content.(type) {
|
||||
case *model.BlockContentOfDashboard:
|
||||
m[blockId] = &DashboardVersion{pb: &storage.BlockWithDependentBlocks{Block: block}, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
case *model.BlockContentOfPage:
|
||||
m[blockId] = &PageVersion{pb: &storage.BlockWithDependentBlocks{Block: block}, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetChildrenIds() []string {
|
||||
return ver.pb.ChildrenIds
|
||||
return ver.pb.Block.ChildrenIds
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetFields() *structpb.Struct {
|
||||
return ver.pb.Fields
|
||||
func (ver *DashboardVersion) GetFields() *types.Struct {
|
||||
return ver.pb.Block.Fields
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetExternalFields() *structpb.Struct {
|
||||
return &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"name": ver.pb.Fields.Fields["name"],
|
||||
"icon": ver.pb.Fields.Fields["icon"],
|
||||
func (ver *DashboardVersion) GetExternalFields() *types.Struct {
|
||||
return &types.Struct{Fields: map[string]*types.Value{
|
||||
"name": ver.pb.Block.Fields.Fields["name"],
|
||||
"icon": ver.pb.Block.Fields.Fields["icon"],
|
||||
}}
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetPermissions() *pb.BlockPermissions {
|
||||
return ver.pb.Permissions
|
||||
func (ver *DashboardVersion) GetPermissions() *model.BlockPermissions {
|
||||
return ver.pb.Block.Permissions
|
||||
}
|
||||
|
||||
func (ver *DashboardVersion) GetContent() pb.IsBlockContent {
|
||||
return ver.pb.Content
|
||||
func (ver *DashboardVersion) GetContent() model.IsBlockContent {
|
||||
return ver.pb.Block.Content
|
||||
}
|
||||
|
|
22
core/page.go
22
core/page.go
|
@ -3,9 +3,11 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/anytypeio/go-anytype-library/pb/storage"
|
||||
"github.com/anytypeio/go-anytype-library/util"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -26,7 +28,7 @@ func (page *Page) GetVersion(id string) (BlockVersion, error) {
|
|||
return nil, fmt.Errorf("readFile error: %s", err.Error())
|
||||
}
|
||||
|
||||
version := &PageVersion{pb: block, VersionId: file.Block, Date: file.Date, User: file.User.Address}
|
||||
version := &PageVersion{pb: block, VersionId: file.Block, Date: util.CastTimestampToGogo(file.Date), User: file.User.Address}
|
||||
|
||||
return version, nil
|
||||
}
|
||||
|
@ -57,7 +59,7 @@ func (page *Page) GetVersions(offset string, limit int, metaOnly bool) ([]BlockV
|
|||
}
|
||||
|
||||
for index, item := range files {
|
||||
version := &PageVersion{VersionId: item.Block, Date: item.Date, User: item.User.Address}
|
||||
version := &PageVersion{VersionId: item.Block, Date: util.CastTimestampToGogo(item.Date), User: item.User.Address}
|
||||
|
||||
if metaOnly {
|
||||
versions = append(versions, version)
|
||||
|
@ -71,13 +73,13 @@ func (page *Page) GetVersions(offset string, limit int, metaOnly bool) ([]BlockV
|
|||
return versions, nil
|
||||
}
|
||||
|
||||
func (page *Page) AddVersion(dependentBlocks map[string]BlockVersion, fields *structpb.Struct, children []string, content pb.IsBlockContent) error {
|
||||
newVersion := &PageVersion{pb: &pb.Block{}}
|
||||
func (page *Page) AddVersion(dependentBlocks map[string]BlockVersion, fields *types.Struct, children []string, content model.IsBlockContent) error {
|
||||
newVersion := &PageVersion{pb: &storage.BlockWithDependentBlocks{}}
|
||||
|
||||
if newVersionContent, ok := content.(*pb.BlockContentOfPage); !ok {
|
||||
if newVersionContent, ok := content.(*model.BlockContentOfPage); !ok {
|
||||
return fmt.Errorf("unxpected smartblock type")
|
||||
} else {
|
||||
newVersion.pb.Content = newVersionContent
|
||||
newVersion.pb.Block.Content = newVersionContent
|
||||
}
|
||||
|
||||
lastVersion, err := page.GetCurrentVersion()
|
||||
|
@ -98,8 +100,8 @@ func (page *Page) AddVersion(dependentBlocks map[string]BlockVersion, fields *st
|
|||
children = lastVersion.GetChildrenIds()
|
||||
}
|
||||
|
||||
lastVersionB, _ := proto.Marshal(lastVersion.(*PageVersion).pb.Content.(*pb.BlockContentOfPage).Page)
|
||||
newVersionB, _ := proto.Marshal(newVersion.pb.Content.(*pb.BlockContentOfPage).Page)
|
||||
lastVersionB, _ := proto.Marshal(lastVersion.(*PageVersion).pb.Block.Content.(*model.BlockContentOfPage).Page)
|
||||
newVersionB, _ := proto.Marshal(newVersion.pb.Block.Content.(*model.BlockContentOfPage).Page)
|
||||
if string(lastVersionB) == string(newVersionB) {
|
||||
log.Debugf("[MERGE] new version has the same blocks as the last version - ignore it")
|
||||
// do not insert the new version if no blocks have changed
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/anytypeio/go-anytype-library/pb/storage"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type PageVersion struct {
|
||||
pb *pb.Block
|
||||
pb *storage.BlockWithDependentBlocks
|
||||
VersionId string
|
||||
User string
|
||||
Date *timestamp.Timestamp
|
||||
Date *types.Timestamp
|
||||
}
|
||||
|
||||
func (pageVersion *PageVersion) GetVersionId() string {
|
||||
|
@ -18,14 +18,14 @@ func (pageVersion *PageVersion) GetVersionId() string {
|
|||
}
|
||||
|
||||
func (pageVersion *PageVersion) GetBlockId() string {
|
||||
return pageVersion.pb.Id
|
||||
return pageVersion.pb.Block.Id
|
||||
}
|
||||
|
||||
func (pageVersion *PageVersion) GetUser() string {
|
||||
return pageVersion.User
|
||||
}
|
||||
|
||||
func (pageVersion *PageVersion) GetDate() *timestamp.Timestamp {
|
||||
func (pageVersion *PageVersion) GetDate() *types.Timestamp {
|
||||
return pageVersion.Date
|
||||
}
|
||||
|
||||
|
@ -38,30 +38,35 @@ func (pageVersion *PageVersion) GetNewVersionsOfBlocks(blocks chan<- []BlockVers
|
|||
func (ver *PageVersion) GetDependentBlocks() map[string]BlockVersion {
|
||||
var m = make(map[string]BlockVersion, len(ver.pb.BlockById))
|
||||
for blockId, block := range ver.pb.BlockById {
|
||||
m[blockId] = &PageVersion{pb: block, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
switch block.Content.(type) {
|
||||
case *model.BlockContentOfDashboard:
|
||||
m[blockId] = &DashboardVersion{pb: &storage.BlockWithDependentBlocks{Block: block}, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
case *model.BlockContentOfPage:
|
||||
m[blockId] = &PageVersion{pb: &storage.BlockWithDependentBlocks{Block: block}, VersionId: ver.VersionId, User: ver.User, Date: ver.Date}
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (pageVersion *PageVersion) GetChildrenIds() []string {
|
||||
return pageVersion.pb.ChildrenIds
|
||||
return pageVersion.pb.Block.ChildrenIds
|
||||
}
|
||||
|
||||
func (ver *PageVersion) GetFields() *structpb.Struct {
|
||||
return ver.pb.Fields
|
||||
func (ver *PageVersion) GetFields() *types.Struct {
|
||||
return ver.pb.Block.Fields
|
||||
}
|
||||
|
||||
func (ver *PageVersion) GetExternalFields() *structpb.Struct {
|
||||
return &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"name": ver.pb.Fields.Fields["name"],
|
||||
"icon": ver.pb.Fields.Fields["icon"],
|
||||
func (ver *PageVersion) GetExternalFields() *types.Struct {
|
||||
return &types.Struct{Fields: map[string]*types.Value{
|
||||
"name": ver.pb.Block.Fields.Fields["name"],
|
||||
"icon": ver.pb.Block.Fields.Fields["icon"],
|
||||
}}
|
||||
}
|
||||
|
||||
func (ver *PageVersion) GetPermissions() *pb.BlockPermissions {
|
||||
return ver.pb.Permissions
|
||||
func (ver *PageVersion) GetPermissions() *model.BlockPermissions {
|
||||
return ver.pb.Block.Permissions
|
||||
}
|
||||
|
||||
func (ver *PageVersion) GetContent() pb.IsBlockContent {
|
||||
return ver.pb.Content
|
||||
func (ver *PageVersion) GetContent() model.IsBlockContent {
|
||||
return ver.pb.Block.Content
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func (t *Textile) DuplicatePage(id string, parentId string) (mh.Multihash, error
|
|||
go func(thrd *Thread) {
|
||||
defer wg.Done()
|
||||
|
||||
config := pb.AddThreadConfig{
|
||||
config := model.AddThreadConfig{
|
||||
Name: thrd.Name,
|
||||
Key: ksuid.New().String(),
|
||||
Schema: &pb.AddThreadConfig_Schema{
|
||||
|
@ -122,16 +122,16 @@ func (t *Textile) DuplicatePage(id string, parentId string) (mh.Multihash, error
|
|||
config.ChildrenIds = append(config.ChildrenIds, id.Pretty())
|
||||
}
|
||||
|
||||
if thrd.ttype == pb.Thread_READ_ONLY && !thrd.writable(t.account.Address()) {
|
||||
config.Type = pb.Thread_OPEN
|
||||
config.Sharing = pb.Thread_SHARED
|
||||
if thrd.ttype == model.Thread_READ_ONLY && !thrd.writable(t.account.Address()) {
|
||||
config.Type = model.Thread_OPEN
|
||||
config.Sharing = model.Thread_SHARED
|
||||
} else {
|
||||
config.Type = thrd.ttype
|
||||
config.Sharing = thrd.sharing
|
||||
}
|
||||
|
||||
if os.Getenv("ANYTYPE_DUPLICATE_READONLY") == "1" {
|
||||
config.Type = pb.Thread_READ_ONLY
|
||||
config.Type = model.Thread_READ_ONLY
|
||||
}
|
||||
|
||||
newThrd, err := t.AddThread(config, sk, t.account.Address(), true, false)
|
||||
|
@ -228,7 +228,7 @@ func (a *Anytype) PageView(id string) (*pb.Page, error) {
|
|||
Id: t.Id,
|
||||
Name: name,
|
||||
Initiator: t.Initiator,
|
||||
Type: pb.Page_Type(t.Type),
|
||||
Type: model.Page_Type(t.Type),
|
||||
Icon: icon,
|
||||
Archived: false,
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func (a *Anytype) Page(id string) (*Page, error) {
|
|||
Id: t.Id,
|
||||
Name: name,
|
||||
Initiator: tv.Initiator,
|
||||
Type: pb.Page_Type(tv.Type),
|
||||
Type: model.Page_Type(tv.Type),
|
||||
Icon: icon,
|
||||
Archived: false,
|
||||
Children: nil,
|
||||
|
|
|
@ -3,9 +3,9 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type SimpleBlock struct {
|
||||
|
@ -64,7 +64,7 @@ func (simpleBlock *SimpleBlock) GetVersions(offset string, limit int, metaOnly b
|
|||
return versions, nil
|
||||
}
|
||||
|
||||
func (simpleBlock *SimpleBlock) AddVersion(dependentBlocks map[string]BlockVersion, fields *structpb.Struct, children []string, content pb.IsBlockContent) error {
|
||||
func (simpleBlock *SimpleBlock) AddVersion(dependentBlocks map[string]BlockVersion, fields *types.Struct, children []string, content model.IsBlockContent) error {
|
||||
if fields != nil {
|
||||
return fmt.Errorf("simpleBlock simpleBlocks can't store fields")
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ func (simpleBlock *SimpleBlock) AddVersion(dependentBlocks map[string]BlockVersi
|
|||
return fmt.Errorf("simpleBlock simpleBlocks can't store dependent simpleBlocks")
|
||||
}
|
||||
|
||||
newVersion := &SimpleBlockVersion{pb: &pb.Block{}}
|
||||
newVersion := &SimpleBlockVersion{pb: &model.Block{}}
|
||||
|
||||
switch content.(type) {
|
||||
case *pb.BlockContentOfPage, *pb.BlockContentOfDashboard, *pb.BlockContentOfDataview:
|
||||
case *model.BlockContentOfPage, *model.BlockContentOfDashboard, *model.BlockContentOfDataview:
|
||||
return fmt.Errorf("unxpected smartsimpleBlock type")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/anytypeio/go-anytype-library/pb/model"
|
||||
"github.com/gogo/protobuf/types"
|
||||
)
|
||||
|
||||
type SimpleBlockVersion struct {
|
||||
pb *pb.Block
|
||||
pb *model.Block
|
||||
parentSmartBlockVersion BlockVersion
|
||||
node *Anytype
|
||||
}
|
||||
|
@ -24,7 +23,7 @@ func (blockVersion *SimpleBlockVersion) GetUser() string {
|
|||
return blockVersion.parentSmartBlockVersion.GetUser()
|
||||
}
|
||||
|
||||
func (blockVersion *SimpleBlockVersion) GetDate() *timestamp.Timestamp {
|
||||
func (blockVersion *SimpleBlockVersion) GetDate() *types.Timestamp {
|
||||
return blockVersion.parentSmartBlockVersion.GetDate()
|
||||
}
|
||||
|
||||
|
@ -32,21 +31,21 @@ func (blockVersion *SimpleBlockVersion) GetChildrenIds() []string {
|
|||
return blockVersion.pb.ChildrenIds
|
||||
}
|
||||
|
||||
func (blockVersion *SimpleBlockVersion) GetPermissions() *pb.BlockPermissions {
|
||||
func (blockVersion *SimpleBlockVersion) GetPermissions() *model.BlockPermissions {
|
||||
return blockVersion.pb.GetPermissions()
|
||||
}
|
||||
|
||||
func (blockVersion *SimpleBlockVersion) GetExternalFields() *structpb.Struct {
|
||||
func (blockVersion *SimpleBlockVersion) GetExternalFields() *types.Struct {
|
||||
// simple blocks can't have fields
|
||||
return nil
|
||||
}
|
||||
|
||||
func (blockVersion *SimpleBlockVersion) GetFields() *structpb.Struct {
|
||||
func (blockVersion *SimpleBlockVersion) GetFields() *types.Struct {
|
||||
// simple blocks can't have fields
|
||||
return nil
|
||||
}
|
||||
|
||||
func (blockVersion *SimpleBlockVersion) GetContent() pb.IsBlockContent {
|
||||
func (blockVersion *SimpleBlockVersion) GetContent() model.IsBlockContent {
|
||||
return blockVersion.pb.Content
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/anytypeio/go-anytype-library/pb/storage"
|
||||
"github.com/anytypeio/go-anytype-library/util"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/gogo/protobuf/types"
|
||||
tcore "github.com/textileio/go-textile/core"
|
||||
mill2 "github.com/textileio/go-textile/mill"
|
||||
tpb "github.com/textileio/go-textile/pb"
|
||||
|
@ -24,7 +25,7 @@ func (smartBlock *SmartBlock) GetId() string {
|
|||
return smartBlock.thread.Id
|
||||
}
|
||||
|
||||
func (smartBlock *SmartBlock) GetVersionBlock(id string) (fileMeta *tpb.Files, block *pb.Block, err error) {
|
||||
func (smartBlock *SmartBlock) GetVersionBlock(id string) (fileMeta *tpb.Files, block *storage.BlockWithDependentBlocks, err error) {
|
||||
fileMeta, err = smartBlock.node.textile().File(id)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -47,7 +48,7 @@ func (smartBlock *SmartBlock) GetVersionBlock(id string) (fileMeta *tpb.Files, b
|
|||
return fileMeta, block, err
|
||||
}
|
||||
|
||||
func (smartBlock *SmartBlock) GetVersionsFiles(offset string, limit int, metaOnly bool) (filesMeta []*tpb.Files, blocks []*pb.Block, err error) {
|
||||
func (smartBlock *SmartBlock) GetVersionsFiles(offset string, limit int, metaOnly bool) (filesMeta []*tpb.Files, blocks []*storage.BlockWithDependentBlocks, err error) {
|
||||
files, err := smartBlock.node.textile().Files(offset, limit, smartBlock.thread.Id)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -60,7 +61,7 @@ func (smartBlock *SmartBlock) GetVersionsFiles(offset string, limit int, metaOnl
|
|||
}
|
||||
|
||||
for _, item := range files.Items {
|
||||
block := &pb.Block{}
|
||||
block := &storage.BlockWithDependentBlocks{}
|
||||
|
||||
plaintext, err := readFile(smartBlock.node.Textile.Node(), item.Files[0].File)
|
||||
if err != nil {
|
||||
|
@ -80,7 +81,7 @@ func (smartBlock *SmartBlock) GetVersionsFiles(offset string, limit int, metaOnl
|
|||
return
|
||||
}
|
||||
|
||||
func (smartBlock *SmartBlock) AddVersion(newVersion *pb.Block) (versionId string, user string, date *timestamp.Timestamp, err error) {
|
||||
func (smartBlock *SmartBlock) AddVersion(newVersion *storage.BlockWithDependentBlocks) (versionId string, user string, date *types.Timestamp, err error) {
|
||||
var newVersionB []byte
|
||||
newVersionB, err = proto.Marshal(newVersion)
|
||||
if err != nil {
|
||||
|
@ -110,7 +111,7 @@ func (smartBlock *SmartBlock) AddVersion(newVersion *pb.Block) (versionId string
|
|||
|
||||
var caption string
|
||||
|
||||
if name, exist := newVersion.GetFields().Fields["name"]; exist {
|
||||
if name, exist := newVersion.Block.GetFields().Fields["name"]; exist {
|
||||
caption = name.String()
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ func (smartBlock *SmartBlock) AddVersion(newVersion *pb.Block) (versionId string
|
|||
}
|
||||
|
||||
if newBlock != nil {
|
||||
date = newBlock.Date
|
||||
date = util.CastTimestampToGogo(newBlock.Date)
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package anytype
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/anytypeio/go-anytype-library/anytypepb"
|
||||
"github.com/anytypeio/go-anytype-library/pb"
|
||||
"github.com/textileio/go-textile/wallet"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
|
||||
}
|
||||
|
||||
func NewServer() (pb.AnytypeServer, error) {
|
||||
return &Server{}, nil
|
||||
}
|
||||
|
||||
func (s *Server) NewWallet(context.Context, *pb.Empty) (*pb.NewWalletResponse, error) {
|
||||
w, err := wallet.WalletFromWordCount(12)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.NewWalletResponse{Mnemonic: w.RecoveryPhrase}, nil
|
||||
}
|
File diff suppressed because it is too large
Load diff
253
pb/model/protos/models.proto
Normal file
253
pb/model/protos/models.proto
Normal file
|
@ -0,0 +1,253 @@
|
|||
syntax = "proto3";
|
||||
package anytype.model;
|
||||
option go_package = "github.com/anytypeio/go-anytype-library/pb/model";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
message Block {
|
||||
string id = 1;
|
||||
google.protobuf.Struct fields = 2;
|
||||
Permissions permissions = 3;
|
||||
repeated string childrenIds = 4;
|
||||
|
||||
message Permissions {
|
||||
bool read = 1;
|
||||
bool edit = 2;
|
||||
bool remove = 3;
|
||||
bool drag = 4;
|
||||
bool dropOn = 5;
|
||||
}
|
||||
|
||||
enum Position {
|
||||
BEFORE = 0;
|
||||
AFTER = 1;
|
||||
}
|
||||
|
||||
oneof content {
|
||||
Content.Dashboard dashboard = 11;
|
||||
Content.Page page = 12;
|
||||
Content.Dataview dataview = 13;
|
||||
|
||||
Content.Text text = 14;
|
||||
Content.Video video = 15;
|
||||
Content.Image image = 16;
|
||||
Content.File file = 17;
|
||||
Content.Layout layout = 18;
|
||||
Content.Div div = 19;
|
||||
Content.Bookmark bookmark = 20;
|
||||
}
|
||||
|
||||
message Content {
|
||||
/*
|
||||
* Layout have no visual representation, but affects on blocks, that it contains.
|
||||
* Row/Column layout blocks creates only automatically, after some of a D&D operations, for example
|
||||
*/
|
||||
message Layout {
|
||||
Style style = 1;
|
||||
|
||||
enum Style {
|
||||
ROW = 0;
|
||||
COLUMN = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Divider: block, that contains only one horizontal thin line
|
||||
*/
|
||||
message Div {
|
||||
}
|
||||
|
||||
/*
|
||||
* Bookmark is to keep a web-link and to preview a content.
|
||||
*/
|
||||
message Bookmark {
|
||||
// Model.Link.Preview preview = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Block type to organize pages on the main screen (main purpose)
|
||||
* It also can be mounted on a page.
|
||||
*/
|
||||
message Dashboard {
|
||||
enum Style {
|
||||
MAIN_SCREEN = 0;
|
||||
// ...
|
||||
}
|
||||
|
||||
Style style = 1;
|
||||
}
|
||||
|
||||
message Dataview {
|
||||
// ...
|
||||
}
|
||||
|
||||
message Text {
|
||||
string text = 1;
|
||||
Style style = 2;
|
||||
Marks marksList = 3; // list of marks to apply to the text
|
||||
|
||||
bool toggleable = 4; // can be toggled or not
|
||||
MarkerType markerType = 5; // if no – it's not a list. If number/bullet – it should be a list with its list-siblings.
|
||||
|
||||
bool checkable = 6; // can be checked or not
|
||||
bool checked = 7;
|
||||
|
||||
message Mark {
|
||||
Range range = 1; // range of symbols to apply this mark. From(symbol) To(symbol)
|
||||
Type type = 2;
|
||||
string param = 3; // link, color, etc
|
||||
|
||||
enum Type {
|
||||
STRIKETHROUGH = 0;
|
||||
KEYBOARD = 1;
|
||||
ITALIC = 2;
|
||||
BOLD = 3;
|
||||
LINK = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Marks {
|
||||
repeated Mark marks = 1;
|
||||
}
|
||||
|
||||
enum Style {
|
||||
p = 0;
|
||||
h1 = 1;
|
||||
h2 = 2;
|
||||
h3 = 3;
|
||||
h4 = 4;
|
||||
quote = 5;
|
||||
code = 6;
|
||||
}
|
||||
|
||||
enum MarkerType {
|
||||
none = 0;
|
||||
number = 1;
|
||||
bullet = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message Video {
|
||||
string localFilePath = 1;
|
||||
State state = 2;
|
||||
Preview preview = 3;
|
||||
|
||||
message Preview {
|
||||
string name = 1;
|
||||
string icon = 2;
|
||||
int32 width = 3;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0; // There is no video and preview, it's an empty block, that waits videos.
|
||||
UPLOADING = 1; // There is stil no video/preview, but video already uploading
|
||||
PREVIEW = 2; // Video exists, preview downloaded, but video – not.
|
||||
DOWNLOADING = 3; // Video exists, preview downloaded, but video downloading
|
||||
DONE = 4; // Video and preview downloaded
|
||||
}
|
||||
}
|
||||
|
||||
message Image {
|
||||
string localFilePath = 1;
|
||||
State state = 2;
|
||||
Preview preview = 3;
|
||||
|
||||
message Preview {
|
||||
string name = 1;
|
||||
string icon = 2;
|
||||
int32 width = 3;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0; // There is no image and preview, it's an empty block, that waits image.
|
||||
UPLOADING = 1; // There is stil no image/preview, but image already uploading
|
||||
PREVIEW = 2; // Image exists, preview downloaded, but image – not.
|
||||
DOWNLOADING = 3; // Image exists, preview downloaded, but image downloading
|
||||
DONE = 4; // Image and preview downloaded
|
||||
}
|
||||
}
|
||||
|
||||
message File {
|
||||
string localFilePath = 1; // Path to the file on a local machine
|
||||
State state = 2;
|
||||
Preview preview = 3; // Content to show before the main content is downladed
|
||||
|
||||
message Preview {
|
||||
string name = 1;
|
||||
string icon = 2;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0; // There is no file and preview, it's an empty block, that waits files.
|
||||
UPLOADING = 1; // There is stil no file/preview, but file already uploading
|
||||
PREVIEW = 2; // File exists, preview downloaded, but file – not.
|
||||
DOWNLOADING = 3; // File exists, preview downloaded, but file downloading
|
||||
DONE = 4; // File and preview downloaded
|
||||
}
|
||||
}
|
||||
|
||||
message Page {
|
||||
enum Style {
|
||||
EMPTY = 0; // Ordinary page, without additional fields
|
||||
TASK = 1; // Page with a task fields
|
||||
BOOKMARK = 2; // Page with a bookmark fields
|
||||
SET = 3; // Page, that organize a set of blocks by a specific criterio
|
||||
// ...
|
||||
}
|
||||
|
||||
Style style = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* General purpose structure, uses in Mark.
|
||||
*/
|
||||
message Range {
|
||||
int32 from = 1;
|
||||
int32 to = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains basic information about a user account
|
||||
*/
|
||||
message Account {
|
||||
string id = 1; // User's thread id
|
||||
string name = 2; // User name, that associated with this account
|
||||
Avatar avatar = 3; // Avatar of a user's account
|
||||
|
||||
/**
|
||||
* Avatar of a user's account. It could be an image or color
|
||||
*/
|
||||
message Avatar {
|
||||
oneof avatar {
|
||||
Image image = 1; // Image of the avatar. Contains hash and size
|
||||
string color = 2; // Color of the avatar, if no image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Image {
|
||||
string id = 1;
|
||||
repeated Size sizes = 2;
|
||||
|
||||
enum Size {
|
||||
LARGE = 0;
|
||||
SMALL = 1;
|
||||
THUMB = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message Video {
|
||||
string id = 1;
|
||||
repeated Size sizes = 2;
|
||||
|
||||
enum Size {
|
||||
SD_360p = 0;
|
||||
SD_480p = 1;
|
||||
HD_720p = 2;
|
||||
HD_1080p = 3;
|
||||
UHD_1440p = 4;
|
||||
UHD_2160p = 5;
|
||||
}
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package anytype;
|
||||
option go_package = "pb";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
message Block {
|
||||
string id = 1;
|
||||
google.protobuf.Struct fields = 2;
|
||||
Permissions permissions = 3;
|
||||
repeated string childrenIds = 4;
|
||||
map<string, Block> blockById = 5;
|
||||
|
||||
message Permissions {
|
||||
bool read = 1;
|
||||
bool edit = 2;
|
||||
bool remove = 3;
|
||||
bool drag = 4;
|
||||
bool dropOn = 5;
|
||||
}
|
||||
|
||||
oneof content {
|
||||
Content.Dashboard dashboard = 11;
|
||||
Content.Page page = 12;
|
||||
Content.Dataview dataview = 13;
|
||||
|
||||
Content.Text text = 14;
|
||||
Content.Video video = 15;
|
||||
Content.Image image = 16;
|
||||
Content.File file = 17;
|
||||
Content.Layout layout = 18;
|
||||
Content.Div div = 19;
|
||||
}
|
||||
|
||||
message Content {
|
||||
message Layout {
|
||||
Style style = 1;
|
||||
|
||||
enum Style {
|
||||
ROW = 0;
|
||||
COLUMN = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message Div {}
|
||||
|
||||
message Dashboard {
|
||||
enum Style {
|
||||
MAIN_SCREEN = 0;
|
||||
// ...
|
||||
}
|
||||
|
||||
Style style = 1;
|
||||
}
|
||||
|
||||
message Dataview {
|
||||
// ...
|
||||
}
|
||||
|
||||
message Text {
|
||||
enum Style {
|
||||
p = 0;
|
||||
h1 = 1;
|
||||
h2 = 2;
|
||||
h3 = 3;
|
||||
h4 = 4;
|
||||
quote = 5;
|
||||
code = 6;
|
||||
}
|
||||
|
||||
enum MarkerType {
|
||||
none = 0;
|
||||
number = 1;
|
||||
bullet = 2;
|
||||
}
|
||||
|
||||
message Marks {
|
||||
repeated Mark marks = 1;
|
||||
}
|
||||
|
||||
message Mark {
|
||||
|
||||
enum Type {
|
||||
STRIKETHROUGH = 0;
|
||||
KEYBOARD = 1;
|
||||
ITALIC = 2;
|
||||
BOLD = 3;
|
||||
LINK = 4;
|
||||
}
|
||||
|
||||
Range range = 1;
|
||||
Type type = 2;
|
||||
string param = 3; // link, color, etc
|
||||
}
|
||||
|
||||
string text = 1;
|
||||
Style style = 2;
|
||||
Marks marksList = 3;
|
||||
|
||||
bool toggleable = 4;
|
||||
MarkerType markerType = 5;
|
||||
|
||||
bool checkable = 6;
|
||||
bool checked = 7;
|
||||
}
|
||||
|
||||
message Video {
|
||||
string localFilePath = 1;
|
||||
State state = 2;
|
||||
Preview preview = 3;
|
||||
|
||||
message Preview {
|
||||
bytes thumbnail = 1;
|
||||
string name = 2;
|
||||
int32 width = 3;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0;
|
||||
UPLOADING = 1;
|
||||
PREVIEW = 2;
|
||||
DOWNLOADING = 3;
|
||||
DONE = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Image {
|
||||
string localFilePath = 1;
|
||||
State state = 2;
|
||||
Preview preview = 3;
|
||||
|
||||
message Preview {
|
||||
bytes thumbnail = 1;
|
||||
string name = 2;
|
||||
int32 width = 3;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0;
|
||||
UPLOADING = 1;
|
||||
PREVIEW = 2;
|
||||
DOWNLOADING = 3;
|
||||
DONE = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message File {
|
||||
string localFilePath = 1;
|
||||
State state = 2;
|
||||
Preview preview = 3;
|
||||
|
||||
message Preview {
|
||||
string name = 1;
|
||||
string icon = 2;
|
||||
}
|
||||
|
||||
enum State {
|
||||
EMPTY = 0;
|
||||
UPLOADING = 1;
|
||||
PREVIEW = 2;
|
||||
DOWNLOADING = 3;
|
||||
DONE = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Page {
|
||||
enum Style {
|
||||
EMPTY = 0;
|
||||
TASK = 1;
|
||||
BOOKMARK = 2;
|
||||
SET = 3;
|
||||
// ...
|
||||
}
|
||||
|
||||
Style style = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Range {
|
||||
int32 from = 1;
|
||||
int32 to = 2;
|
||||
}
|
511
pb/storage/block.pb.go
Normal file
511
pb/storage/block.pb.go
Normal file
|
@ -0,0 +1,511 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: pb/storage/protos/block.proto
|
||||
|
||||
package storage
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
model "github.com/anytypeio/go-anytype-library/pb/model"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type BlockWithDependentBlocks struct {
|
||||
Block *model.Block `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
|
||||
BlockById map[string]*model.Block `protobuf:"bytes,2,rep,name=blockById,proto3" json:"blockById,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
|
||||
func (m *BlockWithDependentBlocks) Reset() { *m = BlockWithDependentBlocks{} }
|
||||
func (m *BlockWithDependentBlocks) String() string { return proto.CompactTextString(m) }
|
||||
func (*BlockWithDependentBlocks) ProtoMessage() {}
|
||||
func (*BlockWithDependentBlocks) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_922fa7b2983033eb, []int{0}
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_BlockWithDependentBlocks.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BlockWithDependentBlocks.Merge(m, src)
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BlockWithDependentBlocks.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BlockWithDependentBlocks proto.InternalMessageInfo
|
||||
|
||||
func (m *BlockWithDependentBlocks) GetBlock() *model.Block {
|
||||
if m != nil {
|
||||
return m.Block
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlockWithDependentBlocks) GetBlockById() map[string]*model.Block {
|
||||
if m != nil {
|
||||
return m.BlockById
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*BlockWithDependentBlocks)(nil), "anytype.storage.BlockWithDependentBlocks")
|
||||
proto.RegisterMapType((map[string]*model.Block)(nil), "anytype.storage.BlockWithDependentBlocks.BlockByIdEntry")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("pb/storage/protos/block.proto", fileDescriptor_922fa7b2983033eb) }
|
||||
|
||||
var fileDescriptor_922fa7b2983033eb = []byte{
|
||||
// 270 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x48, 0xd2, 0x2f,
|
||||
0x2e, 0xc9, 0x2f, 0x4a, 0x4c, 0x4f, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0xd6, 0x4f, 0xca,
|
||||
0xc9, 0x4f, 0xce, 0xd6, 0x03, 0x73, 0x84, 0xf8, 0x13, 0xf3, 0x2a, 0x4b, 0x2a, 0x0b, 0x52, 0xf5,
|
||||
0xa0, 0x6a, 0xa4, 0x64, 0x0a, 0x92, 0xf4, 0x73, 0xf3, 0x53, 0x52, 0x73, 0x60, 0xaa, 0xc1, 0x9c,
|
||||
0x62, 0x88, 0x72, 0xa5, 0x4f, 0x8c, 0x5c, 0x12, 0x4e, 0x20, 0xed, 0xe1, 0x99, 0x25, 0x19, 0x2e,
|
||||
0xa9, 0x05, 0xa9, 0x79, 0x29, 0xa9, 0x79, 0x25, 0x60, 0x91, 0x62, 0x21, 0x2d, 0x2e, 0x56, 0xb0,
|
||||
0xd1, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x22, 0x7a, 0x30, 0xb3, 0xc1, 0x46, 0xe8, 0x81,
|
||||
0x55, 0x05, 0x41, 0x94, 0x08, 0x85, 0x71, 0x71, 0x82, 0x19, 0x4e, 0x95, 0x9e, 0x29, 0x12, 0x4c,
|
||||
0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x16, 0x7a, 0x68, 0x6e, 0xd1, 0xc3, 0x65, 0x13, 0x44, 0x02, 0xa4,
|
||||
0xd5, 0x35, 0xaf, 0xa4, 0xa8, 0x32, 0x08, 0x61, 0x94, 0x54, 0x10, 0x17, 0x1f, 0xaa, 0xa4, 0x90,
|
||||
0x00, 0x17, 0x73, 0x76, 0x6a, 0x25, 0xd8, 0x4d, 0x9c, 0x41, 0x20, 0x26, 0xc8, 0x9d, 0x65, 0x89,
|
||||
0x39, 0xa5, 0xa9, 0x12, 0x4c, 0xf8, 0xdc, 0x09, 0x56, 0x62, 0xc5, 0x64, 0xc1, 0xe8, 0xe4, 0x73,
|
||||
0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7,
|
||||
0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5,
|
||||
0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x43, 0x32, 0xf3, 0xf5, 0xd3, 0xf3, 0x75, 0xa1, 0x1c,
|
||||
0xdd, 0x9c, 0xcc, 0xa4, 0xa2, 0xc4, 0xa2, 0x4a, 0x7d, 0x44, 0x24, 0x24, 0xb1, 0x81, 0x43, 0xd2,
|
||||
0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x96, 0xfe, 0x7e, 0x99, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *BlockWithDependentBlocks) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *BlockWithDependentBlocks) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *BlockWithDependentBlocks) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.BlockById) > 0 {
|
||||
for k := range m.BlockById {
|
||||
v := m.BlockById[k]
|
||||
baseI := i
|
||||
if v != nil {
|
||||
{
|
||||
size, err := v.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintBlock(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
i -= len(k)
|
||||
copy(dAtA[i:], k)
|
||||
i = encodeVarintBlock(dAtA, i, uint64(len(k)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
i = encodeVarintBlock(dAtA, i, uint64(baseI-i))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if m.Block != nil {
|
||||
{
|
||||
size, err := m.Block.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintBlock(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintBlock(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovBlock(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Block != nil {
|
||||
l = m.Block.Size()
|
||||
n += 1 + l + sovBlock(uint64(l))
|
||||
}
|
||||
if len(m.BlockById) > 0 {
|
||||
for k, v := range m.BlockById {
|
||||
_ = k
|
||||
_ = v
|
||||
l = 0
|
||||
if v != nil {
|
||||
l = v.Size()
|
||||
l += 1 + sovBlock(uint64(l))
|
||||
}
|
||||
mapEntrySize := 1 + len(k) + sovBlock(uint64(len(k))) + l
|
||||
n += mapEntrySize + 1 + sovBlock(uint64(mapEntrySize))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovBlock(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozBlock(x uint64) (n int) {
|
||||
return sovBlock(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *BlockWithDependentBlocks) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: BlockWithDependentBlocks: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: BlockWithDependentBlocks: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Block == nil {
|
||||
m.Block = &model.Block{}
|
||||
}
|
||||
if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field BlockById", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.BlockById == nil {
|
||||
m.BlockById = make(map[string]*model.Block)
|
||||
}
|
||||
var mapkey string
|
||||
var mapvalue *model.Block
|
||||
for iNdEx < postIndex {
|
||||
entryPreIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
if fieldNum == 1 {
|
||||
var stringLenmapkey uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLenmapkey |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLenmapkey := int(stringLenmapkey)
|
||||
if intStringLenmapkey < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
postStringIndexmapkey := iNdEx + intStringLenmapkey
|
||||
if postStringIndexmapkey < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if postStringIndexmapkey > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
|
||||
iNdEx = postStringIndexmapkey
|
||||
} else if fieldNum == 2 {
|
||||
var mapmsglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
mapmsglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if mapmsglen < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
postmsgIndex := iNdEx + mapmsglen
|
||||
if postmsgIndex < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if postmsgIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
mapvalue = &model.Block{}
|
||||
if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postmsgIndex
|
||||
} else {
|
||||
iNdEx = entryPreIndex
|
||||
skippy, err := skipBlock(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if (iNdEx + skippy) > postIndex {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
m.BlockById[mapkey] = mapvalue
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipBlock(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthBlock
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipBlock(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowBlock
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthBlock
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupBlock
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthBlock
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthBlock = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowBlock = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupBlock = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
10
pb/storage/protos/block.proto
Normal file
10
pb/storage/protos/block.proto
Normal file
|
@ -0,0 +1,10 @@
|
|||
syntax = "proto3";
|
||||
package anytype.storage;
|
||||
option go_package = "github.com/anytypeio/go-anytype-library/pb/storage";
|
||||
|
||||
import "pb/model/protos/models.proto";
|
||||
|
||||
message BlockWithDependentBlocks {
|
||||
anytype.model.Block block = 1;
|
||||
map<string, anytype.model.Block> blockById = 2;
|
||||
}
|
|
@ -15,5 +15,3 @@ var Dashboard = `
|
|||
"mill": "/blob"
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
|
|
20
util/util.go
20
util/util.go
|
@ -5,6 +5,9 @@ import (
|
|||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/gogo/protobuf/types"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
)
|
||||
|
||||
func DiffStringSlice(old, new []string) (removed []string, added []string) {
|
||||
|
@ -64,3 +67,20 @@ func GzipUncompress(b []byte) ([]byte, error) {
|
|||
return resB.Bytes(), nil
|
||||
}
|
||||
|
||||
func CastTimestampFromGogo(tsP *types.Timestamp) *types.Timestamp {
|
||||
if tsP == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
ts := types.Timestamp(*tsP)
|
||||
return &ts
|
||||
}
|
||||
|
||||
func CastTimestampToGogo(tsP *timestamp.Timestamp) *types.Timestamp {
|
||||
if tsP == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
ts := types.Timestamp(*tsP)
|
||||
return &ts
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue