apify-client 3.0.0-beta.16 → 3.0.0-beta.18

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.
@@ -21,7 +21,7 @@ export const ActorStats = lazySchema(() => z.looseObject({
21
21
  totalUsers30Days: z.int().optional(),
22
22
  totalUsers90Days: z.int().optional(),
23
23
  totalMetamorphs: z.int().optional(),
24
- lastRunStartedAt: z.date().optional(),
24
+ lastRunStartedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).optional(),
25
25
  actorReviewCount: z.int().optional(),
26
26
  actorReviewRating: z.number().optional(),
27
27
  bookmarkCount: z.int().optional(),
@@ -35,8 +35,8 @@ export const ActorStats = lazySchema(() => z.looseObject({
35
35
  }));
36
36
  export const ActorShort = lazySchema(() => z.looseObject({
37
37
  id: z.string(),
38
- createdAt: z.date(),
39
- modifiedAt: z.date(),
38
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
39
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
40
40
  name: z.string(),
41
41
  username: z.string(),
42
42
  title: z.string().optional(),
@@ -132,10 +132,10 @@ export const CreateActorRequest = lazySchema(() => z.looseObject({
132
132
  }));
133
133
  export const CommonActorPricingInfo = lazySchema(() => z.looseObject({
134
134
  apifyMarginPercentage: z.number(),
135
- createdAt: z.date(),
136
- startedAt: z.date(),
137
- notifiedAboutFutureChangeAt: z.date().nullable().optional(),
138
- notifiedAboutChangeAt: z.date().nullable().optional(),
135
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
136
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
137
+ notifiedAboutFutureChangeAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
138
+ notifiedAboutChangeAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
139
139
  reasonForChange: z.string().nullable().optional(),
140
140
  isPriceChangeNotificationSuppressed: z.boolean().optional(),
141
141
  forceContainsSignificantPriceChange: z.boolean().optional(),
@@ -197,7 +197,7 @@ export const TaggedBuildInfo = lazySchema(() => z.looseObject({
197
197
  buildId: z.string().optional(),
198
198
  buildNumber: z.string().regex(/^([0-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])(\.[1-9][0-9]{0,4})$/).nullable().optional(),
199
199
  buildNumberInt: z.int().optional(),
200
- finishedAt: z.date().nullable().optional(),
200
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
201
201
  }));
202
202
  /** A dictionary mapping build tag names (e.g., "latest", "beta") to their build information. */
203
203
  export const TaggedBuilds = lazySchema(() => z.record(z.string(), TaggedBuildInfo().nullable()));
@@ -212,8 +212,8 @@ export const Actor = lazySchema(() => z.looseObject({
212
212
  restartOnError: z.boolean().optional(),
213
213
  isPublic: z.boolean(),
214
214
  actorPermissionLevel: ActorPermissionLevel().optional(),
215
- createdAt: z.date(),
216
- modifiedAt: z.date(),
215
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
216
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
217
217
  stats: ActorStats(),
218
218
  versions: z.array(Version()),
219
219
  pricingInfos: z.array(ActorRunPricingInfo()).optional(),
@@ -305,16 +305,16 @@ export const WebhookCondition = lazySchema(() => z.looseObject({
305
305
  export const WebhookDispatchStatus = lazySchema(() => z.enum(["ACTIVE", "SUCCEEDED", "FAILED"]).or(z.string()));
306
306
  export const ExampleWebhookDispatch = lazySchema(() => z.looseObject({
307
307
  status: WebhookDispatchStatus(),
308
- finishedAt: z.date().nullable().optional(),
309
- removedAt: z.date().nullable().optional(),
308
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
309
+ removedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
310
310
  }));
311
311
  export const WebhookStats = lazySchema(() => z.looseObject({
312
312
  totalDispatches: z.int().optional(),
313
313
  }));
314
314
  export const WebhookShort = lazySchema(() => z.looseObject({
315
315
  id: z.string(),
316
- createdAt: z.date(),
317
- modifiedAt: z.date(),
316
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
317
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
318
318
  userId: z.string(),
319
319
  isAdHoc: z.boolean().nullable().optional(),
320
320
  isApifyIntegration: z.boolean().optional(),
@@ -348,8 +348,8 @@ export const BuildShort = lazySchema(() => z.looseObject({
348
348
  actId: z.string().optional(),
349
349
  userId: z.string().optional(),
350
350
  status: ActorJobStatus(),
351
- startedAt: z.date(),
352
- finishedAt: z.date().nullable().optional(),
351
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
352
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
353
353
  usageTotalUsd: z.number(),
354
354
  buildNumber: z.string().regex(/^([0-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])(\.[1-9][0-9]{0,4})$/),
355
355
  buildNumberInt: z.int().optional(),
@@ -400,8 +400,8 @@ export const Build = lazySchema(() => z.looseObject({
400
400
  id: z.string(),
401
401
  actId: z.string(),
402
402
  userId: z.string(),
403
- startedAt: z.date(),
404
- finishedAt: z.date().nullable().optional(),
403
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
404
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
405
405
  status: ActorJobStatus(),
406
406
  meta: BuildsMeta(),
407
407
  stats: BuildStats().nullable().optional(),
@@ -430,7 +430,7 @@ export const RunMeta = lazySchema(() => z.looseObject({
430
430
  clientIp: z.string().nullable().optional(),
431
431
  userAgent: z.string().nullable().optional(),
432
432
  scheduleId: z.string().nullable().optional(),
433
- scheduledAt: z.date().nullable().optional(),
433
+ scheduledAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
434
434
  }));
435
435
  export const RunShort = lazySchema(() => z.looseObject({
436
436
  id: z.string(),
@@ -438,8 +438,8 @@ export const RunShort = lazySchema(() => z.looseObject({
438
438
  userId: z.string().optional(),
439
439
  actorTaskId: z.string().nullable().optional(),
440
440
  status: ActorJobStatus(),
441
- startedAt: z.date(),
442
- finishedAt: z.date().nullable().optional(),
441
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
442
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
443
443
  buildId: z.string(),
444
444
  buildNumber: z.string().regex(/^([0-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])(\.[1-9][0-9]{0,4})$/).optional(),
445
445
  buildNumberInt: z.int().optional(),
@@ -530,7 +530,7 @@ export const RunUsageUsd = lazySchema(() => z.looseObject({
530
530
  }));
531
531
  /** Information about a metamorph event that occurred during the run. */
532
532
  export const Metamorph = lazySchema(() => z.looseObject({
533
- createdAt: z.date(),
533
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
534
534
  actorId: z.string(),
535
535
  buildId: z.string(),
536
536
  inputKey: z.string().nullable().optional(),
@@ -541,8 +541,8 @@ export const Run = lazySchema(() => z.looseObject({
541
541
  actId: z.string(),
542
542
  userId: z.string(),
543
543
  actorTaskId: z.string().nullable().optional(),
544
- startedAt: z.date(),
545
- finishedAt: z.date().nullable().optional(),
544
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
545
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
546
546
  status: ActorJobStatus(),
547
547
  statusMessage: z.string().nullable().optional(),
548
548
  isStatusMessageTerminal: z.boolean().nullable().optional(),
@@ -591,9 +591,9 @@ export const Dataset = lazySchema(() => z.looseObject({
591
591
  id: z.string(),
592
592
  name: z.string().nullable().optional(),
593
593
  userId: z.string(),
594
- createdAt: z.date(),
595
- modifiedAt: z.date(),
596
- accessedAt: z.date(),
594
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
595
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
596
+ accessedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
597
597
  itemCount: z.int().min(0),
598
598
  cleanItemCount: z.int().min(0),
599
599
  actId: z.string().nullable().optional(),
@@ -666,9 +666,9 @@ export const KeyValueStore = lazySchema(() => z.looseObject({
666
666
  name: z.string().nullable().optional(),
667
667
  userId: z.string().nullable().optional(),
668
668
  username: z.string().nullable().optional(),
669
- createdAt: z.date(),
670
- modifiedAt: z.date(),
671
- accessedAt: z.date(),
669
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
670
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
671
+ accessedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
672
672
  actId: z.string().nullable().optional(),
673
673
  actRunId: z.string().nullable().optional(),
674
674
  consoleUrl: z.url({ normalize: true }).optional(),
@@ -718,11 +718,11 @@ export const QueueId = lazySchema(() => z.string());
718
718
  /** The ID of the user who owns the request queue. */
719
719
  export const QueueUserId = lazySchema(() => z.string());
720
720
  /** The timestamp when the request queue was created. */
721
- export const QueueCreatedAt = lazySchema(() => z.date());
721
+ export const QueueCreatedAt = lazySchema(() => z.iso.datetime({ offset: true }).pipe(z.coerce.date()));
722
722
  /** The timestamp when the request queue was last modified. Modifications include adding, updating, or removing requests, as well as locking or unlocking requests in the request queue. */
723
- export const QueueModifiedAt = lazySchema(() => z.date());
723
+ export const QueueModifiedAt = lazySchema(() => z.iso.datetime({ offset: true }).pipe(z.coerce.date()));
724
724
  /** The timestamp when the request queue was last accessed. */
725
- export const QueueAccessedAt = lazySchema(() => z.date());
725
+ export const QueueAccessedAt = lazySchema(() => z.iso.datetime({ offset: true }).pipe(z.coerce.date()));
726
726
  /** The total number of requests in the request queue. */
727
727
  export const TotalRequestCount = lazySchema(() => z.int().min(0));
728
728
  /** The number of requests that have been handled. */
@@ -786,7 +786,7 @@ export const RequestBase = lazySchema(() => z.looseObject({
786
786
  userData: RequestUserData().optional(),
787
787
  noRetry: z.boolean().nullable().optional(),
788
788
  errorMessages: z.array(z.string()).nullable().optional(),
789
- handledAt: z.date().nullable().optional(),
789
+ handledAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
790
790
  }));
791
791
  /** A unique identifier assigned to the request. */
792
792
  export const RequestId = lazySchema(() => z.string());
@@ -895,7 +895,7 @@ export const UpdateRequestResponse = lazySchema(() => z.looseObject({
895
895
  data: RequestRegistration(),
896
896
  }));
897
897
  /** The timestamp when the lock on this request expires. */
898
- export const LockExpiresAt = lazySchema(() => z.date());
898
+ export const LockExpiresAt = lazySchema(() => z.iso.datetime({ offset: true }).pipe(z.coerce.date()));
899
899
  /** Information about a request lock. */
900
900
  export const RequestLockInfo = lazySchema(() => z.looseObject({
901
901
  lockExpiresAt: LockExpiresAt(),
@@ -959,8 +959,8 @@ export const TaskShort = lazySchema(() => z.looseObject({
959
959
  name: z.string(),
960
960
  username: z.string().nullable().optional(),
961
961
  actUsername: z.string().nullable().optional(),
962
- createdAt: z.date(),
963
- modifiedAt: z.date(),
962
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
963
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
964
964
  stats: TaskStats().nullable().optional(),
965
965
  }));
966
966
  export const ListOfTasks = lazySchema(() => PaginationResponse().extend({
@@ -988,7 +988,7 @@ export const TaskInput = lazySchema(() => z.record(z.string(), z.unknown()));
988
988
  * `publishedAt` is set and unpublished when it is `null`.
989
989
  */
990
990
  export const TaskPublicConfig = lazySchema(() => z.looseObject({
991
- publishedAt: z.date().nullable().optional(),
991
+ publishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
992
992
  seoTitle: z.string().max(60).nullable().optional(),
993
993
  seoDescription: z.string().max(160).nullable().optional(),
994
994
  inputSchemaFields: z.array(z.string()).nullable().optional(),
@@ -1010,9 +1010,9 @@ export const Task = lazySchema(() => z.looseObject({
1010
1010
  actId: z.string(),
1011
1011
  name: z.string(),
1012
1012
  username: z.string().nullable().optional(),
1013
- createdAt: z.date(),
1014
- modifiedAt: z.date(),
1015
- removedAt: z.date().nullable().optional(),
1013
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1014
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1015
+ removedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1016
1016
  stats: TaskStats().nullable().optional(),
1017
1017
  options: TaskOptions().nullable().optional(),
1018
1018
  input: z.union([TaskInput(), z.array(TaskInput())]).nullable().optional(),
@@ -1037,8 +1037,8 @@ export const UpdateTaskRequest = lazySchema(() => z.looseObject({
1037
1037
  }));
1038
1038
  export const Webhook = lazySchema(() => z.looseObject({
1039
1039
  id: z.string(),
1040
- createdAt: z.date(),
1041
- modifiedAt: z.date(),
1040
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1041
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1042
1042
  userId: z.string(),
1043
1043
  isAdHoc: z.boolean().nullable().optional(),
1044
1044
  shouldInterpolateStrings: z.boolean().nullable().optional(),
@@ -1075,9 +1075,9 @@ export const DatasetListItem = lazySchema(() => z.looseObject({
1075
1075
  id: z.string(),
1076
1076
  name: z.string(),
1077
1077
  userId: z.string(),
1078
- createdAt: z.date(),
1079
- modifiedAt: z.date(),
1080
- accessedAt: z.date(),
1078
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1079
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1080
+ accessedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1081
1081
  itemCount: z.int(),
1082
1082
  cleanItemCount: z.int(),
1083
1083
  actId: z.string().nullable().optional(),
@@ -1103,7 +1103,7 @@ export const RequestQueueShort = lazySchema(() => z.looseObject({
1103
1103
  createdAt: QueueCreatedAt(),
1104
1104
  modifiedAt: QueueModifiedAt(),
1105
1105
  accessedAt: QueueAccessedAt(),
1106
- expireAt: z.date().optional(),
1106
+ expireAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).optional(),
1107
1107
  totalRequestCount: TotalRequestCount(),
1108
1108
  handledRequestCount: HandledRequestCount(),
1109
1109
  pendingRequestCount: PendingRequestCount(),
@@ -1162,7 +1162,7 @@ export const WebhookDispatch = lazySchema(() => z.looseObject({
1162
1162
  id: z.string(),
1163
1163
  userId: z.string(),
1164
1164
  webhookId: z.string(),
1165
- createdAt: z.date(),
1165
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1166
1166
  status: WebhookDispatchStatus(),
1167
1167
  eventType: WebhookEventType(),
1168
1168
  eventData: z.looseObject({
@@ -1173,8 +1173,8 @@ export const WebhookDispatch = lazySchema(() => z.looseObject({
1173
1173
  }).nullable().optional(),
1174
1174
  webhook: WebhookDispatchWebhookSummary().nullable().optional(),
1175
1175
  calls: z.array(z.looseObject({
1176
- startedAt: z.date().nullable().optional(),
1177
- finishedAt: z.date().nullable().optional(),
1176
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1177
+ finishedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1178
1178
  errorMessage: z.string().nullable().optional(),
1179
1179
  responseStatus: z.int().nullable().optional(),
1180
1180
  responseBody: z.string().nullable().optional(),
@@ -1200,10 +1200,10 @@ export const ScheduleBase = lazySchema(() => z.looseObject({
1200
1200
  timezone: z.string(),
1201
1201
  isEnabled: z.boolean(),
1202
1202
  isExclusive: z.boolean(),
1203
- createdAt: z.date(),
1204
- modifiedAt: z.date(),
1205
- nextRunAt: z.date().nullable().optional(),
1206
- lastRunAt: z.date().nullable().optional(),
1203
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1204
+ modifiedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1205
+ nextRunAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1206
+ lastRunAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1207
1207
  }));
1208
1208
  export const ScheduleActionShortRunActor = lazySchema(() => z.looseObject({
1209
1209
  id: z.string(),
@@ -1279,7 +1279,7 @@ export const ScheduleResponse = lazySchema(() => z.looseObject({
1279
1279
  export const ScheduleInvoked = lazySchema(() => z.looseObject({
1280
1280
  message: z.string(),
1281
1281
  level: z.string(),
1282
- createdAt: z.date(),
1282
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1283
1283
  }));
1284
1284
  export const ScheduleLogResponse = lazySchema(() => z.looseObject({
1285
1285
  data: z.array(ScheduleInvoked()),
@@ -1287,10 +1287,10 @@ export const ScheduleLogResponse = lazySchema(() => z.looseObject({
1287
1287
  export const CurrentPricingInfo = lazySchema(() => z.looseObject({
1288
1288
  pricingModel: z.string(),
1289
1289
  apifyMarginPercentage: z.number().optional(),
1290
- createdAt: z.date().optional(),
1291
- startedAt: z.date().optional(),
1292
- notifiedAboutChangeAt: z.date().nullable().optional(),
1293
- notifiedAboutFutureChangeAt: z.date().nullable().optional(),
1290
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).optional(),
1291
+ startedAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).optional(),
1292
+ notifiedAboutChangeAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1293
+ notifiedAboutFutureChangeAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable().optional(),
1294
1294
  isPriceChangeNotificationSuppressed: z.boolean().optional(),
1295
1295
  forceContainsSignificantPriceChange: z.boolean().optional(),
1296
1296
  isPPEPlatformUsagePaidByUser: z.boolean().optional(),
@@ -1390,7 +1390,7 @@ export const EffectivePlatformFeature = lazySchema(() => z.looseObject({
1390
1390
  disabledReason: z.string().nullable(),
1391
1391
  disabledReasonType: z.string().nullable(),
1392
1392
  isTrial: z.boolean(),
1393
- trialExpirationAt: z.date().nullable(),
1393
+ trialExpirationAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).nullable(),
1394
1394
  }));
1395
1395
  export const EffectivePlatformFeatures = lazySchema(() => z.looseObject({
1396
1396
  ACTORS: EffectivePlatformFeature(),
@@ -1412,15 +1412,15 @@ export const UserPrivateInfo = lazySchema(() => z.looseObject({
1412
1412
  proxy: Proxy().optional(),
1413
1413
  plan: Plan().optional(),
1414
1414
  effectivePlatformFeatures: EffectivePlatformFeatures().optional(),
1415
- createdAt: z.date().optional(),
1415
+ createdAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()).optional(),
1416
1416
  isPaying: z.boolean().optional(),
1417
1417
  }));
1418
1418
  export const PrivateUserDataResponse = lazySchema(() => z.looseObject({
1419
1419
  data: UserPrivateInfo(),
1420
1420
  }));
1421
1421
  export const UsageCycle = lazySchema(() => z.looseObject({
1422
- startAt: z.date(),
1423
- endAt: z.date(),
1422
+ startAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1423
+ endAt: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1424
1424
  }));
1425
1425
  export const PriceTiers = lazySchema(() => z.looseObject({
1426
1426
  quantityAbove: z.number(),
@@ -1441,7 +1441,7 @@ export const MonthlyServiceUsage = lazySchema(() => z.record(z.string(), UsageIt
1441
1441
  /** A map of service usage item names to their usage details. */
1442
1442
  export const ServiceUsage = lazySchema(() => z.record(z.string(), UsageItem()));
1443
1443
  export const DailyServiceUsages = lazySchema(() => z.looseObject({
1444
- date: z.date(),
1444
+ date: z.iso.datetime({ offset: true }).pipe(z.coerce.date()),
1445
1445
  serviceUsage: ServiceUsage(),
1446
1446
  totalUsageCreditsUsd: z.number(),
1447
1447
  }));
@@ -6,6 +6,7 @@ import type { RequestInterceptorFunction } from './interceptors.js';
6
6
  import type { Statistics } from './statistics.js';
7
7
  import type { Timeout, TimeoutTier } from './timeouts.js';
8
8
  export declare class HttpClient {
9
+ #private;
9
10
  stats: Statistics;
10
11
  maxRetries: number;
11
12
  minDelayBetweenRetriesMillis: number;
@@ -19,63 +20,8 @@ export declare class HttpClient {
19
20
  httpsAgent?: https.Agent;
20
21
  axios: AxiosInstance;
21
22
  workflowKey?: string;
22
- private nodeInitPromise?;
23
- private userAgentSuffix?;
24
23
  constructor(options: HttpClientOptions);
25
- private ensureNodeInit;
26
- private initNode;
27
24
  call<T = any>(config: ApifyRequestConfig): Promise<ApifyResponse<T>>;
28
- private informAboutStreamNoRetry;
29
- /**
30
- * Successful responses are returned, errors and unsuccessful
31
- * status codes are retried. See the following functions for the
32
- * retrying logic.
33
- */
34
- private createRequestHandler;
35
- private isStatusOk;
36
- /**
37
- * Resolves `timeoutSecs` to the number of milliseconds the given attempt gets. A tier name resolves to
38
- * its configured duration, a number is taken as seconds, and `'noTimeout'` becomes `0`, which axios reads
39
- * as no timeout. The result doubles with each attempt and is capped at `timeoutMaxMillis`. A requested
40
- * value above the cap is capped too, which warns once, since it does not take effect in full.
41
- */
42
- private computeTimeoutMillis;
43
- /**
44
- * Handles all unexpected errors that can happen, but are not
45
- * Apify API typed errors. E.g. network errors, timeouts and so on.
46
- */
47
- private handleRequestError;
48
- /**
49
- * Axios calls req.abort() on timeouts so timeout errors will
50
- * have a code ECONNABORTED.
51
- */
52
- private isTimeoutError;
53
- /**
54
- * We don't want to retry every exception thrown from Axios.
55
- * The common denominator for retryable errors are network issues.
56
- * @param {Error} err
57
- * @private
58
- */
59
- private isRetryableError;
60
- /**
61
- * When a network connection to our API is interrupted in the middle of streaming
62
- * a response, the request often does not fail, but simply contains
63
- * an incomplete response. This can often be fixed by retrying.
64
- */
65
- private isResponseBodyInvalid;
66
- /**
67
- * When a network request is attempted by axios and fails,
68
- * it throws an AxiosError, which will have the request
69
- * and config (and other) properties.
70
- */
71
- private isNetworkError;
72
- /**
73
- * We retry 429 (rate limit) and 500+.
74
- * For status codes 300-499 (except 429) we do not retry the request,
75
- * because it's probably caused by invalid url (redirect 3xx) or invalid user input (4xx).
76
- */
77
- private isStatusCodeRetryable;
78
- private onRequestRetry;
79
25
  }
80
26
  export interface ApifyRequestConfig extends Omit<AxiosRequestConfig, 'timeout'> {
81
27
  stringifyFunctions?: boolean;
@@ -20,8 +20,8 @@ export class HttpClient {
20
20
  httpsAgent;
21
21
  axios;
22
22
  workflowKey;
23
- nodeInitPromise;
24
- userAgentSuffix;
23
+ #nodeInitPromise;
24
+ #userAgentSuffix;
25
25
  constructor(options) {
26
26
  const { token } = options;
27
27
  this.stats = options.apifyClientStats;
@@ -36,8 +36,7 @@ export class HttpClient {
36
36
  this.timeoutMaxMillis = options.timeoutMaxSecs * 1000;
37
37
  this.logger = options.logger;
38
38
  this.workflowKey = options.workflowKey || process.env[APIFY_ENV_VARS.WORKFLOW_KEY];
39
- this.userAgentSuffix = options.userAgentSuffix;
40
- this.onRequestRetry = this.onRequestRetry.bind(this);
39
+ this.#userAgentSuffix = options.userAgentSuffix;
41
40
  this.axios = axios.create({
42
41
  // Disable axios's built-in proxy handling since we're using custom agents
43
42
  proxy: false,
@@ -82,13 +81,13 @@ export class HttpClient {
82
81
  this.userProvidedRequestInterceptors.forEach((i) => this.axios.interceptors.request.use(i));
83
82
  responseInterceptors.forEach((i) => this.axios.interceptors.response.use(i));
84
83
  }
85
- async ensureNodeInit() {
84
+ async #ensureNodeInit() {
86
85
  if (!isNode())
87
86
  return;
88
- this.nodeInitPromise ??= this.initNode();
89
- return this.nodeInitPromise;
87
+ this.#nodeInitPromise ??= this.#initNode();
88
+ return this.#nodeInitPromise;
90
89
  }
91
- async initNode() {
90
+ async #initNode() {
92
91
  if (!isNode())
93
92
  return;
94
93
  const [{ ProxyAgent }, os] = await Promise.all([import('proxy-agent'), import('node:os')]);
@@ -129,22 +128,22 @@ export class HttpClient {
129
128
  // Works only in Node. Cannot be set in browser
130
129
  const isAtHome = !!process.env[APIFY_ENV_VARS.IS_AT_HOME];
131
130
  let userAgent = `ApifyClient/${version} (${os.platform()}; Node/${process.version}); isAtHome/${isAtHome}`;
132
- if (this.userAgentSuffix) {
133
- userAgent += `; ${asArray(this.userAgentSuffix).join('; ')}`;
131
+ if (this.#userAgentSuffix) {
132
+ userAgent += `; ${asArray(this.#userAgentSuffix).join('; ')}`;
134
133
  }
135
134
  this.axios.defaults.headers['User-Agent'] = userAgent;
136
135
  }
137
136
  async call(config) {
138
- await this.ensureNodeInit();
137
+ await this.#ensureNodeInit();
139
138
  this.stats.calls++;
140
- const makeRequest = this.createRequestHandler(config);
139
+ const makeRequest = this.#createRequestHandler(config);
141
140
  return retry(makeRequest, {
142
141
  retries: this.maxRetries,
143
142
  minTimeout: this.minDelayBetweenRetriesMillis,
144
- onRetry: this.onRequestRetry,
143
+ onRetry: (error, attempt) => this.#onRequestRetry(error, attempt),
145
144
  });
146
145
  }
147
- informAboutStreamNoRetry() {
146
+ #informAboutStreamNoRetry() {
148
147
  this.logger.warningOnce('Request body was a stream - retrying will not work, as part of it was already consumed.');
149
148
  this.logger.warningOnce('If you want Apify client to handle retries for you, collect the stream into a buffer before sending it.');
150
149
  }
@@ -153,7 +152,7 @@ export class HttpClient {
153
152
  * status codes are retried. See the following functions for the
154
153
  * retrying logic.
155
154
  */
156
- createRequestHandler(config) {
155
+ #createRequestHandler(config) {
157
156
  const { timeoutSecs = 'medium', ...axiosConfig } = config;
158
157
  const makeRequest = async (stopTrying, attempt) => {
159
158
  this.stats.requests++;
@@ -168,21 +167,21 @@ export class HttpClient {
168
167
  }
169
168
  response = await this.axios.request({
170
169
  ...axiosConfig,
171
- timeout: this.computeTimeoutMillis(timeoutSecs, attempt),
170
+ timeout: this.#computeTimeoutMillis(timeoutSecs, attempt),
172
171
  });
173
- if (this.isStatusOk(response.status))
172
+ if (this.#isStatusOk(response.status))
174
173
  return response;
175
174
  }
176
175
  catch (err) {
177
- return cast(this.handleRequestError(err, config, stopTrying));
176
+ return cast(this.#handleRequestError(err, config, stopTrying));
178
177
  }
179
178
  if (response.status === RATE_LIMIT_EXCEEDED_STATUS_CODE) {
180
179
  this.stats.addRateLimitError(attempt);
181
180
  }
182
181
  const apiError = ApifyApiError.fromResponse(response, attempt);
183
- if (this.isStatusCodeRetryable(response.status)) {
182
+ if (this.#isStatusCodeRetryable(response.status)) {
184
183
  if (requestIsStream) {
185
- this.informAboutStreamNoRetry();
184
+ this.#informAboutStreamNoRetry();
186
185
  }
187
186
  else {
188
187
  // allow a retry
@@ -194,7 +193,7 @@ export class HttpClient {
194
193
  };
195
194
  return makeRequest;
196
195
  }
197
- isStatusOk(statusCode) {
196
+ #isStatusOk(statusCode) {
198
197
  return statusCode < 300;
199
198
  }
200
199
  /**
@@ -203,7 +202,7 @@ export class HttpClient {
203
202
  * as no timeout. The result doubles with each attempt and is capped at `timeoutMaxMillis`. A requested
204
203
  * value above the cap is capped too, which warns once, since it does not take effect in full.
205
204
  */
206
- computeTimeoutMillis(timeoutSecs, attempt) {
205
+ #computeTimeoutMillis(timeoutSecs, attempt) {
207
206
  if (timeoutSecs === 'noTimeout')
208
207
  return 0;
209
208
  const requestedMillis = typeof timeoutSecs === 'number' ? timeoutSecs * 1000 : this.timeoutMillis[timeoutSecs];
@@ -219,13 +218,13 @@ export class HttpClient {
219
218
  * Handles all unexpected errors that can happen, but are not
220
219
  * Apify API typed errors. E.g. network errors, timeouts and so on.
221
220
  */
222
- handleRequestError(err, config, stopTrying) {
223
- if (this.isTimeoutError(err) && config.doNotRetryTimeouts) {
221
+ #handleRequestError(err, config, stopTrying) {
222
+ if (this.#isTimeoutError(err) && config.doNotRetryTimeouts) {
224
223
  return stopTrying(err);
225
224
  }
226
- if (this.isRetryableError(err)) {
225
+ if (this.#isRetryableError(err)) {
227
226
  if (isStream(config.data)) {
228
- this.informAboutStreamNoRetry();
227
+ this.#informAboutStreamNoRetry();
229
228
  }
230
229
  else {
231
230
  throw err;
@@ -237,7 +236,7 @@ export class HttpClient {
237
236
  * Axios calls req.abort() on timeouts so timeout errors will
238
237
  * have a code ECONNABORTED.
239
238
  */
240
- isTimeoutError(err) {
239
+ #isTimeoutError(err) {
241
240
  return err.code === 'ECONNABORTED';
242
241
  }
243
242
  /**
@@ -246,15 +245,15 @@ export class HttpClient {
246
245
  * @param {Error} err
247
246
  * @private
248
247
  */
249
- isRetryableError(err) {
250
- return this.isNetworkError(err) || this.isResponseBodyInvalid(err);
248
+ #isRetryableError(err) {
249
+ return this.#isNetworkError(err) || this.#isResponseBodyInvalid(err);
251
250
  }
252
251
  /**
253
252
  * When a network connection to our API is interrupted in the middle of streaming
254
253
  * a response, the request often does not fail, but simply contains
255
254
  * an incomplete response. This can often be fixed by retrying.
256
255
  */
257
- isResponseBodyInvalid(err) {
256
+ #isResponseBodyInvalid(err) {
258
257
  return err instanceof InvalidResponseBodyError;
259
258
  }
260
259
  /**
@@ -262,7 +261,7 @@ export class HttpClient {
262
261
  * it throws an AxiosError, which will have the request
263
262
  * and config (and other) properties.
264
263
  */
265
- isNetworkError(err) {
264
+ #isNetworkError(err) {
266
265
  const hasRequest = err.request && typeof err.request === 'object';
267
266
  const hasConfig = err.config && typeof err.config === 'object';
268
267
  return hasRequest && hasConfig;
@@ -272,12 +271,12 @@ export class HttpClient {
272
271
  * For status codes 300-499 (except 429) we do not retry the request,
273
272
  * because it's probably caused by invalid url (redirect 3xx) or invalid user input (4xx).
274
273
  */
275
- isStatusCodeRetryable(statusCode) {
274
+ #isStatusCodeRetryable(statusCode) {
276
275
  const isRateLimitError = statusCode === RATE_LIMIT_EXCEEDED_STATUS_CODE;
277
276
  const isInternalError = statusCode >= 500;
278
277
  return isRateLimitError || isInternalError;
279
278
  }
280
- onRequestRetry(error, attempt) {
279
+ #onRequestRetry(error, attempt) {
281
280
  if (attempt === Math.round(this.maxRetries / 2)) {
282
281
  this.logger.warning(`API request failed ${attempt} times. Max attempts: ${this.maxRetries + 1}.\nCause:${error.stack}`);
283
282
  }
package/dist/models.d.ts CHANGED
@@ -935,15 +935,14 @@ export interface RequestQueueStats extends GeneratedRequestQueueStats {
935
935
  /**
936
936
  * Fields the API returns on a request queue that the OpenAPI spec does not describe yet.
937
937
  *
938
- * The spec does carry `username` and `expireAt` on `RequestQueueShort`, the listing shape, and simply
939
- * omits both from the full `RequestQueue` schema. `title` is absent from either.
938
+ * The spec does carry `username` on `RequestQueueShort`, the listing shape, and simply omits it from the
939
+ * full `RequestQueue` schema. `title` is absent from either.
940
940
  *
941
941
  * TODO: Remove once the spec covers them.
942
942
  */
943
943
  export interface RequestQueueSpecGaps {
944
944
  title?: string;
945
945
  username?: string;
946
- expireAt?: Date;
947
946
  }
948
947
  export interface RequestQueueRePointed {
949
948
  stats?: RequestQueueStats;
@@ -35,6 +35,7 @@ export type { Dataset, DatasetStatistics, DatasetStats, FieldStatistics } from '
35
35
  * @see https://docs.apify.com/platform/storage/dataset
36
36
  */
37
37
  export declare class DatasetClient<Data extends Record<string | number, any> = Record<string | number, unknown>> extends ResourceClient {
38
+ #private;
38
39
  /**
39
40
  * @hidden
40
41
  */
@@ -236,7 +237,6 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
236
237
  * @since Added in 2.13.0
237
238
  */
238
239
  createItemsPublicUrl(options?: DatasetClientCreateItemsUrlOptions): Promise<string>;
239
- private createPaginationList;
240
240
  }
241
241
  /**
242
242
  * Options for updating a dataset.
@@ -192,7 +192,7 @@ export class DatasetClient extends ResourceClient {
192
192
  params: this.buildParams(datasetListOptions),
193
193
  timeoutSecs,
194
194
  });
195
- return this.createPaginationList(response, datasetListOptions.desc ?? false);
195
+ return this.#createPaginationList(response, datasetListOptions.desc ?? false);
196
196
  };
197
197
  return this.listPaginatedFromCallback(fetchItems, listOptions);
198
198
  }
@@ -371,7 +371,7 @@ export class DatasetClient extends ResourceClient {
371
371
  createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
372
372
  return createdItemsPublicUrl.toString();
373
373
  }
374
- createPaginationList(response, userProvidedDesc) {
374
+ #createPaginationList(response, userProvidedDesc) {
375
375
  const page = {
376
376
  items: response.data,
377
377
  total: Number(response.headers['x-apify-pagination-total']),