1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

GO-4451 Merge main

This commit is contained in:
kirillston 2024-11-08 21:02:14 +01:00
commit 995aa7c0ed
No known key found for this signature in database
GPG key ID: 88218A7F1109754B
19 changed files with 1669 additions and 1854 deletions

View file

@ -121,6 +121,18 @@ func handleZip(input, output string) {
defer r.Close()
for _, f := range r.File {
dir := filepath.Dir(f.Name)
if dir != "." {
// nolint: gosec
outputDir := filepath.Join(output, dir)
if _, err := os.Stat(outputDir); os.IsNotExist(err) {
if err := os.MkdirAll(outputDir, 0755); err != nil {
log.Printf("Failed to create output subdirectory: %v\n", err)
return
}
}
}
// assuming we are only working with files, not directories
if f.FileInfo().IsDir() {
continue

View file

@ -11,6 +11,7 @@ import (
"io"
"os"
"path/filepath"
"slices"
"strings"
"github.com/gogo/protobuf/jsonpb"
@ -207,7 +208,7 @@ func collectUseCaseInfo(files []*zip.File, fileName string) (info *useCaseInfo,
continue
}
if strings.HasPrefix(f.Name, "files") {
if strings.HasPrefix(f.Name, "files") || f.FileInfo().IsDir() {
continue
}
@ -296,14 +297,21 @@ func processFiles(files []*zip.File, zw *zip.Writer, info *useCaseInfo, flags *c
if err != nil {
return err
}
newData, err := processRawData(data, f.Name, info, flags)
if err != nil {
if !(flags.exclude && errors.Is(err, errValidationFailed)) {
// just do not include object that failed validation
incorrectFileFound = true
var newData []byte
if f.FileInfo().IsDir() {
newData = data
} else {
newData, err = processRawData(data, f.Name, info, flags)
if err != nil {
if !(flags.exclude && errors.Is(err, errValidationFailed)) {
// just do not include object that failed validation
incorrectFileFound = true
}
continue
}
continue
}
if newData == nil || !writeNewFile {
continue
}
@ -464,7 +472,11 @@ func removeAccountRelatedDetails(s *pb.ChangeSnapshot) {
bundle.RelationKeyLinks.String(),
bundle.RelationKeyBacklinks.String(),
bundle.RelationKeyWorkspaceId.String(),
bundle.RelationKeyIdentityProfileLink.String():
bundle.RelationKeyIdentityProfileLink.String(),
bundle.RelationKeyAddedDate.String(),
bundle.RelationKeySyncDate.String(),
bundle.RelationKeySyncError.String(),
bundle.RelationKeySyncStatus.String():
delete(s.Data.Details.Fields, key)
}
@ -492,7 +504,7 @@ func processProfile(data []byte, info *useCaseInfo, spaceDashboardId string) ([]
}
fmt.Println("spaceDashboardId = " + profile.SpaceDashboardId)
if _, found := info.objects[profile.SpaceDashboardId]; !found {
if _, found := info.objects[profile.SpaceDashboardId]; !found && !slices.Contains([]string{"lastOpened"}, profile.SpaceDashboardId) {
err := fmt.Errorf("failed to find Space Dashboard object '%s' among provided", profile.SpaceDashboardId)
fmt.Println(err)
return nil, err

View file

@ -80,42 +80,33 @@ func (_c *MockService_Init_Call) RunAndReturn(run func(*app.App) error) *MockSer
}
// ListRelationsWithValue provides a mock function with given fields: spaceId, value
func (_m *MockService) ListRelationsWithValue(spaceId string, value *types.Value) ([]string, []int64, error) {
func (_m *MockService) ListRelationsWithValue(spaceId string, value *types.Value) ([]*pb.RpcRelationListWithValueResponseResponseItem, error) {
ret := _m.Called(spaceId, value)
if len(ret) == 0 {
panic("no return value specified for ListRelationsWithValue")
}
var r0 []string
var r1 []int64
var r2 error
if rf, ok := ret.Get(0).(func(string, *types.Value) ([]string, []int64, error)); ok {
var r0 []*pb.RpcRelationListWithValueResponseResponseItem
var r1 error
if rf, ok := ret.Get(0).(func(string, *types.Value) ([]*pb.RpcRelationListWithValueResponseResponseItem, error)); ok {
return rf(spaceId, value)
}
if rf, ok := ret.Get(0).(func(string, *types.Value) []string); ok {
if rf, ok := ret.Get(0).(func(string, *types.Value) []*pb.RpcRelationListWithValueResponseResponseItem); ok {
r0 = rf(spaceId, value)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]string)
r0 = ret.Get(0).([]*pb.RpcRelationListWithValueResponseResponseItem)
}
}
if rf, ok := ret.Get(1).(func(string, *types.Value) []int64); ok {
if rf, ok := ret.Get(1).(func(string, *types.Value) error); ok {
r1 = rf(spaceId, value)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).([]int64)
}
r1 = ret.Error(1)
}
if rf, ok := ret.Get(2).(func(string, *types.Value) error); ok {
r2 = rf(spaceId, value)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
return r0, r1
}
// MockService_ListRelationsWithValue_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRelationsWithValue'
@ -137,12 +128,12 @@ func (_c *MockService_ListRelationsWithValue_Call) Run(run func(spaceId string,
return _c
}
func (_c *MockService_ListRelationsWithValue_Call) Return(keys []string, counters []int64, err error) *MockService_ListRelationsWithValue_Call {
_c.Call.Return(keys, counters, err)
func (_c *MockService_ListRelationsWithValue_Call) Return(_a0 []*pb.RpcRelationListWithValueResponseResponseItem, _a1 error) *MockService_ListRelationsWithValue_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *MockService_ListRelationsWithValue_Call) RunAndReturn(run func(string, *types.Value) ([]string, []int64, error)) *MockService_ListRelationsWithValue_Call {
func (_c *MockService_ListRelationsWithValue_Call) RunAndReturn(run func(string, *types.Value) ([]*pb.RpcRelationListWithValueResponseResponseItem, error)) *MockService_ListRelationsWithValue_Call {
_c.Call.Return(run)
return _c
}

View file

@ -14,6 +14,7 @@ import (
"github.com/anyproto/anytype-heart/core/block/cache"
"github.com/anyproto/anytype-heart/core/block/editor/smartblock"
"github.com/anyproto/anytype-heart/core/domain"
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
coresb "github.com/anyproto/anytype-heart/pkg/lib/core/smartblock"
"github.com/anyproto/anytype-heart/pkg/lib/database"
@ -65,11 +66,11 @@ func (s *service) ObjectTypeRemoveRelations(ctx context.Context, objectTypeId st
})
}
func (s *service) ListRelationsWithValue(spaceId string, value *types.Value) (keys []string, counters []int64, err error) {
func (s *service) ListRelationsWithValue(spaceId string, value *types.Value) ([]*pb.RpcRelationListWithValueResponseResponseItem, error) {
countersByKeys := make(map[string]int64)
detailHandlesValue := generateFilter(value)
err = s.store.SpaceIndex(spaceId).QueryIterate(database.Query{Filters: nil}, func(details *types.Struct) {
err := s.store.SpaceIndex(spaceId).QueryIterate(database.Query{Filters: nil}, func(details *types.Struct) {
for key, valueToCheck := range details.Fields {
if detailHandlesValue(valueToCheck) {
if counter, ok := countersByKeys[key]; ok {
@ -82,17 +83,21 @@ func (s *service) ListRelationsWithValue(spaceId string, value *types.Value) (ke
})
if err != nil {
return nil, nil, fmt.Errorf("failed to query objects: %w", err)
return nil, fmt.Errorf("failed to query objects: %w", err)
}
keys = maps.Keys(countersByKeys)
keys := maps.Keys(countersByKeys)
slices.Sort(keys)
list := make([]*pb.RpcRelationListWithValueResponseResponseItem, len(keys))
for _, key := range keys {
counters = append(counters, countersByKeys[key])
for i, key := range keys {
list[i] = &pb.RpcRelationListWithValueResponseResponseItem{
RelationKey: key,
Counter: countersByKeys[key],
}
}
return keys, counters, nil
return list, nil
}
func generateFilter(value *types.Value) func(v *types.Value) bool {

View file

@ -13,6 +13,7 @@ import (
"github.com/anyproto/anytype-heart/core/block/editor/smartblock/smarttest"
"github.com/anyproto/anytype-heart/core/block/editor/state"
"github.com/anyproto/anytype-heart/core/domain"
"github.com/anyproto/anytype-heart/pb"
"github.com/anyproto/anytype-heart/pkg/lib/bundle"
"github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore"
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
@ -79,47 +80,59 @@ func TestService_ListRelationsWithValue(t *testing.T) {
bs := service{store: store}
for _, tc := range []struct {
name string
value *types.Value
expectedKeys []string
expectedCounters []int64
name string
value *types.Value
expectedList []*pb.RpcRelationListWithValueResponseResponseItem
}{
{
"date object - today",
pbtypes.String(dateutil.TimeToDateId(now)),
[]string{bundle.RelationKeyAddedDate.String(), bundle.RelationKeyCreatedDate.String(), bundle.RelationKeyLastModifiedDate.String(), bundle.RelationKeyLinks.String(), bundle.RelationKeyMentions.String(), bundle.RelationKeyName.String()},
[]int64{1, 2, 3, 1, 1, 1},
[]*pb.RpcRelationListWithValueResponseResponseItem{
{bundle.RelationKeyAddedDate.String(), 1},
{bundle.RelationKeyCreatedDate.String(), 2},
{bundle.RelationKeyLastModifiedDate.String(), 3},
{bundle.RelationKeyLinks.String(), 1},
{bundle.RelationKeyMentions.String(), 1},
{bundle.RelationKeyName.String(), 1},
},
},
{
"date object - yesterday",
pbtypes.String(dateutil.TimeToDateId(now.Add(-24 * time.Hour))),
[]string{bundle.RelationKeyAddedDate.String(), bundle.RelationKeyCreatedDate.String(), bundle.RelationKeyMentions.String()},
[]int64{1, 1, 1},
[]*pb.RpcRelationListWithValueResponseResponseItem{
{bundle.RelationKeyAddedDate.String(), 1},
{bundle.RelationKeyCreatedDate.String(), 1},
{bundle.RelationKeyMentions.String(), 1},
},
},
{
"number",
pbtypes.Int64(300),
[]string{bundle.RelationKeyCoverX.String(), "daysTillSummer"},
[]int64{2, 1},
[]*pb.RpcRelationListWithValueResponseResponseItem{
{bundle.RelationKeyCoverX.String(), 2},
{"daysTillSummer", 1},
},
},
{
"bool",
pbtypes.Bool(true),
[]string{bundle.RelationKeyIsFavorite.String(), bundle.RelationKeyIsHidden.String()},
[]int64{2, 1},
[]*pb.RpcRelationListWithValueResponseResponseItem{
{bundle.RelationKeyIsFavorite.String(), 2},
{bundle.RelationKeyIsHidden.String(), 1},
},
},
{
"string list",
pbtypes.StringList([]string{"obj2", "obj3", dateutil.TimeToDateId(now.Add(-30 * time.Minute))}),
[]string{bundle.RelationKeyLinks.String()},
[]int64{1},
[]*pb.RpcRelationListWithValueResponseResponseItem{
{bundle.RelationKeyLinks.String(), 1},
},
},
} {
t.Run(tc.name, func(t *testing.T) {
keys, counters, err := bs.ListRelationsWithValue(spaceId, tc.value)
list, err := bs.ListRelationsWithValue(spaceId, tc.value)
assert.NoError(t, err)
assert.Equal(t, tc.expectedKeys, keys)
assert.Equal(t, tc.expectedCounters, counters)
assert.Equal(t, tc.expectedList, list)
})
}
}

View file

@ -41,7 +41,7 @@ type Service interface {
ObjectTypeAddRelations(ctx context.Context, objectTypeId string, relationKeys []domain.RelationKey) error
ObjectTypeRemoveRelations(ctx context.Context, objectTypeId string, relationKeys []domain.RelationKey) error
ListRelationsWithValue(spaceId string, value *types.Value) (keys []string, counters []int64, err error)
ListRelationsWithValue(spaceId string, value *types.Value) ([]*pb.RpcRelationListWithValueResponseResponseItem, error)
SetSpaceInfo(spaceId string, details *types.Struct) error
SetWorkspaceDashboardId(ctx session.Context, workspaceId string, id string) (setId string, err error)

View file

@ -32,6 +32,64 @@ func (_m *MockService) EXPECT() *MockService_Expecter {
return &MockService_Expecter{mock: &_m.Mock}
}
// AddChatDerivedObject provides a mock function with given fields: ctx, space, chatObjectId
func (_m *MockService) AddChatDerivedObject(ctx context.Context, space clientspace.Space, chatObjectId string) (string, error) {
ret := _m.Called(ctx, space, chatObjectId)
if len(ret) == 0 {
panic("no return value specified for AddChatDerivedObject")
}
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, clientspace.Space, string) (string, error)); ok {
return rf(ctx, space, chatObjectId)
}
if rf, ok := ret.Get(0).(func(context.Context, clientspace.Space, string) string); ok {
r0 = rf(ctx, space, chatObjectId)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(context.Context, clientspace.Space, string) error); ok {
r1 = rf(ctx, space, chatObjectId)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockService_AddChatDerivedObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddChatDerivedObject'
type MockService_AddChatDerivedObject_Call struct {
*mock.Call
}
// AddChatDerivedObject is a helper method to define mock.On call
// - ctx context.Context
// - space clientspace.Space
// - chatObjectId string
func (_e *MockService_Expecter) AddChatDerivedObject(ctx interface{}, space interface{}, chatObjectId interface{}) *MockService_AddChatDerivedObject_Call {
return &MockService_AddChatDerivedObject_Call{Call: _e.mock.On("AddChatDerivedObject", ctx, space, chatObjectId)}
}
func (_c *MockService_AddChatDerivedObject_Call) Run(run func(ctx context.Context, space clientspace.Space, chatObjectId string)) *MockService_AddChatDerivedObject_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(clientspace.Space), args[2].(string))
})
return _c
}
func (_c *MockService_AddChatDerivedObject_Call) Return(chatId string, err error) *MockService_AddChatDerivedObject_Call {
_c.Call.Return(chatId, err)
return _c
}
func (_c *MockService_AddChatDerivedObject_Call) RunAndReturn(run func(context.Context, clientspace.Space, string) (string, error)) *MockService_AddChatDerivedObject_Call {
_c.Call.Return(run)
return _c
}
// CreateObject provides a mock function with given fields: ctx, spaceID, req
func (_m *MockService) CreateObject(ctx context.Context, spaceID string, req objectcreator.CreateObjectRequest) (string, *types.Struct, error) {
ret := _m.Called(ctx, spaceID, req)

View file

@ -7,9 +7,9 @@ import (
"github.com/anyproto/any-sync/commonfile/fileblockstore"
ufsio "github.com/ipfs/boxo/ipld/unixfs/io"
"github.com/ipfs/boxo/path"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
"github.com/ipfs/interface-go-ipfs-core/path"
"github.com/anyproto/anytype-heart/core/files/filehelper"
"github.com/anyproto/anytype-heart/pkg/lib/crypto/symmetric"
@ -37,15 +37,19 @@ func (s *service) hasCid(ctx context.Context, spaceID string, c cid.Cid) (bool,
func (s *service) dataAtPath(ctx context.Context, spaceID string, pth string) (cid.Cid, symmetric.ReadSeekCloser, error) {
dagService := s.dagServiceForSpace(spaceID)
resolvedPath, err := helpers.ResolvePath(ctx, dagService, path.New(pth))
newPath, err := path.NewPath("/ipfs/" + pth)
if err != nil {
return cid.Undef, nil, fmt.Errorf("failed to resolve path %s: %w", pth, err)
}
rCid, err := helpers.ResolveCid(ctx, dagService, newPath)
if err != nil {
return cid.Undef, nil, fmt.Errorf("failed to resolve path %s: %w", pth, err)
}
r, err := s.getFile(ctx, spaceID, resolvedPath.Cid())
r, err := s.getFile(ctx, spaceID, rCid)
if err != nil {
return cid.Undef, nil, fmt.Errorf("failed to resolve path %s: %w", pth, err)
}
return resolvedPath.Cid(), r, nil
return rCid, r, nil
}

View file

@ -87,17 +87,16 @@ func (mw *Middleware) RelationOptions(_ context.Context, _ *pb.RpcRelationOption
}
func (mw *Middleware) RelationListWithValue(_ context.Context, req *pb.RpcRelationListWithValueRequest) *pb.RpcRelationListWithValueResponse {
response := func(keys []string, counters []int64, err error) *pb.RpcRelationListWithValueResponse {
response := func(list []*pb.RpcRelationListWithValueResponseResponseItem, err error) *pb.RpcRelationListWithValueResponse {
m := &pb.RpcRelationListWithValueResponse{Error: &pb.RpcRelationListWithValueResponseError{Code: pb.RpcRelationListWithValueResponseError_NULL}}
if err != nil {
m.Error.Description = getErrorDescription(err)
} else {
m.RelationKeys = keys
m.Counters = counters
m.List = list
}
return m
}
keys, counters, err := getService[detailservice.Service](mw).ListRelationsWithValue(req.SpaceId, req.Value)
return response(keys, counters, err)
list, err := getService[detailservice.Service](mw).ListRelationsWithValue(req.SpaceId, req.Value)
return response(list, err)
}

View file

@ -1082,6 +1082,7 @@
- [Rpc.Relation.ListWithValue.Request](#anytype-Rpc-Relation-ListWithValue-Request)
- [Rpc.Relation.ListWithValue.Response](#anytype-Rpc-Relation-ListWithValue-Response)
- [Rpc.Relation.ListWithValue.Response.Error](#anytype-Rpc-Relation-ListWithValue-Response-Error)
- [Rpc.Relation.ListWithValue.Response.ResponseItem](#anytype-Rpc-Relation-ListWithValue-Response-ResponseItem)
- [Rpc.Relation.Options](#anytype-Rpc-Relation-Options)
- [Rpc.Relation.Options.Request](#anytype-Rpc-Relation-Options-Request)
- [Rpc.Relation.Options.Response](#anytype-Rpc-Relation-Options-Response)
@ -17881,8 +17882,7 @@ Available undo/redo operations
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| error | [Rpc.Relation.ListWithValue.Response.Error](#anytype-Rpc-Relation-ListWithValue-Response-Error) | | |
| relationKeys | [string](#string) | repeated | |
| counters | [int64](#int64) | repeated | |
| list | [Rpc.Relation.ListWithValue.Response.ResponseItem](#anytype-Rpc-Relation-ListWithValue-Response-ResponseItem) | repeated | |
@ -17905,6 +17905,22 @@ Available undo/redo operations
<a name="anytype-Rpc-Relation-ListWithValue-Response-ResponseItem"></a>
### Rpc.Relation.ListWithValue.Response.ResponseItem
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| relationKey | [string](#string) | | |
| counter | [int64](#int64) | | |
<a name="anytype-Rpc-Relation-Options"></a>
### Rpc.Relation.Options

36
go.mod
View file

@ -8,7 +8,7 @@ require (
github.com/VividCortex/ewma v1.2.0
github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
github.com/anyproto/any-store v0.1.1
github.com/anyproto/any-sync v0.5.13
github.com/anyproto/any-sync v0.5.17
github.com/anyproto/go-chash v0.1.0
github.com/anyproto/go-naturaldate/v2 v2.0.2-0.20230524105841-9829cfd13438
github.com/anyproto/lexid v0.0.2
@ -50,14 +50,13 @@ require (
github.com/hbagdi/go-unsplash v0.0.0-20230414214043-474fc02c9119
github.com/huandu/skiplist v1.2.1
github.com/improbable-eng/grpc-web v0.15.0
github.com/ipfs/boxo v0.13.1
github.com/ipfs/boxo v0.24.3
github.com/ipfs/go-block-format v0.2.0
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-flatfs v0.5.1
github.com/ipfs/go-ipld-format v0.6.0
github.com/ipfs/go-log v1.0.5
github.com/ipfs/interface-go-ipfs-core v0.11.2
github.com/joho/godotenv v1.5.1
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e
github.com/kelseyhightower/envconfig v1.4.0
@ -101,12 +100,12 @@ require (
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/image v0.21.0
golang.org/x/image v0.22.0
golang.org/x/mobile v0.0.0-20241016134751-7ff83004ec2c
golang.org/x/net v0.30.0
golang.org/x/oauth2 v0.23.0
golang.org/x/text v0.19.0
google.golang.org/grpc v1.67.1
golang.org/x/oauth2 v0.24.0
golang.org/x/text v0.20.0
google.golang.org/grpc v1.68.0
gopkg.in/Graylog2/go-gelf.v2 v2.0.0-20180125164251-1832d8546a9f
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
@ -122,7 +121,7 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/RoaringBitmap/roaring v1.2.3 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/anyproto/go-slip10 v1.0.0 // indirect
@ -149,11 +148,11 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chigopher/pathlib v0.19.1 // indirect
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
github.com/crackcomm/go-gitignore v0.0.0-20241020182519-7843d2ba8fdf // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
@ -197,11 +196,10 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
github.com/ipfs/go-path v0.1.1 // indirect
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
@ -242,7 +240,8 @@ require (
github.com/pseudomuto/protokit v0.2.1 // indirect
github.com/quic-go/quic-go v0.48.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
@ -267,17 +266,18 @@ require (
github.com/zeebo/errs v1.3.0 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.26.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect

468
go.sum

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -3119,8 +3119,12 @@ message Rpc {
message Response {
Error error = 1;
repeated string relationKeys = 2;
repeated int64 counters = 3;
repeated ResponseItem list = 2;
message ResponseItem {
string relationKey = 1;
int64 counter = 2;
}
message Error {
Code code = 1;

View file

@ -9,7 +9,7 @@ import (
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
)
const RelationChecksum = "d020435326985f2804482fd51f0a5fde92c007683e42a11ce26193c9b2876033"
const RelationChecksum = "44f147da7e8233e89bb42533778c305d0735a54238aa2e5ba331a3396145450d"
const (
RelationKeyTag domain.RelationKey = "tag"
RelationKeyCamera domain.RelationKey = "camera"
@ -1856,6 +1856,7 @@ var (
Hidden: true,
Id: "_brtimestamp",
Key: "timestamp",
MaxCount: 1,
Name: "Timestamp",
ReadOnly: true,
ReadOnlyRelation: true,

View file

@ -1356,7 +1356,7 @@
"format": "date",
"hidden": true,
"key": "timestamp",
"maxCount": 0,
"maxCount": 1,
"name": "Timestamp",
"readonly": true,
"source": "derived"

View file

@ -3,12 +3,10 @@ package helpers
import (
"context"
"fmt"
gopath "path"
"time"
"github.com/ipfs/boxo/coreiface/path"
uio "github.com/ipfs/boxo/ipld/unixfs/io"
ipfspath "github.com/ipfs/boxo/path"
"github.com/ipfs/boxo/path"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
mh "github.com/multiformats/go-multihash"
@ -37,16 +35,11 @@ func LinksAtCid(ctx context.Context, dag ipld.DAGService, pathCid string) ([]*ip
return dir.Links(ctx)
}
func ResolvePath(ctx context.Context, dag ipld.DAGService, p path.Path) (path.Resolved, error) {
if _, ok := p.(path.Resolved); ok {
return p.(path.Resolved), nil
func ResolveCid(ctx context.Context, dag ipld.DAGService, p path.Path) (cid.Cid, error) {
ipath, err := path.NewImmutablePath(p)
if err != nil {
return cid.Undef, fmt.Errorf("unsupported path namespace: %s", p.Namespace())
}
if err := p.IsValid(); err != nil {
return nil, err
}
ipath := ipfspath.Path(p.String())
var resolveOnce resolver.ResolveOnce
switch ipath.Segments()[0] {
case "ipfs":
@ -54,24 +47,19 @@ func ResolvePath(ctx context.Context, dag ipld.DAGService, p path.Path) (path.Re
case "ipld":
resolveOnce = resolver.ResolveSingle
default:
return nil, fmt.Errorf("unsupported path namespace: %s", p.Namespace())
return cid.Undef, fmt.Errorf("unsupported path namespace: %s", p.Namespace())
}
r := &resolver.Resolver{
DAG: dag,
ResolveOnce: resolveOnce,
}
node, rest, err := r.ResolveToLastNode(ctx, ipath)
node, _, err := r.ResolveToLastNode(ctx, ipath)
if err != nil {
return nil, err
return cid.Undef, err
}
root, err := cid.Parse(ipath.Segments()[1])
if err != nil {
return nil, err
}
return path.NewResolvedPath(ipath, node, root, gopath.Join(rest...)), nil
return node, nil
}
// AddLinkToDirectory adds a link to a virtual dir

View file

@ -8,8 +8,8 @@ import (
"time"
dag "github.com/ipfs/boxo/ipld/merkledag"
path "github.com/ipfs/boxo/path"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/boxo/path"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log"
)
@ -44,11 +44,8 @@ type Resolver struct {
// ResolveToLastNode walks the given path and returns the cid of the last node
// referenced by the path
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error) {
c, p, err := path.SplitAbsPath(fpath)
if err != nil {
return cid.Cid{}, nil, err
}
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.ImmutablePath) (cid.Cid, []string, error) {
c, p := fpath.RootCid(), fpath.Segments()[2:]
if len(p) == 0 {
return c, nil, nil