apify-client 3.0.0-beta.27 → 3.0.0-beta.29

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 (39) hide show
  1. package/dist/apify_client.d.ts +15 -3
  2. package/dist/apify_client.js +9 -6
  3. package/dist/base/api_client.js +2 -2
  4. package/dist/base/resource_client.d.ts +3 -3
  5. package/dist/base/resource_client.js +13 -9
  6. package/dist/base/resource_collection_client.d.ts +5 -4
  7. package/dist/base/resource_collection_client.js +12 -7
  8. package/dist/bundle.js +6 -6
  9. package/dist/bundle.js.map +1 -1
  10. package/dist/http_clients/base.js +1 -21
  11. package/dist/resource_clients/actor.js +17 -13
  12. package/dist/resource_clients/actor_collection.js +2 -2
  13. package/dist/resource_clients/actor_env_var.js +6 -6
  14. package/dist/resource_clients/actor_env_var_collection.js +4 -4
  15. package/dist/resource_clients/actor_version.js +6 -6
  16. package/dist/resource_clients/actor_version_collection.js +4 -4
  17. package/dist/resource_clients/build.js +8 -6
  18. package/dist/resource_clients/dataset.js +18 -14
  19. package/dist/resource_clients/dataset_collection.js +6 -5
  20. package/dist/resource_clients/key_value_store.js +19 -14
  21. package/dist/resource_clients/key_value_store_collection.js +6 -5
  22. package/dist/resource_clients/log.d.ts +2 -0
  23. package/dist/resource_clients/log.js +10 -4
  24. package/dist/resource_clients/request_queue.js +37 -21
  25. package/dist/resource_clients/request_queue_collection.js +2 -2
  26. package/dist/resource_clients/run.js +21 -15
  27. package/dist/resource_clients/schedule.js +8 -7
  28. package/dist/resource_clients/schedule_collection.js +2 -2
  29. package/dist/resource_clients/task.js +15 -12
  30. package/dist/resource_clients/task_collection.js +2 -2
  31. package/dist/resource_clients/user.js +8 -5
  32. package/dist/resource_clients/webhook.js +8 -7
  33. package/dist/resource_clients/webhook_collection.js +2 -2
  34. package/dist/resource_clients/webhook_dispatch.js +2 -2
  35. package/dist/timeouts.d.ts +12 -0
  36. package/dist/timeouts.js +6 -0
  37. package/dist/utils.d.ts +5 -0
  38. package/dist/utils.js +21 -0
  39. package/package.json +2 -2
@@ -49,8 +49,8 @@ export class UserClient extends ResourceClient {
49
49
  * @see https://docs.apify.com/api/v2/user-get
50
50
  */
51
51
  async get(options = {}) {
52
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
53
- return this.getResource(schemas.UserPrivateInfo(), {}, timeoutSecs);
52
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
53
+ return this.getResource(schemas.UserPrivateInfo(), {}, timeoutSecs, signal);
54
54
  }
55
55
  /**
56
56
  * Retrieves the user's monthly usage data.
@@ -62,12 +62,13 @@ export class UserClient extends ResourceClient {
62
62
  * @since Added in 2.9.2
63
63
  */
64
64
  async monthlyUsage(options = {}) {
65
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
65
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
66
66
  const response = await this.httpClient.call({
67
67
  url: this.buildUrl('usage/monthly'),
68
68
  method: 'GET',
69
69
  params: this.buildParams(),
70
70
  timeoutSecs,
71
+ signal,
71
72
  });
72
73
  return parseResponse(response, schemas.MonthlyUsage());
73
74
  }
@@ -81,12 +82,13 @@ export class UserClient extends ResourceClient {
81
82
  * @since Added in 2.9.2
82
83
  */
83
84
  async limits(options = {}) {
84
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
85
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
85
86
  const response = await this.httpClient.call({
86
87
  url: this.buildUrl('limits'),
87
88
  method: 'GET',
88
89
  params: this.buildParams(),
89
90
  timeoutSecs,
91
+ signal,
90
92
  });
91
93
  return parseResponse(response, schemas.AccountLimits());
92
94
  }
@@ -100,13 +102,14 @@ export class UserClient extends ResourceClient {
100
102
  * @since Added in 2.10.0
101
103
  */
102
104
  async updateLimits(newLimits, options = {}) {
103
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
105
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
104
106
  const requestOpts = {
105
107
  url: this.buildUrl('limits'),
106
108
  method: 'PUT',
107
109
  params: this.buildParams(),
108
110
  data: newLimits,
109
111
  timeoutSecs,
112
+ signal,
110
113
  };
111
114
  await this.httpClient.call(requestOpts);
112
115
  }
@@ -50,8 +50,8 @@ export class WebhookClient extends ResourceClient {
50
50
  * @see https://docs.apify.com/api/v2/webhook-get
51
51
  */
52
52
  async get(options = {}) {
53
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
54
- return this.getResource(schemas.Webhook(), {}, timeoutSecs);
53
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
54
+ return this.getResource(schemas.Webhook(), {}, timeoutSecs, signal);
55
55
  }
56
56
  /**
57
57
  * Updates the webhook with the specified fields.
@@ -64,8 +64,8 @@ export class WebhookClient extends ResourceClient {
64
64
  */
65
65
  async update(newFields, options = {}) {
66
66
  parseArgument(newFields, anyObjectSchema);
67
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
68
- return this.updateResource(schemas.Webhook(), newFields, timeoutSecs);
67
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
68
+ return this.updateResource(schemas.Webhook(), newFields, timeoutSecs, signal);
69
69
  }
70
70
  /**
71
71
  * Deletes the webhook.
@@ -75,8 +75,8 @@ export class WebhookClient extends ResourceClient {
75
75
  * @see https://docs.apify.com/api/v2/webhook-delete
76
76
  */
77
77
  async delete(options = {}) {
78
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
79
- return this.deleteResource(timeoutSecs);
78
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
79
+ return this.deleteResource(timeoutSecs, signal);
80
80
  }
81
81
  /**
82
82
  * Tests the webhook by dispatching a test event.
@@ -87,12 +87,13 @@ export class WebhookClient extends ResourceClient {
87
87
  * @see https://docs.apify.com/api/v2/webhook-test-post
88
88
  */
89
89
  async test(options = {}) {
90
- const { timeoutSecs = 'medium' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
90
+ const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
91
91
  const response = await this.httpClient.call({
92
92
  url: this.buildUrl('test'),
93
93
  method: 'POST',
94
94
  params: this.buildParams(),
95
95
  timeoutSecs,
96
+ signal,
96
97
  });
97
98
  return parseResponse(response, schemas.WebhookDispatch());
98
99
  }
@@ -78,7 +78,7 @@ export class WebhookCollectionClient extends ResourceCollectionClient {
78
78
  */
79
79
  async create(webhook, options = {}) {
80
80
  parseArgument(webhook, webhookCreateSchema);
81
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
82
- return this.createResource(schemas.Webhook(), webhook, timeoutSecs);
81
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
82
+ return this.createResource(schemas.Webhook(), webhook, timeoutSecs, signal);
83
83
  }
84
84
  }
@@ -40,7 +40,7 @@ export class WebhookDispatchClient extends ResourceClient {
40
40
  * @see https://docs.apify.com/api/v2/webhook-dispatch-get
41
41
  */
42
42
  async get(options = {}) {
43
- const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
44
- return this.getResource(schemas.WebhookDispatch(), {}, timeoutSecs);
43
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
44
+ return this.getResource(schemas.WebhookDispatch(), {}, timeoutSecs, signal);
45
45
  }
46
46
  }
@@ -34,6 +34,11 @@ export interface TimeoutOptions {
34
34
  * `'noTimeout'`. Defaults to the tier the method is assigned, which its documentation names.
35
35
  */
36
36
  timeoutSecs?: Timeout;
37
+ /**
38
+ * Aborts the method. Once the signal aborts, the request in flight is ended, no retry or further poll
39
+ * follows, and the method rejects with the signal's `reason`.
40
+ */
41
+ signal?: AbortSignal;
37
42
  }
38
43
  /**
39
44
  * Schema of {@link Timeout}, optional, for the methods that validate `timeoutSecs` on its own.
@@ -45,6 +50,11 @@ export declare const optionalTimeoutSchema: z.ZodOptional<z.ZodUnion<readonly [z
45
50
  noTimeout: "noTimeout";
46
51
  short: "short";
47
52
  }>, z.ZodNumber]>>;
53
+ /**
54
+ * Schema of {@link TimeoutOptions.signal}, for the methods that validate `signal` on its own.
55
+ * @internal
56
+ */
57
+ export declare const optionalSignalSchema: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
48
58
  /**
49
59
  * Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
50
60
  * request. One copy stops it drifting from the interface.
@@ -57,6 +67,7 @@ export declare const timeoutOptionsShape: {
57
67
  noTimeout: "noTimeout";
58
68
  short: "short";
59
69
  }>, z.ZodNumber]>>;
70
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
60
71
  };
61
72
  /**
62
73
  * Schema of {@link TimeoutOptions}, for the methods that take no other option.
@@ -69,4 +80,5 @@ export declare const timeoutOptionsSchema: z.ZodObject<{
69
80
  noTimeout: "noTimeout";
70
81
  short: "short";
71
82
  }>, z.ZodNumber]>>;
83
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
72
84
  }, z.core.$strict>;
package/dist/timeouts.js CHANGED
@@ -16,6 +16,11 @@ const timeoutSchema = z.union([z.enum(['short', 'medium', 'long', 'noTimeout']),
16
16
  * @internal
17
17
  */
18
18
  export const optionalTimeoutSchema = timeoutSchema.optional();
19
+ /**
20
+ * Schema of {@link TimeoutOptions.signal}, for the methods that validate `signal` on its own.
21
+ * @internal
22
+ */
23
+ export const optionalSignalSchema = z.instanceof(AbortSignal).optional();
19
24
  /**
20
25
  * Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
21
26
  * request. One copy stops it drifting from the interface.
@@ -23,6 +28,7 @@ export const optionalTimeoutSchema = timeoutSchema.optional();
23
28
  */
24
29
  export const timeoutOptionsShape = {
25
30
  timeoutSecs: optionalTimeoutSchema,
31
+ signal: optionalSignalSchema,
26
32
  };
27
33
  /**
28
34
  * Schema of {@link TimeoutOptions}, for the methods that take no other option.
package/dist/utils.d.ts CHANGED
@@ -238,3 +238,8 @@ export declare function toPathSegment(value: string): string;
238
238
  * `requests/batch` keep their separators; an array has each of its segments encoded individually.
239
239
  */
240
240
  export declare function toPath(path: string | string[]): string;
241
+ /**
242
+ * Resolves after `millis`, or right away once `signal` aborts.
243
+ * @internal
244
+ */
245
+ export declare function sleep(millis: number, signal?: AbortSignal): Promise<void>;
package/dist/utils.js CHANGED
@@ -355,3 +355,24 @@ export function toPathSegment(value) {
355
355
  export function toPath(path) {
356
356
  return Array.isArray(path) ? path.map(toPathSegment).join('/') : path;
357
357
  }
358
+ /**
359
+ * Resolves after `millis`, or right away once `signal` aborts.
360
+ * @internal
361
+ */
362
+ export async function sleep(millis, signal) {
363
+ return new Promise((resolve) => {
364
+ if (signal?.aborted) {
365
+ resolve();
366
+ return;
367
+ }
368
+ const onAbort = () => {
369
+ clearTimeout(timer);
370
+ resolve();
371
+ };
372
+ const timer = setTimeout(() => {
373
+ signal?.removeEventListener('abort', onAbort);
374
+ resolve();
375
+ }, millis);
376
+ signal?.addEventListener('abort', onAbort, { once: true });
377
+ });
378
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.27",
3
+ "version": "3.0.0-beta.29",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -107,7 +107,7 @@
107
107
  "devEngines": {
108
108
  "packageManager": {
109
109
  "name": "pnpm",
110
- "version": "10.33.4",
110
+ "version": "12.6.0",
111
111
  "onFail": "warn"
112
112
  }
113
113
  },