balena-request 12.0.3 → 12.0.4
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/.versionbot/CHANGELOG.yml +13 -1
- package/CHANGELOG.md +4 -0
- package/build/request.js +11 -14
- package/lib/request.ts +15 -15
- package/package.json +2 -2
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Refactor the interceptors to stop using .reduce()
|
|
3
|
+
hash: bb3ebd421cff85803bc80ead121b83e8ed103499
|
|
4
|
+
body: ""
|
|
5
|
+
footer:
|
|
6
|
+
Change-type: patch
|
|
7
|
+
change-type: patch
|
|
8
|
+
author: Thodoris Greasidis
|
|
9
|
+
nested: []
|
|
10
|
+
version: 12.0.4
|
|
11
|
+
title: ""
|
|
12
|
+
date: 2023-08-23T07:58:50.227Z
|
|
1
13
|
- commits:
|
|
2
14
|
- subject: Avoid deep imports from balena-auth
|
|
3
15
|
hash: c11642a930772b968ff736583358d04a0b9321f4
|
|
@@ -17,7 +29,7 @@
|
|
|
17
29
|
nested: []
|
|
18
30
|
version: 12.0.3
|
|
19
31
|
title: ""
|
|
20
|
-
date: 2023-08-09T12:
|
|
32
|
+
date: 2023-08-09T12:18:22.918Z
|
|
21
33
|
- commits:
|
|
22
34
|
- subject: Make `url` a normal dependency
|
|
23
35
|
hash: 1598cca9808180f2df2455bd8514b2647ea88f47
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## 12.0.4 - 2023-08-23
|
|
8
|
+
|
|
9
|
+
* Refactor the interceptors to stop using .reduce() [Thodoris Greasidis]
|
|
10
|
+
|
|
7
11
|
## 12.0.3 - 2023-08-09
|
|
8
12
|
|
|
9
13
|
* Avoid deep imports from balena-auth [Thodoris Greasidis]
|
package/build/request.js
CHANGED
|
@@ -95,28 +95,25 @@ function getRequest({ auth, debug = false, retries = 0, isBrowser = false, inter
|
|
|
95
95
|
const interceptResponse = (response) => interceptResponseOrError(Promise.resolve(response));
|
|
96
96
|
const interceptResponseError = (responseError) => interceptResponseOrError(Promise.reject(responseError));
|
|
97
97
|
const interceptRequestOrError = (initialPromise) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
|
|
98
|
+
let promise = initialPromise;
|
|
99
|
+
for (const { request, requestError } of exports.interceptors) {
|
|
99
100
|
if (request != null || requestError != null) {
|
|
100
|
-
|
|
101
|
+
promise = promise.then(request, requestError);
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}, initialPromise);
|
|
103
|
+
}
|
|
104
|
+
return promise;
|
|
106
105
|
});
|
|
107
106
|
const interceptResponseOrError = function (initialPromise) {
|
|
108
107
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
|
|
108
|
+
let promise = initialPromise;
|
|
109
|
+
for (const { response, responseError } of exports.interceptors
|
|
110
110
|
.slice()
|
|
111
|
-
.reverse()
|
|
112
|
-
.reduce(function (promise, { response, responseError }) {
|
|
111
|
+
.reverse()) {
|
|
113
112
|
if (response != null || responseError != null) {
|
|
114
|
-
|
|
113
|
+
promise = promise.then(response, responseError);
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}, initialPromise);
|
|
115
|
+
}
|
|
116
|
+
return promise;
|
|
120
117
|
});
|
|
121
118
|
};
|
|
122
119
|
/**
|
package/lib/request.ts
CHANGED
|
@@ -189,28 +189,28 @@ export function getRequest({
|
|
|
189
189
|
const interceptResponseError = (responseError: errors.BalenaRequestError) =>
|
|
190
190
|
interceptResponseOrError(Promise.reject(responseError));
|
|
191
191
|
|
|
192
|
-
const interceptRequestOrError = async (initialPromise: Promise<any>) =>
|
|
193
|
-
|
|
192
|
+
const interceptRequestOrError = async (initialPromise: Promise<any>) => {
|
|
193
|
+
let promise = initialPromise;
|
|
194
|
+
for (const { request, requestError } of exports.interceptors) {
|
|
194
195
|
if (request != null || requestError != null) {
|
|
195
|
-
|
|
196
|
-
} else {
|
|
197
|
-
return promise;
|
|
196
|
+
promise = promise.then(request, requestError);
|
|
198
197
|
}
|
|
199
|
-
}
|
|
198
|
+
}
|
|
199
|
+
return promise;
|
|
200
|
+
};
|
|
200
201
|
|
|
201
202
|
const interceptResponseOrError = async function (
|
|
202
203
|
initialPromise: Promise<any>,
|
|
203
204
|
) {
|
|
204
|
-
|
|
205
|
+
let promise = initialPromise;
|
|
206
|
+
for (const { response, responseError } of exports.interceptors
|
|
205
207
|
.slice()
|
|
206
|
-
.reverse()
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
}, initialPromise);
|
|
208
|
+
.reverse()) {
|
|
209
|
+
if (response != null || responseError != null) {
|
|
210
|
+
promise = promise.then(response, responseError);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return promise;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
216
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "balena-request",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.4",
|
|
4
4
|
"description": "Balena HTTP client",
|
|
5
5
|
"main": "build/request.js",
|
|
6
6
|
"types": "build/request.d.ts",
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"balena-auth": "^5.1.0"
|
|
81
81
|
},
|
|
82
82
|
"versionist": {
|
|
83
|
-
"publishedAt": "2023-08-
|
|
83
|
+
"publishedAt": "2023-08-23T07:58:50.434Z"
|
|
84
84
|
}
|
|
85
85
|
}
|