@docling/docling-client 2.142.0 → 2.146.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.d.cts CHANGED
@@ -113,6 +113,10 @@ interface ConvertDocumentsOptions {
113
113
  from_formats?: InputFormat[];
114
114
  to_formats?: OutputFormat[];
115
115
  pipeline?: ProcessingPipeline;
116
+ /**
117
+ * Only convert a range of pages (1-based, inclusive). The service default
118
+ * is the whole document, which the client never sends explicitly.
119
+ */
116
120
  page_range?: [number, number];
117
121
  do_ocr?: boolean;
118
122
  force_ocr?: boolean;
@@ -543,6 +547,12 @@ type DocumentResultItem<TDocument = DoclingDocument> = ExportResult<TDocument>;
543
547
  interface ZipArchiveResult {
544
548
  kind: 'ZipArchiveResult';
545
549
  content: Uint8Array | unknown;
550
+ /**
551
+ * Suggested download name for the archive, e.g. derived from the source
552
+ * document when the task had a single input. Absent or null when no specific
553
+ * name applies.
554
+ */
555
+ filename?: string | null;
546
556
  }
547
557
  interface RemoteTargetResult {
548
558
  kind: 'RemoteTargetResult';
@@ -583,7 +593,7 @@ interface WebsocketMessage {
583
593
  task?: TaskStatusResponse | null;
584
594
  error?: string | null;
585
595
  }
586
- type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
596
+ type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle' | 'chunks';
587
597
  interface ArtifactRef {
588
598
  artifact_type: ArtifactType;
589
599
  mime_type: string;
package/dist/index.d.ts CHANGED
@@ -113,6 +113,10 @@ interface ConvertDocumentsOptions {
113
113
  from_formats?: InputFormat[];
114
114
  to_formats?: OutputFormat[];
115
115
  pipeline?: ProcessingPipeline;
116
+ /**
117
+ * Only convert a range of pages (1-based, inclusive). The service default
118
+ * is the whole document, which the client never sends explicitly.
119
+ */
116
120
  page_range?: [number, number];
117
121
  do_ocr?: boolean;
118
122
  force_ocr?: boolean;
@@ -543,6 +547,12 @@ type DocumentResultItem<TDocument = DoclingDocument> = ExportResult<TDocument>;
543
547
  interface ZipArchiveResult {
544
548
  kind: 'ZipArchiveResult';
545
549
  content: Uint8Array | unknown;
550
+ /**
551
+ * Suggested download name for the archive, e.g. derived from the source
552
+ * document when the task had a single input. Absent or null when no specific
553
+ * name applies.
554
+ */
555
+ filename?: string | null;
546
556
  }
547
557
  interface RemoteTargetResult {
548
558
  kind: 'RemoteTargetResult';
@@ -583,7 +593,7 @@ interface WebsocketMessage {
583
593
  task?: TaskStatusResponse | null;
584
594
  error?: string | null;
585
595
  }
586
- type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
596
+ type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle' | 'chunks';
587
597
  interface ArtifactRef {
588
598
  artifact_type: ArtifactType;
589
599
  mime_type: string;
package/dist/index.js CHANGED
@@ -1118,6 +1118,9 @@ function applyPageLimits(options, pageRange, maxNumPages) {
1118
1118
  }
1119
1119
  if (effectiveRange !== void 0) {
1120
1120
  validatePageRange(effectiveRange);
1121
+ if (options.page_range === void 0 && effectiveRange[0] === 1 && effectiveRange[1] === Number.MAX_SAFE_INTEGER) {
1122
+ return clone(options);
1123
+ }
1121
1124
  return { ...clone(options), page_range: [...effectiveRange] };
1122
1125
  }
1123
1126
  return clone(options);
@@ -2860,7 +2863,9 @@ var DoclingClient = class {
2860
2863
  target: { kind: "inbody" }
2861
2864
  },
2862
2865
  options
2863
- );
2866
+ ).catch((fallbackError) => {
2867
+ throw combineInBodyFallbackError(error, fallbackError);
2868
+ });
2864
2869
  });
2865
2870
  }
2866
2871
  #submitNormalizedWithAutoTarget(source, options, requestOptions) {
@@ -2878,7 +2883,9 @@ var DoclingClient = class {
2878
2883
  withJsonOutput(options),
2879
2884
  { kind: "inbody" },
2880
2885
  requestOptions
2881
- );
2886
+ ).catch((fallbackError) => {
2887
+ throw combineInBodyFallbackError(error, fallbackError);
2888
+ });
2882
2889
  });
2883
2890
  }
2884
2891
  async #submitRequestForTarget(request, options) {
@@ -3404,7 +3411,8 @@ function parsePresignedResponse(value) {
3404
3411
  "doctags",
3405
3412
  "doclang",
3406
3413
  "dclx",
3407
- "resource_bundle"
3414
+ "resource_bundle",
3415
+ "chunks"
3408
3416
  ].includes(String(artifact.artifact_type))) {
3409
3417
  throw schemaMismatch(`${artifactPath}.artifact_type is unsupported`);
3410
3418
  }
@@ -3708,6 +3716,18 @@ function shouldFallbackFromPresigned(error) {
3708
3716
  "enum"
3709
3717
  ].some((phrase) => detail.includes(phrase));
3710
3718
  }
3719
+ function combineInBodyFallbackError(presignedError, fallbackError) {
3720
+ if (!(presignedError instanceof DoclingHttpError) || !(fallbackError instanceof DoclingHttpError) || ![400, 422].includes(fallbackError.status)) {
3721
+ return fallbackError;
3722
+ }
3723
+ const fallbackDetail = httpDetail2(fallbackError.body);
3724
+ const prefix = fallbackDetail === void 0 ? "" : `${fallbackDetail} `;
3725
+ return new DoclingServiceError(fallbackError.message, {
3726
+ status: fallbackError.status,
3727
+ detail: `${prefix}The client tried the InBody target because the server rejected the presigned_url target: ${httpDetail2(presignedError.body)}`,
3728
+ cause: fallbackError
3729
+ });
3730
+ }
3711
3731
  function targetNeedsJson(target) {
3712
3732
  return target.kind === "inbody";
3713
3733
  }