@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
|
@@ -605,10 +605,17 @@ type DocumentListFields = 'full' | 'lite';
|
|
|
605
605
|
*/
|
|
606
606
|
interface ListPaginatedOptions {
|
|
607
607
|
/**
|
|
608
|
-
* Number of documents per page.
|
|
608
|
+
* Number of documents per page (applies to every page after the first).
|
|
609
609
|
* @default 5000
|
|
610
610
|
*/
|
|
611
611
|
pageSize?: number;
|
|
612
|
+
/**
|
|
613
|
+
* Size of the first page only. When set, the initial request uses this
|
|
614
|
+
* smaller limit so the caller can render something on screen before the
|
|
615
|
+
* full `pageSize`-sized pages stream in. Subsequent pages fall back to
|
|
616
|
+
* `pageSize`. When unset, every page uses `pageSize`.
|
|
617
|
+
*/
|
|
618
|
+
firstPageSize?: number;
|
|
612
619
|
/**
|
|
613
620
|
* Sort order for pagination.
|
|
614
621
|
* @default 'id_asc'
|
|
@@ -629,7 +636,7 @@ interface ListPaginatedOptions {
|
|
|
629
636
|
* Number of pages kept in flight concurrently. A higher value hides more
|
|
630
637
|
* backend + network latency between pages but increases peak backend load
|
|
631
638
|
* and memory for not-yet-consumed pages. Clamped to `[1, MAX_PAGES]`.
|
|
632
|
-
* @default
|
|
639
|
+
* @default 1
|
|
633
640
|
*/
|
|
634
641
|
lookahead?: number;
|
|
635
642
|
}
|
|
@@ -729,11 +736,16 @@ declare function listDocuments(arbi: ArbiClient): Promise<{
|
|
|
729
736
|
*
|
|
730
737
|
* Uses `limit`/`offset` pagination. A FIFO queue of up to `lookahead` requests
|
|
731
738
|
* is kept in flight: as soon as a page is awaited off the queue the next
|
|
732
|
-
* request is enqueued, so the backend is continuously working on the next
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
739
|
+
* request is enqueued, so the backend is continuously working on the next
|
|
740
|
+
* page while the consumer processes the current one. The default of 1 keeps
|
|
741
|
+
* one page in flight at a time (classic sequential pagination). Raise it when
|
|
742
|
+
* you want to pipeline — each extra slot adds one more concurrent backend
|
|
743
|
+
* scan and one more not-yet-consumed page held in memory.
|
|
744
|
+
*
|
|
745
|
+
* Pair `firstPageSize` with a larger `pageSize` when you need the initial
|
|
746
|
+
* page on screen fast: e.g. `firstPageSize: 500, pageSize: 2000` renders the
|
|
747
|
+
* first 500 rows in a fifth of the time of a single 2500-row request, then
|
|
748
|
+
* streams in 2000-row pages after.
|
|
737
749
|
*
|
|
738
750
|
* Iteration stops at the first short page (length < `pageSize`) — in-flight
|
|
739
751
|
* requests past that point are discarded. `MAX_PAGES` is a hard cap on the
|
|
@@ -605,10 +605,17 @@ type DocumentListFields = 'full' | 'lite';
|
|
|
605
605
|
*/
|
|
606
606
|
interface ListPaginatedOptions {
|
|
607
607
|
/**
|
|
608
|
-
* Number of documents per page.
|
|
608
|
+
* Number of documents per page (applies to every page after the first).
|
|
609
609
|
* @default 5000
|
|
610
610
|
*/
|
|
611
611
|
pageSize?: number;
|
|
612
|
+
/**
|
|
613
|
+
* Size of the first page only. When set, the initial request uses this
|
|
614
|
+
* smaller limit so the caller can render something on screen before the
|
|
615
|
+
* full `pageSize`-sized pages stream in. Subsequent pages fall back to
|
|
616
|
+
* `pageSize`. When unset, every page uses `pageSize`.
|
|
617
|
+
*/
|
|
618
|
+
firstPageSize?: number;
|
|
612
619
|
/**
|
|
613
620
|
* Sort order for pagination.
|
|
614
621
|
* @default 'id_asc'
|
|
@@ -629,7 +636,7 @@ interface ListPaginatedOptions {
|
|
|
629
636
|
* Number of pages kept in flight concurrently. A higher value hides more
|
|
630
637
|
* backend + network latency between pages but increases peak backend load
|
|
631
638
|
* and memory for not-yet-consumed pages. Clamped to `[1, MAX_PAGES]`.
|
|
632
|
-
* @default
|
|
639
|
+
* @default 1
|
|
633
640
|
*/
|
|
634
641
|
lookahead?: number;
|
|
635
642
|
}
|
|
@@ -729,11 +736,16 @@ declare function listDocuments(arbi: ArbiClient): Promise<{
|
|
|
729
736
|
*
|
|
730
737
|
* Uses `limit`/`offset` pagination. A FIFO queue of up to `lookahead` requests
|
|
731
738
|
* is kept in flight: as soon as a page is awaited off the queue the next
|
|
732
|
-
* request is enqueued, so the backend is continuously working on the next
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
739
|
+
* request is enqueued, so the backend is continuously working on the next
|
|
740
|
+
* page while the consumer processes the current one. The default of 1 keeps
|
|
741
|
+
* one page in flight at a time (classic sequential pagination). Raise it when
|
|
742
|
+
* you want to pipeline — each extra slot adds one more concurrent backend
|
|
743
|
+
* scan and one more not-yet-consumed page held in memory.
|
|
744
|
+
*
|
|
745
|
+
* Pair `firstPageSize` with a larger `pageSize` when you need the initial
|
|
746
|
+
* page on screen fast: e.g. `firstPageSize: 500, pageSize: 2000` renders the
|
|
747
|
+
* first 500 rows in a fifth of the time of a single 2500-row request, then
|
|
748
|
+
* streams in 2000-row pages after.
|
|
737
749
|
*
|
|
738
750
|
* Iteration stops at the first short page (length < `pageSize`) — in-flight
|
|
739
751
|
* requests past that point are discarded. `MAX_PAGES` is a hard cap on the
|
package/dist/browser.cjs
CHANGED
|
@@ -4160,10 +4160,17 @@ async function listDocuments(arbi) {
|
|
|
4160
4160
|
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
4161
4161
|
}
|
|
4162
4162
|
async function* listPaginated(arbi, options = {}) {
|
|
4163
|
-
const {
|
|
4164
|
-
|
|
4163
|
+
const {
|
|
4164
|
+
pageSize = 5e3,
|
|
4165
|
+
firstPageSize,
|
|
4166
|
+
order = "id_asc",
|
|
4167
|
+
fields,
|
|
4168
|
+
signal,
|
|
4169
|
+
lookahead = 1
|
|
4170
|
+
} = options;
|
|
4171
|
+
const fetchPage = async (pageOffset, limit) => {
|
|
4165
4172
|
const query = {
|
|
4166
|
-
limit
|
|
4173
|
+
limit,
|
|
4167
4174
|
offset: pageOffset,
|
|
4168
4175
|
order
|
|
4169
4176
|
};
|
|
@@ -4186,19 +4193,21 @@ async function* listPaginated(arbi, options = {}) {
|
|
|
4186
4193
|
const queue = [];
|
|
4187
4194
|
const tryEnqueue = () => {
|
|
4188
4195
|
while (!done && queue.length < depth && issued < MAX_PAGES) {
|
|
4189
|
-
const
|
|
4190
|
-
|
|
4196
|
+
const limit = issued === 0 && firstPageSize !== void 0 ? firstPageSize : pageSize;
|
|
4197
|
+
const promise = fetchPage(nextOffsetToIssue, limit);
|
|
4198
|
+
promise.catch(() => {
|
|
4191
4199
|
});
|
|
4192
|
-
queue.push(
|
|
4193
|
-
nextOffsetToIssue +=
|
|
4200
|
+
queue.push({ limit, promise });
|
|
4201
|
+
nextOffsetToIssue += limit;
|
|
4194
4202
|
issued++;
|
|
4195
4203
|
}
|
|
4196
4204
|
};
|
|
4197
4205
|
tryEnqueue();
|
|
4198
4206
|
while (queue.length > 0 && !signal?.aborted) {
|
|
4199
|
-
const
|
|
4207
|
+
const { limit, promise } = queue.shift();
|
|
4208
|
+
const page = await promise;
|
|
4200
4209
|
if (signal?.aborted) return;
|
|
4201
|
-
const isShort = page.length <
|
|
4210
|
+
const isShort = page.length < limit;
|
|
4202
4211
|
if (isShort) done = true;
|
|
4203
4212
|
tryEnqueue();
|
|
4204
4213
|
if (page.length > 0) {
|