ibm-cloud-sdk-core 3.2.1 → 3.2.2-beta

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.
Files changed (160) hide show
  1. package/{auth → dist/auth}/authenticators/authenticator-interface.d.ts +0 -0
  2. package/{auth → dist/auth}/authenticators/authenticator-interface.js +0 -0
  3. package/{auth → dist/auth}/authenticators/authenticator.d.ts +0 -0
  4. package/{auth → dist/auth}/authenticators/authenticator.js +1 -0
  5. package/{auth → dist/auth}/authenticators/basic-authenticator.d.ts +0 -0
  6. package/{auth → dist/auth}/authenticators/basic-authenticator.js +7 -4
  7. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.d.ts +0 -0
  8. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.js +7 -4
  9. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  10. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.js +4 -1
  11. package/{auth → dist/auth}/authenticators/container-authenticator.d.ts +0 -0
  12. package/{auth → dist/auth}/authenticators/container-authenticator.js +4 -1
  13. package/{auth → dist/auth}/authenticators/iam-authenticator.d.ts +0 -0
  14. package/{auth → dist/auth}/authenticators/iam-authenticator.js +5 -2
  15. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.d.ts +0 -0
  16. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.js +4 -1
  17. package/{auth → dist/auth}/authenticators/index.d.ts +0 -0
  18. package/dist/auth/authenticators/index.js +38 -0
  19. package/{auth → dist/auth}/authenticators/no-auth-authenticator.d.ts +0 -0
  20. package/{auth → dist/auth}/authenticators/no-auth-authenticator.js +4 -1
  21. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.d.ts +0 -0
  22. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.js +6 -3
  23. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.d.ts +0 -0
  24. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.js +4 -1
  25. package/{auth → dist/auth}/index.d.ts +0 -0
  26. package/dist/auth/index.js +34 -0
  27. package/{auth → dist/auth}/token-managers/container-token-manager.d.ts +0 -0
  28. package/{auth → dist/auth}/token-managers/container-token-manager.js +7 -4
  29. package/{auth → dist/auth}/token-managers/cp4d-token-manager.d.ts +0 -0
  30. package/{auth → dist/auth}/token-managers/cp4d-token-manager.js +6 -3
  31. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.d.ts +0 -0
  32. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.js +9 -6
  33. package/{auth → dist/auth}/token-managers/iam-token-manager.d.ts +0 -0
  34. package/{auth → dist/auth}/token-managers/iam-token-manager.js +5 -2
  35. package/{auth → dist/auth}/token-managers/index.d.ts +0 -0
  36. package/{auth → dist/auth}/token-managers/index.js +8 -7
  37. package/{auth → dist/auth}/token-managers/jwt-token-manager.d.ts +0 -0
  38. package/{auth → dist/auth}/token-managers/jwt-token-manager.js +5 -2
  39. package/{auth → dist/auth}/token-managers/token-manager.d.ts +0 -0
  40. package/{auth → dist/auth}/token-managers/token-manager.js +5 -4
  41. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.d.ts +0 -0
  42. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.js +11 -8
  43. package/{auth → dist/auth}/utils/file-reading-helpers.browser.d.ts +0 -0
  44. package/{auth → dist/auth}/utils/file-reading-helpers.browser.js +1 -0
  45. package/{auth → dist/auth}/utils/file-reading-helpers.d.ts +0 -0
  46. package/{auth → dist/auth}/utils/file-reading-helpers.js +12 -11
  47. package/{auth → dist/auth}/utils/get-authenticator-from-environment.d.ts +0 -0
  48. package/{auth → dist/auth}/utils/get-authenticator-from-environment.js +3 -2
  49. package/{auth → dist/auth}/utils/helpers.d.ts +0 -0
  50. package/{auth → dist/auth}/utils/helpers.js +5 -4
  51. package/{auth → dist/auth}/utils/index.d.ts +0 -0
  52. package/dist/auth/utils/index.js +46 -0
  53. package/{auth → dist/auth}/utils/read-external-sources.d.ts +0 -0
  54. package/{auth → dist/auth}/utils/read-external-sources.js +6 -5
  55. package/{docs → dist/docs}/ibm-cloud-sdk-core.api.json +0 -0
  56. package/{es → dist/es}/auth/authenticators/authenticator-interface.d.ts +0 -0
  57. package/{es → dist/es}/auth/authenticators/authenticator-interface.js +1 -0
  58. package/{es → dist/es}/auth/authenticators/authenticator.d.ts +0 -0
  59. package/{es → dist/es}/auth/authenticators/authenticator.js +0 -0
  60. package/{es → dist/es}/auth/authenticators/basic-authenticator.d.ts +0 -0
  61. package/{es → dist/es}/auth/authenticators/basic-authenticator.js +0 -0
  62. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.d.ts +0 -0
  63. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.js +0 -0
  64. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  65. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.js +0 -0
  66. package/{es → dist/es}/auth/authenticators/container-authenticator.d.ts +0 -0
  67. package/{es → dist/es}/auth/authenticators/container-authenticator.js +0 -0
  68. package/{es → dist/es}/auth/authenticators/iam-authenticator.d.ts +0 -0
  69. package/{es → dist/es}/auth/authenticators/iam-authenticator.js +0 -0
  70. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.d.ts +0 -0
  71. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.js +0 -0
  72. package/{es → dist/es}/auth/authenticators/index.d.ts +0 -0
  73. package/{es → dist/es}/auth/authenticators/index.js +0 -0
  74. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.d.ts +0 -0
  75. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.js +0 -0
  76. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.d.ts +0 -0
  77. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.js +0 -0
  78. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.d.ts +0 -0
  79. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.js +0 -0
  80. package/{es → dist/es}/auth/index.d.ts +0 -0
  81. package/{es → dist/es}/auth/index.js +0 -0
  82. package/{es → dist/es}/auth/token-managers/container-token-manager.d.ts +0 -0
  83. package/{es → dist/es}/auth/token-managers/container-token-manager.js +0 -0
  84. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.d.ts +0 -0
  85. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.js +0 -0
  86. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.d.ts +0 -0
  87. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.js +0 -0
  88. package/{es → dist/es}/auth/token-managers/iam-token-manager.d.ts +0 -0
  89. package/{es → dist/es}/auth/token-managers/iam-token-manager.js +0 -0
  90. package/{es → dist/es}/auth/token-managers/index.d.ts +0 -0
  91. package/{es → dist/es}/auth/token-managers/index.js +0 -0
  92. package/{es → dist/es}/auth/token-managers/jwt-token-manager.d.ts +0 -0
  93. package/{es → dist/es}/auth/token-managers/jwt-token-manager.js +0 -0
  94. package/{es → dist/es}/auth/token-managers/token-manager.d.ts +0 -0
  95. package/{es → dist/es}/auth/token-managers/token-manager.js +0 -0
  96. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.d.ts +0 -0
  97. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.js +0 -0
  98. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.d.ts +0 -0
  99. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.js +0 -0
  100. package/{es → dist/es}/auth/utils/file-reading-helpers.d.ts +0 -0
  101. package/{es → dist/es}/auth/utils/file-reading-helpers.js +0 -0
  102. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.d.ts +0 -0
  103. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.js +0 -0
  104. package/{es → dist/es}/auth/utils/helpers.d.ts +0 -0
  105. package/{es → dist/es}/auth/utils/helpers.js +0 -0
  106. package/{es → dist/es}/auth/utils/index.d.ts +0 -0
  107. package/{es → dist/es}/auth/utils/index.js +0 -0
  108. package/{es → dist/es}/auth/utils/read-external-sources.d.ts +0 -0
  109. package/{es → dist/es}/auth/utils/read-external-sources.js +0 -0
  110. package/{es → dist/es}/index.d.ts +0 -0
  111. package/{es → dist/es}/index.js +0 -0
  112. package/{es → dist/es}/lib/base-service.d.ts +0 -0
  113. package/{es → dist/es}/lib/base-service.js +0 -0
  114. package/{es → dist/es}/lib/content-type.d.ts +0 -0
  115. package/{es → dist/es}/lib/content-type.js +0 -0
  116. package/{es → dist/es}/lib/get-new-logger.d.ts +0 -0
  117. package/{es → dist/es}/lib/get-new-logger.js +0 -0
  118. package/{es → dist/es}/lib/helper.d.ts +0 -0
  119. package/{es → dist/es}/lib/helper.js +0 -0
  120. package/{es → dist/es}/lib/logger.d.ts +0 -0
  121. package/{es → dist/es}/lib/logger.js +0 -0
  122. package/{es → dist/es}/lib/querystring.d.ts +0 -0
  123. package/{es → dist/es}/lib/querystring.js +0 -0
  124. package/{es → dist/es}/lib/request-wrapper.d.ts +0 -0
  125. package/{es → dist/es}/lib/request-wrapper.js +13 -5
  126. package/{es → dist/es}/lib/sdk-test-helpers.browser.d.ts +0 -0
  127. package/{es → dist/es}/lib/sdk-test-helpers.browser.js +0 -0
  128. package/{es → dist/es}/lib/sdk-test-helpers.d.ts +0 -0
  129. package/{es → dist/es}/lib/sdk-test-helpers.js +0 -0
  130. package/{es → dist/es}/lib/stream-to-promise.d.ts +0 -0
  131. package/{es → dist/es}/lib/stream-to-promise.js +0 -0
  132. package/{ibm-cloud-sdk-core.d.ts → dist/ibm-cloud-sdk-core.d.ts} +0 -0
  133. package/{index.d.ts → dist/index.d.ts} +0 -0
  134. package/dist/index.js +63 -0
  135. package/{lib → dist/lib}/base-service.d.ts +0 -0
  136. package/{lib → dist/lib}/base-service.js +7 -6
  137. package/{lib → dist/lib}/content-type.d.ts +0 -0
  138. package/{lib → dist/lib}/content-type.js +1 -1
  139. package/{lib → dist/lib}/get-new-logger.d.ts +0 -0
  140. package/{lib → dist/lib}/get-new-logger.js +6 -5
  141. package/{lib → dist/lib}/helper.d.ts +0 -0
  142. package/{lib → dist/lib}/helper.js +21 -18
  143. package/{lib → dist/lib}/logger.d.ts +0 -0
  144. package/{lib → dist/lib}/logger.js +1 -1
  145. package/{lib → dist/lib}/querystring.d.ts +0 -0
  146. package/{lib → dist/lib}/querystring.js +1 -1
  147. package/{lib → dist/lib}/request-wrapper.d.ts +0 -0
  148. package/{lib → dist/lib}/request-wrapper.js +54 -29
  149. package/{lib → dist/lib}/sdk-test-helpers.browser.d.ts +0 -0
  150. package/{lib → dist/lib}/sdk-test-helpers.browser.js +1 -0
  151. package/{lib → dist/lib}/sdk-test-helpers.d.ts +0 -0
  152. package/{lib → dist/lib}/sdk-test-helpers.js +8 -7
  153. package/{lib → dist/lib}/stream-to-promise.d.ts +0 -0
  154. package/{lib → dist/lib}/stream-to-promise.js +1 -0
  155. package/dist/package.json +71 -0
  156. package/package.json +40 -6
  157. package/auth/authenticators/index.js +0 -37
  158. package/auth/index.js +0 -23
  159. package/auth/utils/index.js +0 -34
  160. package/index.js +0 -43
@@ -25,13 +25,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  */
26
26
  import axios from 'axios';
27
27
  import * as rax from 'retry-axios';
28
- import axiosCookieJarSupport from 'axios-cookiejar-support';
28
+ import { wrapper as axiosCookieJarSupport } from 'axios-cookiejar-support';
29
29
  import extend from 'extend';
30
30
  import FormData from 'form-data';
31
31
  import { Agent } from 'https';
32
32
  import isStream from 'isstream';
33
33
  import { stringify } from 'querystring';
34
34
  import { gzipSync } from 'zlib';
35
+ import { CookieJar } from 'tough-cookie';
35
36
  import { buildRequestFileObject, isEmptyObject, isFileData, isFileWithMetadata, stripTrailingSlash, } from './helper';
36
37
  import logger from './logger';
37
38
  import { streamToPromise } from './stream-to-promise';
@@ -73,8 +74,15 @@ export class RequestWrapper {
73
74
  // if a cookie jar is provided, wrap the axios instance and update defaults
74
75
  if (axiosOptions.jar) {
75
76
  axiosCookieJarSupport(this.axiosInstance);
76
- this.axiosInstance.defaults.withCredentials = true;
77
- this.axiosInstance.defaults.jar = axiosOptions.jar;
77
+ // axios-cookiejar-support < 2.x accepted a boolean
78
+ // some SDKs might be using that, so create a default
79
+ // CookieJar if detecting true.
80
+ if (axiosOptions.jar === true) {
81
+ this.axiosInstance.defaults.jar = new CookieJar();
82
+ }
83
+ else {
84
+ this.axiosInstance.defaults.jar = axiosOptions.jar;
85
+ }
78
86
  }
79
87
  // get retry config properties and conditionally enable retries
80
88
  if (axiosOptions.enableRetries) {
@@ -193,7 +201,7 @@ export class RequestWrapper {
193
201
  data,
194
202
  raxConfig: this.raxConfig,
195
203
  responseType: options.responseType || 'json',
196
- paramsSerializer: (params) => stringify(params),
204
+ paramsSerializer: { serialize: (params) => stringify(params) },
197
205
  };
198
206
  return this.axiosInstance(requestParams).then((res) => {
199
207
  // sometimes error responses will still trigger the `then` block - escape that behavior here
@@ -297,7 +305,7 @@ export class RequestWrapper {
297
305
  instance: axiosInstance,
298
306
  backoffType: 'exponential',
299
307
  checkRetryAfter: true,
300
- maxRetryDelay: 30 * 1000,
308
+ maxRetryDelay: 30 * 1000, // default to 30 sec max delay
301
309
  };
302
310
  if (retryOptions) {
303
311
  if (typeof retryOptions.maxRetries === 'number') {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2019, 2021.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
+ };
43
+ var __importDefault = (this && this.__importDefault) || function (mod) {
44
+ return (mod && mod.__esModule) ? mod : { "default": mod };
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.getNewLogger = exports.unitTestUtils = exports.contentType = exports.qs = exports.BaseService = void 0;
48
+ /**
49
+ * @module ibm-cloud-sdk-core
50
+ */
51
+ var unitTestUtils = __importStar(require("./lib/sdk-test-helpers"));
52
+ exports.unitTestUtils = unitTestUtils;
53
+ var base_service_1 = require("./lib/base-service");
54
+ Object.defineProperty(exports, "BaseService", { enumerable: true, get: function () { return base_service_1.BaseService; } });
55
+ __exportStar(require("./auth"), exports);
56
+ __exportStar(require("./lib/helper"), exports);
57
+ var querystring_1 = require("./lib/querystring");
58
+ Object.defineProperty(exports, "qs", { enumerable: true, get: function () { return __importDefault(querystring_1).default; } });
59
+ var content_type_1 = require("./lib/content-type");
60
+ Object.defineProperty(exports, "contentType", { enumerable: true, get: function () { return __importDefault(content_type_1).default; } });
61
+ __exportStar(require("./lib/stream-to-promise"), exports);
62
+ var get_new_logger_1 = require("./lib/get-new-logger");
63
+ Object.defineProperty(exports, "getNewLogger", { enumerable: true, get: function () { return get_new_logger_1.getNewLogger; } });
File without changes
@@ -29,6 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.BaseService = void 0;
32
33
  var auth_1 = require("../auth");
33
34
  var helper_1 = require("./helper");
34
35
  var logger_1 = __importDefault(require("./logger"));
@@ -56,7 +57,7 @@ var BaseService = /** @class */ (function () {
56
57
  function BaseService(userOptions) {
57
58
  if (!(this instanceof BaseService)) {
58
59
  var err = 'the "new" keyword is required to create service instances';
59
- logger_1.default.error("Error creating an instance of BaseService: " + err);
60
+ logger_1.default.error("Error creating an instance of BaseService: ".concat(err));
60
61
  throw new Error(err);
61
62
  }
62
63
  var baseServiceOptions = {};
@@ -66,10 +67,10 @@ var BaseService = /** @class */ (function () {
66
67
  options.serviceUrl = options.url;
67
68
  }
68
69
  if (options.serviceUrl) {
69
- baseServiceOptions.serviceUrl = helper_1.stripTrailingSlash(options.serviceUrl);
70
+ baseServiceOptions.serviceUrl = (0, helper_1.stripTrailingSlash)(options.serviceUrl);
70
71
  }
71
72
  // check serviceUrl for common user errors
72
- var credentialProblems = auth_1.checkCredentials(options, ['serviceUrl']);
73
+ var credentialProblems = (0, auth_1.checkCredentials)(options, ['serviceUrl']);
73
74
  if (credentialProblems) {
74
75
  logger_1.default.error(credentialProblems.message);
75
76
  throw credentialProblems;
@@ -103,7 +104,7 @@ var BaseService = /** @class */ (function () {
103
104
  */
104
105
  BaseService.prototype.setServiceUrl = function (url) {
105
106
  if (url) {
106
- this.baseOptions.serviceUrl = helper_1.stripTrailingSlash(url);
107
+ this.baseOptions.serviceUrl = (0, helper_1.stripTrailingSlash)(url);
107
108
  }
108
109
  };
109
110
  /**
@@ -201,7 +202,7 @@ var BaseService = /** @class */ (function () {
201
202
  // eslint-disable-next-line class-methods-use-this
202
203
  BaseService.prototype.readOptionsFromExternalConfig = function (serviceName) {
203
204
  var results = {};
204
- var properties = auth_1.readExternalSources(serviceName);
205
+ var properties = (0, auth_1.readExternalSources)(serviceName);
205
206
  if (properties !== null) {
206
207
  // the user can define the following client-level variables in the credentials file:
207
208
  // - url
@@ -209,7 +210,7 @@ var BaseService = /** @class */ (function () {
209
210
  // - enableGzip
210
211
  var url = properties.url, disableSsl = properties.disableSsl, enableGzip = properties.enableGzip, enableRetries = properties.enableRetries, maxRetries = properties.maxRetries, retryInterval = properties.retryInterval;
211
212
  if (url) {
212
- results.serviceUrl = helper_1.stripTrailingSlash(url);
213
+ results.serviceUrl = (0, helper_1.stripTrailingSlash)(url);
213
214
  }
214
215
  if (disableSsl === true) {
215
216
  results.disableSslVerification = disableSsl;
File without changes
@@ -62,7 +62,7 @@ var fromHeader = function (buffer) {
62
62
  * @return {String|undefined}
63
63
  */
64
64
  var fromFilename = function (file) {
65
- var ext = path_1.extname(
65
+ var ext = (0, path_1.extname)(
66
66
  // eslint-disable-next-line @typescript-eslint/dot-notation
67
67
  (typeof file === 'string' && file) || file['name'] || '');
68
68
  return filenameContentTypes[ext];
File without changes
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.getNewLogger = void 0;
21
22
  var debug_1 = __importDefault(require("debug"));
22
23
  /**
23
24
  * Return a new logger, formatted with a particular name. The logging functions, in
@@ -35,11 +36,11 @@ var debug_1 = __importDefault(require("debug"));
35
36
  * @returns {SDKLogger} the new logger
36
37
  */
37
38
  function getNewLogger(moduleName) {
38
- var debug = debug_1.default(moduleName + ":debug");
39
- var error = debug_1.default(moduleName + ":error");
40
- var info = debug_1.default(moduleName + ":info");
41
- var verbose = debug_1.default(moduleName + ":verbose");
42
- var warn = debug_1.default(moduleName + ":warning");
39
+ var debug = (0, debug_1.default)("".concat(moduleName, ":debug"));
40
+ var error = (0, debug_1.default)("".concat(moduleName, ":error"));
41
+ var info = (0, debug_1.default)("".concat(moduleName, ":info"));
42
+ var verbose = (0, debug_1.default)("".concat(moduleName, ":verbose"));
43
+ var warn = (0, debug_1.default)("".concat(moduleName, ":warning"));
43
44
  // enable loggers if axios flag is set & mimic log levels severity
44
45
  if (process.env.NODE_DEBUG === 'axios') {
45
46
  debug.enabled = true;
File without changes
@@ -50,17 +50,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
51
  }
52
52
  };
53
- var __spreadArrays = (this && this.__spreadArrays) || function () {
54
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
55
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
56
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
57
- r[k] = a[j];
58
- return r;
53
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
+ if (ar || !(i in from)) {
56
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
+ ar[i] = from[i];
58
+ }
59
+ }
60
+ return to.concat(ar || Array.prototype.slice.call(from));
59
61
  };
60
62
  var __importDefault = (this && this.__importDefault) || function (mod) {
61
63
  return (mod && mod.__esModule) ? mod : { "default": mod };
62
64
  };
63
65
  Object.defineProperty(exports, "__esModule", { value: true });
66
+ exports.constructServiceUrl = exports.toLowerKeys = exports.buildRequestFileObject = exports.getFormat = exports.isHTML = exports.validateParams = exports.getMissingParams = exports.getQueryParam = exports.stripTrailingSlash = exports.getContentType = exports.isEmptyObject = exports.isFileData = exports.isFileWithMetadata = void 0;
64
67
  var isstream_1 = require("isstream");
65
68
  var mime_types_1 = require("mime-types");
66
69
  var path_1 = require("path");
@@ -71,14 +74,14 @@ function isFileObject(obj) {
71
74
  return Boolean(obj && obj.value);
72
75
  }
73
76
  function isFileStream(obj) {
74
- return Boolean(obj && isstream_1.isReadable(obj) && obj.path);
77
+ return Boolean(obj && (0, isstream_1.isReadable)(obj) && obj.path);
75
78
  }
76
79
  function isFileWithMetadata(obj) {
77
80
  return Boolean(obj && obj.data && isFileData(obj.data));
78
81
  }
79
82
  exports.isFileWithMetadata = isFileWithMetadata;
80
83
  function isFileData(obj) {
81
- return Boolean(obj && (isstream_1.isReadable(obj) || Buffer.isBuffer(obj)));
84
+ return Boolean(obj && ((0, isstream_1.isReadable)(obj) || Buffer.isBuffer(obj)));
82
85
  }
83
86
  exports.isFileData = isFileData;
84
87
  function isEmptyObject(obj) {
@@ -98,7 +101,7 @@ function getContentType(inputData) {
98
101
  case 0:
99
102
  contentType = null;
100
103
  if (!isFileStream(inputData)) return [3 /*break*/, 1];
101
- mimeType = mime_types_1.lookup(inputData.path);
104
+ mimeType = (0, mime_types_1.lookup)(inputData.path);
102
105
  contentType = { mime: mimeType || null };
103
106
  return [3 /*break*/, 3];
104
107
  case 1:
@@ -162,7 +165,7 @@ function getMissingParams(params, requires) {
162
165
  });
163
166
  }
164
167
  return missing.length > 0
165
- ? new Error("Missing required parameters: " + missing.join(', '))
168
+ ? new Error("Missing required parameters: ".concat(missing.join(', ')))
166
169
  : null;
167
170
  }
168
171
  exports.getMissingParams = getMissingParams;
@@ -210,10 +213,10 @@ function validateParams(params, requiredParams, allParams) {
210
213
  // Return an Error object identifying the errors we found.
211
214
  var errorMsg = 'Parameter validation errors:';
212
215
  if (missing.length > 0) {
213
- errorMsg += "\n Missing required parameters: " + missing.join(', ');
216
+ errorMsg += "\n Missing required parameters: ".concat(missing.join(', '));
214
217
  }
215
218
  if (invalid.length > 0) {
216
- errorMsg += "\n Found invalid parameters: " + invalid.join(', ');
219
+ errorMsg += "\n Found invalid parameters: ".concat(invalid.join(', '));
217
220
  }
218
221
  return new Error(errorMsg);
219
222
  }
@@ -234,7 +237,7 @@ function isMissing(value) {
234
237
  * @returns {boolean} true if 'text' has html tags
235
238
  */
236
239
  function isHTML(text) {
237
- logger_1.default.debug("Determining if the text " + text + " is HTML.");
240
+ logger_1.default.debug("Determining if the text ".concat(text, " is HTML."));
238
241
  return /<[a-z][\s\S]*>/i.test(text);
239
242
  }
240
243
  exports.isHTML = isHTML;
@@ -300,7 +303,7 @@ function buildRequestFileObject(fileParam) {
300
303
  filename = fileObj.value.path;
301
304
  }
302
305
  // toString handles the case when path is a buffer
303
- fileObj.options.filename = filename ? path_1.basename(filename.toString()) : '_';
306
+ fileObj.options.filename = filename ? (0, path_1.basename)(filename.toString()) : '_';
304
307
  if (!(!fileObj.options.contentType && isFileData(fileObj.value))) return [3 /*break*/, 2];
305
308
  _a = fileObj.options;
306
309
  return [4 /*yield*/, getContentType(fileObj.value)];
@@ -323,12 +326,12 @@ exports.buildRequestFileObject = buildRequestFileObject;
323
326
  function toLowerKeys(obj) {
324
327
  var lowerCaseObj = {};
325
328
  if (obj) {
326
- lowerCaseObj = Object.assign.apply(Object, __spreadArrays([{}], Object.keys(obj).map(function (key) {
329
+ lowerCaseObj = Object.assign.apply(Object, __spreadArray([{}], Object.keys(obj).map(function (key) {
327
330
  var _a;
328
331
  return (_a = {},
329
332
  _a[key.toLowerCase()] = obj[key],
330
333
  _a);
331
- })));
334
+ }), false));
332
335
  }
333
336
  return lowerCaseObj;
334
337
  }
@@ -353,7 +356,7 @@ function constructServiceUrl(parameterizedUrl, defaultUrlVariables, providedUrlV
353
356
  // Verify the provided variable names.
354
357
  providedUrlVariables.forEach(function (_, name) {
355
358
  if (!defaultUrlVariables.has(name)) {
356
- throw new Error("'" + name + "' is an invalid variable name.\n Valid variable names: [" + Array.from(defaultUrlVariables.keys()).sort() + "].");
359
+ throw new Error("'".concat(name, "' is an invalid variable name.\n Valid variable names: [").concat(Array.from(defaultUrlVariables.keys()).sort(), "]."));
357
360
  }
358
361
  });
359
362
  // Format the URL with provided or default variable values.
@@ -362,7 +365,7 @@ function constructServiceUrl(parameterizedUrl, defaultUrlVariables, providedUrlV
362
365
  // Use the default variable value if none was provided.
363
366
  var providedValue = providedUrlVariables.get(name);
364
367
  var formatValue = providedValue !== undefined ? providedValue : defaultValue;
365
- formattedUrl = formattedUrl.replace("{" + name + "}", formatValue);
368
+ formattedUrl = formattedUrl.replace("{".concat(name, "}"), formatValue);
366
369
  });
367
370
  return formattedUrl;
368
371
  }
File without changes
@@ -16,4 +16,4 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  var get_new_logger_1 = require("./get-new-logger");
19
- exports.default = get_new_logger_1.getNewLogger('ibm-cloud-sdk-core');
19
+ exports.default = (0, get_new_logger_1.getNewLogger)('ibm-cloud-sdk-core');
File without changes
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  */
24
24
  var stringify = function (queryParams) {
25
25
  return Object.keys(queryParams)
26
- .map(function (key) { return key + "=" + encodeURIComponent(queryParams[key]); })
26
+ .map(function (key) { return "".concat(key, "=").concat(encodeURIComponent(queryParams[key])); })
27
27
  .join('&');
28
28
  };
29
29
  exports.default = {
File without changes
@@ -11,6 +11,29 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  return __assign.apply(this, arguments);
13
13
  };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
14
37
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
39
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -50,14 +73,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
73
  var __importDefault = (this && this.__importDefault) || function (mod) {
51
74
  return (mod && mod.__esModule) ? mod : { "default": mod };
52
75
  };
53
- var __importStar = (this && this.__importStar) || function (mod) {
54
- if (mod && mod.__esModule) return mod;
55
- var result = {};
56
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
57
- result["default"] = mod;
58
- return result;
59
- };
60
76
  Object.defineProperty(exports, "__esModule", { value: true });
77
+ exports.RequestWrapper = void 0;
61
78
  /**
62
79
  * (C) Copyright IBM Corp. 2014, 2021.
63
80
  *
@@ -75,13 +92,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
75
92
  */
76
93
  var axios_1 = __importDefault(require("axios"));
77
94
  var rax = __importStar(require("retry-axios"));
78
- var axios_cookiejar_support_1 = __importDefault(require("axios-cookiejar-support"));
95
+ var axios_cookiejar_support_1 = require("axios-cookiejar-support");
79
96
  var extend_1 = __importDefault(require("extend"));
80
97
  var form_data_1 = __importDefault(require("form-data"));
81
98
  var https_1 = require("https");
82
99
  var isstream_1 = __importDefault(require("isstream"));
83
100
  var querystring_1 = require("querystring");
84
101
  var zlib_1 = require("zlib");
102
+ var tough_cookie_1 = require("tough-cookie");
85
103
  var helper_1 = require("./helper");
86
104
  var logger_1 = __importDefault(require("./logger"));
87
105
  var stream_to_promise_1 = require("./stream-to-promise");
@@ -96,7 +114,7 @@ var RequestWrapper = /** @class */ (function () {
96
114
  maxBodyLength: Infinity,
97
115
  };
98
116
  // merge axios config into default
99
- extend_1.default(true, axiosConfig, axiosOptions);
117
+ (0, extend_1.default)(true, axiosConfig, axiosOptions);
100
118
  // if the user explicitly sets `disableSslVerification` to true,
101
119
  // `rejectUnauthorized` must be set to false in the https agent
102
120
  if (axiosOptions.disableSslVerification === true) {
@@ -123,9 +141,16 @@ var RequestWrapper = /** @class */ (function () {
123
141
  });
124
142
  // if a cookie jar is provided, wrap the axios instance and update defaults
125
143
  if (axiosOptions.jar) {
126
- axios_cookiejar_support_1.default(this.axiosInstance);
127
- this.axiosInstance.defaults.withCredentials = true;
128
- this.axiosInstance.defaults.jar = axiosOptions.jar;
144
+ (0, axios_cookiejar_support_1.wrapper)(this.axiosInstance);
145
+ // axios-cookiejar-support < 2.x accepted a boolean
146
+ // some SDKs might be using that, so create a default
147
+ // CookieJar if detecting true.
148
+ if (axiosOptions.jar === true) {
149
+ this.axiosInstance.defaults.jar = new tough_cookie_1.CookieJar();
150
+ }
151
+ else {
152
+ this.axiosInstance.defaults.jar = axiosOptions.jar;
153
+ }
129
154
  }
130
155
  // get retry config properties and conditionally enable retries
131
156
  if (axiosOptions.enableRetries) {
@@ -180,7 +205,7 @@ var RequestWrapper = /** @class */ (function () {
180
205
  return __generator(this, function (_c) {
181
206
  switch (_c.label) {
182
207
  case 0:
183
- options = extend_1.default(true, {}, parameters.defaultOptions, parameters.options);
208
+ options = (0, extend_1.default)(true, {}, parameters.defaultOptions, parameters.options);
184
209
  path = options.path, body = options.body, form = options.form, formData = options.formData, qs = options.qs, method = options.method, serviceUrl = options.serviceUrl;
185
210
  headers = options.headers, url = options.url;
186
211
  multipartForm = new form_data_1.default();
@@ -192,7 +217,7 @@ var RequestWrapper = /** @class */ (function () {
192
217
  key = _a[_i];
193
218
  values = Array.isArray(formData[key]) ? formData[key] : [formData[key]];
194
219
  // Skip keys with undefined/null values or empty object value
195
- values = values.filter(function (v) { return v != null && !helper_1.isEmptyObject(v); });
220
+ values = values.filter(function (v) { return v != null && !(0, helper_1.isEmptyObject)(v); });
196
221
  _b = 0, values_1 = values;
197
222
  _c.label = 2;
198
223
  case 2:
@@ -200,14 +225,14 @@ var RequestWrapper = /** @class */ (function () {
200
225
  value = values_1[_b];
201
226
  if (!(!Object.prototype.hasOwnProperty.call(value, 'contentType') ||
202
227
  Object.prototype.hasOwnProperty.call(value, 'data'))) return [3 /*break*/, 5];
203
- if (!helper_1.isFileWithMetadata(value)) return [3 /*break*/, 4];
204
- return [4 /*yield*/, helper_1.buildRequestFileObject(value)];
228
+ if (!(0, helper_1.isFileWithMetadata)(value)) return [3 /*break*/, 4];
229
+ return [4 /*yield*/, (0, helper_1.buildRequestFileObject)(value)];
205
230
  case 3:
206
231
  fileObj = _c.sent();
207
232
  multipartForm.append(key, fileObj.value, fileObj.options);
208
233
  return [3 /*break*/, 5];
209
234
  case 4:
210
- if (typeof value === 'object' && !helper_1.isFileData(value)) {
235
+ if (typeof value === 'object' && !(0, helper_1.isFileData)(value)) {
211
236
  value = JSON.stringify(value);
212
237
  }
213
238
  multipartForm.append(key, value);
@@ -233,18 +258,18 @@ var RequestWrapper = /** @class */ (function () {
233
258
  }
234
259
  // Add service default endpoint if options.url start with /
235
260
  if (url && url.charAt(0) === '/') {
236
- url = helper_1.stripTrailingSlash(serviceUrl) + url;
261
+ url = (0, helper_1.stripTrailingSlash)(serviceUrl) + url;
237
262
  }
238
- url = helper_1.stripTrailingSlash(url);
263
+ url = (0, helper_1.stripTrailingSlash)(url);
239
264
  data = body;
240
265
  if (form) {
241
- data = querystring_1.stringify(form);
266
+ data = (0, querystring_1.stringify)(form);
242
267
  headers['Content-type'] = 'application/x-www-form-urlencoded';
243
268
  }
244
269
  if (formData) {
245
270
  data = multipartForm;
246
271
  // form-data generates headers that MUST be included or the request will fail
247
- headers = extend_1.default(true, {}, headers, multipartForm.getHeaders());
272
+ headers = (0, extend_1.default)(true, {}, headers, multipartForm.getHeaders());
248
273
  }
249
274
  // accept gzip encoded responses if Accept-Encoding is not already set
250
275
  headers['Accept-Encoding'] = headers['Accept-Encoding'] || 'gzip';
@@ -262,7 +287,7 @@ var RequestWrapper = /** @class */ (function () {
262
287
  data: data,
263
288
  raxConfig: this.raxConfig,
264
289
  responseType: options.responseType || 'json',
265
- paramsSerializer: function (params) { return querystring_1.stringify(params); },
290
+ paramsSerializer: { serialize: function (params) { return (0, querystring_1.stringify)(params); } },
266
291
  };
267
292
  return [2 /*return*/, this.axiosInstance(requestParams).then(function (res) {
268
293
  // sometimes error responses will still trigger the `then` block - escape that behavior here
@@ -321,7 +346,7 @@ var RequestWrapper = /** @class */ (function () {
321
346
  // ignore the error, use the object, and tack on a warning
322
347
  errorBody = axiosError.data;
323
348
  errorBody.warning = 'Body contains circular reference';
324
- logger_1.default.error("Failed to stringify axiosError: " + e);
349
+ logger_1.default.error("Failed to stringify axiosError: ".concat(e));
325
350
  }
326
351
  error.body = errorBody;
327
352
  // attach headers to error object
@@ -368,7 +393,7 @@ var RequestWrapper = /** @class */ (function () {
368
393
  instance: axiosInstance,
369
394
  backoffType: 'exponential',
370
395
  checkRetryAfter: true,
371
- maxRetryDelay: 30 * 1000,
396
+ maxRetryDelay: 30 * 1000, // default to 30 sec max delay
372
397
  };
373
398
  if (retryOptions) {
374
399
  if (typeof retryOptions.maxRetries === 'number') {
@@ -410,8 +435,8 @@ var RequestWrapper = /** @class */ (function () {
410
435
  _a.label = 1;
411
436
  case 1:
412
437
  _a.trys.push([1, 5, , 6]);
413
- if (!isstream_1.default(data)) return [3 /*break*/, 3];
414
- return [4 /*yield*/, stream_to_promise_1.streamToPromise(data)];
438
+ if (!(0, isstream_1.default)(data)) return [3 /*break*/, 3];
439
+ return [4 /*yield*/, (0, stream_to_promise_1.streamToPromise)(data)];
415
440
  case 2:
416
441
  streamData = _a.sent();
417
442
  reqBuffer = Buffer.isBuffer(streamData) ? streamData : Buffer.from(streamData);
@@ -436,7 +461,7 @@ var RequestWrapper = /** @class */ (function () {
436
461
  return [2 /*return*/, data];
437
462
  case 6:
438
463
  try {
439
- data = zlib_1.gzipSync(reqBuffer);
464
+ data = (0, zlib_1.gzipSync)(reqBuffer);
440
465
  // update the headers by reference - only if the data was actually compressed
441
466
  headers['Content-Encoding'] = 'gzip';
442
467
  }
@@ -466,7 +491,7 @@ function parsePath(path, params) {
466
491
  }
467
492
  return Object.keys(params).reduce(function (parsedPath, param) {
468
493
  var value = encodeURIComponent(params[param]);
469
- return parsedPath.replace(new RegExp("{" + param + "}"), value);
494
+ return parsedPath.replace(new RegExp("{".concat(param, "}")), value);
470
495
  }, path);
471
496
  }
472
497
  /**
@@ -537,6 +562,6 @@ function parseServiceErrorMessage(response) {
537
562
  else if (hasStringProperty(response, 'errorMessage')) {
538
563
  message = response.errorMessage;
539
564
  }
540
- logger_1.default.info("Parsing service error message: " + message);
565
+ logger_1.default.info("Parsing service error message: ".concat(message));
541
566
  return message;
542
567
  }
File without changes
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.expectToBePromise = exports.getOptions = exports.checkForSuccessfulExecution = exports.checkUserHeader = exports.checkMediaHeaders = exports.checkUrlAndMethod = void 0;
4
5
  /**
5
6
  * Copyright 2021 IBM Corp. All Rights Reserved.
6
7
  *
File without changes