mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-08 05:47:07 +09:00
GO-4146 Merge branch 'main' into GO-4146-new-spacestore
# Conflicts: # .github/workflows/perftests-grafana.yml # go.mod # go.sum
This commit is contained in:
commit
4466d9167d
12 changed files with 260 additions and 99 deletions
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
|
@ -12,7 +12,7 @@ on:
|
|||
run-on-runner:
|
||||
description: 'Specify the runner to use'
|
||||
required: true
|
||||
default: 'arm64'
|
||||
default: 'mac-mini-org-heart'
|
||||
|
||||
|
||||
permissions:
|
||||
|
@ -23,17 +23,17 @@ permissions:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ github.event_name == 'push' && 'arm64' || (github.event.inputs.run-on-runner || 'arm64') }}
|
||||
runs-on: ${{ github.event_name == 'push' && 'mac-mini-org-heart' || (github.event.inputs.run-on-runner || 'mac-mini-org-heart') }}
|
||||
steps:
|
||||
- name: validate agent
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.run-on-runner }}" != "arm64" ]]; then
|
||||
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.run-on-runner }}" != "mac-mini-org-heart" ]]; then
|
||||
echo "Invalid runner"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install Go
|
||||
if: runner.name != 'mac-mini-org-heart'
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.23.2
|
||||
|
@ -50,9 +50,14 @@ jobs:
|
|||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install brew and node deps
|
||||
if: runner.name != 'mac-mini-org-heart'
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
run: make install-brew-and-node-deps
|
||||
|
||||
- name: Setup Xcode
|
||||
uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
with:
|
||||
xcode-version: '16.2'
|
||||
|
||||
- name: Set env vars
|
||||
env:
|
||||
UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }}
|
||||
|
|
23
.github/workflows/nightly.yml
vendored
23
.github/workflows/nightly.yml
vendored
|
@ -14,12 +14,14 @@ on:
|
|||
options:
|
||||
- alpha
|
||||
- beta
|
||||
# schedule:
|
||||
# - cron: '0 0 * * *' # every day at midnight
|
||||
# filters:
|
||||
# branches:
|
||||
# include:
|
||||
# - 'nightly-ci-test'
|
||||
run-on-runner:
|
||||
description: 'Specify the runner to use'
|
||||
required: true
|
||||
default: 'mac-mini-org-heart'
|
||||
type: choice
|
||||
options:
|
||||
- mac-mini-org-heart
|
||||
- macos-14
|
||||
|
||||
permissions:
|
||||
actions: 'write'
|
||||
|
@ -28,9 +30,10 @@ permissions:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: 'macos-14'
|
||||
runs-on: ${{ github.event.inputs.run-on-runner }}
|
||||
steps:
|
||||
- name: Install Go
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.23.2
|
||||
|
@ -47,8 +50,14 @@ jobs:
|
|||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install brew and node deps
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
run: make install-brew-and-node-deps
|
||||
|
||||
- name: Setup Xcode
|
||||
uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
with:
|
||||
xcode-version: '16.2'
|
||||
|
||||
- name: Nightly mode env settings
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
18
.github/workflows/perftests-grafana.yml
vendored
18
.github/workflows/perftests-grafana.yml
vendored
|
@ -6,7 +6,11 @@ on:
|
|||
run-on-runner:
|
||||
description: 'Specify the runner to use'
|
||||
required: true
|
||||
default: 'arm64'
|
||||
default: 'mac-mini-org-heart'
|
||||
perf-test:
|
||||
description: 'Run perf test times'
|
||||
required: true
|
||||
default: '1'
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # every day at midnight
|
||||
filters:
|
||||
|
@ -23,10 +27,10 @@ permissions:
|
|||
|
||||
jobs:
|
||||
perftests-grafana:
|
||||
runs-on: ${{ github.event.inputs.run-on-runner || 'arm64' }}
|
||||
runs-on: ${{ github.event.inputs.run-on-runner || 'mac-mini-org-heart' }}
|
||||
steps:
|
||||
- name: Install Go
|
||||
if: runner.name != 'mac-mini-org-heart'
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.23.2
|
||||
|
@ -43,7 +47,7 @@ jobs:
|
|||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install brew and node deps
|
||||
if: runner.name != 'mac-mini-org-heart'
|
||||
if: ${{ !startsWith(runner.name, 'mac-mini-runner-') }}
|
||||
run: make install-brew-and-node-deps
|
||||
|
||||
- name: Set env vars
|
||||
|
@ -92,8 +96,12 @@ jobs:
|
|||
PROM_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
|
||||
run: |
|
||||
echo "Running perf tests"
|
||||
RUN_COUNT=${{ github.event.inputs.perf-test }}
|
||||
if [[ "${{ github.event_name }}" == "schedule" ]]; then
|
||||
RUN_COUNT=10
|
||||
fi
|
||||
cd cmd/perftester/
|
||||
CGO_ENABLED="1" go run main.go 10
|
||||
CGO_ENABLED="1" go run main.go $RUN_COUNT
|
||||
|
||||
- name: Archive perf tests results
|
||||
uses: actions/upload-artifact@v4
|
||||
|
|
4
.github/workflows/perftests.yml
vendored
4
.github/workflows/perftests.yml
vendored
|
@ -8,7 +8,7 @@ on:
|
|||
run-on-runner-mac:
|
||||
description: 'Specify the runner to use on MacOS'
|
||||
required: true
|
||||
default: 'ARM64'
|
||||
default: 'mac-mini-org-heart'
|
||||
run-on-runner-win:
|
||||
description: 'Specify the runner to use on Windows'
|
||||
required: true
|
||||
|
@ -33,7 +33,7 @@ permissions:
|
|||
jobs:
|
||||
perftests-macos:
|
||||
timeout-minutes: 60
|
||||
runs-on: 'ARM64'
|
||||
runs-on: 'mac-mini-org-heart'
|
||||
steps:
|
||||
- name: Setup GO
|
||||
run: |
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -20,3 +20,4 @@ build
|
|||
/core/anytype/config/nodes/custom.yml
|
||||
/.direnv/
|
||||
/.envrc
|
||||
*.swp
|
||||
|
|
|
@ -164,6 +164,9 @@ type exportContext struct {
|
|||
linkStateFilters *state.Filters
|
||||
isLinkProcess bool
|
||||
includeBackLinks bool
|
||||
relations map[string]struct{}
|
||||
setOfList map[string]struct{}
|
||||
objectTypes map[string]struct{}
|
||||
|
||||
*export
|
||||
}
|
||||
|
@ -182,7 +185,11 @@ func newExportContext(e *export, req pb.RpcObjectListExportRequest) *exportConte
|
|||
zip: req.Zip,
|
||||
linkStateFilters: pbFiltersToState(req.LinksStateFilters),
|
||||
includeBackLinks: req.IncludeBacklinks,
|
||||
export: e,
|
||||
setOfList: make(map[string]struct{}),
|
||||
objectTypes: make(map[string]struct{}),
|
||||
relations: make(map[string]struct{}),
|
||||
|
||||
export: e,
|
||||
}
|
||||
return ec
|
||||
}
|
||||
|
@ -201,6 +208,9 @@ func (e *exportContext) copy() *exportContext {
|
|||
isLinkProcess: e.isLinkProcess,
|
||||
linkStateFilters: e.linkStateFilters,
|
||||
includeBackLinks: e.includeBackLinks,
|
||||
relations: e.relations,
|
||||
setOfList: e.setOfList,
|
||||
objectTypes: e.objectTypes,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,70 +534,75 @@ func (e *exportContext) processFiles(ids []string) ([]string, error) {
|
|||
|
||||
func (e *exportContext) addDerivedObjects() error {
|
||||
processedObjects := make(map[string]struct{}, 0)
|
||||
allRelations, allTypes, allSetOfList, err := e.getRelationsAndTypes(e.docs, processedObjects)
|
||||
err := e.getRelationsAndTypes(e.docs, processedObjects)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
templateRelations, templateTypes, templateSetOfList, err := e.getTemplatesRelationsAndTypes(lo.Union(allTypes, allSetOfList), processedObjects)
|
||||
|
||||
err = e.getTemplatesRelationsAndTypes(processedObjects)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
allRelations = lo.Union(allRelations, templateRelations)
|
||||
allTypes = lo.Union(allTypes, templateTypes)
|
||||
allSetOfList = lo.Union(allSetOfList, templateSetOfList)
|
||||
err = e.addRelationsAndTypes(allTypes, allRelations, allSetOfList)
|
||||
err = e.addRelationsAndTypes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *exportContext) getRelationsAndTypes(notProcessedObjects map[string]*Doc, processedObjects map[string]struct{}) ([]string, []string, []string, error) {
|
||||
allRelations, allTypes, allSetOfList, err := e.collectDerivedObjects(notProcessedObjects)
|
||||
func (e *exportContext) getRelationsAndTypes(notProcessedObjects map[string]*Doc, processedObjects map[string]struct{}) error {
|
||||
err := e.collectDerivedObjects(notProcessedObjects)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return err
|
||||
}
|
||||
// get derived objects only from types,
|
||||
// because relations currently have only system relations and object type
|
||||
if len(allTypes) > 0 || len(allSetOfList) > 0 {
|
||||
relations, objectTypes, setOfList, err := e.getDerivedObjectsForTypes(lo.Union(allTypes, allSetOfList), processedObjects)
|
||||
if len(e.objectTypes) > 0 || len(e.setOfList) > 0 {
|
||||
err = e.getDerivedObjectsForTypes(processedObjects)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return err
|
||||
}
|
||||
allRelations = lo.Union(allRelations, relations)
|
||||
allTypes = lo.Union(allTypes, objectTypes)
|
||||
allSetOfList = lo.Union(allSetOfList, setOfList)
|
||||
}
|
||||
return allRelations, allTypes, allSetOfList, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *exportContext) collectDerivedObjects(objects map[string]*Doc) ([]string, []string, []string, error) {
|
||||
var relations, objectsTypes, setOf []string
|
||||
func (e *exportContext) collectDerivedObjects(objects map[string]*Doc) error {
|
||||
for id := range objects {
|
||||
err := cache.Do(e.picker, id, func(b sb.SmartBlock) error {
|
||||
state := b.NewState().Copy().Filter(e.getStateFilters(id))
|
||||
relations = lo.Union(relations, getObjectRelations(state))
|
||||
objectRelations := getObjectRelations(state)
|
||||
fillObjectsMap(e.relations, objectRelations)
|
||||
details := state.CombinedDetails()
|
||||
if isObjectWithDataview(details) {
|
||||
dataviewRelations, err := getDataviewRelations(state)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
relations = lo.Union(relations, dataviewRelations)
|
||||
fillObjectsMap(e.relations, dataviewRelations)
|
||||
}
|
||||
var objectTypes []string
|
||||
if details.Has(bundle.RelationKeyType) {
|
||||
objectTypeId := details.GetString(bundle.RelationKeyType)
|
||||
objectsTypes = lo.Union(objectsTypes, []string{objectTypeId})
|
||||
objectTypes = append(objectTypes, details.GetString(bundle.RelationKeyType))
|
||||
}
|
||||
if details.Has(bundle.RelationKeyTargetObjectType) {
|
||||
objectTypes = append(objectTypes, details.GetString(bundle.RelationKeyTargetObjectType))
|
||||
}
|
||||
fillObjectsMap(e.objectTypes, objectTypes)
|
||||
setOfList := details.GetStringList(bundle.RelationKeySetOf)
|
||||
setOf = lo.Union(setOf, setOfList)
|
||||
fillObjectsMap(e.setOfList, setOfList)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
return relations, objectsTypes, setOf, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func fillObjectsMap(dst map[string]struct{}, objectsToAdd []string) {
|
||||
for _, objectId := range objectsToAdd {
|
||||
dst[objectId] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func getObjectRelations(state *state.State) []string {
|
||||
|
@ -619,33 +634,40 @@ func getDataviewRelations(state *state.State) ([]string, error) {
|
|||
return relations, err
|
||||
}
|
||||
|
||||
func (e *exportContext) getDerivedObjectsForTypes(allTypes []string, processedObjects map[string]struct{}) ([]string, []string, []string, error) {
|
||||
func (e *exportContext) getDerivedObjectsForTypes(processedObjects map[string]struct{}) error {
|
||||
notProceedTypes := make(map[string]*Doc)
|
||||
var relations, objectTypes []string
|
||||
for _, object := range allTypes {
|
||||
if _, ok := processedObjects[object]; ok {
|
||||
continue
|
||||
}
|
||||
notProceedTypes[object] = nil
|
||||
processedObjects[object] = struct{}{}
|
||||
for object := range e.objectTypes {
|
||||
e.fillNotProcessedTypes(processedObjects, object, notProceedTypes)
|
||||
}
|
||||
for object := range e.setOfList {
|
||||
e.fillNotProcessedTypes(processedObjects, object, notProceedTypes)
|
||||
}
|
||||
if len(notProceedTypes) == 0 {
|
||||
return relations, objectTypes, nil, nil
|
||||
return nil
|
||||
}
|
||||
relations, objectTypes, setOfList, err := e.getRelationsAndTypes(notProceedTypes, processedObjects)
|
||||
err := e.getRelationsAndTypes(notProceedTypes, processedObjects)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return err
|
||||
}
|
||||
return relations, objectTypes, setOfList, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *exportContext) getTemplatesRelationsAndTypes(allTypes []string, processedObjects map[string]struct{}) ([]string, []string, []string, error) {
|
||||
func (e *exportContext) fillNotProcessedTypes(processedObjects map[string]struct{}, object string, notProceedTypes map[string]*Doc) {
|
||||
if _, ok := processedObjects[object]; ok {
|
||||
return
|
||||
}
|
||||
notProceedTypes[object] = nil
|
||||
processedObjects[object] = struct{}{}
|
||||
}
|
||||
|
||||
func (e *exportContext) getTemplatesRelationsAndTypes(processedObjects map[string]struct{}) error {
|
||||
allTypes := lo.MapToSlice(e.objectTypes, func(key string, value struct{}) string { return key })
|
||||
templates, err := e.queryAndFilterObjectsByRelation(e.spaceId, allTypes, bundle.RelationKeyTargetObjectType)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return nil
|
||||
}
|
||||
if len(templates) == 0 {
|
||||
return nil, nil, nil, nil
|
||||
return nil
|
||||
}
|
||||
templatesToProcess := make(map[string]*Doc, len(templates))
|
||||
for _, template := range templates {
|
||||
|
@ -656,14 +678,18 @@ func (e *exportContext) getTemplatesRelationsAndTypes(allTypes []string, process
|
|||
templatesToProcess[id] = templateDoc
|
||||
}
|
||||
}
|
||||
templateRelations, templateType, templateSetOfList, err := e.getRelationsAndTypes(templatesToProcess, processedObjects)
|
||||
err = e.getRelationsAndTypes(templatesToProcess, processedObjects)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
return err
|
||||
}
|
||||
return templateRelations, templateType, templateSetOfList, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *exportContext) addRelationsAndTypes(types, relations, setOfList []string) error {
|
||||
func (e *exportContext) addRelationsAndTypes() error {
|
||||
types := lo.MapToSlice(e.objectTypes, func(key string, value struct{}) string { return key })
|
||||
setOfList := lo.MapToSlice(e.setOfList, func(key string, value struct{}) string { return key })
|
||||
relations := lo.MapToSlice(e.relations, func(key string, value struct{}) string { return key })
|
||||
|
||||
err := e.addRelations(relations)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -947,10 +947,10 @@ func Test_docsForExport(t *testing.T) {
|
|||
relationKey := domain.RelationKey("key")
|
||||
storeFixture.AddObjects(t, spaceId, []objectstore.TestObject{
|
||||
{
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
domain.RelationKey(relationKey): domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
relationKey: domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
},
|
||||
})
|
||||
err := storeFixture.SpaceIndex(spaceId).UpdateObjectLinks(context.Background(), "id", []string{"id1"})
|
||||
|
@ -1016,10 +1016,10 @@ func Test_docsForExport(t *testing.T) {
|
|||
|
||||
storeFixture.AddObjects(t, spaceId, []objectstore.TestObject{
|
||||
{
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
domain.RelationKey(relationKey): domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
relationKey: domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
},
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(relationKey),
|
||||
|
@ -1093,10 +1093,10 @@ func Test_docsForExport(t *testing.T) {
|
|||
|
||||
storeFixture.AddObjects(t, spaceId, []objectstore.TestObject{
|
||||
{
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
domain.RelationKey(relationKey): domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
relationKey: domain.String("value"),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
},
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(relationKey),
|
||||
|
@ -1172,10 +1172,10 @@ func Test_docsForExport(t *testing.T) {
|
|||
|
||||
storeFixture.AddObjects(t, spaceId, []objectstore.TestObject{
|
||||
{
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
domain.RelationKey(relationKey): domain.String(optionId),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyId: domain.String("id"),
|
||||
relationKey: domain.String(optionId),
|
||||
bundle.RelationKeyType: domain.String("objectType"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
},
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(relationKey),
|
||||
|
@ -1967,6 +1967,106 @@ func Test_docsForExport(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
assert.Equal(t, 5, len(expCtx.docs))
|
||||
})
|
||||
t.Run("export template", func(t *testing.T) {
|
||||
// given
|
||||
storeFixture := objectstore.NewStoreFixture(t)
|
||||
objectTypeKey := "customObjectType"
|
||||
objectTypeUniqueKey, err := domain.NewUniqueKey(smartblock.SmartBlockTypeObjectType, objectTypeKey)
|
||||
assert.Nil(t, err)
|
||||
|
||||
templateType := "templateType"
|
||||
templateObjectTypeUniqueKey, err := domain.NewUniqueKey(smartblock.SmartBlockTypeObjectType, templateType)
|
||||
assert.Nil(t, err)
|
||||
|
||||
objectId := "objectId"
|
||||
storeFixture.AddObjects(t, spaceId, []objectstore.TestObject{
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(objectId),
|
||||
bundle.RelationKeyName: domain.String("template"),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyTargetObjectType: domain.String(objectTypeKey),
|
||||
bundle.RelationKeyType: domain.String(templateType),
|
||||
},
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(objectTypeKey),
|
||||
bundle.RelationKeyUniqueKey: domain.String(objectTypeUniqueKey.Marshal()),
|
||||
bundle.RelationKeyLayout: domain.Int64(int64(model.ObjectType_objectType)),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyType: domain.String(objectTypeKey),
|
||||
},
|
||||
{
|
||||
bundle.RelationKeyId: domain.String(templateType),
|
||||
bundle.RelationKeyUniqueKey: domain.String(templateObjectTypeUniqueKey.Marshal()),
|
||||
bundle.RelationKeyLayout: domain.Int64(int64(model.ObjectType_objectType)),
|
||||
bundle.RelationKeySpaceId: domain.String(spaceId),
|
||||
bundle.RelationKeyType: domain.String(objectTypeKey),
|
||||
},
|
||||
})
|
||||
|
||||
smartBlockTest := smarttest.New(objectId)
|
||||
doc := smartBlockTest.NewState().SetDetails(domain.NewDetailsFromMap(map[domain.RelationKey]domain.Value{
|
||||
bundle.RelationKeyId: domain.String(objectId),
|
||||
bundle.RelationKeyType: domain.String(templateType),
|
||||
bundle.RelationKeyTargetObjectType: domain.String(objectTypeKey),
|
||||
}))
|
||||
doc.AddRelationLinks(&model.RelationLink{
|
||||
Key: bundle.RelationKeyId.String(),
|
||||
Format: model.RelationFormat_longtext,
|
||||
})
|
||||
smartBlockTest.Doc = doc
|
||||
|
||||
objectType := smarttest.New(objectTypeKey)
|
||||
objectTypeDoc := objectType.NewState().SetDetails(domain.NewDetailsFromMap(map[domain.RelationKey]domain.Value{
|
||||
bundle.RelationKeyId: domain.String(objectTypeKey),
|
||||
bundle.RelationKeyType: domain.String(objectTypeKey),
|
||||
}))
|
||||
objectTypeDoc.AddRelationLinks(&model.RelationLink{
|
||||
Key: bundle.RelationKeyId.String(),
|
||||
Format: model.RelationFormat_longtext,
|
||||
}, &model.RelationLink{
|
||||
Key: bundle.RelationKeyType.String(),
|
||||
Format: model.RelationFormat_longtext,
|
||||
})
|
||||
objectType.Doc = objectTypeDoc
|
||||
|
||||
templateTypeObject := smarttest.New(templateType)
|
||||
templateTypeObjectDoc := objectType.NewState().SetDetails(domain.NewDetailsFromMap(map[domain.RelationKey]domain.Value{
|
||||
bundle.RelationKeyId: domain.String(templateType),
|
||||
bundle.RelationKeyType: domain.String(templateType),
|
||||
}))
|
||||
templateTypeObjectDoc.AddRelationLinks(&model.RelationLink{
|
||||
Key: bundle.RelationKeyId.String(),
|
||||
Format: model.RelationFormat_longtext,
|
||||
}, &model.RelationLink{
|
||||
Key: bundle.RelationKeyType.String(),
|
||||
Format: model.RelationFormat_longtext,
|
||||
})
|
||||
templateTypeObject.Doc = templateTypeObjectDoc
|
||||
|
||||
objectGetter := mock_cache.NewMockObjectGetter(t)
|
||||
objectGetter.EXPECT().GetObject(context.Background(), objectId).Return(smartBlockTest, nil)
|
||||
objectGetter.EXPECT().GetObject(context.Background(), objectTypeKey).Return(objectType, nil)
|
||||
objectGetter.EXPECT().GetObject(context.Background(), templateType).Return(templateTypeObject, nil)
|
||||
|
||||
e := &export{
|
||||
objectStore: storeFixture,
|
||||
picker: objectGetter,
|
||||
}
|
||||
|
||||
expCtx := newExportContext(e, pb.RpcObjectListExportRequest{
|
||||
SpaceId: spaceId,
|
||||
ObjectIds: []string{objectId},
|
||||
IncludeNested: false,
|
||||
Format: model.Export_Protobuf,
|
||||
})
|
||||
|
||||
// when
|
||||
err = expCtx.docsForExport()
|
||||
|
||||
// then
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, len(expCtx.docs))
|
||||
})
|
||||
t.Run("add default object type and template from dataview", func(t *testing.T) {
|
||||
// given
|
||||
id := "id"
|
||||
|
|
|
@ -65,7 +65,7 @@ func (s *SpaceImport) ProvideCollection(snapshots []*common.Snapshot,
|
|||
}
|
||||
|
||||
func (s *SpaceImport) objectShouldBeSkipped(item *common.Snapshot) bool {
|
||||
return item.Snapshot.SbType == smartblock.SmartBlockTypeSubObject || item.Snapshot.SbType == smartblock.SmartBlockTypeTemplate ||
|
||||
return item.Snapshot.SbType == smartblock.SmartBlockTypeSubObject ||
|
||||
item.Snapshot.SbType == smartblock.SmartBlockTypeRelation || item.Snapshot.SbType == smartblock.SmartBlockTypeObjectType ||
|
||||
item.Snapshot.SbType == smartblock.SmartBlockTypeRelationOption
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func TestSpaceImport_ProvideCollection(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
assert.Nil(t, collection)
|
||||
})
|
||||
t.Run("no widget object - add all objects (except template and subobjects) in Protobuf Import collection", func(t *testing.T) {
|
||||
t.Run("no widget object - add all objects (except subobjects) in Protobuf Import collection", func(t *testing.T) {
|
||||
// given
|
||||
p := SpaceImport{}
|
||||
params := &pb.RpcObjectImportRequestPbParams{NoCollection: false}
|
||||
|
@ -85,9 +85,10 @@ func TestSpaceImport_ProvideCollection(t *testing.T) {
|
|||
assert.Len(t, collection, 1)
|
||||
rootCollectionState := state.NewDocFromSnapshot("", collection[0].Snapshot.ToProto()).(*state.State)
|
||||
objectsInCollection := rootCollectionState.GetStoreSlice(template.CollectionStoreKey)
|
||||
assert.Len(t, objectsInCollection, 2)
|
||||
assert.Len(t, objectsInCollection, 3)
|
||||
assert.Equal(t, objectsInCollection[0], "id1")
|
||||
assert.Equal(t, objectsInCollection[1], "id4")
|
||||
assert.Equal(t, objectsInCollection[1], "id3")
|
||||
assert.Equal(t, objectsInCollection[2], "id4")
|
||||
})
|
||||
t.Run("widget with sets - add only sets in Protobuf Import collection", func(t *testing.T) {
|
||||
// given
|
||||
|
@ -106,6 +107,9 @@ func TestSpaceImport_ProvideCollection(t *testing.T) {
|
|||
Id: "id3",
|
||||
Snapshot: &common.SnapshotModel{
|
||||
SbType: smartblock2.SmartBlockTypeTemplate,
|
||||
Data: &common.StateSnapshot{
|
||||
ObjectTypes: []string{bundle.TypeKeyTemplate.URL()},
|
||||
},
|
||||
},
|
||||
},
|
||||
// page
|
||||
|
@ -191,6 +195,9 @@ func TestSpaceImport_ProvideCollection(t *testing.T) {
|
|||
Id: "id3",
|
||||
Snapshot: &common.SnapshotModel{
|
||||
SbType: smartblock2.SmartBlockTypeTemplate,
|
||||
Data: &common.StateSnapshot{
|
||||
ObjectTypes: []string{bundle.TypeKeyTemplate.URL()},
|
||||
},
|
||||
},
|
||||
},
|
||||
// page
|
||||
|
@ -277,6 +284,9 @@ func TestSpaceImport_ProvideCollection(t *testing.T) {
|
|||
Id: "id3",
|
||||
Snapshot: &common.SnapshotModel{
|
||||
SbType: smartblock2.SmartBlockTypeTemplate,
|
||||
Data: &common.StateSnapshot{
|
||||
ObjectTypes: []string{bundle.TypeKeyTemplate.URL()},
|
||||
},
|
||||
},
|
||||
},
|
||||
// favorite page
|
||||
|
|
10
go.mod
10
go.mod
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/PuerkitoBio/goquery v1.10.2
|
||||
github.com/VividCortex/ewma v1.2.0
|
||||
github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
|
||||
github.com/anyproto/any-store v0.1.7
|
||||
github.com/anyproto/any-store v0.1.8
|
||||
github.com/anyproto/any-sync v0.6.1
|
||||
github.com/anyproto/anytype-publish-server/publishclient v0.0.0-20250131145601-de288583ff2a
|
||||
github.com/anyproto/go-chash v0.1.0
|
||||
|
@ -54,8 +54,8 @@ require (
|
|||
github.com/ipfs/boxo v0.28.0
|
||||
github.com/ipfs/go-block-format v0.2.0
|
||||
github.com/ipfs/go-cid v0.5.0
|
||||
github.com/ipfs/go-datastore v0.8.0
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2-0.20250227125509-a1310bca4792
|
||||
github.com/ipfs/go-datastore v0.8.1
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2
|
||||
github.com/ipfs/go-ipld-format v0.6.0
|
||||
github.com/ipfs/go-log v1.0.5
|
||||
github.com/joho/godotenv v1.5.1
|
||||
|
@ -103,7 +103,7 @@ require (
|
|||
go.uber.org/mock v0.5.0
|
||||
go.uber.org/multierr v1.11.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
|
||||
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
|
||||
golang.org/x/image v0.24.0
|
||||
golang.org/x/mobile v0.0.0-20241108191957-fa514ef75a0f
|
||||
golang.org/x/net v0.35.0
|
||||
|
@ -294,7 +294,7 @@ require (
|
|||
modernc.org/libc v1.61.13 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.8.2 // indirect
|
||||
modernc.org/sqlite v1.34.5 // indirect
|
||||
modernc.org/sqlite v1.36.0 // indirect
|
||||
nhooyr.io/websocket v1.8.7 // indirect
|
||||
)
|
||||
|
||||
|
|
22
go.sum
22
go.sum
|
@ -82,8 +82,8 @@ github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5/go.mod h
|
|||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||
github.com/anyproto/any-store v0.1.7 h1:E3DntI+JXo3h7v0WTUJWH+nm7G4MV0PNOXZ6SFzQ2OU=
|
||||
github.com/anyproto/any-store v0.1.7/go.mod h1:nbyRoJYOlvSWU1xDOrmgPP96UeoTf4eYZ9k+qqLK9k8=
|
||||
github.com/anyproto/any-store v0.1.8 h1:/bxUVq6sBTwYkmPL2g1xUAWNb3axF+zPhP2dvdEBH68=
|
||||
github.com/anyproto/any-store v0.1.8/go.mod h1:GpnVhcGm5aUQtOwCnKeTt4jsWgVXZ773WbQVLFdeCFo=
|
||||
github.com/anyproto/any-sync v0.6.1 h1:Dasbp7qGQme8diGGpzaDQfSDs5o7PAK3E5rxHHrB/+4=
|
||||
github.com/anyproto/any-sync v0.6.1/go.mod h1:5js8TNBdqe75zwlr9XEQSVDtwhsvEU2qLeC2wTnT/Fo=
|
||||
github.com/anyproto/anytype-publish-server/publishclient v0.0.0-20250131145601-de288583ff2a h1:ZZM+0OUCQMWSLSflpkf0ZMVo3V76qEDDIXPpQOClNs0=
|
||||
|
@ -589,10 +589,12 @@ github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNi
|
|||
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
|
||||
github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg=
|
||||
github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk=
|
||||
github.com/ipfs/go-datastore v0.8.0 h1:n8xKnoSTo/28L5KM+Jfz4kfohD889/afdWcDHve9VuY=
|
||||
github.com/ipfs/go-datastore v0.8.0/go.mod h1:BGN3N+sLTEWQUHMtOjmm2GKccMJnVFPgSLp6kshNqRk=
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2-0.20250227125509-a1310bca4792 h1:uEelQJ1AfEM+7WtrOxVJEzdQYfNAe3wyRcMz5ZHchYw=
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2-0.20250227125509-a1310bca4792/go.mod h1:hCh3OKNvlqPQ+retNJy8402Oej6QpX4U18OYzLrfLR8=
|
||||
github.com/ipfs/go-datastore v0.8.1 h1:p4+tWJuopShJgB3kIK0MMvnH6CFPvi7g/S44f2/EHQA=
|
||||
github.com/ipfs/go-datastore v0.8.1/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
|
||||
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
|
||||
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2 h1:cGhG7HXdoLZ/t1NcPt43Yi3sDSivOjaU6y6Gnenb68k=
|
||||
github.com/ipfs/go-ds-flatfs v0.5.2/go.mod h1:hCh3OKNvlqPQ+retNJy8402Oej6QpX4U18OYzLrfLR8=
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ=
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
|
||||
github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE=
|
||||
|
@ -1204,8 +1206,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
|
|||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs=
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo=
|
||||
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
|
||||
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -1701,8 +1703,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
|||
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.34.5 h1:Bb6SR13/fjp15jt70CL4f18JIN7p7dnMExd+UFnF15g=
|
||||
modernc.org/sqlite v1.34.5/go.mod h1:YLuNmX9NKs8wRNK2ko1LW1NGYcc9FkBO69JOt1AR9JE=
|
||||
modernc.org/sqlite v1.36.0 h1:EQXNRn4nIS+gfsKeUTymHIz1waxuv5BzU7558dHSfH8=
|
||||
modernc.org/sqlite v1.36.0/go.mod h1:7MPwH7Z6bREicF9ZVUR78P1IKuxfZ8mRIDHD0iD+8TU=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue