ibm-cloud-sdk-core 3.2.0 → 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 (161) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/{auth → dist/auth}/authenticators/authenticator-interface.d.ts +0 -0
  3. package/{auth → dist/auth}/authenticators/authenticator-interface.js +0 -0
  4. package/{auth → dist/auth}/authenticators/authenticator.d.ts +0 -0
  5. package/{auth → dist/auth}/authenticators/authenticator.js +1 -0
  6. package/{auth → dist/auth}/authenticators/basic-authenticator.d.ts +0 -0
  7. package/{auth → dist/auth}/authenticators/basic-authenticator.js +7 -4
  8. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.d.ts +0 -0
  9. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.js +7 -4
  10. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  11. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.js +4 -1
  12. package/{auth → dist/auth}/authenticators/container-authenticator.d.ts +0 -0
  13. package/{auth → dist/auth}/authenticators/container-authenticator.js +4 -1
  14. package/{auth → dist/auth}/authenticators/iam-authenticator.d.ts +0 -0
  15. package/{auth → dist/auth}/authenticators/iam-authenticator.js +5 -2
  16. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.d.ts +0 -0
  17. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.js +4 -1
  18. package/{auth → dist/auth}/authenticators/index.d.ts +0 -0
  19. package/dist/auth/authenticators/index.js +38 -0
  20. package/{auth → dist/auth}/authenticators/no-auth-authenticator.d.ts +0 -0
  21. package/{auth → dist/auth}/authenticators/no-auth-authenticator.js +4 -1
  22. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.d.ts +0 -0
  23. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.js +6 -3
  24. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.d.ts +0 -0
  25. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.js +4 -1
  26. package/{auth → dist/auth}/index.d.ts +0 -0
  27. package/dist/auth/index.js +34 -0
  28. package/{auth → dist/auth}/token-managers/container-token-manager.d.ts +0 -0
  29. package/{auth → dist/auth}/token-managers/container-token-manager.js +7 -4
  30. package/{auth → dist/auth}/token-managers/cp4d-token-manager.d.ts +0 -0
  31. package/{auth → dist/auth}/token-managers/cp4d-token-manager.js +6 -3
  32. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.d.ts +0 -0
  33. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.js +9 -6
  34. package/{auth → dist/auth}/token-managers/iam-token-manager.d.ts +0 -0
  35. package/{auth → dist/auth}/token-managers/iam-token-manager.js +5 -2
  36. package/{auth → dist/auth}/token-managers/index.d.ts +0 -0
  37. package/{auth → dist/auth}/token-managers/index.js +8 -7
  38. package/{auth → dist/auth}/token-managers/jwt-token-manager.d.ts +0 -0
  39. package/{auth → dist/auth}/token-managers/jwt-token-manager.js +5 -2
  40. package/{auth → dist/auth}/token-managers/token-manager.d.ts +0 -0
  41. package/{auth → dist/auth}/token-managers/token-manager.js +5 -4
  42. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.d.ts +0 -0
  43. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.js +11 -8
  44. package/{auth → dist/auth}/utils/file-reading-helpers.browser.d.ts +0 -0
  45. package/{auth → dist/auth}/utils/file-reading-helpers.browser.js +1 -0
  46. package/{auth → dist/auth}/utils/file-reading-helpers.d.ts +0 -0
  47. package/{auth → dist/auth}/utils/file-reading-helpers.js +12 -11
  48. package/{auth → dist/auth}/utils/get-authenticator-from-environment.d.ts +0 -0
  49. package/{auth → dist/auth}/utils/get-authenticator-from-environment.js +3 -2
  50. package/{auth → dist/auth}/utils/helpers.d.ts +0 -0
  51. package/{auth → dist/auth}/utils/helpers.js +5 -4
  52. package/{auth → dist/auth}/utils/index.d.ts +0 -0
  53. package/dist/auth/utils/index.js +46 -0
  54. package/{auth → dist/auth}/utils/read-external-sources.d.ts +0 -0
  55. package/{auth → dist/auth}/utils/read-external-sources.js +6 -5
  56. package/{docs → dist/docs}/ibm-cloud-sdk-core.api.json +0 -0
  57. package/{es → dist/es}/auth/authenticators/authenticator-interface.d.ts +0 -0
  58. package/{es → dist/es}/auth/authenticators/authenticator-interface.js +1 -0
  59. package/{es → dist/es}/auth/authenticators/authenticator.d.ts +0 -0
  60. package/{es → dist/es}/auth/authenticators/authenticator.js +0 -0
  61. package/{es → dist/es}/auth/authenticators/basic-authenticator.d.ts +0 -0
  62. package/{es → dist/es}/auth/authenticators/basic-authenticator.js +0 -0
  63. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.d.ts +0 -0
  64. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.js +0 -0
  65. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  66. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.js +0 -0
  67. package/{es → dist/es}/auth/authenticators/container-authenticator.d.ts +0 -0
  68. package/{es → dist/es}/auth/authenticators/container-authenticator.js +0 -0
  69. package/{es → dist/es}/auth/authenticators/iam-authenticator.d.ts +0 -0
  70. package/{es → dist/es}/auth/authenticators/iam-authenticator.js +0 -0
  71. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.d.ts +0 -0
  72. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.js +0 -0
  73. package/{es → dist/es}/auth/authenticators/index.d.ts +0 -0
  74. package/{es → dist/es}/auth/authenticators/index.js +0 -0
  75. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.d.ts +0 -0
  76. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.js +0 -0
  77. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.d.ts +0 -0
  78. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.js +0 -0
  79. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.d.ts +0 -0
  80. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.js +0 -0
  81. package/{es → dist/es}/auth/index.d.ts +0 -0
  82. package/{es → dist/es}/auth/index.js +0 -0
  83. package/{es → dist/es}/auth/token-managers/container-token-manager.d.ts +0 -0
  84. package/{es → dist/es}/auth/token-managers/container-token-manager.js +0 -0
  85. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.d.ts +0 -0
  86. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.js +0 -0
  87. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.d.ts +0 -0
  88. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.js +0 -0
  89. package/{es → dist/es}/auth/token-managers/iam-token-manager.d.ts +0 -0
  90. package/{es → dist/es}/auth/token-managers/iam-token-manager.js +0 -0
  91. package/{es → dist/es}/auth/token-managers/index.d.ts +0 -0
  92. package/{es → dist/es}/auth/token-managers/index.js +0 -0
  93. package/{es → dist/es}/auth/token-managers/jwt-token-manager.d.ts +0 -0
  94. package/{es → dist/es}/auth/token-managers/jwt-token-manager.js +0 -0
  95. package/{es → dist/es}/auth/token-managers/token-manager.d.ts +0 -0
  96. package/{es → dist/es}/auth/token-managers/token-manager.js +0 -0
  97. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.d.ts +0 -0
  98. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.js +0 -0
  99. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.d.ts +0 -0
  100. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.js +0 -0
  101. package/{es → dist/es}/auth/utils/file-reading-helpers.d.ts +0 -0
  102. package/{es → dist/es}/auth/utils/file-reading-helpers.js +0 -0
  103. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.d.ts +0 -0
  104. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.js +0 -0
  105. package/{es → dist/es}/auth/utils/helpers.d.ts +0 -0
  106. package/{es → dist/es}/auth/utils/helpers.js +0 -0
  107. package/{es → dist/es}/auth/utils/index.d.ts +0 -0
  108. package/{es → dist/es}/auth/utils/index.js +0 -0
  109. package/{es → dist/es}/auth/utils/read-external-sources.d.ts +0 -0
  110. package/{es → dist/es}/auth/utils/read-external-sources.js +0 -0
  111. package/{es → dist/es}/index.d.ts +0 -0
  112. package/{es → dist/es}/index.js +0 -0
  113. package/{es → dist/es}/lib/base-service.d.ts +0 -0
  114. package/{es → dist/es}/lib/base-service.js +0 -0
  115. package/{es → dist/es}/lib/content-type.d.ts +0 -0
  116. package/{es → dist/es}/lib/content-type.js +0 -0
  117. package/{es → dist/es}/lib/get-new-logger.d.ts +0 -0
  118. package/{es → dist/es}/lib/get-new-logger.js +0 -0
  119. package/{es → dist/es}/lib/helper.d.ts +0 -0
  120. package/{es → dist/es}/lib/helper.js +0 -0
  121. package/{es → dist/es}/lib/logger.d.ts +0 -0
  122. package/{es → dist/es}/lib/logger.js +0 -0
  123. package/{es → dist/es}/lib/querystring.d.ts +0 -0
  124. package/{es → dist/es}/lib/querystring.js +0 -0
  125. package/{es → dist/es}/lib/request-wrapper.d.ts +0 -0
  126. package/{es → dist/es}/lib/request-wrapper.js +31 -25
  127. package/{es → dist/es}/lib/sdk-test-helpers.browser.d.ts +0 -0
  128. package/{es → dist/es}/lib/sdk-test-helpers.browser.js +0 -0
  129. package/{es → dist/es}/lib/sdk-test-helpers.d.ts +0 -0
  130. package/{es → dist/es}/lib/sdk-test-helpers.js +0 -0
  131. package/{es → dist/es}/lib/stream-to-promise.d.ts +0 -0
  132. package/{es → dist/es}/lib/stream-to-promise.js +0 -0
  133. package/{ibm-cloud-sdk-core.d.ts → dist/ibm-cloud-sdk-core.d.ts} +0 -0
  134. package/{index.d.ts → dist/index.d.ts} +0 -0
  135. package/dist/index.js +63 -0
  136. package/{lib → dist/lib}/base-service.d.ts +0 -0
  137. package/{lib → dist/lib}/base-service.js +7 -6
  138. package/{lib → dist/lib}/content-type.d.ts +0 -0
  139. package/{lib → dist/lib}/content-type.js +1 -1
  140. package/{lib → dist/lib}/get-new-logger.d.ts +0 -0
  141. package/{lib → dist/lib}/get-new-logger.js +6 -5
  142. package/{lib → dist/lib}/helper.d.ts +0 -0
  143. package/{lib → dist/lib}/helper.js +21 -18
  144. package/{lib → dist/lib}/logger.d.ts +0 -0
  145. package/{lib → dist/lib}/logger.js +1 -1
  146. package/{lib → dist/lib}/querystring.d.ts +0 -0
  147. package/{lib → dist/lib}/querystring.js +1 -1
  148. package/{lib → dist/lib}/request-wrapper.d.ts +0 -0
  149. package/{lib → dist/lib}/request-wrapper.js +92 -67
  150. package/{lib → dist/lib}/sdk-test-helpers.browser.d.ts +0 -0
  151. package/{lib → dist/lib}/sdk-test-helpers.browser.js +1 -0
  152. package/{lib → dist/lib}/sdk-test-helpers.d.ts +0 -0
  153. package/{lib → dist/lib}/sdk-test-helpers.js +8 -7
  154. package/{lib → dist/lib}/stream-to-promise.d.ts +0 -0
  155. package/{lib → dist/lib}/stream-to-promise.js +1 -0
  156. package/dist/package.json +71 -0
  157. package/package.json +40 -6
  158. package/auth/authenticators/index.js +0 -37
  159. package/auth/index.js +0 -23
  160. package/auth/utils/index.js +0 -34
  161. package/index.js +0 -43
@@ -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) {
@@ -175,50 +200,50 @@ var RequestWrapper = /** @class */ (function () {
175
200
  */
176
201
  RequestWrapper.prototype.sendRequest = function (parameters) {
177
202
  return __awaiter(this, void 0, void 0, function () {
178
- var options, path, body, form, formData, qs, method, serviceUrl, headers, url, multipartForm, data, requestParams;
203
+ var options, path, body, form, formData, qs, method, serviceUrl, headers, url, multipartForm, _i, _a, key, values, _b, values_1, value, fileObj, data, requestParams;
179
204
  var _this = this;
180
- return __generator(this, function (_a) {
181
- switch (_a.label) {
205
+ return __generator(this, function (_c) {
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();
187
- // Form params
188
- if (formData) {
189
- Object.keys(formData).forEach(function (key) {
190
- var values = Array.isArray(formData[key]) ? formData[key] : [formData[key]];
191
- // Skip keys with undefined/null values or empty object value
192
- values
193
- .filter(function (v) { return v != null && !helper_1.isEmptyObject(v); })
194
- .forEach(function (value) { return __awaiter(_this, void 0, void 0, function () {
195
- var fileObj;
196
- return __generator(this, function (_a) {
197
- switch (_a.label) {
198
- case 0:
199
- // Special case of empty file object
200
- if (Object.prototype.hasOwnProperty.call(value, 'contentType') &&
201
- !Object.prototype.hasOwnProperty.call(value, 'data')) {
202
- return [2 /*return*/];
203
- }
204
- if (!helper_1.isFileWithMetadata(value)) return [3 /*break*/, 2];
205
- return [4 /*yield*/, helper_1.buildRequestFileObject(value)];
206
- case 1:
207
- fileObj = _a.sent();
208
- multipartForm.append(key, fileObj.value, fileObj.options);
209
- return [3 /*break*/, 3];
210
- case 2:
211
- if (typeof value === 'object' && !helper_1.isFileData(value)) {
212
- value = JSON.stringify(value);
213
- }
214
- multipartForm.append(key, value);
215
- _a.label = 3;
216
- case 3: return [2 /*return*/];
217
- }
218
- });
219
- }); });
220
- });
212
+ if (!formData) return [3 /*break*/, 7];
213
+ _i = 0, _a = Object.keys(formData);
214
+ _c.label = 1;
215
+ case 1:
216
+ if (!(_i < _a.length)) return [3 /*break*/, 7];
217
+ key = _a[_i];
218
+ values = Array.isArray(formData[key]) ? formData[key] : [formData[key]];
219
+ // Skip keys with undefined/null values or empty object value
220
+ values = values.filter(function (v) { return v != null && !(0, helper_1.isEmptyObject)(v); });
221
+ _b = 0, values_1 = values;
222
+ _c.label = 2;
223
+ case 2:
224
+ if (!(_b < values_1.length)) return [3 /*break*/, 6];
225
+ value = values_1[_b];
226
+ if (!(!Object.prototype.hasOwnProperty.call(value, 'contentType') ||
227
+ Object.prototype.hasOwnProperty.call(value, 'data'))) return [3 /*break*/, 5];
228
+ if (!(0, helper_1.isFileWithMetadata)(value)) return [3 /*break*/, 4];
229
+ return [4 /*yield*/, (0, helper_1.buildRequestFileObject)(value)];
230
+ case 3:
231
+ fileObj = _c.sent();
232
+ multipartForm.append(key, fileObj.value, fileObj.options);
233
+ return [3 /*break*/, 5];
234
+ case 4:
235
+ if (typeof value === 'object' && !(0, helper_1.isFileData)(value)) {
236
+ value = JSON.stringify(value);
221
237
  }
238
+ multipartForm.append(key, value);
239
+ _c.label = 5;
240
+ case 5:
241
+ _b++;
242
+ return [3 /*break*/, 2];
243
+ case 6:
244
+ _i++;
245
+ return [3 /*break*/, 1];
246
+ case 7:
222
247
  // Path params
223
248
  url = parsePath(url, path);
224
249
  // Headers
@@ -233,27 +258,27 @@ 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';
251
- if (!this.compressRequestData) return [3 /*break*/, 2];
276
+ if (!this.compressRequestData) return [3 /*break*/, 9];
252
277
  return [4 /*yield*/, this.gzipRequestBody(data, headers)];
253
- case 1:
254
- data = _a.sent();
255
- _a.label = 2;
256
- case 2:
278
+ case 8:
279
+ data = _c.sent();
280
+ _c.label = 9;
281
+ case 9:
257
282
  requestParams = {
258
283
  url: url,
259
284
  method: method,
@@ -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
@@ -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.expectToBePromise = exports.getOptions = exports.checkForSuccessfulExecution = exports.checkUserHeader = exports.checkMediaHeaders = exports.checkUrlAndMethod = void 0;
21
22
  var expect_1 = __importDefault(require("expect"));
22
23
  /**
23
24
  * This module provides a set of helper methods used to reduce code duplication in the generated unit tests
@@ -34,8 +35,8 @@ var expect_1 = __importDefault(require("expect"));
34
35
  * @returns {void}
35
36
  */
36
37
  function checkUrlAndMethod(options, url, method) {
37
- expect_1.default(options.url).toEqual(url);
38
- expect_1.default(options.method).toEqual(method);
38
+ (0, expect_1.default)(options.url).toEqual(url);
39
+ (0, expect_1.default)(options.method).toEqual(method);
39
40
  }
40
41
  exports.checkUrlAndMethod = checkUrlAndMethod;
41
42
  /**
@@ -50,8 +51,8 @@ exports.checkUrlAndMethod = checkUrlAndMethod;
50
51
  */
51
52
  function checkMediaHeaders(createRequestMock, accept, contentType) {
52
53
  var headers = createRequestMock.mock.calls[0][0].defaultOptions.headers;
53
- expect_1.default(headers.Accept).toEqual(accept);
54
- expect_1.default(headers['Content-Type']).toEqual(contentType);
54
+ (0, expect_1.default)(headers.Accept).toEqual(accept);
55
+ (0, expect_1.default)(headers['Content-Type']).toEqual(contentType);
55
56
  }
56
57
  exports.checkMediaHeaders = checkMediaHeaders;
57
58
  /**
@@ -66,7 +67,7 @@ exports.checkMediaHeaders = checkMediaHeaders;
66
67
  */
67
68
  function checkUserHeader(createRequestMock, userHeaderName, userHeaderValue) {
68
69
  var headers = createRequestMock.mock.calls[0][0].defaultOptions.headers;
69
- expect_1.default(headers[userHeaderName]).toEqual(userHeaderValue);
70
+ (0, expect_1.default)(headers[userHeaderName]).toEqual(userHeaderValue);
70
71
  }
71
72
  exports.checkUserHeader = checkUserHeader;
72
73
  /**
@@ -78,7 +79,7 @@ exports.checkUserHeader = checkUserHeader;
78
79
  */
79
80
  function checkForSuccessfulExecution(createRequestMock) {
80
81
  var sdkParams = createRequestMock.mock.calls[0][0];
81
- expect_1.default(typeof sdkParams).toEqual('object');
82
+ (0, expect_1.default)(typeof sdkParams).toEqual('object');
82
83
  }
83
84
  exports.checkForSuccessfulExecution = checkForSuccessfulExecution;
84
85
  /**
@@ -101,6 +102,6 @@ exports.getOptions = getOptions;
101
102
  * @returns {void}
102
103
  */
103
104
  function expectToBePromise(sdkPromise) {
104
- expect_1.default(typeof sdkPromise.then).toBe('function');
105
+ (0, expect_1.default)(typeof sdkPromise.then).toBe('function');
105
106
  }
106
107
  exports.expectToBePromise = expectToBePromise;
File without changes
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.streamToPromise = void 0;
18
19
  /**
19
20
  * 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
21
  * or array of text chunks
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "ibm-cloud-sdk-core",
3
+ "version": "3.2.1",
4
+ "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
+ "main": "./index.js",
6
+ "typings": "./es/index.d.ts",
7
+ "sideEffects": false,
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/IBM/node-sdk-core.git"
11
+ },
12
+ "keywords": [
13
+ "ibm",
14
+ "sdk",
15
+ "openapi",
16
+ "core"
17
+ ],
18
+ "author": "IBM Corp.",
19
+ "contributors": [
20
+ {
21
+ "name": "German Attanasio Ruiz",
22
+ "email": "germanatt@us.ibm.com"
23
+ },
24
+ {
25
+ "name": "Dustin Popp",
26
+ "email": "dustinpopp@ibm.com"
27
+ },
28
+ {
29
+ "name": "Phil Adams",
30
+ "email": "phil_adams@us.ibm.com"
31
+ }
32
+ ],
33
+ "license": "Apache-2.0",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/IBM/node-sdk-core/issues"
39
+ },
40
+ "dependencies": {
41
+ "@types/file-type": "~5.2.1",
42
+ "@types/isstream": "^0.1.0",
43
+ "@types/node": "~10.14.19",
44
+ "@types/tough-cookie": "^4.0.0",
45
+ "axios": "1.2.0",
46
+ "axios-cookiejar-support": "4.0.3",
47
+ "camelcase": "^5.3.1",
48
+ "debug": "^4.1.1",
49
+ "dotenv": "^6.2.0",
50
+ "expect": "^26.1.0",
51
+ "extend": "^3.0.2",
52
+ "file-type": "16.5.4",
53
+ "form-data": "^2.3.3",
54
+ "isstream": "~0.1.2",
55
+ "jsonwebtoken": "^8.5.1",
56
+ "lodash.isempty": "^4.4.0",
57
+ "mime-types": "~2.1.18",
58
+ "object.omit": "~3.0.0",
59
+ "object.pick": "~1.3.0",
60
+ "retry-axios": "^2.6.0",
61
+ "semver": "^6.2.0",
62
+ "tough-cookie": "^4.0.0"
63
+ },
64
+ "browser": {
65
+ "./auth/utils/read-credentials-file": "./auth/utils/read-credentials-file.browser",
66
+ "./lib/sdk-test-helpers": "./lib/sdk-test-helpers.browser"
67
+ },
68
+ "engines": {
69
+ "node": ">=14"
70
+ }
71
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "3.2.0",
3
+ "version": "3.2.2-beta",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
- "main": "index.js",
5
+ "main": "./index.js",
6
6
  "typings": "./es/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "repository": {
@@ -37,13 +37,47 @@
37
37
  "bugs": {
38
38
  "url": "https://github.com/IBM/node-sdk-core/issues"
39
39
  },
40
+ "devDependencies": {
41
+ "@commitlint/cli": "^12.0.1",
42
+ "@commitlint/config-conventional": "^7.0.1",
43
+ "@masterodin/publisher": "^0.10.0",
44
+ "@microsoft/api-documenter": "^7.17.0",
45
+ "@microsoft/api-extractor": "^7.20.0",
46
+ "@semantic-release/changelog": "6.0.1",
47
+ "@semantic-release/git": "10.0.1",
48
+ "@types/debug": "^4.1.7",
49
+ "@types/extend": "^3.0.1",
50
+ "@types/lodash.isempty": "^4.4.6",
51
+ "@types/mime-types": "^2.1.1",
52
+ "@typescript-eslint/eslint-plugin": "^4.24.0",
53
+ "@typescript-eslint/parser": "^4.24.0",
54
+ "dependency-lint": "~5.0.1",
55
+ "eslint": "^7.26.0",
56
+ "eslint-config-airbnb-base": "^14.2.1",
57
+ "eslint-config-airbnb-typescript": "^12.3.1",
58
+ "eslint-config-prettier": "^8.3.0",
59
+ "eslint-plugin-import": "^2.23.2",
60
+ "eslint-plugin-jest": "^24.3.6",
61
+ "eslint-plugin-jsdoc": "^34.6.3",
62
+ "eslint-plugin-node": "^9.0.0",
63
+ "eslint-plugin-prettier": "^3.0.1",
64
+ "jest": "^29.3.1",
65
+ "nock": "^13.1.2",
66
+ "npm-run-all": "^4.1.5",
67
+ "object.assign": "~4.1.0",
68
+ "package-json-reducer": "^1.0.18",
69
+ "prettier": "~2.3.0",
70
+ "rimraf": "^3.0.2",
71
+ "semantic-release": "19.0.3",
72
+ "typescript": "4.8.4"
73
+ },
40
74
  "dependencies": {
41
75
  "@types/file-type": "~5.2.1",
42
76
  "@types/isstream": "^0.1.0",
43
77
  "@types/node": "~10.14.19",
44
78
  "@types/tough-cookie": "^4.0.0",
45
- "axios": "^0.26.1",
46
- "axios-cookiejar-support": "^1.0.0",
79
+ "axios": "1.2.0",
80
+ "axios-cookiejar-support": "4.0.3",
47
81
  "camelcase": "^5.3.1",
48
82
  "debug": "^4.1.1",
49
83
  "dotenv": "^6.2.0",
@@ -66,7 +100,7 @@
66
100
  "./lib/sdk-test-helpers": "./lib/sdk-test-helpers.browser"
67
101
  },
68
102
  "engines": {
69
- "node": ">=12"
103
+ "node": ">=14"
70
104
  },
71
105
  "scripts": {
72
106
  "clean": "rm -fr node_modules",
@@ -97,4 +131,4 @@
97
131
  "coverageDirectory": "./coverage/",
98
132
  "testEnvironment": "node"
99
133
  }
100
- }
134
+ }
@@ -1,37 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- var authenticator_1 = require("./authenticator");
19
- exports.Authenticator = authenticator_1.Authenticator;
20
- var basic_authenticator_1 = require("./basic-authenticator");
21
- exports.BasicAuthenticator = basic_authenticator_1.BasicAuthenticator;
22
- var bearer_token_authenticator_1 = require("./bearer-token-authenticator");
23
- exports.BearerTokenAuthenticator = bearer_token_authenticator_1.BearerTokenAuthenticator;
24
- var cloud_pak_for_data_authenticator_1 = require("./cloud-pak-for-data-authenticator");
25
- exports.CloudPakForDataAuthenticator = cloud_pak_for_data_authenticator_1.CloudPakForDataAuthenticator;
26
- var iam_authenticator_1 = require("./iam-authenticator");
27
- exports.IamAuthenticator = iam_authenticator_1.IamAuthenticator;
28
- var container_authenticator_1 = require("./container-authenticator");
29
- exports.ContainerAuthenticator = container_authenticator_1.ContainerAuthenticator;
30
- var no_auth_authenticator_1 = require("./no-auth-authenticator");
31
- exports.NoAuthAuthenticator = no_auth_authenticator_1.NoAuthAuthenticator;
32
- var iam_request_based_authenticator_1 = require("./iam-request-based-authenticator");
33
- exports.IamRequestBasedAuthenticator = iam_request_based_authenticator_1.IamRequestBasedAuthenticator;
34
- var token_request_based_authenticator_1 = require("./token-request-based-authenticator");
35
- exports.TokenRequestBasedAuthenticator = token_request_based_authenticator_1.TokenRequestBasedAuthenticator;
36
- var vpc_instance_authenticator_1 = require("./vpc-instance-authenticator");
37
- exports.VpcInstanceAuthenticator = vpc_instance_authenticator_1.VpcInstanceAuthenticator;
package/auth/index.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright 2019 IBM Corp. All Rights Reserved.
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
- function __export(m) {
18
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
19
- }
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- __export(require("./authenticators"));
22
- __export(require("./token-managers"));
23
- __export(require("./utils"));
@@ -1,34 +0,0 @@
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
- function __export(m) {
18
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
19
- }
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- /**
22
- * @module utils
23
- * Helper functions used by generated SDKs.
24
- *
25
- * functions:
26
- * getAuthenticatorFromEnvironment: Get authenticator from external sources.
27
- * readExternalSources: Get config object from external sources.
28
- */
29
- __export(require("./helpers"));
30
- __export(require("./file-reading-helpers"));
31
- var get_authenticator_from_environment_1 = require("./get-authenticator-from-environment");
32
- exports.getAuthenticatorFromEnvironment = get_authenticator_from_environment_1.getAuthenticatorFromEnvironment;
33
- var read_external_sources_1 = require("./read-external-sources");
34
- exports.readExternalSources = read_external_sources_1.readExternalSources;
package/index.js DELETED
@@ -1,43 +0,0 @@
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
- function __export(m) {
18
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
19
- }
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
24
- result["default"] = mod;
25
- return result;
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- /**
29
- * @module ibm-cloud-sdk-core
30
- */
31
- var unitTestUtils = __importStar(require("./lib/sdk-test-helpers"));
32
- exports.unitTestUtils = unitTestUtils;
33
- var base_service_1 = require("./lib/base-service");
34
- exports.BaseService = base_service_1.BaseService;
35
- __export(require("./auth"));
36
- __export(require("./lib/helper"));
37
- var querystring_1 = require("./lib/querystring");
38
- exports.qs = querystring_1.default;
39
- var content_type_1 = require("./lib/content-type");
40
- exports.contentType = content_type_1.default;
41
- __export(require("./lib/stream-to-promise"));
42
- var get_new_logger_1 = require("./lib/get-new-logger");
43
- exports.getNewLogger = get_new_logger_1.getNewLogger;