@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 +25 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ interface DoclingDocument {
|
|
|
12
12
|
name: string;
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
|
-
type InputFormat = 'docx' | 'doc' | 'pptx' | 'html' | 'image' | 'pdf' | 'asciidoc' | 'md' | 'csv' | 'xlsx' | 'xml_uspto' | 'xml_jats' | 'json_docling' | 'dclx' | 'audio' | 'vtt' | 'xml_xbrl' | 'mets_gbs' | 'latex' | 'ppt' | 'xls' | 'odt' | 'ods' | 'odp' | 'xml_doclang' | 'video' | 'email' | 'epub' | 'boxnote';
|
|
15
|
+
type InputFormat = 'docx' | 'doc' | 'pptx' | 'html' | 'image' | 'pdf' | 'asciidoc' | 'md' | 'csv' | 'xlsx' | 'xml_uspto' | 'xml_jats' | 'json_docling' | 'dclx' | 'audio' | 'vtt' | 'xml_xbrl' | 'mets_gbs' | 'latex' | 'ppt' | 'xls' | 'odt' | 'ods' | 'odp' | 'xml_doclang' | 'video' | 'email' | 'epub' | 'boxnote' | 'ebcdic';
|
|
16
16
|
type OutputFormat = 'md' | 'json' | 'yaml' | 'html' | 'html_split_page' | 'text' | 'doctags' | 'vtt' | 'doclang' | 'dclx' | 'chunks';
|
|
17
17
|
type ProcessingPipeline = 'legacy' | 'standard' | 'vlm' | 'asr';
|
|
18
18
|
type TableMode = 'fast' | 'accurate';
|
|
@@ -225,18 +225,16 @@ interface GoogleDriveSource extends GoogleDriveCoordinates {
|
|
|
225
225
|
interface GoogleDriveTarget extends GoogleDriveCoordinates {
|
|
226
226
|
kind: 'google_drive';
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
type GenericSource = {
|
|
229
229
|
kind: string;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
interface GenericTarget {
|
|
230
|
+
} & Record<string, unknown>;
|
|
231
|
+
type GenericTarget = {
|
|
233
232
|
kind: string;
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
type StorageTarget = S3Target | AzureBlobTarget | GoogleCloudStorageTarget | GoogleDriveTarget;
|
|
237
|
-
type SubmitTarget = InBodyTarget | ZipTarget | PresignedUrlTarget | PutTarget | StorageTarget;
|
|
233
|
+
} & Record<string, unknown>;
|
|
238
234
|
type BatchSource = HttpSource | S3Source | AzureBlobSource | GoogleCloudStorageSource | GoogleDriveSource | GenericSource;
|
|
239
235
|
type BatchTarget = PresignedUrlTarget | StorageTarget | GenericTarget;
|
|
236
|
+
type StorageTarget = S3Target | AzureBlobTarget | GoogleCloudStorageTarget | GoogleDriveTarget;
|
|
237
|
+
type SubmitTarget = InBodyTarget | ZipTarget | PresignedUrlTarget | PutTarget | StorageTarget;
|
|
240
238
|
interface CallbackSpec {
|
|
241
239
|
url: string;
|
|
242
240
|
headers?: Record<string, string>;
|
|
@@ -252,7 +250,8 @@ interface ConvertSourcesRequest<TTarget extends SubmitTarget = SubmitTarget> {
|
|
|
252
250
|
interface BatchConvertSourcesRequest<TTarget extends BatchTarget = BatchTarget> {
|
|
253
251
|
options?: ConvertDocumentsOptions;
|
|
254
252
|
sources: BatchSource[];
|
|
255
|
-
target
|
|
253
|
+
target?: TTarget;
|
|
254
|
+
targets?: TTarget[];
|
|
256
255
|
callbacks?: CallbackSpec[];
|
|
257
256
|
}
|
|
258
257
|
type ChunkerKind = 'hybrid' | 'hierarchical';
|
|
@@ -359,7 +358,7 @@ interface ExportResult<TDocument = DoclingDocument> {
|
|
|
359
358
|
timings: Record<string, ProfilingItem>;
|
|
360
359
|
confidence?: ConfidenceScores | null;
|
|
361
360
|
}
|
|
362
|
-
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'resource_bundle';
|
|
361
|
+
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
|
|
363
362
|
interface ArtifactRef {
|
|
364
363
|
artifact_type: ArtifactType;
|
|
365
364
|
mime_type: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface DoclingDocument {
|
|
|
12
12
|
name: string;
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
|
-
type InputFormat = 'docx' | 'doc' | 'pptx' | 'html' | 'image' | 'pdf' | 'asciidoc' | 'md' | 'csv' | 'xlsx' | 'xml_uspto' | 'xml_jats' | 'json_docling' | 'dclx' | 'audio' | 'vtt' | 'xml_xbrl' | 'mets_gbs' | 'latex' | 'ppt' | 'xls' | 'odt' | 'ods' | 'odp' | 'xml_doclang' | 'video' | 'email' | 'epub' | 'boxnote';
|
|
15
|
+
type InputFormat = 'docx' | 'doc' | 'pptx' | 'html' | 'image' | 'pdf' | 'asciidoc' | 'md' | 'csv' | 'xlsx' | 'xml_uspto' | 'xml_jats' | 'json_docling' | 'dclx' | 'audio' | 'vtt' | 'xml_xbrl' | 'mets_gbs' | 'latex' | 'ppt' | 'xls' | 'odt' | 'ods' | 'odp' | 'xml_doclang' | 'video' | 'email' | 'epub' | 'boxnote' | 'ebcdic';
|
|
16
16
|
type OutputFormat = 'md' | 'json' | 'yaml' | 'html' | 'html_split_page' | 'text' | 'doctags' | 'vtt' | 'doclang' | 'dclx' | 'chunks';
|
|
17
17
|
type ProcessingPipeline = 'legacy' | 'standard' | 'vlm' | 'asr';
|
|
18
18
|
type TableMode = 'fast' | 'accurate';
|
|
@@ -225,18 +225,16 @@ interface GoogleDriveSource extends GoogleDriveCoordinates {
|
|
|
225
225
|
interface GoogleDriveTarget extends GoogleDriveCoordinates {
|
|
226
226
|
kind: 'google_drive';
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
type GenericSource = {
|
|
229
229
|
kind: string;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
interface GenericTarget {
|
|
230
|
+
} & Record<string, unknown>;
|
|
231
|
+
type GenericTarget = {
|
|
233
232
|
kind: string;
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
type StorageTarget = S3Target | AzureBlobTarget | GoogleCloudStorageTarget | GoogleDriveTarget;
|
|
237
|
-
type SubmitTarget = InBodyTarget | ZipTarget | PresignedUrlTarget | PutTarget | StorageTarget;
|
|
233
|
+
} & Record<string, unknown>;
|
|
238
234
|
type BatchSource = HttpSource | S3Source | AzureBlobSource | GoogleCloudStorageSource | GoogleDriveSource | GenericSource;
|
|
239
235
|
type BatchTarget = PresignedUrlTarget | StorageTarget | GenericTarget;
|
|
236
|
+
type StorageTarget = S3Target | AzureBlobTarget | GoogleCloudStorageTarget | GoogleDriveTarget;
|
|
237
|
+
type SubmitTarget = InBodyTarget | ZipTarget | PresignedUrlTarget | PutTarget | StorageTarget;
|
|
240
238
|
interface CallbackSpec {
|
|
241
239
|
url: string;
|
|
242
240
|
headers?: Record<string, string>;
|
|
@@ -252,7 +250,8 @@ interface ConvertSourcesRequest<TTarget extends SubmitTarget = SubmitTarget> {
|
|
|
252
250
|
interface BatchConvertSourcesRequest<TTarget extends BatchTarget = BatchTarget> {
|
|
253
251
|
options?: ConvertDocumentsOptions;
|
|
254
252
|
sources: BatchSource[];
|
|
255
|
-
target
|
|
253
|
+
target?: TTarget;
|
|
254
|
+
targets?: TTarget[];
|
|
256
255
|
callbacks?: CallbackSpec[];
|
|
257
256
|
}
|
|
258
257
|
type ChunkerKind = 'hybrid' | 'hierarchical';
|
|
@@ -359,7 +358,7 @@ interface ExportResult<TDocument = DoclingDocument> {
|
|
|
359
358
|
timings: Record<string, ProfilingItem>;
|
|
360
359
|
confidence?: ConfidenceScores | null;
|
|
361
360
|
}
|
|
362
|
-
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'resource_bundle';
|
|
361
|
+
type ArtifactType = 'json' | 'html' | 'markdown' | 'text' | 'doctags' | 'doclang' | 'dclx' | 'resource_bundle';
|
|
363
362
|
interface ArtifactRef {
|
|
364
363
|
artifact_type: ArtifactType;
|
|
365
364
|
mime_type: string;
|
package/dist/index.js
CHANGED
|
@@ -2397,7 +2397,8 @@ var DoclingClient = class {
|
|
|
2397
2397
|
const payload = {
|
|
2398
2398
|
options: convertOptions,
|
|
2399
2399
|
sources: structuredClone(request.sources),
|
|
2400
|
-
target: structuredClone(request.target),
|
|
2400
|
+
...request.target !== void 0 ? { target: structuredClone(request.target) } : {},
|
|
2401
|
+
...request.targets !== void 0 ? { targets: structuredClone(request.targets) } : {},
|
|
2401
2402
|
callbacks: structuredClone(request.callbacks ?? [])
|
|
2402
2403
|
};
|
|
2403
2404
|
throwIfAborted2(options.signal);
|
|
@@ -2408,7 +2409,8 @@ var DoclingClient = class {
|
|
|
2408
2409
|
signal: options.signal
|
|
2409
2410
|
})
|
|
2410
2411
|
);
|
|
2411
|
-
const
|
|
2412
|
+
const effectiveTargetList = request.targets?.length ? request.targets : request.target !== void 0 ? [request.target] : [];
|
|
2413
|
+
const loader = effectiveTargetList.some(isStorageTarget) ? (taskId, lastStatus, signal) => this.#fetchCountsResult(taskId, lastStatus, signal) : (taskId, lastStatus, signal) => this.#fetchPresignedResult(taskId, lastStatus, signal);
|
|
2412
2414
|
return new DoclingJob(
|
|
2413
2415
|
this,
|
|
2414
2416
|
status,
|
|
@@ -3333,6 +3335,7 @@ function parsePresignedResponse(value) {
|
|
|
3333
3335
|
"text",
|
|
3334
3336
|
"doctags",
|
|
3335
3337
|
"doclang",
|
|
3338
|
+
"dclx",
|
|
3336
3339
|
"resource_bundle"
|
|
3337
3340
|
].includes(String(artifact.artifact_type))) {
|
|
3338
3341
|
throw schemaMismatch(`${artifactPath}.artifact_type is unsupported`);
|
|
@@ -3629,8 +3632,8 @@ function shouldFallbackFromPresigned(error) {
|
|
|
3629
3632
|
function targetNeedsJson(target) {
|
|
3630
3633
|
return target.kind === "inbody";
|
|
3631
3634
|
}
|
|
3632
|
-
function
|
|
3633
|
-
return target.kind
|
|
3635
|
+
function isStorageTarget(target) {
|
|
3636
|
+
return target.kind !== "presigned_url";
|
|
3634
3637
|
}
|
|
3635
3638
|
function validateBatchRequest(request) {
|
|
3636
3639
|
if (!Array.isArray(request.sources) || request.sources.length === 0) {
|
|
@@ -3645,15 +3648,28 @@ function validateBatchRequest(request) {
|
|
|
3645
3648
|
}
|
|
3646
3649
|
validateKnownConnector(source, "source");
|
|
3647
3650
|
}
|
|
3648
|
-
if (
|
|
3649
|
-
throw new DoclingProtocolError(
|
|
3651
|
+
if (request.target === void 0 && (request.targets === void 0 || request.targets.length === 0)) {
|
|
3652
|
+
throw new DoclingProtocolError(
|
|
3653
|
+
"Batch conversion requires either 'target' or 'targets'"
|
|
3654
|
+
);
|
|
3650
3655
|
}
|
|
3651
|
-
if (
|
|
3656
|
+
if (request.target !== void 0 && request.targets !== void 0 && request.targets.length > 0) {
|
|
3652
3657
|
throw new DoclingProtocolError(
|
|
3653
|
-
|
|
3658
|
+
"Batch conversion received both 'target' and 'targets'; supply only one"
|
|
3654
3659
|
);
|
|
3655
3660
|
}
|
|
3656
|
-
|
|
3661
|
+
const effectiveTargets = request.targets && request.targets.length > 0 ? request.targets : request.target !== void 0 ? [request.target] : [];
|
|
3662
|
+
for (const target of effectiveTargets) {
|
|
3663
|
+
if (!isRecord4(target) || typeof target.kind !== "string" || target.kind === "") {
|
|
3664
|
+
throw new DoclingProtocolError("Batch target kind must not be empty");
|
|
3665
|
+
}
|
|
3666
|
+
if (["inbody", "zip", "put"].includes(target.kind)) {
|
|
3667
|
+
throw new DoclingProtocolError(
|
|
3668
|
+
`Batch conversion does not accept ${target.kind} targets`
|
|
3669
|
+
);
|
|
3670
|
+
}
|
|
3671
|
+
validateKnownConnector(target, "target");
|
|
3672
|
+
}
|
|
3657
3673
|
validateCallbacks(request.callbacks);
|
|
3658
3674
|
}
|
|
3659
3675
|
function validateChunkRequestOptions(request) {
|