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

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 (76) hide show
  1. package/dist/apify_api_error.d.ts +4 -19
  2. package/dist/apify_api_error.js +16 -15
  3. package/dist/apify_client.d.ts +22 -3
  4. package/dist/apify_client.js +35 -29
  5. package/dist/base/api_client.d.ts +6 -6
  6. package/dist/base/api_client.js +11 -10
  7. package/dist/base/resource_client.d.ts +13 -8
  8. package/dist/base/resource_client.js +35 -19
  9. package/dist/base/resource_collection_client.d.ts +6 -4
  10. package/dist/base/resource_collection_client.js +17 -11
  11. package/dist/bundle.js +12 -12
  12. package/dist/bundle.js.map +1 -1
  13. package/dist/http_client.d.ts +18 -51
  14. package/dist/http_client.js +67 -38
  15. package/dist/index.d.ts +1 -0
  16. package/dist/resource_clients/actor.d.ts +26 -11
  17. package/dist/resource_clients/actor.js +62 -33
  18. package/dist/resource_clients/actor_collection.d.ts +6 -2
  19. package/dist/resource_clients/actor_collection.js +9 -3
  20. package/dist/resource_clients/actor_env_var.d.ts +10 -3
  21. package/dist/resource_clients/actor_env_var.js +16 -6
  22. package/dist/resource_clients/actor_env_var_collection.d.ts +7 -2
  23. package/dist/resource_clients/actor_env_var_collection.js +11 -4
  24. package/dist/resource_clients/actor_version.d.ts +10 -3
  25. package/dist/resource_clients/actor_version.js +18 -8
  26. package/dist/resource_clients/actor_version_collection.d.ts +7 -2
  27. package/dist/resource_clients/actor_version_collection.js +11 -4
  28. package/dist/resource_clients/build.d.ts +16 -6
  29. package/dist/resource_clients/build.js +30 -15
  30. package/dist/resource_clients/build_collection.d.ts +3 -1
  31. package/dist/resource_clients/build_collection.js +4 -1
  32. package/dist/resource_clients/dataset.d.ts +21 -7
  33. package/dist/resource_clients/dataset.js +56 -34
  34. package/dist/resource_clients/dataset_collection.d.ts +6 -2
  35. package/dist/resource_clients/dataset_collection.js +12 -2
  36. package/dist/resource_clients/key_value_store.d.ts +31 -11
  37. package/dist/resource_clients/key_value_store.js +58 -34
  38. package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
  39. package/dist/resource_clients/key_value_store_collection.js +12 -2
  40. package/dist/resource_clients/log.d.ts +5 -17
  41. package/dist/resource_clients/log.js +46 -37
  42. package/dist/resource_clients/request_queue.d.ts +47 -19
  43. package/dist/resource_clients/request_queue.js +127 -73
  44. package/dist/resource_clients/request_queue_collection.d.ts +6 -2
  45. package/dist/resource_clients/request_queue_collection.js +9 -3
  46. package/dist/resource_clients/run.d.ts +33 -13
  47. package/dist/resource_clients/run.js +65 -35
  48. package/dist/resource_clients/run_collection.d.ts +3 -1
  49. package/dist/resource_clients/run_collection.js +4 -1
  50. package/dist/resource_clients/schedule.d.ts +13 -4
  51. package/dist/resource_clients/schedule.js +23 -9
  52. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  53. package/dist/resource_clients/schedule_collection.js +9 -3
  54. package/dist/resource_clients/store_collection.d.ts +3 -1
  55. package/dist/resource_clients/store_collection.js +4 -1
  56. package/dist/resource_clients/task.d.ts +27 -9
  57. package/dist/resource_clients/task.js +60 -31
  58. package/dist/resource_clients/task_collection.d.ts +6 -2
  59. package/dist/resource_clients/task_collection.js +9 -3
  60. package/dist/resource_clients/user.d.ts +14 -5
  61. package/dist/resource_clients/user.js +30 -14
  62. package/dist/resource_clients/webhook.d.ts +13 -4
  63. package/dist/resource_clients/webhook.js +24 -10
  64. package/dist/resource_clients/webhook_collection.d.ts +6 -2
  65. package/dist/resource_clients/webhook_collection.js +9 -3
  66. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  67. package/dist/resource_clients/webhook_dispatch.js +7 -2
  68. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  69. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  70. package/dist/statistics.d.ts +1 -6
  71. package/dist/statistics.js +2 -2
  72. package/dist/timeouts.d.ts +72 -0
  73. package/dist/timeouts.js +31 -0
  74. package/dist/utils.d.ts +1 -4
  75. package/dist/utils.js +14 -14
  76. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import type { z } from 'zod';
2
+ import type { Timeout, TimeoutOptions } from '../timeouts.js';
2
3
  import type { PaginatedResponse, PaginationOptions } from '../utils.js';
3
4
  import { ApiClient } from './api_client.js';
4
5
  /**
@@ -9,11 +10,12 @@ export declare class ResourceCollectionClient extends ApiClient {
9
10
  /**
10
11
  * @private
11
12
  */
12
- protected _list<T, R>(schema: z.ZodType, options?: T): Promise<R>;
13
+ protected listResources<T, R>(schema: z.ZodType, options: T | undefined, timeoutSecs: Timeout): Promise<R>;
13
14
  /**
14
15
  * Returns async iterator to iterate through all items and Promise that can be awaited to get first page of results.
16
+ * `defaultTimeoutSecs` applies to every page request unless `options.timeoutSecs` overrides it.
15
17
  */
16
- protected _listPaginated<T extends PaginationOptions, Data, R extends PaginatedResponse<Data>>(schema: z.ZodType, options?: T): AsyncIterable<Data> & Promise<R>;
17
- protected _create<D, R>(schema: z.ZodType, resource: D): Promise<R>;
18
- protected _getOrCreate<D, R>(schema: z.ZodType, name?: string, resource?: D): Promise<R>;
18
+ protected listResourcesPaginated<T extends PaginationOptions & TimeoutOptions, Data, R extends PaginatedResponse<Data>>(schema: z.ZodType, options: T, defaultTimeoutSecs: Timeout): AsyncIterable<Data> & Promise<R>;
19
+ protected createResource<D, R>(schema: z.ZodType, resource: D, timeoutSecs: Timeout): Promise<R>;
20
+ protected getOrCreateResource<D, R>(schema: z.ZodType, name: string | undefined, resource: D | undefined, timeoutSecs: Timeout): Promise<R>;
19
21
  }
@@ -8,35 +8,41 @@ export class ResourceCollectionClient extends ApiClient {
8
8
  /**
9
9
  * @private
10
10
  */
11
- async _list(schema, options = {}) {
11
+ async listResources(schema, options, timeoutSecs) {
12
12
  const response = await this.httpClient.call({
13
- url: this._url(),
13
+ url: this.buildUrl(),
14
14
  method: 'GET',
15
- params: this._params(options),
15
+ params: this.buildParams(options),
16
+ timeoutSecs,
16
17
  });
17
18
  return parseResponse(response, schema);
18
19
  }
19
20
  /**
20
21
  * Returns async iterator to iterate through all items and Promise that can be awaited to get first page of results.
22
+ * `defaultTimeoutSecs` applies to every page request unless `options.timeoutSecs` overrides it.
21
23
  */
22
- _listPaginated(schema, options = {}) {
23
- return this._listPaginatedFromCallback(async (listOptions) => this._list(schema, listOptions), options);
24
+ listResourcesPaginated(schema, options, defaultTimeoutSecs) {
25
+ // `timeoutSecs` only times the page requests; it is not an API parameter, so it must not reach the query string.
26
+ const { timeoutSecs = defaultTimeoutSecs, ...listOptions } = options;
27
+ return this.listPaginatedFromCallback(async (pageOptions) => this.listResources(schema, pageOptions, timeoutSecs), listOptions);
24
28
  }
25
- async _create(schema, resource) {
29
+ async createResource(schema, resource, timeoutSecs) {
26
30
  const response = await this.httpClient.call({
27
- url: this._url(),
31
+ url: this.buildUrl(),
28
32
  method: 'POST',
29
- params: this._params(),
33
+ params: this.buildParams(),
30
34
  data: resource,
35
+ timeoutSecs,
31
36
  });
32
37
  return parseResponse(response, schema);
33
38
  }
34
- async _getOrCreate(schema, name, resource) {
39
+ async getOrCreateResource(schema, name, resource, timeoutSecs) {
35
40
  const response = await this.httpClient.call({
36
- url: this._url(),
41
+ url: this.buildUrl(),
37
42
  method: 'POST',
38
- params: this._params({ name }),
43
+ params: this.buildParams({ name }),
39
44
  data: resource,
45
+ timeoutSecs,
40
46
  });
41
47
  return parseResponse(response, schema);
42
48
  }