Documentation ¶
Index ¶
- func GetEntityByName(schema *base.SchemaDefinition, name string) (entityDefinition *base.EntityDefinition, err error)
- func GetPermissionByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (permissionDefinition *base.PermissionDefinition, err error)
- func GetRelationByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationDefinition *base.RelationDefinition, err error)
- func GetTypeOfRelationalReferenceByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationalDefinitionType base.EntityDefinition_RelationalReference, err error)
- func IsDirectlyRelated(target *base.RelationDefinition, source *base.RelationReference) bool
- func NewEntityDefinitionsFromStringDefinitions(validation bool, definitions ...string) ([]*base.EntityDefinition, error)
- func NewSchemaFromEntityDefinitions(entities ...*base.EntityDefinition) *base.SchemaDefinition
- func NewSchemaFromStringDefinitions(validation bool, definitions ...string) (*base.SchemaDefinition, error)
- type LinkedEntrance
- type LinkedEntranceKind
- type LinkedSchemaGraph
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEntityByName ¶
func GetEntityByName(schema *base.SchemaDefinition, name string) (entityDefinition *base.EntityDefinition, err error)
GetEntityByName retrieves an `EntityDefinition` from a `SchemaDefinition` by its name. It returns a pointer to the `EntityDefinition` if it is found in the `SchemaDefinition`. If the `EntityDefinition` is not found, it returns an error with error code `ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND`.
func GetPermissionByNameInEntityDefinition ¶ added in v0.3.9
func GetPermissionByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (permissionDefinition *base.PermissionDefinition, err error)
GetPermissionByNameInEntityDefinition retrieves an `PermissionDefinition` from an `EntityDefinition` by its name. It returns a pointer to the `PermissionDefinition` if it is found in the `EntityDefinition`. If the `PermissionDefinition` is not found, it returns an error with error code `ERROR_CODE_ACTION_DEFINITION_NOT_FOUND`.
func GetRelationByNameInEntityDefinition ¶
func GetRelationByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationDefinition *base.RelationDefinition, err error)
GetRelationByNameInEntityDefinition retrieves a `RelationDefinition` from an `EntityDefinition` by its name. It returns a pointer to the `RelationDefinition` if it is found in the `EntityDefinition`. If the `RelationDefinition` is not found, it returns an error with error code `ERROR_CODE_RELATION_DEFINITION_NOT_FOUND`.
func GetTypeOfRelationalReferenceByNameInEntityDefinition ¶
func GetTypeOfRelationalReferenceByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationalDefinitionType base.EntityDefinition_RelationalReference, err error)
GetTypeOfRelationalReferenceByNameInEntityDefinition retrieves the type of a relational reference in an `EntityDefinition` by its name. It returns the type of the relational reference if it is found in the `EntityDefinition`. If the relational reference is not found, it returns an error with error code `ERROR_CODE_RELATION_DEFINITION_NOT_FOUND`.
func IsDirectlyRelated ¶ added in v0.3.5
func IsDirectlyRelated(target *base.RelationDefinition, source *base.RelationReference) bool
IsDirectlyRelated checks if a source `RelationReference` is directly related to a target `RelationDefinition`. It returns true if the source and target have the same type and relation, false otherwise.
func NewEntityDefinitionsFromStringDefinitions ¶
func NewEntityDefinitionsFromStringDefinitions(validation bool, definitions ...string) ([]*base.EntityDefinition, error)
NewEntityDefinitionsFromStringDefinitions creates a list of `EntityDefinition`s from a list of string definitions. The `validation` argument determines whether to validate the input definitions before creating the entity definitions. It first uses the `parser` package to parse the string definitions into a `Schema` object. If there's an error during parsing, it returns an error. Then it uses the `compiler` package to compile the `Schema` into a list of `EntityDefinition`s. If the validation is successful, it returns the list of `EntityDefinition`s. If there's an error during validation or compiling, it returns an error.
func NewSchemaFromEntityDefinitions ¶
func NewSchemaFromEntityDefinitions(entities ...*base.EntityDefinition) *base.SchemaDefinition
NewSchemaFromEntityDefinitions creates a new `SchemaDefinition` from a list of `EntityDefinition`s. It initializes the `EntityDefinitions` property of the `SchemaDefinition` as an empty map, and then adds each `EntityDefinition` to the map using the entity name as the key. If an `EntityDefinition` doesn't have a `Relations` or `Permissions` property, it initializes it as an empty map. Finally, it returns a pointer to the newly created `SchemaDefinition`.
func NewSchemaFromStringDefinitions ¶
func NewSchemaFromStringDefinitions(validation bool, definitions ...string) (*base.SchemaDefinition, error)
NewSchemaFromStringDefinitions creates a new `SchemaDefinition` from a list of string definitions. The `validation` argument determines whether to validate the input definitions before creating the schema. If the validation is successful, it returns a pointer to the newly created `SchemaDefinition`. If there's an error during validation or creating the schema, it returns an error.
Types ¶
type LinkedEntrance ¶ added in v0.3.5
type LinkedEntrance struct { Kind LinkedEntranceKind TargetEntrance *base.RelationReference TupleSetRelation string }
LinkedEntrance represents an entry point into the LinkedSchemaGraph, which is used to resolve permissions and expand user sets for a given request. The object contains a kind that specifies the type of entry point (e.g. relation, tuple-to-user-set), an entry point reference that identifies the specific entry point in the graph, and a tuple set relation reference that specifies the relation to use when expanding user sets for the entry point.
Fields:
- Kind: LinkedEntranceKind representing the type of entry point
- LinkedEntrance: pointer to a base.RelationReference that identifies the entry point in the schema graph
- TupleSetRelation: pointer to a base.RelationReference that specifies the relation to use when expanding user sets for the entry point
func (LinkedEntrance) LinkedEntranceKind ¶ added in v0.3.5
func (re LinkedEntrance) LinkedEntranceKind() LinkedEntranceKind
LinkedEntranceKind returns the kind of the LinkedEntrance object. The kind specifies the type of entry point (e.g. relation, tuple-to-user-set, computed user set).
Returns:
- LinkedEntranceKind representing the type of entry point
type LinkedEntranceKind ¶ added in v0.3.5
type LinkedEntranceKind string
LinkedEntranceKind is a string type that represents the kind of LinkedEntrance object. An LinkedEntrance object defines an entry point into the LinkedSchemaGraph, which is used to resolve permissions and expand user sets for a given request.
Values:
- RelationLinkedEntrance: represents an entry point into a relationship object in the schema graph
- TupleToUserSetLinkedEntrance: represents an entry point into a tuple-to-user-set object in the schema graph
- ComputedUserSetLinkedEntrance: represents an entry point into a computed user set object in the schema graph
const ( RelationLinkedEntrance LinkedEntranceKind = "relation" TupleToUserSetLinkedEntrance LinkedEntranceKind = "tuple_to_user_set" ComputedUserSetLinkedEntrance LinkedEntranceKind = "computed_user_set" )
type LinkedSchemaGraph ¶ added in v0.3.5
type LinkedSchemaGraph struct {
// contains filtered or unexported fields
}
LinkedSchemaGraph represents a graph of linked schema objects. The schema object contains definitions for entities, relationships, and permissions, and the graph is constructed by linking objects together based on their dependencies. The graph is used by the PermissionEngine to resolve permissions and expand user sets for a given request.
Fields:
- schema: pointer to the base.SchemaDefinition that defines the schema objects in the graph
func NewLinkedGraph ¶ added in v0.3.5
func NewLinkedGraph(schema *base.SchemaDefinition) *LinkedSchemaGraph
NewLinkedGraph returns a new instance of LinkedSchemaGraph with the specified base.SchemaDefinition as its schema. The schema object contains definitions for entities, relationships, and permissions, and is used to construct a graph of linked schema objects. The graph is used by the PermissionEngine to resolve permissions and expand user sets for a given request.
Parameters:
- schema: pointer to the base.SchemaDefinition that defines the schema objects in the graph
Returns:
- pointer to a new instance of LinkedSchemaGraph with the specified schema object
func (*LinkedSchemaGraph) RelationshipLinkedEntrances ¶ added in v0.3.5
func (g *LinkedSchemaGraph) RelationshipLinkedEntrances(target, source *base.RelationReference) ([]*LinkedEntrance, error)
RelationshipLinkedEntrances returns a slice of LinkedEntrance objects that represent entry points into the LinkedSchemaGraph for the specified target and source relations. The function recursively searches the graph for all entry points that can be reached from the target relation through the specified source relation. The resulting entry points contain a reference to the relation object in the schema graph and the relation used to expand user sets for the entry point. If the target or source relation does not exist in the schema graph, the function returns an error.
Parameters:
- target: pointer to a base.RelationReference that identifies the target relation
- source: pointer to a base.RelationReference that identifies the source relation used to reach the target relation
Returns:
- slice of LinkedEntrance objects that represent entry points into the LinkedSchemaGraph, or an error if the target or source relation does not exist in the schema graph