UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

257 lines (236 loc) 7.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OcrResult = exports.GenericDocument = exports.Field = void 0; var _utils = require("../utils"); /** Result of OCR text recognition. */ class OcrResult extends _utils.PartiallyConstructible { /** Maximum number of accumulated frames to inspect before actual result is returned. */ /** Minimum number of accumulated frames that have equal result. */ /** @param source {@displayType `DeepPartial<OcrResult>`} */ constructor(source = {}) { super(); if (source.text !== undefined) { this.text = source.text; } else { throw new Error('text must be present in constructor argument'); } if (source.confidence !== undefined) { this.confidence = source.confidence; } else { throw new Error('confidence must be present in constructor argument'); } } } /** Field validation status. - `UNDEFINED`: Field value was not considered during validation. iOS only - `INVALID`: Field value failed validation. - `VALID`: Field value passed validation. - `CONFIRMED`: Field value was confirmed. */ exports.OcrResult = OcrResult; /**` Generic document field */ class Field extends _utils.PartiallyConstructible { /** The type of the field. */ /** Value of the field. Applicable only to text fields. */ /** Coordinates of the field in the root document coordinate system. Android only. */ /** Field validation status. Applicable only to fields that support some kind of validation. */ /** @param source {@displayType `DeepPartial<Field>`} */ constructor(source = {}) { super(); if (source.type !== undefined) { this.type = new Field.Type(source.type); } else { throw new Error('type must be present in constructor argument'); } if (source.value !== undefined) { this.value = source.value != null ? new OcrResult(source.value) : null; } else { throw new Error('value must be present in constructor argument'); } if (source.polygonInRoot !== undefined) { this.polygonInRoot = source.polygonInRoot.map(it => new _utils.Point(it.x, it.y)); } if (source.validationStatus !== undefined) { this.validationStatus = source.validationStatus != null ? source.validationStatus : null; } else { throw new Error('validationStatus must be present in constructor argument'); } } } exports.Field = Field; (function (_Field) { class Type extends _utils.PartiallyConstructible { /** Local field type name scoped to the containing document type */ /** Unique global field type name prefixed with the document types of all containing documents */ /** Normalized global field type name. Fields in document types derived from the same base document type in the schema will have the same normalized name. */ /** Commonly occurring fields that have the same semantic meaning in different document types will often have a set common type. */ /** The friendly, human-readable display name of this field type in English. iOS only. */ displayText = null; /** A document can contain multiple fields of the same name, the property serves for storing natural order of such fields, null if multiple entries aren't allowed for this field */ listIndex = null; /** @param source {@displayType `DeepPartial<Type>`} */ constructor(source = {}) { super(); if (source.name !== undefined) { this.name = source.name; } else { throw new Error('name must be present in constructor argument'); } if (source.fullName !== undefined) { this.fullName = source.fullName; } else { throw new Error('fullName must be present in constructor argument'); } if (source.normalizedName !== undefined) { this.normalizedName = source.normalizedName; } else { throw new Error('normalizedName must be present in constructor argument'); } if (source.commonType !== undefined) { this.commonType = source.commonType != null ? source.commonType : null; } else { throw new Error('commonType must be present in constructor argument'); } if (source.displayText !== undefined) { this.displayText = source.displayText; } if (source.listIndex !== undefined) { this.listIndex = source.listIndex != null ? source.listIndex : null; } } } _Field.Type = Type; })(Field || (exports.Field = Field = {})); /** Generic document */ class GenericDocument extends _utils.PartiallyConstructible { /** Document type */ /** List of document fields */ /** List of document sub-documents */ /** The average confidence in the accuracy of the document recognition result Default is 0 */ confidence = 0.0; /** The weight of the confidence. Can be used to calculate the weighted average confidence of two documents. Default is 0 */ confidenceWeight = 0.0; /** @param source {@displayType `DeepPartial<GenericDocument>`} */ constructor(source = {}) { super(); if (source.type !== undefined) { this.type = new GenericDocument.Type(source.type); } else { throw new Error('type must be present in constructor argument'); } if (source.fields !== undefined) { this.fields = source.fields.map(it => { return new Field(it); }); } else { throw new Error('fields must be present in constructor argument'); } if (source.children !== undefined) { this.children = source.children.map(it => { return new GenericDocument(it); }); } else { throw new Error('children must be present in constructor argument'); } if (source.confidence !== undefined) { this.confidence = source.confidence; } if (source.confidenceWeight !== undefined) { this.confidenceWeight = source.confidenceWeight; } } } exports.GenericDocument = GenericDocument; (function (_GenericDocument) { class Type extends _utils.PartiallyConstructible { /** Local document type name */ /** Unique global document type name prefixed with the document types of all containing documents */ /** Normalized global document type name. Common document types appearing as child documents in different places will often have the same normalized type name. */ /** The friendly, human-readable display name of this document type in English. iOS only. */ displayText = null; /** A document can contain multiple fields of the same name, the property serves for storing natural order of such fields, null if multiple entries aren't allowed for this field */ listIndex = null; /** @param source {@displayType `DeepPartial<Type>`} */ constructor(source = {}) { super(); if (source.name !== undefined) { this.name = source.name; } else { throw new Error('name must be present in constructor argument'); } if (source.fullName !== undefined) { this.fullName = source.fullName; } else { throw new Error('fullName must be present in constructor argument'); } if (source.normalizedName !== undefined) { this.normalizedName = source.normalizedName; } else { throw new Error('normalizedName must be present in constructor argument'); } if (source.displayText !== undefined) { this.displayText = source.displayText; } if (source.listIndex !== undefined) { this.listIndex = source.listIndex != null ? source.listIndex : null; } } } _GenericDocument.Type = Type; })(GenericDocument || (exports.GenericDocument = GenericDocument = {})); //# sourceMappingURL=GenericDocument.js.map