@ezs/basics 1.22.2 → 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 CHANGED
@@ -3,6 +3,28 @@
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
+
17
+ ## [1.22.3](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.2...@ezs/basics@1.22.3) (2022-09-19)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * 🐛 locations like [files] ([42fb184](https://github.com/Inist-CNRS/ezs/commit/42fb184bba3534bf2123a12d276d89f6809d09a7))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.22.2](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.1...@ezs/basics@1.22.2) (2022-09-14)
7
29
 
8
30
 
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/file-load.js CHANGED
@@ -54,9 +54,8 @@ async function FILELoad(data, feed) {
54
54
 
55
55
  const cwd = process.cwd();
56
56
  const tpd = (0, _os.tmpdir)();
57
- const location = this.getParam('location', tpd);
58
57
  const compress = this.getParam('compress', false);
59
- const locations = [cwd, tpd, location];
58
+ const locations = this.ezs.getPath().concat(cwd, tpd, this.getParam('location'));
60
59
  const file = locations.filter(Boolean).map(dir => (0, _path.resolve)(dir, String(data).trim())).filter(fil => (0, _fs.existsSync)(fil)).shift();
61
60
 
62
61
  if (!file) {
@@ -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 bodyIn = this.input.pipe(ezs('dump')).pipe(ezs.toBuffer());
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.2",
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": "51729dbb9364dc2a882af2a3cbccbb2e79de89d2",
40
+ "gitHead": "93076ad048cd7839983724f187b064fd71a0ed52",
40
41
  "homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
41
42
  "keywords": [
42
43
  "ezs"