apify-client 2.25.1-beta.8 → 3.0.0-beta.1

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 (60) hide show
  1. package/dist/apify_client.js +34 -30
  2. package/dist/argument_validation_error.d.ts +17 -0
  3. package/dist/argument_validation_error.js +157 -0
  4. package/dist/base/api_client.d.ts +2 -2
  5. package/dist/base/api_client.js +13 -10
  6. package/dist/bundle.js +66 -28147
  7. package/dist/bundle.js.LICENSE.txt +33 -0
  8. package/dist/bundle.js.map +1 -1
  9. package/dist/generated/api.d.ts +20522 -0
  10. package/dist/generated/api.js +6 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +1 -0
  13. package/dist/index.mjs +1 -0
  14. package/dist/models.d.ts +1072 -0
  15. package/dist/models.js +89 -0
  16. package/dist/resource_clients/actor.d.ts +2 -448
  17. package/dist/resource_clients/actor.js +60 -55
  18. package/dist/resource_clients/actor_collection.d.ts +2 -7
  19. package/dist/resource_clients/actor_collection.js +13 -11
  20. package/dist/resource_clients/actor_env_var.js +2 -3
  21. package/dist/resource_clients/actor_env_var_collection.js +3 -3
  22. package/dist/resource_clients/actor_version.d.ts +3 -40
  23. package/dist/resource_clients/actor_version.js +8 -12
  24. package/dist/resource_clients/actor_version_collection.js +3 -3
  25. package/dist/resource_clients/build.d.ts +2 -77
  26. package/dist/resource_clients/build.js +7 -10
  27. package/dist/resource_clients/build_collection.d.ts +2 -2
  28. package/dist/resource_clients/build_collection.js +8 -8
  29. package/dist/resource_clients/dataset.d.ts +8 -72
  30. package/dist/resource_clients/dataset.js +66 -57
  31. package/dist/resource_clients/dataset_collection.js +14 -12
  32. package/dist/resource_clients/key_value_store.d.ts +5 -73
  33. package/dist/resource_clients/key_value_store.js +69 -51
  34. package/dist/resource_clients/key_value_store_collection.js +14 -12
  35. package/dist/resource_clients/request_queue.d.ts +15 -174
  36. package/dist/resource_clients/request_queue.js +85 -91
  37. package/dist/resource_clients/request_queue_collection.js +12 -11
  38. package/dist/resource_clients/run.js +39 -40
  39. package/dist/resource_clients/run_collection.js +12 -11
  40. package/dist/resource_clients/schedule.d.ts +3 -81
  41. package/dist/resource_clients/schedule.js +4 -12
  42. package/dist/resource_clients/schedule_collection.js +10 -9
  43. package/dist/resource_clients/store_collection.d.ts +2 -30
  44. package/dist/resource_clients/store_collection.js +13 -13
  45. package/dist/resource_clients/task.d.ts +3 -73
  46. package/dist/resource_clients/task.js +36 -33
  47. package/dist/resource_clients/task_collection.d.ts +2 -1
  48. package/dist/resource_clients/task_collection.js +9 -9
  49. package/dist/resource_clients/user.d.ts +3 -179
  50. package/dist/resource_clients/user.js +3 -11
  51. package/dist/resource_clients/webhook.d.ts +2 -61
  52. package/dist/resource_clients/webhook.js +1 -3
  53. package/dist/resource_clients/webhook_collection.js +10 -9
  54. package/dist/resource_clients/webhook_dispatch.d.ts +3 -36
  55. package/dist/resource_clients/webhook_dispatch.js +3 -7
  56. package/dist/resource_clients/webhook_dispatch_collection.js +8 -8
  57. package/dist/statistics.js +4 -3
  58. package/dist/utils.d.ts +51 -5
  59. package/dist/utils.js +103 -15
  60. package/package.json +22 -7
@@ -1,5 +1,8 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client';
2
2
  import { ResourceClient } from '../base/resource_client';
3
+ import type { AccountAndUsageLimits, MonthlyUsage, User } from '../models';
4
+ export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models';
5
+ export { PlatformFeature } from '../models';
3
6
  /**
4
7
  * Client for managing user account information.
5
8
  *
@@ -64,169 +67,6 @@ export declare class UserClient extends ResourceClient {
64
67
  */
65
68
  updateLimits(options: LimitsUpdateOptions): Promise<void>;
66
69
  }
67
- export interface User {
68
- username: string;
69
- profile: {
70
- bio?: string;
71
- name?: string;
72
- pictureUrl?: string;
73
- githubUsername?: string;
74
- websiteUrl?: string;
75
- twitterUsername?: string;
76
- };
77
- id?: string;
78
- email?: string;
79
- proxy?: UserProxy;
80
- plan?: UserPlan;
81
- /**
82
- * @since Added in 2.12.5
83
- */
84
- effectivePlatformFeatures?: EffectivePlatformFeatures;
85
- /**
86
- * @since Added in 2.12.5
87
- */
88
- createdAt?: Date;
89
- /**
90
- * @since Added in 2.12.5
91
- */
92
- isPaying?: boolean;
93
- }
94
- export interface UserProxy {
95
- password: string;
96
- groups: ProxyGroup[];
97
- }
98
- export interface ProxyGroup {
99
- name: string;
100
- description: string;
101
- availableCount: number;
102
- }
103
- export interface UserPlan {
104
- id: string;
105
- description: string;
106
- isEnabled: boolean;
107
- monthlyBasePriceUsd: number;
108
- monthlyUsageCreditsUsd: number;
109
- usageDiscountPercent: number;
110
- enabledPlatformFeatures: PlatformFeature[];
111
- maxMonthlyUsageUsd: number;
112
- maxActorMemoryGbytes: number;
113
- maxMonthlyActorComputeUnits: number;
114
- maxMonthlyResidentialProxyGbytes: number;
115
- maxMonthlyProxySerps: number;
116
- maxMonthlyExternalDataTransferGbytes: number;
117
- maxActorCount: number;
118
- maxActorTaskCount: number;
119
- dataRetentionDays: number;
120
- availableProxyGroups: Record<string, number>;
121
- teamAccountSeatCount: number;
122
- supportLevel: string;
123
- availableAddOns: unknown[];
124
- }
125
- export declare enum PlatformFeature {
126
- Actors = "ACTORS",
127
- Storage = "STORAGE",
128
- ProxySERPS = "PROXY_SERPS",
129
- Scheduler = "SCHEDULER",
130
- Webhooks = "WEBHOOKS",
131
- Proxy = "PROXY",
132
- ProxyExternalAccess = "PROXY_EXTERNAL_ACCESS"
133
- }
134
- interface EffectivePlatformFeature {
135
- isEnabled: boolean;
136
- disabledReason: string | null;
137
- disabledReasonType: string | null;
138
- isTrial: boolean;
139
- trialExpirationAt: Date | null;
140
- }
141
- interface EffectivePlatformFeatures {
142
- ACTORS: EffectivePlatformFeature;
143
- STORAGE: EffectivePlatformFeature;
144
- SCHEDULER: EffectivePlatformFeature;
145
- PROXY: EffectivePlatformFeature;
146
- PROXY_EXTERNAL_ACCESS: EffectivePlatformFeature;
147
- PROXY_RESIDENTIAL: EffectivePlatformFeature;
148
- PROXY_SERPS: EffectivePlatformFeature;
149
- WEBHOOKS: EffectivePlatformFeature;
150
- ACTORS_PUBLIC_ALL: EffectivePlatformFeature;
151
- ACTORS_PUBLIC_DEVELOPER: EffectivePlatformFeature;
152
- }
153
- /**
154
- * @since Added in 2.9.2
155
- */
156
- export interface MonthlyUsage {
157
- usageCycle: UsageCycle;
158
- monthlyServiceUsage: {
159
- [key: string]: MonthlyServiceUsageData;
160
- };
161
- dailyServiceUsages: DailyServiceUsage[];
162
- totalUsageCreditsUsdBeforeVolumeDiscount: number;
163
- totalUsageCreditsUsdAfterVolumeDiscount: number;
164
- }
165
- /**
166
- * @since Added in 2.9.2
167
- */
168
- export interface UsageCycle {
169
- startAt: Date;
170
- endAt: Date;
171
- }
172
- /** Monthly usage of a single service */
173
- interface MonthlyServiceUsageData {
174
- quantity: number;
175
- baseAmountUsd: number;
176
- baseUnitPriceUsd: number;
177
- amountAfterVolumeDiscountUsd: number;
178
- priceTiers: PriceTier[];
179
- }
180
- interface PriceTier {
181
- quantityAbove: number;
182
- discountPercent: number;
183
- tierQuantity: number;
184
- unitPriceUsd: number;
185
- priceUsd: number;
186
- }
187
- interface DailyServiceUsage {
188
- date: Date;
189
- serviceUsage: {
190
- [key: string]: DailyServiceUsageData;
191
- };
192
- totalUsageCreditsUsd: number;
193
- }
194
- /** Daily usage of a single service */
195
- interface DailyServiceUsageData {
196
- quantity: number;
197
- baseAmountUsd: number;
198
- }
199
- /**
200
- * @since Added in 2.9.2
201
- */
202
- export interface AccountAndUsageLimits {
203
- monthlyUsageCycle: MonthlyUsageCycle;
204
- limits: Limits;
205
- current: Current;
206
- }
207
- /**
208
- * @since Added in 2.9.2
209
- */
210
- export interface MonthlyUsageCycle {
211
- startAt: Date;
212
- endAt: Date;
213
- }
214
- /**
215
- * @since Added in 2.9.2
216
- */
217
- export interface Limits {
218
- maxMonthlyUsageUsd: number;
219
- maxMonthlyActorComputeUnits: number;
220
- maxMonthlyExternalDataTransferGbytes: number;
221
- maxMonthlyProxySerps: number;
222
- maxMonthlyResidentialProxyGbytes: number;
223
- maxActorMemoryGbytes: number;
224
- maxActorCount: number;
225
- maxActorTaskCount: number;
226
- maxConcurrentActorJobs: number;
227
- maxTeamAccountSeatCount: number;
228
- dataRetentionDays: number;
229
- }
230
70
  /**
231
71
  * @since Added in 2.10.0
232
72
  */
@@ -235,19 +75,3 @@ export type LimitsUpdateOptions = {
235
75
  } | {
236
76
  dataRetentionDays: number;
237
77
  };
238
- /**
239
- * @since Added in 2.9.2
240
- */
241
- export interface Current {
242
- monthlyUsageUsd: number;
243
- monthlyActorComputeUnits: number;
244
- monthlyExternalDataTransferGbytes: number;
245
- monthlyProxySerps: number;
246
- monthlyResidentialProxyGbytes: number;
247
- actorMemoryGbytes: number;
248
- actorCount: number;
249
- actorTaskCount: number;
250
- activeActorJobCount: number;
251
- teamAccountSeatCount: number;
252
- }
253
- export {};
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformFeature = exports.UserClient = void 0;
3
+ exports.UserClient = exports.PlatformFeature = void 0;
4
4
  const resource_client_1 = require("../base/resource_client");
5
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; } });
6
8
  /**
7
9
  * Client for managing user account information.
8
10
  *
@@ -113,13 +115,3 @@ class UserClient extends resource_client_1.ResourceClient {
113
115
  }
114
116
  }
115
117
  exports.UserClient = UserClient;
116
- var PlatformFeature;
117
- (function (PlatformFeature) {
118
- PlatformFeature["Actors"] = "ACTORS";
119
- PlatformFeature["Storage"] = "STORAGE";
120
- PlatformFeature["ProxySERPS"] = "PROXY_SERPS";
121
- PlatformFeature["Scheduler"] = "SCHEDULER";
122
- PlatformFeature["Webhooks"] = "WEBHOOKS";
123
- PlatformFeature["Proxy"] = "PROXY";
124
- PlatformFeature["ProxyExternalAccess"] = "PROXY_EXTERNAL_ACCESS";
125
- })(PlatformFeature || (exports.PlatformFeature = PlatformFeature = {}));
@@ -1,8 +1,9 @@
1
- import type { WEBHOOK_EVENT_TYPES } from '@apify/consts';
2
1
  import type { ApiClientSubResourceOptions } from '../base/api_client';
3
2
  import { ResourceClient } from '../base/resource_client';
3
+ import type { Webhook, WebhookEventType } from '../models';
4
4
  import type { WebhookDispatch } from './webhook_dispatch';
5
5
  import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection';
6
+ export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models';
6
7
  /**
7
8
  * Client for managing a specific webhook.
8
9
  *
@@ -72,43 +73,6 @@ export declare class WebhookClient extends ResourceClient {
72
73
  */
73
74
  dispatches(): WebhookDispatchCollectionClient;
74
75
  }
75
- /**
76
- * Represents a webhook for receiving notifications about Actor events.
77
- *
78
- * Webhooks send HTTP POST requests to specified URLs when certain events occur
79
- * (e.g., Actor run succeeds, fails, or times out).
80
- */
81
- export interface Webhook {
82
- id: string;
83
- userId: string;
84
- createdAt: Date;
85
- modifiedAt: Date;
86
- isAdHoc: boolean;
87
- eventTypes: WebhookEventType[];
88
- condition: WebhookCondition;
89
- ignoreSslErrors: boolean;
90
- doNotRetry: boolean;
91
- requestUrl: string;
92
- payloadTemplate: string;
93
- lastDispatch: string;
94
- stats: WebhookStats;
95
- /**
96
- * @since Added in 2.7.2
97
- */
98
- shouldInterpolateStrings: boolean;
99
- /**
100
- * @since Added in 2.9.4
101
- */
102
- isApifyIntegration?: boolean;
103
- /**
104
- * @since Added in 2.8.1
105
- */
106
- headersTemplate?: string;
107
- /**
108
- * @since Added in 2.8.1
109
- */
110
- description?: string;
111
- }
112
76
  export interface WebhookIdempotencyKey {
113
77
  idempotencyKey?: string;
114
78
  }
@@ -118,26 +82,3 @@ export interface WebhookIdempotencyKey {
118
82
  export type WebhookUpdateData = Partial<Pick<Webhook, 'isAdHoc' | 'condition' | 'ignoreSslErrors' | 'doNotRetry' | 'requestUrl' | 'payloadTemplate' | 'shouldInterpolateStrings' | 'isApifyIntegration' | 'headersTemplate' | 'description'> & {
119
83
  eventTypes: readonly WebhookEventType[];
120
84
  }> & WebhookIdempotencyKey;
121
- /**
122
- * Statistics about webhook usage.
123
- */
124
- export interface WebhookStats {
125
- totalDispatches: number;
126
- }
127
- /**
128
- * Event types that can trigger webhooks.
129
- */
130
- export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[keyof typeof WEBHOOK_EVENT_TYPES];
131
- /**
132
- * Condition that determines when a webhook should be triggered.
133
- */
134
- export type WebhookCondition = WebhookAnyRunOfActorCondition | WebhookAnyRunOfActorTaskCondition | WebhookCertainRunCondition;
135
- export interface WebhookAnyRunOfActorCondition {
136
- actorId: string;
137
- }
138
- export interface WebhookAnyRunOfActorTaskCondition {
139
- actorTaskId: string;
140
- }
141
- export interface WebhookCertainRunCondition {
142
- actorRunId: string;
143
- }
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
4
  const resource_client_1 = require("../base/resource_client");
7
5
  const utils_1 = require("../utils");
8
6
  const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
@@ -61,7 +59,7 @@ class WebhookClient extends resource_client_1.ResourceClient {
61
59
  * @see https://docs.apify.com/api/v2/webhook-put
62
60
  */
63
61
  async update(newFields) {
64
- (0, ow_1.default)(newFields, ow_1.default.object);
62
+ (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
65
63
  return this._update(newFields);
66
64
  }
67
65
  /**
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
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(),
10
+ });
11
+ const webhookCreateSchema = utils_1.anyObjectSchema.optional();
7
12
  /**
8
13
  * Client for managing the collection of Webhooks.
9
14
  *
@@ -58,12 +63,8 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
58
63
  * @see https://docs.apify.com/api/v2/webhooks-get
59
64
  */
60
65
  list(options = {}) {
61
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
62
- limit: ow_1.default.optional.number.not.negative,
63
- offset: ow_1.default.optional.number.not.negative,
64
- desc: ow_1.default.optional.boolean,
65
- }));
66
- return this._listPaginated(options);
66
+ const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookCollectionListOptions');
67
+ return this._listPaginated(parsed);
67
68
  }
68
69
  /**
69
70
  * Creates a new webhook.
@@ -73,7 +74,7 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
73
74
  * @see https://docs.apify.com/api/v2/webhooks-post
74
75
  */
75
76
  async create(webhook) {
76
- (0, ow_1.default)(webhook, ow_1.default.optional.object);
77
+ (0, utils_1.parseArgument)(webhook, webhookCreateSchema);
77
78
  return this._create(webhook);
78
79
  }
79
80
  }
@@ -1,6 +1,8 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client';
2
2
  import { ResourceClient } from '../base/resource_client';
3
- import type { Webhook, WebhookEventType } from './webhook';
3
+ import type { WebhookDispatch } from '../models';
4
+ export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models';
5
+ export { WebhookDispatchStatus } from '../models';
4
6
  /**
5
7
  * Client for managing a specific webhook dispatch.
6
8
  *
@@ -32,38 +34,3 @@ export declare class WebhookDispatchClient extends ResourceClient {
32
34
  */
33
35
  get(): Promise<WebhookDispatch | undefined>;
34
36
  }
35
- export interface WebhookDispatch {
36
- id: string;
37
- userId: string;
38
- webhookId: string;
39
- createdAt: Date;
40
- status: WebhookDispatchStatus;
41
- eventType: WebhookEventType;
42
- calls: WebhookDispatchCall[];
43
- webhook: Pick<Webhook, 'requestUrl' | 'isAdHoc'>;
44
- /**
45
- * @since Added in 2.13.0
46
- */
47
- eventData: WebhookDispatchEventData | null;
48
- }
49
- export declare enum WebhookDispatchStatus {
50
- Active = "ACTIVE",
51
- Succeeded = "SUCCEEDED",
52
- Failed = "FAILED"
53
- }
54
- export interface WebhookDispatchCall {
55
- startedAt: Date;
56
- finishedAt: Date;
57
- errorMessage: string | null;
58
- responseStatus: number | null;
59
- responseBody: string | null;
60
- }
61
- /**
62
- * @since Added in 2.13.0
63
- */
64
- export interface WebhookDispatchEventData {
65
- actorRunId?: string;
66
- actorId?: string;
67
- actorTaskId?: string;
68
- actorBuildId?: string;
69
- }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookDispatchStatus = exports.WebhookDispatchClient = void 0;
3
+ exports.WebhookDispatchClient = exports.WebhookDispatchStatus = void 0;
4
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; } });
5
7
  /**
6
8
  * Client for managing a specific webhook dispatch.
7
9
  *
@@ -41,9 +43,3 @@ class WebhookDispatchClient extends resource_client_1.ResourceClient {
41
43
  }
42
44
  }
43
45
  exports.WebhookDispatchClient = WebhookDispatchClient;
44
- var WebhookDispatchStatus;
45
- (function (WebhookDispatchStatus) {
46
- WebhookDispatchStatus["Active"] = "ACTIVE";
47
- WebhookDispatchStatus["Succeeded"] = "SUCCEEDED";
48
- WebhookDispatchStatus["Failed"] = "FAILED";
49
- })(WebhookDispatchStatus || (exports.WebhookDispatchStatus = WebhookDispatchStatus = {}));
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookDispatchCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
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(),
10
+ });
7
11
  /**
8
12
  * Client for managing the collection of webhook dispatches.
9
13
  *
@@ -53,12 +57,8 @@ class WebhookDispatchCollectionClient extends resource_collection_client_1.Resou
53
57
  * @see https://docs.apify.com/api/v2/webhook-dispatches-get
54
58
  */
55
59
  list(options = {}) {
56
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
57
- limit: ow_1.default.optional.number.not.negative,
58
- offset: ow_1.default.optional.number.not.negative,
59
- desc: ow_1.default.optional.boolean,
60
- }));
61
- return this._listPaginated(options);
60
+ const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
61
+ return this._listPaginated(parsed);
62
62
  }
63
63
  }
64
64
  exports.WebhookDispatchCollectionClient = WebhookDispatchCollectionClient;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Statistics = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
5
+ const utils_1 = require("./utils");
6
+ const attemptSchema = zod_1.z.number().gt(0);
6
7
  class Statistics {
7
8
  /**
8
9
  * Number of Apify client function calls
@@ -18,7 +19,7 @@ class Statistics {
18
19
  */
19
20
  rateLimitErrors = [];
20
21
  addRateLimitError(attempt) {
21
- (0, ow_1.default)(attempt, ow_1.default.number.greaterThan(0));
22
+ (0, utils_1.parseArgument)(attempt, attemptSchema);
22
23
  // attempt is never 0,
23
24
  // but we don't want index 0 empty
24
25
  const index = attempt - 1;
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,30 @@
1
1
  import type { Readable } from 'node:stream';
2
2
  import type { JsonValue, TypedArray } from 'type-fest';
3
+ import { z } from 'zod';
3
4
  import type { ApifyApiError } from './apify_api_error';
4
5
  import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue';
5
6
  import type { WebhookUpdateData } from './resource_clients/webhook';
7
+ /**
8
+ * Parses `value` with `schema`, returning the typed result (with schema defaults applied).
9
+ * Throws {@link ArgumentValidationError} on failure.
10
+ *
11
+ * The optional `label` names the interface being validated and is appended to every error line
12
+ * (e.g. ``... at `memory` in `ActorStartOptions` ``).
13
+ * @internal
14
+ */
15
+ export declare function parseArgument<TValue, TSchema extends z.ZodType>(value: TValue, schema: TSchema, label?: string): TValue & z.output<TSchema>;
16
+ /**
17
+ * Accepts any non-null, non-array object as a predicate for `z.custom()`.
18
+ * @internal
19
+ */
20
+ export declare function isNonArrayObject(value: unknown): value is Record<string, unknown>;
21
+ /**
22
+ * Matches any plain object, letting unknown keys through - for payloads whose shape the API
23
+ * validates itself. A `z.custom()` predicate rather than an object schema, so parsing returns
24
+ * the value itself instead of a copy.
25
+ * @internal
26
+ */
27
+ export declare const anyObjectSchema: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
6
28
  /**
7
29
  * Generic interface for objects that may contain a data property.
8
30
  *
@@ -40,7 +62,7 @@ export declare function parseDateFields(input: JsonValue, shouldParseField?: ((k
40
62
  /**
41
63
  * Helper function that converts array of webhooks to base64 string
42
64
  */
43
- export declare function stringifyWebhooksToBase64(webhooks: WebhookUpdateData[]): string | undefined;
65
+ export declare function stringifyWebhooksToBase64(webhooks?: readonly WebhookUpdateData[]): string | undefined;
44
66
  export interface CompressedValue {
45
67
  data: Buffer;
46
68
  encoding: 'br' | 'gzip';
@@ -103,6 +125,16 @@ export interface PaginationOptions {
103
125
  * */
104
126
  chunkSize?: number;
105
127
  }
128
+ /**
129
+ * Schema shape of {@link PaginationOptions}, to spread into every paginating client's list schema. One
130
+ * copy stops it drifting from the interface.
131
+ * @internal
132
+ */
133
+ export declare const paginationOptionsShape: {
134
+ limit: z.ZodOptional<z.ZodNumber>;
135
+ offset: z.ZodOptional<z.ZodNumber>;
136
+ chunkSize: z.ZodOptional<z.ZodNumber>;
137
+ };
106
138
  /**
107
139
  * Standard paginated response format.
108
140
  *
@@ -160,8 +192,22 @@ export type DistributiveOptional<T, K extends keyof T> = T extends any ? Omit<T,
160
192
  * Adds query parameters to a given URL based on the provided options object.
161
193
  */
162
194
  export declare function applyQueryParamsToUrl(url: URL, options?: Record<string, string | number | boolean | string[] | undefined>): URL;
163
- export declare const mutuallyExclusive: <T, K extends keyof T>(...keys: K[]) => (value: T) => {
164
- validator: boolean;
165
- message: string;
166
- };
195
+ /**
196
+ * Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
197
+ * is present. Pass the options interface as `T`, so that a misspelled key is a type error.
198
+ * @internal
199
+ */
200
+ export declare const mutuallyExclusive: <T extends object>(...keys: (keyof T & string)[]) => [(value: T) => boolean, string];
201
+ /**
202
+ * Percent-encodes a caller-supplied URL path segment so it cannot restructure the request path.
203
+ *
204
+ * Empty strings and dot segments are rejected instead of encoded, because URL parsers resolve
205
+ * dot segments after decoding - `records/%2E%2E` collapses to the parent endpoint just like `records/..`.
206
+ */
207
+ export declare function toPathSegment(value: string): string;
208
+ /**
209
+ * Builds a URL path from segments. A plain string is used as-is, so literal paths such as
210
+ * `requests/batch` keep their separators; an array has each of its segments encoded individually.
211
+ */
212
+ export declare function toPath(path: string | string[]): string;
167
213
  export {};