userstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// Fields may be renamed, but their ID cannot be changed.
	ID   uuid.UUID `json:"id" validate:"notnil"`
	Name string    `json:"name" validate:"notempty"`
	Type FieldType `json:"type"`
}

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

type FieldType

type FieldType int

FieldType is an enum for supported field types

const (
	FieldTypeInvalid FieldType = 0

	FieldTypeString FieldType = 100

	FieldTypeTimestamp FieldType = 200
)

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

func (FieldType) MarshalText

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

MarshalText implements encoding.TextMarshaler (for JSON)

func (FieldType) String

func (t FieldType) String() string

just here for easier debugging

func (*FieldType) UnmarshalText

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

UnmarshalText implements encoding.TextMarshaler (for JSON)

func (FieldType) Validate

func (ft FieldType) Validate() error

Validate implements Validateable

type Record

type Record map[uuid.UUID]interface{}

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

func (Record) FixupAndValidate

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

FixupAndValidate validates a record against a schema, and fixes up types in the record to match the schema when possible (e.g. since JSON and other serde formats don't preserve Go types, this attempts to parse rich types from strings as needed). This method should be called whenever a Record is deserialized.

func (Record) Validate

func (r Record) Validate() error

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

type Schema

type Schema struct {
	Fields []Field `json:"fields"`
}

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