schema

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attribute added in v0.5.0

func Attribute(name string, typ base.AttributeType) *base.AttributeDefinition

Attribute is a function that generates an attribute definition given a name and an attribute type.

func Attributes added in v0.5.0

func Attributes(defs ...*base.AttributeDefinition) []*base.AttributeDefinition

Attributes - Attributes builder

func Call added in v0.5.0

func Call(name string, arguments ...*base.Argument) *base.Child

Call is a function that generates a child definition for a call given its name and a list of arguments.

func ComputedAttribute added in v0.5.0

func ComputedAttribute(name string) *base.Child

ComputedAttribute is a function that generates a child definition for a computed attribute given its name.

func ComputedUserSet

func ComputedUserSet(relation string) *base.Child

ComputedUserSet - returns a Child definition that represents a computed set of users based on a relation relation: the name of the relation on which the computed set is based exclusion: a boolean indicating if the computed set should exclude or include the users in the set

func Entities added in v0.5.0

func Entities(defs ...*base.EntityDefinition) []*base.EntityDefinition

Entities - Entities builder

func Entity

func Entity(name string, relations []*base.RelationDefinition, attributes []*base.AttributeDefinition, permissions []*base.PermissionDefinition) *base.EntityDefinition

Entity - Entity builder This function creates and returns a new instance of EntityDefinition. It takes in the name of the entity, an array of relations, and an array of actions. It then initializes the EntityDefinition with the provided values and returns it. The EntityDefinition contains information about the entity's name, its relations, actions, and references.

func Exclusion added in v0.4.2

func Exclusion(children ...*base.Child) *base.Child

Exclusion - Returns a child element that represents the exclusion of the given children. This child element can be used in defining entity relations and actions.

func Intersection

func Intersection(children ...*base.Child) *base.Child

Intersection - Returns a child element that represents the intersection of the given children. This child element can be used in defining entity relations and actions.

func Permission added in v0.3.9

func Permission(name string, child *base.Child) *base.PermissionDefinition

Permission - Permission builder creates a new action definition with the given name and child entity

func Permissions added in v0.3.9

func Permissions(defs ...*base.PermissionDefinition) []*base.PermissionDefinition

Permissions - Permissions builder creates a slice of action definitions from the given variadic list of action definitions

func Reference

func Reference(name string) *base.RelationReference

Reference - Reference builder

func Relation

func Relation(name string, references ...*base.RelationReference) *base.RelationDefinition

Relation - Relation builder function that creates a new RelationDefinition instance with the given name and references.

Parameters: - name: a string representing the name of the relation. - references: a variadic parameter representing the relation references associated with this relation.

Returns: - a pointer to a new RelationDefinition instance with the given name and references.

func Relations

func Relations(defs ...*base.RelationDefinition) []*base.RelationDefinition

Relations - Relations builder

func Rule added in v0.5.0

func Rule(name string, arguments map[string]base.AttributeType, expression string) *base.RuleDefinition

Rule is a function that generates a rule definition given a name, a map of argument names to attribute types, and an expression string. The expression string is compiled and transformed to a checked expression.

func Rules added in v0.5.0

func Rules(defs ...*base.RuleDefinition) []*base.RuleDefinition

Rules - Rules builder

func Schema

func Schema(entities []*base.EntityDefinition, rules []*base.RuleDefinition) *base.SchemaDefinition

Schema is a function that returns a pointer to a SchemaDefinition structure. It takes a variable number of pointers to EntityDefinition structures as input arguments, which are added to the schema being constructed. The function creates a new SchemaDefinition structure, initializes its EntityDefinitions field to an empty map, and then adds each input EntityDefinition structure to this map with the entity name as the key. Finally, it returns the pointer to the constructed SchemaDefinition structure.

func TupleToUserSet

func TupleToUserSet(reference, relation string) *base.Child

TupleToUserSet - Returns a pointer to a base.Child struct, containing a Leaf struct with a TupleToUserSet struct, that represents a child computation where the tuple set is passed to the computed user set. Takes a reference string, relation string, and exclusion boolean as arguments. reference: the name of the reference to the tuple set relation: the name of the relation for the computed user set exclusion: a boolean indicating whether to exclude the computed user set Returns a pointer to a base.Child struct.

func Union

func Union(children ...*base.Child) *base.Child

Union takes a variable number of Child arguments and returns a new Child representing the union of all the sets obtained by evaluating each child.

Types

type Loader added in v0.5.9

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

Loader is a struct that holds a map of loader functions, each corresponding to a Type.

func NewSchemaLoader added in v0.5.9

func NewSchemaLoader() *Loader

NewSchemaLoader initializes and returns a new Loader instance. It sets up the map of loader functions for each Type.

func (*Loader) LoadSchema added in v0.5.9

func (s *Loader) LoadSchema(input string) (string, error)

LoadSchema loads a schema based on its type

type Type added in v0.5.9

type Type int

Type defines an enumeration for different schema types.

const (
	// URL represents a schema type for URLs.
	URL Type = iota

	// File represents a schema type for file paths.
	File

	// Inline represents a schema type for inline data.
	Inline
)

Jump to

Keyboard shortcuts

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