documents

package
v0.1.0-round1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package documents implements document registration, recovery, and source access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameMatches

type NameMatches struct {
	NormalizedName string
	Total          int
	Documents      []knowledge.DocumentSummary
}

NameMatches describes existing Documents whose normalized display name is equal to a proposed name. Matches are guidance only and never block creation.

type Preflight

type Preflight struct {
	FileName      string
	ByteSize      int
	PageCount     int
	SHA256        string
	SuggestedName string
}

Preflight describes a PDF that passed parser validation without persisting it.

type RegisterCommand

type RegisterCommand struct {
	RequestKey       string
	Operation        knowledge.RegistrationOperation
	TargetDocumentID *uuid.UUID
	DocumentName     string
	OriginalFileName string
	Content          []byte
}

RegisterCommand contains the user intent and uploaded PDF for one registration.

type Service

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

Service owns document registration and access policy across persistence adapters.

func New

func New(repository repository, originals originalStore, parser parser) (*Service, error)

New returns a document module backed by the provided persistence adapters.

func (*Service) FindNameMatches

func (s *Service) FindNameMatches(ctx context.Context, value string, limit int) (NameMatches, error)

FindNameMatches returns bounded, exact normalized-name matches so callers can distinguish creating a separate Document from adding a Version.

func (*Service) GetDocument

func (s *Service) GetDocument(ctx context.Context, documentID uuid.UUID) (knowledge.DocumentDetails, error)

GetDocument returns document details and version history.

func (*Service) ListDocuments

func (s *Service) ListDocuments(ctx context.Context, limit, offset int) ([]knowledge.DocumentSummary, error)

ListDocuments returns one bounded page of documents.

func (*Service) Preflight

func (s *Service) Preflight(ctx context.Context, fileName string, content []byte) (Preflight, error)

Preflight validates a PDF and returns stable metadata without storing it.

func (*Service) Ready

func (s *Service) Ready(ctx context.Context) error

Ready reports whether every dependency required for document requests is available.

func (*Service) RecoverRegistration

func (s *Service) RecoverRegistration(ctx context.Context, requestKey string) (knowledge.UploadRecovery, error)

RecoverRegistration resolves an idempotent upload request after response loss.

func (*Service) Register

func (s *Service) Register(ctx context.Context, command RegisterCommand) (knowledge.Registration, error)

Register validates and stores a PDF before atomically registering its version. If the database write fails, it removes the object only after proving that no committed version references the content-addressed key.

func (*Service) Retry

func (s *Service) Retry(ctx context.Context, runID uuid.UUID, requestKey string) (uuid.UUID, error)

Retry queues one idempotent manual retry for an exhausted transient run.

func (*Service) Source

func (s *Service) Source(ctx context.Context, documentID uuid.UUID, version int) (Source, error)

Source returns an immutable version and the confined path to its original PDF.

type Source

type Source struct {
	Document knowledge.SourceDocument
	Path     string
}

Source identifies an immutable document version and its confined local path.

Jump to

Keyboard shortcuts

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