preference

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID     = fmt.Errorf("invalid preference id")
	ErrNotFound      = fmt.Errorf("preference not found")
	ErrInvalidFilter = fmt.Errorf("invalid preference filter set")
	ErrTraitNotFound = fmt.Errorf("preference trait not found, preferences can only be created with valid trait")
)
View Source
var DefaultTraits = []Trait{

	{
		ResourceType: schema.UserPrincipal,
		Name:         "profile_picture",
		Title:        "Profile picture",
		Description:  "Profile picture of the user",
		Heading:      "Profile",
		Input:        TraitInputText,
	},
	{
		ResourceType: schema.UserPrincipal,
		Name:         "first_name",
		Title:        "Full name",
		Description:  "Full name of the user",
		Heading:      "Profile",
		Input:        TraitInputText,
	},

	{
		ResourceType: schema.OrganizationNamespace,
		Name:         "logo",
		Title:        "Logo",
		Description:  "Select a logo for your organization.",
		Heading:      "General",
		Input:        TraitInputText,
	},
	{
		ResourceType: schema.OrganizationNamespace,
		Name:         "social_login",
		Title:        "Social Login",
		Description:  "Allow login through Google/Github/Facebook/etc single sign-on functionality.",
		Heading:      "Security",
		SubHeading:   "Manage organization security and how it's members authenticate.",
		Input:        TraitInputCheckbox,
	},
	{
		ResourceType: schema.OrganizationNamespace,
		Name:         "mail_otp",
		Title:        "Email code",
		Description:  "Allow password less login via code delivered over email.",
		Heading:      "Security",
		SubHeading:   "Manage organization security and how it's members authenticate.",
		Input:        TraitInputCheckbox,
	},
	{
		ResourceType: schema.OrganizationNamespace,
		Name:         "mail_link",
		Title:        "Email magic link",
		Description:  "Allow password less login via a link delivered over email.",
		Heading:      "Security",
		SubHeading:   "Manage organization security and how it's members authenticate.",
		Input:        TraitInputCheckbox,
	},
}

Functions

This section is empty.

Types

type Filter

type Filter struct {
	OrgID      string `json:"org_id"`
	ProjectID  string `json:"project_id"`
	UserID     string `json:"user_id"`
	GroupID    string `json:"group_id"`
	ResourceID string `json:"resource_id"`
}

type Preference

type Preference struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Value        string    `json:"value"`
	ResourceID   string    `json:"resource_id"`
	ResourceType string    `json:"resource_type"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type Repository

type Repository interface {
	Set(ctx context.Context, preference Preference) (Preference, error)
	Get(ctx context.Context, id uuid.UUID) (Preference, error)
	List(ctx context.Context, filter Filter) ([]Preference, error)
}

type Service

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

func NewService

func NewService(repo Repository) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, preference Preference) (Preference, error)

func (*Service) Describe

func (s *Service) Describe(ctx context.Context) []Trait

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (Preference, error)

func (*Service) List

func (s *Service) List(ctx context.Context, filter Filter) ([]Preference, error)

type Trait

type Trait struct {
	ResourceType    string     `json:"resource_type"`
	Name            string     `json:"name"`
	Title           string     `json:"title"`
	Description     string     `json:"description"`
	LongDescription string     `json:"long_description"`
	Heading         string     `json:"heading"`
	SubHeading      string     `json:"sub_heading"`
	Breadcrumb      string     `json:"breadcrumb"`
	Input           TraitInput `json:"input"`
	InputHints      string     `json:"input_hints"`
}

type TraitInput

type TraitInput string
const (
	TraitInputText        TraitInput = "text"
	TraitInputTextarea    TraitInput = "textarea"
	TraitInputSelect      TraitInput = "select"
	TraitInputCombobox    TraitInput = "combobox"
	TraitInputCheckbox    TraitInput = "checkbox"
	TraitInputMultiselect TraitInput = "multiselect"
	TraitInputNumber      TraitInput = "number"
)

Jump to

Keyboard shortcuts

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