apify-client 3.0.0-beta.1 → 3.0.0-beta.100

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 (131) hide show
  1. package/README.md +21 -5
  2. package/dist/apify_api_error.d.ts +64 -22
  3. package/dist/apify_api_error.js +100 -30
  4. package/dist/apify_client.d.ts +150 -35
  5. package/dist/apify_client.js +198 -118
  6. package/dist/apify_client_error.d.ts +10 -0
  7. package/dist/apify_client_error.js +10 -0
  8. package/dist/base/api_client.d.ts +9 -9
  9. package/dist/base/api_client.js +41 -45
  10. package/dist/base/resource_client.d.ts +24 -10
  11. package/dist/base/resource_client.js +78 -48
  12. package/dist/base/resource_collection_client.d.ts +15 -6
  13. package/dist/base/resource_collection_client.js +40 -21
  14. package/dist/body_parser.d.ts +3 -4
  15. package/dist/body_parser.js +20 -32
  16. package/dist/bundle.js +47 -52
  17. package/dist/bundle.js.map +1 -1
  18. package/dist/generated/api.d.ts +3363 -1185
  19. package/dist/generated/api.js +1 -2
  20. package/dist/generated/schemas.d.ts +8146 -0
  21. package/dist/generated/schemas.js +1866 -0
  22. package/dist/http_clients/axios.d.ts +61 -0
  23. package/dist/http_clients/axios.js +119 -0
  24. package/dist/http_clients/base.d.ts +391 -0
  25. package/dist/http_clients/base.js +650 -0
  26. package/dist/http_clients/index.d.ts +4 -0
  27. package/dist/http_clients/index.js +2 -0
  28. package/dist/http_compressors/base.d.ts +40 -0
  29. package/dist/http_compressors/base.js +9 -0
  30. package/dist/http_compressors/brotli.d.ts +33 -0
  31. package/dist/http_compressors/brotli.js +39 -0
  32. package/dist/http_compressors/gzip.d.ts +33 -0
  33. package/dist/http_compressors/gzip.js +39 -0
  34. package/dist/http_compressors/index.d.ts +8 -0
  35. package/dist/http_compressors/index.js +3 -0
  36. package/dist/http_compressors/resolve.d.ts +24 -0
  37. package/dist/http_compressors/resolve.js +30 -0
  38. package/dist/http_compressors/zstd.d.ts +34 -0
  39. package/dist/http_compressors/zstd.js +43 -0
  40. package/dist/index.d.ts +38 -32
  41. package/dist/index.js +36 -36
  42. package/dist/invalid_response_body_error.d.ts +14 -0
  43. package/dist/invalid_response_body_error.js +18 -0
  44. package/dist/lazy_schema.d.ts +8 -0
  45. package/dist/lazy_schema.js +11 -0
  46. package/dist/models.d.ts +196 -278
  47. package/dist/models.js +14 -15
  48. package/dist/resource_clients/actor.d.ts +115 -45
  49. package/dist/resource_clients/actor.js +187 -116
  50. package/dist/resource_clients/actor_collection.d.ts +21 -17
  51. package/dist/resource_clients/actor_collection.js +26 -21
  52. package/dist/resource_clients/actor_env_var.d.ts +13 -6
  53. package/dist/resource_clients/actor_env_var.js +21 -14
  54. package/dist/resource_clients/actor_env_var_collection.d.ts +18 -22
  55. package/dist/resource_clients/actor_env_var_collection.js +23 -20
  56. package/dist/resource_clients/actor_server.d.ts +149 -0
  57. package/dist/resource_clients/actor_server.js +199 -0
  58. package/dist/resource_clients/actor_version.d.ts +30 -10
  59. package/dist/resource_clients/actor_version.js +29 -23
  60. package/dist/resource_clients/actor_version_collection.d.ts +20 -21
  61. package/dist/resource_clients/actor_version_collection.js +25 -20
  62. package/dist/resource_clients/build.d.ts +24 -11
  63. package/dist/resource_clients/build.js +43 -26
  64. package/dist/resource_clients/build_collection.d.ts +10 -8
  65. package/dist/resource_clients/build_collection.js +13 -13
  66. package/dist/resource_clients/dataset.d.ts +87 -40
  67. package/dist/resource_clients/dataset.js +159 -175
  68. package/dist/resource_clients/dataset_collection.d.ts +13 -9
  69. package/dist/resource_clients/dataset_collection.js +29 -21
  70. package/dist/resource_clients/key_value_store.d.ts +110 -28
  71. package/dist/resource_clients/key_value_store.js +177 -99
  72. package/dist/resource_clients/key_value_store_collection.d.ts +13 -9
  73. package/dist/resource_clients/key_value_store_collection.js +29 -21
  74. package/dist/resource_clients/log.d.ts +42 -23
  75. package/dist/resource_clients/log.js +156 -85
  76. package/dist/resource_clients/request_queue.d.ts +77 -38
  77. package/dist/resource_clients/request_queue.js +251 -172
  78. package/dist/resource_clients/request_queue_collection.d.ts +12 -8
  79. package/dist/resource_clients/request_queue_collection.js +23 -20
  80. package/dist/resource_clients/run.d.ts +134 -34
  81. package/dist/resource_clients/run.js +225 -84
  82. package/dist/resource_clients/run_collection.d.ts +8 -6
  83. package/dist/resource_clients/run_collection.js +18 -18
  84. package/dist/resource_clients/schedule.d.ts +20 -11
  85. package/dist/resource_clients/schedule.js +36 -30
  86. package/dist/resource_clients/schedule_collection.d.ts +10 -6
  87. package/dist/resource_clients/schedule_collection.js +20 -17
  88. package/dist/resource_clients/store_collection.d.ts +9 -7
  89. package/dist/resource_clients/store_collection.js +18 -18
  90. package/dist/resource_clients/task.d.ts +44 -21
  91. package/dist/resource_clients/task.js +116 -86
  92. package/dist/resource_clients/task_collection.d.ts +13 -9
  93. package/dist/resource_clients/task_collection.js +19 -16
  94. package/dist/resource_clients/user.d.ts +22 -13
  95. package/dist/resource_clients/user.js +46 -47
  96. package/dist/resource_clients/webhook.d.ts +21 -12
  97. package/dist/resource_clients/webhook.js +35 -30
  98. package/dist/resource_clients/webhook_collection.d.ts +11 -7
  99. package/dist/resource_clients/webhook_collection.js +20 -17
  100. package/dist/resource_clients/webhook_dispatch.d.ts +9 -6
  101. package/dist/resource_clients/webhook_dispatch.js +11 -10
  102. package/dist/resource_clients/webhook_dispatch_collection.d.ts +7 -5
  103. package/dist/resource_clients/webhook_dispatch_collection.js +13 -13
  104. package/dist/response_validation_error.d.ts +27 -0
  105. package/dist/response_validation_error.js +38 -0
  106. package/dist/runtime/node.d.ts +6 -0
  107. package/dist/runtime/node.js +87 -0
  108. package/dist/runtime/types.d.ts +60 -0
  109. package/dist/runtime/types.js +1 -0
  110. package/dist/runtime/web.d.ts +5 -0
  111. package/dist/runtime/web.js +21 -0
  112. package/dist/schemas.d.ts +381 -0
  113. package/dist/schemas.js +37 -0
  114. package/dist/statistics.d.ts +1 -6
  115. package/dist/statistics.js +7 -11
  116. package/dist/timeouts.d.ts +84 -0
  117. package/dist/timeouts.js +37 -0
  118. package/dist/timezones.d.ts +1 -1
  119. package/dist/timezones.js +1 -2
  120. package/dist/utils.d.ts +99 -70
  121. package/dist/utils.js +251 -229
  122. package/dist/wait_for_resources.d.ts +8 -0
  123. package/dist/wait_for_resources.js +39 -0
  124. package/package.json +48 -47
  125. package/dist/argument_validation_error.d.ts +0 -17
  126. package/dist/argument_validation_error.js +0 -157
  127. package/dist/http_client.d.ts +0 -88
  128. package/dist/http_client.js +0 -260
  129. package/dist/index.mjs +0 -42
  130. package/dist/interceptors.d.ts +0 -19
  131. package/dist/interceptors.js +0 -110
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserClient = exports.PlatformFeature = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- const utils_1 = require("../utils");
6
- var models_1 = require("../models");
7
- Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: function () { return models_1.PlatformFeature; } });
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
+ import { parseArgument, parseResponse } from '../utils.js';
5
+ export { PlatformFeature } from '../models.js';
8
6
  /**
9
7
  * Client for managing user account information.
10
8
  *
@@ -29,7 +27,7 @@ Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: funct
29
27
  *
30
28
  * @see https://docs.apify.com/platform/actors/running
31
29
  */
32
- class UserClient extends resource_client_1.ResourceClient {
30
+ export class UserClient extends ResourceClient {
33
31
  /**
34
32
  * @hidden
35
33
  */
@@ -45,73 +43,74 @@ class UserClient extends resource_client_1.ResourceClient {
45
43
  * Depending on whether ApifyClient was created with a token,
46
44
  * the method will either return public or private user data.
47
45
  *
48
- * @returns The user object.
46
+ * @param options - Request options
47
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
48
+ * @returns The user object, or `undefined` if it does not exist.
49
49
  * @see https://docs.apify.com/api/v2/user-get
50
50
  */
51
- async get() {
52
- return this._get();
51
+ async get(options = {}) {
52
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
53
+ return this.getResource(schemas.UserPrivateInfo(), {}, timeoutSecs, signal);
53
54
  }
54
55
  /**
55
56
  * Retrieves the user's monthly usage data.
56
57
  *
57
- * @returns The monthly usage object, or `undefined` if it does not exist.
58
+ * @param options - Request options
59
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
60
+ * @returns The monthly usage object.
58
61
  * @see https://docs.apify.com/api/v2/users-me-usage-monthly-get
59
62
  * @since Added in 2.9.2
60
63
  */
61
- async monthlyUsage() {
62
- const requestOpts = {
63
- url: this._url('usage/monthly'),
64
+ async monthlyUsage(options = {}) {
65
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
66
+ const response = await this.httpClient.call({
67
+ url: this.buildUrl('usage/monthly'),
64
68
  method: 'GET',
65
- params: this._params(),
66
- };
67
- try {
68
- const response = await this.httpClient.call(requestOpts);
69
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data),
70
- // Convert monthlyUsage.dailyServiceUsages[].date to Date (by default it's ignored by parseDateFields)
71
- /* shouldParseField = */ (key) => key === 'date'));
72
- }
73
- catch (err) {
74
- (0, utils_1.catchNotFoundOrThrow)(err);
75
- }
76
- return undefined;
69
+ params: this.buildParams(),
70
+ timeoutSecs,
71
+ signal,
72
+ });
73
+ return parseResponse(response, schemas.MonthlyUsage());
77
74
  }
78
75
  /**
79
76
  * Retrieves the user's account and usage limits.
80
77
  *
81
- * @returns The account and usage limits object, or `undefined` if it does not exist.
78
+ * @param options - Request options
79
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
80
+ * @returns The account and usage limits object.
82
81
  * @see https://docs.apify.com/api/v2/users-me-limits-get
83
82
  * @since Added in 2.9.2
84
83
  */
85
- async limits() {
86
- const requestOpts = {
87
- url: this._url('limits'),
84
+ async limits(options = {}) {
85
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
86
+ const response = await this.httpClient.call({
87
+ url: this.buildUrl('limits'),
88
88
  method: 'GET',
89
- params: this._params(),
90
- };
91
- try {
92
- const response = await this.httpClient.call(requestOpts);
93
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
94
- }
95
- catch (err) {
96
- (0, utils_1.catchNotFoundOrThrow)(err);
97
- }
98
- return undefined;
89
+ params: this.buildParams(),
90
+ timeoutSecs,
91
+ signal,
92
+ });
93
+ return parseResponse(response, schemas.AccountLimits());
99
94
  }
100
95
  /**
101
96
  * Updates the user's account and usage limits.
102
97
  *
103
- * @param options - The new limits to set.
98
+ * @param newLimits - The new limits to set.
99
+ * @param options - Request options
100
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
104
101
  * @see https://docs.apify.com/api/v2/users-me-limits-put
105
102
  * @since Added in 2.10.0
106
103
  */
107
- async updateLimits(options) {
104
+ async updateLimits(newLimits, options = {}) {
105
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
108
106
  const requestOpts = {
109
- url: this._url('limits'),
107
+ url: this.buildUrl('limits'),
110
108
  method: 'PUT',
111
- params: this._params(),
112
- data: options,
109
+ params: this.buildParams(),
110
+ data: newLimits,
111
+ timeoutSecs,
112
+ signal,
113
113
  };
114
114
  await this.httpClient.call(requestOpts);
115
115
  }
116
116
  }
117
- exports.UserClient = UserClient;
@@ -1,9 +1,10 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { Webhook, WebhookEventType } from '../models';
4
- import type { WebhookDispatch } from './webhook_dispatch';
5
- import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection';
6
- export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { WebhookResource, WebhookEventType } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
5
+ import type { WebhookDispatch } from './webhook_dispatch.js';
6
+ import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
7
+ export type { WebhookLastDispatch, WebhookResource, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookStats, } from '../models.js';
7
8
  /**
8
9
  * Client for managing a specific webhook.
9
10
  *
@@ -40,31 +41,39 @@ export declare class WebhookClient extends ResourceClient {
40
41
  /**
41
42
  * Retrieves the webhook.
42
43
  *
44
+ * @param options - Request options
45
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
43
46
  * @returns The webhook object, or `undefined` if it does not exist.
44
47
  * @see https://docs.apify.com/api/v2/webhook-get
45
48
  */
46
- get(): Promise<Webhook | undefined>;
49
+ get(options?: TimeoutOptions): Promise<WebhookResource | undefined>;
47
50
  /**
48
51
  * Updates the webhook with the specified fields.
49
52
  *
50
53
  * @param newFields - Fields to update.
54
+ * @param options - Request options
55
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
51
56
  * @returns The updated webhook object.
52
57
  * @see https://docs.apify.com/api/v2/webhook-put
53
58
  */
54
- update(newFields: WebhookUpdateData): Promise<Webhook>;
59
+ update(newFields: WebhookUpdateData, options?: TimeoutOptions): Promise<WebhookResource>;
55
60
  /**
56
61
  * Deletes the webhook.
57
62
  *
63
+ * @param options - Request options
64
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
65
  * @see https://docs.apify.com/api/v2/webhook-delete
59
66
  */
60
- delete(): Promise<void>;
67
+ delete(options?: TimeoutOptions): Promise<void>;
61
68
  /**
62
69
  * Tests the webhook by dispatching a test event.
63
70
  *
64
- * @returns The webhook dispatch object, or `undefined` if the test fails.
71
+ * @param options - Request options
72
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
73
+ * @returns The webhook dispatch object.
65
74
  * @see https://docs.apify.com/api/v2/webhook-test-post
66
75
  */
67
- test(): Promise<WebhookDispatch | undefined>;
76
+ test(options?: TimeoutOptions): Promise<WebhookDispatch>;
68
77
  /**
69
78
  * Returns a client for the dispatches of this webhook.
70
79
  *
@@ -79,6 +88,6 @@ export interface WebhookIdempotencyKey {
79
88
  /**
80
89
  * Data for updating a webhook.
81
90
  */
82
- export type WebhookUpdateData = Partial<Pick<Webhook, 'isAdHoc' | 'condition' | 'ignoreSslErrors' | 'doNotRetry' | 'requestUrl' | 'payloadTemplate' | 'shouldInterpolateStrings' | 'isApifyIntegration' | 'headersTemplate' | 'description'> & {
91
+ export type WebhookUpdateData = Partial<Pick<WebhookResource, 'isAdHoc' | 'condition' | 'ignoreSslErrors' | 'doNotRetry' | 'requestUrl' | 'payloadTemplate' | 'shouldInterpolateStrings' | 'isApifyIntegration' | 'headersTemplate' | 'description'> & {
83
92
  eventTypes: readonly WebhookEventType[];
84
93
  }> & WebhookIdempotencyKey;
@@ -1,9 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookClient = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- const utils_1 = require("../utils");
6
- const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
+ import { anyObjectSchema, parseArgument, parseResponse } from '../utils.js';
5
+ import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
7
6
  /**
8
7
  * Client for managing a specific webhook.
9
8
  *
@@ -32,7 +31,7 @@ const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
32
31
  *
33
32
  * @see https://docs.apify.com/platform/integrations/webhooks
34
33
  */
35
- class WebhookClient extends resource_client_1.ResourceClient {
34
+ export class WebhookClient extends ResourceClient {
36
35
  /**
37
36
  * @hidden
38
37
  */
@@ -45,51 +44,58 @@ class WebhookClient extends resource_client_1.ResourceClient {
45
44
  /**
46
45
  * Retrieves the webhook.
47
46
  *
47
+ * @param options - Request options
48
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
48
49
  * @returns The webhook object, or `undefined` if it does not exist.
49
50
  * @see https://docs.apify.com/api/v2/webhook-get
50
51
  */
51
- async get() {
52
- return this._get();
52
+ async get(options = {}) {
53
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
54
+ return this.getResource(schemas.WebhookResource(), {}, timeoutSecs, signal);
53
55
  }
54
56
  /**
55
57
  * Updates the webhook with the specified fields.
56
58
  *
57
59
  * @param newFields - Fields to update.
60
+ * @param options - Request options
61
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
62
  * @returns The updated webhook object.
59
63
  * @see https://docs.apify.com/api/v2/webhook-put
60
64
  */
61
- async update(newFields) {
62
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
63
- return this._update(newFields);
65
+ async update(newFields, options = {}) {
66
+ parseArgument(newFields, anyObjectSchema);
67
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
68
+ return this.updateResource(schemas.WebhookResource(), newFields, timeoutSecs, signal);
64
69
  }
65
70
  /**
66
71
  * Deletes the webhook.
67
72
  *
73
+ * @param options - Request options
74
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
68
75
  * @see https://docs.apify.com/api/v2/webhook-delete
69
76
  */
70
- async delete() {
71
- return this._delete();
77
+ async delete(options = {}) {
78
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
79
+ return this.deleteResource(timeoutSecs, signal);
72
80
  }
73
81
  /**
74
82
  * Tests the webhook by dispatching a test event.
75
83
  *
76
- * @returns The webhook dispatch object, or `undefined` if the test fails.
84
+ * @param options - Request options
85
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
86
+ * @returns The webhook dispatch object.
77
87
  * @see https://docs.apify.com/api/v2/webhook-test-post
78
88
  */
79
- async test() {
80
- const request = {
81
- url: this._url('test'),
89
+ async test(options = {}) {
90
+ const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
91
+ const response = await this.httpClient.call({
92
+ url: this.buildUrl('test'),
82
93
  method: 'POST',
83
- params: this._params(),
84
- };
85
- try {
86
- const response = await this.httpClient.call(request);
87
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
88
- }
89
- catch (err) {
90
- (0, utils_1.catchNotFoundOrThrow)(err);
91
- }
92
- return undefined;
94
+ params: this.buildParams(),
95
+ timeoutSecs,
96
+ signal,
97
+ });
98
+ return parseResponse(response, schemas.WebhookDispatch());
93
99
  }
94
100
  /**
95
101
  * Returns a client for the dispatches of this webhook.
@@ -98,9 +104,8 @@ class WebhookClient extends resource_client_1.ResourceClient {
98
104
  * @see https://docs.apify.com/api/v2/webhook-webhook-dispatches-get
99
105
  */
100
106
  dispatches() {
101
- return new webhook_dispatch_collection_1.WebhookDispatchCollectionClient(this._subResourceOptions({
107
+ return new WebhookDispatchCollectionClient(this.subResourceOptions({
102
108
  resourcePath: 'dispatches',
103
109
  }));
104
110
  }
105
111
  }
106
- exports.WebhookClient = WebhookClient;
@@ -1,7 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceCollectionClient } from '../base/resource_collection_client';
3
- import type { PaginatedIterator, PaginationOptions } from '../utils';
4
- import type { Webhook, WebhookUpdateData } from './webhook';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { PaginatedIterator, PaginationOptions } from '../utils.js';
5
+ import type { WebhookResource, WebhookUpdateData } from './webhook.js';
5
6
  /**
6
7
  * Client for managing the collection of Webhooks.
7
8
  *
@@ -47,19 +48,22 @@ export declare class WebhookCollectionClient extends ResourceCollectionClient {
47
48
  * ```
48
49
  *
49
50
  * @param options - Pagination and sorting options.
51
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
50
52
  * @returns A paginated iterator of webhooks.
51
53
  * @see https://docs.apify.com/api/v2/webhooks-get
52
54
  */
53
- list(options?: WebhookCollectionListOptions): PaginatedIterator<Omit<Webhook, 'payloadTemplate' | 'headersTemplate'>>;
55
+ list(options?: WebhookCollectionListOptions): PaginatedIterator<Omit<WebhookResource, 'payloadTemplate' | 'headersTemplate'>>;
54
56
  /**
55
57
  * Creates a new webhook.
56
58
  *
57
59
  * @param webhook - The webhook data.
60
+ * @param options - Request options
61
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
62
  * @returns The created webhook object.
59
63
  * @see https://docs.apify.com/api/v2/webhooks-post
60
64
  */
61
- create(webhook?: WebhookUpdateData): Promise<Webhook>;
65
+ create(webhook?: WebhookUpdateData, options?: TimeoutOptions): Promise<WebhookResource>;
62
66
  }
63
- export interface WebhookCollectionListOptions extends PaginationOptions {
67
+ export interface WebhookCollectionListOptions extends PaginationOptions, TimeoutOptions {
64
68
  desc?: boolean;
65
69
  }
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookCollectionClient = void 0;
4
- const zod_1 = require("zod");
5
- const resource_collection_client_1 = require("../base/resource_collection_client");
6
- const utils_1 = require("../utils");
7
- const listOptionsSchema = zod_1.z.strictObject({
8
- ...utils_1.paginationOptionsShape,
9
- desc: zod_1.z.boolean().optional(),
1
+ import { z } from 'zod';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
5
+ import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
6
+ const listOptionsSchema = z.strictObject({
7
+ ...paginationOptionsShape,
8
+ desc: z.boolean().optional(),
9
+ ...timeoutOptionsShape,
10
10
  });
11
- const webhookCreateSchema = utils_1.anyObjectSchema.optional();
11
+ const webhookCreateSchema = anyObjectSchema.optional();
12
12
  /**
13
13
  * Client for managing the collection of Webhooks.
14
14
  *
@@ -32,7 +32,7 @@ const webhookCreateSchema = utils_1.anyObjectSchema.optional();
32
32
  *
33
33
  * @see https://docs.apify.com/platform/integrations/webhooks
34
34
  */
35
- class WebhookCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
35
+ export class WebhookCollectionClient extends ResourceCollectionClient {
36
36
  /**
37
37
  * @hidden
38
38
  */
@@ -59,23 +59,26 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
59
59
  * ```
60
60
  *
61
61
  * @param options - Pagination and sorting options.
62
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
62
63
  * @returns A paginated iterator of webhooks.
63
64
  * @see https://docs.apify.com/api/v2/webhooks-get
64
65
  */
65
66
  list(options = {}) {
66
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookCollectionListOptions');
67
- return this._listPaginated(parsed);
67
+ const parsed = parseArgument(options, listOptionsSchema, 'WebhookCollectionListOptions');
68
+ return this.listResourcesPaginated(schemas.ListOfWebhooks(), parsed, 'medium');
68
69
  }
69
70
  /**
70
71
  * Creates a new webhook.
71
72
  *
72
73
  * @param webhook - The webhook data.
74
+ * @param options - Request options
75
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
73
76
  * @returns The created webhook object.
74
77
  * @see https://docs.apify.com/api/v2/webhooks-post
75
78
  */
76
- async create(webhook) {
77
- (0, utils_1.parseArgument)(webhook, webhookCreateSchema);
78
- return this._create(webhook);
79
+ async create(webhook, options = {}) {
80
+ parseArgument(webhook, webhookCreateSchema);
81
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
82
+ return this.createResource(schemas.WebhookResource(), webhook, timeoutSecs, signal);
79
83
  }
80
84
  }
81
- exports.WebhookCollectionClient = WebhookCollectionClient;
@@ -1,8 +1,9 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { WebhookDispatch } from '../models';
4
- export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models';
5
- export { WebhookDispatchStatus } from '../models';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { WebhookDispatch } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
5
+ export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models.js';
6
+ export { WebhookDispatchStatus } from '../models.js';
6
7
  /**
7
8
  * Client for managing a specific webhook dispatch.
8
9
  *
@@ -29,8 +30,10 @@ export declare class WebhookDispatchClient extends ResourceClient {
29
30
  /**
30
31
  * Retrieves the webhook dispatch.
31
32
  *
33
+ * @param options - Request options
34
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
32
35
  * @returns The webhook dispatch object, or `undefined` if it does not exist.
33
36
  * @see https://docs.apify.com/api/v2/webhook-dispatch-get
34
37
  */
35
- get(): Promise<WebhookDispatch | undefined>;
38
+ get(options?: TimeoutOptions): Promise<WebhookDispatch | undefined>;
36
39
  }
@@ -1,9 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookDispatchClient = exports.WebhookDispatchStatus = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- var models_1 = require("../models");
6
- Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get: function () { return models_1.WebhookDispatchStatus; } });
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
+ import { parseArgument } from '../utils.js';
5
+ export { WebhookDispatchStatus } from '../models.js';
7
6
  /**
8
7
  * Client for managing a specific webhook dispatch.
9
8
  *
@@ -22,7 +21,7 @@ Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get:
22
21
  *
23
22
  * @see https://docs.apify.com/platform/integrations/webhooks
24
23
  */
25
- class WebhookDispatchClient extends resource_client_1.ResourceClient {
24
+ export class WebhookDispatchClient extends ResourceClient {
26
25
  /**
27
26
  * @hidden
28
27
  */
@@ -35,11 +34,13 @@ class WebhookDispatchClient extends resource_client_1.ResourceClient {
35
34
  /**
36
35
  * Retrieves the webhook dispatch.
37
36
  *
37
+ * @param options - Request options
38
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
38
39
  * @returns The webhook dispatch object, or `undefined` if it does not exist.
39
40
  * @see https://docs.apify.com/api/v2/webhook-dispatch-get
40
41
  */
41
- async get() {
42
- return this._get();
42
+ async get(options = {}) {
43
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
44
+ return this.getResource(schemas.WebhookDispatch(), {}, timeoutSecs, signal);
43
45
  }
44
46
  }
45
- exports.WebhookDispatchClient = WebhookDispatchClient;
@@ -1,7 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceCollectionClient } from '../base/resource_collection_client';
3
- import type { PaginatedIterator, PaginationOptions } from '../utils';
4
- import type { WebhookDispatch } from './webhook_dispatch';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { PaginatedIterator, PaginationOptions } from '../utils.js';
5
+ import type { WebhookDispatch } from './webhook_dispatch.js';
5
6
  /**
6
7
  * Client for managing the collection of webhook dispatches.
7
8
  *
@@ -42,11 +43,12 @@ export declare class WebhookDispatchCollectionClient extends ResourceCollectionC
42
43
  * ```
43
44
  *
44
45
  * @param options - Pagination and sorting options.
46
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
45
47
  * @returns A paginated iterator of webhook dispatches.
46
48
  * @see https://docs.apify.com/api/v2/webhook-dispatches-get
47
49
  */
48
50
  list(options?: WebhookDispatchCollectionListOptions): PaginatedIterator<WebhookDispatch>;
49
51
  }
50
- export interface WebhookDispatchCollectionListOptions extends PaginationOptions {
52
+ export interface WebhookDispatchCollectionListOptions extends PaginationOptions, TimeoutOptions {
51
53
  desc?: boolean;
52
54
  }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookDispatchCollectionClient = void 0;
4
- const zod_1 = require("zod");
5
- const resource_collection_client_1 = require("../base/resource_collection_client");
6
- const utils_1 = require("../utils");
7
- const listOptionsSchema = zod_1.z.strictObject({
8
- ...utils_1.paginationOptionsShape,
9
- desc: zod_1.z.boolean().optional(),
1
+ import { z } from 'zod';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsShape } from '../timeouts.js';
5
+ import { paginationOptionsShape, parseArgument } from '../utils.js';
6
+ const listOptionsSchema = z.strictObject({
7
+ ...paginationOptionsShape,
8
+ desc: z.boolean().optional(),
9
+ ...timeoutOptionsShape,
10
10
  });
11
11
  /**
12
12
  * Client for managing the collection of webhook dispatches.
@@ -26,7 +26,7 @@ const listOptionsSchema = zod_1.z.strictObject({
26
26
  *
27
27
  * @see https://docs.apify.com/platform/integrations/webhooks
28
28
  */
29
- class WebhookDispatchCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
29
+ export class WebhookDispatchCollectionClient extends ResourceCollectionClient {
30
30
  /**
31
31
  * @hidden
32
32
  */
@@ -53,12 +53,12 @@ class WebhookDispatchCollectionClient extends resource_collection_client_1.Resou
53
53
  * ```
54
54
  *
55
55
  * @param options - Pagination and sorting options.
56
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
56
57
  * @returns A paginated iterator of webhook dispatches.
57
58
  * @see https://docs.apify.com/api/v2/webhook-dispatches-get
58
59
  */
59
60
  list(options = {}) {
60
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
61
- return this._listPaginated(parsed);
61
+ const parsed = parseArgument(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
62
+ return this.listResourcesPaginated(schemas.ListOfWebhookDispatches(), parsed, 'medium');
62
63
  }
63
64
  }
64
- exports.WebhookDispatchCollectionClient = WebhookDispatchCollectionClient;
@@ -0,0 +1,27 @@
1
+ import type { z } from 'zod';
2
+ import { ApifyClientError } from './apify_client_error.js';
3
+ /**
4
+ * Thrown when an API response does not match the schema the client expects for it.
5
+ *
6
+ * The schemas are generated from the Apify OpenAPI specification, so this error means the API returned
7
+ * something the specification does not describe -- a missing required field, a different type, a value
8
+ * outside the documented range. Unknown fields and unknown enum values are not errors: the schemas let
9
+ * both through, so the client keeps working when the API grows.
10
+ *
11
+ * The `message` names the request and every offending field with the value it received, and ends by asking for
12
+ * a bug report: the mismatch is in the API or its specification, not in the caller's code. The structured
13
+ * {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
14
+ * for programmatic inspection.
15
+ */
16
+ export declare class ResponseValidationError extends ApifyClientError {
17
+ /** Structured issues from the underlying schema check. */
18
+ readonly issues: z.ZodError['issues'];
19
+ /** HTTP method of the request whose response failed validation, upper-cased. */
20
+ readonly method: string;
21
+ /** URL of the request whose response failed validation, without its query string. */
22
+ readonly url: string;
23
+ constructor(error: z.ZodError, value: unknown, request: {
24
+ method: string;
25
+ url: string;
26
+ });
27
+ }
@@ -0,0 +1,38 @@
1
+ import { ArgumentValidationError } from '@apify/validations';
2
+ import { ApifyClientError } from './apify_client_error.js';
3
+ const REPORT_HINT = 'The API returned something its OpenAPI specification does not describe. ' +
4
+ 'Please report this at https://github.com/apify/apify-client-js/issues.';
5
+ /**
6
+ * Thrown when an API response does not match the schema the client expects for it.
7
+ *
8
+ * The schemas are generated from the Apify OpenAPI specification, so this error means the API returned
9
+ * something the specification does not describe -- a missing required field, a different type, a value
10
+ * outside the documented range. Unknown fields and unknown enum values are not errors: the schemas let
11
+ * both through, so the client keeps working when the API grows.
12
+ *
13
+ * The `message` names the request and every offending field with the value it received, and ends by asking for
14
+ * a bug report: the mismatch is in the API or its specification, not in the caller's code. The structured
15
+ * {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
16
+ * for programmatic inspection.
17
+ */
18
+ export class ResponseValidationError extends ApifyClientError {
19
+ /** Structured issues from the underlying schema check. */
20
+ issues;
21
+ /** HTTP method of the request whose response failed validation, upper-cased. */
22
+ method;
23
+ /** URL of the request whose response failed validation, without its query string. */
24
+ url;
25
+ constructor(error, value, request) {
26
+ const method = request.method.toUpperCase();
27
+ // `@apify/validations` keeps its zod error formatter private, so the issue lines come from the
28
+ // message of the error class it does export.
29
+ const details = new ArgumentValidationError(error, value).message;
30
+ super(`Response from ${method} ${request.url} does not match the API schema:\n${details}\n${REPORT_HINT}`, {
31
+ cause: error,
32
+ });
33
+ this.name = 'ResponseValidationError';
34
+ this.issues = error.issues;
35
+ this.method = method;
36
+ this.url = request.url;
37
+ }
38
+ }