userstore

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllColumnTypes is a slice of all ColumnType values

Functions

This section is empty.

Types

type Accessor added in v0.4.0

type Accessor struct {
	ID uuid.UUID `json:"id" validate:"notnil"`

	// Friendly ID, must be unique?
	Name string `json:"name" validate:"notempty"`

	// Description of the accessor
	Description string `json:"description"`

	// Version of the accessor
	Version int `json:"version"`

	// the columns that are accessed here
	ColumnIDs []uuid.UUID `json:"column_ids" validate:"notnil"`

	// makes decisions about who can access this particular view of this field
	AccessPolicyID uuid.UUID `json:"access_policy_id" validate:"notnil"`

	// transforms the value of this field before it is returned to the client
	TransformationPolicyID uuid.UUID `json:"transformation_policy_id" validate:"notnil"`
}

Accessor represents a customer-defined view / permissions policy on a column

type Column added in v0.3.0

type Column struct {
	// Columns may be renamed, but their ID cannot be changed.
	ID           uuid.UUID  `json:"id" validate:"notnil"`
	Name         string     `json:"name" validate:"notempty"`
	Type         ColumnType `json:"type"`
	DefaultValue string     `json:"default_value,omitempty"`
	Unique       bool       `json:"unique"`
}

Column represents a single field/column/value to be collected/stored/managed in the user data store of a tenant.

type ColumnAccessor added in v0.3.0

type ColumnAccessor struct {
	ID uuid.UUID `json:"id" validate:"notnil"`

	// Friendly ID, must be unique?
	Name string `json:"name" validate:"notempty"`

	// the columns that are accessed here
	ColumnIDs []uuid.UUID `json:"column_ids" validate:"notnil"`

	// makes decisions about who can access this particular view of this field
	AccessPolicyID uuid.UUID `json:"access_policy_id" validate:"notnil"`

	// transforms the value of this field before it is returned to the client
	TransformationPolicyID uuid.UUID `json:"transformation_policy_id" validate:"notnil"`
}

ColumnAccessor represents a customer-defined view / permissions policy on a column

type ColumnAccessors added in v0.3.0

type ColumnAccessors []ColumnAccessor

ColumnAccessors is simply a slice of ColumnAccessor, and this type exists soley so that we can hang Scan() and Value() on it to make the db layer work.

type ColumnType added in v0.3.0

type ColumnType int

ColumnType is an enum for supported column types

const (
	ColumnTypeInvalid ColumnType = 0

	ColumnTypeString ColumnType = 100

	ColumnTypeTimestamp ColumnType = 200
)

ColumnType constants (leaving gaps intentionally to allow future related types to be grouped) NOTE: keep in sync with mapColumnType defined in TenantUserStoreConfig.tsx

func (ColumnType) MarshalText added in v0.3.0

func (t ColumnType) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler (for JSON)

func (ColumnType) String added in v0.3.0

func (t ColumnType) String() string

just here for easier debugging

func (*ColumnType) UnmarshalText added in v0.3.0

func (t *ColumnType) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextMarshaler (for JSON)

func (*ColumnType) Validate added in v0.3.0

func (t *ColumnType) Validate() error

Validate implements Validateable

type Mutator added in v0.4.0

type Mutator struct {
	ID uuid.UUID `json:"id" validate:"notnil"`

	// Friendly ID, must be unique
	Name string `json:"name" validate:"notempty"`

	// Description of the mutator
	Description string `json:"description"`

	// Version of the mutator
	Version int `json:"version"`

	// The columns that are updated here
	ColumnIDs []uuid.UUID `json:"column_ids" validate:"notnil"`

	// Decides who can update these columns
	AccessPolicyID uuid.UUID `json:"access_policy_id" validate:"notnil"`

	// Validates the data before it is written to the userstore
	ValidationPolicyID uuid.UUID `json:"validation_policy_id" validate:"notnil"`
}

Mutator represents a customer-defined permissions policy for updating columns in userstore

type Record

type Record map[uuid.UUID]interface{}

Record is a single "row" of data containing 0 or more Columns that adhere to a Schema. The key is the Column UUID, since names can change but IDs are stable.

func (Record) Validate

func (r Record) Validate() error

Validate implements Validateable and ensures that a Record has columns which consist only of valid ColumnTypes. TODO: need a Validation method that validates against a particular schema.

func (Record) ValidateAgainstSchema added in v0.4.0

func (r Record) ValidateAgainstSchema(s *Schema) error

ValidateAgainstSchema validates a record against a schema

type Schema

type Schema struct {
	Columns []Column `json:"columns,omitempty"` // the omitempty will cause us to *not* serialize `columns: null` in the JSON for an empty-and-not-initialized array
}

Schema defines the format of the User Data Store/Vault for a given tenant.

Jump to

Keyboard shortcuts

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