ibm-cloud-sdk-core 2.17.3 → 2.17.7
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 +28 -0
- package/README.md +0 -1
- package/build/docs/ibm-cloud-sdk-core.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.streamtopromise.md +1 -1
- package/docs/ibm-cloud-sdk-core.api.json +2 -2
- package/es/lib/request-wrapper.js +5 -1
- package/es/lib/stream-to-promise.d.ts +2 -1
- package/es/lib/stream-to-promise.js +3 -2
- package/es/tsdoc-metadata.json +1 -1
- package/ibm-cloud-sdk-core.d.ts +2 -1
- package/lib/request-wrapper.js +13 -10
- package/lib/stream-to-promise.d.ts +2 -1
- package/lib/stream-to-promise.js +3 -2
- package/package.json +4 -2
- package/temp/ibm-cloud-sdk-core.api.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [2.17.7](https://github.com/IBM/node-sdk-core/compare/v2.17.6...v2.17.7) (2022-01-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove 'module' entry from package.json ([#187](https://github.com/IBM/node-sdk-core/issues/187)) ([3a0aea5](https://github.com/IBM/node-sdk-core/commit/3a0aea5109f01d61ad54c79a7a6f2606fb845ab8))
|
|
7
|
+
|
|
8
|
+
## [2.17.6](https://github.com/IBM/node-sdk-core/compare/v2.17.5...v2.17.6) (2022-01-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use npm8 and package-lock v2 ([#186](https://github.com/IBM/node-sdk-core/issues/186)) ([6b1122c](https://github.com/IBM/node-sdk-core/commit/6b1122c5318c304454414dcd9cafb9b151c5b51a))
|
|
14
|
+
|
|
15
|
+
## [2.17.5](https://github.com/IBM/node-sdk-core/compare/v2.17.4...v2.17.5) (2021-12-17)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* avoid Buffer re-encode during compression ([#184](https://github.com/IBM/node-sdk-core/issues/184)) ([8b82f36](https://github.com/IBM/node-sdk-core/commit/8b82f36bf6d4ac0163563ce3a10f0a395bd87627))
|
|
21
|
+
|
|
22
|
+
## [2.17.4](https://github.com/IBM/node-sdk-core/compare/v2.17.3...v2.17.4) (2021-12-16)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* don't always convert bytes to text in streamToPromise ([#182](https://github.com/IBM/node-sdk-core/issues/182)) ([7fe261b](https://github.com/IBM/node-sdk-core/commit/7fe261b20f934cd3fde45acc69b9d4888836aa69))
|
|
28
|
+
|
|
1
29
|
## [2.17.3](https://github.com/IBM/node-sdk-core/compare/v2.17.2...v2.17.3) (2021-12-13)
|
|
2
30
|
|
|
3
31
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
[](https://app.travis-ci.com/IBM/node-sdk-core)
|
|
2
2
|
[](https://www.npmjs.com/package/ibm-cloud-sdk-core)
|
|
3
|
-
[](https://codecov.io/gh/IBM/node-sdk-core)
|
|
4
3
|
[](https://github.com/semantic-release/semantic-release)
|
|
5
4
|
[](https://cla-assistant.io/ibm/node-sdk-core)
|
|
6
5
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
| [readCrTokenFile(filepath)](./ibm-cloud-sdk-core.readcrtokenfile.md) | |
|
|
55
55
|
| [readExternalSources(serviceName)](./ibm-cloud-sdk-core.readexternalsources.md) | Read properties stored in external sources like Environment Variables, the credentials file, VCAP services, etc. and return them as an object. The keys of this object will have the service name prefix removed and will be converted to lower camel case.<!-- -->Only one source will be used at a time. |
|
|
56
56
|
| [removeSuffix(str, suffix)](./ibm-cloud-sdk-core.removesuffix.md) | Remove a given suffix if it exists. |
|
|
57
|
-
| [streamToPromise(stream)](./ibm-cloud-sdk-core.streamtopromise.md) | Helper method that can be bound to a stream - it
|
|
57
|
+
| [streamToPromise(stream)](./ibm-cloud-sdk-core.streamtopromise.md) | Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise |
|
|
58
58
|
| [stripTrailingSlash(url)](./ibm-cloud-sdk-core.striptrailingslash.md) | |
|
|
59
59
|
| [toLowerKeys(obj)](./ibm-cloud-sdk-core.tolowerkeys.md) | This function converts an object's keys to lower case. note: does not convert nested keys |
|
|
60
60
|
| [validateInput(options, requiredOptions)](./ibm-cloud-sdk-core.validateinput.md) | |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## streamToPromise() function
|
|
6
6
|
|
|
7
|
-
Helper method that can be bound to a stream - it
|
|
7
|
+
Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.19.
|
|
4
|
+
"toolVersion": "7.19.4",
|
|
5
5
|
"schemaVersion": 1004,
|
|
6
6
|
"oldestForwardsCompatibleVersion": 1001,
|
|
7
7
|
"tsdocConfig": {
|
|
@@ -5139,7 +5139,7 @@
|
|
|
5139
5139
|
{
|
|
5140
5140
|
"kind": "Function",
|
|
5141
5141
|
"canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
|
|
5142
|
-
"docComment": "/**\n * Helper method that can be bound to a stream - it
|
|
5142
|
+
"docComment": "/**\n * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
|
|
5143
5143
|
"excerptTokens": [
|
|
5144
5144
|
{
|
|
5145
5145
|
"kind": "Content",
|
|
@@ -360,7 +360,11 @@ export class RequestWrapper {
|
|
|
360
360
|
let reqBuffer;
|
|
361
361
|
try {
|
|
362
362
|
if (isStream(data)) {
|
|
363
|
-
|
|
363
|
+
const streamData = yield streamToPromise(data);
|
|
364
|
+
reqBuffer = Buffer.isBuffer(streamData) ? streamData : Buffer.from(streamData);
|
|
365
|
+
}
|
|
366
|
+
else if (Buffer.isBuffer(data)) {
|
|
367
|
+
reqBuffer = data;
|
|
364
368
|
}
|
|
365
369
|
else if (data.toString && data.toString() !== '[object Object]' && !Array.isArray(data)) {
|
|
366
370
|
// this handles pretty much any primitive that isnt a JSON object or array
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
/// <reference types="node" />
|
|
17
17
|
import { Stream } from 'stream';
|
|
18
18
|
/**
|
|
19
|
-
* Helper method that can be bound to a stream - it
|
|
19
|
+
* Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
|
|
20
|
+
* or array of text chunks
|
|
20
21
|
* Essentially a smaller version of concat-stream wrapped in a promise
|
|
21
22
|
*
|
|
22
23
|
* @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
* Helper method that can be bound to a stream - it
|
|
17
|
+
* Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
|
|
18
|
+
* or array of text chunks
|
|
18
19
|
* Essentially a smaller version of concat-stream wrapped in a promise
|
|
19
20
|
*
|
|
20
21
|
* @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
|
|
@@ -29,7 +30,7 @@ export function streamToPromise(stream) {
|
|
|
29
30
|
results.push(result);
|
|
30
31
|
})
|
|
31
32
|
.on('end', () => {
|
|
32
|
-
resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results)
|
|
33
|
+
resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results) : results);
|
|
33
34
|
})
|
|
34
35
|
.on('error', reject);
|
|
35
36
|
});
|
package/es/tsdoc-metadata.json
CHANGED
package/ibm-cloud-sdk-core.d.ts
CHANGED
|
@@ -1228,7 +1228,8 @@ export declare class BaseService {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
1230
|
/**
|
|
1231
|
-
* Helper method that can be bound to a stream - it
|
|
1231
|
+
* Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
|
|
1232
|
+
* or array of text chunks
|
|
1232
1233
|
* Essentially a smaller version of concat-stream wrapped in a promise
|
|
1233
1234
|
*
|
|
1234
1235
|
* @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
|
package/lib/request-wrapper.js
CHANGED
|
@@ -411,35 +411,38 @@ var RequestWrapper = /** @class */ (function () {
|
|
|
411
411
|
};
|
|
412
412
|
RequestWrapper.prototype.gzipRequestBody = function (data, headers) {
|
|
413
413
|
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
-
var contentSetToGzip, reqBuffer,
|
|
415
|
-
return __generator(this, function (
|
|
416
|
-
switch (
|
|
414
|
+
var contentSetToGzip, reqBuffer, streamData, err_1;
|
|
415
|
+
return __generator(this, function (_a) {
|
|
416
|
+
switch (_a.label) {
|
|
417
417
|
case 0:
|
|
418
418
|
contentSetToGzip = headers['Content-Encoding'] && headers['Content-Encoding'].toString().includes('gzip');
|
|
419
419
|
if (!data || contentSetToGzip) {
|
|
420
420
|
return [2 /*return*/, data];
|
|
421
421
|
}
|
|
422
|
-
|
|
422
|
+
_a.label = 1;
|
|
423
423
|
case 1:
|
|
424
|
-
|
|
424
|
+
_a.trys.push([1, 5, , 6]);
|
|
425
425
|
if (!isstream_1.default(data)) return [3 /*break*/, 3];
|
|
426
|
-
_b = (_a = Buffer).from;
|
|
427
426
|
return [4 /*yield*/, stream_to_promise_1.streamToPromise(data)];
|
|
428
427
|
case 2:
|
|
429
|
-
|
|
428
|
+
streamData = _a.sent();
|
|
429
|
+
reqBuffer = Buffer.isBuffer(streamData) ? streamData : Buffer.from(streamData);
|
|
430
430
|
return [3 /*break*/, 4];
|
|
431
431
|
case 3:
|
|
432
|
-
if (
|
|
432
|
+
if (Buffer.isBuffer(data)) {
|
|
433
|
+
reqBuffer = data;
|
|
434
|
+
}
|
|
435
|
+
else if (data.toString && data.toString() !== '[object Object]' && !Array.isArray(data)) {
|
|
433
436
|
// this handles pretty much any primitive that isnt a JSON object or array
|
|
434
437
|
reqBuffer = Buffer.from(data.toString());
|
|
435
438
|
}
|
|
436
439
|
else {
|
|
437
440
|
reqBuffer = Buffer.from(JSON.stringify(data));
|
|
438
441
|
}
|
|
439
|
-
|
|
442
|
+
_a.label = 4;
|
|
440
443
|
case 4: return [3 /*break*/, 6];
|
|
441
444
|
case 5:
|
|
442
|
-
err_1 =
|
|
445
|
+
err_1 = _a.sent();
|
|
443
446
|
logger_1.default.error('Error converting request body to a buffer - data will not be compressed.');
|
|
444
447
|
logger_1.default.debug(err_1);
|
|
445
448
|
return [2 /*return*/, data];
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
/// <reference types="node" />
|
|
17
17
|
import { Stream } from 'stream';
|
|
18
18
|
/**
|
|
19
|
-
* Helper method that can be bound to a stream - it
|
|
19
|
+
* Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
|
|
20
|
+
* or array of text chunks
|
|
20
21
|
* Essentially a smaller version of concat-stream wrapped in a promise
|
|
21
22
|
*
|
|
22
23
|
* @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
|
package/lib/stream-to-promise.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
/**
|
|
19
|
-
* Helper method that can be bound to a stream - it
|
|
19
|
+
* Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
|
|
20
|
+
* or array of text chunks
|
|
20
21
|
* Essentially a smaller version of concat-stream wrapped in a promise
|
|
21
22
|
*
|
|
22
23
|
* @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
|
|
@@ -31,7 +32,7 @@ function streamToPromise(stream) {
|
|
|
31
32
|
results.push(result);
|
|
32
33
|
})
|
|
33
34
|
.on('end', function () {
|
|
34
|
-
resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results)
|
|
35
|
+
resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results) : results);
|
|
35
36
|
})
|
|
36
37
|
.on('error', reject);
|
|
37
38
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ibm-cloud-sdk-core",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.7",
|
|
4
4
|
"description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"module": "./es/index.js",
|
|
7
6
|
"typings": "./es/index.d.ts",
|
|
8
7
|
"sideEffects": false,
|
|
9
8
|
"repository": {
|
|
@@ -32,6 +31,9 @@
|
|
|
32
31
|
}
|
|
33
32
|
],
|
|
34
33
|
"license": "Apache-2.0",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
35
37
|
"bugs": {
|
|
36
38
|
"url": "https://github.com/IBM/node-sdk-core/issues"
|
|
37
39
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.19.
|
|
4
|
+
"toolVersion": "7.19.4",
|
|
5
5
|
"schemaVersion": 1004,
|
|
6
6
|
"oldestForwardsCompatibleVersion": 1001,
|
|
7
7
|
"tsdocConfig": {
|
|
@@ -5139,7 +5139,7 @@
|
|
|
5139
5139
|
{
|
|
5140
5140
|
"kind": "Function",
|
|
5141
5141
|
"canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
|
|
5142
|
-
"docComment": "/**\n * Helper method that can be bound to a stream - it
|
|
5142
|
+
"docComment": "/**\n * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
|
|
5143
5143
|
"excerptTokens": [
|
|
5144
5144
|
{
|
|
5145
5145
|
"kind": "Content",
|