apify-client 3.0.0-beta.28 → 3.0.0-beta.29
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_client.d.ts +15 -3
- package/dist/apify_client.js +9 -6
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -1
- package/package.json +2 -2
package/dist/apify_client.d.ts
CHANGED
|
@@ -401,7 +401,10 @@ export declare class ApifyClient {
|
|
|
401
401
|
* Configuration options for ApifyClient.
|
|
402
402
|
*/
|
|
403
403
|
export interface ApifyClientOptions {
|
|
404
|
-
/**
|
|
404
|
+
/**
|
|
405
|
+
* URL of the Apify API, with or without the `/v2` version path, which is appended when missing.
|
|
406
|
+
* @default https://api.apify.com
|
|
407
|
+
*/
|
|
405
408
|
baseUrl?: string;
|
|
406
409
|
/**
|
|
407
410
|
* Compression of request bodies: the name of a built-in algorithm, or an {@link HttpCompressor} for a custom
|
|
@@ -416,6 +419,8 @@ export interface ApifyClientOptions {
|
|
|
416
419
|
*/
|
|
417
420
|
headers?: Record<string, string>;
|
|
418
421
|
/**
|
|
422
|
+
* Publicly accessible URL of the Apify API, used in the URLs the client generates. Like `baseUrl`, with or
|
|
423
|
+
* without the `/v2` version path.
|
|
419
424
|
* @default https://api.apify.com
|
|
420
425
|
* @since Added in 2.17.0
|
|
421
426
|
*/
|
|
@@ -456,9 +461,16 @@ export interface ApifyClientOptions {
|
|
|
456
461
|
* on the HTTP client itself.
|
|
457
462
|
*/
|
|
458
463
|
export interface ApifyClientCustomHttpClientOptions {
|
|
459
|
-
/**
|
|
464
|
+
/**
|
|
465
|
+
* URL of the Apify API, with or without the `/v2` version path, which is appended when missing.
|
|
466
|
+
* @default https://api.apify.com
|
|
467
|
+
*/
|
|
460
468
|
baseUrl?: string;
|
|
461
|
-
/**
|
|
469
|
+
/**
|
|
470
|
+
* Publicly accessible URL of the Apify API, used in the URLs the client generates. Like `baseUrl`, with or
|
|
471
|
+
* without the `/v2` version path.
|
|
472
|
+
* @default https://api.apify.com
|
|
473
|
+
*/
|
|
462
474
|
publicBaseUrl?: string;
|
|
463
475
|
/** Set as the HTTP client's `Authorization` header, unless it already has one. */
|
|
464
476
|
token?: string;
|
package/dist/apify_client.js
CHANGED
|
@@ -31,6 +31,13 @@ import { Statistics } from './statistics.js';
|
|
|
31
31
|
import { DEFAULT_TIMEOUT_LONG_SECS, DEFAULT_TIMEOUT_MAX_SECS, DEFAULT_TIMEOUT_MEDIUM_SECS, DEFAULT_TIMEOUT_SHORT_SECS, } from './timeouts.js';
|
|
32
32
|
import { getEnv, parseArgument } from './utils.js';
|
|
33
33
|
const DEFAULT_API_URL = 'https://api.apify.com';
|
|
34
|
+
const API_VERSION_PATH = '/v2';
|
|
35
|
+
function toApiBaseUrl(url) {
|
|
36
|
+
const parsed = new URL(url);
|
|
37
|
+
const path = parsed.pathname.replace(/\/+$/, '');
|
|
38
|
+
parsed.pathname = path.endsWith(API_VERSION_PATH) ? path : `${path}${API_VERSION_PATH}`;
|
|
39
|
+
return parsed.href;
|
|
40
|
+
}
|
|
34
41
|
const clientOptionsSchema = z.strictObject({
|
|
35
42
|
baseUrl: z.string().default(DEFAULT_API_URL),
|
|
36
43
|
compression: compressionSchema.default('brotli'),
|
|
@@ -105,12 +112,8 @@ export class ApifyClient {
|
|
|
105
112
|
constructor(options = {}) {
|
|
106
113
|
const parsed = parseArgument(options, clientOptionsSchema, 'ApifyClientOptions');
|
|
107
114
|
const { baseUrl, compression, headers, publicBaseUrl, maxRetries, minDelayBetweenRetriesMillis, timeoutShortSecs, timeoutMediumSecs, timeoutLongSecs, timeoutMaxSecs, token, } = parsed;
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
const tempPublicBaseUrl = publicBaseUrl.endsWith('/')
|
|
111
|
-
? publicBaseUrl.slice(0, publicBaseUrl.length - 1)
|
|
112
|
-
: publicBaseUrl;
|
|
113
|
-
this.publicBaseUrl = `${tempPublicBaseUrl}/v2`;
|
|
115
|
+
this.baseUrl = toApiBaseUrl(baseUrl);
|
|
116
|
+
this.publicBaseUrl = toApiBaseUrl(publicBaseUrl);
|
|
114
117
|
this.token = token;
|
|
115
118
|
this.stats = new Statistics();
|
|
116
119
|
this.logger = logger.child({ prefix: 'ApifyClient' });
|