apify-client 3.0.0-beta.1 → 3.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/apify_api_error.d.ts +59 -3
- package/dist/apify_api_error.js +71 -11
- package/dist/apify_client.d.ts +27 -27
- package/dist/apify_client.js +86 -91
- package/dist/base/api_client.d.ts +3 -3
- package/dist/base/api_client.js +6 -10
- package/dist/base/resource_client.d.ts +13 -4
- package/dist/base/resource_client.js +25 -21
- package/dist/base/resource_collection_client.d.ts +7 -6
- package/dist/base/resource_collection_client.js +11 -15
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +287 -214
- package/dist/generated/api.js +1 -2
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +33 -32
- package/dist/index.js +32 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +33 -52
- package/dist/models.js +8 -11
- package/dist/resource_clients/actor.d.ts +13 -13
- package/dist/resource_clients/actor.js +70 -73
- package/dist/resource_clients/actor_collection.d.ts +10 -10
- package/dist/resource_clients/actor_collection.js +19 -20
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +7 -10
- package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
- package/dist/resource_clients/actor_env_var_collection.js +15 -19
- package/dist/resource_clients/actor_version.d.ts +16 -8
- package/dist/resource_clients/actor_version.js +15 -19
- package/dist/resource_clients/actor_version_collection.d.ts +13 -19
- package/dist/resource_clients/actor_version_collection.js +17 -19
- package/dist/resource_clients/build.d.ts +7 -5
- package/dist/resource_clients/build.js +16 -17
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +10 -13
- package/dist/resource_clients/dataset.d.ts +8 -8
- package/dist/resource_clients/dataset.js +75 -85
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +18 -21
- package/dist/resource_clients/key_value_store.d.ts +16 -8
- package/dist/resource_clients/key_value_store.js +61 -65
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +18 -21
- package/dist/resource_clients/log.d.ts +6 -4
- package/dist/resource_clients/log.js +23 -28
- package/dist/resource_clients/request_queue.d.ts +4 -11
- package/dist/resource_clients/request_queue.js +100 -106
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +16 -19
- package/dist/resource_clients/run.d.ts +18 -8
- package/dist/resource_clients/run.js +62 -54
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +15 -18
- package/dist/resource_clients/schedule.d.ts +8 -8
- package/dist/resource_clients/schedule.js +14 -23
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +13 -16
- package/dist/resource_clients/store_collection.d.ts +5 -5
- package/dist/resource_clients/store_collection.js +15 -18
- package/dist/resource_clients/task.d.ts +11 -11
- package/dist/resource_clients/task.js +49 -59
- package/dist/resource_clients/task_collection.d.ts +6 -6
- package/dist/resource_clients/task_collection.js +12 -15
- package/dist/resource_clients/user.d.ts +11 -11
- package/dist/resource_clients/user.js +16 -35
- package/dist/resource_clients/webhook.d.ts +8 -8
- package/dist/resource_clients/webhook.js +13 -23
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +13 -16
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
- package/dist/resource_clients/webhook_dispatch.js +5 -9
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +27 -24
- package/dist/utils.js +69 -93
- package/package.json +38 -40
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/index.mjs +0 -42
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const log_2 = require("./log");
|
|
11
|
-
const request_queue_1 = require("./request_queue");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LEVELS, Log } from '@apify/log';
|
|
3
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { anyObjectSchema, isNode, parseArgument, parseResponse } from '../utils.js';
|
|
6
|
+
import { DatasetClient } from './dataset.js';
|
|
7
|
+
import { KeyValueStoreClient } from './key_value_store.js';
|
|
8
|
+
import { LogClient, LoggerActorRedirect, StreamedLog } from './log.js';
|
|
9
|
+
import { RequestQueueClient } from './request_queue.js';
|
|
12
10
|
const RUN_CHARGE_IDEMPOTENCY_HEADER = 'idempotency-key';
|
|
13
|
-
const getOptionsSchema =
|
|
14
|
-
const abortOptionsSchema =
|
|
15
|
-
const targetActorIdSchema =
|
|
16
|
-
const metamorphOptionsSchema =
|
|
17
|
-
contentType:
|
|
18
|
-
build:
|
|
11
|
+
const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional() });
|
|
12
|
+
const abortOptionsSchema = z.strictObject({ gracefully: z.boolean().optional() });
|
|
13
|
+
const targetActorIdSchema = z.string();
|
|
14
|
+
const metamorphOptionsSchema = z.strictObject({
|
|
15
|
+
contentType: z.string().optional(),
|
|
16
|
+
build: z.string().optional(),
|
|
19
17
|
});
|
|
20
|
-
const resurrectOptionsSchema =
|
|
21
|
-
build:
|
|
22
|
-
memory:
|
|
23
|
-
timeout:
|
|
24
|
-
maxItems:
|
|
25
|
-
maxTotalChargeUsd:
|
|
26
|
-
restartOnError:
|
|
18
|
+
const resurrectOptionsSchema = z.strictObject({
|
|
19
|
+
build: z.string().optional(),
|
|
20
|
+
memory: z.number().optional(),
|
|
21
|
+
timeout: z.number().optional(),
|
|
22
|
+
maxItems: z.number().optional(),
|
|
23
|
+
maxTotalChargeUsd: z.number().optional(),
|
|
24
|
+
restartOnError: z.boolean().optional(),
|
|
27
25
|
});
|
|
28
|
-
const chargeOptionsSchema =
|
|
29
|
-
eventName:
|
|
30
|
-
count:
|
|
31
|
-
idempotencyKey:
|
|
26
|
+
const chargeOptionsSchema = z.strictObject({
|
|
27
|
+
eventName: z.string(),
|
|
28
|
+
count: z.number().default(1),
|
|
29
|
+
idempotencyKey: z.string().optional(),
|
|
32
30
|
});
|
|
33
|
-
const waitForFinishOptionsSchema =
|
|
31
|
+
const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional() });
|
|
34
32
|
/**
|
|
35
33
|
* Client for managing a specific Actor run.
|
|
36
34
|
*
|
|
@@ -54,7 +52,7 @@ const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.numb
|
|
|
54
52
|
*
|
|
55
53
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds
|
|
56
54
|
*/
|
|
57
|
-
class RunClient extends
|
|
55
|
+
export class RunClient extends ResourceClient {
|
|
58
56
|
/**
|
|
59
57
|
* @hidden
|
|
60
58
|
*/
|
|
@@ -83,8 +81,8 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
83
81
|
* ```
|
|
84
82
|
*/
|
|
85
83
|
async get(options = {}) {
|
|
86
|
-
const parsed =
|
|
87
|
-
return this._get(parsed);
|
|
84
|
+
const parsed = parseArgument(options, getOptionsSchema, 'RunGetOptions');
|
|
85
|
+
return this._get(schemas.Run(), parsed);
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Aborts the Actor run.
|
|
@@ -104,13 +102,13 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
104
102
|
* ```
|
|
105
103
|
*/
|
|
106
104
|
async abort(options = {}) {
|
|
107
|
-
const parsed =
|
|
105
|
+
const parsed = parseArgument(options, abortOptionsSchema, 'RunAbortOptions');
|
|
108
106
|
const response = await this.httpClient.call({
|
|
109
107
|
url: this._url('abort'),
|
|
110
108
|
method: 'POST',
|
|
111
109
|
params: this._params(parsed),
|
|
112
110
|
});
|
|
113
|
-
return (
|
|
111
|
+
return parseResponse(response, schemas.Run());
|
|
114
112
|
}
|
|
115
113
|
/**
|
|
116
114
|
* Deletes the Actor run.
|
|
@@ -147,9 +145,9 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
147
145
|
* ```
|
|
148
146
|
*/
|
|
149
147
|
async metamorph(targetActorId, input, options = {}) {
|
|
150
|
-
|
|
148
|
+
parseArgument(targetActorId, targetActorIdSchema);
|
|
151
149
|
// input can be anything, pointless to validate
|
|
152
|
-
const parsed =
|
|
150
|
+
const parsed = parseArgument(options, metamorphOptionsSchema, 'RunMetamorphOptions');
|
|
153
151
|
const safeTargetActorId = this._toSafeId(targetActorId);
|
|
154
152
|
const params = {
|
|
155
153
|
targetActorId: safeTargetActorId,
|
|
@@ -172,7 +170,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
172
170
|
};
|
|
173
171
|
}
|
|
174
172
|
const response = await this.httpClient.call(request);
|
|
175
|
-
return (
|
|
173
|
+
return parseResponse(response, schemas.Run());
|
|
176
174
|
}
|
|
177
175
|
/**
|
|
178
176
|
* Reboots the Actor run.
|
|
@@ -196,7 +194,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
196
194
|
method: 'POST',
|
|
197
195
|
};
|
|
198
196
|
const response = await this.httpClient.call(request);
|
|
199
|
-
return (
|
|
197
|
+
return parseResponse(response, schemas.Run());
|
|
200
198
|
}
|
|
201
199
|
/**
|
|
202
200
|
* Updates the Actor run with specified fields.
|
|
@@ -217,8 +215,8 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
217
215
|
* @since Added in 2.6.0
|
|
218
216
|
*/
|
|
219
217
|
async update(newFields) {
|
|
220
|
-
|
|
221
|
-
return this._update(newFields);
|
|
218
|
+
parseArgument(newFields, anyObjectSchema);
|
|
219
|
+
return this._update(schemas.Run(), newFields);
|
|
222
220
|
}
|
|
223
221
|
/**
|
|
224
222
|
* Resurrects a finished Actor run, starting it again with the same settings.
|
|
@@ -244,13 +242,13 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
244
242
|
* ```
|
|
245
243
|
*/
|
|
246
244
|
async resurrect(options = {}) {
|
|
247
|
-
const parsed =
|
|
245
|
+
const parsed = parseArgument(options, resurrectOptionsSchema, 'RunResurrectOptions');
|
|
248
246
|
const response = await this.httpClient.call({
|
|
249
247
|
url: this._url('resurrect'),
|
|
250
248
|
method: 'POST',
|
|
251
249
|
params: this._params(parsed),
|
|
252
250
|
});
|
|
253
|
-
return (
|
|
251
|
+
return parseResponse(response, schemas.Run());
|
|
254
252
|
}
|
|
255
253
|
/**
|
|
256
254
|
* Charges the Actor run for a specific event.
|
|
@@ -264,7 +262,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
264
262
|
* @since Added in 2.11.0
|
|
265
263
|
*/
|
|
266
264
|
async charge(options) {
|
|
267
|
-
const { eventName, count, idempotencyKey: providedIdempotencyKey, } =
|
|
265
|
+
const { eventName, count, idempotencyKey: providedIdempotencyKey, } = parseArgument(options, chargeOptionsSchema, 'RunChargeOptions');
|
|
268
266
|
/** To avoid duplicates during the same milisecond, doesn't need to by crypto-secure. */
|
|
269
267
|
const randomSuffix = (Math.random() + 1).toString(36).slice(3, 8);
|
|
270
268
|
const idempotencyKey = providedIdempotencyKey ?? `${this.id}-${eventName}-${Date.now()}-${randomSuffix}`;
|
|
@@ -311,12 +309,14 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
311
309
|
* ```
|
|
312
310
|
*/
|
|
313
311
|
async waitForFinish(options = {}) {
|
|
314
|
-
const parsed =
|
|
315
|
-
return this._waitForFinish(parsed);
|
|
312
|
+
const parsed = parseArgument(options, waitForFinishOptionsSchema, 'RunWaitForFinishOptions');
|
|
313
|
+
return this._waitForFinish(schemas.Run(), parsed);
|
|
316
314
|
}
|
|
317
315
|
/**
|
|
318
316
|
* Returns a client for the default dataset of this Actor run.
|
|
319
317
|
*
|
|
318
|
+
* A 404 from this client throws an `ApifyApiError`, since the run itself may be what is missing.
|
|
319
|
+
*
|
|
320
320
|
* @returns A client for accessing the run's default dataset
|
|
321
321
|
* @see https://docs.apify.com/api/v2/actor-run-get
|
|
322
322
|
*
|
|
@@ -327,13 +327,16 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
327
327
|
* ```
|
|
328
328
|
*/
|
|
329
329
|
dataset() {
|
|
330
|
-
return new
|
|
330
|
+
return new DatasetClient(this._subResourceOptions({
|
|
331
331
|
resourcePath: 'dataset',
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
335
|
* Returns a client for the default key-value store of this Actor run.
|
|
336
336
|
*
|
|
337
|
+
* `get()` and `delete()` throw an `ApifyApiError` on a 404, since the run itself may be what is missing. Record
|
|
338
|
+
* lookups such as `getRecord()` read a 404 as a missing record.
|
|
339
|
+
*
|
|
337
340
|
* @returns A client for accessing the run's default key-value store
|
|
338
341
|
* @see https://docs.apify.com/api/v2/actor-run-get
|
|
339
342
|
*
|
|
@@ -344,13 +347,16 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
344
347
|
* ```
|
|
345
348
|
*/
|
|
346
349
|
keyValueStore() {
|
|
347
|
-
return new
|
|
350
|
+
return new KeyValueStoreClient(this._subResourceOptions({
|
|
348
351
|
resourcePath: 'key-value-store',
|
|
349
352
|
}));
|
|
350
353
|
}
|
|
351
354
|
/**
|
|
352
355
|
* Returns a client for the default Request queue of this Actor run.
|
|
353
356
|
*
|
|
357
|
+
* `get()` and `delete()` throw an `ApifyApiError` on a 404, since the run itself may be what is missing.
|
|
358
|
+
* `getRequest()` reads a 404 as a missing request.
|
|
359
|
+
*
|
|
354
360
|
* @returns A client for accessing the run's default Request queue
|
|
355
361
|
* @see https://docs.apify.com/api/v2/actor-run-get
|
|
356
362
|
*
|
|
@@ -361,13 +367,15 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
361
367
|
* ```
|
|
362
368
|
*/
|
|
363
369
|
requestQueue() {
|
|
364
|
-
return new
|
|
370
|
+
return new RequestQueueClient(this._subResourceOptions({
|
|
365
371
|
resourcePath: 'request-queue',
|
|
366
372
|
}));
|
|
367
373
|
}
|
|
368
374
|
/**
|
|
369
375
|
* Returns a client for accessing the log of this Actor run.
|
|
370
376
|
*
|
|
377
|
+
* A 404 from this client throws an `ApifyApiError`, since the run itself may be what is missing.
|
|
378
|
+
*
|
|
371
379
|
* @returns A client for accessing the run's log
|
|
372
380
|
* @see https://docs.apify.com/api/v2/actor-run-get
|
|
373
381
|
*
|
|
@@ -379,7 +387,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
379
387
|
* ```
|
|
380
388
|
*/
|
|
381
389
|
log() {
|
|
382
|
-
return new
|
|
390
|
+
return new LogClient(this._subResourceOptions({
|
|
383
391
|
resourcePath: 'log',
|
|
384
392
|
}));
|
|
385
393
|
}
|
|
@@ -390,7 +398,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
390
398
|
async getStreamedLog(options = {}) {
|
|
391
399
|
const { fromStart = true } = options;
|
|
392
400
|
let { toLog } = options;
|
|
393
|
-
if (toLog === null || !
|
|
401
|
+
if (toLog === null || !isNode()) {
|
|
394
402
|
// Explicitly no logging or not in Node.js
|
|
395
403
|
return undefined;
|
|
396
404
|
}
|
|
@@ -400,12 +408,12 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
400
408
|
const runData = await this.get();
|
|
401
409
|
const runId = runData?.id ?? '';
|
|
402
410
|
const actorId = runData?.actId ?? '';
|
|
403
|
-
|
|
411
|
+
// `apifyClient.actor()` rejects an empty ID, which is what a run that could not be read leaves here.
|
|
412
|
+
const actorData = actorId ? await this.apifyClient.actor(actorId).get() : undefined;
|
|
404
413
|
const actorName = actorData?.name ?? '';
|
|
405
414
|
const name = [actorName, `runId:${runId}`].filter(Boolean).join(' ');
|
|
406
|
-
toLog = new
|
|
415
|
+
toLog = new Log({ level: LEVELS.DEBUG, prefix: `${name} -> `, logger: new LoggerActorRedirect() });
|
|
407
416
|
}
|
|
408
|
-
return new
|
|
417
|
+
return new StreamedLog({ logClient: this.log(), toLog, fromStart });
|
|
409
418
|
}
|
|
410
419
|
}
|
|
411
|
-
exports.RunClient = RunClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ACTOR_JOB_STATUSES } from '@apify/consts';
|
|
2
|
-
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
|
|
3
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
4
|
-
import type { PaginatedIterator, PaginationOptions } from '../utils';
|
|
5
|
-
import type { ActorRunListItem } from './actor';
|
|
2
|
+
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
|
|
3
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
5
|
+
import type { ActorRunListItem } from './actor.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing the collection of Actor runs.
|
|
8
8
|
*
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
startedBefore: zod_1.z.union([zod_1.z.date(), zod_1.z.string()]).optional(),
|
|
14
|
-
startedAfter: zod_1.z.union([zod_1.z.date(), zod_1.z.string()]).optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ACTOR_JOB_STATUSES } from '@apify/consts';
|
|
3
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
6
|
+
const jobStatusSchema = z.enum(ACTOR_JOB_STATUSES);
|
|
7
|
+
const listOptionsSchema = z.strictObject({
|
|
8
|
+
...paginationOptionsShape,
|
|
9
|
+
desc: z.boolean().optional(),
|
|
10
|
+
status: z.union([jobStatusSchema, z.array(jobStatusSchema)]).optional(),
|
|
11
|
+
startedBefore: z.union([z.date(), z.string()]).optional(),
|
|
12
|
+
startedAfter: z.union([z.date(), z.string()]).optional(),
|
|
15
13
|
});
|
|
16
14
|
/**
|
|
17
15
|
* Client for managing the collection of Actor runs.
|
|
@@ -34,7 +32,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
34
32
|
*
|
|
35
33
|
* @see https://docs.apify.com/platform/actors/running/runs-and-builds
|
|
36
34
|
*/
|
|
37
|
-
class RunCollectionClient extends
|
|
35
|
+
export class RunCollectionClient extends ResourceCollectionClient {
|
|
38
36
|
/**
|
|
39
37
|
* @hidden
|
|
40
38
|
*/
|
|
@@ -65,8 +63,7 @@ class RunCollectionClient extends resource_collection_client_1.ResourceCollectio
|
|
|
65
63
|
* @see https://docs.apify.com/api/v2/actor-runs-get
|
|
66
64
|
*/
|
|
67
65
|
list(options = {}) {
|
|
68
|
-
const parsed =
|
|
69
|
-
return this._listPaginated(parsed);
|
|
66
|
+
const parsed = parseArgument(options, listOptionsSchema, 'RunCollectionListOptions');
|
|
67
|
+
return this._listPaginated(schemas.ListOfRuns(), parsed);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
exports.RunCollectionClient = RunCollectionClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { Schedule, ScheduleAction } from '../models';
|
|
4
|
-
import type { DistributiveOptional } from '../utils';
|
|
5
|
-
export type { Schedule, ScheduleAction, ScheduleActionRunActor, ScheduleActionRunActorTask, ScheduledActorRunInput, ScheduledActorRunOptions, } from '../models';
|
|
6
|
-
export { ScheduleActions } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { Schedule, ScheduleAction, ScheduleInvoked } from '../models.js';
|
|
4
|
+
import type { DistributiveOptional } from '../utils.js';
|
|
5
|
+
export type { Schedule, ScheduleAction, ScheduleActionRunActor, ScheduleActionRunActorTask, ScheduledActorRunInput, ScheduledActorRunOptions, ScheduleInvoked, } from '../models.js';
|
|
6
|
+
export { ScheduleActions } from '../models.js';
|
|
7
7
|
/**
|
|
8
8
|
* Client for managing a specific Schedule.
|
|
9
9
|
*
|
|
@@ -56,10 +56,10 @@ export declare class ScheduleClient extends ResourceClient {
|
|
|
56
56
|
/**
|
|
57
57
|
* Retrieves the schedule's log.
|
|
58
58
|
*
|
|
59
|
-
* @returns The schedule log
|
|
59
|
+
* @returns The schedule log, one entry per invocation.
|
|
60
60
|
* @see https://docs.apify.com/api/v2/schedule-log-get
|
|
61
61
|
*/
|
|
62
|
-
getLog(): Promise<
|
|
62
|
+
getLog(): Promise<ScheduleInvoked[]>;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Data for creating or updating a Schedule.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "ScheduleActions", { enumerable: true, get: function () { return models_1.ScheduleActions; } });
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { anyObjectSchema, parseArgument, parseResponse } from '../utils.js';
|
|
5
|
+
export { ScheduleActions } from '../models.js';
|
|
6
|
+
const scheduleLogSchema = z.array(schemas.ScheduleInvoked());
|
|
8
7
|
/**
|
|
9
8
|
* Client for managing a specific Schedule.
|
|
10
9
|
*
|
|
@@ -28,7 +27,7 @@ Object.defineProperty(exports, "ScheduleActions", { enumerable: true, get: funct
|
|
|
28
27
|
*
|
|
29
28
|
* @see https://docs.apify.com/platform/schedules
|
|
30
29
|
*/
|
|
31
|
-
class ScheduleClient extends
|
|
30
|
+
export class ScheduleClient extends ResourceClient {
|
|
32
31
|
/**
|
|
33
32
|
* @hidden
|
|
34
33
|
*/
|
|
@@ -45,7 +44,7 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
45
44
|
* @see https://docs.apify.com/api/v2/schedule-get
|
|
46
45
|
*/
|
|
47
46
|
async get() {
|
|
48
|
-
return this._get();
|
|
47
|
+
return this._get(schemas.Schedule());
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* Updates the schedule with the specified fields.
|
|
@@ -55,8 +54,8 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
55
54
|
* @see https://docs.apify.com/api/v2/schedule-put
|
|
56
55
|
*/
|
|
57
56
|
async update(newFields) {
|
|
58
|
-
|
|
59
|
-
return this._update(newFields);
|
|
57
|
+
parseArgument(newFields, anyObjectSchema);
|
|
58
|
+
return this._update(schemas.Schedule(), newFields);
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
62
61
|
* Deletes the schedule.
|
|
@@ -69,23 +68,15 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
69
68
|
/**
|
|
70
69
|
* Retrieves the schedule's log.
|
|
71
70
|
*
|
|
72
|
-
* @returns The schedule log
|
|
71
|
+
* @returns The schedule log, one entry per invocation.
|
|
73
72
|
* @see https://docs.apify.com/api/v2/schedule-log-get
|
|
74
73
|
*/
|
|
75
74
|
async getLog() {
|
|
76
|
-
const
|
|
75
|
+
const response = await this.httpClient.call({
|
|
77
76
|
url: this._url('log'),
|
|
78
77
|
method: 'GET',
|
|
79
78
|
params: this._params(),
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const response = await this.httpClient.call(requestOpts);
|
|
83
|
-
return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
(0, utils_1.catchNotFoundOrThrow)(err);
|
|
87
|
-
}
|
|
88
|
-
return undefined;
|
|
79
|
+
});
|
|
80
|
+
return parseResponse(response, scheduleLogSchema);
|
|
89
81
|
}
|
|
90
82
|
}
|
|
91
|
-
exports.ScheduleClient = ScheduleClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type { PaginatedIterator, PaginationOptions } from '../utils';
|
|
4
|
-
import type { Schedule, ScheduleCreateOrUpdateData } from './schedule';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
4
|
+
import type { Schedule, ScheduleCreateOrUpdateData } from './schedule.js';
|
|
5
5
|
/**
|
|
6
6
|
* Client for managing the collection of Schedules in your account.
|
|
7
7
|
*
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
...utils_1.paginationOptionsShape,
|
|
9
|
-
desc: zod_1.z.boolean().optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const listOptionsSchema = z.strictObject({
|
|
6
|
+
...paginationOptionsShape,
|
|
7
|
+
desc: z.boolean().optional(),
|
|
10
8
|
});
|
|
11
|
-
const scheduleCreateSchema =
|
|
9
|
+
const scheduleCreateSchema = anyObjectSchema.optional();
|
|
12
10
|
/**
|
|
13
11
|
* Client for managing the collection of Schedules in your account.
|
|
14
12
|
*
|
|
@@ -33,7 +31,7 @@ const scheduleCreateSchema = utils_1.anyObjectSchema.optional();
|
|
|
33
31
|
*
|
|
34
32
|
* @see https://docs.apify.com/platform/schedules
|
|
35
33
|
*/
|
|
36
|
-
class ScheduleCollectionClient extends
|
|
34
|
+
export class ScheduleCollectionClient extends ResourceCollectionClient {
|
|
37
35
|
/**
|
|
38
36
|
* @hidden
|
|
39
37
|
*/
|
|
@@ -64,8 +62,8 @@ class ScheduleCollectionClient extends resource_collection_client_1.ResourceColl
|
|
|
64
62
|
* @see https://docs.apify.com/api/v2/schedules-get
|
|
65
63
|
*/
|
|
66
64
|
list(options = {}) {
|
|
67
|
-
const parsed =
|
|
68
|
-
return this._listPaginated(parsed);
|
|
65
|
+
const parsed = parseArgument(options, listOptionsSchema, 'ScheduleCollectionListOptions');
|
|
66
|
+
return this._listPaginated(schemas.ListOfSchedules(), parsed);
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
69
|
* Creates a new schedule.
|
|
@@ -75,8 +73,7 @@ class ScheduleCollectionClient extends resource_collection_client_1.ResourceColl
|
|
|
75
73
|
* @see https://docs.apify.com/api/v2/schedules-post
|
|
76
74
|
*/
|
|
77
75
|
async create(schedule) {
|
|
78
|
-
|
|
79
|
-
return this._create(schedule);
|
|
76
|
+
parseArgument(schedule, scheduleCreateSchema);
|
|
77
|
+
return this._create(schemas.Schedule(), schedule);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
exports.ScheduleCollectionClient = ScheduleCollectionClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type { ActorStoreList } from '../models';
|
|
4
|
-
import type { PaginatedIterator, PaginationOptions } from '../utils';
|
|
5
|
-
export type { ActorStoreList, PricingInfo } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { ActorStoreList } from '../models.js';
|
|
4
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
5
|
+
export type { ActorStoreList, PricingInfo } from '../models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for browsing Actors in the Apify Store.
|
|
8
8
|
*
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
pricingModel: zod_1.z.string().optional(),
|
|
14
|
-
includeUnrunnableActors: zod_1.z.boolean().optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const listOptionsSchema = z.strictObject({
|
|
6
|
+
...paginationOptionsShape,
|
|
7
|
+
search: z.string().optional(),
|
|
8
|
+
sortBy: z.string().optional(),
|
|
9
|
+
category: z.string().optional(),
|
|
10
|
+
username: z.string().optional(),
|
|
11
|
+
pricingModel: z.string().optional(),
|
|
12
|
+
includeUnrunnableActors: z.boolean().optional(),
|
|
15
13
|
});
|
|
16
14
|
/**
|
|
17
15
|
* Client for browsing Actors in the Apify Store.
|
|
@@ -34,7 +32,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
34
32
|
* @see https://docs.apify.com/platform/actors/publishing
|
|
35
33
|
* @since Added in 2.7.2
|
|
36
34
|
*/
|
|
37
|
-
class StoreCollectionClient extends
|
|
35
|
+
export class StoreCollectionClient extends ResourceCollectionClient {
|
|
38
36
|
/**
|
|
39
37
|
* @hidden
|
|
40
38
|
*/
|
|
@@ -65,8 +63,7 @@ class StoreCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
65
63
|
* @see https://docs.apify.com/api/v2/store-get
|
|
66
64
|
*/
|
|
67
65
|
list(options = {}) {
|
|
68
|
-
const parsed =
|
|
69
|
-
return this._listPaginated(parsed);
|
|
66
|
+
const parsed = parseArgument(options, listOptionsSchema, 'StoreCollectionListOptions');
|
|
67
|
+
return this._listPaginated(schemas.ListOfStoreActors(), parsed);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
exports.StoreCollectionClient = StoreCollectionClient;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { Task, TaskPublicConfig } from '../models';
|
|
4
|
-
import type { Dictionary } from '../utils';
|
|
5
|
-
import type { ActorLastRunOptions, ActorRun, ActorStartOptions } from './actor';
|
|
6
|
-
import { RunClient } from './run';
|
|
7
|
-
import { RunCollectionClient } from './run_collection';
|
|
8
|
-
import { WebhookCollectionClient } from './webhook_collection';
|
|
9
|
-
export type { Task, TaskOptions, TaskPublicConfig, TaskStats } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { Task, TaskPublicConfig } from '../models.js';
|
|
4
|
+
import type { Dictionary } from '../utils.js';
|
|
5
|
+
import type { ActorLastRunOptions, ActorRun, ActorStartOptions } from './actor.js';
|
|
6
|
+
import { RunClient } from './run.js';
|
|
7
|
+
import { RunCollectionClient } from './run_collection.js';
|
|
8
|
+
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
9
|
+
export type { Task, TaskOptions, TaskPublicConfig, TaskStats } from '../models.js';
|
|
10
10
|
/**
|
|
11
11
|
* Client for managing a specific Actor task.
|
|
12
12
|
*
|
|
@@ -117,10 +117,10 @@ export declare class TaskClient extends ResourceClient {
|
|
|
117
117
|
/**
|
|
118
118
|
* Retrieves the Actor task's input object.
|
|
119
119
|
*
|
|
120
|
-
* @returns The Task's input
|
|
120
|
+
* @returns The Task's input.
|
|
121
121
|
* @see https://docs.apify.com/api/v2/actor-task-input-get
|
|
122
122
|
*/
|
|
123
|
-
getInput(): Promise<Dictionary | Dictionary[]
|
|
123
|
+
getInput(): Promise<Dictionary | Dictionary[]>;
|
|
124
124
|
/**
|
|
125
125
|
* Updates the Actor task's input object.
|
|
126
126
|
*
|