qcode

package
v2.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownValidator = errors.New("unknown validator")

Functions

This section is empty.

Types

type AggregrateOp

type AggregrateOp int8
const (
	AgCount AggregrateOp = iota + 1
	AgSum
	AgAvg
	AgMax
	AgMin
)

func (AggregrateOp) String

func (i AggregrateOp) String() string

type Arg

type Arg struct {
	Type  ArgType
	DType string
	Name  string
	Val   string
	Col   sdata.DBColumn
}

type ArgType

type ArgType int8
const (
	ArgTypeVal ArgType = iota
	ArgTypeVar
	ArgTypeCol
)

type Cache

type Cache struct {
	Header string
}

type ColKey

type ColKey struct {
	Name string
	Base bool
}

type Column

type Column struct {
	Col         sdata.DBColumn
	FieldFilter Filter
	FieldName   string
}

type Compiler

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

func NewCompiler

func NewCompiler(s *sdata.DBSchema, c Config) (*Compiler, error)

func (*Compiler) AddRole

func (co *Compiler) AddRole(role, schema, table string, trc TRConfig) error

func (*Compiler) Compile

func (co *Compiler) Compile(
	query []byte,
	vmap map[string]json.RawMessage,
	role, namespace string,
) (qc *QCode, err error)

func (*Compiler) Find

func (co *Compiler) Find(schema, name string) (sdata.DBTable, error)

func (*Compiler) FindPath

func (co *Compiler) FindPath(from, to, through string) ([]sdata.TPath, error)

func (*Compiler) ParseName added in v2.0.22

func (co *Compiler) ParseName(name string) string

type Config

type Config struct {
	Vars            map[string]string
	TConfig         map[string]TConfig
	DefaultBlock    bool
	DefaultLimit    int
	DisableAgg      bool
	DisableFuncs    bool
	EnableCamelcase bool
	DBSchema        string
	Validators      map[string]Validator
	// contains filtered or unexported fields
}

type Constraint added in v2.0.23

type Constraint struct {
	VarName string
	// contains filtered or unexported fields
}

type DeleteConfig

type DeleteConfig struct {
	Filters []string
	Columns []string
	Block   bool
}

type Exp

type Exp struct {
	Op    ExpOp
	Joins []Join
	Order
	OrderBy bool

	Left struct {
		ID    int32
		Table string
		Col   sdata.DBColumn
	}
	Right struct {
		ValType  ValType
		Val      string
		ID       int32
		Table    string
		Col      sdata.DBColumn
		ListType ValType
		ListVal  []string
		Path     []string
	}
	Children []*Exp
	// contains filtered or unexported fields
}

type ExpOp

type ExpOp int8
const (
	OpNop ExpOp = iota
	OpAnd
	OpOr
	OpNot
	OpEquals
	OpNotEquals
	OpGreaterOrEquals
	OpLesserOrEquals
	OpGreaterThan
	OpLesserThan
	OpIn
	OpNotIn
	OpLike
	OpNotLike
	OpILike
	OpNotILike
	OpSimilar
	OpNotSimilar
	OpRegex
	OpNotRegex
	OpIRegex
	OpNotIRegex
	OpContains
	OpContainedIn
	OpHasInCommon
	OpHasKey
	OpHasKeyAny
	OpHasKeyAll
	OpIsNull
	OpIsNotNull
	OpTsQuery
	OpFalse
	OpNotDistinct
	OpDistinct
	OpEqualsTrue
	OpNotEqualsTrue
	OpSelectExists
)

func (ExpOp) String

func (i ExpOp) String() string

type Field

type Field struct {
	ID          int32
	ParentID    int32
	Type        FieldType
	Col         sdata.DBColumn
	Func        sdata.DBFunction
	FieldName   string
	FieldFilter Filter
	Args        []Arg
	SkipRender  SkipType
}

type FieldType

type FieldType int8
const (
	FieldTypeTable FieldType = iota
	FieldTypeCol
	FieldTypeFunc
)

func (FieldType) String added in v2.0.16

func (i FieldType) String() string

type Filter

type Filter struct {
	*Exp
}

type Fragment added in v2.0.19

type Fragment struct {
	Name  string
	Value []byte
}

type Function

type Function struct {
	Name string
	// Col       sdata.DBColumn
	Func sdata.DBFunction
	Args []Arg
	Agg  bool
}

type InsertConfig

type InsertConfig struct {
	Columns []string
	Presets map[string]string
	Block   bool
}

type Join

type Join struct {
	Filter *Exp
	Rel    sdata.DBRel
	Local  bool
}

type MColumn

type MColumn struct {
	Col       sdata.DBColumn
	FieldName string
	Alias     string
	Value     string
	Set       bool
}

type MRColumn

type MRColumn struct {
	Col  sdata.DBColumn
	VCol sdata.DBColumn
}

type MTable

type MTable struct {
	Ti sdata.DBTable
}

type MType

type MType uint8
const (
	MTInsert MType = iota + 1
	MTUpdate
	MTUpsert
	MTDelete
	MTConnect
	MTDisconnect
	MTNone
	MTKeyword
)

func (MType) String

func (i MType) String() string

type Mutate

type Mutate struct {
	Field

	ID        int32
	ParentID  int32
	DependsOn map[int32]struct{}
	Type      MType
	// CType     uint8
	Key   string
	Path  []string
	Val   json.RawMessage
	Cols  []MColumn
	RCols []MRColumn
	Ti    sdata.DBTable
	Rel   sdata.DBRel
	Where Filter
	Multi bool
	// contains filtered or unexported fields
}

type NewValidFn added in v2.0.23

type NewValidFn func(args []string) (fn ValidFn, err error)

type Order

type Order int8
const (
	OrderNone Order = iota
	OrderAsc
	OrderDesc
	OrderAscNullsFirst
	OrderAscNullsLast
	OrderDescNullsFirst
	OrderDescNullsLast
)

func (Order) String

func (o Order) String() string

type OrderBy

type OrderBy struct {
	KeyVar string
	Key    string
	Col    sdata.DBColumn
	Var    string
	Order  Order
}

type Paging

type Paging struct {
	Type      PagingType
	LimitVar  string
	Limit     int32
	OffsetVar string
	Offset    int32
	Cursor    bool
	NoLimit   bool
}

type PagingType

type PagingType int8
const (
	PTOffset PagingType = iota
	PTForward
	PTBackward
)

func (PagingType) String

func (i PagingType) String() string

type QCode

type QCode struct {
	Type      QType
	SType     QType
	Name      string
	ActionVar string
	ActionVal json.RawMessage
	Vars      []Var
	Selects   []Select
	Consts    []Constraint
	Roots     []int32

	Mutates    []Mutate
	MUnions    map[string][]int32
	Schema     *sdata.DBSchema
	Remotes    int32
	Cache      Cache
	Script     Script
	Validation Validation
	Typename   bool
	Query      []byte
	Fragments  []Fragment
	// contains filtered or unexported fields
}

func (*QCode) ProcessConstraints added in v2.0.23

func (qc *QCode) ProcessConstraints(vmap map[string]json.RawMessage) (errs []ValidErr)

type QType

type QType int8
const (
	QTUnknown      QType = iota // Unknown
	QTQuery                     // Query
	QTSubscription              // Subcription
	QTMutation                  // Mutation
	QTInsert                    // Insert
	QTUpdate                    // Update
	QTDelete                    // Delete
	QTUpsert                    // Upsert
)

func GetQType

func GetQType(t graph.ParserType) QType

func GetQTypeByName

func GetQTypeByName(t string) QType

func (QType) String

func (i QType) String() string

type QueryConfig

type QueryConfig struct {
	Limit            int
	Filters          []string
	Columns          []string
	DisableFunctions bool
	Block            bool
}

type Schema added in v2.0.19

type Schema struct {
	Type      string
	Version   int
	Schema    string
	Columns   []sdata.DBColumn
	Functions []sdata.DBFunction
}

func ParseSchema added in v2.0.19

func ParseSchema(b []byte) (ds Schema, err error)

type Script

type Script struct {
	Exists bool
	Source string
	Name   string
	SC     plugin.ScriptExecuter
}

func (*Script) HasReqFn

func (s *Script) HasReqFn() bool

func (*Script) HasRespFn

func (s *Script) HasRespFn() bool

type SelType

type SelType int8
const (
	SelTypeNone SelType = iota
	SelTypeUnion
	SelTypeMember
)

func (SelType) String

func (i SelType) String() string

type Select

type Select struct {
	Field
	Type       SelType
	Singular   bool
	Typename   bool
	Table      string
	Schema     string
	Fields     []Field
	BCols      []Column
	IArgs      []Arg
	Where      Filter
	OrderBy    []OrderBy
	DistinctOn []sdata.DBColumn
	GroupCols  bool
	Paging     Paging
	Children   []int32
	Ti         sdata.DBTable
	Rel        sdata.DBRel
	Joins      []Join
	// contains filtered or unexported fields
}

func (*Select) GetInternalArg

func (sel *Select) GetInternalArg(name string) (Arg, bool)

type SkipType

type SkipType int8
const (
	SkipTypeNone SkipType = iota
	SkipTypeDrop
	SkipTypeNulled
	SkipTypeUserNeeded
	SkipTypeBlocked
	SkipTypeRemote
)

func (SkipType) String

func (i SkipType) String() string

type TConfig

type TConfig struct {
	OrderBy map[string][][2]string
}

type TRConfig

type TRConfig struct {
	Query  QueryConfig
	Insert InsertConfig
	Update UpdateConfig
	Upsert UpsertConfig
	Delete DeleteConfig
}

type TableInfo

type TableInfo struct {
	sdata.DBTable
}

type UpdateConfig

type UpdateConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type UpsertConfig

type UpsertConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type ValType

type ValType int8
const (
	ValStr ValType = iota + 1
	ValNum
	ValBool
	ValList
	ValObj
	ValVar
)

func (ValType) String

func (i ValType) String() string

type ValidErr added in v2.0.23

type ValidErr struct {
	FieldName  string `json:"field_name"`
	Constraint string `json:"constraint"`
}

type ValidFn added in v2.0.23

type ValidFn func(Vars, Constraint) bool

type Validation

type Validation struct {
	Exists bool
	Source string
	Type   string
	VE     plugin.ValidationExecuter
}

type Validator added in v2.0.23

type Validator struct {
	Description string
	Type        string
	List        bool
	Types       []graph.ParserType
	NewFn       NewValidFn
}

type Var added in v2.0.27

type Var struct {
	Name string
	Val  json.RawMessage
}

type Vars added in v2.0.23

type Vars map[string]json.RawMessage

Jump to

Keyboard shortcuts

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