@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/dist/index.d.cts
CHANGED
|
@@ -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
|
@@ -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", {
|
|
@@ -4204,6 +4253,7 @@ export {
|
|
|
4204
4253
|
fileSourceFromBinary,
|
|
4205
4254
|
materializePresignedResult,
|
|
4206
4255
|
normalizeSourceInput,
|
|
4256
|
+
parseArtifactOrigin,
|
|
4207
4257
|
preflightFileSize,
|
|
4208
4258
|
resolveConvertOptions,
|
|
4209
4259
|
selectDocumentArtifact,
|