apify-client 3.0.0-beta.1 → 3.0.0-beta.11
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 +5 -3
- package/dist/apify_api_error.d.ts +59 -3
- package/dist/apify_api_error.js +71 -11
- package/dist/apify_client.d.ts +27 -27
- package/dist/apify_client.js +86 -91
- package/dist/base/api_client.d.ts +3 -3
- package/dist/base/api_client.js +6 -10
- package/dist/base/resource_client.d.ts +13 -4
- package/dist/base/resource_client.js +25 -21
- package/dist/base/resource_collection_client.d.ts +7 -6
- package/dist/base/resource_collection_client.js +11 -15
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +287 -214
- package/dist/generated/api.js +1 -2
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +33 -32
- package/dist/index.js +32 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +33 -52
- package/dist/models.js +8 -11
- package/dist/resource_clients/actor.d.ts +13 -13
- package/dist/resource_clients/actor.js +70 -73
- package/dist/resource_clients/actor_collection.d.ts +10 -10
- package/dist/resource_clients/actor_collection.js +19 -20
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +7 -10
- package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
- package/dist/resource_clients/actor_env_var_collection.js +15 -19
- package/dist/resource_clients/actor_version.d.ts +16 -8
- package/dist/resource_clients/actor_version.js +15 -19
- package/dist/resource_clients/actor_version_collection.d.ts +13 -19
- package/dist/resource_clients/actor_version_collection.js +17 -19
- package/dist/resource_clients/build.d.ts +7 -5
- package/dist/resource_clients/build.js +16 -17
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +10 -13
- package/dist/resource_clients/dataset.d.ts +8 -8
- package/dist/resource_clients/dataset.js +75 -85
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +18 -21
- package/dist/resource_clients/key_value_store.d.ts +16 -8
- package/dist/resource_clients/key_value_store.js +61 -65
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +18 -21
- package/dist/resource_clients/log.d.ts +6 -4
- package/dist/resource_clients/log.js +23 -28
- package/dist/resource_clients/request_queue.d.ts +4 -11
- package/dist/resource_clients/request_queue.js +100 -106
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +16 -19
- package/dist/resource_clients/run.d.ts +18 -8
- package/dist/resource_clients/run.js +62 -54
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +15 -18
- package/dist/resource_clients/schedule.d.ts +8 -8
- package/dist/resource_clients/schedule.js +14 -23
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +13 -16
- package/dist/resource_clients/store_collection.d.ts +5 -5
- package/dist/resource_clients/store_collection.js +15 -18
- package/dist/resource_clients/task.d.ts +11 -11
- package/dist/resource_clients/task.js +49 -59
- package/dist/resource_clients/task_collection.d.ts +6 -6
- package/dist/resource_clients/task_collection.js +12 -15
- package/dist/resource_clients/user.d.ts +11 -11
- package/dist/resource_clients/user.js +16 -35
- package/dist/resource_clients/webhook.d.ts +8 -8
- package/dist/resource_clients/webhook.js +13 -23
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +13 -16
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
- package/dist/resource_clients/webhook_dispatch.js +5 -9
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +27 -24
- package/dist/utils.js +69 -93
- package/package.json +38 -40
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/index.mjs +0 -42
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type { BuildCollectionClientListItem } from '../models';
|
|
4
|
-
import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils';
|
|
5
|
-
export type { BuildCollectionClientListItem } from '../models';
|
|
1
|
+
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { BuildCollectionClientListItem } from '../models.js';
|
|
4
|
+
import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
|
|
5
|
+
export type { BuildCollectionClientListItem } from '../models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing the collection of Actor builds.
|
|
8
8
|
*
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
...utils_1.paginationOptionsShape,
|
|
9
|
-
desc: zod_1.z.boolean().optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const listOptionsSchema = z.strictObject({
|
|
6
|
+
...paginationOptionsShape,
|
|
7
|
+
desc: z.boolean().optional(),
|
|
10
8
|
});
|
|
11
9
|
/**
|
|
12
10
|
* Client for managing the collection of Actor builds.
|
|
@@ -29,7 +27,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
29
27
|
*
|
|
30
28
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds#builds
|
|
31
29
|
*/
|
|
32
|
-
class BuildCollectionClient extends
|
|
30
|
+
export class BuildCollectionClient extends ResourceCollectionClient {
|
|
33
31
|
/**
|
|
34
32
|
* @hidden
|
|
35
33
|
*/
|
|
@@ -60,8 +58,7 @@ class BuildCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
60
58
|
* @see https://docs.apify.com/api/v2/actor-builds-get
|
|
61
59
|
*/
|
|
62
60
|
list(options = {}) {
|
|
63
|
-
const parsed =
|
|
64
|
-
return this._listPaginated(parsed);
|
|
61
|
+
const parsed = parseArgument(options, listOptionsSchema, 'BuildCollectionClientListOptions');
|
|
62
|
+
return this._listPaginated(schemas.ListOfBuilds(), parsed);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
exports.BuildCollectionClient = BuildCollectionClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
|
|
2
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
3
|
-
import { ResourceClient } from '../base/resource_client';
|
|
4
|
-
import type { Dataset, DatasetStatistics } from '../models';
|
|
5
|
-
import type { PaginatedIterator, PaginationOptions } from '../utils';
|
|
6
|
-
export type { Dataset, DatasetStatistics, DatasetStats, FieldStatistics } from '../models';
|
|
2
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
3
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
+
import type { Dataset, DatasetStatistics } from '../models.js';
|
|
5
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
6
|
+
export type { Dataset, DatasetStatistics, DatasetStats, FieldStatistics } from '../models.js';
|
|
7
7
|
/**
|
|
8
8
|
* Client for managing a specific Dataset.
|
|
9
9
|
*
|
|
@@ -144,7 +144,7 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
144
144
|
* });
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
|
-
downloadItems(format: DownloadItemsFormat
|
|
147
|
+
downloadItems(format: `${DownloadItemsFormat}`, options?: DatasetClientDownloadItemsOptions): Promise<Buffer>;
|
|
148
148
|
/**
|
|
149
149
|
* Stores one or more items into the dataset.
|
|
150
150
|
*
|
|
@@ -184,11 +184,11 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
184
184
|
* Returns statistics for each field in the dataset, including information about
|
|
185
185
|
* data types, null counts, and value ranges.
|
|
186
186
|
*
|
|
187
|
-
* @returns Dataset statistics
|
|
187
|
+
* @returns Dataset statistics
|
|
188
188
|
* @see https://docs.apify.com/api/v2/dataset-statistics-get
|
|
189
189
|
* @since Added in 2.11.2
|
|
190
190
|
*/
|
|
191
|
-
getStatistics(): Promise<DatasetStatistics
|
|
191
|
+
getStatistics(): Promise<DatasetStatistics>;
|
|
192
192
|
/**
|
|
193
193
|
* Generates a public URL for accessing dataset items.
|
|
194
194
|
*
|
|
@@ -1,63 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const resource_client_1 = require("../base/resource_client");
|
|
7
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createStorageContentSignatureAsync } from '@apify/utilities';
|
|
3
|
+
import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { anyObjectSchema, applyQueryParamsToUrl, cast, isNonArrayObject, paginationOptionsShape, parseArgument, parseResponse, } from '../utils.js';
|
|
8
6
|
// A predicate, not a `z.object()` arm, which would walk and copy every key of every pushed item.
|
|
9
|
-
const itemSchema =
|
|
10
|
-
const listItemsOptionsSchema =
|
|
11
|
-
clean:
|
|
12
|
-
desc:
|
|
13
|
-
flatten:
|
|
14
|
-
fields:
|
|
15
|
-
omit:
|
|
16
|
-
...
|
|
17
|
-
skipEmpty:
|
|
18
|
-
skipHidden:
|
|
19
|
-
unwind:
|
|
20
|
-
view:
|
|
21
|
-
signature:
|
|
7
|
+
const itemSchema = z.custom(isNonArrayObject, 'Expected an object');
|
|
8
|
+
const listItemsOptionsSchema = z.strictObject({
|
|
9
|
+
clean: z.boolean().optional(),
|
|
10
|
+
desc: z.boolean().optional(),
|
|
11
|
+
flatten: z.array(z.string()).optional(),
|
|
12
|
+
fields: z.array(z.string()).optional(),
|
|
13
|
+
omit: z.array(z.string()).optional(),
|
|
14
|
+
...paginationOptionsShape,
|
|
15
|
+
skipEmpty: z.boolean().optional(),
|
|
16
|
+
skipHidden: z.boolean().optional(),
|
|
17
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
18
|
+
view: z.string().optional(),
|
|
19
|
+
signature: z.string().optional(),
|
|
22
20
|
});
|
|
23
21
|
// Spells out `limit` / `offset` instead of spreading `paginationOptionsShape`: a download is one
|
|
24
22
|
// request, so `chunkSize` has nothing to size. The options type omits it to match.
|
|
25
|
-
const downloadItemsOptionsSchema =
|
|
26
|
-
attachment:
|
|
27
|
-
bom:
|
|
28
|
-
clean:
|
|
29
|
-
delimiter:
|
|
30
|
-
desc:
|
|
31
|
-
flatten:
|
|
32
|
-
fields:
|
|
33
|
-
omit:
|
|
34
|
-
limit:
|
|
35
|
-
offset:
|
|
36
|
-
skipEmpty:
|
|
37
|
-
skipHeaderRow:
|
|
38
|
-
skipHidden:
|
|
39
|
-
unwind:
|
|
40
|
-
view:
|
|
41
|
-
xmlRoot:
|
|
42
|
-
xmlRow:
|
|
43
|
-
signature:
|
|
23
|
+
const downloadItemsOptionsSchema = z.strictObject({
|
|
24
|
+
attachment: z.boolean().optional(),
|
|
25
|
+
bom: z.boolean().optional(),
|
|
26
|
+
clean: z.boolean().optional(),
|
|
27
|
+
delimiter: z.string().optional(),
|
|
28
|
+
desc: z.boolean().optional(),
|
|
29
|
+
flatten: z.array(z.string()).optional(),
|
|
30
|
+
fields: z.array(z.string()).optional(),
|
|
31
|
+
omit: z.array(z.string()).optional(),
|
|
32
|
+
limit: z.number().min(0).optional(),
|
|
33
|
+
offset: z.number().min(0).optional(),
|
|
34
|
+
skipEmpty: z.boolean().optional(),
|
|
35
|
+
skipHeaderRow: z.boolean().optional(),
|
|
36
|
+
skipHidden: z.boolean().optional(),
|
|
37
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
38
|
+
view: z.string().optional(),
|
|
39
|
+
xmlRoot: z.string().optional(),
|
|
40
|
+
xmlRow: z.string().optional(),
|
|
41
|
+
signature: z.string().optional(),
|
|
44
42
|
});
|
|
45
|
-
const pushItemsSchema =
|
|
43
|
+
const pushItemsSchema = z.union([itemSchema, z.string(), z.array(z.union([itemSchema, z.string()]))]);
|
|
46
44
|
// Every option becomes a query parameter of the generated URL, so `chunkSize` (client-side only) and
|
|
47
45
|
// `signature` (which this method produces) are left out. The options type omits both to match.
|
|
48
|
-
const createItemsPublicUrlOptionsSchema =
|
|
49
|
-
clean:
|
|
50
|
-
desc:
|
|
51
|
-
flatten:
|
|
52
|
-
fields:
|
|
53
|
-
omit:
|
|
54
|
-
limit:
|
|
55
|
-
offset:
|
|
56
|
-
skipEmpty:
|
|
57
|
-
skipHidden:
|
|
58
|
-
unwind:
|
|
59
|
-
view:
|
|
60
|
-
expiresInSecs:
|
|
46
|
+
const createItemsPublicUrlOptionsSchema = z.strictObject({
|
|
47
|
+
clean: z.boolean().optional(),
|
|
48
|
+
desc: z.boolean().optional(),
|
|
49
|
+
flatten: z.array(z.string()).optional(),
|
|
50
|
+
fields: z.array(z.string()).optional(),
|
|
51
|
+
omit: z.array(z.string()).optional(),
|
|
52
|
+
limit: z.number().min(0).optional(),
|
|
53
|
+
offset: z.number().min(0).optional(),
|
|
54
|
+
skipEmpty: z.boolean().optional(),
|
|
55
|
+
skipHidden: z.boolean().optional(),
|
|
56
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
57
|
+
view: z.string().optional(),
|
|
58
|
+
expiresInSecs: z.number().optional(),
|
|
61
59
|
});
|
|
62
60
|
/**
|
|
63
61
|
* Client for managing a specific Dataset.
|
|
@@ -88,7 +86,7 @@ const createItemsPublicUrlOptionsSchema = zod_1.z.strictObject({
|
|
|
88
86
|
*
|
|
89
87
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
90
88
|
*/
|
|
91
|
-
class DatasetClient extends
|
|
89
|
+
export class DatasetClient extends ResourceClient {
|
|
92
90
|
/**
|
|
93
91
|
* @hidden
|
|
94
92
|
*/
|
|
@@ -105,7 +103,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
105
103
|
* @see https://docs.apify.com/api/v2/dataset-get
|
|
106
104
|
*/
|
|
107
105
|
async get() {
|
|
108
|
-
return this._get({},
|
|
106
|
+
return this._get(schemas.Dataset(), {}, SMALL_TIMEOUT_MILLIS);
|
|
109
107
|
}
|
|
110
108
|
/**
|
|
111
109
|
* Updates the dataset with specified fields.
|
|
@@ -115,8 +113,8 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
115
113
|
* @see https://docs.apify.com/api/v2/dataset-put
|
|
116
114
|
*/
|
|
117
115
|
async update(newFields) {
|
|
118
|
-
|
|
119
|
-
return this._update(newFields,
|
|
116
|
+
parseArgument(newFields, anyObjectSchema);
|
|
117
|
+
return this._update(schemas.Dataset(), newFields, SMALL_TIMEOUT_MILLIS);
|
|
120
118
|
}
|
|
121
119
|
/**
|
|
122
120
|
* Deletes the dataset.
|
|
@@ -124,7 +122,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
124
122
|
* @see https://docs.apify.com/api/v2/dataset-delete
|
|
125
123
|
*/
|
|
126
124
|
async delete() {
|
|
127
|
-
return this._delete(
|
|
125
|
+
return this._delete(SMALL_TIMEOUT_MILLIS);
|
|
128
126
|
}
|
|
129
127
|
/**
|
|
130
128
|
* Lists items in the dataset.
|
|
@@ -171,13 +169,13 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
171
169
|
* ```
|
|
172
170
|
*/
|
|
173
171
|
listItems(options = {}) {
|
|
174
|
-
const parsed =
|
|
172
|
+
const parsed = parseArgument(options, listItemsOptionsSchema, 'DatasetClientListItemOptions');
|
|
175
173
|
const fetchItems = async (datasetListOptions = {}) => {
|
|
176
174
|
const response = await this.httpClient.call({
|
|
177
175
|
url: this._url('items'),
|
|
178
176
|
method: 'GET',
|
|
179
177
|
params: this._params(datasetListOptions),
|
|
180
|
-
timeout:
|
|
178
|
+
timeout: DEFAULT_TIMEOUT_MILLIS,
|
|
181
179
|
});
|
|
182
180
|
return this._createPaginationList(response, datasetListOptions.desc ?? false);
|
|
183
181
|
};
|
|
@@ -224,8 +222,8 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
224
222
|
* ```
|
|
225
223
|
*/
|
|
226
224
|
async downloadItems(format, options = {}) {
|
|
227
|
-
|
|
228
|
-
const parsed =
|
|
225
|
+
parseArgument(format, itemFormatSchema);
|
|
226
|
+
const parsed = parseArgument(options, downloadItemsOptionsSchema, 'DatasetClientDownloadItemsOptions');
|
|
229
227
|
const { data } = await this.httpClient.call({
|
|
230
228
|
url: this._url('items'),
|
|
231
229
|
method: 'GET',
|
|
@@ -234,9 +232,9 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
234
232
|
...parsed,
|
|
235
233
|
}),
|
|
236
234
|
forceBuffer: true,
|
|
237
|
-
timeout:
|
|
235
|
+
timeout: DEFAULT_TIMEOUT_MILLIS,
|
|
238
236
|
});
|
|
239
|
-
return
|
|
237
|
+
return cast(data);
|
|
240
238
|
}
|
|
241
239
|
/**
|
|
242
240
|
* Stores one or more items into the dataset.
|
|
@@ -271,7 +269,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
271
269
|
* ```
|
|
272
270
|
*/
|
|
273
271
|
async pushItems(items) {
|
|
274
|
-
|
|
272
|
+
parseArgument(items, pushItemsSchema);
|
|
275
273
|
await this.httpClient.call({
|
|
276
274
|
url: this._url('items'),
|
|
277
275
|
method: 'POST',
|
|
@@ -281,7 +279,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
281
279
|
data: items,
|
|
282
280
|
params: this._params(),
|
|
283
281
|
doNotRetryTimeouts: true, // see timeout handling in http-client
|
|
284
|
-
timeout:
|
|
282
|
+
timeout: MEDIUM_TIMEOUT_MILLIS,
|
|
285
283
|
});
|
|
286
284
|
}
|
|
287
285
|
/**
|
|
@@ -290,25 +288,18 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
290
288
|
* Returns statistics for each field in the dataset, including information about
|
|
291
289
|
* data types, null counts, and value ranges.
|
|
292
290
|
*
|
|
293
|
-
* @returns Dataset statistics
|
|
291
|
+
* @returns Dataset statistics
|
|
294
292
|
* @see https://docs.apify.com/api/v2/dataset-statistics-get
|
|
295
293
|
* @since Added in 2.11.2
|
|
296
294
|
*/
|
|
297
295
|
async getStatistics() {
|
|
298
|
-
const
|
|
296
|
+
const response = await this.httpClient.call({
|
|
299
297
|
url: this._url('statistics'),
|
|
300
298
|
method: 'GET',
|
|
301
299
|
params: this._params(),
|
|
302
|
-
timeout:
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
const response = await this.httpClient.call(requestOpts);
|
|
306
|
-
return (0, utils_1.cast)((0, utils_1.pluckData)(response.data));
|
|
307
|
-
}
|
|
308
|
-
catch (err) {
|
|
309
|
-
(0, utils_1.catchNotFoundOrThrow)(err);
|
|
310
|
-
}
|
|
311
|
-
return undefined;
|
|
300
|
+
timeout: SMALL_TIMEOUT_MILLIS,
|
|
301
|
+
});
|
|
302
|
+
return parseResponse(response, schemas.DatasetStatistics());
|
|
312
303
|
}
|
|
313
304
|
/**
|
|
314
305
|
* Generates a public URL for accessing dataset items.
|
|
@@ -343,19 +334,19 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
343
334
|
* @since Added in 2.13.0
|
|
344
335
|
*/
|
|
345
336
|
async createItemsPublicUrl(options = {}) {
|
|
346
|
-
const parsed =
|
|
337
|
+
const parsed = parseArgument(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
|
|
347
338
|
const dataset = await this.get();
|
|
348
339
|
const { expiresInSecs, ...queryOptions } = parsed;
|
|
349
340
|
let createdItemsPublicUrl = new URL(this._publicUrl('items'));
|
|
350
341
|
if (dataset?.urlSigningSecretKey) {
|
|
351
|
-
const signature = await
|
|
342
|
+
const signature = await createStorageContentSignatureAsync({
|
|
352
343
|
resourceId: dataset.id,
|
|
353
344
|
urlSigningSecretKey: dataset.urlSigningSecretKey,
|
|
354
345
|
expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
|
|
355
346
|
});
|
|
356
347
|
createdItemsPublicUrl.searchParams.set('signature', signature);
|
|
357
348
|
}
|
|
358
|
-
createdItemsPublicUrl =
|
|
349
|
+
createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
|
|
359
350
|
return createdItemsPublicUrl.toString();
|
|
360
351
|
}
|
|
361
352
|
_createPaginationList(response, userProvidedDesc) {
|
|
@@ -370,11 +361,10 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
370
361
|
};
|
|
371
362
|
}
|
|
372
363
|
}
|
|
373
|
-
exports.DatasetClient = DatasetClient;
|
|
374
364
|
/**
|
|
375
365
|
* Supported formats for downloading dataset items.
|
|
376
366
|
*/
|
|
377
|
-
var DownloadItemsFormat;
|
|
367
|
+
export var DownloadItemsFormat;
|
|
378
368
|
(function (DownloadItemsFormat) {
|
|
379
369
|
DownloadItemsFormat["JSON"] = "json";
|
|
380
370
|
DownloadItemsFormat["JSONL"] = "jsonl";
|
|
@@ -383,7 +373,7 @@ var DownloadItemsFormat;
|
|
|
383
373
|
DownloadItemsFormat["CSV"] = "csv";
|
|
384
374
|
DownloadItemsFormat["XLSX"] = "xlsx";
|
|
385
375
|
DownloadItemsFormat["RSS"] = "rss";
|
|
386
|
-
})(DownloadItemsFormat || (
|
|
376
|
+
})(DownloadItemsFormat || (DownloadItemsFormat = {}));
|
|
387
377
|
const validItemFormats = [...new Set(Object.values(DownloadItemsFormat).map((item) => item.toLowerCase()))];
|
|
388
378
|
// Declared below `validItemFormats` because it references it at module load time.
|
|
389
|
-
const itemFormatSchema =
|
|
379
|
+
const itemFormatSchema = z.enum(validItemFormats);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
|
|
2
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
3
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
4
|
-
import type { PaginatedList, PaginationOptions } from '../utils';
|
|
5
|
-
import type { Dataset } from './dataset';
|
|
2
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
3
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import type { PaginatedList, PaginationOptions } from '../utils.js';
|
|
5
|
+
import type { Dataset } from './dataset.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing the collection of datasets in your account.
|
|
8
8
|
*
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
desc: zod_1.z.boolean().optional(),
|
|
12
|
-
ownership: zod_1.z.enum(consts_1.STORAGE_OWNERSHIP_FILTER).optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
|
|
3
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
6
|
+
const listOptionsSchema = z.strictObject({
|
|
7
|
+
unnamed: z.boolean().optional(),
|
|
8
|
+
...paginationOptionsShape,
|
|
9
|
+
desc: z.boolean().optional(),
|
|
10
|
+
ownership: z.enum(STORAGE_OWNERSHIP_FILTER).optional(),
|
|
13
11
|
});
|
|
14
|
-
const nameSchema =
|
|
15
|
-
const schemaSchema =
|
|
12
|
+
const nameSchema = z.string().optional();
|
|
13
|
+
const schemaSchema = anyObjectSchema.optional();
|
|
16
14
|
/**
|
|
17
15
|
* Client for managing the collection of datasets in your account.
|
|
18
16
|
*
|
|
@@ -33,7 +31,7 @@ const schemaSchema = utils_1.anyObjectSchema.optional();
|
|
|
33
31
|
*
|
|
34
32
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
35
33
|
*/
|
|
36
|
-
class DatasetCollectionClient extends
|
|
34
|
+
export class DatasetCollectionClient extends ResourceCollectionClient {
|
|
37
35
|
/**
|
|
38
36
|
* @hidden
|
|
39
37
|
*/
|
|
@@ -64,8 +62,8 @@ class DatasetCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
64
62
|
* @see https://docs.apify.com/api/v2/datasets-get
|
|
65
63
|
*/
|
|
66
64
|
list(options = {}) {
|
|
67
|
-
const parsed =
|
|
68
|
-
return this._listPaginated(parsed);
|
|
65
|
+
const parsed = parseArgument(options, listOptionsSchema, 'DatasetCollectionClientListOptions');
|
|
66
|
+
return this._listPaginated(schemas.ListOfDatasets(), parsed);
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
69
|
* Gets or creates a dataset with the specified name.
|
|
@@ -76,9 +74,8 @@ class DatasetCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
76
74
|
* @see https://docs.apify.com/api/v2/datasets-post
|
|
77
75
|
*/
|
|
78
76
|
async getOrCreate(name, options) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return this._getOrCreate(name, options);
|
|
77
|
+
parseArgument(name, nameSchema);
|
|
78
|
+
parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
|
|
79
|
+
return this._getOrCreate(schemas.Dataset(), name, options);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
|
-
exports.DatasetCollectionClient = DatasetCollectionClient;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { JsonValue } from 'type-fest';
|
|
2
|
+
import type { JsonValue, TypedArray } from 'type-fest';
|
|
3
3
|
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
|
|
4
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
5
|
-
import { ResourceClient } from '../base/resource_client';
|
|
6
|
-
import type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore } from '../models';
|
|
7
|
-
export type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore, KeyValueStoreStats } from '../models';
|
|
4
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
5
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
6
|
+
import type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore } from '../models.js';
|
|
7
|
+
export type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore, KeyValueStoreStats } from '../models.js';
|
|
8
8
|
/**
|
|
9
9
|
* Client for managing a specific key-value store.
|
|
10
10
|
*
|
|
@@ -185,11 +185,11 @@ export declare class KeyValueStoreClient extends ResourceClient {
|
|
|
185
185
|
*
|
|
186
186
|
* @param record - The record to store
|
|
187
187
|
* @param record.key - Record key (unique identifier)
|
|
188
|
-
* @param record.value - Record value (
|
|
188
|
+
* @param record.value - Record value (a JSON-serializable value, Buffer, ArrayBuffer, typed array, or Readable)
|
|
189
189
|
* @param record.contentType - Optional MIME type. Auto-detected if not provided:
|
|
190
190
|
* - Objects: `'application/json; charset=utf-8'`
|
|
191
191
|
* - Strings: `'text/plain; charset=utf-8'`
|
|
192
|
-
* -
|
|
192
|
+
* - Binary values and streams: `'application/octet-stream'`
|
|
193
193
|
* @param options - Storage options
|
|
194
194
|
* @param options.timeoutSecs - Timeout for the upload in seconds. Default varies by value size.
|
|
195
195
|
* @param options.doNotRetryTimeouts - If `true`, don't retry on timeout errors. Default is `false`.
|
|
@@ -219,7 +219,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
|
|
|
219
219
|
* });
|
|
220
220
|
* ```
|
|
221
221
|
*/
|
|
222
|
-
setRecord(record: KeyValueStoreRecord<
|
|
222
|
+
setRecord(record: KeyValueStoreRecord<KeyValueStoreRecordValue>, options?: KeyValueStoreRecordOptions): Promise<void>;
|
|
223
223
|
/**
|
|
224
224
|
* Deletes a record from the key-value store.
|
|
225
225
|
*
|
|
@@ -284,6 +284,14 @@ export interface KeyValueClientGetRecordOptions {
|
|
|
284
284
|
*/
|
|
285
285
|
signature?: string;
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* A value that `setRecord` accepts.
|
|
289
|
+
*
|
|
290
|
+
* Anything JSON-serializable, or binary content the client uploads as bytes instead of JSON-encoding
|
|
291
|
+
* it: a `Buffer`, an `ArrayBuffer`, a typed array, or a readable stream. `Buffer` is a `Uint8Array`, so
|
|
292
|
+
* `TypedArray` covers it.
|
|
293
|
+
*/
|
|
294
|
+
export type KeyValueStoreRecordValue = JsonValue | ArrayBuffer | TypedArray | Readable;
|
|
287
295
|
/**
|
|
288
296
|
* Represents a record (key-value pair) in a Key-Value Store.
|
|
289
297
|
*
|