mindee 4.31.0 → 4.31.1

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,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.31.1 - 2025-10-08
4
+ ### Fixes
5
+ * :bug: make sure input sources are only initialized once
6
+
7
+
3
8
  ## v4.31.0 - 2025-10-07
4
9
  ### Changes
5
10
  * :sparkles: allow comparing v2 field confidence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.31.0",
3
+ "version": "4.31.1",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/clientV2.js CHANGED
@@ -46,9 +46,7 @@ class ClientV2 {
46
46
  if (inputSource === undefined) {
47
47
  throw new Error("The 'enqueue' function requires an input document.");
48
48
  }
49
- if (!inputSource.isInitialized()) {
50
- await inputSource.init();
51
- }
49
+ await inputSource.init();
52
50
  return await this.mindeeApi.reqPostInferenceEnqueue(inputSource, params);
53
51
  }
54
52
  /**
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Base64Input = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class Base64Input extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputString, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class Base64Input extends localInputSource_1.LocalInputSource {
13
14
  this.inputString = inputString;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from base64");
16
21
  this.fileObject = Buffer.from(this.inputString, "base64");
17
22
  this.mimeType = await this.checkMimetype();
18
23
  // clear out the string
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BufferInput = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class BufferInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ buffer, filename }) {
8
9
  super({
@@ -12,6 +13,10 @@ class BufferInput extends localInputSource_1.LocalInputSource {
12
13
  this.filename = filename;
13
14
  }
14
15
  async init() {
16
+ if (this.initialized) {
17
+ return;
18
+ }
19
+ logger_1.logger.debug("Loading from buffer");
15
20
  this.mimeType = await this.checkMimetype();
16
21
  this.initialized = true;
17
22
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BytesInput = void 0;
4
4
  const inputSource_1 = require("./inputSource");
5
5
  const localInputSource_1 = require("./localInputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class BytesInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputBytes, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class BytesInput extends localInputSource_1.LocalInputSource {
13
14
  this.inputBytes = inputBytes;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from bytes");
16
21
  this.fileObject = Buffer.from(this.inputBytes);
17
22
  this.mimeType = await this.checkMimetype();
18
23
  this.inputBytes = new Uint8Array(0);
@@ -19,7 +19,10 @@ class PathInput extends localInputSource_1.LocalInputSource {
19
19
  this.filename = path_1.default.basename(this.inputPath);
20
20
  }
21
21
  async init() {
22
- logger_1.logger.debug(`Loading from: ${this.inputPath}`);
22
+ if (this.initialized) {
23
+ return;
24
+ }
25
+ logger_1.logger.debug(`Loading from path: ${this.inputPath}`);
23
26
  this.fileObject = Buffer.from(await fs_1.promises.readFile(this.inputPath));
24
27
  this.mimeType = await this.checkMimetype();
25
28
  this.initialized = true;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StreamInput = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class StreamInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputStream, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class StreamInput extends localInputSource_1.LocalInputSource {
13
14
  this.inputStream = inputStream;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from stream");
16
21
  this.fileObject = await this.stream2buffer(this.inputStream);
17
22
  this.mimeType = await this.checkMimetype();
18
23
  this.initialized = true;
@@ -8,12 +8,17 @@ const crypto_1 = require("crypto");
8
8
  const promises_1 = require("fs/promises");
9
9
  const https_1 = require("https");
10
10
  const bytesInput_1 = require("./bytesInput");
11
+ const logger_1 = require("../../logger");
11
12
  class UrlInput extends inputSource_1.InputSource {
12
13
  constructor({ url }) {
13
14
  super();
14
15
  this.url = url;
15
16
  }
16
17
  async init() {
18
+ if (this.initialized) {
19
+ return;
20
+ }
21
+ logger_1.logger.debug(`source URL: ${this.url}`);
17
22
  if (!this.url.toLowerCase().startsWith("https")) {
18
23
  throw new Error("URL must be HTTPS");
19
24
  }