@docling/docling-client 0.1.0 → 0.2.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
@@ -608,6 +608,7 @@ interface SubmitSourceOptions<TTarget extends SubmitTarget = SubmitTarget> exten
608
608
  options?: ConvertDocumentsOptions;
609
609
  outputFormats?: ConvertDocumentsOptions['to_formats'];
610
610
  target?: TTarget;
611
+ callbacks?: CallbackSpec[];
611
612
  }
612
613
  interface ConvertOptions extends WaitForTaskOptions {
613
614
  options?: ConvertDocumentsOptions;
@@ -859,7 +860,7 @@ declare function validateConvertOptions(options: ConvertDocumentsOptions): void;
859
860
  declare function applyPageLimits(options: ConvertDocumentsOptions, pageRange?: [number, number], maxNumPages?: number): ConvertDocumentsOptions;
860
861
  declare function validateMaxFileSize(value: number | undefined): void;
861
862
  declare function preflightFileSize(source: NormalizedSource, maxFileSize: number | undefined): string | null;
862
- declare function formValue(value: unknown): string;
863
+ declare function appendFormValue(form: FormData, key: string, value: unknown): void;
863
864
  declare function fileSourceFromBinary(source: BinaryFileSource, signal?: AbortSignal): Promise<FileSource>;
864
865
 
865
- export { type ArtifactAddressResolver, ArtifactDownloader, type ArtifactDownloaderOptions, type ArtifactRef, type ArtifactType, type AutoSubmitResult, type AzureBlobCoordinates, type AzureBlobSource, type AzureBlobTarget, type BaseChunkingOptions, type BatchConvertSourcesRequest, type BatchResultForTarget, type BatchSource, type BatchSubmitCallOptions, type BatchTarget, type BinaryFileSource, type CallbackSpec, type ChunkCallOptions, type ChunkDocumentResponse, type ChunkSourceOptions, type ChunkSourcesRequest, type ChunkedDocumentResultItem, type ChunkerKind, type ConfidenceScores, type ConversionInput, type ConversionItem, type ConversionResult, type ConversionSource, type ConversionSourceInput, type ConversionStatus, type ConvertAllOptions, type ConvertDocumentResponse, type ConvertDocumentsOptions, type ConvertOptions, type ConvertSourcesRequest, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, type DoclingBinaryResponse, DoclingClient, type DoclingClientOptions, type DoclingComponentType, DoclingConversionError, type DoclingDocument, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, type DoclingRequestBodyType, DoclingResponseSchemaMismatchError, type DoclingResponseType, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, type DoclingTransport, type DoclingTransportRequest, DoclingUsageLimitExceededError, type DocumentArtifactItem, type DocumentLimits, type ErrorItem, type ExportDocumentResponse, type ExportResult, type FailureCategory, type FetchLike, FetchTransport, type FetchTransportOptions, type FileSource, type GenericSource, type GenericTarget, type GoogleCloudStorageCoordinates, type GoogleCloudStorageServiceAccountInfo, type GoogleCloudStorageSource, type GoogleCloudStorageTarget, type GoogleDriveCoordinates, type GoogleDriveCredentials, type GoogleDriveSource, type GoogleDriveTarget, type HealthCheckResponse, type HierarchicalChunkSourcesRequest, type HierarchicalChunkingOptions, type HttpSource, type HybridChunkSourcesRequest, type HybridChunkingOptions, type ImageExportMode, type InBodyConversionResponse, type InBodyTarget, type InputFormat, type LegacyVlmModelType, MAX_CONCURRENCY_LIMIT, type NormalizedJsonSource, type NormalizedMultipartSource, type NormalizedSource, type OutcomeCounts, type OutputFormat, type PdfBackend, type PictureClassificationLabel, type PictureDescriptionApi, type PictureDescriptionLocal, type PresignedUrlConvertDocumentResponse, type PresignedUrlConvertResponse, type PresignedUrlTarget, type ProcessingPipeline, type ProfilingItem, type ProfilingScope, type PublicFailureInfo, type PutTarget, type QualityGrade, type RawServiceResult, type RemoteTargetResponse, type S3Coordinates, type S3Source, type S3Target, type StatusWatcherKind, type StorageTarget, type SubmitAndRetrieveOptions, type SubmitCallOptions, type SubmitResultForTarget, type SubmitSourceOptions, type SubmitTarget, type TableMode, type TaskFailureResult, type TaskProcessingMeta, type TaskStatus, type TaskStatusResponse, type TaskType, type TransformersModelType, type VlmInferenceFramework, type VlmModelApi, type VlmModelLocal, type VlmResponseFormat, type WaitForTaskOptions, type WatchTaskOptions, type WebSocketFactory, type WebSocketFactoryOptions, type WebSocketLike, type ZipTarget, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, formValue, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
866
+ export { type ArtifactAddressResolver, ArtifactDownloader, type ArtifactDownloaderOptions, type ArtifactRef, type ArtifactType, type AutoSubmitResult, type AzureBlobCoordinates, type AzureBlobSource, type AzureBlobTarget, type BaseChunkingOptions, type BatchConvertSourcesRequest, type BatchResultForTarget, type BatchSource, type BatchSubmitCallOptions, type BatchTarget, type BinaryFileSource, type CallbackSpec, type ChunkCallOptions, type ChunkDocumentResponse, type ChunkSourceOptions, type ChunkSourcesRequest, type ChunkedDocumentResultItem, type ChunkerKind, type ConfidenceScores, type ConversionInput, type ConversionItem, type ConversionResult, type ConversionSource, type ConversionSourceInput, type ConversionStatus, type ConvertAllOptions, type ConvertDocumentResponse, type ConvertDocumentsOptions, type ConvertOptions, type ConvertSourcesRequest, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, type DoclingBinaryResponse, DoclingClient, type DoclingClientOptions, type DoclingComponentType, DoclingConversionError, type DoclingDocument, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, type DoclingRequestBodyType, DoclingResponseSchemaMismatchError, type DoclingResponseType, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, type DoclingTransport, type DoclingTransportRequest, DoclingUsageLimitExceededError, type DocumentArtifactItem, type DocumentLimits, type ErrorItem, type ExportDocumentResponse, type ExportResult, type FailureCategory, type FetchLike, FetchTransport, type FetchTransportOptions, type FileSource, type GenericSource, type GenericTarget, type GoogleCloudStorageCoordinates, type GoogleCloudStorageServiceAccountInfo, type GoogleCloudStorageSource, type GoogleCloudStorageTarget, type GoogleDriveCoordinates, type GoogleDriveCredentials, type GoogleDriveSource, type GoogleDriveTarget, type HealthCheckResponse, type HierarchicalChunkSourcesRequest, type HierarchicalChunkingOptions, type HttpSource, type HybridChunkSourcesRequest, type HybridChunkingOptions, type ImageExportMode, type InBodyConversionResponse, type InBodyTarget, type InputFormat, type LegacyVlmModelType, MAX_CONCURRENCY_LIMIT, type NormalizedJsonSource, type NormalizedMultipartSource, type NormalizedSource, type OutcomeCounts, type OutputFormat, type PdfBackend, type PictureClassificationLabel, type PictureDescriptionApi, type PictureDescriptionLocal, type PresignedUrlConvertDocumentResponse, type PresignedUrlConvertResponse, type PresignedUrlTarget, type ProcessingPipeline, type ProfilingItem, type ProfilingScope, type PublicFailureInfo, type PutTarget, type QualityGrade, type RawServiceResult, type RemoteTargetResponse, type S3Coordinates, type S3Source, type S3Target, type StatusWatcherKind, type StorageTarget, type SubmitAndRetrieveOptions, type SubmitCallOptions, type SubmitResultForTarget, type SubmitSourceOptions, type SubmitTarget, type TableMode, type TaskFailureResult, type TaskProcessingMeta, type TaskStatus, type TaskStatusResponse, type TaskType, type TransformersModelType, type VlmInferenceFramework, type VlmModelApi, type VlmModelLocal, type VlmResponseFormat, type WaitForTaskOptions, type WatchTaskOptions, type WebSocketFactory, type WebSocketFactoryOptions, type WebSocketLike, type ZipTarget, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
package/dist/index.d.ts CHANGED
@@ -608,6 +608,7 @@ interface SubmitSourceOptions<TTarget extends SubmitTarget = SubmitTarget> exten
608
608
  options?: ConvertDocumentsOptions;
609
609
  outputFormats?: ConvertDocumentsOptions['to_formats'];
610
610
  target?: TTarget;
611
+ callbacks?: CallbackSpec[];
611
612
  }
612
613
  interface ConvertOptions extends WaitForTaskOptions {
613
614
  options?: ConvertDocumentsOptions;
@@ -859,7 +860,7 @@ declare function validateConvertOptions(options: ConvertDocumentsOptions): void;
859
860
  declare function applyPageLimits(options: ConvertDocumentsOptions, pageRange?: [number, number], maxNumPages?: number): ConvertDocumentsOptions;
860
861
  declare function validateMaxFileSize(value: number | undefined): void;
861
862
  declare function preflightFileSize(source: NormalizedSource, maxFileSize: number | undefined): string | null;
862
- declare function formValue(value: unknown): string;
863
+ declare function appendFormValue(form: FormData, key: string, value: unknown): void;
863
864
  declare function fileSourceFromBinary(source: BinaryFileSource, signal?: AbortSignal): Promise<FileSource>;
864
865
 
865
- export { type ArtifactAddressResolver, ArtifactDownloader, type ArtifactDownloaderOptions, type ArtifactRef, type ArtifactType, type AutoSubmitResult, type AzureBlobCoordinates, type AzureBlobSource, type AzureBlobTarget, type BaseChunkingOptions, type BatchConvertSourcesRequest, type BatchResultForTarget, type BatchSource, type BatchSubmitCallOptions, type BatchTarget, type BinaryFileSource, type CallbackSpec, type ChunkCallOptions, type ChunkDocumentResponse, type ChunkSourceOptions, type ChunkSourcesRequest, type ChunkedDocumentResultItem, type ChunkerKind, type ConfidenceScores, type ConversionInput, type ConversionItem, type ConversionResult, type ConversionSource, type ConversionSourceInput, type ConversionStatus, type ConvertAllOptions, type ConvertDocumentResponse, type ConvertDocumentsOptions, type ConvertOptions, type ConvertSourcesRequest, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, type DoclingBinaryResponse, DoclingClient, type DoclingClientOptions, type DoclingComponentType, DoclingConversionError, type DoclingDocument, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, type DoclingRequestBodyType, DoclingResponseSchemaMismatchError, type DoclingResponseType, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, type DoclingTransport, type DoclingTransportRequest, DoclingUsageLimitExceededError, type DocumentArtifactItem, type DocumentLimits, type ErrorItem, type ExportDocumentResponse, type ExportResult, type FailureCategory, type FetchLike, FetchTransport, type FetchTransportOptions, type FileSource, type GenericSource, type GenericTarget, type GoogleCloudStorageCoordinates, type GoogleCloudStorageServiceAccountInfo, type GoogleCloudStorageSource, type GoogleCloudStorageTarget, type GoogleDriveCoordinates, type GoogleDriveCredentials, type GoogleDriveSource, type GoogleDriveTarget, type HealthCheckResponse, type HierarchicalChunkSourcesRequest, type HierarchicalChunkingOptions, type HttpSource, type HybridChunkSourcesRequest, type HybridChunkingOptions, type ImageExportMode, type InBodyConversionResponse, type InBodyTarget, type InputFormat, type LegacyVlmModelType, MAX_CONCURRENCY_LIMIT, type NormalizedJsonSource, type NormalizedMultipartSource, type NormalizedSource, type OutcomeCounts, type OutputFormat, type PdfBackend, type PictureClassificationLabel, type PictureDescriptionApi, type PictureDescriptionLocal, type PresignedUrlConvertDocumentResponse, type PresignedUrlConvertResponse, type PresignedUrlTarget, type ProcessingPipeline, type ProfilingItem, type ProfilingScope, type PublicFailureInfo, type PutTarget, type QualityGrade, type RawServiceResult, type RemoteTargetResponse, type S3Coordinates, type S3Source, type S3Target, type StatusWatcherKind, type StorageTarget, type SubmitAndRetrieveOptions, type SubmitCallOptions, type SubmitResultForTarget, type SubmitSourceOptions, type SubmitTarget, type TableMode, type TaskFailureResult, type TaskProcessingMeta, type TaskStatus, type TaskStatusResponse, type TaskType, type TransformersModelType, type VlmInferenceFramework, type VlmModelApi, type VlmModelLocal, type VlmResponseFormat, type WaitForTaskOptions, type WatchTaskOptions, type WebSocketFactory, type WebSocketFactoryOptions, type WebSocketLike, type ZipTarget, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, formValue, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
866
+ export { type ArtifactAddressResolver, ArtifactDownloader, type ArtifactDownloaderOptions, type ArtifactRef, type ArtifactType, type AutoSubmitResult, type AzureBlobCoordinates, type AzureBlobSource, type AzureBlobTarget, type BaseChunkingOptions, type BatchConvertSourcesRequest, type BatchResultForTarget, type BatchSource, type BatchSubmitCallOptions, type BatchTarget, type BinaryFileSource, type CallbackSpec, type ChunkCallOptions, type ChunkDocumentResponse, type ChunkSourceOptions, type ChunkSourcesRequest, type ChunkedDocumentResultItem, type ChunkerKind, type ConfidenceScores, type ConversionInput, type ConversionItem, type ConversionResult, type ConversionSource, type ConversionSourceInput, type ConversionStatus, type ConvertAllOptions, type ConvertDocumentResponse, type ConvertDocumentsOptions, type ConvertOptions, type ConvertSourcesRequest, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, type DoclingBinaryResponse, DoclingClient, type DoclingClientOptions, type DoclingComponentType, DoclingConversionError, type DoclingDocument, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, type DoclingRequestBodyType, DoclingResponseSchemaMismatchError, type DoclingResponseType, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, type DoclingTransport, type DoclingTransportRequest, DoclingUsageLimitExceededError, type DocumentArtifactItem, type DocumentLimits, type ErrorItem, type ExportDocumentResponse, type ExportResult, type FailureCategory, type FetchLike, FetchTransport, type FetchTransportOptions, type FileSource, type GenericSource, type GenericTarget, type GoogleCloudStorageCoordinates, type GoogleCloudStorageServiceAccountInfo, type GoogleCloudStorageSource, type GoogleCloudStorageTarget, type GoogleDriveCoordinates, type GoogleDriveCredentials, type GoogleDriveSource, type GoogleDriveTarget, type HealthCheckResponse, type HierarchicalChunkSourcesRequest, type HierarchicalChunkingOptions, type HttpSource, type HybridChunkSourcesRequest, type HybridChunkingOptions, type ImageExportMode, type InBodyConversionResponse, type InBodyTarget, type InputFormat, type LegacyVlmModelType, MAX_CONCURRENCY_LIMIT, type NormalizedJsonSource, type NormalizedMultipartSource, type NormalizedSource, type OutcomeCounts, type OutputFormat, type PdfBackend, type PictureClassificationLabel, type PictureDescriptionApi, type PictureDescriptionLocal, type PresignedUrlConvertDocumentResponse, type PresignedUrlConvertResponse, type PresignedUrlTarget, type ProcessingPipeline, type ProfilingItem, type ProfilingScope, type PublicFailureInfo, type PutTarget, type QualityGrade, type RawServiceResult, type RemoteTargetResponse, type S3Coordinates, type S3Source, type S3Target, type StatusWatcherKind, type StorageTarget, type SubmitAndRetrieveOptions, type SubmitCallOptions, type SubmitResultForTarget, type SubmitSourceOptions, type SubmitTarget, type TableMode, type TaskFailureResult, type TaskProcessingMeta, type TaskStatus, type TaskStatusResponse, type TaskType, type TransformersModelType, type VlmInferenceFramework, type VlmModelApi, type VlmModelLocal, type VlmResponseFormat, type WaitForTaskOptions, type WatchTaskOptions, type WebSocketFactory, type WebSocketFactoryOptions, type WebSocketLike, type ZipTarget, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
package/dist/index.js CHANGED
@@ -1111,14 +1111,16 @@ function preflightFileSize(source, maxFileSize) {
1111
1111
  }
1112
1112
  return `File size ${source.descriptor.file_size} exceeds the configured limit of ${maxFileSize} bytes`;
1113
1113
  }
1114
- function formValue(value) {
1115
- if (typeof value === "string") {
1116
- return value;
1117
- }
1118
- if (typeof value === "number" || typeof value === "boolean") {
1119
- return String(value);
1114
+ function appendFormValue(form, key, value) {
1115
+ if (Array.isArray(value)) {
1116
+ value.forEach((item) => appendFormValue(form, key, item));
1117
+ } else if (typeof value === "string") {
1118
+ form.append(key, value);
1119
+ } else if (typeof value === "number" || typeof value === "boolean") {
1120
+ form.append(key, String(value));
1121
+ } else {
1122
+ form.append(key, JSON.stringify(value));
1120
1123
  }
1121
- return JSON.stringify(value);
1122
1124
  }
1123
1125
  async function fileSourceFromBinary(source, signal) {
1124
1126
  throwIfAborted(signal);
@@ -2516,12 +2518,12 @@ var DoclingClient = class {
2516
2518
  );
2517
2519
  for (const [key, value] of Object.entries(convertOptions)) {
2518
2520
  if (value !== void 0 && value !== null) {
2519
- form.append(`convert_${key}`, formValue(value));
2521
+ appendFormValue(form, `convert_${key}`, value);
2520
2522
  }
2521
2523
  }
2522
2524
  for (const [key, value] of Object.entries(request.chunking_options ?? {})) {
2523
2525
  if (key !== "chunker" && value !== void 0 && value !== null) {
2524
- form.append(`chunking_${key}`, formValue(value));
2526
+ appendFormValue(form, `chunking_${key}`, value);
2525
2527
  }
2526
2528
  }
2527
2529
  form.append(
@@ -2836,13 +2838,14 @@ var DoclingClient = class {
2836
2838
  );
2837
2839
  }
2838
2840
  async #submitNormalizedForTarget(source, options, target, requestOptions) {
2841
+ const callbacks = requestOptions.callbacks ?? [];
2839
2842
  if (source.kind === "json") {
2840
2843
  return this.#submitRequestForTarget(
2841
2844
  {
2842
2845
  options,
2843
2846
  sources: [source.source],
2844
2847
  target,
2845
- callbacks: []
2848
+ callbacks
2846
2849
  },
2847
2850
  requestOptions
2848
2851
  );
@@ -2854,7 +2857,7 @@ var DoclingClient = class {
2854
2857
  options,
2855
2858
  sources: [fileSource],
2856
2859
  target,
2857
- callbacks: []
2860
+ callbacks
2858
2861
  },
2859
2862
  requestOptions
2860
2863
  );
@@ -2862,9 +2865,13 @@ var DoclingClient = class {
2862
2865
  const form = new FormData();
2863
2866
  for (const [key, value] of Object.entries(options)) {
2864
2867
  if (value !== void 0 && value !== null) {
2865
- form.append(key, formValue(value));
2868
+ appendFormValue(form, key, value);
2866
2869
  }
2867
2870
  }
2871
+ validateCallbacks(callbacks);
2872
+ for (const callback of callbacks) {
2873
+ form.append("callbacks", JSON.stringify(callback));
2874
+ }
2868
2875
  form.append("target_type", target.kind);
2869
2876
  form.append("files", source.blob, source.descriptor.filename);
2870
2877
  const status = parseTaskStatus(
@@ -4073,11 +4080,11 @@ export {
4073
4080
  DoclingUsageLimitExceededError,
4074
4081
  FetchTransport,
4075
4082
  MAX_CONCURRENCY_LIMIT,
4083
+ appendFormValue,
4076
4084
  applyPageLimits,
4077
4085
  documentFromBundle,
4078
4086
  documentFromJson,
4079
4087
  fileSourceFromBinary,
4080
- formValue,
4081
4088
  materializePresignedResult,
4082
4089
  normalizeSourceInput,
4083
4090
  preflightFileSize,