apify-client 3.0.0-beta.0 → 3.0.0-beta.2
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/argument_validation_error.js +1 -5
- 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 +8 -8
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +20522 -0
- package/dist/generated/api.js +5 -0
- 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 +1072 -0
- package/dist/models.js +86 -0
- package/dist/resource_clients/actor.d.ts +13 -459
- package/dist/resource_clients/actor.js +67 -71
- package/dist/resource_clients/actor_collection.d.ts +7 -12
- 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 -44
- package/dist/resource_clients/actor_version.js +12 -22
- 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 -80
- 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 -71
- 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 -73
- package/dist/resource_clients/key_value_store.js +60 -63
- 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 +17 -176
- package/dist/resource_clients/request_queue.js +93 -98
- 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 -84
- package/dist/resource_clients/schedule.js +7 -18
- 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 -33
- package/dist/resource_clients/store_collection.js +13 -17
- package/dist/resource_clients/task.d.ts +9 -79
- package/dist/resource_clients/task.js +44 -48
- package/dist/resource_clients/task_collection.d.ts +6 -5
- package/dist/resource_clients/task_collection.js +9 -13
- package/dist/resource_clients/user.d.ts +5 -181
- package/dist/resource_clients/user.js +8 -21
- package/dist/resource_clients/webhook.d.ts +6 -65
- 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 -38
- package/dist/resource_clients/webhook_dispatch.js +3 -12
- 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 +3 -3
- package/dist/utils.js +41 -56
- package/package.json +16 -9
- package/dist/index.mjs +0 -42
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { Build } from '../models.js';
|
|
4
|
+
import { LogClient } from './log.js';
|
|
5
|
+
export type { Build, BuildMeta, BuildOptions, BuildStats, BuildUsage } from '../models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing a specific Actor build.
|
|
8
8
|
*
|
|
@@ -143,80 +143,6 @@ export interface BuildClientWaitForFinishOptions {
|
|
|
143
143
|
*/
|
|
144
144
|
waitSecs?: number;
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Metadata about how a Build was initiated.
|
|
148
|
-
*/
|
|
149
|
-
export interface BuildMeta {
|
|
150
|
-
origin: string;
|
|
151
|
-
clientIp: string;
|
|
152
|
-
userAgent: string;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Represents an Actor build.
|
|
156
|
-
*
|
|
157
|
-
* Builds compile Actor source code and prepare it for execution. Each build has a unique ID
|
|
158
|
-
* and can be tagged (e.g., 'latest', 'beta') for easy reference.
|
|
159
|
-
*/
|
|
160
|
-
export interface Build {
|
|
161
|
-
id: string;
|
|
162
|
-
actId: string;
|
|
163
|
-
userId: string;
|
|
164
|
-
startedAt: Date;
|
|
165
|
-
finishedAt?: Date;
|
|
166
|
-
status: (typeof ACT_JOB_TERMINAL_STATUSES)[number];
|
|
167
|
-
meta: BuildMeta;
|
|
168
|
-
stats?: BuildStats;
|
|
169
|
-
options?: BuildOptions;
|
|
170
|
-
/**
|
|
171
|
-
* @deprecated This property is deprecated in favor of `actorDefinition.input`.
|
|
172
|
-
*/
|
|
173
|
-
inputSchema?: string;
|
|
174
|
-
/**
|
|
175
|
-
* @deprecated This property is deprecated in favor of `actorDefinition.readme`.
|
|
176
|
-
*/
|
|
177
|
-
readme?: string;
|
|
178
|
-
buildNumber: string;
|
|
179
|
-
/**
|
|
180
|
-
* @since Added in 2.7.2
|
|
181
|
-
*/
|
|
182
|
-
usage?: BuildUsage;
|
|
183
|
-
/**
|
|
184
|
-
* @since Added in 2.7.2
|
|
185
|
-
*/
|
|
186
|
-
usageTotalUsd?: number;
|
|
187
|
-
/**
|
|
188
|
-
* @since Added in 2.7.2
|
|
189
|
-
*/
|
|
190
|
-
usageUsd?: BuildUsage;
|
|
191
|
-
/**
|
|
192
|
-
* @since Added in 2.11.0
|
|
193
|
-
*/
|
|
194
|
-
actorDefinition?: ActorDefinition;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Resource usage for an Actor build.
|
|
198
|
-
* @since Added in 2.7.2
|
|
199
|
-
*/
|
|
200
|
-
export interface BuildUsage {
|
|
201
|
-
ACTOR_COMPUTE_UNITS?: number;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Runtime statistics for an Actor build.
|
|
205
|
-
*/
|
|
206
|
-
export interface BuildStats {
|
|
207
|
-
durationMillis: number;
|
|
208
|
-
runTimeSecs: number;
|
|
209
|
-
computeUnits: number;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Configuration options used for an Actor build.
|
|
213
|
-
*/
|
|
214
|
-
export interface BuildOptions {
|
|
215
|
-
useCache?: boolean;
|
|
216
|
-
betaPackages?: boolean;
|
|
217
|
-
memoryMbytes?: number;
|
|
218
|
-
diskMbytes?: number;
|
|
219
|
-
}
|
|
220
146
|
/**
|
|
221
147
|
* OpenAPI specification for an Actor.
|
|
222
148
|
*
|
|
@@ -283,4 +209,3 @@ interface OpenApiOperation {
|
|
|
283
209
|
};
|
|
284
210
|
};
|
|
285
211
|
}
|
|
286
|
-
export {};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const log_1 = require("./log");
|
|
8
|
-
const getOptionsSchema = zod_1.z.strictObject({ waitForFinish: zod_1.z.number().optional() });
|
|
9
|
-
const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.number().optional() });
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import { cast, parseArgument, parseDateFields, pluckData } from '../utils.js';
|
|
4
|
+
import { LogClient } from './log.js';
|
|
5
|
+
const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional() });
|
|
6
|
+
const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional() });
|
|
10
7
|
/**
|
|
11
8
|
* Client for managing a specific Actor build.
|
|
12
9
|
*
|
|
@@ -30,7 +27,7 @@ const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.numb
|
|
|
30
27
|
*
|
|
31
28
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds#builds
|
|
32
29
|
*/
|
|
33
|
-
class BuildClient extends
|
|
30
|
+
export class BuildClient extends ResourceClient {
|
|
34
31
|
/**
|
|
35
32
|
* @hidden
|
|
36
33
|
*/
|
|
@@ -59,7 +56,7 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
59
56
|
* ```
|
|
60
57
|
*/
|
|
61
58
|
async get(options = {}) {
|
|
62
|
-
const parsed =
|
|
59
|
+
const parsed = parseArgument(options, getOptionsSchema, 'BuildClientGetOptions');
|
|
63
60
|
return this._get(parsed);
|
|
64
61
|
}
|
|
65
62
|
/**
|
|
@@ -81,7 +78,7 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
81
78
|
method: 'POST',
|
|
82
79
|
params: this._params(),
|
|
83
80
|
});
|
|
84
|
-
return
|
|
81
|
+
return cast(parseDateFields(pluckData(response.data)));
|
|
85
82
|
}
|
|
86
83
|
/**
|
|
87
84
|
* Deletes the Actor build.
|
|
@@ -138,7 +135,7 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
138
135
|
* ```
|
|
139
136
|
*/
|
|
140
137
|
async waitForFinish(options = {}) {
|
|
141
|
-
const parsed =
|
|
138
|
+
const parsed = parseArgument(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
|
|
142
139
|
return this._waitForFinish(parsed);
|
|
143
140
|
}
|
|
144
141
|
/**
|
|
@@ -156,9 +153,8 @@ class BuildClient extends resource_client_1.ResourceClient {
|
|
|
156
153
|
* @since Added in 2.9.0
|
|
157
154
|
*/
|
|
158
155
|
log() {
|
|
159
|
-
return new
|
|
156
|
+
return new LogClient(this._subResourceOptions({
|
|
160
157
|
resourcePath: 'log',
|
|
161
158
|
}));
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
exports.BuildClient = BuildClient;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
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';
|
|
5
6
|
/**
|
|
6
7
|
* Client for managing the collection of Actor builds.
|
|
7
8
|
*
|
|
@@ -53,5 +54,4 @@ export declare class BuildCollectionClient extends ResourceCollectionClient {
|
|
|
53
54
|
export interface BuildCollectionClientListOptions extends PaginationOptions {
|
|
54
55
|
desc?: boolean;
|
|
55
56
|
}
|
|
56
|
-
export type BuildCollectionClientListItem = Required<Pick<Build, 'id' | 'status' | 'startedAt' | 'finishedAt'>> & Partial<Pick<Build, 'meta' | 'usageTotalUsd'>>;
|
|
57
57
|
export type BuildCollectionClientListResult = PaginatedList<BuildCollectionClientListItem>;
|
|
@@ -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,7 +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 {
|
|
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';
|
|
5
7
|
/**
|
|
6
8
|
* Client for managing a specific Dataset.
|
|
7
9
|
*
|
|
@@ -222,55 +224,6 @@ export declare class DatasetClient<Data extends Record<string | number, any> = R
|
|
|
222
224
|
createItemsPublicUrl(options?: DatasetClientCreateItemsUrlOptions): Promise<string>;
|
|
223
225
|
private _createPaginationList;
|
|
224
226
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Represents a dataset storage on the Apify platform.
|
|
227
|
-
*
|
|
228
|
-
* Datasets store structured data as a sequence of items (records). Each item is a JSON object.
|
|
229
|
-
* Datasets are useful for storing results from web scraping, crawling, or data processing tasks.
|
|
230
|
-
*/
|
|
231
|
-
export interface Dataset {
|
|
232
|
-
id: string;
|
|
233
|
-
name?: string;
|
|
234
|
-
/**
|
|
235
|
-
* @since Added in 2.6.1
|
|
236
|
-
*/
|
|
237
|
-
title?: string;
|
|
238
|
-
userId: string;
|
|
239
|
-
/**
|
|
240
|
-
* @since Added in 2.21.0
|
|
241
|
-
*/
|
|
242
|
-
username?: string;
|
|
243
|
-
createdAt: Date;
|
|
244
|
-
modifiedAt: Date;
|
|
245
|
-
accessedAt: Date;
|
|
246
|
-
itemCount: number;
|
|
247
|
-
cleanItemCount: number;
|
|
248
|
-
actId?: string;
|
|
249
|
-
actRunId?: string;
|
|
250
|
-
stats: DatasetStats;
|
|
251
|
-
fields: string[];
|
|
252
|
-
/**
|
|
253
|
-
* @since Added in 2.12.2
|
|
254
|
-
*/
|
|
255
|
-
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
256
|
-
/**
|
|
257
|
-
* @since Added in 2.13.0
|
|
258
|
-
*/
|
|
259
|
-
urlSigningSecretKey?: string | null;
|
|
260
|
-
/**
|
|
261
|
-
* @since Added in 2.13.0
|
|
262
|
-
*/
|
|
263
|
-
itemsPublicUrl: string;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Statistics about dataset usage and storage.
|
|
267
|
-
*/
|
|
268
|
-
export interface DatasetStats {
|
|
269
|
-
readCount?: number;
|
|
270
|
-
writeCount?: number;
|
|
271
|
-
deleteCount?: number;
|
|
272
|
-
storageBytes?: number;
|
|
273
|
-
}
|
|
274
227
|
/**
|
|
275
228
|
* Options for updating a dataset.
|
|
276
229
|
*/
|
|
@@ -348,22 +301,3 @@ export interface DatasetClientDownloadItemsOptions extends Omit<DatasetClientLis
|
|
|
348
301
|
xmlRoot?: string;
|
|
349
302
|
xmlRow?: string;
|
|
350
303
|
}
|
|
351
|
-
/**
|
|
352
|
-
* Statistical information about dataset fields.
|
|
353
|
-
*
|
|
354
|
-
* Provides insights into the data structure and content of the dataset.
|
|
355
|
-
* @since Added in 2.11.2
|
|
356
|
-
*/
|
|
357
|
-
export interface DatasetStatistics {
|
|
358
|
-
fieldStatistics: Record<string, FieldStatistics>;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Statistics for a single field in a dataset.
|
|
362
|
-
* @since Added in 2.11.2
|
|
363
|
-
*/
|
|
364
|
-
export interface FieldStatistics {
|
|
365
|
-
min?: number;
|
|
366
|
-
max?: number;
|
|
367
|
-
nullCount?: number;
|
|
368
|
-
emptyCount?: number;
|
|
369
|
-
}
|
|
@@ -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;
|