apify-client 3.0.0-beta.2 → 3.0.0-beta.21
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 +7 -3
- package/dist/apify_api_error.d.ts +60 -19
- package/dist/apify_api_error.js +88 -22
- package/dist/apify_client.d.ts +22 -3
- package/dist/apify_client.js +37 -31
- package/dist/base/api_client.d.ts +6 -6
- package/dist/base/api_client.js +24 -16
- package/dist/base/resource_client.d.ts +23 -9
- package/dist/base/resource_client.js +49 -25
- package/dist/base/resource_collection_client.d.ts +7 -4
- package/dist/base/resource_collection_client.js +21 -15
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +17 -24
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +287 -214
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +18 -51
- package/dist/http_client.js +90 -85
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/interceptors.js +24 -6
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +32 -52
- package/dist/resource_clients/actor.d.ts +46 -31
- package/dist/resource_clients/actor.js +71 -53
- package/dist/resource_clients/actor_collection.d.ts +9 -5
- package/dist/resource_clients/actor_collection.js +12 -3
- package/dist/resource_clients/actor_env_var.d.ts +10 -3
- package/dist/resource_clients/actor_env_var.js +17 -6
- package/dist/resource_clients/actor_env_var_collection.d.ts +14 -18
- package/dist/resource_clients/actor_env_var_collection.js +18 -11
- package/dist/resource_clients/actor_version.d.ts +18 -3
- package/dist/resource_clients/actor_version.js +20 -9
- package/dist/resource_clients/actor_version_collection.d.ts +16 -17
- package/dist/resource_clients/actor_version_collection.js +20 -11
- package/dist/resource_clients/build.d.ts +18 -6
- package/dist/resource_clients/build.js +35 -17
- package/dist/resource_clients/build_collection.d.ts +3 -1
- package/dist/resource_clients/build_collection.js +5 -1
- package/dist/resource_clients/dataset.d.ts +23 -9
- package/dist/resource_clients/dataset.js +70 -48
- package/dist/resource_clients/dataset_collection.d.ts +6 -2
- package/dist/resource_clients/dataset_collection.js +13 -2
- package/dist/resource_clients/key_value_store.d.ts +48 -15
- package/dist/resource_clients/key_value_store.js +71 -40
- package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
- package/dist/resource_clients/key_value_store_collection.js +13 -2
- package/dist/resource_clients/log.d.ts +9 -19
- package/dist/resource_clients/log.js +57 -45
- package/dist/resource_clients/request_queue.d.ts +56 -26
- package/dist/resource_clients/request_queue.js +178 -113
- package/dist/resource_clients/request_queue_collection.d.ts +6 -2
- package/dist/resource_clients/request_queue_collection.js +10 -3
- package/dist/resource_clients/run.d.ts +51 -17
- package/dist/resource_clients/run.js +85 -44
- package/dist/resource_clients/run_collection.d.ts +3 -1
- package/dist/resource_clients/run_collection.js +5 -1
- package/dist/resource_clients/schedule.d.ts +16 -7
- package/dist/resource_clients/schedule.js +31 -21
- package/dist/resource_clients/schedule_collection.d.ts +6 -2
- package/dist/resource_clients/schedule_collection.js +10 -3
- package/dist/resource_clients/store_collection.d.ts +3 -1
- package/dist/resource_clients/store_collection.js +5 -1
- package/dist/resource_clients/task.d.ts +28 -10
- package/dist/resource_clients/task.js +67 -44
- package/dist/resource_clients/task_collection.d.ts +6 -2
- package/dist/resource_clients/task_collection.js +10 -3
- package/dist/resource_clients/user.d.ts +17 -8
- package/dist/resource_clients/user.js +40 -39
- package/dist/resource_clients/webhook.d.ts +14 -5
- package/dist/resource_clients/webhook.js +30 -22
- package/dist/resource_clients/webhook_collection.d.ts +6 -2
- package/dist/resource_clients/webhook_collection.js +10 -3
- package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
- package/dist/resource_clients/webhook_dispatch.js +8 -2
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +5 -1
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +58 -0
- package/dist/runtime/types.d.ts +50 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +17 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +2 -2
- package/dist/timeouts.d.ts +72 -0
- package/dist/timeouts.js +31 -0
- package/dist/utils.d.ts +75 -55
- package/dist/utils.js +201 -180
- package/package.json +42 -35
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -153
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schemas the resource clients validate API responses with.
|
|
3
|
+
*
|
|
4
|
+
* Today these are exactly the generated ones. The module still exists as the one place where a generated
|
|
5
|
+
* schema is widened when the API is known to return something the specification does not describe, so a
|
|
6
|
+
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
|
+
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
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 produces what the specification describes,
|
|
10
|
+
* so one cannot narrow by accident.
|
|
11
|
+
*
|
|
12
|
+
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
|
13
|
+
* through. Neither do client narrowings: a schema only ever accepts more than the published type.
|
|
14
|
+
*/
|
|
15
|
+
export * from './generated/schemas.js';
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schemas the resource clients validate API responses with.
|
|
3
|
+
*
|
|
4
|
+
* Today these are exactly the generated ones. The module still exists as the one place where a generated
|
|
5
|
+
* schema is widened when the API is known to return something the specification does not describe, so a
|
|
6
|
+
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
|
+
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
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 produces what the specification describes,
|
|
10
|
+
* so one cannot narrow by accident.
|
|
11
|
+
*
|
|
12
|
+
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
|
13
|
+
* through. Neither do client narrowings: a schema only ever accepts more than the published type.
|
|
14
|
+
*/
|
|
15
|
+
export * from './generated/schemas.js';
|
package/dist/statistics.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare class Statistics {
|
|
2
|
+
#private;
|
|
2
3
|
/**
|
|
3
4
|
* Number of Apify client function calls
|
|
4
5
|
*/
|
|
@@ -13,10 +14,4 @@ export declare class Statistics {
|
|
|
13
14
|
*/
|
|
14
15
|
rateLimitErrors: number[];
|
|
15
16
|
addRateLimitError(attempt: number): void;
|
|
16
|
-
/**
|
|
17
|
-
* Removes the necessity to pre-initialize array with correct
|
|
18
|
-
* number of zeroes by dynamically filling the empty indexes
|
|
19
|
-
* when necessary.
|
|
20
|
-
*/
|
|
21
|
-
private _fillBlanksWithZeroes;
|
|
22
17
|
}
|
package/dist/statistics.js
CHANGED
|
@@ -20,7 +20,7 @@ export class Statistics {
|
|
|
20
20
|
// attempt is never 0,
|
|
21
21
|
// but we don't want index 0 empty
|
|
22
22
|
const index = attempt - 1;
|
|
23
|
-
this
|
|
23
|
+
this.#fillBlanksWithZeroes(index);
|
|
24
24
|
this.rateLimitErrors[index]++;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -28,7 +28,7 @@ export class Statistics {
|
|
|
28
28
|
* number of zeroes by dynamically filling the empty indexes
|
|
29
29
|
* when necessary.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
#fillBlanksWithZeroes(inclusiveIndex) {
|
|
32
32
|
if (this.rateLimitErrors.length <= inclusiveIndex) {
|
|
33
33
|
for (let k = 0; k <= inclusiveIndex; k++) {
|
|
34
34
|
if (typeof this.rateLimitErrors[k] !== 'number') {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Default duration of the `short` timeout tier, in seconds. */
|
|
3
|
+
export declare const DEFAULT_TIMEOUT_SHORT_SECS = 5;
|
|
4
|
+
/** Default duration of the `medium` timeout tier, in seconds. */
|
|
5
|
+
export declare const DEFAULT_TIMEOUT_MEDIUM_SECS = 30;
|
|
6
|
+
/** Default duration of the `long` timeout tier, in seconds. */
|
|
7
|
+
export declare const DEFAULT_TIMEOUT_LONG_SECS = 360;
|
|
8
|
+
/** Default cap on the timeout of a single request attempt, in seconds. */
|
|
9
|
+
export declare const DEFAULT_TIMEOUT_MAX_SECS = 360;
|
|
10
|
+
/**
|
|
11
|
+
* Preconfigured timeout tiers. Every client method picks the tier that fits the expected duration of its
|
|
12
|
+
* request: `short` for simple metadata reads and writes, `medium` for listing, batch and trigger operations,
|
|
13
|
+
* `long` for downloads, uploads and streaming. The duration of each tier is set on the {@link ApifyClient}
|
|
14
|
+
* constructor.
|
|
15
|
+
*/
|
|
16
|
+
export type TimeoutTier = 'short' | 'medium' | 'long';
|
|
17
|
+
/**
|
|
18
|
+
* Timeout of a single API request.
|
|
19
|
+
*
|
|
20
|
+
* A tier name picks the duration configured for that tier on the {@link ApifyClient} constructor, a number is
|
|
21
|
+
* an exact duration in seconds, and `'noTimeout'` lets the request run for as long as it takes. A tier or an
|
|
22
|
+
* explicit duration above `timeoutMaxSecs` is capped at it, and the client logs a warning when that happens.
|
|
23
|
+
* The timeout applies to each attempt separately, and doubles with every retry up to the same cap.
|
|
24
|
+
*
|
|
25
|
+
* With `'noTimeout'` the client never aborts the request, so a connection that stalls is not retried either.
|
|
26
|
+
*/
|
|
27
|
+
export type Timeout = TimeoutTier | 'noTimeout' | number;
|
|
28
|
+
/**
|
|
29
|
+
* Options shared by every method that sends a request to the API.
|
|
30
|
+
*/
|
|
31
|
+
export interface TimeoutOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Timeout for the API request: a tier name (`'short'`, `'medium'`, `'long'`), a number of seconds, or
|
|
34
|
+
* `'noTimeout'`. Defaults to the tier the method is assigned, which its documentation names.
|
|
35
|
+
*/
|
|
36
|
+
timeoutSecs?: Timeout;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Schema of {@link Timeout}, optional, for the methods that validate `timeoutSecs` on its own.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare const optionalTimeoutSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
43
|
+
short: "short";
|
|
44
|
+
medium: "medium";
|
|
45
|
+
long: "long";
|
|
46
|
+
noTimeout: "noTimeout";
|
|
47
|
+
}>, z.ZodNumber]>>;
|
|
48
|
+
/**
|
|
49
|
+
* Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
|
|
50
|
+
* request. One copy stops it drifting from the interface.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export declare const timeoutOptionsShape: {
|
|
54
|
+
timeoutSecs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
55
|
+
short: "short";
|
|
56
|
+
medium: "medium";
|
|
57
|
+
long: "long";
|
|
58
|
+
noTimeout: "noTimeout";
|
|
59
|
+
}>, z.ZodNumber]>>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Schema of {@link TimeoutOptions}, for the methods that take no other option.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export declare const timeoutOptionsSchema: z.ZodObject<{
|
|
66
|
+
timeoutSecs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
67
|
+
short: "short";
|
|
68
|
+
medium: "medium";
|
|
69
|
+
long: "long";
|
|
70
|
+
noTimeout: "noTimeout";
|
|
71
|
+
}>, z.ZodNumber]>>;
|
|
72
|
+
}, z.core.$strict>;
|
package/dist/timeouts.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Default duration of the `short` timeout tier, in seconds. */
|
|
3
|
+
export const DEFAULT_TIMEOUT_SHORT_SECS = 5;
|
|
4
|
+
/** Default duration of the `medium` timeout tier, in seconds. */
|
|
5
|
+
export const DEFAULT_TIMEOUT_MEDIUM_SECS = 30;
|
|
6
|
+
/** Default duration of the `long` timeout tier, in seconds. */
|
|
7
|
+
export const DEFAULT_TIMEOUT_LONG_SECS = 360;
|
|
8
|
+
/** Default cap on the timeout of a single request attempt, in seconds. */
|
|
9
|
+
export const DEFAULT_TIMEOUT_MAX_SECS = 360;
|
|
10
|
+
/**
|
|
11
|
+
* Schema of {@link Timeout}. Zero is rejected on purpose - `'noTimeout'` is the explicit way to run without one.
|
|
12
|
+
*/
|
|
13
|
+
const timeoutSchema = z.union([z.enum(['short', 'medium', 'long', 'noTimeout']), z.number().positive()]);
|
|
14
|
+
/**
|
|
15
|
+
* Schema of {@link Timeout}, optional, for the methods that validate `timeoutSecs` on its own.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const optionalTimeoutSchema = timeoutSchema.optional();
|
|
19
|
+
/**
|
|
20
|
+
* Schema shape of {@link TimeoutOptions}, to spread into the option schema of every method that sends a
|
|
21
|
+
* request. One copy stops it drifting from the interface.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const timeoutOptionsShape = {
|
|
25
|
+
timeoutSecs: optionalTimeoutSchema,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Schema of {@link TimeoutOptions}, for the methods that take no other option.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const timeoutOptionsSchema = z.strictObject(timeoutOptionsShape);
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
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
|
+
import { parseArgument } from '@apify/validations';
|
|
6
|
+
import type { ApifyResponse } from './http_client.js';
|
|
7
|
+
import type { CompressedValue } from './runtime/types.js';
|
|
5
8
|
import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue.js';
|
|
6
9
|
import type { WebhookUpdateData } from './resource_clients/webhook.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Throws {@link ArgumentValidationError} on failure.
|
|
10
|
-
*
|
|
11
|
-
* The optional `label` names the interface being validated and is appended to every error line
|
|
12
|
-
* (e.g. ``... at `memory` in `ActorStartOptions` ``).
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseArgument<TValue, TSchema extends z.ZodType>(value: TValue, schema: TSchema, label?: string): TValue & z.output<TSchema>;
|
|
10
|
+
export declare const version: any;
|
|
11
|
+
export { parseArgument };
|
|
16
12
|
/**
|
|
17
13
|
* Accepts any non-null, non-array object as a predicate for `z.custom()`.
|
|
18
14
|
* @internal
|
|
@@ -33,71 +29,93 @@ export declare const anyObjectSchema: z.ZodCustom<Record<string, unknown>, Recor
|
|
|
33
29
|
export interface MaybeData<R> {
|
|
34
30
|
data?: R;
|
|
35
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope and validates the
|
|
34
|
+
* result against `schema`, one of the schemas generated from the OpenAPI specification. The validated copy is what
|
|
35
|
+
* callers get, so it is the schema's output -- unknown fields and unknown enum values included, since the schemas let
|
|
36
|
+
* both through, date-time fields turned into `Date` objects, and URL fields normalized, since `z.url()` hands back the
|
|
37
|
+
* parsed URL's serialization.
|
|
38
|
+
*
|
|
39
|
+
* Throws {@link ResponseValidationError} when the response does not match the specification.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodType): R;
|
|
36
43
|
/**
|
|
37
44
|
* Returns object's 'data' property or throws if parameter is not an object,
|
|
38
45
|
* or an object without a 'data' property.
|
|
39
46
|
*/
|
|
40
47
|
export declare function pluckData<R>(obj: MaybeData<R>): R;
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
43
|
-
* Otherwise rethrows error.
|
|
49
|
+
* Swallows a 404 Not Found API error and rethrows anything else.
|
|
44
50
|
*/
|
|
45
51
|
export declare function catchNotFoundOrThrow(err: ApifyApiError): void;
|
|
46
|
-
type ReturnJsonValue = string | number | boolean | null | Date | ReturnJsonObject | ReturnJsonArray;
|
|
47
|
-
type ReturnJsonObject = {
|
|
48
|
-
[Key in string]?: ReturnJsonValue;
|
|
49
|
-
};
|
|
50
|
-
type ReturnJsonArray = ReturnJsonValue[];
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
-
* "createdAt").
|
|
54
|
-
*
|
|
55
|
-
* If you want parse other fields as well, you can provide a custom matcher function shouldParseField(). This
|
|
56
|
-
* admittedly awkward approach allows this function to be reused for various purposes without introducing potential
|
|
57
|
-
* breaking changes.
|
|
53
|
+
* Like `catchNotFoundOrThrow()`, but swallows the 404 only when the client names its resource by ID.
|
|
58
54
|
*
|
|
59
|
-
*
|
|
55
|
+
* A chained client without an ID, such as `run.dataset()` or `run.log()`, requests a path where a 404 can mean either
|
|
56
|
+
* the parent or the default sub-resource is missing. The response cannot tell the two apart, so the error propagates.
|
|
57
|
+
* @internal
|
|
60
58
|
*/
|
|
61
|
-
export declare function
|
|
59
|
+
export declare function catchNotFoundForResourceOrThrow(err: ApifyApiError, resourceId: string | undefined): void;
|
|
62
60
|
/**
|
|
63
61
|
* Helper function that converts array of webhooks to base64 string
|
|
64
62
|
*/
|
|
65
63
|
export declare function stringifyWebhooksToBase64(webhooks?: readonly WebhookUpdateData[]): string | undefined;
|
|
66
|
-
export interface CompressedValue {
|
|
67
|
-
data: Buffer;
|
|
68
|
-
encoding: 'br' | 'gzip';
|
|
69
|
-
}
|
|
70
64
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
65
|
+
* Encodes bytes as base64. `btoa()` takes a binary string, and the bytes are turned into one in slices,
|
|
66
|
+
* because spreading them all into a single `String.fromCharCode()` call overflows the argument limit on
|
|
67
|
+
* inputs of a few tens of kilobytes.
|
|
68
|
+
*/
|
|
69
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
70
|
+
/**
|
|
71
|
+
* Concatenates byte chunks into one array.
|
|
72
|
+
*/
|
|
73
|
+
export declare function concatBytes(chunks: Uint8Array[]): Uint8Array;
|
|
74
|
+
/**
|
|
75
|
+
* Decides whether a request body with the given content type is worth compressing.
|
|
76
|
+
*
|
|
77
|
+
* Images, audio, video and archives already carry their own compression. Running them through brotli or gzip
|
|
78
|
+
* burns CPU, holds a second full copy of the body in memory, and usually produces output slightly larger than
|
|
79
|
+
* the input. Formats that are raw despite such a media type, for example `image/bmp` or `audio/wav`, are still
|
|
80
|
+
* compressed. A body with no content type is assumed to be compressible.
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export declare function isCompressibleContentType(contentType?: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Compresses the passed value with the runtime's best available algorithm. Returns `undefined` if the data
|
|
86
|
+
* is too small, is not a string or binary value, or if the runtime does not offer compression.
|
|
73
87
|
*/
|
|
74
88
|
export declare function maybeCompressValue(value: unknown): Promise<CompressedValue | undefined>;
|
|
75
89
|
/**
|
|
76
|
-
*
|
|
90
|
+
* Reads an environment variable, on runtimes that have them.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getEnv(name: string): string | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the UTF-8 byte length of a string.
|
|
95
|
+
*/
|
|
96
|
+
export declare function utf8ByteLength(value: string): number;
|
|
97
|
+
/**
|
|
98
|
+
* Splits JSON-serialized items into consecutive batches of at most `maxCount` items, each of which fits into a JSON
|
|
99
|
+
* array body - the items joined by commas between brackets - of at most `maxByteLength` bytes. The `byteLength` of an
|
|
100
|
+
* item is the UTF-8 byte length of its serialization. An item too large for a body of its own still gets one, so a
|
|
101
|
+
* caller that cannot send such an item has to reject it beforehand.
|
|
77
102
|
*/
|
|
78
|
-
export declare function
|
|
79
|
-
|
|
103
|
+
export declare function splitIntoJsonArrayBatches<T extends {
|
|
104
|
+
byteLength: number;
|
|
105
|
+
}>(items: readonly T[], { maxCount, maxByteLength }: {
|
|
106
|
+
maxCount: number;
|
|
107
|
+
maxByteLength: number;
|
|
108
|
+
}): T[][];
|
|
80
109
|
export declare function isBuffer(value: unknown): value is Buffer | ArrayBuffer | TypedArray;
|
|
81
110
|
export declare function isStream(value: unknown): value is Readable;
|
|
82
|
-
export declare function getVersionData(): {
|
|
83
|
-
version: string;
|
|
84
|
-
};
|
|
85
111
|
/**
|
|
86
|
-
* Helper class to create async iterators from paginated list endpoints
|
|
112
|
+
* Helper class to create async iterators from paginated list endpoints.
|
|
87
113
|
*/
|
|
88
114
|
export declare class RequestQueuePaginationIterator {
|
|
89
|
-
private
|
|
90
|
-
private readonly getPage;
|
|
91
|
-
private readonly limit?;
|
|
92
|
-
private readonly exclusiveStartId?;
|
|
93
|
-
private readonly cursor?;
|
|
115
|
+
#private;
|
|
94
116
|
constructor(options: RequestQueuePaginationIteratorOptions);
|
|
95
117
|
[Symbol.asyncIterator](): AsyncIterator<RequestQueueClientListRequestsResult>;
|
|
96
118
|
}
|
|
97
|
-
declare global {
|
|
98
|
-
export const BROWSER_BUILD: boolean | undefined;
|
|
99
|
-
export const VERSION: string | undefined;
|
|
100
|
-
}
|
|
101
119
|
/**
|
|
102
120
|
* Options for creating a pagination iterator.
|
|
103
121
|
*/
|
|
@@ -105,7 +123,6 @@ export interface RequestQueuePaginationIteratorOptions {
|
|
|
105
123
|
maxPageLimit: number;
|
|
106
124
|
getPage: (opts: RequestQueueClientListRequestsOptions) => Promise<RequestQueueClientListRequestsResult>;
|
|
107
125
|
limit?: number;
|
|
108
|
-
exclusiveStartId?: string;
|
|
109
126
|
cursor?: string;
|
|
110
127
|
}
|
|
111
128
|
/**
|
|
@@ -164,6 +181,16 @@ export interface PaginatedList<Data> extends PaginatedResponse<Data> {
|
|
|
164
181
|
/** Should the results be in descending order. */
|
|
165
182
|
desc: boolean;
|
|
166
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Key under which a page of dataset items carries the number of rows the API scanned to produce it, as a
|
|
186
|
+
* non-enumerable property that stays out of the page's public shape. The API applies `offset` and `limit` to the
|
|
187
|
+
* dataset's rows first and shapes the result afterwards: filters (`clean`, `skipEmpty`, `skipHidden`) drop items and
|
|
188
|
+
* `unwind` splits or drops them, so `items.length` can land on either side of the rows scanned. The
|
|
189
|
+
* `x-apify-pagination-count` header reports the scanned number, and the offset iterator advances and terminates by it
|
|
190
|
+
* alone. A page without the property falls back to `items.length`.
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
export declare const SCANNED_COUNT: unique symbol;
|
|
167
194
|
/**
|
|
168
195
|
* Type representing both a Promise of a paginated list and an async iterable.
|
|
169
196
|
*
|
|
@@ -192,12 +219,6 @@ export type DistributiveOptional<T, K extends keyof T> = T extends any ? Omit<T,
|
|
|
192
219
|
* Adds query parameters to a given URL based on the provided options object.
|
|
193
220
|
*/
|
|
194
221
|
export declare function applyQueryParamsToUrl(url: URL, options?: Record<string, string | number | boolean | string[] | undefined>): URL;
|
|
195
|
-
/**
|
|
196
|
-
* Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
|
|
197
|
-
* is present. Pass the options interface as `T`, so that a misspelled key is a type error.
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
export declare const mutuallyExclusive: <T extends object>(...keys: (keyof T & string)[]) => [(value: T) => boolean, string];
|
|
201
222
|
/**
|
|
202
223
|
* Percent-encodes a caller-supplied URL path segment so it cannot restructure the request path.
|
|
203
224
|
*
|
|
@@ -210,4 +231,3 @@ export declare function toPathSegment(value: string): string;
|
|
|
210
231
|
* `requests/batch` keep their separators; an array has each of its segments encoded individually.
|
|
211
232
|
*/
|
|
212
233
|
export declare function toPath(path: string | string[]): string;
|
|
213
|
-
export {};
|