apify-client 3.0.0-beta.86 → 3.0.0-beta.88
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/base/api_client.js +8 -8
- package/dist/bundle.js +13 -13
- package/dist/bundle.js.map +1 -1
- package/dist/resource_clients/dataset.js +5 -9
- package/dist/resource_clients/run.js +2 -2
- package/dist/utils.d.ts +6 -11
- package/dist/utils.js +0 -10
- package/package.json +16 -16
|
@@ -4,7 +4,7 @@ import { ResourceClient } from '../base/resource_client.js';
|
|
|
4
4
|
import * as schemas from '../schemas.js';
|
|
5
5
|
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
6
6
|
import { runtime } from '#runtime';
|
|
7
|
-
import { anyObjectSchema, applyQueryParamsToUrl, cast, isNonArrayObject, paginationOptionsShape, parseArgument, parseResponse,
|
|
7
|
+
import { anyObjectSchema, applyQueryParamsToUrl, cast, isNonArrayObject, paginationOptionsShape, parseArgument, parseResponse, } from '../utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Supported formats for downloading dataset items.
|
|
10
10
|
*/
|
|
@@ -356,21 +356,17 @@ export class DatasetClient extends ResourceClient {
|
|
|
356
356
|
}
|
|
357
357
|
#createPaginationList(response, userProvidedDesc) {
|
|
358
358
|
const descHeader = response.headers['x-apify-pagination-desc'];
|
|
359
|
-
|
|
359
|
+
return {
|
|
360
360
|
items: response.data,
|
|
361
361
|
total: Number(response.headers['x-apify-pagination-total']),
|
|
362
362
|
offset: Number(response.headers['x-apify-pagination-offset']),
|
|
363
363
|
// `x-apify-pagination-count` reports the rows scanned, which filters and `unwind` can leave above or below
|
|
364
|
-
// the items returned.
|
|
365
|
-
|
|
364
|
+
// the items returned. It is derived from the dataset's item count, which lags a fresh push, so it can also
|
|
365
|
+
// fall below the items returned on an unfiltered page.
|
|
366
|
+
count: Math.max(Number(response.headers['x-apify-pagination-count'] ?? 0), response.data.length),
|
|
366
367
|
limit: Number(response.headers['x-apify-pagination-limit']), // API returns 999999999999 when no limit is used
|
|
367
368
|
// TODO: Replace this once https://github.com/apify/apify-core/issues/3503 is solved
|
|
368
369
|
desc: typeof descHeader === 'string' ? JSON.parse(descHeader) : userProvidedDesc,
|
|
369
370
|
};
|
|
370
|
-
const scannedCount = response.headers['x-apify-pagination-count'];
|
|
371
|
-
if (scannedCount === undefined)
|
|
372
|
-
return page;
|
|
373
|
-
// The offset iterator paginates by the scanned number, so it travels with the page outside its public shape.
|
|
374
|
-
return Object.defineProperty(page, SCANNED_COUNT, { value: Number(scannedCount) });
|
|
375
371
|
}
|
|
376
372
|
}
|
|
@@ -5,7 +5,7 @@ import { ResourceClient } from '../base/resource_client.js';
|
|
|
5
5
|
import * as schemas from '../schemas.js';
|
|
6
6
|
import { optionalSignalSchema, optionalTimeoutSchema, timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
7
7
|
import { runtime } from '#runtime';
|
|
8
|
-
import { anyObjectSchema, paginationOptionsShape, parseArgument, parseResponse
|
|
8
|
+
import { anyObjectSchema, paginationOptionsShape, parseArgument, parseResponse } from '../utils.js';
|
|
9
9
|
import { DatasetClient } from './dataset.js';
|
|
10
10
|
import { KeyValueStoreClient } from './key_value_store.js';
|
|
11
11
|
import { LogClient, LoggerActorRedirect, StreamedLog } from './log.js';
|
|
@@ -537,7 +537,7 @@ export class RunClient extends ResourceClient {
|
|
|
537
537
|
yield* page.items;
|
|
538
538
|
// Only an empty page marks the end, as filters can shorten a full one. A page that `clean`, `skipEmpty` or
|
|
539
539
|
// `unwind` emptied past a lagging `itemCount` reports no scanned rows either, so a plain read checks.
|
|
540
|
-
const isEmpty = page.
|
|
540
|
+
const isEmpty = page.count === 0;
|
|
541
541
|
if (isEmpty &&
|
|
542
542
|
(!(clean || skipEmpty || unwind?.length) ||
|
|
543
543
|
(await datasetClient.listItems({ offset: position, limit: 1, timeoutSecs, signal })).items
|
package/dist/utils.d.ts
CHANGED
|
@@ -177,7 +177,12 @@ export interface PaginatedResponse<Data> {
|
|
|
177
177
|
* @template Data - The type of items in the list
|
|
178
178
|
*/
|
|
179
179
|
export interface PaginatedList<Data> extends PaginatedResponse<Data> {
|
|
180
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Number of entries on this page. On a page from {@link DatasetClient.listItems}, the number of dataset rows the
|
|
182
|
+
* API scanned for it, or the number of items returned when that is larger. Filters (`clean`, `skipEmpty`) can
|
|
183
|
+
* leave it above `items.length`. The next page starts at `offset + Math.min(count, limit)`; the cap matters only
|
|
184
|
+
* with `unwind`, which can return more items than the rows scanned.
|
|
185
|
+
*/
|
|
181
186
|
count: number;
|
|
182
187
|
/** Position of the first returned entry in the dataset. */
|
|
183
188
|
offset: number;
|
|
@@ -186,16 +191,6 @@ export interface PaginatedList<Data> extends PaginatedResponse<Data> {
|
|
|
186
191
|
/** Should the results be in descending order. */
|
|
187
192
|
desc: boolean;
|
|
188
193
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Key under which a page of dataset items carries the number of rows the API scanned to produce it, as a
|
|
191
|
-
* non-enumerable property that stays out of the page's public shape. The API applies `offset` and `limit` to the
|
|
192
|
-
* dataset's rows first and shapes the result afterwards: filters (`clean`, `skipEmpty`, `skipHidden`) drop items and
|
|
193
|
-
* `unwind` splits or drops them, so `items.length` can land on either side of the rows scanned. The
|
|
194
|
-
* `x-apify-pagination-count` header reports the scanned number, and the offset iterator advances and terminates by it
|
|
195
|
-
* alone. A page without the property falls back to `items.length`.
|
|
196
|
-
* @internal
|
|
197
|
-
*/
|
|
198
|
-
export declare const SCANNED_COUNT: unique symbol;
|
|
199
194
|
/**
|
|
200
195
|
* Type representing both a Promise of a paginated list and an async iterable.
|
|
201
196
|
*
|
package/dist/utils.js
CHANGED
|
@@ -315,16 +315,6 @@ export const paginationOptionsShape = {
|
|
|
315
315
|
offset: z.number().min(0).optional(),
|
|
316
316
|
chunkSize: z.number().positive().optional(),
|
|
317
317
|
};
|
|
318
|
-
/**
|
|
319
|
-
* Key under which a page of dataset items carries the number of rows the API scanned to produce it, as a
|
|
320
|
-
* non-enumerable property that stays out of the page's public shape. The API applies `offset` and `limit` to the
|
|
321
|
-
* dataset's rows first and shapes the result afterwards: filters (`clean`, `skipEmpty`, `skipHidden`) drop items and
|
|
322
|
-
* `unwind` splits or drops them, so `items.length` can land on either side of the rows scanned. The
|
|
323
|
-
* `x-apify-pagination-count` header reports the scanned number, and the offset iterator advances and terminates by it
|
|
324
|
-
* alone. A page without the property falls back to `items.length`.
|
|
325
|
-
* @internal
|
|
326
|
-
*/
|
|
327
|
-
export const SCANNED_COUNT = Symbol('scannedCount');
|
|
328
318
|
export function cast(input) {
|
|
329
319
|
return input;
|
|
330
320
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apify-client",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.88",
|
|
4
4
|
"description": "Apify API client for JavaScript",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.13.0"
|
|
@@ -66,42 +66,42 @@
|
|
|
66
66
|
"@apify/consts": "^3.0.1",
|
|
67
67
|
"@apify/log": "^3.0.1",
|
|
68
68
|
"@apify/utilities": "^3.1.0",
|
|
69
|
-
"@apify/validations": "^1.1.
|
|
69
|
+
"@apify/validations": "^1.1.2",
|
|
70
70
|
"ansi-colors": "^4.1.3",
|
|
71
|
-
"axios": "^1.
|
|
71
|
+
"axios": "^1.21.0",
|
|
72
72
|
"content-type": "^3.1.1",
|
|
73
73
|
"proxy-agent": "^8.0.2",
|
|
74
|
-
"tslib": "^2.
|
|
74
|
+
"tslib": "^2.9.1",
|
|
75
75
|
"type-fest": "^5.10.0",
|
|
76
|
-
"zod": "^4.6.
|
|
76
|
+
"zod": "^4.6.7"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@apify/oxlint-config": "^0.3.0",
|
|
80
80
|
"@apify/tsconfig": "^0.2.0",
|
|
81
81
|
"@crawlee/puppeteer": "4.0.0-rc.1",
|
|
82
|
-
"@rsbuild/core": "^2.
|
|
82
|
+
"@rsbuild/core": "^2.3.0",
|
|
83
83
|
"@rsbuild/plugin-node-polyfill": "^1.4.6",
|
|
84
|
-
"@rspack/cli": "^2.
|
|
85
|
-
"@rspack/core": "^2.
|
|
84
|
+
"@rspack/cli": "^2.3.0",
|
|
85
|
+
"@rspack/core": "^2.3.0",
|
|
86
86
|
"@types/compression": "^1.8.1",
|
|
87
87
|
"@types/express": "^5.0.6",
|
|
88
|
-
"@types/node": "^26.
|
|
88
|
+
"@types/node": "^26.6.6",
|
|
89
89
|
"ajv": "^8.20.0",
|
|
90
|
-
"body-parser": "^2.
|
|
90
|
+
"body-parser": "^2.4.0",
|
|
91
91
|
"compression": "^1.8.2",
|
|
92
92
|
"esbuild": "0.28.2",
|
|
93
|
-
"express": "^5.
|
|
93
|
+
"express": "^5.3.0",
|
|
94
94
|
"oxfmt": "0.75.0",
|
|
95
95
|
"oxlint": "1.90.0",
|
|
96
96
|
"oxlint-tsgolint": "7.0.2005",
|
|
97
|
-
"puppeteer": "^25.
|
|
97
|
+
"puppeteer": "^25.16.0",
|
|
98
98
|
"rimraf": "^6.1.3",
|
|
99
|
-
"rolldown": "^1.2.
|
|
99
|
+
"rolldown": "^1.2.16",
|
|
100
100
|
"typescript": "^7.0.2",
|
|
101
101
|
"typescript-v6": "npm:typescript@^6.0.3",
|
|
102
|
-
"vitest": "^5.0
|
|
103
|
-
"webpack": "^5.
|
|
104
|
-
"webpack-cli": "^7.
|
|
102
|
+
"vitest": "^5.1.0",
|
|
103
|
+
"webpack": "^5.112.2",
|
|
104
|
+
"webpack-cli": "^7.3.1"
|
|
105
105
|
},
|
|
106
106
|
"devEngines": {
|
|
107
107
|
"packageManager": {
|