@ezs/basics 1.22.3 → 1.22.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/CHANGELOG.md +11 -0
- package/README.md +5 -0
- package/lib/url-connect.js +17 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.22.4](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.3...@ezs/basics@1.22.4) (2022-12-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* on retry, input stream was lost ([1b710f1](https://github.com/Inist-CNRS/ezs/commit/1b710f19d1dd163bcaf3580f0d23def6f948423a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.22.3](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.2...@ezs/basics@1.22.3) (2022-09-19)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -619,6 +619,11 @@ The output will be the returned content of URL.
|
|
|
619
619
|
|
|
620
620
|
Useful to send JSON data to an API and get results.
|
|
621
621
|
|
|
622
|
+
Warning :
|
|
623
|
+
if retries === 1, it will directly use the stream
|
|
624
|
+
to connect to the server otherwise the stream will be fully
|
|
625
|
+
read to be buffered and sent to the server (n times)
|
|
626
|
+
|
|
622
627
|
#### Parameters
|
|
623
628
|
|
|
624
629
|
- `url` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** URL to fetch
|
package/lib/url-connect.js
CHANGED
|
@@ -17,6 +17,8 @@ var _parseHeaders = _interopRequireDefault(require("parse-headers"));
|
|
|
17
17
|
|
|
18
18
|
var _asyncRetry = _interopRequireDefault(require("async-retry"));
|
|
19
19
|
|
|
20
|
+
var _getStream = _interopRequireDefault(require("get-stream"));
|
|
21
|
+
|
|
20
22
|
var _request = _interopRequireDefault(require("./request"));
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -28,6 +30,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
28
30
|
*
|
|
29
31
|
* Useful to send JSON data to an API and get results.
|
|
30
32
|
*
|
|
33
|
+
* Warning :
|
|
34
|
+
* if retries === 1, it will directly use the stream
|
|
35
|
+
* to connect to the server otherwise the stream will be fully
|
|
36
|
+
* read to be buffered and sent to the server (n times)
|
|
37
|
+
*
|
|
31
38
|
* @name URLConnect
|
|
32
39
|
* @param {String} [url] URL to fetch
|
|
33
40
|
* @param {String} [json=false] Parse as JSON the content of URL
|
|
@@ -53,7 +60,16 @@ async function URLConnect(data, feed) {
|
|
|
53
60
|
const output = ezs.createStream(ezs.objectMode());
|
|
54
61
|
this.whenFinish = feed.flow(output);
|
|
55
62
|
(0, _streamWrite.default)(this.input, data, () => feed.end());
|
|
56
|
-
const
|
|
63
|
+
const streamIn = this.input.pipe(ezs('dump'));
|
|
64
|
+
let bodyIn;
|
|
65
|
+
|
|
66
|
+
if (retries === 1) {
|
|
67
|
+
bodyIn = streamIn.pipe(ezs.toBuffer());
|
|
68
|
+
} else {
|
|
69
|
+
bodyIn = await (0, _getStream.default)(streamIn);
|
|
70
|
+
headers['Content-Type'] = 'application/json';
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
const parameters = {
|
|
58
74
|
method: 'POST',
|
|
59
75
|
body: bodyIn,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "1.22.
|
|
4
|
+
"version": "1.22.4",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"debug": "4.3.3",
|
|
13
13
|
"fetch-with-proxy": "3.0.1",
|
|
14
14
|
"flat": "5.0.2",
|
|
15
|
+
"get-stream": "6.0.1",
|
|
15
16
|
"lodash.escaperegexp": "4.1.2",
|
|
16
17
|
"lodash.get": "4.4.2",
|
|
17
18
|
"lodash.mapkeys": "4.6.0",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"directories": {
|
|
37
38
|
"test": "test"
|
|
38
39
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "93076ad048cd7839983724f187b064fd71a0ed52",
|
|
40
41
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
41
42
|
"keywords": [
|
|
42
43
|
"ezs"
|