apify-client 3.0.0-beta.23 → 3.0.0-beta.24
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 +6 -0
- package/dist/apify_api_error.d.ts +3 -3
- package/dist/apify_api_error.js +11 -4
- package/dist/apify_client.d.ts +70 -5
- package/dist/apify_client.js +91 -18
- package/dist/base/api_client.d.ts +1 -1
- package/dist/bundle.js +14 -14
- package/dist/bundle.js.map +1 -1
- package/dist/generated/schemas.d.ts +110 -110
- package/dist/http_clients/axios.d.ts +60 -0
- package/dist/http_clients/axios.js +117 -0
- package/dist/http_clients/base.d.ts +333 -0
- package/dist/http_clients/base.js +583 -0
- package/dist/http_clients/index.d.ts +4 -0
- package/dist/http_clients/index.js +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/invalid_response_body_error.d.ts +13 -0
- package/dist/invalid_response_body_error.js +17 -0
- package/dist/resource_clients/actor.js +2 -4
- package/dist/resource_clients/dataset.js +4 -3
- package/dist/resource_clients/key_value_store.js +1 -1
- package/dist/resource_clients/run.d.ts +1 -1
- package/dist/resource_clients/run.js +1 -2
- package/dist/resource_clients/task.js +1 -2
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -3
- package/dist/http_client.d.ts +0 -62
- package/dist/http_client.js +0 -266
- package/dist/interceptors.d.ts +0 -26
- package/dist/interceptors.js +0 -153
package/README.md
CHANGED
|
@@ -59,6 +59,12 @@ By default, it will retry up to 8 times. First retry will be attempted after ~50
|
|
|
59
59
|
and so on. You can configure those parameters using the `maxRetries` and `minDelayBetweenRetriesMillis`
|
|
60
60
|
options of the `ApifyClient` constructor.
|
|
61
61
|
|
|
62
|
+
### Pluggable HTTP client
|
|
63
|
+
|
|
64
|
+
The client ships with an axios-based HTTP client and accepts a custom one. Extend `HttpClient`, implement
|
|
65
|
+
`sendRequest()` over the HTTP library of your choice and plug it in with `ApifyClient.withCustomHttpClient()`. The
|
|
66
|
+
custom client inherits the retries, timeouts, compression and error handling of the built-in one.
|
|
67
|
+
|
|
62
68
|
### Convenience functions and options
|
|
63
69
|
|
|
64
70
|
Some actions can't be performed by the API itself, such as indefinite waiting for an actor run to finish
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AxiosResponse } from 'axios';
|
|
2
1
|
import type { LiteralUnion } from 'type-fest';
|
|
2
|
+
import type { ApifyResponse } from './http_clients/base.js';
|
|
3
3
|
import type { ApifyApiErrorType } from './models.js';
|
|
4
4
|
export type { ApifyApiErrorType } from './models.js';
|
|
5
5
|
/**
|
|
@@ -58,12 +58,12 @@ export declare class ApifyApiError extends Error {
|
|
|
58
58
|
/**
|
|
59
59
|
* @hidden
|
|
60
60
|
*/
|
|
61
|
-
constructor(response:
|
|
61
|
+
constructor(response: ApifyResponse, attempt: number);
|
|
62
62
|
/**
|
|
63
63
|
* Creates the error for a failed response as an instance of the subclass matching its HTTP status code.
|
|
64
64
|
* @hidden
|
|
65
65
|
*/
|
|
66
|
-
static fromResponse(response:
|
|
66
|
+
static fromResponse(response: ApifyResponse, attempt: number): ApifyApiError;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Thrown when the Apify API responds with HTTP 400 Bad Request, typically because the request
|
package/dist/apify_api_error.js
CHANGED
|
@@ -6,9 +6,16 @@ import { isBuffer } from './utils.js';
|
|
|
6
6
|
* 2: "ActorCollectionClient"
|
|
7
7
|
* 3: undefined
|
|
8
8
|
* 4: "listResources"
|
|
9
|
+
*
|
|
10
|
+
* The error is created inside the HTTP client's pipeline, whose frames sit above the resource client's. The
|
|
11
|
+
* pipeline's own methods are private, so V8 prints them with a `#` that no method name can match. Its public
|
|
12
|
+
* `call()` prints under the name of the transport's class, which can be anything, so the lookaheads skip a class
|
|
13
|
+
* named after `HttpClient` and the method `call`. A transport named `SomethingClient` whose `call()` override
|
|
14
|
+
* awaits a helper of its own is reported under that helper. `ActorClient.call()` and `TaskClient.call()` reach the
|
|
15
|
+
* pipeline through `start()`, whose frame sits closer to the error and matches first.
|
|
9
16
|
* @private
|
|
10
17
|
*/
|
|
11
|
-
const CLIENT_METHOD_REGEX = /at( async)? ([A-Za-z]+(Collection)?Client)\.([A-Za-z]+) \(/;
|
|
18
|
+
const CLIENT_METHOD_REGEX = /at( async)? (?![A-Za-z]*HttpClient\.)([A-Za-z]+(Collection)?Client)\.(?!call \()([A-Za-z]+) \(/;
|
|
12
19
|
/**
|
|
13
20
|
* An `ApifyApiError` is thrown for successful HTTP requests that reach the API,
|
|
14
21
|
* but the API responds with an error response. Typically, those are rate limit
|
|
@@ -69,8 +76,8 @@ export class ApifyApiError extends Error {
|
|
|
69
76
|
let type;
|
|
70
77
|
let responseData = response.data;
|
|
71
78
|
let errorData;
|
|
72
|
-
// A `
|
|
73
|
-
// has read into a buffer, both arrive unparsed. Parse the body here to get at the error.
|
|
79
|
+
// A `responseType: 'buffer'` request (e.g. `downloadItems()`) and a failed streaming request, whose body
|
|
80
|
+
// `HttpClient` has read into a buffer, both arrive unparsed. Parse the body here to get at the error.
|
|
74
81
|
if (isBuffer(responseData)) {
|
|
75
82
|
const body = new TextDecoder().decode(response.data);
|
|
76
83
|
try {
|
|
@@ -146,7 +153,7 @@ export class ApifyApiError extends Error {
|
|
|
146
153
|
* statusCode: 404
|
|
147
154
|
* type: record-not-found
|
|
148
155
|
* attempt: 1
|
|
149
|
-
* httpMethod:
|
|
156
|
+
* httpMethod: POST
|
|
150
157
|
* path: /v2/actor-tasks/user~my-task/runs
|
|
151
158
|
*/
|
|
152
159
|
#createApiStack() {
|
package/dist/apify_client.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { SetStatusMessageOptions } from '@crawlee/types';
|
|
2
2
|
import type { Log } from '@apify/log';
|
|
3
|
-
import { HttpClient } from './
|
|
3
|
+
import { HttpClient } from './http_clients/base.js';
|
|
4
4
|
import type { HttpCompressor } from './http_compressors/base.js';
|
|
5
5
|
import type { HttpCompressionAlgorithm } from './http_compressors/resolve.js';
|
|
6
|
-
import type { RequestInterceptorFunction } from './interceptors.js';
|
|
7
6
|
import { ActorClient } from './resource_clients/actor.js';
|
|
8
7
|
import { ActorCollectionClient } from './resource_clients/actor_collection.js';
|
|
9
8
|
import { BuildClient } from './resource_clients/build.js';
|
|
@@ -58,10 +57,59 @@ export declare class ApifyClient {
|
|
|
58
57
|
*/
|
|
59
58
|
publicBaseUrl: string;
|
|
60
59
|
token?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Statistics of the API calls made through the client. With a custom HTTP client, this is the client's own
|
|
62
|
+
* `stats` object, so it only reflects what that client records.
|
|
63
|
+
*/
|
|
61
64
|
stats: Statistics;
|
|
62
65
|
logger: Log;
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Creates a client that sends its requests through the built-in {@link AxiosHttpClient}, configured from
|
|
68
|
+
* `options`: the API token, retries, the timeout tiers, request compression and default headers. The HTTP
|
|
69
|
+
* client itself is created when {@link httpClient} is first read. To send the requests through a custom HTTP
|
|
70
|
+
* client, use {@link ApifyClient.withCustomHttpClient} instead.
|
|
71
|
+
*
|
|
72
|
+
* @param options - Configuration of the client and of its HTTP client.
|
|
73
|
+
* @throws {ArgumentValidationError} When an option is unknown or has an invalid value.
|
|
74
|
+
*/
|
|
64
75
|
constructor(options?: ApifyClientOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Creates an `ApifyClient` that sends its requests through a custom HTTP client.
|
|
78
|
+
*
|
|
79
|
+
* The custom client owns its transport configuration: retries, timeouts, default headers and whatever its
|
|
80
|
+
* transport needs are set on the client itself. This is also how the built-in {@link AxiosHttpClient} is
|
|
81
|
+
* configured beyond what the constructor options offer, for example with axios request interceptors. The
|
|
82
|
+
* token is set as the client's `Authorization` header, unless the client already has one configured.
|
|
83
|
+
*
|
|
84
|
+
* @param options - The token, the API URLs and the HTTP client to use.
|
|
85
|
+
* @returns A client whose {@link httpClient} is the given one.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```javascript
|
|
89
|
+
* import { ApifyClient, HttpClient } from 'apify-client';
|
|
90
|
+
*
|
|
91
|
+
* class MyHttpClient extends HttpClient {
|
|
92
|
+
* async sendRequest({ method, url, headers, body, timeoutMillis, stream, signal }) {
|
|
93
|
+
* // Send the request with the HTTP library of your choice and return { status, headers, body }.
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new MyHttpClient() });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
static withCustomHttpClient(options: ApifyClientCustomHttpClientOptions): ApifyClient;
|
|
101
|
+
/**
|
|
102
|
+
* The HTTP client the requests go through: the custom one when set through
|
|
103
|
+
* {@link ApifyClient.withCustomHttpClient}, and otherwise an {@link AxiosHttpClient} configured from the
|
|
104
|
+
* constructor options, created on first access. Assigning a client applies {@link token} to it through
|
|
105
|
+
* {@link HttpClient.setDefaultAuthorization} and points {@link stats} at its statistics, so the counters keep
|
|
106
|
+
* tracking the calls the client actually makes. Resource clients hold on to the HTTP client they were created
|
|
107
|
+
* with, so assign before reaching for them. Assigning does not close the client it replaces. A default client
|
|
108
|
+
* that already sent a request keeps its keep-alive agents open until {@link HttpClient.close} is called on it,
|
|
109
|
+
* so close it yourself, or assign before the first request.
|
|
110
|
+
*/
|
|
111
|
+
get httpClient(): HttpClient;
|
|
112
|
+
set httpClient(httpClient: HttpClient);
|
|
65
113
|
/**
|
|
66
114
|
* Returns a client for managing Actors in your account.
|
|
67
115
|
*
|
|
@@ -362,6 +410,11 @@ export interface ApifyClientOptions {
|
|
|
362
410
|
* @default 'brotli'
|
|
363
411
|
*/
|
|
364
412
|
compression?: HttpCompressionAlgorithm | HttpCompressor;
|
|
413
|
+
/**
|
|
414
|
+
* Additional headers sent with every request, such as an integration platform marker. They win over the
|
|
415
|
+
* built-in defaults, and a header set on a single call wins over them.
|
|
416
|
+
*/
|
|
417
|
+
headers?: Record<string, string>;
|
|
365
418
|
/**
|
|
366
419
|
* @default https://api.apify.com
|
|
367
420
|
* @since Added in 2.17.0
|
|
@@ -371,8 +424,6 @@ export interface ApifyClientOptions {
|
|
|
371
424
|
maxRetries?: number;
|
|
372
425
|
/** @default 500 */
|
|
373
426
|
minDelayBetweenRetriesMillis?: number;
|
|
374
|
-
/** @default [] */
|
|
375
|
-
requestInterceptors?: RequestInterceptorFunction[];
|
|
376
427
|
/**
|
|
377
428
|
* Duration of the `short` timeout tier, in seconds: simple metadata reads and writes.
|
|
378
429
|
* @default 5
|
|
@@ -400,3 +451,17 @@ export interface ApifyClientOptions {
|
|
|
400
451
|
*/
|
|
401
452
|
userAgentSuffix?: string | string[];
|
|
402
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Configuration options for {@link ApifyClient.withCustomHttpClient}. Retries, timeouts and headers are configured
|
|
456
|
+
* on the HTTP client itself.
|
|
457
|
+
*/
|
|
458
|
+
export interface ApifyClientCustomHttpClientOptions {
|
|
459
|
+
/** @default https://api.apify.com */
|
|
460
|
+
baseUrl?: string;
|
|
461
|
+
/** @default https://api.apify.com */
|
|
462
|
+
publicBaseUrl?: string;
|
|
463
|
+
/** Set as the HTTP client's `Authorization` header, unless it already has one. */
|
|
464
|
+
token?: string;
|
|
465
|
+
/** The HTTP client to send the requests through. */
|
|
466
|
+
httpClient: HttpClient;
|
|
467
|
+
}
|
package/dist/apify_client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ACTOR_ENV_VARS, ME_USER_NAME_PLACEHOLDER } from '@apify/consts';
|
|
3
3
|
import logger from '@apify/log';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { AxiosHttpClient } from './http_clients/axios.js';
|
|
5
|
+
import { DEFAULT_MAX_RETRIES, DEFAULT_MIN_DELAY_BETWEEN_RETRIES_MILLIS, HttpClient, httpClientOptionsShape, } from './http_clients/base.js';
|
|
6
|
+
import { compressionSchema } from './http_compressors/resolve.js';
|
|
6
7
|
import { ActorClient } from './resource_clients/actor.js';
|
|
7
8
|
import { ActorCollectionClient } from './resource_clients/actor_collection.js';
|
|
8
9
|
import { BuildClient } from './resource_clients/build.js';
|
|
@@ -29,20 +30,27 @@ import { WebhookDispatchCollectionClient } from './resource_clients/webhook_disp
|
|
|
29
30
|
import { Statistics } from './statistics.js';
|
|
30
31
|
import { DEFAULT_TIMEOUT_LONG_SECS, DEFAULT_TIMEOUT_MAX_SECS, DEFAULT_TIMEOUT_MEDIUM_SECS, DEFAULT_TIMEOUT_SHORT_SECS, } from './timeouts.js';
|
|
31
32
|
import { getEnv, parseArgument } from './utils.js';
|
|
33
|
+
const DEFAULT_API_URL = 'https://api.apify.com';
|
|
32
34
|
const clientOptionsSchema = z.strictObject({
|
|
33
|
-
baseUrl: z.string().default(
|
|
35
|
+
baseUrl: z.string().default(DEFAULT_API_URL),
|
|
34
36
|
compression: compressionSchema.default('brotli'),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
timeoutShortSecs:
|
|
40
|
-
timeoutMediumSecs:
|
|
41
|
-
timeoutLongSecs:
|
|
42
|
-
timeoutMaxSecs:
|
|
37
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
38
|
+
publicBaseUrl: z.string().default(DEFAULT_API_URL),
|
|
39
|
+
maxRetries: httpClientOptionsShape.maxRetries.default(DEFAULT_MAX_RETRIES),
|
|
40
|
+
minDelayBetweenRetriesMillis: httpClientOptionsShape.minDelayBetweenRetriesMillis.default(DEFAULT_MIN_DELAY_BETWEEN_RETRIES_MILLIS),
|
|
41
|
+
timeoutShortSecs: httpClientOptionsShape.timeoutShortSecs.default(DEFAULT_TIMEOUT_SHORT_SECS),
|
|
42
|
+
timeoutMediumSecs: httpClientOptionsShape.timeoutMediumSecs.default(DEFAULT_TIMEOUT_MEDIUM_SECS),
|
|
43
|
+
timeoutLongSecs: httpClientOptionsShape.timeoutLongSecs.default(DEFAULT_TIMEOUT_LONG_SECS),
|
|
44
|
+
timeoutMaxSecs: httpClientOptionsShape.timeoutMaxSecs.default(DEFAULT_TIMEOUT_MAX_SECS),
|
|
43
45
|
token: z.string().optional(),
|
|
44
46
|
userAgentSuffix: z.union([z.string(), z.array(z.string())]).optional(),
|
|
45
47
|
});
|
|
48
|
+
const customHttpClientOptionsSchema = z.strictObject({
|
|
49
|
+
baseUrl: z.string().default(DEFAULT_API_URL),
|
|
50
|
+
publicBaseUrl: z.string().default(DEFAULT_API_URL),
|
|
51
|
+
token: z.string().optional(),
|
|
52
|
+
httpClient: z.instanceof(HttpClient),
|
|
53
|
+
});
|
|
46
54
|
const resourceIdSchema = z.string().min(1);
|
|
47
55
|
const requestQueueOptionsSchema = z.strictObject({
|
|
48
56
|
clientKey: z.string().min(1).optional(),
|
|
@@ -76,12 +84,27 @@ export class ApifyClient {
|
|
|
76
84
|
*/
|
|
77
85
|
publicBaseUrl;
|
|
78
86
|
token;
|
|
87
|
+
/**
|
|
88
|
+
* Statistics of the API calls made through the client. With a custom HTTP client, this is the client's own
|
|
89
|
+
* `stats` object, so it only reflects what that client records.
|
|
90
|
+
*/
|
|
79
91
|
stats;
|
|
80
92
|
logger;
|
|
81
|
-
httpClient;
|
|
93
|
+
#httpClient;
|
|
94
|
+
/** Configuration of the default HTTP client, applied when no custom one is set. */
|
|
95
|
+
#httpClientOptions;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a client that sends its requests through the built-in {@link AxiosHttpClient}, configured from
|
|
98
|
+
* `options`: the API token, retries, the timeout tiers, request compression and default headers. The HTTP
|
|
99
|
+
* client itself is created when {@link httpClient} is first read. To send the requests through a custom HTTP
|
|
100
|
+
* client, use {@link ApifyClient.withCustomHttpClient} instead.
|
|
101
|
+
*
|
|
102
|
+
* @param options - Configuration of the client and of its HTTP client.
|
|
103
|
+
* @throws {ArgumentValidationError} When an option is unknown or has an invalid value.
|
|
104
|
+
*/
|
|
82
105
|
constructor(options = {}) {
|
|
83
106
|
const parsed = parseArgument(options, clientOptionsSchema, 'ApifyClientOptions');
|
|
84
|
-
const { baseUrl, compression, publicBaseUrl, maxRetries, minDelayBetweenRetriesMillis,
|
|
107
|
+
const { baseUrl, compression, headers, publicBaseUrl, maxRetries, minDelayBetweenRetriesMillis, timeoutShortSecs, timeoutMediumSecs, timeoutLongSecs, timeoutMaxSecs, token, } = parsed;
|
|
85
108
|
const tempBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, baseUrl.length - 1) : baseUrl;
|
|
86
109
|
this.baseUrl = `${tempBaseUrl}/v2`;
|
|
87
110
|
const tempPublicBaseUrl = publicBaseUrl.endsWith('/')
|
|
@@ -91,12 +114,12 @@ export class ApifyClient {
|
|
|
91
114
|
this.token = token;
|
|
92
115
|
this.stats = new Statistics();
|
|
93
116
|
this.logger = logger.child({ prefix: 'ApifyClient' });
|
|
94
|
-
this
|
|
95
|
-
|
|
117
|
+
this.#httpClientOptions = {
|
|
118
|
+
stats: this.stats,
|
|
96
119
|
maxRetries,
|
|
97
120
|
minDelayBetweenRetriesMillis,
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
compression,
|
|
122
|
+
headers,
|
|
100
123
|
timeoutShortSecs,
|
|
101
124
|
timeoutMediumSecs,
|
|
102
125
|
timeoutLongSecs,
|
|
@@ -104,7 +127,57 @@ export class ApifyClient {
|
|
|
104
127
|
logger: this.logger,
|
|
105
128
|
token: this.token,
|
|
106
129
|
userAgentSuffix: parsed.userAgentSuffix,
|
|
107
|
-
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates an `ApifyClient` that sends its requests through a custom HTTP client.
|
|
134
|
+
*
|
|
135
|
+
* The custom client owns its transport configuration: retries, timeouts, default headers and whatever its
|
|
136
|
+
* transport needs are set on the client itself. This is also how the built-in {@link AxiosHttpClient} is
|
|
137
|
+
* configured beyond what the constructor options offer, for example with axios request interceptors. The
|
|
138
|
+
* token is set as the client's `Authorization` header, unless the client already has one configured.
|
|
139
|
+
*
|
|
140
|
+
* @param options - The token, the API URLs and the HTTP client to use.
|
|
141
|
+
* @returns A client whose {@link httpClient} is the given one.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```javascript
|
|
145
|
+
* import { ApifyClient, HttpClient } from 'apify-client';
|
|
146
|
+
*
|
|
147
|
+
* class MyHttpClient extends HttpClient {
|
|
148
|
+
* async sendRequest({ method, url, headers, body, timeoutMillis, stream, signal }) {
|
|
149
|
+
* // Send the request with the HTTP library of your choice and return { status, headers, body }.
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
152
|
+
*
|
|
153
|
+
* const client = ApifyClient.withCustomHttpClient({ token: 'my-token', httpClient: new MyHttpClient() });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
static withCustomHttpClient(options) {
|
|
157
|
+
const { httpClient, ...rest } = parseArgument(options, customHttpClientOptionsSchema, 'ApifyClientCustomHttpClientOptions');
|
|
158
|
+
const client = new ApifyClient(rest);
|
|
159
|
+
client.httpClient = httpClient;
|
|
160
|
+
return client;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The HTTP client the requests go through: the custom one when set through
|
|
164
|
+
* {@link ApifyClient.withCustomHttpClient}, and otherwise an {@link AxiosHttpClient} configured from the
|
|
165
|
+
* constructor options, created on first access. Assigning a client applies {@link token} to it through
|
|
166
|
+
* {@link HttpClient.setDefaultAuthorization} and points {@link stats} at its statistics, so the counters keep
|
|
167
|
+
* tracking the calls the client actually makes. Resource clients hold on to the HTTP client they were created
|
|
168
|
+
* with, so assign before reaching for them. Assigning does not close the client it replaces. A default client
|
|
169
|
+
* that already sent a request keeps its keep-alive agents open until {@link HttpClient.close} is called on it,
|
|
170
|
+
* so close it yourself, or assign before the first request.
|
|
171
|
+
*/
|
|
172
|
+
get httpClient() {
|
|
173
|
+
this.#httpClient ??= new AxiosHttpClient(this.#httpClientOptions);
|
|
174
|
+
return this.#httpClient;
|
|
175
|
+
}
|
|
176
|
+
set httpClient(httpClient) {
|
|
177
|
+
if (this.token)
|
|
178
|
+
httpClient.setDefaultAuthorization(this.token);
|
|
179
|
+
this.#httpClient = httpClient;
|
|
180
|
+
this.stats = httpClient.stats;
|
|
108
181
|
}
|
|
109
182
|
#subClientOptions() {
|
|
110
183
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApifyClient } from '../apify_client.js';
|
|
2
|
-
import type { HttpClient } from '../
|
|
2
|
+
import type { HttpClient } from '../http_clients/index.js';
|
|
3
3
|
import type { PaginatedResponse, PaginationOptions } from '../utils.js';
|
|
4
4
|
/** @private */
|
|
5
5
|
export interface ApiClientOptions {
|