apify-client 3.0.0-beta.1 → 3.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/apify_api_error.js +5 -9
- package/dist/apify_client.d.ts +27 -27
- package/dist/apify_client.js +86 -91
- package/dist/base/api_client.d.ts +3 -3
- package/dist/base/api_client.js +6 -10
- package/dist/base/resource_client.d.ts +1 -1
- package/dist/base/resource_client.js +14 -18
- package/dist/base/resource_collection_client.d.ts +2 -2
- package/dist/base/resource_collection_client.js +6 -10
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +35 -47
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.js +1 -2
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +32 -32
- package/dist/index.js +31 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/models.d.ts +3 -3
- package/dist/models.js +8 -11
- package/dist/resource_clients/actor.d.ts +13 -13
- package/dist/resource_clients/actor.js +67 -71
- package/dist/resource_clients/actor_collection.d.ts +7 -7
- package/dist/resource_clients/actor_collection.js +14 -18
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +4 -8
- package/dist/resource_clients/actor_env_var_collection.d.ts +4 -4
- package/dist/resource_clients/actor_env_var_collection.js +5 -9
- package/dist/resource_clients/actor_version.d.ts +7 -7
- package/dist/resource_clients/actor_version.js +12 -17
- package/dist/resource_clients/actor_version_collection.d.ts +4 -4
- package/dist/resource_clients/actor_version_collection.js +5 -9
- package/dist/resource_clients/build.d.ts +5 -5
- package/dist/resource_clients/build.js +11 -15
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +8 -12
- package/dist/resource_clients/dataset.d.ts +5 -5
- package/dist/resource_clients/dataset.js +72 -76
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +15 -19
- package/dist/resource_clients/key_value_store.d.ts +4 -4
- package/dist/resource_clients/key_value_store.js +57 -62
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +15 -19
- package/dist/resource_clients/log.d.ts +2 -2
- package/dist/resource_clients/log.js +15 -22
- package/dist/resource_clients/request_queue.d.ts +4 -4
- package/dist/resource_clients/request_queue.js +91 -96
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +13 -17
- package/dist/resource_clients/run.d.ts +8 -8
- package/dist/resource_clients/run.js +46 -50
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +13 -17
- package/dist/resource_clients/schedule.d.ts +6 -6
- package/dist/resource_clients/schedule.js +7 -12
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +10 -14
- package/dist/resource_clients/store_collection.d.ts +5 -5
- package/dist/resource_clients/store_collection.js +13 -17
- package/dist/resource_clients/task.d.ts +9 -9
- package/dist/resource_clients/task.js +44 -48
- package/dist/resource_clients/task_collection.d.ts +6 -6
- package/dist/resource_clients/task_collection.js +9 -13
- package/dist/resource_clients/user.d.ts +5 -5
- package/dist/resource_clients/user.js +8 -13
- package/dist/resource_clients/webhook.d.ts +6 -6
- package/dist/resource_clients/webhook.js +8 -12
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +10 -14
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
- package/dist/resource_clients/webhook_dispatch.js +3 -8
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +8 -12
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +5 -13
- package/dist/utils.js +30 -69
- package/package.json +10 -12
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/index.mjs +0 -42
package/dist/generated/api.js
CHANGED
package/dist/http_client.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type http from 'node:http';
|
|
|
2
2
|
import type https from 'node:https';
|
|
3
3
|
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
4
4
|
import type { Log } from '@apify/log';
|
|
5
|
-
import type { RequestInterceptorFunction } from './interceptors';
|
|
6
|
-
import type { Statistics } from './statistics';
|
|
5
|
+
import type { RequestInterceptorFunction } from './interceptors.js';
|
|
6
|
+
import type { Statistics } from './statistics.js';
|
|
7
7
|
export declare class HttpClient {
|
|
8
8
|
stats: Statistics;
|
|
9
9
|
maxRetries: number;
|
package/dist/http_client.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const apify_api_error_1 = require("./apify_api_error");
|
|
9
|
-
const interceptors_1 = require("./interceptors");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const { version } = (0, utils_1.getVersionData)();
|
|
1
|
+
import retry from 'async-retry';
|
|
2
|
+
import axios, { AxiosHeaders } from 'axios';
|
|
3
|
+
import { APIFY_ENV_VARS } from '@apify/consts';
|
|
4
|
+
import { ApifyApiError } from './apify_api_error.js';
|
|
5
|
+
import { InvalidResponseBodyError, requestInterceptors, responseInterceptors } from './interceptors.js';
|
|
6
|
+
import { asArray, cast, getVersionData, isNode, isStream } from './utils.js';
|
|
7
|
+
const { version } = getVersionData();
|
|
12
8
|
const RATE_LIMIT_EXCEEDED_STATUS_CODE = 429;
|
|
13
|
-
class HttpClient {
|
|
9
|
+
export class HttpClient {
|
|
14
10
|
stats;
|
|
15
11
|
maxRetries;
|
|
16
12
|
minDelayBetweenRetriesMillis;
|
|
@@ -31,10 +27,10 @@ class HttpClient {
|
|
|
31
27
|
this.userProvidedRequestInterceptors = options.requestInterceptors;
|
|
32
28
|
this.timeoutMillis = options.timeoutSecs * 1000;
|
|
33
29
|
this.logger = options.logger;
|
|
34
|
-
this.workflowKey = options.workflowKey || process.env[
|
|
30
|
+
this.workflowKey = options.workflowKey || process.env[APIFY_ENV_VARS.WORKFLOW_KEY];
|
|
35
31
|
this.userAgentSuffix = options.userAgentSuffix;
|
|
36
32
|
this._onRequestRetry = this._onRequestRetry.bind(this);
|
|
37
|
-
this.axios =
|
|
33
|
+
this.axios = axios.create({
|
|
38
34
|
// Disable axios's built-in proxy handling since we're using custom agents
|
|
39
35
|
proxy: false,
|
|
40
36
|
paramsSerializer: (params) => {
|
|
@@ -63,7 +59,7 @@ class HttpClient {
|
|
|
63
59
|
maxContentLength: -1,
|
|
64
60
|
});
|
|
65
61
|
// Clean all default headers because they only make a mess and their merging is difficult to understand and buggy.
|
|
66
|
-
this.axios.defaults.headers = new
|
|
62
|
+
this.axios.defaults.headers = new AxiosHeaders();
|
|
67
63
|
// If workflow key is available, pass it as a header
|
|
68
64
|
if (this.workflowKey) {
|
|
69
65
|
this.axios.defaults.headers['X-Apify-Workflow-Key'] = this.workflowKey;
|
|
@@ -72,18 +68,18 @@ class HttpClient {
|
|
|
72
68
|
if (token) {
|
|
73
69
|
this.axios.defaults.headers.Authorization = `Bearer ${token}`;
|
|
74
70
|
}
|
|
75
|
-
|
|
71
|
+
requestInterceptors.forEach((i) => this.axios.interceptors.request.use(i));
|
|
76
72
|
this.userProvidedRequestInterceptors.forEach((i) => this.axios.interceptors.request.use(i));
|
|
77
|
-
|
|
73
|
+
responseInterceptors.forEach((i) => this.axios.interceptors.response.use(i));
|
|
78
74
|
}
|
|
79
75
|
async ensureNodeInit() {
|
|
80
|
-
if (!
|
|
76
|
+
if (!isNode())
|
|
81
77
|
return;
|
|
82
78
|
this.nodeInitPromise ??= this.initNode();
|
|
83
79
|
return this.nodeInitPromise;
|
|
84
80
|
}
|
|
85
81
|
async initNode() {
|
|
86
|
-
if (!
|
|
82
|
+
if (!isNode())
|
|
87
83
|
return;
|
|
88
84
|
const [{ ProxyAgent }, os] = await Promise.all([import('proxy-agent'), import('node:os')]);
|
|
89
85
|
// We want to keep sockets alive for better performance.
|
|
@@ -121,10 +117,10 @@ class HttpClient {
|
|
|
121
117
|
this.axios.defaults.httpAgent = this.httpAgent;
|
|
122
118
|
this.axios.defaults.httpsAgent = this.httpsAgent;
|
|
123
119
|
// Works only in Node. Cannot be set in browser
|
|
124
|
-
const isAtHome = !!process.env[
|
|
120
|
+
const isAtHome = !!process.env[APIFY_ENV_VARS.IS_AT_HOME];
|
|
125
121
|
let userAgent = `ApifyClient/${version} (${os.platform()}; Node/${process.version}); isAtHome/${isAtHome}`;
|
|
126
122
|
if (this.userAgentSuffix) {
|
|
127
|
-
userAgent += `; ${
|
|
123
|
+
userAgent += `; ${asArray(this.userAgentSuffix).join('; ')}`;
|
|
128
124
|
}
|
|
129
125
|
this.axios.defaults.headers['User-Agent'] = userAgent;
|
|
130
126
|
}
|
|
@@ -132,7 +128,7 @@ class HttpClient {
|
|
|
132
128
|
await this.ensureNodeInit();
|
|
133
129
|
this.stats.calls++;
|
|
134
130
|
const makeRequest = this._createRequestHandler(config);
|
|
135
|
-
return (
|
|
131
|
+
return retry(makeRequest, {
|
|
136
132
|
retries: this.maxRetries,
|
|
137
133
|
minTimeout: this.minDelayBetweenRetriesMillis,
|
|
138
134
|
onRetry: this._onRequestRetry,
|
|
@@ -151,7 +147,7 @@ class HttpClient {
|
|
|
151
147
|
const makeRequest = async (stopTrying, attempt) => {
|
|
152
148
|
this.stats.requests++;
|
|
153
149
|
let response;
|
|
154
|
-
const requestIsStream =
|
|
150
|
+
const requestIsStream = isStream(config.data);
|
|
155
151
|
try {
|
|
156
152
|
if (requestIsStream) {
|
|
157
153
|
// Handling redirects is not possible without buffering - part of the stream has already been sent and can't be recovered
|
|
@@ -166,12 +162,12 @@ class HttpClient {
|
|
|
166
162
|
return response;
|
|
167
163
|
}
|
|
168
164
|
catch (err) {
|
|
169
|
-
return
|
|
165
|
+
return cast(this._handleRequestError(err, config, stopTrying));
|
|
170
166
|
}
|
|
171
167
|
if (response.status === RATE_LIMIT_EXCEEDED_STATUS_CODE) {
|
|
172
168
|
this.stats.addRateLimitError(attempt);
|
|
173
169
|
}
|
|
174
|
-
const apiError = new
|
|
170
|
+
const apiError = new ApifyApiError(response, attempt);
|
|
175
171
|
if (this._isStatusCodeRetryable(response.status)) {
|
|
176
172
|
if (requestIsStream) {
|
|
177
173
|
this._informAboutStreamNoRetry();
|
|
@@ -198,7 +194,7 @@ class HttpClient {
|
|
|
198
194
|
return stopTrying(err);
|
|
199
195
|
}
|
|
200
196
|
if (this._isRetryableError(err)) {
|
|
201
|
-
if (
|
|
197
|
+
if (isStream(config.data)) {
|
|
202
198
|
this._informAboutStreamNoRetry();
|
|
203
199
|
}
|
|
204
200
|
else {
|
|
@@ -229,7 +225,7 @@ class HttpClient {
|
|
|
229
225
|
* an incomplete response. This can often be fixed by retrying.
|
|
230
226
|
*/
|
|
231
227
|
_isResponseBodyInvalid(err) {
|
|
232
|
-
return err instanceof
|
|
228
|
+
return err instanceof InvalidResponseBodyError;
|
|
233
229
|
}
|
|
234
230
|
/**
|
|
235
231
|
* When a network request is attempted by axios and fails,
|
|
@@ -257,4 +253,3 @@ class HttpClient {
|
|
|
257
253
|
}
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
|
-
exports.HttpClient = HttpClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export * from './apify_client';
|
|
2
|
-
export * from './resource_clients/actor';
|
|
3
|
-
export * from './resource_clients/actor_collection';
|
|
4
|
-
export * from './resource_clients/actor_env_var';
|
|
5
|
-
export * from './resource_clients/actor_env_var_collection';
|
|
6
|
-
export * from './resource_clients/actor_version';
|
|
7
|
-
export * from './resource_clients/actor_version_collection';
|
|
8
|
-
export * from './resource_clients/build';
|
|
9
|
-
export * from './resource_clients/build_collection';
|
|
10
|
-
export * from './resource_clients/dataset';
|
|
11
|
-
export * from './resource_clients/dataset_collection';
|
|
12
|
-
export * from './resource_clients/key_value_store';
|
|
13
|
-
export * from './resource_clients/key_value_store_collection';
|
|
14
|
-
export * from './resource_clients/log';
|
|
15
|
-
export * from './resource_clients/request_queue';
|
|
16
|
-
export * from './resource_clients/request_queue_collection';
|
|
17
|
-
export * from './resource_clients/run';
|
|
18
|
-
export * from './resource_clients/run_collection';
|
|
19
|
-
export * from './resource_clients/schedule';
|
|
20
|
-
export * from './resource_clients/schedule_collection';
|
|
21
|
-
export * from './resource_clients/store_collection';
|
|
22
|
-
export * from './resource_clients/task';
|
|
23
|
-
export * from './resource_clients/task_collection';
|
|
24
|
-
export * from './resource_clients/user';
|
|
25
|
-
export * from './resource_clients/webhook';
|
|
26
|
-
export * from './resource_clients/webhook_collection';
|
|
27
|
-
export * from './resource_clients/webhook_dispatch';
|
|
28
|
-
export * from './resource_clients/webhook_dispatch_collection';
|
|
29
|
-
export * from './apify_api_error';
|
|
30
|
-
export
|
|
31
|
-
export { InvalidResponseBodyError } from './interceptors';
|
|
32
|
-
export type { PaginatedList, Dictionary } from './utils';
|
|
1
|
+
export * from './apify_client.js';
|
|
2
|
+
export * from './resource_clients/actor.js';
|
|
3
|
+
export * from './resource_clients/actor_collection.js';
|
|
4
|
+
export * from './resource_clients/actor_env_var.js';
|
|
5
|
+
export * from './resource_clients/actor_env_var_collection.js';
|
|
6
|
+
export * from './resource_clients/actor_version.js';
|
|
7
|
+
export * from './resource_clients/actor_version_collection.js';
|
|
8
|
+
export * from './resource_clients/build.js';
|
|
9
|
+
export * from './resource_clients/build_collection.js';
|
|
10
|
+
export * from './resource_clients/dataset.js';
|
|
11
|
+
export * from './resource_clients/dataset_collection.js';
|
|
12
|
+
export * from './resource_clients/key_value_store.js';
|
|
13
|
+
export * from './resource_clients/key_value_store_collection.js';
|
|
14
|
+
export * from './resource_clients/log.js';
|
|
15
|
+
export * from './resource_clients/request_queue.js';
|
|
16
|
+
export * from './resource_clients/request_queue_collection.js';
|
|
17
|
+
export * from './resource_clients/run.js';
|
|
18
|
+
export * from './resource_clients/run_collection.js';
|
|
19
|
+
export * from './resource_clients/schedule.js';
|
|
20
|
+
export * from './resource_clients/schedule_collection.js';
|
|
21
|
+
export * from './resource_clients/store_collection.js';
|
|
22
|
+
export * from './resource_clients/task.js';
|
|
23
|
+
export * from './resource_clients/task_collection.js';
|
|
24
|
+
export * from './resource_clients/user.js';
|
|
25
|
+
export * from './resource_clients/webhook.js';
|
|
26
|
+
export * from './resource_clients/webhook_collection.js';
|
|
27
|
+
export * from './resource_clients/webhook_dispatch.js';
|
|
28
|
+
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
29
|
+
export * from './apify_api_error.js';
|
|
30
|
+
export { ArgumentValidationError } from '@apify/validations';
|
|
31
|
+
export { InvalidResponseBodyError } from './interceptors.js';
|
|
32
|
+
export type { PaginatedList, Dictionary } from './utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
tslib_1.__exportStar(require("./resource_clients/webhook_dispatch_collection"), exports);
|
|
33
|
-
tslib_1.__exportStar(require("./apify_api_error"), exports);
|
|
34
|
-
tslib_1.__exportStar(require("./argument_validation_error"), exports);
|
|
35
|
-
var interceptors_1 = require("./interceptors");
|
|
36
|
-
Object.defineProperty(exports, "InvalidResponseBodyError", { enumerable: true, get: function () { return interceptors_1.InvalidResponseBodyError; } });
|
|
1
|
+
export * from './apify_client.js';
|
|
2
|
+
export * from './resource_clients/actor.js';
|
|
3
|
+
export * from './resource_clients/actor_collection.js';
|
|
4
|
+
export * from './resource_clients/actor_env_var.js';
|
|
5
|
+
export * from './resource_clients/actor_env_var_collection.js';
|
|
6
|
+
export * from './resource_clients/actor_version.js';
|
|
7
|
+
export * from './resource_clients/actor_version_collection.js';
|
|
8
|
+
export * from './resource_clients/build.js';
|
|
9
|
+
export * from './resource_clients/build_collection.js';
|
|
10
|
+
export * from './resource_clients/dataset.js';
|
|
11
|
+
export * from './resource_clients/dataset_collection.js';
|
|
12
|
+
export * from './resource_clients/key_value_store.js';
|
|
13
|
+
export * from './resource_clients/key_value_store_collection.js';
|
|
14
|
+
export * from './resource_clients/log.js';
|
|
15
|
+
export * from './resource_clients/request_queue.js';
|
|
16
|
+
export * from './resource_clients/request_queue_collection.js';
|
|
17
|
+
export * from './resource_clients/run.js';
|
|
18
|
+
export * from './resource_clients/run_collection.js';
|
|
19
|
+
export * from './resource_clients/schedule.js';
|
|
20
|
+
export * from './resource_clients/schedule_collection.js';
|
|
21
|
+
export * from './resource_clients/store_collection.js';
|
|
22
|
+
export * from './resource_clients/task.js';
|
|
23
|
+
export * from './resource_clients/task_collection.js';
|
|
24
|
+
export * from './resource_clients/user.js';
|
|
25
|
+
export * from './resource_clients/webhook.js';
|
|
26
|
+
export * from './resource_clients/webhook_collection.js';
|
|
27
|
+
export * from './resource_clients/webhook_dispatch.js';
|
|
28
|
+
export * from './resource_clients/webhook_dispatch_collection.js';
|
|
29
|
+
export * from './apify_api_error.js';
|
|
30
|
+
export { ArgumentValidationError } from '@apify/validations';
|
|
31
|
+
export { InvalidResponseBodyError } from './interceptors.js';
|
package/dist/interceptors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxiosInterceptorManager, AxiosResponse } from 'axios';
|
|
2
|
-
import type { ApifyRequestConfig, ApifyResponse } from './http_client';
|
|
2
|
+
import type { ApifyRequestConfig, ApifyResponse } from './http_client.js';
|
|
3
3
|
/**
|
|
4
4
|
* This error exists for the quite common situation, where only a partial JSON response is received and
|
|
5
5
|
* an attempt to parse the JSON throws an error. In most cases this can be resolved by retrying the
|
package/dist/interceptors.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const axios_1 = tslib_1.__importStar(require("axios"));
|
|
6
|
-
const content_type_1 = tslib_1.__importDefault(require("content-type"));
|
|
7
|
-
const body_parser_1 = require("./body_parser");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import axios, { AxiosHeaders } from 'axios';
|
|
2
|
+
import contentTypeParser from 'content-type';
|
|
3
|
+
import { maybeParseBody } from './body_parser.js';
|
|
4
|
+
import { isNode, maybeCompressValue } from './utils.js';
|
|
9
5
|
/**
|
|
10
6
|
* This error exists for the quite common situation, where only a partial JSON response is received and
|
|
11
7
|
* an attempt to parse the JSON throws an error. In most cases this can be resolved by retrying the
|
|
@@ -13,7 +9,7 @@ const utils_1 = require("./utils");
|
|
|
13
9
|
*
|
|
14
10
|
* The properties mimic AxiosError for easier integration in HttpClient error handling.
|
|
15
11
|
*/
|
|
16
|
-
class InvalidResponseBodyError extends Error {
|
|
12
|
+
export class InvalidResponseBodyError extends Error {
|
|
17
13
|
code;
|
|
18
14
|
response;
|
|
19
15
|
constructor(response, cause) {
|
|
@@ -24,9 +20,8 @@ class InvalidResponseBodyError extends Error {
|
|
|
24
20
|
this.cause = cause;
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
exports.InvalidResponseBodyError = InvalidResponseBodyError;
|
|
28
23
|
function serializeRequest(config) {
|
|
29
|
-
const [defaultTransform] =
|
|
24
|
+
const [defaultTransform] = axios.defaults.transformRequest;
|
|
30
25
|
// The function not only serializes data, but it also adds correct headers.
|
|
31
26
|
const data = defaultTransform(config.data, config.headers);
|
|
32
27
|
// Actor inputs can include functions and we don't want to omit those,
|
|
@@ -37,7 +32,7 @@ function serializeRequest(config) {
|
|
|
37
32
|
if (config.stringifyFunctions) {
|
|
38
33
|
const contentTypeHeader = config.headers?.['Content-Type'] || config.headers?.['content-type'];
|
|
39
34
|
try {
|
|
40
|
-
const { type } =
|
|
35
|
+
const { type } = contentTypeParser.parse(contentTypeHeader);
|
|
41
36
|
if (type === 'application/json' && typeof config.data === 'object') {
|
|
42
37
|
config.data = stringifyWithFunctions(config.data);
|
|
43
38
|
}
|
|
@@ -55,8 +50,8 @@ function serializeRequest(config) {
|
|
|
55
50
|
return config;
|
|
56
51
|
}
|
|
57
52
|
function ensureHeadersPrototype(config) {
|
|
58
|
-
if (config.headers && !(config.headers instanceof
|
|
59
|
-
Object.setPrototypeOf(config.headers,
|
|
53
|
+
if (config.headers && !(config.headers instanceof AxiosHeaders)) {
|
|
54
|
+
Object.setPrototypeOf(config.headers, AxiosHeaders.prototype);
|
|
60
55
|
}
|
|
61
56
|
return config;
|
|
62
57
|
}
|
|
@@ -72,7 +67,7 @@ function stringifyWithFunctions(obj) {
|
|
|
72
67
|
async function maybeCompressRequest(config) {
|
|
73
68
|
if (config.headers?.['content-encoding'])
|
|
74
69
|
return config;
|
|
75
|
-
const maybeCompressed = await
|
|
70
|
+
const maybeCompressed = await maybeCompressValue(config.data);
|
|
76
71
|
if (maybeCompressed) {
|
|
77
72
|
config.headers ??= {};
|
|
78
73
|
config.headers['content-encoding'] = maybeCompressed.encoding;
|
|
@@ -87,7 +82,7 @@ function parseResponseData(response) {
|
|
|
87
82
|
) {
|
|
88
83
|
return response;
|
|
89
84
|
}
|
|
90
|
-
const isBufferEmpty =
|
|
85
|
+
const isBufferEmpty = isNode() ? !response.data.length : !response.data.byteLength;
|
|
91
86
|
if (isBufferEmpty) {
|
|
92
87
|
// undefined is better than an empty buffer
|
|
93
88
|
response.data = undefined;
|
|
@@ -95,16 +90,16 @@ function parseResponseData(response) {
|
|
|
95
90
|
}
|
|
96
91
|
const contentTypeHeader = response.headers['content-type'];
|
|
97
92
|
try {
|
|
98
|
-
response.data =
|
|
93
|
+
response.data = maybeParseBody(response.data, contentTypeHeader);
|
|
99
94
|
}
|
|
100
95
|
catch (err) {
|
|
101
96
|
throw new InvalidResponseBodyError(response, err);
|
|
102
97
|
}
|
|
103
98
|
return response;
|
|
104
99
|
}
|
|
105
|
-
|
|
100
|
+
export const requestInterceptors = [
|
|
106
101
|
maybeCompressRequest,
|
|
107
102
|
serializeRequest,
|
|
108
103
|
ensureHeadersPrototype,
|
|
109
104
|
];
|
|
110
|
-
|
|
105
|
+
export const responseInterceptors = [parseResponseData];
|
package/dist/models.d.ts
CHANGED
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
* nullability and optionality are adopted rather than papered over.
|
|
25
25
|
*/
|
|
26
26
|
import type { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS, RUN_GENERAL_ACCESS, STORAGE_GENERAL_ACCESS, ValueOf, WEBHOOK_EVENT_TYPES } from '@apify/consts';
|
|
27
|
-
import type { components } from './generated/api';
|
|
28
|
-
import type { Timezone } from './timezones';
|
|
29
|
-
import type { Dictionary } from './utils';
|
|
27
|
+
import type { components } from './generated/api.js';
|
|
28
|
+
import type { Timezone } from './timezones.js';
|
|
29
|
+
import type { Dictionary } from './utils.js';
|
|
30
30
|
type Schemas = components['schemas'];
|
|
31
31
|
/**
|
|
32
32
|
* Event types that can trigger webhooks.
|
package/dist/models.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Public models adapted from the generated OpenAPI types in `./generated/api`.
|
|
4
3
|
*
|
|
@@ -24,8 +23,6 @@
|
|
|
24
23
|
* Backward-compatibility shims are deliberately absent. This lands in the next major, so the spec's
|
|
25
24
|
* nullability and optionality are adopted rather than papered over.
|
|
26
25
|
*/
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.PlatformFeature = exports.ScheduleActions = exports.ActorSourceType = exports.WebhookDispatchStatus = void 0;
|
|
29
26
|
/**
|
|
30
27
|
* Status of a webhook dispatch.
|
|
31
28
|
*
|
|
@@ -33,12 +30,12 @@ exports.PlatformFeature = exports.ScheduleActions = exports.ActorSourceType = ex
|
|
|
33
30
|
* reference it without closing an import cycle. It is re-exported from there, so the public name and
|
|
34
31
|
* import path are unchanged.
|
|
35
32
|
*/
|
|
36
|
-
var WebhookDispatchStatus;
|
|
33
|
+
export var WebhookDispatchStatus;
|
|
37
34
|
(function (WebhookDispatchStatus) {
|
|
38
35
|
WebhookDispatchStatus["Active"] = "ACTIVE";
|
|
39
36
|
WebhookDispatchStatus["Succeeded"] = "SUCCEEDED";
|
|
40
37
|
WebhookDispatchStatus["Failed"] = "FAILED";
|
|
41
|
-
})(WebhookDispatchStatus || (
|
|
38
|
+
})(WebhookDispatchStatus || (WebhookDispatchStatus = {}));
|
|
42
39
|
/**
|
|
43
40
|
* Where the source code of an Actor version lives.
|
|
44
41
|
*
|
|
@@ -46,14 +43,14 @@ var WebhookDispatchStatus;
|
|
|
46
43
|
* reference it without closing an import cycle. It is re-exported from there, so the public name and
|
|
47
44
|
* import path are unchanged.
|
|
48
45
|
*/
|
|
49
|
-
var ActorSourceType;
|
|
46
|
+
export var ActorSourceType;
|
|
50
47
|
(function (ActorSourceType) {
|
|
51
48
|
ActorSourceType["SourceFiles"] = "SOURCE_FILES";
|
|
52
49
|
ActorSourceType["GitRepo"] = "GIT_REPO";
|
|
53
50
|
ActorSourceType["Tarball"] = "TARBALL";
|
|
54
51
|
ActorSourceType["GitHubGist"] = "GITHUB_GIST";
|
|
55
52
|
ActorSourceType["SourceCode"] = "SOURCE_CODE";
|
|
56
|
-
})(ActorSourceType || (
|
|
53
|
+
})(ActorSourceType || (ActorSourceType = {}));
|
|
57
54
|
/**
|
|
58
55
|
* Types of actions that can be scheduled.
|
|
59
56
|
*
|
|
@@ -61,11 +58,11 @@ var ActorSourceType;
|
|
|
61
58
|
* without closing an import cycle. It is re-exported from there, so the public name and import path are
|
|
62
59
|
* unchanged.
|
|
63
60
|
*/
|
|
64
|
-
var ScheduleActions;
|
|
61
|
+
export var ScheduleActions;
|
|
65
62
|
(function (ScheduleActions) {
|
|
66
63
|
ScheduleActions["RunActor"] = "RUN_ACTOR";
|
|
67
64
|
ScheduleActions["RunActorTask"] = "RUN_ACTOR_TASK";
|
|
68
|
-
})(ScheduleActions || (
|
|
65
|
+
})(ScheduleActions || (ScheduleActions = {}));
|
|
69
66
|
/**
|
|
70
67
|
* Platform features a plan can enable.
|
|
71
68
|
*
|
|
@@ -77,7 +74,7 @@ var ScheduleActions;
|
|
|
77
74
|
* Declared here rather than in `./resource_clients/user` so the user types can live alongside it. It is
|
|
78
75
|
* re-exported from there, so the public name and import path are unchanged.
|
|
79
76
|
*/
|
|
80
|
-
var PlatformFeature;
|
|
77
|
+
export var PlatformFeature;
|
|
81
78
|
(function (PlatformFeature) {
|
|
82
79
|
PlatformFeature["Actors"] = "ACTORS";
|
|
83
80
|
PlatformFeature["Storage"] = "STORAGE";
|
|
@@ -86,4 +83,4 @@ var PlatformFeature;
|
|
|
86
83
|
PlatformFeature["Webhooks"] = "WEBHOOKS";
|
|
87
84
|
PlatformFeature["Proxy"] = "PROXY";
|
|
88
85
|
PlatformFeature["ProxyExternalAccess"] = "PROXY_EXTERNAL_ACCESS";
|
|
89
|
-
})(PlatformFeature || (
|
|
86
|
+
})(PlatformFeature || (PlatformFeature = {}));
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
|
|
2
2
|
import { Log } from '@apify/log';
|
|
3
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
4
|
-
import { ResourceClient } from '../base/resource_client';
|
|
5
|
-
import type { Actor, ActorRun } from '../models';
|
|
6
|
-
import { ActorVersionClient } from './actor_version';
|
|
7
|
-
import { ActorVersionCollectionClient } from './actor_version_collection';
|
|
8
|
-
import type { Build, BuildClientGetOptions } from './build';
|
|
9
|
-
import { BuildClient } from './build';
|
|
10
|
-
import { BuildCollectionClient } from './build_collection';
|
|
11
|
-
import { RunClient } from './run';
|
|
12
|
-
import { RunCollectionClient } from './run_collection';
|
|
13
|
-
import type { WebhookUpdateData } from './webhook';
|
|
14
|
-
import { WebhookCollectionClient } from './webhook_collection';
|
|
3
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
4
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
5
|
+
import type { Actor, ActorRun } from '../models.js';
|
|
6
|
+
import { ActorVersionClient } from './actor_version.js';
|
|
7
|
+
import { ActorVersionCollectionClient } from './actor_version_collection.js';
|
|
8
|
+
import type { Build, BuildClientGetOptions } from './build.js';
|
|
9
|
+
import { BuildClient } from './build.js';
|
|
10
|
+
import { BuildCollectionClient } from './build_collection.js';
|
|
11
|
+
import { RunClient } from './run.js';
|
|
12
|
+
import { RunCollectionClient } from './run_collection.js';
|
|
13
|
+
import type { WebhookUpdateData } from './webhook.js';
|
|
14
|
+
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
15
15
|
import type { ValueOf } from 'type-fest';
|
|
16
|
-
export type { Actor, ActorChargeEvent, ActorChargeEvents, ActorDefaultRunOptions, ActorDefinition, ActorExampleRunInput, ActorRun, ActorRunListItem, ActorRunMeta, ActorRunMetamorph, ActorRunOptions, ActorRunPricingInfo, ActorRunStats, ActorRunStorageIds, ActorRunUsage, ActorStandby, ActorStats, ActorTaggedBuild, ActorTaggedBuilds, FlatPricePerMonthActorPricingInfo, FreeActorPricingInfo, PricePerDatasetItemActorPricingInfo, PricePerEventActorPricingInfo, TieredPricingPerDatasetItem, TieredPricingPerDatasetItemEntry, TieredPricingPerEvent, TieredPricingPerEventEntry, } from '../models';
|
|
16
|
+
export type { Actor, ActorChargeEvent, ActorChargeEvents, ActorDefaultRunOptions, ActorDefinition, ActorExampleRunInput, ActorRun, ActorRunListItem, ActorRunMeta, ActorRunMetamorph, ActorRunOptions, ActorRunPricingInfo, ActorRunStats, ActorRunStorageIds, ActorRunUsage, ActorStandby, ActorStats, ActorTaggedBuild, ActorTaggedBuilds, FlatPricePerMonthActorPricingInfo, FreeActorPricingInfo, PricePerDatasetItemActorPricingInfo, PricePerEventActorPricingInfo, TieredPricingPerDatasetItem, TieredPricingPerDatasetItemEntry, TieredPricingPerEvent, TieredPricingPerEventEntry, } from '../models.js';
|
|
17
17
|
/**
|
|
18
18
|
* Client for managing a specific Actor.
|
|
19
19
|
*
|