apify-client 2.23.5-beta.0 → 2.23.5-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/dist/apify_api_error.js +37 -84
- package/dist/apify_client.js +6 -36
- package/dist/base/api_client.js +10 -56
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/dist/http_client.js +15 -77
- package/dist/interceptors.js +5 -17
- package/dist/resource_clients/actor.js +3 -3
- package/dist/resource_clients/actor_collection.d.ts +2 -0
- package/dist/resource_clients/dataset.js +3 -5
- package/dist/resource_clients/dataset_collection.js +1 -1
- package/dist/resource_clients/key_value_store.js +2 -2
- package/dist/resource_clients/key_value_store_collection.js +1 -1
- package/dist/resource_clients/log.js +7 -42
- package/dist/resource_clients/request_queue.js +14 -36
- package/dist/resource_clients/run.js +5 -7
- package/dist/statistics.js +13 -30
- package/dist/utils.js +6 -31
- package/package.json +5 -5
package/dist/apify_api_error.js
CHANGED
|
@@ -21,11 +21,45 @@ const CLIENT_METHOD_REGEX = /at( async)? ([A-Za-z]+(Collection)?Client)\._?([A-Z
|
|
|
21
21
|
* needed.
|
|
22
22
|
*/
|
|
23
23
|
class ApifyApiError extends Error {
|
|
24
|
+
name;
|
|
25
|
+
/**
|
|
26
|
+
* The invoked resource client and the method. Known issue: Sometimes it displays
|
|
27
|
+
* as `unknown` because it can't be parsed from a stack trace.
|
|
28
|
+
*/
|
|
29
|
+
clientMethod;
|
|
30
|
+
/**
|
|
31
|
+
* HTTP status code of the error.
|
|
32
|
+
*/
|
|
33
|
+
statusCode;
|
|
34
|
+
/**
|
|
35
|
+
* The type of the error, as returned by the API.
|
|
36
|
+
*/
|
|
37
|
+
type;
|
|
38
|
+
/**
|
|
39
|
+
* Number of the API call attempt.
|
|
40
|
+
*/
|
|
41
|
+
attempt;
|
|
42
|
+
/**
|
|
43
|
+
* HTTP method of the API call.
|
|
44
|
+
*/
|
|
45
|
+
httpMethod;
|
|
46
|
+
/**
|
|
47
|
+
* Full path of the API endpoint (URL excluding origin).
|
|
48
|
+
*/
|
|
49
|
+
path;
|
|
50
|
+
/**
|
|
51
|
+
* Original stack trace of the exception. It is replaced
|
|
52
|
+
* by a more informative stack with API call information.
|
|
53
|
+
*/
|
|
54
|
+
originalStack;
|
|
55
|
+
/**
|
|
56
|
+
* Additional data provided by the API about the error
|
|
57
|
+
*/
|
|
58
|
+
data;
|
|
24
59
|
/**
|
|
25
60
|
* @hidden
|
|
26
61
|
*/
|
|
27
62
|
constructor(response, attempt) {
|
|
28
|
-
var _a;
|
|
29
63
|
let message;
|
|
30
64
|
let type;
|
|
31
65
|
let responseData = response.data;
|
|
@@ -57,92 +91,12 @@ class ApifyApiError extends Error {
|
|
|
57
91
|
message = `Unexpected error: ${dataString}`;
|
|
58
92
|
}
|
|
59
93
|
super(message);
|
|
60
|
-
Object.defineProperty(this, "name", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
configurable: true,
|
|
63
|
-
writable: true,
|
|
64
|
-
value: void 0
|
|
65
|
-
});
|
|
66
|
-
/**
|
|
67
|
-
* The invoked resource client and the method. Known issue: Sometimes it displays
|
|
68
|
-
* as `unknown` because it can't be parsed from a stack trace.
|
|
69
|
-
*/
|
|
70
|
-
Object.defineProperty(this, "clientMethod", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: void 0
|
|
75
|
-
});
|
|
76
|
-
/**
|
|
77
|
-
* HTTP status code of the error.
|
|
78
|
-
*/
|
|
79
|
-
Object.defineProperty(this, "statusCode", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: void 0
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* The type of the error, as returned by the API.
|
|
87
|
-
*/
|
|
88
|
-
Object.defineProperty(this, "type", {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
configurable: true,
|
|
91
|
-
writable: true,
|
|
92
|
-
value: void 0
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Number of the API call attempt.
|
|
96
|
-
*/
|
|
97
|
-
Object.defineProperty(this, "attempt", {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
configurable: true,
|
|
100
|
-
writable: true,
|
|
101
|
-
value: void 0
|
|
102
|
-
});
|
|
103
|
-
/**
|
|
104
|
-
* HTTP method of the API call.
|
|
105
|
-
*/
|
|
106
|
-
Object.defineProperty(this, "httpMethod", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true,
|
|
110
|
-
value: void 0
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* Full path of the API endpoint (URL excluding origin).
|
|
114
|
-
*/
|
|
115
|
-
Object.defineProperty(this, "path", {
|
|
116
|
-
enumerable: true,
|
|
117
|
-
configurable: true,
|
|
118
|
-
writable: true,
|
|
119
|
-
value: void 0
|
|
120
|
-
});
|
|
121
|
-
/**
|
|
122
|
-
* Original stack trace of the exception. It is replaced
|
|
123
|
-
* by a more informative stack with API call information.
|
|
124
|
-
*/
|
|
125
|
-
Object.defineProperty(this, "originalStack", {
|
|
126
|
-
enumerable: true,
|
|
127
|
-
configurable: true,
|
|
128
|
-
writable: true,
|
|
129
|
-
value: void 0
|
|
130
|
-
});
|
|
131
|
-
/**
|
|
132
|
-
* Additional data provided by the API about the error
|
|
133
|
-
*/
|
|
134
|
-
Object.defineProperty(this, "data", {
|
|
135
|
-
enumerable: true,
|
|
136
|
-
configurable: true,
|
|
137
|
-
writable: true,
|
|
138
|
-
value: void 0
|
|
139
|
-
});
|
|
140
94
|
this.name = this.constructor.name;
|
|
141
95
|
this.clientMethod = this._extractClientAndMethodFromStack();
|
|
142
96
|
this.statusCode = response.status;
|
|
143
97
|
this.type = type;
|
|
144
98
|
this.attempt = attempt;
|
|
145
|
-
this.httpMethod =
|
|
99
|
+
this.httpMethod = response.config?.method;
|
|
146
100
|
this.path = this._safelyParsePathFromResponse(response);
|
|
147
101
|
const stack = this.stack;
|
|
148
102
|
this.originalStack = stack.slice(stack.indexOf('\n'));
|
|
@@ -150,8 +104,7 @@ class ApifyApiError extends Error {
|
|
|
150
104
|
this.data = errorData;
|
|
151
105
|
}
|
|
152
106
|
_safelyParsePathFromResponse(response) {
|
|
153
|
-
|
|
154
|
-
const urlString = (_a = response.config) === null || _a === void 0 ? void 0 : _a.url;
|
|
107
|
+
const urlString = response.config?.url;
|
|
155
108
|
let url;
|
|
156
109
|
try {
|
|
157
110
|
url = new URL(urlString);
|
package/dist/apify_client.js
CHANGED
|
@@ -53,43 +53,13 @@ const DEFAULT_TIMEOUT_SECS = 360;
|
|
|
53
53
|
* @see https://docs.apify.com/api/v2
|
|
54
54
|
*/
|
|
55
55
|
class ApifyClient {
|
|
56
|
+
baseUrl;
|
|
57
|
+
publicBaseUrl;
|
|
58
|
+
token;
|
|
59
|
+
stats;
|
|
60
|
+
logger;
|
|
61
|
+
httpClient;
|
|
56
62
|
constructor(options = {}) {
|
|
57
|
-
Object.defineProperty(this, "baseUrl", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
writable: true,
|
|
61
|
-
value: void 0
|
|
62
|
-
});
|
|
63
|
-
Object.defineProperty(this, "publicBaseUrl", {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
configurable: true,
|
|
66
|
-
writable: true,
|
|
67
|
-
value: void 0
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(this, "token", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true,
|
|
72
|
-
writable: true,
|
|
73
|
-
value: void 0
|
|
74
|
-
});
|
|
75
|
-
Object.defineProperty(this, "stats", {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
configurable: true,
|
|
78
|
-
writable: true,
|
|
79
|
-
value: void 0
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(this, "logger", {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
value: void 0
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(this, "httpClient", {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
configurable: true,
|
|
90
|
-
writable: true,
|
|
91
|
-
value: void 0
|
|
92
|
-
});
|
|
93
63
|
(0, ow_1.default)(options, ow_1.default.object.exactShape({
|
|
94
64
|
baseUrl: ow_1.default.optional.string,
|
|
95
65
|
publicBaseUrl: ow_1.default.optional.string,
|
package/dist/base/api_client.js
CHANGED
|
@@ -3,61 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ApiClient = void 0;
|
|
4
4
|
/** @private */
|
|
5
5
|
class ApiClient {
|
|
6
|
+
id;
|
|
7
|
+
safeId;
|
|
8
|
+
baseUrl;
|
|
9
|
+
publicBaseUrl;
|
|
10
|
+
resourcePath;
|
|
11
|
+
url;
|
|
12
|
+
apifyClient;
|
|
13
|
+
httpClient;
|
|
14
|
+
params;
|
|
6
15
|
constructor(options) {
|
|
7
|
-
Object.defineProperty(this, "id", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: void 0
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "safeId", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "baseUrl", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "publicBaseUrl", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(this, "resourcePath", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: void 0
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(this, "url", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: void 0
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(this, "apifyClient", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "httpClient", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(this, "params", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
61
16
|
const { baseUrl, publicBaseUrl, apifyClient, httpClient, resourcePath, id, params = {} } = options;
|
|
62
17
|
this.id = id;
|
|
63
18
|
this.safeId = id && this._toSafeId(id);
|
|
@@ -116,10 +71,9 @@ class ApiClient {
|
|
|
116
71
|
limit: minForLimitParam(options.limit, options.chunkSize),
|
|
117
72
|
});
|
|
118
73
|
async function* asyncGenerator() {
|
|
119
|
-
var _a;
|
|
120
74
|
let currentPage = await paginatedListPromise;
|
|
121
75
|
yield* currentPage.items;
|
|
122
|
-
const offset =
|
|
76
|
+
const offset = options.offset ?? 0;
|
|
123
77
|
const limit = Math.min(options.limit || currentPage.total, currentPage.total);
|
|
124
78
|
let currentOffset = offset + currentPage.items.length;
|
|
125
79
|
let remainingItems = Math.min(currentPage.total - offset, limit) - currentPage.items.length;
|
package/dist/bundle.js
CHANGED
|
@@ -18031,7 +18031,7 @@ function isStream(value) {
|
|
|
18031
18031
|
function getVersionData() {
|
|
18032
18032
|
if (true) {
|
|
18033
18033
|
return {
|
|
18034
|
-
version: "2.23.5-beta.
|
|
18034
|
+
version: "2.23.5-beta.10"
|
|
18035
18035
|
};
|
|
18036
18036
|
}
|
|
18037
18037
|
// eslint-disable-next-line
|