apify-client 3.0.0-beta.111 → 3.0.0-beta.113
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/README.md +4 -2
- package/dist/apify_client.d.ts +8 -8
- package/dist/apify_client.js +10 -10
- package/dist/axios.d.ts +2 -0
- package/dist/axios.js +1 -0
- package/dist/bundle.js +31 -30
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +103 -28
- package/dist/generated/schemas.d.ts +12 -51
- package/dist/generated/schemas.js +10 -4
- package/dist/http_clients/axios.d.ts +27 -13
- package/dist/http_clients/axios.js +35 -20
- package/dist/http_clients/base.d.ts +2 -2
- package/dist/http_clients/base.js +6 -3
- package/dist/http_clients/fetch.d.ts +52 -0
- package/dist/http_clients/fetch.js +183 -0
- package/dist/http_clients/index.d.ts +2 -2
- package/dist/http_clients/index.js +1 -1
- package/dist/resource_clients/store_collection.d.ts +4 -0
- package/dist/runtime/node.js +34 -11
- package/dist/runtime/types.d.ts +18 -3
- package/dist/runtime/web.js +8 -0
- package/package.json +15 -3
package/dist/generated/api.d.ts
CHANGED
|
@@ -4484,8 +4484,13 @@ export interface paths {
|
|
|
4484
4484
|
* and readme.
|
|
4485
4485
|
* If you need detailed info about a specific Actor, use the [Get Actor](https://docs.apify.com/api/v2/actor-get) endpoint.
|
|
4486
4486
|
*
|
|
4487
|
-
*
|
|
4488
|
-
* It will not return more than 1,000 records.
|
|
4487
|
+
* Without `search`, the endpoint supports pagination using the `limit` and
|
|
4488
|
+
* `offset` parameters. It will not return more than 1,000 records per page.
|
|
4489
|
+
*
|
|
4490
|
+
* With `search`, results are ranked by relevance and returned as a single
|
|
4491
|
+
* page of at most 100 records. `offset` is ignored and there is no second
|
|
4492
|
+
* page. `total` and `count` equal the number of returned items. To narrow
|
|
4493
|
+
* the results, use `category`, `username` or `pricingModel`.
|
|
4489
4494
|
*/
|
|
4490
4495
|
get: operations["store_get"];
|
|
4491
4496
|
put?: never;
|
|
@@ -9145,8 +9150,8 @@ export interface components {
|
|
|
9145
9150
|
description?: string | null;
|
|
9146
9151
|
/**
|
|
9147
9152
|
* @example [
|
|
9148
|
-
* "
|
|
9149
|
-
* "
|
|
9153
|
+
* "AI_AND_ML",
|
|
9154
|
+
* "GENERATE_LEADS"
|
|
9150
9155
|
* ]
|
|
9151
9156
|
*/
|
|
9152
9157
|
categories?: string[];
|
|
@@ -9163,16 +9168,55 @@ export interface components {
|
|
|
9163
9168
|
* @example https://...
|
|
9164
9169
|
*/
|
|
9165
9170
|
url?: string | null;
|
|
9166
|
-
|
|
9171
|
+
/**
|
|
9172
|
+
* StoreActorStats
|
|
9173
|
+
* @description Actor usage statistics and Apify Store metrics returned by the Store endpoint.
|
|
9174
|
+
*/
|
|
9175
|
+
stats: {
|
|
9176
|
+
/**
|
|
9177
|
+
* @description The total number of Actor users, including its owner.
|
|
9178
|
+
* @example 6
|
|
9179
|
+
*/
|
|
9180
|
+
totalUsers: number;
|
|
9181
|
+
/**
|
|
9182
|
+
* @description The total number of runs of the Actor.
|
|
9183
|
+
* @example 16
|
|
9184
|
+
*/
|
|
9185
|
+
totalRuns?: number;
|
|
9186
|
+
/**
|
|
9187
|
+
* @description The number of active users of the Actor in the last 7 days.
|
|
9188
|
+
* @example 2
|
|
9189
|
+
*/
|
|
9190
|
+
totalUsers7Days?: number;
|
|
9191
|
+
/**
|
|
9192
|
+
* @description The number of active users of the Actor in the last 30 days.
|
|
9193
|
+
* @example 6
|
|
9194
|
+
*/
|
|
9195
|
+
totalUsers30Days?: number;
|
|
9196
|
+
/**
|
|
9197
|
+
* @description The number of active users of the Actor in the last 90 days.
|
|
9198
|
+
* @example 6
|
|
9199
|
+
*/
|
|
9200
|
+
totalUsers90Days?: number;
|
|
9201
|
+
/**
|
|
9202
|
+
* @description The average rating of the Actor in Apify Store.
|
|
9203
|
+
* @example 4.7
|
|
9204
|
+
*/
|
|
9205
|
+
actorReviewRating: number;
|
|
9206
|
+
/**
|
|
9207
|
+
* @description The number of reviews the Actor has received in Apify Store.
|
|
9208
|
+
* @example 69
|
|
9209
|
+
*/
|
|
9210
|
+
actorReviewCount: number;
|
|
9211
|
+
};
|
|
9167
9212
|
currentPricingInfo?: components["schemas"]["CurrentPricingInfo"];
|
|
9168
9213
|
/** @description Whether the Actor is whitelisted for agentic payment processing. */
|
|
9169
9214
|
isWhiteListedForAgenticPayments?: boolean | null;
|
|
9170
|
-
/**
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
bookmarkCount?: number;
|
|
9215
|
+
/**
|
|
9216
|
+
* @description Whether the Actor's developer has a verified identity.
|
|
9217
|
+
* @example false
|
|
9218
|
+
*/
|
|
9219
|
+
isVerified?: boolean;
|
|
9176
9220
|
/** @example null */
|
|
9177
9221
|
badge?: string | null;
|
|
9178
9222
|
/** @description A brief, LLM-generated readme summary */
|
|
@@ -9224,23 +9268,27 @@ export interface components {
|
|
|
9224
9268
|
* "name": "my-public-actor",
|
|
9225
9269
|
* "username": "jane35",
|
|
9226
9270
|
* "userFullName": "Jane Doe",
|
|
9271
|
+
* "categories": [
|
|
9272
|
+
* "AI_AND_ML",
|
|
9273
|
+
* "GENERATE_LEADS"
|
|
9274
|
+
* ],
|
|
9227
9275
|
* "description": "My public Actor!",
|
|
9228
9276
|
* "pictureUrl": "https://...",
|
|
9229
9277
|
* "userPictureUrl": "https://...",
|
|
9230
9278
|
* "url": "https://...",
|
|
9231
9279
|
* "stats": {
|
|
9232
|
-
* "totalBuilds": 9,
|
|
9233
9280
|
* "totalRuns": 16,
|
|
9234
9281
|
* "totalUsers": 6,
|
|
9235
9282
|
* "totalUsers7Days": 2,
|
|
9236
9283
|
* "totalUsers30Days": 6,
|
|
9237
9284
|
* "totalUsers90Days": 6,
|
|
9238
|
-
* "
|
|
9239
|
-
* "
|
|
9285
|
+
* "actorReviewRating": 4.7,
|
|
9286
|
+
* "actorReviewCount": 69
|
|
9240
9287
|
* },
|
|
9241
9288
|
* "currentPricingInfo": {
|
|
9242
9289
|
* "pricingModel": "FREE"
|
|
9243
9290
|
* },
|
|
9291
|
+
* "isVerified": true,
|
|
9244
9292
|
* "isWhiteListedForAgenticPayments": true
|
|
9245
9293
|
* },
|
|
9246
9294
|
* {
|
|
@@ -9250,26 +9298,25 @@ export interface components {
|
|
|
9250
9298
|
* "username": "jane35",
|
|
9251
9299
|
* "userFullName": "Jane H. Doe",
|
|
9252
9300
|
* "categories": [
|
|
9253
|
-
* "
|
|
9254
|
-
* "LEAD_GENERATION"
|
|
9301
|
+
* "ECOMMERCE"
|
|
9255
9302
|
* ],
|
|
9256
9303
|
* "description": "My public Actor!",
|
|
9257
9304
|
* "pictureUrl": "https://...",
|
|
9258
9305
|
* "userPictureUrl": "https://...",
|
|
9259
9306
|
* "url": "https://...",
|
|
9260
9307
|
* "stats": {
|
|
9261
|
-
* "totalBuilds": 9,
|
|
9262
9308
|
* "totalRuns": 16,
|
|
9263
9309
|
* "totalUsers": 6,
|
|
9264
9310
|
* "totalUsers7Days": 2,
|
|
9265
9311
|
* "totalUsers30Days": 6,
|
|
9266
9312
|
* "totalUsers90Days": 6,
|
|
9267
|
-
* "
|
|
9268
|
-
* "
|
|
9313
|
+
* "actorReviewRating": 4.7,
|
|
9314
|
+
* "actorReviewCount": 69
|
|
9269
9315
|
* },
|
|
9270
9316
|
* "currentPricingInfo": {
|
|
9271
9317
|
* "pricingModel": "FREE"
|
|
9272
9318
|
* },
|
|
9319
|
+
* "isVerified": false,
|
|
9273
9320
|
* "isWhiteListedForAgenticPayments": false
|
|
9274
9321
|
* }
|
|
9275
9322
|
* ]
|
|
@@ -10424,6 +10471,17 @@ export interface components {
|
|
|
10424
10471
|
webhookId: string;
|
|
10425
10472
|
/** @description Schedule ID. */
|
|
10426
10473
|
scheduleId: string;
|
|
10474
|
+
/**
|
|
10475
|
+
* @description Maximum number of items to return. The default value as well as the
|
|
10476
|
+
* maximum is `1000`. When `search` is used, the default and maximum are
|
|
10477
|
+
* `100`, and larger values are reduced to `100`.
|
|
10478
|
+
*/
|
|
10479
|
+
storeLimit: number;
|
|
10480
|
+
/**
|
|
10481
|
+
* @description Number of items that should be skipped at the start. The default value
|
|
10482
|
+
* is `0`. Ignored when `search` is used.
|
|
10483
|
+
*/
|
|
10484
|
+
storeOffset: number;
|
|
10427
10485
|
/** @description ID of the Actor build or run. */
|
|
10428
10486
|
buildOrRunId: string;
|
|
10429
10487
|
};
|
|
@@ -22094,21 +22152,38 @@ export interface operations {
|
|
|
22094
22152
|
store_get: {
|
|
22095
22153
|
parameters: {
|
|
22096
22154
|
query?: {
|
|
22097
|
-
/** @description Maximum number of items to return. The default value as well as the maximum is `1000`. */
|
|
22098
|
-
limit?: components["parameters"]["limit"];
|
|
22099
|
-
/** @description Number of items that should be skipped at the start. The default value is `0`. */
|
|
22100
|
-
offset?: components["parameters"]["offset"];
|
|
22101
22155
|
/**
|
|
22102
|
-
* @description
|
|
22103
|
-
*
|
|
22156
|
+
* @description Maximum number of items to return. The default value as well as the
|
|
22157
|
+
* maximum is `1000`. When `search` is used, the default and maximum are
|
|
22158
|
+
* `100`, and larger values are reduced to `100`.
|
|
22159
|
+
*/
|
|
22160
|
+
limit?: components["parameters"]["storeLimit"];
|
|
22161
|
+
/**
|
|
22162
|
+
* @description Number of items that should be skipped at the start. The default value
|
|
22163
|
+
* is `0`. Ignored when `search` is used.
|
|
22164
|
+
*/
|
|
22165
|
+
offset?: components["parameters"]["storeOffset"];
|
|
22166
|
+
/**
|
|
22167
|
+
* @description String to search by. Results are ranked by relevance and returned as a
|
|
22168
|
+
* single page of at most 100 items.
|
|
22104
22169
|
*/
|
|
22105
22170
|
search?: string;
|
|
22106
22171
|
/**
|
|
22107
|
-
* @
|
|
22108
|
-
*
|
|
22172
|
+
* @deprecated
|
|
22173
|
+
* @description Deprecated and ignored. The value is accepted for backward
|
|
22174
|
+
* compatibility but has no effect. Results are ordered by relevance when
|
|
22175
|
+
* `search` is used, and by Store position otherwise. Sort the results
|
|
22176
|
+
* on the client if you need a different order.
|
|
22109
22177
|
*/
|
|
22110
22178
|
sortBy?: string;
|
|
22111
|
-
/**
|
|
22179
|
+
/**
|
|
22180
|
+
* @description Filters the results by category. Accepts one or more category IDs,
|
|
22181
|
+
* separated by commas and case-insensitive. An Actor must match all of
|
|
22182
|
+
* the listed categories. See the
|
|
22183
|
+
* [list of category IDs](https://github.com/apify/apify-shared-js/blob/master/packages/actor-categories/src/actor_categories.ts).
|
|
22184
|
+
* Legacy keys such as `social_media` are still accepted. An unknown
|
|
22185
|
+
* category returns a `400` error.
|
|
22186
|
+
*/
|
|
22112
22187
|
category?: string;
|
|
22113
22188
|
/** @description Filters the results by the specified username. */
|
|
22114
22189
|
username?: string;
|
|
@@ -7116,24 +7116,13 @@ export declare const StoreActor: () => z.ZodObject<{
|
|
|
7116
7116
|
userPictureUrl: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7117
7117
|
url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7118
7118
|
stats: z.ZodObject<{
|
|
7119
|
-
|
|
7119
|
+
totalUsers: z.ZodInt;
|
|
7120
7120
|
totalRuns: z.ZodOptional<z.ZodInt>;
|
|
7121
|
-
totalUsers: z.ZodOptional<z.ZodInt>;
|
|
7122
7121
|
totalUsers7Days: z.ZodOptional<z.ZodInt>;
|
|
7123
7122
|
totalUsers30Days: z.ZodOptional<z.ZodInt>;
|
|
7124
7123
|
totalUsers90Days: z.ZodOptional<z.ZodInt>;
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
actorReviewCount: z.ZodOptional<z.ZodInt>;
|
|
7128
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7129
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7130
|
-
publicActorRunStats30Days: z.ZodOptional<z.ZodObject<{
|
|
7131
|
-
ABORTED: z.ZodOptional<z.ZodInt>;
|
|
7132
|
-
FAILED: z.ZodOptional<z.ZodInt>;
|
|
7133
|
-
SUCCEEDED: z.ZodOptional<z.ZodInt>;
|
|
7134
|
-
"TIMED-OUT": z.ZodOptional<z.ZodInt>;
|
|
7135
|
-
TOTAL: z.ZodOptional<z.ZodInt>;
|
|
7136
|
-
}, z.core.$loose>>;
|
|
7124
|
+
actorReviewRating: z.ZodNumber;
|
|
7125
|
+
actorReviewCount: z.ZodInt;
|
|
7137
7126
|
}, z.core.$loose>;
|
|
7138
7127
|
currentPricingInfo: z.ZodOptional<z.ZodObject<{
|
|
7139
7128
|
pricingModel: z.ZodString;
|
|
@@ -7157,9 +7146,7 @@ export declare const StoreActor: () => z.ZodObject<{
|
|
|
7157
7146
|
notifiedAboutRentalToPpePriceChangeAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
|
|
7158
7147
|
}, z.core.$loose>>;
|
|
7159
7148
|
isWhiteListedForAgenticPayments: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
7160
|
-
|
|
7161
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7162
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7149
|
+
isVerified: z.ZodOptional<z.ZodBoolean>;
|
|
7163
7150
|
badge: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7164
7151
|
readmeSummary: z.ZodOptional<z.ZodString>;
|
|
7165
7152
|
inputSchema: z.ZodOptional<z.ZodObject<{
|
|
@@ -7193,24 +7180,13 @@ export declare const ListOfStoreActors: () => z.ZodObject<{
|
|
|
7193
7180
|
userPictureUrl: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7194
7181
|
url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7195
7182
|
stats: z.ZodObject<{
|
|
7196
|
-
|
|
7183
|
+
totalUsers: z.ZodInt;
|
|
7197
7184
|
totalRuns: z.ZodOptional<z.ZodInt>;
|
|
7198
|
-
totalUsers: z.ZodOptional<z.ZodInt>;
|
|
7199
7185
|
totalUsers7Days: z.ZodOptional<z.ZodInt>;
|
|
7200
7186
|
totalUsers30Days: z.ZodOptional<z.ZodInt>;
|
|
7201
7187
|
totalUsers90Days: z.ZodOptional<z.ZodInt>;
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
actorReviewCount: z.ZodOptional<z.ZodInt>;
|
|
7205
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7206
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7207
|
-
publicActorRunStats30Days: z.ZodOptional<z.ZodObject<{
|
|
7208
|
-
ABORTED: z.ZodOptional<z.ZodInt>;
|
|
7209
|
-
FAILED: z.ZodOptional<z.ZodInt>;
|
|
7210
|
-
SUCCEEDED: z.ZodOptional<z.ZodInt>;
|
|
7211
|
-
"TIMED-OUT": z.ZodOptional<z.ZodInt>;
|
|
7212
|
-
TOTAL: z.ZodOptional<z.ZodInt>;
|
|
7213
|
-
}, z.core.$loose>>;
|
|
7188
|
+
actorReviewRating: z.ZodNumber;
|
|
7189
|
+
actorReviewCount: z.ZodInt;
|
|
7214
7190
|
}, z.core.$loose>;
|
|
7215
7191
|
currentPricingInfo: z.ZodOptional<z.ZodObject<{
|
|
7216
7192
|
pricingModel: z.ZodString;
|
|
@@ -7234,9 +7210,7 @@ export declare const ListOfStoreActors: () => z.ZodObject<{
|
|
|
7234
7210
|
notifiedAboutRentalToPpePriceChangeAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
|
|
7235
7211
|
}, z.core.$loose>>;
|
|
7236
7212
|
isWhiteListedForAgenticPayments: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
7237
|
-
|
|
7238
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7239
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7213
|
+
isVerified: z.ZodOptional<z.ZodBoolean>;
|
|
7240
7214
|
badge: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7241
7215
|
readmeSummary: z.ZodOptional<z.ZodString>;
|
|
7242
7216
|
inputSchema: z.ZodOptional<z.ZodObject<{
|
|
@@ -7272,24 +7246,13 @@ export declare const ListOfStoreActorsResponse: () => z.ZodObject<{
|
|
|
7272
7246
|
userPictureUrl: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7273
7247
|
url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
7274
7248
|
stats: z.ZodObject<{
|
|
7275
|
-
|
|
7249
|
+
totalUsers: z.ZodInt;
|
|
7276
7250
|
totalRuns: z.ZodOptional<z.ZodInt>;
|
|
7277
|
-
totalUsers: z.ZodOptional<z.ZodInt>;
|
|
7278
7251
|
totalUsers7Days: z.ZodOptional<z.ZodInt>;
|
|
7279
7252
|
totalUsers30Days: z.ZodOptional<z.ZodInt>;
|
|
7280
7253
|
totalUsers90Days: z.ZodOptional<z.ZodInt>;
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
actorReviewCount: z.ZodOptional<z.ZodInt>;
|
|
7284
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7285
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7286
|
-
publicActorRunStats30Days: z.ZodOptional<z.ZodObject<{
|
|
7287
|
-
ABORTED: z.ZodOptional<z.ZodInt>;
|
|
7288
|
-
FAILED: z.ZodOptional<z.ZodInt>;
|
|
7289
|
-
SUCCEEDED: z.ZodOptional<z.ZodInt>;
|
|
7290
|
-
"TIMED-OUT": z.ZodOptional<z.ZodInt>;
|
|
7291
|
-
TOTAL: z.ZodOptional<z.ZodInt>;
|
|
7292
|
-
}, z.core.$loose>>;
|
|
7254
|
+
actorReviewRating: z.ZodNumber;
|
|
7255
|
+
actorReviewCount: z.ZodInt;
|
|
7293
7256
|
}, z.core.$loose>;
|
|
7294
7257
|
currentPricingInfo: z.ZodOptional<z.ZodObject<{
|
|
7295
7258
|
pricingModel: z.ZodString;
|
|
@@ -7313,9 +7276,7 @@ export declare const ListOfStoreActorsResponse: () => z.ZodObject<{
|
|
|
7313
7276
|
notifiedAboutRentalToPpePriceChangeAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodCoercedDate<string>>>>;
|
|
7314
7277
|
}, z.core.$loose>>;
|
|
7315
7278
|
isWhiteListedForAgenticPayments: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
7316
|
-
|
|
7317
|
-
actorReviewRating: z.ZodOptional<z.ZodNumber>;
|
|
7318
|
-
bookmarkCount: z.ZodOptional<z.ZodInt>;
|
|
7279
|
+
isVerified: z.ZodOptional<z.ZodBoolean>;
|
|
7319
7280
|
badge: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7320
7281
|
readmeSummary: z.ZodOptional<z.ZodString>;
|
|
7321
7282
|
inputSchema: z.ZodOptional<z.ZodObject<{
|
|
@@ -1588,12 +1588,18 @@ export const StoreActor = lazySchema(() => z.looseObject({
|
|
|
1588
1588
|
pictureUrl: z.string().nullable().optional(),
|
|
1589
1589
|
userPictureUrl: z.url({ normalize: true }).nullable().optional(),
|
|
1590
1590
|
url: z.url({ normalize: true }).nullable().optional(),
|
|
1591
|
-
stats:
|
|
1591
|
+
stats: z.looseObject({
|
|
1592
|
+
totalUsers: z.int(),
|
|
1593
|
+
totalRuns: z.int().optional(),
|
|
1594
|
+
totalUsers7Days: z.int().optional(),
|
|
1595
|
+
totalUsers30Days: z.int().optional(),
|
|
1596
|
+
totalUsers90Days: z.int().optional(),
|
|
1597
|
+
actorReviewRating: z.number(),
|
|
1598
|
+
actorReviewCount: z.int(),
|
|
1599
|
+
}),
|
|
1592
1600
|
currentPricingInfo: CurrentPricingInfo().optional(),
|
|
1593
1601
|
isWhiteListedForAgenticPayments: z.boolean().nullable().optional(),
|
|
1594
|
-
|
|
1595
|
-
actorReviewRating: z.number().optional(),
|
|
1596
|
-
bookmarkCount: z.int().optional(),
|
|
1602
|
+
isVerified: z.boolean().optional(),
|
|
1597
1603
|
badge: z.string().nullable().optional(),
|
|
1598
1604
|
readmeSummary: z.string().optional(),
|
|
1599
1605
|
inputSchema: z.looseObject({
|
|
@@ -15,26 +15,40 @@ export type RequestInterceptorFunction = Parameters<AxiosInterceptorManager<Inte
|
|
|
15
15
|
export interface AxiosHttpClientOptions extends HttpClientOptions {
|
|
16
16
|
/** @default [] */
|
|
17
17
|
requestInterceptors?: RequestInterceptorFunction[];
|
|
18
|
+
/**
|
|
19
|
+
* Agent for plain HTTP requests in Node.js, in place of the built-in keep-alive one. A proxy agent goes here
|
|
20
|
+
* and in {@link httpsAgent}. The client does not destroy an agent it was given.
|
|
21
|
+
*/
|
|
22
|
+
httpAgent?: http.Agent;
|
|
23
|
+
/** Agent for HTTPS requests in Node.js, in place of the built-in keep-alive one. Requests to the Apify API use it. */
|
|
24
|
+
httpsAgent?: https.Agent;
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
27
|
+
* An HTTP client for {@link ApifyClient} built on [axios](https://axios-http.com), which was the transport of the
|
|
28
|
+
* client before version 3. It is exported from `apify-client/axios` and needs the `axios` package installed
|
|
29
|
+
* next to the client.
|
|
21
30
|
*
|
|
22
|
-
* It inherits the request pipeline from {@link HttpClient} and adds the transport: in Node.js, keep-alive agents
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
31
|
+
* It inherits the request pipeline from {@link HttpClient} and adds the transport: in Node.js, keep-alive agents;
|
|
32
|
+
* in the browser, the XHR adapter of axios, or its fetch adapter for a request that must not follow redirects.
|
|
33
|
+
* Network errors are retried, timeouts included, and a stream body is sent without following redirects, since the
|
|
34
|
+
* part of it already sent could not be replayed. The proxy environment variables are not read: pass a proxy agent
|
|
35
|
+
* in {@link AxiosHttpClientOptions.httpAgent} and {@link AxiosHttpClientOptions.httpsAgent} instead.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```javascript
|
|
39
|
+
* import { ApifyClient } from 'apify-client';
|
|
40
|
+
* import { AxiosHttpClient } from 'apify-client/axios';
|
|
41
|
+
*
|
|
42
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new AxiosHttpClient() });
|
|
43
|
+
* ```
|
|
27
44
|
*/
|
|
28
45
|
export declare class AxiosHttpClient extends HttpClient {
|
|
29
46
|
#private;
|
|
30
47
|
/** The axios instance the requests go through. */
|
|
31
48
|
axios: AxiosInstance;
|
|
32
|
-
/**
|
|
33
|
-
* Keep-alive agent for plain HTTP, created with the first request in Node.js. It is the same `ProxyAgent` as
|
|
34
|
-
* {@link httpsAgent}, so the socket pool is shared across both schemes.
|
|
35
|
-
*/
|
|
49
|
+
/** Agent for plain HTTP: the one from the options, or a keep-alive one created with the first request in Node.js. */
|
|
36
50
|
httpAgent?: http.Agent;
|
|
37
|
-
/**
|
|
51
|
+
/** Agent for HTTPS: the one from the options, or a keep-alive one created with the first request in Node.js. */
|
|
38
52
|
httpsAgent?: https.Agent;
|
|
39
53
|
constructor(options?: AxiosHttpClientOptions);
|
|
40
54
|
/**
|
|
@@ -49,8 +63,8 @@ export declare class AxiosHttpClient extends HttpClient {
|
|
|
49
63
|
*/
|
|
50
64
|
isRetryableTransportError(error: unknown): boolean;
|
|
51
65
|
/**
|
|
52
|
-
* Destroys the keep-alive agents, closing every pooled socket. A client that never sent a request in
|
|
53
|
-
* has nothing to close.
|
|
66
|
+
* Destroys the built-in keep-alive agents, closing every pooled socket. A client that never sent a request in
|
|
67
|
+
* Node.js has nothing to close, and agents passed in the options are left to their owner.
|
|
54
68
|
*/
|
|
55
69
|
close(): Promise<void>;
|
|
56
70
|
/**
|
|
@@ -4,29 +4,38 @@ import { ApifyClientError } from '../apify_client_error.js';
|
|
|
4
4
|
import { isStream } from '../utils.js';
|
|
5
5
|
import { HttpClient } from './base.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* An HTTP client for {@link ApifyClient} built on [axios](https://axios-http.com), which was the transport of the
|
|
8
|
+
* client before version 3. It is exported from `apify-client/axios` and needs the `axios` package installed
|
|
9
|
+
* next to the client.
|
|
8
10
|
*
|
|
9
|
-
* It inherits the request pipeline from {@link HttpClient} and adds the transport: in Node.js, keep-alive agents
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* It inherits the request pipeline from {@link HttpClient} and adds the transport: in Node.js, keep-alive agents;
|
|
12
|
+
* in the browser, the XHR adapter of axios, or its fetch adapter for a request that must not follow redirects.
|
|
13
|
+
* Network errors are retried, timeouts included, and a stream body is sent without following redirects, since the
|
|
14
|
+
* part of it already sent could not be replayed. The proxy environment variables are not read: pass a proxy agent
|
|
15
|
+
* in {@link AxiosHttpClientOptions.httpAgent} and {@link AxiosHttpClientOptions.httpsAgent} instead.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```javascript
|
|
19
|
+
* import { ApifyClient } from 'apify-client';
|
|
20
|
+
* import { AxiosHttpClient } from 'apify-client/axios';
|
|
21
|
+
*
|
|
22
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new AxiosHttpClient() });
|
|
23
|
+
* ```
|
|
14
24
|
*/
|
|
15
25
|
export class AxiosHttpClient extends HttpClient {
|
|
16
26
|
/** The axios instance the requests go through. */
|
|
17
27
|
axios;
|
|
18
|
-
/**
|
|
19
|
-
* Keep-alive agent for plain HTTP, created with the first request in Node.js. It is the same `ProxyAgent` as
|
|
20
|
-
* {@link httpsAgent}, so the socket pool is shared across both schemes.
|
|
21
|
-
*/
|
|
28
|
+
/** Agent for plain HTTP: the one from the options, or a keep-alive one created with the first request in Node.js. */
|
|
22
29
|
httpAgent;
|
|
23
|
-
/**
|
|
30
|
+
/** Agent for HTTPS: the one from the options, or a keep-alive one created with the first request in Node.js. */
|
|
24
31
|
httpsAgent;
|
|
32
|
+
/** The built-in agents, which are the ones `close()` destroys. */
|
|
33
|
+
#ownAgents = [];
|
|
25
34
|
#httpAgentsPromise;
|
|
26
35
|
constructor(options = {}) {
|
|
27
36
|
super(options);
|
|
28
37
|
this.axios = axios.create({
|
|
29
|
-
//
|
|
38
|
+
// Axios cannot tunnel HTTPS through a proxy on its own, so a proxy is left to the agents.
|
|
30
39
|
proxy: false,
|
|
31
40
|
validateStatus: null,
|
|
32
41
|
// The shared pipeline serializes and parses the bodies, so axios only moves bytes.
|
|
@@ -42,6 +51,8 @@ export class AxiosHttpClient extends HttpClient {
|
|
|
42
51
|
});
|
|
43
52
|
// The pipeline merges every header the client sends, so the axios defaults would only get in the way.
|
|
44
53
|
this.axios.defaults.headers = new AxiosHeaders();
|
|
54
|
+
this.httpAgent = options.httpAgent;
|
|
55
|
+
this.httpsAgent = options.httpsAgent;
|
|
45
56
|
for (const interceptor of options.requestInterceptors ?? []) {
|
|
46
57
|
this.axios.interceptors.request.use(interceptor);
|
|
47
58
|
}
|
|
@@ -69,14 +80,14 @@ export class AxiosHttpClient extends HttpClient {
|
|
|
69
80
|
return typeof error.request === 'object' && error.request !== null && error.config != null;
|
|
70
81
|
}
|
|
71
82
|
/**
|
|
72
|
-
* Destroys the keep-alive agents, closing every pooled socket. A client that never sent a request in
|
|
73
|
-
* has nothing to close.
|
|
83
|
+
* Destroys the built-in keep-alive agents, closing every pooled socket. A client that never sent a request in
|
|
84
|
+
* Node.js has nothing to close, and agents passed in the options are left to their owner.
|
|
74
85
|
*/
|
|
75
86
|
async close() {
|
|
76
87
|
// A failed initialization left nothing to release, and its error belongs to the request that hit it.
|
|
77
88
|
await this.#httpAgentsPromise?.catch(() => { });
|
|
78
|
-
this.
|
|
79
|
-
|
|
89
|
+
for (const agent of this.#ownAgents.splice(0))
|
|
90
|
+
agent.destroy();
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* Sends the request through axios and hands the raw response back. A stream body is sent without following
|
|
@@ -119,11 +130,15 @@ export class AxiosHttpClient extends HttpClient {
|
|
|
119
130
|
}
|
|
120
131
|
async #initHttpAgents() {
|
|
121
132
|
const agents = await runtime.createHttpAgents({ timeoutMillis: this.timeoutMaxMillis });
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
if (agents) {
|
|
134
|
+
this.httpAgent ??= this.#own(agents.httpAgent);
|
|
135
|
+
this.httpsAgent ??= this.#own(agents.httpsAgent);
|
|
136
|
+
}
|
|
126
137
|
this.axios.defaults.httpAgent = this.httpAgent;
|
|
127
138
|
this.axios.defaults.httpsAgent = this.httpsAgent;
|
|
128
139
|
}
|
|
140
|
+
#own(agent) {
|
|
141
|
+
this.#ownAgents.push(agent);
|
|
142
|
+
return agent;
|
|
143
|
+
}
|
|
129
144
|
}
|
|
@@ -243,7 +243,7 @@ export interface HttpClientOptions {
|
|
|
243
243
|
* ```javascript
|
|
244
244
|
* import { ApifyClient, HttpClient } from 'apify-client';
|
|
245
245
|
*
|
|
246
|
-
* class
|
|
246
|
+
* class MyFetchHttpClient extends HttpClient {
|
|
247
247
|
* async sendRequest({ method, url, headers, body, timeoutMillis, followRedirects, signal }) {
|
|
248
248
|
* const signals = signal ? [signal] : [];
|
|
249
249
|
* if (timeoutMillis !== undefined) signals.push(AbortSignal.timeout(timeoutMillis));
|
|
@@ -267,7 +267,7 @@ export interface HttpClientOptions {
|
|
|
267
267
|
* }
|
|
268
268
|
* }
|
|
269
269
|
*
|
|
270
|
-
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new
|
|
270
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new MyFetchHttpClient() });
|
|
271
271
|
* ```
|
|
272
272
|
*/
|
|
273
273
|
export declare abstract class HttpClient {
|
|
@@ -54,7 +54,7 @@ const UNSERIALIZABLE_OBJECT_TAGS = new Set(['FormData', 'ReadableStream']);
|
|
|
54
54
|
* ```javascript
|
|
55
55
|
* import { ApifyClient, HttpClient } from 'apify-client';
|
|
56
56
|
*
|
|
57
|
-
* class
|
|
57
|
+
* class MyFetchHttpClient extends HttpClient {
|
|
58
58
|
* async sendRequest({ method, url, headers, body, timeoutMillis, followRedirects, signal }) {
|
|
59
59
|
* const signals = signal ? [signal] : [];
|
|
60
60
|
* if (timeoutMillis !== undefined) signals.push(AbortSignal.timeout(timeoutMillis));
|
|
@@ -78,7 +78,7 @@ const UNSERIALIZABLE_OBJECT_TAGS = new Set(['FormData', 'ReadableStream']);
|
|
|
78
78
|
* }
|
|
79
79
|
* }
|
|
80
80
|
*
|
|
81
|
-
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new
|
|
81
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new MyFetchHttpClient() });
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
84
|
export class HttpClient {
|
|
@@ -471,7 +471,10 @@ export class HttpClient {
|
|
|
471
471
|
}
|
|
472
472
|
#onRequestRetry(error, attempt) {
|
|
473
473
|
if (attempt === Math.round(this.maxRetries / 2)) {
|
|
474
|
-
|
|
474
|
+
// A failed `fetch` names the network error only in its `cause`, and Bun gives its errors no stack.
|
|
475
|
+
const { stack, cause } = error;
|
|
476
|
+
const causedBy = cause instanceof Error ? `\nCaused by: ${cause.stack ?? cause}` : '';
|
|
477
|
+
this.logger.warning(`API request failed ${attempt} times. Max attempts: ${this.maxRetries + 1}.\nCause:${stack ?? error}${causedBy}`);
|
|
475
478
|
}
|
|
476
479
|
}
|
|
477
480
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HttpClientOptions, HttpRequest, HttpResponse } from './base.js';
|
|
2
|
+
import { HttpClient } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* A function with the signature of the global [`fetch`](https://developer.mozilla.org/docs/Web/API/Window/fetch).
|
|
5
|
+
*/
|
|
6
|
+
export type FetchFunction = typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* Configuration of {@link FetchHttpClient}.
|
|
9
|
+
*/
|
|
10
|
+
export interface FetchHttpClientOptions extends HttpClientOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The `fetch` implementation the requests go through. Pass a wrapper around the global `fetch` to adjust every
|
|
13
|
+
* request, or the `fetch` of another library, such as `undici` with a dispatcher of your own, to control the
|
|
14
|
+
* connections. A stream body reaches it as an async iterable of byte chunks, or as the stream itself in Bun.
|
|
15
|
+
* @default globalThis.fetch
|
|
16
|
+
*/
|
|
17
|
+
fetch?: FetchFunction;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The default HTTP client of {@link ApifyClient}, built on the `fetch` of the runtime, so it works the same way in
|
|
21
|
+
* Node.js, browsers and edge runtimes and brings no dependency of its own.
|
|
22
|
+
*
|
|
23
|
+
* It inherits the request pipeline from {@link HttpClient} and adds the transport. Network errors are retried,
|
|
24
|
+
* timeouts included, and a stream body is sent without following redirects, since the part of it already sent could
|
|
25
|
+
* not be replayed. The timeout of a request runs until the response headers arrive and starts over with every chunk
|
|
26
|
+
* of the response body and of a stream body, so a large download or upload does not time out while it makes progress.
|
|
27
|
+
*
|
|
28
|
+
* In Node.js, `fetch` keeps connections alive on its own, and goes through a proxy only when Node.js is told to
|
|
29
|
+
* read the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables: start it with `NODE_USE_ENV_PROXY=1`
|
|
30
|
+
* (Node.js 22.21 and 24.0) or `--use-env-proxy` (Node.js 22.21 and 24.5).
|
|
31
|
+
*/
|
|
32
|
+
export declare class FetchHttpClient extends HttpClient {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(options?: FetchHttpClientOptions);
|
|
35
|
+
/**
|
|
36
|
+
* A timeout is the `TimeoutError` this client aborts a late request with, or a `fetch` failure caused by one of
|
|
37
|
+
* the connection, headers and body timeouts of Node.js.
|
|
38
|
+
*/
|
|
39
|
+
isTimeoutError(error: unknown): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* A network failure is the `TypeError` that `fetch` rejects with: a connection that could not be made, dropped
|
|
42
|
+
* mid-way or timed out. In Node.js it carries the failure as its `cause`, which tells it apart from a request
|
|
43
|
+
* that was never sent, such as one with an invalid URL. Bun rejects with an `Error` that has a `code` instead.
|
|
44
|
+
*/
|
|
45
|
+
isRetryableTransportError(error: unknown): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Sends the request through `fetch` and hands the raw response back. A stream body is sent without following
|
|
48
|
+
* redirects, and so is a request with `followRedirects: false`. A browser hides such a redirect response from
|
|
49
|
+
* the page, so there it fails the request.
|
|
50
|
+
*/
|
|
51
|
+
sendRequest(request: HttpRequest): Promise<HttpResponse>;
|
|
52
|
+
}
|