apify-client 3.0.0-beta.1 → 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 +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 +5 -5
- 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 -6
- 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 -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 +2 -2
- package/dist/resource_clients/log.js +15 -22
- 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 +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 -8
- package/dist/resource_clients/schedule.js +13 -15
- 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 +9 -9
- package/dist/resource_clients/task.js +47 -50
- 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 +5 -5
- package/dist/resource_clients/user.js +11 -16
- package/dist/resource_clients/webhook.d.ts +6 -6
- 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 -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 +19 -24
- package/dist/utils.js +57 -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,37 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
|
|
20
|
-
restartOnError: zod_1.z.boolean().optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
|
|
3
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { anyObjectSchema, cast, catchNotFoundOrThrow, parseArgument, parseResponse, stringifyWebhooksToBase64, } from '../utils.js';
|
|
6
|
+
import { RunClient } from './run.js';
|
|
7
|
+
import { RunCollectionClient } from './run_collection.js';
|
|
8
|
+
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
9
|
+
const inputSchema = anyObjectSchema.optional();
|
|
10
|
+
const startOptionsSchema = z.strictObject({
|
|
11
|
+
build: z.string().optional(),
|
|
12
|
+
memory: z.number().optional(),
|
|
13
|
+
timeout: z.number().optional(),
|
|
14
|
+
waitForFinish: z.number().optional(),
|
|
15
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
16
|
+
maxItems: z.number().min(0).optional(),
|
|
17
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
18
|
+
restartOnError: z.boolean().optional(),
|
|
21
19
|
});
|
|
22
|
-
const callOptionsSchema =
|
|
23
|
-
build:
|
|
24
|
-
memory:
|
|
25
|
-
timeout:
|
|
26
|
-
waitSecs:
|
|
27
|
-
webhooks:
|
|
28
|
-
maxItems:
|
|
29
|
-
maxTotalChargeUsd:
|
|
30
|
-
restartOnError:
|
|
20
|
+
const callOptionsSchema = z.strictObject({
|
|
21
|
+
build: z.string().optional(),
|
|
22
|
+
memory: z.number().optional(),
|
|
23
|
+
timeout: z.number().min(0).optional(),
|
|
24
|
+
waitSecs: z.number().min(0).optional(),
|
|
25
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
26
|
+
maxItems: z.number().min(0).optional(),
|
|
27
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
28
|
+
restartOnError: z.boolean().optional(),
|
|
31
29
|
});
|
|
32
|
-
const lastRunOptionsSchema =
|
|
33
|
-
status:
|
|
34
|
-
origin:
|
|
30
|
+
const lastRunOptionsSchema = z.strictObject({
|
|
31
|
+
status: z.enum(ACT_JOB_STATUSES).optional(),
|
|
32
|
+
origin: z.enum(META_ORIGINS).optional(),
|
|
35
33
|
});
|
|
36
34
|
/**
|
|
37
35
|
* Client for managing a specific Actor task.
|
|
@@ -53,7 +51,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
|
|
|
53
51
|
*
|
|
54
52
|
* @see https://docs.apify.com/platform/actors/running/tasks
|
|
55
53
|
*/
|
|
56
|
-
class TaskClient extends
|
|
54
|
+
export class TaskClient extends ResourceClient {
|
|
57
55
|
/**
|
|
58
56
|
* @hidden
|
|
59
57
|
*/
|
|
@@ -70,7 +68,7 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
70
68
|
* @see https://docs.apify.com/api/v2/actor-task-get
|
|
71
69
|
*/
|
|
72
70
|
async get() {
|
|
73
|
-
return this._get();
|
|
71
|
+
return this._get(schemas.Task());
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* Updates the task with the specified fields.
|
|
@@ -80,8 +78,8 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
80
78
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
81
79
|
*/
|
|
82
80
|
async update(newFields) {
|
|
83
|
-
|
|
84
|
-
return this._update(newFields);
|
|
81
|
+
parseArgument(newFields, anyObjectSchema);
|
|
82
|
+
return this._update(schemas.Task(), newFields);
|
|
85
83
|
}
|
|
86
84
|
/**
|
|
87
85
|
* Publishes the task on its public landing page, by setting `isPublic` through
|
|
@@ -138,15 +136,15 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
138
136
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
139
137
|
*/
|
|
140
138
|
async start(input, options = {}) {
|
|
141
|
-
|
|
142
|
-
const parsed =
|
|
139
|
+
parseArgument(input, inputSchema);
|
|
140
|
+
const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
|
|
143
141
|
const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError } = parsed;
|
|
144
142
|
const params = {
|
|
145
143
|
waitForFinish,
|
|
146
144
|
timeout,
|
|
147
145
|
memory,
|
|
148
146
|
build,
|
|
149
|
-
webhooks:
|
|
147
|
+
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
150
148
|
maxItems,
|
|
151
149
|
maxTotalChargeUsd,
|
|
152
150
|
restartOnError,
|
|
@@ -164,7 +162,7 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
164
162
|
},
|
|
165
163
|
};
|
|
166
164
|
const response = await this.httpClient.call(request);
|
|
167
|
-
return (
|
|
165
|
+
return parseResponse(response, schemas.Run());
|
|
168
166
|
}
|
|
169
167
|
/**
|
|
170
168
|
* Starts a task and waits for it to finish before returning the Run object.
|
|
@@ -184,8 +182,8 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
184
182
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
185
183
|
*/
|
|
186
184
|
async call(input, options = {}) {
|
|
187
|
-
|
|
188
|
-
const parsed =
|
|
185
|
+
parseArgument(input, inputSchema);
|
|
186
|
+
const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
|
|
189
187
|
const { waitSecs, ...startOptions } = parsed;
|
|
190
188
|
const { id } = await this.start(input, startOptions);
|
|
191
189
|
// Calling root client because we need access to top level API.
|
|
@@ -207,10 +205,10 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
207
205
|
};
|
|
208
206
|
try {
|
|
209
207
|
const response = await this.httpClient.call(requestOpts);
|
|
210
|
-
return
|
|
208
|
+
return cast(response.data);
|
|
211
209
|
}
|
|
212
210
|
catch (err) {
|
|
213
|
-
|
|
211
|
+
catchNotFoundOrThrow(err);
|
|
214
212
|
}
|
|
215
213
|
return undefined;
|
|
216
214
|
}
|
|
@@ -228,7 +226,7 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
228
226
|
params: this._params(),
|
|
229
227
|
data: newFields,
|
|
230
228
|
});
|
|
231
|
-
return
|
|
229
|
+
return cast(response.data);
|
|
232
230
|
}
|
|
233
231
|
/**
|
|
234
232
|
* Returns a client for the last run of this task.
|
|
@@ -240,8 +238,8 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
240
238
|
* @see https://docs.apify.com/api/v2/actor-task-runs-last-get
|
|
241
239
|
*/
|
|
242
240
|
lastRun(options = {}) {
|
|
243
|
-
const parsed =
|
|
244
|
-
return new
|
|
241
|
+
const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
|
|
242
|
+
return new RunClient(this._subResourceOptions({
|
|
245
243
|
id: 'last',
|
|
246
244
|
params: this._params(parsed),
|
|
247
245
|
resourcePath: 'runs',
|
|
@@ -254,7 +252,7 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
254
252
|
* @see https://docs.apify.com/api/v2/actor-task-runs-get
|
|
255
253
|
*/
|
|
256
254
|
runs() {
|
|
257
|
-
return new
|
|
255
|
+
return new RunCollectionClient(this._subResourceOptions({
|
|
258
256
|
resourcePath: 'runs',
|
|
259
257
|
}));
|
|
260
258
|
}
|
|
@@ -265,7 +263,6 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
265
263
|
* @see https://docs.apify.com/api/v2/actor-task-webhooks-get
|
|
266
264
|
*/
|
|
267
265
|
webhooks() {
|
|
268
|
-
return new
|
|
266
|
+
return new WebhookCollectionClient(this._subResourceOptions());
|
|
269
267
|
}
|
|
270
268
|
}
|
|
271
|
-
exports.TaskClient = TaskClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type { TaskList } from '../models';
|
|
4
|
-
import type { PaginatedIterator, PaginationOptions } from '../utils';
|
|
5
|
-
import type { Task, TaskUpdateData } from './task';
|
|
6
|
-
export type { TaskList } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { TaskList } from '../models.js';
|
|
4
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
5
|
+
import type { Task, TaskUpdateData } from './task.js';
|
|
6
|
+
export type { TaskList } from '../models.js';
|
|
7
7
|
/**
|
|
8
8
|
* Client for managing the collection of Actor tasks in your account.
|
|
9
9
|
*
|
|
@@ -1,12 +1,10 @@
|
|
|
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
9
|
/**
|
|
12
10
|
* Client for managing the collection of Actor tasks in your account.
|
|
@@ -32,7 +30,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
32
30
|
*
|
|
33
31
|
* @see https://docs.apify.com/platform/actors/running/tasks
|
|
34
32
|
*/
|
|
35
|
-
class TaskCollectionClient extends
|
|
33
|
+
export class TaskCollectionClient extends ResourceCollectionClient {
|
|
36
34
|
/**
|
|
37
35
|
* @hidden
|
|
38
36
|
*/
|
|
@@ -63,8 +61,8 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
|
|
|
63
61
|
* @see https://docs.apify.com/api/v2/actor-tasks-get
|
|
64
62
|
*/
|
|
65
63
|
list(options = {}) {
|
|
66
|
-
const parsed =
|
|
67
|
-
return this._listPaginated(parsed);
|
|
64
|
+
const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
|
|
65
|
+
return this._listPaginated(schemas.ListOfTasks(), parsed);
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Creates a new task.
|
|
@@ -74,8 +72,7 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
|
|
|
74
72
|
* @see https://docs.apify.com/api/v2/actor-tasks-post
|
|
75
73
|
*/
|
|
76
74
|
async create(task) {
|
|
77
|
-
|
|
78
|
-
return this._create(task);
|
|
75
|
+
parseArgument(task, anyObjectSchema);
|
|
76
|
+
return this._create(schemas.Task(), task);
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
exports.TaskCollectionClient = TaskCollectionClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { AccountAndUsageLimits, MonthlyUsage, User } from '../models';
|
|
4
|
-
export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models';
|
|
5
|
-
export { PlatformFeature } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { AccountAndUsageLimits, MonthlyUsage, User } from '../models.js';
|
|
4
|
+
export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models.js';
|
|
5
|
+
export { PlatformFeature } from '../models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing user account information.
|
|
8
8
|
*
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
var models_1 = require("../models");
|
|
7
|
-
Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: function () { return models_1.PlatformFeature; } });
|
|
1
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import { catchNotFoundOrThrow, parseResponse } from '../utils.js';
|
|
4
|
+
export { PlatformFeature } from '../models.js';
|
|
8
5
|
/**
|
|
9
6
|
* Client for managing user account information.
|
|
10
7
|
*
|
|
@@ -29,7 +26,7 @@ Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: funct
|
|
|
29
26
|
*
|
|
30
27
|
* @see https://docs.apify.com/platform/actors/running
|
|
31
28
|
*/
|
|
32
|
-
class UserClient extends
|
|
29
|
+
export class UserClient extends ResourceClient {
|
|
33
30
|
/**
|
|
34
31
|
* @hidden
|
|
35
32
|
*/
|
|
@@ -49,7 +46,7 @@ class UserClient extends resource_client_1.ResourceClient {
|
|
|
49
46
|
* @see https://docs.apify.com/api/v2/user-get
|
|
50
47
|
*/
|
|
51
48
|
async get() {
|
|
52
|
-
return this._get();
|
|
49
|
+
return this._get(schemas.UserPrivateInfo());
|
|
53
50
|
}
|
|
54
51
|
/**
|
|
55
52
|
* Retrieves the user's monthly usage data.
|
|
@@ -66,12 +63,11 @@ class UserClient extends resource_client_1.ResourceClient {
|
|
|
66
63
|
};
|
|
67
64
|
try {
|
|
68
65
|
const response = await this.httpClient.call(requestOpts);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/* shouldParseField = */ (key) => key === 'date'));
|
|
66
|
+
// `dailyServiceUsages[].date` does not end in `At`, so it has to be named for `parseDateFields`.
|
|
67
|
+
return parseResponse(response, schemas.MonthlyUsage(), (key) => key === 'date');
|
|
72
68
|
}
|
|
73
69
|
catch (err) {
|
|
74
|
-
|
|
70
|
+
catchNotFoundOrThrow(err);
|
|
75
71
|
}
|
|
76
72
|
return undefined;
|
|
77
73
|
}
|
|
@@ -90,10 +86,10 @@ class UserClient extends resource_client_1.ResourceClient {
|
|
|
90
86
|
};
|
|
91
87
|
try {
|
|
92
88
|
const response = await this.httpClient.call(requestOpts);
|
|
93
|
-
return (
|
|
89
|
+
return parseResponse(response, schemas.AccountLimits());
|
|
94
90
|
}
|
|
95
91
|
catch (err) {
|
|
96
|
-
|
|
92
|
+
catchNotFoundOrThrow(err);
|
|
97
93
|
}
|
|
98
94
|
return undefined;
|
|
99
95
|
}
|
|
@@ -114,4 +110,3 @@ class UserClient extends resource_client_1.ResourceClient {
|
|
|
114
110
|
await this.httpClient.call(requestOpts);
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
|
-
exports.UserClient = UserClient;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { Webhook, WebhookEventType } from '../models';
|
|
4
|
-
import type { WebhookDispatch } from './webhook_dispatch';
|
|
5
|
-
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection';
|
|
6
|
-
export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { Webhook, WebhookEventType } from '../models.js';
|
|
4
|
+
import type { WebhookDispatch } from './webhook_dispatch.js';
|
|
5
|
+
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
|
|
6
|
+
export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models.js';
|
|
7
7
|
/**
|
|
8
8
|
* Client for managing a specific webhook.
|
|
9
9
|
*
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
|
|
1
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import { anyObjectSchema, catchNotFoundOrThrow, parseArgument, parseResponse } from '../utils.js';
|
|
4
|
+
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
|
|
7
5
|
/**
|
|
8
6
|
* Client for managing a specific webhook.
|
|
9
7
|
*
|
|
@@ -32,7 +30,7 @@ const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
|
|
|
32
30
|
*
|
|
33
31
|
* @see https://docs.apify.com/platform/integrations/webhooks
|
|
34
32
|
*/
|
|
35
|
-
class WebhookClient extends
|
|
33
|
+
export class WebhookClient extends ResourceClient {
|
|
36
34
|
/**
|
|
37
35
|
* @hidden
|
|
38
36
|
*/
|
|
@@ -49,7 +47,7 @@ class WebhookClient extends resource_client_1.ResourceClient {
|
|
|
49
47
|
* @see https://docs.apify.com/api/v2/webhook-get
|
|
50
48
|
*/
|
|
51
49
|
async get() {
|
|
52
|
-
return this._get();
|
|
50
|
+
return this._get(schemas.Webhook());
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
53
|
* Updates the webhook with the specified fields.
|
|
@@ -59,8 +57,8 @@ class WebhookClient extends resource_client_1.ResourceClient {
|
|
|
59
57
|
* @see https://docs.apify.com/api/v2/webhook-put
|
|
60
58
|
*/
|
|
61
59
|
async update(newFields) {
|
|
62
|
-
|
|
63
|
-
return this._update(newFields);
|
|
60
|
+
parseArgument(newFields, anyObjectSchema);
|
|
61
|
+
return this._update(schemas.Webhook(), newFields);
|
|
64
62
|
}
|
|
65
63
|
/**
|
|
66
64
|
* Deletes the webhook.
|
|
@@ -84,10 +82,10 @@ class WebhookClient extends resource_client_1.ResourceClient {
|
|
|
84
82
|
};
|
|
85
83
|
try {
|
|
86
84
|
const response = await this.httpClient.call(request);
|
|
87
|
-
return (
|
|
85
|
+
return parseResponse(response, schemas.WebhookDispatch());
|
|
88
86
|
}
|
|
89
87
|
catch (err) {
|
|
90
|
-
|
|
88
|
+
catchNotFoundOrThrow(err);
|
|
91
89
|
}
|
|
92
90
|
return undefined;
|
|
93
91
|
}
|
|
@@ -98,9 +96,8 @@ class WebhookClient extends resource_client_1.ResourceClient {
|
|
|
98
96
|
* @see https://docs.apify.com/api/v2/webhook-webhook-dispatches-get
|
|
99
97
|
*/
|
|
100
98
|
dispatches() {
|
|
101
|
-
return new
|
|
99
|
+
return new WebhookDispatchCollectionClient(this._subResourceOptions({
|
|
102
100
|
resourcePath: 'dispatches',
|
|
103
101
|
}));
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
|
-
exports.WebhookClient = WebhookClient;
|
|
@@ -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 { Webhook, WebhookUpdateData } from './webhook';
|
|
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 { Webhook, WebhookUpdateData } from './webhook.js';
|
|
5
5
|
/**
|
|
6
6
|
* Client for managing the collection of Webhooks.
|
|
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 webhookCreateSchema =
|
|
9
|
+
const webhookCreateSchema = anyObjectSchema.optional();
|
|
12
10
|
/**
|
|
13
11
|
* Client for managing the collection of Webhooks.
|
|
14
12
|
*
|
|
@@ -32,7 +30,7 @@ const webhookCreateSchema = utils_1.anyObjectSchema.optional();
|
|
|
32
30
|
*
|
|
33
31
|
* @see https://docs.apify.com/platform/integrations/webhooks
|
|
34
32
|
*/
|
|
35
|
-
class WebhookCollectionClient extends
|
|
33
|
+
export class WebhookCollectionClient extends ResourceCollectionClient {
|
|
36
34
|
/**
|
|
37
35
|
* @hidden
|
|
38
36
|
*/
|
|
@@ -63,8 +61,8 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
63
61
|
* @see https://docs.apify.com/api/v2/webhooks-get
|
|
64
62
|
*/
|
|
65
63
|
list(options = {}) {
|
|
66
|
-
const parsed =
|
|
67
|
-
return this._listPaginated(parsed);
|
|
64
|
+
const parsed = parseArgument(options, listOptionsSchema, 'WebhookCollectionListOptions');
|
|
65
|
+
return this._listPaginated(schemas.ListOfWebhooks(), parsed);
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Creates a new webhook.
|
|
@@ -74,8 +72,7 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
|
|
|
74
72
|
* @see https://docs.apify.com/api/v2/webhooks-post
|
|
75
73
|
*/
|
|
76
74
|
async create(webhook) {
|
|
77
|
-
|
|
78
|
-
return this._create(webhook);
|
|
75
|
+
parseArgument(webhook, webhookCreateSchema);
|
|
76
|
+
return this._create(schemas.Webhook(), webhook);
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
exports.WebhookCollectionClient = WebhookCollectionClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { WebhookDispatch } from '../models';
|
|
4
|
-
export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models';
|
|
5
|
-
export { WebhookDispatchStatus } from '../models';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { WebhookDispatch } from '../models.js';
|
|
4
|
+
export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models.js';
|
|
5
|
+
export { WebhookDispatchStatus } from '../models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Client for managing a specific webhook dispatch.
|
|
8
8
|
*
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const resource_client_1 = require("../base/resource_client");
|
|
5
|
-
var models_1 = require("../models");
|
|
6
|
-
Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get: function () { return models_1.WebhookDispatchStatus; } });
|
|
1
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
export { WebhookDispatchStatus } from '../models.js';
|
|
7
4
|
/**
|
|
8
5
|
* Client for managing a specific webhook dispatch.
|
|
9
6
|
*
|
|
@@ -22,7 +19,7 @@ Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get:
|
|
|
22
19
|
*
|
|
23
20
|
* @see https://docs.apify.com/platform/integrations/webhooks
|
|
24
21
|
*/
|
|
25
|
-
class WebhookDispatchClient extends
|
|
22
|
+
export class WebhookDispatchClient extends ResourceClient {
|
|
26
23
|
/**
|
|
27
24
|
* @hidden
|
|
28
25
|
*/
|
|
@@ -39,7 +36,6 @@ class WebhookDispatchClient extends resource_client_1.ResourceClient {
|
|
|
39
36
|
* @see https://docs.apify.com/api/v2/webhook-dispatch-get
|
|
40
37
|
*/
|
|
41
38
|
async get() {
|
|
42
|
-
return this._get();
|
|
39
|
+
return this._get(schemas.WebhookDispatch());
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
exports.WebhookDispatchClient = WebhookDispatchClient;
|
|
@@ -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 { WebhookDispatch } from './webhook_dispatch';
|
|
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 { WebhookDispatch } from './webhook_dispatch.js';
|
|
5
5
|
/**
|
|
6
6
|
* Client for managing the collection of webhook dispatches.
|
|
7
7
|
*
|
|
@@ -1,12 +1,10 @@
|
|
|
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 { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const listOptionsSchema = z.strictObject({
|
|
6
|
+
...paginationOptionsShape,
|
|
7
|
+
desc: z.boolean().optional(),
|
|
10
8
|
});
|
|
11
9
|
/**
|
|
12
10
|
* Client for managing the collection of webhook dispatches.
|
|
@@ -26,7 +24,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
26
24
|
*
|
|
27
25
|
* @see https://docs.apify.com/platform/integrations/webhooks
|
|
28
26
|
*/
|
|
29
|
-
class WebhookDispatchCollectionClient extends
|
|
27
|
+
export class WebhookDispatchCollectionClient extends ResourceCollectionClient {
|
|
30
28
|
/**
|
|
31
29
|
* @hidden
|
|
32
30
|
*/
|
|
@@ -57,8 +55,7 @@ class WebhookDispatchCollectionClient extends resource_collection_client_1.Resou
|
|
|
57
55
|
* @see https://docs.apify.com/api/v2/webhook-dispatches-get
|
|
58
56
|
*/
|
|
59
57
|
list(options = {}) {
|
|
60
|
-
const parsed =
|
|
61
|
-
return this._listPaginated(parsed);
|
|
58
|
+
const parsed = parseArgument(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
|
|
59
|
+
return this._listPaginated(schemas.ListOfWebhookDispatches(), parsed);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
|
-
exports.WebhookDispatchCollectionClient = WebhookDispatchCollectionClient;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when an API response does not match the schema the client expects for it.
|
|
4
|
+
*
|
|
5
|
+
* The schemas are generated from the Apify OpenAPI specification, so this error means the API returned
|
|
6
|
+
* something the specification does not describe -- a missing required field, a different type, a value
|
|
7
|
+
* outside the documented range. Unknown fields and unknown enum values are not errors: the schemas let
|
|
8
|
+
* both through, so the client keeps working when the API grows.
|
|
9
|
+
*
|
|
10
|
+
* The `message` names the request and every offending field with the value it received, and ends by asking for
|
|
11
|
+
* a bug report: the mismatch is in the API or its specification, not in the caller's code. The structured
|
|
12
|
+
* {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
|
|
13
|
+
* for programmatic inspection.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ResponseValidationError extends Error {
|
|
16
|
+
/** Structured issues from the underlying schema check. */
|
|
17
|
+
readonly issues: z.ZodError['issues'];
|
|
18
|
+
/** HTTP method of the request whose response failed validation, upper-cased. */
|
|
19
|
+
readonly method: string;
|
|
20
|
+
/** URL of the request whose response failed validation, without its query string. */
|
|
21
|
+
readonly url: string;
|
|
22
|
+
constructor(error: z.ZodError, value: unknown, request: {
|
|
23
|
+
method: string;
|
|
24
|
+
url: string;
|
|
25
|
+
});
|
|
26
|
+
}
|