apify-client 3.0.0-beta.17 → 3.0.0-beta.19
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.
- package/dist/apify_api_error.js +6 -4
- package/dist/bundle.js +13 -13
- package/dist/bundle.js.map +1 -1
- package/dist/generated/schemas.d.ts +374 -374
- package/dist/generated/schemas.js +64 -64
- package/dist/http_client.js +7 -0
- package/dist/models.d.ts +2 -3
- package/dist/resource_clients/request_queue.js +2 -3
- package/dist/resource_clients/user.js +1 -2
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- package/dist/utils.d.ts +7 -23
- package/dist/utils.js +7 -54
- package/package.json +1 -1
|
@@ -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
|
}));
|
package/dist/http_client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import retry from 'async-retry';
|
|
2
2
|
import axios, { AxiosHeaders } from 'axios';
|
|
3
3
|
import { APIFY_ENV_VARS } from '@apify/consts';
|
|
4
|
+
import { concatStreamToBuffer } from '@apify/utilities';
|
|
4
5
|
import { ApifyApiError } from './apify_api_error.js';
|
|
5
6
|
import { InvalidResponseBodyError, requestInterceptors, responseInterceptors } from './interceptors.js';
|
|
6
7
|
import { asArray, cast, getVersionData, isNode, isStream } from './utils.js';
|
|
@@ -171,6 +172,12 @@ export class HttpClient {
|
|
|
171
172
|
});
|
|
172
173
|
if (this.#isStatusOk(response.status))
|
|
173
174
|
return response;
|
|
175
|
+
// A failed request with `responseType: 'stream'` carries the API error body in the stream. Read
|
|
176
|
+
// it so that `ApifyApiError` can parse it like any other error body. A body that cannot be read
|
|
177
|
+
// leaves the error without a message, which beats losing the status code to a stream error.
|
|
178
|
+
if (isStream(response.data)) {
|
|
179
|
+
response.data = await concatStreamToBuffer(response.data).catch(() => undefined);
|
|
180
|
+
}
|
|
174
181
|
}
|
|
175
182
|
catch (err) {
|
|
176
183
|
return cast(this.#handleRequestError(err, config, stopTrying));
|
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`
|
|
939
|
-
*
|
|
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;
|
|
@@ -5,7 +5,7 @@ import { ResourceClient } from '../base/resource_client.js';
|
|
|
5
5
|
import { ResponseValidationError } from '../response_validation_error.js';
|
|
6
6
|
import * as schemas from '../schemas.js';
|
|
7
7
|
import { optionalTimeoutSchema, timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
8
|
-
import { anyObjectSchema,
|
|
8
|
+
import { anyObjectSchema, catchNotFoundOrThrow, isNonArrayObject, parseArgument, parseResponse, RequestQueuePaginationIterator, sliceArrayByByteLength, } from '../utils.js';
|
|
9
9
|
const DEFAULT_PARALLEL_BATCH_ADD_REQUESTS = 5;
|
|
10
10
|
const DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS = 3;
|
|
11
11
|
const DEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES_MILLIS = 500;
|
|
@@ -342,8 +342,7 @@ export class RequestQueueClient extends ResourceClient {
|
|
|
342
342
|
setTimeout(resolve, delayMillis);
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
-
|
|
346
|
-
return cast(parseDateFields(result));
|
|
345
|
+
return { processedRequests, unprocessedRequests };
|
|
347
346
|
}
|
|
348
347
|
/**
|
|
349
348
|
* Adds multiple requests to the queue in a single operation.
|
|
@@ -69,8 +69,7 @@ export class UserClient extends ResourceClient {
|
|
|
69
69
|
params: this.buildParams(),
|
|
70
70
|
timeoutSecs,
|
|
71
71
|
});
|
|
72
|
-
|
|
73
|
-
return parseResponse(response, schemas.MonthlyUsage(), (key) => key === 'date');
|
|
72
|
+
return parseResponse(response, schemas.MonthlyUsage());
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
76
75
|
* Retrieves the user's account and usage limits.
|
package/dist/schemas.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
7
|
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
8
8
|
* built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
|
|
9
|
-
* top of it, and `spec_guards.ts` checks that each override still
|
|
9
|
+
* top of it, and `spec_guards.ts` checks that each override still produces what the specification describes,
|
|
10
10
|
* so one cannot narrow by accident.
|
|
11
11
|
*
|
|
12
12
|
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
package/dist/schemas.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
7
|
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
8
8
|
* built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
|
|
9
|
-
* top of it, and `spec_guards.ts` checks that each override still
|
|
9
|
+
* top of it, and `spec_guards.ts` checks that each override still produces what the specification describes,
|
|
10
10
|
* so one cannot narrow by accident.
|
|
11
11
|
*
|
|
12
12
|
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TypedArray } from 'type-fest';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import type { ApifyApiError } from './apify_api_error.js';
|
|
5
5
|
import { parseArgument } from '@apify/validations';
|
|
@@ -28,16 +28,16 @@ export interface MaybeData<R> {
|
|
|
28
28
|
data?: R;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
31
|
+
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope and validates the
|
|
32
|
+
* result against `schema`, one of the schemas generated from the OpenAPI specification. The validated copy is what
|
|
33
|
+
* callers get, so it is the schema's output -- unknown fields and unknown enum values included, since the schemas let
|
|
34
|
+
* both through, date-time fields turned into `Date` objects, and URL fields normalized, since `z.url()` hands back the
|
|
35
|
+
* parsed URL's serialization.
|
|
36
36
|
*
|
|
37
37
|
* Throws {@link ResponseValidationError} when the response does not match the specification.
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
|
-
export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodType
|
|
40
|
+
export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodType): R;
|
|
41
41
|
/**
|
|
42
42
|
* Returns object's 'data' property or throws if parameter is not an object,
|
|
43
43
|
* or an object without a 'data' property.
|
|
@@ -55,22 +55,6 @@ export declare function catchNotFoundOrThrow(err: ApifyApiError): void;
|
|
|
55
55
|
* @internal
|
|
56
56
|
*/
|
|
57
57
|
export declare function catchNotFoundForResourceOrThrow(err: ApifyApiError, resourceId: string | undefined): void;
|
|
58
|
-
type ReturnJsonValue = string | number | boolean | null | Date | ReturnJsonObject | ReturnJsonArray;
|
|
59
|
-
type ReturnJsonObject = {
|
|
60
|
-
[Key in string]?: ReturnJsonValue;
|
|
61
|
-
};
|
|
62
|
-
type ReturnJsonArray = ReturnJsonValue[];
|
|
63
|
-
/**
|
|
64
|
-
* Traverses JSON structure and converts fields that end with "At" to a Date object (fields such as "modifiedAt" or
|
|
65
|
-
* "createdAt").
|
|
66
|
-
*
|
|
67
|
-
* If you want parse other fields as well, you can provide a custom matcher function shouldParseField(). This
|
|
68
|
-
* admittedly awkward approach allows this function to be reused for various purposes without introducing potential
|
|
69
|
-
* breaking changes.
|
|
70
|
-
*
|
|
71
|
-
* If the field cannot be converted to Date, it is left as is.
|
|
72
|
-
*/
|
|
73
|
-
export declare function parseDateFields(input: JsonValue, shouldParseField?: ((key: string) => boolean) | null, depth?: number): ReturnJsonValue;
|
|
74
58
|
/**
|
|
75
59
|
* Helper function that converts array of webhooks to base64 string
|
|
76
60
|
*/
|
package/dist/utils.js
CHANGED
|
@@ -72,17 +72,17 @@ export const anyObjectSchema = z.custom(isNonArrayObject, {
|
|
|
72
72
|
// in per parse keeps them intact without reaching into the zod config the whole process shares.
|
|
73
73
|
const { localeError } = z.locales.en();
|
|
74
74
|
/**
|
|
75
|
-
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
75
|
+
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope and validates the
|
|
76
|
+
* result against `schema`, one of the schemas generated from the OpenAPI specification. The validated copy is what
|
|
77
|
+
* callers get, so it is the schema's output -- unknown fields and unknown enum values included, since the schemas let
|
|
78
|
+
* both through, date-time fields turned into `Date` objects, and URL fields normalized, since `z.url()` hands back the
|
|
79
|
+
* parsed URL's serialization.
|
|
80
80
|
*
|
|
81
81
|
* Throws {@link ResponseValidationError} when the response does not match the specification.
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
84
|
-
export function parseResponse(response, schema
|
|
85
|
-
const data =
|
|
84
|
+
export function parseResponse(response, schema) {
|
|
85
|
+
const data = pluckData(response.data);
|
|
86
86
|
const result = schema.safeParse(data, { error: localeError });
|
|
87
87
|
if (!result.success) {
|
|
88
88
|
const { method = 'GET', url = '' } = response.config;
|
|
@@ -120,53 +120,6 @@ export function catchNotFoundForResourceOrThrow(err, resourceId) {
|
|
|
120
120
|
throw err;
|
|
121
121
|
catchNotFoundOrThrow(err);
|
|
122
122
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Traverses JSON structure and converts fields that end with "At" to a Date object (fields such as "modifiedAt" or
|
|
125
|
-
* "createdAt").
|
|
126
|
-
*
|
|
127
|
-
* If you want parse other fields as well, you can provide a custom matcher function shouldParseField(). This
|
|
128
|
-
* admittedly awkward approach allows this function to be reused for various purposes without introducing potential
|
|
129
|
-
* breaking changes.
|
|
130
|
-
*
|
|
131
|
-
* If the field cannot be converted to Date, it is left as is.
|
|
132
|
-
*/
|
|
133
|
-
export function parseDateFields(input, shouldParseField = null, depth = 0) {
|
|
134
|
-
// Don't go too deep to avoid stack overflows (especially if there is a circular reference). The depth of 4
|
|
135
|
-
// corresponds to obj.items.[x].someArrayField.[y].field, which is what a list response looks like: it
|
|
136
|
-
// nests one level deeper than the single resource it wraps, because both the item array and the nested
|
|
137
|
-
// array spend a level.
|
|
138
|
-
//
|
|
139
|
-
// In a list response it also reaches one level into caller-owned blobs the API stores verbatim, so a
|
|
140
|
-
// listed request's `userData.foo.somethingAt` comes back as a `Date` rather than the string it was
|
|
141
|
-
// written as.
|
|
142
|
-
// TODO: Consider removing this limitation. It might came across as an annoying surprise as it's not communicated.
|
|
143
|
-
if (depth > 4) {
|
|
144
|
-
return input;
|
|
145
|
-
}
|
|
146
|
-
if (Array.isArray(input))
|
|
147
|
-
return input.map((child) => parseDateFields(child, shouldParseField, depth + 1));
|
|
148
|
-
if (!input || typeof input !== 'object')
|
|
149
|
-
return input;
|
|
150
|
-
return Object.entries(input).reduce((output, [k, v]) => {
|
|
151
|
-
const isValObject = !!v && typeof v === 'object';
|
|
152
|
-
if (k.endsWith('At') || (shouldParseField && shouldParseField(k))) {
|
|
153
|
-
if (v) {
|
|
154
|
-
const d = new Date(v);
|
|
155
|
-
output[k] = Number.isNaN(d.getTime()) ? v : d;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
output[k] = v;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else if (isValObject || Array.isArray(v)) {
|
|
162
|
-
output[k] = parseDateFields(v, shouldParseField, depth + 1);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
output[k] = v;
|
|
166
|
-
}
|
|
167
|
-
return output;
|
|
168
|
-
}, {});
|
|
169
|
-
}
|
|
170
123
|
/**
|
|
171
124
|
* Helper function that converts array of webhooks to base64 string
|
|
172
125
|
*/
|