foundation

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionPool = []Repository{}
View Source
var FileConnectionPool = []FileRepository{}
View Source
var StationConnectionPool = []StationRepository{}

Functions

func AddNotificationByText

func AddNotificationByText(notifications []*Notification, destination Notifiable, message string, users []string, source string)

func AddNotifications

func AddNotifications(notifications []*Notification, destination Notifiable, users []string, source string)

func CountNotifications

func CountNotifications(notifications []*Notification, message string) int

func GetDefaultLanguages

func GetDefaultLanguages() map[string]Language

func GetGCPToken

func GetGCPToken(token string, tokenType string, user User) (*oauth2.Token, error)

func GetValueToObjectId

func GetValueToObjectId(container map[string]interface{}, key string) *primitive.ObjectID

func InTimeSpan

func InTimeSpan(start, end, checkTime time.Time) bool

func NewError

func NewError(i Notifiable, message string, users []string, source string) *[]*Notification

func NewInfo

func NewInfo(i Notifiable, message string, users []string, source string) *[]*Notification

func NewNotification

func NewNotification(notifications []*Notification, message *Message) *[]*Notification

func NewWarning

func NewWarning(i Notifiable, message string, users []string, source string) *[]*Notification

func NewWarningWithCode

func NewWarningWithCode(i Notifiable, message string, code NotifyCode, users []string, source string) *[]*Notification

func Notify

func Notify(i Notifiable, message *Message, users []string, source string) *[]*Notification

func ParseMapToStruct

func ParseMapToStruct(data map[string]interface{}, model interface{}) error

func SendNotificationToUser

func SendNotificationToUser(userID string, count int) error

SendNotificationToUser sends a notification using the default service

func SetNotificationService

func SetNotificationService(service NotificationService)

SetNotificationService sets the global notification service

func UpdateBaseList

func UpdateBaseList(model ListItemModel, list interface{}) error

Types

type Action

type Action utils.Enum
const (
	ActionUpdate Action = "ActionUpdate"
	ActionDelete Action = "ActionDelete"
	ActionNone   Action = ""
)

type ActionLog

type ActionLog utils.Enum

type AuditType

type AuditType utils.Enum
const (
	AuditTypeNone     AuditType = ""
	AuditTypeInternal AuditType = "audit_type_internal"
	AuditTypeExternal AuditType = "audit_type_external"
)

func GetAuditType

func GetAuditType(name string) (AuditType, error)

type BaseModel

type BaseModel struct {
	ID       *primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
	UserLogs `bson:",inline"`
	Language Language `json:"language,omitempty" bson:"language,omitempty"`
	// Refers to other system for synchronization
	ExternalID string     `json:"external_id,omitempty" bson:"external_id,omitempty"`
	SyncAt     *time.Time `json:"sync_at,omitempty" bson:"sync_at,omitempty"`
	Labels     *Labels    `json:"labels" bson:"labels,omitempty"`
	Tags       *Tags      `json:"tags" bson:"tags,omitempty"`
	// Relations with others in same collection
	FamilyID string `json:"family_id,omitempty" bson:"family_id,omitempty"`
	// Store domain of the model
	RepoID string `json:"repo_id,omitempty" bson:"repo_id,omitempty"`
	// REMOVE
	OriginRepoID string `json:"origin_repo_id,omitempty" bson:"origin_repo_id,omitempty"`
	// Interface connection with other collections
	SourceID   string     `json:"source_id,omitempty" bson:"source_id"`
	SourceType SourceType `json:"source_tlabype,omitempty" bson:"source_type,omitempty"`
	Version    int        `json:"version,omitempty" bson:"version,omitempty"`
	Touched    bool       `json:"touched,omitempty" bson:"-"`
	ParentID   string     `json:"parent_id" bson:"parent_id,omitempty"`
	LabelsNot  *Labels    `json:"labels_not,omitempty" bson:"-"`
}

func (*BaseModel) BaseAddItemInArray

func (m *BaseModel) BaseAddItemInArray(request *BaseRequest) BaseResponse

func (*BaseModel) BaseCount

func (m *BaseModel) BaseCount(request *BaseRequest) BaseResponse

func (*BaseModel) BaseDelete

func (m *BaseModel) BaseDelete(request BaseRequest) BaseResponse

func (*BaseModel) BaseDeleteSoft

func (m *BaseModel) BaseDeleteSoft(request BaseRequest) BaseResponse

func (*BaseModel) BaseFind

func (m *BaseModel) BaseFind(request *BaseRequest) BaseResponse

func (*BaseModel) BaseFindOne

func (m *BaseModel) BaseFindOne(request BaseRequest) BaseResponse

func (*BaseModel) BaseRemoveField

func (m *BaseModel) BaseRemoveField(request BaseRequest, field string) BaseResponse

func (*BaseModel) BaseRemoveItemInArray

func (m *BaseModel) BaseRemoveItemInArray(request *BaseRequest, field string, value string) BaseResponse

func (*BaseModel) BaseSwitchItemInArray

func (m *BaseModel) BaseSwitchItemInArray(request *BaseRequest, field string, value string) BaseResponse

func (*BaseModel) BaseUpdate

func (m *BaseModel) BaseUpdate(request BaseRequest) BaseResponse

func (*BaseModel) BaseUpdateField

func (m *BaseModel) BaseUpdateField(request BaseRequest, field string, value interface{}) BaseResponse

func (*BaseModel) BaseUpdateMany

func (m *BaseModel) BaseUpdateMany(request BaseRequest, values map[string]interface{}) BaseResponse

func (*BaseModel) BecomeNew

func (m *BaseModel) BecomeNew()

func (*BaseModel) BecomeNewButKeepID

func (m *BaseModel) BecomeNewButKeepID()

func (*BaseModel) CompareLabels

func (m *BaseModel) CompareLabels(labels Labels) bool

func (*BaseModel) Err

func (m *BaseModel) Err(err error) error

func (*BaseModel) False

func (m *BaseModel) False() *bool

func (*BaseModel) GetBaseFindOptions

func (m *BaseModel) GetBaseFindOptions(request *BaseRequest) *FindOptions

func (*BaseModel) GetExternalID

func (m *BaseModel) GetExternalID() string

func (*BaseModel) GetID

func (m *BaseModel) GetID() (interface{}, error)

func (*BaseModel) GetIDStr

func (m *BaseModel) GetIDStr() string

func (*BaseModel) GetLabels

func (m *BaseModel) GetLabels() []Label

func (*BaseModel) GetRepoID

func (m *BaseModel) GetRepoID() string

func (*BaseModel) HasLabel

func (m *BaseModel) HasLabel(label Label) bool

func (*BaseModel) HasLabels

func (m *BaseModel) HasLabels(labels []Label) bool

func (*BaseModel) IsDeleted

func (m *BaseModel) IsDeleted() bool

func (*BaseModel) IsEmpty

func (m *BaseModel) IsEmpty() bool

Esta función es válida para modelos NO globales

func (*BaseModel) IsFalse

func (m *BaseModel) IsFalse(condition *bool) bool

func (*BaseModel) IsLabeled

func (m *BaseModel) IsLabeled() bool

func (*BaseModel) IsNew

func (m *BaseModel) IsNew() bool

func (*BaseModel) IsTrue

func (m *BaseModel) IsTrue(condition *bool) bool

func (*BaseModel) Label

func (m *BaseModel) Label(labels ...Label)

func (*BaseModel) LabelFromStrings

func (m *BaseModel) LabelFromStrings(strings ...string)

func (*BaseModel) LabelIf

func (m *BaseModel) LabelIf(label Label, b interface{})

func (*BaseModel) LabelTotal

func (m *BaseModel) LabelTotal() int

func (*BaseModel) LastSync

func (m *BaseModel) LastSync() *time.Time

func (*BaseModel) NewBool

func (m *BaseModel) NewBool(condition bool) *bool

func (*BaseModel) PrepareForSync

func (m *BaseModel) PrepareForSync(externalID interface{}) error

func (*BaseModel) SetCreated

func (m *BaseModel) SetCreated(user User)

func (*BaseModel) SetDeleted

func (m *BaseModel) SetDeleted(user User)

func (*BaseModel) SetID

func (m *BaseModel) SetID(id string) error

func (*BaseModel) SetRecover

func (m *BaseModel) SetRecover(user User)

func (*BaseModel) SetRepoID

func (m *BaseModel) SetRepoID(value string)

func (*BaseModel) SetUpdated

func (m *BaseModel) SetUpdated(user User)

func (BaseModel) ToJSON

func (m BaseModel) ToJSON(model interface{}) string

func (BaseModel) ToRaw

func (m BaseModel) ToRaw(model interface{}) []byte

func (*BaseModel) Trace

func (m *BaseModel) Trace(err error) error

func (*BaseModel) True

func (m *BaseModel) True() *bool

For nil booleans

func (*BaseModel) UnLabel

func (m *BaseModel) UnLabel(labels ...Label)

func (*BaseModel) ValidateBase

func (m *BaseModel) ValidateBase() error

type BaseRequest

type BaseRequest struct {
	ID          *primitive.ObjectID
	SourceID    string
	PageSize    int64
	CurrentPage int64
	Order       *Orders
	SearchTerms SearchTerms

	Repo             Repository
	SpaceID          string
	IncludeDeleted   bool
	NotNilFields     []string
	Language         Language
	IDs              interface{}
	ExcludedIDs      []*primitive.ObjectID
	User             User
	Model            RepositoryModel
	List             interface{}
	TargetCollection string
	// Puede cambiar el campo ID que por defecto es "_id"
	QueryField  string
	QueryValues interface{}
	Target      string
	DateRange
	HTTPClient interface{}
	Max        int
	Min        int
	Total      int
	Message    string
	// contains filtered or unexported fields
}

func NewBaseRequest

func NewBaseRequest(model RepositoryModel, repo Repository, user User) (*BaseRequest, error)

func NewBaseRequestWithModel

func NewBaseRequestWithModel(model RepositoryModel, user User) (*BaseRequest, error)

func (*BaseRequest) AddOrderAsc

func (m *BaseRequest) AddOrderAsc(fields ...string)

func (*BaseRequest) AddOrderDesc

func (m *BaseRequest) AddOrderDesc(fields ...string)

func (*BaseRequest) Clone

func (m *BaseRequest) Clone(model RepositoryModel) (*BaseRequest, error)

func (*BaseRequest) CloneModelToNewDomain

func (m *BaseRequest) CloneModelToNewDomain(domain string) (*BaseRequest, error)

func (*BaseRequest) GetFindOptions

func (m *BaseRequest) GetFindOptions() *FindOptions

func (*BaseRequest) GetObjectsIDs

func (m *BaseRequest) GetObjectsIDs() []*primitive.ObjectID

func (*BaseRequest) GetRepoRequest

func (m *BaseRequest) GetRepoRequest() RepoRequest

func (*BaseRequest) HasIDs

func (m *BaseRequest) HasIDs() bool

func (*BaseRequest) SetFindOptions

func (m *BaseRequest) SetFindOptions(findOptions *FindOptions)

func (*BaseRequest) ToJSON

func (m *BaseRequest) ToJSON() string

func (*BaseRequest) Validate

func (m *BaseRequest) Validate() error

type BaseResponse

type BaseResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	// Es un error crítico
	StrError string `json:"str_error"`
	Error    error  `json:"error"`
	// Son errores no críticos
	Errors        []error     `json:"errors"`
	TotalRows     int64       `json:"total_rows"`
	TotalPages    int64       `json:"total_pages"`
	PageSize      int64       `json:"page_size"`
	CurrentPage   int64       `json:"current_page"`
	List          interface{} `json:"list"`
	Token         string      `json:"token"`
	ExternalToken string      `json:"external_token"`
	Status        string      `json:"status"`
}

func NewBaseResponse

func NewBaseResponse() *BaseResponse

func NewBaseResponseFromError

func NewBaseResponseFromError(err error) BaseResponse

func NewBaseResponseFromErrorStr

func NewBaseResponseFromErrorStr(err string) BaseResponse

func NewBaseResponseFromErrorWithCode

func NewBaseResponseFromErrorWithCode(err error, code int) BaseResponse

func NewBaseResponseFromModel

func NewBaseResponseFromModel(model interface{}) BaseResponse

func NewBaseResponseFromModelAndError

func NewBaseResponseFromModelAndError(model interface{}, err error) BaseResponse

func NewBaseResponseFromRepoResponse

func NewBaseResponseFromRepoResponse(repoResponse RepoResponse) BaseResponse

func (*BaseResponse) AddID

func (m *BaseResponse) AddID(id *primitive.ObjectID) error

func (*BaseResponse) AppendToList

func (m *BaseResponse) AppendToList(item interface{})

func (*BaseResponse) GetAtIndex

func (m *BaseResponse) GetAtIndex(index int, model interface{}) error

func (*BaseResponse) GetFirst

func (m *BaseResponse) GetFirst(model interface{}) error

func (*BaseResponse) GetList

func (m *BaseResponse) GetList(list interface{}) error

func (*BaseResponse) GetListInterface

func (m *BaseResponse) GetListInterface() List

func (*BaseResponse) Merge

func (m *BaseResponse) Merge(response BaseResponse) BaseResponse

func (*BaseResponse) SetError

func (m *BaseResponse) SetError(err error)

func (*BaseResponse) ToJSON

func (m *BaseResponse) ToJSON() string

type BulkList

type BulkList struct {
	NewList    []interface{}
	UpdateList []interface{}
}

func NewBulkList

func NewBulkList() *BulkList

newbulks

type ConfigType

type ConfigType utils.Enum
const (
	ConfigTypeNone       ConfigType = ""
	ConfigTypeTag        ConfigType = "config_type_tag"
	ConfigTypeDictionary ConfigType = "config_type_dictionary"
)

type CustomerWelcome

type CustomerWelcome struct {
	Email EmailSender
}

func (*CustomerWelcome) Welcome

func (welcomer *CustomerWelcome) Welcome(name, email string) error

type DateRange

type DateRange struct {
	StartDate *time.Time `json:"start_date,omitempty" bson:"start_date,omitempty"`
	EndDate   *time.Time `json:"end_date,omitempty" bson:"end_date,omitempty"`
}

func NewDataRangeFromRange

func NewDataRangeFromRange(r *DateRange, add time.Duration) *DateRange

func NewDataRangeThisWeek

func NewDataRangeThisWeek() (*DateRange, error)

func NewDateRange

func NewDateRange(startDate *time.Time, endDate *time.Time) (*DateRange, error)

func NewDateRangeFromStartDate

func NewDateRangeFromStartDate(startDate *time.Time) (*DateRange, error)

func NewDateRangeFromStr

func NewDateRangeFromStr(startDate string, endDate string) (DateRange, error)

func NewDateRangeFromWeekNumber

func NewDateRangeFromWeekNumber(weekNumber int) (*DateRange, error)

func NewDateRangeFullDay

func NewDateRangeFullDay(startDate *time.Time) DateRange

func NewDateRangeFullWeek

func NewDateRangeFullWeek(startDate *time.Time) *DateRange

func NewDateRangeNextWeek

func NewDateRangeNextWeek(startDate *time.Time) (*DateRange, error)

func NewDateRangeWeek

func NewDateRangeWeek(startDate *time.Time) (*DateRange, error)

func (DateRange) Add

func (m DateRange) Add(time time.Duration) *DateRange

func (DateRange) AddMonths

func (m DateRange) AddMonths(months int) DateRange

func (DateRange) AdjustHours

func (m DateRange) AdjustHours() DateRange

func (DateRange) Difference

func (m DateRange) Difference() time.Duration

func (DateRange) ExtractSuccessiveMonthDates

func (m DateRange) ExtractSuccessiveMonthDates() []time.Time

func (*DateRange) GetDateRangeInWeek

func (m *DateRange) GetDateRangeInWeek() *DateRange

func (DateRange) GetEndYear

func (m DateRange) GetEndYear() int

func (DateRange) GetFutureDateRange

func (m DateRange) GetFutureDateRange() DateRange

func (DateRange) GetFutureYearDateRange

func (m DateRange) GetFutureYearDateRange() DateRange

func (DateRange) GetPreviousDateRange

func (m DateRange) GetPreviousDateRange() DateRange

func (DateRange) GetPreviousYearDateRange

func (m DateRange) GetPreviousYearDateRange() DateRange

func (DateRange) GetStartYear

func (m DateRange) GetStartYear() int

func (DateRange) GetWeek

func (m DateRange) GetWeek() int

func (DateRange) IsEqual

func (m DateRange) IsEqual(dateRange DateRange) bool

func (DateRange) IsEqualOmitTime

func (m DateRange) IsEqualOmitTime(dateRange DateRange) bool

func (*DateRange) IsNextDateRange

func (m *DateRange) IsNextDateRange(dateRange DateRange) bool

func (*DateRange) IsPreviousDateRange

func (m *DateRange) IsPreviousDateRange(dateRange DateRange) bool

func (DateRange) IsValid

func (m DateRange) IsValid() bool

func (*DateRange) Overlaps

func (m *DateRange) Overlaps(dateRange DateRange) bool

func (*DateRange) RangeIn

func (m *DateRange) RangeIn(checkDateRange DateRange) bool

func (*DateRange) RecalcDateLimits

func (m *DateRange) RecalcDateLimits(dateToInclude *time.Time)

func (*DateRange) Set

func (m *DateRange) Set(date []string)

func (DateRange) SetEnd

func (m DateRange) SetEnd() DateRange

func (DateRange) SetOneFullDay

func (m DateRange) SetOneFullDay(day *time.Time) DateRange

func (*DateRange) TimeIn

func (m *DateRange) TimeIn(checkTime time.Time) bool

type Dictionaries

type Dictionaries []Dictionary

func (Dictionaries) ToRaw

func (m Dictionaries) ToRaw() []byte

type Dictionary

type Dictionary struct {
	Tag   `bson:",inline"`
	Group int `json:"group" bson:"group"`
}

func NewDictionary

func NewDictionary(tag Tag, group int) (*Dictionary, error)

func (*Dictionary) ToJSON

func (m *Dictionary) ToJSON() string

func (*Dictionary) ToRaw

func (m *Dictionary) ToRaw() []byte

func (*Dictionary) Validate

func (m *Dictionary) Validate() error

type DictionaryRepo

type DictionaryRepo struct {
	ConfigType              ConfigType `json:"config_type" bson:"config_type"`
	BaseModel               `bson:",inline"`
	DictionaryType          DictionaryType `json:"dictionary_type" bson:"dictionary_type"`
	DictionarySecondaryType AuditType      `json:"dictionary_secondary_type" bson:"dictionary_secondary_type"`
	Dictionaries            Dictionaries   `json:"dictionaries" bson:"dictionaries"`
}

func GetDictionaryRepo

func GetDictionaryRepo(request *BaseRequest, dictionaryType DictionaryType, auditType AuditType, language Language) (*DictionaryRepo, error)

func NewDictionaryRepo

func NewDictionaryRepo(dictionaryType DictionaryType, dictionaries Dictionaries) (*DictionaryRepo, error)

func (*DictionaryRepo) Delete

func (m *DictionaryRepo) Delete(request *BaseRequest) BaseResponse

func (*DictionaryRepo) Find

func (m *DictionaryRepo) Find(request *BaseRequest) BaseResponse

func (*DictionaryRepo) FindOne

func (m *DictionaryRepo) FindOne(request *BaseRequest) BaseResponse

func (*DictionaryRepo) FindOrCreate

func (m *DictionaryRepo) FindOrCreate(request *BaseRequest) BaseResponse

func (*DictionaryRepo) GetCollection

func (m *DictionaryRepo) GetCollection() (name string, isGlobal bool)

func (*DictionaryRepo) GetDictionaryByTag

func (m *DictionaryRepo) GetDictionaryByTag(tag Tag) (dictionary Dictionary, err error)

func (*DictionaryRepo) GetDictionaryByTagValueOrNumber

func (m *DictionaryRepo) GetDictionaryByTagValueOrNumber(value string, number int) (dictionary *Dictionary, err error)

func (*DictionaryRepo) GetFindOptions

func (m *DictionaryRepo) GetFindOptions(request *BaseRequest) *FindOptions

func (*DictionaryRepo) GetRepoType

func (m *DictionaryRepo) GetRepoType() RepoType

func (*DictionaryRepo) ToJSON

func (m *DictionaryRepo) ToJSON() string

func (*DictionaryRepo) Update

func (m *DictionaryRepo) Update(request *BaseRequest) BaseResponse

func (*DictionaryRepo) UpdateMany

func (m *DictionaryRepo) UpdateMany(request *BaseRequest, values map[string]interface{}) BaseResponse

func (*DictionaryRepo) Validate

func (m *DictionaryRepo) Validate() error

type DictionaryType

type DictionaryType utils.Enum
const (
	DictionaryTypeNone         DictionaryType = ""
	DictionaryTypeImpact       DictionaryType = "dictionary_type_impact"
	DictionaryTypeProbability  DictionaryType = "dictionary_type_probability"
	DictionaryTypeRating       DictionaryType = "dictionary_type_rating"
	DictionaryTypeRI           DictionaryType = "dictionary_type_ri"
	DictionaryTypeRC           DictionaryType = "dictionary_type_rc"
	DictionaryTypeRcStrength   DictionaryType = "dictionary_type_rc_strength"
	DictionaryTypeRcEvaluation DictionaryType = "dictionary_type_rc_evaluation"
	DictionaryTypeRcEfficiency DictionaryType = "dictionary_type_rc_efficiency"
)

func GetDictionaryType

func GetDictionaryType(name string) (DictionaryType, error)

type EmailSender

type EmailSender interface {
	Send(to, subject, body string) error
}

type FileRepoRequest

type FileRepoRequest struct {
	FileID   string
	Folder   string
	FileName string
	File     io.Reader
	RepoType FileRepoType
	User     User
}

func (*FileRepoRequest) ToJSON

func (m *FileRepoRequest) ToJSON() string

type FileRepoResponse

type FileRepoResponse struct {
	Error   error
	Content []byte
}

type FileRepoType

type FileRepoType utils.Enum
const (
	FileRepoNone      FileRepoType = ""
	FileRepoLocal     FileRepoType = "file_repo_local"
	FileRepoS3        FileRepoType = "file_repo_s3"
	FileRepoGoogle    FileRepoType = "file_repo_google"
	FileRepoOffice365 FileRepoType = "file_repo_office365"
	FileRepoMockup    FileRepoType = "file_repo_mockup"
)

func (FileRepoType) GetFileRepoType

func (m FileRepoType) GetFileRepoType(s string) FileRepoType

type FileRepository

type FileRepository interface {
	Save() FileRepoResponse
	Delete() FileRepoResponse
	EmptyBin() FileRepoResponse
	GetAccess() FileRepoResponse
	Download() FileRepoResponse
	GetPath() string
	GetFile() io.Reader
	Open() FileRepoResponse
	Close()
}

func NewFileRepository

func NewFileRepository(request FileRepoRequest) (FileRepository, error)

type Filter

type Filter struct {
	Key      string         `json:"key"`
	Operator FilterOperator `json:"operator"`
	Value    interface{}    `json:"value"`
}

type FilterOperator

type FilterOperator utils.Enum
const (
	FilterOperatorEquals                    FilterOperator = "="
	FilterOperatorEqualsWithCaseInsensitive FilterOperator = "equal_ci"
	FilterOperatorNotEquals                 FilterOperator = "!="
	FilterOperatorIn                        FilterOperator = "in"
	FilterOperatorNotIn                     FilterOperator = "not_in"
	FilterOperatorSize                      FilterOperator = "size"
	FilterOperatorGreat                     FilterOperator = "greater"
	FilterOperatorLess                      FilterOperator = "less"
	FilterOperatorGreatOrEqual              FilterOperator = "greater_or_equal"
	FilterOperatorLessOrEqual               FilterOperator = "less_or_equal"
	FilterOperatorAll                       FilterOperator = "all"
	FilterOperatorContains                  FilterOperator = "contains"
	FilterOperatorGroupsOfArrays            FilterOperator = "groups_of_arrays"
	FilterOperatorGroupBy                   FilterOperator = "group_by"
	FilterOperatorNotNil                    FilterOperator = "not_nil"
	FilterOperatorNil                       FilterOperator = "nil"
)

type FilterOr

type FilterOr []Filter

type FindOptions

type FindOptions struct {
	Filters   []Filter    `json:"filters"`
	FiltersOr []FilterOr  `json:"filters_or"`
	Order     *Orders     `json:"order"`
	Pipeline  interface{} `json:"pipeline"`
}

func NewFindOptions

func NewFindOptions() *FindOptions

func (*FindOptions) AddAll

func (m *FindOptions) AddAll(name string, value interface{})

func (*FindOptions) AddComplex

func (m *FindOptions) AddComplex(name string, operation FilterOperator, value interface{})

func (*FindOptions) AddEquals

func (m *FindOptions) AddEquals(name string, value interface{})

func (*FindOptions) AddEqualsCI

func (m *FindOptions) AddEqualsCI(name string, value interface{})

AddEqualsCI adds a filter to the FindOptions that matches the specified field with the given value, ignoring case.

func (*FindOptions) AddGreat

func (m *FindOptions) AddGreat(name string, value interface{})

func (*FindOptions) AddGreatOrEqual

func (m *FindOptions) AddGreatOrEqual(name string, value interface{})

func (*FindOptions) AddIn

func (m *FindOptions) AddIn(name string, value interface{})

func (*FindOptions) AddLess

func (m *FindOptions) AddLess(name string, value interface{})

func (*FindOptions) AddLessOrEqual

func (m *FindOptions) AddLessOrEqual(name string, value interface{})

func (*FindOptions) AddMultiple

func (m *FindOptions) AddMultiple(value FilterOr)

func (*FindOptions) AddNil

func (m *FindOptions) AddNil(name string)

func (*FindOptions) AddNotEquals

func (m *FindOptions) AddNotEquals(name string, value interface{})

func (*FindOptions) AddNotNil

func (m *FindOptions) AddNotNil(name string)

func (*FindOptions) AddOrderAsc

func (m *FindOptions) AddOrderAsc(fields ...string)

func (*FindOptions) AddOrderDesc

func (m *FindOptions) AddOrderDesc(fields ...string)

func (*FindOptions) AddRange

func (m *FindOptions) AddRange(nameFrom string, valueFrom interface{}, nameTo string, valueTo interface{})

func (*FindOptions) GetTotalOrders

func (m *FindOptions) GetTotalOrders() int64

func (*FindOptions) Remove

func (m *FindOptions) Remove(key string)

func (*FindOptions) ToJSON

func (m *FindOptions) ToJSON() string

type GCSBucketAdapter added in v1.5.0

type GCSBucketAdapter struct {
	*storage.BucketHandle
}

func (*GCSBucketAdapter) Object added in v1.5.0

func (a *GCSBucketAdapter) Object(name string) GCSObjectInterface

func (*GCSBucketAdapter) Objects added in v1.5.0

type GCSBucketInterface added in v1.5.0

type GCSBucketInterface interface {
	Object(name string) GCSObjectInterface
	Objects(ctx context.Context, query *storage.Query) GCSObjectIteratorInterface
}

GCSBucketInterface representa un bucket de GCS

type GCSClientAdapter added in v1.5.0

type GCSClientAdapter struct {
	*storage.Client
}

Adaptadores para que storage.Client implemente GCSClientInterface

func (*GCSClientAdapter) Bucket added in v1.5.0

func (a *GCSClientAdapter) Bucket(name string) GCSBucketInterface

type GCSClientInterface added in v1.5.0

type GCSClientInterface interface {
	Bucket(name string) GCSBucketInterface
	Close() error
}

GCSClientInterface permite inyectar un mock para tests

type GCSFileRepository

type GCSFileRepository struct {
	FileID         string
	FileName       string
	Path           string
	File           io.Reader
	RepositoryPath string

	User User
	// contains filtered or unexported fields
}

func NewGCSFileRepository

func NewGCSFileRepository(request FileRepoRequest) (GCSFileRepository, error)

func (*GCSFileRepository) Close

func (m *GCSFileRepository) Close()

func (*GCSFileRepository) Connect

func (m *GCSFileRepository) Connect() error

func (*GCSFileRepository) Delete

func (m *GCSFileRepository) Delete() FileRepoResponse

func (*GCSFileRepository) Download

func (m *GCSFileRepository) Download() FileRepoResponse

func (*GCSFileRepository) EmptyBin

func (m *GCSFileRepository) EmptyBin() FileRepoResponse

func (*GCSFileRepository) GetAccess

func (m *GCSFileRepository) GetAccess() FileRepoResponse

func (*GCSFileRepository) GetFile

func (m *GCSFileRepository) GetFile() io.Reader

func (*GCSFileRepository) GetPath

func (m *GCSFileRepository) GetPath() string

func (*GCSFileRepository) Mount

func (m *GCSFileRepository) Mount(fileID string, fileName string, path string, repositoryPath string)

func (*GCSFileRepository) Open

func (*GCSFileRepository) Save

func (*GCSFileRepository) ToJSON

func (m *GCSFileRepository) ToJSON() string

type GCSObjectAdapter added in v1.5.0

type GCSObjectAdapter struct {
	*storage.ObjectHandle
}

func (*GCSObjectAdapter) Attrs added in v1.5.0

func (*GCSObjectAdapter) Delete added in v1.5.0

func (a *GCSObjectAdapter) Delete(ctx context.Context) error

type GCSObjectInterface added in v1.5.0

type GCSObjectInterface interface {
	Delete(ctx context.Context) error
	Attrs(ctx context.Context) (*storage.ObjectAttrs, error)
}

GCSObjectInterface representa un objeto en GCS

type GCSObjectIteratorInterface added in v1.5.0

type GCSObjectIteratorInterface interface {
	Next() (*storage.ObjectAttrs, error)
}

GCSObjectIteratorInterface representa un iterador de objetos

type JSON

type JSON map[string]interface{}

func (JSON) Get

func (m JSON) Get(field string) interface{}

func (JSON) Has

func (m JSON) Has(field string) bool

func (JSON) Set

func (m JSON) Set(field string, value interface{})

type Key

type Key = []string

type Label

type Label utils.Enum
const (
	LabelNone          Label = ""
	LabelClient        Label = "client"
	LabelEnterprise    Label = "enterprise"
	LabelContactPerson Label = "contact_person"
	LabelField         Label = "field"
	LabelPlot          Label = "plot"
	LabelDomain        Label = "domain"
	LabelUser          Label = "user"
	LabelSystem        Label = "system"
	LabelMember        Label = "member"
	LabelHidden        Label = "hidden"
	LabelHeritage      Label = "heritage"
	LabelGuest         Label = "guest"
	LabelStaff         Label = "staff"
	LabelAdmin         Label = "admin"
	LabelProcesable    Label = "procesable"
	LabelTemplate      Label = "template"
	LabelSpaceRole     Label = "space_role"
	LabelGlobal        Label = "global"
	LabelQueued        Label = "queued"

	LabelEpicTask  Label = "epic_task"
	LabelCompleted Label = "completed"
	LabelInactive  Label = "inactive"

	LabelLink Label = "link"

	LabelDraft Label = "draft"
	LabelError Label = "error"

	LabelSupport     Label = "support"
	LabelNoData      Label = "no_data"
	LabelNeedRefresh Label = "need_refresh"
)

func NewLabelFromString

func NewLabelFromString(text string) Label

func (Label) IsError

func (m Label) IsError() bool

func (Label) IsWarning

func (m Label) IsWarning() bool

func (Label) ToString

func (m Label) ToString() string

type Labels

type Labels []Label

func (*Labels) Add

func (m *Labels) Add(labels ...Label)

func (*Labels) Has

func (m *Labels) Has(label Label) bool

func (*Labels) Remove

func (m *Labels) Remove(labels ...Label) bool

func (*Labels) ToArray

func (m *Labels) ToArray() []Label

func (Labels) ToString

func (m Labels) ToString() []string

func (Labels) Total

func (m Labels) Total() int

type Language

type Language string

func GetTemplatesLanguages

func GetTemplatesLanguages() []Language

func GetTranslatedLanguages

func GetTranslatedLanguages() []Language

func NewLanguage

func NewLanguage(code string) (Language, error)

func NewLanguageFromDataSourceName

func NewLanguageFromDataSourceName(fileName string) (Language, bool)

func (Language) Normalize

func (m Language) Normalize() (Language, error)

func (Language) String

func (m Language) String() string

func (Language) Validate

func (m Language) Validate() (Language, error)

type List

type List struct {
	Error     error         `json:"error"`
	TotalRows int64         `json:"total_rows"`
	Rows      []interface{} `json:"rows"`
}

type ListItem

type ListItem struct {
	ID       *primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
	ParentID *primitive.ObjectID `json:"parent_id" bson:"parent_id"`
	UserLogs `bson:",inline"`
}

func (*ListItem) GetID

func (m *ListItem) GetID() string

func (*ListItem) Validate

func (m *ListItem) Validate() error

type ListItemModel

type ListItemModel interface {
	GetID() string
	SetID(*primitive.ObjectID)
	GetParentID() *primitive.ObjectID
	Validate() error
	Calculate(dictionaries Dictionaries)
	SetUserLogs(User)
}

type LocalFileRepository

type LocalFileRepository struct {
	FileID         string
	FileName       string
	Path           string
	File           io.Reader
	RepositoryPath string
}

func NewLocalFileRepository

func NewLocalFileRepository(request FileRepoRequest) (LocalFileRepository, error)

func (*LocalFileRepository) Close

func (m *LocalFileRepository) Close()

func (*LocalFileRepository) Delete

func (*LocalFileRepository) Download

func (m *LocalFileRepository) Download() FileRepoResponse

func (*LocalFileRepository) EmptyBin

func (m *LocalFileRepository) EmptyBin() FileRepoResponse

func (*LocalFileRepository) GetAccess

func (m *LocalFileRepository) GetAccess() FileRepoResponse

func (*LocalFileRepository) GetFile

func (m *LocalFileRepository) GetFile() io.Reader

func (*LocalFileRepository) GetPath

func (m *LocalFileRepository) GetPath() string

func (*LocalFileRepository) Open

func (*LocalFileRepository) Save

func (*LocalFileRepository) ToJSON

func (m *LocalFileRepository) ToJSON() string

type Message

type Message struct {
	Text  string
	Level NotifyLevel2
	Code  NotifyCode
}

type MiniModel

type MiniModel struct {
	ID   string `json:"id" bson:"id"`
	Name string `json:"name" bson:"name"`
}

type MockBucket added in v1.5.0

type MockBucket struct {
	Name       string
	ObjectsMap map[string]*MockObject
	// contains filtered or unexported fields
}

MockBucket simula storage.BucketHandle

func (*MockBucket) CountNonDeletedObjects added in v1.5.0

func (b *MockBucket) CountNonDeletedObjects() int

CountNonDeletedObjects cuenta objetos no eliminados (helper para tests)

func (*MockBucket) GetAllObjects added in v1.5.0

func (b *MockBucket) GetAllObjects() map[string]*MockObject

GetAllObjects retorna todos los objetos del bucket (helper para tests)

func (*MockBucket) Object added in v1.5.0

func (b *MockBucket) Object(path string) GCSObjectInterface

Object retorna o crea un objeto mock

func (*MockBucket) Objects added in v1.5.0

Objects retorna un iterador de objetos que coinciden con el query

func (*MockBucket) ReadObject added in v1.5.0

func (b *MockBucket) ReadObject(path string) ([]byte, error)

ReadObject lee el contenido de un objeto (helper para tests)

func (*MockBucket) Reset added in v1.5.0

func (b *MockBucket) Reset()

Reset limpia todos los objetos del bucket (helper para tests)

type MockFileRepository

type MockFileRepository struct {
	FileID         string
	FileName       string
	Path           string
	RepositoryPath string
}

func NewMockupFileRepository

func NewMockupFileRepository(request FileRepoRequest) (MockFileRepository, error)

func (*MockFileRepository) Close

func (m *MockFileRepository) Close()

func (*MockFileRepository) Delete

func (*MockFileRepository) Download

func (m *MockFileRepository) Download() FileRepoResponse

func (*MockFileRepository) EmptyBin

func (m *MockFileRepository) EmptyBin() FileRepoResponse

func (*MockFileRepository) GetAccess

func (m *MockFileRepository) GetAccess() FileRepoResponse

func (*MockFileRepository) GetFile

func (m *MockFileRepository) GetFile() io.Reader

func (*MockFileRepository) GetPath

func (m *MockFileRepository) GetPath() string

func (*MockFileRepository) Open

func (*MockFileRepository) Save

func (*MockFileRepository) ToJSON

func (m *MockFileRepository) ToJSON() string

type MockFolder

type MockFolder struct {
	ID    string
	Files []string
}

type MockGCSClient added in v1.5.0

type MockGCSClient struct {
	Buckets map[string]*MockBucket
	// contains filtered or unexported fields
}

MockGCSClient simula storage.Client para tests

func NewMockGCSClient added in v1.5.0

func NewMockGCSClient() *MockGCSClient

NewMockGCSClient crea un nuevo cliente GCS mock

func (*MockGCSClient) Bucket added in v1.5.0

func (m *MockGCSClient) Bucket(name string) GCSBucketInterface

Bucket retorna o crea un bucket mock

func (*MockGCSClient) Close added in v1.5.0

func (m *MockGCSClient) Close() error

Close simula el cierre del cliente

func (*MockGCSClient) GetBucket added in v1.5.0

func (m *MockGCSClient) GetBucket(name string) *MockBucket

GetBucket retorna el bucket mock real (helper para tests)

type MockIO

type MockIO struct {
	Folders []*MockFolder
}

func (*MockIO) AddFile

func (m *MockIO) AddFile(repo MockFileRepository) error

func (*MockIO) CountFiles

func (m *MockIO) CountFiles(repoID string) int

func (*MockIO) Delete

func (m *MockIO) Delete(repo MockFileRepository) error

func (*MockIO) GetFiles

func (m *MockIO) GetFiles(repoID string) ([]string, error)

func (*MockIO) Len

func (m *MockIO) Len(repoID string) int

type MockObject added in v1.5.0

type MockObject struct {
	Path    string
	Data    []byte
	Deleted bool
	// contains filtered or unexported fields
}

MockObject simula storage.ObjectHandle

func (*MockObject) Attrs added in v1.5.0

func (o *MockObject) Attrs(ctx context.Context) (*storage.ObjectAttrs, error)

Attrs retorna los atributos del objeto

func (*MockObject) Delete added in v1.5.0

func (o *MockObject) Delete(ctx context.Context) error

Delete marca el objeto como eliminado

func (*MockObject) NewWriter added in v1.5.0

func (o *MockObject) NewWriter(ctx context.Context) *MockWriter

NewWriter crea un nuevo writer mock para este objeto

type MockObjectIterator added in v1.5.0

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

MockObjectIterator simula el iterador de objetos

func (*MockObjectIterator) Next added in v1.5.0

Next retorna el siguiente objeto en el iterador

type MockStationSiarRepository

type MockStationSiarRepository struct {
	APIKey      string
	BaseURL     string
	StationName string
	DateRange   *DateRange
}

func NewMockStationSIARRepository

func NewMockStationSIARRepository(request StationRequest) (MockStationSiarRepository, error)

func (*MockStationSiarRepository) GetData

func (*MockStationSiarRepository) ToJSON

func (m *MockStationSiarRepository) ToJSON() string

type MockWriter added in v1.5.0

type MockWriter struct {
	Object    *MockObject
	Buffer    *bytes.Buffer
	Closed    bool
	ChunkSize int
	// contains filtered or unexported fields
}

MockWriter simula storage.Writer

func (*MockWriter) Close added in v1.5.0

func (w *MockWriter) Close() error

Close finaliza la escritura y guarda los datos en el objeto

func (*MockWriter) Write added in v1.5.0

func (w *MockWriter) Write(p []byte) (n int, err error)

Write escribe datos al buffer

type Model

type Model interface {
	ToJSON()
	ToRaw()
}

type MongoRepository

type MongoRepository struct {
	Error            error
	ConnectionString string
	RepoID           string
	DataBase         string
	Collection       string
	// contains filtered or unexported fields
}

func NewMongoRepository

func NewMongoRepository(connection string, repoID string, collection string, isGlobal bool) MongoRepository

func (*MongoRepository) AddItemInArray

func (m *MongoRepository) AddItemInArray(request RepoRequest, field string, value string) RepoResponse

func (*MongoRepository) Aggregate

func (m *MongoRepository) Aggregate(request RepoRequest) RepoResponse

func (*MongoRepository) Count

func (m *MongoRepository) Count(request RepoRequest) RepoResponse

func (*MongoRepository) CreateMany

func (m *MongoRepository) CreateMany(dbModel RepositoryModel, list []interface{}) error

func (*MongoRepository) Delete

func (m *MongoRepository) Delete(request RepoRequest) RepoResponse

func (*MongoRepository) DeleteAll

func (m *MongoRepository) DeleteAll(dbModel RepositoryModel) error

func (*MongoRepository) DeleteDataBasesByCollections

func (m *MongoRepository) DeleteDataBasesByCollections(list []utils.Dictionary, exceptions []string) error

func (*MongoRepository) DeleteDatabase

func (m *MongoRepository) DeleteDatabase(connection string, database string) error

func (*MongoRepository) DeleteSoft

func (m *MongoRepository) DeleteSoft(request RepoRequest) RepoResponse

func (*MongoRepository) Find

func (m *MongoRepository) Find(request RepoRequest) RepoResponse

func (*MongoRepository) FindOne

func (m *MongoRepository) FindOne(request RepoRequest) RepoResponse

func (*MongoRepository) GetCollection

func (m *MongoRepository) GetCollection() (*mongo.Collection, error)

func (*MongoRepository) GetConnection

func (m *MongoRepository) GetConnection() string

func (*MongoRepository) GetDB

func (m *MongoRepository) GetDB() (*mongo.Database, error)

func (*MongoRepository) GetDataBase

func (m *MongoRepository) GetDataBase() string

func (*MongoRepository) GetFilter

func (m *MongoRepository) GetFilter(filterOptions FindOptions) (map[string]interface{}, error)

func (*MongoRepository) GetMongoClient

func (m *MongoRepository) GetMongoClient()

func (*MongoRepository) GetOrder

func (m *MongoRepository) GetOrder(filterOptions FindOptions) map[string]interface{}

func (*MongoRepository) GetRepoID

func (m *MongoRepository) GetRepoID() string

func (*MongoRepository) GetSize

func (m *MongoRepository) GetSize(dbModel RepositoryModel) error

func (*MongoRepository) GetType

func (m *MongoRepository) GetType() RepoType

func (*MongoRepository) Move

func (m *MongoRepository) Move(request RepoRequest) RepoResponse

func (*MongoRepository) RemoveField

func (m *MongoRepository) RemoveField(request RepoRequest, field string) RepoResponse

func (*MongoRepository) RemoveItemInArray

func (m *MongoRepository) RemoveItemInArray(request RepoRequest, field string, value string) RepoResponse

func (*MongoRepository) RepoBackup

func (m *MongoRepository) RepoBackup(request RepoRequest, backupID string) RepoResponse

func (*MongoRepository) RepoRestore

func (m *MongoRepository) RepoRestore(request RepoRequest, backupID string) RepoResponse

func (*MongoRepository) SetRepoID

func (m *MongoRepository) SetRepoID(repoID string) error

func (*MongoRepository) SwitchItemInArray

func (m *MongoRepository) SwitchItemInArray(request RepoRequest, field string, value string) RepoResponse

func (*MongoRepository) ToJSON

func (m *MongoRepository) ToJSON() string

func (*MongoRepository) Update

func (m *MongoRepository) Update(request RepoRequest) RepoResponse

func (*MongoRepository) UpdateField

func (m *MongoRepository) UpdateField(request RepoRequest, field string, value interface{}) RepoResponse

func (*MongoRepository) UpdateMany

func (m *MongoRepository) UpdateMany(request RepoRequest, values map[string]interface{}) RepoResponse

type Notifiable

type Notifiable interface {
	GetNotifications() *[]*Notification
}

Para poder modificar el array debe ser un puntero

type Notification

type Notification struct {
	Text   string       `json:"text" bson:"text,omitempty"`
	Level  NotifyLevel2 `json:"level" bson:"level,omitempty"`
	Count  int          `json:"count" bson:"count,omitempty"`
	Users  []string     `json:"users" bson:"users"`
	Code   NotifyCode   `json:"code" bson:"code,omitempty"`
	Source string       `json:"source_id" bson:"source_id,omitempty"`
	Viewed *time.Time   `json:"viewed" bson:"viewed,omitempty"`
}

func DeleteNotification

func DeleteNotification(notifications []*Notification, message string) []*Notification

func DeleteNotificationByCode

func DeleteNotificationByCode(notifications []*Notification, code NotifyCode) []*Notification

func DeleteNotificationIfContains

func DeleteNotificationIfContains(notifications []*Notification, message string) []*Notification

func (*Notification) CloneTo

func (m *Notification) CloneTo(i Notifiable, users []string, source string) *[]*Notification

func (*Notification) ToJSON

func (m *Notification) ToJSON() string

type NotificationService

type NotificationService interface {
	SendNotification(userID string, count int) error
}

NotificationService defines the interface for sending notifications

type NotifyCode

type NotifyCode utils.Enum
const (
	NotifyCodeNone NotifyCode = ""
)

type NotifyLevel2

type NotifyLevel2 utils.Enum
const (
	NotifyLevelInfo    NotifyLevel2 = "info"
	NotifyLevelWarning NotifyLevel2 = "warning"
	NotifyLevelError   NotifyLevel2 = "error"
)

type Order

type Order struct {
	Field     string
	Direction int
}

type Orders

type Orders []Order

func (*Orders) Add

func (m *Orders) Add(orders ...Order)

func (*Orders) Has

func (m *Orders) Has(order Order) bool

func (*Orders) HasByFields

func (m *Orders) HasByFields(fields ...string) bool

func (*Orders) IsEmpty

func (m *Orders) IsEmpty() bool

func (*Orders) List

func (m *Orders) List() []Order

type Permission

type Permission struct {
	ID             string         `json:"id" bson:"id"`
	PermissionType PermissionType `json:"permission_type" bson:"permission_type"`
	Value          string         `json:"value" bson:"value"`
	Label          Label          `json:"label" bson:"label"`
}

Tags are detailed tokens for know permission information

func (Permission) HasDomainRestriction

func (m Permission) HasDomainRestriction() bool

type PermissionClass

type PermissionClass utils.Enum
const (
	PermissionClassFirm PermissionClass = "permission_class_firm"
)

type PermissionCloud

type PermissionCloud struct {
	Permissions []Permission `json:"permissions" bson:"permissions, omitempty"`
}

A system block is a block that is not created by a user... PermissionTypeTotal is assigned to system_user

func NewPermissionCloud

func NewPermissionCloud(permissions ...Permission) *PermissionCloud

func (*PermissionCloud) AddPermission

func (m *PermissionCloud) AddPermission(permission Permission, user User) error

func (*PermissionCloud) AddUser

func (m *PermissionCloud) AddUser(user User, permissionType PermissionType) error

func (*PermissionCloud) GetPermission

func (m *PermissionCloud) GetPermission(user *User) (Permission, error)

func (*PermissionCloud) HasDomainRestriction

func (m *PermissionCloud) HasDomainRestriction() bool

func (*PermissionCloud) HasPermission

func (m *PermissionCloud) HasPermission(token []string, permissionType PermissionType) bool

func (*PermissionCloud) HasPermission_v2

func (m *PermissionCloud) HasPermission_v2(user *User, permissionType PermissionType) bool

func (PermissionCloud) IsEmpty

func (m PermissionCloud) IsEmpty() bool

func (*PermissionCloud) RemovePermission

func (m *PermissionCloud) RemovePermission(id string, user User) error

type PermissionType

type PermissionType int
const (
	// Incremental permissions, each level includes the previous, best with iota for comparison
	PermissionTypeNone PermissionType = iota
	PermissionTypeNoAccess
	// read only
	PermissionTypeView
	// comment and sign
	PermissionTypeComment
	// feedback
	PermissionTypeFeedback
	// edit but not empty bin, not recover from bin and not change permissions
	PermissionTypeEdit
	// full access except system blocks
	PermissionTypeFull
)

type RepoRequest

type RepoRequest struct {
	ID               string
	PageSize         int64
	SortBy           []Sort
	CurrentPage      int64
	User             User
	Model            RepositoryModel
	FindOptions      FindOptions
	List             interface{}
	RepoID           string
	Pipeline         interface{}
	TargetCollection string
}

func (*RepoRequest) ToJSON

func (m *RepoRequest) ToJSON() string

type RepoResponse

type RepoResponse struct {
	Error       error
	Errors      []error
	TotalRows   int64
	TotalPages  int64
	PageSize    int64
	CurrentPage int64
	List        interface{}
}

func NewRepoResponse

func NewRepoResponse() (*RepoResponse, error)

func (*RepoResponse) ToJSON

func (m *RepoResponse) ToJSON() string

type RepoType

type RepoType uint64
const (
	RepoTypeUnknown RepoType = iota
	RepoTypeMongoDB
)

type Repository

type Repository interface {
	Aggregate(request RepoRequest) RepoResponse
	Find(request RepoRequest) RepoResponse
	Count(request RepoRequest) RepoResponse
	FindOne(request RepoRequest) RepoResponse
	Update(request RepoRequest) RepoResponse
	UpdateMany(request RepoRequest, values map[string]interface{}) RepoResponse
	UpdateField(request RepoRequest, field string, value interface{}) RepoResponse
	SwitchItemInArray(request RepoRequest, field string, value string) RepoResponse
	AddItemInArray(request RepoRequest, field string, value string) RepoResponse
	RemoveItemInArray(request RepoRequest, field string, value string) RepoResponse
	Move(request RepoRequest) RepoResponse
	Delete(request RepoRequest) RepoResponse
	DeleteSoft(request RepoRequest) RepoResponse
	RemoveField(request RepoRequest, field string) RepoResponse
	GetFilter(filterOptions FindOptions) (map[string]interface{}, error)
	GetOrder(filterOptions FindOptions) map[string]interface{}
	GetType() RepoType
	GetRepoID() string
	GetDataBase() string
	GetConnection() string
	SetRepoID(value string) error
	RepoBackup(request RepoRequest, backupID string) RepoResponse
	RepoRestore(request RepoRequest, backupID string) RepoResponse
	DeleteDatabase(connection string, database string) error
}

func CloneRepository

func CloneRepository(repo Repository, model RepositoryModel) (Repository, error)

func NewRepository

func NewRepository(connection string, repoType RepoType, database string, collection string, isGlobal bool) (Repository, error)

func NewRepositoryFromModel

func NewRepositoryFromModel(model RepositoryModel, connection string) (Repository, error)

type RepositoryModel

type RepositoryModel interface {
	GetID() (interface{}, error)
	SetID(string) error
	IsNew() bool
	BecomeNew()
	BecomeNewButKeepID()
	GetCollection() (name string, isGlobal bool)
	SetCreated(user User)
	SetUpdated(user User)
	SetDeleted(user User)
	GetRepoType() RepoType
	GetRepoID() string
	SetRepoID(value string)
	LabelFromStrings(strings ...string)
}

type RolePermission

type RolePermission struct {
	PermissionID   string         `json:"permission_id" bson:"permission_id"`
	PermissionType PermissionType `json:"permission_type" bson:"permission_type"`
	Role           SpaceRole      `json:"role" bson:"role"`
}

func (RolePermission) HasPermission

func (m RolePermission) HasPermission(permissionID string) bool

type RolePermissions

type RolePermissions []RolePermission

func (RolePermissions) AddPermission

func (m RolePermissions) AddPermission(permission RolePermission) RolePermissions

func (RolePermissions) GetPermission

func (m RolePermissions) GetPermission(permissionID string) (RolePermission, bool)

type SearchTerms

type SearchTerms []string

func (SearchTerms) Add

func (m SearchTerms) Add(term string) SearchTerms

type SendEmail

type SendEmail struct {
	From string
}

TESTING +++++++++++++++++++++++++++++++++

func (*SendEmail) Send

func (sender *SendEmail) Send(to, subject, body string) error

type Sort

type Sort struct {
	Name       string
	Descending bool
}

type SourceType

type SourceType utils.Enum
const (
	SourceTypeEnumNone     SourceType = ""
	SourceTypeImportedData SourceType = "imported_data"
	// Same ID as DomainID Cloned
	SourceTypeDomainClone SourceType = "domain_clone"
)

type SpaceMember

type SpaceMember struct {
	UserID    string    `json:"user_id" bson:"user_id"`
	SpaceRole SpaceRole `json:"space_role" bson:"space_role"`
}

type SpaceMembers

type SpaceMembers []SpaceMember

func (SpaceMembers) AddMember

func (m SpaceMembers) AddMember(user User) (SpaceMembers, bool)

func (SpaceMembers) AddRoleToMembers

func (m SpaceMembers) AddRoleToMembers(userID string, role SpaceRole) (SpaceMembers, bool)

func (SpaceMembers) GetMember

func (m SpaceMembers) GetMember(userID string) (SpaceMember, bool)

func (SpaceMembers) RemoveMember

func (m SpaceMembers) RemoveMember(userID string) (SpaceMembers, error)

type SpaceRole

type SpaceRole utils.Enum
const (
	SpaceRoleNone   SpaceRole = ""
	SpaceRoleNoRole SpaceRole = "no_role"
	SpaceRoleMember SpaceRole = "member"
	SpaceRoleAdmin  SpaceRole = "admin"
	SpaceRoleOwner  SpaceRole = "owner"
	SpaceRoleGuest  SpaceRole = "guest"
)

func (SpaceRole) ToString

func (m SpaceRole) ToString() string

type StationRepoResponse

type StationRepoResponse struct {
	Error   error
	Content WeatherData
}

type StationRepository

type StationRepository interface {
	GetData() StationRepoResponse
}

func NewStationRepository

func NewStationRepository(request StationRequest) (StationRepository, error)

type StationRequest

type StationRequest struct {
	StationName string
	DateRange   *DateRange
	StationType StationType
}

func (*StationRequest) ToJSON

func (m *StationRequest) ToJSON() string

type StationSiarRepository

type StationSiarRepository struct {
	APIKey      string
	BaseURL     string
	StationName string
	DateRange   *DateRange
}

func NewStationSIARRepository

func NewStationSIARRepository(request StationRequest) (StationSiarRepository, error)

func (*StationSiarRepository) GetData

func (*StationSiarRepository) ToJSON

func (m *StationSiarRepository) ToJSON() string

type StationType

type StationType utils.Enum
const (
	StationNone   StationType = ""
	StationSIAR   StationType = "station_siar"
	StationWeitec StationType = "station_weitec"
	StationMockup StationType = "station_mockup"
)

func (StationType) GetStationType

func (m StationType) GetStationType(s string) StationType

type StationWeitecRepository

type StationWeitecRepository struct {
	APIKey      string
	BaseURL     string
	StationName string
	DateRange   *DateRange
}

func NewStationWeitecRepository

func NewStationWeitecRepository(request StationRequest) (StationWeitecRepository, error)

func (*StationWeitecRepository) GetData

func (*StationWeitecRepository) ToJSON

func (m *StationWeitecRepository) ToJSON() string

type Synchronizable

type Synchronizable interface {
	LastSync() *time.Time
	Sync(model interface{}) error
	GetExternalID() string
	Delete() RepoResponse
}

type SysNotify added in v1.7.0

type SysNotify utils.Enum
const (
	SysNotifyNone            SysNotify = ""
	SysNotifyReportPublished SysNotify = "report_published"
)

type Tag

type Tag struct {
	Key   string `json:"key" bson:"key"`
	Value string `json:"value" bson:"value"`
	Group string `json:"group,omitempty" bson:"group,omitempty"`
	Check bool   `json:"check,omitempty" bson:"check,omitempty"`
}

func NewTag

func NewTag(key string, value string) *Tag

func NewTagByValue

func NewTagByValue(value string) *Tag

func (*Tag) HasSameKey

func (m *Tag) HasSameKey(tag Tag) bool

func (*Tag) IsEmpty

func (m *Tag) IsEmpty() bool

func (*Tag) IsEqual

func (m *Tag) IsEqual(tag Tag) bool

func (*Tag) Normalize

func (m *Tag) Normalize()

type TagCloud

type TagCloud struct {
	TagKeys   []string `json:"tag_keys" bson:"tag_keys"`
	TagValues []string `json:"tag_values" bson:"tag_values"`
	Tags      Tags     `json:"tags" bson:"tags"`
}

func NewTagCloud

func NewTagCloud() *TagCloud

func (*TagCloud) AddTag

func (m *TagCloud) AddTag(tag Tag) (bool, string)

func (*TagCloud) AddTagCloud

func (m *TagCloud) AddTagCloud(tagCloud TagCloud)

func (*TagCloud) HasTag

func (m *TagCloud) HasTag(tag Tag) int

func (*TagCloud) RemoveTag

func (m *TagCloud) RemoveTag(tag Tag) bool

type TagKey

type TagKey string

type TagRepo

type TagRepo struct {
	TagType TagType `json:"tag_type" bson:"tag_type"`
	// System tags are not editable by users at the moment and has always the same key
	System bool `json:"system" bson:"system"`
	Tag    `bson:",inline"`
}

Esta clase contiene todo tipo de configuraciones... tags, monedas, etc.

type TagRepoList

type TagRepoList struct {
	List     []*TagRepo `bson:",inline"`
	TagList  []Tag
	TagType  TagType
	Language Language
	Touched  bool
	RepoID   string
	User     User
}

Must be used instead of TagRepo

type TagType

type TagType utils.Enum
const (
	TagTypeNone    TagType = ""
	TagTypeUser    TagType = "tag_user"
	TagTypeDomain  TagType = "tag_domain"
	TagTypeContact TagType = "tag_contact"
	TagTypeFile    TagType = "tag_file"
	TagTypeTask    TagType = "tag_task"
)

func GetTagType

func GetTagType(name string) (TagType, error)

type Tags

type Tags []Tag

func (*Tags) AddOrReplace

func (m *Tags) AddOrReplace(tag Tag)

AddOrReplace agrega un nuevo tag o reemplaza uno existente si ya existe uno con la misma clave

func (*Tags) AddTag

func (m *Tags) AddTag(tag Tag) (bool, Tag)

func (*Tags) AddTags

func (m *Tags) AddTags(tags Tags)

func (*Tags) AddValue

func (m *Tags) AddValue(value string) (bool, Tag)

func (*Tags) Compare

func (m *Tags) Compare(tagRepos *TagRepoList)

func (*Tags) GetKeys

func (m *Tags) GetKeys() []string

func (*Tags) HasTag

func (m *Tags) HasTag(tag Tag) bool

func (*Tags) HasTagAndGet

func (m *Tags) HasTagAndGet(tag Tag) (bool, Tag)

func (*Tags) HasTagByKey

func (m *Tags) HasTagByKey(key string) bool

func (*Tags) HasTagByKeyAndGetTag

func (m *Tags) HasTagByKeyAndGetTag(key string) (bool, Tag)

func (*Tags) Normalize

func (m *Tags) Normalize(tagRepos *TagRepoList) (*Tags, error)

func (*Tags) RemoveDuplicates

func (m *Tags) RemoveDuplicates() *Tags

func (*Tags) ToArray

func (m *Tags) ToArray() []Tag

func (*Tags) ToArrayByValues

func (m *Tags) ToArrayByValues() []string

func (*Tags) Total

func (m *Tags) Total() int

func (*Tags) Update

func (m *Tags) Update(request *BaseRequest, language Language) (*Tags, error)

type Trace

type Trace struct {
	BaseModel `bson:",inline"`
	Message   string `json:"message" bson:"message"`
	Level     string `json:"level" bson:"level"`
	File      string `json:"file" bson:"file"`
	Line      int    `json:"line" bson:"line"`
}

func LogErr

func LogErr(model *BaseModel, err error) (*Trace, error)

func LogTrace

func LogTrace(model *BaseModel, err error) (*Trace, error)

func (*Trace) Find

func (m *Trace) Find() *TraceList

func (*Trace) GetCollection

func (m *Trace) GetCollection() (name string, isGlobal bool)

func (*Trace) GetFindOptions

func (m *Trace) GetFindOptions(request *BaseRequest) FindOptions

func (*Trace) ToJSON

func (m *Trace) ToJSON() string

func (*Trace) Update

func (m *Trace) Update() (*Trace, error)

type TraceList

type TraceList struct {
	BaseResponse
}

func (*TraceList) First

func (m *TraceList) First() (*Trace, error)

func (*TraceList) ToList

func (m *TraceList) ToList() []*Trace

type User

type User struct {
	// El external ID es el ID de auth0
	BaseModel     `bson:",inline"`
	Nick          string          `json:"nick" bson:"nick"`
	Username      string          `json:"username" bson:"username"`
	ContactID     string          `json:"contact_id" bson:"contact_id"`
	Email         string          `json:"email" bson:"email"`
	Password      string          `json:"password" bson:"password"`
	Licenses      []string        `json:"licenses" bson:"licenses"`
	Connection    string          `json:"connection" bson:"connection"`
	Session       DateRange       `json:"session" bson:"session"`
	ExternalToken string          `json:"external_token" bson:"external_token"`
	Avatar        string          `json:"avatar" bson:"avatar"`
	SysNotify     []SysNotify     `json:"sys_notify" bson:"sys_notify"`
	Roles         RolePermissions `json:"roles" bson:"-"`
	RolePermission
	SpaceID        string `json:"space_id" bson:"-"`
	ChangePassword bool   `json:"change_password" bson:"-"`
}

func GetUserByID

func GetUserByID(id string) (*User, error)

func NewUser

func NewUser(userName string) *User

func (*User) CheckPassword

func (m *User) CheckPassword(request *BaseRequest) (*User, error)

func (*User) CloseSession

func (m *User) CloseSession(request *BaseRequest) BaseResponse

func (*User) Delete

func (m *User) Delete(request *BaseRequest) BaseResponse

func (*User) EncryptPassword

func (m *User) EncryptPassword() error

func (*User) Find

func (m *User) Find(request *BaseRequest) BaseResponse

func (*User) FindOne

func (m *User) FindOne(request *BaseRequest) BaseResponse

func (*User) FindOrCreate

func (m *User) FindOrCreate(request *BaseRequest) BaseResponse

func (*User) GetCollection

func (m *User) GetCollection() (name string, isGlobal bool)

func (*User) GetFindOptions

func (m *User) GetFindOptions(request *BaseRequest) *FindOptions

func (*User) GetFromMap

func (m *User) GetFromMap(token map[string]interface{}) error

func (*User) GetNotificationUsersIDs

func (m *User) GetNotificationUsersIDs() []string

func (*User) GetOne

func (m *User) GetOne(request *BaseRequest) (*User, error)

func (*User) GetRepoType

func (m *User) GetRepoType() RepoType

func (*User) GetSystemUser

func (m *User) GetSystemUser() (*User, error)

func (*User) GetUserLog

func (m *User) GetUserLog() *UserLog

func (*User) HasSysNotify added in v1.7.0

func (m *User) HasSysNotify(sysNotify SysNotify) bool

func (*User) IsAdmin

func (m *User) IsAdmin() bool

func (*User) IsStaff

func (m *User) IsStaff() bool

func (*User) IsSystem

func (m *User) IsSystem() bool

func (*User) IsValid

func (m *User) IsValid() bool

func (*User) OpenSession

func (m *User) OpenSession(request *BaseRequest) error

func (*User) ToArray

func (m *User) ToArray() []string

func (*User) ToJSON

func (m *User) ToJSON() string

func (*User) ToRaw

func (m *User) ToRaw() []byte

func (*User) Update

func (m *User) Update(request *BaseRequest) BaseResponse

func (*User) UpdateRaw

func (m *User) UpdateRaw(request *BaseRequest) BaseResponse

func (*User) Validate

func (m *User) Validate() error

type UserLog

type UserLog struct {
	User string    `json:"user" bson:"user"`
	Time time.Time `json:"time" bson:"time"`
}

type UserLogs

type UserLogs struct {
	CreatedBy  *UserLog `json:"created_by,omitempty" bson:"created_by,omitempty"`
	UpdatedBy  *UserLog `json:"updated_by,omitempty" bson:"updated_by,omitempty"`
	DeletedBy  *UserLog `json:"deleted_by,omitempty" bson:"deleted_by,omitempty"`
	LastAccess *UserLog `json:"last_access,omitempty" bson:"last_access,omitempty"`
	LockedBy   *UserLog `json:"locked_by,omitempty" bson:"locked_by,omitempty"`
}

type WeatherData

type WeatherData struct {
	Year             int     `json:"Año"`
	Week             int     `json:"Semana"`
	AvgTemp          float64 `json:"TempMedia"`
	MaxTemp          float64 `json:"TempMax"`
	DateTimeMaxTemp  string  `json:"DiaHorMinTempMax"`
	MinTemp          float64 `json:"TempMin"`
	DateTimeMinTemp  string  `json:"DiaHorMinTempMin"`
	AvgHumidity      float64 `json:"HumedadMedia"`
	MaxHumidity      float64 `json:"HumedadMax"`
	DateTimeMaxHum   string  `json:"DiaHorMinHumMax"`
	MinHumidity      float64 `json:"HumedadMin"`
	DateTimeMinHum   string  `json:"DiaHorMinHumMin"`
	WindSpeed        float64 `json:"VelViento"`
	WindDirection    float64 `json:"DirViento"`
	MaxWindSpeed     float64 `json:"VelVientoMax"`
	DateTimeMaxSpeed string  `json:"DiaHorMinVelMax"`
	WindDirMaxSpeed  float64 `json:"DirVientoVelMax"`
	Radiation        float64 `json:"Radiacion"`
	Precipitation    float64 `json:"Precipitacion"`
	EtPMon           float64 `json:"EtPMon"`
	PePMon           float64 `json:"PePMon"`
	Station          string  `json:"Estacion"`
}

type WeatherDataResponse

type WeatherDataResponse struct {
	Datos []WeatherData `json:"Datos"`
}

type WeatherMetric

type WeatherMetric struct {
	TempHigh      float64 `json:"tempHigh"`
	TempLow       float64 `json:"tempLow"`
	TempAvg       float64 `json:"tempAvg"`
	WindspeedHigh float64 `json:"windspeedHigh"`
	WindspeedAvg  float64 `json:"windspeedAvg"`
	HumidityHigh  int     `json:"humidityHigh"`
	HumidityLow   int     `json:"humidityLow"`
	HumidityAvg   int     `json:"humidityAvg"`
}

type WeatherObservation

type WeatherObservation struct {
	StationID    string        `json:"stationID"`
	ObsTimeLocal string        `json:"obsTimeLocal"`
	WinddirAvg   float64       `json:"winddirAvg"`
	Metric       WeatherMetric `json:"metric"`
}

type WeatherResponse

type WeatherResponse struct {
	Observations []WeatherObservation `json:"observations"`
}

Jump to

Keyboard shortcuts

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