database

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const WorkflowPaymentDB = "workflowpaymentsdb"
View Source
const WorkflowPaymentDBDir = "workflowpayments"

Variables

This section is empty.

Functions

func DecryptWithAES

func DecryptWithAES(secret, encryptedString string) (string, error)

func EncryptWithAES

func EncryptWithAES(secret, stringToEncrypt string) (string, error)

func IsReadGrantedFor

func IsReadGrantedFor(auth model.Auth, includeGrant bool) q.Matcher

IsReadGrantedFor returns a matcher used to compare permisions fields with specific values

func NewDBSet

func NewDBSet(sDB storage.SettingsIF, folderPath string) (me *storage.DBSet, err error)

NewDBSet uses the configuration in the setting db to instantiate the remaining databases and return them as a set

Types

type DBConfig

type DBConfig struct {
	Dir    string
	Engine string
	URI    string
}

type DocTemplateDB

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

func NewDocTemplateDB

func NewDocTemplateDB(c DBConfig) (*DocTemplateDB, error)

NewDocTemplateDB opens a handle to the Document Template database

func (*DocTemplateDB) AssetsKey

func (me *DocTemplateDB) AssetsKey() string

AssetsKeys return the base filepath of the document templates

func (*DocTemplateDB) Close

func (me *DocTemplateDB) Close() error

Close closes the databases

func (*DocTemplateDB) Delete

func (me *DocTemplateDB) Delete(auth model.Auth, files storage.FilesIF, id string) error

Delete removes a template's files on the file system

func (*DocTemplateDB) DeleteTemplate

func (me *DocTemplateDB) DeleteTemplate(auth model.Auth, files storage.FilesIF, id, lang string) error

DeleteTemplate removes a template from the database

func (*DocTemplateDB) Get

func (me *DocTemplateDB) Get(auth model.Auth, id string) (*model.TemplateItem, error)

Get retrieves a single template item using its key

func (*DocTemplateDB) GetTemplate

func (me *DocTemplateDB) GetTemplate(auth model.Auth, id, lang string) (*file.IO, error)

GetTemplate returns the file template

func (*DocTemplateDB) List

func (me *DocTemplateDB) List(auth model.Auth, contains string, options storage.Options) ([]*model.TemplateItem, error)

List fetches template items from the database based on the supplied filter options

func (*DocTemplateDB) ProvideFileInfoFor

func (me *DocTemplateDB) ProvideFileInfoFor(auth model.Auth, id, lang string, fm *file.Meta) (*file.IO, error)

ProvideFileInfoFor returns the fileinfo for a file On return, n == len(buf) if and only if err == nil.

func (*DocTemplateDB) Put

func (me *DocTemplateDB) Put(auth model.Auth, item *model.TemplateItem) error

Put inserts a template item

func (*DocTemplateDB) PutVars

func (me *DocTemplateDB) PutVars(auth model.Auth, id, lang string, vars []string) error

PutVars inserts a new variable into the database

func (*DocTemplateDB) Vars

func (me *DocTemplateDB) Vars(auth model.Auth, contains string, options storage.Options) ([]string, error)

Vars returns a list of variables defines for a specific template

type FileDB

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

func NewFileDB

func NewFileDB(c DBConfig) (*FileDB, error)

NewFileDB returns a handle for the File database

func (*FileDB) Close

func (d *FileDB) Close() error

Close closes the database

func (*FileDB) Delete

func (d *FileDB) Delete(path string) error

Delete removes a file from the file database

func (*FileDB) Exists

func (d *FileDB) Exists(path string) (bool, error)

Exists checks whether a file with a specific path exists in the file database

func (*FileDB) Read

func (d *FileDB) Read(path string, w io.Writer) error

Read returns a file content to the supplied writer

func (*FileDB) Write

func (d *FileDB) Write(path string, r io.Reader) error

Write writes a file content from the supplied reader

type FormDB

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

func NewFormDB

func NewFormDB(c DBConfig) (*FormDB, error)

NewFormDB returns a handle to the form component database

func (*FormDB) Close

func (me *FormDB) Close() error

Close closes the database

func (*FormDB) DelComp

func (me *FormDB) DelComp(auth model.Auth, id string) error

DelComp removes a form component definition from the database

func (*FormDB) Delete

func (me *FormDB) Delete(auth model.Auth, id string) error

Delete removes a form item from the database

func (*FormDB) Get

func (me *FormDB) Get(auth model.Auth, id string) (*model.FormItem, error)

Get returns one form item by its id

func (*FormDB) GetComp

func (me *FormDB) GetComp(auth model.Auth, id string) (*model.FormComponentItem, error)

GetComp retrieves a form component from the database

func (*FormDB) List

func (me *FormDB) List(auth model.Auth, contains string, options storage.Options) ([]*model.FormItem, error)

List returns the set of form items matching the supplied filter criteria

func (*FormDB) ListComp

func (me *FormDB) ListComp(auth model.Auth, contains string, options storage.Options) (map[string]*model.FormComponentItem, error)

ListComp returns a list of form component matching the supplied filter criteria

func (*FormDB) Put

func (me *FormDB) Put(auth model.Auth, item *model.FormItem) error

Put saves a form item into the database

func (*FormDB) PutComp

func (me *FormDB) PutComp(auth model.Auth, comp *model.FormComponentItem) error

PutComp saves a form component into the database

func (*FormDB) Vars

func (me *FormDB) Vars(auth model.Auth, contains string, options storage.Options) ([]string, error)

Vars returns a list of variable defined in a form

type GrantMatcher

type GrantMatcher struct {
	Auth       model.Auth
	CheckWrite bool //false checks for read perm
}

func (*GrantMatcher) MatchField

func (me *GrantMatcher) MatchField(v interface{}) (bool, error)

type GroupAndOthersMatcher

type GroupAndOthersMatcher struct {
	Auth       model.Auth
	CheckWrite bool //false checks for read perm
}

func (*GroupAndOthersMatcher) MatchField

func (me *GroupAndOthersMatcher) MatchField(v interface{}) (bool, error)

type I18nDB

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

func NewI18nDB

func NewI18nDB(c DBConfig) (*I18nDB, error)

NewI18nDB returns a handle to the translation database

func (*I18nDB) Close

func (me *I18nDB) Close() error

Close closes the database

func (*I18nDB) Find

func (me *I18nDB) Find(keyContains string, valueContains string, options storage.Options) (map[string]map[string]string, error)

Find retrieves a list of translations matching the supplied filter criteria

func (*I18nDB) Get

func (me *I18nDB) Get(lang string, key string, args ...string) (string, error)

Get retrieves a specific translation item

func (*I18nDB) GetAll

func (me *I18nDB) GetAll(lang string) (map[string]string, error)

GetAll returns the full set of translations

func (*I18nDB) GetAllLangs

func (me *I18nDB) GetAllLangs() ([]*model.Lang, error)

GetAllLangs returns the full list of all languages defined

func (*I18nDB) GetFallback

func (me *I18nDB) GetFallback() (string, error)

GetFallback returns the currently defined default/fallback language

func (*I18nDB) GetLangs

func (me *I18nDB) GetLangs(enabled bool) ([]*model.Lang, error)

GetLangs returns a list of languages

func (*I18nDB) HasLang

func (me *I18nDB) HasLang(lang string) bool

HasLang checks indicates if a language exists

func (*I18nDB) Put

func (me *I18nDB) Put(lang string, key string, text string) error

Put saves a single translation into the database

func (*I18nDB) PutAll

func (me *I18nDB) PutAll(lang string, translations map[string]string) error

PutAll saves the supplied translations into the database

func (*I18nDB) PutFallback

func (me *I18nDB) PutFallback(lang string) error

PutFallback sets a specific language as default/fallback

func (*I18nDB) PutLang

func (me *I18nDB) PutLang(lang string, enabled bool) error

PutLang adds a new language to the translation database

type SessionDB

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

func NewSessionDB

func NewSessionDB(c DBConfig, sessionExpiration, tokenExpiration time.Duration) (*SessionDB, error)

NewSessionDB returns a handle to the session & token database with the supplied expiration times

func (*SessionDB) Close

func (d *SessionDB) Close() error

func (*SessionDB) Delete

func (d *SessionDB) Delete(s *model.Session) error

Delete removes a session

func (*SessionDB) DeleteTokenRequest

func (d *SessionDB) DeleteTokenRequest(r *model.TokenRequest) error

DeleteTokenRequest removes a token request

func (*SessionDB) DeleteValue

func (d *SessionDB) DeleteValue(key string) error

DeleteValue removes the value of a key

func (*SessionDB) Get

func (d *SessionDB) Get(sid string) (*model.Session, error)

Get returns a session

func (*SessionDB) GetTokenRequest

func (d *SessionDB) GetTokenRequest(t model.TokenType, id string) (*model.TokenRequest, error)

GetTokenRequest returns a token request

func (*SessionDB) GetValue

func (d *SessionDB) GetValue(key string, v interface{}) error

GetValue returns the value for the provided key

func (*SessionDB) Put

func (d *SessionDB) Put(s *model.Session) error

Put inserts a session

func (*SessionDB) PutTokenRequest

func (d *SessionDB) PutTokenRequest(r *model.TokenRequest) error

PutTokenRequest inserts a token request

func (*SessionDB) PutValue

func (d *SessionDB) PutValue(key string, v interface{}) error

PutValue sets the value for a key

type SettingsDB

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

func NewSettingsDB

func NewSettingsDB(settingsFile string, initialSettings *model.Settings) (*SettingsDB, error)

NewSettingsDB returns a handle to access the settings database / file

func (*SettingsDB) Close

func (se *SettingsDB) Close() error

Close closes the database

func (*SettingsDB) Get

func (se *SettingsDB) Get() (*model.Settings, error)

Get retrieves all settings from the database / file

func (*SettingsDB) Put

func (se *SettingsDB) Put(s *model.Settings) error

Put adds a new set of settings into the database / file

type SignatureRequestsDB

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

func NewSignatureDB

func NewSignatureDB(c DBConfig) (*SignatureRequestsDB, error)

NewSignatureDB return a handle to the signature request database

func (*SignatureRequestsDB) Add

Add saves a signature request into the database

func (*SignatureRequestsDB) Close

func (me *SignatureRequestsDB) Close() error

Close closes the database

func (*SignatureRequestsDB) GetByHashAndSigner

func (me *SignatureRequestsDB) GetByHashAndSigner(hash string, signatory string) (*[]model.SignatureRequestItem, error)

GetByHashAndSigner returns a list of signture requests for a specific file hash and signatory

func (*SignatureRequestsDB) GetByID

func (me *SignatureRequestsDB) GetByID(docid string, docpath string) (*[]model.SignatureRequestItem, error)

GetByID returns the signature request item by its id

func (*SignatureRequestsDB) GetBySignatory

func (me *SignatureRequestsDB) GetBySignatory(ethAddr string) (*[]model.SignatureRequestItem, error)

GetBySignatory returns the list of signature requests for a specific signatory

func (*SignatureRequestsDB) SetRejected

func (me *SignatureRequestsDB) SetRejected(docid string, docpath string, signatory string) error

SetRejected alters the status of a signature request to rejected

func (*SignatureRequestsDB) SetRevoked

func (me *SignatureRequestsDB) SetRevoked(docid string, docpath string, signatory string) error

SetRevoked alters the status of a signature request to revoked

type UserDB

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

func NewUserDB

func NewUserDB(c DBConfig, fileDB storage.FilesIF) (*UserDB, error)

NewUserDB returns a handle to the user database, containing the user object, incl. their credentials for login and API access

func (*UserDB) Close

func (me *UserDB) Close() error

Close closes the database

func (*UserDB) Count

func (me *UserDB) Count() (int, error)

Count returns the user count

func (*UserDB) CreateApiKey

func (me *UserDB) CreateApiKey(auth model.Auth, userId, apiKeyName string) (string, error)

CreateApiKey saves and returns a newly created random api key for a user

func (*UserDB) DeleteApiKey

func (me *UserDB) DeleteApiKey(auth model.Auth, userId, hiddenApiKey string) error

DeleteApiKey removes an existing API key by name or value

func (*UserDB) Get

func (me *UserDB) Get(auth model.Auth, id string) (*model.User, error)

Get return a specific user object by machting its id

func (*UserDB) GetBaseFilePath

func (me *UserDB) GetBaseFilePath() string

GetBaseFilePath returns the base file path

func (*UserDB) GetByApiKey

func (me *UserDB) GetByApiKey(key string, userID string) (*model.User, error)

APIKey tries to authenticate the user with the supplied API key and returns the user object or an error

func (*UserDB) GetByBCAddress

func (me *UserDB) GetByBCAddress(bcAddress string) (*model.User, error)

GetByBCAddress return a specific user object by matching the ethereum address

func (*UserDB) GetByEmail

func (me *UserDB) GetByEmail(email string) (*model.User, error)

GetByEmail return a specific user object by matching the email address

func (*UserDB) GetProfilePhoto

func (me *UserDB) GetProfilePhoto(auth model.Auth, id string, writer io.Writer) error

GetProfilePhoto returns a users photo

func (*UserDB) List

func (me *UserDB) List(auth model.Auth, contains string, options storage.Options) ([]*model.User, error)

List returns references to all the user object matching the supplied filter criteria

func (*UserDB) Login

func (me *UserDB) Login(name, pw string) (*model.User, error)

Login tries to authenticate a user with the supplied credentials and returns the user object or an error

func (*UserDB) Put

func (me *UserDB) Put(auth model.Auth, item *model.User) error

Put saves a user object into the database

func (*UserDB) PutProfilePhoto

func (me *UserDB) PutProfilePhoto(auth model.Auth, id string, reader io.Reader) error

PutProfilePhoto sets a new photo for a specific user

func (*UserDB) PutPw

func (me *UserDB) PutPw(id, pass string) error

PutPw sets a new password for a specific user id

func (*UserDB) UpdateEmail

func (me *UserDB) UpdateEmail(id, email string) error

UpdateEmail sets a new email address for a specific user id

type UserDataDB

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

func NewUserDataDB

func NewUserDataDB(c DBConfig) (*UserDataDB, error)

NewUserDataDB returns a handle to the user data database

func (*UserDataDB) AssetsKey

func (me *UserDataDB) AssetsKey() string

AssetsKey returns the base path of the data items associated file

func (*UserDataDB) Close

func (me *UserDataDB) Close() error

Close closes the database

func (*UserDataDB) Delete

func (me *UserDataDB) Delete(auth model.Auth, filesDB storage.FilesIF, id string) error

Delete removes user data and its accociates files from the database

func (*UserDataDB) Get

func (me *UserDataDB) Get(auth model.Auth, id string) (*model.UserDataItem, error)

Get returns a specific user data item by matching the id

func (*UserDataDB) GetAllFileInfosOf

func (me *UserDataDB) GetAllFileInfosOf(ud *model.UserDataItem) []*file.IO

GetAllFileInfosOf returns the associated file objects of a user data item

func (*UserDataDB) GetByWorkflow

func (me *UserDataDB) GetByWorkflow(auth model.Auth, wf *model.WorkflowItem, finished bool) (*model.UserDataItem, bool, error)

GetByWorkflow returns a the user data item by matching a specific workflow item

func (*UserDataDB) GetData

func (me *UserDataDB) GetData(auth model.Auth, id, dataPath string) (interface{}, error)

GetData returns the data object for retrieving specific data from a data item

func (*UserDataDB) GetDataAndFiles

func (me *UserDataDB) GetDataAndFiles(auth model.Auth, id, dataPath string) (interface{}, []string, error)

GetDataAndFiles returns the data object and associated files

func (*UserDataDB) GetDataFile

func (me *UserDataDB) GetDataFile(auth model.Auth, id, dataPath string) (*file.IO, error)

GetDataFile returns the files associated with a data item

func (*UserDataDB) List

func (me *UserDataDB) List(auth model.Auth, contains string, options storage.Options, includeReadGranted bool) ([]*model.UserDataItem, error)

List returns all user data item matching the supplied filter criteria

func (*UserDataDB) NewFile

func (me *UserDataDB) NewFile(auth model.Auth, meta file.Meta) *file.IO

NewFile return a handle for a new data item file based on the defined base path and specific file metadata

func (*UserDataDB) Put

func (me *UserDataDB) Put(auth model.Auth, item *model.UserDataItem) error

Put saves a user data item into the database

func (*UserDataDB) PutData

func (me *UserDataDB) PutData(auth model.Auth, id string, dataObj map[string]interface{}) error

PutData inserts a data object into the data item database

type Var

type Var struct {
	ID      string          `storm:"id"` //var
	VarRefs map[string]bool //ids that contain this var
}

type VarsMaintenance

type VarsMaintenance struct {
	ID   string `json:"id" storm:"id"` //form id
	Vars []string
}

type WorkflowDB

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

func NewWorkflowDB

func NewWorkflowDB(c DBConfig) (*WorkflowDB, error)

NewWorkflowDB returns a handle to the workflow database

func (*WorkflowDB) Close

func (me *WorkflowDB) Close() error

Close closes the database

func (*WorkflowDB) Delete

func (me *WorkflowDB) Delete(auth model.Auth, id string) error

Delete removes a workflow item from the database by matching its id

func (*WorkflowDB) DeleteExternalNode

func (me *WorkflowDB) DeleteExternalNode(auth model.Auth, id string) error

DeleteExternalNode remove an external node definition

func (*WorkflowDB) Get

func (me *WorkflowDB) Get(auth model.Auth, id string) (*model.WorkflowItem, error)

Get retrieves a worklfow item machting its id

func (*WorkflowDB) GetList

func (me *WorkflowDB) GetList(auth model.Auth, ids []string) ([]*model.WorkflowItem, error)

GetList retrieves multiple workflows by matching their id

func (*WorkflowDB) GetPublished

func (me *WorkflowDB) GetPublished(auth model.Auth, id string) (*model.WorkflowItem, error)

GetPublished returns a workflow item matching the supplied filter options that if it is flagged as published

func (*WorkflowDB) List

func (me *WorkflowDB) List(auth model.Auth, contains string, options storage.Options) ([]*model.WorkflowItem, error)

ListPublished returns all workflow items matching the supplied filter options

func (*WorkflowDB) ListExternalNodes

func (me *WorkflowDB) ListExternalNodes() []*externalnode.ExternalNode

ListExternalNodes return a list of all external node definitions

func (*WorkflowDB) ListPublished

func (me *WorkflowDB) ListPublished(auth model.Auth, contains string, options storage.Options) ([]*model.WorkflowItem, error)

ListPublished returns all workflow items matching the supplied filter options that are flagged as published

func (*WorkflowDB) NodeByName

func (me *WorkflowDB) NodeByName(auth model.Auth, name string) (*externalnode.ExternalNode, error)

NodeByName retrieves an external node definition matching the supplied name

func (*WorkflowDB) Put

func (me *WorkflowDB) Put(auth model.Auth, item *model.WorkflowItem) error

Put adds a workflow item into the database

func (*WorkflowDB) PutExternalNodeInstance

func (me *WorkflowDB) PutExternalNodeInstance(auth model.Auth, item *externalnode.ExternalNodeInstance) error

PutExternalNodeInstance saves an instance of an external node to the database

func (*WorkflowDB) QueryFromInstanceID

func (me *WorkflowDB) QueryFromInstanceID(auth model.Auth, id string) (externalnode.ExternalNodeInstance, error)

QueryFromInstanceID return an external node instance by machting the specified id

func (*WorkflowDB) RegisterExternalNode

func (me *WorkflowDB) RegisterExternalNode(auth model.Auth, n *externalnode.ExternalNode) error

RegisterExternalNode saves an external node definition

type WorkflowPaymentsDB

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

func NewWorkflowPaymentDB

func NewWorkflowPaymentDB(c DBConfig) (*WorkflowPaymentsDB, error)

NewWorkflowPaymentDB return a handle to the workflow payment database

func (*WorkflowPaymentsDB) All

All returns a list of all workflow payment items from the database

func (*WorkflowPaymentsDB) Cancel

func (me *WorkflowPaymentsDB) Cancel(paymentId, from string) error

Cancel sets the status of a workflow payment item to cancelled for the item matching the supplied id and from address

func (*WorkflowPaymentsDB) Close

func (me *WorkflowPaymentsDB) Close() error

Close closes the database

func (*WorkflowPaymentsDB) ConfirmPayment

func (me *WorkflowPaymentsDB) ConfirmPayment(txHash, from, to string, xes uint64) error

ConfirmPayment sets the status of a workflow payment item to confirmed by trying to find a matching transaction hash and searching for pending or created items matching the supplied criteria

func (*WorkflowPaymentsDB) Delete

func (me *WorkflowPaymentsDB) Delete(paymentId string) error

Delete sets the status of a workflow payment item to deleted by matching the supplied id

func (*WorkflowPaymentsDB) Get

func (me *WorkflowPaymentsDB) Get(paymentId string) (*model.WorkflowPaymentItem, error)

Get returns a specific Workflow payment item matching its id

func (*WorkflowPaymentsDB) GetByTxHashAndStatusAndFromEthAddress

func (me *WorkflowPaymentsDB) GetByTxHashAndStatusAndFromEthAddress(txHash, status,
	fromEthAddr string) (*model.WorkflowPaymentItem, error)

GetByTxHashAndStatusAndFromEthAddress returns a workflow payment item by matching the supplied filter parameters

func (*WorkflowPaymentsDB) GetByWorkflowIdAndFromEthAddress

func (me *WorkflowPaymentsDB) GetByWorkflowIdAndFromEthAddress(workflowID, fromEthAddr string,
	statuses []string) (*model.WorkflowPaymentItem, error)

GetByWorkflowIdAndFromEthAddress returns a workflow payment item by matching the supplied filter parameters

func (*WorkflowPaymentsDB) Redeem

func (me *WorkflowPaymentsDB) Redeem(workflowId, from string) error

Redeem sets the status of a workflow payment item to redeemed for the item matching the supplied id and from address

func (*WorkflowPaymentsDB) Remove

func (me *WorkflowPaymentsDB) Remove(payment *model.WorkflowPaymentItem) error

Remove removes a workflow payment item

func (*WorkflowPaymentsDB) Save

Save add a workflow payment item to the database

func (*WorkflowPaymentsDB) SetAbandonedToTimeoutBeforeTime

func (me *WorkflowPaymentsDB) SetAbandonedToTimeoutBeforeTime(beforeTime time.Time) error

SetAbandonedToTimeoutBeforeTime updates the status of all payment items created before the specified time to status timeout

func (*WorkflowPaymentsDB) Update

func (me *WorkflowPaymentsDB) Update(paymentId, status, txHash, from string) error

Update sets the status and tx hash of created workflow items matching the supplied criteria to the supplied values

Directories

Path Synopsis
Package db holds the database layer for the Proxeus core
Package db holds the database layer for the Proxeus core
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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