/** * TRP classes for (generic document) key-value form objects */ import { ApiBlockType, ApiRelationshipType } from "./api-models/base"; import { ApiSelectionStatus } from "./api-models/content"; import { ApiKeyBlock, ApiKeyValueSetBlock, ApiValueBlock } from "./api-models/form"; import { AggregationMethod, IApiBlockWrapper, IBlockManager, IDocBlocks, IRenderable, IRenderOpts, PageHostedApiBlockWrapper } from "./base"; import { IWithContent, SelectionElement, Signature, Word } from "./content"; import { Geometry, IWithGeometry } from "./geometry"; declare const FieldKeyGeneric_base: { new (...args: any[]): { getText(opts?: import("./base").IBlockTypeFilterOpts | undefined): string; iterWords({ includeBlockTypes, onUnexpectedBlockType, skipBlockTypes, }?: import("./base").IBlockTypeFilterOpts): Iterable; listWords({ includeBlockTypes, onUnexpectedBlockType, skipBlockTypes, }?: import("./base").IBlockTypeFilterOpts): Word[]; readonly nWords: number; get text(): string; wordAtIndex(ix: number): Word; readonly id: string; readonly blockType: ApiBlockType; readonly childBlockIds: string[]; relatedBlockIdsByRelType(relType: ApiRelationshipType | ApiRelationshipType[]): string[]; _dict: import("./api-models").ApiBlock; readonly dict: import("./api-models").ApiBlock; parentPage: IBlockManager; iterRelatedItemsByRelType(relType: ApiRelationshipType | ApiRelationshipType[], opts?: import("./base").IBlockTypeFilterOpts | undefined): Iterable>; listRelatedItemsByRelType(relType: ApiRelationshipType | ApiRelationshipType[], opts?: import("./base").IBlockTypeFilterOpts | undefined): IApiBlockWrapper[]; }; } & typeof PageHostedApiBlockWrapper; /** * Generic base class for a FieldKey, as the parent Page is not defined here. * * If you're consuming this library, you probably just want to use `document.ts/FieldKey`. */ export declare class FieldKeyGeneric extends FieldKeyGeneric_base implements IRenderable, IWithGeometry> { _geometry: Geometry>; _parentField: FieldGeneric; constructor(block: ApiKeyBlock | ApiKeyValueSetBlock, parentField: FieldGeneric); get geometry(): Geometry>; get parentField(): FieldGeneric; /** * Structural (not text) confidence score of the key/value pair detection * * This score reflects the confidence of the model detecting the key-value relation. For the text * OCR confidence, see the `.getOcrConfidence()` method instead. */ get confidence(): number; /** * Aggregate OCR confidence score of the text in this field key * * This score reflects the aggregated OCR confidence of the text detected in the field key. For * the model's confidence on the key/value relation itself, see `.confidence`. * * @param {AggregationMethod} aggMethod How to combine individual word OCR confidences together * @returns Aggregated confidence, or null if this field key has no content/text */ getOcrConfidence(aggMethod?: AggregationMethod): number | null; /** * The semantic `html()` representation of a field key is just the (HTML-escaped) text */ html({ includeBlockTypes, skipBlockTypes }?: IRenderOpts): string; /** * The `str()` representation of a field key is just the contained text */ str(): string; } declare const FieldValueGeneric_base: { new (...args: any[]): { getText(opts?: import("./base").IBlockTypeFilterOpts | undefined): string; iterContent({ includeBlockTypes, onUnexpectedBlockType, skipBlockTypes, }?: import("./base").IBlockTypeFilterOpts): Iterable; listContent({ includeBlockTypes, onUnexpectedBlockType, skipBlockTypes, }?: import("./base").IBlockTypeFilterOpts): (Word | SelectionElement | Signature)[]; readonly nContentItems: number; get text(): string; readonly id: string; readonly blockType: ApiBlockType; readonly childBlockIds: string[]; relatedBlockIdsByRelType(relType: ApiRelationshipType | ApiRelationshipType[]): string[]; _dict: import("./api-models").ApiBlock; readonly dict: import("./api-models").ApiBlock; parentPage: IBlockManager; iterRelatedItemsByRelType(relType: ApiRelationshipType | ApiRelationshipType[], opts?: import("./base").IBlockTypeFilterOpts | undefined): Iterable>; listRelatedItemsByRelType(relType: ApiRelationshipType | ApiRelationshipType[], opts?: import("./base").IBlockTypeFilterOpts | undefined): IApiBlockWrapper[]; }; } & typeof PageHostedApiBlockWrapper; /** * Generic base class for a FieldValue, as the parent Page is not defined here. * * If you're consuming this library, you probably just want to use `document.ts/FieldValue`. */ export declare class FieldValueGeneric extends FieldValueGeneric_base implements IRenderable, IWithContent, IWithGeometry> { _geometry: Geometry>; _parentField: FieldGeneric; constructor(valueBlock: ApiKeyValueSetBlock | ApiValueBlock, parentField: FieldGeneric); /** * Structural (not text) confidence score of the key/value pair detection * * This score reflects the confidence of the model detecting the key-value relation. For the text * OCR confidence, see the `.getOcrConfidence()` method instead. */ get confidence(): number; get geometry(): Geometry>; /** * A field value is "a checkbox" if it contains one SELECTION_ELEMENT * * Use this to check whether this field value is a checkbox/radio button/etc. Other (text) * content may also be present. */ get isCheckbox(): boolean; /** * Selection status if field value is one SELECTION_ELEMENT, else null * * If the field value contains exactly one SELECTION_ELEMENT, this property returns `true` if * it's SELECTED or `false` if it's NOT_SELECTED. Otherwise, this property returns null. */ get isSelected(): boolean | null; get parentField(): FieldGeneric; /** * Selection status if field value is one SELECTION_ELEMENT, else null * * If the field value contains exactly one SELECTION_ELEMENT, this property returns its * SelectionStatus. Otherwise, null. */ get selectionStatus(): ApiSelectionStatus | null; /** * Aggregate OCR confidence score of the text in this field value * * This score reflects the aggregated OCR confidence of the text detected in the field value. For * the model's confidence on the key/value relation itself, see `.confidence`. * * @param {AggregationMethod} aggMethod How to combine individual word OCR confidences together * @returns Aggregated confidence, or null if this field value has no content/text */ getOcrConfidence(aggMethod?: AggregationMethod): number | null; /** * The semantic `html()` representation of a field value is just the (HTML-escaped) text */ html({ includeBlockTypes, skipBlockTypes }?: IRenderOpts): string; /** * The `str()` representation of a field value is just the contained text */ str(): string; } /** * Generic base class for a Field, as the parent Page is not defined here. * * If you're consuming this library, you probably just want to use `document.ts/Field`. * * TODO: We should probably do away with FieldKeyGeneric and just use this class? * Then it could directly wrap underlying objects */ export declare class FieldGeneric implements IApiBlockWrapper, IRenderable { _key: FieldKeyGeneric; _parentForm: FormGeneric; _value: FieldValueGeneric | null; constructor(keyBlock: ApiKeyBlock | ApiKeyValueSetBlock, parentForm: FormGeneric); get blockType(): ApiBlockType; /** * Overall structural (not text) confidence score of the key/value pair detection * * Note this score describes the model's confidence in the validity of the key-value pair, not * the underlying OCR confidence of the text. (For that, see `.getOcrConfidence()` instead) * * Returns the average structure confidence over whichever of {key} and {value} are present. */ get confidence(): number; get childBlockIds(): string[]; get dict(): ApiKeyBlock | ApiKeyValueSetBlock; get id(): string; /** * Selection status if field value is one SELECTION_ELEMENT, else null * * If the field value contains exactly one SELECTION_ELEMENT, this property returns `true` if * it's SELECTED or `false` if it's NOT_SELECTED. Otherwise, this property returns null. */ get isSelected(): boolean | null; /** * A field is a "checkbox" if its .value contains one SELECTION_ELEMENT * * Use this to check whether this is a checkbox/radio button/etc field. Other (text) content may * also be present. */ get isCheckbox(): boolean; get key(): FieldKeyGeneric; get parentForm(): FormGeneric; get parentPage(): TPage; /** * Selection status if field value is one SELECTION_ELEMENT, else null * * If the field value contains exactly one SELECTION_ELEMENT, this property returns its * SelectionStatus. Otherwise, null. */ get selectionStatus(): ApiSelectionStatus | null; get text(): string; get value(): FieldValueGeneric | null; /** * Aggregate OCR confidence score of the text in this field key and value (whichever are present) * * This score reflects the aggregated OCR confidence of all the text content detected in the * field key and/or value (whichever of the two are present). For the model's confidence on the * key/value relation itself, see `.confidence`. * * @param {AggregationMethod} aggMethod How to combine individual word OCR confidences together * @returns Aggregated confidence, or null if this field has no content/text */ getOcrConfidence(aggMethod?: AggregationMethod): number | null; relatedBlockIdsByRelType(relType: ApiRelationshipType | ApiRelationshipType[]): string[]; /** * The semantic `html()` representation of a form field uses an `` element * * We render a text field, but `disable` it to prevent accidental edits when viewing reports */ html(opts?: IRenderOpts): string; str(): string; } /** * Generic class for a Form, as the parent Page is not defined here. * * If you're consuming this library, you probably just want to use `document.ts/Form`. */ export declare class FormGeneric implements IRenderable { _fields: FieldGeneric[]; _fieldsMap: { [keyText: string]: FieldGeneric; }; _parentPage: TPage; constructor(keyBlocks: Array, parentPage: TPage); get nFields(): number; get parentPage(): TPage; get text(): string; getFieldByKey(key: string): FieldGeneric | null; /** * The semantic `html()` representation of a Form field collection uses a `
` element * * Within the ``, we list out all the individual fields */ html(opts?: IRenderOpts): string; /** * Iterate through the Fields in the Form. * @param skipFieldsWithoutKey Set `true` to skip fields with no field.key (Included by default) * @example * for (const field of form.iterFields()) { * console.log(field?.key.text); * } * @example * const fields = [...form.iterFields()]; */ iterFields(skipFieldsWithoutKey?: boolean): Iterable>; /** * List the Fields in the Form. * @param skipFieldsWithoutKey Set `true` to skip fields with no field.key (Included by default) */ listFields(skipFieldsWithoutKey?: boolean): FieldGeneric[]; /** * List the Fields in the Form with key text containing (case-insensitive) `key` * @param key The text to search for in field keys */ searchFieldsByKey(key: string): FieldGeneric[]; str(): string; } /** * Generic base class for a composite of multiple Forms, as Page and TextractDocument are not defined here. * * If you're consuming this library, you probably just want to use `document.ts/FormsComposite`. * * While a Form is associated with a particular page, the FormsComposite class exposes a similar interface * for querying detected fields across all pages of the document at once. In general, results are analyzed * and presented in page order. */ export declare class FormsCompositeGeneric implements IRenderable { _forms: FormGeneric[]; _parentDocument: TDocument; constructor(forms: FormGeneric[], parentDocument: TDocument); get nFields(): number; get parentDocument(): TDocument; get text(): string; getFieldByKey(key: string): FieldGeneric | null; /** * The semantic `html()` for a composite form uses a `
` of class "form-page" * * Within the container, we render the representation of each page's separate ``. */ html(): string; /** * Iterate through the Fields in all Forms. * @param skipFieldsWithoutKey Set `true` to skip fields with no field.key (Included by default) * @example * for (const field of form.iterFields()) { * console.log(field?.key.text); * } * @example * const fields = [...form.iterFields()]; */ iterFields(skipFieldsWithoutKey?: boolean): Iterable>; /** * List the Fields in all Forms. * @param skipFieldsWithoutKey Set `true` to skip fields with no field.key (Included by default) */ listFields(skipFieldsWithoutKey?: boolean): FieldGeneric[]; /** * List the Fields in the Form with key text containing (case-insensitive) `key` * @param key The text to search for in field keys */ searchFieldsByKey(key: string): FieldGeneric[]; str(): string; } /** * Interface for a (`Page`-like) object that exposes page-level form data */ export interface IWithForm { /** * Parsed Forms (key-value pairs) data */ form: FormGeneric; } /** * Interface for a (`TextractDocument`-like) object that exposes document-level composite form data */ export interface IWithFormsComposite { /** * Parsed Forms (key-value pairs) data */ form: FormsCompositeGeneric; } export {};