apify-client 3.0.0-beta.0 → 3.0.0-beta.10
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 +5 -4
- package/dist/base/resource_client.js +17 -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 +20595 -0
- package/dist/generated/api.js +5 -0
- 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 +1053 -0
- package/dist/models.js +86 -0
- package/dist/resource_clients/actor.d.ts +13 -459
- package/dist/resource_clients/actor.js +70 -73
- package/dist/resource_clients/actor_collection.d.ts +10 -15
- 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 +14 -43
- package/dist/resource_clients/actor_version.js +15 -24
- 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 +5 -80
- package/dist/resource_clients/build.js +14 -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 +6 -72
- package/dist/resource_clients/dataset.js +73 -76
- 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 -77
- package/dist/resource_clients/key_value_store.js +64 -66
- 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 +2 -2
- package/dist/resource_clients/log.js +15 -22
- package/dist/resource_clients/request_queue.d.ts +17 -183
- package/dist/resource_clients/request_queue.js +102 -108
- 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 +8 -8
- package/dist/resource_clients/run.js +50 -53
- 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 -86
- package/dist/resource_clients/schedule.js +13 -21
- 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 -33
- package/dist/resource_clients/store_collection.js +15 -18
- package/dist/resource_clients/task.d.ts +9 -79
- package/dist/resource_clients/task.js +47 -50
- package/dist/resource_clients/task_collection.d.ts +6 -5
- package/dist/resource_clients/task_collection.js +12 -15
- package/dist/resource_clients/user.d.ts +5 -181
- package/dist/resource_clients/user.js +11 -24
- package/dist/resource_clients/webhook.d.ts +6 -65
- package/dist/resource_clients/webhook.js +11 -14
- 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 -38
- package/dist/resource_clients/webhook_dispatch.js +5 -13
- 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 +19 -24
- package/dist/utils.js +66 -96
- package/package.json +48 -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,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, catchNotFoundOrThrow, 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
|
/**
|
|
@@ -299,14 +297,14 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
299
297
|
url: this._url('statistics'),
|
|
300
298
|
method: 'GET',
|
|
301
299
|
params: this._params(),
|
|
302
|
-
timeout:
|
|
300
|
+
timeout: SMALL_TIMEOUT_MILLIS,
|
|
303
301
|
};
|
|
304
302
|
try {
|
|
305
303
|
const response = await this.httpClient.call(requestOpts);
|
|
306
|
-
return (
|
|
304
|
+
return parseResponse(response, schemas.DatasetStatistics());
|
|
307
305
|
}
|
|
308
306
|
catch (err) {
|
|
309
|
-
|
|
307
|
+
catchNotFoundOrThrow(err);
|
|
310
308
|
}
|
|
311
309
|
return undefined;
|
|
312
310
|
}
|
|
@@ -343,19 +341,19 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
343
341
|
* @since Added in 2.13.0
|
|
344
342
|
*/
|
|
345
343
|
async createItemsPublicUrl(options = {}) {
|
|
346
|
-
const parsed =
|
|
344
|
+
const parsed = parseArgument(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
|
|
347
345
|
const dataset = await this.get();
|
|
348
346
|
const { expiresInSecs, ...queryOptions } = parsed;
|
|
349
347
|
let createdItemsPublicUrl = new URL(this._publicUrl('items'));
|
|
350
348
|
if (dataset?.urlSigningSecretKey) {
|
|
351
|
-
const signature = await
|
|
349
|
+
const signature = await createStorageContentSignatureAsync({
|
|
352
350
|
resourceId: dataset.id,
|
|
353
351
|
urlSigningSecretKey: dataset.urlSigningSecretKey,
|
|
354
352
|
expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
|
|
355
353
|
});
|
|
356
354
|
createdItemsPublicUrl.searchParams.set('signature', signature);
|
|
357
355
|
}
|
|
358
|
-
createdItemsPublicUrl =
|
|
356
|
+
createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
|
|
359
357
|
return createdItemsPublicUrl.toString();
|
|
360
358
|
}
|
|
361
359
|
_createPaginationList(response, userProvidedDesc) {
|
|
@@ -370,11 +368,10 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
370
368
|
};
|
|
371
369
|
}
|
|
372
370
|
}
|
|
373
|
-
exports.DatasetClient = DatasetClient;
|
|
374
371
|
/**
|
|
375
372
|
* Supported formats for downloading dataset items.
|
|
376
373
|
*/
|
|
377
|
-
var DownloadItemsFormat;
|
|
374
|
+
export var DownloadItemsFormat;
|
|
378
375
|
(function (DownloadItemsFormat) {
|
|
379
376
|
DownloadItemsFormat["JSON"] = "json";
|
|
380
377
|
DownloadItemsFormat["JSONL"] = "jsonl";
|
|
@@ -383,7 +380,7 @@ var DownloadItemsFormat;
|
|
|
383
380
|
DownloadItemsFormat["CSV"] = "csv";
|
|
384
381
|
DownloadItemsFormat["XLSX"] = "xlsx";
|
|
385
382
|
DownloadItemsFormat["RSS"] = "rss";
|
|
386
|
-
})(DownloadItemsFormat || (
|
|
383
|
+
})(DownloadItemsFormat || (DownloadItemsFormat = {}));
|
|
387
384
|
const validItemFormats = [...new Set(Object.values(DownloadItemsFormat).map((item) => item.toLowerCase()))];
|
|
388
385
|
// Declared below `validItemFormats` because it references it at module load time.
|
|
389
|
-
const itemFormatSchema =
|
|
386
|
+
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,8 +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';
|
|
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';
|
|
6
8
|
/**
|
|
7
9
|
* Client for managing a specific key-value store.
|
|
8
10
|
*
|
|
@@ -183,11 +185,11 @@ export declare class KeyValueStoreClient extends ResourceClient {
|
|
|
183
185
|
*
|
|
184
186
|
* @param record - The record to store
|
|
185
187
|
* @param record.key - Record key (unique identifier)
|
|
186
|
-
* @param record.value - Record value (
|
|
188
|
+
* @param record.value - Record value (a JSON-serializable value, Buffer, ArrayBuffer, typed array, or Readable)
|
|
187
189
|
* @param record.contentType - Optional MIME type. Auto-detected if not provided:
|
|
188
190
|
* - Objects: `'application/json; charset=utf-8'`
|
|
189
191
|
* - Strings: `'text/plain; charset=utf-8'`
|
|
190
|
-
* -
|
|
192
|
+
* - Binary values and streams: `'application/octet-stream'`
|
|
191
193
|
* @param options - Storage options
|
|
192
194
|
* @param options.timeoutSecs - Timeout for the upload in seconds. Default varies by value size.
|
|
193
195
|
* @param options.doNotRetryTimeouts - If `true`, don't retry on timeout errors. Default is `false`.
|
|
@@ -217,7 +219,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
|
|
|
217
219
|
* });
|
|
218
220
|
* ```
|
|
219
221
|
*/
|
|
220
|
-
setRecord(record: KeyValueStoreRecord<
|
|
222
|
+
setRecord(record: KeyValueStoreRecord<KeyValueStoreRecordValue>, options?: KeyValueStoreRecordOptions): Promise<void>;
|
|
221
223
|
/**
|
|
222
224
|
* Deletes a record from the key-value store.
|
|
223
225
|
*
|
|
@@ -231,53 +233,6 @@ export declare class KeyValueStoreClient extends ResourceClient {
|
|
|
231
233
|
*/
|
|
232
234
|
deleteRecord(key: string): Promise<void>;
|
|
233
235
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Represents a Key-Value Store storage on the Apify platform.
|
|
236
|
-
*
|
|
237
|
-
* Key-value stores are used to store arbitrary data records or files. Each record is identified
|
|
238
|
-
* by a unique key and can contain any data - JSON objects, strings, binary files, etc.
|
|
239
|
-
*/
|
|
240
|
-
export interface KeyValueStore {
|
|
241
|
-
id: string;
|
|
242
|
-
name?: string;
|
|
243
|
-
/**
|
|
244
|
-
* @since Added in 2.6.1
|
|
245
|
-
*/
|
|
246
|
-
title?: string;
|
|
247
|
-
userId: string;
|
|
248
|
-
/**
|
|
249
|
-
* @since Added in 2.21.0
|
|
250
|
-
*/
|
|
251
|
-
username?: string;
|
|
252
|
-
createdAt: Date;
|
|
253
|
-
modifiedAt: Date;
|
|
254
|
-
accessedAt: Date;
|
|
255
|
-
actId?: string;
|
|
256
|
-
actRunId?: string;
|
|
257
|
-
stats?: KeyValueStoreStats;
|
|
258
|
-
/**
|
|
259
|
-
* @since Added in 2.12.2
|
|
260
|
-
*/
|
|
261
|
-
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
262
|
-
/**
|
|
263
|
-
* @since Added in 2.13.0
|
|
264
|
-
*/
|
|
265
|
-
urlSigningSecretKey?: string | null;
|
|
266
|
-
/**
|
|
267
|
-
* @since Added in 2.13.0
|
|
268
|
-
*/
|
|
269
|
-
keysPublicUrl: string;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Statistics about Key-Value Store usage and storage.
|
|
273
|
-
*/
|
|
274
|
-
export interface KeyValueStoreStats {
|
|
275
|
-
readCount?: number;
|
|
276
|
-
writeCount?: number;
|
|
277
|
-
deleteCount?: number;
|
|
278
|
-
listCount?: number;
|
|
279
|
-
storageBytes?: number;
|
|
280
|
-
}
|
|
281
236
|
/**
|
|
282
237
|
* Options for updating a Key-Value Store.
|
|
283
238
|
*/
|
|
@@ -318,30 +273,6 @@ export interface KeyValueClientListKeysOptions {
|
|
|
318
273
|
export interface KeyValueClientCreateKeysUrlOptions extends Omit<KeyValueClientListKeysOptions, 'signature'> {
|
|
319
274
|
expiresInSecs?: number;
|
|
320
275
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Result of listing keys in a Key-Value Store.
|
|
323
|
-
*
|
|
324
|
-
* Contains paginated list of keys with metadata and pagination information.
|
|
325
|
-
*/
|
|
326
|
-
export interface KeyValueClientListKeysResult {
|
|
327
|
-
count: number;
|
|
328
|
-
limit: number;
|
|
329
|
-
exclusiveStartKey: string;
|
|
330
|
-
isTruncated: boolean;
|
|
331
|
-
nextExclusiveStartKey: string;
|
|
332
|
-
items: KeyValueListItem[];
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Metadata about a single key in a Key-Value Store.
|
|
336
|
-
*/
|
|
337
|
-
export interface KeyValueListItem {
|
|
338
|
-
key: string;
|
|
339
|
-
size: number;
|
|
340
|
-
/**
|
|
341
|
-
* @since Added in 2.15.1
|
|
342
|
-
*/
|
|
343
|
-
recordPublicUrl: string;
|
|
344
|
-
}
|
|
345
276
|
/**
|
|
346
277
|
* Options for retrieving a record from a Key-Value Store.
|
|
347
278
|
*/
|
|
@@ -353,6 +284,14 @@ export interface KeyValueClientGetRecordOptions {
|
|
|
353
284
|
*/
|
|
354
285
|
signature?: string;
|
|
355
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;
|
|
356
295
|
/**
|
|
357
296
|
* Represents a record (key-value pair) in a Key-Value Store.
|
|
358
297
|
*
|