data

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 8 Imported by: 8

Documentation

Index

Constants

View Source
const (
	EntityTypeRoot       = "Root"
	EntityTypePermission = "Permission"
	EntityTypeUser       = "User"
	EntityTypeClient     = "Client"
	EntityTypeRole       = "Role"
)

Variables

This section is empty.

Functions

func FileDecode

func FileDecode(encoded string) []byte

func FileEncode

func FileEncode(content []byte) string

Types

type Choice added in v0.1.5

type Choice interface {
	// selected index
	Index() int64
	SetIndex(index int64) Choice
}

type ChoiceFieldSchema added in v0.1.5

type ChoiceFieldSchema interface {
	FieldSchema
	GetChoices() []string
	SetChoices([]string) ChoiceFieldSchema
}

type CompleteChoice added in v0.1.5

type CompleteChoice interface {
	Choice

	// selected option
	Option() string

	// all options
	Options() []string

	SetOptions(options []string) Choice

	IsValid() bool
	Count() int
	Select(option string) bool
}

type Connector added in v0.1.0

type Connector interface {
	Connect(context.Context)
	Disconnect(context.Context)
	IsConnected(context.Context) bool

	Connected() signalslots.Signal
	Disconnected() signalslots.Signal
}

type Entity

type Entity interface {
	GetId() string
	GetType() string

	SetId(string)
	SetType(string)

	Impl() any
}

type EntityBinding

type EntityBinding interface {
	Entity

	DoMulti(context.Context, func(EntityBinding))

	GetField(string) FieldBinding
}

type EntityFieldValidator

type EntityFieldValidator interface {
	// RegisterEntityFields registers required fields for an entity type
	RegisterEntityFields(entityType string, fields ...string)
	// ValidateFields checks if all registered entity fields exist in the schema
	ValidateFields(context.Context) error
}

EntityFieldValidator ensures that entities and their fields exist in the schema

func NewEntityFieldValidator

func NewEntityFieldValidator(store Store) EntityFieldValidator

type EntityList added in v0.1.5

type EntityList interface {
	// GetEntities returns all entity IDs in the list
	GetEntities() []string

	// SetEntities updates all entity IDs in the list
	SetEntities(entities []string) EntityList

	// Add adds an entity ID to the list if not already present
	// Returns true if added, false if already exists
	Add(entity string) bool

	// Remove removes an entity ID from the list
	// Returns true if removed, false if not found
	Remove(entity string) bool

	// Contains checks if an entity ID is in the list
	Contains(entity string) bool

	// Count returns the number of entities in the list
	Count() int

	// Clear removes all entities from the list
	Clear() EntityList
}

EntityList represents a collection of entity references

type EntityManager added in v0.1.0

type EntityManager interface {
	CreateEntity(ctx context.Context, entityType, parentId, name string) string
	GetEntity(ctx context.Context, entityId string) Entity
	DeleteEntity(ctx context.Context, entityId string)
	FindEntities(ctx context.Context, entityType string) []string
	GetEntityTypes(ctx context.Context) []string
	EntityExists(ctx context.Context, entityId string) bool
}

type EntityManagerSetter added in v0.1.0

type EntityManagerSetter interface {
	SetEntityManager(EntityManager)
}

type EntitySchema

type EntitySchema interface {
	GetType() string
	GetFields() []FieldSchema
	GetFieldNames() []string
	GetField(string) FieldSchema

	SetType(string)
	SetFields([]FieldSchema)
}

type Field

type Field interface {
	GetValue() Value
	GetWriteTime() time.Time
	GetWriter() string
	GetEntityId() string
	GetFieldName() string
}

type FieldAuthorizer added in v0.1.5

type FieldAuthorizer interface {
	AccessorId() string
	IsAuthorized(ctx context.Context, entityId, fieldName string, forWrite bool) bool
}

type FieldBinding

type FieldBinding interface {
	GetEntityId() string
	GetFieldName() string
	GetWriteTime() time.Time
	GetWriter() string

	IsInt() bool
	IsFloat() bool
	IsString() bool
	IsBool() bool
	IsBinaryFile() bool
	IsEntityReference() bool
	IsTimestamp() bool
	IsChoice() bool
	IsEntityList() bool

	GetValue() Value
	GetInt() int64
	GetFloat() float64
	GetString() string
	GetBool() bool
	GetBinaryFile() string
	GetEntityReference() string
	GetTimestamp() time.Time
	GetChoice() Choice
	GetCompleteChoice(context.Context) CompleteChoice
	GetEntityList() EntityList

	SetValue(Value) FieldBinding

	WriteValue(context.Context, Value) FieldBinding
	WriteInt(context.Context, ...interface{}) FieldBinding
	WriteFloat(context.Context, ...interface{}) FieldBinding
	WriteString(context.Context, ...interface{}) FieldBinding
	WriteBool(context.Context, ...interface{}) FieldBinding
	WriteBinaryFile(context.Context, ...interface{}) FieldBinding
	WriteEntityReference(context.Context, ...interface{}) FieldBinding
	WriteTimestamp(context.Context, ...interface{}) FieldBinding
	WriteChoice(context.Context, ...interface{}) FieldBinding
	WriteEntityList(context.Context, ...interface{}) FieldBinding

	ReadValue(context.Context) Value
	ReadInt(context.Context) int64
	ReadFloat(context.Context) float64
	ReadString(context.Context) string
	ReadBool(context.Context) bool
	ReadBinaryFile(context.Context) string
	ReadEntityReference(context.Context) string
	ReadTimestamp(context.Context) time.Time
	ReadChoice(context.Context) CompleteChoice
	ReadEntityList(context.Context) EntityList
}

type FieldOperator added in v0.1.0

type FieldOperator interface {
	FieldReader
	FieldWriter
}

type FieldOperatorSetter added in v0.1.0

type FieldOperatorSetter interface {
	SetFieldOperator(FieldOperator)
}

type FieldQuery

type FieldQuery interface {
	Equals(value any) Query
	NotEquals(value any) Query
	GreaterThan(value any) Query
	LessThan(value any) Query
	LessThanOrEqual(value any) Query
	GreaterThanOrEqual(value any) Query
	Contains(value any) Query
	NotContains(value any) Query
}

type FieldReader added in v0.1.0

type FieldReader interface {
	Read(context.Context, ...Request)
}

type FieldSchema

type FieldSchema interface {
	GetFieldName() string
	GetFieldType() string

	IsInt() bool
	IsFloat() bool
	IsString() bool
	IsBool() bool
	IsBinaryFile() bool
	IsEntityReference() bool
	IsTimestamp() bool
	IsChoice() bool
	IsEntityList() bool

	GetReadPermissions() []string
	GetWritePermissions() []string

	AsChoiceFieldSchema() ChoiceFieldSchema
}

type FieldWriter added in v0.1.0

type FieldWriter interface {
	Write(context.Context, ...Request)
}

type IndirectionResolver added in v0.1.2

type IndirectionResolver interface {
	Resolve(ctx context.Context, entityId string, fields string) (string, string)
}

type ModifiableEntityManager added in v0.1.0

type ModifiableEntityManager interface {
	SchemaManagerSetter
	FieldOperatorSetter
	EntityManager
}

type ModifiableNotificationConsumer added in v0.1.0

type ModifiableNotificationConsumer interface {
	TransformerSetter
	NotificationConsumer
}

type ModifiableNotificationPublisher added in v0.1.0

type ModifiableNotificationPublisher interface {
	EntityManagerSetter
	FieldOperatorSetter
	NotificationPublisher
}

type ModifiableSchemaManager added in v0.1.0

type ModifiableSchemaManager interface {
	EntityManagerSetter
	FieldOperatorSetter
	SchemaManager
}

type ModifiableSnapshotManager added in v0.1.0

type ModifiableSnapshotManager interface {
	SchemaManagerSetter
	EntityManagerSetter
	FieldOperatorSetter
	SnapshotManager
}

type MultiBinding added in v0.0.9

type MultiBinding interface {
	Store

	GetEntityById(context.Context, string) EntityBinding
	Commit(context.Context)
}

type Notification

type Notification interface {
	GetToken() string
	GetCurrent() Field
	GetPrevious() Field
	GetContext(index int) Field
	GetContextCount() int
}

type NotificationCallback

type NotificationCallback interface {
	Fn(context.Context, Notification)
	Id() string
}

type NotificationConfig

type NotificationConfig interface {
	GetEntityId() string
	GetEntityType() string
	GetFieldName() string
	GetContextFields() []string
	GetNotifyOnChange() bool
	GetServiceId() string
	GetToken() string
	IsDistributed() bool

	SetEntityId(string) NotificationConfig
	SetEntityType(string) NotificationConfig
	SetFieldName(string) NotificationConfig
	SetContextFields(...string) NotificationConfig
	SetNotifyOnChange(bool) NotificationConfig
	SetServiceId(string) NotificationConfig
	SetDistributed(bool) NotificationConfig
}

type NotificationConsumer added in v0.1.0

type NotificationConsumer interface {
	Notify(ctx context.Context, config NotificationConfig, callback NotificationCallback) NotificationToken
	Unnotify(ctx context.Context, subscriptionId string)
	UnnotifyCallback(ctx context.Context, subscriptionId string, callback NotificationCallback)
	Consumed() signalslots.Signal
}

type NotificationConsumerSetter added in v0.1.0

type NotificationConsumerSetter interface {
	SetNotificationConsumer(NotificationConsumer)
}

type NotificationPublisher added in v0.1.0

type NotificationPublisher interface {
	PublishNotifications(ctx context.Context, curr Request, prev Request)
}

type NotificationPublisherSetter added in v0.1.0

type NotificationPublisherSetter interface {
	SetNotificationPublisher(NotificationPublisher)
}

type NotificationToken

type NotificationToken interface {
	Id() string
	Unbind(context.Context)
}

type Query

type Query interface {
	ForType(string) Query

	// SQL alias for ForType
	From(string) Query

	// Pulls the specified fields from the entity
	Select(...string) Query

	Where(string) FieldQuery
	Execute(context.Context) []EntityBinding
}

type Request

type Request interface {
	GetEntityId() string
	GetFieldName() string
	GetWriteTime() *time.Time
	GetWriter() *string
	GetValue() Value
	IsSuccessful() bool

	SetEntityId(string) Request
	SetFieldName(string) Request
	SetWriteTime(*time.Time) Request
	SetWriter(*string) Request
	SetValue(Value) Request
	SetSuccessful(bool) Request

	GetWriteOpt() WriteOpt
	SetWriteOpt(WriteOpt) Request

	Clone() Request
}

type SchemaManager added in v0.1.0

type SchemaManager interface {
	FieldExists(ctx context.Context, fieldName, entityType string) bool
	GetEntitySchema(ctx context.Context, entityType string) EntitySchema
	SetEntitySchema(context.Context, EntitySchema)
	GetFieldSchema(ctx context.Context, fieldName, entityType string) FieldSchema
	SetFieldSchema(ctx context.Context, entityType, fieldName string, schema FieldSchema)
}

type SchemaManagerSetter added in v0.1.0

type SchemaManagerSetter interface {
	SetSchemaManager(SchemaManager)
}

type SessionProvider added in v0.1.5

type SessionProvider interface {
	Session(ctx context.Context) auth.Session
}

type Snapshot

type Snapshot interface {
	GetEntities() []Entity
	GetFields() []Field
	GetSchemas() []EntitySchema

	SetEntities([]Entity)
	SetFields([]Field)
	SetSchemas([]EntitySchema)

	AppendEntity(Entity)
	AppendField(Field)
	AppendSchema(EntitySchema)
}

type SnapshotManager added in v0.1.0

type SnapshotManager interface {
	CreateSnapshot(context.Context) Snapshot
	RestoreSnapshot(context.Context, Snapshot)
}

type SnapshotManagerSetter added in v0.1.0

type SnapshotManagerSetter interface {
	SetSnapshotManager(SnapshotManager)
}

type Transformer

type Transformer interface {
	Transform(context.Context, string, Request)
	ProcessPending()
}

Transformer calls scripts to transform field values of type Transformation

type TransformerSetter added in v0.1.0

type TransformerSetter interface {
	SetTransformer(Transformer)
}

type Value

type Value interface {
	IsNil() bool
	IsInt() bool
	IsFloat() bool
	IsString() bool
	IsBool() bool
	IsBinaryFile() bool
	IsEntityReference() bool
	IsTimestamp() bool
	IsChoice() bool
	IsEntityList() bool

	GetType() string
	GetInt() int64
	GetFloat() float64
	GetString() string
	GetBool() bool
	GetBinaryFile() string
	GetEntityReference() string
	GetTimestamp() time.Time
	GetChoice() Choice
	GetEntityList() EntityList

	SetInt(interface{}) Value
	SetFloat(interface{}) Value
	SetString(interface{}) Value
	SetBool(interface{}) Value
	SetBinaryFile(interface{}) Value
	SetEntityReference(interface{}) Value
	SetTimestamp(interface{}) Value
	SetChoice(interface{}) Value
	SetEntityList(interface{}) Value
}

type WriteOpt

type WriteOpt int
const (
	WriteNormal WriteOpt = iota
	WriteChanges
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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