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.
Files changed (94) hide show
  1. package/README.md +5 -3
  2. package/dist/apify_api_error.d.ts +59 -3
  3. package/dist/apify_api_error.js +71 -11
  4. package/dist/apify_client.d.ts +27 -27
  5. package/dist/apify_client.js +86 -91
  6. package/dist/base/api_client.d.ts +3 -3
  7. package/dist/base/api_client.js +6 -10
  8. package/dist/base/resource_client.d.ts +5 -4
  9. package/dist/base/resource_client.js +17 -21
  10. package/dist/base/resource_collection_client.d.ts +7 -6
  11. package/dist/base/resource_collection_client.js +11 -15
  12. package/dist/body_parser.js +6 -11
  13. package/dist/bundle.js +38 -48
  14. package/dist/bundle.js.map +1 -1
  15. package/dist/generated/api.d.ts +20595 -0
  16. package/dist/generated/api.js +5 -0
  17. package/dist/generated/schemas.d.ts +6699 -0
  18. package/dist/generated/schemas.js +1521 -0
  19. package/dist/http_client.d.ts +2 -2
  20. package/dist/http_client.js +23 -28
  21. package/dist/index.d.ts +33 -32
  22. package/dist/index.js +32 -36
  23. package/dist/interceptors.d.ts +1 -1
  24. package/dist/interceptors.js +14 -19
  25. package/dist/lazy_schema.d.ts +8 -0
  26. package/dist/lazy_schema.js +11 -0
  27. package/dist/models.d.ts +1053 -0
  28. package/dist/models.js +86 -0
  29. package/dist/resource_clients/actor.d.ts +13 -459
  30. package/dist/resource_clients/actor.js +70 -73
  31. package/dist/resource_clients/actor_collection.d.ts +10 -15
  32. package/dist/resource_clients/actor_collection.js +19 -20
  33. package/dist/resource_clients/actor_env_var.d.ts +3 -3
  34. package/dist/resource_clients/actor_env_var.js +7 -10
  35. package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
  36. package/dist/resource_clients/actor_env_var_collection.js +15 -19
  37. package/dist/resource_clients/actor_version.d.ts +14 -43
  38. package/dist/resource_clients/actor_version.js +15 -24
  39. package/dist/resource_clients/actor_version_collection.d.ts +13 -19
  40. package/dist/resource_clients/actor_version_collection.js +17 -19
  41. package/dist/resource_clients/build.d.ts +5 -80
  42. package/dist/resource_clients/build.js +14 -17
  43. package/dist/resource_clients/build_collection.d.ts +5 -5
  44. package/dist/resource_clients/build_collection.js +10 -13
  45. package/dist/resource_clients/dataset.d.ts +6 -72
  46. package/dist/resource_clients/dataset.js +73 -76
  47. package/dist/resource_clients/dataset_collection.d.ts +4 -4
  48. package/dist/resource_clients/dataset_collection.js +18 -21
  49. package/dist/resource_clients/key_value_store.d.ts +16 -77
  50. package/dist/resource_clients/key_value_store.js +64 -66
  51. package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
  52. package/dist/resource_clients/key_value_store_collection.js +18 -21
  53. package/dist/resource_clients/log.d.ts +2 -2
  54. package/dist/resource_clients/log.js +15 -22
  55. package/dist/resource_clients/request_queue.d.ts +17 -183
  56. package/dist/resource_clients/request_queue.js +102 -108
  57. package/dist/resource_clients/request_queue_collection.d.ts +4 -4
  58. package/dist/resource_clients/request_queue_collection.js +16 -19
  59. package/dist/resource_clients/run.d.ts +8 -8
  60. package/dist/resource_clients/run.js +50 -53
  61. package/dist/resource_clients/run_collection.d.ts +4 -4
  62. package/dist/resource_clients/run_collection.js +15 -18
  63. package/dist/resource_clients/schedule.d.ts +8 -86
  64. package/dist/resource_clients/schedule.js +13 -21
  65. package/dist/resource_clients/schedule_collection.d.ts +4 -4
  66. package/dist/resource_clients/schedule_collection.js +13 -16
  67. package/dist/resource_clients/store_collection.d.ts +5 -33
  68. package/dist/resource_clients/store_collection.js +15 -18
  69. package/dist/resource_clients/task.d.ts +9 -79
  70. package/dist/resource_clients/task.js +47 -50
  71. package/dist/resource_clients/task_collection.d.ts +6 -5
  72. package/dist/resource_clients/task_collection.js +12 -15
  73. package/dist/resource_clients/user.d.ts +5 -181
  74. package/dist/resource_clients/user.js +11 -24
  75. package/dist/resource_clients/webhook.d.ts +6 -65
  76. package/dist/resource_clients/webhook.js +11 -14
  77. package/dist/resource_clients/webhook_collection.d.ts +4 -4
  78. package/dist/resource_clients/webhook_collection.js +13 -16
  79. package/dist/resource_clients/webhook_dispatch.d.ts +5 -38
  80. package/dist/resource_clients/webhook_dispatch.js +5 -13
  81. package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
  82. package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
  83. package/dist/response_validation_error.d.ts +26 -0
  84. package/dist/response_validation_error.js +37 -0
  85. package/dist/schemas.d.ts +15 -0
  86. package/dist/schemas.js +15 -0
  87. package/dist/statistics.js +5 -9
  88. package/dist/timezones.js +1 -2
  89. package/dist/utils.d.ts +19 -24
  90. package/dist/utils.js +66 -96
  91. package/package.json +48 -40
  92. package/dist/argument_validation_error.d.ts +0 -17
  93. package/dist/argument_validation_error.js +0 -157
  94. package/dist/index.mjs +0 -42
@@ -1,63 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DownloadItemsFormat = exports.DatasetClient = void 0;
4
- const zod_1 = require("zod");
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 * 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 = zod_1.z.custom(utils_1.isNonArrayObject, 'Expected an object');
10
- const listItemsOptionsSchema = zod_1.z.strictObject({
11
- clean: zod_1.z.boolean().optional(),
12
- desc: zod_1.z.boolean().optional(),
13
- flatten: zod_1.z.array(zod_1.z.string()).optional(),
14
- fields: zod_1.z.array(zod_1.z.string()).optional(),
15
- omit: zod_1.z.array(zod_1.z.string()).optional(),
16
- ...utils_1.paginationOptionsShape,
17
- skipEmpty: zod_1.z.boolean().optional(),
18
- skipHidden: zod_1.z.boolean().optional(),
19
- unwind: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
20
- view: zod_1.z.string().optional(),
21
- signature: zod_1.z.string().optional(),
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 = zod_1.z.strictObject({
26
- attachment: zod_1.z.boolean().optional(),
27
- bom: zod_1.z.boolean().optional(),
28
- clean: zod_1.z.boolean().optional(),
29
- delimiter: zod_1.z.string().optional(),
30
- desc: zod_1.z.boolean().optional(),
31
- flatten: zod_1.z.array(zod_1.z.string()).optional(),
32
- fields: zod_1.z.array(zod_1.z.string()).optional(),
33
- omit: zod_1.z.array(zod_1.z.string()).optional(),
34
- limit: zod_1.z.number().min(0).optional(),
35
- offset: zod_1.z.number().min(0).optional(),
36
- skipEmpty: zod_1.z.boolean().optional(),
37
- skipHeaderRow: zod_1.z.boolean().optional(),
38
- skipHidden: zod_1.z.boolean().optional(),
39
- unwind: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
40
- view: zod_1.z.string().optional(),
41
- xmlRoot: zod_1.z.string().optional(),
42
- xmlRow: zod_1.z.string().optional(),
43
- signature: zod_1.z.string().optional(),
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 = zod_1.z.union([itemSchema, zod_1.z.string(), zod_1.z.array(zod_1.z.union([itemSchema, zod_1.z.string()]))]);
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 = zod_1.z.strictObject({
49
- clean: zod_1.z.boolean().optional(),
50
- desc: zod_1.z.boolean().optional(),
51
- flatten: zod_1.z.array(zod_1.z.string()).optional(),
52
- fields: zod_1.z.array(zod_1.z.string()).optional(),
53
- omit: zod_1.z.array(zod_1.z.string()).optional(),
54
- limit: zod_1.z.number().min(0).optional(),
55
- offset: zod_1.z.number().min(0).optional(),
56
- skipEmpty: zod_1.z.boolean().optional(),
57
- skipHidden: zod_1.z.boolean().optional(),
58
- unwind: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
59
- view: zod_1.z.string().optional(),
60
- expiresInSecs: zod_1.z.number().optional(),
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 resource_client_1.ResourceClient {
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({}, resource_client_1.SMALL_TIMEOUT_MILLIS);
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
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
119
- return this._update(newFields, resource_client_1.SMALL_TIMEOUT_MILLIS);
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(resource_client_1.SMALL_TIMEOUT_MILLIS);
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 = (0, utils_1.parseArgument)(options, listItemsOptionsSchema, 'DatasetClientListItemOptions');
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: resource_client_1.DEFAULT_TIMEOUT_MILLIS,
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
- (0, utils_1.parseArgument)(format, itemFormatSchema);
228
- const parsed = (0, utils_1.parseArgument)(options, downloadItemsOptionsSchema, 'DatasetClientDownloadItemsOptions');
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: resource_client_1.DEFAULT_TIMEOUT_MILLIS,
235
+ timeout: DEFAULT_TIMEOUT_MILLIS,
238
236
  });
239
- return (0, utils_1.cast)(data);
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
- (0, utils_1.parseArgument)(items, pushItemsSchema);
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: resource_client_1.MEDIUM_TIMEOUT_MILLIS,
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: resource_client_1.SMALL_TIMEOUT_MILLIS,
300
+ timeout: SMALL_TIMEOUT_MILLIS,
303
301
  };
304
302
  try {
305
303
  const response = await this.httpClient.call(requestOpts);
306
- return (0, utils_1.cast)((0, utils_1.pluckData)(response.data));
304
+ return parseResponse(response, schemas.DatasetStatistics());
307
305
  }
308
306
  catch (err) {
309
- (0, utils_1.catchNotFoundOrThrow)(err);
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 = (0, utils_1.parseArgument)(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
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 (0, utilities_1.createStorageContentSignatureAsync)({
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 = (0, utils_1.applyQueryParamsToUrl)(createdItemsPublicUrl, queryOptions);
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 || (exports.DownloadItemsFormat = 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 = zod_1.z.enum(validItemFormats);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatasetCollectionClient = void 0;
4
- const zod_1 = require("zod");
5
- const consts_1 = require("@apify/consts");
6
- const resource_collection_client_1 = require("../base/resource_collection_client");
7
- const utils_1 = require("../utils");
8
- const listOptionsSchema = zod_1.z.strictObject({
9
- unnamed: zod_1.z.boolean().optional(),
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 * 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 = zod_1.z.string().optional();
15
- const schemaSchema = utils_1.anyObjectSchema.optional();
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 resource_collection_client_1.ResourceCollectionClient {
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 = (0, utils_1.parseArgument)(options, listOptionsSchema, 'DatasetCollectionClientListOptions');
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
- (0, utils_1.parseArgument)(name, nameSchema);
80
- (0, utils_1.parseArgument)(options?.schema, schemaSchema); // TODO: Add schema validation
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 (object, string, Buffer, or Stream)
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
- * - Buffers/Streams: `'application/octet-stream'`
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<JsonValue>, options?: KeyValueStoreRecordOptions): Promise<void>;
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
  *