@docling/docling-client 2.145.0 → 2.147.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.
@@ -1,7 +1,7 @@
1
1
  # Python client parity
2
2
 
3
- This document compares `@docling/docling-client` with Docling Python 2.145.0
4
- at commit `45d334e`, specifically:
3
+ This document compares `@docling/docling-client` with Docling Python 2.147.0
4
+ at commit `e3681a6`, specifically:
5
5
 
6
6
  - `DoclingServiceClient`
7
7
  - `AsyncDoclingServiceClient`
@@ -15,23 +15,24 @@ additional TypeScript capabilities are documented after the parity tables.
15
15
 
16
16
  ## Client configuration
17
17
 
18
- | Python constructor capability | TypeScript | Parity notes |
19
- | ----------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
20
- | Service URL | `baseUrl` | Both normalize trailing slashes and reject `/v1`, query, and fragment components. |
21
- | API key | `apiKey` | HTTP uses `X-Api-Key`; WebSocket uses the query parameter and also the header in Node. |
22
- | Default conversion options | `options` | Deep-copied at construction; per-call merge is shallow. |
23
- | Status watcher | `statusWatcher` | `websocket` default or `polling`. |
24
- | WebSocket polling fallback | `webSocketFallbackToPoll` | Enabled by default. |
25
- | Poll server wait | `pollServerWaitSeconds` | Five seconds by default. |
26
- | Poll client interval | `pollClientIntervalMs` | Defaults to the server-wait duration. |
27
- | Job timeout | `jobTimeoutMs` | Five minutes by default. |
28
- | Conversion concurrency | `maxConcurrency` | Eight by default; valid range 1–512. |
29
- | HTTP retries | `httpRetries` | Three by default. |
30
- | HTTP timeout | `httpTimeoutMs` | Fetch has one total per-attempt timeout; Python/httpx exposes distinct connect and read/write/pool timeouts. |
31
- | HTTP backoff | `httpBackoffBaseMs` | One second by default. |
32
- | Artifact timeout and size | `artifactDownload.timeoutMs`, `maxBytes` | Same 60-second and 512-MiB defaults. |
33
- | Private artifact override | `artifactDownload.allowPrivateUrls` | Public TypeScript option; Python keeps its equivalent internal. |
34
- | Owned resource cleanup | `close()` | TypeScript close is asynchronous, idempotent, closes an injected transport once, and prevents later requests. |
18
+ | Python constructor capability | TypeScript | Parity notes |
19
+ | ----------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
20
+ | Service URL | `baseUrl` | Both normalize trailing slashes and reject `/v1`, query, and fragment components. |
21
+ | API key | `apiKey` | HTTP uses `X-Api-Key`; WebSocket uses the query parameter and also the header in Node. |
22
+ | Default conversion options | `options` | Deep-copied at construction; per-call merge is shallow. |
23
+ | Status watcher | `statusWatcher` | `websocket` default or `polling`. |
24
+ | WebSocket polling fallback | `webSocketFallbackToPoll` | Enabled by default. |
25
+ | Poll server wait | `pollServerWaitSeconds` | Five seconds by default. |
26
+ | Poll client interval | `pollClientIntervalMs` | Defaults to the server-wait duration. |
27
+ | Job timeout | `jobTimeoutMs` | Five minutes by default. |
28
+ | Conversion concurrency | `maxConcurrency` | Eight by default; valid range 1–512. |
29
+ | HTTP retries | `httpRetries` | Three by default. |
30
+ | HTTP timeout | `httpTimeoutMs` | Fetch has one total per-attempt timeout; Python/httpx exposes distinct connect and read/write/pool timeouts. |
31
+ | HTTP backoff | `httpBackoffBaseMs` | One second by default. |
32
+ | Artifact timeout and size | `artifactDownloadTimeout` / `maxArtifactDownloadBytes` | Direct or `artifactDownload.timeoutMs`, `maxBytes`. Same 60-second and 512-MiB defaults. |
33
+ | Private artifact override | `allowPrivateArtifactUrls` | Direct or `artifactDownload.allowPrivateUrls`. Now supported in both Python and TypeScript. |
34
+ | Artifact URL allowlist | `artifactUrlAllowlist` | Direct or `artifactDownload.artifactUrlAllowlist`. Supported in both Python and TypeScript. |
35
+ | Owned resource cleanup | `close()` | TypeScript close is asynchronous, idempotent, closes an injected transport once, and prevents later requests. |
35
36
 
36
37
  `fetch`, `transport`, `webSocketFactory`, `artifactDownloader`, and artifact
37
38
  DNS/fetch injection are TypeScript extensions.
@@ -159,6 +160,62 @@ High-level limits match Python:
159
160
  TypeScript restricts limit values to safe integers, which is stricter than
160
161
  Python's unbounded integer type.
161
162
 
163
+ ## Service client changes (v2.147.0)
164
+
165
+ Python v2.147.0 at commit `e3681a6` formally exposes `artifact_url_allowlist` and `_allow_private_artifact_urls` in `DoclingServiceClient.__init__`:
166
+
167
+ ```
168
+ https://github.com/docling-project/docling/blob/v2.147.0/docling/service_client/client.py#L933
169
+ ```
170
+
171
+ TypeScript fully supports these options:
172
+
173
+ - `artifactUrlAllowlist` (and nested `artifactDownload.artifactUrlAllowlist`) parses origins to selectively trust internal endpoints.
174
+ - `allowPrivateArtifactUrls` (and nested `artifactDownload.allowPrivateUrls`) completely bypasses public-address checks when desired.
175
+
176
+ | Python (v2.147.0) | TypeScript | Option Key |
177
+ | ------------------------------ | -------------------------- | -------------------------- |
178
+ | `artifact_url_allowlist` | `artifactUrlAllowlist` | `artifactUrlAllowlist` |
179
+ | `_allow_private_artifact_urls` | `allowPrivateArtifactUrls` | `allowPrivateArtifactUrls` |
180
+
181
+ ## Service client changes (v2.146.0)
182
+
183
+ Python v2.146.0 at commit `c622bcb` includes two service-facing fixes since
184
+ v2.145.0. The remaining v2.146.0 changes (VLM presets, LightOnOCR-3,
185
+ Nemotron parsing, and backend fixes) are server-side or core-library behavior
186
+ with no service-client or service-datamodel surface.
187
+
188
+ - `ArtifactRef.artifact_type` now allows `"chunks"`:
189
+
190
+ ```
191
+ https://github.com/docling-project/docling/blob/v2.146.0/docling/datamodel/service/responses.py#L148
192
+ ```
193
+
194
+ The TypeScript `ArtifactType` union includes `'chunks'` and the presigned
195
+ response validator accepts it. `selectDocumentArtifact()` still materializes
196
+ only `resource_bundle` or `json` artifacts, so a `chunks` artifact is never
197
+ mistaken for a document.
198
+
199
+ - The presigned-first auto-target path no longer hides the presigned rejection
200
+ when the `InBody` fallback is also refused. When the fallback fails with HTTP
201
+ 400 or 422, Python raises a combined `ServiceError` that keeps the fallback
202
+ status and appends the presigned detail:
203
+
204
+ ```
205
+ https://github.com/docling-project/docling/blob/v2.146.0/docling/service_client/client.py#L857
206
+ ```
207
+
208
+ TypeScript `combineInBodyFallbackError()` mirrors this and throws a
209
+ `DoclingServiceError` with the fallback status and the combined `detail`
210
+ that appends "The client tried the InBody target because the server rejected
211
+ the presigned_url target: <presigned detail>" to the fallback detail. Other
212
+ fallback failures propagate unchanged.
213
+
214
+ | Python (v2.146.0) | TypeScript | Wire key |
215
+ | --------------------------- | ------------------------------ | --------------- |
216
+ | `ArtifactRef.artifact_type` | `ArtifactType` | `artifact_type` |
217
+ | `_inbody_fallback_error()` | `combineInBodyFallbackError()` | `detail` |
218
+
162
219
  ## Service client changes (v2.145.0)
163
220
 
164
221
  Python v2.145.0 at commit `45d334e` includes two service-facing changes since
package/dist/index.cjs CHANGED
@@ -62,6 +62,7 @@ __export(index_exports, {
62
62
  fileSourceFromBinary: () => fileSourceFromBinary,
63
63
  materializePresignedResult: () => materializePresignedResult,
64
64
  normalizeSourceInput: () => normalizeSourceInput,
65
+ parseArtifactOrigin: () => parseArtifactOrigin,
65
66
  preflightFileSize: () => preflightFileSize,
66
67
  resolveConvertOptions: () => resolveConvertOptions,
67
68
  selectDocumentArtifact: () => selectDocumentArtifact,
@@ -192,6 +193,27 @@ var DoclingBatchConversionError = class extends DoclingError {
192
193
  };
193
194
 
194
195
  // src/artifacts.ts
196
+ function parseArtifactOrigin(value) {
197
+ try {
198
+ const url = new URL(value);
199
+ const protocol = url.protocol.toLowerCase();
200
+ if (protocol !== "http:" && protocol !== "https:") {
201
+ throw new Error("Only http and https protocols are supported");
202
+ }
203
+ const hostname = url.hostname.toLowerCase();
204
+ if (!hostname) {
205
+ throw new Error("Host is required");
206
+ }
207
+ const defaultPort = protocol === "http:" ? 80 : 443;
208
+ const port = url.port !== "" ? parseInt(url.port, 10) : defaultPort;
209
+ return { protocol: protocol.slice(0, -1), hostname, port };
210
+ } catch (error) {
211
+ throw new DoclingArtifactDownloadError(
212
+ `Invalid artifactUrlAllowlist entry ${JSON.stringify(value)}: expected an http(s) origin such as 'http://minio.storage.svc.cluster.local:9000'.`,
213
+ { cause: error }
214
+ );
215
+ }
216
+ }
195
217
  var ArtifactDownloader = class {
196
218
  #fetch;
197
219
  #resolver;
@@ -199,6 +221,7 @@ var ArtifactDownloader = class {
199
221
  #timeoutMs;
200
222
  #maxBytes;
201
223
  #maxRedirects;
224
+ #artifactUrlAllowlist;
202
225
  constructor(options = {}) {
203
226
  if (options.fetch === void 0 && globalThis.fetch === void 0) {
204
227
  throw new DoclingArtifactDownloadError(
@@ -211,6 +234,8 @@ var ArtifactDownloader = class {
211
234
  this.#timeoutMs = options.timeoutMs ?? 6e4;
212
235
  this.#maxBytes = options.maxBytes ?? 512 * 1024 * 1024;
213
236
  this.#maxRedirects = options.maxRedirects ?? 5;
237
+ const allowlist = options.artifactUrlAllowlist ?? [];
238
+ this.#artifactUrlAllowlist = allowlist.map(parseArtifactOrigin);
214
239
  validateArtifactLimits(this.#timeoutMs, this.#maxBytes, this.#maxRedirects);
215
240
  }
216
241
  async download(url, signal) {
@@ -287,13 +312,23 @@ var ArtifactDownloader = class {
287
312
  if (this.#allowPrivateUrls) {
288
313
  return;
289
314
  }
290
- const hostname = url.hostname.replace(/^\[|\]$/g, "");
315
+ const protocol = url.protocol.slice(0, -1).toLowerCase();
316
+ const hostname = url.hostname.toLowerCase();
317
+ const defaultPort = protocol === "http" ? 80 : 443;
318
+ const port = url.port !== "" ? parseInt(url.port, 10) : defaultPort;
319
+ const isTrusted = this.#artifactUrlAllowlist.some(
320
+ (origin) => origin.protocol === protocol && origin.hostname === hostname && origin.port === port
321
+ );
322
+ if (isTrusted) {
323
+ return;
324
+ }
325
+ const cleanHostname = url.hostname.replace(/^\[|\]$/g, "");
291
326
  let addresses;
292
327
  try {
293
- addresses = import_ipaddr.default.isValid(hostname) ? [hostname] : await this.#resolver(hostname);
328
+ addresses = import_ipaddr.default.isValid(cleanHostname) ? [cleanHostname] : await this.#resolver(cleanHostname);
294
329
  } catch (error) {
295
330
  throw new DoclingArtifactDownloadError(
296
- `Could not resolve artifact host ${hostname}`,
331
+ `Could not resolve artifact host ${cleanHostname}`,
297
332
  { cause: error }
298
333
  );
299
334
  }
@@ -2411,7 +2446,22 @@ var DoclingClient = class {
2411
2446
  this.#maxConcurrency = validateConcurrency(
2412
2447
  options.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY
2413
2448
  );
2414
- this.#artifactDownloader = options.artifactDownloader ?? new ArtifactDownloader(options.artifactDownload);
2449
+ const downloaderOptions = {
2450
+ ...options.artifactDownload
2451
+ };
2452
+ if (options.artifactDownloadTimeout !== void 0) {
2453
+ downloaderOptions.timeoutMs = options.artifactDownloadTimeout;
2454
+ }
2455
+ if (options.maxArtifactDownloadBytes !== void 0) {
2456
+ downloaderOptions.maxBytes = options.maxArtifactDownloadBytes;
2457
+ }
2458
+ if (options.artifactUrlAllowlist !== void 0) {
2459
+ downloaderOptions.artifactUrlAllowlist = options.artifactUrlAllowlist;
2460
+ }
2461
+ if (options.allowPrivateArtifactUrls !== void 0) {
2462
+ downloaderOptions.allowPrivateUrls = options.allowPrivateArtifactUrls;
2463
+ }
2464
+ this.#artifactDownloader = options.artifactDownloader ?? new ArtifactDownloader(downloaderOptions);
2415
2465
  }
2416
2466
  async health(options = {}) {
2417
2467
  const value = await this.#request("GET", "/health", {
@@ -2937,7 +2987,9 @@ var DoclingClient = class {
2937
2987
  target: { kind: "inbody" }
2938
2988
  },
2939
2989
  options
2940
- );
2990
+ ).catch((fallbackError) => {
2991
+ throw combineInBodyFallbackError(error, fallbackError);
2992
+ });
2941
2993
  });
2942
2994
  }
2943
2995
  #submitNormalizedWithAutoTarget(source, options, requestOptions) {
@@ -2955,7 +3007,9 @@ var DoclingClient = class {
2955
3007
  withJsonOutput(options),
2956
3008
  { kind: "inbody" },
2957
3009
  requestOptions
2958
- );
3010
+ ).catch((fallbackError) => {
3011
+ throw combineInBodyFallbackError(error, fallbackError);
3012
+ });
2959
3013
  });
2960
3014
  }
2961
3015
  async #submitRequestForTarget(request, options) {
@@ -3481,7 +3535,8 @@ function parsePresignedResponse(value) {
3481
3535
  "doctags",
3482
3536
  "doclang",
3483
3537
  "dclx",
3484
- "resource_bundle"
3538
+ "resource_bundle",
3539
+ "chunks"
3485
3540
  ].includes(String(artifact.artifact_type))) {
3486
3541
  throw schemaMismatch(`${artifactPath}.artifact_type is unsupported`);
3487
3542
  }
@@ -3785,6 +3840,18 @@ function shouldFallbackFromPresigned(error) {
3785
3840
  "enum"
3786
3841
  ].some((phrase) => detail.includes(phrase));
3787
3842
  }
3843
+ function combineInBodyFallbackError(presignedError, fallbackError) {
3844
+ if (!(presignedError instanceof DoclingHttpError) || !(fallbackError instanceof DoclingHttpError) || ![400, 422].includes(fallbackError.status)) {
3845
+ return fallbackError;
3846
+ }
3847
+ const fallbackDetail = httpDetail2(fallbackError.body);
3848
+ const prefix = fallbackDetail === void 0 ? "" : `${fallbackDetail} `;
3849
+ return new DoclingServiceError(fallbackError.message, {
3850
+ status: fallbackError.status,
3851
+ detail: `${prefix}The client tried the InBody target because the server rejected the presigned_url target: ${httpDetail2(presignedError.body)}`,
3852
+ cause: fallbackError
3853
+ });
3854
+ }
3788
3855
  function targetNeedsJson(target) {
3789
3856
  return target.kind === "inbody";
3790
3857
  }
@@ -4262,6 +4329,7 @@ function isRecord4(value) {
4262
4329
  fileSourceFromBinary,
4263
4330
  materializePresignedResult,
4264
4331
  normalizeSourceInput,
4332
+ parseArtifactOrigin,
4265
4333
  preflightFileSize,
4266
4334
  resolveConvertOptions,
4267
4335
  selectDocumentArtifact,