UNPKG

react-native-scanbot-sdk

Version:

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

334 lines (319 loc) 10.1 kB
import { DeepPartial, PartiallyConstructible } from '../../utils'; /** The customer format used in AUSTRALIA_POST codes. Only relevant for format codes 59 and 62. - `NUMERIC`: The numeric format. - `ALPHA_NUMERIC`: The alphanumeric format. */ export type AustraliaPostCustomerFormat = 'NUMERIC' | 'ALPHA_NUMERIC'; /** Type of MSI plessey checksum algorithm used. - `NONE`: No checksum algorithm used. - `MOD_10`: Mod10 checksum algorithm - `MOD_11_IBM`: Mod11IBM checksum algorithm - `MOD_11_NCR`: Mod11NCR checksum algorithm - `MOD_1010`: Mod1010 checksum algorithm - `MOD_1110_IBM`: Mod1110IBM checksum algorithm - `MOD_1110_NCR`: Mod1110NCR checksum algorithm */ export type MSIPlesseyChecksumAlgorithm = | 'NONE' | 'MOD_10' | 'MOD_11_IBM' | 'MOD_11_NCR' | 'MOD_1010' | 'MOD_1110_IBM' | 'MOD_1110_NCR'; /** GS1_COMPOSITE barcode type handling - `NONE`: The (FNC1) character is simply stripped from the result in barcodes that implement this mode. Do not use. Will be removed in a future release. - `PARSE`: GS1 messages are converted to the machine-readable format per the GS1 spec (the special FNC1 character is converted to ASCII \x1D). The implied 01 AI key is prepended to DataBar results. No validation is performed. - `VALIDATE_STRUCTURE`: Same as PARSE. Additionally, messages containing unknown AI keys, or containing values of incorrect format for known keys, are not returned. - `DECODE_STRUCTURE`: Same as VALIDATE_STRUCTURE, except that GS1 strings are converted to the human-readable format, instead (with parentheses used to wrap AI keys, e.g. (01)123456789). The \x1D character is never used in this representation. - `VALIDATE_FULL`: Full validation including linting and checksums. This is the most strict mode. - `DECODE_FULL`: Same as DECODE_STRUCTURE, but with full validation. */ export type Gs1Handling = | 'NONE' | 'PARSE' | 'VALIDATE_STRUCTURE' | 'DECODE_STRUCTURE' | 'VALIDATE_FULL' | 'DECODE_FULL'; /** Type of barcode document format used. - `AAMVA`: American Association of Motor Vehicle Administrators barcode document - `BOARDING_PASS`: Boarding pass barcode document - `DE_MEDICAL_PLAN`: German medication plan barcode document - `MEDICAL_CERTIFICATE`: German medical certificate barcode document - `ID_CARD_PDF_417`: ID card barcode document - `SEPA`: SEPA barcode (aka GiroCode) document - `SWISS_QR`: Swiss QR barcode document - `VCARD`: VCard barcode document - `GS1`: GS1 barcode document */ export type BarcodeDocumentFormat = | 'AAMVA' | 'BOARDING_PASS' | 'DE_MEDICAL_PLAN' | 'MEDICAL_CERTIFICATE' | 'ID_CARD_PDF_417' | 'SEPA' | 'SWISS_QR' | 'VCARD' | 'GS1'; /** Barcode symbology used. - `AZTEC`: Aztec barcode type - `CODABAR`: Codabar barcode type - `CODE_25`: Code 25 barcode type - `CODE_39`: Code 39 barcode type - `CODE_93`: Code 93 barcode type - `CODE_128`: Code 128 barcode type - `DATA_MATRIX`: Data Matrix barcode type - `EAN_8`: EAN-8 barcode type - `EAN_13`: EAN-13 barcode type - `ITF`: ITF (Interleaved 2 of 5) barcode type - `PDF_417`: PDF417 barcode type - `QR_CODE`: QR Code barcode type - `MICRO_QR_CODE`: Micro QR Code barcode type - `DATABAR`: Databar barcode type - `DATABAR_EXPANDED`: Databar Expanded barcode type - `UPC_A`: UPC-A barcode type - `UPC_E`: UPC-E barcode type - `MSI_PLESSEY`: MSI Plessey barcode type - `IATA_2_OF_5`: IATA 2 of 5 barcode type - `INDUSTRIAL_2_OF_5`: Industrial 2 of 5 barcode type - `USPS_INTELLIGENT_MAIL`: USPS Intelligent Mail (aka USPS OneCode, USPS-STD-11) - `ROYAL_MAIL`: Royal Mail Four-State Customer Code, (aka RM4SCC, CBC, BPO 4 State Code) - `JAPAN_POST`: Japan Post Four-State Barcode - `ROYAL_TNT_POST`: Royal TNT Post Four-State Barcode (aka KIX, Klant IndeX) - `AUSTRALIA_POST`: Australia Post Four-State Customer Code - `DATABAR_LIMITED`: GS1 DataBar Limited - `GS1_COMPOSITE`: GS1 Composite - `MICRO_PDF_417`: Databar micro pdf 417 - `MAXI_CODE`: Maxicode - `RMQR_CODE`: RMQR code - `CODE_11`: Code 11 barcode type - `CODE_32`: Code 32 barcode type */ export type BarcodeFormat = | 'AZTEC' | 'CODABAR' | 'CODE_25' | 'CODE_39' | 'CODE_93' | 'CODE_128' | 'DATA_MATRIX' | 'EAN_8' | 'EAN_13' | 'ITF' | 'PDF_417' | 'QR_CODE' | 'MICRO_QR_CODE' | 'DATABAR' | 'DATABAR_EXPANDED' | 'UPC_A' | 'UPC_E' | 'MSI_PLESSEY' | 'IATA_2_OF_5' | 'INDUSTRIAL_2_OF_5' | 'USPS_INTELLIGENT_MAIL' | 'ROYAL_MAIL' | 'JAPAN_POST' | 'ROYAL_TNT_POST' | 'AUSTRALIA_POST' | 'DATABAR_LIMITED' | 'GS1_COMPOSITE' | 'MICRO_PDF_417' | 'MAXI_CODE' | 'RMQR_CODE' | 'CODE_11' | 'CODE_32'; /** Filter for extended EAN and UPC barcodes. - `NO_FILTER`: EAN and UPC codes are not filtered. Both are returned regardless if they have an extension or not. - `ONLY_WITH_EXTENSIONS`: Only EAN and UPC codes with extensions are returned. - `ONLY_WITHOUT_EXTENSIONS`: Only EAN and UPC codes without extensions are returned. */ export type BarcodesExtensionFilter = | 'NO_FILTER' | 'ONLY_WITH_EXTENSIONS' | 'ONLY_WITHOUT_EXTENSIONS'; /** Configuration of the scanning behavior. */ export class BarcodeRecognizerConfiguration extends PartiallyConstructible { /** List of accepted barcode document formats. */ public acceptedDocumentFormats: BarcodeDocumentFormat[] = []; /** Filter for extended EAN and UPC barcodes. Default is NO_FILTER */ public barcodesExtensionFilter: BarcodesExtensionFilter = 'NO_FILTER'; /** Regular expression filter for barcode text. If the barcode text does not match the regular expression, it will not be scanned. The default is an empty string (setting is turned off). This option overrides `barcodesExtensionFilter` option. Default is "" */ public barcodesRegexFilter: string = ''; /** Optional minimum required text length of the detected barcode. The default is 0 (setting is turned off). NOTE - This feature works on ITF barcodes only. Default is 0 */ public minimumTextLength: number = 0; /** Optional maximum text length of the detected barcode. The default is 0 (setting is turned off). NOTE - This feature works on ITF barcodes only. Default is 0 */ public maximumTextLength: number = 0; /** Optional minimum required quiet zone on the barcode. Measured in modules (the smallest bar size on a barcode). The default is 10. NOTE - This feature works on ITF barcodes only. Default is 10 */ public minimum1DBarcodesQuietZone: number = 10; /** If `true`, check digits for UPC, EAN and MSI Plessey codes are removed from the result. Has no effect if both single and double digit MSI Plessey checksums are enabled. The default is `false`. Default is false */ public stripCheckDigits: boolean = false; /** If `true`, the optional check digit for IATA_2_OF_5 codes is used in validation. The default is `true`. Default is true */ public useIATA2OF5Checksum: boolean = true; /** If `true`, the optional check digit for CODE_11 codes is used in validation. The default is `true`. Default is true */ public useCode11Checksum: boolean = true; /** List of accepted barcode symbologies. */ public barcodeFormats: BarcodeFormat[] = []; /** Checksum algorithm used for MSI Plessey barcodes. The default value is MOD_10. Default is MOD_10 */ public msiPlesseyChecksumAlgorithm: MSIPlesseyChecksumAlgorithm = 'MOD_10'; /** The customer format used in AUSTRALIA_POST codes. The default value is ALPHA_NUMERIC. Default is ALPHA_NUMERIC */ public australiaPostCustomerFormat: AustraliaPostCustomerFormat = 'ALPHA_NUMERIC'; /** If `true`, enables a mode that slightly decreases scanning quality and energy consumption. Increases scanning speed. If `false`, the mode is disabled. The default is `false`. Android only. Default is false */ public lowPowerMode: boolean = false; /** The expected way of handling GS1_COMPOSITE barcodes. Default is PARSE */ public gs1Handling: Gs1Handling = 'PARSE'; /** @param source {@displayType `DeepPartial<BarcodeRecognizerConfiguration>`} */ public constructor(source: DeepPartial<BarcodeRecognizerConfiguration> = {}) { super(); if (source.acceptedDocumentFormats !== undefined) { this.acceptedDocumentFormats = source.acceptedDocumentFormats.map((it) => it); } if (source.barcodesExtensionFilter !== undefined) { this.barcodesExtensionFilter = source.barcodesExtensionFilter; } if (source.barcodesRegexFilter !== undefined) { this.barcodesRegexFilter = source.barcodesRegexFilter; } if (source.minimumTextLength !== undefined) { this.minimumTextLength = source.minimumTextLength; } if (source.maximumTextLength !== undefined) { this.maximumTextLength = source.maximumTextLength; } if (source.minimum1DBarcodesQuietZone !== undefined) { this.minimum1DBarcodesQuietZone = source.minimum1DBarcodesQuietZone; } if (source.stripCheckDigits !== undefined) { this.stripCheckDigits = source.stripCheckDigits; } if (source.useIATA2OF5Checksum !== undefined) { this.useIATA2OF5Checksum = source.useIATA2OF5Checksum; } if (source.useCode11Checksum !== undefined) { this.useCode11Checksum = source.useCode11Checksum; } if (source.barcodeFormats !== undefined) { this.barcodeFormats = source.barcodeFormats.map((it) => it); } if (source.msiPlesseyChecksumAlgorithm !== undefined) { this.msiPlesseyChecksumAlgorithm = source.msiPlesseyChecksumAlgorithm; } if (source.australiaPostCustomerFormat !== undefined) { this.australiaPostCustomerFormat = source.australiaPostCustomerFormat; } if (source.lowPowerMode !== undefined) { this.lowPowerMode = source.lowPowerMode; } if (source.gs1Handling !== undefined) { this.gs1Handling = source.gs1Handling; } } }