@arbidocs/sdk 0.4.156 → 0.4.157
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/{browser-CYDtwz9K.d.cts → browser-Dnc05Tkf.d.cts} +12 -1
- package/dist/{browser-CYDtwz9K.d.ts → browser-Dnc05Tkf.d.ts} +12 -1
- package/dist/browser.cjs +48 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +48 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +48 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3624,6 +3624,52 @@ async function authenticatedFetch(options) {
|
|
|
3624
3624
|
}
|
|
3625
3625
|
return res;
|
|
3626
3626
|
}
|
|
3627
|
+
|
|
3628
|
+
// src/progress-fetch.ts
|
|
3629
|
+
var NULL_BODY_STATUSES = /* @__PURE__ */ new Set([101, 204, 205, 304]);
|
|
3630
|
+
function parseHeaders(raw) {
|
|
3631
|
+
const headers = new Headers();
|
|
3632
|
+
for (const line of raw.trim().split(/[\r\n]+/)) {
|
|
3633
|
+
const at2 = line.indexOf(":");
|
|
3634
|
+
if (at2 > 0) headers.append(line.slice(0, at2).trim(), line.slice(at2 + 1).trim());
|
|
3635
|
+
}
|
|
3636
|
+
return headers;
|
|
3637
|
+
}
|
|
3638
|
+
function progressFetch(onProgress) {
|
|
3639
|
+
const Xhr = globalThis.XMLHttpRequest;
|
|
3640
|
+
return async (request) => {
|
|
3641
|
+
if (!Xhr) {
|
|
3642
|
+
const response = await fetch(request);
|
|
3643
|
+
const size = Number(request.headers.get("content-length") ?? 0);
|
|
3644
|
+
onProgress(size, size);
|
|
3645
|
+
return response;
|
|
3646
|
+
}
|
|
3647
|
+
const body = await request.blob();
|
|
3648
|
+
return new Promise((resolve2, reject) => {
|
|
3649
|
+
const xhr = new Xhr();
|
|
3650
|
+
xhr.open(request.method, request.url);
|
|
3651
|
+
request.headers.forEach((value, name) => xhr.setRequestHeader(name, value));
|
|
3652
|
+
xhr.withCredentials = request.credentials === "include";
|
|
3653
|
+
xhr.upload.onprogress = (event) => {
|
|
3654
|
+
if (event.lengthComputable) onProgress(event.loaded, event.total);
|
|
3655
|
+
};
|
|
3656
|
+
xhr.onload = () => {
|
|
3657
|
+
onProgress(body.size, body.size);
|
|
3658
|
+
resolve2(
|
|
3659
|
+
new Response(NULL_BODY_STATUSES.has(xhr.status) ? null : xhr.responseText, {
|
|
3660
|
+
status: xhr.status,
|
|
3661
|
+
statusText: xhr.statusText,
|
|
3662
|
+
headers: parseHeaders(xhr.getAllResponseHeaders())
|
|
3663
|
+
})
|
|
3664
|
+
);
|
|
3665
|
+
};
|
|
3666
|
+
xhr.onerror = () => reject(new TypeError("Network error during upload"));
|
|
3667
|
+
xhr.onabort = () => reject(new DOMException("Upload aborted", "AbortError"));
|
|
3668
|
+
request.signal?.addEventListener("abort", () => xhr.abort(), { once: true });
|
|
3669
|
+
xhr.send(body);
|
|
3670
|
+
});
|
|
3671
|
+
};
|
|
3672
|
+
}
|
|
3627
3673
|
var DEFAULT_SESSION = {
|
|
3628
3674
|
lastMessageExtId: null,
|
|
3629
3675
|
conversationExtId: null,
|
|
@@ -5121,6 +5167,7 @@ async function uploadDocuments(arbi, files, options = {}) {
|
|
|
5121
5167
|
}
|
|
5122
5168
|
const result = await arbi.fetch.POST("/v1/document/upload", {
|
|
5123
5169
|
params: { query },
|
|
5170
|
+
...options.onProgress ? { fetch: progressFetch(options.onProgress) } : {},
|
|
5124
5171
|
// The schema types the files as strings; they go as multipart parts.
|
|
5125
5172
|
body: { files },
|
|
5126
5173
|
bodySerializer: () => {
|
|
@@ -11930,6 +11977,7 @@ exports.performPasswordLogin = performPasswordLogin;
|
|
|
11930
11977
|
exports.performSigningKeyLogin = performSigningKeyLogin;
|
|
11931
11978
|
exports.performSsoDeviceFlowLogin = performSsoDeviceFlowLogin;
|
|
11932
11979
|
exports.profile = profile_exports;
|
|
11980
|
+
exports.progressFetch = progressFetch;
|
|
11933
11981
|
exports.projects = projects_exports;
|
|
11934
11982
|
exports.refusalReason = refusalReason;
|
|
11935
11983
|
exports.requireData = requireData;
|