mindee 4.27.0 → 4.27.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,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.27.1 - 2025-04-23
4
+ ### Fixes
5
+ * :bug: fix workflow polling not working when ran with ts-node
6
+ * :memo: add example script for workflow polling
7
+
8
+
3
9
  ## v4.27.0 - 2025-04-23
4
10
  ### Changes
5
11
  * :sparkles: add support for RAG polling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.27.0",
3
+ "version": "4.27.1",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/client.js CHANGED
@@ -81,9 +81,6 @@ class Client {
81
81
  */
82
82
  async enqueue(productClass, inputSource, params = {}) {
83
83
  const endpoint = params?.endpoint ?? __classPrivateFieldGet(this, _Client_instances, "m", _Client_initializeOTSEndpoint).call(this, productClass);
84
- if (params.workflowId) {
85
- endpoint.useWorkflowId(params.workflowId);
86
- }
87
84
  if (inputSource === undefined) {
88
85
  throw new Error("The 'parse' function requires an input document.");
89
86
  }
@@ -93,8 +90,8 @@ class Client {
93
90
  fullText: this.getBooleanParam(params.fullText),
94
91
  pageOptions: params?.pageOptions,
95
92
  cropper: this.getBooleanParam(params.cropper),
96
- workflowId: params.workflowId,
97
- rag: this.getBooleanParam(params.rag)
93
+ rag: this.getBooleanParam(params.rag),
94
+ workflowId: params.workflowId
98
95
  });
99
96
  return new common_1.AsyncPredictResponse(productClass, rawResponse.data);
100
97
  }
@@ -64,6 +64,7 @@ export declare class Endpoint extends BaseEndpoint {
64
64
  * @param fullText
65
65
  * @param cropper
66
66
  * @param rag
67
+ * @param workflowId
67
68
  */
68
- protected sendFileForPrediction(input: InputSource, predictUrl: string, includeWords?: boolean, fullText?: boolean, cropper?: boolean, rag?: boolean): Promise<EndpointResponse>;
69
+ protected sendFileForPrediction(input: InputSource, predictUrl: string, includeWords?: boolean, fullText?: boolean, cropper?: boolean, rag?: boolean, workflowId?: string | undefined): Promise<EndpointResponse>;
69
70
  }
@@ -64,7 +64,7 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
64
64
  if (params.pageOptions !== undefined) {
65
65
  await super.cutDocPages(params.inputDoc, params.pageOptions);
66
66
  }
67
- const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.fullText, params.cropper, params.rag);
67
+ const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.fullText, params.cropper, params.rag, params.workflowId);
68
68
  if (!(0, responseValidation_1.isValidAsyncResponse)(response)) {
69
69
  (0, error_1.handleError)(this.urlName, response, this.extractStatusMessage(response));
70
70
  }
@@ -137,8 +137,9 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
137
137
  * @param fullText
138
138
  * @param cropper
139
139
  * @param rag
140
+ * @param workflowId
140
141
  */
141
- sendFileForPrediction(input, predictUrl, includeWords = false, fullText = false, cropper = false, rag = false) {
142
+ sendFileForPrediction(input, predictUrl, includeWords = false, fullText = false, cropper = false, rag = false, workflowId = undefined) {
142
143
  return new Promise((resolve, reject) => {
143
144
  const searchParams = new url_1.URLSearchParams();
144
145
  if (cropper) {
@@ -163,7 +164,13 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
163
164
  form.append("include_mvision", "true");
164
165
  }
165
166
  const headers = { ...this.settings.baseHeaders, ...form.getHeaders() };
166
- let path = `${this.urlRoot}/${predictUrl}`;
167
+ let path;
168
+ if (workflowId === undefined) {
169
+ path = `${this.urlRoot}/${predictUrl}`;
170
+ }
171
+ else {
172
+ path = `/v1/workflows/${workflowId}/predict_async`;
173
+ }
167
174
  if (searchParams.toString().length > 0) {
168
175
  path += `?${searchParams}`;
169
176
  }
@@ -184,8 +191,18 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
184
191
  exports.Endpoint = Endpoint;
185
192
  _Endpoint_instances = new WeakSet(), _Endpoint_predictReqPost = function _Endpoint_predictReqPost(input, includeWords = false, fullText = false, cropper = false) {
186
193
  return this.sendFileForPrediction(input, "predict", includeWords, fullText, cropper);
187
- }, _Endpoint_predictAsyncReqPost = function _Endpoint_predictAsyncReqPost(input, includeWords = false, fullText = false, cropper = false, rag = false) {
188
- return this.sendFileForPrediction(input, "predict_async", includeWords, fullText, cropper, rag);
194
+ }, _Endpoint_predictAsyncReqPost = function _Endpoint_predictAsyncReqPost(
195
+ /**
196
+ * Make a request to POST a document for async prediction.
197
+ * @param input
198
+ * @param includeWords
199
+ * @param fullText
200
+ * @param cropper
201
+ * @param rag
202
+ * @param workflowId
203
+ */
204
+ input, includeWords = false, fullText = false, cropper = false, rag = false, workflowId = undefined) {
205
+ return this.sendFileForPrediction(input, "predict_async", includeWords, fullText, cropper, rag, workflowId);
189
206
  }, _Endpoint_documentQueueReqGet = function _Endpoint_documentQueueReqGet(queueId) {
190
207
  return new Promise((resolve, reject) => {
191
208
  const options = {