Documentation ¶
Index ¶
- Constants
- func IsDirectEntityReference(s RelationTypeStatement) bool
- type EntityStatement
- type Expression
- type ExpressionStatement
- type ExpressionType
- type Identifier
- type InfixExpression
- type Node
- type Operator
- type PermissionStatement
- type RelationStatement
- type RelationTypeStatement
- type RelationalReferenceType
- type Schema
- func (sch *Schema) GetRelationReferenceIfExist(name string) ([]RelationTypeStatement, bool)
- func (sch *Schema) GetRelationalReferenceTypeIfExist(r string) (RelationalReferenceType, bool)
- func (sch *Schema) IsEntityReferenceExist(name string) bool
- func (sch *Schema) IsRelationReferenceExist(name string) bool
- func (sch *Schema) IsRelationalReferenceExist(name string) bool
- func (sch *Schema) SetEntityReferences(r map[string]struct{})
- func (sch *Schema) SetPermissionReferences(r map[string]struct{})
- func (sch *Schema) SetRelationReferences(r map[string][]RelationTypeStatement)
- func (sch *Schema) SetRelationalReferences(r map[string]RelationalReferenceType)
- func (sch *Schema) Validate() error
- type Statement
Constants ¶
const ( IDENTIFIER ExpressionType = "identifier" INFLIX ExpressionType = "inflix" AND Operator = "and" OR Operator = "or" NOT Operator = "not" PERMISSION RelationalReferenceType = "permission" RELATION RelationalReferenceType = "relation" )
Variables ¶
This section is empty.
Functions ¶
func IsDirectEntityReference ¶ added in v0.3.1
func IsDirectEntityReference(s RelationTypeStatement) bool
IsDirectEntityReference returns true if the RelationTypeStatement is a direct entity reference.
Types ¶
type EntityStatement ¶
type EntityStatement struct { Entity token.Token // token.ENTITY Name token.Token // token.IDENT RelationStatements []Statement // Statements that define relationships between entities PermissionStatements []Statement // Statements that define permissions performed on the entity }
EntityStatement represents a statement that refers to an entity.
func (*EntityStatement) String ¶
func (ls *EntityStatement) String() string
String returns a string representation of the EntityStatement.
type Expression ¶
type Expression interface { Node IsInfix() bool GetType() ExpressionType // contains filtered or unexported methods }
Expression defines an interface for an expression node.
type ExpressionStatement ¶
type ExpressionStatement struct {
Expression Expression
}
ExpressionStatement struct represents an expression statement
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
String function returns a string representation of the ExpressionStatement
type Identifier ¶
type Identifier struct {
Idents []token.Token // Idents is a slice of tokens that make up the identifier
}
Identifier represents an expression that identifies an entity, permission or relation
func (*Identifier) GetType ¶
func (ls *Identifier) GetType() ExpressionType
GetType returns the type of the expression which is Identifier
func (*Identifier) IsInfix ¶
func (ls *Identifier) IsInfix() bool
IsInfix returns false since an identifier is not an infix expression
func (*Identifier) String ¶
func (ls *Identifier) String() string
String returns a string representation of the identifier expression
type InfixExpression ¶
type InfixExpression struct { Op token.Token // The operator token, e.g. and, or, not. Left Expression // The left-hand side sub-expression. Operator Operator // The operator as a string. Right Expression // The right-hand side sub-expression. }
InfixExpression represents an expression with an operator between two sub-expressions.
func (*InfixExpression) GetType ¶
func (ie *InfixExpression) GetType() ExpressionType
GetType returns the type of the expression, which is infix.
func (*InfixExpression) IsInfix ¶
func (ie *InfixExpression) IsInfix() bool
IsInfix returns true because it's an infix expression.
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
String returns the string representation of the infix expression.
type PermissionStatement ¶ added in v0.3.9
type PermissionStatement struct { Permission token.Token // token.PERMISSION Name token.Token // token.IDENT ExpressionStatement Statement }
PermissionStatement represents an permission statement, which consists of an permission name and an optional expression statement. It implements the Statement interface.
func (*PermissionStatement) String ¶ added in v0.3.9
func (ls *PermissionStatement) String() string
String returns a string representation of the permission statement.
type RelationStatement ¶
type RelationStatement struct { Relation token.Token // token.RELATION Name token.Token // token.IDENT RelationTypes []RelationTypeStatement // Statements that define the types of the relationship }
RelationStatement represents a statement that defines a relationship between two entities.
func (*RelationStatement) String ¶
func (ls *RelationStatement) String() string
String returns a string representation of the RelationStatement.
type RelationTypeStatement ¶
type RelationTypeStatement struct { Sign token.Token // token.SIGN Type token.Token // token.IDENT Relation token.Token // token.IDENT }
RelationTypeStatement represents a statement that defines the type of a relationship.
func (*RelationTypeStatement) String ¶
func (ls *RelationTypeStatement) String() string
String returns a string representation of the RelationTypeStatement.
type RelationalReferenceType ¶
type RelationalReferenceType string
RelationalReferenceType defines the type of relational reference.
type Schema ¶
type Schema struct { // The list of statements in the schema Statements []Statement // contains filtered or unexported fields }
Schema represents the parsed schema, which contains all the statements and extracted entity and relational references used by the schema. It is used as an intermediate representation before generating the corresponding metadata.
func (*Schema) GetRelationReferenceIfExist ¶
func (sch *Schema) GetRelationReferenceIfExist(name string) ([]RelationTypeStatement, bool)
GetRelationReferenceIfExist returns the relation reference if it exists in the schema
func (*Schema) GetRelationalReferenceTypeIfExist ¶
func (sch *Schema) GetRelationalReferenceTypeIfExist(r string) (RelationalReferenceType, bool)
GetRelationalReferenceTypeIfExist returns the relational reference type if it exists
func (*Schema) IsEntityReferenceExist ¶
IsEntityReferenceExist checks if the entity reference exists in the schema
func (*Schema) IsRelationReferenceExist ¶
IsRelationReferenceExist checks if the relation reference exists in the schema
func (*Schema) IsRelationalReferenceExist ¶ added in v0.3.1
IsRelationalReferenceExist checks if the relational reference exists in the schema
func (*Schema) SetEntityReferences ¶
SetEntityReferences sets the entity references in the schema
func (*Schema) SetPermissionReferences ¶ added in v0.3.9
SetPermissionReferences sets the permission references in the schema
func (*Schema) SetRelationReferences ¶
func (sch *Schema) SetRelationReferences(r map[string][]RelationTypeStatement)
SetRelationReferences sets the relation references in the schema
func (*Schema) SetRelationalReferences ¶
func (sch *Schema) SetRelationalReferences(r map[string]RelationalReferenceType)
SetRelationalReferences sets the relational references in the schema