apify-client 3.0.0-beta.1 → 3.0.0-beta.100
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 +21 -5
- package/dist/apify_api_error.d.ts +64 -22
- package/dist/apify_api_error.js +100 -30
- package/dist/apify_client.d.ts +150 -35
- package/dist/apify_client.js +198 -118
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/base/api_client.d.ts +9 -9
- package/dist/base/api_client.js +41 -45
- package/dist/base/resource_client.d.ts +24 -10
- package/dist/base/resource_client.js +78 -48
- package/dist/base/resource_collection_client.d.ts +15 -6
- package/dist/base/resource_collection_client.js +40 -21
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +20 -32
- package/dist/bundle.js +47 -52
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3363 -1185
- package/dist/generated/api.js +1 -2
- package/dist/generated/schemas.d.ts +8146 -0
- package/dist/generated/schemas.js +1866 -0
- package/dist/http_clients/axios.d.ts +61 -0
- package/dist/http_clients/axios.js +119 -0
- package/dist/http_clients/base.d.ts +391 -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 +8 -0
- package/dist/http_compressors/index.js +3 -0
- package/dist/http_compressors/resolve.d.ts +24 -0
- package/dist/http_compressors/resolve.js +30 -0
- package/dist/http_compressors/zstd.d.ts +34 -0
- package/dist/http_compressors/zstd.js +43 -0
- package/dist/index.d.ts +38 -32
- package/dist/index.js +36 -36
- package/dist/invalid_response_body_error.d.ts +14 -0
- package/dist/invalid_response_body_error.js +18 -0
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +196 -278
- package/dist/models.js +14 -15
- package/dist/resource_clients/actor.d.ts +115 -45
- package/dist/resource_clients/actor.js +187 -116
- package/dist/resource_clients/actor_collection.d.ts +21 -17
- package/dist/resource_clients/actor_collection.js +26 -21
- package/dist/resource_clients/actor_env_var.d.ts +13 -6
- package/dist/resource_clients/actor_env_var.js +21 -14
- package/dist/resource_clients/actor_env_var_collection.d.ts +18 -22
- package/dist/resource_clients/actor_env_var_collection.js +23 -20
- package/dist/resource_clients/actor_server.d.ts +149 -0
- package/dist/resource_clients/actor_server.js +199 -0
- package/dist/resource_clients/actor_version.d.ts +30 -10
- package/dist/resource_clients/actor_version.js +29 -23
- package/dist/resource_clients/actor_version_collection.d.ts +20 -21
- package/dist/resource_clients/actor_version_collection.js +25 -20
- package/dist/resource_clients/build.d.ts +24 -11
- package/dist/resource_clients/build.js +43 -26
- package/dist/resource_clients/build_collection.d.ts +10 -8
- package/dist/resource_clients/build_collection.js +13 -13
- package/dist/resource_clients/dataset.d.ts +87 -40
- package/dist/resource_clients/dataset.js +159 -175
- package/dist/resource_clients/dataset_collection.d.ts +13 -9
- package/dist/resource_clients/dataset_collection.js +29 -21
- package/dist/resource_clients/key_value_store.d.ts +110 -28
- package/dist/resource_clients/key_value_store.js +177 -99
- package/dist/resource_clients/key_value_store_collection.d.ts +13 -9
- package/dist/resource_clients/key_value_store_collection.js +29 -21
- package/dist/resource_clients/log.d.ts +42 -23
- package/dist/resource_clients/log.js +156 -85
- package/dist/resource_clients/request_queue.d.ts +77 -38
- package/dist/resource_clients/request_queue.js +251 -172
- package/dist/resource_clients/request_queue_collection.d.ts +12 -8
- package/dist/resource_clients/request_queue_collection.js +23 -20
- package/dist/resource_clients/run.d.ts +134 -34
- package/dist/resource_clients/run.js +225 -84
- package/dist/resource_clients/run_collection.d.ts +8 -6
- package/dist/resource_clients/run_collection.js +18 -18
- package/dist/resource_clients/schedule.d.ts +20 -11
- package/dist/resource_clients/schedule.js +36 -30
- package/dist/resource_clients/schedule_collection.d.ts +10 -6
- package/dist/resource_clients/schedule_collection.js +20 -17
- package/dist/resource_clients/store_collection.d.ts +9 -7
- package/dist/resource_clients/store_collection.js +18 -18
- package/dist/resource_clients/task.d.ts +44 -21
- package/dist/resource_clients/task.js +116 -86
- package/dist/resource_clients/task_collection.d.ts +13 -9
- package/dist/resource_clients/task_collection.js +19 -16
- package/dist/resource_clients/user.d.ts +22 -13
- package/dist/resource_clients/user.js +46 -47
- package/dist/resource_clients/webhook.d.ts +21 -12
- package/dist/resource_clients/webhook.js +35 -30
- package/dist/resource_clients/webhook_collection.d.ts +11 -7
- package/dist/resource_clients/webhook_collection.js +20 -17
- package/dist/resource_clients/webhook_dispatch.d.ts +9 -6
- package/dist/resource_clients/webhook_dispatch.js +11 -10
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +7 -5
- package/dist/resource_clients/webhook_dispatch_collection.js +13 -13
- package/dist/response_validation_error.d.ts +27 -0
- package/dist/response_validation_error.js +38 -0
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +87 -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 +381 -0
- package/dist/schemas.js +37 -0
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +7 -11
- package/dist/timeouts.d.ts +84 -0
- package/dist/timeouts.js +37 -0
- package/dist/timezones.d.ts +1 -1
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +99 -70
- package/dist/utils.js +251 -229
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +48 -47
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/http_client.d.ts +0 -88
- package/dist/http_client.js +0 -260
- package/dist/index.mjs +0 -42
- package/dist/interceptors.d.ts +0 -19
- package/dist/interceptors.js +0 -110
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.number().optional() });
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
5
|
+
import { parseArgument, parseResponse } from '../utils.js';
|
|
6
|
+
import { LogClient } from './log.js';
|
|
7
|
+
const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional(), ...timeoutOptionsShape });
|
|
8
|
+
const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional(), ...timeoutOptionsShape });
|
|
10
9
|
/**
|
|
11
10
|
* Client for managing a specific Actor build.
|
|
12
11
|
*
|
|
@@ -30,7 +29,7 @@ const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.numb
|
|
|
30
29
|
*
|
|
31
30
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds#builds
|
|
32
31
|
*/
|
|
33
|
-
class BuildClient extends
|
|
32
|
+
export class BuildClient extends ResourceClient {
|
|
34
33
|
/**
|
|
35
34
|
* @hidden
|
|
36
35
|
*/
|
|
@@ -45,6 +44,8 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
45
44
|
*
|
|
46
45
|
* @param options - Get options
|
|
47
46
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the build to finish on the API side before returning. Default is 0 (returns immediately).
|
|
47
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
|
|
48
|
+
* when the API is asked to hold the response.
|
|
48
49
|
* @returns The Build object, or `undefined` if it does not exist
|
|
49
50
|
* @see https://docs.apify.com/api/v2/actor-build-get
|
|
50
51
|
*
|
|
@@ -59,14 +60,16 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
59
60
|
* ```
|
|
60
61
|
*/
|
|
61
62
|
async get(options = {}) {
|
|
62
|
-
const
|
|
63
|
-
return this.
|
|
63
|
+
const { timeoutSecs, signal, ...params } = parseArgument(options, getOptionsSchema, 'BuildClientGetOptions');
|
|
64
|
+
return this.getResource(schemas.Build(), params, this.timeoutForWaitForFinish(timeoutSecs, 'short', params.waitForFinish), signal);
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Aborts the Actor build.
|
|
67
68
|
*
|
|
68
69
|
* Stops the build process immediately. The build will have an `ABORTED` status.
|
|
69
70
|
*
|
|
71
|
+
* @param options - Request options
|
|
72
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
70
73
|
* @returns The updated Build object with `ABORTED` status
|
|
71
74
|
* @see https://docs.apify.com/api/v2/actor-build-abort-post
|
|
72
75
|
*
|
|
@@ -75,35 +78,46 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
75
78
|
* await client.build('build-id').abort();
|
|
76
79
|
* ```
|
|
77
80
|
*/
|
|
78
|
-
async abort() {
|
|
81
|
+
async abort(options = {}) {
|
|
82
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
79
83
|
const response = await this.httpClient.call({
|
|
80
|
-
url: this.
|
|
84
|
+
url: this.buildUrl('abort'),
|
|
81
85
|
method: 'POST',
|
|
82
|
-
params: this.
|
|
86
|
+
params: this.buildParams(),
|
|
87
|
+
timeoutSecs,
|
|
88
|
+
signal,
|
|
83
89
|
});
|
|
84
|
-
return (
|
|
90
|
+
return parseResponse(response, schemas.Build());
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
* Deletes the Actor build.
|
|
88
94
|
*
|
|
95
|
+
* @param options - Request options
|
|
96
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
89
97
|
* @see https://docs.apify.com/api/v2/actor-build-delete
|
|
90
98
|
* @since Added in 2.8.1
|
|
91
99
|
*/
|
|
92
|
-
async delete() {
|
|
93
|
-
|
|
100
|
+
async delete(options = {}) {
|
|
101
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
102
|
+
return this.deleteResource(timeoutSecs, signal);
|
|
94
103
|
}
|
|
95
104
|
/**
|
|
96
105
|
* Retrieves the OpenAPI definition for the Actor build.
|
|
97
106
|
*
|
|
107
|
+
* @param options - Request options
|
|
108
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
98
109
|
* @returns The OpenAPI definition object.
|
|
99
110
|
* @see https://docs.apify.com/api/v2/actor-build-openapi-json-get
|
|
100
111
|
* @since Added in 2.11.2
|
|
101
112
|
*/
|
|
102
|
-
async getOpenApiDefinition() {
|
|
113
|
+
async getOpenApiDefinition(options = {}) {
|
|
114
|
+
const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
103
115
|
const response = await this.httpClient.call({
|
|
104
|
-
url: this.
|
|
116
|
+
url: this.buildUrl('openapi.json'),
|
|
105
117
|
method: 'GET',
|
|
106
|
-
params: this.
|
|
118
|
+
params: this.buildParams(),
|
|
119
|
+
timeoutSecs,
|
|
120
|
+
signal,
|
|
107
121
|
});
|
|
108
122
|
return response.data;
|
|
109
123
|
}
|
|
@@ -117,12 +131,14 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
117
131
|
* Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
|
|
118
132
|
* by polling the build status. It uses the `waitForFinish` parameter internally (max 60s per call)
|
|
119
133
|
* and continuously polls until the build finishes or the timeout is reached.
|
|
134
|
+
* Rejects with a {@link NotFoundError} if the build keeps returning 404 for 3 seconds.
|
|
120
135
|
*
|
|
121
136
|
* This is useful when you need to immediately start a run after a build finishes.
|
|
122
137
|
*
|
|
123
138
|
* @param options - Wait options
|
|
124
139
|
* @param options.waitSecs - Maximum time to wait for the build to finish, in seconds. If omitted, waits indefinitely.
|
|
125
|
-
* @
|
|
140
|
+
* @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
|
|
141
|
+
* @returns The Build object (finished or still building if the timeout was reached)
|
|
126
142
|
*
|
|
127
143
|
* @example
|
|
128
144
|
* ```javascript
|
|
@@ -138,12 +154,14 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
138
154
|
* ```
|
|
139
155
|
*/
|
|
140
156
|
async waitForFinish(options = {}) {
|
|
141
|
-
const parsed =
|
|
142
|
-
return this.
|
|
157
|
+
const parsed = parseArgument(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
|
|
158
|
+
return this.waitForJobFinish(schemas.Build(), parsed);
|
|
143
159
|
}
|
|
144
160
|
/**
|
|
145
161
|
* Returns a client for accessing the log of this Actor build.
|
|
146
162
|
*
|
|
163
|
+
* A 404 from this client throws an `ApifyApiError`, since the build itself may be what is missing.
|
|
164
|
+
*
|
|
147
165
|
* @returns A client for accessing the build's log
|
|
148
166
|
* @see https://docs.apify.com/api/v2/actor-build-log-get
|
|
149
167
|
*
|
|
@@ -156,9 +174,8 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
156
174
|
* @since Added in 2.9.0
|
|
157
175
|
*/
|
|
158
176
|
log() {
|
|
159
|
-
return new
|
|
177
|
+
return new LogClient(this.subResourceOptions({
|
|
160
178
|
resourcePath: 'log',
|
|
161
179
|
}));
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
|
-
exports.BuildClient = BuildClient;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
1
|
+
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { BuildListItem } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
5
|
+
import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
|
|
6
|
+
export type { BuildListItem } from '../models.js';
|
|
6
7
|
/**
|
|
7
8
|
* Client for managing the collection of Actor builds.
|
|
8
9
|
*
|
|
@@ -46,12 +47,13 @@ export declare class BuildCollectionClient extends ResourceCollectionClient {
|
|
|
46
47
|
* ```
|
|
47
48
|
*
|
|
48
49
|
* @param options - Pagination and sorting options.
|
|
50
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
49
51
|
* @returns A paginated iterator of Actor builds.
|
|
50
52
|
* @see https://docs.apify.com/api/v2/actor-builds-get
|
|
51
53
|
*/
|
|
52
|
-
list(options?: BuildCollectionClientListOptions): PaginatedIterator<
|
|
54
|
+
list(options?: BuildCollectionClientListOptions): PaginatedIterator<BuildListItem>;
|
|
53
55
|
}
|
|
54
|
-
export interface BuildCollectionClientListOptions extends PaginationOptions {
|
|
56
|
+
export interface BuildCollectionClientListOptions extends PaginationOptions, TimeoutOptions {
|
|
55
57
|
desc?: boolean;
|
|
56
58
|
}
|
|
57
|
-
export type BuildCollectionClientListResult = PaginatedList<
|
|
59
|
+
export type BuildCollectionClientListResult = PaginatedList<BuildListItem>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsShape } from '../timeouts.js';
|
|
5
|
+
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
6
|
+
const listOptionsSchema = z.strictObject({
|
|
7
|
+
...paginationOptionsShape,
|
|
8
|
+
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
12
|
* Client for managing the collection of Actor builds.
|
|
@@ -29,7 +29,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
29
29
|
*
|
|
30
30
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds#builds
|
|
31
31
|
*/
|
|
32
|
-
class BuildCollectionClient extends
|
|
32
|
+
export class BuildCollectionClient extends ResourceCollectionClient {
|
|
33
33
|
/**
|
|
34
34
|
* @hidden
|
|
35
35
|
*/
|
|
@@ -56,12 +56,12 @@ class BuildCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
58
|
* @param options - Pagination and sorting options.
|
|
59
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
59
60
|
* @returns A paginated iterator of Actor builds.
|
|
60
61
|
* @see https://docs.apify.com/api/v2/actor-builds-get
|
|
61
62
|
*/
|
|
62
63
|
list(options = {}) {
|
|
63
|
-
const parsed =
|
|
64
|
-
return this.
|
|
64
|
+
const parsed = parseArgument(options, listOptionsSchema, 'BuildCollectionClientListOptions');
|
|
65
|
+
return this.listResourcesPaginated(schemas.ListOfBuilds(), parsed, 'medium');
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
exports.BuildCollectionClient = BuildCollectionClient;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
1
2
|
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
|
|
2
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
3
|
-
import { ResourceClient } from '../base/resource_client';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
3
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
4
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
5
|
+
import type { DatasetResource, DatasetStatistics } from '../models.js';
|
|
6
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
7
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
8
|
+
/**
|
|
9
|
+
* Supported formats for downloading dataset items.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum DownloadItemsFormat {
|
|
12
|
+
JSON = "json",
|
|
13
|
+
JSONL = "jsonl",
|
|
14
|
+
XML = "xml",
|
|
15
|
+
HTML = "html",
|
|
16
|
+
CSV = "csv",
|
|
17
|
+
XLSX = "xlsx",
|
|
18
|
+
RSS = "rss"
|
|
19
|
+
}
|
|
20
|
+
export type { DatasetResource, DatasetFieldStatistics, DatasetStatistics, DatasetStats } from '../models.js';
|
|
7
21
|
/**
|
|
8
22
|
* Client for managing a specific Dataset.
|
|
9
23
|
*
|
|
@@ -34,6 +48,7 @@ export type { Dataset, DatasetStatistics, DatasetStats, FieldStatistics } from '
|
|
|
34
48
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
35
49
|
*/
|
|
36
50
|
export declare class DatasetClient<Data extends Record<string | number, any> = Record<string | number, unknown>> extends ResourceClient {
|
|
51
|
+
#private;
|
|
37
52
|
/**
|
|
38
53
|
* @hidden
|
|
39
54
|
*/
|
|
@@ -41,24 +56,30 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
41
56
|
/**
|
|
42
57
|
* Gets the dataset object from the Apify API.
|
|
43
58
|
*
|
|
59
|
+
* @param options - Request options
|
|
60
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
44
61
|
* @returns The Dataset object, or `undefined` if it does not exist
|
|
45
62
|
* @see https://docs.apify.com/api/v2/dataset-get
|
|
46
63
|
*/
|
|
47
|
-
get(): Promise<
|
|
64
|
+
get(options?: TimeoutOptions): Promise<DatasetResource | undefined>;
|
|
48
65
|
/**
|
|
49
66
|
* Updates the dataset with specified fields.
|
|
50
67
|
*
|
|
51
68
|
* @param newFields - Fields to update in the dataset
|
|
69
|
+
* @param options - Request options
|
|
70
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
52
71
|
* @returns The updated Dataset object
|
|
53
72
|
* @see https://docs.apify.com/api/v2/dataset-put
|
|
54
73
|
*/
|
|
55
|
-
update(newFields: DatasetClientUpdateOptions): Promise<
|
|
74
|
+
update(newFields: DatasetClientUpdateOptions, options?: TimeoutOptions): Promise<DatasetResource>;
|
|
56
75
|
/**
|
|
57
76
|
* Deletes the dataset.
|
|
58
77
|
*
|
|
78
|
+
* @param options - Request options
|
|
79
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
59
80
|
* @see https://docs.apify.com/api/v2/dataset-delete
|
|
60
81
|
*/
|
|
61
|
-
delete(): Promise<void>;
|
|
82
|
+
delete(options?: TimeoutOptions): Promise<void>;
|
|
62
83
|
/**
|
|
63
84
|
* Lists items in the dataset.
|
|
64
85
|
*
|
|
@@ -69,6 +90,7 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
69
90
|
* @param options - Options for listing items
|
|
70
91
|
* @param options.limit - Maximum number of items to return. Default is all items.
|
|
71
92
|
* @param options.chunkSize - Maximum number of items returned in one API response. Relevant in the context of asyncIterator.
|
|
93
|
+
* Without it, iteration loads the whole dataset, or all `limit` items, in one response.
|
|
72
94
|
* @param options.offset - Number of items to skip from the beginning. Default is 0.
|
|
73
95
|
* @param options.desc - If `true`, items are returned in descending order (newest first). Default is `false`.
|
|
74
96
|
* @param options.fields - Array of field names to include in the results. Omits all other fields.
|
|
@@ -77,8 +99,9 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
77
99
|
* @param options.skipEmpty - If `true`, skips empty items. Default is `false`.
|
|
78
100
|
* @param options.skipHidden - If `true`, skips hidden fields (fields starting with `#`). Default is `false`.
|
|
79
101
|
* @param options.flatten - Array of field names to flatten. Nested objects are converted to dot notation (e.g., `obj.field`).
|
|
80
|
-
* @param options.unwind -
|
|
102
|
+
* @param options.unwind - Array of field names to unwind. Each array value creates a separate item.
|
|
81
103
|
* @param options.view - Name of a predefined view to use for field selection.
|
|
104
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'long'`.
|
|
82
105
|
* @returns A paginated list with `items`, `total` count, `offset`, `count`, and `limit`
|
|
83
106
|
* @see https://docs.apify.com/api/v2/dataset-items-get
|
|
84
107
|
*
|
|
@@ -111,6 +134,11 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
111
134
|
* dataset items, this method returns the items serialized to the provided format
|
|
112
135
|
* (JSON, CSV, Excel, etc.) as a Buffer. Useful for exporting data for further processing.
|
|
113
136
|
*
|
|
137
|
+
* In Node.js you can use the `stream` option to get a Readable stream, so a large export is processed in chunks
|
|
138
|
+
* without holding all of it in memory. The stream holds its connection open until you consume it to the end or
|
|
139
|
+
* destroy it. Iterating it with `for await` or passing it to `pipeline()` from `node:stream/promises` does either
|
|
140
|
+
* one for you.
|
|
141
|
+
*
|
|
114
142
|
* @param format - Output format: `'json'`, `'jsonl'`, `'csv'`, `'xlsx'`, `'xml'`, `'rss'`, or `'html'`
|
|
115
143
|
* @param options - Download and formatting options (extends all options from {@link listItems})
|
|
116
144
|
* @param options.attachment - If `true`, the response will have `Content-Disposition: attachment` header.
|
|
@@ -121,7 +149,12 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
121
149
|
* @param options.xmlRow - Name of the XML element for each item. Default is `'item'`.
|
|
122
150
|
* @param options.fields - Array of field names to include in the export.
|
|
123
151
|
* @param options.omit - Array of field names to exclude from the export.
|
|
124
|
-
* @
|
|
152
|
+
* @param options.stream - If `true`, the items are returned as a Readable stream. Node.js only.
|
|
153
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'long'`. With `stream`, it bounds the
|
|
154
|
+
* wait for the API to start responding; once the stream is returned, it only limits inactivity: the stream errors
|
|
155
|
+
* if no data arrives for that long. To stop the download early or cap its total duration, destroy the stream or
|
|
156
|
+
* abort `signal`.
|
|
157
|
+
* @returns Buffer containing the serialized data in the specified format, or a Readable stream of it with `stream`
|
|
125
158
|
* @see https://docs.apify.com/api/v2/dataset-items-get
|
|
126
159
|
*
|
|
127
160
|
* @example
|
|
@@ -142,19 +175,34 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
142
175
|
* xmlRoot: 'products',
|
|
143
176
|
* xmlRow: 'product'
|
|
144
177
|
* });
|
|
178
|
+
*
|
|
179
|
+
* // Stream a CSV export straight to a file
|
|
180
|
+
* const { createWriteStream } = require('node:fs');
|
|
181
|
+
* const { pipeline } = require('node:stream/promises');
|
|
182
|
+
* const stream = await client.dataset('my-dataset').downloadItems('csv', { stream: true });
|
|
183
|
+
* await pipeline(stream, createWriteStream('output.csv'));
|
|
145
184
|
* ```
|
|
146
185
|
*/
|
|
147
|
-
downloadItems(format: DownloadItemsFormat
|
|
186
|
+
downloadItems(format: `${DownloadItemsFormat}`, options?: DatasetClientDownloadItemsOptions & {
|
|
187
|
+
stream?: false;
|
|
188
|
+
}): Promise<Buffer>;
|
|
189
|
+
downloadItems(format: `${DownloadItemsFormat}`, options: DatasetClientDownloadItemsOptions & {
|
|
190
|
+
stream: true;
|
|
191
|
+
}): Promise<Readable>;
|
|
192
|
+
downloadItems(format: `${DownloadItemsFormat}`, options?: DatasetClientDownloadItemsOptions): Promise<Buffer | Readable>;
|
|
148
193
|
/**
|
|
149
194
|
* Stores one or more items into the dataset.
|
|
150
195
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
196
|
+
* Each item will be stored as a separate record in the dataset. Objects are automatically
|
|
197
|
+
* serialized to JSON. If you provide an array, all items will be stored in order. This method
|
|
198
|
+
* is idempotent - calling it multiple times with the same data will not create duplicates, but
|
|
199
|
+
* will append items each time.
|
|
155
200
|
*
|
|
156
|
-
* @param items - A single item
|
|
157
|
-
*
|
|
201
|
+
* @param items - A single item, an array of items, or a string that is the JSON serialization of
|
|
202
|
+
* either - the API only accepts an object or an array of objects, so a plain string
|
|
203
|
+
* is not a valid item on its own.
|
|
204
|
+
* @param options - Request options
|
|
205
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
158
206
|
* @see https://docs.apify.com/api/v2/dataset-items-post
|
|
159
207
|
*
|
|
160
208
|
* @example
|
|
@@ -172,23 +220,22 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
172
220
|
* { url: 'https://test.com', title: 'Test' },
|
|
173
221
|
* { url: 'https://demo.com', title: 'Demo' }
|
|
174
222
|
* ]);
|
|
175
|
-
*
|
|
176
|
-
* // Store string items
|
|
177
|
-
* await client.dataset('my-dataset').pushItems(['item1', 'item2', 'item3']);
|
|
178
223
|
* ```
|
|
179
224
|
*/
|
|
180
|
-
pushItems(items: Data | Data[] | string
|
|
225
|
+
pushItems(items: Data | Data[] | string, options?: TimeoutOptions): Promise<void>;
|
|
181
226
|
/**
|
|
182
227
|
* Gets statistical information about the dataset.
|
|
183
228
|
*
|
|
184
229
|
* Returns statistics for each field in the dataset, including information about
|
|
185
230
|
* data types, null counts, and value ranges.
|
|
186
231
|
*
|
|
187
|
-
* @
|
|
232
|
+
* @param options - Request options
|
|
233
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
234
|
+
* @returns Dataset statistics
|
|
188
235
|
* @see https://docs.apify.com/api/v2/dataset-statistics-get
|
|
189
236
|
* @since Added in 2.11.2
|
|
190
237
|
*/
|
|
191
|
-
getStatistics(): Promise<DatasetStatistics
|
|
238
|
+
getStatistics(options?: TimeoutOptions): Promise<DatasetStatistics>;
|
|
192
239
|
/**
|
|
193
240
|
* Generates a public URL for accessing dataset items.
|
|
194
241
|
*
|
|
@@ -197,10 +244,13 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
197
244
|
* This is useful for sharing dataset results with external services or users.
|
|
198
245
|
*
|
|
199
246
|
* @param options - URL generation options (extends all options from {@link listItems})
|
|
200
|
-
* @param options.expiresInSecs - Number of seconds until the signed URL expires. If omitted, the URL
|
|
247
|
+
* @param options.expiresInSecs - Number of seconds until the signed URL expires. Must be positive. If omitted, the URL
|
|
248
|
+
* never expires.
|
|
201
249
|
* @param options.fields - Array of field names to include in the response.
|
|
250
|
+
* @param options.format - Format of the items served by the URL. Defaults to `json`.
|
|
202
251
|
* @param options.limit - Maximum number of items to return.
|
|
203
252
|
* @param options.offset - Number of items to skip.
|
|
253
|
+
* @param options.timeoutSecs - Timeout for the API request that fetches the dataset. Default is `'long'`.
|
|
204
254
|
* @returns A public URL string for accessing the dataset items
|
|
205
255
|
*
|
|
206
256
|
* @example
|
|
@@ -222,7 +272,6 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
222
272
|
* @since Added in 2.13.0
|
|
223
273
|
*/
|
|
224
274
|
createItemsPublicUrl(options?: DatasetClientCreateItemsUrlOptions): Promise<string>;
|
|
225
|
-
private _createPaginationList;
|
|
226
275
|
}
|
|
227
276
|
/**
|
|
228
277
|
* Options for updating a dataset.
|
|
@@ -244,7 +293,7 @@ export interface DatasetClientUpdateOptions {
|
|
|
244
293
|
* Provides various filtering, pagination, and transformation options to customize
|
|
245
294
|
* the output format and content of retrieved items.
|
|
246
295
|
*/
|
|
247
|
-
export interface DatasetClientListItemOptions extends PaginationOptions {
|
|
296
|
+
export interface DatasetClientListItemOptions extends PaginationOptions, TimeoutOptions {
|
|
248
297
|
clean?: boolean;
|
|
249
298
|
desc?: boolean;
|
|
250
299
|
/**
|
|
@@ -255,7 +304,7 @@ export interface DatasetClientListItemOptions extends PaginationOptions {
|
|
|
255
304
|
omit?: string[];
|
|
256
305
|
skipEmpty?: boolean;
|
|
257
306
|
skipHidden?: boolean;
|
|
258
|
-
unwind?: string
|
|
307
|
+
unwind?: string[];
|
|
259
308
|
/**
|
|
260
309
|
* @since Added in 2.2.0
|
|
261
310
|
*/
|
|
@@ -268,25 +317,18 @@ export interface DatasetClientListItemOptions extends PaginationOptions {
|
|
|
268
317
|
/**
|
|
269
318
|
* Options for creating a public URL to access dataset items.
|
|
270
319
|
*
|
|
271
|
-
* Extends {@link DatasetClientListItemOptions} with URL expiration control, minus `chunkSize` (it only
|
|
320
|
+
* Extends {@link DatasetClientListItemOptions} with output format and URL expiration control, minus `chunkSize` (it only
|
|
272
321
|
* sizes a client-side iteration) and `signature` (this method produces one).
|
|
273
322
|
* @since Added in 2.16.0
|
|
274
323
|
*/
|
|
275
324
|
export interface DatasetClientCreateItemsUrlOptions extends Omit<DatasetClientListItemOptions, 'chunkSize' | 'signature'> {
|
|
325
|
+
/**
|
|
326
|
+
* Format of the items served by the URL. Defaults to `json`.
|
|
327
|
+
* @since Added in 2.26.0
|
|
328
|
+
*/
|
|
329
|
+
format?: `${DownloadItemsFormat}`;
|
|
276
330
|
expiresInSecs?: number;
|
|
277
331
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Supported formats for downloading dataset items.
|
|
280
|
-
*/
|
|
281
|
-
export declare enum DownloadItemsFormat {
|
|
282
|
-
JSON = "json",
|
|
283
|
-
JSONL = "jsonl",
|
|
284
|
-
XML = "xml",
|
|
285
|
-
HTML = "html",
|
|
286
|
-
CSV = "csv",
|
|
287
|
-
XLSX = "xlsx",
|
|
288
|
-
RSS = "rss"
|
|
289
|
-
}
|
|
290
332
|
/**
|
|
291
333
|
* Options for downloading dataset items in a specific format.
|
|
292
334
|
*
|
|
@@ -300,4 +342,9 @@ export interface DatasetClientDownloadItemsOptions extends Omit<DatasetClientLis
|
|
|
300
342
|
skipHeaderRow?: boolean;
|
|
301
343
|
xmlRoot?: string;
|
|
302
344
|
xmlRow?: string;
|
|
345
|
+
/**
|
|
346
|
+
* If `true`, the items are returned as a Readable stream. Node.js only.
|
|
347
|
+
* @default false
|
|
348
|
+
*/
|
|
349
|
+
stream?: boolean;
|
|
303
350
|
}
|