apify-client 3.0.0-beta.85 → 3.0.0-beta.87
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/base/resource_client.js +8 -8
- package/dist/bundle.js +6 -6
- 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 +1 -1
package/dist/base/api_client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { minForLimitParam,
|
|
1
|
+
import { minForLimitParam, toPath, toPathSegment } from '../utils.js';
|
|
2
2
|
/** @private */
|
|
3
3
|
export class ApiClient {
|
|
4
4
|
id;
|
|
@@ -60,14 +60,14 @@ export class ApiClient {
|
|
|
60
60
|
const { chunkSize, ...listOptions } = options;
|
|
61
61
|
const firstPageLimit = minForLimitParam(options.limit, chunkSize);
|
|
62
62
|
const paginatedListPromise = getPaginatedList({ ...listOptions, limit: firstPageLimit });
|
|
63
|
-
// A page can return more or fewer items than the rows it scanned (see `
|
|
64
|
-
// the stop condition follow the scanned rows: advancing by `items.length` would re-scan
|
|
65
|
-
// dropped some and skip rows after `unwind` multiplied them, and stopping at an empty page
|
|
66
|
-
// iteration in front of rows a filter hid. The
|
|
67
|
-
//
|
|
68
|
-
//
|
|
63
|
+
// A page of dataset items can return more or fewer items than the rows it scanned (see `PaginatedList.count`).
|
|
64
|
+
// The next offset and the stop condition follow the scanned rows: advancing by `items.length` would re-scan
|
|
65
|
+
// rows after a filter dropped some and skip rows after `unwind` multiplied them, and stopping at an empty page
|
|
66
|
+
// would end the iteration in front of rows a filter hid. The step is the larger of `count` and `items.length`,
|
|
67
|
+
// capped at the rows the request asked for, which keeps an unwound page from advancing past rows the next
|
|
68
|
+
// request would then never read.
|
|
69
69
|
const scannedRows = (page, requestedLimit) => {
|
|
70
|
-
const scanned = Math.max(page
|
|
70
|
+
const scanned = Math.max(page.count ?? 0, page.items.length);
|
|
71
71
|
return requestedLimit ? Math.min(scanned, requestedLimit) : scanned;
|
|
72
72
|
};
|
|
73
73
|
// `total` is not consulted, as it changes when the listed resource grows during the iteration.
|
|
@@ -102,7 +102,7 @@ export class ResourceClient extends ApiClient {
|
|
|
102
102
|
const hasJobEnded = job && ACT_JOB_TERMINAL_STATUSES.includes(job.status);
|
|
103
103
|
return !hasJobEnded;
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
while (true) {
|
|
106
106
|
const millisSinceStart = Date.now() - startedAt;
|
|
107
107
|
const remainingWaitSeconds = Math.round((waitMillis - millisSinceStart) / 1000);
|
|
108
108
|
const waitForFinish = Math.max(0, remainingWaitSeconds);
|
|
@@ -124,13 +124,13 @@ export class ResourceClient extends ApiClient {
|
|
|
124
124
|
notFoundSince ??= Date.now();
|
|
125
125
|
notFoundError = err;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
127
|
+
if (!shouldRepeat())
|
|
128
|
+
break;
|
|
129
|
+
// The API answers right away when the remaining wait rounds to 0 seconds, and database replicas may not see
|
|
130
|
+
// a new job for a short while, so pause before the next poll.
|
|
131
|
+
await sleep(250, signal);
|
|
132
|
+
signal?.throwIfAborted();
|
|
133
|
+
}
|
|
134
134
|
if (!job)
|
|
135
135
|
throw notFoundError;
|
|
136
136
|
return job;
|