mindee 4.29.0-rc2 → 4.29.0-rc3

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,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.29.0-rc3 - 2025-07-25
4
+ ### Changes
5
+ * :sparkles: add support for URL input source
6
+ ### Fixes
7
+ * :arrow_up: bump dependencies to cover vulnerabilities
8
+
9
+
3
10
  ## v4.29.0-rc2 - 2025-07-25
4
11
  ### Changes
5
12
  * :recycle: harmonize with other client libraries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.29.0-rc2",
3
+ "version": "4.29.0-rc3",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/clientV2.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Base64Input, BufferInput, BytesInput, LocalInputSource, PathInput, StreamInput, UrlInput } from "./input";
1
+ import { Base64Input, BufferInput, BytesInput, InputSource, PathInput, StreamInput, UrlInput } from "./input";
2
2
  import { InferenceResponse, JobResponse } from "./parsing/v2";
3
3
  import { MindeeApiV2 } from "./http/mindeeApiV2";
4
4
  import { Readable } from "stream";
@@ -106,7 +106,7 @@ export interface ClientOptions {
106
106
  */
107
107
  export declare class ClientV2 {
108
108
  #private;
109
- /** Key of the API. */
109
+ /** Mindee API handler. */
110
110
  protected mindeeApi: MindeeApiV2;
111
111
  /**
112
112
  * @param {ClientOptions} options options for the initialization of a client.
@@ -114,12 +114,12 @@ export declare class ClientV2 {
114
114
  constructor({ apiKey, throwOnError, debug }?: ClientOptions);
115
115
  /**
116
116
  * Send the document to an asynchronous endpoint and return its ID in the queue.
117
- * @param inputSource file to parse.
117
+ * @param inputSource file or URL to parse.
118
118
  * @param params parameters relating to prediction options.
119
119
  * @category Asynchronous
120
120
  * @returns a `Promise` containing the job (queue) corresponding to a document.
121
121
  */
122
- enqueueInference(inputSource: LocalInputSource, params: InferenceParameters): Promise<JobResponse>;
122
+ enqueueInference(inputSource: InputSource, params: InferenceParameters): Promise<JobResponse>;
123
123
  /**
124
124
  * Retrieves an inference.
125
125
  *
@@ -152,7 +152,7 @@ export declare class ClientV2 {
152
152
  * @category Synchronous
153
153
  * @returns a `Promise` containing parsing results.
154
154
  */
155
- enqueueAndGetInference(inputDoc: LocalInputSource, params: InferenceParameters): Promise<InferenceResponse>;
155
+ enqueueAndGetInference(inputDoc: InputSource, params: InferenceParameters): Promise<InferenceResponse>;
156
156
  /**
157
157
  * Load an input source from a local path.
158
158
  * @param inputPath
package/src/clientV2.js CHANGED
@@ -38,7 +38,7 @@ class ClientV2 {
38
38
  }
39
39
  /**
40
40
  * Send the document to an asynchronous endpoint and return its ID in the queue.
41
- * @param inputSource file to parse.
41
+ * @param inputSource file or URL to parse.
42
42
  * @param params parameters relating to prediction options.
43
43
  * @category Asynchronous
44
44
  * @returns a `Promise` containing the job (queue) corresponding to a document.
@@ -1,20 +1,20 @@
1
1
  import { ApiSettingsV2 } from "./apiSettingsV2";
2
2
  import { InferenceParameters } from "../clientV2";
3
3
  import { InferenceResponse, JobResponse } from "../parsing/v2";
4
- import { LocalInputSource } from "../input";
4
+ import { InputSource } from "../input";
5
5
  export declare class MindeeApiV2 {
6
6
  #private;
7
7
  settings: ApiSettingsV2;
8
8
  constructor(apiKey?: string);
9
9
  /**
10
10
  * Sends a file to the inference queue.
11
- * @param inputDoc Local file loaded as an input.
11
+ * @param inputSource Local file loaded as an input.
12
12
  * @param params {InferenceParameters} parameters relating to the enqueueing options.
13
13
  * @category V2
14
14
  * @throws Error if the server's response contains one.
15
15
  * @returns a `Promise` containing a job response.
16
16
  */
17
- reqPostInferenceEnqueue(inputDoc: LocalInputSource, params: InferenceParameters): Promise<JobResponse>;
17
+ reqPostInferenceEnqueue(inputSource: InputSource, params: InferenceParameters): Promise<JobResponse>;
18
18
  /**
19
19
  * Requests the job of a queued document from the API.
20
20
  * Throws an error if the server's response contains one.
@@ -14,6 +14,7 @@ const apiSettingsV2_1 = require("./apiSettingsV2");
14
14
  const v2_1 = require("../parsing/v2");
15
15
  const form_data_1 = __importDefault(require("form-data"));
16
16
  const baseEndpoint_1 = require("./baseEndpoint");
17
+ const input_1 = require("../input");
17
18
  const mindeeError_1 = require("../errors/mindeeError");
18
19
  const logger_1 = require("../logger");
19
20
  class MindeeApiV2 {
@@ -23,18 +24,18 @@ class MindeeApiV2 {
23
24
  }
24
25
  /**
25
26
  * Sends a file to the inference queue.
26
- * @param inputDoc Local file loaded as an input.
27
+ * @param inputSource Local file loaded as an input.
27
28
  * @param params {InferenceParameters} parameters relating to the enqueueing options.
28
29
  * @category V2
29
30
  * @throws Error if the server's response contains one.
30
31
  * @returns a `Promise` containing a job response.
31
32
  */
32
- async reqPostInferenceEnqueue(inputDoc, params) {
33
- await inputDoc.init();
33
+ async reqPostInferenceEnqueue(inputSource, params) {
34
+ await inputSource.init();
34
35
  if (params.modelId === undefined || params.modelId === null || params.modelId === "") {
35
36
  throw new Error("Model ID must be provided");
36
37
  }
37
- const result = await __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_documentEnqueuePost).call(this, inputDoc, params);
38
+ const result = await __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_documentEnqueuePost).call(this, inputSource, params);
38
39
  if (result.data.error?.code !== undefined) {
39
40
  throw new mindeeError_1.MindeeHttpErrorV2(result.data.error.code, result.data.error.message ?? "Unknown error.");
40
41
  }
@@ -78,7 +79,7 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function
78
79
  logger_1.logger.error(`Raised '${e}' Couldn't deserialize response object:\n${JSON.stringify(result.data)}`);
79
80
  throw new mindeeError_1.MindeeApiV2Error("Couldn't deserialize response object.");
80
81
  }
81
- }, _MindeeApiV2_documentEnqueuePost = function _MindeeApiV2_documentEnqueuePost(inputDoc, params) {
82
+ }, _MindeeApiV2_documentEnqueuePost = function _MindeeApiV2_documentEnqueuePost(inputSource, params) {
82
83
  const form = new form_data_1.default();
83
84
  form.append("model_id", params.modelId);
84
85
  if (params.rag) {
@@ -87,9 +88,14 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function
87
88
  if (params.webhookIds && params.webhookIds.length > 0) {
88
89
  form.append("webhook_ids", params.webhookIds.join(","));
89
90
  }
90
- form.append("file", inputDoc.fileObject, {
91
- filename: inputDoc.filename,
92
- });
91
+ if (inputSource instanceof input_1.LocalInputSource) {
92
+ form.append("file", inputSource.fileObject, {
93
+ filename: inputSource.filename,
94
+ });
95
+ }
96
+ else {
97
+ form.append("url", inputSource.url);
98
+ }
93
99
  const path = "/v2/inferences/enqueue";
94
100
  const headers = { ...this.settings.baseHeaders, ...form.getHeaders() };
95
101
  const options = {
@@ -1,7 +1,7 @@
1
1
  import { InputSource } from "./inputSource";
2
2
  import { BytesInput } from "./bytesInput";
3
3
  export declare class UrlInput extends InputSource {
4
- private readonly url;
4
+ readonly url: string;
5
5
  constructor({ url }: {
6
6
  url: string;
7
7
  });
@@ -1,9 +1,7 @@
1
1
  import { FieldConfidence } from "./fieldConfidence";
2
- import { FieldLocation } from "./fieldLocation";
3
2
  import { StringDict } from "../../common";
4
3
  export declare abstract class BaseField {
5
4
  protected _indentLevel: number;
6
- locations: Array<FieldLocation> | undefined;
7
5
  confidence: FieldConfidence | undefined;
8
6
  protected constructor(rawResponse: StringDict, indentLevel?: number);
9
7
  }
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseField = void 0;
4
- const fieldLocation_1 = require("./fieldLocation");
5
4
  class BaseField {
6
5
  constructor(rawResponse, indentLevel = 0) {
7
6
  this._indentLevel = indentLevel;
8
- if (rawResponse["locations"]) {
9
- this.locations = rawResponse["locations"].map((location) => {
10
- return location ? new fieldLocation_1.FieldLocation(location) : "";
11
- });
12
- }
13
7
  if (rawResponse["confidence"] !== undefined) {
14
8
  this.confidence = rawResponse["confidence"];
15
9
  }
@@ -0,0 +1,7 @@
1
+ import { BaseField } from "./baseField";
2
+ import { FieldLocation } from "./fieldLocation";
3
+ import { StringDict } from "../../common";
4
+ export declare class DynamicField extends BaseField {
5
+ locations: Array<FieldLocation> | undefined;
6
+ constructor(rawResponse: StringDict, indentLevel?: number);
7
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DynamicField = void 0;
4
+ const baseField_1 = require("./baseField");
5
+ const fieldLocation_1 = require("./fieldLocation");
6
+ class DynamicField extends baseField_1.BaseField {
7
+ constructor(rawResponse, indentLevel = 0) {
8
+ super(rawResponse, indentLevel);
9
+ if (rawResponse["locations"]) {
10
+ this.locations = rawResponse["locations"].map((location) => {
11
+ return location ? new fieldLocation_1.FieldLocation(location) : "";
12
+ });
13
+ }
14
+ }
15
+ }
16
+ exports.DynamicField = DynamicField;
@@ -1,7 +1,7 @@
1
- import { BaseField } from "./baseField";
2
1
  import { InferenceFields } from "./inferenceFields";
3
2
  import { StringDict } from "../../common";
4
- export declare class ObjectField extends BaseField {
3
+ import { DynamicField } from "./dynamicField";
4
+ export declare class ObjectField extends DynamicField {
5
5
  readonly fields: InferenceFields;
6
6
  constructor(serverResponse: StringDict, indentLevel?: number);
7
7
  toString(): string;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectField = void 0;
4
- const baseField_1 = require("./baseField");
5
4
  const inferenceFields_1 = require("./inferenceFields");
6
- class ObjectField extends baseField_1.BaseField {
5
+ const dynamicField_1 = require("./dynamicField");
6
+ class ObjectField extends dynamicField_1.DynamicField {
7
7
  constructor(serverResponse, indentLevel = 0) {
8
8
  super(serverResponse, indentLevel);
9
9
  this.fields = new inferenceFields_1.InferenceFields(serverResponse["fields"], this._indentLevel + 1);
@@ -1,6 +1,6 @@
1
- import { BaseField } from "./baseField";
2
1
  import { StringDict } from "../../common";
3
- export declare class SimpleField extends BaseField {
2
+ import { DynamicField } from "./dynamicField";
3
+ export declare class SimpleField extends DynamicField {
4
4
  readonly value: string | number | boolean | null;
5
5
  constructor(serverResponse: StringDict, indentLevel?: number);
6
6
  toString(): string;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SimpleField = void 0;
4
- const baseField_1 = require("./baseField");
5
- class SimpleField extends baseField_1.BaseField {
4
+ const dynamicField_1 = require("./dynamicField");
5
+ class SimpleField extends dynamicField_1.DynamicField {
6
6
  constructor(serverResponse, indentLevel = 0) {
7
7
  super(serverResponse, indentLevel);
8
8
  this.value =