@docling/docling-client 0.2.0 → 0.3.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/dist/index.cjs CHANGED
@@ -2467,7 +2467,8 @@ var DoclingClient = class {
2467
2467
  const payload = {
2468
2468
  options: convertOptions,
2469
2469
  sources: structuredClone(request.sources),
2470
- target: structuredClone(request.target),
2470
+ ...request.target !== void 0 ? { target: structuredClone(request.target) } : {},
2471
+ ...request.targets !== void 0 ? { targets: structuredClone(request.targets) } : {},
2471
2472
  callbacks: structuredClone(request.callbacks ?? [])
2472
2473
  };
2473
2474
  throwIfAborted2(options.signal);
@@ -2478,7 +2479,8 @@ var DoclingClient = class {
2478
2479
  signal: options.signal
2479
2480
  })
2480
2481
  );
2481
- const loader = isPresignedTarget(request.target) ? (taskId, lastStatus, signal) => this.#fetchPresignedResult(taskId, lastStatus, signal) : (taskId, lastStatus, signal) => this.#fetchCountsResult(taskId, lastStatus, signal);
2482
+ const effectiveTargetList = request.targets?.length ? request.targets : request.target !== void 0 ? [request.target] : [];
2483
+ const loader = effectiveTargetList.some(isStorageTarget) ? (taskId, lastStatus, signal) => this.#fetchCountsResult(taskId, lastStatus, signal) : (taskId, lastStatus, signal) => this.#fetchPresignedResult(taskId, lastStatus, signal);
2482
2484
  return new DoclingJob(
2483
2485
  this,
2484
2486
  status,
@@ -3403,6 +3405,7 @@ function parsePresignedResponse(value) {
3403
3405
  "text",
3404
3406
  "doctags",
3405
3407
  "doclang",
3408
+ "dclx",
3406
3409
  "resource_bundle"
3407
3410
  ].includes(String(artifact.artifact_type))) {
3408
3411
  throw schemaMismatch(`${artifactPath}.artifact_type is unsupported`);
@@ -3699,8 +3702,8 @@ function shouldFallbackFromPresigned(error) {
3699
3702
  function targetNeedsJson(target) {
3700
3703
  return target.kind === "inbody";
3701
3704
  }
3702
- function isPresignedTarget(target) {
3703
- return target.kind === "presigned_url";
3705
+ function isStorageTarget(target) {
3706
+ return target.kind !== "presigned_url";
3704
3707
  }
3705
3708
  function validateBatchRequest(request) {
3706
3709
  if (!Array.isArray(request.sources) || request.sources.length === 0) {
@@ -3715,15 +3718,28 @@ function validateBatchRequest(request) {
3715
3718
  }
3716
3719
  validateKnownConnector(source, "source");
3717
3720
  }
3718
- if (!isRecord4(request.target) || typeof request.target.kind !== "string" || request.target.kind === "") {
3719
- throw new DoclingProtocolError("Batch target kind must not be empty");
3721
+ if (request.target === void 0 && (request.targets === void 0 || request.targets.length === 0)) {
3722
+ throw new DoclingProtocolError(
3723
+ "Batch conversion requires either 'target' or 'targets'"
3724
+ );
3720
3725
  }
3721
- if (["inbody", "zip", "put"].includes(request.target.kind)) {
3726
+ if (request.target !== void 0 && request.targets !== void 0 && request.targets.length > 0) {
3722
3727
  throw new DoclingProtocolError(
3723
- `Batch conversion does not accept ${request.target.kind} targets`
3728
+ "Batch conversion received both 'target' and 'targets'; supply only one"
3724
3729
  );
3725
3730
  }
3726
- validateKnownConnector(request.target, "target");
3731
+ const effectiveTargets = request.targets && request.targets.length > 0 ? request.targets : request.target !== void 0 ? [request.target] : [];
3732
+ for (const target of effectiveTargets) {
3733
+ if (!isRecord4(target) || typeof target.kind !== "string" || target.kind === "") {
3734
+ throw new DoclingProtocolError("Batch target kind must not be empty");
3735
+ }
3736
+ if (["inbody", "zip", "put"].includes(target.kind)) {
3737
+ throw new DoclingProtocolError(
3738
+ `Batch conversion does not accept ${target.kind} targets`
3739
+ );
3740
+ }
3741
+ validateKnownConnector(target, "target");
3742
+ }
3727
3743
  validateCallbacks(request.callbacks);
3728
3744
  }
3729
3745
  function validateChunkRequestOptions(request) {