apify-client 3.0.0-beta.6 → 3.0.0-beta.7

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.
@@ -100,8 +100,6 @@ export interface ActorCollectionCreateOptions {
100
100
  isDeprecated?: boolean;
101
101
  isPublic?: boolean;
102
102
  name?: string;
103
- /** @deprecated Use defaultRunOptions.restartOnError instead */
104
- restartOnError?: boolean;
105
103
  /**
106
104
  * @since Added in 2.8.6
107
105
  */
@@ -1,6 +1,6 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
- import type { PaginatedList, PaginationOptions } from '../utils.js';
3
+ import type { PaginatedList } from '../utils.js';
4
4
  import type { ActorEnvironmentVariable } from './actor_version.js';
5
5
  /**
6
6
  * Client for managing the collection of environment variables for an Actor version.
@@ -37,23 +37,22 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
37
37
  /**
38
38
  * Lists all environment variables of this Actor version.
39
39
  *
40
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
41
- * items in a single API call is limited.
40
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
41
+ * with a Promise) gets the whole list.
42
42
  * ```javascript
43
- * const paginatedList = await client.list();
44
- *```
43
+ * const { items } = await client.list();
44
+ * ```
45
45
  *
46
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
47
- * retrieved.
46
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
48
47
  *
49
48
  * ```javascript
50
49
  * for await (const singleItem of client.list()) {...}
51
50
  * ```
52
51
  *
53
- * @returns A paginated iterator of environment variables.
52
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
54
53
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
55
54
  */
56
- list(_options?: ActorEnvVarCollectionListOptions): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
55
+ list(): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
57
56
  /**
58
57
  * Creates a new environment variable for this Actor version.
59
58
  *
@@ -63,14 +62,6 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
63
62
  */
64
63
  create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
65
64
  }
66
- /**
67
- * @deprecated No options are used in the current API implementation.
68
- * https://github.com/apify/apify-client-js/issues/799
69
- * @since Added in 2.1.0
70
- */
71
- export interface ActorEnvVarCollectionListOptions extends PaginationOptions {
72
- desc?: boolean;
73
- }
74
65
  /**
75
66
  * @since Added in 2.1.0
76
67
  */
@@ -42,23 +42,22 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
42
42
  /**
43
43
  * Lists all environment variables of this Actor version.
44
44
  *
45
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
46
- * items in a single API call is limited.
45
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
46
+ * with a Promise) gets the whole list.
47
47
  * ```javascript
48
- * const paginatedList = await client.list();
49
- *```
48
+ * const { items } = await client.list();
49
+ * ```
50
50
  *
51
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
52
- * retrieved.
51
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
53
52
  *
54
53
  * ```javascript
55
54
  * for await (const singleItem of client.list()) {...}
56
55
  * ```
57
56
  *
58
- * @returns A paginated iterator of environment variables.
57
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
59
58
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
60
59
  */
61
- list(_options = {}) {
60
+ list() {
62
61
  return this._listPaginated(schemas.ListOfEnvVars());
63
62
  }
64
63
  /**
@@ -1,6 +1,6 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
- import type { PaginatedList, PaginationOptions } from '../utils.js';
3
+ import type { PaginatedList } from '../utils.js';
4
4
  import type { ActorVersion, FinalActorVersion } from './actor_version.js';
5
5
  /**
6
6
  * Client for managing the collection of Actor versions.
@@ -34,23 +34,22 @@ export declare class ActorVersionCollectionClient extends ResourceCollectionClie
34
34
  /**
35
35
  * Lists all Actor versions.
36
36
  *
37
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
38
- * items in a single API call is limited.
37
+ * The endpoint returns every version in one response, so awaiting the return value (as you would with a Promise)
38
+ * gets the whole list.
39
39
  * ```javascript
40
- * const paginatedList = await client.list();
41
- *```
40
+ * const { items } = await client.list();
41
+ * ```
42
42
  *
43
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
44
- * retrieved.
43
+ * Asynchronous iteration is also supported, and yields the versions one by one.
45
44
  *
46
45
  * ```javascript
47
46
  * for await (const singleItem of client.list()) {...}
48
47
  * ```
49
48
  *
50
- * @returns A paginated iterator of Actor versions.
49
+ * @returns The Actor versions, awaitable as a whole list or iterable one by one.
51
50
  * @see https://docs.apify.com/api/v2/act-versions-get
52
51
  */
53
- list(_options?: ActorVersionCollectionListOptions): Promise<ActorVersionListResult> & AsyncIterable<FinalActorVersion>;
52
+ list(): Promise<ActorVersionListResult> & AsyncIterable<FinalActorVersion>;
54
53
  /**
55
54
  * Creates a new Actor version.
56
55
  *
@@ -60,11 +59,4 @@ export declare class ActorVersionCollectionClient extends ResourceCollectionClie
60
59
  */
61
60
  create(actorVersion: ActorVersion): Promise<FinalActorVersion>;
62
61
  }
63
- /**
64
- * @deprecated No options are used in the current API implementation.
65
- * https://github.com/apify/apify-client-js/issues/799
66
- */
67
- export interface ActorVersionCollectionListOptions extends PaginationOptions {
68
- desc?: boolean;
69
- }
70
62
  export type ActorVersionListResult = Pick<PaginatedList<FinalActorVersion>, 'total' | 'items'>;
@@ -39,23 +39,22 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
39
39
  /**
40
40
  * Lists all Actor versions.
41
41
  *
42
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
43
- * items in a single API call is limited.
42
+ * The endpoint returns every version in one response, so awaiting the return value (as you would with a Promise)
43
+ * gets the whole list.
44
44
  * ```javascript
45
- * const paginatedList = await client.list();
46
- *```
45
+ * const { items } = await client.list();
46
+ * ```
47
47
  *
48
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
49
- * retrieved.
48
+ * Asynchronous iteration is also supported, and yields the versions one by one.
50
49
  *
51
50
  * ```javascript
52
51
  * for await (const singleItem of client.list()) {...}
53
52
  * ```
54
53
  *
55
- * @returns A paginated iterator of Actor versions.
54
+ * @returns The Actor versions, awaitable as a whole list or iterable one by one.
56
55
  * @see https://docs.apify.com/api/v2/act-versions-get
57
56
  */
58
- list(_options = {}) {
57
+ list() {
59
58
  return this._listPaginated(schemas.ListOfVersions());
60
59
  }
61
60
  /**
@@ -346,11 +346,6 @@ export type RequestQueueListRequestsFilter = 'locked' | 'pending';
346
346
  */
347
347
  export interface RequestQueueClientListRequestsOptions {
348
348
  limit?: number;
349
- /**
350
- * Using id of request that does not exist in request queue leads to unpredictable results.
351
- * @deprecated Use `cursor` for pagination instead.
352
- */
353
- exclusiveStartId?: string;
354
349
  /**
355
350
  * @since Added in 2.23.2
356
351
  */
@@ -367,8 +362,6 @@ export interface RequestQueueClientListRequestsOptions {
367
362
  export interface RequestQueueClientPaginateRequestsOptions {
368
363
  limit?: number;
369
364
  maxPageLimit?: number;
370
- /** @deprecated Use `cursor` for pagination instead. */
371
- exclusiveStartId?: string;
372
365
  /**
373
366
  * @since Added in 2.23.2
374
367
  */
@@ -4,7 +4,7 @@ import log from '@apify/log';
4
4
  import { MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS } from '../base/resource_client.js';
5
5
  import { ResponseValidationError } from '../response_validation_error.js';
6
6
  import * as schemas from '../schemas.js';
7
- import { anyObjectSchema, cast, catchNotFoundOrThrow, isNonArrayObject, mutuallyExclusive, parseArgument, parseDateFields, parseResponse, RequestQueuePaginationIterator, sliceArrayByByteLength, } from '../utils.js';
7
+ import { anyObjectSchema, cast, catchNotFoundOrThrow, isNonArrayObject, parseArgument, parseDateFields, parseResponse, RequestQueuePaginationIterator, sliceArrayByByteLength, } from '../utils.js';
8
8
  const DEFAULT_PARALLEL_BATCH_ADD_REQUESTS = 5;
9
9
  const DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS = 3;
10
10
  const DEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES_MILLIS = 500;
@@ -35,23 +35,17 @@ const prolongRequestLockOptionsSchema = z.strictObject({
35
35
  forefront: z.boolean().optional(),
36
36
  });
37
37
  const requestFilterSchema = z.array(z.enum(['locked', 'pending'])).min(1);
38
- const listRequestsOptionsSchema = z
39
- .strictObject({
38
+ const listRequestsOptionsSchema = z.strictObject({
40
39
  limit: z.number().min(0).optional(),
41
- exclusiveStartId: z.string().optional(),
42
40
  cursor: z.string().optional(),
43
41
  filter: requestFilterSchema.optional(),
44
- })
45
- .refine(...mutuallyExclusive('exclusiveStartId', 'cursor'));
46
- const paginateRequestsOptionsSchema = z
47
- .strictObject({
42
+ });
43
+ const paginateRequestsOptionsSchema = z.strictObject({
48
44
  limit: z.number().min(0).optional(),
49
45
  maxPageLimit: z.number().default(DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT),
50
- exclusiveStartId: z.string().optional(),
51
46
  cursor: z.string().optional(),
52
47
  filter: requestFilterSchema.optional(),
53
- })
54
- .refine(...mutuallyExclusive('exclusiveStartId', 'cursor'));
48
+ });
55
49
  /**
56
50
  * Client for managing a specific Request queue.
57
51
  *
@@ -589,8 +583,6 @@ export class RequestQueueClient extends ResourceClient {
589
583
  const newOptions = {
590
584
  ...parsed,
591
585
  limit: remainingItems,
592
- // remove original exclusiveStartId, if there was any, and use cursor-based pagination
593
- exclusiveStartId: undefined,
594
586
  cursor: currentPage.nextCursor,
595
587
  };
596
588
  currentPage = await getPaginatedList(newOptions);
@@ -644,11 +636,10 @@ export class RequestQueueClient extends ResourceClient {
644
636
  * @since Added in 2.5.1
645
637
  */
646
638
  paginateRequests(options = {}) {
647
- const { limit, exclusiveStartId, cursor, filter, maxPageLimit } = parseArgument(options, paginateRequestsOptionsSchema, 'RequestQueueClientPaginateRequestsOptions');
639
+ const { limit, cursor, filter, maxPageLimit } = parseArgument(options, paginateRequestsOptionsSchema, 'RequestQueueClientPaginateRequestsOptions');
648
640
  return new RequestQueuePaginationIterator({
649
641
  getPage: async (pageOptions) => this.listRequests({ ...pageOptions, filter }),
650
642
  limit,
651
- exclusiveStartId,
652
643
  cursor,
653
644
  maxPageLimit,
654
645
  });
package/dist/utils.d.ts CHANGED
@@ -86,13 +86,12 @@ export declare function getVersionData(): {
86
86
  version: string;
87
87
  };
88
88
  /**
89
- * Helper class to create async iterators from paginated list endpoints with exclusive start key.
89
+ * Helper class to create async iterators from paginated list endpoints.
90
90
  */
91
91
  export declare class RequestQueuePaginationIterator {
92
92
  private readonly maxPageLimit;
93
93
  private readonly getPage;
94
94
  private readonly limit?;
95
- private readonly exclusiveStartId?;
96
95
  private readonly cursor?;
97
96
  constructor(options: RequestQueuePaginationIteratorOptions);
98
97
  [Symbol.asyncIterator](): AsyncIterator<RequestQueueClientListRequestsResult>;
@@ -108,7 +107,6 @@ export interface RequestQueuePaginationIteratorOptions {
108
107
  maxPageLimit: number;
109
108
  getPage: (opts: RequestQueueClientListRequestsOptions) => Promise<RequestQueueClientListRequestsResult>;
110
109
  limit?: number;
111
- exclusiveStartId?: string;
112
110
  cursor?: string;
113
111
  }
114
112
  /**
@@ -195,12 +193,6 @@ export type DistributiveOptional<T, K extends keyof T> = T extends any ? Omit<T,
195
193
  * Adds query parameters to a given URL based on the provided options object.
196
194
  */
197
195
  export declare function applyQueryParamsToUrl(url: URL, options?: Record<string, string | number | boolean | string[] | undefined>): URL;
198
- /**
199
- * Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
200
- * is present. Pass the options interface as `T`, so that a misspelled key is a type error.
201
- * @internal
202
- */
203
- export declare const mutuallyExclusive: <T extends object>(...keys: (keyof T & string)[]) => [(value: T) => boolean, string];
204
196
  /**
205
197
  * Percent-encodes a caller-supplied URL path segment so it cannot restructure the request path.
206
198
  *
package/dist/utils.js CHANGED
@@ -231,25 +231,21 @@ export function getVersionData() {
231
231
  return packageJson;
232
232
  }
233
233
  /**
234
- * Helper class to create async iterators from paginated list endpoints with exclusive start key.
234
+ * Helper class to create async iterators from paginated list endpoints.
235
235
  */
236
236
  export class RequestQueuePaginationIterator {
237
237
  maxPageLimit;
238
238
  getPage;
239
239
  limit;
240
- exclusiveStartId;
241
240
  cursor;
242
241
  constructor(options) {
243
242
  this.maxPageLimit = options.maxPageLimit;
244
243
  this.limit = options.limit;
245
- this.exclusiveStartId = options.exclusiveStartId;
246
244
  this.cursor = options.cursor;
247
245
  this.getPage = options.getPage;
248
246
  }
249
247
  async *[Symbol.asyncIterator]() {
250
248
  let nextCursor = this.cursor;
251
- // allow using exclusiveStartId for the first page, but then we'll delete it to avoid using it for any later page
252
- let nextExclusiveStartId = this.exclusiveStartId;
253
249
  let iterateItemCount = 0;
254
250
  while (true) {
255
251
  const pageLimit = this.limit
@@ -258,7 +254,6 @@ export class RequestQueuePaginationIterator {
258
254
  const page = await this.getPage({
259
255
  limit: pageLimit,
260
256
  cursor: nextCursor,
261
- exclusiveStartId: nextExclusiveStartId,
262
257
  });
263
258
  // There are no more pages to iterate
264
259
  if (page.items.length === 0)
@@ -269,7 +264,6 @@ export class RequestQueuePaginationIterator {
269
264
  if ((this.limit && iterateItemCount >= this.limit) || !page.nextCursor)
270
265
  return;
271
266
  nextCursor = page.nextCursor;
272
- nextExclusiveStartId = undefined; // see comment above - delete it for any page after the first one, and paginate with cursor
273
267
  }
274
268
  }
275
269
  }
@@ -309,15 +303,6 @@ export function applyQueryParamsToUrl(url, options) {
309
303
  }
310
304
  return url;
311
305
  }
312
- /**
313
- * Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
314
- * is present. Pass the options interface as `T`, so that a misspelled key is a type error.
315
- * @internal
316
- */
317
- export const mutuallyExclusive = (...keys) => [
318
- (value) => keys.filter((key) => typeof value[key] !== 'undefined').length <= 1,
319
- `At most one of the following fields is allowed: ${keys.join(', ')}`,
320
- ];
321
306
  const pathSegmentSchema = z
322
307
  .string()
323
308
  .nonempty()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.7",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"