mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Middleware | 0.15.10-SNAPSHOT (#1546)
This commit is contained in:
parent
9d7779159b
commit
73bb057f9a
10 changed files with 174 additions and 37 deletions
2
.github/workflows/check.yml
vendored
2
.github/workflows/check.yml
vendored
|
@ -1,7 +1,7 @@
|
|||
on:
|
||||
pull_request:
|
||||
# add "synchronize" in "types", in order to trigger workflow for pull request commit(s) pushes.
|
||||
types: [opened, synchronize]
|
||||
types: [opened]
|
||||
branches: [develop]
|
||||
name: Run debug unit tests
|
||||
jobs:
|
||||
|
|
|
@ -17,5 +17,6 @@ enum class SmartBlockType {
|
|||
BUNDLED_RELATION,
|
||||
INDEXED_RELATION,
|
||||
ANYTYPE_PROFILE,
|
||||
DATABASE
|
||||
DATABASE,
|
||||
BUNDLED_TEMPLATE
|
||||
}
|
|
@ -8,9 +8,7 @@ import com.anytypeio.anytype.core_models.Id
|
|||
data class DataViewRestrictions(val block: Id, val restrictions: List<DataViewRestriction>)
|
||||
|
||||
enum class DataViewRestriction {
|
||||
CREATE_VIEW,
|
||||
FILTERS,
|
||||
CREATE_RELATION,
|
||||
CREATE_OBJECT,
|
||||
EDIT_OBJECT
|
||||
VIEWS,
|
||||
RELATION,
|
||||
CREATE_OBJECT
|
||||
}
|
|
@ -13,17 +13,17 @@ enum class ObjectRestriction {
|
|||
/**
|
||||
* restricts work with relations
|
||||
*/
|
||||
RELATION,
|
||||
RELATIONS,
|
||||
|
||||
/**
|
||||
* restricts edit details
|
||||
* restricts work with details
|
||||
*/
|
||||
DETAILS,
|
||||
|
||||
/**
|
||||
* restricts create a new block
|
||||
* restricts work with blocks
|
||||
*/
|
||||
CREATE_BLOCK,
|
||||
BLOCKS,
|
||||
|
||||
/**
|
||||
* restricts changing type
|
||||
|
@ -33,6 +33,8 @@ enum class ObjectRestriction {
|
|||
/**
|
||||
* restricts changing layout
|
||||
*/
|
||||
LAYOUT_CHANGE
|
||||
LAYOUT_CHANGE,
|
||||
|
||||
TEMPLATE
|
||||
|
||||
}
|
|
@ -86,7 +86,7 @@ ext {
|
|||
|
||||
// Anytype
|
||||
|
||||
middleware_version = '0.15.8'
|
||||
middleware_version = '0.15.10-SNAPSHOT'
|
||||
|
||||
mainApplication = [
|
||||
kotlin: "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
|
||||
|
|
|
@ -35,7 +35,7 @@ fun anytype.Event.Message.toCoreModels(
|
|||
type = type,
|
||||
objectTypes = event.objectTypes.map { it.toCoreModels() },
|
||||
relations = event.relations.map { it.toCoreModels() },
|
||||
objectRestrictions = event.restrictions?.object_?.map { it.toCoreModel() }.orEmpty(),
|
||||
objectRestrictions = event.restrictions?.object_?.mapNotNull { it.toCoreModel() }.orEmpty(),
|
||||
dataViewRestrictions = event.restrictions?.dataview?.map { it.toCoreModel() }.orEmpty()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -481,27 +481,31 @@ fun MSmartBlockType.toCoreModel(): SmartBlockType = when (this) {
|
|||
MSmartBlockType.IndexedRelation -> SmartBlockType.INDEXED_RELATION
|
||||
MSmartBlockType.BundledObjectType -> SmartBlockType.BUNDLED_OBJECT_TYPE
|
||||
MSmartBlockType.AnytypeProfile -> SmartBlockType.ANYTYPE_PROFILE
|
||||
MSmartBlockType.BundledTemplate -> SmartBlockType.BUNDLED_TEMPLATE
|
||||
}
|
||||
|
||||
// ---------------------- RESTRICTIONS ------------------------
|
||||
fun MObjectRestriction.toCoreModel(): ObjectRestriction = when (this) {
|
||||
fun MObjectRestriction.toCoreModel(): ObjectRestriction? = when (this) {
|
||||
MObjectRestriction.Delete -> ObjectRestriction.DELETE
|
||||
MObjectRestriction.Relation -> ObjectRestriction.RELATION
|
||||
MObjectRestriction.Header -> ObjectRestriction.DETAILS
|
||||
MObjectRestriction.CreateBlock -> ObjectRestriction.CREATE_BLOCK
|
||||
MObjectRestriction.Relations -> ObjectRestriction.RELATIONS
|
||||
MObjectRestriction.Details -> ObjectRestriction.DETAILS
|
||||
MObjectRestriction.Blocks -> ObjectRestriction.BLOCKS
|
||||
MObjectRestriction.TypeChange -> ObjectRestriction.TYPE_CHANGE
|
||||
MObjectRestriction.LayoutChange -> ObjectRestriction.LAYOUT_CHANGE
|
||||
MObjectRestriction.Template -> ObjectRestriction.TEMPLATE
|
||||
MObjectRestriction.None -> null
|
||||
}
|
||||
|
||||
fun MDVRestrictions.toCoreModel(): DataViewRestrictions {
|
||||
return DataViewRestrictions(
|
||||
block = this.blockId,
|
||||
restrictions = this.restrictions.map { it.toCoreModel() }
|
||||
restrictions = this.restrictions.mapNotNull { it.toCoreModel() }
|
||||
)
|
||||
}
|
||||
|
||||
fun MDVRestriction.toCoreModel(): DataViewRestriction = when (this) {
|
||||
Restrictions.DataviewRestriction.CreateView -> DataViewRestriction.CREATE_VIEW
|
||||
Restrictions.DataviewRestriction.Filters -> DataViewRestriction.FILTERS
|
||||
Restrictions.DataviewRestriction.CreateRelation -> DataViewRestriction.CREATE_RELATION
|
||||
Restrictions.DataviewRestriction.CreateObject -> DataViewRestriction.CREATE_OBJECT
|
||||
Restrictions.DataviewRestriction.EditObject -> DataViewRestriction.EDIT_OBJECT
|
||||
fun MDVRestriction.toCoreModel(): DataViewRestriction? = when (this) {
|
||||
Restrictions.DataviewRestriction.DVViews -> DataViewRestriction.VIEWS
|
||||
Restrictions.DataviewRestriction.DVRelation -> DataViewRestriction.RELATION
|
||||
Restrictions.DataviewRestriction.DVCreateObject -> DataViewRestriction.CREATE_OBJECT
|
||||
Restrictions.DataviewRestriction.DVNone -> null
|
||||
}
|
|
@ -1406,6 +1406,7 @@ message Rpc {
|
|||
string contextId = 1;
|
||||
string blockId = 2;
|
||||
google.protobuf.Struct record = 3;
|
||||
string templateId = 4;
|
||||
}
|
||||
|
||||
message Response {
|
||||
|
@ -1732,6 +1733,32 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
|
||||
message Show {
|
||||
message Request {
|
||||
string contextId = 1; // id of the context blo1k
|
||||
string blockId = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
ResponseEvent event = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
ANYTYPE_NEEDS_UPGRADE = 10; // failed to read unknown data format – need to upgrade anytype
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message GetPublicWebURL {
|
||||
message Request {
|
||||
string blockId = 1;
|
||||
|
@ -3088,10 +3115,37 @@ message Rpc {
|
|||
}
|
||||
|
||||
enum Format {
|
||||
MD = 0;
|
||||
Markdown = 0;
|
||||
Protobuf = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message ExportTemplates {
|
||||
message Request {
|
||||
// the path where export files will place
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
string path = 2;
|
||||
ResponseEvent event = 3;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message MakeTemplate {
|
||||
message Request {
|
||||
// id of block for making them template
|
||||
|
@ -3115,7 +3169,80 @@ message Rpc {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message MakeTemplateByObjectType {
|
||||
message Request {
|
||||
// id of desired object type
|
||||
string objectType = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
// created template id
|
||||
string id = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message CloneTemplate {
|
||||
message Request {
|
||||
// id of template block for cloning
|
||||
string contextId = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
// created template id
|
||||
string id = 2;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message ApplyTemplate {
|
||||
message Request {
|
||||
string contextId = 1;
|
||||
// id of template
|
||||
string templateId = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
Error error = 1;
|
||||
|
||||
message Error {
|
||||
Code code = 1;
|
||||
string description = 2;
|
||||
|
||||
enum Code {
|
||||
NULL = 0;
|
||||
UNKNOWN_ERROR = 1;
|
||||
BAD_INPUT = 2;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Debug {
|
||||
|
|
|
@ -56,4 +56,5 @@ message ObjectStoreChecksums {
|
|||
int32 filesForceReindexCounter = 5; // increased in order to fully reindex all objects
|
||||
int32 idxRebuildCounter = 6; // increased in order to remove indexes and reindex everything. Automatically triggers objects and files reindex(one time only)
|
||||
int32 fulltextRebuild = 7; // increased in order to perform fulltext indexing for all type of objects (useful when we change fulltext config)
|
||||
string bundledTemplates = 8;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ enum SmartBlockType {
|
|||
File = 0x100;
|
||||
|
||||
Template = 0x120;
|
||||
BundledTemplate = 0x121;
|
||||
|
||||
MarketplaceType = 0x110;
|
||||
MarketplaceRelation = 0x111;
|
||||
|
@ -374,14 +375,18 @@ message Restrictions {
|
|||
repeated DataviewRestrictions dataview = 2;
|
||||
|
||||
enum ObjectRestriction {
|
||||
None = 0;
|
||||
// restricts delete
|
||||
Delete = 0;
|
||||
Delete = 1;
|
||||
// restricts work with relations
|
||||
Relation = 1;
|
||||
// restricts edit a header (title, description, etc.)
|
||||
Header = 2;
|
||||
// restricts create a new block
|
||||
CreateBlock = 3;
|
||||
Relations = 2;
|
||||
// restricts work with blocks
|
||||
Blocks = 3;
|
||||
// restricts work with details
|
||||
Details = 4;
|
||||
TypeChange = 5;
|
||||
LayoutChange = 6;
|
||||
Template = 7;
|
||||
}
|
||||
|
||||
|
||||
|
@ -391,11 +396,10 @@ message Restrictions {
|
|||
}
|
||||
|
||||
enum DataviewRestriction {
|
||||
CreateView = 0;
|
||||
Filters = 1;
|
||||
CreateRelation = 2;
|
||||
CreateObject = 3;
|
||||
EditObject = 4;
|
||||
DVNone = 0;
|
||||
DVRelation = 1;
|
||||
DVCreateObject = 2;
|
||||
DVViews = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue