store

package
v0.0.0-...-bb643ca Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComparisonILike  = "ilike"
	ComparisonRegexp = "~"
)

Variables

View Source
var Ident = func(left, right string) string {
	return fmt.Sprintf("%s.%s", left, right)
}

Ident returns a string that represents a qualified identifier. For example, Ident("cc", "case_link") returns "cc.case_link".

Functions

func AddSearchTerm

func AddSearchTerm(base squirrel.SelectBuilder, q string, columns ...string) squirrel.SelectBuilder

func ApplyDefaultSorting

func ApplyDefaultSorting(opts model.Sorter, base squirrel.SelectBuilder, defaultSort string) squirrel.SelectBuilder

func ApplyPaging

func ApplyPaging(page int, size int, base squirrel.SelectBuilder) squirrel.SelectBuilder

func BindNamed

func BindNamed(query string, params map[string]interface{}) (string, []interface{}, error)

BindNamed transforms a named query into a positional query with its arguments.

func CompactSQL

func CompactSQL(s string) string

CompactSQL formats given SQL text to compact form. - replaces consecutive white-space(s) with single SPACE(' ') - suppress single-line comment(s), started with -- up to [E]nd[o]f[L]ine - suppress multi-line comment(s), enclosed into /* ... */ pairs - transmits literal '..' or ".." sources in their original form https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS

func FormAsCTE

func FormAsCTE(in squirrel.Sqlizer, alias string) (string, []any, error)

func FormAsCTEs

func FormAsCTEs(in map[string]squirrel.Sqlizer) (string, []any, error)

func GetSortingOperator

func GetSortingOperator(opts model.Sorter) (field, direction string)

func ParseSearchTerm

func ParseSearchTerm(q string) (s string, operator string)

ParseSearchTerm delimit searches for the regexp search indicators and if found returns string without indicators and indicator that regexp search found. Returns changed copy of the input slice.

func PrepareSearchNumber

func PrepareSearchNumber(number string) string

PrepareSearchNumber reverses the first string

func ResolvePaging

func ResolvePaging[T any](size int, items []*T) (updatedItems []*T, next bool)

Types

type AccessControlStore

type AccessControlStore interface {
	// Check if user has Rbac access
	RbacAccess(ctx context.Context, domainId, id int64, groups []int, access uint8, table string) (bool, error)
}

------------Access Control------------//

type CaseCommentStore

type CaseCommentStore interface {
	// Create comment
	Publish(rpc *model.CreateOptions, add *_go.CaseComment) (*_go.CaseComment, error)
	// List comments
	List(rpc *model.SearchOptions) (*_go.CaseCommentList, error)
	// Update comment
	Update(req *model.UpdateOptions, upd *_go.CaseComment) (*_go.CaseComment, error)
	// Delete comment
	Delete(req *model.DeleteOptions) error
}

Comments attribute attached to the case (n:1)

type CaseCommunicationStore

type CaseCommunicationStore interface {
	Link(*model.CreateOptions, []*_go.InputCaseCommunication) ([]*_go.CaseCommunication, error)
	Unlink(*model.DeleteOptions) (int64, error)
	List(opts *model.SearchOptions) (*_go.ListCommunicationsResponse, error)
}

Case connected communications (chats, calls etc.)

type CaseFileStore

type CaseFileStore interface {
	// List files
	List(rpc *model.SearchOptions) (*_go.CaseFileList, error)
	// Delete Case | File association
	Delete(req *model.DeleteOptions) error
}

type CaseLinkStore

type CaseLinkStore interface {
	// Create link
	Create(rpc *model.CreateOptions, add *_go.InputCaseLink) (*_go.CaseLink, error)
	// List links
	List(rpc *model.SearchOptions) (*_go.CaseLinkList, error)
	// Update link
	Update(req *model.UpdateOptions, upd *_go.InputCaseLink) (*_go.CaseLink, error)
	// Delete link
	Delete(req *model.DeleteOptions) error
}

RelatedCases attribute attached to the case (n:1)

type CaseStore

type CaseStore interface {
	// Create a new case
	Create(rpc *model.CreateOptions, add *_go.Case) (*_go.Case, error)
	// List cases
	List(rpc *model.SearchOptions) (*_go.CaseList, error)
	// Update case
	Update(req *model.UpdateOptions, upd *_go.Case) (*_go.Case, error)
	// Delete case
	Delete(req *model.DeleteOptions) error
	// Check case by current auth options
	CheckRbacAccess(ctx context.Context, auth auth.Auther, access auth.AccessMode, caseId int64) (bool, error)
}

------------ Cases Stores ------------ //

type CaseTimelineStore

type CaseTimelineStore interface {
	Get(rpc *model.SearchOptions) (*_go.GetTimelineResponse, error)
	GetCounter(rpc *model.SearchOptions) ([]*model.TimelineCounter, error)
}

Case timeline

type CatalogStore

type CatalogStore interface {
	// Create a new catalog
	Create(rpc *model.CreateOptions, add *_go.Catalog) (*_go.Catalog, error)
	// List catalogs
	List(rpc *model.SearchOptions, depth int64, subfields []string, hasSubservices bool) (*_go.CatalogList, error)
	// Delete catalog
	Delete(rpc *model.DeleteOptions) error
	// Update catalog
	Update(rpc *model.UpdateOptions, lookup *_go.Catalog) (*_go.Catalog, error)
}

CatalogStore is parent store managing service catalogs.

type CloseReasonGroupStore

type CloseReasonGroupStore interface {
	// Create a new close reason lookup
	Create(rpc *model.CreateOptions, add *_go.CloseReasonGroup) (*_go.CloseReasonGroup, error)
	// List close reason lookup
	List(rpc *model.SearchOptions) (*_go.CloseReasonGroupList, error)
	// Delete close reason lookup
	Delete(rpc *model.DeleteOptions) error
	// Update close reason lookup
	Update(rpc *model.UpdateOptions, lookup *_go.CloseReasonGroup) (*_go.CloseReasonGroup, error)
}

type CloseReasonStore

type CloseReasonStore interface {
	// Create a new reason
	Create(ctx *model.CreateOptions, add *_go.CloseReason) (*_go.CloseReason, error)
	// List reasons
	List(ctx *model.SearchOptions, closeReasonId int64) (*_go.CloseReasonList, error)
	// Delete reason
	Delete(ctx *model.DeleteOptions, closeReasonId int64) error
	// Update reason
	Update(ctx *model.UpdateOptions, lookup *_go.CloseReason) (*_go.CloseReason, error)
}

type PriorityStore

type PriorityStore interface {
	// Create a new priority lookup
	Create(rpc *model.CreateOptions, add *_go.Priority) (*_go.Priority, error)
	// List priority lookup
	List(rpc *model.SearchOptions, notInSla int64, inSla int64) (*_go.PriorityList, error)
	// Delete priority lookup
	Delete(rpc *model.DeleteOptions) error
	// Update priority lookup
	Update(rpc *model.UpdateOptions, lookup *_go.Priority) (*_go.Priority, error)
}

type RelatedCaseStore

type RelatedCaseStore interface {
	// Create relation
	Create(rpc *model.CreateOptions, relation *_go.RelationType) (*_go.RelatedCase, error)
	// List related cases
	List(rpc *model.SearchOptions) (*_go.RelatedCaseList, error)
	// Update relation
	Update(req *model.UpdateOptions, upd *_go.InputRelatedCase) (*_go.RelatedCase, error)
	// Delete relation
	Delete(req *model.DeleteOptions) error
}

type SLAConditionStore

type SLAConditionStore interface {
	// Create a new SLA сondition
	Create(ctx *model.CreateOptions, add *_go.SLACondition, priorities []int64) (*_go.SLACondition, error)
	// List SLA сondition
	List(ctx *model.SearchOptions) (*_go.SLAConditionList, error)
	// Delete SLA сondition
	Delete(ctx *model.DeleteOptions) error
	// Update SLA сondition
	Update(ctx *model.UpdateOptions, lookup *_go.SLACondition) (*_go.SLACondition, error)
}

type SLAStore

type SLAStore interface {
	// Create a new SLA lookup
	Create(rpc *model.CreateOptions, add *_go.SLA) (*_go.SLA, error)
	// List SLA lookup
	List(rpc *model.SearchOptions) (*_go.SLAList, error)
	// Delete SLA lookup
	Delete(rpc *model.DeleteOptions) error
	// Update SLA lookup
	Update(rpc *model.UpdateOptions, lookup *_go.SLA) (*_go.SLA, error)
}

type ServiceStore

type ServiceStore interface {
	// Create a new service
	Create(rpc *model.CreateOptions, add *_go.Service) (*_go.Service, error)
	// List services
	List(rpc *model.SearchOptions) (*_go.ServiceList, error)
	// Delete service
	Delete(rpc *model.DeleteOptions) error
	// Update service
	Update(rpc *model.UpdateOptions, lookup *_go.Service) (*_go.Service, error)
}

Service is child store managing services within catalogs.

type SourceStore

type SourceStore interface {
	// Create a new source lookup
	Create(rpc *model.CreateOptions, add *_go.Source) (*_go.Source, error)
	// List source lookup
	List(rpc *model.SearchOptions) (*_go.SourceList, error)
	// Delete source lookup
	Delete(rpc *model.DeleteOptions) error
	// Update source lookup
	Update(rpc *model.UpdateOptions, lookup *_go.Source) (*_go.Source, error)
}

type StatusConditionStore

type StatusConditionStore interface {
	// Create a new status сondition
	Create(ctx *model.CreateOptions, add *_go.StatusCondition) (*_go.StatusCondition, error)
	// List status сondition
	List(ctx *model.SearchOptions, statusId int64) (*_go.StatusConditionList, error)
	// Delete status сondition
	Delete(ctx *model.DeleteOptions, statusId int64) error
	// Update status сondition
	Update(ctx *model.UpdateOptions, status *_go.StatusCondition) (*_go.StatusCondition, error)
}

type StatusStore

type StatusStore interface {
	// Create a new status lookup
	Create(rpc *model.CreateOptions, add *_go.Status) (*_go.Status, error)
	// List status lookup
	List(rpc *model.SearchOptions) (*_go.StatusList, error)
	// Delete status lookup
	Delete(rpc *model.DeleteOptions) error
	// Update status lookup
	Update(rpc *model.UpdateOptions, lookup *_go.Status) (*_go.Status, error)
}

------------ Dictionary Stores ------------ //

type Store

type Store interface {
	// ------------ Cases Stores ------------ //
	Case() CaseStore
	CaseComment() CaseCommentStore
	CaseLink() CaseLinkStore
	CaseFile() CaseFileStore
	CaseTimeline() CaseTimelineStore
	CaseCommunication() CaseCommunicationStore
	RelatedCase() RelatedCaseStore

	// ------------ Dictionary Stores ------------ //
	Source() SourceStore
	Priority() PriorityStore

	// ------------ Closure reasons Stores ------------ //
	CloseReasonGroup() CloseReasonGroupStore
	CloseReason() CloseReasonStore

	// ------------ Status ------------ //
	Status() StatusStore
	StatusCondition() StatusConditionStore

	// ------------ SLA Stores ------------ //
	SLA() SLAStore
	SLACondition() SLAConditionStore

	// ------------ Catalog and Service Stores ------------ //
	Catalog() CatalogStore
	Service() ServiceStore

	// ------------ Access Control ------------ //
	AccessControl() AccessControlStore

	// ------------ Database Management ------------ //
	Database() (*pgxpool.Pool, *dberr.DBError) // Return custom DB error
	Open() *dberr.DBError                      // Return custom DB error
	Close() *dberr.DBError                     // Return custom DB error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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