engine

package
v0.46.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *slog.Logger

Logger is global since we will need it everywhere

Functions

func ApplyTagAliasesFromConfig added in v0.43.4

func ApplyTagAliasesFromConfig(configPath string, db database.Repository) error

ApplyTagAliasesFromConfig reads tag_aliases.json and inserts aliases into the database. For each entry it looks up the tag by name and inserts the alias. Entries whose tag_name doesn't exist in the DB are silently skipped.

func CalculateFileHash added in v0.46.0

func CalculateFileHash(filePath string) (string, error)

CalculateFileHash computes MD5 hash of a file

func CanonicalDocName added in v0.45.1

func CanonicalDocName(id int, ext string) string

CanonicalDocName returns the canonical filename for a document: "001234.orig.pdf". ext should include the leading dot.

func ComputeNestedPath added in v0.42.1

func ComputeNestedPath(id int, ext string, documentRoot string) (path string, folder string)

ComputeNestedPath returns the nested directory path for a document based on its DB ID. The scheme uses letter prefixes (L/K/J) and 2-digit pair directory levels:

L: IDs 1–99,999       → L/XX/YY/ZZ/NNNNNN.orig.ext
K: IDs 100,000–9,999,999 → K/XX/YY/ZZ/WW/NNNNNNNN.orig.ext
J: IDs 10,000,000+    → J/XX/YY/ZZ/WW/VV/NNNNNNNNNN.orig.ext

ext should include the leading dot (e.g. ".pdf").

func DeleteFile

func DeleteFile(filePath string) error

DeleteFile deletes a folder (or file) and everything in that folder

func EnsureConfigDir added in v0.43.4

func EnsureConfigDir(configPath string) error

EnsureConfigDir creates the config directory if it doesn't exist.

func ReadTagAliases added in v0.43.4

func ReadTagAliases(configPath string) ([]database.TagAliasEntry, error)

ReadTagAliases reads tag aliases from config/tag_aliases.json. Returns an empty slice if the file doesn't exist.

func RotateDocumentFile added in v0.46.0

func RotateDocumentFile(docPath string, degrees int) error

RotateDocumentFile rotates a document file in place. degrees must be 90, 180, or 270 (clockwise).

func SaveThumbnailFile added in v0.46.0

func SaveThumbnailFile(docPath string) error

SaveThumbnailFile is the exported version of saveThumbnailFile.

func SidecarBasePath added in v0.45.1

func SidecarBasePath(docPath string) string

SidecarBasePath strips the ".orig.{ext}" suffix from a canonical document path, returning the base used for all sidecar files. e.g. "L/00/12/34/001234.orig.pdf" → "L/00/12/34/001234"

func ThumbnailSupported added in v0.46.0

func ThumbnailSupported(path string) bool

ThumbnailSupported is the exported version of thumbnailSupported.

func WriteTagAliases added in v0.43.4

func WriteTagAliases(configPath string, db database.Repository) error

WriteTagAliases exports all tag aliases from the database to config/tag_aliases.json.

Types

type DocumentStatus added in v0.32.0

type DocumentStatus struct {
	ULID          string `json:"ulid"`
	Name          string `json:"name"`
	Path          string `json:"path"`
	DocumentType  string `json:"documentType"`
	HasThumbnail  bool   `json:"hasThumbnail"`
	ThumbnailURL  string `json:"thumbnailURL,omitempty"`
	HasText       bool   `json:"hasText"`
	TextLength    int    `json:"textLength"`
	TextURL       string `json:"textURL,omitempty"`
	HasTags       bool   `json:"hasTags"`
	TagCount      int    `json:"tagCount"`
	ViewURL       string `json:"viewURL"`
	IngressTime   string `json:"ingressTime"`
	FileExists    bool   `json:"fileExists"`
	FileSizeBytes int64  `json:"fileSizeBytes,omitempty"`
	DocumentDate  string `json:"documentDate,omitempty"`
}

DocumentStatus represents the status information for a document

type LogEntry added in v0.23.0

type LogEntry struct {
	Level   string                 `json:"level"`
	Message string                 `json:"message"`
	Attrs   map[string]interface{} `json:"attrs"`
}

LogEntry represents a log entry from the frontend

type SearchResponse added in v0.34.0

type SearchResponse struct {
	Documents   []database.Document `json:"documents"`
	Page        int                 `json:"page"`
	PageSize    int                 `json:"pageSize"`
	TotalCount  int                 `json:"totalCount"`
	TotalPages  int                 `json:"totalPages"`
	HasNext     bool                `json:"hasNext"`
	HasPrevious bool                `json:"hasPrevious"`
	Query       string              `json:"query"`
	SearchName  string              `json:"searchName,omitempty"`
}

SearchResponse represents the response from search execution

type ServerHandler

type ServerHandler struct {
	DB           database.Repository
	Echo         *echo.Echo
	ServerConfig config.ServerConfig
}

ServerHandler will inject the variables needed into routes

func (*ServerHandler) AddDocumentTag added in v0.21.4

func (serverHandler *ServerHandler) AddDocumentTag(c echo.Context) error

AddDocumentTag adds a tag to a document @Summary Add tag to document @Description Associate a tag with a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Param tagId body int true "Tag ID" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags [post]

func (*ServerHandler) AddDocumentViewRoutes

func (serverHandler *ServerHandler) AddDocumentViewRoutes() error

AddDocumentViewRoutes adds all of the current documents to an echo route

func (*ServerHandler) CleanDatabase

func (serverHandler *ServerHandler) CleanDatabase(c echo.Context) error

CleanDatabase checks all documents and removes entries for missing files, and moves orphaned files (not in database) back to ingress for reprocessing @Summary Clean database @Description Remove database entries for missing files and move orphaned files to ingress @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Job created with jobId" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /clean [post]

func (*ServerHandler) CreateFolder

func (serverHandler *ServerHandler) CreateFolder(context echo.Context) error

CreateFolder creates a folder in the document tree @Summary Create a new folder @Description Create a new folder in the document filesystem @Tags Folders @Accept json @Produce json @Param folder query string true "Folder name" @Param path query string true "Parent path" @Success 200 {string} string "Full folder path created" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /folder [post]

func (*ServerHandler) CreateSavedSearch added in v0.34.0

func (serverHandler *ServerHandler) CreateSavedSearch(c echo.Context) error

CreateSavedSearch creates a new saved search @Summary Create a saved search @Description Create a new saved search @Tags Searches @Accept json @Produce json @Param search body database.SavedSearch true "Saved search object" @Success 201 {object} database.SavedSearch @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/saved-searches [post]

func (*ServerHandler) CreateTag added in v0.21.4

func (serverHandler *ServerHandler) CreateTag(c echo.Context) error

CreateTag creates a new tag @Summary Create a new tag @Description Create a new tag @Tags Tags @Accept json @Produce json @Param tag body database.Tag true "Tag object" @Success 201 {object} database.Tag @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags [post]

func (*ServerHandler) DeleteFile

func (serverHandler *ServerHandler) DeleteFile(context echo.Context) error

DeleteFile deletes a folder or file from the database (and all children if folder) (and on disc and from bleve search if document) @Summary Delete a file or folder @Description Deletes a document or folder from the system, including database entry and physical file @Tags Documents @Accept json @Produce json @Param id query string false "Document ULID" @Param path query string false "File path relative to document root" @Success 200 {string} string "Document Deleted" or "Folder Deleted" @Failure 404 {object} map[string]interface{} "File not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document [delete]

func (*ServerHandler) DeleteSavedSearch added in v0.34.0

func (serverHandler *ServerHandler) DeleteSavedSearch(c echo.Context) error

DeleteSavedSearch deletes a saved search @Summary Delete a saved search @Description Delete a saved search by ID @Tags Searches @Accept json @Produce json @Param id path int true "Search ID" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 403 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/saved-searches/{id} [delete]

func (*ServerHandler) DeleteTag added in v0.21.4

func (serverHandler *ServerHandler) DeleteTag(c echo.Context) error

DeleteTag deletes a tag @Summary Delete a tag @Description Delete a tag and remove it from all documents @Tags Tags @Accept json @Produce json @Param id path int true "Tag ID" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags/{id} [delete]

func (*ServerHandler) ExecuteAdHocSearch added in v0.34.0

func (serverHandler *ServerHandler) ExecuteAdHocSearch(c echo.Context) error

ExecuteAdHocSearch executes an ad-hoc search query @Summary Execute an ad-hoc search @Description Execute a search query and return paginated results @Tags Searches @Accept json @Produce json @Param q query string true "Search query" @Param page query int false "Page number" default(1) @Param pageSize query int false "Page size" default(20) @Success 200 {object} SearchResponse @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/search/query [get]

func (*ServerHandler) ExecuteSavedSearch added in v0.34.0

func (serverHandler *ServerHandler) ExecuteSavedSearch(c echo.Context) error

ExecuteSavedSearch executes a saved search by ID @Summary Execute a saved search @Description Execute a saved search and return paginated results @Tags Searches @Accept json @Produce json @Param id path int true "Search ID" @Param page query int false "Page number" default(1) @Param pageSize query int false "Page size" default(20) @Success 200 {object} SearchResponse @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/saved-searches/{id}/execute [get]

func (*ServerHandler) GetAboutInfo

func (serverHandler *ServerHandler) GetAboutInfo(c echo.Context) error

GetAboutInfo returns information about the application configuration @Summary Get application information @Description Retrieve information about the application configuration, version, and database @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Application information" @Router /about [get]

func (*ServerHandler) GetActiveJobs

func (serverHandler *ServerHandler) GetActiveJobs(c echo.Context) error

GetActiveJobs retrieves all currently running or pending jobs @Summary Get active jobs @Description Retrieve all jobs that are currently running or pending @Tags Jobs @Accept json @Produce json @Success 200 {array} database.Job "List of active jobs" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /jobs/active [get]

func (*ServerHandler) GetAllDimensions added in v0.21.4

func (serverHandler *ServerHandler) GetAllDimensions(c echo.Context) error

GetAllDimensions returns all dimension definitions with their values @Summary Get all dimensions @Description Retrieve all dimension types and their possible values @Tags Dimensions @Accept json @Produce json @Success 200 {array} database.DimensionWithValues @Failure 500 {object} map[string]interface{} @Router /api/dimensions [get]

func (*ServerHandler) GetAllSavedSearches added in v0.34.0

func (serverHandler *ServerHandler) GetAllSavedSearches(c echo.Context) error

GetAllSavedSearches returns all saved searches with document counts @Summary Get all saved searches @Description Retrieve all saved searches with their document counts @Tags Searches @Accept json @Produce json @Success 200 {array} database.SavedSearchWithCount @Failure 500 {object} map[string]interface{} @Router /api/saved-searches [get]

func (*ServerHandler) GetAllTags added in v0.21.4

func (serverHandler *ServerHandler) GetAllTags(c echo.Context) error

GetAllTags returns all available tags @Summary Get all tags @Description Retrieve all tags in the system @Tags Tags @Accept json @Produce json @Success 200 {array} database.Tag @Failure 500 {object} map[string]interface{} @Router /api/tags [get]

func (*ServerHandler) GetAllTagsWithUsage added in v0.33.0

func (serverHandler *ServerHandler) GetAllTagsWithUsage(c echo.Context) error

GetAllTagsWithUsage returns all tags with their document usage counts @Summary Get all tags with usage counts @Description Retrieve all tags with the number of documents using each tag @Tags Tags @Accept json @Produce json @Success 200 {array} TagWithUsage @Failure 500 {object} map[string]interface{} @Router /api/tags/usage [get]

func (*ServerHandler) GetDocument

func (serverHandler *ServerHandler) GetDocument(context echo.Context) error

GetDocument will return a document by ULID @Summary Get a document by ID @Description Retrieve document details by ULID @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Success 200 {object} database.Document "Document details" @Failure 404 {object} map[string]interface{} "Document not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/{id} [get]

func (*ServerHandler) GetDocumentDimensions added in v0.21.4

func (serverHandler *ServerHandler) GetDocumentDimensions(c echo.Context) error

GetDocumentDimensions returns dimension values for a specific document @Summary Get document dimensions @Description Get all dimension values assigned to a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Success 200 {object} map[string]database.DimensionValue @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions [get]

func (*ServerHandler) GetDocumentFileSystem

func (serverHandler *ServerHandler) GetDocumentFileSystem(context echo.Context) error

GetDocumentFileSystem will scan the document folder and get the complete tree to send to the frontend @Summary Get document filesystem tree @Description Retrieve the complete document folder structure as a tree @Tags Documents @Accept json @Produce json @Success 200 {object} fullFileSystem "Complete filesystem tree" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /documents/filesystem [get]

func (*ServerHandler) GetDocumentStatus added in v0.32.0

func (serverHandler *ServerHandler) GetDocumentStatus(context echo.Context) error

GetDocumentStatus returns status information about a document @Summary Get document status @Description Get status information including thumbnail, text, and tag availability @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Success 200 {object} DocumentStatus "Document status" @Failure 404 {object} map[string]string "Document not found" @Failure 500 {object} map[string]string "Internal server error" @Router /api/document/{id}/status [get]

func (*ServerHandler) GetDocumentTags added in v0.21.4

func (serverHandler *ServerHandler) GetDocumentTags(c echo.Context) error

GetDocumentTags returns all tags for a specific document @Summary Get document tags @Description Get all tags associated with a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Success 200 {array} database.Tag @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags [get]

func (*ServerHandler) GetDocumentText added in v0.32.0

func (serverHandler *ServerHandler) GetDocumentText(context echo.Context) error

GetDocumentText returns the extracted text content of a document @Summary Get document text @Description Get the extracted full text content of a document @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Success 200 {object} map[string]string "Document text" @Failure 404 {object} map[string]string "Document not found or no text available" @Router /api/document/{id}/text [get]

func (*ServerHandler) GetDocumentThumbnail added in v0.19.3

func (serverHandler *ServerHandler) GetDocumentThumbnail(context echo.Context) error

GetDocumentThumbnail serves the thumbnail image for a document @Summary Get document thumbnail @Description Get a thumbnail image for a document by its ID @Tags Documents @Produce image/jpeg @Param id path string true "Document ULID" @Success 200 {file} binary "Thumbnail image" @Failure 404 {object} map[string]string "Thumbnail not found" @Failure 500 {object} map[string]string "Internal server error" @Router /api/document/{id}/thumbnail [get]

func (*ServerHandler) GetDocumentsByTag added in v0.34.0

func (serverHandler *ServerHandler) GetDocumentsByTag(c echo.Context) error

GetDocumentsByTag returns documents with a specific tag @Summary Get documents by tag @Description Get paginated documents that have a specific tag @Tags Searches @Accept json @Produce json @Param tagId path int true "Tag ID" @Param page query int false "Page number" default(1) @Param pageSize query int false "Page size" default(20) @Success 200 {object} SearchResponse @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/by-tag/{tagId} [get]

func (*ServerHandler) GetFolder

func (serverHandler *ServerHandler) GetFolder(context echo.Context) error

GetFolder fetches all the documents in the folder @Summary Get folder contents @Description Retrieve all documents in a specific folder @Tags Folders @Accept json @Produce json @Param folder path string true "Folder name" @Success 200 {array} database.Document "List of documents in folder" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /folder/{folder} [get]

func (*ServerHandler) GetJob

func (serverHandler *ServerHandler) GetJob(c echo.Context) error

GetJob retrieves a job by ID @Summary Get job by ID @Description Retrieve details of a specific job by its ID @Tags Jobs @Accept json @Produce json @Param id path string true "Job ID (ULID)" @Success 200 {object} database.Job "Job details" @Failure 400 {object} map[string]interface{} "Invalid job ID" @Failure 404 {object} map[string]interface{} "Job not found" @Router /jobs/{id} [get]

func (*ServerHandler) GetLatestDocuments

func (serverHandler *ServerHandler) GetLatestDocuments(context echo.Context) error

GetLatestDocuments gets the latest documents that were ingressed @Summary Get latest documents @Description Retrieve the most recently ingested documents with pagination @Tags Documents @Accept json @Produce json @Param page query int false "Page number (default: 1)" @Success 200 {object} map[string]interface{} "Paginated documents with metadata" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /documents/latest [get]

func (*ServerHandler) GetRecentJobs

func (serverHandler *ServerHandler) GetRecentJobs(c echo.Context) error

GetRecentJobs retrieves recent jobs with pagination @Summary Get recent jobs @Description Retrieve a list of recent jobs with pagination @Tags Jobs @Accept json @Produce json @Param limit query int false "Number of jobs to return (default: 20)" @Param offset query int false "Offset for pagination (default: 0)" @Success 200 {array} database.Job "List of jobs" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /jobs [get]

func (*ServerHandler) GetSavedSearch added in v0.34.0

func (serverHandler *ServerHandler) GetSavedSearch(c echo.Context) error

GetSavedSearch returns a single saved search by ID @Summary Get a saved search @Description Retrieve a saved search by ID @Tags Searches @Accept json @Produce json @Param id path int true "Search ID" @Success 200 {object} database.SavedSearch @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/saved-searches/{id} [get]

func (*ServerHandler) GetTagGroups added in v0.33.1

func (serverHandler *ServerHandler) GetTagGroups(c echo.Context) error

GetTagGroups returns a list of distinct tag groups @Summary Get tag groups @Description Retrieve all distinct tag group names @Tags Tags @Accept json @Produce json @Success 200 {array} string @Failure 500 {object} map[string]interface{} @Router /api/tags/groups [get]

func (*ServerHandler) GetUntaggedDocuments added in v0.34.0

func (serverHandler *ServerHandler) GetUntaggedDocuments(c echo.Context) error

GetUntaggedDocuments returns documents without any tags @Summary Get untagged documents @Description Get paginated documents that have no tags (Inbox) @Tags Searches @Accept json @Produce json @Param page query int false "Page number" default(1) @Param pageSize query int false "Page size" default(20) @Success 200 {object} SearchResponse @Failure 500 {object} map[string]interface{} @Router /api/documents/untagged [get]

func (*ServerHandler) GetWordCloud

func (serverHandler *ServerHandler) GetWordCloud(c echo.Context) error

GetWordCloud returns the top N most frequent words for word cloud visualization @Summary Get word cloud data @Description Retrieve the top N most frequent words from all documents for word cloud visualization @Tags WordCloud @Accept json @Produce json @Param limit query int false "Maximum number of words to return (default: 100, max: 500)" @Success 200 {object} map[string]interface{} "Word cloud data with words, metadata, and count" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /wordcloud [get]

func (*ServerHandler) IngestDocumentWithSteps

func (serverHandler *ServerHandler) IngestDocumentWithSteps(filePath string, db database.Repository, jobID ulid.ULID, fileNum, totalFiles int) error

IngestDocumentWithSteps processes a document through explicit steps with progress tracking Step 1: Calculate hash and create initial database record Step 2: Move file to documents folder and verify hash Step 3: Extract text and update search/wordcloud

func (*ServerHandler) InitializeSchedules

func (serverHandler *ServerHandler) InitializeSchedules(db database.Repository)

InitializeSchedules starts all the cron jobs (currently just one)

func (*ServerHandler) LogFromFrontend added in v0.23.0

func (serverHandler *ServerHandler) LogFromFrontend(c echo.Context) error

LogFromFrontend receives and logs messages from the frontend using slog @Summary Log from frontend @Description Accept log entries from the frontend and log them using slog with proper structure @Tags Admin @Accept json @Produce json @Param logEntry body LogEntry true "Log entry from frontend" @Success 200 {object} map[string]string "Log entry recorded" @Failure 400 {object} map[string]string "Invalid log format" @Router /api/log [post]

func (*ServerHandler) LookupDocument added in v0.43.1

func (serverHandler *ServerHandler) LookupDocument(c echo.Context) error

LookupDocument finds a document by hash (for import tools to locate uploaded documents). GET /api/document/lookup?hash=<md5hash>

func (*ServerHandler) MoveDocuments

func (serverHandler *ServerHandler) MoveDocuments(context echo.Context) error

MoveDocuments will accept an API call from the frontend to move a document or documents @Summary Move documents to a new folder @Description Move one or more documents to a different folder in the document tree @Tags Documents @Accept json @Produce json @Param folder query string true "Target folder path" @Param id query []string true "Document ULID(s) to move" @Success 200 {string} string "Ok" @Failure 400 {object} map[string]interface{} "Bad request" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/move [patch]

func (*ServerHandler) RecalculateWordCloud

func (serverHandler *ServerHandler) RecalculateWordCloud(c echo.Context) error

RecalculateWordCloud triggers a full recalculation of word frequencies @Summary Recalculate word cloud @Description Trigger a full recalculation of word frequencies from all documents @Tags WordCloud @Accept json @Produce json @Success 200 {object} map[string]interface{} "Recalculation started" @Router /wordcloud/recalculate [post]

func (*ServerHandler) RegenerateThumbnail added in v0.32.1

func (serverHandler *ServerHandler) RegenerateThumbnail(context echo.Context) error

RegenerateThumbnail regenerates the thumbnail for a document @Summary Regenerate document thumbnail @Description Force regeneration of thumbnail for a PDF document @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Success 200 {object} map[string]string "Thumbnail regenerated" @Failure 400 {object} map[string]string "Document is not a PDF" @Failure 404 {object} map[string]string "Document not found" @Failure 500 {object} map[string]string "Failed to regenerate thumbnail" @Router /api/document/{id}/thumbnail/regenerate [post]

func (*ServerHandler) ReindexSearchDocuments

func (serverHandler *ServerHandler) ReindexSearchDocuments(context echo.Context) error

ReindexSearchDocuments reindexes all documents for full-text search @Summary Reindex search documents @Description Rebuild the full-text search index for all documents @Tags Search @Accept json @Produce json @Success 200 {object} map[string]interface{} "Reindex successful" @Failure 500 {object} map[string]interface{} "Reindex failed" @Router /search/reindex [post]

func (*ServerHandler) RemoveDocumentDimension added in v0.21.4

func (serverHandler *ServerHandler) RemoveDocumentDimension(c echo.Context) error

RemoveDocumentDimension removes a dimension value from a document @Summary Remove document dimension @Description Remove a dimension value assignment from a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Param dimensionName path string true "Dimension name" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions/{dimensionName} [delete]

func (*ServerHandler) RemoveDocumentTag added in v0.21.4

func (serverHandler *ServerHandler) RemoveDocumentTag(c echo.Context) error

RemoveDocumentTag removes a tag from a document @Summary Remove tag from document @Description Remove a tag association from a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Param tagId path int true "Tag ID" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags/{tagId} [delete]

func (*ServerHandler) RescanOrphanedDocument added in v0.33.3

func (serverHandler *ServerHandler) RescanOrphanedDocument(filePath string, db database.Repository, seenHashes map[string]string) (string, error)

RescanOrphanedDocument imports a file that exists on disk but not in the database. Unlike regular ingestion, this does NOT move the file - it imports it in-place. Returns the file's hash for duplicate tracking.

func (*ServerHandler) RotateDocument added in v0.46.0

func (serverHandler *ServerHandler) RotateDocument(c echo.Context) error

RotateDocument rotates a document file in place and regenerates derived data. POST /api/document/:id/rotate Body: {"degrees": 90}

func (*ServerHandler) RunCleanupAsync added in v0.38.0

func (sh *ServerHandler) RunCleanupAsync() (*database.Job, error)

RunCleanupAsync creates a cleanup job and runs it in a background goroutine.

func (*ServerHandler) RunIngestNow

func (serverHandler *ServerHandler) RunIngestNow(c echo.Context) error

RunIngestNow triggers the ingestion process manually @Summary Trigger document ingestion @Description Manually trigger the document ingestion process to process files in the ingress folder @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Job created with job ID" @Router /ingest [post]

func (*ServerHandler) RunIngestionAsync added in v0.38.0

func (sh *ServerHandler) RunIngestionAsync() (*database.Job, error)

RunIngestionAsync creates an ingestion job and runs it in a background goroutine.

func (*ServerHandler) SearchDocuments

func (serverHandler *ServerHandler) SearchDocuments(context echo.Context) error

SearchDocuments will take the search terms and search all documents using PostgreSQL full-text search @Summary Search documents @Description Search all documents using PostgreSQL full-text search @Tags Search @Accept json @Produce json @Param term query string true "Search term" @Success 200 {object} fullFileSystem "Search results" @Success 204 "No results found" @Failure 404 {string} string "Empty search term" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /search [get]

func (*ServerHandler) SetDocumentDimension added in v0.21.4

func (serverHandler *ServerHandler) SetDocumentDimension(c echo.Context) error

SetDocumentDimension sets a dimension value for a document @Summary Set document dimension @Description Set or update a dimension value for a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Param dimension body object true "Dimension assignment" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions [post]

func (*ServerHandler) StartupChecks

func (serverHandler *ServerHandler) StartupChecks() error

StartupChecks performs all the checks to make sure everything works

func (*ServerHandler) UpdateDocumentDate added in v0.42.1

func (serverHandler *ServerHandler) UpdateDocumentDate(c echo.Context) error

UpdateDocumentDate updates the document date of a document

func (*ServerHandler) UpdateDocumentMetadata added in v0.43.0

func (serverHandler *ServerHandler) UpdateDocumentMetadata(c echo.Context) error

UpdateDocumentMetadata updates import metadata fields (author, source, dates, etc.) Also generates a thumbnail if one doesn't already exist.

func (*ServerHandler) UpdateDocumentOCR added in v0.45.1

func (serverHandler *ServerHandler) UpdateDocumentOCR(c echo.Context) error

UpdateDocumentOCR sets the OCR/extracted text for a document. Writes the .ocr.txt sidecar file on disk and updates the database full_text field. External tools should use this endpoint instead of writing sidecar files directly.

@Summary Set document OCR text @Description Set or replace the extracted text for a document. Writes the sidecar file and updates search index. @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Param body body object true "OCR text" example({"text":"extracted text content"}) @Success 200 {object} map[string]string "Text updated" @Failure 400 {object} map[string]string "Invalid request" @Failure 404 {object} map[string]string "Document not found" @Failure 500 {object} map[string]string "Internal server error" @Router /api/document/{id}/ocr [put]

func (*ServerHandler) UpdateDocumentText added in v0.42.1

func (serverHandler *ServerHandler) UpdateDocumentText(c echo.Context) error

UpdateDocumentText updates the full text of a document

func (*ServerHandler) UpdateSavedSearch added in v0.34.0

func (serverHandler *ServerHandler) UpdateSavedSearch(c echo.Context) error

UpdateSavedSearch updates an existing saved search @Summary Update a saved search @Description Update saved search properties @Tags Searches @Accept json @Produce json @Param id path int true "Search ID" @Param search body database.SavedSearch true "Saved search object" @Success 200 {object} database.SavedSearch @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/saved-searches/{id} [put]

func (*ServerHandler) UpdateTag added in v0.21.4

func (serverHandler *ServerHandler) UpdateTag(c echo.Context) error

UpdateTag updates an existing tag @Summary Update a tag @Description Update tag properties @Tags Tags @Accept json @Produce json @Param id path int true "Tag ID" @Param tag body database.Tag true "Tag object" @Success 200 {object} database.Tag @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags/{id} [put]

func (*ServerHandler) UploadDocuments

func (serverHandler *ServerHandler) UploadDocuments(context echo.Context) error

UploadDocuments handles documents uploaded from the frontend @Summary Upload a document @Description Upload a new document file to the ingress folder for processing @Tags Documents @Accept multipart/form-data @Produce json @Param path formData string false "Upload path (relative to ingress folder)" @Param file formData file true "Document file to upload" @Success 200 {string} string "Path to uploaded file" @Failure 400 {object} map[string]interface{} "Bad request" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/upload [post]

func (*ServerHandler) ViewDocument added in v0.29.0

func (serverHandler *ServerHandler) ViewDocument(context echo.Context) error

ViewDocument serves the actual document file by ULID @Summary View/download a document file @Description Serve the actual document file for viewing or download @Tags Documents @Produce application/pdf,image/png,image/jpeg,application/octet-stream @Param ulid path string true "Document ULID" @Success 200 {file} binary "Document file" @Failure 404 {object} map[string]interface{} "Document not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/view/{ulid} [get]

type TagWithUsage added in v0.33.0

type TagWithUsage struct {
	database.Tag
	UsageCount int `json:"usageCount"`
}

TagWithUsage represents a tag with its usage count

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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