apify-client 3.0.0-beta.4 → 3.0.0-beta.41

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