mindee 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.7.0 - 2024-01-30
4
+ ### Changes
5
+ * :arrow_up: update invoices to 4.4
6
+ * :sparkles: add rawValue to string fields.
7
+
8
+
9
+ ## v4.6.1 - 2023-12-15
10
+ ### Changes
11
+ * :recycle: tweak async delays & retry
12
+ * :recycle: tweak default async sample delays & retry
13
+ * :memo: update md doc & fix typos
14
+
15
+
3
16
  ## v4.6.0 - 2023-12-11
4
17
  ### Changes
5
18
  * :sparkles: add invoice-splitter auto-splitting feature
package/README.md CHANGED
@@ -47,7 +47,7 @@ const inputSource = mindeeClient.docFromBase64(myInputString, "my-file-name")
47
47
 
48
48
  A stream:
49
49
  ```js
50
- const inputSource = mindeeClient.docFromBuffer(myReadableStream, "my-file-name")
50
+ const inputSource = mindeeClient.docFromStream(myReadableStream, "my-file-name")
51
51
  ```
52
52
 
53
53
  A buffer:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/cli.js CHANGED
@@ -228,9 +228,9 @@ async function callEnqueueAndParse(productClass, command, inputPath, options) {
228
228
  pageOptions: pageOptions,
229
229
  allWords: predictParams.allWords,
230
230
  cropper: predictParams.cropper,
231
- initialDelaySec: 6,
232
- delaySec: 3,
233
- maxRetries: 10,
231
+ initialDelaySec: 4,
232
+ delaySec: 2,
233
+ maxRetries: 30,
234
234
  });
235
235
  }
236
236
  else {
@@ -238,9 +238,9 @@ async function callEnqueueAndParse(productClass, command, inputPath, options) {
238
238
  pageOptions: pageOptions,
239
239
  allWords: predictParams.allWords,
240
240
  cropper: predictParams.cropper,
241
- initialDelaySec: 6,
242
- delaySec: 3,
243
- maxRetries: 10,
241
+ initialDelaySec: 4,
242
+ delaySec: 2,
243
+ maxRetries: 30,
244
244
  });
245
245
  if (!response.document) {
246
246
  throw Error("Document could not be retrieved");
package/src/client.js CHANGED
@@ -153,9 +153,9 @@ class Client {
153
153
  allWords: undefined,
154
154
  cropper: undefined,
155
155
  pageOptions: undefined,
156
- initialDelaySec: 6,
157
- delaySec: 3,
158
- maxRetries: 10,
156
+ initialDelaySec: 4,
157
+ delaySec: 2,
158
+ maxRetries: 30,
159
159
  initialTimerOptions: undefined,
160
160
  recurringTimerOptions: undefined,
161
161
  }) {
@@ -283,17 +283,20 @@ Job status: ${pollResults.job.status}.`);
283
283
  }
284
284
  exports.Client = Client;
285
285
  _Client_instances = new WeakSet(), _Client_validateAsyncParams = function _Client_validateAsyncParams(asyncParams) {
286
- asyncParams.delaySec ?? (asyncParams.delaySec = 3);
287
- asyncParams.initialDelaySec ?? (asyncParams.initialDelaySec = 6);
288
- asyncParams.maxRetries ?? (asyncParams.maxRetries = 10);
289
- if (asyncParams.delaySec < 2) {
290
- throw Error("Cannot set auto-parsing delay to less than 2 seconds.");
286
+ const minDelaySec = 1;
287
+ const minInitialDelay = 2;
288
+ const minRetries = 2;
289
+ asyncParams.delaySec ?? (asyncParams.delaySec = 2);
290
+ asyncParams.initialDelaySec ?? (asyncParams.initialDelaySec = 4);
291
+ asyncParams.maxRetries ?? (asyncParams.maxRetries = 30);
292
+ if (asyncParams.delaySec < minDelaySec) {
293
+ throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} seconds.`);
291
294
  }
292
- if (asyncParams.initialDelaySec < 4) {
293
- throw Error("Cannot set initial parsing delay to less than 4 seconds.");
295
+ if (asyncParams.initialDelaySec < minInitialDelay) {
296
+ throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} seconds.`);
294
297
  }
295
- if (!Number.isInteger(asyncParams.maxRetries)) {
296
- throw Error("Retry amount must be an integer.");
298
+ if (asyncParams.maxRetries < minRetries) {
299
+ throw Error(`Cannot set retry to less than ${minRetries}.`);
297
300
  }
298
301
  }, _Client_buildProductEndpoint = function _Client_buildProductEndpoint(endpointName, accountName, endpointVersion) {
299
302
  return new http_1.Endpoint(endpointName, accountName, endpointVersion, __classPrivateFieldGet(this, _Client_instances, "m", _Client_buildApiSettings).call(this));
@@ -12,5 +12,7 @@ export interface FieldConstructor {
12
12
  export declare class StringField extends Field {
13
13
  /** The value. */
14
14
  value?: string;
15
+ /** Value as it appears on the document. */
16
+ rawValue?: string;
15
17
  constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
16
18
  }
@@ -8,6 +8,9 @@ const field_1 = require("./field");
8
8
  class StringField extends field_1.Field {
9
9
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
10
10
  super({ prediction, valueKey, reconstructed, pageId });
11
+ if (prediction["raw_value"]) {
12
+ this.rawValue = prediction["raw_value"];
13
+ }
11
14
  }
12
15
  }
13
16
  exports.StringField = StringField;
@@ -39,6 +39,8 @@ export declare class InvoiceV4Document implements Prediction {
39
39
  totalAmount: AmountField;
40
40
  /** The net amount paid: does not include taxes, fees, and discounts. */
41
41
  totalNet: AmountField;
42
+ /** The total tax: includes all the taxes paid for this invoice. */
43
+ totalTax: AmountField;
42
44
  constructor(rawPrediction: StringDict, pageId?: number);
43
45
  /**
44
46
  * Default string representation.
@@ -87,6 +87,10 @@ class InvoiceV4Document {
87
87
  prediction: rawPrediction["total_net"],
88
88
  pageId: pageId,
89
89
  });
90
+ this.totalTax = new standard_1.AmountField({
91
+ prediction: rawPrediction["total_tax"],
92
+ pageId: pageId,
93
+ });
90
94
  }
91
95
  /**
92
96
  * Default string representation.
@@ -117,6 +121,7 @@ class InvoiceV4Document {
117
121
  :Due Date: ${this.dueDate}
118
122
  :Total Net: ${this.totalNet}
119
123
  :Total Amount: ${this.totalAmount}
124
+ :Total Tax: ${this.totalTax}
120
125
  :Taxes: ${this.taxes}
121
126
  :Supplier Payment Details: ${supplierPaymentDetails}
122
127
  :Supplier Name: ${this.supplierName}