mctypes

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 4 Imported by: 2

README

mctypes | github.com/abbeymart/mctypes

  • mConnect Constants and Types for mConnect solutions, micro-services & packages

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionParamType added in v0.4.1

type ActionParamType map[string]interface{}

type ActionParamsType

type ActionParamsType []ActionParamType

type AppParamsType added in v0.4.4

type AppParamsType struct {
	AppId     string `json:"appId"`
	AccessKey string `json:"accessKey"`
	AppName   string `json:"appName"`
}

type AppType added in v0.4.4

type AppType struct {
	BaseModelType
	AppName     string `json:"appName"`
	AccessKey   string `json:"accessKey"`
	AppCategory string `json:"appCategory"`
	OwnerId     string `json:"ownerId"`
}

type AuditStampType

type AuditStampType struct {
	IsActive  bool      `json:"isActive"` // => activate by modelOptionsType settings...
	CreatedBy string    `json:"createdBy"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedBy string    `json:"updatedBy"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type AuthError

type AuthError ErrorType

type BaseModelType added in v0.4.4

type BaseModelType struct {
	Id        string    `json:"id"`
	Language  string    `json:"language"`
	Desc      string    `json:"desc"`
	AppId     string    `json:"appId"`    // application-id in a multi-hosted apps environment (e.g. cloud-env)
	IsActive  bool      `json:"isActive"` // => activate by modelOptionsType settings...
	CreatedBy string    `json:"createdBy"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedBy string    `json:"updatedBy"`
	UpdatedAt time.Time `json:"updatedAt"`
	DeletedAt time.Time `json:"deletedAt"`
}

type CheckAccessParamsType

type CheckAccessParamsType struct {
	AccessDb         *pgxpool.Pool `json:"accessDb"`
	UserInfo         UserInfoType  `json:"userInfo"`
	TableName        string        `json:"tableName"`
	RecordIds        []string      `json:"recordIds"` // for update, delete and read tasks
	AccessTable      string        `json:"accessTable"`
	UserTable        string        `json:"userTable"`
	RoleTable        string        `json:"roleTable"`
	ServiceTable     string        `json:"serviceTable"`
	UserProfileTable string        `json:"userProfileTable"`
}

type CheckAccessType

type CheckAccessType struct {
	UserId       string            `json:"userId" mcorm:"userId"`
	Group        string            `json:"group" mcorm:"group"`
	Groups       []string          `json:"groups" mcorm:"groups"`
	IsActive     bool              `json:"isActive" mcorm:"isActive"`
	IsAdmin      bool              `json:"isAdmin" mcorm:"isAdmin"`
	RoleServices []RoleServiceType `json:"roleServices" mcorm:"roleServices"`
	TableId      string            `json:"tableId" mcorm:"tableId"`
}

type ComputedMethodsType

type ComputedMethodsType map[string]ComputedValueType

type ComputedValueType

type ComputedValueType func(val interface{}) interface{}

type ConnectError

type ConnectError ErrorType

type CreateError

type CreateError ErrorType

type CreateQueryError

type CreateQueryError ErrorType

type CreateQueryResponseType

type CreateQueryResponseType struct {
	CreateQuery string
	FieldNames  []string
	FieldValues [][]interface{}
}

type CrudOptionsType

type CrudOptionsType struct {
	ParentTables     []string
	ChildTables      []string
	RecursiveDelete  bool
	CheckAccess      bool
	AccessDb         *pgxpool.Pool
	AuditDb          *pgxpool.Pool
	ServiceDb        *pgxpool.Pool
	AuditTable       string
	ServiceTable     string
	UserTable        string
	RoleTable        string
	AccessTable      string
	VerifyTable      string
	UserProfileTable string
	MaxQueryLimit    int

	LogCreate             bool
	LogUpdate             bool
	LogRead               bool
	LogDelete             bool
	LogLogin              bool
	LogLogout             bool
	UnAuthorizedMessage   string
	RecExistMessage       string
	CacheExpire           int
	LoginTimeout          int
	UsernameExistsMessage string
	EmailExistsMessage    string
	MsgFrom               string
	// contains filtered or unexported fields
}

type CrudParamType

type CrudParamType struct {
	AppDb            *pgxpool.Pool // use *pgxpool.Pool, preferred || *pgx.Conn
	TableName        string
	Token            string
	UserInfo         UserInfoType
	UserId           string
	Group            string
	Groups           []string
	RecordIds        []string
	ActionParams     ActionParamsType
	QueryParams      QueryParamType
	ExistParams      ExistParamsType
	ProjectParams    ProjectParamType
	SortParams       SortParamType
	Skip             int
	Limit            int
	ParentTables     []string
	ChildTables      []string
	RecursiveDelete  bool
	CheckAccess      bool
	AccessDb         *pgxpool.Pool
	AuditDb          *pgxpool.Pool
	AuditTable       string
	ServiceTable     string
	UserTable        string
	UserProfileTable string
	RoleTable        string
	AccessTable      string
	MaxQueryLimit    int

	LogCreate bool
	LogUpdate bool
	LogRead   bool
	LogDelete bool
	//transLog AuditLog
	HashKey             string
	IsRecExist          bool
	ActionAuthorized    bool
	UnAuthorizedMessage string
	RecExistMessage     string
	IsAdmin             bool
	CreateItems         ActionParamsType
	UpdateItems         ActionParamsType
	CurrentRecs         ActionParamsType
	RoleServices        []RoleServiceType
	SubItems            []bool
	CacheExpire         int
	Params              CrudParamsType
	// contains filtered or unexported fields
}

type CrudParamsType

type CrudParamsType struct {
	AppDb         *pgxpool.Pool    `json:"-"`
	TableName     string           `json:"-"`
	UserInfo      UserInfoType     `json:"userInfo"`
	ActionParams  ActionParamsType `json:"actionParams"`
	ExistParams   ExistParamsType  `json:"existParams"`
	QueryParams   WhereParamType   `json:"queryParams"`
	RecordIds     []string         `json:"recordIds"`
	ProjectParams ProjectParamType `json:"projectParams"`
	SortParams    SortParamType    `json:"sortParams"`
	Token         string           `json:"token"`
	Skip          int              `json:"skip"`
	Limit         int              `json:"limit"`
	TaskName      string           `json:"-"`
}

CrudParamsType is the struct type for receiving, composing and passing CRUD inputs

type DefaultValueType

type DefaultValueType func() interface{}

type DeleteCrudParamsType added in v0.3.4

type DeleteCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type DeleteError

type DeleteError ErrorType

type DeleteParamsType added in v0.3.0

type DeleteParamsType struct {
	UserInfo    UserInfoType   `json:"userInfo"`
	RecordIds   []string       `json:"recordIds"`
	QueryParams QueryParamType `json:"queryParams"`
}

type DeleteQueryError

type DeleteQueryError ErrorType

type DeleteQueryResponseType

type DeleteQueryResponseType struct {
	DeleteQuery string
	WhereQuery  string
	FieldValues []interface{}
}

type ErrorType

type ErrorType struct {
	Code    string
	Message string
}

ErrorType provides the structure for error reporting

func (ErrorType) Error

func (err ErrorType) Error() string

sample Error() implementation

type ExistParamType

type ExistParamType map[string]interface{}

type ExistParamsType

type ExistParamsType []ExistParamType

type FieldDescType

type FieldDescType struct {
	FieldType       string
	FieldLength     int    // default: 255 for DataType.STRING
	FieldPattern    string // "/^[0-9]{10}$/" => includes 10 digits, 0 to 9 | "/^[0-9]{6}.[0-9]{2}$/ => max 16 digits and 2 decimal places
	AllowNull       bool   // default: true
	Unique          bool
	Indexable       bool
	PrimaryKey      bool
	MinValue        int
	MaxValue        int
	SetValue        SetValueType       // set/transform fieldValue prior to save(create/insert), T=>fieldType
	DefaultValue    DefaultValueType   // result/T must be of fieldType
	Validate        ValidateMethodType // T=>fieldType, returns a bool (valid=true/invalid=false)
	ValidateMessage string
}

type FieldValueType

type FieldValueType interface{}

type GetCrudParamsType added in v0.3.4

type GetCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type GetParamsType added in v0.3.0

type GetParamsType struct {
	UserInfo     UserInfoType     `json:"userInfo"`
	Skip         int              `json:"skip"`
	Limit        int              `json:"limit"`
	RecordIds    []string         `json:"recordIds"`
	QueryParams  QueryParamType   `json:"queryParams"`
	SortParam    SortParamType    `json:"sortParams"`
	ProjectParam ProjectParamType `json:"projectParam"`
}

type GetValueType

type GetValueType func() interface{}

type MessageObject

type MessageObject map[string]string

type ModelRelationType

type ModelRelationType struct {
	SourceTable   string
	TargetTable   string
	SourceField   string
	TargetField   string
	RelationType  string
	SourceModel   ModelType
	TargetModel   ModelType
	ForeignField  string // source-to-targetField map
	RelationField string // relation-targetField, for many-to-many
	RelationTable string // optional tableName for many-to-many | default: sourceTable_targetTable
	OnDelete      string
	OnUpdate      string
}

type ModelType

type ModelType struct {
	AppDb           *pgxpool.Pool
	TableName       string
	RecordDesc      RecordDescType
	TimeStamp       bool // auto-add: createdAt and updatedAt | default: true
	ActorStamp      bool // auto-add: createdBy and updatedBy | default: true
	ActiveStamp     bool // record active status, isActive (true | false) | default: true
	Relations       []ModelRelationType
	ComputedMethods ComputedMethodsType // model-level functions, e.g fullName(a, b: T): T
	ValidateMethods ValidateMethodsType
	AlterSyncTable  bool // create / alter table/collection and sync existing data, if there was a change to the table structure | default: true

}

type MongoCrudOptionsType

type MongoCrudOptionsType struct {
	Skip            int
	Limit           int
	ParentTables    []string
	ChildTables     []string
	RecursiveDelete bool
	CheckAccess     bool
	AccessDb        *mongo.Client
	AuditDb         *mongo.Client
	ServiceDb       *mongo.Client
	AuditTable      string
	ServiceTable    string
	UserTable       string
	RoleTable       string
	AccessTable     string
	VerifyTable     string
	MaxQueryLimit   int

	LogCreate             bool
	LogUpdate             bool
	LogRead               bool
	LogDelete             bool
	LogLogin              bool
	LogLogout             bool
	UnAuthorizedMessage   string
	RecExistMessage       string
	CacheExpire           int
	LoginTimeout          int
	UsernameExistsMessage string
	EmailExistsMessage    string
	MsgFrom               string
	// contains filtered or unexported fields
}

type MongoCrudParamType

type MongoCrudParamType struct {
	AppDb           *mongo.Client
	TableName       string
	Token           string
	UserInfo        UserInfoType
	UserId          string
	Group           string
	Groups          []string
	RecordIds       []string
	ActionParams    ActionParamsType
	QueryParams     QueryParamType
	ExistParams     ExistParamsType
	ProjectParams   ProjectParamType
	SortParams      SortParamType
	Skip            int
	Limit           int
	ParentTables    []string
	ChildTables     []string
	RecursiveDelete bool
	CheckAccess     bool
	AccessDb        *mongo.Client
	AuditDb         *mongo.Client
	AuditTable      string
	ServiceTable    string
	UserTable       string
	RoleTable       string
	AccessTable     string
	MaxQueryLimit   int

	LogCreate bool
	LogUpdate bool
	LogRead   bool
	LogDelete bool
	//transLog AuditLog
	HashKey             string
	IsRecExist          bool
	ActionAuthorized    bool
	UnAuthorizedMessage string
	RecExistMessage     string
	IsAdmin             bool
	CreateItems         ActionParamsType
	UpdateItems         ActionParamsType
	CurrentRecs         ActionParamsType
	RoleServices        []RoleServiceType
	SubItems            []bool
	CacheExpire         int
	Params              MongoCrudTaskType
	// contains filtered or unexported fields
}

type MongoCrudTaskType

type MongoCrudTaskType struct {
	AppDb         *mongo.Client
	TableName     string
	UserInfo      UserInfoType
	ActionParams  ActionParamsType
	ExistParams   ExistParamsType
	QueryParams   QueryParamType
	RecordIds     []string
	ProjectParams ProjectParamType
	SortParams    SortParamType
	Token         string
	Options       MongoCrudOptionsType
	TaskName      string
}

type OkResponse

type OkResponse struct {
	Ok bool `json:"ok"`
}

type ProjectParamType

type ProjectParamType map[string]bool // 1 or true for inclusion, 0 or false for exclusion

type QueryGroupType

type QueryGroupType struct {
	GroupName   string          `json:"groupName"`   // for group-items(fields) categorization
	GroupItems  []QueryItemType `json:"groupItems"`  // group items to be composed by category
	GroupOrder  int             `json:"groupOrder"`  // group order
	GroupLinkOp string          `json:"groupLinkOp"` // group relationship to the next group (AND, OR), the last group groupLinkOp should be "" or will be ignored
}

type QueryItemType

type QueryItemType struct {
	GroupItem      map[string]map[string]interface{} `json:"groupItem"`      // key1 => fieldName, key2 => fieldOperator, interface{}=> value(s)
	GroupItemOrder int                               `json:"groupItemOrder"` // item/field order within the group
	GroupItemOp    string                            `json:"groupItemOp"`    // group-item relationship to the next item (AND, OR), the last item groupItemOp should be "" or will be ignored
}

type QueryParamType

type QueryParamType []QueryGroupType

type ReadError

type ReadError ErrorType

type RecordDescType

type RecordDescType map[string]FieldDescType

type RecordValueType

type RecordValueType map[string]ActionParamType

type RoleFuncType

type RoleFuncType func(it1 string, it2 RoleServiceType) bool

type RoleServiceType

type RoleServiceType struct {
	ServiceId            string   `json:"serviceId"`
	RoleId               string   `json:"roleId"`
	RoleIds              []string `json:"roleIds"`
	ServiceCategory      string   `json:"serviceCategory"`
	CanRead              bool     `json:"canRead"`
	CanCreate            bool     `json:"canCreate"`
	CanUpdate            bool     `json:"canUpdate"`
	CanDelete            bool     `json:"canDelete"`
	CanCrud              bool     `json:"canCrud"`
	TableAccessPermitted bool     `json:"tableAccessPermitted"`
}

type SaveCrudParamsType added in v0.3.4

type SaveCrudParamsType struct {
	CrudParams         CrudParamsType
	CrudOptions        CrudOptionsType
	CreateTableFields  []string
	UpdateTableFields  []string
	GetTableFields     []string
	TableFieldPointers []interface{}
	AuditLog           bool
}

type SaveError

type SaveError ErrorType

type SaveParamsType added in v0.3.0

type SaveParamsType struct {
	UserInfo    UserInfoType   `json:"userInfo"`
	QueryParams QueryParamType `json:"queryParams"`
	RecordIds   []string       `json:"recordIds"`
}

type SelectQueryError

type SelectQueryError ErrorType

type SelectQueryResponseType

type SelectQueryResponseType struct {
	SelectQuery string
	WhereQuery  string
	FieldValues []interface{}
}

type SetValueType

type SetValueType func(val interface{}) interface{}

type SortParamType

type SortParamType map[string]int // 1 for "asc", -1 for "desc"

type UpdateError

type UpdateError ErrorType

type UpdateQueryError

type UpdateQueryError ErrorType

type UpdateQueryResponseType

type UpdateQueryResponseType struct {
	UpdateQuery string
	WhereQuery  string
	FieldValues []interface{}
}

type UserInfoType

type UserInfoType struct {
	UserId    string `json:"userId" form:"userId"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Language  string `json:"language"`
	LoginName string `json:"loginName" form:"loginName"`
	Token     string `json:"token"`
	Expire    int64  `json:"expire"`
	Email     string `json:"email" form:"email"`
	Group     string `json:"group"`
}

type ValidateMethodResponseType

type ValidateMethodResponseType func(val interface{}) ValidateResponseType

type ValidateMethodType

type ValidateMethodType func(val interface{}) bool

type ValidateMethodsType

type ValidateMethodsType map[string]ValidateMethodResponseType

type ValidateResponseType

type ValidateResponseType struct {
	Ok     bool          `json:"ok"`
	Errors MessageObject `json:"errors"`
}

type ValueToDataType

type ValueToDataType map[string]interface{}

type ValueType added in v0.3.6

type ValueType struct {
	Value interface{} `json:"value"`
	Type  string      `json:"type"`
}

type WhereParamType

type WhereParamType []QueryGroupType

type WhereQueryError

type WhereQueryError ErrorType

type WhereQueryResponseType

type WhereQueryResponseType struct {
	WhereQuery  string
	FieldValues []interface{}
}

Directories

Path Synopsis
Package appConstants publish default application/system constants
Package appConstants publish default application/system constants

Jump to

Keyboard shortcuts

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