@docling/docling-client 2.145.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 +76 -19
- package/dist/index.cjs +75 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +74 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -593,7 +593,7 @@ interface WebsocketMessage {
|
|
|
593
593
|
task?: TaskStatusResponse | null;
|
|
594
594
|
error?: string | null;
|
|
595
595
|
}
|
|
596
|
-
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
|
|
596
|
+
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle' | 'chunks';
|
|
597
597
|
interface ArtifactRef {
|
|
598
598
|
artifact_type: ArtifactType;
|
|
599
599
|
mime_type: string;
|
|
@@ -730,6 +730,12 @@ interface SubmitAndRetrieveOptions<TTarget extends SubmitTarget> {
|
|
|
730
730
|
}
|
|
731
731
|
|
|
732
732
|
type ArtifactAddressResolver = (hostname: string) => Promise<string[]>;
|
|
733
|
+
interface ParsedOrigin {
|
|
734
|
+
protocol: string;
|
|
735
|
+
hostname: string;
|
|
736
|
+
port: number;
|
|
737
|
+
}
|
|
738
|
+
declare function parseArtifactOrigin(value: string): ParsedOrigin;
|
|
733
739
|
interface ArtifactDownloaderOptions {
|
|
734
740
|
fetch?: typeof globalThis.fetch;
|
|
735
741
|
resolver?: ArtifactAddressResolver;
|
|
@@ -737,6 +743,7 @@ interface ArtifactDownloaderOptions {
|
|
|
737
743
|
timeoutMs?: number;
|
|
738
744
|
maxBytes?: number;
|
|
739
745
|
maxRedirects?: number;
|
|
746
|
+
artifactUrlAllowlist?: string[];
|
|
740
747
|
}
|
|
741
748
|
declare class ArtifactDownloader {
|
|
742
749
|
#private;
|
|
@@ -840,6 +847,10 @@ interface DoclingClientOptions {
|
|
|
840
847
|
maxConcurrency?: number;
|
|
841
848
|
artifactDownloader?: ArtifactDownloader;
|
|
842
849
|
artifactDownload?: ArtifactDownloaderOptions;
|
|
850
|
+
artifactDownloadTimeout?: number;
|
|
851
|
+
maxArtifactDownloadBytes?: number;
|
|
852
|
+
artifactUrlAllowlist?: string[];
|
|
853
|
+
allowPrivateArtifactUrls?: boolean;
|
|
843
854
|
}
|
|
844
855
|
interface SubmitCallOptions {
|
|
845
856
|
signal?: AbortSignal;
|
|
@@ -1107,5 +1118,5 @@ declare function preflightFileSize(source: NormalizedSource, maxFileSize: number
|
|
|
1107
1118
|
declare function appendFormValue(form: FormData, key: string, value: unknown): void;
|
|
1108
1119
|
declare function fileSourceFromBinary(source: BinaryFileSource, signal?: AbortSignal): Promise<FileSource>;
|
|
1109
1120
|
|
|
1110
|
-
export { ArtifactDownloader, ChunkerKind, ChunkerType, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, DoclingClient, DoclingConversionError, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, DoclingResponseSchemaMismatchError, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, DoclingUsageLimitExceededError, FetchTransport, MAX_CONCURRENCY_LIMIT, StatusWatcherKind, TargetName, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
|
|
1111
|
-
export type { AnyHttpSourceRequest, ArtifactAddressResolver, ArtifactDownloaderOptions, ArtifactRef, ArtifactType, AutoSubmitResult, AzureBlobCoordinates, AzureBlobSource, AzureBlobSourceRequest, AzureBlobTarget, BaseChunkDocumentsRequest, BaseChunkerOptions, BaseChunkingOptions, BaseProgress, BatchConvertSourcesRequest, BatchResultForTarget, BatchSource, BatchSourceRequestInput, BatchSourceRequestItem, BatchSubmitCallOptions, BatchTarget, BatchTargetRequest, BatchTargetRequestInput, BinaryFileSource, CallbackSpec, ChunkCallOptions, ChunkDocumentResponse, ChunkSourceOptions, ChunkSourcesRequest, ChunkedDocumentResult, ChunkedDocumentResultItem, ChunkingExportOptions, ChunkingOptionType, ClearResponse, ConfidenceScores, ConversionInput, ConversionItem, ConversionResult, ConversionSource, ConversionSourceInput, ConversionStatus, ConvertAllOptions, ConvertDocumentErrorResponse, ConvertDocumentResponse, ConvertDocumentResult, ConvertDocumentsOptions, ConvertDocumentsRequest, ConvertOptions, ConvertSourcesRequest, ConvertedOutcomeCountsMixin, DoclingBinaryResponse, DoclingClientOptions, DoclingComponentType, DoclingDocument, DoclingRequestBodyType, DoclingResponseType, DoclingTaskResult, DoclingTransport, DoclingTransportRequest, DocumentArtifactItem, DocumentCompletedItem, DocumentLimits, DocumentResultItem, ErrorItem, ExportDocumentResponse, ExportResult, FailureCategory, FailurePhase, FetchLike, FetchTransportOptions, FileSource, FileSourceRequest, GenericChunkDocumentsRequest, GenericSource, GenericSourceRequest, GenericTarget, GenericTargetRequest, GoogleCloudStorageCoordinates, GoogleCloudStorageServiceAccountInfo, GoogleCloudStorageSource, GoogleCloudStorageSourceRequest, GoogleCloudStorageTarget, GoogleDriveCoordinates, GoogleDriveCredentials, GoogleDriveSource, GoogleDriveSourceRequest, GoogleDriveTarget, HeadingHierarchyOptions, HealthCheckResponse, HierarchicalChunkSourcesRequest, HierarchicalChunkerOptions, HierarchicalChunkingOptions, HttpSource, HttpSourceRequest, HybridChunkSourcesRequest, HybridChunkerOptions, HybridChunkingOptions, ImageExportMode, ImageRefMode, InBodyConversionResponse, InBodyTarget, InferenceFramework, InputFormat, KnownBatchSourceRequestItem, KnownBatchTargetRequest, LegacyVlmModelType, MessageKind, NormalizedJsonSource, NormalizedMultipartSource, NormalizedSource, OutcomeCounts, OutputFormat, PdfBackend, PictureClassificationLabel, PictureDescriptionApi, PictureDescriptionLocal, PresignedArtifactResult, PresignedUrlConvertDocumentResponse, PresignedUrlConvertResponse, PresignedUrlTarget, ProcessedDocsItem, ProcessingPipeline, ProfilingItem, ProfilingScope, ProgressCallbackRequest, ProgressCallbackResponse, ProgressDocumentCompleted, ProgressKind, ProgressSetNumDocs, ProgressTaskCompleted, ProgressUpdateProcessed, PublicFailureInfo, PutTarget, QualityGrade, RawServiceResult, ReadinessResponse, RemoteTargetResponse, RemoteTargetResult, ResponseFormat, ResultType, S3Coordinates, S3Source, S3SourceRequest, S3Target, SourceRequestItem, StorageTarget, SubmitAndRetrieveOptions, SubmitCallOptions, SubmitResultForTarget, SubmitSourceOptions, SubmitTarget, TableFormerMode, TableMode, Target, TargetRequest, TaskFailureResult, TaskProcessingMeta, TaskStatus, TaskStatusResponse, TaskType, TransformersModelType, UsageLimitExceededDetails, UsageLimitExceededResponse, VlmInferenceFramework, VlmModelApi, VlmModelLocal, VlmModelType, VlmResponseFormat, WaitForTaskOptions, WatchTaskOptions, WebSocketFactory, WebSocketFactoryOptions, WebSocketLike, WebsocketMessage, ZipArchiveResult, ZipTarget };
|
|
1121
|
+
export { ArtifactDownloader, ChunkerKind, ChunkerType, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, DoclingClient, DoclingConversionError, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, DoclingResponseSchemaMismatchError, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, DoclingUsageLimitExceededError, FetchTransport, MAX_CONCURRENCY_LIMIT, StatusWatcherKind, TargetName, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, parseArtifactOrigin, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
|
|
1122
|
+
export type { AnyHttpSourceRequest, ArtifactAddressResolver, ArtifactDownloaderOptions, ArtifactRef, ArtifactType, AutoSubmitResult, AzureBlobCoordinates, AzureBlobSource, AzureBlobSourceRequest, AzureBlobTarget, BaseChunkDocumentsRequest, BaseChunkerOptions, BaseChunkingOptions, BaseProgress, BatchConvertSourcesRequest, BatchResultForTarget, BatchSource, BatchSourceRequestInput, BatchSourceRequestItem, BatchSubmitCallOptions, BatchTarget, BatchTargetRequest, BatchTargetRequestInput, BinaryFileSource, CallbackSpec, ChunkCallOptions, ChunkDocumentResponse, ChunkSourceOptions, ChunkSourcesRequest, ChunkedDocumentResult, ChunkedDocumentResultItem, ChunkingExportOptions, ChunkingOptionType, ClearResponse, ConfidenceScores, ConversionInput, ConversionItem, ConversionResult, ConversionSource, ConversionSourceInput, ConversionStatus, ConvertAllOptions, ConvertDocumentErrorResponse, ConvertDocumentResponse, ConvertDocumentResult, ConvertDocumentsOptions, ConvertDocumentsRequest, ConvertOptions, ConvertSourcesRequest, ConvertedOutcomeCountsMixin, DoclingBinaryResponse, DoclingClientOptions, DoclingComponentType, DoclingDocument, DoclingRequestBodyType, DoclingResponseType, DoclingTaskResult, DoclingTransport, DoclingTransportRequest, DocumentArtifactItem, DocumentCompletedItem, DocumentLimits, DocumentResultItem, ErrorItem, ExportDocumentResponse, ExportResult, FailureCategory, FailurePhase, FetchLike, FetchTransportOptions, FileSource, FileSourceRequest, GenericChunkDocumentsRequest, GenericSource, GenericSourceRequest, GenericTarget, GenericTargetRequest, GoogleCloudStorageCoordinates, GoogleCloudStorageServiceAccountInfo, GoogleCloudStorageSource, GoogleCloudStorageSourceRequest, GoogleCloudStorageTarget, GoogleDriveCoordinates, GoogleDriveCredentials, GoogleDriveSource, GoogleDriveSourceRequest, GoogleDriveTarget, HeadingHierarchyOptions, HealthCheckResponse, HierarchicalChunkSourcesRequest, HierarchicalChunkerOptions, HierarchicalChunkingOptions, HttpSource, HttpSourceRequest, HybridChunkSourcesRequest, HybridChunkerOptions, HybridChunkingOptions, ImageExportMode, ImageRefMode, InBodyConversionResponse, InBodyTarget, InferenceFramework, InputFormat, KnownBatchSourceRequestItem, KnownBatchTargetRequest, LegacyVlmModelType, MessageKind, NormalizedJsonSource, NormalizedMultipartSource, NormalizedSource, OutcomeCounts, OutputFormat, ParsedOrigin, PdfBackend, PictureClassificationLabel, PictureDescriptionApi, PictureDescriptionLocal, PresignedArtifactResult, PresignedUrlConvertDocumentResponse, PresignedUrlConvertResponse, PresignedUrlTarget, ProcessedDocsItem, ProcessingPipeline, ProfilingItem, ProfilingScope, ProgressCallbackRequest, ProgressCallbackResponse, ProgressDocumentCompleted, ProgressKind, ProgressSetNumDocs, ProgressTaskCompleted, ProgressUpdateProcessed, PublicFailureInfo, PutTarget, QualityGrade, RawServiceResult, ReadinessResponse, RemoteTargetResponse, RemoteTargetResult, ResponseFormat, ResultType, S3Coordinates, S3Source, S3SourceRequest, S3Target, SourceRequestItem, StorageTarget, SubmitAndRetrieveOptions, SubmitCallOptions, SubmitResultForTarget, SubmitSourceOptions, SubmitTarget, TableFormerMode, TableMode, Target, TargetRequest, TaskFailureResult, TaskProcessingMeta, TaskStatus, TaskStatusResponse, TaskType, TransformersModelType, UsageLimitExceededDetails, UsageLimitExceededResponse, VlmInferenceFramework, VlmModelApi, VlmModelLocal, VlmModelType, VlmResponseFormat, WaitForTaskOptions, WatchTaskOptions, WebSocketFactory, WebSocketFactoryOptions, WebSocketLike, WebsocketMessage, ZipArchiveResult, ZipTarget };
|
package/dist/index.d.ts
CHANGED
|
@@ -593,7 +593,7 @@ interface WebsocketMessage {
|
|
|
593
593
|
task?: TaskStatusResponse | null;
|
|
594
594
|
error?: string | null;
|
|
595
595
|
}
|
|
596
|
-
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
|
|
596
|
+
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle' | 'chunks';
|
|
597
597
|
interface ArtifactRef {
|
|
598
598
|
artifact_type: ArtifactType;
|
|
599
599
|
mime_type: string;
|
|
@@ -730,6 +730,12 @@ interface SubmitAndRetrieveOptions<TTarget extends SubmitTarget> {
|
|
|
730
730
|
}
|
|
731
731
|
|
|
732
732
|
type ArtifactAddressResolver = (hostname: string) => Promise<string[]>;
|
|
733
|
+
interface ParsedOrigin {
|
|
734
|
+
protocol: string;
|
|
735
|
+
hostname: string;
|
|
736
|
+
port: number;
|
|
737
|
+
}
|
|
738
|
+
declare function parseArtifactOrigin(value: string): ParsedOrigin;
|
|
733
739
|
interface ArtifactDownloaderOptions {
|
|
734
740
|
fetch?: typeof globalThis.fetch;
|
|
735
741
|
resolver?: ArtifactAddressResolver;
|
|
@@ -737,6 +743,7 @@ interface ArtifactDownloaderOptions {
|
|
|
737
743
|
timeoutMs?: number;
|
|
738
744
|
maxBytes?: number;
|
|
739
745
|
maxRedirects?: number;
|
|
746
|
+
artifactUrlAllowlist?: string[];
|
|
740
747
|
}
|
|
741
748
|
declare class ArtifactDownloader {
|
|
742
749
|
#private;
|
|
@@ -840,6 +847,10 @@ interface DoclingClientOptions {
|
|
|
840
847
|
maxConcurrency?: number;
|
|
841
848
|
artifactDownloader?: ArtifactDownloader;
|
|
842
849
|
artifactDownload?: ArtifactDownloaderOptions;
|
|
850
|
+
artifactDownloadTimeout?: number;
|
|
851
|
+
maxArtifactDownloadBytes?: number;
|
|
852
|
+
artifactUrlAllowlist?: string[];
|
|
853
|
+
allowPrivateArtifactUrls?: boolean;
|
|
843
854
|
}
|
|
844
855
|
interface SubmitCallOptions {
|
|
845
856
|
signal?: AbortSignal;
|
|
@@ -1107,5 +1118,5 @@ declare function preflightFileSize(source: NormalizedSource, maxFileSize: number
|
|
|
1107
1118
|
declare function appendFormValue(form: FormData, key: string, value: unknown): void;
|
|
1108
1119
|
declare function fileSourceFromBinary(source: BinaryFileSource, signal?: AbortSignal): Promise<FileSource>;
|
|
1109
1120
|
|
|
1110
|
-
export { ArtifactDownloader, ChunkerKind, ChunkerType, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, DoclingClient, DoclingConversionError, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, DoclingResponseSchemaMismatchError, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, DoclingUsageLimitExceededError, FetchTransport, MAX_CONCURRENCY_LIMIT, StatusWatcherKind, TargetName, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
|
|
1111
|
-
export type { AnyHttpSourceRequest, ArtifactAddressResolver, ArtifactDownloaderOptions, ArtifactRef, ArtifactType, AutoSubmitResult, AzureBlobCoordinates, AzureBlobSource, AzureBlobSourceRequest, AzureBlobTarget, BaseChunkDocumentsRequest, BaseChunkerOptions, BaseChunkingOptions, BaseProgress, BatchConvertSourcesRequest, BatchResultForTarget, BatchSource, BatchSourceRequestInput, BatchSourceRequestItem, BatchSubmitCallOptions, BatchTarget, BatchTargetRequest, BatchTargetRequestInput, BinaryFileSource, CallbackSpec, ChunkCallOptions, ChunkDocumentResponse, ChunkSourceOptions, ChunkSourcesRequest, ChunkedDocumentResult, ChunkedDocumentResultItem, ChunkingExportOptions, ChunkingOptionType, ClearResponse, ConfidenceScores, ConversionInput, ConversionItem, ConversionResult, ConversionSource, ConversionSourceInput, ConversionStatus, ConvertAllOptions, ConvertDocumentErrorResponse, ConvertDocumentResponse, ConvertDocumentResult, ConvertDocumentsOptions, ConvertDocumentsRequest, ConvertOptions, ConvertSourcesRequest, ConvertedOutcomeCountsMixin, DoclingBinaryResponse, DoclingClientOptions, DoclingComponentType, DoclingDocument, DoclingRequestBodyType, DoclingResponseType, DoclingTaskResult, DoclingTransport, DoclingTransportRequest, DocumentArtifactItem, DocumentCompletedItem, DocumentLimits, DocumentResultItem, ErrorItem, ExportDocumentResponse, ExportResult, FailureCategory, FailurePhase, FetchLike, FetchTransportOptions, FileSource, FileSourceRequest, GenericChunkDocumentsRequest, GenericSource, GenericSourceRequest, GenericTarget, GenericTargetRequest, GoogleCloudStorageCoordinates, GoogleCloudStorageServiceAccountInfo, GoogleCloudStorageSource, GoogleCloudStorageSourceRequest, GoogleCloudStorageTarget, GoogleDriveCoordinates, GoogleDriveCredentials, GoogleDriveSource, GoogleDriveSourceRequest, GoogleDriveTarget, HeadingHierarchyOptions, HealthCheckResponse, HierarchicalChunkSourcesRequest, HierarchicalChunkerOptions, HierarchicalChunkingOptions, HttpSource, HttpSourceRequest, HybridChunkSourcesRequest, HybridChunkerOptions, HybridChunkingOptions, ImageExportMode, ImageRefMode, InBodyConversionResponse, InBodyTarget, InferenceFramework, InputFormat, KnownBatchSourceRequestItem, KnownBatchTargetRequest, LegacyVlmModelType, MessageKind, NormalizedJsonSource, NormalizedMultipartSource, NormalizedSource, OutcomeCounts, OutputFormat, PdfBackend, PictureClassificationLabel, PictureDescriptionApi, PictureDescriptionLocal, PresignedArtifactResult, PresignedUrlConvertDocumentResponse, PresignedUrlConvertResponse, PresignedUrlTarget, ProcessedDocsItem, ProcessingPipeline, ProfilingItem, ProfilingScope, ProgressCallbackRequest, ProgressCallbackResponse, ProgressDocumentCompleted, ProgressKind, ProgressSetNumDocs, ProgressTaskCompleted, ProgressUpdateProcessed, PublicFailureInfo, PutTarget, QualityGrade, RawServiceResult, ReadinessResponse, RemoteTargetResponse, RemoteTargetResult, ResponseFormat, ResultType, S3Coordinates, S3Source, S3SourceRequest, S3Target, SourceRequestItem, StorageTarget, SubmitAndRetrieveOptions, SubmitCallOptions, SubmitResultForTarget, SubmitSourceOptions, SubmitTarget, TableFormerMode, TableMode, Target, TargetRequest, TaskFailureResult, TaskProcessingMeta, TaskStatus, TaskStatusResponse, TaskType, TransformersModelType, UsageLimitExceededDetails, UsageLimitExceededResponse, VlmInferenceFramework, VlmModelApi, VlmModelLocal, VlmModelType, VlmResponseFormat, WaitForTaskOptions, WatchTaskOptions, WebSocketFactory, WebSocketFactoryOptions, WebSocketLike, WebsocketMessage, ZipArchiveResult, ZipTarget };
|
|
1121
|
+
export { ArtifactDownloader, ChunkerKind, ChunkerType, DEFAULT_MAX_CONCURRENCY, DoclingArtifactDownloadError, DoclingBatchConversionError, DoclingClient, DoclingConversionError, DoclingError, DoclingHttpError, DoclingJob, DoclingProtocolError, DoclingResponseSchemaMismatchError, DoclingResultExpiredError, DoclingResultNotReadyError, DoclingServiceError, DoclingServiceUnavailableError, DoclingTaskError, DoclingTaskNotFoundError, DoclingTimeoutError, DoclingUsageLimitExceededError, FetchTransport, MAX_CONCURRENCY_LIMIT, StatusWatcherKind, TargetName, appendFormValue, applyPageLimits, documentFromBundle, documentFromJson, fileSourceFromBinary, materializePresignedResult, normalizeSourceInput, parseArtifactOrigin, preflightFileSize, resolveConvertOptions, selectDocumentArtifact, validateConvertOptions, validateMaxFileSize, watchTask, withJsonOutput };
|
|
1122
|
+
export type { AnyHttpSourceRequest, ArtifactAddressResolver, ArtifactDownloaderOptions, ArtifactRef, ArtifactType, AutoSubmitResult, AzureBlobCoordinates, AzureBlobSource, AzureBlobSourceRequest, AzureBlobTarget, BaseChunkDocumentsRequest, BaseChunkerOptions, BaseChunkingOptions, BaseProgress, BatchConvertSourcesRequest, BatchResultForTarget, BatchSource, BatchSourceRequestInput, BatchSourceRequestItem, BatchSubmitCallOptions, BatchTarget, BatchTargetRequest, BatchTargetRequestInput, BinaryFileSource, CallbackSpec, ChunkCallOptions, ChunkDocumentResponse, ChunkSourceOptions, ChunkSourcesRequest, ChunkedDocumentResult, ChunkedDocumentResultItem, ChunkingExportOptions, ChunkingOptionType, ClearResponse, ConfidenceScores, ConversionInput, ConversionItem, ConversionResult, ConversionSource, ConversionSourceInput, ConversionStatus, ConvertAllOptions, ConvertDocumentErrorResponse, ConvertDocumentResponse, ConvertDocumentResult, ConvertDocumentsOptions, ConvertDocumentsRequest, ConvertOptions, ConvertSourcesRequest, ConvertedOutcomeCountsMixin, DoclingBinaryResponse, DoclingClientOptions, DoclingComponentType, DoclingDocument, DoclingRequestBodyType, DoclingResponseType, DoclingTaskResult, DoclingTransport, DoclingTransportRequest, DocumentArtifactItem, DocumentCompletedItem, DocumentLimits, DocumentResultItem, ErrorItem, ExportDocumentResponse, ExportResult, FailureCategory, FailurePhase, FetchLike, FetchTransportOptions, FileSource, FileSourceRequest, GenericChunkDocumentsRequest, GenericSource, GenericSourceRequest, GenericTarget, GenericTargetRequest, GoogleCloudStorageCoordinates, GoogleCloudStorageServiceAccountInfo, GoogleCloudStorageSource, GoogleCloudStorageSourceRequest, GoogleCloudStorageTarget, GoogleDriveCoordinates, GoogleDriveCredentials, GoogleDriveSource, GoogleDriveSourceRequest, GoogleDriveTarget, HeadingHierarchyOptions, HealthCheckResponse, HierarchicalChunkSourcesRequest, HierarchicalChunkerOptions, HierarchicalChunkingOptions, HttpSource, HttpSourceRequest, HybridChunkSourcesRequest, HybridChunkerOptions, HybridChunkingOptions, ImageExportMode, ImageRefMode, InBodyConversionResponse, InBodyTarget, InferenceFramework, InputFormat, KnownBatchSourceRequestItem, KnownBatchTargetRequest, LegacyVlmModelType, MessageKind, NormalizedJsonSource, NormalizedMultipartSource, NormalizedSource, OutcomeCounts, OutputFormat, ParsedOrigin, PdfBackend, PictureClassificationLabel, PictureDescriptionApi, PictureDescriptionLocal, PresignedArtifactResult, PresignedUrlConvertDocumentResponse, PresignedUrlConvertResponse, PresignedUrlTarget, ProcessedDocsItem, ProcessingPipeline, ProfilingItem, ProfilingScope, ProgressCallbackRequest, ProgressCallbackResponse, ProgressDocumentCompleted, ProgressKind, ProgressSetNumDocs, ProgressTaskCompleted, ProgressUpdateProcessed, PublicFailureInfo, PutTarget, QualityGrade, RawServiceResult, ReadinessResponse, RemoteTargetResponse, RemoteTargetResult, ResponseFormat, ResultType, S3Coordinates, S3Source, S3SourceRequest, S3Target, SourceRequestItem, StorageTarget, SubmitAndRetrieveOptions, SubmitCallOptions, SubmitResultForTarget, SubmitSourceOptions, SubmitTarget, TableFormerMode, TableMode, Target, TargetRequest, TaskFailureResult, TaskProcessingMeta, TaskStatus, TaskStatusResponse, TaskType, TransformersModelType, UsageLimitExceededDetails, UsageLimitExceededResponse, VlmInferenceFramework, VlmModelApi, VlmModelLocal, VlmModelType, VlmResponseFormat, WaitForTaskOptions, WatchTaskOptions, WebSocketFactory, WebSocketFactoryOptions, WebSocketLike, WebsocketMessage, ZipArchiveResult, ZipTarget };
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,27 @@ var DoclingBatchConversionError = class extends DoclingError {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
// src/artifacts.ts
|
|
121
|
+
function parseArtifactOrigin(value) {
|
|
122
|
+
try {
|
|
123
|
+
const url = new URL(value);
|
|
124
|
+
const protocol = url.protocol.toLowerCase();
|
|
125
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
126
|
+
throw new Error("Only http and https protocols are supported");
|
|
127
|
+
}
|
|
128
|
+
const hostname = url.hostname.toLowerCase();
|
|
129
|
+
if (!hostname) {
|
|
130
|
+
throw new Error("Host is required");
|
|
131
|
+
}
|
|
132
|
+
const defaultPort = protocol === "http:" ? 80 : 443;
|
|
133
|
+
const port = url.port !== "" ? parseInt(url.port, 10) : defaultPort;
|
|
134
|
+
return { protocol: protocol.slice(0, -1), hostname, port };
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throw new DoclingArtifactDownloadError(
|
|
137
|
+
`Invalid artifactUrlAllowlist entry ${JSON.stringify(value)}: expected an http(s) origin such as 'http://minio.storage.svc.cluster.local:9000'.`,
|
|
138
|
+
{ cause: error }
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
121
142
|
var ArtifactDownloader = class {
|
|
122
143
|
#fetch;
|
|
123
144
|
#resolver;
|
|
@@ -125,6 +146,7 @@ var ArtifactDownloader = class {
|
|
|
125
146
|
#timeoutMs;
|
|
126
147
|
#maxBytes;
|
|
127
148
|
#maxRedirects;
|
|
149
|
+
#artifactUrlAllowlist;
|
|
128
150
|
constructor(options = {}) {
|
|
129
151
|
if (options.fetch === void 0 && globalThis.fetch === void 0) {
|
|
130
152
|
throw new DoclingArtifactDownloadError(
|
|
@@ -137,6 +159,8 @@ var ArtifactDownloader = class {
|
|
|
137
159
|
this.#timeoutMs = options.timeoutMs ?? 6e4;
|
|
138
160
|
this.#maxBytes = options.maxBytes ?? 512 * 1024 * 1024;
|
|
139
161
|
this.#maxRedirects = options.maxRedirects ?? 5;
|
|
162
|
+
const allowlist = options.artifactUrlAllowlist ?? [];
|
|
163
|
+
this.#artifactUrlAllowlist = allowlist.map(parseArtifactOrigin);
|
|
140
164
|
validateArtifactLimits(this.#timeoutMs, this.#maxBytes, this.#maxRedirects);
|
|
141
165
|
}
|
|
142
166
|
async download(url, signal) {
|
|
@@ -213,13 +237,23 @@ var ArtifactDownloader = class {
|
|
|
213
237
|
if (this.#allowPrivateUrls) {
|
|
214
238
|
return;
|
|
215
239
|
}
|
|
216
|
-
const
|
|
240
|
+
const protocol = url.protocol.slice(0, -1).toLowerCase();
|
|
241
|
+
const hostname = url.hostname.toLowerCase();
|
|
242
|
+
const defaultPort = protocol === "http" ? 80 : 443;
|
|
243
|
+
const port = url.port !== "" ? parseInt(url.port, 10) : defaultPort;
|
|
244
|
+
const isTrusted = this.#artifactUrlAllowlist.some(
|
|
245
|
+
(origin) => origin.protocol === protocol && origin.hostname === hostname && origin.port === port
|
|
246
|
+
);
|
|
247
|
+
if (isTrusted) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const cleanHostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
217
251
|
let addresses;
|
|
218
252
|
try {
|
|
219
|
-
addresses = ipaddr.isValid(
|
|
253
|
+
addresses = ipaddr.isValid(cleanHostname) ? [cleanHostname] : await this.#resolver(cleanHostname);
|
|
220
254
|
} catch (error) {
|
|
221
255
|
throw new DoclingArtifactDownloadError(
|
|
222
|
-
`Could not resolve artifact host ${
|
|
256
|
+
`Could not resolve artifact host ${cleanHostname}`,
|
|
223
257
|
{ cause: error }
|
|
224
258
|
);
|
|
225
259
|
}
|
|
@@ -2337,7 +2371,22 @@ var DoclingClient = class {
|
|
|
2337
2371
|
this.#maxConcurrency = validateConcurrency(
|
|
2338
2372
|
options.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY
|
|
2339
2373
|
);
|
|
2340
|
-
|
|
2374
|
+
const downloaderOptions = {
|
|
2375
|
+
...options.artifactDownload
|
|
2376
|
+
};
|
|
2377
|
+
if (options.artifactDownloadTimeout !== void 0) {
|
|
2378
|
+
downloaderOptions.timeoutMs = options.artifactDownloadTimeout;
|
|
2379
|
+
}
|
|
2380
|
+
if (options.maxArtifactDownloadBytes !== void 0) {
|
|
2381
|
+
downloaderOptions.maxBytes = options.maxArtifactDownloadBytes;
|
|
2382
|
+
}
|
|
2383
|
+
if (options.artifactUrlAllowlist !== void 0) {
|
|
2384
|
+
downloaderOptions.artifactUrlAllowlist = options.artifactUrlAllowlist;
|
|
2385
|
+
}
|
|
2386
|
+
if (options.allowPrivateArtifactUrls !== void 0) {
|
|
2387
|
+
downloaderOptions.allowPrivateUrls = options.allowPrivateArtifactUrls;
|
|
2388
|
+
}
|
|
2389
|
+
this.#artifactDownloader = options.artifactDownloader ?? new ArtifactDownloader(downloaderOptions);
|
|
2341
2390
|
}
|
|
2342
2391
|
async health(options = {}) {
|
|
2343
2392
|
const value = await this.#request("GET", "/health", {
|
|
@@ -2863,7 +2912,9 @@ var DoclingClient = class {
|
|
|
2863
2912
|
target: { kind: "inbody" }
|
|
2864
2913
|
},
|
|
2865
2914
|
options
|
|
2866
|
-
)
|
|
2915
|
+
).catch((fallbackError) => {
|
|
2916
|
+
throw combineInBodyFallbackError(error, fallbackError);
|
|
2917
|
+
});
|
|
2867
2918
|
});
|
|
2868
2919
|
}
|
|
2869
2920
|
#submitNormalizedWithAutoTarget(source, options, requestOptions) {
|
|
@@ -2881,7 +2932,9 @@ var DoclingClient = class {
|
|
|
2881
2932
|
withJsonOutput(options),
|
|
2882
2933
|
{ kind: "inbody" },
|
|
2883
2934
|
requestOptions
|
|
2884
|
-
)
|
|
2935
|
+
).catch((fallbackError) => {
|
|
2936
|
+
throw combineInBodyFallbackError(error, fallbackError);
|
|
2937
|
+
});
|
|
2885
2938
|
});
|
|
2886
2939
|
}
|
|
2887
2940
|
async #submitRequestForTarget(request, options) {
|
|
@@ -3407,7 +3460,8 @@ function parsePresignedResponse(value) {
|
|
|
3407
3460
|
"doctags",
|
|
3408
3461
|
"doclang",
|
|
3409
3462
|
"dclx",
|
|
3410
|
-
"resource_bundle"
|
|
3463
|
+
"resource_bundle",
|
|
3464
|
+
"chunks"
|
|
3411
3465
|
].includes(String(artifact.artifact_type))) {
|
|
3412
3466
|
throw schemaMismatch(`${artifactPath}.artifact_type is unsupported`);
|
|
3413
3467
|
}
|
|
@@ -3711,6 +3765,18 @@ function shouldFallbackFromPresigned(error) {
|
|
|
3711
3765
|
"enum"
|
|
3712
3766
|
].some((phrase) => detail.includes(phrase));
|
|
3713
3767
|
}
|
|
3768
|
+
function combineInBodyFallbackError(presignedError, fallbackError) {
|
|
3769
|
+
if (!(presignedError instanceof DoclingHttpError) || !(fallbackError instanceof DoclingHttpError) || ![400, 422].includes(fallbackError.status)) {
|
|
3770
|
+
return fallbackError;
|
|
3771
|
+
}
|
|
3772
|
+
const fallbackDetail = httpDetail2(fallbackError.body);
|
|
3773
|
+
const prefix = fallbackDetail === void 0 ? "" : `${fallbackDetail} `;
|
|
3774
|
+
return new DoclingServiceError(fallbackError.message, {
|
|
3775
|
+
status: fallbackError.status,
|
|
3776
|
+
detail: `${prefix}The client tried the InBody target because the server rejected the presigned_url target: ${httpDetail2(presignedError.body)}`,
|
|
3777
|
+
cause: fallbackError
|
|
3778
|
+
});
|
|
3779
|
+
}
|
|
3714
3780
|
function targetNeedsJson(target) {
|
|
3715
3781
|
return target.kind === "inbody";
|
|
3716
3782
|
}
|
|
@@ -4187,6 +4253,7 @@ export {
|
|
|
4187
4253
|
fileSourceFromBinary,
|
|
4188
4254
|
materializePresignedResult,
|
|
4189
4255
|
normalizeSourceInput,
|
|
4256
|
+
parseArtifactOrigin,
|
|
4190
4257
|
preflightFileSize,
|
|
4191
4258
|
resolveConvertOptions,
|
|
4192
4259
|
selectDocumentArtifact,
|