mindee 5.5.0 → 5.6.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.
Files changed (209) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/package.json +26 -14
  3. package/src/geometry/bbox.d.ts +5 -0
  4. package/src/geometry/bbox.js +1 -0
  5. package/src/geometry/minMax.d.ts +3 -0
  6. package/src/geometry/polygonUtils.d.ts +23 -0
  7. package/src/geometry/polygonUtils.js +23 -0
  8. package/src/http/baseSettings.d.ts +5 -0
  9. package/src/http/baseSettings.js +2 -0
  10. package/src/image/extractedImage.d.ts +4 -0
  11. package/src/image/extractedImages.d.ts +1 -0
  12. package/src/image/extractedImages.js +1 -0
  13. package/src/image/imageCompressor.d.ts +1 -1
  14. package/src/image/imageExtractor.d.ts +5 -6
  15. package/src/image/imageExtractor.js +71 -73
  16. package/src/input/base64Input.d.ts +3 -0
  17. package/src/input/base64Input.js +3 -0
  18. package/src/input/bufferInput.d.ts +2 -0
  19. package/src/input/bufferInput.js +2 -0
  20. package/src/input/bytesInput.d.ts +3 -0
  21. package/src/input/bytesInput.js +3 -0
  22. package/src/input/inputSource.d.ts +15 -0
  23. package/src/input/inputSource.js +15 -0
  24. package/src/input/localInputSource.d.ts +6 -0
  25. package/src/input/localInputSource.js +3 -0
  26. package/src/input/pathInput.d.ts +4 -0
  27. package/src/input/pathInput.js +3 -0
  28. package/src/input/streamInput.d.ts +4 -0
  29. package/src/input/streamInput.js +4 -0
  30. package/src/input/urlInput.d.ts +12 -0
  31. package/src/input/urlInput.js +52 -10
  32. package/src/logger.js +1 -1
  33. package/src/parsing/dateParser.d.ts +4 -0
  34. package/src/parsing/dateParser.js +5 -1
  35. package/src/parsing/localResponseBase.d.ts +2 -0
  36. package/src/parsing/localResponseBase.js +2 -0
  37. package/src/parsing/stringDict.d.ts +1 -0
  38. package/src/pdf/extractedPdf.d.ts +5 -0
  39. package/src/pdf/extractedPdf.js +1 -0
  40. package/src/pdf/extractedPdfs.d.ts +1 -0
  41. package/src/pdf/extractedPdfs.js +1 -0
  42. package/src/pdf/pdfCompressor.js +12 -0
  43. package/src/pdf/pdfExtractor.js +3 -0
  44. package/src/pdf/pdfOperation.d.ts +3 -0
  45. package/src/pdf/pdfOperation.js +3 -0
  46. package/src/pdf/pdfUtils.js +5 -0
  47. package/src/v1/cli.d.ts +3 -0
  48. package/src/v1/cli.js +84 -26
  49. package/src/v1/client.d.ts +16 -16
  50. package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.d.ts +2 -0
  51. package/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.js +14 -0
  52. package/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.d.ts +2 -0
  53. package/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.js +3 -0
  54. package/src/v1/http/apiSettingsV1.d.ts +5 -0
  55. package/src/v1/http/apiSettingsV1.js +4 -0
  56. package/src/v1/http/errors.d.ts +7 -1
  57. package/src/v1/http/errors.js +65 -86
  58. package/src/v1/http/httpParams.d.ts +12 -0
  59. package/src/v1/parsing/common/asyncPredictResponse.d.ts +4 -0
  60. package/src/v1/parsing/common/asyncPredictResponse.js +5 -2
  61. package/src/v1/parsing/common/executionPriority.d.ts +4 -0
  62. package/src/v1/parsing/common/executionPriority.js +4 -0
  63. package/src/v1/parsing/common/extras/cropperExtra.d.ts +2 -0
  64. package/src/v1/parsing/common/extras/cropperExtra.js +3 -0
  65. package/src/v1/parsing/common/extras/extras.d.ts +3 -0
  66. package/src/v1/parsing/common/extras/extras.js +2 -0
  67. package/src/v1/parsing/common/extras/fullTextOcrExtra.d.ts +3 -0
  68. package/src/v1/parsing/common/extras/fullTextOcrExtra.js +1 -0
  69. package/src/v1/parsing/common/extras/ragExtra.d.ts +1 -0
  70. package/src/v1/parsing/common/extras/ragExtra.js +1 -0
  71. package/src/v1/parsing/common/feedback/feedbackResponse.js +1 -0
  72. package/src/v1/parsing/common/index.d.ts +1 -1
  73. package/src/v1/parsing/common/index.js +1 -1
  74. package/src/v1/parsing/common/inference.d.ts +2 -0
  75. package/src/v1/parsing/common/inference.js +2 -0
  76. package/src/v1/parsing/common/prediction.d.ts +1 -0
  77. package/src/v1/parsing/common/prediction.js +1 -0
  78. package/src/v1/parsing/common/summaryHelper.d.ts +12 -1
  79. package/src/v1/parsing/common/summaryHelper.js +18 -1
  80. package/src/v1/parsing/generated/generatedObject.d.ts +6 -0
  81. package/src/v1/parsing/generated/generatedObject.js +38 -27
  82. package/src/v1/parsing/localResponse.d.ts +1 -0
  83. package/src/v1/parsing/localResponse.js +1 -0
  84. package/src/v1/parsing/standard/base.d.ts +6 -0
  85. package/src/v1/parsing/standard/base.js +1 -0
  86. package/src/v1/parsing/standard/boolean.d.ts +1 -1
  87. package/src/v1/parsing/standard/companyRegistration.d.ts +1 -0
  88. package/src/v1/parsing/standard/companyRegistration.js +1 -0
  89. package/src/v1/parsing/standard/date.d.ts +1 -0
  90. package/src/v1/parsing/standard/date.js +1 -0
  91. package/src/v1/parsing/standard/paymentDetails.d.ts +5 -5
  92. package/src/v1/parsing/standard/position.d.ts +2 -2
  93. package/src/v1/parsing/standard/tax.d.ts +1 -0
  94. package/src/v1/parsing/standard/tax.js +1 -0
  95. package/src/v1/parsing/standard/text.d.ts +1 -1
  96. package/src/v1/parsing/standard/word.d.ts +3 -0
  97. package/src/v1/parsing/standard/word.js +1 -0
  98. package/src/v1/product/financialDocument/financialDocumentV1LineItem.js +16 -58
  99. package/src/v1/product/generated/generatedV1Prediction.d.ts +1 -0
  100. package/src/v1/product/generated/generatedV1Prediction.js +2 -1
  101. package/src/v1/product/invoice/invoiceV4LineItem.js +5 -16
  102. package/src/v1/product/receipt/receiptV5LineItem.js +2 -6
  103. package/src/v1/product/resume/resumeV1Certificate.js +5 -21
  104. package/src/v1/product/resume/resumeV1Education.js +8 -36
  105. package/src/v1/product/resume/resumeV1Language.js +3 -11
  106. package/src/v1/product/resume/resumeV1ProfessionalExperience.js +10 -46
  107. package/src/v1/product/resume/resumeV1SocialNetworksUrl.js +3 -11
  108. package/src/v2/cli.d.ts +3 -0
  109. package/src/v2/cli.js +21 -0
  110. package/src/v2/client.d.ts +1 -0
  111. package/src/v2/client.js +1 -0
  112. package/src/v2/clientOptions/pollingOptions.d.ts +5 -0
  113. package/src/v2/clientOptions/pollingOptions.js +2 -0
  114. package/src/v2/parsing/baseResponse.d.ts +2 -0
  115. package/src/v2/parsing/baseResponse.js +1 -0
  116. package/src/v2/parsing/error/errorDetails.d.ts +1 -0
  117. package/src/v2/parsing/index.d.ts +1 -1
  118. package/src/v2/parsing/index.js +1 -1
  119. package/src/v2/parsing/inference/baseInference.d.ts +2 -0
  120. package/src/v2/parsing/inference/baseInference.js +2 -0
  121. package/src/v2/parsing/inference/failedInferenceResponse.d.ts +33 -0
  122. package/src/v2/parsing/inference/failedInferenceResponse.js +17 -0
  123. package/src/v2/parsing/inference/field/baseField.d.ts +3 -0
  124. package/src/v2/parsing/inference/field/fieldConfidence.d.ts +4 -0
  125. package/src/v2/parsing/inference/field/fieldConfidence.js +4 -0
  126. package/src/v2/parsing/inference/field/fieldFactory.d.ts +5 -0
  127. package/src/v2/parsing/inference/field/fieldFactory.js +5 -0
  128. package/src/v2/parsing/inference/field/fieldLocation.d.ts +1 -0
  129. package/src/v2/parsing/inference/field/fieldLocation.js +1 -0
  130. package/src/v2/parsing/inference/field/inferenceFields.d.ts +5 -0
  131. package/src/v2/parsing/inference/field/inferenceFields.js +4 -0
  132. package/src/v2/parsing/inference/field/listField.d.ts +2 -0
  133. package/src/v2/parsing/inference/field/listField.js +2 -0
  134. package/src/v2/parsing/inference/field/objectField.d.ts +4 -0
  135. package/src/v2/parsing/inference/field/objectField.js +3 -0
  136. package/src/v2/parsing/inference/field/ragMetadata.d.ts +1 -0
  137. package/src/v2/parsing/inference/field/ragMetadata.js +1 -0
  138. package/src/v2/parsing/inference/field/rawText.d.ts +2 -0
  139. package/src/v2/parsing/inference/field/rawText.js +2 -0
  140. package/src/v2/parsing/inference/field/simpleField.d.ts +2 -0
  141. package/src/v2/parsing/inference/field/simpleField.js +2 -0
  142. package/src/v2/parsing/inference/inferenceFile.d.ts +2 -0
  143. package/src/v2/parsing/inference/inferenceFile.js +2 -0
  144. package/src/v2/parsing/inference/inferenceModel.d.ts +2 -0
  145. package/src/v2/parsing/inference/inferenceModel.js +2 -0
  146. package/src/v2/parsing/job/job.d.ts +1 -1
  147. package/src/v2/parsing/job/job.js +1 -3
  148. package/src/v2/parsing/job/jobResponse.d.ts +3 -0
  149. package/src/v2/parsing/job/jobResponse.js +3 -0
  150. package/src/v2/product/classification/classification.d.ts +3 -0
  151. package/src/v2/product/classification/classification.js +3 -0
  152. package/src/v2/product/classification/classificationClassifier.d.ts +2 -0
  153. package/src/v2/product/classification/classificationClassifier.js +2 -0
  154. package/src/v2/product/classification/classificationInference.d.ts +2 -0
  155. package/src/v2/product/classification/classificationInference.js +2 -0
  156. package/src/v2/product/classification/classificationResponse.d.ts +1 -0
  157. package/src/v2/product/classification/classificationResponse.js +1 -0
  158. package/src/v2/product/classification/classificationResult.d.ts +2 -0
  159. package/src/v2/product/classification/classificationResult.js +2 -0
  160. package/src/v2/product/crop/crop.d.ts +3 -0
  161. package/src/v2/product/crop/crop.js +3 -0
  162. package/src/v2/product/crop/cropInference.d.ts +2 -0
  163. package/src/v2/product/crop/cropInference.js +2 -0
  164. package/src/v2/product/crop/cropItem.d.ts +2 -0
  165. package/src/v2/product/crop/cropItem.js +2 -0
  166. package/src/v2/product/crop/cropResponse.d.ts +1 -0
  167. package/src/v2/product/crop/cropResponse.js +1 -0
  168. package/src/v2/product/crop/cropResult.d.ts +2 -0
  169. package/src/v2/product/crop/cropResult.js +2 -0
  170. package/src/v2/product/extraction/dataSchemaActiveOption.d.ts +1 -0
  171. package/src/v2/product/extraction/dataSchemaActiveOption.js +1 -0
  172. package/src/v2/product/extraction/extraction.d.ts +3 -0
  173. package/src/v2/product/extraction/extraction.js +3 -0
  174. package/src/v2/product/extraction/extractionActiveOptions.d.ts +2 -0
  175. package/src/v2/product/extraction/extractionActiveOptions.js +2 -0
  176. package/src/v2/product/extraction/extractionInference.d.ts +2 -0
  177. package/src/v2/product/extraction/extractionInference.js +2 -0
  178. package/src/v2/product/extraction/extractionResponse.d.ts +1 -0
  179. package/src/v2/product/extraction/extractionResponse.js +1 -0
  180. package/src/v2/product/extraction/extractionResult.d.ts +2 -0
  181. package/src/v2/product/extraction/extractionResult.js +2 -0
  182. package/src/v2/product/extraction/params/dataSchema.d.ts +9 -6
  183. package/src/v2/product/extraction/params/dataSchema.js +2 -0
  184. package/src/v2/product/extraction/params/dataSchemaField.d.ts +25 -1
  185. package/src/v2/product/extraction/params/dataSchemaField.js +3 -0
  186. package/src/v2/product/extraction/params/dataSchemaReplace.d.ts +9 -4
  187. package/src/v2/product/extraction/params/dataSchemaReplace.js +2 -0
  188. package/src/v2/product/ocr/ocr.d.ts +3 -0
  189. package/src/v2/product/ocr/ocr.js +3 -0
  190. package/src/v2/product/ocr/ocrInference.d.ts +2 -0
  191. package/src/v2/product/ocr/ocrInference.js +2 -0
  192. package/src/v2/product/ocr/ocrPage.d.ts +2 -0
  193. package/src/v2/product/ocr/ocrPage.js +2 -0
  194. package/src/v2/product/ocr/ocrResponse.d.ts +1 -0
  195. package/src/v2/product/ocr/ocrResponse.js +1 -0
  196. package/src/v2/product/ocr/ocrResult.d.ts +1 -0
  197. package/src/v2/product/ocr/ocrResult.js +1 -0
  198. package/src/v2/product/ocr/ocrWord.d.ts +2 -0
  199. package/src/v2/product/ocr/ocrWord.js +2 -0
  200. package/src/v2/product/split/split.d.ts +3 -0
  201. package/src/v2/product/split/split.js +3 -0
  202. package/src/v2/product/split/splitInference.d.ts +2 -0
  203. package/src/v2/product/split/splitInference.js +2 -0
  204. package/src/v2/product/split/splitRange.d.ts +1 -0
  205. package/src/v2/product/split/splitRange.js +1 -0
  206. package/src/v2/product/split/splitResponse.d.ts +1 -0
  207. package/src/v2/product/split/splitResponse.js +1 -0
  208. package/src/v2/product/split/splitResult.d.ts +1 -0
  209. package/src/v2/product/split/splitResult.js +1 -0
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _ResumeV1ProfessionalExperience_instances, _ResumeV1ProfessionalExperience_printableValues;
7
- import { cleanSpecialChars } from "../../../v1/parsing/common/index.js";
7
+ import { cleanAndTruncate } from "../../../v1/parsing/common/index.js";
8
8
  import { Polygon } from "../../../geometry/index.js";
9
9
  /**
10
10
  * The list of the candidate's professional experiences.
@@ -86,50 +86,14 @@ export class ResumeV1ProfessionalExperience {
86
86
  }
87
87
  _ResumeV1ProfessionalExperience_instances = new WeakSet(), _ResumeV1ProfessionalExperience_printableValues = function _ResumeV1ProfessionalExperience_printableValues() {
88
88
  return {
89
- contractType: this.contractType ?
90
- this.contractType.length <= 15 ?
91
- cleanSpecialChars(this.contractType) :
92
- cleanSpecialChars(this.contractType).slice(0, 12) + "..." :
93
- "",
94
- department: this.department ?
95
- this.department.length <= 10 ?
96
- cleanSpecialChars(this.department) :
97
- cleanSpecialChars(this.department).slice(0, 7) + "..." :
98
- "",
99
- description: this.description ?
100
- this.description.length <= 36 ?
101
- cleanSpecialChars(this.description) :
102
- cleanSpecialChars(this.description).slice(0, 33) + "..." :
103
- "",
104
- employer: this.employer ?
105
- this.employer.length <= 25 ?
106
- cleanSpecialChars(this.employer) :
107
- cleanSpecialChars(this.employer).slice(0, 22) + "..." :
108
- "",
109
- endMonth: this.endMonth ?
110
- this.endMonth.length <= 9 ?
111
- cleanSpecialChars(this.endMonth) :
112
- cleanSpecialChars(this.endMonth).slice(0, 6) + "..." :
113
- "",
114
- endYear: this.endYear ?
115
- this.endYear.length <= 8 ?
116
- cleanSpecialChars(this.endYear) :
117
- cleanSpecialChars(this.endYear).slice(0, 5) + "..." :
118
- "",
119
- role: this.role ?
120
- this.role.length <= 20 ?
121
- cleanSpecialChars(this.role) :
122
- cleanSpecialChars(this.role).slice(0, 17) + "..." :
123
- "",
124
- startMonth: this.startMonth ?
125
- this.startMonth.length <= 11 ?
126
- cleanSpecialChars(this.startMonth) :
127
- cleanSpecialChars(this.startMonth).slice(0, 8) + "..." :
128
- "",
129
- startYear: this.startYear ?
130
- this.startYear.length <= 10 ?
131
- cleanSpecialChars(this.startYear) :
132
- cleanSpecialChars(this.startYear).slice(0, 7) + "..." :
133
- "",
89
+ contractType: cleanAndTruncate(this.contractType, 15),
90
+ department: cleanAndTruncate(this.department, 10),
91
+ description: cleanAndTruncate(this.description, 36),
92
+ employer: cleanAndTruncate(this.employer, 25),
93
+ endMonth: cleanAndTruncate(this.endMonth, 9),
94
+ endYear: cleanAndTruncate(this.endYear, 8),
95
+ role: cleanAndTruncate(this.role, 20),
96
+ startMonth: cleanAndTruncate(this.startMonth, 11),
97
+ startYear: cleanAndTruncate(this.startYear, 10),
134
98
  };
135
99
  };
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _ResumeV1SocialNetworksUrl_instances, _ResumeV1SocialNetworksUrl_printableValues;
7
- import { cleanSpecialChars } from "../../../v1/parsing/common/index.js";
7
+ import { cleanAndTruncate } from "../../../v1/parsing/common/index.js";
8
8
  import { Polygon } from "../../../geometry/index.js";
9
9
  /**
10
10
  * The list of social network profiles of the candidate.
@@ -51,15 +51,7 @@ export class ResumeV1SocialNetworksUrl {
51
51
  }
52
52
  _ResumeV1SocialNetworksUrl_instances = new WeakSet(), _ResumeV1SocialNetworksUrl_printableValues = function _ResumeV1SocialNetworksUrl_printableValues() {
53
53
  return {
54
- name: this.name ?
55
- this.name.length <= 20 ?
56
- cleanSpecialChars(this.name) :
57
- cleanSpecialChars(this.name).slice(0, 17) + "..." :
58
- "",
59
- url: this.url ?
60
- this.url.length <= 50 ?
61
- cleanSpecialChars(this.url) :
62
- cleanSpecialChars(this.url).slice(0, 47) + "..." :
63
- "",
54
+ name: cleanAndTruncate(this.name, 20),
55
+ url: cleanAndTruncate(this.url, 50),
64
56
  };
65
57
  };
package/src/v2/cli.d.ts CHANGED
@@ -1 +1,4 @@
1
+ /**
2
+ * Build the CLI.
3
+ */
1
4
  export declare function cli(): void;
package/src/v2/cli.js CHANGED
@@ -6,12 +6,22 @@ const program = new Command();
6
6
  //
7
7
  // EXECUTE THE COMMANDS
8
8
  //
9
+ /**
10
+ * Initialize the client.
11
+ * @param options Options.
12
+ */
9
13
  function initClient(options) {
10
14
  return new Client({
11
15
  apiKey: options.apiKey,
12
16
  debug: options.debug,
13
17
  });
14
18
  }
19
+ /**
20
+ * Enqueue and get inference.
21
+ * @param product Product.
22
+ * @param inputPath Input path.
23
+ * @param options Options.
24
+ */
15
25
  async function enqueueAndGetInference(product, inputPath, options) {
16
26
  const mindeeClient = initClient(options);
17
27
  let inputSource;
@@ -31,6 +41,10 @@ async function enqueueAndGetInference(product, inputPath, options) {
31
41
  }
32
42
  printResponse(response.inference);
33
43
  }
44
+ /**
45
+ * Print response.
46
+ * @param document Document.
47
+ */
34
48
  function printResponse(document) {
35
49
  if (document) {
36
50
  console.log(`\n${document}`);
@@ -39,10 +53,17 @@ function printResponse(document) {
39
53
  //
40
54
  // BUILD THE COMMANDS
41
55
  //
56
+ /**
57
+ * Add main options.
58
+ * @param prog Program.
59
+ */
42
60
  function addMainOptions(prog) {
43
61
  prog.requiredOption("-m, --model <model_id>", "Model ID (required)");
44
62
  prog.argument("<input_path>", "full path or URL to the file");
45
63
  }
64
+ /**
65
+ * Build the CLI.
66
+ */
46
67
  export function cli() {
47
68
  program.name("mindee")
48
69
  .description("Command line interface for Mindee V2 products.")
@@ -39,6 +39,7 @@ export declare class Client {
39
39
  * @returns a `Promise` containing the search response.
40
40
  */
41
41
  searchModels(name?: string, modelType?: string): Promise<SearchResponse>;
42
+ /** Enqueues a product inference job without waiting for completion. */
42
43
  enqueue<P extends typeof BaseProduct>(product: P, inputSource: InputSource, params: InstanceType<P["parametersClass"]> | ConstructorParameters<P["parametersClass"]>[0]): Promise<JobResponse>;
43
44
  /**
44
45
  * Retrieves the result of a previously enqueued request.
package/src/v2/client.js CHANGED
@@ -34,6 +34,7 @@ export class Client {
34
34
  async searchModels(name, modelType) {
35
35
  return await this.mindeeApi.reqGetSearchModel(name, modelType);
36
36
  }
37
+ /** Enqueues a product inference job without waiting for completion. */
37
38
  async enqueue(product, inputSource, params) {
38
39
  if (inputSource === undefined) {
39
40
  throw new MindeeError("An input document is required.");
@@ -1,5 +1,8 @@
1
+ /** Optional timer settings used by polling delays. */
1
2
  export interface TimerOptions {
3
+ /** Whether the timer should keep the event loop active. */
2
4
  ref?: boolean;
5
+ /** Optional signal used to abort timer waits. */
3
6
  signal?: AbortSignal;
4
7
  }
5
8
  export interface PollingOptionsConstructor {
@@ -51,6 +54,8 @@ export declare class PollingOptions {
51
54
  /** Options passed to every recurring `setTimeout()`. */
52
55
  recurringTimerOptions?: TimerOptions;
53
56
  constructor(params?: PollingOptionsConstructor);
57
+ /** Validates polling options against minimum accepted values. */
54
58
  validateSettings(): void;
59
+ /** Returns a compact string representation of the polling options. */
55
60
  toString(): string;
56
61
  }
@@ -65,6 +65,7 @@ export class PollingOptions {
65
65
  this.validateSettings();
66
66
  logger.debug(`Polling options initialized: ${this.toString()}`);
67
67
  }
68
+ /** Validates polling options against minimum accepted values. */
68
69
  validateSettings() {
69
70
  if (this.delaySec < minDelaySec) {
70
71
  throw new MindeeConfigurationError(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`);
@@ -76,6 +77,7 @@ export class PollingOptions {
76
77
  throw new MindeeConfigurationError(`Cannot set retry to less than ${minRetries}.`);
77
78
  }
78
79
  }
80
+ /** Returns a compact string representation of the polling options. */
79
81
  toString() {
80
82
  return `{ initialDelaySec: ${this.initialDelaySec}, delaySec: ${this.delaySec}, maxRetries: ${this.maxRetries} }`;
81
83
  }
@@ -1,4 +1,5 @@
1
1
  import { StringDict } from "../../parsing/stringDict.js";
2
+ /** Base response contract for v2 product responses. */
2
3
  export declare abstract class BaseResponse {
3
4
  /**
4
5
  * Raw text representation of the API's response.
@@ -14,4 +15,5 @@ export declare abstract class BaseResponse {
14
15
  */
15
16
  getRawHttp(): StringDict;
16
17
  }
18
+ /** Constructor signature for typed v2 response classes. */
17
19
  export type ResponseConstructor<T extends BaseResponse> = new (serverResponse: StringDict) => T;
@@ -1,4 +1,5 @@
1
1
  import { logger } from "../../logger.js";
2
+ /** Base response contract for v2 product responses. */
2
3
  export class BaseResponse {
3
4
  /**
4
5
  * @param serverResponse JSON response from the server.
@@ -1,4 +1,5 @@
1
1
  import { ErrorItem } from "./errorItem.js";
2
+ /** Structured error payload returned by v2 APIs. */
2
3
  export interface ErrorDetails {
3
4
  /**
4
5
  * The HTTP status code returned by the server.
@@ -1,6 +1,6 @@
1
1
  export { ErrorResponse, ErrorItem, } from "./error/index.js";
2
2
  export type { ErrorDetails } from "./error/index.js";
3
- export { Job, JobResponse, JobWebhook } from "./job/index.js";
3
+ export { Job, JobResponse, JobWebhook, } from "./job/index.js";
4
4
  export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
5
5
  export { LocalResponse } from "./localResponse.js";
6
6
  export { BaseResponse } from "./baseResponse.js";
@@ -1,5 +1,5 @@
1
1
  export { ErrorResponse, ErrorItem, } from "./error/index.js";
2
- export { Job, JobResponse, JobWebhook } from "./job/index.js";
2
+ export { Job, JobResponse, JobWebhook, } from "./job/index.js";
3
3
  export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
4
4
  export { LocalResponse } from "./localResponse.js";
5
5
  export { BaseResponse } from "./baseResponse.js";
@@ -2,6 +2,7 @@ import { StringDict } from "../../../parsing/index.js";
2
2
  import { InferenceModel } from "./inferenceModel.js";
3
3
  import { InferenceFile } from "./inferenceFile.js";
4
4
  import { InferenceJob } from "./inferenceJob.js";
5
+ /** Shared metadata container for v2 inference payloads. */
5
6
  export declare abstract class BaseInference {
6
7
  /**
7
8
  * Model info for the inference.
@@ -20,5 +21,6 @@ export declare abstract class BaseInference {
20
21
  */
21
22
  id: string;
22
23
  protected constructor(serverResponse: StringDict);
24
+ /** Returns a printable representation of inference metadata. */
23
25
  toString(): string;
24
26
  }
@@ -1,6 +1,7 @@
1
1
  import { InferenceModel } from "./inferenceModel.js";
2
2
  import { InferenceFile } from "./inferenceFile.js";
3
3
  import { InferenceJob } from "./inferenceJob.js";
4
+ /** Shared metadata container for v2 inference payloads. */
4
5
  export class BaseInference {
5
6
  constructor(serverResponse) {
6
7
  this.id = serverResponse["id"];
@@ -8,6 +9,7 @@ export class BaseInference {
8
9
  this.model = new InferenceModel(serverResponse["model"]);
9
10
  this.file = new InferenceFile(serverResponse["file"]);
10
11
  }
12
+ /** Returns a printable representation of inference metadata. */
11
13
  toString() {
12
14
  return ("Inference\n" +
13
15
  "#########\n" +
@@ -0,0 +1,33 @@
1
+ import { StringDict } from "../../../parsing/index.js";
2
+ import { ErrorResponse } from "../../../v2/index.js";
3
+ import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
4
+ /**
5
+ * Webhook payload returned when an inference fails before producing a result.
6
+ */
7
+ export declare class FailedInferenceResponse extends BaseResponse {
8
+ /**
9
+ * UUID of the failed inference.
10
+ */
11
+ inferenceId: string;
12
+ /**
13
+ * UUID of the model used.
14
+ */
15
+ modelId: string;
16
+ /**
17
+ * Name of the input file.
18
+ */
19
+ fileName: string;
20
+ /**
21
+ * Alias sent for the file, if any.
22
+ */
23
+ fileAlias?: string;
24
+ /**
25
+ * Problem details for the failure, if available.
26
+ */
27
+ error: ErrorResponse;
28
+ /**
29
+ * Date and time when the inference was started.
30
+ */
31
+ createdAt: Date | null;
32
+ constructor(serverResponse: StringDict);
33
+ }
@@ -0,0 +1,17 @@
1
+ import { parseDate } from "../../../parsing/index.js";
2
+ import { ErrorResponse } from "../../../v2/index.js";
3
+ import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
4
+ /**
5
+ * Webhook payload returned when an inference fails before producing a result.
6
+ */
7
+ export class FailedInferenceResponse extends BaseResponse {
8
+ constructor(serverResponse) {
9
+ super(serverResponse);
10
+ this.inferenceId = serverResponse["inference_id"];
11
+ this.modelId = serverResponse["model_id"];
12
+ this.fileName = serverResponse["file_name"];
13
+ this.fileAlias = serverResponse["file_alias"];
14
+ this.error = new ErrorResponse(serverResponse["error"]);
15
+ this.createdAt = parseDate(serverResponse["created_at"]);
16
+ }
17
+ }
@@ -2,8 +2,11 @@ import { FieldConfidence } from "./fieldConfidence.js";
2
2
  import { StringDict } from "../../../../parsing/stringDict.js";
3
3
  import { FieldLocation } from "./fieldLocation.js";
4
4
  export declare abstract class BaseField {
5
+ /** Indentation level used when rendering field text output. */
5
6
  protected _indentLevel: number;
7
+ /** Confidence level associated with this field. */
6
8
  confidence: FieldConfidence | undefined;
9
+ /** Optional list of source locations for this field. */
7
10
  locations: Array<FieldLocation> | undefined;
8
11
  protected constructor(rawResponse: StringDict, indentLevel?: number);
9
12
  }
@@ -2,9 +2,13 @@
2
2
  * Confidence level of a field as returned by the V2 API.
3
3
  */
4
4
  export declare enum FieldConfidence {
5
+ /** Maximum confidence level. */
5
6
  Certain = "Certain",
7
+ /** High confidence level. */
6
8
  High = "High",
9
+ /** Medium confidence level. */
7
10
  Medium = "Medium",
11
+ /** Low confidence level. */
8
12
  Low = "Low"
9
13
  }
10
14
  export declare namespace FieldConfidence {
@@ -4,9 +4,13 @@
4
4
  */
5
5
  export var FieldConfidence;
6
6
  (function (FieldConfidence) {
7
+ /** Maximum confidence level. */
7
8
  FieldConfidence["Certain"] = "Certain";
9
+ /** High confidence level. */
8
10
  FieldConfidence["High"] = "High";
11
+ /** Medium confidence level. */
9
12
  FieldConfidence["Medium"] = "Medium";
13
+ /** Low confidence level. */
10
14
  FieldConfidence["Low"] = "Low";
11
15
  })(FieldConfidence || (FieldConfidence = {}));
12
16
  // eslint-disable-next-line @typescript-eslint/no-namespace
@@ -5,4 +5,9 @@ import { StringDict } from "../../../../parsing/stringDict.js";
5
5
  import { ListField } from "./listField.js";
6
6
  import { ObjectField } from "./objectField.js";
7
7
  import { SimpleField } from "./simpleField.js";
8
+ /**
9
+ * Create a field from a server response.
10
+ * @param serverResponse Server response.
11
+ * @param indentLevel Indent level.
12
+ */
8
13
  export declare function createField(serverResponse: StringDict, indentLevel?: number): SimpleField | ObjectField | ListField;
@@ -2,6 +2,11 @@ import { MindeeDeserializationError } from "../../../../errors/index.js";
2
2
  import { ListField } from "./listField.js";
3
3
  import { ObjectField } from "./objectField.js";
4
4
  import { SimpleField } from "./simpleField.js";
5
+ /**
6
+ * Create a field from a server response.
7
+ * @param serverResponse Server response.
8
+ * @param indentLevel Indent level.
9
+ */
5
10
  export function createField(serverResponse, indentLevel = 0) {
6
11
  if (typeof serverResponse !== "object" || serverResponse === null) {
7
12
  throw new MindeeDeserializationError(`Unrecognized field format ${JSON.stringify(serverResponse)}.`);
@@ -9,5 +9,6 @@ export declare class FieldLocation {
9
9
  /** 0-based page index of where the polygon is located. */
10
10
  readonly page: any;
11
11
  constructor(serverResponse: StringDict);
12
+ /** Returns a readable location string. */
12
13
  toString(): string;
13
14
  }
@@ -7,6 +7,7 @@ export class FieldLocation {
7
7
  this.polygon = new Polygon(...serverResponse["polygon"]);
8
8
  this.page = serverResponse["page"];
9
9
  }
10
+ /** Returns a readable location string. */
10
11
  toString() {
11
12
  return `${this.polygon} on page ${this.page}`;
12
13
  }
@@ -2,11 +2,16 @@ import { StringDict } from "../../../../parsing/stringDict.js";
2
2
  import type { ListField } from "./listField.js";
3
3
  import type { ObjectField } from "./objectField.js";
4
4
  import type { SimpleField } from "./simpleField.js";
5
+ /** Typed map of extraction fields returned by the API. */
5
6
  export declare class InferenceFields extends Map<string, SimpleField | ObjectField | ListField> {
7
+ /** Indentation level used when rendering text output. */
6
8
  protected _indentLevel: number;
7
9
  constructor(serverResponse: StringDict, indentLevel?: number);
10
+ /** Returns a field as a `SimpleField`, or throws if the type mismatches. */
8
11
  getSimpleField(fieldName: string): SimpleField;
12
+ /** Returns a field as an `ObjectField`, or throws if the type mismatches. */
9
13
  getObjectField(fieldName: string): ObjectField;
14
+ /** Returns a field as a `ListField`, or throws if the type mismatches. */
10
15
  getListField(fieldName: string): ListField;
11
16
  toString(indent?: number): string;
12
17
  }
@@ -1,4 +1,5 @@
1
1
  import { createField } from "./fieldFactory.js";
2
+ /** Typed map of extraction fields returned by the API. */
2
3
  export class InferenceFields extends Map {
3
4
  constructor(serverResponse, indentLevel = 0) {
4
5
  super(Object.entries(serverResponse).map(([key, value]) => {
@@ -6,6 +7,7 @@ export class InferenceFields extends Map {
6
7
  }));
7
8
  this._indentLevel = indentLevel;
8
9
  }
10
+ /** Returns a field as a `SimpleField`, or throws if the type mismatches. */
9
11
  getSimpleField(fieldName) {
10
12
  const field = this.get(fieldName);
11
13
  if (field === undefined) {
@@ -16,6 +18,7 @@ export class InferenceFields extends Map {
16
18
  }
17
19
  return field;
18
20
  }
21
+ /** Returns a field as an `ObjectField`, or throws if the type mismatches. */
19
22
  getObjectField(fieldName) {
20
23
  const field = this.get(fieldName);
21
24
  if (field === undefined) {
@@ -26,6 +29,7 @@ export class InferenceFields extends Map {
26
29
  }
27
30
  return field;
28
31
  }
32
+ /** Returns a field as a `ListField`, or throws if the type mismatches. */
29
33
  getListField(fieldName) {
30
34
  const field = this.get(fieldName);
31
35
  if (field === undefined) {
@@ -2,6 +2,7 @@ import { StringDict } from "../../../../parsing/stringDict.js";
2
2
  import { BaseField } from "./baseField.js";
3
3
  import { ObjectField } from "./objectField.js";
4
4
  import { SimpleField } from "./simpleField.js";
5
+ /** List-valued inference field. */
5
6
  export declare class ListField extends BaseField {
6
7
  /**
7
8
  * Items contained in the list.
@@ -16,5 +17,6 @@ export declare class ListField extends BaseField {
16
17
  */
17
18
  get objectItems(): Array<ObjectField>;
18
19
  constructor(serverResponse: StringDict, indentLevel?: number);
20
+ /** Returns a readable representation of list items. */
19
21
  toString(): string;
20
22
  }
@@ -3,6 +3,7 @@ import { BaseField } from "./baseField.js";
3
3
  import { ObjectField } from "./objectField.js";
4
4
  import { SimpleField } from "./simpleField.js";
5
5
  import { createField } from "./fieldFactory.js";
6
+ /** List-valued inference field. */
6
7
  export class ListField extends BaseField {
7
8
  /**
8
9
  * SimpleField items from the list.
@@ -43,6 +44,7 @@ export class ListField extends BaseField {
43
44
  return createField(item, indentLevel + 1);
44
45
  });
45
46
  }
47
+ /** Returns a readable representation of list items. */
46
48
  toString() {
47
49
  if (!this.items || this.items.length === 0) {
48
50
  return "\n";
@@ -3,7 +3,9 @@ import { StringDict } from "../../../../parsing/stringDict.js";
3
3
  import { BaseField } from "./baseField.js";
4
4
  import type { SimpleField } from "./simpleField.js";
5
5
  import type { ListField } from "./listField.js";
6
+ /** Object-valued inference field. */
6
7
  export declare class ObjectField extends BaseField {
8
+ /** Nested fields carried by this object. */
7
9
  readonly fields: InferenceFields;
8
10
  /**
9
11
  * Retrieves the simple sub-fields in the object.
@@ -48,6 +50,8 @@ export declare class ObjectField extends BaseField {
48
50
  */
49
51
  getObjectField(fieldName: string): ObjectField;
50
52
  constructor(serverResponse: StringDict, indentLevel?: number);
53
+ /** Returns a readable representation of nested fields. */
51
54
  toString(): string;
55
+ /** Returns a compact representation suitable for list items. */
52
56
  toStringFromList(): string;
53
57
  }
@@ -1,5 +1,6 @@
1
1
  import { InferenceFields } from "./inferenceFields.js";
2
2
  import { BaseField } from "./baseField.js";
3
+ /** Object-valued inference field. */
3
4
  export class ObjectField extends BaseField {
4
5
  /**
5
6
  * Retrieves the simple sub-fields in the object.
@@ -95,9 +96,11 @@ export class ObjectField extends BaseField {
95
96
  super(serverResponse, indentLevel);
96
97
  this.fields = new InferenceFields(serverResponse["fields"], this._indentLevel + 1);
97
98
  }
99
+ /** Returns a readable representation of nested fields. */
98
100
  toString() {
99
101
  return "\n" + (this.fields ? this.fields.toString(1) : "");
100
102
  }
103
+ /** Returns a compact representation suitable for list items. */
101
104
  toStringFromList() {
102
105
  return this.fields ? this.fields.toString(2).substring(4) : "";
103
106
  }
@@ -1,4 +1,5 @@
1
1
  import { StringDict } from "../../../../parsing/stringDict.js";
2
+ /** Metadata produced by RAG-enabled extraction. */
2
3
  export declare class RagMetadata {
3
4
  /**
4
5
  * The UUID of the matched document used during the RAG operation.
@@ -1,3 +1,4 @@
1
+ /** Metadata produced by RAG-enabled extraction. */
1
2
  export class RagMetadata {
2
3
  constructor(serverResponse) {
3
4
  this.retrievedDocumentId = serverResponse["retrieved_document_id"] ?? undefined;
@@ -1,10 +1,12 @@
1
1
  import { StringDict } from "../../../../parsing/stringDict.js";
2
2
  import { RawTextPage } from "./rawTextPage.js";
3
+ /** Full raw OCR text grouped by page. */
3
4
  export declare class RawText {
4
5
  /**
5
6
  * List of pages with their extracted text content.
6
7
  */
7
8
  pages: Array<RawTextPage>;
8
9
  constructor(serverResponse: StringDict);
10
+ /** Returns concatenated raw text for all pages. */
9
11
  toString(): string;
10
12
  }
@@ -1,8 +1,10 @@
1
1
  import { RawTextPage } from "./rawTextPage.js";
2
+ /** Full raw OCR text grouped by page. */
2
3
  export class RawText {
3
4
  constructor(serverResponse) {
4
5
  this.pages = serverResponse["pages"] ? serverResponse["pages"].map((rawTextPage) => new RawTextPage(rawTextPage)) : [];
5
6
  }
7
+ /** Returns concatenated raw text for all pages. */
6
8
  toString() {
7
9
  return this.pages.map(page => page.toString()).join("\n\n");
8
10
  }
@@ -1,5 +1,6 @@
1
1
  import { StringDict } from "../../../../parsing/stringDict.js";
2
2
  import { BaseField } from "./baseField.js";
3
+ /** Scalar inference field. */
3
4
  export declare class SimpleField extends BaseField {
4
5
  /**
5
6
  * The untyped value of the field.
@@ -23,5 +24,6 @@ export declare class SimpleField extends BaseField {
23
24
  * Retrieves a boolean field value as a boolean.
24
25
  */
25
26
  get booleanValue(): boolean | null;
27
+ /** Returns a readable scalar representation. */
26
28
  toString(): string;
27
29
  }
@@ -1,4 +1,5 @@
1
1
  import { BaseField } from "./baseField.js";
2
+ /** Scalar inference field. */
2
3
  export class SimpleField extends BaseField {
3
4
  constructor(serverResponse, indentLevel = 0) {
4
5
  super(serverResponse, indentLevel);
@@ -32,6 +33,7 @@ export class SimpleField extends BaseField {
32
33
  }
33
34
  return this.value;
34
35
  }
36
+ /** Returns a readable scalar representation. */
35
37
  toString() {
36
38
  if (this.value === null) {
37
39
  return "";
@@ -1,4 +1,5 @@
1
1
  import { StringDict } from "../../../parsing/stringDict.js";
2
+ /** File metadata attached to a v2 inference. */
2
3
  export declare class InferenceFile {
3
4
  /**
4
5
  * Name of the file.
@@ -17,5 +18,6 @@ export declare class InferenceFile {
17
18
  */
18
19
  mimeType: string;
19
20
  constructor(serverResponse: StringDict);
21
+ /** Returns a printable representation of file metadata. */
20
22
  toString(): string;
21
23
  }
@@ -1,3 +1,4 @@
1
+ /** File metadata attached to a v2 inference. */
1
2
  export class InferenceFile {
2
3
  constructor(serverResponse) {
3
4
  this.name = serverResponse["name"];
@@ -5,6 +6,7 @@ export class InferenceFile {
5
6
  this.pageCount = serverResponse["page_count"];
6
7
  this.mimeType = serverResponse["mime_type"];
7
8
  }
9
+ /** Returns a printable representation of file metadata. */
8
10
  toString() {
9
11
  return ("File\n" +
10
12
  "====\n" +