UNPKG

capacitor-plugin-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK for Capacitor

195 lines 7.06 kB
import { Point, PartiallyConstructible } from '../utils'; /** Result of OCR text recognition. */ export class OcrResult extends PartiallyConstructible { /** @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'); } } } /**` Generic document field */ export class Field extends PartiallyConstructible { /** @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 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'); } } } (function (Field) { /** Generic Document Type */ class Type extends PartiallyConstructible { /** @param source {@displayType `DeepPartial<Type>`} */ constructor(source = {}) { super(); /** The friendly, human-readable display name of this field type in English. iOS only. */ this.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 */ this.listIndex = null; 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 || (Field = {})); /** Generic document */ export class GenericDocument extends PartiallyConstructible { /** @param source {@displayType `DeepPartial<GenericDocument>`} */ constructor(source = {}) { super(); /** The average confidence in the accuracy of the document recognition result Default is 0 */ this.confidence = 0.0; /** The weight of the confidence. Can be used to calculate the weighted average confidence of two documents. Default is 0 */ this.confidenceWeight = 0.0; 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; } } } (function (GenericDocument) { /** Generic Document Type */ class Type extends PartiallyConstructible { /** @param source {@displayType `DeepPartial<Type>`} */ constructor(source = {}) { super(); /** The friendly, human-readable display name of this document type in English. iOS only. */ this.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 */ this.listIndex = null; 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 || (GenericDocument = {})); //# sourceMappingURL=GenericDocument.js.map