apify-client 3.0.0-beta.11 → 3.0.0-beta.111
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 +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 +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 +3109 -987
- package/dist/generated/schemas.d.ts +2563 -957
- package/dist/generated/schemas.js +585 -229
- package/dist/http_clients/axios.d.ts +63 -0
- package/dist/http_clients/axios.js +129 -0
- package/dist/http_clients/base.d.ts +397 -0
- package/dist/http_clients/base.js +656 -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 +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 +177 -240
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +104 -34
- package/dist/resource_clients/actor.js +129 -55
- 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 +150 -0
- package/dist/resource_clients/actor_server.js +199 -0
- package/dist/resource_clients/actor_version.d.ts +18 -6
- package/dist/resource_clients/actor_version.js +18 -8
- package/dist/resource_clients/actor_version_collection.d.ts +9 -4
- package/dist/resource_clients/actor_version_collection.js +11 -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 -36
- package/dist/resource_clients/dataset.js +103 -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 +101 -27
- package/dist/resource_clients/key_value_store.js +132 -50
- 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 +38 -21
- package/dist/resource_clients/log.js +139 -63
- 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 +124 -30
- package/dist/resource_clients/run.js +188 -51
- 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 +6 -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 +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 +370 -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 +87 -61
- package/dist/utils.js +208 -162
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +41 -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,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
|
*
|
|
@@ -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}`, options?: DatasetClientDownloadItemsOptions
|
|
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
|
*
|
|
232
|
+
* @param options - Request options
|
|
233
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
187
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
|
}
|