Documentation ¶
Index ¶
- Constants
- func IsDirectEntityReference(s RelationTypeStatement) bool
- type AttributeStatement
- type AttributeTypeStatement
- type Call
- type EntityStatement
- type Expression
- type ExpressionStatement
- type ExpressionType
- type Identifier
- type InfixExpression
- type Node
- type Operator
- type PermissionStatement
- type ReferenceType
- type References
- func (refs *References) GetAttributeReferenceTypeIfExist(name string) (AttributeTypeStatement, bool)
- func (refs *References) GetReferenceType(key string) (ReferenceType, bool)
- func (refs *References) GetRelationReferenceTypesIfExist(name string) ([]RelationTypeStatement, bool)
- func (refs *References) GetRuleArgumentTypesIfRuleExist(name string) (map[string]string, bool)
- func (refs *References) IsAttributeReferenceExist(name string) bool
- func (refs *References) IsEntityReferenceExist(name string) bool
- func (refs *References) IsReferenceExist(name string) bool
- func (refs *References) IsRelationReferenceExist(name string) bool
- func (refs *References) IsRuleReferenceExist(name string) bool
- func (refs *References) SetAttributeReferences(key string, typ AttributeTypeStatement) error
- func (refs *References) SetEntityReference(name string) error
- func (refs *References) SetPermissionReference(key string) error
- func (refs *References) SetRelationReferences(key string, types []RelationTypeStatement) error
- func (refs *References) SetRuleReference(name string, types map[string]string) error
- type RelationStatement
- type RelationTypeStatement
- type RuleStatement
- type Schema
- type Statement
Constants ¶
const ( IDENTIFIER ExpressionType = "identifier" CALL ExpressionType = "call" INFLIX ExpressionType = "inflix" AND Operator = "and" OR Operator = "or" NOT Operator = "not" )
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 AttributeStatement ¶ added in v0.5.0
type AttributeStatement struct { Attribute token.Token // token.ATTRIBUTE Name token.Token // token.IDENT AttributeType AttributeTypeStatement }
AttributeStatement represents a statement that defines an attribute of an entity.
func (*AttributeStatement) GetName ¶ added in v0.5.0
func (as *AttributeStatement) GetName() string
func (*AttributeStatement) String ¶ added in v0.5.0
func (as *AttributeStatement) String() string
String returns a string representation of the AttributeStatement.
type AttributeTypeStatement ¶ added in v0.5.0
AttributeTypeStatement represents a statement that defines the type of a relationship.
func (*AttributeTypeStatement) GetName ¶ added in v0.5.0
func (as *AttributeTypeStatement) GetName() string
func (*AttributeTypeStatement) String ¶ added in v0.5.0
func (as *AttributeTypeStatement) String() string
String returns a string representation of the RelationTypeStatement.
type Call ¶ added in v0.5.0
type Call struct { Name token.Token // Rule Name token Arguments []Identifier // Idents is a slice of tokens that make up the identifier }
func (*Call) GetType ¶ added in v0.5.0
func (ls *Call) GetType() ExpressionType
GetType returns the type of the expression which is Identifier
type EntityStatement ¶
type EntityStatement struct { Entity token.Token // token.ENTITY Name token.Token // token.IDENT RelationStatements []Statement // Statements that define relationships between entities AttributeStatements []Statement // Statements that define attributes of the entity PermissionStatements []Statement // Statements that define permissions performed on the entity }
EntityStatement represents a statement that refers to an entity.
func (*EntityStatement) GetName ¶ added in v0.5.0
func (ls *EntityStatement) GetName() string
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) GetName ¶ added in v0.5.0
func (es *ExpressionStatement) GetName() string
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) GetName ¶ added in v0.5.0
func (ls *PermissionStatement) GetName() string
func (*PermissionStatement) String ¶ added in v0.3.9
func (ls *PermissionStatement) String() string
String returns a string representation of the permission statement.
type ReferenceType ¶ added in v0.5.0
type ReferenceType string
ReferenceType defines the type of reference.
const ( UNSPECIFIED ReferenceType = "unspecified" PERMISSION ReferenceType = "permission" RELATION ReferenceType = "relation" ATTRIBUTE ReferenceType = "attribute" ENTITY ReferenceType = "entity" RULE ReferenceType = "rule" )
type References ¶ added in v0.5.0
type References struct {
// contains filtered or unexported fields
}
References - Map of all relational references extracted from the schema
func NewReferences ¶ added in v0.5.0
func NewReferences() *References
NewReferences creates a new instance of References
func (*References) GetAttributeReferenceTypeIfExist ¶ added in v0.5.0
func (refs *References) GetAttributeReferenceTypeIfExist(name string) (AttributeTypeStatement, bool)
GetAttributeReferenceTypeIfExist retrieves the attribute type for a given attribute reference key.
func (*References) GetReferenceType ¶ added in v0.5.0
func (refs *References) GetReferenceType(key string) (ReferenceType, bool)
GetReferenceType retrieves the type of the reference for a given key.
func (*References) GetRelationReferenceTypesIfExist ¶ added in v0.5.0
func (refs *References) GetRelationReferenceTypesIfExist(name string) ([]RelationTypeStatement, bool)
GetRelationReferenceTypesIfExist retrieves the relation types for a given relation reference key.
func (*References) GetRuleArgumentTypesIfRuleExist ¶ added in v0.5.0
func (refs *References) GetRuleArgumentTypesIfRuleExist(name string) (map[string]string, bool)
GetRuleArgumentTypesIfRuleExist retrieves the rule argument types for a given rule reference key.
func (*References) IsAttributeReferenceExist ¶ added in v0.5.0
func (refs *References) IsAttributeReferenceExist(name string) bool
IsAttributeReferenceExist checks if an attribute reference exists for the given key.
func (*References) IsEntityReferenceExist ¶ added in v0.5.0
func (refs *References) IsEntityReferenceExist(name string) bool
IsEntityReferenceExist checks if an entity reference exists for the given name.
func (*References) IsReferenceExist ¶ added in v0.5.0
func (refs *References) IsReferenceExist(name string) bool
IsReferenceExist checks if a reference exists for the given key.
func (*References) IsRelationReferenceExist ¶ added in v0.5.0
func (refs *References) IsRelationReferenceExist(name string) bool
IsRelationReferenceExist checks if a relation reference exists for the given key.
func (*References) IsRuleReferenceExist ¶ added in v0.5.0
func (refs *References) IsRuleReferenceExist(name string) bool
IsRuleReferenceExist checks if a rule reference exists for the given name.
func (*References) SetAttributeReferences ¶ added in v0.5.0
func (refs *References) SetAttributeReferences(key string, typ AttributeTypeStatement) error
SetAttributeReferences sets references for an attribute with its type.
func (*References) SetEntityReference ¶ added in v0.5.0
func (refs *References) SetEntityReference(name string) error
SetEntityReference sets a reference for an entity.
func (*References) SetPermissionReference ¶ added in v0.5.0
func (refs *References) SetPermissionReference(key string) error
SetPermissionReference sets a reference for a permission.
func (*References) SetRelationReferences ¶ added in v0.5.0
func (refs *References) SetRelationReferences(key string, types []RelationTypeStatement) error
SetRelationReferences sets references for a relation with its types.
func (*References) SetRuleReference ¶ added in v0.5.0
func (refs *References) SetRuleReference(name string, types map[string]string) error
SetRuleReference sets a reference for a rule.
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) GetName ¶ added in v0.5.0
func (ls *RelationStatement) GetName() string
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 relationship.
func (*RelationTypeStatement) GetName ¶ added in v0.5.0
func (ls *RelationTypeStatement) GetName() string
func (*RelationTypeStatement) String ¶
func (ls *RelationTypeStatement) String() string
String returns a string representation of the RelationTypeStatement.
type RuleStatement ¶ added in v0.5.0
type RuleStatement struct { Rule token.Token // token.RULE Name token.Token // token.IDENT Arguments map[token.Token]AttributeTypeStatement Expression string }
RuleStatement represents a rule statement, which consists of a rule name, a list of parameters and a body.
func (*RuleStatement) GetName ¶ added in v0.5.0
func (rs *RuleStatement) GetName() string
func (*RuleStatement) String ¶ added in v0.5.0
func (rs *RuleStatement) String() string
String returns a string representation of the permission statement.
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) GetReferences ¶ added in v0.5.0
func (sch *Schema) GetReferences() *References
func (*Schema) SetReferences ¶ added in v0.5.0
func (sch *Schema) SetReferences(refs *References)