@docling/docling-client 2.146.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.
- package/PYTHON_CLIENT_PARITY.md +38 -19
- package/dist/index.cjs +55 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +54 -4
- 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.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
|
|
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,24 @@ 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
|
+
|
|
162
181
|
## Service client changes (v2.146.0)
|
|
163
182
|
|
|
164
183
|
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
|
}
|
|
@@ -2411,7 +2446,22 @@ var DoclingClient = class {
|
|
|
2411
2446
|
this.#maxConcurrency = validateConcurrency(
|
|
2412
2447
|
options.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY
|
|
2413
2448
|
);
|
|
2414
|
-
|
|
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", {
|
|
@@ -4279,6 +4329,7 @@ function isRecord4(value) {
|
|
|
4279
4329
|
fileSourceFromBinary,
|
|
4280
4330
|
materializePresignedResult,
|
|
4281
4331
|
normalizeSourceInput,
|
|
4332
|
+
parseArtifactOrigin,
|
|
4282
4333
|
preflightFileSize,
|
|
4283
4334
|
resolveConvertOptions,
|
|
4284
4335
|
selectDocumentArtifact,
|