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