library

package
v1.26.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PropertyTypeEnumText      = PropertyType{propertyTypeEnumText}
	PropertyTypeEnumNumber    = PropertyType{propertyTypeEnumNumber}
	PropertyTypeEnumTimestamp = PropertyType{propertyTypeEnumTimestamp}
	PropertyTypeEnumBoolean   = PropertyType{propertyTypeEnumBoolean}
)

Functions

func ItemRef

func ItemRef(c *ent.Node) (datagraph.Item, error)

func MapNode

func MapNode(isRoot bool, ps *PropertySchemaTable) func(c *ent.Node) (*Node, error)

func RoleHydrationTargetsFromNode

func RoleHydrationTargetsFromNode(root *ent.Node) []*ent.Account

Types

type ExistingPropertyMutation

type ExistingPropertyMutation struct {
	PropertySchemaField
	IsSchemaChanged bool
	Value           string
}

type ExistingPropertyMutations

type ExistingPropertyMutations []*ExistingPropertyMutation

type Mark

type Mark struct{ mark.Mark }

func NewMark

func NewMark(id xid.ID, slug string) Mark

type Node

type Node struct {
	Mark      Mark
	CreatedAt time.Time
	UpdatedAt time.Time
	IndexedAt opt.Optional[time.Time]

	Name            string
	Assets          []*asset.Asset
	WebLink         opt.Optional[link_ref.LinkRef]
	Content         opt.Optional[datagraph.Content]
	Description     opt.Optional[string]
	PrimaryImage    opt.Optional[asset.Asset]
	Owner           profile.Ref
	Parent          opt.Optional[Node]
	Properties      opt.Optional[PropertyTable]
	ChildProperties opt.Optional[PropertySchema]
	HideChildTree   bool
	Tags            tag_ref.Tags
	Collections     collection_item_status.Status // NOTE: Not done yet
	Visibility      visibility.Visibility
	SortKey         lexorank.Key
	RelevanceScore  opt.Optional[float64]
	Metadata        map[string]any

	Nodes []*Node
}

func (*Node) GetAssets

func (c *Node) GetAssets() []*asset.Asset

func (*Node) GetAuthor

func (c *Node) GetAuthor() xid.ID

func (*Node) GetContent

func (c *Node) GetContent() datagraph.Content

func (*Node) GetCreated

func (c *Node) GetCreated() time.Time

func (*Node) GetDesc

func (c *Node) GetDesc() string

func (*Node) GetID

func (c *Node) GetID() xid.ID

func (*Node) GetKind

func (c *Node) GetKind() datagraph.Kind

func (*Node) GetName

func (c *Node) GetName() string

func (*Node) GetProps

func (c *Node) GetProps() map[string]any

func (*Node) GetResourceName

func (*Node) GetResourceName() string

func (*Node) GetSlug

func (c *Node) GetSlug() string

func (*Node) GetTags

func (c *Node) GetTags() []string

func (*Node) GetUpdated

func (c *Node) GetUpdated() time.Time

type NodeID

type NodeID xid.ID

func NodeIDFromString

func NodeIDFromString(id string) (NodeID, error)

func (NodeID) MarshalJSON

func (i NodeID) MarshalJSON() ([]byte, error)

func (NodeID) String

func (i NodeID) String() string

func (*NodeID) UnmarshalJSON

func (i *NodeID) UnmarshalJSON(data []byte) error

type NodeSlug

type NodeSlug string

type Properties

type Properties []*Property

type Property

type Property struct {
	Field PropertySchemaField
	Value opt.Optional[string]
}

type PropertyMutation

type PropertyMutation struct {
	// ID is optional, when set the mutation is modifying an existing field and
	// when not set, the mutation assumes it's a new field.
	ID    opt.Optional[xid.ID]
	Name  string
	Value string
	Type  opt.Optional[PropertyType]
	Sort  opt.Optional[string]
}

Property mutations are used to update properties on a node.

type PropertyMutationList

type PropertyMutationList []*PropertyMutation

type PropertySchema

type PropertySchema struct {
	ID     xid.ID
	Fields PropertySchemaFields
}

func (PropertySchema) FieldIDs

func (p PropertySchema) FieldIDs() []xid.ID

func (PropertySchema) GetField

func (p PropertySchema) GetField(id xid.ID) (*PropertySchemaField, bool)

func (PropertySchema) Split

Split takes a mutation (a list of properties to update) and splits it into two lists, one for properties that need to be added to the schema and current schema fields which can be processed as simple property update operations. We also need to get the actual field ID for each existing property.

type PropertySchemaField

type PropertySchemaField struct {
	ID   xid.ID
	Name string
	Type PropertyType
	Sort string
}

type PropertySchemaFields

type PropertySchemaFields []*PropertySchemaField

type PropertySchemaMutation

type PropertySchemaMutation struct {
	NewProps      PropertyMutationList
	ExistingProps ExistingPropertyMutations
	RemovedProps  ExistingPropertyMutations
}

type PropertySchemaQueryRow

type PropertySchemaQueryRow struct {
	SchemaID xid.ID       `db:"schema_id"`
	FieldID  xid.ID       `db:"field_id"`
	Name     string       `db:"name"`
	Type     PropertyType `db:"type"`
	Sort     string       `db:"sort"`
	Source   string       `db:"source"`
}

PropertySchemaQueryRow is a row from the property schema query which pulls all the property schemas for both sibling and child properties of a node.

type PropertySchemaQueryRows

type PropertySchemaQueryRows []PropertySchemaQueryRow

func (PropertySchemaQueryRows) Map

Map harmonises the splits the raw rows into sibling and child schemas.

type PropertySchemaTable

type PropertySchemaTable struct {
	// contains filtered or unexported fields
}

func (*PropertySchemaTable) BuildPropertyTable

func (r *PropertySchemaTable) BuildPropertyTable(in []*ent.Property, isRoot bool) *PropertyTable

BuildPropertyTable yields the properties that are set for the node and also properties that don't have values by merging in the unused property schemas.

func (PropertySchemaTable) ChildSchemas

func (r PropertySchemaTable) ChildSchemas() *PropertySchema

type PropertyTable

type PropertyTable struct {
	Schema     PropertySchema
	Properties Properties
}

type PropertyType

type PropertyType struct {
	// contains filtered or unexported fields
}

func NewPropertyType

func NewPropertyType(__iNpUt__ string) (PropertyType, error)

func (PropertyType) Format

func (r PropertyType) Format(f fmt.State, verb rune)

func (PropertyType) MarshalText

func (r PropertyType) MarshalText() ([]byte, error)

func (*PropertyType) Scan

func (r *PropertyType) Scan(__iNpUt__ any) error

func (PropertyType) String

func (r PropertyType) String() string

func (*PropertyType) UnmarshalText

func (r *PropertyType) UnmarshalText(__iNpUt__ []byte) error

func (PropertyType) Value

func (r PropertyType) Value() (driver.Value, error)

type QueryKey

type QueryKey struct{ mark.Queryable }

func NewID

func NewID(id xid.ID) QueryKey

func NewKey

func NewKey(in string) QueryKey

func NewQueryKey

func NewQueryKey(m Mark) QueryKey

func (QueryKey) Predicate

func (m QueryKey) Predicate() (p predicate.Node)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL