concept

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package concept is a generated GoMock package.

Index

Constants

View Source
const (
	// AuthorizationConcept is a concept required for authorization credentials
	AuthorizationConcept = "authorization"
	// OrganizationConcept is a concept required for the auth module to work
	OrganizationConcept = "organization"
	// OrganizationName defines the concept path for an organization name
	OrganizationName = "organization.name"
	// OrganizationCity defines the concept path for an organization city
	OrganizationCity = "organization.city"
)
View Source
const EqType = "eq"

EqType is the identifier for an equals clause

View Source
const ExampleConcept = "human"
View Source
const ExampleType = "HumanCredential"
View Source
const IDField = "id"

IDField defines the concept/VC JSON joinPath to a VC ID

View Source
const IssuerField = "issuer"

IssuerField defines the concept/VC JSON joinPath to a VC issuer

View Source
const PrefixType = "prefix"

PrefixType is the identifier for a prefix clause

View Source
const SubjectField = "subject"

SubjectField defines the concept JSONPath to a VC subject

View Source
const TestCredential = `` /* 555-byte string literal not displayed */
View Source
const TestRevocation = `` /* 229-byte string literal not displayed */
View Source
const TypeField = "type"

TypeField defines the concept/VC JSON joinPath to a VC type

Variables

View Source
var ErrIncorrectType = errors.New("set value is not of correct type")

ErrIncorrectType is returned when a requested value type is different tham the set type.

View Source
var ErrNoType = errors.New("no template type found")

ErrNoType is returned when a template is loaded which doesn't have a type

View Source
var ErrNoValue = errors.New("no value for given path")

ErrNoValue is returned when a requested path doesn't have a value.

View Source
var ErrUnknownConcept = errors.New("unknown concept")

ErrUnknownConcept is returned when an unknown concept is requested

View Source
var ExampleConfig = Config{
	Concept:        "human",
	CredentialType: "HumanCredential",
	Indices: []Index{
		{
			Name: "human",
			Parts: []IndexPart{
				{Alias: &humanEyeColour, JSONPath: "credentialSubject.human.eyeColour"},
				{Alias: &humanHairColour, JSONPath: "credentialSubject.human.hairColour"},
			},
		},
		{
			Name:  "subject",
			Parts: []IndexPart{{Alias: &humanSubject, JSONPath: "credentialSubject.id"}},
		},
		{
			Name:  "id",
			Parts: []IndexPart{{JSONPath: "id"}},
		},
		{
			Name:  "issuer",
			Parts: []IndexPart{{JSONPath: "issuer"}},
		},
	},
	Template: &humanTemplate,
}

Functions

func CologneTransformer

func CologneTransformer(text interface{}) interface{}

CologneTransformer is a go-leia compatible function for generating the phonetic representation of a string.

func TestVC

func TestVC() vc.VerifiableCredential

Types

type Clause

type Clause interface {
	// Key returns the key to match against.
	Key() string
	// Seek returns the first matching value for this Clause or "" if not applicable.
	Seek() string
	// Match returns the string that should match each subsequent test when using a cursor or something equal.
	Match() string
	// Type returns the clause identifier type. This type is used for mapping to the underlying DB query language
	Type() string
}

Clause abstracts different equality clauses, comparable to '=', '!=', 'between' and 'abc%' in SQL. note: it currently only supports a key/value store with a binary tree index. When other DB's need to be supported, it could be the case that we will have to add 'dialects' for queries.

func Eq

func Eq(key string, value string) Clause

Eq creates an equal Clause

func Prefix

func Prefix(key string, value string) Clause

Prefix creates a prefix Clause

type Concept

type Concept map[string]interface{}

Concept is a JSON format for querying and returning results of queries. It contains the default values of a VC: id, type, issuer and subject as well as custom concept specific data.

func (Concept) GetString

func (c Concept) GetString(path string) (string, error)

GetString returns the value at the given path or nil if not found

type Config

type Config struct {
	// Concept groups multiple credentials under a single name
	Concept string `yaml:"concept"`
	// CredentialType defines the type of the credential. 'VerifiableCredential' is omitted.
	CredentialType string `yaml:"credentialType"`
	// Indices contains a set of Index values
	Indices []Index `yaml:"indices"`
	// Public indicates if this credential may be published on the DAG
	Public bool `yaml:"public"`
	// Template is the string template for outputting a credential to a common format
	// Each <<JSONPath>> value is substituted with the outcome of the JSONPath query
	Template *string `yaml:"template"`
}

Config defines the concept configuration for a VerifiableCredential

type CredentialQuery

type CredentialQuery struct {
	Clauses []Clause
	// contains filtered or unexported fields
}

CredentialQuery represents a query/template combination

func (*CredentialQuery) CredentialType

func (tq *CredentialQuery) CredentialType() string

CredentialType returns the VC type.

type Index

type Index struct {
	// Name identifies the index, must be unique per credential
	Name string `yaml:"name"`
	// Parts defines the individual index parts, the ordering is significant
	Parts []IndexPart `yaml:"parts"`
}

Index for a credential

type IndexPart

type IndexPart struct {
	// Alias defines an optional alias that can be used within a search query
	Alias *string `yaml:"alias"`
	// JSONPath defines the JSON search path
	JSONPath string `yaml:"path"`
	// Tokenizer defines an optional tokenizer. Possible values: [whitespace]
	Tokenizer *string `yaml:"tokenizer"`
	// Transformer defines an optional transformer. Possible values: [cologne, lowercase]
	Transformer *string `yaml:"transformer"`
}

IndexPart defines the JSONPath and type of index for a partial index within a compound index

type MockReader

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

MockReader is a mock of Reader interface.

func NewMockReader

func NewMockReader(ctrl *gomock.Controller) *MockReader

NewMockReader creates a new mock instance.

func (*MockReader) Concepts

func (m *MockReader) Concepts() []Config

Concepts mocks base method.

func (*MockReader) EXPECT

func (m *MockReader) EXPECT() *MockReaderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockReader) FindByType

func (m *MockReader) FindByType(credentialType string) *Config

FindByType mocks base method.

func (*MockReader) QueryFor

func (m *MockReader) QueryFor(concept string) (Query, error)

QueryFor mocks base method.

func (*MockReader) Transform

func (m *MockReader) Transform(concept string, VC vc.VerifiableCredential) (Concept, error)

Transform mocks base method.

type MockReaderMockRecorder

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

MockReaderMockRecorder is the mock recorder for MockReader.

func (*MockReaderMockRecorder) Concepts

func (mr *MockReaderMockRecorder) Concepts() *gomock.Call

Concepts indicates an expected call of Concepts.

func (*MockReaderMockRecorder) FindByType

func (mr *MockReaderMockRecorder) FindByType(credentialType interface{}) *gomock.Call

FindByType indicates an expected call of FindByType.

func (*MockReaderMockRecorder) QueryFor

func (mr *MockReaderMockRecorder) QueryFor(concept interface{}) *gomock.Call

QueryFor indicates an expected call of QueryFor.

func (*MockReaderMockRecorder) Transform

func (mr *MockReaderMockRecorder) Transform(concept, VC interface{}) *gomock.Call

Transform indicates an expected call of Transform.

type MockRegistry

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

MockRegistry is a mock of Registry interface.

func NewMockRegistry

func NewMockRegistry(ctrl *gomock.Controller) *MockRegistry

NewMockRegistry creates a new mock instance.

func (*MockRegistry) Add

func (m *MockRegistry) Add(config Config) error

Add mocks base method.

func (*MockRegistry) Concepts

func (m *MockRegistry) Concepts() []Config

Concepts mocks base method.

func (*MockRegistry) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRegistry) FindByType

func (m *MockRegistry) FindByType(credentialType string) *Config

FindByType mocks base method.

func (*MockRegistry) QueryFor

func (m *MockRegistry) QueryFor(concept string) (Query, error)

QueryFor mocks base method.

func (*MockRegistry) Transform

func (m *MockRegistry) Transform(concept string, VC vc.VerifiableCredential) (Concept, error)

Transform mocks base method.

type MockRegistryMockRecorder

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

MockRegistryMockRecorder is the mock recorder for MockRegistry.

func (*MockRegistryMockRecorder) Add

func (mr *MockRegistryMockRecorder) Add(config interface{}) *gomock.Call

Add indicates an expected call of Add.

func (*MockRegistryMockRecorder) Concepts

func (mr *MockRegistryMockRecorder) Concepts() *gomock.Call

Concepts indicates an expected call of Concepts.

func (*MockRegistryMockRecorder) FindByType

func (mr *MockRegistryMockRecorder) FindByType(credentialType interface{}) *gomock.Call

FindByType indicates an expected call of FindByType.

func (*MockRegistryMockRecorder) QueryFor

func (mr *MockRegistryMockRecorder) QueryFor(concept interface{}) *gomock.Call

QueryFor indicates an expected call of QueryFor.

func (*MockRegistryMockRecorder) Transform

func (mr *MockRegistryMockRecorder) Transform(concept, VC interface{}) *gomock.Call

Transform indicates an expected call of Transform.

type MockWriter

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

MockWriter is a mock of Writer interface.

func NewMockWriter

func NewMockWriter(ctrl *gomock.Controller) *MockWriter

NewMockWriter creates a new mock instance.

func (*MockWriter) Add

func (m *MockWriter) Add(config Config) error

Add mocks base method.

func (*MockWriter) EXPECT

func (m *MockWriter) EXPECT() *MockWriterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockWriterMockRecorder

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

MockWriterMockRecorder is the mock recorder for MockWriter.

func (*MockWriterMockRecorder) Add

func (mr *MockWriterMockRecorder) Add(config interface{}) *gomock.Call

Add indicates an expected call of Add.

type Query

type Query interface {
	// Concept returns the concept name.
	Concept() string
	// Parts returns the different concept queries
	Parts() []*CredentialQuery
	// AddClause adds a clause to the query.
	AddClause(clause Clause)
}

Query is an DB query abstraction. it is created from the registry in the context of a concept. It contains concept specific query arguments, that need to be resolved by the DB facade using the template registry.

type Reader

type Reader interface {
	// Concepts returns a list of concept configs
	Concepts() []Config
	// FindByType returns the Config if the given credentialType is registered, nil otherwise
	FindByType(credentialType string) *Config
	// QueryFor creates a query for the given concept.
	// The query is preloaded with required fixed values like the type.
	// It returns ErrUnknownConcept if the concept is not found
	QueryFor(concept string) (Query, error)
	// Transform a VerifiableCredential to concept format.
	Transform(concept string, VC vc.VerifiableCredential) (Concept, error)
}

Reader contains all read-only operations for the concept registry

type Registry

type Registry interface {
	Reader
	Writer
}

Registry defines the interface for accessing loaded concepts and using the templates to generate queries and transform results.

func NewRegistry

func NewRegistry() Registry

NewRegistry creates a new registry instance with no templates.

type Writer

type Writer interface {
	// Add a credential config to the registry
	Add(config Config) error
}

Writer contains state changing operations for the concept registry

Jump to

Keyboard shortcuts

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