mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-10 18:10:49 +09:00
GO-4969: Distinguish Property from PropertyWithValue
This commit is contained in:
parent
5fd171130b
commit
20bd325355
5 changed files with 114 additions and 85 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -344,7 +344,7 @@ components:
|
|||
properties:
|
||||
description: The properties of the object
|
||||
items:
|
||||
$ref: '#/components/schemas/object.Property'
|
||||
$ref: '#/components/schemas/object.PropertyWithValue'
|
||||
type: array
|
||||
uniqueItems: false
|
||||
snippet:
|
||||
|
@ -407,7 +407,7 @@ components:
|
|||
properties:
|
||||
description: The properties of the object
|
||||
items:
|
||||
$ref: '#/components/schemas/object.Property'
|
||||
$ref: '#/components/schemas/object.PropertyWithValue'
|
||||
type: array
|
||||
uniqueItems: false
|
||||
snippet:
|
||||
|
@ -425,29 +425,6 @@ components:
|
|||
object.Property:
|
||||
description: The property block, if applicable
|
||||
properties:
|
||||
checkbox:
|
||||
description: The checkbox value, if applicable
|
||||
enum:
|
||||
- true
|
||||
- false
|
||||
example: true
|
||||
type: boolean
|
||||
date:
|
||||
description: The date value, if applicable
|
||||
example: "2025-02-14T12:34:56Z"
|
||||
type: string
|
||||
email:
|
||||
description: The email value, if applicable
|
||||
example: example@example.com
|
||||
type: string
|
||||
files:
|
||||
description: The file references, if applicable
|
||||
example:
|
||||
- '[''fileId'']'
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
uniqueItems: false
|
||||
format:
|
||||
$ref: '#/components/schemas/object.PropertyFormat'
|
||||
id:
|
||||
|
@ -458,46 +435,14 @@ components:
|
|||
description: The key of the property
|
||||
example: last_modified_date
|
||||
type: string
|
||||
multi_select:
|
||||
description: The multi-select values, if applicable
|
||||
items:
|
||||
$ref: '#/components/schemas/object.Tag'
|
||||
type: array
|
||||
uniqueItems: false
|
||||
name:
|
||||
description: The name of the property
|
||||
example: Last modified date
|
||||
type: string
|
||||
number:
|
||||
description: The number value, if applicable
|
||||
example: 42
|
||||
type: number
|
||||
object:
|
||||
description: The data model of the object
|
||||
example: property
|
||||
type: string
|
||||
objects:
|
||||
description: The object references, if applicable
|
||||
example:
|
||||
- '[''objectId'']'
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
uniqueItems: false
|
||||
phone:
|
||||
description: The phone number value, if applicable
|
||||
example: "+1234567890"
|
||||
type: string
|
||||
select:
|
||||
$ref: '#/components/schemas/object.Tag'
|
||||
text:
|
||||
description: The text value, if applicable
|
||||
example: Some text...
|
||||
type: string
|
||||
url:
|
||||
description: The url value, if applicable
|
||||
example: https://example.com
|
||||
type: string
|
||||
type: object
|
||||
object.PropertyEntry:
|
||||
properties:
|
||||
|
@ -595,6 +540,82 @@ components:
|
|||
property:
|
||||
$ref: '#/components/schemas/object.Property'
|
||||
type: object
|
||||
object.PropertyWithValue:
|
||||
properties:
|
||||
checkbox:
|
||||
description: The checkbox value, if applicable
|
||||
enum:
|
||||
- true
|
||||
- false
|
||||
example: true
|
||||
type: boolean
|
||||
date:
|
||||
description: The date value, if applicable
|
||||
example: "2025-02-14T12:34:56Z"
|
||||
type: string
|
||||
email:
|
||||
description: The email value, if applicable
|
||||
example: example@example.com
|
||||
type: string
|
||||
files:
|
||||
description: The file references, if applicable
|
||||
example:
|
||||
- '[''fileId'']'
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
uniqueItems: false
|
||||
format:
|
||||
$ref: '#/components/schemas/object.PropertyFormat'
|
||||
id:
|
||||
description: The id of the property
|
||||
example: bafyreids36kpw5ppuwm3ce2p4ezb3ab7cihhkq6yfbwzwpp4mln7rcgw7a
|
||||
type: string
|
||||
key:
|
||||
description: The key of the property
|
||||
example: last_modified_date
|
||||
type: string
|
||||
multi_select:
|
||||
description: The multi-select values, if applicable
|
||||
items:
|
||||
$ref: '#/components/schemas/object.Tag'
|
||||
type: array
|
||||
uniqueItems: false
|
||||
name:
|
||||
description: The name of the property
|
||||
example: Last modified date
|
||||
type: string
|
||||
number:
|
||||
description: The number value, if applicable
|
||||
example: 42
|
||||
type: number
|
||||
object:
|
||||
description: The data model of the object
|
||||
example: property
|
||||
type: string
|
||||
objects:
|
||||
description: The object references, if applicable
|
||||
example:
|
||||
- '[''objectId'']'
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
uniqueItems: false
|
||||
phone:
|
||||
description: The phone number value, if applicable
|
||||
example: "+1234567890"
|
||||
type: string
|
||||
select:
|
||||
$ref: '#/components/schemas/object.Tag'
|
||||
text:
|
||||
description: The text value, if applicable
|
||||
example: Some text...
|
||||
type: string
|
||||
url:
|
||||
description: The url value, if applicable
|
||||
example: https://example.com
|
||||
type: string
|
||||
type: object
|
||||
object.Tag:
|
||||
description: The select value, if applicable
|
||||
properties:
|
||||
|
@ -719,7 +740,7 @@ components:
|
|||
example: My object
|
||||
type: string
|
||||
properties:
|
||||
description: The properties to set on the object
|
||||
description: The properties to set for the object
|
||||
items:
|
||||
$ref: '#/components/schemas/object.PropertyEntry'
|
||||
type: array
|
||||
|
|
|
@ -58,30 +58,30 @@ type ObjectResponse struct {
|
|||
}
|
||||
|
||||
type Object struct {
|
||||
Object string `json:"object" example:"object"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreie6n5l5nkbjal37su54cha4coy7qzuhrnajluzv5qd5jvtsrxkequ"` // The id of the object
|
||||
Name string `json:"name" example:"My object"` // The name of the object
|
||||
Icon Icon `json:"icon"` // The icon of the object
|
||||
Archived bool `json:"archived" example:"false"` // Whether the object is archived
|
||||
SpaceId string `json:"space_id" example:"bafyreigyfkt6rbv24sbv5aq2hko3bhmv5xxlf22b4bypdu6j7hnphm3psq.23me69r569oi1"` // The id of the space the object is in
|
||||
Snippet string `json:"snippet" example:"The beginning of the object body..."` // The snippet of the object, especially important for notes as they don't have a name
|
||||
Layout string `json:"layout" example:"basic"` // The layout of the object
|
||||
Type Type `json:"type"` // The type of the object
|
||||
Properties []Property `json:"properties"` // The properties of the object
|
||||
Object string `json:"object" example:"object"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreie6n5l5nkbjal37su54cha4coy7qzuhrnajluzv5qd5jvtsrxkequ"` // The id of the object
|
||||
Name string `json:"name" example:"My object"` // The name of the object
|
||||
Icon Icon `json:"icon"` // The icon of the object
|
||||
Archived bool `json:"archived" example:"false"` // Whether the object is archived
|
||||
SpaceId string `json:"space_id" example:"bafyreigyfkt6rbv24sbv5aq2hko3bhmv5xxlf22b4bypdu6j7hnphm3psq.23me69r569oi1"` // The id of the space the object is in
|
||||
Snippet string `json:"snippet" example:"The beginning of the object body..."` // The snippet of the object, especially important for notes as they don't have a name
|
||||
Layout string `json:"layout" example:"basic"` // The layout of the object
|
||||
Type Type `json:"type"` // The type of the object
|
||||
Properties []PropertyWithValue `json:"properties"` // The properties of the object
|
||||
}
|
||||
|
||||
type ObjectWithBlocks struct {
|
||||
Object string `json:"object" example:"object"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreie6n5l5nkbjal37su54cha4coy7qzuhrnajluzv5qd5jvtsrxkequ"` // The id of the object
|
||||
Name string `json:"name" example:"My object"` // The name of the object
|
||||
Icon Icon `json:"icon"` // The icon of the object
|
||||
Archived bool `json:"archived" example:"false"` // Whether the object is archived
|
||||
SpaceId string `json:"space_id" example:"bafyreigyfkt6rbv24sbv5aq2hko3bhmv5xxlf22b4bypdu6j7hnphm3psq.23me69r569oi1"` // The id of the space the object is in
|
||||
Snippet string `json:"snippet" example:"The beginning of the object body..."` // The snippet of the object, especially important for notes as they don't have a name
|
||||
Layout string `json:"layout" example:"basic"` // The layout of the object
|
||||
Type Type `json:"type"` // The type of the object
|
||||
Properties []Property `json:"properties"` // The properties of the object
|
||||
Blocks []Block `json:"blocks"` // The blocks of the object. Omitted in endpoints for searching or listing objects, only included when getting single object.
|
||||
Object string `json:"object" example:"object"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreie6n5l5nkbjal37su54cha4coy7qzuhrnajluzv5qd5jvtsrxkequ"` // The id of the object
|
||||
Name string `json:"name" example:"My object"` // The name of the object
|
||||
Icon Icon `json:"icon"` // The icon of the object
|
||||
Archived bool `json:"archived" example:"false"` // Whether the object is archived
|
||||
SpaceId string `json:"space_id" example:"bafyreigyfkt6rbv24sbv5aq2hko3bhmv5xxlf22b4bypdu6j7hnphm3psq.23me69r569oi1"` // The id of the space the object is in
|
||||
Snippet string `json:"snippet" example:"The beginning of the object body..."` // The snippet of the object, especially important for notes as they don't have a name
|
||||
Layout string `json:"layout" example:"basic"` // The layout of the object
|
||||
Type Type `json:"type"` // The type of the object
|
||||
Properties []PropertyWithValue `json:"properties"` // The properties of the object
|
||||
Blocks []Block `json:"blocks"` // The blocks of the object. Omitted in endpoints for searching or listing objects, only included when getting single object.
|
||||
}
|
||||
|
||||
type Block struct {
|
||||
|
@ -136,6 +136,14 @@ type UpdatePropertyRequest struct {
|
|||
}
|
||||
|
||||
type Property struct {
|
||||
Object string `json:"object" example:"property"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreids36kpw5ppuwm3ce2p4ezb3ab7cihhkq6yfbwzwpp4mln7rcgw7a"` // The id of the property
|
||||
Key string `json:"key" example:"last_modified_date"` // The key of the property
|
||||
Name string `json:"name" example:"Last modified date"` // The name of the property
|
||||
Format PropertyFormat `json:"format" example:"date" enums:"text,number,select,multi_select,date,files,checkbox,url,email,phone,objects"` // The format of the property
|
||||
}
|
||||
|
||||
type PropertyWithValue struct {
|
||||
Object string `json:"object" example:"property"` // The data model of the object
|
||||
Id string `json:"id" example:"bafyreids36kpw5ppuwm3ce2p4ezb3ab7cihhkq6yfbwzwpp4mln7rcgw7a"` // The id of the property
|
||||
Key string `json:"key" example:"last_modified_date"` // The key of the property
|
||||
|
|
|
@ -451,8 +451,8 @@ func (s *service) mapPropertyFromRecord(record *types.Struct) (string, Property)
|
|||
}
|
||||
|
||||
// getPropertiesFromStruct retrieves the properties from the details.
|
||||
func (s *service) getPropertiesFromStruct(details *types.Struct, propertyMap map[string]Property, tagMap map[string]Tag) []Property {
|
||||
properties := make([]Property, 0)
|
||||
func (s *service) getPropertiesFromStruct(details *types.Struct, propertyMap map[string]Property, tagMap map[string]Tag) []PropertyWithValue {
|
||||
properties := make([]PropertyWithValue, 0)
|
||||
for rk, value := range details.GetFields() {
|
||||
if _, isExcluded := excludedSystemProperties[rk]; isExcluded {
|
||||
continue
|
||||
|
@ -538,8 +538,8 @@ func (s *service) convertPropertyValue(key string, value *types.Value, format Pr
|
|||
}
|
||||
|
||||
// buildPropertyWithValue creates a Property based on the format and converted value.
|
||||
func (s *service) buildPropertyWithValue(id string, key string, name string, format PropertyFormat, val interface{}) Property {
|
||||
p := &Property{
|
||||
func (s *service) buildPropertyWithValue(id string, key string, name string, format PropertyFormat, val interface{}) PropertyWithValue {
|
||||
p := &PropertyWithValue{
|
||||
Object: "property",
|
||||
Id: id,
|
||||
Key: key,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue