17fc813823
M1, M2 and M3 complete * M1, M2 and M3 complete * review changes * docs * docs
83 lines
2.4 KiB
Go
83 lines
2.4 KiB
Go
package document
|
|
|
|
import (
|
|
"time"
|
|
|
|
"queryorchestration/internal/serviceconfig"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// DocumentSummary contains minimal document identification info.
|
|
type DocumentSummary struct {
|
|
ID uuid.UUID
|
|
ClientID string
|
|
Hash string
|
|
}
|
|
|
|
// DocumentExternal contains document info for external API responses.
|
|
// Note: Query functionality (Fields) has been removed. See remove_query_plan.md for details.
|
|
type DocumentExternal struct {
|
|
Id uuid.UUID
|
|
ClientID string
|
|
Hash string
|
|
}
|
|
|
|
// DocumentEnriched contains full document details including metadata, labels, and optionally text record.
|
|
// Used by GET /document/{id} endpoint.
|
|
// Note: Query functionality (Fields) has been removed. See remove_query_plan.md for details.
|
|
//
|
|
// Milestone 2.3a adds two fields for the mutable-metadata feature:
|
|
// - CustomSchemaID is the bound schema id (nil when the document has no schema).
|
|
// - HasCustomMetadata is true iff document_custom_metadata has >=1 row for the document.
|
|
//
|
|
// Both values are populated from the extended GetDocumentEnriched query in
|
|
// one round-trip; no follow-up DB call is made.
|
|
type DocumentEnriched struct {
|
|
ID uuid.UUID
|
|
ClientID string
|
|
Hash string
|
|
HasTextRecord bool
|
|
FolderID *uuid.UUID
|
|
Filename *string
|
|
OriginalPath *string
|
|
Labels []LabelRecord
|
|
TextRecord *TextRecord // Only populated when includeTextRecord=true
|
|
FileSizeBytes *int64 // File size in bytes (nil for legacy documents)
|
|
CustomSchemaID *uuid.UUID // Bound schema id (nil = no schema)
|
|
HasCustomMetadata bool // True iff any document_custom_metadata row exists
|
|
}
|
|
|
|
// 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.
|
|
type Service struct {
|
|
cfg serviceconfig.ConfigProvider
|
|
}
|
|
|
|
// New creates a new Document service instance.
|
|
func New(cfg serviceconfig.ConfigProvider) *Service {
|
|
return &Service{
|
|
cfg,
|
|
}
|
|
}
|