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.
- package/.secrets.baseline +20 -30
- package/CHANGELOG.md +16 -4
- package/MIGRATION-V4.md +54 -0
- package/auth/authenticators/authenticator-interface.d.ts +3 -4
- package/auth/authenticators/authenticator-interface.js +1 -1
- package/auth/authenticators/authenticator.d.ts +5 -9
- package/auth/authenticators/authenticator.js +4 -8
- package/auth/authenticators/basic-authenticator.d.ts +12 -12
- package/auth/authenticators/basic-authenticator.js +12 -12
- package/auth/authenticators/bearer-token-authenticator.d.ts +11 -14
- package/auth/authenticators/bearer-token-authenticator.js +11 -14
- package/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +15 -15
- package/auth/authenticators/cloud-pak-for-data-authenticator.js +15 -15
- package/auth/authenticators/container-authenticator.d.ts +23 -23
- package/auth/authenticators/container-authenticator.js +23 -23
- package/auth/authenticators/iam-authenticator.d.ts +20 -20
- package/auth/authenticators/iam-authenticator.js +20 -20
- package/auth/authenticators/iam-request-based-authenticator.d.ts +23 -25
- package/auth/authenticators/iam-request-based-authenticator.js +23 -25
- package/auth/authenticators/token-request-based-authenticator.d.ts +19 -24
- package/auth/authenticators/token-request-based-authenticator.js +19 -24
- package/auth/authenticators/vpc-instance-authenticator.d.ts +17 -16
- package/auth/authenticators/vpc-instance-authenticator.js +17 -16
- package/auth/token-managers/container-token-manager.d.ts +23 -25
- package/auth/token-managers/container-token-manager.js +23 -25
- package/auth/token-managers/cp4d-token-manager.d.ts +13 -13
- package/auth/token-managers/cp4d-token-manager.js +13 -13
- package/auth/token-managers/iam-request-based-token-manager.d.ts +26 -31
- package/auth/token-managers/iam-request-based-token-manager.js +26 -31
- package/auth/token-managers/iam-token-manager.d.ts +17 -16
- package/auth/token-managers/iam-token-manager.js +17 -16
- package/auth/token-managers/jwt-token-manager.d.ts +10 -13
- package/auth/token-managers/jwt-token-manager.js +13 -16
- package/auth/token-managers/token-manager.d.ts +23 -35
- package/auth/token-managers/token-manager.js +22 -34
- package/auth/token-managers/vpc-instance-token-manager.d.ts +15 -15
- package/auth/token-managers/vpc-instance-token-manager.js +15 -15
- package/auth/utils/get-authenticator-from-environment.d.ts +2 -2
- package/auth/utils/get-authenticator-from-environment.js +2 -2
- package/auth/utils/helpers.d.ts +34 -32
- package/auth/utils/helpers.js +34 -32
- package/auth/utils/read-external-sources.d.ts +2 -1
- package/auth/utils/read-external-sources.js +5 -4
- package/build/docs/ibm-cloud-sdk-core.atleastone.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.atmostone.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.authenticator._constructor_.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.authenticator.authenticate.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.authenticator.authenticationtype.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.authenticator.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticate.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice._constructor_.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice.configureservice.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice.createrequest.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.baseservice.enableretries.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice.getauthenticator.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.baseservice.setdefaultheaders.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.baseservice.setserviceurl.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator._constructor_.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticate.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator._constructor_.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticate.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.buildrequestfileobject.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.checkcredentials.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator._constructor_.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.computebasicauthheader.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.constructserviceurl.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator._constructor_.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setcrtokenfilename.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofileid.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofilename.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.requesttoken.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setcrtokenfilename.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofileid.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofilename.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.fileobject.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.fileoptions.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.filestream.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.filewithmetadata.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.getauthenticatorfromenvironment.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.getcontenttype.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.getcurrenttime.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.getformat.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.getmissingparams.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.getnewlogger.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.getqueryparam.md +1 -5
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator._constructor_.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator._constructor_.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.getrefreshtoken.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.md +7 -7
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setclientidandsecret.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setscope.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.getrefreshtoken.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.md +8 -8
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.requesttoken.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.savetokeninfo.md +1 -3
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setclientidandsecret.md +3 -5
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setscope.md +2 -4
- package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.md +3 -3
- package/build/docs/ibm-cloud-sdk-core.ishtml.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager._constructor_.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.md +5 -5
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.requesttoken.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.savetokeninfo.md +1 -3
- package/build/docs/ibm-cloud-sdk-core.md +24 -24
- package/build/docs/ibm-cloud-sdk-core.onlyone.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.qs.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.readexternalsources.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.removesuffix.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.sdklogger.md +7 -7
- package/build/docs/ibm-cloud-sdk-core.streamtopromise.md +3 -1
- package/build/docs/ibm-cloud-sdk-core.striptrailingslash.md +4 -2
- package/build/docs/ibm-cloud-sdk-core.tokenmanager._constructor_.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.gettoken.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.md +15 -15
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.pacedrequesttoken.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.requesttoken.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.savetokeninfo.md +1 -3
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.setdisablesslverification.md +1 -3
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.setheaders.md +2 -4
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator._constructor_.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.authenticate.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.md +9 -9
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setdisablesslverification.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setheaders.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.tolowerkeys.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.unittestutils.checkforsuccessfulexecution.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.unittestutils.checkmediaheaders.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.unittestutils.checkurlandmethod.md +1 -3
- package/build/docs/ibm-cloud-sdk-core.unittestutils.checkuserheader.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.unittestutils.expecttobepromise.md +0 -2
- package/build/docs/ibm-cloud-sdk-core.unittestutils.getoptions.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.useroptions.md +9 -9
- package/build/docs/ibm-cloud-sdk-core.validateinput.md +8 -2
- package/build/docs/ibm-cloud-sdk-core.validateparams.md +1 -1
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.md +6 -6
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofilecrn.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofileid.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager._constructor_.md +6 -2
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.md +4 -4
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofilecrn.md +2 -2
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofileid.md +2 -2
- package/docs/ibm-cloud-sdk-core.api.json +516 -241
- package/es/auth/authenticators/authenticator-interface.d.ts +3 -4
- package/es/auth/authenticators/authenticator-interface.js +1 -1
- package/es/auth/authenticators/authenticator.d.ts +5 -9
- package/es/auth/authenticators/authenticator.js +4 -8
- package/es/auth/authenticators/basic-authenticator.d.ts +12 -12
- package/es/auth/authenticators/basic-authenticator.js +12 -12
- package/es/auth/authenticators/bearer-token-authenticator.d.ts +11 -14
- package/es/auth/authenticators/bearer-token-authenticator.js +11 -14
- package/es/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +15 -15
- package/es/auth/authenticators/cloud-pak-for-data-authenticator.js +15 -15
- package/es/auth/authenticators/container-authenticator.d.ts +23 -23
- package/es/auth/authenticators/container-authenticator.js +23 -23
- package/es/auth/authenticators/iam-authenticator.d.ts +20 -20
- package/es/auth/authenticators/iam-authenticator.js +20 -20
- package/es/auth/authenticators/iam-request-based-authenticator.d.ts +23 -25
- package/es/auth/authenticators/iam-request-based-authenticator.js +23 -25
- package/es/auth/authenticators/token-request-based-authenticator.d.ts +19 -24
- package/es/auth/authenticators/token-request-based-authenticator.js +19 -24
- package/es/auth/authenticators/vpc-instance-authenticator.d.ts +17 -16
- package/es/auth/authenticators/vpc-instance-authenticator.js +17 -16
- package/es/auth/token-managers/container-token-manager.d.ts +23 -25
- package/es/auth/token-managers/container-token-manager.js +23 -25
- package/es/auth/token-managers/cp4d-token-manager.d.ts +13 -13
- package/es/auth/token-managers/cp4d-token-manager.js +13 -13
- package/es/auth/token-managers/iam-request-based-token-manager.d.ts +26 -31
- package/es/auth/token-managers/iam-request-based-token-manager.js +26 -31
- package/es/auth/token-managers/iam-token-manager.d.ts +17 -16
- package/es/auth/token-managers/iam-token-manager.js +17 -16
- package/es/auth/token-managers/jwt-token-manager.d.ts +10 -13
- package/es/auth/token-managers/jwt-token-manager.js +13 -16
- package/es/auth/token-managers/token-manager.d.ts +23 -35
- package/es/auth/token-managers/token-manager.js +22 -34
- package/es/auth/token-managers/vpc-instance-token-manager.d.ts +15 -15
- package/es/auth/token-managers/vpc-instance-token-manager.js +15 -15
- package/es/auth/utils/get-authenticator-from-environment.d.ts +2 -2
- package/es/auth/utils/get-authenticator-from-environment.js +2 -2
- package/es/auth/utils/helpers.d.ts +34 -32
- package/es/auth/utils/helpers.js +34 -32
- package/es/auth/utils/read-external-sources.d.ts +2 -1
- package/es/auth/utils/read-external-sources.js +5 -4
- package/es/lib/base-service.d.ts +31 -32
- package/es/lib/base-service.js +31 -32
- package/es/lib/content-type.js +5 -5
- package/es/lib/get-new-logger.d.ts +2 -2
- package/es/lib/get-new-logger.js +2 -2
- package/es/lib/helper.d.ts +24 -31
- package/es/lib/helper.js +25 -32
- package/es/lib/querystring.d.ts +1 -1
- package/es/lib/querystring.js +3 -3
- package/es/lib/request-wrapper.d.ts +4 -6
- package/es/lib/request-wrapper.js +17 -23
- package/es/lib/sdk-test-helpers.d.ts +14 -19
- package/es/lib/sdk-test-helpers.js +14 -19
- package/es/lib/stream-to-promise.d.ts +3 -3
- package/es/lib/stream-to-promise.js +3 -3
- package/es/tsdoc-metadata.json +1 -1
- package/etc/ibm-cloud-sdk-core.api.md +12 -12
- package/ibm-cloud-sdk-core.d.ts +1402 -1449
- package/lib/base-service.d.ts +31 -32
- package/lib/base-service.js +31 -32
- package/lib/content-type.js +5 -5
- package/lib/get-new-logger.d.ts +2 -2
- package/lib/get-new-logger.js +2 -2
- package/lib/helper.d.ts +24 -31
- package/lib/helper.js +25 -32
- package/lib/querystring.d.ts +1 -1
- package/lib/querystring.js +3 -3
- package/lib/request-wrapper.d.ts +4 -6
- package/lib/request-wrapper.js +17 -23
- package/lib/sdk-test-helpers.d.ts +14 -19
- package/lib/sdk-test-helpers.js +14 -19
- package/lib/stream-to-promise.d.ts +3 -3
- package/lib/stream-to-promise.js +3 -3
- package/package.json +2 -2
- package/temp/ibm-cloud-sdk-core.api.json +516 -241
- package/temp/ibm-cloud-sdk-core.api.md +12 -12
- package/MIGRATION-V1.md +0 -42
package/lib/base-service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
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
|
-
*
|
|
67
|
-
* @param
|
|
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
|
-
*
|
|
70
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @returns
|
|
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;
|
package/lib/base-service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* (C) Copyright IBM Corp. 2014,
|
|
3
|
+
* (C) Copyright IBM Corp. 2014, 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.
|
|
@@ -43,15 +43,14 @@ var request_wrapper_1 = require("./request-wrapper");
|
|
|
43
43
|
var BaseService = /** @class */ (function () {
|
|
44
44
|
/**
|
|
45
45
|
* Configuration values for a service.
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
46
|
+
*
|
|
47
|
+
* @param userOptions - the configuration options to set on the service instance.
|
|
48
|
+
* This should be an object with the following fields:
|
|
49
|
+
* - authenticator: (required) an Object used to authenticate requests to the service.
|
|
50
|
+
* - serviceUrl: (optional) the base url to use when contacting the service.
|
|
48
51
|
* The base url may differ between IBM Cloud regions.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @param {string} [userOptions.version] The API version date to use with the service,
|
|
52
|
-
* in "YYYY-MM-DD" format.
|
|
53
|
-
* @param {boolean} [userOptions.disableSslVerification] A flag that indicates
|
|
54
|
-
* whether verification of the token server's SSL certificate should be
|
|
52
|
+
* - headers: (optional) a set of HTTP headers that should be included with every request sent to the service
|
|
53
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the server's SSL certificate should be
|
|
55
54
|
* disabled or not.
|
|
56
55
|
*/
|
|
57
56
|
function BaseService(userOptions) {
|
|
@@ -92,7 +91,7 @@ var BaseService = /** @class */ (function () {
|
|
|
92
91
|
/**
|
|
93
92
|
* Get the instance of the authenticator set on the service.
|
|
94
93
|
*
|
|
95
|
-
* @returns
|
|
94
|
+
* @returns the Authenticator instance
|
|
96
95
|
*/
|
|
97
96
|
BaseService.prototype.getAuthenticator = function () {
|
|
98
97
|
return this.authenticator;
|
|
@@ -100,7 +99,7 @@ var BaseService = /** @class */ (function () {
|
|
|
100
99
|
/**
|
|
101
100
|
* Set the service URL to send requests to.
|
|
102
101
|
*
|
|
103
|
-
* @param
|
|
102
|
+
* @param url - the base URL for the service.
|
|
104
103
|
*/
|
|
105
104
|
BaseService.prototype.setServiceUrl = function (url) {
|
|
106
105
|
if (url) {
|
|
@@ -110,7 +109,7 @@ var BaseService = /** @class */ (function () {
|
|
|
110
109
|
/**
|
|
111
110
|
* Set the HTTP headers to be sent in every request.
|
|
112
111
|
*
|
|
113
|
-
* @param
|
|
112
|
+
* @param headers - the map of headers to include in requests.
|
|
114
113
|
*/
|
|
115
114
|
BaseService.prototype.setDefaultHeaders = function (headers) {
|
|
116
115
|
if (typeof headers !== 'object') {
|
|
@@ -122,7 +121,7 @@ var BaseService = /** @class */ (function () {
|
|
|
122
121
|
/**
|
|
123
122
|
* Turn request body compression on or off.
|
|
124
123
|
*
|
|
125
|
-
* @param
|
|
124
|
+
* @param setting - Will turn it on if 'true', off if 'false'.
|
|
126
125
|
*/
|
|
127
126
|
BaseService.prototype.setEnableGzipCompression = function (setting) {
|
|
128
127
|
this.requestWrapperInstance.setCompressRequestData(setting);
|
|
@@ -139,7 +138,7 @@ var BaseService = /** @class */ (function () {
|
|
|
139
138
|
/**
|
|
140
139
|
* Enable retries for unfulfilled requests.
|
|
141
140
|
*
|
|
142
|
-
* @param
|
|
141
|
+
* @param retryOptions - the configuration for retries
|
|
143
142
|
*/
|
|
144
143
|
BaseService.prototype.enableRetries = function (retryOptions) {
|
|
145
144
|
this.requestWrapperInstance.enableRetries(retryOptions);
|
|
@@ -153,7 +152,7 @@ var BaseService = /** @class */ (function () {
|
|
|
153
152
|
/**
|
|
154
153
|
* Configure the service using external configuration
|
|
155
154
|
*
|
|
156
|
-
* @param
|
|
155
|
+
* @param serviceName - the name of the service. This will be used to read from external
|
|
157
156
|
* configuration.
|
|
158
157
|
*/
|
|
159
158
|
BaseService.prototype.configureService = function (serviceName) {
|
|
@@ -169,23 +168,23 @@ var BaseService = /** @class */ (function () {
|
|
|
169
168
|
/**
|
|
170
169
|
* Wrapper around `sendRequest` that enforces the request will be authenticated.
|
|
171
170
|
*
|
|
172
|
-
* @param
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* @returns
|
|
171
|
+
* @param parameters - Service request options passed in by user.
|
|
172
|
+
* This should be an object with the following fields:
|
|
173
|
+
* - options.method: the http method
|
|
174
|
+
* - options.url: the path portion of the URL to be appended to the serviceUrl
|
|
175
|
+
* - options.path: the path parameters to be inserted into the URL
|
|
176
|
+
* - options.qs: the querystring to be included in the URL
|
|
177
|
+
* - options.body: the data to be sent as the request body
|
|
178
|
+
* - options.form: an object containing the key/value pairs for a www-form-urlencoded request.
|
|
179
|
+
* - options.formData: an object containing the contents for a multipart/form-data request
|
|
180
|
+
* The following processing is performed on formData values:
|
|
181
|
+
* - string: no special processing -- the value is sent as is
|
|
182
|
+
* - object: the value is converted to a JSON string before insertion into the form body
|
|
183
|
+
* - NodeJS.ReadableStream|Buffer|FileWithMetadata: sent as a file, with any associated metadata
|
|
184
|
+
* - array: each element of the array is sent as a separate form part using any special processing as described above
|
|
185
|
+
* - defaultOptions.serviceUrl: the base URL of the service
|
|
186
|
+
* - defaultOptions.headers: additional HTTP headers to be sent with the request
|
|
187
|
+
* @returns a Promise
|
|
189
188
|
*/
|
|
190
189
|
BaseService.prototype.createRequest = function (parameters) {
|
|
191
190
|
var _this = this;
|
package/lib/content-type.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable prettier/prettier */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
/**
|
|
5
|
-
* (C) Copyright IBM Corp. 2019,
|
|
5
|
+
* (C) Copyright IBM Corp. 2019, 2022.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -41,8 +41,8 @@ var filenameContentTypes = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Takes the beginning of an audio file and returns the associated content-type / mime type
|
|
43
43
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @return
|
|
44
|
+
* @param buffer - a Buffer containing at least the first 4 bytes of the file
|
|
45
|
+
* @return sthe contentType or undefined
|
|
46
46
|
*/
|
|
47
47
|
var fromHeader = function (buffer) {
|
|
48
48
|
var headerStr = buffer
|
|
@@ -58,8 +58,8 @@ var fromHeader = function (buffer) {
|
|
|
58
58
|
* Note: Blob and File objects include a .type property, but we're ignoring it because it's frequently either
|
|
59
59
|
* incorrect (e.g. video/ogg instead of audio/ogg) or else a different format than what's expected (e.g. audio/x-wav)
|
|
60
60
|
*
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
61
|
+
* @param file - a String filename or url, or binary File/Blob object.
|
|
62
|
+
* @returns the content type
|
|
63
63
|
*/
|
|
64
64
|
var fromFilename = function (file) {
|
|
65
65
|
var ext = (0, path_1.extname)(
|
package/lib/get-new-logger.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
37
|
+
* @returns the new logger
|
|
38
38
|
*/
|
|
39
39
|
export declare function getNewLogger(moduleName: string): SDKLogger;
|
package/lib/get-new-logger.js
CHANGED
|
@@ -30,10 +30,10 @@ var debug_1 = __importDefault(require("debug"));
|
|
|
30
30
|
* Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
|
|
31
31
|
* environment variable is set to "axios".
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
33
|
+
* @param moduleName - the namespace for the logger. The name will appear in
|
|
34
34
|
* the logs and it will be the name used for configuring the log level.
|
|
35
35
|
*
|
|
36
|
-
* @returns
|
|
36
|
+
* @returns the new logger
|
|
37
37
|
*/
|
|
38
38
|
function getNewLogger(moduleName) {
|
|
39
39
|
var debug = (0, debug_1.default)("".concat(moduleName, ":debug"));
|
package/lib/helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
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
|
|
39
|
-
* @returns
|
|
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
|
|
45
|
-
* @returns
|
|
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
|
|
52
|
-
* @param
|
|
53
|
-
*
|
|
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
|
|
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
|
|
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
|
|
86
|
-
* @returns
|
|
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
|
|
93
|
-
* @param
|
|
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
|
|
102
|
-
* @
|
|
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
|
|
112
|
-
* @returns
|
|
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
|
|
119
|
-
* @param
|
|
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
|
|
122
|
-
* If a variable is not provided in this map,
|
|
123
|
-
*
|
|
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;
|
package/lib/helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* (C) Copyright IBM Corp. 2014,
|
|
3
|
+
* (C) Copyright IBM Corp. 2014, 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.
|
|
@@ -90,8 +90,8 @@ function isEmptyObject(obj) {
|
|
|
90
90
|
exports.isEmptyObject = isEmptyObject;
|
|
91
91
|
/**
|
|
92
92
|
* This function retrieves the content type of the input.
|
|
93
|
-
* @param
|
|
94
|
-
* @returns
|
|
93
|
+
* @param inputData - The data to retrieve content type for.
|
|
94
|
+
* @returns the content type of the input.
|
|
95
95
|
*/
|
|
96
96
|
function getContentType(inputData) {
|
|
97
97
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -118,9 +118,9 @@ function getContentType(inputData) {
|
|
|
118
118
|
}
|
|
119
119
|
exports.getContentType = getContentType;
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
122
|
-
* @param
|
|
123
|
-
* @returns
|
|
121
|
+
* Strips trailing slashes from "url", if present.
|
|
122
|
+
* @param url - the url string
|
|
123
|
+
* @returns the url with any trailing slashes removed
|
|
124
124
|
*/
|
|
125
125
|
function stripTrailingSlash(url) {
|
|
126
126
|
// Match a forward slash / at the end of the string ($)
|
|
@@ -130,11 +130,9 @@ exports.stripTrailingSlash = stripTrailingSlash;
|
|
|
130
130
|
/**
|
|
131
131
|
* Return a query parameter value from a URL
|
|
132
132
|
*
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
*
|
|
136
|
-
* @returns {string} the value of the `param` query parameter
|
|
137
|
-
* @throws if urlStr is an invalid URL
|
|
133
|
+
* @param urlStr - the url string.
|
|
134
|
+
* @param param - the name of the query parameter whose value should be returned
|
|
135
|
+
* @returns the value of the "param" query parameter
|
|
138
136
|
*/
|
|
139
137
|
function getQueryParam(urlStr, param) {
|
|
140
138
|
// The base URL is a dummy value just so we can process relative URLs
|
|
@@ -146,7 +144,7 @@ exports.getQueryParam = getQueryParam;
|
|
|
146
144
|
* Validates that all required params are provided
|
|
147
145
|
* @param params - the method parameters.
|
|
148
146
|
* @param requires - the required parameter names.
|
|
149
|
-
* @returns
|
|
147
|
+
* @returns null if no errors found, otherwise an Error instance
|
|
150
148
|
*/
|
|
151
149
|
function getMissingParams(params, requires) {
|
|
152
150
|
var missing;
|
|
@@ -180,7 +178,7 @@ exports.getMissingParams = getMissingParams;
|
|
|
180
178
|
* If null, then the "required params" check is bypassed.
|
|
181
179
|
* @param allParams - the names of all valid parameters.
|
|
182
180
|
* If null, then the "valid params" check is bypassed.
|
|
183
|
-
* @returns
|
|
181
|
+
* @returns null if no errors found, otherwise an Error instance
|
|
184
182
|
*/
|
|
185
183
|
function validateParams(params, requiredParams, allParams) {
|
|
186
184
|
var missing = [];
|
|
@@ -226,15 +224,15 @@ exports.validateParams = validateParams;
|
|
|
226
224
|
* as `undefined`, `null`, or the empty string.
|
|
227
225
|
*
|
|
228
226
|
* @param value - the parameter value
|
|
229
|
-
* @returns
|
|
227
|
+
* @returns true if "value" is either undefined, null or "" (empty string)
|
|
230
228
|
*/
|
|
231
229
|
function isMissing(value) {
|
|
232
230
|
return value === undefined || value === null || value === '';
|
|
233
231
|
}
|
|
234
232
|
/**
|
|
235
233
|
* Return true if 'text' is html
|
|
236
|
-
* @param
|
|
237
|
-
* @returns
|
|
234
|
+
* @param text - The 'text' to analyze
|
|
235
|
+
* @returns true if 'text' has html tags
|
|
238
236
|
*/
|
|
239
237
|
function isHTML(text) {
|
|
240
238
|
logger_1.default.debug("Determining if the text ".concat(text, " is HTML."));
|
|
@@ -244,9 +242,8 @@ exports.isHTML = isHTML;
|
|
|
244
242
|
/**
|
|
245
243
|
* Returns the first match from formats that is key the params map
|
|
246
244
|
* otherwise null
|
|
247
|
-
* @param
|
|
248
|
-
* @param
|
|
249
|
-
* @returns {string|null}
|
|
245
|
+
* @param params - The parameters.
|
|
246
|
+
* @param requires - The keys we want to check
|
|
250
247
|
*/
|
|
251
248
|
function getFormat(params, formats) {
|
|
252
249
|
if (!formats || !params) {
|
|
@@ -262,11 +259,8 @@ function getFormat(params, formats) {
|
|
|
262
259
|
exports.getFormat = getFormat;
|
|
263
260
|
/**
|
|
264
261
|
* This function builds a `form-data` object for each file parameter.
|
|
265
|
-
* @param
|
|
266
|
-
* @
|
|
267
|
-
* @param {string} fileParam.filename The filename of the file.
|
|
268
|
-
* @param {string} fileParam.contentType The content type of the file.
|
|
269
|
-
* @returns {FileObject}
|
|
262
|
+
* @param fileParam - The FileWithMetadata instance that contains the file information
|
|
263
|
+
* @returns the FileObject instance
|
|
270
264
|
*/
|
|
271
265
|
function buildRequestFileObject(fileParam) {
|
|
272
266
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -320,8 +314,8 @@ exports.buildRequestFileObject = buildRequestFileObject;
|
|
|
320
314
|
/**
|
|
321
315
|
* This function converts an object's keys to lower case.
|
|
322
316
|
* note: does not convert nested keys
|
|
323
|
-
* @param
|
|
324
|
-
* @returns
|
|
317
|
+
* @param obj - The object to convert the keys of.
|
|
318
|
+
* @returns the object with keys folded to lowercase
|
|
325
319
|
*/
|
|
326
320
|
function toLowerKeys(obj) {
|
|
327
321
|
var lowerCaseObj = {};
|
|
@@ -339,13 +333,12 @@ exports.toLowerKeys = toLowerKeys;
|
|
|
339
333
|
/**
|
|
340
334
|
* Constructs a service URL by formatting a parameterized URL.
|
|
341
335
|
*
|
|
342
|
-
* @param
|
|
343
|
-
* @param
|
|
336
|
+
* @param parameterizedUrl - a URL that contains variable placeholders, e.g. '\{scheme\}://ibm.com'.
|
|
337
|
+
* @param defaultUrlVariables - a Map of variable names to default values.
|
|
344
338
|
* Each variable in the parameterized URL must have a default value specified in this map.
|
|
345
|
-
* @param
|
|
346
|
-
* If a variable is not provided in this map,
|
|
347
|
-
*
|
|
348
|
-
* @returns {string} The formatted URL with all variable placeholders replaced by values.
|
|
339
|
+
* @param providedUrlVariables - a Map of variable names to desired values.
|
|
340
|
+
* If a variable is not provided in this map, the default variable value will be used instead.
|
|
341
|
+
* @returns the formatted URL with all variable placeholders replaced by values.
|
|
349
342
|
*/
|
|
350
343
|
function constructServiceUrl(parameterizedUrl, defaultUrlVariables, providedUrlVariables) {
|
|
351
344
|
// If null was passed, we set the variables to an empty map.
|
package/lib/querystring.d.ts
CHANGED
package/lib/querystring.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* (C) Copyright IBM Corp. 2019,
|
|
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.
|
|
@@ -18,8 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
/**
|
|
19
19
|
* Lightweight implementation for stringify-ing query params
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
21
|
+
* @param queryParams - the query params
|
|
22
|
+
* @returns the query string
|
|
23
23
|
*/
|
|
24
24
|
var stringify = function (queryParams) {
|
|
25
25
|
return Object.keys(queryParams)
|
package/lib/request-wrapper.d.ts
CHANGED
|
@@ -40,16 +40,14 @@ export declare class RequestWrapper {
|
|
|
40
40
|
* 2. Checks for missing parameters
|
|
41
41
|
* 3. Encode path and query parameters
|
|
42
42
|
* 4. Call the api
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @throws {Error}
|
|
43
|
+
* @returns ReadableStream|undefined
|
|
44
|
+
* @throws Error
|
|
46
45
|
*/
|
|
47
46
|
sendRequest(parameters: any): Promise<any>;
|
|
48
47
|
/**
|
|
49
48
|
* Format error returned by axios
|
|
50
|
-
* @param
|
|
51
|
-
* @
|
|
52
|
-
* @returns {Error}
|
|
49
|
+
* @param axiosError - the object returned by axios via rejection
|
|
50
|
+
* @returns the Error object
|
|
53
51
|
*/
|
|
54
52
|
formatError(axiosError: any): Error;
|
|
55
53
|
getHttpClient(): AxiosInstance;
|