@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.cjs +21 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51,11 +51,11 @@ __export(index_exports, {
|
|
|
51
51
|
DoclingUsageLimitExceededError: () => DoclingUsageLimitExceededError,
|
|
52
52
|
FetchTransport: () => FetchTransport,
|
|
53
53
|
MAX_CONCURRENCY_LIMIT: () => MAX_CONCURRENCY_LIMIT,
|
|
54
|
+
appendFormValue: () => appendFormValue,
|
|
54
55
|
applyPageLimits: () => applyPageLimits,
|
|
55
56
|
documentFromBundle: () => documentFromBundle,
|
|
56
57
|
documentFromJson: () => documentFromJson,
|
|
57
58
|
fileSourceFromBinary: () => fileSourceFromBinary,
|
|
58
|
-
formValue: () => formValue,
|
|
59
59
|
materializePresignedResult: () => materializePresignedResult,
|
|
60
60
|
normalizeSourceInput: () => normalizeSourceInput,
|
|
61
61
|
preflightFileSize: () => preflightFileSize,
|
|
@@ -1181,14 +1181,16 @@ function preflightFileSize(source, maxFileSize) {
|
|
|
1181
1181
|
}
|
|
1182
1182
|
return `File size ${source.descriptor.file_size} exceeds the configured limit of ${maxFileSize} bytes`;
|
|
1183
1183
|
}
|
|
1184
|
-
function
|
|
1185
|
-
if (
|
|
1186
|
-
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1184
|
+
function appendFormValue(form, key, value) {
|
|
1185
|
+
if (Array.isArray(value)) {
|
|
1186
|
+
value.forEach((item) => appendFormValue(form, key, item));
|
|
1187
|
+
} else if (typeof value === "string") {
|
|
1188
|
+
form.append(key, value);
|
|
1189
|
+
} else if (typeof value === "number" || typeof value === "boolean") {
|
|
1190
|
+
form.append(key, String(value));
|
|
1191
|
+
} else {
|
|
1192
|
+
form.append(key, JSON.stringify(value));
|
|
1190
1193
|
}
|
|
1191
|
-
return JSON.stringify(value);
|
|
1192
1194
|
}
|
|
1193
1195
|
async function fileSourceFromBinary(source, signal) {
|
|
1194
1196
|
throwIfAborted(signal);
|
|
@@ -2586,12 +2588,12 @@ var DoclingClient = class {
|
|
|
2586
2588
|
);
|
|
2587
2589
|
for (const [key, value] of Object.entries(convertOptions)) {
|
|
2588
2590
|
if (value !== void 0 && value !== null) {
|
|
2589
|
-
form
|
|
2591
|
+
appendFormValue(form, `convert_${key}`, value);
|
|
2590
2592
|
}
|
|
2591
2593
|
}
|
|
2592
2594
|
for (const [key, value] of Object.entries(request.chunking_options ?? {})) {
|
|
2593
2595
|
if (key !== "chunker" && value !== void 0 && value !== null) {
|
|
2594
|
-
form
|
|
2596
|
+
appendFormValue(form, `chunking_${key}`, value);
|
|
2595
2597
|
}
|
|
2596
2598
|
}
|
|
2597
2599
|
form.append(
|
|
@@ -2906,13 +2908,14 @@ var DoclingClient = class {
|
|
|
2906
2908
|
);
|
|
2907
2909
|
}
|
|
2908
2910
|
async #submitNormalizedForTarget(source, options, target, requestOptions) {
|
|
2911
|
+
const callbacks = requestOptions.callbacks ?? [];
|
|
2909
2912
|
if (source.kind === "json") {
|
|
2910
2913
|
return this.#submitRequestForTarget(
|
|
2911
2914
|
{
|
|
2912
2915
|
options,
|
|
2913
2916
|
sources: [source.source],
|
|
2914
2917
|
target,
|
|
2915
|
-
callbacks
|
|
2918
|
+
callbacks
|
|
2916
2919
|
},
|
|
2917
2920
|
requestOptions
|
|
2918
2921
|
);
|
|
@@ -2924,7 +2927,7 @@ var DoclingClient = class {
|
|
|
2924
2927
|
options,
|
|
2925
2928
|
sources: [fileSource],
|
|
2926
2929
|
target,
|
|
2927
|
-
callbacks
|
|
2930
|
+
callbacks
|
|
2928
2931
|
},
|
|
2929
2932
|
requestOptions
|
|
2930
2933
|
);
|
|
@@ -2932,9 +2935,13 @@ var DoclingClient = class {
|
|
|
2932
2935
|
const form = new FormData();
|
|
2933
2936
|
for (const [key, value] of Object.entries(options)) {
|
|
2934
2937
|
if (value !== void 0 && value !== null) {
|
|
2935
|
-
form
|
|
2938
|
+
appendFormValue(form, key, value);
|
|
2936
2939
|
}
|
|
2937
2940
|
}
|
|
2941
|
+
validateCallbacks(callbacks);
|
|
2942
|
+
for (const callback of callbacks) {
|
|
2943
|
+
form.append("callbacks", JSON.stringify(callback));
|
|
2944
|
+
}
|
|
2938
2945
|
form.append("target_type", target.kind);
|
|
2939
2946
|
form.append("files", source.blob, source.descriptor.filename);
|
|
2940
2947
|
const status = parseTaskStatus(
|
|
@@ -4144,11 +4151,11 @@ function isRecord4(value) {
|
|
|
4144
4151
|
DoclingUsageLimitExceededError,
|
|
4145
4152
|
FetchTransport,
|
|
4146
4153
|
MAX_CONCURRENCY_LIMIT,
|
|
4154
|
+
appendFormValue,
|
|
4147
4155
|
applyPageLimits,
|
|
4148
4156
|
documentFromBundle,
|
|
4149
4157
|
documentFromJson,
|
|
4150
4158
|
fileSourceFromBinary,
|
|
4151
|
-
formValue,
|
|
4152
4159
|
materializePresignedResult,
|
|
4153
4160
|
normalizeSourceInput,
|
|
4154
4161
|
preflightFileSize,
|