ibm-cloud-sdk-core 4.0.0 → 4.0.2

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 (233) hide show
  1. package/.secrets.baseline +20 -30
  2. package/CHANGELOG.md +16 -4
  3. package/MIGRATION-V4.md +54 -0
  4. package/auth/authenticators/authenticator-interface.d.ts +3 -4
  5. package/auth/authenticators/authenticator-interface.js +1 -1
  6. package/auth/authenticators/authenticator.d.ts +5 -9
  7. package/auth/authenticators/authenticator.js +4 -8
  8. package/auth/authenticators/basic-authenticator.d.ts +12 -12
  9. package/auth/authenticators/basic-authenticator.js +12 -12
  10. package/auth/authenticators/bearer-token-authenticator.d.ts +11 -14
  11. package/auth/authenticators/bearer-token-authenticator.js +11 -14
  12. package/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +15 -15
  13. package/auth/authenticators/cloud-pak-for-data-authenticator.js +15 -15
  14. package/auth/authenticators/container-authenticator.d.ts +23 -23
  15. package/auth/authenticators/container-authenticator.js +23 -23
  16. package/auth/authenticators/iam-authenticator.d.ts +20 -20
  17. package/auth/authenticators/iam-authenticator.js +20 -20
  18. package/auth/authenticators/iam-request-based-authenticator.d.ts +23 -25
  19. package/auth/authenticators/iam-request-based-authenticator.js +23 -25
  20. package/auth/authenticators/token-request-based-authenticator.d.ts +19 -24
  21. package/auth/authenticators/token-request-based-authenticator.js +19 -24
  22. package/auth/authenticators/vpc-instance-authenticator.d.ts +17 -16
  23. package/auth/authenticators/vpc-instance-authenticator.js +17 -16
  24. package/auth/token-managers/container-token-manager.d.ts +23 -25
  25. package/auth/token-managers/container-token-manager.js +23 -25
  26. package/auth/token-managers/cp4d-token-manager.d.ts +13 -13
  27. package/auth/token-managers/cp4d-token-manager.js +13 -13
  28. package/auth/token-managers/iam-request-based-token-manager.d.ts +26 -31
  29. package/auth/token-managers/iam-request-based-token-manager.js +26 -31
  30. package/auth/token-managers/iam-token-manager.d.ts +17 -16
  31. package/auth/token-managers/iam-token-manager.js +17 -16
  32. package/auth/token-managers/jwt-token-manager.d.ts +10 -13
  33. package/auth/token-managers/jwt-token-manager.js +13 -16
  34. package/auth/token-managers/token-manager.d.ts +23 -35
  35. package/auth/token-managers/token-manager.js +22 -34
  36. package/auth/token-managers/vpc-instance-token-manager.d.ts +15 -15
  37. package/auth/token-managers/vpc-instance-token-manager.js +15 -15
  38. package/auth/utils/get-authenticator-from-environment.d.ts +2 -2
  39. package/auth/utils/get-authenticator-from-environment.js +2 -2
  40. package/auth/utils/helpers.d.ts +34 -32
  41. package/auth/utils/helpers.js +34 -32
  42. package/auth/utils/read-external-sources.d.ts +2 -1
  43. package/auth/utils/read-external-sources.js +5 -4
  44. package/build/docs/ibm-cloud-sdk-core.atleastone.md +4 -4
  45. package/build/docs/ibm-cloud-sdk-core.atmostone.md +2 -2
  46. package/build/docs/ibm-cloud-sdk-core.authenticator._constructor_.md +1 -1
  47. package/build/docs/ibm-cloud-sdk-core.authenticator.authenticate.md +1 -1
  48. package/build/docs/ibm-cloud-sdk-core.authenticator.authenticationtype.md +1 -1
  49. package/build/docs/ibm-cloud-sdk-core.authenticator.md +1 -1
  50. package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticate.md +1 -1
  51. package/build/docs/ibm-cloud-sdk-core.baseservice._constructor_.md +1 -1
  52. package/build/docs/ibm-cloud-sdk-core.baseservice.configureservice.md +1 -1
  53. package/build/docs/ibm-cloud-sdk-core.baseservice.createrequest.md +2 -2
  54. package/build/docs/ibm-cloud-sdk-core.baseservice.enableretries.md +1 -1
  55. package/build/docs/ibm-cloud-sdk-core.baseservice.getauthenticator.md +1 -1
  56. package/build/docs/ibm-cloud-sdk-core.baseservice.md +3 -3
  57. package/build/docs/ibm-cloud-sdk-core.baseservice.setdefaultheaders.md +1 -1
  58. package/build/docs/ibm-cloud-sdk-core.baseservice.setserviceurl.md +1 -1
  59. package/build/docs/ibm-cloud-sdk-core.basicauthenticator._constructor_.md +2 -2
  60. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticate.md +1 -1
  61. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.md +3 -3
  62. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator._constructor_.md +2 -2
  63. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticate.md +2 -2
  64. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.md +3 -3
  65. package/build/docs/ibm-cloud-sdk-core.buildrequestfileobject.md +2 -2
  66. package/build/docs/ibm-cloud-sdk-core.checkcredentials.md +3 -3
  67. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator._constructor_.md +3 -3
  68. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.md +5 -5
  69. package/build/docs/ibm-cloud-sdk-core.computebasicauthheader.md +1 -1
  70. package/build/docs/ibm-cloud-sdk-core.constructserviceurl.md +4 -4
  71. package/build/docs/ibm-cloud-sdk-core.containerauthenticator._constructor_.md +3 -3
  72. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.md +4 -4
  73. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setcrtokenfilename.md +1 -1
  74. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofileid.md +1 -1
  75. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofilename.md +1 -1
  76. package/build/docs/ibm-cloud-sdk-core.containertokenmanager._constructor_.md +6 -2
  77. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.md +5 -5
  78. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.requesttoken.md +0 -2
  79. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setcrtokenfilename.md +2 -2
  80. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofileid.md +2 -2
  81. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofilename.md +2 -2
  82. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager._constructor_.md +6 -2
  83. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.md +3 -3
  84. package/build/docs/ibm-cloud-sdk-core.fileobject.md +5 -5
  85. package/build/docs/ibm-cloud-sdk-core.fileoptions.md +4 -4
  86. package/build/docs/ibm-cloud-sdk-core.filestream.md +3 -3
  87. package/build/docs/ibm-cloud-sdk-core.filewithmetadata.md +5 -5
  88. package/build/docs/ibm-cloud-sdk-core.getauthenticatorfromenvironment.md +1 -1
  89. package/build/docs/ibm-cloud-sdk-core.getcontenttype.md +1 -1
  90. package/build/docs/ibm-cloud-sdk-core.getcurrenttime.md +2 -2
  91. package/build/docs/ibm-cloud-sdk-core.getformat.md +0 -2
  92. package/build/docs/ibm-cloud-sdk-core.getmissingparams.md +1 -1
  93. package/build/docs/ibm-cloud-sdk-core.getnewlogger.md +1 -1
  94. package/build/docs/ibm-cloud-sdk-core.getqueryparam.md +1 -5
  95. package/build/docs/ibm-cloud-sdk-core.iamauthenticator._constructor_.md +3 -3
  96. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.md +5 -5
  97. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator._constructor_.md +3 -3
  98. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.getrefreshtoken.md +1 -1
  99. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.md +7 -7
  100. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setclientidandsecret.md +3 -3
  101. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setscope.md +1 -1
  102. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager._constructor_.md +6 -2
  103. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.getrefreshtoken.md +2 -2
  104. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.md +8 -8
  105. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.requesttoken.md +2 -2
  106. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.savetokeninfo.md +1 -3
  107. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setclientidandsecret.md +3 -5
  108. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setscope.md +2 -4
  109. package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.md +5 -5
  110. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager._constructor_.md +6 -2
  111. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.md +3 -3
  112. package/build/docs/ibm-cloud-sdk-core.ishtml.md +1 -1
  113. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager._constructor_.md +2 -2
  114. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.md +5 -5
  115. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.requesttoken.md +1 -1
  116. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.savetokeninfo.md +1 -3
  117. package/build/docs/ibm-cloud-sdk-core.md +24 -24
  118. package/build/docs/ibm-cloud-sdk-core.onlyone.md +2 -2
  119. package/build/docs/ibm-cloud-sdk-core.qs.md +1 -1
  120. package/build/docs/ibm-cloud-sdk-core.readexternalsources.md +1 -1
  121. package/build/docs/ibm-cloud-sdk-core.removesuffix.md +4 -4
  122. package/build/docs/ibm-cloud-sdk-core.sdklogger.md +7 -7
  123. package/build/docs/ibm-cloud-sdk-core.streamtopromise.md +3 -1
  124. package/build/docs/ibm-cloud-sdk-core.striptrailingslash.md +4 -2
  125. package/build/docs/ibm-cloud-sdk-core.tokenmanager._constructor_.md +2 -2
  126. package/build/docs/ibm-cloud-sdk-core.tokenmanager.gettoken.md +1 -1
  127. package/build/docs/ibm-cloud-sdk-core.tokenmanager.md +15 -15
  128. package/build/docs/ibm-cloud-sdk-core.tokenmanager.pacedrequesttoken.md +1 -1
  129. package/build/docs/ibm-cloud-sdk-core.tokenmanager.requesttoken.md +1 -1
  130. package/build/docs/ibm-cloud-sdk-core.tokenmanager.savetokeninfo.md +1 -3
  131. package/build/docs/ibm-cloud-sdk-core.tokenmanager.setdisablesslverification.md +1 -3
  132. package/build/docs/ibm-cloud-sdk-core.tokenmanager.setheaders.md +2 -4
  133. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator._constructor_.md +2 -2
  134. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.authenticate.md +2 -2
  135. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.md +9 -9
  136. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setdisablesslverification.md +1 -1
  137. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setheaders.md +1 -1
  138. package/build/docs/ibm-cloud-sdk-core.tolowerkeys.md +1 -1
  139. package/build/docs/ibm-cloud-sdk-core.unittestutils.checkforsuccessfulexecution.md +0 -2
  140. package/build/docs/ibm-cloud-sdk-core.unittestutils.checkmediaheaders.md +0 -2
  141. package/build/docs/ibm-cloud-sdk-core.unittestutils.checkurlandmethod.md +1 -3
  142. package/build/docs/ibm-cloud-sdk-core.unittestutils.checkuserheader.md +0 -2
  143. package/build/docs/ibm-cloud-sdk-core.unittestutils.expecttobepromise.md +0 -2
  144. package/build/docs/ibm-cloud-sdk-core.unittestutils.getoptions.md +1 -1
  145. package/build/docs/ibm-cloud-sdk-core.useroptions.md +9 -9
  146. package/build/docs/ibm-cloud-sdk-core.validateinput.md +8 -2
  147. package/build/docs/ibm-cloud-sdk-core.validateparams.md +1 -1
  148. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator._constructor_.md +6 -2
  149. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.md +6 -6
  150. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofilecrn.md +2 -2
  151. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofileid.md +2 -2
  152. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager._constructor_.md +6 -2
  153. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.md +4 -4
  154. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofilecrn.md +2 -2
  155. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofileid.md +2 -2
  156. package/docs/ibm-cloud-sdk-core.api.json +516 -241
  157. package/es/auth/authenticators/authenticator-interface.d.ts +3 -4
  158. package/es/auth/authenticators/authenticator-interface.js +1 -1
  159. package/es/auth/authenticators/authenticator.d.ts +5 -9
  160. package/es/auth/authenticators/authenticator.js +4 -8
  161. package/es/auth/authenticators/basic-authenticator.d.ts +12 -12
  162. package/es/auth/authenticators/basic-authenticator.js +12 -12
  163. package/es/auth/authenticators/bearer-token-authenticator.d.ts +11 -14
  164. package/es/auth/authenticators/bearer-token-authenticator.js +11 -14
  165. package/es/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +15 -15
  166. package/es/auth/authenticators/cloud-pak-for-data-authenticator.js +15 -15
  167. package/es/auth/authenticators/container-authenticator.d.ts +23 -23
  168. package/es/auth/authenticators/container-authenticator.js +23 -23
  169. package/es/auth/authenticators/iam-authenticator.d.ts +20 -20
  170. package/es/auth/authenticators/iam-authenticator.js +20 -20
  171. package/es/auth/authenticators/iam-request-based-authenticator.d.ts +23 -25
  172. package/es/auth/authenticators/iam-request-based-authenticator.js +23 -25
  173. package/es/auth/authenticators/token-request-based-authenticator.d.ts +19 -24
  174. package/es/auth/authenticators/token-request-based-authenticator.js +19 -24
  175. package/es/auth/authenticators/vpc-instance-authenticator.d.ts +17 -16
  176. package/es/auth/authenticators/vpc-instance-authenticator.js +17 -16
  177. package/es/auth/token-managers/container-token-manager.d.ts +23 -25
  178. package/es/auth/token-managers/container-token-manager.js +23 -25
  179. package/es/auth/token-managers/cp4d-token-manager.d.ts +13 -13
  180. package/es/auth/token-managers/cp4d-token-manager.js +13 -13
  181. package/es/auth/token-managers/iam-request-based-token-manager.d.ts +26 -31
  182. package/es/auth/token-managers/iam-request-based-token-manager.js +26 -31
  183. package/es/auth/token-managers/iam-token-manager.d.ts +17 -16
  184. package/es/auth/token-managers/iam-token-manager.js +17 -16
  185. package/es/auth/token-managers/jwt-token-manager.d.ts +10 -13
  186. package/es/auth/token-managers/jwt-token-manager.js +13 -16
  187. package/es/auth/token-managers/token-manager.d.ts +23 -35
  188. package/es/auth/token-managers/token-manager.js +22 -34
  189. package/es/auth/token-managers/vpc-instance-token-manager.d.ts +15 -15
  190. package/es/auth/token-managers/vpc-instance-token-manager.js +15 -15
  191. package/es/auth/utils/get-authenticator-from-environment.d.ts +2 -2
  192. package/es/auth/utils/get-authenticator-from-environment.js +2 -2
  193. package/es/auth/utils/helpers.d.ts +34 -32
  194. package/es/auth/utils/helpers.js +34 -32
  195. package/es/auth/utils/read-external-sources.d.ts +2 -1
  196. package/es/auth/utils/read-external-sources.js +5 -4
  197. package/es/lib/base-service.d.ts +31 -32
  198. package/es/lib/base-service.js +31 -32
  199. package/es/lib/content-type.js +5 -5
  200. package/es/lib/get-new-logger.d.ts +2 -2
  201. package/es/lib/get-new-logger.js +2 -2
  202. package/es/lib/helper.d.ts +24 -31
  203. package/es/lib/helper.js +25 -32
  204. package/es/lib/querystring.d.ts +1 -1
  205. package/es/lib/querystring.js +3 -3
  206. package/es/lib/request-wrapper.d.ts +4 -6
  207. package/es/lib/request-wrapper.js +17 -23
  208. package/es/lib/sdk-test-helpers.d.ts +14 -19
  209. package/es/lib/sdk-test-helpers.js +14 -19
  210. package/es/lib/stream-to-promise.d.ts +3 -3
  211. package/es/lib/stream-to-promise.js +3 -3
  212. package/es/tsdoc-metadata.json +1 -1
  213. package/etc/ibm-cloud-sdk-core.api.md +12 -12
  214. package/ibm-cloud-sdk-core.d.ts +1402 -1449
  215. package/lib/base-service.d.ts +31 -32
  216. package/lib/base-service.js +31 -32
  217. package/lib/content-type.js +5 -5
  218. package/lib/get-new-logger.d.ts +2 -2
  219. package/lib/get-new-logger.js +2 -2
  220. package/lib/helper.d.ts +24 -31
  221. package/lib/helper.js +25 -32
  222. package/lib/querystring.d.ts +1 -1
  223. package/lib/querystring.js +3 -3
  224. package/lib/request-wrapper.d.ts +4 -6
  225. package/lib/request-wrapper.js +17 -23
  226. package/lib/sdk-test-helpers.d.ts +14 -19
  227. package/lib/sdk-test-helpers.js +14 -19
  228. package/lib/stream-to-promise.d.ts +3 -3
  229. package/lib/stream-to-promise.js +3 -3
  230. package/package.json +2 -2
  231. package/temp/ibm-cloud-sdk-core.api.json +516 -241
  232. package/temp/ibm-cloud-sdk-core.api.md +12 -12
  233. package/MIGRATION-V1.md +0 -42
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2021.
2
+ * (C) Copyright IBM Corp. 2019, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@ import { getMissingParams } from '../../lib/helper';
17
17
  /**
18
18
  * Compute and return a Basic Authorization header from a username and password.
19
19
  *
20
- * @param {string} username - The username or client id
21
- * @param {string} password - The password or client secret
22
- * @returns {string} - A Basic Auth header with format "Basic <encoded-credentials>"
20
+ * @param username - The username or client id
21
+ * @param password - The password or client secret
22
+ * @returns a Basic Auth header with format "Basic <encoded-credentials>"
23
23
  */
24
24
  export function computeBasicAuthHeader(username, password) {
25
25
  const encodedCreds = Buffer.from(`${username}:${password}`).toString('base64');
@@ -31,11 +31,11 @@ function badCharAtAnEnd(value) {
31
31
  return (value.startsWith('{') || value.startsWith('"') || value.endsWith('}') || value.endsWith('"'));
32
32
  }
33
33
  /**
34
- * Checks credentials for common user mistakes of copying {, }, or " characters from the documentation
34
+ * Checks credentials for common user mistakes of copying \{, \}, or \" characters from the documentation
35
35
  *
36
- * @param {object} obj - The options object holding credentials
37
- * @param {string[]} credsToCheck - An array containing the keys of the credentials to check for problems
38
- * @returns {string | null} - Returns a string with the error message if there were problems, null if not
36
+ * @param obj - the options object holding credentials
37
+ * @param credsToCheck - an array containing the keys of the credentials to check for problems
38
+ * @returns a string with the error message if there were problems, null if not
39
39
  */
40
40
  export function checkCredentials(obj, credsToCheck) {
41
41
  let errorMessage = '';
@@ -52,8 +52,11 @@ export function checkCredentials(obj, credsToCheck) {
52
52
  return null;
53
53
  }
54
54
  /**
55
- * @param {object} options - A configuration options object.
56
- * @param {string[]} requiredOptions - The list of properties that must be specified.
55
+ * Validates "options".
56
+ * @param options - a configuration options object
57
+ * @param requiredOptions - the list of properties that must be present in "options"
58
+ *
59
+ * @throws Error: "options" failed validation
57
60
  */
58
61
  export function validateInput(options, requiredOptions) {
59
62
  // check for required params
@@ -70,32 +73,33 @@ export function validateInput(options, requiredOptions) {
70
73
  }
71
74
  }
72
75
  /**
73
- * Get the current time
76
+ * Gets the current time.
74
77
  *
75
- * @returns {number} - Returns the current time in seconds.
78
+ * @returns the current time in seconds.
76
79
  */
77
80
  export function getCurrentTime() {
78
81
  return Math.floor(Date.now() / 1000);
79
82
  }
80
83
  /**
81
- * Check for only one of two elements being defined.
84
+ * Checks for only one of two elements being defined.
82
85
  * Returns true if a is defined and b is undefined,
83
86
  * or vice versa. Returns false if both are defined
84
87
  * or both are undefined.
85
88
  *
86
- * @param {any} a - The first object
87
- * @param {any} b - The second object
88
- * @returns {boolean}
89
+ * @param a - The first object
90
+ * @param b - The second object
91
+ * @returns true if and only if exactly one of a or b is defined
89
92
  */
90
93
  export function onlyOne(a, b) {
91
94
  return Boolean((a && !b) || (b && !a));
92
95
  }
93
96
  /**
94
- * Remove a given suffix if it exists.
97
+ * Removes a given suffix if it exists.
98
+ *
99
+ * @param str - the base string to operate on
100
+ * @param suffix - the suffix to remove, if present
95
101
  *
96
- * @param {string} str - The base string to operate on
97
- * @param {string} suffix - The suffix to remove, if present
98
- * @returns {string}
102
+ * @returns the substring of "str" that remains after the suffix is removed
99
103
  */
100
104
  export function removeSuffix(str, suffix) {
101
105
  if (str.endsWith(suffix)) {
@@ -104,25 +108,23 @@ export function removeSuffix(str, suffix) {
104
108
  return str;
105
109
  }
106
110
  /**
107
- * Check for at least one of two elements being defined.
108
- * Returns true if a or b is defined. Returns false if
109
- * both are undefined.
111
+ * Checks for at least one of two elements being defined.
110
112
  *
111
- * @param {any} a - The first object
112
- * @param {any} b - The second object
113
- * @returns {boolean}
113
+ * @param a - the first object
114
+ * @param b - the second object
115
+ * @returns true if a or b is defined; false if both are undefined
114
116
  */
115
117
  export function atLeastOne(a, b) {
116
118
  return Boolean(a || b);
117
119
  }
118
120
  /**
119
- * Verify that both properties are not specified.
120
- * Returns true if only a, only b, or neither is defined.
121
- * Returns false if both are defined.
121
+ * Verifies that both properties are not specified.
122
+ *
123
+ * @param a - The first object
124
+ * @param b - The second object
122
125
  *
123
- * @param {any} a - The first object
124
- * @param {any} b - The second object
125
- * @returns {boolean}
126
+ * @returns false if a and b are both defined, true otherwise
127
+
126
128
  */
127
129
  export function atMostOne(a, b) {
128
130
  return Boolean(!(a && b));
@@ -5,6 +5,7 @@
5
5
  * and will be converted to lower camel case.
6
6
  *
7
7
  * Only one source will be used at a time.
8
- * @param {string} serviceName The service name prefix.
8
+ *
9
+ * @param serviceName - the service name prefix
9
10
  */
10
11
  export declare function readExternalSources(serviceName: string): any;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-restricted-syntax */
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2021.
3
+ * (C) Copyright IBM Corp. 2019, 2022.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,8 @@ import { readCredentialsFile } from './file-reading-helpers';
25
25
  * and will be converted to lower camel case.
26
26
  *
27
27
  * Only one source will be used at a time.
28
- * @param {string} serviceName The service name prefix.
28
+ *
29
+ * @param serviceName - the service name prefix
29
30
  */
30
31
  export function readExternalSources(serviceName) {
31
32
  if (!serviceName) {
@@ -57,8 +58,8 @@ function getProperties(serviceName) {
57
58
  * For example, if service.name is speech_to_text,
58
59
  * env properties are SPEECH_TO_TEXT_USERNAME and SPEECH_TO_TEXT_PASSWORD
59
60
  *
60
- * @param {object} envObj - the object containing the credentials keyed by environment variables
61
- * @returns {Credentials}
61
+ * @param envObj - the object containing the credentials keyed by environment variables
62
+ * @returns the set of credentials
62
63
  */
63
64
  function filterPropertiesByServiceName(envObj, serviceName) {
64
65
  const credentials = {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2014, 2021.
2
+ * (C) Copyright IBM Corp. 2014, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -63,40 +63,39 @@ export declare class BaseService {
63
63
  private requestWrapperInstance;
64
64
  /**
65
65
  * Configuration values for a service.
66
- * @param {Authenticator} userOptions.authenticator Object used to authenticate requests to the service.
67
- * @param {string} [userOptions.serviceUrl] The base url to use when contacting the service.
66
+ *
67
+ * @param userOptions - the configuration options to set on the service instance.
68
+ * This should be an object with the following fields:
69
+ * - authenticator: (required) an Object used to authenticate requests to the service.
70
+ * - serviceUrl: (optional) the base url to use when contacting the service.
68
71
  * The base url may differ between IBM Cloud regions.
69
- * @param {object<string, string>} [userOptions.headers] Default headers that shall be
70
- * included with every request to the service.
71
- * @param {string} [userOptions.version] The API version date to use with the service,
72
- * in "YYYY-MM-DD" format.
73
- * @param {boolean} [userOptions.disableSslVerification] A flag that indicates
74
- * whether verification of the token server's SSL certificate should be
72
+ * - headers: (optional) a set of HTTP headers that should be included with every request sent to the service
73
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the server's SSL certificate should be
75
74
  * disabled or not.
76
75
  */
77
76
  constructor(userOptions: UserOptions);
78
77
  /**
79
78
  * Get the instance of the authenticator set on the service.
80
79
  *
81
- * @returns {Authenticator}
80
+ * @returns the Authenticator instance
82
81
  */
83
82
  getAuthenticator(): any;
84
83
  /**
85
84
  * Set the service URL to send requests to.
86
85
  *
87
- * @param {string} url The base URL for the service.
86
+ * @param url - the base URL for the service.
88
87
  */
89
88
  setServiceUrl(url: string): void;
90
89
  /**
91
90
  * Set the HTTP headers to be sent in every request.
92
91
  *
93
- * @param {OutgoingHttpHeaders} headers The map of headers to include in requests.
92
+ * @param headers - the map of headers to include in requests.
94
93
  */
95
94
  setDefaultHeaders(headers: OutgoingHttpHeaders): void;
96
95
  /**
97
96
  * Turn request body compression on or off.
98
97
  *
99
- * @param {boolean} setting Will turn it on if 'true', off if 'false'.
98
+ * @param setting - Will turn it on if 'true', off if 'false'.
100
99
  */
101
100
  setEnableGzipCompression(setting: boolean): void;
102
101
  /**
@@ -107,7 +106,7 @@ export declare class BaseService {
107
106
  /**
108
107
  * Enable retries for unfulfilled requests.
109
108
  *
110
- * @param {RetryOptions} retryOptions configuration for retries
109
+ * @param retryOptions - the configuration for retries
111
110
  */
112
111
  enableRetries(retryOptions?: RetryOptions): void;
113
112
  /**
@@ -117,30 +116,30 @@ export declare class BaseService {
117
116
  /**
118
117
  * Configure the service using external configuration
119
118
  *
120
- * @param {string} serviceName The name of the service. Will be used to read from external
119
+ * @param serviceName - the name of the service. This will be used to read from external
121
120
  * configuration.
122
121
  */
123
122
  protected configureService(serviceName: string): void;
124
123
  /**
125
124
  * Wrapper around `sendRequest` that enforces the request will be authenticated.
126
125
  *
127
- * @param {object} parameters Service request options passed in by user.
128
- * @param {string} parameters.options.method The http method.
129
- * @param {string} parameters.options.url The path portion of the URL to be appended to the serviceUrl.
130
- * @param {object} [parameters.options.path] The path parameters to be inserted into the URL.
131
- * @param {object} [parameters.options.qs] The querystring to be included in the URL.
132
- * @param {object} [parameters.options.body] The data to be sent as the request body.
133
- * @param {object} [parameters.options.form] An object containing the key/value pairs for a www-form-urlencoded request.
134
- * @param {object} [parameters.options.formData] An object containing the contents for a multipart/form-data request
135
- * The following processing is performed on formData values:
136
- * - string: no special processing -- the value is sent as is
137
- * - object: the value is converted to a JSON string before insertion into the form body
138
- * - NodeJS.ReadableStream|Buffer|FileWithMetadata: sent as a file, with any associated metadata
139
- * - array: each element of the array is sent as a separate form part using any special processing as described above
140
- * @param {object} parameters.defaultOptions
141
- * @param {string} parameters.defaultOptions.serviceUrl The base URL of the service.
142
- * @param {OutgoingHttpHeaders} parameters.defaultOptions.headers Additional headers to be passed on the request.
143
- * @returns {Promise<any>}
126
+ * @param parameters - Service request options passed in by user.
127
+ * This should be an object with the following fields:
128
+ * - options.method: the http method
129
+ * - options.url: the path portion of the URL to be appended to the serviceUrl
130
+ * - options.path: the path parameters to be inserted into the URL
131
+ * - options.qs: the querystring to be included in the URL
132
+ * - options.body: the data to be sent as the request body
133
+ * - options.form: an object containing the key/value pairs for a www-form-urlencoded request.
134
+ * - options.formData: an object containing the contents for a multipart/form-data request
135
+ * The following processing is performed on formData values:
136
+ * - string: no special processing -- the value is sent as is
137
+ * - object: the value is converted to a JSON string before insertion into the form body
138
+ * - NodeJS.ReadableStream|Buffer|FileWithMetadata: sent as a file, with any associated metadata
139
+ * - array: each element of the array is sent as a separate form part using any special processing as described above
140
+ * - defaultOptions.serviceUrl: the base URL of the service
141
+ * - defaultOptions.headers: additional HTTP headers to be sent with the request
142
+ * @returns a Promise
144
143
  */
145
144
  protected createRequest(parameters: any): Promise<any>;
146
145
  private readOptionsFromExternalConfig;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2014, 2021.
2
+ * (C) Copyright IBM Corp. 2014, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -26,15 +26,14 @@ import { RequestWrapper } from './request-wrapper';
26
26
  export class BaseService {
27
27
  /**
28
28
  * Configuration values for a service.
29
- * @param {Authenticator} userOptions.authenticator Object used to authenticate requests to the service.
30
- * @param {string} [userOptions.serviceUrl] The base url to use when contacting the service.
29
+ *
30
+ * @param userOptions - the configuration options to set on the service instance.
31
+ * This should be an object with the following fields:
32
+ * - authenticator: (required) an Object used to authenticate requests to the service.
33
+ * - serviceUrl: (optional) the base url to use when contacting the service.
31
34
  * The base url may differ between IBM Cloud regions.
32
- * @param {object<string, string>} [userOptions.headers] Default headers that shall be
33
- * included with every request to the service.
34
- * @param {string} [userOptions.version] The API version date to use with the service,
35
- * in "YYYY-MM-DD" format.
36
- * @param {boolean} [userOptions.disableSslVerification] A flag that indicates
37
- * whether verification of the token server's SSL certificate should be
35
+ * - headers: (optional) a set of HTTP headers that should be included with every request sent to the service
36
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the server's SSL certificate should be
38
37
  * disabled or not.
39
38
  */
40
39
  constructor(userOptions) {
@@ -75,7 +74,7 @@ export class BaseService {
75
74
  /**
76
75
  * Get the instance of the authenticator set on the service.
77
76
  *
78
- * @returns {Authenticator}
77
+ * @returns the Authenticator instance
79
78
  */
80
79
  getAuthenticator() {
81
80
  return this.authenticator;
@@ -83,7 +82,7 @@ export class BaseService {
83
82
  /**
84
83
  * Set the service URL to send requests to.
85
84
  *
86
- * @param {string} url The base URL for the service.
85
+ * @param url - the base URL for the service.
87
86
  */
88
87
  setServiceUrl(url) {
89
88
  if (url) {
@@ -93,7 +92,7 @@ export class BaseService {
93
92
  /**
94
93
  * Set the HTTP headers to be sent in every request.
95
94
  *
96
- * @param {OutgoingHttpHeaders} headers The map of headers to include in requests.
95
+ * @param headers - the map of headers to include in requests.
97
96
  */
98
97
  setDefaultHeaders(headers) {
99
98
  if (typeof headers !== 'object') {
@@ -105,7 +104,7 @@ export class BaseService {
105
104
  /**
106
105
  * Turn request body compression on or off.
107
106
  *
108
- * @param {boolean} setting Will turn it on if 'true', off if 'false'.
107
+ * @param setting - Will turn it on if 'true', off if 'false'.
109
108
  */
110
109
  setEnableGzipCompression(setting) {
111
110
  this.requestWrapperInstance.setCompressRequestData(setting);
@@ -122,7 +121,7 @@ export class BaseService {
122
121
  /**
123
122
  * Enable retries for unfulfilled requests.
124
123
  *
125
- * @param {RetryOptions} retryOptions configuration for retries
124
+ * @param retryOptions - the configuration for retries
126
125
  */
127
126
  enableRetries(retryOptions) {
128
127
  this.requestWrapperInstance.enableRetries(retryOptions);
@@ -136,7 +135,7 @@ export class BaseService {
136
135
  /**
137
136
  * Configure the service using external configuration
138
137
  *
139
- * @param {string} serviceName The name of the service. Will be used to read from external
138
+ * @param serviceName - the name of the service. This will be used to read from external
140
139
  * configuration.
141
140
  */
142
141
  configureService(serviceName) {
@@ -152,23 +151,23 @@ export class BaseService {
152
151
  /**
153
152
  * Wrapper around `sendRequest` that enforces the request will be authenticated.
154
153
  *
155
- * @param {object} parameters Service request options passed in by user.
156
- * @param {string} parameters.options.method The http method.
157
- * @param {string} parameters.options.url The path portion of the URL to be appended to the serviceUrl.
158
- * @param {object} [parameters.options.path] The path parameters to be inserted into the URL.
159
- * @param {object} [parameters.options.qs] The querystring to be included in the URL.
160
- * @param {object} [parameters.options.body] The data to be sent as the request body.
161
- * @param {object} [parameters.options.form] An object containing the key/value pairs for a www-form-urlencoded request.
162
- * @param {object} [parameters.options.formData] An object containing the contents for a multipart/form-data request
163
- * The following processing is performed on formData values:
164
- * - string: no special processing -- the value is sent as is
165
- * - object: the value is converted to a JSON string before insertion into the form body
166
- * - NodeJS.ReadableStream|Buffer|FileWithMetadata: sent as a file, with any associated metadata
167
- * - array: each element of the array is sent as a separate form part using any special processing as described above
168
- * @param {object} parameters.defaultOptions
169
- * @param {string} parameters.defaultOptions.serviceUrl The base URL of the service.
170
- * @param {OutgoingHttpHeaders} parameters.defaultOptions.headers Additional headers to be passed on the request.
171
- * @returns {Promise<any>}
154
+ * @param parameters - Service request options passed in by user.
155
+ * This should be an object with the following fields:
156
+ * - options.method: the http method
157
+ * - options.url: the path portion of the URL to be appended to the serviceUrl
158
+ * - options.path: the path parameters to be inserted into the URL
159
+ * - options.qs: the querystring to be included in the URL
160
+ * - options.body: the data to be sent as the request body
161
+ * - options.form: an object containing the key/value pairs for a www-form-urlencoded request.
162
+ * - options.formData: an object containing the contents for a multipart/form-data request
163
+ * The following processing is performed on formData values:
164
+ * - string: no special processing -- the value is sent as is
165
+ * - object: the value is converted to a JSON string before insertion into the form body
166
+ * - NodeJS.ReadableStream|Buffer|FileWithMetadata: sent as a file, with any associated metadata
167
+ * - array: each element of the array is sent as a separate form part using any special processing as described above
168
+ * - defaultOptions.serviceUrl: the base URL of the service
169
+ * - defaultOptions.headers: additional HTTP headers to be sent with the request
170
+ * @returns a Promise
172
171
  */
173
172
  createRequest(parameters) {
174
173
  // validate serviceUrl parameter has been set
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable prettier/prettier */
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2021.
3
+ * (C) Copyright IBM Corp. 2019, 2022.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -39,8 +39,8 @@ const filenameContentTypes = {
39
39
  /**
40
40
  * Takes the beginning of an audio file and returns the associated content-type / mime type
41
41
  *
42
- * @param {Buffer} buffer With at least the first 4 bytes of the file
43
- * @return {String|undefined} The contentType or undefined
42
+ * @param buffer - a Buffer containing at least the first 4 bytes of the file
43
+ * @return sthe contentType or undefined
44
44
  */
45
45
  const fromHeader = (buffer) => {
46
46
  const headerStr = buffer
@@ -56,8 +56,8 @@ const fromHeader = (buffer) => {
56
56
  * Note: Blob and File objects include a .type property, but we're ignoring it because it's frequently either
57
57
  * incorrect (e.g. video/ogg instead of audio/ogg) or else a different format than what's expected (e.g. audio/x-wav)
58
58
  *
59
- * @param {String|ReadableStream|FileObject|Buffer|File} file String filename or url, or binary File/Blob object.
60
- * @return {String|undefined}
59
+ * @param file - a String filename or url, or binary File/Blob object.
60
+ * @returns the content type
61
61
  */
62
62
  const fromFilename = (file) => {
63
63
  const ext = extname(
@@ -31,9 +31,9 @@ export interface SDKLogger {
31
31
  * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
32
32
  * environment variable is set to "axios".
33
33
  *
34
- * @param {string} moduleName - the namespace for the logger. The name will appear in
34
+ * @param moduleName - the namespace for the logger. The name will appear in
35
35
  * the logs and it will be the name used for configuring the log level.
36
36
  *
37
- * @returns {SDKLogger} the new logger
37
+ * @returns the new logger
38
38
  */
39
39
  export declare function getNewLogger(moduleName: string): SDKLogger;
@@ -24,10 +24,10 @@ import logger from 'debug';
24
24
  * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
25
25
  * environment variable is set to "axios".
26
26
  *
27
- * @param {string} moduleName - the namespace for the logger. The name will appear in
27
+ * @param moduleName - the namespace for the logger. The name will appear in
28
28
  * the logs and it will be the name used for configuring the log level.
29
29
  *
30
- * @returns {SDKLogger} the new logger
30
+ * @returns the new logger
31
31
  */
32
32
  export function getNewLogger(moduleName) {
33
33
  const debug = logger(`${moduleName}:debug`);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2014, 2021.
2
+ * (C) Copyright IBM Corp. 2014, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -35,31 +35,29 @@ export declare function isFileData(obj: any): obj is NodeJS.ReadableStream | Buf
35
35
  export declare function isEmptyObject(obj: any): boolean;
36
36
  /**
37
37
  * This function retrieves the content type of the input.
38
- * @param {NodeJS.ReadableStream|Buffer} inputData - The data to retrieve content type for.
39
- * @returns {string} the content type of the input.
38
+ * @param inputData - The data to retrieve content type for.
39
+ * @returns the content type of the input.
40
40
  */
41
41
  export declare function getContentType(inputData: NodeJS.ReadableStream | Buffer): Promise<string>;
42
42
  /**
43
- *
44
- * @param {string} url - the url string.
45
- * @returns {string}
43
+ * Strips trailing slashes from "url", if present.
44
+ * @param url - the url string
45
+ * @returns the url with any trailing slashes removed
46
46
  */
47
47
  export declare function stripTrailingSlash(url: string): string;
48
48
  /**
49
49
  * Return a query parameter value from a URL
50
50
  *
51
- * @param {string} urlStr - the url string.
52
- * @param {string} param - the name of the query parameter
53
- * whose value should be returned
54
- * @returns {string} the value of the `param` query parameter
55
- * @throws if urlStr is an invalid URL
51
+ * @param urlStr - the url string.
52
+ * @param param - the name of the query parameter whose value should be returned
53
+ * @returns the value of the "param" query parameter
56
54
  */
57
55
  export declare function getQueryParam(urlStr: string, param: string): string;
58
56
  /**
59
57
  * Validates that all required params are provided
60
58
  * @param params - the method parameters.
61
59
  * @param requires - the required parameter names.
62
- * @returns {Error|null}
60
+ * @returns null if no errors found, otherwise an Error instance
63
61
  */
64
62
  export declare function getMissingParams(params: {
65
63
  [key: string]: any;
@@ -75,52 +73,47 @@ export declare function getMissingParams(params: {
75
73
  * If null, then the "required params" check is bypassed.
76
74
  * @param allParams - the names of all valid parameters.
77
75
  * If null, then the "valid params" check is bypassed.
78
- * @returns {Error|null}
76
+ * @returns null if no errors found, otherwise an Error instance
79
77
  */
80
78
  export declare function validateParams(params: {
81
79
  [key: string]: any;
82
80
  }, requiredParams: string[], allParams: string[]): null | Error;
83
81
  /**
84
82
  * Return true if 'text' is html
85
- * @param {string} text - The 'text' to analyze
86
- * @returns {boolean} true if 'text' has html tags
83
+ * @param text - The 'text' to analyze
84
+ * @returns true if 'text' has html tags
87
85
  */
88
86
  export declare function isHTML(text: string): boolean;
89
87
  /**
90
88
  * Returns the first match from formats that is key the params map
91
89
  * otherwise null
92
- * @param {Object} params - The parameters.
93
- * @param {string[]} requires - The keys we want to check
94
- * @returns {string|null}
90
+ * @param params - The parameters.
91
+ * @param requires - The keys we want to check
95
92
  */
96
93
  export declare function getFormat(params: {
97
94
  [key: string]: any;
98
95
  }, formats: string[]): string;
99
96
  /**
100
97
  * This function builds a `form-data` object for each file parameter.
101
- * @param {FileWithMetadata} fileParam The file parameter.
102
- * @param {NodeJS.ReadableStream|Buffer} fileParam.data The data content of the file.
103
- * @param {string} fileParam.filename The filename of the file.
104
- * @param {string} fileParam.contentType The content type of the file.
105
- * @returns {FileObject}
98
+ * @param fileParam - The FileWithMetadata instance that contains the file information
99
+ * @returns the FileObject instance
106
100
  */
107
101
  export declare function buildRequestFileObject(fileParam: FileWithMetadata): Promise<FileObject>;
108
102
  /**
109
103
  * This function converts an object's keys to lower case.
110
104
  * note: does not convert nested keys
111
- * @param {Object} obj The object to convert the keys of.
112
- * @returns {Object}
105
+ * @param obj - The object to convert the keys of.
106
+ * @returns the object with keys folded to lowercase
113
107
  */
114
108
  export declare function toLowerKeys(obj: Object): Object;
115
109
  /**
116
110
  * Constructs a service URL by formatting a parameterized URL.
117
111
  *
118
- * @param {string} parameterizedUrl URL that contains variable placeholders, e.g. '{scheme}://ibm.com'.
119
- * @param {Map<string, string>} defaultUrlVariables Map from variable names to default values.
112
+ * @param parameterizedUrl - a URL that contains variable placeholders, e.g. '\{scheme\}://ibm.com'.
113
+ * @param defaultUrlVariables - a Map of variable names to default values.
120
114
  * Each variable in the parameterized URL must have a default value specified in this map.
121
- * @param {Map<string, string>} providedUrlVariables Map from variable names to desired values.
122
- * If a variable is not provided in this map,
123
- * the default variable value will be used instead.
124
- * @returns {string} The formatted URL with all variable placeholders replaced by values.
115
+ * @param providedUrlVariables - a Map of variable names to desired values.
116
+ * If a variable is not provided in this map, the default variable value will be used instead.
117
+ * @returns the formatted URL with all variable placeholders replaced by values.
125
118
  */
126
119
  export declare function constructServiceUrl(parameterizedUrl: string, defaultUrlVariables: Map<string, string>, providedUrlVariables: Map<string, string> | null): string;