module_model

package
v0.0.0-...-6dc645d Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RULETYPE_NONE     = "none"
	RULETYPE_ALWAYS   = "always"
	RULETYPE_CUSTOM   = "custom"
	RULEPREFIX_TOKEN  = "token"
	RULEPREFIX_DOCS   = "docs"
	RULEPREFIX_NONE   = "none"
	QUERY_TYPE_INSERT = "insert"
	QUERY_TYPE_UPDATE = "update"
	QUERY_TYPE_DELETE = "delete"
	QUERY_TYPE_SELECT = "select"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnMasking

type ColumnMasking struct {
	MaskingType string
	MaskingRule string
	CustomRule  security_rule.CustomRule
}

type DataSource

type DataSource struct {
	DbAlias                    string                                  `eru:"required"`
	DbType                     string                                  `eru:"required"`
	DbName                     string                                  `eru:"required"`
	DbConfig                   DbConfig                                `eru:"required"`
	SchemaTables               map[string]map[string]TableColsMetaData //tableName is the key
	OtherTables                map[string]map[string]TableColsMetaData `json:"-"` //tableName is the key
	SchemaTablesSecurity       map[string]SecurityRules
	SchemaTablesTransformation map[string]TransformRules
	TableJoins                 map[string]*TableJoins
	Con                        *sqlx.DB `json:"-"`
	ConStatus                  bool
	DbSecurityRules            SecurityRules
}

func (*DataSource) AddTableJoins

func (ds *DataSource) AddTableJoins(ctx context.Context, tj *TableJoins)

func (*DataSource) CreateTable

func (ds *DataSource) CreateTable(ctx context.Context, tableName string, tableObj map[string]TableColsMetaData) (err error)

func (*DataSource) GetTableJoins

func (ds *DataSource) GetTableJoins(ctx context.Context, parentTableName string, childTableName string, otherTables map[string]string) (TableJoins, error)

func (*DataSource) RemoveTableJoins

func (ds *DataSource) RemoveTableJoins(ctx context.Context, tj *TableJoins)

type DbConfig

type DbConfig struct {
	Host          string       `eru:"required"`
	Port          string       `eru:"required"`
	User          string       `eru:"required"`
	Password      string       `eru:"required"`
	DefaultDB     string       `eru:"required"`
	DefaultSchema string       `eru:"required"`
	DriverConfig  DriverConfig `eru:"required"`
	OtherDbConfig OtherDbConfig
}

type DriverConfig

type DriverConfig struct {
	MaxOpenConns    int           `eru:"required"`
	MaxIdleConns    int           `eru:"required"`
	ConnMaxLifetime time.Duration `eru:"required"`
}

type ModuleProjectI

type ModuleProjectI interface {
	CompareProject(ctx context.Context, compareProject Project) (StoreCompare, error)
}

type MutationRecord

type MutationRecord struct {
	Cols            string
	NonNestedCols   string
	NonNestedValues []interface{}
	UpdatedCols     string
	ColsPlaceholder string
	Values          []interface{}
	ChildRecords    map[string][]MutationRecord
	TableJoins      map[string]TableJoins
	DBQuery         string
}

type MutationResultMaker

type MutationResultMaker struct {
	MainTableName   string
	MainAliasName   string
	MutationRecords []MutationRecord
	MutationReturn  MutationReturn
	QueryType       string
	SingleTxn       bool
	OpenTxn         bool
	CloseTxn        bool
	TxnFlag         bool
	IsNested        bool
	DBQuery         string
	PreparedQuery   bool
}

type MutationReturn

type MutationReturn struct {
	ReturnError      bool
	ReturnDoc        bool
	ReturnErrorAlias string
	ReturnDocAlias   string
	ReturnFields     string
}

type MyQuery

type MyQuery struct {
	QueryName    string
	Query        string
	Vars         map[string]interface{}
	QueryType    string
	DBAlias      string
	ReadWrite    string
	Cols         string
	SecurityRule security_rule.SecurityRule
}
type AesKey struct {
	Key string
	//Bits int
}
type TokenSecret struct {
	HeaderKey  string
	SecretAlgo string
	SecretKey  string
	JwkUrl     string
	Audience   []string
	Issuer     []string
}

type OtherDbConfig

type OtherDbConfig struct {
	RowLimit       int
	QueryTimeOut   int
	AllowDropTable bool
}

type Project

type Project struct {
	ProjectId       string                 `eru:"required"`
	DataSources     map[string]*DataSource //DB alias is the key
	MyQueries       map[string]*MyQuery    //queryName is key
	ProjectSettings ProjectSettings
}

func (*Project) CompareProject

func (prj *Project) CompareProject(ctx context.Context, compareProject Project) (StoreCompare, error)

type ProjectSettings

type ProjectSettings struct {
	AesKey    string
	ClaimsKey string
}

type QueryResultMaker

type QueryResultMaker struct {
	QueryLevel    int
	QuerySubLevel []int
	MainTableName string
	MainAliasName string
	Tables        [][]Tables
	SQLQuery      string
}

type SecurityRules

type CustomRule struct {
	AND []CustomRuleDetails `json:",omitempty"`
	OR  []CustomRuleDetails `json:",omitempty"`
}
type CustomRuleDetails struct {
	DataType  string              `json:",omitempty"`
	Variable1 string              `json:",omitempty"`
	Variable2 string              `json:",omitempty"`
	Operator  string              `json:",omitempty"`
	ErrorMsg  string              `json:",omitempty"`
	AND       []CustomRuleDetails `json:",omitempty"`
	OR        []CustomRuleDetails `json:",omitempty"`
}
type SecurityRule struct {
	RuleType   string
	CustomRule CustomRule
}

type StoreCompare

type StoreCompare struct {
	DeleteQueries       []string
	NewQueries          []string
	MismatchQuries      map[string]interface{}
	DeleteDataSources   []string
	NewDataSources      []string
	MismatchDataSources map[string]interface{}
}

type TableColsMetaData

type TableColsMetaData struct {
	TblSchema         string `eru:"required"`
	TblName           string `eru:"required"`
	ColName           string `eru:"required"`
	DataType          string
	OwnDataType       string `eru:"required"`
	PrimaryKey        bool   `eru:"required"`
	IsUnique          bool   `eru:"required"`
	PkConstraintName  string
	UqConstraintName  string
	IsNullable        bool `eru:"required"`
	ColPosition       int
	DefaultValue      string
	AutoIncrement     bool
	CharMaxLength     int
	NumericPrecision  string
	NumericScale      int
	DatetimePrecision int
	FkConstraintName  string
	FkDeleteRule      string
	FkTblSchema       string
	FkTblName         string
	FkColName         string
	ColumnMasking     ColumnMasking
}

type TableJoins

type TableJoins struct {
	Table1Name       string
	Table1Cols       []string
	Table2Name       string
	Table2Cols       []string
	IsActive         bool
	IsCustom         bool
	ComplexCondition map[string]interface{}
}

func (*TableJoins) GetOnClause

func (tj *TableJoins) GetOnClause(ctx context.Context) (res map[string]interface{})

type Tables

type Tables struct {
	Name     string
	Nested   bool
	SqlQuery string
}

tables used in query

type TransformRule

type TransformRule struct {
	RuleType string
	ApplyOn  []string
	Rules    []TransformRuleDetail
}

type TransformRuleDetail

type TransformRuleDetail struct {
	CustomRule         security_rule.CustomRule
	ForceColumnValues  map[string]string
	RemoveColumnValues []string
	ComplexScript      string
	RuleRank           int
}

type TransformRules

type TransformRules struct {
	TransformInput  TransformRule
	TransformOutput TransformRule
}

Jump to

Keyboard shortcuts

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