apify-client 3.0.0-beta.15 → 3.0.0-beta.16

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.
Files changed (71) hide show
  1. package/dist/apify_api_error.js +23 -7
  2. package/dist/apify_client.d.ts +22 -3
  3. package/dist/apify_client.js +35 -29
  4. package/dist/base/api_client.d.ts +6 -6
  5. package/dist/base/api_client.js +11 -10
  6. package/dist/base/resource_client.d.ts +13 -8
  7. package/dist/base/resource_client.js +35 -19
  8. package/dist/base/resource_collection_client.d.ts +6 -4
  9. package/dist/base/resource_collection_client.js +17 -11
  10. package/dist/bundle.js +13 -13
  11. package/dist/bundle.js.map +1 -1
  12. package/dist/http_client.d.ts +34 -13
  13. package/dist/http_client.js +58 -28
  14. package/dist/index.d.ts +1 -0
  15. package/dist/resource_clients/actor.d.ts +26 -11
  16. package/dist/resource_clients/actor.js +62 -33
  17. package/dist/resource_clients/actor_collection.d.ts +6 -2
  18. package/dist/resource_clients/actor_collection.js +9 -3
  19. package/dist/resource_clients/actor_env_var.d.ts +10 -3
  20. package/dist/resource_clients/actor_env_var.js +16 -6
  21. package/dist/resource_clients/actor_env_var_collection.d.ts +7 -2
  22. package/dist/resource_clients/actor_env_var_collection.js +11 -4
  23. package/dist/resource_clients/actor_version.d.ts +10 -3
  24. package/dist/resource_clients/actor_version.js +18 -8
  25. package/dist/resource_clients/actor_version_collection.d.ts +7 -2
  26. package/dist/resource_clients/actor_version_collection.js +11 -4
  27. package/dist/resource_clients/build.d.ts +16 -6
  28. package/dist/resource_clients/build.js +30 -15
  29. package/dist/resource_clients/build_collection.d.ts +3 -1
  30. package/dist/resource_clients/build_collection.js +4 -1
  31. package/dist/resource_clients/dataset.d.ts +21 -7
  32. package/dist/resource_clients/dataset.js +56 -34
  33. package/dist/resource_clients/dataset_collection.d.ts +6 -2
  34. package/dist/resource_clients/dataset_collection.js +12 -2
  35. package/dist/resource_clients/key_value_store.d.ts +31 -11
  36. package/dist/resource_clients/key_value_store.js +58 -34
  37. package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
  38. package/dist/resource_clients/key_value_store_collection.js +12 -2
  39. package/dist/resource_clients/log.d.ts +4 -1
  40. package/dist/resource_clients/log.js +15 -6
  41. package/dist/resource_clients/request_queue.d.ts +52 -18
  42. package/dist/resource_clients/request_queue.js +114 -60
  43. package/dist/resource_clients/request_queue_collection.d.ts +6 -2
  44. package/dist/resource_clients/request_queue_collection.js +9 -3
  45. package/dist/resource_clients/run.d.ts +33 -13
  46. package/dist/resource_clients/run.js +65 -35
  47. package/dist/resource_clients/run_collection.d.ts +3 -1
  48. package/dist/resource_clients/run_collection.js +4 -1
  49. package/dist/resource_clients/schedule.d.ts +13 -4
  50. package/dist/resource_clients/schedule.js +23 -9
  51. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  52. package/dist/resource_clients/schedule_collection.js +9 -3
  53. package/dist/resource_clients/store_collection.d.ts +3 -1
  54. package/dist/resource_clients/store_collection.js +4 -1
  55. package/dist/resource_clients/task.d.ts +27 -9
  56. package/dist/resource_clients/task.js +60 -31
  57. package/dist/resource_clients/task_collection.d.ts +6 -2
  58. package/dist/resource_clients/task_collection.js +9 -3
  59. package/dist/resource_clients/user.d.ts +14 -5
  60. package/dist/resource_clients/user.js +30 -14
  61. package/dist/resource_clients/webhook.d.ts +13 -4
  62. package/dist/resource_clients/webhook.js +24 -10
  63. package/dist/resource_clients/webhook_collection.d.ts +6 -2
  64. package/dist/resource_clients/webhook_collection.js +9 -3
  65. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  66. package/dist/resource_clients/webhook_dispatch.js +7 -2
  67. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  68. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  69. package/dist/timeouts.d.ts +72 -0
  70. package/dist/timeouts.js +31 -0
  71. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
5
  import { anyObjectSchema, parseArgument, parseResponse } from '../utils.js';
5
6
  export { ScheduleActions } from '../models.js';
6
7
  const scheduleLogSchema = z.array(schemas.ScheduleInvoked());
@@ -40,42 +41,55 @@ export class ScheduleClient extends ResourceClient {
40
41
  /**
41
42
  * Retrieves the schedule.
42
43
  *
44
+ * @param options - Request options
45
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
43
46
  * @returns The schedule object, or `undefined` if it does not exist.
44
47
  * @see https://docs.apify.com/api/v2/schedule-get
45
48
  */
46
- async get() {
47
- return this._get(schemas.Schedule());
49
+ async get(options = {}) {
50
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
51
+ return this.getResource(schemas.Schedule(), {}, timeoutSecs);
48
52
  }
49
53
  /**
50
54
  * Updates the schedule with the specified fields.
51
55
  *
52
56
  * @param newFields - Fields to update.
57
+ * @param options - Request options
58
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
53
59
  * @returns The updated schedule object.
54
60
  * @see https://docs.apify.com/api/v2/schedule-put
55
61
  */
56
- async update(newFields) {
62
+ async update(newFields, options = {}) {
57
63
  parseArgument(newFields, anyObjectSchema);
58
- return this._update(schemas.Schedule(), newFields);
64
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
65
+ return this.updateResource(schemas.Schedule(), newFields, timeoutSecs);
59
66
  }
60
67
  /**
61
68
  * Deletes the schedule.
62
69
  *
70
+ * @param options - Request options
71
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
63
72
  * @see https://docs.apify.com/api/v2/schedule-delete
64
73
  */
65
- async delete() {
66
- return this._delete();
74
+ async delete(options = {}) {
75
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
76
+ return this.deleteResource(timeoutSecs);
67
77
  }
68
78
  /**
69
79
  * Retrieves the schedule's log.
70
80
  *
81
+ * @param options - Request options
82
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
71
83
  * @returns The schedule log, one entry per invocation.
72
84
  * @see https://docs.apify.com/api/v2/schedule-log-get
73
85
  */
74
- async getLog() {
86
+ async getLog(options = {}) {
87
+ const { timeoutSecs = 'medium' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
75
88
  const response = await this.httpClient.call({
76
- url: this._url('log'),
89
+ url: this.buildUrl('log'),
77
90
  method: 'GET',
78
- params: this._params(),
91
+ params: this.buildParams(),
92
+ timeoutSecs,
79
93
  });
80
94
  return parseResponse(response, scheduleLogSchema);
81
95
  }
@@ -1,5 +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 { TimeoutOptions } from '../timeouts.js';
3
4
  import type { PaginatedIterator, PaginationOptions } from '../utils.js';
4
5
  import type { Schedule, ScheduleCreateOrUpdateData } from './schedule.js';
5
6
  /**
@@ -48,6 +49,7 @@ export declare class ScheduleCollectionClient extends ResourceCollectionClient {
48
49
  * ```
49
50
  *
50
51
  * @param options - Pagination and sorting options.
52
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
51
53
  * @returns A paginated iterator of schedules.
52
54
  * @see https://docs.apify.com/api/v2/schedules-get
53
55
  */
@@ -56,11 +58,13 @@ export declare class ScheduleCollectionClient extends ResourceCollectionClient {
56
58
  * Creates a new schedule.
57
59
  *
58
60
  * @param schedule - The schedule data.
61
+ * @param options - Request options
62
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
59
63
  * @returns The created schedule object.
60
64
  * @see https://docs.apify.com/api/v2/schedules-post
61
65
  */
62
- create(schedule?: ScheduleCreateOrUpdateData): Promise<Schedule>;
66
+ create(schedule?: ScheduleCreateOrUpdateData, options?: TimeoutOptions): Promise<Schedule>;
63
67
  }
64
- export interface ScheduleCollectionListOptions extends PaginationOptions {
68
+ export interface ScheduleCollectionListOptions extends PaginationOptions, TimeoutOptions {
65
69
  desc?: boolean;
66
70
  }
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
4
5
  import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
5
6
  const listOptionsSchema = z.strictObject({
6
7
  ...paginationOptionsShape,
7
8
  desc: z.boolean().optional(),
9
+ ...timeoutOptionsShape,
8
10
  });
9
11
  const scheduleCreateSchema = anyObjectSchema.optional();
10
12
  /**
@@ -58,22 +60,26 @@ export class ScheduleCollectionClient extends ResourceCollectionClient {
58
60
  * ```
59
61
  *
60
62
  * @param options - Pagination and sorting options.
63
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
61
64
  * @returns A paginated iterator of schedules.
62
65
  * @see https://docs.apify.com/api/v2/schedules-get
63
66
  */
64
67
  list(options = {}) {
65
68
  const parsed = parseArgument(options, listOptionsSchema, 'ScheduleCollectionListOptions');
66
- return this._listPaginated(schemas.ListOfSchedules(), parsed);
69
+ return this.listResourcesPaginated(schemas.ListOfSchedules(), parsed, 'medium');
67
70
  }
68
71
  /**
69
72
  * Creates a new schedule.
70
73
  *
71
74
  * @param schedule - The schedule data.
75
+ * @param options - Request options
76
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
72
77
  * @returns The created schedule object.
73
78
  * @see https://docs.apify.com/api/v2/schedules-post
74
79
  */
75
- async create(schedule) {
80
+ async create(schedule, options = {}) {
76
81
  parseArgument(schedule, scheduleCreateSchema);
77
- return this._create(schemas.Schedule(), schedule);
82
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
83
+ return this.createResource(schemas.Schedule(), schedule, timeoutSecs);
78
84
  }
79
85
  }
@@ -1,6 +1,7 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import type { ActorStoreList } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import type { PaginatedIterator, PaginationOptions } from '../utils.js';
5
6
  export type { ActorStoreList, PricingInfo } from '../models.js';
6
7
  /**
@@ -46,6 +47,7 @@ export declare class StoreCollectionClient extends ResourceCollectionClient {
46
47
  * ```
47
48
  *
48
49
  * @param options - Search and pagination options.
50
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
49
51
  * @returns A paginated iterator of store Actors.
50
52
  * @see https://docs.apify.com/api/v2/store-get
51
53
  */
@@ -54,7 +56,7 @@ export declare class StoreCollectionClient extends ResourceCollectionClient {
54
56
  /**
55
57
  * @since Added in 2.7.2
56
58
  */
57
- export interface StoreCollectionListOptions extends PaginationOptions {
59
+ export interface StoreCollectionListOptions extends PaginationOptions, TimeoutOptions {
58
60
  search?: string;
59
61
  sortBy?: string;
60
62
  category?: string;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsShape } from '../timeouts.js';
4
5
  import { paginationOptionsShape, parseArgument } from '../utils.js';
5
6
  const listOptionsSchema = z.strictObject({
6
7
  ...paginationOptionsShape,
@@ -10,6 +11,7 @@ const listOptionsSchema = z.strictObject({
10
11
  username: z.string().optional(),
11
12
  pricingModel: z.string().optional(),
12
13
  includeUnrunnableActors: z.boolean().optional(),
14
+ ...timeoutOptionsShape,
13
15
  });
14
16
  /**
15
17
  * Client for browsing Actors in the Apify Store.
@@ -59,11 +61,12 @@ export class StoreCollectionClient extends ResourceCollectionClient {
59
61
  * ```
60
62
  *
61
63
  * @param options - Search and pagination options.
64
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
62
65
  * @returns A paginated iterator of store Actors.
63
66
  * @see https://docs.apify.com/api/v2/store-get
64
67
  */
65
68
  list(options = {}) {
66
69
  const parsed = parseArgument(options, listOptionsSchema, 'StoreCollectionListOptions');
67
- return this._listPaginated(schemas.ListOfStoreActors(), parsed);
70
+ return this.listResourcesPaginated(schemas.ListOfStoreActors(), parsed, 'medium');
68
71
  }
69
72
  }
@@ -1,6 +1,7 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import type { Task, TaskPublicConfig } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import type { Dictionary } from '../utils.js';
5
6
  import type { ActorLastRunOptions, ActorRun, ActorStartOptions } from './actor.js';
6
7
  import { RunClient } from './run.js';
@@ -35,18 +36,22 @@ export declare class TaskClient extends ResourceClient {
35
36
  /**
36
37
  * Retrieves the Actor task.
37
38
  *
39
+ * @param options - Request options
40
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
38
41
  * @returns The task object, or `undefined` if it does not exist.
39
42
  * @see https://docs.apify.com/api/v2/actor-task-get
40
43
  */
41
- get(): Promise<Task | undefined>;
44
+ get(options?: TimeoutOptions): Promise<Task | undefined>;
42
45
  /**
43
46
  * Updates the task with the specified fields.
44
47
  *
45
48
  * @param newFields - Fields to update.
49
+ * @param options - Request options
50
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
46
51
  * @returns The updated task object.
47
52
  * @see https://docs.apify.com/api/v2/actor-task-put
48
53
  */
49
- update(newFields: TaskUpdateData): Promise<Task>;
54
+ update(newFields: TaskUpdateData, options?: TimeoutOptions): Promise<Task>;
50
55
  /**
51
56
  * Publishes the task on its public landing page, by setting `isPublic` through
52
57
  * {@apilink TaskClient.update}.
@@ -55,11 +60,13 @@ export declare class TaskClient extends ResourceClient {
55
60
  * (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
56
61
  * Publishing an already published task does nothing.
57
62
  *
63
+ * @param options - Request options
64
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
65
  * @returns The task object.
59
66
  * @see https://docs.apify.com/api/v2/actor-task-put
60
67
  * @since Added in 2.25.0
61
68
  */
62
- publish(): Promise<Task>;
69
+ publish(options?: TimeoutOptions): Promise<Task>;
63
70
  /**
64
71
  * Unpublishes the task from its public landing page, by setting `isPublic` through
65
72
  * {@apilink TaskClient.update}.
@@ -68,17 +75,21 @@ export declare class TaskClient extends ResourceClient {
68
75
  * published again without re-entering it. Requires write permission to both the task and its
69
76
  * Actor. Unpublishing a task that is not published does nothing.
70
77
  *
78
+ * @param options - Request options
79
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
71
80
  * @returns The task object.
72
81
  * @see https://docs.apify.com/api/v2/actor-task-put
73
82
  * @since Added in 2.25.0
74
83
  */
75
- unpublish(): Promise<Task>;
84
+ unpublish(options?: TimeoutOptions): Promise<Task>;
76
85
  /**
77
86
  * Deletes the Task.
78
87
  *
88
+ * @param options - Request options
89
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
79
90
  * @see https://docs.apify.com/api/v2/actor-task-delete
80
91
  */
81
- delete(): Promise<void>;
92
+ delete(options?: TimeoutOptions): Promise<void>;
82
93
  /**
83
94
  * Starts an Actor task and immediately returns the Run object.
84
95
  *
@@ -86,12 +97,14 @@ export declare class TaskClient extends ResourceClient {
86
97
  * @param options - Run options.
87
98
  * @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
88
99
  * @param options.memory - Memory in megabytes allocated for the run.
89
- * @param options.timeout - Timeout for the run in seconds. Zero means no timeout.
100
+ * @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
90
101
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
91
102
  * @param options.webhooks - Webhooks to trigger for specific Actor run events.
92
103
  * @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
93
104
  * @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
94
105
  * @param options.restartOnError - Whether to restart the run on error.
106
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
107
+ * when the API is asked to hold the response.
95
108
  * @returns The Actor Run object.
96
109
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
97
110
  */
@@ -104,12 +117,13 @@ export declare class TaskClient extends ResourceClient {
104
117
  * @param options - Run and wait options.
105
118
  * @param options.build - Tag or number of the Actor build to run.
106
119
  * @param options.memory - Memory in megabytes allocated for the run.
107
- * @param options.timeout - Timeout for the run in seconds.
120
+ * @param options.runTimeoutSecs - Timeout for the run in seconds.
108
121
  * @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
109
122
  * @param options.webhooks - Webhooks to trigger for specific Actor run events.
110
123
  * @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
111
124
  * @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
112
125
  * @param options.restartOnError - Whether to restart the run on error.
126
+ * @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
113
127
  * @returns The Actor run object.
114
128
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
115
129
  */
@@ -117,18 +131,22 @@ export declare class TaskClient extends ResourceClient {
117
131
  /**
118
132
  * Retrieves the Actor task's input object.
119
133
  *
134
+ * @param options - Request options
135
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
120
136
  * @returns The Task's input.
121
137
  * @see https://docs.apify.com/api/v2/actor-task-input-get
122
138
  */
123
- getInput(): Promise<Dictionary | Dictionary[]>;
139
+ getInput(options?: TimeoutOptions): Promise<Dictionary | Dictionary[]>;
124
140
  /**
125
141
  * Updates the Actor task's input object.
126
142
  *
127
143
  * @param newFields - New input data for the task.
144
+ * @param options - Request options
145
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
128
146
  * @returns The updated task input.
129
147
  * @see https://docs.apify.com/api/v2/actor-task-input-put
130
148
  */
131
- updateInput(newFields: Dictionary | Dictionary[]): Promise<Dictionary | Dictionary[]>;
149
+ updateInput(newFields: Dictionary | Dictionary[], options?: TimeoutOptions): Promise<Dictionary | Dictionary[]>;
132
150
  /**
133
151
  * Returns a client for the last run of this task.
134
152
  *
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
3
3
  import { ResourceClient } from '../base/resource_client.js';
4
4
  import * as schemas from '../schemas.js';
5
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
5
6
  import { anyObjectSchema, cast, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
6
7
  import { RunClient } from './run.js';
7
8
  import { RunCollectionClient } from './run_collection.js';
@@ -10,22 +11,24 @@ const inputSchema = anyObjectSchema.optional();
10
11
  const startOptionsSchema = z.strictObject({
11
12
  build: z.string().optional(),
12
13
  memory: z.number().optional(),
13
- timeout: z.number().optional(),
14
+ runTimeoutSecs: z.number().min(0).optional(),
14
15
  waitForFinish: z.number().optional(),
15
16
  webhooks: z.array(anyObjectSchema).optional(),
16
17
  maxItems: z.number().min(0).optional(),
17
18
  maxTotalChargeUsd: z.number().min(0).optional(),
18
19
  restartOnError: z.boolean().optional(),
20
+ ...timeoutOptionsShape,
19
21
  });
20
22
  const callOptionsSchema = z.strictObject({
21
23
  build: z.string().optional(),
22
24
  memory: z.number().optional(),
23
- timeout: z.number().min(0).optional(),
25
+ runTimeoutSecs: z.number().min(0).optional(),
24
26
  waitSecs: z.number().min(0).optional(),
25
27
  webhooks: z.array(anyObjectSchema).optional(),
26
28
  maxItems: z.number().min(0).optional(),
27
29
  maxTotalChargeUsd: z.number().min(0).optional(),
28
30
  restartOnError: z.boolean().optional(),
31
+ ...timeoutOptionsShape,
29
32
  });
30
33
  const lastRunOptionsSchema = z.strictObject({
31
34
  status: z.enum(ACT_JOB_STATUSES).optional(),
@@ -64,22 +67,28 @@ export class TaskClient extends ResourceClient {
64
67
  /**
65
68
  * Retrieves the Actor task.
66
69
  *
70
+ * @param options - Request options
71
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
67
72
  * @returns The task object, or `undefined` if it does not exist.
68
73
  * @see https://docs.apify.com/api/v2/actor-task-get
69
74
  */
70
- async get() {
71
- return this._get(schemas.Task());
75
+ async get(options = {}) {
76
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
77
+ return this.getResource(schemas.Task(), {}, timeoutSecs);
72
78
  }
73
79
  /**
74
80
  * Updates the task with the specified fields.
75
81
  *
76
82
  * @param newFields - Fields to update.
83
+ * @param options - Request options
84
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
77
85
  * @returns The updated task object.
78
86
  * @see https://docs.apify.com/api/v2/actor-task-put
79
87
  */
80
- async update(newFields) {
88
+ async update(newFields, options = {}) {
81
89
  parseArgument(newFields, anyObjectSchema);
82
- return this._update(schemas.Task(), newFields);
90
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
91
+ return this.updateResource(schemas.Task(), newFields, timeoutSecs);
83
92
  }
84
93
  /**
85
94
  * Publishes the task on its public landing page, by setting `isPublic` through
@@ -89,12 +98,14 @@ export class TaskClient extends ResourceClient {
89
98
  * (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
90
99
  * Publishing an already published task does nothing.
91
100
  *
101
+ * @param options - Request options
102
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
92
103
  * @returns The task object.
93
104
  * @see https://docs.apify.com/api/v2/actor-task-put
94
105
  * @since Added in 2.25.0
95
106
  */
96
- async publish() {
97
- return this.update({ isPublic: true });
107
+ async publish(options = {}) {
108
+ return this.update({ isPublic: true }, options);
98
109
  }
99
110
  /**
100
111
  * Unpublishes the task from its public landing page, by setting `isPublic` through
@@ -104,20 +115,25 @@ export class TaskClient extends ResourceClient {
104
115
  * published again without re-entering it. Requires write permission to both the task and its
105
116
  * Actor. Unpublishing a task that is not published does nothing.
106
117
  *
118
+ * @param options - Request options
119
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
107
120
  * @returns The task object.
108
121
  * @see https://docs.apify.com/api/v2/actor-task-put
109
122
  * @since Added in 2.25.0
110
123
  */
111
- async unpublish() {
112
- return this.update({ isPublic: false });
124
+ async unpublish(options = {}) {
125
+ return this.update({ isPublic: false }, options);
113
126
  }
114
127
  /**
115
128
  * Deletes the Task.
116
129
  *
130
+ * @param options - Request options
131
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
117
132
  * @see https://docs.apify.com/api/v2/actor-task-delete
118
133
  */
119
- async delete() {
120
- return this._delete();
134
+ async delete(options = {}) {
135
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
136
+ return this.deleteResource(timeoutSecs);
121
137
  }
122
138
  /**
123
139
  * Starts an Actor task and immediately returns the Run object.
@@ -126,22 +142,25 @@ export class TaskClient extends ResourceClient {
126
142
  * @param options - Run options.
127
143
  * @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
128
144
  * @param options.memory - Memory in megabytes allocated for the run.
129
- * @param options.timeout - Timeout for the run in seconds. Zero means no timeout.
145
+ * @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
130
146
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
131
147
  * @param options.webhooks - Webhooks to trigger for specific Actor run events.
132
148
  * @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
133
149
  * @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
134
150
  * @param options.restartOnError - Whether to restart the run on error.
151
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
152
+ * when the API is asked to hold the response.
135
153
  * @returns The Actor Run object.
136
154
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
137
155
  */
138
156
  async start(input, options = {}) {
139
157
  parseArgument(input, inputSchema);
140
158
  const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
141
- const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError } = parsed;
159
+ const { waitForFinish, runTimeoutSecs, memory, build, maxItems, maxTotalChargeUsd, restartOnError, timeoutSecs, } = parsed;
160
+ // The API's `timeout` parameter bounds the run, not the request.
142
161
  const params = {
143
162
  waitForFinish,
144
- timeout,
163
+ timeout: runTimeoutSecs,
145
164
  memory,
146
165
  build,
147
166
  webhooks: stringifyWebhooksToBase64(parsed.webhooks),
@@ -150,16 +169,17 @@ export class TaskClient extends ResourceClient {
150
169
  restartOnError,
151
170
  };
152
171
  const request = {
153
- url: this._url('runs'),
172
+ url: this.buildUrl('runs'),
154
173
  method: 'POST',
155
174
  data: input,
156
- params: this._params(params),
175
+ params: this.buildParams(params),
157
176
  // Apify internal property. Tells the request serialization interceptor
158
177
  // to stringify functions to JSON, instead of omitting them.
159
178
  stringifyFunctions: true,
160
179
  headers: {
161
180
  'Content-Type': 'application/json',
162
181
  },
182
+ timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', waitForFinish),
163
183
  };
164
184
  const response = await this.httpClient.call(request);
165
185
  return parseResponse(response, schemas.Run());
@@ -172,36 +192,41 @@ export class TaskClient extends ResourceClient {
172
192
  * @param options - Run and wait options.
173
193
  * @param options.build - Tag or number of the Actor build to run.
174
194
  * @param options.memory - Memory in megabytes allocated for the run.
175
- * @param options.timeout - Timeout for the run in seconds.
195
+ * @param options.runTimeoutSecs - Timeout for the run in seconds.
176
196
  * @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
177
197
  * @param options.webhooks - Webhooks to trigger for specific Actor run events.
178
198
  * @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
179
199
  * @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
180
200
  * @param options.restartOnError - Whether to restart the run on error.
201
+ * @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
181
202
  * @returns The Actor run object.
182
203
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
183
204
  */
184
205
  async call(input, options = {}) {
185
206
  parseArgument(input, inputSchema);
186
207
  const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
187
- const { waitSecs, ...startOptions } = parsed;
188
- const { id } = await this.start(input, startOptions);
208
+ const { waitSecs, timeoutSecs = 'noTimeout', ...startOptions } = parsed;
209
+ const { id } = await this.start(input, { ...startOptions, timeoutSecs });
189
210
  // Calling root client because we need access to top level API.
190
211
  // Creating a new instance of RunClient here would only allow
191
212
  // setting it up as a nested route under task API.
192
- return this.apifyClient.run(id).waitForFinish({ waitSecs });
213
+ return this.apifyClient.run(id).waitForFinish({ waitSecs, timeoutSecs });
193
214
  }
194
215
  /**
195
216
  * Retrieves the Actor task's input object.
196
217
  *
218
+ * @param options - Request options
219
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
197
220
  * @returns The Task's input.
198
221
  * @see https://docs.apify.com/api/v2/actor-task-input-get
199
222
  */
200
- async getInput() {
223
+ async getInput(options = {}) {
224
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
201
225
  const response = await this.httpClient.call({
202
- url: this._url('input'),
226
+ url: this.buildUrl('input'),
203
227
  method: 'GET',
204
- params: this._params(),
228
+ params: this.buildParams(),
229
+ timeoutSecs,
205
230
  });
206
231
  return cast(response.data);
207
232
  }
@@ -209,15 +234,19 @@ export class TaskClient extends ResourceClient {
209
234
  * Updates the Actor task's input object.
210
235
  *
211
236
  * @param newFields - New input data for the task.
237
+ * @param options - Request options
238
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
212
239
  * @returns The updated task input.
213
240
  * @see https://docs.apify.com/api/v2/actor-task-input-put
214
241
  */
215
- async updateInput(newFields) {
242
+ async updateInput(newFields, options = {}) {
243
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
216
244
  const response = await this.httpClient.call({
217
- url: this._url('input'),
245
+ url: this.buildUrl('input'),
218
246
  method: 'PUT',
219
- params: this._params(),
247
+ params: this.buildParams(),
220
248
  data: newFields,
249
+ timeoutSecs,
221
250
  });
222
251
  return cast(response.data);
223
252
  }
@@ -232,9 +261,9 @@ export class TaskClient extends ResourceClient {
232
261
  */
233
262
  lastRun(options = {}) {
234
263
  const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
235
- return new RunClient(this._subResourceOptions({
264
+ return new RunClient(this.subResourceOptions({
236
265
  id: 'last',
237
- params: this._params(parsed),
266
+ params: this.buildParams(parsed),
238
267
  resourcePath: 'runs',
239
268
  }));
240
269
  }
@@ -245,7 +274,7 @@ export class TaskClient extends ResourceClient {
245
274
  * @see https://docs.apify.com/api/v2/actor-task-runs-get
246
275
  */
247
276
  runs() {
248
- return new RunCollectionClient(this._subResourceOptions({
277
+ return new RunCollectionClient(this.subResourceOptions({
249
278
  resourcePath: 'runs',
250
279
  }));
251
280
  }
@@ -256,6 +285,6 @@ export class TaskClient extends ResourceClient {
256
285
  * @see https://docs.apify.com/api/v2/actor-task-webhooks-get
257
286
  */
258
287
  webhooks() {
259
- return new WebhookCollectionClient(this._subResourceOptions());
288
+ return new WebhookCollectionClient(this.subResourceOptions());
260
289
  }
261
290
  }
@@ -1,6 +1,7 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import type { TaskList } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import type { PaginatedIterator, PaginationOptions } from '../utils.js';
5
6
  import type { Task, TaskUpdateData } from './task.js';
6
7
  export type { TaskList } from '../models.js';
@@ -50,6 +51,7 @@ export declare class TaskCollectionClient extends ResourceCollectionClient {
50
51
  * ```
51
52
  *
52
53
  * @param options - Pagination and sorting options.
54
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
53
55
  * @returns A paginated iterator of tasks.
54
56
  * @see https://docs.apify.com/api/v2/actor-tasks-get
55
57
  */
@@ -58,12 +60,14 @@ export declare class TaskCollectionClient extends ResourceCollectionClient {
58
60
  * Creates a new task.
59
61
  *
60
62
  * @param task - The task data.
63
+ * @param options - Request options
64
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
61
65
  * @returns The created task object.
62
66
  * @see https://docs.apify.com/api/v2/actor-tasks-post
63
67
  */
64
- create(task: TaskCreateData): Promise<Task>;
68
+ create(task: TaskCreateData, options?: TimeoutOptions): Promise<Task>;
65
69
  }
66
- export interface TaskCollectionListOptions extends PaginationOptions {
70
+ export interface TaskCollectionListOptions extends PaginationOptions, TimeoutOptions {
67
71
  desc?: boolean;
68
72
  }
69
73
  /**