From 791b58434593805fd578367250a987375a982341 Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Thu, 7 Nov 2024 10:09:31 -0500 Subject: [PATCH 1/2] Update Types --- lib/client/getHeaders.js | 2 +- lib/types/LineItem.ts | 19 +++++++++++-- lib/types/Vendor.ts | 26 +++++++++++++++--- lib/types/VeryfiDocument.ts | 54 ++++++++++++++++++++++++++++++++++++- package.json | 2 +- test/main.test.js | 5 +++- 6 files changed, 99 insertions(+), 9 deletions(-) diff --git a/lib/client/getHeaders.js b/lib/client/getHeaders.js index d352bb4..fb07244 100644 --- a/lib/client/getHeaders.js +++ b/lib/client/getHeaders.js @@ -8,7 +8,7 @@ const Client = require('../client/constructor'); */ Client.prototype._get_headers = function (has_files = false) { let final_headers = { - "User-Agent": "Node.js Veryfi-Nodejs/1.4.0", + "User-Agent": "Node.js Veryfi-Nodejs/1.4.1", "Accept": "application/json", "Content-Type": "application/json", "Client-Id": this.client_id, diff --git a/lib/types/LineItem.ts b/lib/types/LineItem.ts index 86c6d21..5168b2a 100644 --- a/lib/types/LineItem.ts +++ b/lib/types/LineItem.ts @@ -1,13 +1,23 @@ import {BoundingElement} from "./BoundingElement"; - export declare type LineItem = { + category?: null | string | BoundingElement; + country_of_origin?: null | string | BoundingElement; + custom_fields?: Record; date?: null | string | BoundingElement; description?: null | string | BoundingElement; discount?: null | number | BoundingElement; + discount_price?: null | number | BoundingElement; + discount_rate?: null | number | BoundingElement; end_date?: null | string | BoundingElement; + full_description?: null | string | BoundingElement; + gross_total?: null | number | BoundingElement; hsn?: null | string; id?: null | number; + lot?: null | string | BoundingElement; + manufacturer?: null | string | BoundingElement; + net_total?: null | number | BoundingElement; + normalized_description?: null | string | BoundingElement; order?: null | number; price?: null | number | BoundingElement; quantity?: null | number | BoundingElement; @@ -15,10 +25,15 @@ export declare type LineItem = { section?: null | string; sku?: null | string | BoundingElement; start_date?: null | string; - tags?: null | null[]; + subtotal?: null | number | BoundingElement; + tags?: null | string[]; tax?: null | number | BoundingElement; + tax_code?: null | string | BoundingElement; tax_rate?: null | number; + text?: null | string | BoundingElement; total?: null | number | BoundingElement; type?: null | string; unit_of_measure?: null | string; + upc?: null | string | BoundingElement; + weight?: null | number | BoundingElement; }; diff --git a/lib/types/Vendor.ts b/lib/types/Vendor.ts index d563c40..ada3749 100644 --- a/lib/types/Vendor.ts +++ b/lib/types/Vendor.ts @@ -1,15 +1,35 @@ import {BoundingElement} from "./BoundingElement"; export declare type Vendor = { + abn_number?: null | string | BoundingElement; + account_currency?: null | string | BoundingElement; + account_number?: null | string | BoundingElement; address?: null | string | BoundingElement; + bank_breakdown?: Array>; + bank_name?: null | string | BoundingElement; + bank_number?: null | string | BoundingElement; + bank_swift?: null | string | BoundingElement; + biller_code?: null | string | BoundingElement; category?: null | string | BoundingElement; + country_code?: null | string | BoundingElement; email?: null | string | BoundingElement; + external_id?: null | string | BoundingElement; + external_ids?: Array; fax_number?: null | string | BoundingElement; + iban?: null | string | BoundingElement; + lat?: number; + lng?: number; + logo?: null | string | BoundingElement; + logo_name?: null | string | BoundingElement; + map_url?: null | string | BoundingElement; name?: null | string | BoundingElement; + order_number?: null | string | BoundingElement; + parsed_address?: null | Record; phone_number?: null | string | BoundingElement; + raw_address?: null | string | BoundingElement; raw_name?: null | string; - vendor_logo?: null | string | BoundingElement; - vendor_reg_number?: null | string | BoundingElement; - vendor_type?: null | string; + reg_number?: null | string | BoundingElement; + type?: null | string | BoundingElement; + vat_number?: null | string | BoundingElement; web?: null | string | BoundingElement; }; diff --git a/lib/types/VeryfiDocument.ts b/lib/types/VeryfiDocument.ts index d655447..9ac9b71 100644 --- a/lib/types/VeryfiDocument.ts +++ b/lib/types/VeryfiDocument.ts @@ -16,7 +16,7 @@ export declare type VeryfiDocument = { account_number?: null | string | BoundingElement; accounting_entry_type?: null | string; balance?: null | string | BoundingElement; - barcodes?: null | string[] | BoundingElement[]; + barcodes?: null | Array<{ data: string; type: string }>; bill_to?: null | BillTo; card_number?: null | string | BoundingElement; cashback?: null | number | BoundingElement; @@ -51,16 +51,62 @@ export declare type VeryfiDocument = { is_document?: null | boolean; is_duplicate?: null | boolean; is_money_in?: null | boolean | BoundingElement; + language?: null | string[]; license_plate_number?: null | string | BoundingElement; line_items?: null | LineItem[]; line_items_with_scores?: null | LineItem[]; + meta?: null | { + device_id?: null | string; + device_user_uuid?: null | string; + duplicates?: Array<{ + id: number; + score: number; + url: string; + }>; + fraud?: { + attribution?: null | string; + color?: string; + custom_types?: string[]; + decision?: string; + images?: Array<{ + is_lcd: boolean; + score: number; + }>; + pages?: Array<{ + is_lcd: { + score: number; + value: boolean; + }; + }>; + score?: number; + submissions?: Record; + types?: string[]; + version?: null | string; + }; + }; notes?: null | string; ocr_text?: null | string; order_date?: null | string | BoundingElement; + owner?: null | string; + pages?: Array<{ + height: number; + is_blurry: { + score: number; + value: boolean; + }; + language: string[]; + screenshot: { + score: number; + type: null | string; + }; + width: number; + }>; payment?: null | Payment; pdf_url?: null | string; previous_balance?: null | number | BoundingElement; + processed_pages?: null | number; purchase_order_number?: null | string | BoundingElement; + reference_number?: null | string | BoundingElement; rounding?: null | number | BoundingElement; server_name?: null | string | BoundingElement; service_end_date?: null | string; @@ -68,6 +114,12 @@ export declare type VeryfiDocument = { ship_date?: null | string | BoundingElement; ship_to?: null | ShipTo; shipping?: null | number | BoundingElement; + source?: null | string; + source_documents?: Array<{ + height: number; + size_kb: number; + width: number; + }>; status?: null | string; store_number?: null | string | BoundingElement; subtotal?: null | number | BoundingElement; diff --git a/package.json b/package.json index a406757..8412a14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@veryfi/veryfi-sdk", - "version": "1.4.0", + "version": "1.4.1", "description": "Node.js module for communicating with the Veryfi OCR API", "main": "lib/client/client.js", "typings": "lib/types/Client.ts", diff --git a/test/main.test.js b/test/main.test.js index e472469..7372a2e 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -44,7 +44,10 @@ describe('Processing documents', () => { const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); let response = await veryfi_client.process_document_from_base64( base64_encoded_string, - 'receipt.png' + 'receipt.png', + null, + false, + {device_data: {user_uuid: '7c4a4f92-9d31-4e56-8f2a-e62435f1b871'}} ); expect(response['total']).toBe(34.95); } catch (error) { From 01f95e243e3210fe79a1ffa7265b61e278d5bd9e Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Thu, 7 Nov 2024 10:59:43 -0500 Subject: [PATCH 2/2] Update VeryfiDocument.ts --- lib/types/VeryfiDocument.ts | 50 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/types/VeryfiDocument.ts b/lib/types/VeryfiDocument.ts index 9ac9b71..e04a039 100644 --- a/lib/types/VeryfiDocument.ts +++ b/lib/types/VeryfiDocument.ts @@ -83,28 +83,41 @@ export declare type VeryfiDocument = { types?: string[]; version?: null | string; }; + handwritten_fields?: null | string[]; + language?: null | string[]; + owner?: null | string; + pages?: Array<{ + height: number; + is_blurry: { + score: number; + value: boolean; + }; + language: string[]; + screenshot: { + score: number; + type: null | string; + }; + width: number; + }>; + processed_pages?: null | number; + source?: null | string; + source_documents?: Array<{ + height: number; + size_kb: number; + width: number; + }>; + total_pages?: null | number; + warnings?: Array<{ + message: string; + type: string; + }>; }; notes?: null | string; ocr_text?: null | string; order_date?: null | string | BoundingElement; - owner?: null | string; - pages?: Array<{ - height: number; - is_blurry: { - score: number; - value: boolean; - }; - language: string[]; - screenshot: { - score: number; - type: null | string; - }; - width: number; - }>; payment?: null | Payment; pdf_url?: null | string; previous_balance?: null | number | BoundingElement; - processed_pages?: null | number; purchase_order_number?: null | string | BoundingElement; reference_number?: null | string | BoundingElement; rounding?: null | number | BoundingElement; @@ -114,12 +127,6 @@ export declare type VeryfiDocument = { ship_date?: null | string | BoundingElement; ship_to?: null | ShipTo; shipping?: null | number | BoundingElement; - source?: null | string; - source_documents?: Array<{ - height: number; - size_kb: number; - width: number; - }>; status?: null | string; store_number?: null | string | BoundingElement; subtotal?: null | number | BoundingElement; @@ -128,7 +135,6 @@ export declare type VeryfiDocument = { tax_lines?: null | TaxLine[]; tip?: null | number | BoundingElement; total?: null | number | BoundingElement; - total_pages?: null | number; total_quantity?: null | string | BoundingElement; total_weight?: null | string | BoundingElement; tracking_number?: null | string | BoundingElement;