apify-client 3.0.0-beta.0 → 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/apify_api_error.d.ts +59 -3
- package/dist/apify_api_error.js +71 -11
- package/dist/apify_client.d.ts +27 -27
- package/dist/apify_client.js +86 -91
- package/dist/base/api_client.d.ts +3 -3
- package/dist/base/api_client.js +6 -10
- package/dist/base/resource_client.d.ts +5 -4
- package/dist/base/resource_client.js +17 -21
- package/dist/base/resource_collection_client.d.ts +7 -6
- package/dist/base/resource_collection_client.js +11 -15
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +20595 -0
- package/dist/generated/api.js +5 -0
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +33 -32
- package/dist/index.js +32 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +1053 -0
- package/dist/models.js +86 -0
- package/dist/resource_clients/actor.d.ts +13 -459
- package/dist/resource_clients/actor.js +70 -73
- package/dist/resource_clients/actor_collection.d.ts +10 -15
- package/dist/resource_clients/actor_collection.js +19 -20
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +7 -10
- package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
- package/dist/resource_clients/actor_env_var_collection.js +15 -19
- package/dist/resource_clients/actor_version.d.ts +14 -43
- package/dist/resource_clients/actor_version.js +15 -24
- package/dist/resource_clients/actor_version_collection.d.ts +13 -19
- package/dist/resource_clients/actor_version_collection.js +17 -19
- package/dist/resource_clients/build.d.ts +5 -80
- package/dist/resource_clients/build.js +14 -17
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +10 -13
- package/dist/resource_clients/dataset.d.ts +6 -72
- package/dist/resource_clients/dataset.js +73 -76
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +18 -21
- package/dist/resource_clients/key_value_store.d.ts +16 -77
- package/dist/resource_clients/key_value_store.js +64 -66
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +18 -21
- package/dist/resource_clients/log.d.ts +2 -2
- package/dist/resource_clients/log.js +15 -22
- package/dist/resource_clients/request_queue.d.ts +17 -183
- package/dist/resource_clients/request_queue.js +102 -108
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +16 -19
- package/dist/resource_clients/run.d.ts +8 -8
- package/dist/resource_clients/run.js +50 -53
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +15 -18
- package/dist/resource_clients/schedule.d.ts +8 -86
- package/dist/resource_clients/schedule.js +13 -21
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +13 -16
- package/dist/resource_clients/store_collection.d.ts +5 -33
- package/dist/resource_clients/store_collection.js +15 -18
- package/dist/resource_clients/task.d.ts +9 -79
- package/dist/resource_clients/task.js +47 -50
- package/dist/resource_clients/task_collection.d.ts +6 -5
- package/dist/resource_clients/task_collection.js +12 -15
- package/dist/resource_clients/user.d.ts +5 -181
- package/dist/resource_clients/user.js +11 -24
- package/dist/resource_clients/webhook.d.ts +6 -65
- package/dist/resource_clients/webhook.js +11 -14
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +13 -16
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -38
- package/dist/resource_clients/webhook_dispatch.js +5 -13
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +19 -24
- package/dist/utils.js +66 -96
- package/package.json +48 -40
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/index.mjs +0 -42
|
@@ -1,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,8 +309,8 @@ 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.
|
|
@@ -327,7 +325,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
327
325
|
* ```
|
|
328
326
|
*/
|
|
329
327
|
dataset() {
|
|
330
|
-
return new
|
|
328
|
+
return new DatasetClient(this._subResourceOptions({
|
|
331
329
|
resourcePath: 'dataset',
|
|
332
330
|
}));
|
|
333
331
|
}
|
|
@@ -344,7 +342,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
344
342
|
* ```
|
|
345
343
|
*/
|
|
346
344
|
keyValueStore() {
|
|
347
|
-
return new
|
|
345
|
+
return new KeyValueStoreClient(this._subResourceOptions({
|
|
348
346
|
resourcePath: 'key-value-store',
|
|
349
347
|
}));
|
|
350
348
|
}
|
|
@@ -361,7 +359,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
361
359
|
* ```
|
|
362
360
|
*/
|
|
363
361
|
requestQueue() {
|
|
364
|
-
return new
|
|
362
|
+
return new RequestQueueClient(this._subResourceOptions({
|
|
365
363
|
resourcePath: 'request-queue',
|
|
366
364
|
}));
|
|
367
365
|
}
|
|
@@ -379,7 +377,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
379
377
|
* ```
|
|
380
378
|
*/
|
|
381
379
|
log() {
|
|
382
|
-
return new
|
|
380
|
+
return new LogClient(this._subResourceOptions({
|
|
383
381
|
resourcePath: 'log',
|
|
384
382
|
}));
|
|
385
383
|
}
|
|
@@ -390,7 +388,7 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
390
388
|
async getStreamedLog(options = {}) {
|
|
391
389
|
const { fromStart = true } = options;
|
|
392
390
|
let { toLog } = options;
|
|
393
|
-
if (toLog === null || !
|
|
391
|
+
if (toLog === null || !isNode()) {
|
|
394
392
|
// Explicitly no logging or not in Node.js
|
|
395
393
|
return undefined;
|
|
396
394
|
}
|
|
@@ -403,9 +401,8 @@ class RunClient extends resource_client_1.ResourceClient {
|
|
|
403
401
|
const actorData = (await this.apifyClient.actor(actorId).get()) || { name: '' };
|
|
404
402
|
const actorName = actorData?.name ?? '';
|
|
405
403
|
const name = [actorName, `runId:${runId}`].filter(Boolean).join(' ');
|
|
406
|
-
toLog = new
|
|
404
|
+
toLog = new Log({ level: LEVELS.DEBUG, prefix: `${name} -> `, logger: new LoggerActorRedirect() });
|
|
407
405
|
}
|
|
408
|
-
return new
|
|
406
|
+
return new StreamedLog({ logClient: this.log(), toLog, fromStart });
|
|
409
407
|
}
|
|
410
408
|
}
|
|
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,7 +1,9 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type {
|
|
4
|
-
import type { DistributiveOptional } from '../utils';
|
|
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';
|
|
5
7
|
/**
|
|
6
8
|
* Client for managing a specific Schedule.
|
|
7
9
|
*
|
|
@@ -54,40 +56,10 @@ export declare class ScheduleClient extends ResourceClient {
|
|
|
54
56
|
/**
|
|
55
57
|
* Retrieves the schedule's log.
|
|
56
58
|
*
|
|
57
|
-
* @returns The schedule log
|
|
59
|
+
* @returns The schedule log, one entry per invocation, or `undefined` if the schedule does not exist.
|
|
58
60
|
* @see https://docs.apify.com/api/v2/schedule-log-get
|
|
59
61
|
*/
|
|
60
|
-
getLog(): Promise<
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Represents a schedule for automated Actor or Task runs.
|
|
64
|
-
*
|
|
65
|
-
* Schedules use cron expressions to define when Actors or Tasks should run automatically.
|
|
66
|
-
*/
|
|
67
|
-
export interface Schedule {
|
|
68
|
-
id: string;
|
|
69
|
-
userId: string;
|
|
70
|
-
name: string;
|
|
71
|
-
/**
|
|
72
|
-
* @since Added in 2.6.1
|
|
73
|
-
*/
|
|
74
|
-
title?: string;
|
|
75
|
-
cronExpression: string;
|
|
76
|
-
timezone: Timezone;
|
|
77
|
-
isEnabled: boolean;
|
|
78
|
-
isExclusive: boolean;
|
|
79
|
-
description?: string;
|
|
80
|
-
createdAt: Date;
|
|
81
|
-
modifiedAt: Date;
|
|
82
|
-
nextRunAt: string;
|
|
83
|
-
lastRunAt: string;
|
|
84
|
-
actions: ScheduleAction[];
|
|
85
|
-
/**
|
|
86
|
-
* @since Added in 2.9.4
|
|
87
|
-
*/
|
|
88
|
-
notifications: {
|
|
89
|
-
email: boolean;
|
|
90
|
-
};
|
|
62
|
+
getLog(): Promise<ScheduleInvoked[] | undefined>;
|
|
91
63
|
}
|
|
92
64
|
/**
|
|
93
65
|
* Data for creating or updating a Schedule.
|
|
@@ -96,53 +68,3 @@ export interface Schedule {
|
|
|
96
68
|
export type ScheduleCreateOrUpdateData = Partial<Pick<Schedule, 'name' | 'title' | 'cronExpression' | 'timezone' | 'isEnabled' | 'isExclusive' | 'description' | 'notifications'> & {
|
|
97
69
|
actions: DistributiveOptional<ScheduleAction, 'id'>[];
|
|
98
70
|
}>;
|
|
99
|
-
/**
|
|
100
|
-
* Types of actions that can be scheduled.
|
|
101
|
-
*/
|
|
102
|
-
export declare enum ScheduleActions {
|
|
103
|
-
RunActor = "RUN_ACTOR",
|
|
104
|
-
RunActorTask = "RUN_ACTOR_TASK"
|
|
105
|
-
}
|
|
106
|
-
interface BaseScheduleAction<Type extends ScheduleActions> {
|
|
107
|
-
id: string;
|
|
108
|
-
type: Type;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Union type representing all possible scheduled actions.
|
|
112
|
-
*/
|
|
113
|
-
export type ScheduleAction = ScheduleActionRunActor | ScheduleActionRunActorTask;
|
|
114
|
-
/**
|
|
115
|
-
* Scheduled action to run an Actor.
|
|
116
|
-
*/
|
|
117
|
-
export interface ScheduleActionRunActor extends BaseScheduleAction<ScheduleActions.RunActor> {
|
|
118
|
-
actorId: string;
|
|
119
|
-
runInput?: ScheduledActorRunInput;
|
|
120
|
-
runOptions?: ScheduledActorRunOptions;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Input configuration for a scheduled Actor run.
|
|
124
|
-
*/
|
|
125
|
-
export interface ScheduledActorRunInput {
|
|
126
|
-
body: string;
|
|
127
|
-
contentType: string;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Run options for a scheduled Actor run.
|
|
131
|
-
*/
|
|
132
|
-
export interface ScheduledActorRunOptions {
|
|
133
|
-
build: string;
|
|
134
|
-
timeoutSecs: number;
|
|
135
|
-
memoryMbytes: number;
|
|
136
|
-
/**
|
|
137
|
-
* @since Added in 2.19.0
|
|
138
|
-
*/
|
|
139
|
-
restartOnError?: boolean;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Scheduled action to run an Actor task.
|
|
143
|
-
*/
|
|
144
|
-
export interface ScheduleActionRunActorTask extends BaseScheduleAction<ScheduleActions.RunActorTask> {
|
|
145
|
-
actorTaskId: string;
|
|
146
|
-
input?: string;
|
|
147
|
-
}
|
|
148
|
-
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { anyObjectSchema, catchNotFoundOrThrow, parseArgument, parseResponse } from '../utils.js';
|
|
5
|
+
export { ScheduleActions } from '../models.js';
|
|
6
|
+
const scheduleLogSchema = z.array(schemas.ScheduleInvoked());
|
|
6
7
|
/**
|
|
7
8
|
* Client for managing a specific Schedule.
|
|
8
9
|
*
|
|
@@ -26,7 +27,7 @@ const utils_1 = require("../utils");
|
|
|
26
27
|
*
|
|
27
28
|
* @see https://docs.apify.com/platform/schedules
|
|
28
29
|
*/
|
|
29
|
-
class ScheduleClient extends
|
|
30
|
+
export class ScheduleClient extends ResourceClient {
|
|
30
31
|
/**
|
|
31
32
|
* @hidden
|
|
32
33
|
*/
|
|
@@ -43,7 +44,7 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
43
44
|
* @see https://docs.apify.com/api/v2/schedule-get
|
|
44
45
|
*/
|
|
45
46
|
async get() {
|
|
46
|
-
return this._get();
|
|
47
|
+
return this._get(schemas.Schedule());
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Updates the schedule with the specified fields.
|
|
@@ -53,8 +54,8 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
53
54
|
* @see https://docs.apify.com/api/v2/schedule-put
|
|
54
55
|
*/
|
|
55
56
|
async update(newFields) {
|
|
56
|
-
|
|
57
|
-
return this._update(newFields);
|
|
57
|
+
parseArgument(newFields, anyObjectSchema);
|
|
58
|
+
return this._update(schemas.Schedule(), newFields);
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Deletes the schedule.
|
|
@@ -67,7 +68,7 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
67
68
|
/**
|
|
68
69
|
* Retrieves the schedule's log.
|
|
69
70
|
*
|
|
70
|
-
* @returns The schedule log
|
|
71
|
+
* @returns The schedule log, one entry per invocation, or `undefined` if the schedule does not exist.
|
|
71
72
|
* @see https://docs.apify.com/api/v2/schedule-log-get
|
|
72
73
|
*/
|
|
73
74
|
async getLog() {
|
|
@@ -78,20 +79,11 @@ class ScheduleClient extends resource_client_1.ResourceClient {
|
|
|
78
79
|
};
|
|
79
80
|
try {
|
|
80
81
|
const response = await this.httpClient.call(requestOpts);
|
|
81
|
-
return (
|
|
82
|
+
return parseResponse(response, scheduleLogSchema);
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
84
|
-
|
|
85
|
+
catchNotFoundOrThrow(err);
|
|
85
86
|
}
|
|
86
87
|
return undefined;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
exports.ScheduleClient = ScheduleClient;
|
|
90
|
-
/**
|
|
91
|
-
* Types of actions that can be scheduled.
|
|
92
|
-
*/
|
|
93
|
-
var ScheduleActions;
|
|
94
|
-
(function (ScheduleActions) {
|
|
95
|
-
ScheduleActions["RunActor"] = "RUN_ACTOR";
|
|
96
|
-
ScheduleActions["RunActorTask"] = "RUN_ACTOR_TASK";
|
|
97
|
-
})(ScheduleActions || (exports.ScheduleActions = ScheduleActions = {}));
|
|
@@ -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,7 +1,8 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
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';
|
|
5
6
|
/**
|
|
6
7
|
* Client for browsing Actors in the Apify Store.
|
|
7
8
|
*
|
|
@@ -50,35 +51,6 @@ export declare class StoreCollectionClient extends ResourceCollectionClient {
|
|
|
50
51
|
*/
|
|
51
52
|
list(options?: StoreCollectionListOptions): PaginatedIterator<ActorStoreList>;
|
|
52
53
|
}
|
|
53
|
-
/**
|
|
54
|
-
* @since Added in 2.7.2
|
|
55
|
-
*/
|
|
56
|
-
export interface PricingInfo {
|
|
57
|
-
pricingModel: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @since Added in 2.7.2
|
|
61
|
-
*/
|
|
62
|
-
export interface ActorStoreList {
|
|
63
|
-
id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
username: string;
|
|
66
|
-
title?: string;
|
|
67
|
-
description?: string;
|
|
68
|
-
stats: ActorStats;
|
|
69
|
-
currentPricingInfo: PricingInfo;
|
|
70
|
-
pictureUrl?: string;
|
|
71
|
-
userPictureUrl?: string;
|
|
72
|
-
/**
|
|
73
|
-
* @since Added in 2.8.6
|
|
74
|
-
*/
|
|
75
|
-
url: string;
|
|
76
|
-
/**
|
|
77
|
-
* A brief, LLM-generated readme summary
|
|
78
|
-
* @since Added in 2.22.1
|
|
79
|
-
*/
|
|
80
|
-
readmeSummary?: string;
|
|
81
|
-
}
|
|
82
54
|
/**
|
|
83
55
|
* @since Added in 2.7.2
|
|
84
56
|
*/
|
|
@@ -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;
|