Documentation ¶
Index ¶
- Constants
- Variables
- func GetPrettySize(bytes int64) string
- func MidnightForDate(t time.Time) time.Time
- type Document
- func (d *Document) Diff(newDocument *Document, userId int) ([]DocumentHistory, error)
- func (d *Document) FilterAttributes() []string
- func (d *Document) GetSize() string
- func (d *Document) GetType() string
- func (d *Document) HasMetadataKey(keyId int) bool
- func (d *Document) HasMetadataKeyValue(keyId, valueId int) bool
- func (d *Document) Init()
- func (d *Document) IsImage() bool
- func (d *Document) IsPdf() bool
- func (d *Document) SortAttributes() []string
- func (d *Document) SortNoCase() []string
- type DocumentHistory
- type DocumentHistoryAction
- type DocumentMetadataHistoryEntry
- type DocumentSharePermission
- type Int
- type IntId
- type Job
- type JobComposite
- type JobStatus
- type Lang
- type Language
- type LinkedDocument
- type Metadata
- type MetadataArray
- type MetadataKey
- type MetadataKeyAnnotated
- type MetadataKeyStatistics
- type MetadataRuleType
- type MetadataSearchResult
- type MetadataValue
- type Modeler
- type PasswordResetToken
- type Permissions
- type ProcessItem
- type ProcessStep
- type Rule
- type RuleAction
- type RuleActionType
- type RuleCondition
- type RuleConditionMatchType
- type RuleConditionType
- type RuleTrigger
- type RuleTriggerArray
- type SystemStatistics
- type Tag
- type TagComposite
- type Text
- type Timestamp
- type Token
- type UpdateUserSharing
- type User
- type UserDocumentStatistics
- type UserDocumentYearStat
- type UserInfo
- type UserPreferences
Constants ¶
const ( DocumentHistoryActionCreate = "create" DocumentHistoryActionRename = "rename" DocumentHistoryActionDescription = "description" DocumentHistoryActionDate = "date" DocumentHistoryActionLanguage = "lang" DocumentHistoryActionContent = "content" DocumentHistoryActionMetadataRemove = "remove metadata" DocumentHistoryActionMetadataAdd = "add metadata" DocumentHistoryActionDelete = "delete" DocumentHistoryActionRestore = "restore" DocumentHistoryActionFavorite = "favorite" DocumentHistoryActionUnFavorite = "unfavorite" )
Variables ¶
var AllConditionTypes = []RuleConditionType{ RuleConditionNameIs, RuleConditionNameStarts, RuleConditionNameContains, RuleConditionDescriptionIs, RuleConditionDescriptionStarts, RuleConditionDescriptionContains, RuleConditionContentIs, RuleConditionContentStarts, RuleConditionContentContains, RuleConditionDateIs, RuleConditionDateAfter, RuleConditionDateBefore, RuleConditionMetadataHasKey, RuleConditionMetadataHasKeyValue, RuleConditionMetadataCount, RuleConditionMetadataCountLessThan, RuleConditionMetadataCountMoreThan, }
var AllRuleTriggers = RuleTriggerArray{RuleTriggerCreate, RuleTriggerUpdate}
var ProcessStepsAll = []ProcessStep{ProcessHash, ProcessThumbnail, ProcessParseContent, ProcessDetectLanguage, ProcessRules, ProcessFts}
ProcessStepsAll is a list of default steps to run for new document.
var ProcessStepsKeys = map[ProcessStep]string{ ProcessHash: "hash", ProcessThumbnail: "thumbnail", ProcessParseContent: "content", ProcessDetectLanguage: "detect-language", ProcessRules: "rules", ProcessFts: "fts", }
var ProcessStepsOrder = map[ProcessStep]int{ ProcessHash: 1, ProcessThumbnail: 2, ProcessParseContent: 3, ProcessDetectLanguage: 4, ProcessRules: 5, ProcessFts: 6, }
ProcessStepsOrder is the order in which the steps are to be run in ascending order.
Functions ¶
Types ¶
type Document ¶
type Document struct { Timestamp Id string `db:"id"` UserId int `db:"user_id"` Name string `db:"name"` Description string `db:"description"` Content string `db:"content"` Filename string `db:"filename"` Hash string `db:"hash"` Mimetype string `db:"mimetype"` Size int64 `db:"size"` Date time.Time `db:"date"` Metadata []Metadata Tags []Tag Lang Lang `db:"lang"` Favorite bool `db:"favorite"` DeletedAt sql.NullTime `db:"deleted_at"` }
Document represents single file and data related to it.
func (*Document) Diff ¶
func (d *Document) Diff(newDocument *Document, userId int) ([]DocumentHistory, error)
Diffs returns a list of DocumentHistory items from d -> newDocument. Metadata changes are not evaluated.
func (*Document) FilterAttributes ¶
func (*Document) HasMetadataKey ¶
HasMetadataKey returns true if document has given metadata key.
func (*Document) HasMetadataKeyValue ¶
HasMetadataKeyValue returns true if document has given metadata key and value.
func (*Document) Init ¶
func (d *Document) Init()
Init initializes new document. It ensures document has valid uuid assigned to it.
func (*Document) SortAttributes ¶
func (*Document) SortNoCase ¶
type DocumentHistory ¶
type DocumentHistory struct { Id int `db:"id" json:"id"` DocumentId string `db:"document_id" json:"document_id"` Action string `db:"action" json:"action"` OldValue string `db:"old_value" json:"old_value"` NewValue string `db:"new_value" json:"new_value"` UserId int `db:"user_id" json:"user_id"` User string `db:"user" json:"user"` CreatedAt time.Time `db:"created_at" json:"created_at"` }
func MetadataDiff ¶
func MetadataDiff(id string, userId int, original, updated *MetadataArray) []DocumentHistory
func (*DocumentHistory) FilterAttributes ¶
func (dh *DocumentHistory) FilterAttributes() []string
func (*DocumentHistory) SortAttributes ¶
func (dh *DocumentHistory) SortAttributes() []string
func (*DocumentHistory) SortNoCase ¶
func (dh *DocumentHistory) SortNoCase() []string
func (*DocumentHistory) Update ¶
func (dh *DocumentHistory) Update()
type DocumentHistoryAction ¶
type DocumentHistoryAction string
type DocumentSharePermission ¶ added in v0.6.0
type DocumentSharePermission struct {}
type IntId ¶
type IntId uint64
type Job ¶
type Job struct { Id int `db:"id" json:"id"` DocumentId string `db:"document_id" json:"document_id"` Message string `db:"message" json:"message"` Status JobStatus `json:"status"` Step ProcessStep `db:"process_step"` StartedAt time.Time `db:"started_at" json:"started_at"` StoppedAt time.Time `db:"stopped_at" json:"stopped_at"` }
Job is a pipeline that each document goes through. It consists of multiple steps to process document. Job is only used for logging purposes.
type JobComposite ¶
JobComposite contains additional information. Actual underlying model is still Job.
func (*JobComposite) SetDuration ¶
func (jc *JobComposite) SetDuration()
type JobStatus ¶
type JobStatus string
JobStatus describes status for process-step It maps as integer to database.
type LinkedDocument ¶
type LinkedDocument struct { DocumentId string `json:"id"` DocumentName string `json:"name"` CreatedAt time.Time `json:"created_at"` }
LinkedDocument represents documents that are linked together
type Metadata ¶
type Metadata struct { KeyId int `db:"key_id" json:"key_id"` Key string `db:"key" json:"key"` Icon string `db:"icon" json:"icon"` Style string `db:"style" json:"style"` ValueId int `db:"value_id" json:"value_id"` Value string `db:"value" json:"value"` }
Metadata is metadata key-value pair assigned to document
type MetadataArray ¶ added in v0.6.0
type MetadataArray []Metadata
func (*MetadataArray) Len ¶ added in v0.6.0
func (m *MetadataArray) Len() int
func (*MetadataArray) Less ¶ added in v0.6.0
func (m *MetadataArray) Less(i, j int) bool
func (*MetadataArray) Swap ¶ added in v0.6.0
func (m *MetadataArray) Swap(i, j int)
type MetadataKey ¶
type MetadataKey struct { Id int `db:"id" json:"id"` UserId int `db:"user_id" json:"-"` Key string `db:"key" json:"key"` CreatedAt time.Time `db:"created_at" json:"created_at"` Comment string `db:"comment" json:"comment"` Icon string `db:"icon" json:"icon"` Style string `db:"style" json:"style"` }
func (*MetadataKey) FilterAttributes ¶
func (m *MetadataKey) FilterAttributes() []string
func (*MetadataKey) SortAttributes ¶
func (m *MetadataKey) SortAttributes() []string
func (*MetadataKey) SortNoCase ¶
func (m *MetadataKey) SortNoCase() []string
func (*MetadataKey) Update ¶
func (m *MetadataKey) Update()
type MetadataKeyAnnotated ¶
type MetadataKeyAnnotated struct { MetadataKey MetadataKeyStatistics }
type MetadataKeyStatistics ¶
type MetadataRuleType ¶
type MetadataRuleType string
const ( MetadataMatchExact MetadataRuleType = "exact" MetadataMatchRegex MetadataRuleType = "regex" )
type MetadataSearchResult ¶ added in v0.6.0
type MetadataSearchResult struct { Keys []MetadataKey `json:"keys"` Values []MetadataValue `json:"values"` }
type MetadataValue ¶
type MetadataValue struct { Id int `db:"id" json:"id"` UserId int `db:"user_id" json:"-"` Key string `db:"key" json:"key"` KeyId int `db:"key_id" json:"key_id"` Value string `db:"value" json:"value"` CreatedAt time.Time `db:"created_at" json:"created_at"` Comment string `db:"comment" json:"comment"` NumDocuments int `db:"documents_count" json:"documents_count"` // MatchDocuments instructs to try to automatically match MetadataValue inside documents MatchDocuments bool `db:"match_documents" json:"match_documents"` MatchType MetadataRuleType `db:"match_type" json:"match_type"` MatchFilter string `db:"match_filter" json:"match_filter"` }
func (*MetadataValue) FilterAttributes ¶
func (m *MetadataValue) FilterAttributes() []string
func (*MetadataValue) SortAttributes ¶
func (m *MetadataValue) SortAttributes() []string
func (*MetadataValue) SortNoCase ¶
func (m *MetadataValue) SortNoCase() []string
func (*MetadataValue) Update ¶
func (m *MetadataValue) Update()
type Modeler ¶
type Modeler interface { // Update marks model as updated. Update() // FilterAttributes returns list of attributes that can be used for filtering. FilterAttributes() []string // SortAttributes returns list of attributes that can be used for sorting. SortAttributes() []string SortNoCase() []string }
Modeler is a basic interface for all models.
type PasswordResetToken ¶
type PasswordResetToken struct { Timestamp Id int `db:"id"` UserId int `db:"user_id"` Token string `db:"token"` ExpiresAt time.Time `db:"expires_at"` }
func (*PasswordResetToken) HasExpired ¶
func (p *PasswordResetToken) HasExpired() bool
func (*PasswordResetToken) TokenMatches ¶
func (p *PasswordResetToken) TokenMatches(token string) (bool, error)
func (*PasswordResetToken) Validate ¶
func (p *PasswordResetToken) Validate() error
type Permissions ¶ added in v0.6.0
type Permissions struct { Read bool `json:"read"` Write bool `json:"write"` Delete bool `json:"delete"` }
func (*Permissions) Scan ¶ added in v0.6.0
func (p *Permissions) Scan(src interface{}) error
type ProcessItem ¶
type ProcessItem struct { DocumentId string `db:"document_id"` Document *Document Action ProcessStep `db:"action"` CreatedAt time.Time `db:"created_at"` Trigger RuleTrigger `db:"trigger"` }
ProcessItem contains document that awaits further processing.
type ProcessStep ¶
type ProcessStep string
ProcessStep describes next step for document. It maps as integer to database.
const ( ProcessHash ProcessStep = "hash" ProcessThumbnail ProcessStep = "thumbnail" ProcessParseContent ProcessStep = "extract" ProcessDetectLanguage ProcessStep = "detect-language" ProcessRules ProcessStep = "rules" ProcessFts ProcessStep = "fts" )
func (*ProcessStep) Scan ¶
func (ps *ProcessStep) Scan(src interface{}) error
func (ProcessStep) String ¶
func (ps ProcessStep) String() string
type Rule ¶
type Rule struct { Id int `db:"id"` UserId int `db:"user_id"` Name string `db:"name"` Description string `db:"description"` Enabled bool `db:"enabled"` Order int `db:"rule_order"` Mode RuleConditionMatchType `db:"mode"` Timestamp Triggers RuleTriggerArray `db:"triggers"` Conditions []*RuleCondition Actions []*RuleAction }
type RuleAction ¶
type RuleAction struct { Id int `db:"id"` RuleId int `db:"rule_id"` Enabled bool `db:"enabled"` // OnCondition, if vs else OnCondition bool `db:"on_condition"` Action RuleActionType `db:"action"` Value string `db:"value"` MetadataKey IntId `db:"metadata_key"` MetadataValue IntId `db:"metadata_value"` MetadataKeyName Text `db:"metadata_key_name"` MetadataValueName Text `db:"metadata_value_name"` }
type RuleActionType ¶
type RuleActionType string
const ( RuleActionSetName RuleActionType = "name_set" RuleActionAppendName RuleActionType = "name_append" RuleActionSetDescription RuleActionType = "description_set" RuleActionAppendDescription RuleActionType = "description_append" RuleActionAddMetadata RuleActionType = "metadata_add" RuleActionRemoveMetadata RuleActionType = "metadata_remove" RuleActionSetDate RuleActionType = "date_set" )
func (RuleActionType) String ¶
func (r RuleActionType) String() string
type RuleCondition ¶
type RuleCondition struct { Id int `db:"id"` RuleId int `db:"rule_id"` Enabled bool `db:"enabled"` CaseInsensitive bool `db:"case_insensitive"` // Inverted inverts the match result Inverted bool `db:"inverted_match"` ConditionType RuleConditionType `db:"condition_type"` // IsRegex defines whether to apply regex pattern IsRegex bool `db:"is_regex"` // Value to compare against, if text field Value string `db:"value"` DateFmt string `db:"date_fmt"` // Metadata to operate with MetadataKey IntId `db:"metadata_key"` MetadataValue IntId `db:"metadata_value"` MetadataKeyName Text `db:"metadata_key_name"` MetadataValueName Text `db:"metadata_value_name"` }
func (*RuleCondition) HasMetadata ¶
func (r *RuleCondition) HasMetadata() bool
func (*RuleCondition) Validate ¶
func (r *RuleCondition) Validate() error
type RuleConditionMatchType ¶
type RuleConditionMatchType int
const ( // RuleMatchAll requires all conditions must be matched RuleMatchAll RuleConditionMatchType = 1 //RuleMatchAny allows any condition to match RuleMatchAny RuleConditionMatchType = 2 )
func (*RuleConditionMatchType) FromString ¶
func (r *RuleConditionMatchType) FromString(str string) error
func (RuleConditionMatchType) String ¶
func (r RuleConditionMatchType) String() string
type RuleConditionType ¶
type RuleConditionType string
const ( RuleConditionNameIs RuleConditionType = "name_is" RuleConditionNameStarts RuleConditionType = "name_starts" RuleConditionNameContains RuleConditionType = "name_contains" RuleConditionDescriptionIs RuleConditionType = "description_is" RuleConditionDescriptionStarts RuleConditionType = "description_starts" RuleConditionDescriptionContains RuleConditionType = "description_contains" RuleConditionContentIs RuleConditionType = "content_is" RuleConditionContentStarts RuleConditionType = "content_starts" RuleConditionContentContains RuleConditionType = "content_contains" RuleConditionDateIs RuleConditionType = "date_is" RuleConditionDateAfter RuleConditionType = "date_after" RuleConditionDateBefore RuleConditionType = "date_before" RuleConditionMetadataHasKey RuleConditionType = "metadata_has_key" RuleConditionMetadataHasKeyValue RuleConditionType = "metadata_has_key_value" RuleConditionMetadataCount RuleConditionType = "metadata_count" RuleConditionMetadataCountLessThan RuleConditionType = "metadata_count_less_than" RuleConditionMetadataCountMoreThan RuleConditionType = "metadata_count_more_than" )
func (RuleConditionType) String ¶
func (r RuleConditionType) String() string
type RuleTrigger ¶ added in v0.6.0
type RuleTrigger string
const ( RuleTriggerCreate RuleTrigger = "document-create" RuleTriggerUpdate RuleTrigger = "document-update" )
type RuleTriggerArray ¶ added in v0.6.0
type RuleTriggerArray []RuleTrigger
func (*RuleTriggerArray) Scan ¶ added in v0.6.0
func (t *RuleTriggerArray) Scan(src interface{}) error
func (*RuleTriggerArray) ToJsonString ¶ added in v0.6.0
func (t *RuleTriggerArray) ToJsonString() string
type SystemStatistics ¶
type SystemStatistics struct { DocumentsInQueue int `json:"documents_queued" db:"documents_queued"` DocumentsProcessedToday int `json:"documents_processed_today" db:"documents_processed_today"` DocumentsProcessedLastWeek int `json:"documents_processed_past_week" db:"documents_processed_past_week"` DocumentsProcessedLastMonth int `json:"documents_processed_past_month" db:"documents_processed_past_month"` DocumentsTotal int `json:"documents_total" db:"documents_total"` DocumentsTotalSize int64 `json:"documents_total_size" db:"documents_size"` DocumentsTotalSizeString string `json:"documents_total_size_string"` ServerLoad string `json:"server_load"` }
type Tag ¶
type Tag struct { Id int `db:"id" json:"id"` Key string `db:"key" json:"key"` Comment string `db:"comment" json:"comment"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Tag is a per-user label to add to documents. It has many-to-many relationship with documents.
type TagComposite ¶
type Timestamp ¶
type Timestamp struct { CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
func (*Timestamp) FilterAttributes ¶
func (*Timestamp) SortAttributes ¶
func (*Timestamp) SortNoCase ¶
type Token ¶
type Token struct { Timestamp Id int `json:"id" db:"id"` UserId int `json:"user_id" db:"user_id"` Key string `json:"key" db:"key"` Name string `json:"name" db:"name"` IpAddr string `json:"ip_addr" db:"ip_address"` ExpiresAt time.Time `json:"expires_at" db:"expires_at"` LastSeen time.Time `json:"last_seen" db:"last_seen"` LastConfirmed time.Time `json:"last_confirmed" db:"last_confirmed"` }
func (*Token) ConfirmationExpired ¶
func (*Token) HasExpired ¶
type UpdateUserSharing ¶ added in v0.6.0
type UpdateUserSharing struct { UserId int `json:"user_id"` Permissions Permissions `json:"permissions"` }
type User ¶
type User struct { Timestamp Id int `db:"id"` Name string `db:"name"` Password string `db:"password"` Email string `db:"email"` IsAdmin bool `db:"admin"` IsActive bool `db:"active"` }
func (*User) SetPassword ¶
type UserDocumentStatistics ¶
type UserDocumentStatistics struct { UserId int `json:"id"` NumDocuments int `json:"num_documents"` YearlyStats []UserDocumentYearStat `json:"yearly_stats"` NumMetadataKeys int `json:"num_metadata_keys"` NumMetadataValues int `json:"num_metadata_values"` LastDocumentsUpdated []string `json:"last_documents_updated"` LastDocumentsAdded []string `json:"last_documents_added"` LastDocumentsViewed []string `json:"last_documents_viewed"` Favorites []string `json:"favorites"` }
UserDocumentStatistics contains various about user's documents.
type UserDocumentYearStat ¶
type UserInfo ¶
type UserInfo struct { UserId int `json:"id" db:"user_id"` UserName string `json:"user_name" db:"username"` Email string `json:"email" db:"email"` IsActive bool `json:"is_active" db:"active"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` DocumentCount Int `json:"documents_count" db:"documents_count"` DocumentsSize Int `json:"documents_size" db:"documents_size"` IsAdmin bool `json:"is_admin" db:"admin"` LastSeen time.Time `json:"last_seen" db:"last_seen"` Indexing bool `json:"indexing"` }
type UserPreferences ¶
type UserPreferences struct { UserId int `json:"user_id" db:"user_id"` UserName string `json:"user_name" db:"username"` Email string `json:"email" db:"email"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` DocumentCount Int `json:"documents_count" db:"documents_count"` DocumentsSize Int `json:"documents_size" db:"documents_size"` IsAdmin bool `json:"is_admin" db:"is_admin"` }
UserPreferences are per-user preferences and configuration options.