Documentation
¶
Index ¶
- Constants
- Variables
- type Adapter
- type AdapterVersion
- type AnalyzeIDDetections
- type Block
- type BoundingBox
- type DatasetConfig
- type DetectedSignature
- type DocumentGroup
- type DocumentJob
- type EvaluationMetrics
- type ExpenseDetection
- type ExpenseDocument
- type ExpenseField
- type ExpenseGroupProperty
- type ExpenseJob
- type Extraction
- type Geometry
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type IdentityDocument
- type IdentityDocumentField
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) AnalyzeDocument(_ context.Context, documentURI string) []Block
- func (b *InMemoryBackend) AnalyzeDocumentWithFeatures(_ context.Context, documentURI string, featureTypes []string, ...) []Block
- func (b *InMemoryBackend) AnalyzeExpense(_ context.Context, documentURI string) []ExpenseDocument
- func (b *InMemoryBackend) AnalyzeID(_ context.Context, documentURIs []string) []IdentityDocument
- func (b *InMemoryBackend) BuildAdapterARN(adapterID string) string
- func (b *InMemoryBackend) BuildAdapterVersionARN(adapterID, version string) string
- func (b *InMemoryBackend) CreateAdapter(ctx context.Context, name, description, autoUpdate string, ...) (*Adapter, error)
- func (b *InMemoryBackend) CreateAdapterVersion(ctx context.Context, adapterID string, tags map[string]string) (*AdapterVersion, error)
- func (b *InMemoryBackend) CreateAdapterVersionWithOptions(ctx context.Context, adapterID string, tags map[string]string, ...) (*AdapterVersion, error)
- func (b *InMemoryBackend) CreateAdapterWithToken(ctx context.Context, name, description, autoUpdate string, ...) (*Adapter, error)
- func (b *InMemoryBackend) DeleteAdapter(ctx context.Context, adapterID string) error
- func (b *InMemoryBackend) DeleteAdapterVersion(ctx context.Context, adapterID, version string) error
- func (b *InMemoryBackend) DetectDocumentText(_ context.Context, documentURI string) []Block
- func (b *InMemoryBackend) GetAdapter(ctx context.Context, adapterID string) (*Adapter, error)
- func (b *InMemoryBackend) GetAdapterVersion(ctx context.Context, adapterID, version string) (*AdapterVersion, error)
- func (b *InMemoryBackend) GetDocumentAnalysis(ctx context.Context, jobID string) (*DocumentJob, error)
- func (b *InMemoryBackend) GetDocumentTextDetection(ctx context.Context, jobID string) (*DocumentJob, error)
- func (b *InMemoryBackend) GetExpenseAnalysis(ctx context.Context, jobID string) (*ExpenseJob, error)
- func (b *InMemoryBackend) GetLendingAnalysis(ctx context.Context, jobID string) (*LendingJob, error)
- func (b *InMemoryBackend) GetLendingAnalysisSummary(ctx context.Context, jobID string) (*LendingJob, error)
- func (b *InMemoryBackend) ListAdapterVersions(ctx context.Context, adapterID string) ([]AdapterVersion, error)
- func (b *InMemoryBackend) ListAdapters(ctx context.Context) []Adapter
- func (b *InMemoryBackend) ListJobs(ctx context.Context) []DocumentJob
- func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Shutdown(ctx context.Context)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartDocumentAnalysis(ctx context.Context, documentURI string) (*DocumentJob, error)
- func (b *InMemoryBackend) StartDocumentAnalysisWithOptions(ctx context.Context, documentURI string, featureTypes []string, ...) (*DocumentJob, error)
- func (b *InMemoryBackend) StartDocumentTextDetection(ctx context.Context, documentURI string) (*DocumentJob, error)
- func (b *InMemoryBackend) StartDocumentTextDetectionWithOptions(ctx context.Context, documentURI string, outputConfig *OutputConfig, ...) (*DocumentJob, error)
- func (b *InMemoryBackend) StartExpenseAnalysis(ctx context.Context, documentURI string) (*ExpenseJob, error)
- func (b *InMemoryBackend) StartExpenseAnalysisWithOptions(ctx context.Context, documentURI string, outputConfig *OutputConfig, ...) (*ExpenseJob, error)
- func (b *InMemoryBackend) StartLendingAnalysis(ctx context.Context, documentURI string) (*LendingJob, error)
- func (b *InMemoryBackend) StartLendingAnalysisWithOptions(ctx context.Context, _ string, outputConfig *OutputConfig, ...) (*LendingJob, error)
- func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
- func (b *InMemoryBackend) UpdateAdapter(ctx context.Context, adapterID, description, autoUpdate string) (*Adapter, error)
- type LendingDetection
- type LendingDocument
- type LendingField
- type LendingJob
- type LendingResult
- type LendingSummary
- type LineItem
- type LineItemGroup
- type NormalizedValue
- type NotificationChannel
- type OutputConfig
- type PageClassification
- type Point
- type Provider
- type QueriesConfig
- type QueryBlock
- type QueryEntry
- type Relationship
- type S3ObjectRef
- type SignatureDetection
- type SplitDocument
- type StorageBackend
- type WarningBlock
Constants ¶
const MaxJobHistory = maxJobHistory
MaxJobHistory is the exported value for testing.
Variables ¶
var ( // ErrJobNotFound is returned when a document job is not found. ErrJobNotFound = awserr.New("InvalidJobIdException", awserr.ErrNotFound) // ErrAdapterNotFound is returned when an adapter is not found. ErrAdapterNotFound = awserr.New("InvalidParameterException", awserr.ErrNotFound) // ErrAdapterVersionNotFound is returned when an adapter version is not found. ErrAdapterVersionNotFound = awserr.New("InvalidParameterException", awserr.ErrNotFound) // ErrValidation is returned when request parameters fail validation. ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter) )
var ErrNilAppContext = errors.New("textract: nil AppContext")
ErrNilAppContext is returned when Init receives a nil AppContext.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
CreationTime time.Time `json:"creationTime"`
Tags map[string]string `json:"tags"`
AdapterID string `json:"adapterId"`
// Region is the store.Table[Adapter] key material -- see the
// DocumentJob.Region doc comment above for why this field exists and is
// excluded from persisted JSON.
Region string `json:"-"`
AdapterName string `json:"adapterName"`
AutoUpdate string `json:"autoUpdate"`
Description string `json:"description"`
ClientRequestToken string `json:"clientRequestToken,omitempty"`
FeatureTypes []string `json:"featureTypes"`
}
Adapter represents a Textract Adapter.
type AdapterVersion ¶
type AdapterVersion struct {
CreationTime time.Time `json:"creationTime"`
Tags map[string]string `json:"tags"`
DatasetConfig *DatasetConfig `json:"datasetConfig,omitempty"`
OutputConfig *OutputConfig `json:"outputConfig,omitempty"`
EvaluationMetrics *EvaluationMetrics `json:"evaluationMetrics,omitempty"`
AdapterVersion string `json:"adapterVersion"`
AdapterID string `json:"adapterId"`
Status string `json:"status"`
StatusMessage string `json:"statusMessage"`
//nolint:revive,staticcheck // KMSKeyId: AWS SDK field name convention
KMSKeyId string `json:"kmsKeyId,omitempty"`
ClientRequestToken string `json:"clientRequestToken,omitempty"`
Region string `json:"-"`
FeatureTypes []string `json:"featureTypes"`
}
AdapterVersion represents a version of a Textract Adapter.
type AnalyzeIDDetections ¶
type AnalyzeIDDetections struct {
Geometry *Geometry `json:"Geometry,omitempty"`
NormalizedValue *NormalizedValue `json:"NormalizedValue,omitempty"`
Text string `json:"Text"`
Confidence float64 `json:"Confidence"`
}
AnalyzeIDDetections holds a detected ID field.
type Block ¶
type Block struct {
RowIndex *int `json:"RowIndex,omitempty"`
ColumnIndex *int `json:"ColumnIndex,omitempty"`
Query *QueryBlock `json:"Query,omitempty"`
Page *int `json:"Page,omitempty"`
Geometry *Geometry `json:"Geometry,omitempty"`
ColumnSpan *int `json:"ColumnSpan,omitempty"`
RowSpan *int `json:"RowSpan,omitempty"`
BlockType string `json:"BlockType"`
SelectionStatus string `json:"SelectionStatus,omitempty"`
Text string `json:"Text"`
ID string `json:"Id"`
TextType string `json:"TextType,omitempty"`
EntityTypes []string `json:"EntityTypes,omitempty"`
Relationships []Relationship `json:"Relationships,omitempty"`
Confidence float64 `json:"Confidence"`
ColumnHeader bool `json:"ColumnHeader,omitempty"`
}
Block represents a detected text element returned by Textract.
type BoundingBox ¶
type BoundingBox struct {
Width float64 `json:"Width"`
Height float64 `json:"Height"`
Left float64 `json:"Left"`
Top float64 `json:"Top"`
}
BoundingBox represents the bounding box of a detected element.
type DatasetConfig ¶
type DatasetConfig struct {
ManifestS3Object *S3ObjectRef `json:"ManifestS3Object,omitempty"`
}
DatasetConfig holds dataset configuration for an adapter version.
type DetectedSignature ¶
type DetectedSignature struct {
Page int `json:"Page"`
}
DetectedSignature describes a detected signature page.
type DocumentGroup ¶
type DocumentGroup struct {
Type string `json:"Type"`
SplitDocuments []SplitDocument `json:"SplitDocuments,omitempty"`
DetectedSignatures []DetectedSignature `json:"DetectedSignatures,omitempty"`
UndetectedSignatures []DetectedSignature `json:"UndetectedSignatures,omitempty"`
}
DocumentGroup groups documents of the same type in a lending summary.
type DocumentJob ¶
type DocumentJob struct {
CreationTime time.Time `json:"creationTime"`
JobID string `json:"jobId"`
// Region is the store.Table[DocumentJob] key material (see jobKey in
// store_setup.go): this backend nests jobs by region, and DocumentJob
// otherwise carries no field recording which region bucket it lives in.
// Excluded from persisted JSON -- persistence.go's DTO-based
// Snapshot/Restore captures Region as a real field instead (Phase 3.3).
Region string `json:"-"`
JobStatus string `json:"jobStatus"`
JobType string `json:"jobType"` // "DocumentAnalysis" or "TextDetection"
Blocks []Block `json:"blocks"`
OutputConfig *OutputConfig `json:"outputConfig,omitempty"`
NotificationChannel *NotificationChannel `json:"notificationChannel,omitempty"`
JobTag string `json:"jobTag,omitempty"`
ClientRequestToken string `json:"clientRequestToken,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
Warnings []WarningBlock `json:"warnings,omitempty"`
}
DocumentJob represents an asynchronous Textract document job.
type EvaluationMetrics ¶
type EvaluationMetrics struct {
F1Score float64 `json:"F1Score"`
Precision float64 `json:"Precision"`
Recall float64 `json:"Recall"`
}
EvaluationMetrics holds model evaluation metrics for an adapter version.
type ExpenseDetection ¶
type ExpenseDetection struct {
Geometry *Geometry `json:"Geometry,omitempty"`
Text string `json:"Text"`
Confidence float64 `json:"Confidence"`
}
ExpenseDetection holds a detected expense field value.
type ExpenseDocument ¶
type ExpenseDocument struct {
Blocks []Block `json:"Blocks"`
SummaryFields []ExpenseField `json:"SummaryFields,omitempty"`
LineItemGroups []LineItemGroup `json:"LineItemGroups,omitempty"`
ExpenseIndex int `json:"ExpenseIndex"`
}
ExpenseDocument represents a single expense document result.
type ExpenseField ¶
type ExpenseField struct {
Type *ExpenseDetection `json:"Type,omitempty"`
LabelDetection *ExpenseDetection `json:"LabelDetection,omitempty"`
ValueDetection *ExpenseDetection `json:"ValueDetection,omitempty"`
Currency *ExpenseDetection `json:"Currency,omitempty"`
GroupProperties []ExpenseGroupProperty `json:"GroupProperties,omitempty"`
PageNumber int `json:"PageNumber"`
}
ExpenseField represents a single field in an expense document.
type ExpenseGroupProperty ¶
type ExpenseGroupProperty struct {
Id string `json:"Id"` //nolint:revive,staticcheck // AWS SDK field name convention
Types []string `json:"Types"`
}
ExpenseGroupProperty describes an expense group membership.
type ExpenseJob ¶
type ExpenseJob struct {
CreationTime time.Time `json:"creationTime"`
JobID string `json:"jobId"`
// Region is the store.Table[ExpenseJob] key material -- see the
// DocumentJob.Region doc comment above for why this field exists and is
// excluded from persisted JSON.
Region string `json:"-"`
JobStatus string `json:"jobStatus"`
ExpenseDocuments []ExpenseDocument `json:"expenseDocuments"`
OutputConfig *OutputConfig `json:"outputConfig,omitempty"`
NotificationChannel *NotificationChannel `json:"notificationChannel,omitempty"`
JobTag string `json:"jobTag,omitempty"`
ClientRequestToken string `json:"clientRequestToken,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
Warnings []WarningBlock `json:"warnings,omitempty"`
}
ExpenseJob represents an asynchronous Textract expense analysis job.
type Extraction ¶
type Extraction struct {
LendingDocument *LendingDocument `json:"LendingDocument,omitempty"`
ExpenseDocument *ExpenseDocument `json:"ExpenseDocument,omitempty"`
}
Extraction holds the extraction results for a single lending page.
type Geometry ¶
type Geometry struct {
BoundingBox *BoundingBox `json:"BoundingBox"`
Polygon []Point `json:"Polygon"`
}
Geometry contains bounding box and polygon for a block.
type Handler ¶
type Handler struct {
Backend StorageBackend
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for Amazon Textract operations.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new Textract handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this Textract instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the Textract action from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource extracts the S3 document URI from the request body.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported Textract operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears all backend state. Implements service.Resettable.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches Textract requests.
type IdentityDocument ¶
type IdentityDocument struct {
Blocks []Block `json:"Blocks"`
IdentityDocumentFields []IdentityDocumentField `json:"IdentityDocumentFields,omitempty"`
DocumentIndex int `json:"DocumentIndex"`
}
IdentityDocument represents a single identity document result.
type IdentityDocumentField ¶
type IdentityDocumentField struct {
Type *AnalyzeIDDetections `json:"Type,omitempty"`
ValueDetection *AnalyzeIDDetections `json:"ValueDetection,omitempty"`
}
IdentityDocumentField holds a single field from an ID document.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory store for Textract jobs.
jobs/expenseJobs/lendingJobs/adapters/adapterVersions were formerly nested by region (outer key = region) so that same-named resources in different regions are fully isolated; each is now a store.Table[T] keyed by a region+id composite (see regionKey in store_setup.go) providing the same isolation. clientTokenToJobID/adapterClientTokenToID remain plain region-nested maps: their values are strings, not *T, so they do not fit store.Table's keyed-by-identity-value shape.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new InMemoryBackend with a background lifecycle context. Prefer NewInMemoryBackendWithContext when a service context is available so delayed job completions are cancelled on shutdown.
func NewInMemoryBackendWithContext ¶
func NewInMemoryBackendWithContext(svcCtx context.Context, accountID, region string) *InMemoryBackend
NewInMemoryBackendWithContext creates a new InMemoryBackend whose delayed job-completion goroutines are tied to svcCtx, so they are cancelled when the service shuts down. If svcCtx is nil, context.Background is used.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the AWS account ID for this backend.
func (*InMemoryBackend) AnalyzeDocument ¶
func (b *InMemoryBackend) AnalyzeDocument(_ context.Context, documentURI string) []Block
AnalyzeDocument performs a synchronous document analysis and returns blocks based on the requested feature types.
func (*InMemoryBackend) AnalyzeDocumentWithFeatures ¶
func (b *InMemoryBackend) AnalyzeDocumentWithFeatures( _ context.Context, documentURI string, featureTypes []string, queries *QueriesConfig, ) []Block
AnalyzeDocumentWithFeatures performs synchronous document analysis using feature types.
func (*InMemoryBackend) AnalyzeExpense ¶
func (b *InMemoryBackend) AnalyzeExpense(_ context.Context, documentURI string) []ExpenseDocument
AnalyzeExpense performs a synchronous expense analysis and returns expense documents.
func (*InMemoryBackend) AnalyzeID ¶
func (b *InMemoryBackend) AnalyzeID(_ context.Context, documentURIs []string) []IdentityDocument
AnalyzeID performs a synchronous ID analysis and returns identity documents.
func (*InMemoryBackend) BuildAdapterARN ¶
func (b *InMemoryBackend) BuildAdapterARN(adapterID string) string
BuildAdapterARN returns the ARN for an adapter (exported for handler use).
func (*InMemoryBackend) BuildAdapterVersionARN ¶
func (b *InMemoryBackend) BuildAdapterVersionARN(adapterID, version string) string
BuildAdapterVersionARN returns the ARN for an adapter version (exported for handler use).
func (*InMemoryBackend) CreateAdapter ¶
func (b *InMemoryBackend) CreateAdapter( ctx context.Context, name, description, autoUpdate string, featureTypes []string, tags map[string]string, ) (*Adapter, error)
CreateAdapter creates a new Textract adapter and returns it.
func (*InMemoryBackend) CreateAdapterVersion ¶
func (b *InMemoryBackend) CreateAdapterVersion( ctx context.Context, adapterID string, tags map[string]string, ) (*AdapterVersion, error)
CreateAdapterVersion creates a new version for an existing adapter.
func (*InMemoryBackend) CreateAdapterVersionWithOptions ¶
func (b *InMemoryBackend) CreateAdapterVersionWithOptions( ctx context.Context, adapterID string, tags map[string]string, datasetConfig *DatasetConfig, outputConfig *OutputConfig, kmsKeyID, clientRequestToken string, ) (*AdapterVersion, error)
CreateAdapterVersionWithOptions creates an adapter version with full options.
func (*InMemoryBackend) CreateAdapterWithToken ¶
func (b *InMemoryBackend) CreateAdapterWithToken( ctx context.Context, name, description, autoUpdate string, featureTypes []string, tags map[string]string, clientRequestToken string, ) (*Adapter, error)
CreateAdapterWithToken creates an adapter with ClientRequestToken dedup.
func (*InMemoryBackend) DeleteAdapter ¶
func (b *InMemoryBackend) DeleteAdapter(ctx context.Context, adapterID string) error
DeleteAdapter removes an adapter and all its versions by ID.
func (*InMemoryBackend) DeleteAdapterVersion ¶
func (b *InMemoryBackend) DeleteAdapterVersion(ctx context.Context, adapterID, version string) error
DeleteAdapterVersion removes a specific adapter version.
func (*InMemoryBackend) DetectDocumentText ¶
func (b *InMemoryBackend) DetectDocumentText(_ context.Context, documentURI string) []Block
DetectDocumentText performs synchronous text detection and returns proper blocks.
func (*InMemoryBackend) GetAdapter ¶
GetAdapter retrieves an adapter by ID.
func (*InMemoryBackend) GetAdapterVersion ¶
func (b *InMemoryBackend) GetAdapterVersion(ctx context.Context, adapterID, version string) (*AdapterVersion, error)
GetAdapterVersion retrieves a specific adapter version.
func (*InMemoryBackend) GetDocumentAnalysis ¶
func (b *InMemoryBackend) GetDocumentAnalysis(ctx context.Context, jobID string) (*DocumentJob, error)
GetDocumentAnalysis retrieves the results of a document analysis job. Returns a clone of the stored job.
func (*InMemoryBackend) GetDocumentTextDetection ¶
func (b *InMemoryBackend) GetDocumentTextDetection(ctx context.Context, jobID string) (*DocumentJob, error)
GetDocumentTextDetection retrieves the results of a text detection job. Returns a clone of the stored job.
func (*InMemoryBackend) GetExpenseAnalysis ¶
func (b *InMemoryBackend) GetExpenseAnalysis(ctx context.Context, jobID string) (*ExpenseJob, error)
GetExpenseAnalysis retrieves the results of an expense analysis job. Returns a deep clone so callers may safely mutate the returned value.
func (*InMemoryBackend) GetLendingAnalysis ¶
func (b *InMemoryBackend) GetLendingAnalysis(ctx context.Context, jobID string) (*LendingJob, error)
GetLendingAnalysis retrieves the results of a lending analysis job. Returns a clone of the stored job.
func (*InMemoryBackend) GetLendingAnalysisSummary ¶
func (b *InMemoryBackend) GetLendingAnalysisSummary(ctx context.Context, jobID string) (*LendingJob, error)
GetLendingAnalysisSummary returns a summary of a lending analysis job.
func (*InMemoryBackend) ListAdapterVersions ¶
func (b *InMemoryBackend) ListAdapterVersions(ctx context.Context, adapterID string) ([]AdapterVersion, error)
ListAdapterVersions returns all versions for a given adapter, sorted by version string.
func (*InMemoryBackend) ListAdapters ¶
func (b *InMemoryBackend) ListAdapters(ctx context.Context) []Adapter
ListAdapters returns a sorted list of all adapters for the request region.
func (*InMemoryBackend) ListJobs ¶
func (b *InMemoryBackend) ListJobs(ctx context.Context) []DocumentJob
ListJobs returns all stored jobs for the request region, sorted by creation time (newest first).
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
ListTagsForResource returns a copy of the tags for an adapter or adapter version. Region is resolved from the ARN, falling back to the context region.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the AWS region for this backend.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all stored resources, resetting the backend to its initial state.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) Shutdown ¶
func (b *InMemoryBackend) Shutdown(ctx context.Context)
Shutdown cancels in-flight delayed job completions and waits for their goroutines to exit, bounded by ctx. It implements the service shutdown contract used by the handler.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartDocumentAnalysis ¶
func (b *InMemoryBackend) StartDocumentAnalysis(ctx context.Context, documentURI string) (*DocumentJob, error)
StartDocumentAnalysis creates an async document analysis job.
func (*InMemoryBackend) StartDocumentAnalysisWithOptions ¶
func (b *InMemoryBackend) StartDocumentAnalysisWithOptions( ctx context.Context, documentURI string, featureTypes []string, queries *QueriesConfig, outputConfig *OutputConfig, jobTag, clientRequestToken string, ) (*DocumentJob, error)
StartDocumentAnalysisWithOptions creates an async document analysis job with full options.
func (*InMemoryBackend) StartDocumentTextDetection ¶
func (b *InMemoryBackend) StartDocumentTextDetection(ctx context.Context, documentURI string) (*DocumentJob, error)
StartDocumentTextDetection creates an async text detection job.
func (*InMemoryBackend) StartDocumentTextDetectionWithOptions ¶
func (b *InMemoryBackend) StartDocumentTextDetectionWithOptions( ctx context.Context, documentURI string, outputConfig *OutputConfig, notificationChannel *NotificationChannel, jobTag, clientRequestToken string, ) (*DocumentJob, error)
StartDocumentTextDetectionWithOptions creates an async text detection job with options.
func (*InMemoryBackend) StartExpenseAnalysis ¶
func (b *InMemoryBackend) StartExpenseAnalysis(ctx context.Context, documentURI string) (*ExpenseJob, error)
StartExpenseAnalysis creates an async expense analysis job.
func (*InMemoryBackend) StartExpenseAnalysisWithOptions ¶
func (b *InMemoryBackend) StartExpenseAnalysisWithOptions( ctx context.Context, documentURI string, outputConfig *OutputConfig, notificationChannel *NotificationChannel, jobTag, clientRequestToken string, ) (*ExpenseJob, error)
StartExpenseAnalysisWithOptions creates an async expense analysis job with full options, including ClientRequestToken dedup: real AWS returns the same JobId when the same token is reused (see the docs on StartExpenseAnalysisInput.ClientRequestToken).
func (*InMemoryBackend) StartLendingAnalysis ¶
func (b *InMemoryBackend) StartLendingAnalysis(ctx context.Context, documentURI string) (*LendingJob, error)
StartLendingAnalysis creates an async lending analysis job.
func (*InMemoryBackend) StartLendingAnalysisWithOptions ¶
func (b *InMemoryBackend) StartLendingAnalysisWithOptions( ctx context.Context, _ string, outputConfig *OutputConfig, notificationChannel *NotificationChannel, jobTag, clientRequestToken string, ) (*LendingJob, error)
StartLendingAnalysisWithOptions creates an async lending analysis job with full options, including ClientRequestToken dedup: real AWS returns the same JobId when the same token is reused (see the docs on StartLendingAnalysisInput.ClientRequestToken).
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
TagResource adds or replaces tags on an adapter or adapter version identified by ARN. Region is resolved from the ARN, falling back to the context region.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
UntagResource removes the specified tag keys from an adapter or adapter version. Region is resolved from the ARN, falling back to the context region.
func (*InMemoryBackend) UpdateAdapter ¶
func (b *InMemoryBackend) UpdateAdapter( ctx context.Context, adapterID, description, autoUpdate string, ) (*Adapter, error)
UpdateAdapter updates mutable fields on an existing adapter.
type LendingDetection ¶
type LendingDetection struct {
Geometry *Geometry `json:"Geometry,omitempty"`
Text string `json:"Text,omitempty"`
SelectionStatus string `json:"SelectionStatus,omitempty"`
Confidence float64 `json:"Confidence"`
}
LendingDetection holds a detected lending field value.
type LendingDocument ¶
type LendingDocument struct {
LendingFields []LendingField `json:"LendingFields,omitempty"`
SignatureDetections []SignatureDetection `json:"SignatureDetections,omitempty"`
}
LendingDocument holds the extracted fields for a lending page.
type LendingField ¶
type LendingField struct {
Type *LendingDetection `json:"Type,omitempty"`
ValueDetection *LendingDetection `json:"ValueDetection,omitempty"`
KeyDetection *LendingDetection `json:"KeyDetection,omitempty"`
PageNumber int `json:"PageNumber"`
}
LendingField is a single field detected in a lending document.
type LendingJob ¶
type LendingJob struct {
CreationTime time.Time `json:"creationTime"`
JobID string `json:"jobId"`
// Region is the store.Table[LendingJob] key material -- see the
// DocumentJob.Region doc comment above for why this field exists and is
// excluded from persisted JSON.
Region string `json:"-"`
JobStatus string `json:"jobStatus"`
Results []LendingResult `json:"results"`
Summary *LendingSummary `json:"summary,omitempty"`
OutputConfig *OutputConfig `json:"outputConfig,omitempty"`
NotificationChannel *NotificationChannel `json:"notificationChannel,omitempty"`
JobTag string `json:"jobTag,omitempty"`
ClientRequestToken string `json:"clientRequestToken,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
Warnings []WarningBlock `json:"warnings,omitempty"`
}
LendingJob represents an asynchronous Textract lending analysis job.
type LendingResult ¶
type LendingResult struct {
PageClassification *PageClassification `json:"PageClassification,omitempty"`
Extractions []Extraction `json:"Extractions,omitempty"`
Page int `json:"Page"`
}
LendingResult represents a single lending analysis result page.
type LendingSummary ¶
type LendingSummary struct {
DocumentGroups []DocumentGroup `json:"DocumentGroups,omitempty"`
UndetectedDocumentTypes []string `json:"UndetectedDocumentTypes,omitempty"`
}
LendingSummary summarizes lending analysis results.
type LineItem ¶
type LineItem struct {
LineItemExpenseFields []ExpenseField `json:"LineItemExpenseFields"`
}
LineItem represents a single line item in an expense document.
type LineItemGroup ¶
type LineItemGroup struct {
LineItems []LineItem `json:"LineItems"`
LineItemGroupIndex int `json:"LineItemGroupIndex"`
}
LineItemGroup represents a group of line items.
type NormalizedValue ¶
NormalizedValue holds a normalized field value.
type NotificationChannel ¶
type NotificationChannel struct {
RoleArn string `json:"RoleArn"`
SNSTopicArn string `json:"SNSTopicArn"`
}
NotificationChannel holds SNS topic configuration.
type OutputConfig ¶
OutputConfig holds S3 output configuration for async jobs.
type PageClassification ¶
type PageClassification struct {
PageType []LendingDetection `json:"PageType"`
PageNumber []LendingDetection `json:"PageNumber"`
}
PageClassification holds the page classification for a lending page.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Amazon Textract.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Textract service backend and handler.
type QueriesConfig ¶
type QueriesConfig struct {
Queries []QueryEntry `json:"Queries"`
}
QueriesConfig holds query configuration for AnalyzeDocument.
type QueryBlock ¶
type QueryBlock struct {
Text string `json:"Text"`
Alias string `json:"Alias"`
Pages []string `json:"Pages"`
}
QueryBlock holds query metadata for QUERY blocks.
type QueryEntry ¶
type QueryEntry struct {
Text string `json:"Text"`
Alias string `json:"Alias"`
Pages []string `json:"Pages"`
}
QueryEntry is a single query with text, alias and page filters.
type Relationship ¶
type Relationship struct {
Type string `json:"Type"`
Ids []string `json:"Ids"` //nolint:revive // AWS SDK field name convention
}
Relationship describes child/value relationships between blocks.
type S3ObjectRef ¶
type S3ObjectRef struct {
Bucket string `json:"Bucket"`
Name string `json:"Name"`
Version string `json:"Version,omitempty"`
}
S3ObjectRef is an S3 object reference.
type SignatureDetection ¶
type SignatureDetection struct {
Geometry *Geometry `json:"Geometry,omitempty"`
Confidence float64 `json:"Confidence"`
}
SignatureDetection represents a detected signature.
type SplitDocument ¶
SplitDocument describes a sub-document within a group.
type StorageBackend ¶
type StorageBackend interface {
AnalyzeDocument(ctx context.Context, documentURI string) []Block
AnalyzeExpense(ctx context.Context, documentURI string) []ExpenseDocument
AnalyzeID(ctx context.Context, documentURIs []string) []IdentityDocument
CreateAdapter(
ctx context.Context,
name, description, autoUpdate string,
featureTypes []string, tags map[string]string,
) (*Adapter, error)
CreateAdapterVersion(ctx context.Context, adapterID string, tags map[string]string) (
*AdapterVersion, error,
)
DeleteAdapter(ctx context.Context, adapterID string) error
DeleteAdapterVersion(ctx context.Context, adapterID, version string) error
DetectDocumentText(ctx context.Context, documentURI string) []Block
GetAdapter(ctx context.Context, adapterID string) (*Adapter, error)
GetAdapterVersion(ctx context.Context, adapterID, version string) (*AdapterVersion, error)
GetDocumentAnalysis(ctx context.Context, jobID string) (*DocumentJob, error)
GetDocumentTextDetection(ctx context.Context, jobID string) (*DocumentJob, error)
GetExpenseAnalysis(ctx context.Context, jobID string) (*ExpenseJob, error)
GetLendingAnalysis(ctx context.Context, jobID string) (*LendingJob, error)
GetLendingAnalysisSummary(ctx context.Context, jobID string) (*LendingJob, error)
ListAdapterVersions(ctx context.Context, adapterID string) ([]AdapterVersion, error)
ListAdapters(ctx context.Context) []Adapter
ListJobs(ctx context.Context) []DocumentJob
ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
Region() string
Reset()
Restore(ctx context.Context, data []byte) error
Snapshot(ctx context.Context) []byte
StartDocumentAnalysis(ctx context.Context, documentURI string) (*DocumentJob, error)
StartDocumentTextDetection(ctx context.Context, documentURI string) (*DocumentJob, error)
StartExpenseAnalysis(ctx context.Context, documentURI string) (*ExpenseJob, error)
StartLendingAnalysis(ctx context.Context, documentURI string) (*LendingJob, error)
TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
UpdateAdapter(ctx context.Context, adapterID, description, autoUpdate string) (
*Adapter, error,
)
}
StorageBackend is the interface for Textract storage operations.
type WarningBlock ¶
WarningBlock represents a warning returned in async job responses.
Source Files
¶
- adapter_versions.go
- adapters.go
- document_analysis.go
- document_detection.go
- errors.go
- expense_analysis.go
- handler.go
- handler_adapter_versions.go
- handler_adapters.go
- handler_document_analysis.go
- handler_document_detection.go
- handler_expense_analysis.go
- handler_id_analysis.go
- handler_lending_analysis.go
- handler_tags.go
- id_analysis.go
- interfaces.go
- lending_analysis.go
- models.go
- persistence.go
- provider.go
- store.go
- store_setup.go
- synthetic_blocks.go
- tags.go