namespace

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddComment

func AddComment(metadata *core.Metadata, comment string) (*core.Metadata, error)

AddComment adds a comment to the given metadata message.

func AllowedPublicNamespace added in v1.3.0

func AllowedPublicNamespace(namespaceName string) *core.AllowedRelation

AllowedPublicNamespace creates a relation reference to an allowed public namespace.

func AllowedRelation added in v1.3.0

func AllowedRelation(namespaceName string, relationName string) *core.AllowedRelation

AllowedRelation creates a relation reference to an allowed relation.

func ComputeHashForRevision added in v1.2.0

func ComputeHashForRevision(encodedRevision string) (string, error)

ComputeHashForRevision computes a *stable* hash for the encoded v1alpha1 schema revision.

func ComputeV1Alpha1Revision added in v1.2.0

func ComputeV1Alpha1Revision(revisions map[string]decimal.Decimal) (string, error)

ComputeV1Alpha1Revision computes and encodes a string representing the revisions for each of the namespaces in the map.

func ComputedUserset

func ComputedUserset(relation string) *core.SetOperation_Child

ComputesUserset creates a child for a set operation that follows a relation on the given starting object.

func DecodeV1Alpha1Revision added in v1.2.0

func DecodeV1Alpha1Revision(encoded string) (map[string]decimal.Decimal, error)

DecodeV1Alpha1Revision decodes and returns the map of namespace names and their associated revisions.

func Exclusion

func Exclusion(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite

Exclusion creates a rewrite definition that starts with the usersets of the first child and iteratively removes usersets that appear in the remaining children.

func FilterUserDefinedMetadataInPlace added in v1.5.0

func FilterUserDefinedMetadataInPlace(nsconfig *core.NamespaceDefinition)

FilterUserDefinedMetadataInPlace removes user-defined metadata (e.g. comments) from the given namespace *in place*.

func GetComments

func GetComments(metadata *core.Metadata) []string

GetComments returns the comment metadata found within the given metadata message.

func GetRelationKind

func GetRelationKind(relation *core.Relation) iv1.RelationMetadata_RelationKind

GetRelationKind returns the kind of the relation.

func Intersection

func Intersection(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite

Intersection creates a rewrite definition that returns/considers only usersets present in all children.

func Namespace

func Namespace(name string, relations ...*core.Relation) *core.NamespaceDefinition

Namespace creates a namespace definition with one or more defined relations.

func NamespaceWithComment

func NamespaceWithComment(name string, comment string, relations ...*core.Relation) *core.NamespaceDefinition

NamespaceWithComment creates a namespace definition with one or more defined relations.

func Nil added in v1.6.0

func Nil() *core.SetOperation_Child

Nil creates a child for a set operation that references the empty set.

func Relation

func Relation(name string, rewrite *core.UsersetRewrite, allowedDirectRelations ...*core.AllowedRelation) *core.Relation

Relation creates a relation definition with an optional rewrite definition.

func RelationReference

func RelationReference(namespaceName string, relationName string) *core.RelationReference

RelationReference creates a relation reference.

func RelationWithComment

func RelationWithComment(name string, comment string, rewrite *core.UsersetRewrite, allowedDirectRelations ...*core.AllowedRelation) *core.Relation

RelationWithComment creates a relation definition with an optional rewrite definition.

func Rewrite

func Rewrite(rewrite *core.UsersetRewrite) *core.SetOperation_Child

Rewrite wraps a rewrite as a set operation child of another rewrite.

func SetRelationKind

func SetRelationKind(relation *core.Relation, kind iv1.RelationMetadata_RelationKind) error

SetRelationKind sets the kind of relation.

func This

func This() *core.SetOperation_Child

This creates a child for a set operation that references only direct usersets with the parent relation.

TODO(jschorr): Remove once v0 is fully removed.

func TupleToUserset

func TupleToUserset(tuplesetRelation, usersetRelation string) *core.SetOperation_Child

TupleToUserset creates a child which first loads all tuples with the specific relation, and then unions all children on the usersets found by following a relation on those loaded tuples.

func Union

func Union(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite

Union creates a rewrite definition that combines/considers usersets in all children.

Types

type Mapper added in v0.0.2

type Mapper interface {
	// Encode translates a given namespace name to an encoded namespace identifier.
	Encode(name string) (string, error)

	// Reverse translates a given namespace identifier to the user supplied namespace name.
	Reverse(id string) (string, error)
}

Mapper provides an interface for creating synthetic namespace names from user provided namespace names.

var PassthroughMapper Mapper = passthrough{}

PassthroughMapper is a mapper implementation which passes through the original namespace names unmodified.

type WithSourcePosition added in v1.6.0

type WithSourcePosition interface {
	GetSourcePosition() *core.SourcePosition
}

WithSourcePosition defines an interface for proto messages in core with SourcePosition information attached.

Jump to

Keyboard shortcuts

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