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,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import type { WebhookDispatch } from './webhook_dispatch';
|
|
5
|
-
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection';
|
|
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';
|
|
6
7
|
/**
|
|
7
8
|
* Client for managing a specific webhook.
|
|
8
9
|
*
|
|
@@ -72,43 +73,6 @@ export declare class WebhookClient extends ResourceClient {
|
|
|
72
73
|
*/
|
|
73
74
|
dispatches(): WebhookDispatchCollectionClient;
|
|
74
75
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Represents a webhook for receiving notifications about Actor events.
|
|
77
|
-
*
|
|
78
|
-
* Webhooks send HTTP POST requests to specified URLs when certain events occur
|
|
79
|
-
* (e.g., Actor run succeeds, fails, or times out).
|
|
80
|
-
*/
|
|
81
|
-
export interface Webhook {
|
|
82
|
-
id: string;
|
|
83
|
-
userId: string;
|
|
84
|
-
createdAt: Date;
|
|
85
|
-
modifiedAt: Date;
|
|
86
|
-
isAdHoc: boolean;
|
|
87
|
-
eventTypes: WebhookEventType[];
|
|
88
|
-
condition: WebhookCondition;
|
|
89
|
-
ignoreSslErrors: boolean;
|
|
90
|
-
doNotRetry: boolean;
|
|
91
|
-
requestUrl: string;
|
|
92
|
-
payloadTemplate: string;
|
|
93
|
-
lastDispatch: string;
|
|
94
|
-
stats: WebhookStats;
|
|
95
|
-
/**
|
|
96
|
-
* @since Added in 2.7.2
|
|
97
|
-
*/
|
|
98
|
-
shouldInterpolateStrings: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* @since Added in 2.9.4
|
|
101
|
-
*/
|
|
102
|
-
isApifyIntegration?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* @since Added in 2.8.1
|
|
105
|
-
*/
|
|
106
|
-
headersTemplate?: string;
|
|
107
|
-
/**
|
|
108
|
-
* @since Added in 2.8.1
|
|
109
|
-
*/
|
|
110
|
-
description?: string;
|
|
111
|
-
}
|
|
112
76
|
export interface WebhookIdempotencyKey {
|
|
113
77
|
idempotencyKey?: string;
|
|
114
78
|
}
|
|
@@ -118,26 +82,3 @@ export interface WebhookIdempotencyKey {
|
|
|
118
82
|
export type WebhookUpdateData = Partial<Pick<Webhook, 'isAdHoc' | 'condition' | 'ignoreSslErrors' | 'doNotRetry' | 'requestUrl' | 'payloadTemplate' | 'shouldInterpolateStrings' | 'isApifyIntegration' | 'headersTemplate' | 'description'> & {
|
|
119
83
|
eventTypes: readonly WebhookEventType[];
|
|
120
84
|
}> & WebhookIdempotencyKey;
|
|
121
|
-
/**
|
|
122
|
-
* Statistics about webhook usage.
|
|
123
|
-
*/
|
|
124
|
-
export interface WebhookStats {
|
|
125
|
-
totalDispatches: number;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Event types that can trigger webhooks.
|
|
129
|
-
*/
|
|
130
|
-
export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[keyof typeof WEBHOOK_EVENT_TYPES];
|
|
131
|
-
/**
|
|
132
|
-
* Condition that determines when a webhook should be triggered.
|
|
133
|
-
*/
|
|
134
|
-
export type WebhookCondition = WebhookAnyRunOfActorCondition | WebhookAnyRunOfActorTaskCondition | WebhookCertainRunCondition;
|
|
135
|
-
export interface WebhookAnyRunOfActorCondition {
|
|
136
|
-
actorId: string;
|
|
137
|
-
}
|
|
138
|
-
export interface WebhookAnyRunOfActorTaskCondition {
|
|
139
|
-
actorTaskId: string;
|
|
140
|
-
}
|
|
141
|
-
export interface WebhookCertainRunCondition {
|
|
142
|
-
actorRunId: string;
|
|
143
|
-
}
|
|
@@ -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,6 +1,8 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type {
|
|
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';
|
|
4
6
|
/**
|
|
5
7
|
* Client for managing a specific webhook dispatch.
|
|
6
8
|
*
|
|
@@ -32,38 +34,3 @@ export declare class WebhookDispatchClient extends ResourceClient {
|
|
|
32
34
|
*/
|
|
33
35
|
get(): Promise<WebhookDispatch | undefined>;
|
|
34
36
|
}
|
|
35
|
-
export interface WebhookDispatch {
|
|
36
|
-
id: string;
|
|
37
|
-
userId: string;
|
|
38
|
-
webhookId: string;
|
|
39
|
-
createdAt: Date;
|
|
40
|
-
status: WebhookDispatchStatus;
|
|
41
|
-
eventType: WebhookEventType;
|
|
42
|
-
calls: WebhookDispatchCall[];
|
|
43
|
-
webhook: Pick<Webhook, 'requestUrl' | 'isAdHoc'>;
|
|
44
|
-
/**
|
|
45
|
-
* @since Added in 2.13.0
|
|
46
|
-
*/
|
|
47
|
-
eventData: WebhookDispatchEventData | null;
|
|
48
|
-
}
|
|
49
|
-
export declare enum WebhookDispatchStatus {
|
|
50
|
-
Active = "ACTIVE",
|
|
51
|
-
Succeeded = "SUCCEEDED",
|
|
52
|
-
Failed = "FAILED"
|
|
53
|
-
}
|
|
54
|
-
export interface WebhookDispatchCall {
|
|
55
|
-
startedAt: Date;
|
|
56
|
-
finishedAt: Date;
|
|
57
|
-
errorMessage: string | null;
|
|
58
|
-
responseStatus: number | null;
|
|
59
|
-
responseBody: string | null;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @since Added in 2.13.0
|
|
63
|
-
*/
|
|
64
|
-
export interface WebhookDispatchEventData {
|
|
65
|
-
actorRunId?: string;
|
|
66
|
-
actorId?: string;
|
|
67
|
-
actorTaskId?: string;
|
|
68
|
-
actorBuildId?: string;
|
|
69
|
-
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const resource_client_1 = require("../base/resource_client");
|
|
1
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
export { WebhookDispatchStatus } from '../models.js';
|
|
5
4
|
/**
|
|
6
5
|
* Client for managing a specific webhook dispatch.
|
|
7
6
|
*
|
|
@@ -20,7 +19,7 @@ const resource_client_1 = require("../base/resource_client");
|
|
|
20
19
|
*
|
|
21
20
|
* @see https://docs.apify.com/platform/integrations/webhooks
|
|
22
21
|
*/
|
|
23
|
-
class WebhookDispatchClient extends
|
|
22
|
+
export class WebhookDispatchClient extends ResourceClient {
|
|
24
23
|
/**
|
|
25
24
|
* @hidden
|
|
26
25
|
*/
|
|
@@ -37,13 +36,6 @@ class WebhookDispatchClient extends resource_client_1.ResourceClient {
|
|
|
37
36
|
* @see https://docs.apify.com/api/v2/webhook-dispatch-get
|
|
38
37
|
*/
|
|
39
38
|
async get() {
|
|
40
|
-
return this._get();
|
|
39
|
+
return this._get(schemas.WebhookDispatch());
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
exports.WebhookDispatchClient = WebhookDispatchClient;
|
|
44
|
-
var WebhookDispatchStatus;
|
|
45
|
-
(function (WebhookDispatchStatus) {
|
|
46
|
-
WebhookDispatchStatus["Active"] = "ACTIVE";
|
|
47
|
-
WebhookDispatchStatus["Succeeded"] = "SUCCEEDED";
|
|
48
|
-
WebhookDispatchStatus["Failed"] = "FAILED";
|
|
49
|
-
})(WebhookDispatchStatus || (exports.WebhookDispatchStatus = WebhookDispatchStatus = {}));
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ArgumentValidationError } from '@apify/validations';
|
|
2
|
+
const REPORT_HINT = 'The API returned something its OpenAPI specification does not describe. ' +
|
|
3
|
+
'Please report this at https://github.com/apify/apify-client-js/issues.';
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when an API response does not match the schema the client expects for it.
|
|
6
|
+
*
|
|
7
|
+
* The schemas are generated from the Apify OpenAPI specification, so this error means the API returned
|
|
8
|
+
* something the specification does not describe -- a missing required field, a different type, a value
|
|
9
|
+
* outside the documented range. Unknown fields and unknown enum values are not errors: the schemas let
|
|
10
|
+
* both through, so the client keeps working when the API grows.
|
|
11
|
+
*
|
|
12
|
+
* The `message` names the request and every offending field with the value it received, and ends by asking for
|
|
13
|
+
* a bug report: the mismatch is in the API or its specification, not in the caller's code. The structured
|
|
14
|
+
* {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
|
|
15
|
+
* for programmatic inspection.
|
|
16
|
+
*/
|
|
17
|
+
export class ResponseValidationError extends Error {
|
|
18
|
+
/** Structured issues from the underlying schema check. */
|
|
19
|
+
issues;
|
|
20
|
+
/** HTTP method of the request whose response failed validation, upper-cased. */
|
|
21
|
+
method;
|
|
22
|
+
/** URL of the request whose response failed validation, without its query string. */
|
|
23
|
+
url;
|
|
24
|
+
constructor(error, value, request) {
|
|
25
|
+
const method = request.method.toUpperCase();
|
|
26
|
+
// `@apify/validations` keeps its zod error formatter private, so the issue lines come from the
|
|
27
|
+
// message of the error class it does export.
|
|
28
|
+
const details = new ArgumentValidationError(error, value).message;
|
|
29
|
+
super(`Response from ${method} ${request.url} does not match the API schema:\n${details}\n${REPORT_HINT}`, {
|
|
30
|
+
cause: error,
|
|
31
|
+
});
|
|
32
|
+
this.name = 'ResponseValidationError';
|
|
33
|
+
this.issues = error.issues;
|
|
34
|
+
this.method = method;
|
|
35
|
+
this.url = request.url;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schemas the resource clients validate API responses with.
|
|
3
|
+
*
|
|
4
|
+
* Today these are exactly the generated ones. The module still exists as the one place where a generated
|
|
5
|
+
* schema is widened when the API is known to return something the specification does not describe, so a
|
|
6
|
+
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
|
+
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
8
|
+
* built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
|
|
9
|
+
* top of it, and `spec_guards.ts` checks that each override still accepts what the specification describes,
|
|
10
|
+
* so one cannot narrow by accident.
|
|
11
|
+
*
|
|
12
|
+
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
|
13
|
+
* through. Neither do client narrowings: a schema only ever accepts more than the published type.
|
|
14
|
+
*/
|
|
15
|
+
export * from './generated/schemas.js';
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schemas the resource clients validate API responses with.
|
|
3
|
+
*
|
|
4
|
+
* Today these are exactly the generated ones. The module still exists as the one place where a generated
|
|
5
|
+
* schema is widened when the API is known to return something the specification does not describe, so a
|
|
6
|
+
* documented deviation never sends a resource client reaching into `./generated` directly. An override
|
|
7
|
+
* declared here shadows the generated export of the same name and takes the same form, a `lazySchema()` thunk
|
|
8
|
+
* built on the generated schema it replaces. Every schema that embeds an overridden one has to be rebuilt on
|
|
9
|
+
* top of it, and `spec_guards.ts` checks that each override still accepts what the specification describes,
|
|
10
|
+
* so one cannot narrow by accident.
|
|
11
|
+
*
|
|
12
|
+
* Spec gaps need no override: the generated objects are loose, so a field the specification omits passes
|
|
13
|
+
* through. Neither do client narrowings: a schema only ever accepts more than the published type.
|
|
14
|
+
*/
|
|
15
|
+
export * from './generated/schemas.js';
|
package/dist/statistics.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
const attemptSchema = zod_1.z.number().gt(0);
|
|
7
|
-
class Statistics {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseArgument } from './utils.js';
|
|
3
|
+
const attemptSchema = z.number().gt(0);
|
|
4
|
+
export class Statistics {
|
|
8
5
|
/**
|
|
9
6
|
* Number of Apify client function calls
|
|
10
7
|
*/
|
|
@@ -19,7 +16,7 @@ class Statistics {
|
|
|
19
16
|
*/
|
|
20
17
|
rateLimitErrors = [];
|
|
21
18
|
addRateLimitError(attempt) {
|
|
22
|
-
|
|
19
|
+
parseArgument(attempt, attemptSchema);
|
|
23
20
|
// attempt is never 0,
|
|
24
21
|
// but we don't want index 0 empty
|
|
25
22
|
const index = attempt - 1;
|
|
@@ -41,4 +38,3 @@ class Statistics {
|
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
exports.Statistics = Statistics;
|
package/dist/timezones.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// This contains exactly the list of timezones supported by 'moment-timezone' package, you can fetch it using:
|
|
3
2
|
// require('moment-timzone').tz.names()
|
|
4
3
|
// This should be kept in sync with timezones.js in storage
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
4
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
5
|
const timezones = [
|
|
8
6
|
'Africa/Abidjan',
|
|
@@ -599,3 +597,4 @@ const timezones = [
|
|
|
599
597
|
'WET',
|
|
600
598
|
'Zulu',
|
|
601
599
|
];
|
|
600
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { JsonValue, TypedArray } from 'type-fest';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import type { ApifyApiError } from './apify_api_error';
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
* The optional `label` names the interface being validated and is appended to every error line
|
|
12
|
-
* (e.g. ``... at `memory` in `ActorStartOptions` ``).
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseArgument<TValue, TSchema extends z.ZodType>(value: TValue, schema: TSchema, label?: string): TValue & z.output<TSchema>;
|
|
4
|
+
import type { ApifyApiError } from './apify_api_error.js';
|
|
5
|
+
import { parseArgument } from '@apify/validations';
|
|
6
|
+
import type { ApifyResponse } from './http_client.js';
|
|
7
|
+
import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue.js';
|
|
8
|
+
import type { WebhookUpdateData } from './resource_clients/webhook.js';
|
|
9
|
+
export { parseArgument };
|
|
16
10
|
/**
|
|
17
11
|
* Accepts any non-null, non-array object as a predicate for `z.custom()`.
|
|
18
12
|
* @internal
|
|
@@ -33,14 +27,24 @@ export declare const anyObjectSchema: z.ZodCustom<Record<string, unknown>, Recor
|
|
|
33
27
|
export interface MaybeData<R> {
|
|
34
28
|
data?: R;
|
|
35
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Turns a JSON API response into the value a resource method returns: unwraps the `data` envelope, converts the
|
|
32
|
+
* date fields and validates the result against `schema`, one of the schemas generated from the OpenAPI
|
|
33
|
+
* specification. The validated copy is what callers get, so it is the schema's output -- unknown fields and unknown
|
|
34
|
+
* enum values included, since the schemas let both through, and URL fields normalized, since `z.url()` hands back
|
|
35
|
+
* the parsed URL's serialization.
|
|
36
|
+
*
|
|
37
|
+
* Throws {@link ResponseValidationError} when the response does not match the specification.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseResponse<R>(response: ApifyResponse, schema: z.ZodType, shouldParseField?: ((key: string) => boolean) | null): R;
|
|
36
41
|
/**
|
|
37
42
|
* Returns object's 'data' property or throws if parameter is not an object,
|
|
38
43
|
* or an object without a 'data' property.
|
|
39
44
|
*/
|
|
40
45
|
export declare function pluckData<R>(obj: MaybeData<R>): R;
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
* Otherwise rethrows error.
|
|
47
|
+
* Swallows a 404 Not Found API error and rethrows anything else.
|
|
44
48
|
*/
|
|
45
49
|
export declare function catchNotFoundOrThrow(err: ApifyApiError): void;
|
|
46
50
|
type ReturnJsonValue = string | number | boolean | null | Date | ReturnJsonObject | ReturnJsonArray;
|
|
@@ -83,13 +87,12 @@ export declare function getVersionData(): {
|
|
|
83
87
|
version: string;
|
|
84
88
|
};
|
|
85
89
|
/**
|
|
86
|
-
* Helper class to create async iterators from paginated list endpoints
|
|
90
|
+
* Helper class to create async iterators from paginated list endpoints.
|
|
87
91
|
*/
|
|
88
92
|
export declare class RequestQueuePaginationIterator {
|
|
89
93
|
private readonly maxPageLimit;
|
|
90
94
|
private readonly getPage;
|
|
91
95
|
private readonly limit?;
|
|
92
|
-
private readonly exclusiveStartId?;
|
|
93
96
|
private readonly cursor?;
|
|
94
97
|
constructor(options: RequestQueuePaginationIteratorOptions);
|
|
95
98
|
[Symbol.asyncIterator](): AsyncIterator<RequestQueueClientListRequestsResult>;
|
|
@@ -105,7 +108,6 @@ export interface RequestQueuePaginationIteratorOptions {
|
|
|
105
108
|
maxPageLimit: number;
|
|
106
109
|
getPage: (opts: RequestQueueClientListRequestsOptions) => Promise<RequestQueueClientListRequestsResult>;
|
|
107
110
|
limit?: number;
|
|
108
|
-
exclusiveStartId?: string;
|
|
109
111
|
cursor?: string;
|
|
110
112
|
}
|
|
111
113
|
/**
|
|
@@ -192,12 +194,6 @@ export type DistributiveOptional<T, K extends keyof T> = T extends any ? Omit<T,
|
|
|
192
194
|
* Adds query parameters to a given URL based on the provided options object.
|
|
193
195
|
*/
|
|
194
196
|
export declare function applyQueryParamsToUrl(url: URL, options?: Record<string, string | number | boolean | string[] | undefined>): URL;
|
|
195
|
-
/**
|
|
196
|
-
* Builds a `[check, message]` pair to spread into `.refine()`, asserting that at most one of `keys`
|
|
197
|
-
* is present. Pass the options interface as `T`, so that a misspelled key is a type error.
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
export declare const mutuallyExclusive: <T extends object>(...keys: (keyof T & string)[]) => [(value: T) => boolean, string];
|
|
201
197
|
/**
|
|
202
198
|
* Percent-encodes a caller-supplied URL path segment so it cannot restructure the request path.
|
|
203
199
|
*
|
|
@@ -210,4 +206,3 @@ export declare function toPathSegment(value: string): string;
|
|
|
210
206
|
* `requests/batch` keep their separators; an array has each of its segments encoded individually.
|
|
211
207
|
*/
|
|
212
208
|
export declare function toPath(path: string | string[]): string;
|
|
213
|
-
export {};
|