2025-01-24 16:12:25 +00:00
|
|
|
package document
|
|
|
|
|
|
|
|
|
|
import (
|
2025-12-11 14:25:51 +00:00
|
|
|
"time"
|
|
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
"queryorchestration/internal/serviceconfig"
|
2025-01-24 16:12:25 +00:00
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
2025-12-11 14:25:51 +00:00
|
|
|
// DocumentSummary contains minimal document identification info.
|
2025-03-17 18:14:15 +00:00
|
|
|
type DocumentSummary struct {
|
2025-03-10 11:03:00 +00:00
|
|
|
ID uuid.UUID
|
2025-04-02 18:50:03 +00:00
|
|
|
ClientID string
|
2025-03-10 11:03:00 +00:00
|
|
|
Hash string
|
2025-01-24 16:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-11 14:25:51 +00:00
|
|
|
// DocumentExternal contains document info with computed fields for external API responses.
|
2025-03-17 18:14:15 +00:00
|
|
|
type DocumentExternal struct {
|
|
|
|
|
Id uuid.UUID
|
|
|
|
|
ClientID string
|
|
|
|
|
Hash string
|
|
|
|
|
Fields map[string]interface{}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 14:25:51 +00:00
|
|
|
// DocumentEnriched contains full document details including metadata, labels, and optionally text record.
|
|
|
|
|
// Used by GET /document/{id} endpoint.
|
|
|
|
|
type DocumentEnriched struct {
|
|
|
|
|
ID uuid.UUID
|
|
|
|
|
ClientID string
|
|
|
|
|
Hash string
|
|
|
|
|
Fields map[string]interface{}
|
|
|
|
|
HasTextRecord bool
|
|
|
|
|
FolderID *uuid.UUID
|
|
|
|
|
Filename *string
|
|
|
|
|
OriginalPath *string
|
|
|
|
|
Labels []LabelRecord
|
|
|
|
|
TextRecord *TextRecord // Only populated when includeTextRecord=true
|
2026-01-12 17:46:07 +00:00
|
|
|
FileSizeBytes *int64 // File size in bytes (nil for legacy documents)
|
2025-12-11 14:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LabelRecord represents a label applied to a document.
|
|
|
|
|
type LabelRecord struct {
|
|
|
|
|
ID uuid.UUID
|
|
|
|
|
DocumentID uuid.UUID
|
|
|
|
|
Label string
|
|
|
|
|
AppliedBy string
|
|
|
|
|
AppliedAt time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TextRecord represents the field extraction response for a document.
|
|
|
|
|
// This mirrors the FieldExtractionResponse from the API.
|
|
|
|
|
type TextRecord struct {
|
|
|
|
|
ID uuid.UUID
|
|
|
|
|
DocumentID uuid.UUID
|
|
|
|
|
Version int32
|
|
|
|
|
SingleFields interface{}
|
|
|
|
|
ArrayFields interface{}
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
CreatedBy string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Service provides document-related operations.
|
2025-01-24 16:12:25 +00:00
|
|
|
type Service struct {
|
2025-01-31 13:43:55 +00:00
|
|
|
cfg serviceconfig.ConfigProvider
|
2025-01-24 16:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-11 14:25:51 +00:00
|
|
|
// New creates a new Document service instance.
|
2025-01-31 13:43:55 +00:00
|
|
|
func New(cfg serviceconfig.ConfigProvider) *Service {
|
2025-01-24 16:12:25 +00:00
|
|
|
return &Service{
|
2025-01-31 13:43:55 +00:00
|
|
|
cfg,
|
2025-01-24 16:12:25 +00:00
|
|
|
}
|
|
|
|
|
}
|