@docling/docling-client 2.146.0 → 2.148.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.
- package/PYTHON_CLIENT_PARITY.md +82 -19
- package/dist/index.cjs +69 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +68 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/PYTHON_CLIENT_PARITY.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Python client parity
|
|
2
2
|
|
|
3
|
-
This document compares `@docling/docling-client` with Docling Python 2.
|
|
4
|
-
at commit `
|
|
3
|
+
This document compares `@docling/docling-client` with Docling Python 2.148.0
|
|
4
|
+
at commit `0fa0918`, 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
|
|
19
|
-
| ----------------------------- |
|
|
20
|
-
| Service URL | `baseUrl`
|
|
21
|
-
| API key | `apiKey`
|
|
22
|
-
| Default conversion options | `options`
|
|
23
|
-
| Status watcher | `statusWatcher`
|
|
24
|
-
| WebSocket polling fallback | `webSocketFallbackToPoll`
|
|
25
|
-
| Poll server wait | `pollServerWaitSeconds`
|
|
26
|
-
| Poll client interval | `pollClientIntervalMs`
|
|
27
|
-
| Job timeout | `jobTimeoutMs`
|
|
28
|
-
| Conversion concurrency | `maxConcurrency`
|
|
29
|
-
| HTTP retries | `httpRetries`
|
|
30
|
-
| HTTP timeout | `httpTimeoutMs`
|
|
31
|
-
| HTTP backoff | `httpBackoffBaseMs`
|
|
32
|
-
| Artifact timeout and size | `artifactDownload.timeoutMs`, `maxBytes
|
|
33
|
-
| Private artifact override | `artifactDownload.allowPrivateUrls
|
|
34
|
-
|
|
|
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,68 @@ 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.148.0)
|
|
164
|
+
|
|
165
|
+
Python v2.148.0 at commit `0fa0918` adds two service-facing changes since
|
|
166
|
+
v2.147.0. The remaining changes (superscript/subscript detection, backend
|
|
167
|
+
fixes) are server-side or core-library behavior with no service-client or
|
|
168
|
+
service-datamodel surface.
|
|
169
|
+
|
|
170
|
+
- `InputFormat.CALENDAR` (`"calendar"`) for the new iCalendar backend, with the
|
|
171
|
+
extensions `ics`, `ical`, `icalendar`, and `ifb` and the `text/calendar` MIME
|
|
172
|
+
type. `ConvertDocumentsOptions.from_formats` defaults to every `InputFormat`:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
https://github.com/docling-project/docling/blob/v2.148.0/docling/datamodel/base_models.py#L136
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The TypeScript `InputFormat` union includes `'calendar'`, the `from_formats`
|
|
179
|
+
validator accepts it, and the source normalizer maps those extensions to it
|
|
180
|
+
through the same extension table that Python builds in
|
|
181
|
+
`_build_extension_to_format_map()`:
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
https://github.com/docling-project/docling/blob/v2.148.0/docling/service_client/client.py#L906
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- `ResponseFormat` gained `SURYA_HTML` (Surya OCR 2.5), `UNLIMITED_OCR2`,
|
|
188
|
+
`LIGHTONOCR_MARKDOWN`, and `NEMOTRON_PARSE_V3_5`, used by
|
|
189
|
+
`VlmModelLocal.response_format` and `VlmModelApi.response_format`:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
https://github.com/docling-project/docling/blob/v2.148.0/docling/datamodel/pipeline_options_vlm_model.py#L104
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The TypeScript `VlmResponseFormat` (alias `ResponseFormat`) union and the
|
|
196
|
+
request-option validator accept the new values.
|
|
197
|
+
|
|
198
|
+
| Python (v2.148.0) | TypeScript | Wire key |
|
|
199
|
+
| ------------------------------------ | -------------------------------------------- | --------------------- |
|
|
200
|
+
| `InputFormat.CALENDAR` | `InputFormat` / `INPUT_FORMATS` | `calendar` |
|
|
201
|
+
| `FormatToExtensions[CALENDAR]` | `EXTENSION_FORMATS` / `guessMimeType()` | `ics`, `ifb`, ... |
|
|
202
|
+
| `ResponseFormat.SURYA_HTML` | `VlmResponseFormat` / `VLM_RESPONSE_FORMATS` | `surya_html` |
|
|
203
|
+
| `ResponseFormat.UNLIMITED_OCR2` | `VlmResponseFormat` / `VLM_RESPONSE_FORMATS` | `unlimited_ocr2` |
|
|
204
|
+
| `ResponseFormat.LIGHTONOCR_MARKDOWN` | `VlmResponseFormat` / `VLM_RESPONSE_FORMATS` | `lightonocr_markdown` |
|
|
205
|
+
| `ResponseFormat.NEMOTRON_PARSE_V3_5` | `VlmResponseFormat` / `VLM_RESPONSE_FORMATS` | `nemotron_parse_v3_5` |
|
|
206
|
+
|
|
207
|
+
## Service client changes (v2.147.0)
|
|
208
|
+
|
|
209
|
+
Python v2.147.0 at commit `e3681a6` formally exposes `artifact_url_allowlist` and `_allow_private_artifact_urls` in `DoclingServiceClient.__init__`:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
https://github.com/docling-project/docling/blob/v2.147.0/docling/service_client/client.py#L933
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
TypeScript fully supports these options:
|
|
216
|
+
|
|
217
|
+
- `artifactUrlAllowlist` (and nested `artifactDownload.artifactUrlAllowlist`) parses origins to selectively trust internal endpoints.
|
|
218
|
+
- `allowPrivateArtifactUrls` (and nested `artifactDownload.allowPrivateUrls`) completely bypasses public-address checks when desired.
|
|
219
|
+
|
|
220
|
+
| Python (v2.147.0) | TypeScript | Option Key |
|
|
221
|
+
| ------------------------------ | -------------------------- | -------------------------- |
|
|
222
|
+
| `artifact_url_allowlist` | `artifactUrlAllowlist` | `artifactUrlAllowlist` |
|
|
223
|
+
| `_allow_private_artifact_urls` | `allowPrivateArtifactUrls` | `allowPrivateArtifactUrls` |
|
|
224
|
+
|
|
162
225
|
## Service client changes (v2.146.0)
|
|
163
226
|
|
|
164
227
|
Python v2.146.0 at commit `c622bcb` includes two service-facing fixes 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
|
|
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(
|
|
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 ${
|
|
331
|
+
`Could not resolve artifact host ${cleanHostname}`,
|
|
297
332
|
{ cause: error }
|
|
298
333
|
);
|
|
299
334
|
}
|
|
@@ -872,7 +907,11 @@ var EXTENSION_FORMATS = {
|
|
|
872
907
|
numbers: "iwork_numbers",
|
|
873
908
|
ebc: "ebcdic",
|
|
874
909
|
ebcdic: "ebcdic",
|
|
875
|
-
afp: "afp"
|
|
910
|
+
afp: "afp",
|
|
911
|
+
ics: "calendar",
|
|
912
|
+
ical: "calendar",
|
|
913
|
+
icalendar: "calendar",
|
|
914
|
+
ifb: "calendar"
|
|
876
915
|
};
|
|
877
916
|
async function normalizeSourceInput(input, signal) {
|
|
878
917
|
throwIfAborted(signal);
|
|
@@ -1349,7 +1388,9 @@ function guessMimeType(filename) {
|
|
|
1349
1388
|
vtt: "text/vtt",
|
|
1350
1389
|
eml: "message/rfc822",
|
|
1351
1390
|
msg: "application/vnd.ms-outlook",
|
|
1352
|
-
epub: "application/epub+zip"
|
|
1391
|
+
epub: "application/epub+zip",
|
|
1392
|
+
ics: "text/calendar",
|
|
1393
|
+
ifb: "text/calendar"
|
|
1353
1394
|
}[extension] ?? "application/octet-stream";
|
|
1354
1395
|
}
|
|
1355
1396
|
var INPUT_FORMATS = /* @__PURE__ */ new Set([
|
|
@@ -1388,7 +1429,8 @@ var INPUT_FORMATS = /* @__PURE__ */ new Set([
|
|
|
1388
1429
|
"iwork_keynote",
|
|
1389
1430
|
"iwork_numbers",
|
|
1390
1431
|
"ebcdic",
|
|
1391
|
-
"afp"
|
|
1432
|
+
"afp",
|
|
1433
|
+
"calendar"
|
|
1392
1434
|
]);
|
|
1393
1435
|
var OUTPUT_FORMATS = /* @__PURE__ */ new Set([
|
|
1394
1436
|
"md",
|
|
@@ -1440,12 +1482,16 @@ var VLM_RESPONSE_FORMATS = /* @__PURE__ */ new Set([
|
|
|
1440
1482
|
"markdown",
|
|
1441
1483
|
"deepseekocr_markdown",
|
|
1442
1484
|
"unlimited_ocr_markdown",
|
|
1485
|
+
"unlimited_ocr2",
|
|
1486
|
+
"lightonocr_markdown",
|
|
1443
1487
|
"html",
|
|
1444
1488
|
"otsl",
|
|
1445
1489
|
"plaintext",
|
|
1446
1490
|
"chandra_html",
|
|
1491
|
+
"surya_html",
|
|
1447
1492
|
"dots_json",
|
|
1448
1493
|
"nemotron_parse_v2",
|
|
1494
|
+
"nemotron_parse_v3_5",
|
|
1449
1495
|
"mineru2"
|
|
1450
1496
|
]);
|
|
1451
1497
|
var VLM_INFERENCE_FRAMEWORKS = /* @__PURE__ */ new Set(["mlx", "transformers", "vllm"]);
|
|
@@ -2411,7 +2457,22 @@ var DoclingClient = class {
|
|
|
2411
2457
|
this.#maxConcurrency = validateConcurrency(
|
|
2412
2458
|
options.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY
|
|
2413
2459
|
);
|
|
2414
|
-
|
|
2460
|
+
const downloaderOptions = {
|
|
2461
|
+
...options.artifactDownload
|
|
2462
|
+
};
|
|
2463
|
+
if (options.artifactDownloadTimeout !== void 0) {
|
|
2464
|
+
downloaderOptions.timeoutMs = options.artifactDownloadTimeout;
|
|
2465
|
+
}
|
|
2466
|
+
if (options.maxArtifactDownloadBytes !== void 0) {
|
|
2467
|
+
downloaderOptions.maxBytes = options.maxArtifactDownloadBytes;
|
|
2468
|
+
}
|
|
2469
|
+
if (options.artifactUrlAllowlist !== void 0) {
|
|
2470
|
+
downloaderOptions.artifactUrlAllowlist = options.artifactUrlAllowlist;
|
|
2471
|
+
}
|
|
2472
|
+
if (options.allowPrivateArtifactUrls !== void 0) {
|
|
2473
|
+
downloaderOptions.allowPrivateUrls = options.allowPrivateArtifactUrls;
|
|
2474
|
+
}
|
|
2475
|
+
this.#artifactDownloader = options.artifactDownloader ?? new ArtifactDownloader(downloaderOptions);
|
|
2415
2476
|
}
|
|
2416
2477
|
async health(options = {}) {
|
|
2417
2478
|
const value = await this.#request("GET", "/health", {
|
|
@@ -4279,6 +4340,7 @@ function isRecord4(value) {
|
|
|
4279
4340
|
fileSourceFromBinary,
|
|
4280
4341
|
materializePresignedResult,
|
|
4281
4342
|
normalizeSourceInput,
|
|
4343
|
+
parseArtifactOrigin,
|
|
4282
4344
|
preflightFileSize,
|
|
4283
4345
|
resolveConvertOptions,
|
|
4284
4346
|
selectDocumentArtifact,
|