@arbidocs/sdk 0.3.46 → 0.3.47
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-HVCa8Ph5.d.cts → browser-CtYFcHNd.d.cts} +19 -7
- package/dist/{browser-HVCa8Ph5.d.ts → browser-CtYFcHNd.d.ts} +19 -7
- package/dist/browser.cjs +18 -9
- 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 +18 -9
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +18 -9
- 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 +18 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4709,10 +4709,17 @@ async function listDocuments(arbi) {
|
|
|
4709
4709
|
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
4710
4710
|
}
|
|
4711
4711
|
async function* listPaginated(arbi, options = {}) {
|
|
4712
|
-
const {
|
|
4713
|
-
|
|
4712
|
+
const {
|
|
4713
|
+
pageSize = 5e3,
|
|
4714
|
+
firstPageSize,
|
|
4715
|
+
order = "id_asc",
|
|
4716
|
+
fields,
|
|
4717
|
+
signal,
|
|
4718
|
+
lookahead = 1
|
|
4719
|
+
} = options;
|
|
4720
|
+
const fetchPage = async (pageOffset, limit) => {
|
|
4714
4721
|
const query = {
|
|
4715
|
-
limit
|
|
4722
|
+
limit,
|
|
4716
4723
|
offset: pageOffset,
|
|
4717
4724
|
order
|
|
4718
4725
|
};
|
|
@@ -4735,19 +4742,21 @@ async function* listPaginated(arbi, options = {}) {
|
|
|
4735
4742
|
const queue = [];
|
|
4736
4743
|
const tryEnqueue = () => {
|
|
4737
4744
|
while (!done && queue.length < depth && issued < MAX_PAGES) {
|
|
4738
|
-
const
|
|
4739
|
-
|
|
4745
|
+
const limit = issued === 0 && firstPageSize !== void 0 ? firstPageSize : pageSize;
|
|
4746
|
+
const promise = fetchPage(nextOffsetToIssue, limit);
|
|
4747
|
+
promise.catch(() => {
|
|
4740
4748
|
});
|
|
4741
|
-
queue.push(
|
|
4742
|
-
nextOffsetToIssue +=
|
|
4749
|
+
queue.push({ limit, promise });
|
|
4750
|
+
nextOffsetToIssue += limit;
|
|
4743
4751
|
issued++;
|
|
4744
4752
|
}
|
|
4745
4753
|
};
|
|
4746
4754
|
tryEnqueue();
|
|
4747
4755
|
while (queue.length > 0 && !signal?.aborted) {
|
|
4748
|
-
const
|
|
4756
|
+
const { limit, promise } = queue.shift();
|
|
4757
|
+
const page = await promise;
|
|
4749
4758
|
if (signal?.aborted) return;
|
|
4750
|
-
const isShort = page.length <
|
|
4759
|
+
const isShort = page.length < limit;
|
|
4751
4760
|
if (isShort) done = true;
|
|
4752
4761
|
tryEnqueue();
|
|
4753
4762
|
if (page.length > 0) {
|