apify-client 3.0.0-beta.9 → 3.0.0-beta.90
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 +16 -2
- package/dist/apify_api_error.d.ts +13 -27
- package/dist/apify_api_error.js +33 -23
- package/dist/apify_client.d.ts +125 -10
- package/dist/apify_client.js +133 -48
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/base/api_client.d.ts +7 -7
- package/dist/base/api_client.js +36 -36
- package/dist/base/resource_client.d.ts +21 -8
- package/dist/base/resource_client.js +70 -36
- package/dist/base/resource_collection_client.d.ts +12 -4
- package/dist/base/resource_collection_client.js +34 -11
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +19 -26
- package/dist/bundle.js +27 -22
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3040 -971
- package/dist/generated/schemas.d.ts +2369 -934
- package/dist/generated/schemas.js +570 -229
- package/dist/http_clients/axios.d.ts +61 -0
- package/dist/http_clients/axios.js +119 -0
- package/dist/http_clients/base.d.ts +386 -0
- package/dist/http_clients/base.js +650 -0
- package/dist/http_clients/index.d.ts +4 -0
- package/dist/http_clients/index.js +2 -0
- package/dist/http_compressors/base.d.ts +40 -0
- package/dist/http_compressors/base.js +9 -0
- package/dist/http_compressors/brotli.d.ts +33 -0
- package/dist/http_compressors/brotli.js +39 -0
- package/dist/http_compressors/gzip.d.ts +33 -0
- package/dist/http_compressors/gzip.js +39 -0
- package/dist/http_compressors/index.d.ts +6 -0
- package/dist/http_compressors/index.js +2 -0
- package/dist/http_compressors/resolve.d.ts +23 -0
- package/dist/http_compressors/resolve.js +27 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/invalid_response_body_error.d.ts +14 -0
- package/dist/invalid_response_body_error.js +18 -0
- package/dist/models.d.ts +166 -243
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +104 -34
- package/dist/resource_clients/actor.js +130 -56
- package/dist/resource_clients/actor_collection.d.ts +18 -12
- package/dist/resource_clients/actor_collection.js +11 -3
- package/dist/resource_clients/actor_env_var.d.ts +11 -4
- package/dist/resource_clients/actor_env_var.js +16 -6
- package/dist/resource_clients/actor_env_var_collection.d.ts +9 -4
- package/dist/resource_clients/actor_env_var_collection.js +11 -4
- package/dist/resource_clients/actor_server.d.ts +141 -0
- package/dist/resource_clients/actor_server.js +195 -0
- package/dist/resource_clients/actor_version.d.ts +20 -5
- package/dist/resource_clients/actor_version.js +19 -9
- package/dist/resource_clients/actor_version_collection.d.ts +11 -4
- package/dist/resource_clients/actor_version_collection.js +13 -4
- package/dist/resource_clients/build.d.ts +20 -7
- package/dist/resource_clients/build.js +35 -15
- package/dist/resource_clients/build_collection.d.ts +7 -5
- package/dist/resource_clients/build_collection.js +4 -1
- package/dist/resource_clients/dataset.d.ts +83 -37
- package/dist/resource_clients/dataset.js +107 -121
- package/dist/resource_clients/dataset_collection.d.ts +10 -6
- package/dist/resource_clients/dataset_collection.js +13 -2
- package/dist/resource_clients/key_value_store.d.ts +108 -26
- package/dist/resource_clients/key_value_store.js +134 -52
- package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
- package/dist/resource_clients/key_value_store_collection.js +13 -2
- package/dist/resource_clients/log.d.ts +40 -21
- package/dist/resource_clients/log.js +144 -66
- package/dist/resource_clients/request_queue.d.ts +76 -31
- package/dist/resource_clients/request_queue.js +178 -93
- package/dist/resource_clients/request_queue_collection.d.ts +9 -5
- package/dist/resource_clients/request_queue_collection.js +9 -3
- package/dist/resource_clients/run.d.ts +126 -28
- package/dist/resource_clients/run.js +193 -49
- package/dist/resource_clients/run_collection.d.ts +5 -3
- package/dist/resource_clients/run_collection.js +4 -1
- package/dist/resource_clients/schedule.d.ts +16 -7
- package/dist/resource_clients/schedule.js +30 -22
- package/dist/resource_clients/schedule_collection.d.ts +6 -2
- package/dist/resource_clients/schedule_collection.js +9 -3
- package/dist/resource_clients/store_collection.d.ts +6 -4
- package/dist/resource_clients/store_collection.js +4 -1
- package/dist/resource_clients/task.d.ts +36 -13
- package/dist/resource_clients/task.js +79 -46
- package/dist/resource_clients/task_collection.d.ts +9 -5
- package/dist/resource_clients/task_collection.js +9 -3
- package/dist/resource_clients/user.d.ts +19 -10
- package/dist/resource_clients/user.js +42 -38
- package/dist/resource_clients/webhook.d.ts +17 -8
- package/dist/resource_clients/webhook.js +30 -22
- package/dist/resource_clients/webhook_collection.d.ts +8 -4
- package/dist/resource_clients/webhook_collection.js +9 -3
- package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
- package/dist/resource_clients/webhook_dispatch.js +7 -2
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
- package/dist/response_validation_error.d.ts +2 -1
- package/dist/response_validation_error.js +2 -1
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +80 -0
- package/dist/runtime/types.d.ts +60 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +21 -0
- package/dist/schemas.d.ts +368 -4
- package/dist/schemas.js +26 -4
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +2 -2
- package/dist/timeouts.d.ts +84 -0
- package/dist/timeouts.js +37 -0
- package/dist/timezones.d.ts +1 -1
- package/dist/utils.d.ts +89 -59
- package/dist/utils.js +216 -158
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +37 -34
- package/dist/http_client.d.ts +0 -88
- package/dist/http_client.js +0 -255
- package/dist/interceptors.d.ts +0 -19
- package/dist/interceptors.js +0 -105
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Strategy for compressing HTTP request bodies.
|
|
4
|
+
*
|
|
5
|
+
* Implement this interface to create a custom compressor. Set `contentEncoding` to the value that should be sent in
|
|
6
|
+
* the `Content-Encoding` header and implement `compress()`. The client calls it only for bodies that are large
|
|
7
|
+
* enough to benefit from compression, whose content type does not already carry its own compression, and which the
|
|
8
|
+
* caller did not send with a `Content-Encoding` of their own.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* import { ApifyClient } from 'apify-client';
|
|
13
|
+
*
|
|
14
|
+
* const identityCompressor = {
|
|
15
|
+
* contentEncoding: 'identity',
|
|
16
|
+
*
|
|
17
|
+
* async compress(data) {
|
|
18
|
+
* return data;
|
|
19
|
+
* },
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* const client = new ApifyClient({ token: 'my-token', compression: identityCompressor });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface HttpCompressor {
|
|
26
|
+
/** Value sent in the `Content-Encoding` header, for example `gzip` or `br`. */
|
|
27
|
+
readonly contentEncoding: string;
|
|
28
|
+
/**
|
|
29
|
+
* Compresses a request body.
|
|
30
|
+
*
|
|
31
|
+
* @param data - The raw bytes to compress.
|
|
32
|
+
* @returns The compressed bytes.
|
|
33
|
+
*/
|
|
34
|
+
compress(data: Buffer): Promise<Buffer>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Schema accepting anything shaped like an {@link HttpCompressor}.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare const httpCompressorSchema: z.ZodCustom<HttpCompressor, HttpCompressor>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Schema accepting anything shaped like an {@link HttpCompressor}.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export const httpCompressorSchema = z.custom((value) => typeof value === 'object' &&
|
|
7
|
+
value !== null &&
|
|
8
|
+
typeof value.contentEncoding === 'string' &&
|
|
9
|
+
typeof value.compress === 'function', { error: 'Invalid input: expected an HttpCompressor' });
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HttpCompressor } from './base.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compresses request bodies using brotli.
|
|
4
|
+
*
|
|
5
|
+
* Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```javascript
|
|
9
|
+
* import { ApifyClient, BrotliHttpCompressor } from 'apify-client';
|
|
10
|
+
*
|
|
11
|
+
* const client = new ApifyClient({ token: 'my-token', compression: new BrotliHttpCompressor({ quality: 11 }) });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class BrotliHttpCompressor implements HttpCompressor {
|
|
15
|
+
#private;
|
|
16
|
+
readonly contentEncoding = "br";
|
|
17
|
+
/**
|
|
18
|
+
* @param options - Compressor options.
|
|
19
|
+
* @throws {ArgumentValidationError} If `quality` is out of the valid range.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options?: BrotliHttpCompressorOptions);
|
|
22
|
+
compress(data: Buffer): Promise<Buffer>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Options for {@link BrotliHttpCompressor}.
|
|
26
|
+
*/
|
|
27
|
+
export interface BrotliHttpCompressorOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Compression level, from `0` (the fastest) to `11` (the best compression).
|
|
30
|
+
* @default 6
|
|
31
|
+
*/
|
|
32
|
+
quality?: number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { runtime } from '#runtime';
|
|
3
|
+
import { parseArgument } from '../utils.js';
|
|
4
|
+
/** Lowest valid brotli quality, the fastest with the least compression. */
|
|
5
|
+
const MIN_QUALITY = 0;
|
|
6
|
+
/** Highest valid brotli quality, the slowest with the best compression. */
|
|
7
|
+
const MAX_QUALITY = 11;
|
|
8
|
+
/** Middle of the range, where brotli already beats gzip at a comparable CPU cost. */
|
|
9
|
+
const DEFAULT_QUALITY = 6;
|
|
10
|
+
const optionsSchema = z.strictObject({
|
|
11
|
+
quality: z.int().min(MIN_QUALITY).max(MAX_QUALITY).default(DEFAULT_QUALITY),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Compresses request bodies using brotli.
|
|
15
|
+
*
|
|
16
|
+
* Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```javascript
|
|
20
|
+
* import { ApifyClient, BrotliHttpCompressor } from 'apify-client';
|
|
21
|
+
*
|
|
22
|
+
* const client = new ApifyClient({ token: 'my-token', compression: new BrotliHttpCompressor({ quality: 11 }) });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class BrotliHttpCompressor {
|
|
26
|
+
contentEncoding = 'br';
|
|
27
|
+
#quality;
|
|
28
|
+
/**
|
|
29
|
+
* @param options - Compressor options.
|
|
30
|
+
* @throws {ArgumentValidationError} If `quality` is out of the valid range.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
const { quality } = parseArgument(options, optionsSchema, 'BrotliHttpCompressorOptions');
|
|
34
|
+
this.#quality = quality;
|
|
35
|
+
}
|
|
36
|
+
async compress(data) {
|
|
37
|
+
return runtime.compress(data, { algorithm: 'br', quality: this.#quality });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HttpCompressor } from './base.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compresses request bodies using gzip.
|
|
4
|
+
*
|
|
5
|
+
* Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```javascript
|
|
9
|
+
* import { ApifyClient, GzipHttpCompressor } from 'apify-client';
|
|
10
|
+
*
|
|
11
|
+
* const client = new ApifyClient({ token: 'my-token', compression: new GzipHttpCompressor({ quality: 1 }) });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class GzipHttpCompressor implements HttpCompressor {
|
|
15
|
+
#private;
|
|
16
|
+
readonly contentEncoding = "gzip";
|
|
17
|
+
/**
|
|
18
|
+
* @param options - Compressor options.
|
|
19
|
+
* @throws {ArgumentValidationError} If `quality` is out of the valid range.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options?: GzipHttpCompressorOptions);
|
|
22
|
+
compress(data: Buffer): Promise<Buffer>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Options for {@link GzipHttpCompressor}.
|
|
26
|
+
*/
|
|
27
|
+
export interface GzipHttpCompressorOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Compression level, from `1` (the fastest) to `9` (the best compression).
|
|
30
|
+
* @default 6
|
|
31
|
+
*/
|
|
32
|
+
quality?: number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { runtime } from '#runtime';
|
|
3
|
+
import { parseArgument } from '../utils.js';
|
|
4
|
+
/** Lowest valid gzip quality, the fastest with the least compression. */
|
|
5
|
+
const MIN_QUALITY = 1;
|
|
6
|
+
/** Highest valid gzip quality, the slowest with the best compression. */
|
|
7
|
+
const MAX_QUALITY = 9;
|
|
8
|
+
/** zlib's own default. The levels above it roughly double the CPU cost for about a percent fewer bytes. */
|
|
9
|
+
const DEFAULT_QUALITY = 6;
|
|
10
|
+
const optionsSchema = z.strictObject({
|
|
11
|
+
quality: z.int().min(MIN_QUALITY).max(MAX_QUALITY).default(DEFAULT_QUALITY),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Compresses request bodies using gzip.
|
|
15
|
+
*
|
|
16
|
+
* Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```javascript
|
|
20
|
+
* import { ApifyClient, GzipHttpCompressor } from 'apify-client';
|
|
21
|
+
*
|
|
22
|
+
* const client = new ApifyClient({ token: 'my-token', compression: new GzipHttpCompressor({ quality: 1 }) });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class GzipHttpCompressor {
|
|
26
|
+
contentEncoding = 'gzip';
|
|
27
|
+
#quality;
|
|
28
|
+
/**
|
|
29
|
+
* @param options - Compressor options.
|
|
30
|
+
* @throws {ArgumentValidationError} If `quality` is out of the valid range.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
const { quality } = parseArgument(options, optionsSchema, 'GzipHttpCompressorOptions');
|
|
34
|
+
this.#quality = quality;
|
|
35
|
+
}
|
|
36
|
+
async compress(data) {
|
|
37
|
+
return runtime.compress(data, { algorithm: 'gzip', quality: this.#quality });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { HttpCompressor } from './base.js';
|
|
2
|
+
export { BrotliHttpCompressor } from './brotli.js';
|
|
3
|
+
export type { BrotliHttpCompressorOptions } from './brotli.js';
|
|
4
|
+
export { GzipHttpCompressor } from './gzip.js';
|
|
5
|
+
export type { GzipHttpCompressorOptions } from './gzip.js';
|
|
6
|
+
export type { HttpCompressionAlgorithm } from './resolve.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { HttpCompressor } from './base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compression algorithms the `compression` option of {@link ApifyClient} accepts by name. Each name selects the
|
|
5
|
+
* matching built-in compressor with its default quality: `'brotli'` a {@link BrotliHttpCompressor}, `'gzip'` a
|
|
6
|
+
* {@link GzipHttpCompressor}. The Apify API also accepts `deflate` and `identity`, which a custom
|
|
7
|
+
* {@link HttpCompressor} covers.
|
|
8
|
+
*/
|
|
9
|
+
export type HttpCompressionAlgorithm = 'brotli' | 'gzip';
|
|
10
|
+
/**
|
|
11
|
+
* Schema of the `compression` option: an algorithm name or an {@link HttpCompressor}.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare const compressionSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
15
|
+
brotli: "brotli";
|
|
16
|
+
gzip: "gzip";
|
|
17
|
+
}>, z.ZodCustom<HttpCompressor, HttpCompressor>]>;
|
|
18
|
+
/**
|
|
19
|
+
* Turns the `compression` option into a ready-to-use {@link HttpCompressor}: a name into the matching built-in
|
|
20
|
+
* compressor with its default quality, a compressor into itself.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCompressor(compression: HttpCompressionAlgorithm | HttpCompressor): HttpCompressor;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { httpCompressorSchema } from './base.js';
|
|
3
|
+
import { BrotliHttpCompressor } from './brotli.js';
|
|
4
|
+
import { GzipHttpCompressor } from './gzip.js';
|
|
5
|
+
/**
|
|
6
|
+
* Schema of the `compression` option: an algorithm name or an {@link HttpCompressor}.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const compressionSchema = z.union([
|
|
10
|
+
z.enum(['brotli', 'gzip']),
|
|
11
|
+
httpCompressorSchema,
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* Turns the `compression` option into a ready-to-use {@link HttpCompressor}: a name into the matching built-in
|
|
15
|
+
* compressor with its default quality, a compressor into itself.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function resolveCompressor(compression) {
|
|
19
|
+
if (typeof compression !== 'string')
|
|
20
|
+
return compression;
|
|
21
|
+
switch (compression) {
|
|
22
|
+
case 'gzip':
|
|
23
|
+
return new GzipHttpCompressor();
|
|
24
|
+
case 'brotli':
|
|
25
|
+
return new BrotliHttpCompressor();
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './resource_clients/actor.js';
|
|
|
3
3
|
export * from './resource_clients/actor_collection.js';
|
|
4
4
|
export * from './resource_clients/actor_env_var.js';
|
|
5
5
|
export * from './resource_clients/actor_env_var_collection.js';
|
|
6
|
+
export * from './resource_clients/actor_server.js';
|
|
6
7
|
export * from './resource_clients/actor_version.js';
|
|
7
8
|
export * from './resource_clients/actor_version_collection.js';
|
|
8
9
|
export * from './resource_clients/build.js';
|
|
@@ -26,8 +27,12 @@ export * from './resource_clients/webhook.js';
|
|
|
26
27
|
export * from './resource_clients/webhook_collection.js';
|
|
27
28
|
export * from './resource_clients/webhook_dispatch.js';
|
|
28
29
|
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
30
|
+
export * from './apify_client_error.js';
|
|
29
31
|
export * from './apify_api_error.js';
|
|
30
32
|
export { ArgumentValidationError } from '@apify/validations';
|
|
31
33
|
export * from './response_validation_error.js';
|
|
32
|
-
export
|
|
34
|
+
export * from './invalid_response_body_error.js';
|
|
35
|
+
export * from './http_clients/index.js';
|
|
36
|
+
export * from './http_compressors/index.js';
|
|
33
37
|
export type { PaginatedList, Dictionary } from './utils.js';
|
|
38
|
+
export type { Timeout, TimeoutOptions, TimeoutTier } from './timeouts.js';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './resource_clients/actor.js';
|
|
|
3
3
|
export * from './resource_clients/actor_collection.js';
|
|
4
4
|
export * from './resource_clients/actor_env_var.js';
|
|
5
5
|
export * from './resource_clients/actor_env_var_collection.js';
|
|
6
|
+
export * from './resource_clients/actor_server.js';
|
|
6
7
|
export * from './resource_clients/actor_version.js';
|
|
7
8
|
export * from './resource_clients/actor_version_collection.js';
|
|
8
9
|
export * from './resource_clients/build.js';
|
|
@@ -26,7 +27,10 @@ export * from './resource_clients/webhook.js';
|
|
|
26
27
|
export * from './resource_clients/webhook_collection.js';
|
|
27
28
|
export * from './resource_clients/webhook_dispatch.js';
|
|
28
29
|
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
30
|
+
export * from './apify_client_error.js';
|
|
29
31
|
export * from './apify_api_error.js';
|
|
30
32
|
export { ArgumentValidationError } from '@apify/validations';
|
|
31
33
|
export * from './response_validation_error.js';
|
|
32
|
-
export
|
|
34
|
+
export * from './invalid_response_body_error.js';
|
|
35
|
+
export * from './http_clients/index.js';
|
|
36
|
+
export * from './http_compressors/index.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApifyClientError } from './apify_client_error.js';
|
|
2
|
+
import type { HttpResponse } from './http_clients/base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when the body of a successful response does not parse as its content type claims, for example a non-JSON
|
|
5
|
+
* value stored under `application/json`. The response arrived in full, so the request is not retried. An error
|
|
6
|
+
* status with an unparsable body throws {@link ApifyApiError} for its status code.
|
|
7
|
+
*/
|
|
8
|
+
export declare class InvalidResponseBodyError extends ApifyClientError {
|
|
9
|
+
code: string;
|
|
10
|
+
/** The response whose body did not parse, with the body as the transport returned it. */
|
|
11
|
+
response: HttpResponse;
|
|
12
|
+
cause: Error;
|
|
13
|
+
constructor(response: HttpResponse, cause: Error);
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApifyClientError } from './apify_client_error.js';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the body of a successful response does not parse as its content type claims, for example a non-JSON
|
|
4
|
+
* value stored under `application/json`. The response arrived in full, so the request is not retried. An error
|
|
5
|
+
* status with an unparsable body throws {@link ApifyApiError} for its status code.
|
|
6
|
+
*/
|
|
7
|
+
export class InvalidResponseBodyError extends ApifyClientError {
|
|
8
|
+
code;
|
|
9
|
+
/** The response whose body did not parse, with the body as the transport returned it. */
|
|
10
|
+
response;
|
|
11
|
+
constructor(response, cause) {
|
|
12
|
+
super(`Response body could not be parsed.\nCause:${cause.message}`);
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
this.code = 'invalid-response-body';
|
|
15
|
+
this.response = response;
|
|
16
|
+
this.cause = cause;
|
|
17
|
+
}
|
|
18
|
+
}
|