@arbidocs/sdk 0.5.57 → 0.5.59
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/README.md +68 -5
- package/dist/{browser-CVDwtLvB.d.ts → browser-H9ziI77P.d.ts} +28 -4
- package/dist/{browser-B8W0xqOq.d.cts → browser-wtQhRmpE.d.cts} +28 -4
- package/dist/browser.cjs +69 -19
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +69 -19
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +69 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +69 -19
- package/dist/index.js.map +1 -1
- package/examples/node-response.mjs +36 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -3685,10 +3685,19 @@ var STATUS_FALLBACKS = {
|
|
|
3685
3685
|
503: "The selected LLM is not responding. Please retry or select another model."
|
|
3686
3686
|
};
|
|
3687
3687
|
async function authenticatedFetch(options) {
|
|
3688
|
-
const {
|
|
3688
|
+
const {
|
|
3689
|
+
baseUrl,
|
|
3690
|
+
accessToken,
|
|
3691
|
+
path: path5,
|
|
3692
|
+
method,
|
|
3693
|
+
body,
|
|
3694
|
+
headers,
|
|
3695
|
+
signal,
|
|
3696
|
+
fetch: send = globalThis.fetch
|
|
3697
|
+
} = options;
|
|
3689
3698
|
let res;
|
|
3690
3699
|
try {
|
|
3691
|
-
res = await
|
|
3700
|
+
res = await send(`${baseUrl}${path5}`, {
|
|
3692
3701
|
method: method ?? (body ? "POST" : "GET"),
|
|
3693
3702
|
headers: {
|
|
3694
3703
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -3722,11 +3731,11 @@ function parseHeaders(raw) {
|
|
|
3722
3731
|
}
|
|
3723
3732
|
return headers;
|
|
3724
3733
|
}
|
|
3725
|
-
function progressFetch(onProgress) {
|
|
3734
|
+
function progressFetch(onProgress, transport) {
|
|
3726
3735
|
const Xhr = globalThis.XMLHttpRequest;
|
|
3727
|
-
|
|
3728
|
-
if (!Xhr) {
|
|
3729
|
-
const response = await fetch(request);
|
|
3736
|
+
const adapter = async (request) => {
|
|
3737
|
+
if (!Xhr || transport?.customFetch) {
|
|
3738
|
+
const response = await (transport?.customFetch ? transport.fetch : globalThis.fetch)(request);
|
|
3730
3739
|
const size = Number(request.headers.get("content-length") ?? 0);
|
|
3731
3740
|
onProgress(size, size);
|
|
3732
3741
|
return response;
|
|
@@ -3740,7 +3749,10 @@ function progressFetch(onProgress) {
|
|
|
3740
3749
|
xhr.upload.onprogress = (event) => {
|
|
3741
3750
|
if (event.lengthComputable) onProgress(event.loaded, event.total);
|
|
3742
3751
|
};
|
|
3752
|
+
const cleanup = () => request.signal.removeEventListener("abort", abort);
|
|
3753
|
+
const abort = () => xhr.abort();
|
|
3743
3754
|
xhr.onload = () => {
|
|
3755
|
+
cleanup();
|
|
3744
3756
|
onProgress(body.size, body.size);
|
|
3745
3757
|
resolve2(
|
|
3746
3758
|
new Response(NULL_BODY_STATUSES.has(xhr.status) ? null : xhr.responseText, {
|
|
@@ -3750,12 +3762,30 @@ function progressFetch(onProgress) {
|
|
|
3750
3762
|
})
|
|
3751
3763
|
);
|
|
3752
3764
|
};
|
|
3753
|
-
xhr.onerror = () =>
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3765
|
+
xhr.onerror = () => {
|
|
3766
|
+
cleanup();
|
|
3767
|
+
reject(new TypeError("Network error during upload"));
|
|
3768
|
+
};
|
|
3769
|
+
xhr.onabort = () => {
|
|
3770
|
+
cleanup();
|
|
3771
|
+
reject(request.signal.reason ?? new DOMException("Upload aborted", "AbortError"));
|
|
3772
|
+
};
|
|
3773
|
+
if (request.signal.aborted) {
|
|
3774
|
+
reject(request.signal.reason ?? new DOMException("Upload aborted", "AbortError"));
|
|
3775
|
+
return;
|
|
3776
|
+
}
|
|
3777
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
3778
|
+
try {
|
|
3779
|
+
xhr.send(body);
|
|
3780
|
+
} catch (error) {
|
|
3781
|
+
cleanup();
|
|
3782
|
+
reject(error);
|
|
3783
|
+
}
|
|
3757
3784
|
});
|
|
3758
3785
|
};
|
|
3786
|
+
if (transport?.customFetch) return adapter;
|
|
3787
|
+
const send = transport?.withFetch((input, init) => adapter(new Request(input, init)));
|
|
3788
|
+
return send ? (request) => send(request) : adapter;
|
|
3759
3789
|
}
|
|
3760
3790
|
var DEFAULT_SESSION = {
|
|
3761
3791
|
lastMessageExtId: null,
|
|
@@ -5763,7 +5793,7 @@ async function uploadDocuments(arbi, files, options = {}) {
|
|
|
5763
5793
|
}
|
|
5764
5794
|
const result = await arbi.fetch.POST("/v1/document/upload", {
|
|
5765
5795
|
params: { query: query2 },
|
|
5766
|
-
...options.onProgress ? { fetch: progressFetch(options.onProgress) } : {},
|
|
5796
|
+
...options.onProgress ? { fetch: progressFetch(options.onProgress, arbi.http) } : {},
|
|
5767
5797
|
// The schema types the files as strings; they go as multipart parts.
|
|
5768
5798
|
body: { files },
|
|
5769
5799
|
bodySerializer: () => {
|
|
@@ -6721,10 +6751,11 @@ function searchChunks(result) {
|
|
|
6721
6751
|
return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
|
|
6722
6752
|
}
|
|
6723
6753
|
async function queryAssistant(options) {
|
|
6724
|
-
const { baseUrl, accessToken, signal, ...request } = options;
|
|
6754
|
+
const { baseUrl, accessToken, signal, fetch: fetch2, ...request } = options;
|
|
6725
6755
|
return authenticatedFetch({
|
|
6726
6756
|
baseUrl,
|
|
6727
6757
|
accessToken,
|
|
6758
|
+
fetch: fetch2,
|
|
6728
6759
|
path: "/v1/responses",
|
|
6729
6760
|
method: "POST",
|
|
6730
6761
|
body: JSON.stringify(buildTurnRequest(request)),
|
|
@@ -6779,7 +6810,7 @@ async function refusal(response) {
|
|
|
6779
6810
|
);
|
|
6780
6811
|
}
|
|
6781
6812
|
async function openTurnStream(auth, body, signal) {
|
|
6782
|
-
const response = await fetch(`${auth.baseUrl}/v1/responses`, {
|
|
6813
|
+
const response = await (auth.fetch ?? globalThis.fetch)(`${auth.baseUrl}/v1/responses`, {
|
|
6783
6814
|
method: "POST",
|
|
6784
6815
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${auth.accessToken}` },
|
|
6785
6816
|
body: JSON.stringify(body),
|
|
@@ -6797,7 +6828,7 @@ async function openTurnStream(auth, body, signal) {
|
|
|
6797
6828
|
return response;
|
|
6798
6829
|
}
|
|
6799
6830
|
async function openRunStream(auth, responseId, signal) {
|
|
6800
|
-
const response = await fetch(
|
|
6831
|
+
const response = await (auth.fetch ?? globalThis.fetch)(
|
|
6801
6832
|
`${auth.baseUrl}/v1/assistant/run/${encodeURIComponent(responseId)}/stream`,
|
|
6802
6833
|
{
|
|
6803
6834
|
method: "GET",
|
|
@@ -9780,6 +9811,7 @@ async function remindFact(arbi, factId, options = {}) {
|
|
|
9780
9811
|
var databases_exports = {};
|
|
9781
9812
|
__export(databases_exports, {
|
|
9782
9813
|
addDatabaseRows: () => addDatabaseRows,
|
|
9814
|
+
aggregateDatabase: () => aggregateDatabase,
|
|
9783
9815
|
createDatabase: () => createDatabase,
|
|
9784
9816
|
deleteDatabase: () => deleteDatabase,
|
|
9785
9817
|
deleteDatabaseRows: () => deleteDatabaseRows,
|
|
@@ -9815,6 +9847,15 @@ async function listDatabaseRows(arbi, databaseId, query2 = {}) {
|
|
|
9815
9847
|
"Failed to read the rows"
|
|
9816
9848
|
);
|
|
9817
9849
|
}
|
|
9850
|
+
async function aggregateDatabase(arbi, databaseId, body) {
|
|
9851
|
+
return requireData(
|
|
9852
|
+
await arbi.fetch.POST("/v1/databases/{database_id}/aggregate", {
|
|
9853
|
+
params: path2(databaseId),
|
|
9854
|
+
body: { time_bucket: "month", limit: 50, ...body }
|
|
9855
|
+
}),
|
|
9856
|
+
"Failed to aggregate the database"
|
|
9857
|
+
);
|
|
9858
|
+
}
|
|
9818
9859
|
async function createDatabase(arbi, body) {
|
|
9819
9860
|
return requireData(
|
|
9820
9861
|
await arbi.fetch.POST("/v1/databases", { body }),
|
|
@@ -11203,6 +11244,10 @@ var Arbi = class {
|
|
|
11203
11244
|
options;
|
|
11204
11245
|
constructor(options) {
|
|
11205
11246
|
this.options = options;
|
|
11247
|
+
if (options.session && options.transport)
|
|
11248
|
+
throw new ArbiError(
|
|
11249
|
+
"Configure transport on the host session client, not on its Arbi wrapper."
|
|
11250
|
+
);
|
|
11206
11251
|
if (options.session) {
|
|
11207
11252
|
this.client = options.session.client;
|
|
11208
11253
|
this.loginResult = options.session.login;
|
|
@@ -11227,6 +11272,8 @@ var Arbi = class {
|
|
|
11227
11272
|
baseUrl: this.options.url,
|
|
11228
11273
|
deploymentDomain: domain,
|
|
11229
11274
|
credentials: this.options.credentials ?? "omit",
|
|
11275
|
+
persistence: this.options.persistence,
|
|
11276
|
+
transport: this.options.transport,
|
|
11230
11277
|
session: client.createSessionManager({ storage: this.options.sessionStorage }),
|
|
11231
11278
|
// A silent re-login rotates the server session key: keep ours in step, or the next
|
|
11232
11279
|
// workspace open would seal the key for a session the server no longer has.
|
|
@@ -11659,7 +11706,8 @@ var Arbi = class {
|
|
|
11659
11706
|
}
|
|
11660
11707
|
return {
|
|
11661
11708
|
baseUrl: this.options.url,
|
|
11662
|
-
accessToken
|
|
11709
|
+
accessToken,
|
|
11710
|
+
...client.http ? { fetch: client.http.fetch } : {}
|
|
11663
11711
|
};
|
|
11664
11712
|
}
|
|
11665
11713
|
// ── Projects ──────────────────────────────────────────────────────────
|
|
@@ -12176,10 +12224,10 @@ var Arbi = class {
|
|
|
12176
12224
|
/** Authenticated native Word transport, with normal session recovery. */
|
|
12177
12225
|
editor = {
|
|
12178
12226
|
request: (path5, options = {}) => this.recovering(async () => {
|
|
12179
|
-
const { baseUrl, accessToken } = this.getAuthHeaders();
|
|
12227
|
+
const { baseUrl, accessToken, fetch: send = globalThis.fetch } = this.getAuthHeaders();
|
|
12180
12228
|
const headers = new Headers(options.headers);
|
|
12181
12229
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
12182
|
-
const response = await
|
|
12230
|
+
const response = await send(`${baseUrl}/v1/editor${path5}`, { ...options, headers });
|
|
12183
12231
|
if (!response.ok) {
|
|
12184
12232
|
const body = await response.json().catch(() => null);
|
|
12185
12233
|
throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
|
|
@@ -12197,12 +12245,12 @@ var Arbi = class {
|
|
|
12197
12245
|
mail = {
|
|
12198
12246
|
/** Fetch a path under `/v1/mail`; rejects a non-2xx response with an `ArbiApiError` (`status`). */
|
|
12199
12247
|
fetch: (path5, init = {}) => this.recovering(async () => {
|
|
12200
|
-
const { baseUrl, accessToken } = this.getAuthHeaders();
|
|
12248
|
+
const { baseUrl, accessToken, fetch: send = globalThis.fetch } = this.getAuthHeaders();
|
|
12201
12249
|
const headers = new Headers(init.headers);
|
|
12202
12250
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
12203
12251
|
if (init.body && !headers.has("Content-Type"))
|
|
12204
12252
|
headers.set("Content-Type", "application/json");
|
|
12205
|
-
const response = await
|
|
12253
|
+
const response = await send(`${baseUrl}/v1/mail${path5}`, { ...init, headers });
|
|
12206
12254
|
if (!response.ok) {
|
|
12207
12255
|
const body = await response.json().catch(() => null);
|
|
12208
12256
|
throw new ArbiApiError(
|
|
@@ -13075,6 +13123,8 @@ var Arbi = class {
|
|
|
13075
13123
|
get: (databaseId) => getDatabase(this.requireClient(), databaseId),
|
|
13076
13124
|
/** A search of the rows (any cell), sorted and paged on the server. */
|
|
13077
13125
|
rows: (databaseId, query2) => listDatabaseRows(this.requireClient(), databaseId, query2),
|
|
13126
|
+
/** Group and measure the rows on the server (a chart's labels and series). */
|
|
13127
|
+
aggregate: (databaseId, body) => aggregateDatabase(this.requireClient(), databaseId, body),
|
|
13078
13128
|
create: (body) => createDatabase(this.requireClient(), body),
|
|
13079
13129
|
update: (databaseId, body) => updateDatabase(this.requireClient(), databaseId, body),
|
|
13080
13130
|
delete: (databaseId) => deleteDatabase(this.requireClient(), databaseId),
|