mindee 5.6.0 → 5.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +1 -3
  3. package/src/http/apiCore.d.ts +0 -7
  4. package/src/http/apiCore.js +0 -11
  5. package/src/http/baseSettings.js +2 -2
  6. package/src/http/dispatcher.d.ts +6 -0
  7. package/src/http/dispatcher.js +17 -0
  8. package/src/http/index.d.ts +1 -0
  9. package/src/http/index.js +1 -0
  10. package/src/input/urlInput.js +3 -2
  11. package/src/v1/http/baseEndpoint.d.ts +15 -0
  12. package/src/v1/http/baseEndpoint.js +17 -0
  13. package/src/v1/http/endpoint.d.ts +2 -5
  14. package/src/v1/http/endpoint.js +6 -6
  15. package/src/v1/http/workflowEndpoint.d.ts +2 -5
  16. package/src/v1/http/workflowEndpoint.js +5 -5
  17. package/src/v2/client.d.ts +9 -0
  18. package/src/v2/client.js +18 -1
  19. package/src/v2/clientOptions/{baseParameters.d.ts → baseProductParameters.d.ts} +7 -19
  20. package/src/v2/clientOptions/baseProductParameters.js +30 -0
  21. package/src/v2/clientOptions/baseSearchParameters.d.ts +26 -0
  22. package/src/v2/clientOptions/baseSearchParameters.js +23 -0
  23. package/src/v2/clientOptions/index.d.ts +2 -1
  24. package/src/v2/clientOptions/index.js +2 -1
  25. package/src/v2/http/mindeeApiV2.d.ts +16 -15
  26. package/src/v2/http/mindeeApiV2.js +33 -32
  27. package/src/v2/index.d.ts +2 -1
  28. package/src/v2/index.js +1 -0
  29. package/src/v2/parsing/inference/field/listField.d.ts +1 -1
  30. package/src/v2/parsing/inference/field/listField.js +9 -9
  31. package/src/v2/parsing/search/baseSearchResponse.d.ts +18 -0
  32. package/src/v2/parsing/search/baseSearchResponse.js +17 -0
  33. package/src/v2/parsing/search/index.d.ts +2 -0
  34. package/src/v2/parsing/search/index.js +2 -0
  35. package/src/v2/parsing/search/searchModels.d.ts +6 -0
  36. package/src/v2/parsing/search/searchModels.js +19 -0
  37. package/src/v2/parsing/search/searchRagDocument.d.ts +35 -0
  38. package/src/v2/parsing/search/searchRagDocument.js +16 -0
  39. package/src/v2/parsing/search/searchRagDocuments.d.ts +9 -0
  40. package/src/v2/parsing/search/searchRagDocuments.js +26 -0
  41. package/src/v2/parsing/search/searchResponse.d.ts +3 -13
  42. package/src/v2/parsing/search/searchResponse.js +3 -17
  43. package/src/v2/product/baseProduct.d.ts +5 -2
  44. package/src/v2/product/baseProduct.js +3 -0
  45. package/src/v2/product/classification/classification.d.ts +3 -3
  46. package/src/v2/product/classification/classification.js +3 -3
  47. package/src/v2/product/classification/params/classificationParameters.d.ts +4 -18
  48. package/src/v2/product/classification/params/classificationParameters.js +3 -17
  49. package/src/v2/product/crop/crop.d.ts +3 -3
  50. package/src/v2/product/crop/crop.js +3 -3
  51. package/src/v2/product/crop/params/cropParameters.d.ts +4 -18
  52. package/src/v2/product/crop/params/cropParameters.js +3 -17
  53. package/src/v2/product/extraction/extraction.d.ts +3 -3
  54. package/src/v2/product/extraction/extraction.js +3 -3
  55. package/src/v2/product/extraction/params/extractionParameters.d.ts +5 -21
  56. package/src/v2/product/extraction/params/extractionParameters.js +12 -32
  57. package/src/v2/product/ocr/ocr.d.ts +3 -3
  58. package/src/v2/product/ocr/ocr.js +3 -3
  59. package/src/v2/product/ocr/params/ocrParameters.d.ts +4 -18
  60. package/src/v2/product/ocr/params/ocrParameters.js +3 -17
  61. package/src/v2/product/split/params/splitParameters.d.ts +4 -18
  62. package/src/v2/product/split/params/splitParameters.js +3 -17
  63. package/src/v2/product/split/split.d.ts +3 -3
  64. package/src/v2/product/split/split.js +3 -3
  65. package/src/v2/search/baseSearch.d.ts +15 -0
  66. package/src/v2/search/baseSearch.js +19 -0
  67. package/src/v2/search/index.d.ts +6 -0
  68. package/src/v2/search/index.js +6 -0
  69. package/src/v2/search/models/index.d.ts +3 -0
  70. package/src/v2/search/models/index.js +3 -0
  71. package/src/v2/search/models/modelSearch.d.ts +14 -0
  72. package/src/v2/search/models/modelSearch.js +20 -0
  73. package/src/v2/search/models/modelSearchParameters.d.ts +24 -0
  74. package/src/v2/search/models/modelSearchParameters.js +22 -0
  75. package/src/v2/search/models/modelSearchResponse.d.ts +14 -0
  76. package/src/v2/search/models/modelSearchResponse.js +14 -0
  77. package/src/v2/search/ragDocuments/index.d.ts +3 -0
  78. package/src/v2/search/ragDocuments/index.js +3 -0
  79. package/src/v2/search/ragDocuments/ragDocumentSearch.d.ts +14 -0
  80. package/src/v2/search/ragDocuments/ragDocumentSearch.js +20 -0
  81. package/src/v2/search/ragDocuments/ragDocumentSearchParameters.d.ts +24 -0
  82. package/src/v2/search/ragDocuments/ragDocumentSearchParameters.js +24 -0
  83. package/src/v2/search/ragDocuments/ragDocumentSearchResponse.d.ts +14 -0
  84. package/src/v2/search/ragDocuments/ragDocumentSearchResponse.js +14 -0
  85. package/src/v2/clientOptions/baseParameters.js +0 -42
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Mindee Node.js API Library Changelog
2
2
 
3
+ ## v5.7.0 - 2026-08-20
4
+ ### Changes
5
+ * :sparkles: add support for RAG search API
6
+ * :recycle: rework and mutualize a lot of http classes
7
+
8
+ ### Fixes
9
+ * :bug: fix undici unexpectedly re-using request agents when not specified
10
+
11
+
12
+ ## v5.6.1 - 2026-08-19
13
+ ### Changes
14
+ * :arrow_up: security updates
15
+
3
16
 
4
17
  ## v5.6.0 - 2026-07-21
5
18
  ### Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "author": {
6
6
  "name": "Mindee",
@@ -32,11 +32,9 @@
32
32
  "test:integration:light": "node tests/runner.mjs integration",
33
33
  "test:v2": "tsc --noEmit && node tests/runner.mjs spec v2",
34
34
  "lint": "tsc --noEmit && eslint --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
35
- "lint:check": "npm run lint",
36
35
  "lint:fix": "tsc --noEmit && eslint --fix --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
37
36
  "lint:package": "npm run build:dist && publint ./dist && attw --pack ./dist --profile esm-only",
38
37
  "lint:secrets": "secretlint '**/*'",
39
- "lint:full": "npm run lint:check && npm run lint:package && npm run lint:secrets",
40
38
  "license:check": "license-checker-rseidelsohn --onlyAllow \"MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;LGPL-3.0-or-later;Python-2.0;BlueOak-1.0.0;CC-BY-3.0;CC0-1.0;0BSD;LGPL-3.0-only;WTFPL;Artistic-2.0;Unlicense\"",
41
39
  "docs": "typedoc --out docs/_build ./src/index.ts",
42
40
  "docs:dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/",
@@ -1,5 +1,4 @@
1
1
  import { Dispatcher, FormData } from "undici";
2
- import { InputSource, PageOptions } from "../input/index.js";
3
2
  export declare const TIMEOUT_SECS_DEFAULT: number;
4
3
  export interface RequestOptions {
5
4
  hostname?: string;
@@ -16,12 +15,6 @@ export interface BaseHttpResponse {
16
15
  [key: string]: any;
17
16
  };
18
17
  }
19
- /**
20
- * Cuts a document's pages according to the given options.
21
- * @param inputDoc input document.
22
- * @param pageOptions page cutting options.
23
- */
24
- export declare function cutDocPages(inputDoc: InputSource, pageOptions: PageOptions): Promise<void>;
25
18
  /**
26
19
  * Reads a response from the API and processes it.
27
20
  * @param dispatcher custom dispatcher to use for the request.
@@ -1,17 +1,6 @@
1
1
  import { logger } from "../logger.js";
2
2
  import { request } from "undici";
3
- import { LocalInputSource } from "../input/index.js";
4
3
  export const TIMEOUT_SECS_DEFAULT = 120;
5
- /**
6
- * Cuts a document's pages according to the given options.
7
- * @param inputDoc input document.
8
- * @param pageOptions page cutting options.
9
- */
10
- export async function cutDocPages(inputDoc, pageOptions) {
11
- if (inputDoc instanceof LocalInputSource && inputDoc.isPdf()) {
12
- await inputDoc.applyPageOptions(pageOptions);
13
- }
14
- }
15
4
  /**
16
5
  * Reads a response from the API and processes it.
17
6
  * @param dispatcher custom dispatcher to use for the request.
@@ -1,8 +1,8 @@
1
- import { getGlobalDispatcher } from "undici";
2
1
  // eslint-disable-next-line no-restricted-imports
3
2
  import packageJson from "../../package.json" with { type: "json" };
4
3
  import * as os from "os";
5
4
  import { TIMEOUT_SECS_DEFAULT } from "./apiCore.js";
5
+ import { resolveDefaultDispatcher } from "./dispatcher.js";
6
6
  export class BaseSettings {
7
7
  constructor(apiKey, dispatcher) {
8
8
  if (apiKey === undefined || !apiKey || apiKey.length === 0) {
@@ -11,7 +11,7 @@ export class BaseSettings {
11
11
  else {
12
12
  this.apiKey = apiKey;
13
13
  }
14
- this.dispatcher = dispatcher ?? getGlobalDispatcher();
14
+ this.dispatcher = dispatcher ?? resolveDefaultDispatcher();
15
15
  this.hostname = this.hostnameFromEnv();
16
16
  this.timeoutSecs = process.env.MINDEE_REQUEST_TIMEOUT
17
17
  ? parseInt(process.env.MINDEE_REQUEST_TIMEOUT)
@@ -0,0 +1,6 @@
1
+ import { Dispatcher } from "undici";
2
+ /**
3
+ * Returns the global undici dispatcher, provided it was created by the same
4
+ * undici copy this library imports.
5
+ */
6
+ export declare function resolveDefaultDispatcher(): Dispatcher;
@@ -0,0 +1,17 @@
1
+ import { Agent, Dispatcher, getGlobalDispatcher } from "undici";
2
+ import { logger } from "../logger.js";
3
+ /** Library-owned fallback dispatcher, shared across all components. */
4
+ let fallbackDispatcher;
5
+ /**
6
+ * Returns the global undici dispatcher, provided it was created by the same
7
+ * undici copy this library imports.
8
+ */
9
+ export function resolveDefaultDispatcher() {
10
+ const globalDispatcher = getGlobalDispatcher();
11
+ if (globalDispatcher instanceof Dispatcher) {
12
+ return globalDispatcher;
13
+ }
14
+ logger.debug("Global dispatcher belongs to a different undici instance, using a library-owned Agent instead.");
15
+ fallbackDispatcher ?? (fallbackDispatcher = new Agent());
16
+ return fallbackDispatcher;
17
+ }
@@ -1,3 +1,4 @@
1
1
  export type { BaseHttpResponse } from "./apiCore.js";
2
2
  export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, } from "../v1/http/responseValidation.js";
3
3
  export { BaseSettings } from "./baseSettings.js";
4
+ export { resolveDefaultDispatcher } from "./dispatcher.js";
package/src/http/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, } from "../v1/http/responseValidation.js";
2
2
  export { BaseSettings } from "./baseSettings.js";
3
+ export { resolveDefaultDispatcher } from "./dispatcher.js";
@@ -3,16 +3,17 @@ import { URL } from "url";
3
3
  import { basename, extname } from "path";
4
4
  import { randomBytes } from "crypto";
5
5
  import { writeFile } from "fs/promises";
6
- import { request, getGlobalDispatcher } from "undici";
6
+ import { request } from "undici";
7
7
  import { logger } from "../logger.js";
8
8
  import { MindeeInputSourceError } from "../errors/index.js";
9
+ import { resolveDefaultDispatcher } from "../http/dispatcher.js";
9
10
  import { BytesInput } from "./bytesInput.js";
10
11
  /** Remote input source represented by a validated HTTPS URL. */
11
12
  export class UrlInput extends InputSource {
12
13
  constructor({ url, dispatcher }) {
13
14
  super();
14
15
  this.url = url;
15
- this.dispatcher = dispatcher ?? getGlobalDispatcher();
16
+ this.dispatcher = dispatcher ?? resolveDefaultDispatcher();
16
17
  logger.debug("Initialized URL input source.");
17
18
  }
18
19
  /** Initializes this source by validating and storing the URL. */
@@ -0,0 +1,15 @@
1
+ import { InputSource, PageOptions } from "../../input/index.js";
2
+ import { ApiSettingsV1 } from "../../v1/http/apiSettingsV1.js";
3
+ export declare abstract class BaseEndpoint {
4
+ /** Settings relating to the API. */
5
+ settings: ApiSettingsV1;
6
+ /** Root of the URL for API calls. */
7
+ urlRoot: string;
8
+ protected constructor(settings: ApiSettingsV1, urlRoot: string);
9
+ /**
10
+ * Cuts a document's pages according to the given options.
11
+ * @param inputDoc input document.
12
+ * @param pageOptions page cutting options.
13
+ */
14
+ cutDocPages(inputDoc: InputSource, pageOptions: PageOptions): Promise<void>;
15
+ }
@@ -0,0 +1,17 @@
1
+ import { LocalInputSource } from "../../input/index.js";
2
+ export class BaseEndpoint {
3
+ constructor(settings, urlRoot) {
4
+ this.settings = settings;
5
+ this.urlRoot = urlRoot;
6
+ }
7
+ /**
8
+ * Cuts a document's pages according to the given options.
9
+ * @param inputDoc input document.
10
+ * @param pageOptions page cutting options.
11
+ */
12
+ async cutDocPages(inputDoc, pageOptions) {
13
+ if (inputDoc instanceof LocalInputSource && inputDoc.isPdf()) {
14
+ await inputDoc.applyPageOptions(pageOptions);
15
+ }
16
+ }
17
+ }
@@ -3,15 +3,12 @@ import { StringDict } from "../../parsing/stringDict.js";
3
3
  import { BaseHttpResponse } from "../../http/apiCore.js";
4
4
  import { ApiSettingsV1 } from "./apiSettingsV1.js";
5
5
  import { PredictParams } from "./httpParams.js";
6
+ import { BaseEndpoint } from "../../v1/http/baseEndpoint.js";
6
7
  /**
7
8
  * Endpoint for a product (OTS or Custom).
8
9
  */
9
- export declare class Endpoint {
10
+ export declare class Endpoint extends BaseEndpoint {
10
11
  #private;
11
- /** Settings relating to the API. */
12
- settings: ApiSettingsV1;
13
- /** Root of the URL for API calls. */
14
- urlRoot: string;
15
12
  /** URL of a product. */
16
13
  urlName: string;
17
14
  /** Account owning the product. */
@@ -7,17 +7,17 @@ var _Endpoint_instances, _Endpoint_predictReqPost, _Endpoint_predictAsyncReqPost
7
7
  import { URLSearchParams } from "url";
8
8
  import { FormData } from "undici";
9
9
  import { LocalInputSource } from "../../input/index.js";
10
- import { cutDocPages, sendRequestAndReadResponse, } from "../../http/apiCore.js";
10
+ import { sendRequestAndReadResponse, } from "../../http/apiCore.js";
11
11
  import { handleError } from "./errors.js";
12
12
  import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation.js";
13
+ import { BaseEndpoint } from "../../v1/http/baseEndpoint.js";
13
14
  /**
14
15
  * Endpoint for a product (OTS or Custom).
15
16
  */
16
- export class Endpoint {
17
+ export class Endpoint extends BaseEndpoint {
17
18
  constructor(urlName, owner, version, settings) {
19
+ super(settings, `/v1/products/${owner}/${urlName}/v${version}`);
18
20
  _Endpoint_instances.add(this);
19
- this.settings = settings;
20
- this.urlRoot = `/v1/products/${owner}/${urlName}/v${version}`;
21
21
  this.owner = owner;
22
22
  this.urlName = urlName;
23
23
  this.version = version;
@@ -32,7 +32,7 @@ export class Endpoint {
32
32
  async predict(params) {
33
33
  await params.inputDoc.init();
34
34
  if (params.pageOptions !== undefined) {
35
- await cutDocPages(params.inputDoc, params.pageOptions);
35
+ await this.cutDocPages(params.inputDoc, params.pageOptions);
36
36
  }
37
37
  const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictReqPost).call(this, params.inputDoc, params.includeWords, params.fullText, params.cropper);
38
38
  if (!isValidSyncResponse(response)) {
@@ -50,7 +50,7 @@ export class Endpoint {
50
50
  async predictAsync(params) {
51
51
  await params.inputDoc.init();
52
52
  if (params.pageOptions !== undefined) {
53
- await cutDocPages(params.inputDoc, params.pageOptions);
53
+ await this.cutDocPages(params.inputDoc, params.pageOptions);
54
54
  }
55
55
  const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.fullText, params.cropper, params.rag, params.workflowId);
56
56
  if (!isValidAsyncResponse(response)) {
@@ -3,15 +3,12 @@ import { ExecutionPriority } from "../../v1/parsing/common/index.js";
3
3
  import { BaseHttpResponse } from "../../http/apiCore.js";
4
4
  import { ApiSettingsV1 } from "./apiSettingsV1.js";
5
5
  import { WorkflowParams } from "./httpParams.js";
6
+ import { BaseEndpoint } from "../../v1/http/baseEndpoint.js";
6
7
  /**
7
8
  * Endpoint for a workflow.
8
9
  */
9
- export declare class WorkflowEndpoint {
10
+ export declare class WorkflowEndpoint extends BaseEndpoint {
10
11
  #private;
11
- /** Settings relating to the API. */
12
- settings: ApiSettingsV1;
13
- /** Root of the URL for API calls. */
14
- urlRoot: string;
15
12
  constructor(settings: ApiSettingsV1, workflowId: string);
16
13
  /**
17
14
  * Sends a document to a workflow execution.
@@ -7,17 +7,17 @@ var _WorkflowEndpoint_instances, _WorkflowEndpoint_workflowReqPost;
7
7
  import { URLSearchParams } from "url";
8
8
  import { FormData } from "undici";
9
9
  import { LocalInputSource } from "../../input/index.js";
10
- import { cutDocPages, sendRequestAndReadResponse, } from "../../http/apiCore.js";
10
+ import { sendRequestAndReadResponse, } from "../../http/apiCore.js";
11
11
  import { handleError } from "./errors.js";
12
12
  import { isValidSyncResponse } from "./responseValidation.js";
13
+ import { BaseEndpoint } from "../../v1/http/baseEndpoint.js";
13
14
  /**
14
15
  * Endpoint for a workflow.
15
16
  */
16
- export class WorkflowEndpoint {
17
+ export class WorkflowEndpoint extends BaseEndpoint {
17
18
  constructor(settings, workflowId) {
19
+ super(settings, `/v1/workflows/${workflowId}/executions`);
18
20
  _WorkflowEndpoint_instances.add(this);
19
- this.settings = settings;
20
- this.urlRoot = `/v1/workflows/${workflowId}/executions`;
21
21
  }
22
22
  /**
23
23
  * Sends a document to a workflow execution.
@@ -29,7 +29,7 @@ export class WorkflowEndpoint {
29
29
  async executeWorkflow(params) {
30
30
  await params.inputDoc.init();
31
31
  if (params.pageOptions !== undefined) {
32
- await cutDocPages(params.inputDoc, params.pageOptions);
32
+ await this.cutDocPages(params.inputDoc, params.pageOptions);
33
33
  }
34
34
  const response = await __classPrivateFieldGet(this, _WorkflowEndpoint_instances, "m", _WorkflowEndpoint_workflowReqPost).call(this, params);
35
35
  if (!isValidSyncResponse(response)) {
@@ -5,6 +5,7 @@ import { SearchResponse } from "./parsing/search/index.js";
5
5
  import { MindeeApiV2 } from "./http/mindeeApiV2.js";
6
6
  import { PollingOptions, PollingOptionsConstructor } from "./clientOptions/index.js";
7
7
  import { BaseProduct } from "../v2/product/baseProduct.js";
8
+ import { BaseSearch } from "../v2/search/baseSearch.js";
8
9
  /**
9
10
  * Options for the V2 Mindee Client.
10
11
  * @example
@@ -37,8 +38,16 @@ export declare class Client {
37
38
  * @param name Optional name filter.
38
39
  * @param modelType Optional model type filter.
39
40
  * @returns a `Promise` containing the search response.
41
+ * @deprecated Use `search(ModelSearch, {})` instead.
40
42
  */
41
43
  searchModels(name?: string, modelType?: string): Promise<SearchResponse>;
44
+ /**
45
+ * Searches for resources matching the given criteria.
46
+ * @param search
47
+ * @param searchParameters Search parameters.
48
+ * @returns a `Promise` containing the search response.
49
+ */
50
+ search<S extends typeof BaseSearch>(search: S, searchParameters: InstanceType<S["parametersClass"]> | ConstructorParameters<S["parametersClass"]>[0]): Promise<InstanceType<S["responseClass"]>>;
42
51
  /** Enqueues a product inference job without waiting for completion. */
43
52
  enqueue<P extends typeof BaseProduct>(product: P, inputSource: InputSource, params: InstanceType<P["parametersClass"]> | ConstructorParameters<P["parametersClass"]>[0]): Promise<JobResponse>;
44
53
  /**
package/src/v2/client.js CHANGED
@@ -5,6 +5,7 @@ import { LOG_LEVELS, logger } from "../logger.js";
5
5
  import { MindeeApiV2 } from "./http/mindeeApiV2.js";
6
6
  import { MindeeHttpErrorV2 } from "./http/errors.js";
7
7
  import { PollingOptions } from "./clientOptions/index.js";
8
+ import { ModelSearch } from "../v2/search/models/modelSearch.js";
8
9
  /**
9
10
  * Mindee Client V2 class that centralizes most basic operations.
10
11
  */
@@ -30,9 +31,25 @@ export class Client {
30
31
  * @param name Optional name filter.
31
32
  * @param modelType Optional model type filter.
32
33
  * @returns a `Promise` containing the search response.
34
+ * @deprecated Use `search(ModelSearch, {})` instead.
33
35
  */
34
36
  async searchModels(name, modelType) {
35
- return await this.mindeeApi.reqGetSearchModel(name, modelType);
37
+ return await this.search(ModelSearch, { name: name, modelType: modelType });
38
+ }
39
+ /**
40
+ * Searches for resources matching the given criteria.
41
+ * @param search
42
+ * @param searchParameters Search parameters.
43
+ * @returns a `Promise` containing the search response.
44
+ */
45
+ async search(search, searchParameters) {
46
+ if (!searchParameters) {
47
+ throw new MindeeError("Search parameters are required.");
48
+ }
49
+ const paramsInstance = searchParameters instanceof search.parametersClass
50
+ ? searchParameters
51
+ : new search.parametersClass(searchParameters);
52
+ return await this.mindeeApi.reqGetSearch(search, paramsInstance);
36
53
  }
37
54
  /** Enqueues a product inference job without waiting for completion. */
38
55
  async enqueue(product, inputSource, params) {
@@ -1,28 +1,16 @@
1
- import { FormData } from "undici";
2
1
  /**
3
2
  * Constructor parameters for BaseParameters and its subclasses.
4
3
  */
5
- export interface BaseParametersConstructor {
4
+ export interface BaseProductParametersConstructor {
6
5
  modelId: string;
7
6
  alias?: string;
8
7
  webhookIds?: string[];
9
8
  closeFile?: boolean;
10
9
  }
11
10
  /**
12
- * Parameters accepted by all v2 products.
13
- *
14
- * All fields are optional except `modelId`.
15
- *
16
- * @category ClientV2
17
- * @example
18
- * const params = {
19
- * modelId: "YOUR_MODEL_ID",
20
- * rag: true,
21
- * alias: "YOUR_ALIAS",
22
- * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
23
- * };
11
+ * Base parameters for sending a file to a Mindee V2 product.
24
12
  */
25
- export declare abstract class BaseParameters {
13
+ export declare abstract class BaseProductParameters {
26
14
  /**
27
15
  * Model ID to use for the inference. **Required.**
28
16
  */
@@ -43,10 +31,10 @@ export declare abstract class BaseParameters {
43
31
  * Set to `false` to keep it open.
44
32
  */
45
33
  closeFile?: boolean;
46
- protected constructor(params: BaseParametersConstructor);
34
+ protected constructor(params: BaseProductParametersConstructor);
47
35
  /**
48
- * Returns the form data to send to the API.
49
- * @returns A `FormData` object.
36
+ * Gets the request parameters for the enqueue request.
37
+ * @returns A `Record` mapping parameter names to their string values.
50
38
  */
51
- getFormData(): FormData;
39
+ getRequestParameters(): Record<string, string>;
52
40
  }
@@ -0,0 +1,30 @@
1
+ import { MindeeConfigurationError } from "../../errors/index.js";
2
+ /**
3
+ * Base parameters for sending a file to a Mindee V2 product.
4
+ */
5
+ export class BaseProductParameters {
6
+ constructor(params) {
7
+ if (params.modelId === undefined || params.modelId === null || params.modelId === "") {
8
+ throw new MindeeConfigurationError("Model ID must be provided");
9
+ }
10
+ this.modelId = params.modelId;
11
+ this.alias = params.alias;
12
+ this.webhookIds = params.webhookIds;
13
+ this.closeFile = params.closeFile;
14
+ }
15
+ /**
16
+ * Gets the request parameters for the enqueue request.
17
+ * @returns A `Record` mapping parameter names to their string values.
18
+ */
19
+ getRequestParameters() {
20
+ const parameters = {};
21
+ parameters["model_id"] = this.modelId;
22
+ if (this.alias !== undefined && this.alias !== null) {
23
+ parameters["alias"] = this.alias;
24
+ }
25
+ if (this.webhookIds && this.webhookIds.length > 0) {
26
+ parameters["webhook_ids"] = this.webhookIds.join(",");
27
+ }
28
+ return parameters;
29
+ }
30
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Constructor parameters for BaseSearchParameters and its subclasses.
3
+ */
4
+ export interface BaseSearchParametersConstructor {
5
+ page?: number;
6
+ perPage?: number;
7
+ }
8
+ /**
9
+ * Base parameters for searches.
10
+ */
11
+ export declare abstract class BaseSearchParameters {
12
+ /**
13
+ * 1-based page index.
14
+ */
15
+ page?: number;
16
+ /**
17
+ * Number of items per page.
18
+ */
19
+ perPage?: number;
20
+ protected constructor(params: BaseSearchParametersConstructor);
21
+ /**
22
+ * Gets the request parameters for the search request.
23
+ * @returns A `Record` mapping parameter names to their string values.
24
+ */
25
+ getRequestParameters(): Record<string, string>;
26
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Base parameters for searches.
3
+ */
4
+ export class BaseSearchParameters {
5
+ constructor(params) {
6
+ this.page = params.page;
7
+ this.perPage = params.perPage;
8
+ }
9
+ /**
10
+ * Gets the request parameters for the search request.
11
+ * @returns A `Record` mapping parameter names to their string values.
12
+ */
13
+ getRequestParameters() {
14
+ const parameters = {};
15
+ if (this.page !== null && this.page !== undefined && this.page > 0) {
16
+ parameters["page"] = this.page.toString();
17
+ }
18
+ if (this.perPage !== null && this.perPage !== undefined && this.perPage > 0) {
19
+ parameters["per_page"] = this.perPage.toString();
20
+ }
21
+ return parameters;
22
+ }
23
+ }
@@ -1,3 +1,4 @@
1
1
  export { PollingOptions } from "./pollingOptions.js";
2
2
  export type { PollingOptionsConstructor, TimerOptions, } from "./pollingOptions.js";
3
- export { BaseParameters } from "./baseParameters.js";
3
+ export { BaseProductParameters } from "./baseProductParameters.js";
4
+ export { BaseSearchParameters } from "./baseSearchParameters.js";
@@ -1,2 +1,3 @@
1
1
  export { PollingOptions } from "./pollingOptions.js";
2
- export { BaseParameters } from "./baseParameters.js";
2
+ export { BaseProductParameters } from "./baseProductParameters.js";
3
+ export { BaseSearchParameters } from "./baseSearchParameters.js";
@@ -1,10 +1,11 @@
1
1
  import { ApiSettings } from "./apiSettings.js";
2
2
  import { Dispatcher } from "undici";
3
- import { BaseParameters } from "../../v2/index.js";
3
+ import { BaseProductParameters } from "../../v2/index.js";
4
+ import { BaseSearchParameters } from "../../v2/clientOptions/baseSearchParameters.js";
4
5
  import { JobResponse } from "../../v2/parsing/index.js";
5
6
  import { InputSource } from "../../input/index.js";
6
7
  import { BaseProduct } from "../../v2/product/baseProduct.js";
7
- import { SearchResponse } from "../../v2/parsing/search/index.js";
8
+ import { BaseSearch } from "../../v2/search/baseSearch.js";
8
9
  /**
9
10
  * Mindee V2 API handler.
10
11
  */
@@ -13,35 +14,28 @@ export declare class MindeeApiV2 {
13
14
  settings: ApiSettings;
14
15
  constructor(dispatcher?: Dispatcher, apiKey?: string);
15
16
  /**
16
- * Search for models available to the account.
17
- * @param name Optional name filter.
18
- * @param modelType Optional model type filter.
19
- * @returns a `Promise` containing the search response.
20
- */
21
- reqGetSearchModel(name?: string, modelType?: string): Promise<SearchResponse>;
22
- /**
23
- * Sends a document to the inference queue.
17
+ * Send a file to the asynchronous processing queue for inference processing.
24
18
  * @param product Product to enqueue.
25
19
  * @param inputSource Local or remote file as an input.
26
20
  * @param params {ExtractionParameters} parameters relating to the enqueueing options.
27
21
  */
28
- reqPostProductEnqueue(product: typeof BaseProduct, inputSource: InputSource, params: BaseParameters): Promise<JobResponse>;
22
+ reqPostProductEnqueue(product: typeof BaseProduct, inputSource: InputSource, params: BaseProductParameters): Promise<JobResponse>;
29
23
  /**
30
- * Get the specified Job by its ID.
24
+ * Get the status of an inference that was previously enqueued.
31
25
  * Throws an error if the server's response contains an error.
32
26
  * @param jobId The Job ID as returned by the enqueue request.
33
27
  * @returns a `Promise` containing the job response.
34
28
  */
35
29
  reqGetJobById(jobId: string): Promise<JobResponse>;
36
30
  /**
37
- * Get the specified Job from a polling URL.
31
+ * Get the status of an inference that was previously enqueued.
38
32
  * Throws an error if the server's response contains an error.
39
33
  * @param pollingUrl The polling URL as returned by a Job's pollingUrl property.
40
34
  * @returns a `Promise` containing the job response.
41
35
  */
42
36
  reqGetJobByUrl(pollingUrl: string): Promise<JobResponse>;
43
37
  /**
44
- * Get the result of a queued document from the API.
38
+ * Get the result of an inference that was previously enqueued.
45
39
  * Throws an error if the server's response contains an error.
46
40
  * @param product
47
41
  * @param inferenceId The inference ID for the result.
@@ -49,11 +43,18 @@ export declare class MindeeApiV2 {
49
43
  */
50
44
  reqGetProductResultById<P extends typeof BaseProduct>(product: P, inferenceId: string): Promise<InstanceType<P["responseClass"]>>;
51
45
  /**
52
- * Get the result of a queued document from the API.
46
+ * Get the result of an inference that was previously enqueued.
53
47
  * Throws an error if the server's response contains an error.
54
48
  * @param product
55
49
  * @param url The URL as returned by a Job's resultUrl property.
56
50
  * @returns a `Promise` containing the parsed result.
57
51
  */
58
52
  reqGetProductResultByUrl<P extends typeof BaseProduct>(product: P, url: string): Promise<InstanceType<P["responseClass"]>>;
53
+ /**
54
+ * Searches for resources matching the given criteria.
55
+ * @param search
56
+ * @param parameters Search parameters.
57
+ * @returns a `Promise` containing the search response.
58
+ */
59
+ reqGetSearch<S extends typeof BaseSearch>(search: S, parameters: BaseSearchParameters): Promise<InstanceType<S["responseClass"]>>;
59
60
  }