apify-client 3.0.0-beta.1 → 3.0.0-beta.3
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 +2 -2
- package/dist/apify_api_error.js +5 -9
- 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 +1 -1
- package/dist/base/resource_client.js +14 -18
- package/dist/base/resource_collection_client.d.ts +2 -2
- package/dist/base/resource_collection_client.js +6 -10
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +35 -47
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.js +1 -2
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +32 -32
- package/dist/index.js +31 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/models.d.ts +3 -3
- package/dist/models.js +8 -11
- package/dist/resource_clients/actor.d.ts +13 -13
- package/dist/resource_clients/actor.js +67 -71
- package/dist/resource_clients/actor_collection.d.ts +7 -7
- package/dist/resource_clients/actor_collection.js +14 -18
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +4 -8
- package/dist/resource_clients/actor_env_var_collection.d.ts +4 -4
- package/dist/resource_clients/actor_env_var_collection.js +5 -9
- package/dist/resource_clients/actor_version.d.ts +7 -7
- package/dist/resource_clients/actor_version.js +12 -17
- package/dist/resource_clients/actor_version_collection.d.ts +4 -4
- package/dist/resource_clients/actor_version_collection.js +5 -9
- package/dist/resource_clients/build.d.ts +5 -5
- package/dist/resource_clients/build.js +11 -15
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +8 -12
- package/dist/resource_clients/dataset.d.ts +5 -5
- package/dist/resource_clients/dataset.js +72 -76
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +15 -19
- package/dist/resource_clients/key_value_store.d.ts +4 -4
- package/dist/resource_clients/key_value_store.js +57 -62
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +15 -19
- 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 +4 -4
- package/dist/resource_clients/request_queue.js +91 -96
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +13 -17
- package/dist/resource_clients/run.d.ts +8 -8
- package/dist/resource_clients/run.js +46 -50
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +13 -17
- package/dist/resource_clients/schedule.d.ts +6 -6
- package/dist/resource_clients/schedule.js +7 -12
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +10 -14
- package/dist/resource_clients/store_collection.d.ts +5 -5
- package/dist/resource_clients/store_collection.js +13 -17
- package/dist/resource_clients/task.d.ts +9 -9
- package/dist/resource_clients/task.js +44 -48
- package/dist/resource_clients/task_collection.d.ts +6 -6
- package/dist/resource_clients/task_collection.js +9 -13
- package/dist/resource_clients/user.d.ts +5 -5
- package/dist/resource_clients/user.js +8 -13
- package/dist/resource_clients/webhook.d.ts +6 -6
- package/dist/resource_clients/webhook.js +8 -12
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +10 -14
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
- package/dist/resource_clients/webhook_dispatch.js +3 -8
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +8 -12
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +5 -13
- package/dist/utils.js +30 -69
- package/package.json +10 -12
- 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,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const listOptionsSchema = zod_1.z.strictObject({
|
|
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 { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
4
|
+
const listOptionsSchema = z.strictObject({
|
|
5
|
+
...paginationOptionsShape,
|
|
6
|
+
desc: z.boolean().optional(),
|
|
10
7
|
});
|
|
11
8
|
/**
|
|
12
9
|
* Client for managing the collection of Actor builds.
|
|
@@ -29,7 +26,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
29
26
|
*
|
|
30
27
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds#builds
|
|
31
28
|
*/
|
|
32
|
-
class BuildCollectionClient extends
|
|
29
|
+
export class BuildCollectionClient extends ResourceCollectionClient {
|
|
33
30
|
/**
|
|
34
31
|
* @hidden
|
|
35
32
|
*/
|
|
@@ -60,8 +57,7 @@ class BuildCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
60
57
|
* @see https://docs.apify.com/api/v2/actor-builds-get
|
|
61
58
|
*/
|
|
62
59
|
list(options = {}) {
|
|
63
|
-
const parsed =
|
|
60
|
+
const parsed = parseArgument(options, listOptionsSchema, 'BuildCollectionClientListOptions');
|
|
64
61
|
return this._listPaginated(parsed);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
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
|
*
|
|
@@ -1,63 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utilities_1 = require("@apify/utilities");
|
|
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 { anyObjectSchema, applyQueryParamsToUrl, cast, catchNotFoundOrThrow, isNonArrayObject, paginationOptionsShape, parseArgument, pluckData, } from '../utils.js';
|
|
8
5
|
// 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:
|
|
6
|
+
const itemSchema = z.custom(isNonArrayObject, 'Expected an object');
|
|
7
|
+
const listItemsOptionsSchema = z.strictObject({
|
|
8
|
+
clean: z.boolean().optional(),
|
|
9
|
+
desc: z.boolean().optional(),
|
|
10
|
+
flatten: z.array(z.string()).optional(),
|
|
11
|
+
fields: z.array(z.string()).optional(),
|
|
12
|
+
omit: z.array(z.string()).optional(),
|
|
13
|
+
...paginationOptionsShape,
|
|
14
|
+
skipEmpty: z.boolean().optional(),
|
|
15
|
+
skipHidden: z.boolean().optional(),
|
|
16
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
17
|
+
view: z.string().optional(),
|
|
18
|
+
signature: z.string().optional(),
|
|
22
19
|
});
|
|
23
20
|
// Spells out `limit` / `offset` instead of spreading `paginationOptionsShape`: a download is one
|
|
24
21
|
// 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:
|
|
22
|
+
const downloadItemsOptionsSchema = z.strictObject({
|
|
23
|
+
attachment: z.boolean().optional(),
|
|
24
|
+
bom: z.boolean().optional(),
|
|
25
|
+
clean: z.boolean().optional(),
|
|
26
|
+
delimiter: z.string().optional(),
|
|
27
|
+
desc: z.boolean().optional(),
|
|
28
|
+
flatten: z.array(z.string()).optional(),
|
|
29
|
+
fields: z.array(z.string()).optional(),
|
|
30
|
+
omit: z.array(z.string()).optional(),
|
|
31
|
+
limit: z.number().min(0).optional(),
|
|
32
|
+
offset: z.number().min(0).optional(),
|
|
33
|
+
skipEmpty: z.boolean().optional(),
|
|
34
|
+
skipHeaderRow: z.boolean().optional(),
|
|
35
|
+
skipHidden: z.boolean().optional(),
|
|
36
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
37
|
+
view: z.string().optional(),
|
|
38
|
+
xmlRoot: z.string().optional(),
|
|
39
|
+
xmlRow: z.string().optional(),
|
|
40
|
+
signature: z.string().optional(),
|
|
44
41
|
});
|
|
45
|
-
const pushItemsSchema =
|
|
42
|
+
const pushItemsSchema = z.union([itemSchema, z.string(), z.array(z.union([itemSchema, z.string()]))]);
|
|
46
43
|
// Every option becomes a query parameter of the generated URL, so `chunkSize` (client-side only) and
|
|
47
44
|
// `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:
|
|
45
|
+
const createItemsPublicUrlOptionsSchema = z.strictObject({
|
|
46
|
+
clean: z.boolean().optional(),
|
|
47
|
+
desc: z.boolean().optional(),
|
|
48
|
+
flatten: z.array(z.string()).optional(),
|
|
49
|
+
fields: z.array(z.string()).optional(),
|
|
50
|
+
omit: z.array(z.string()).optional(),
|
|
51
|
+
limit: z.number().min(0).optional(),
|
|
52
|
+
offset: z.number().min(0).optional(),
|
|
53
|
+
skipEmpty: z.boolean().optional(),
|
|
54
|
+
skipHidden: z.boolean().optional(),
|
|
55
|
+
unwind: z.union([z.string(), z.array(z.string())]).optional(),
|
|
56
|
+
view: z.string().optional(),
|
|
57
|
+
expiresInSecs: z.number().optional(),
|
|
61
58
|
});
|
|
62
59
|
/**
|
|
63
60
|
* Client for managing a specific Dataset.
|
|
@@ -88,7 +85,7 @@ const createItemsPublicUrlOptionsSchema = zod_1.z.strictObject({
|
|
|
88
85
|
*
|
|
89
86
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
90
87
|
*/
|
|
91
|
-
class DatasetClient extends
|
|
88
|
+
export class DatasetClient extends ResourceClient {
|
|
92
89
|
/**
|
|
93
90
|
* @hidden
|
|
94
91
|
*/
|
|
@@ -105,7 +102,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
105
102
|
* @see https://docs.apify.com/api/v2/dataset-get
|
|
106
103
|
*/
|
|
107
104
|
async get() {
|
|
108
|
-
return this._get({},
|
|
105
|
+
return this._get({}, SMALL_TIMEOUT_MILLIS);
|
|
109
106
|
}
|
|
110
107
|
/**
|
|
111
108
|
* Updates the dataset with specified fields.
|
|
@@ -115,8 +112,8 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
115
112
|
* @see https://docs.apify.com/api/v2/dataset-put
|
|
116
113
|
*/
|
|
117
114
|
async update(newFields) {
|
|
118
|
-
|
|
119
|
-
return this._update(newFields,
|
|
115
|
+
parseArgument(newFields, anyObjectSchema);
|
|
116
|
+
return this._update(newFields, SMALL_TIMEOUT_MILLIS);
|
|
120
117
|
}
|
|
121
118
|
/**
|
|
122
119
|
* Deletes the dataset.
|
|
@@ -124,7 +121,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
124
121
|
* @see https://docs.apify.com/api/v2/dataset-delete
|
|
125
122
|
*/
|
|
126
123
|
async delete() {
|
|
127
|
-
return this._delete(
|
|
124
|
+
return this._delete(SMALL_TIMEOUT_MILLIS);
|
|
128
125
|
}
|
|
129
126
|
/**
|
|
130
127
|
* Lists items in the dataset.
|
|
@@ -171,13 +168,13 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
171
168
|
* ```
|
|
172
169
|
*/
|
|
173
170
|
listItems(options = {}) {
|
|
174
|
-
const parsed =
|
|
171
|
+
const parsed = parseArgument(options, listItemsOptionsSchema, 'DatasetClientListItemOptions');
|
|
175
172
|
const fetchItems = async (datasetListOptions = {}) => {
|
|
176
173
|
const response = await this.httpClient.call({
|
|
177
174
|
url: this._url('items'),
|
|
178
175
|
method: 'GET',
|
|
179
176
|
params: this._params(datasetListOptions),
|
|
180
|
-
timeout:
|
|
177
|
+
timeout: DEFAULT_TIMEOUT_MILLIS,
|
|
181
178
|
});
|
|
182
179
|
return this._createPaginationList(response, datasetListOptions.desc ?? false);
|
|
183
180
|
};
|
|
@@ -224,8 +221,8 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
224
221
|
* ```
|
|
225
222
|
*/
|
|
226
223
|
async downloadItems(format, options = {}) {
|
|
227
|
-
|
|
228
|
-
const parsed =
|
|
224
|
+
parseArgument(format, itemFormatSchema);
|
|
225
|
+
const parsed = parseArgument(options, downloadItemsOptionsSchema, 'DatasetClientDownloadItemsOptions');
|
|
229
226
|
const { data } = await this.httpClient.call({
|
|
230
227
|
url: this._url('items'),
|
|
231
228
|
method: 'GET',
|
|
@@ -234,9 +231,9 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
234
231
|
...parsed,
|
|
235
232
|
}),
|
|
236
233
|
forceBuffer: true,
|
|
237
|
-
timeout:
|
|
234
|
+
timeout: DEFAULT_TIMEOUT_MILLIS,
|
|
238
235
|
});
|
|
239
|
-
return
|
|
236
|
+
return cast(data);
|
|
240
237
|
}
|
|
241
238
|
/**
|
|
242
239
|
* Stores one or more items into the dataset.
|
|
@@ -271,7 +268,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
271
268
|
* ```
|
|
272
269
|
*/
|
|
273
270
|
async pushItems(items) {
|
|
274
|
-
|
|
271
|
+
parseArgument(items, pushItemsSchema);
|
|
275
272
|
await this.httpClient.call({
|
|
276
273
|
url: this._url('items'),
|
|
277
274
|
method: 'POST',
|
|
@@ -281,7 +278,7 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
281
278
|
data: items,
|
|
282
279
|
params: this._params(),
|
|
283
280
|
doNotRetryTimeouts: true, // see timeout handling in http-client
|
|
284
|
-
timeout:
|
|
281
|
+
timeout: MEDIUM_TIMEOUT_MILLIS,
|
|
285
282
|
});
|
|
286
283
|
}
|
|
287
284
|
/**
|
|
@@ -299,14 +296,14 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
299
296
|
url: this._url('statistics'),
|
|
300
297
|
method: 'GET',
|
|
301
298
|
params: this._params(),
|
|
302
|
-
timeout:
|
|
299
|
+
timeout: SMALL_TIMEOUT_MILLIS,
|
|
303
300
|
};
|
|
304
301
|
try {
|
|
305
302
|
const response = await this.httpClient.call(requestOpts);
|
|
306
|
-
return
|
|
303
|
+
return cast(pluckData(response.data));
|
|
307
304
|
}
|
|
308
305
|
catch (err) {
|
|
309
|
-
|
|
306
|
+
catchNotFoundOrThrow(err);
|
|
310
307
|
}
|
|
311
308
|
return undefined;
|
|
312
309
|
}
|
|
@@ -343,19 +340,19 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
343
340
|
* @since Added in 2.13.0
|
|
344
341
|
*/
|
|
345
342
|
async createItemsPublicUrl(options = {}) {
|
|
346
|
-
const parsed =
|
|
343
|
+
const parsed = parseArgument(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
|
|
347
344
|
const dataset = await this.get();
|
|
348
345
|
const { expiresInSecs, ...queryOptions } = parsed;
|
|
349
346
|
let createdItemsPublicUrl = new URL(this._publicUrl('items'));
|
|
350
347
|
if (dataset?.urlSigningSecretKey) {
|
|
351
|
-
const signature = await
|
|
348
|
+
const signature = await createStorageContentSignatureAsync({
|
|
352
349
|
resourceId: dataset.id,
|
|
353
350
|
urlSigningSecretKey: dataset.urlSigningSecretKey,
|
|
354
351
|
expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
|
|
355
352
|
});
|
|
356
353
|
createdItemsPublicUrl.searchParams.set('signature', signature);
|
|
357
354
|
}
|
|
358
|
-
createdItemsPublicUrl =
|
|
355
|
+
createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
|
|
359
356
|
return createdItemsPublicUrl.toString();
|
|
360
357
|
}
|
|
361
358
|
_createPaginationList(response, userProvidedDesc) {
|
|
@@ -370,11 +367,10 @@ class DatasetClient extends resource_client_1.ResourceClient {
|
|
|
370
367
|
};
|
|
371
368
|
}
|
|
372
369
|
}
|
|
373
|
-
exports.DatasetClient = DatasetClient;
|
|
374
370
|
/**
|
|
375
371
|
* Supported formats for downloading dataset items.
|
|
376
372
|
*/
|
|
377
|
-
var DownloadItemsFormat;
|
|
373
|
+
export var DownloadItemsFormat;
|
|
378
374
|
(function (DownloadItemsFormat) {
|
|
379
375
|
DownloadItemsFormat["JSON"] = "json";
|
|
380
376
|
DownloadItemsFormat["JSONL"] = "jsonl";
|
|
@@ -383,7 +379,7 @@ var DownloadItemsFormat;
|
|
|
383
379
|
DownloadItemsFormat["CSV"] = "csv";
|
|
384
380
|
DownloadItemsFormat["XLSX"] = "xlsx";
|
|
385
381
|
DownloadItemsFormat["RSS"] = "rss";
|
|
386
|
-
})(DownloadItemsFormat || (
|
|
382
|
+
})(DownloadItemsFormat || (DownloadItemsFormat = {}));
|
|
387
383
|
const validItemFormats = [...new Set(Object.values(DownloadItemsFormat).map((item) => item.toLowerCase()))];
|
|
388
384
|
// Declared below `validItemFormats` because it references it at module load time.
|
|
389
|
-
const itemFormatSchema =
|
|
385
|
+
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,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
...utils_1.paginationOptionsShape,
|
|
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 { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const listOptionsSchema = z.strictObject({
|
|
6
|
+
unnamed: z.boolean().optional(),
|
|
7
|
+
...paginationOptionsShape,
|
|
8
|
+
desc: z.boolean().optional(),
|
|
9
|
+
ownership: z.enum(STORAGE_OWNERSHIP_FILTER).optional(),
|
|
13
10
|
});
|
|
14
|
-
const nameSchema =
|
|
15
|
-
const schemaSchema =
|
|
11
|
+
const nameSchema = z.string().optional();
|
|
12
|
+
const schemaSchema = anyObjectSchema.optional();
|
|
16
13
|
/**
|
|
17
14
|
* Client for managing the collection of datasets in your account.
|
|
18
15
|
*
|
|
@@ -33,7 +30,7 @@ const schemaSchema = utils_1.anyObjectSchema.optional();
|
|
|
33
30
|
*
|
|
34
31
|
* @see https://docs.apify.com/platform/storage/dataset
|
|
35
32
|
*/
|
|
36
|
-
class DatasetCollectionClient extends
|
|
33
|
+
export class DatasetCollectionClient extends ResourceCollectionClient {
|
|
37
34
|
/**
|
|
38
35
|
* @hidden
|
|
39
36
|
*/
|
|
@@ -64,7 +61,7 @@ class DatasetCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
64
61
|
* @see https://docs.apify.com/api/v2/datasets-get
|
|
65
62
|
*/
|
|
66
63
|
list(options = {}) {
|
|
67
|
-
const parsed =
|
|
64
|
+
const parsed = parseArgument(options, listOptionsSchema, 'DatasetCollectionClientListOptions');
|
|
68
65
|
return this._listPaginated(parsed);
|
|
69
66
|
}
|
|
70
67
|
/**
|
|
@@ -76,9 +73,8 @@ class DatasetCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
76
73
|
* @see https://docs.apify.com/api/v2/datasets-post
|
|
77
74
|
*/
|
|
78
75
|
async getOrCreate(name, options) {
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
parseArgument(name, nameSchema);
|
|
77
|
+
parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
|
|
81
78
|
return this._getOrCreate(name, options);
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
exports.DatasetCollectionClient = DatasetCollectionClient;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { JsonValue } 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
|
*
|