apify-client 3.0.0-beta.12 → 3.0.0-beta.121
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 +23 -2
- package/dist/apify_api_error.d.ts +14 -28
- 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/axios.d.ts +2 -0
- package/dist/axios.js +1 -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 +13 -8
- package/dist/base/resource_client.js +60 -34
- 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 +4 -5
- package/dist/body_parser.js +19 -26
- package/dist/bundle.js +41 -35
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3266 -1103
- package/dist/generated/schemas.d.ts +2608 -1079
- package/dist/generated/schemas.js +600 -239
- package/dist/http_clients/axios.d.ts +80 -0
- package/dist/http_clients/axios.js +165 -0
- package/dist/http_clients/base.d.ts +402 -0
- package/dist/http_clients/base.js +680 -0
- package/dist/http_clients/fetch.d.ts +53 -0
- package/dist/http_clients/fetch.js +219 -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 +7 -2
- 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 +177 -240
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +94 -23
- package/dist/resource_clients/actor.js +129 -43
- package/dist/resource_clients/actor_collection.d.ts +15 -11
- package/dist/resource_clients/actor_collection.js +9 -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 +149 -0
- package/dist/resource_clients/actor_server.js +195 -0
- package/dist/resource_clients/actor_version.d.ts +19 -6
- package/dist/resource_clients/actor_version.js +19 -8
- package/dist/resource_clients/actor_version_collection.d.ts +10 -4
- package/dist/resource_clients/actor_version_collection.js +12 -4
- package/dist/resource_clients/build.d.ts +18 -7
- package/dist/resource_clients/build.js +33 -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 +99 -109
- 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 -33
- package/dist/resource_clients/key_value_store.js +134 -53
- 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 +41 -25
- package/dist/resource_clients/log.js +142 -65
- package/dist/resource_clients/request_queue.d.ts +77 -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 +119 -29
- package/dist/resource_clients/run.js +188 -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 +15 -6
- package/dist/resource_clients/schedule.js +25 -10
- 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 +10 -4
- package/dist/resource_clients/store_collection.js +4 -1
- package/dist/resource_clients/task.d.ts +35 -12
- package/dist/resource_clients/task.js +75 -35
- 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 +16 -7
- package/dist/resource_clients/user.js +34 -16
- package/dist/resource_clients/webhook.d.ts +16 -7
- package/dist/resource_clients/webhook.js +25 -10
- 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 +111 -0
- package/dist/runtime/types.d.ts +82 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +60 -0
- package/dist/schemas.d.ts +372 -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 +115 -61
- package/dist/utils.js +220 -161
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +53 -38
- 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
|
|
@@ -131,13 +142,13 @@ export declare class BuildClient extends ResourceClient {
|
|
|
131
142
|
/**
|
|
132
143
|
* Options for getting a Build.
|
|
133
144
|
*/
|
|
134
|
-
export interface BuildClientGetOptions {
|
|
145
|
+
export interface BuildClientGetOptions extends TimeoutOptions {
|
|
135
146
|
waitForFinish?: number;
|
|
136
147
|
}
|
|
137
148
|
/**
|
|
138
149
|
* Options for waiting for a Build to finish.
|
|
139
150
|
*/
|
|
140
|
-
export interface BuildClientWaitForFinishOptions {
|
|
151
|
+
export interface BuildClientWaitForFinishOptions extends TimeoutOptions {
|
|
141
152
|
/**
|
|
142
153
|
* Maximum time to wait for the build to finish, in seconds.
|
|
143
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,7 +155,7 @@ 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.
|
|
@@ -156,7 +174,7 @@ export class BuildClient extends ResourceClient {
|
|
|
156
174
|
* @since Added in 2.9.0
|
|
157
175
|
*/
|
|
158
176
|
log() {
|
|
159
|
-
return new LogClient(this.
|
|
177
|
+
return new LogClient(this.subResourceOptions({
|
|
160
178
|
resourcePath: 'log',
|
|
161
179
|
}));
|
|
162
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,22 @@
|
|
|
1
1
|
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
|
|
2
2
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
3
3
|
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DatasetResource, DatasetStatistics } from '../models.js';
|
|
5
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
5
6
|
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Supported formats for downloading dataset items.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum DownloadItemsFormat {
|
|
11
|
+
JSON = "json",
|
|
12
|
+
JSONL = "jsonl",
|
|
13
|
+
XML = "xml",
|
|
14
|
+
HTML = "html",
|
|
15
|
+
CSV = "csv",
|
|
16
|
+
XLSX = "xlsx",
|
|
17
|
+
RSS = "rss"
|
|
18
|
+
}
|
|
19
|
+
export type { DatasetResource, DatasetFieldStatistics, DatasetStatistics, DatasetStats } from '../models.js';
|
|
7
20
|
/**
|
|
8
21
|
* Client for managing a specific Dataset.
|
|
9
22
|
*
|
|
@@ -34,6 +47,7 @@ export type { Dataset, DatasetStatistics, DatasetStats, FieldStatistics } from '
|
|
|
34
47
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
35
48
|
*/
|
|
36
49
|
export declare class DatasetClient<Data extends Record<string | number, any> = Record<string | number, unknown>> extends ResourceClient {
|
|
50
|
+
#private;
|
|
37
51
|
/**
|
|
38
52
|
* @hidden
|
|
39
53
|
*/
|
|
@@ -41,24 +55,30 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
41
55
|
/**
|
|
42
56
|
* Gets the dataset object from the Apify API.
|
|
43
57
|
*
|
|
58
|
+
* @param options - Request options
|
|
59
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
44
60
|
* @returns The Dataset object, or `undefined` if it does not exist
|
|
45
61
|
* @see https://docs.apify.com/api/v2/dataset-get
|
|
46
62
|
*/
|
|
47
|
-
get(): Promise<
|
|
63
|
+
get(options?: TimeoutOptions): Promise<DatasetResource | undefined>;
|
|
48
64
|
/**
|
|
49
65
|
* Updates the dataset with specified fields.
|
|
50
66
|
*
|
|
51
67
|
* @param newFields - Fields to update in the dataset
|
|
68
|
+
* @param options - Request options
|
|
69
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
52
70
|
* @returns The updated Dataset object
|
|
53
71
|
* @see https://docs.apify.com/api/v2/dataset-put
|
|
54
72
|
*/
|
|
55
|
-
update(newFields: DatasetClientUpdateOptions): Promise<
|
|
73
|
+
update(newFields: DatasetClientUpdateOptions, options?: TimeoutOptions): Promise<DatasetResource>;
|
|
56
74
|
/**
|
|
57
75
|
* Deletes the dataset.
|
|
58
76
|
*
|
|
77
|
+
* @param options - Request options
|
|
78
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
59
79
|
* @see https://docs.apify.com/api/v2/dataset-delete
|
|
60
80
|
*/
|
|
61
|
-
delete(): Promise<void>;
|
|
81
|
+
delete(options?: TimeoutOptions): Promise<void>;
|
|
62
82
|
/**
|
|
63
83
|
* Lists items in the dataset.
|
|
64
84
|
*
|
|
@@ -69,6 +89,7 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
69
89
|
* @param options - Options for listing items
|
|
70
90
|
* @param options.limit - Maximum number of items to return. Default is all items.
|
|
71
91
|
* @param options.chunkSize - Maximum number of items returned in one API response. Relevant in the context of asyncIterator.
|
|
92
|
+
* Without it, iteration loads the whole dataset, or all `limit` items, in one response.
|
|
72
93
|
* @param options.offset - Number of items to skip from the beginning. Default is 0.
|
|
73
94
|
* @param options.desc - If `true`, items are returned in descending order (newest first). Default is `false`.
|
|
74
95
|
* @param options.fields - Array of field names to include in the results. Omits all other fields.
|
|
@@ -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
|
*
|
|
@@ -109,7 +131,12 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
109
131
|
*
|
|
110
132
|
* Unlike {@link listItems} which returns a {@link PaginatedList} with an array of individual
|
|
111
133
|
* dataset items, this method returns the items serialized to the provided format
|
|
112
|
-
* (JSON, CSV, Excel, etc.) as a
|
|
134
|
+
* (JSON, CSV, Excel, etc.) as a Uint8Array. Useful for exporting data for further processing.
|
|
135
|
+
*
|
|
136
|
+
* You can use the `stream` option to get a web ReadableStream, so a large export is processed in chunks without
|
|
137
|
+
* holding all of it in memory. The stream holds its connection open until you consume it to the end or cancel
|
|
138
|
+
* it. Iterating it with `for await` or piping it with `pipeTo()` does either one for you. In Node.js,
|
|
139
|
+
* `Readable.fromWeb()` turns it into a Readable.
|
|
113
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})
|
|
@@ -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 web ReadableStream.
|
|
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. To stop the download early or cap its total duration, cancel the stream
|
|
154
|
+
* or abort `signal`.
|
|
155
|
+
* @returns Uint8Array containing the serialized data in the specified format, or a web ReadableStream of it with
|
|
156
|
+
* `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}`, options?: DatasetClientDownloadItemsOptions
|
|
185
|
+
downloadItems(format: `${DownloadItemsFormat}`, options?: DatasetClientDownloadItemsOptions & {
|
|
186
|
+
stream?: false;
|
|
187
|
+
}): Promise<Uint8Array>;
|
|
188
|
+
downloadItems(format: `${DownloadItemsFormat}`, options: DatasetClientDownloadItemsOptions & {
|
|
189
|
+
stream: true;
|
|
190
|
+
}): Promise<ReadableStream<Uint8Array>>;
|
|
191
|
+
downloadItems(format: `${DownloadItemsFormat}`, options?: DatasetClientDownloadItemsOptions): Promise<Uint8Array | ReadableStream<Uint8Array>>;
|
|
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
|
*
|
|
231
|
+
* @param options - Request options
|
|
232
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
187
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 web ReadableStream.
|
|
346
|
+
* @default false
|
|
347
|
+
*/
|
|
348
|
+
stream?: boolean;
|
|
303
349
|
}
|