@huaweicloud/huaweicloud-sdk-core
Advanced tools
Comparing version 3.0.8-beta to 3.0.9-beta
@@ -83,3 +83,3 @@ "use strict"; | ||
} | ||
builder.addHeaders("Content-Type", "application/json"); | ||
// builder.addHeaders("Content-Type", "application/json"); | ||
builder.addAllHeaders(httpRequest.headers); | ||
@@ -86,0 +86,0 @@ extend_1.default(httpRequest, builder.build()); |
@@ -83,3 +83,3 @@ "use strict"; | ||
} | ||
builder.addHeaders("Content-Type", "application/json"); | ||
// builder.addHeaders("Content-Type", "application/json"); | ||
builder.addAllHeaders(httpRequest.headers); | ||
@@ -86,0 +86,0 @@ extend_1.default(httpRequest, builder.build()); |
@@ -0,1 +1,64 @@ | ||
# 3.0.9-beta 2021-06-29 | ||
### HuaweiCloud SDK Core | ||
- _新增特性_ | ||
- 支持 multipart/form-data | ||
- _解决问题_ | ||
- 无 | ||
- _特性变更_ | ||
- 无 | ||
### HuaweiCloud SDK ECS | ||
- _新增特性_ | ||
- 无 | ||
- _解决问题_ | ||
- 解决了使用接口`NovaShowKeypair`获取秘钥,结果解析异常的问题 | ||
- _特性变更_ | ||
- 无 | ||
### HuaweiCloud SDK CCE | ||
- _新增特性_ | ||
- 无 | ||
- _解决问题_ | ||
- [Issue 20](https://github.com/huaweicloud/huaweicloud-sdk-go-v3/issues/20): 修复`extendParam`类型定义错误的问题 | ||
- [Issue 22](https://github.com/huaweicloud/huaweicloud-sdk-go-v3/issues/22): 修正接口`ListAddonInstances`的响应参数`status`可选值 | ||
- _特性变更_ | ||
- 接口`DeleteCluster`新增请求参数`tobedeleted` | ||
- 接口`CreateNodePool`、`ShowNodePool`、`UpdateNodePool`、`DeleteNodePool`新增请求参数`storage` | ||
### HuaweiCloud SDK IoTDA | ||
- _新增特性_ | ||
- 新增支持接口: | ||
- `ListComplexQueryDevice` | ||
- `UploadBatchTaskFile` | ||
- 下线订阅管理相关接口: | ||
- `ListSubscriptions` | ||
- `CreateSubscription` | ||
- `UpdateSubscription` | ||
- `ShowSubscription` | ||
- `DeleteSubscription` | ||
- _解决问题_ | ||
- 无 | ||
- _特性变更_ | ||
- 无 | ||
### HuaweiCloud SDK IAM | ||
- _新增特性_ | ||
- 无 | ||
- _解决问题_ | ||
- 无 | ||
- _特性变更_ | ||
- 接口 `CreateUsers` 新增请求体参数和响应体参数 _access_mode_ | ||
- 接口 `DeleteBindingDevice` 将请求体参数 _authentication_code_ 设置为必填参数 | ||
- 查询账号配额接口`ShowDomainQuota`的请求参数`type`增加可选值: | ||
- `assigment_group_mp` | ||
- `assigment_agency_mp` | ||
- `assigment_group_ep` | ||
- `assigment_user_ep` | ||
- 接口`KeystoneListPermissions`新增请求参数`permission_type`、`display_name`、`catalog`、`type` | ||
# 3.0.8-beta 2021-04-15 | ||
@@ -2,0 +65,0 @@ |
@@ -0,1 +1,65 @@ | ||
# 3.0.9-beta 2021-06-29 | ||
### HuaweiCloud SDK Core | ||
- _feature_ | ||
- Support multipart/form-data | ||
- _Bug Fix_ | ||
- None | ||
- _Change_ | ||
- None | ||
### HuaweiCloud SDK ECS | ||
- _Features_ | ||
- None | ||
- _Bug Fix_ | ||
- Solve the issue of abnormal parsing result when using interface `NovaShowKeypair` to obtain the secret key. | ||
- _Change_ | ||
- None | ||
### HuaweiCloud SDK CCE | ||
- _Features_ | ||
- None | ||
- _Bug Fix_ | ||
- [Issue 20](https://github.com/huaweicloud/huaweicloud-sdk-go-v3/issues/20): Fix the issue that the type of `extendParam` | ||
is defined incorrectly. | ||
- [Issue 22](https://github.com/huaweicloud/huaweicloud-sdk-go-v3/issues/22): Modify the optional value of response parameter `status` of interface `ListAddonInstances`. | ||
- _Change_ | ||
- Add the request parameter `tobedeleted` to the interface `DeleteCluster`. | ||
- Add a request parameter `storage` to interfaces `CreateNodePool`,`ShowNodePool`,`UpdateNodePool`,`DeleteNodePool`. | ||
### HuaweiCloud SDK IoTDA | ||
- _Features_ | ||
- Support more interfaces: | ||
- `UploadBatchTaskFile` | ||
- `ListComplexQueryDevice` | ||
- Remove interfaces: | ||
- `ListSubscriptions` | ||
- `CreateSubscription` | ||
- `UpdateSubscription` | ||
- `ShowSubscription` | ||
- `DeleteSubscription` | ||
- _Bug Fix_ | ||
- None | ||
- _Change_ | ||
- None | ||
### HuaweiCloud SDK IAM | ||
- _Features_ | ||
- None | ||
- _Bug Fix_ | ||
- None | ||
- _Change_ | ||
- Add the parameter `access_mode` to interface `CreateUsers`. | ||
- Change the parameter `authentication_code` of interface `DeleteBindingDevice` from required to optional. | ||
- Add optional values to request parameter `type` of the interface `ShowDomainQuota`: | ||
- `assigment_group_mp` | ||
- `assigment_agency_mp` | ||
- `assigment_group_ep` | ||
- `assigment_user_ep` | ||
- Add request parameters`permission_type`,`display_name`,`catalog`,`type` of interface `KeystoneListPermissions`. | ||
# 3.0.8-beta 2021-04-15 | ||
@@ -2,0 +66,0 @@ |
@@ -16,3 +16,3 @@ import { HttpClient } from "./http/HttpClient"; | ||
private buildRequest; | ||
private static extractResponse; | ||
private extractResponse; | ||
} |
@@ -53,10 +53,8 @@ "use strict"; | ||
// @ts-ignore | ||
return new Promise(function (resolve, reject) { | ||
_this.httpClient.sendRequest(request).then(function (res) { | ||
return resolve(HcClient.extractResponse(res)); | ||
}, function (err) { | ||
var error = err; | ||
var statusCode = error.status; | ||
return reject(ExceptionUtil_1.ExceptionUtil.generalException(statusCode, error.body)); | ||
}); | ||
return this.httpClient.sendRequest(request).then(function (res) { | ||
return _this.extractResponse(res); | ||
}, function (err) { | ||
var error = err; | ||
var statusCode = error.status; | ||
return ExceptionUtil_1.ExceptionUtil.generalException(statusCode, error.body); | ||
}); | ||
@@ -86,3 +84,3 @@ }; | ||
}; | ||
HcClient.extractResponse = function (result) { | ||
HcClient.prototype.extractResponse = function (result) { | ||
var headers = result.headers; | ||
@@ -89,0 +87,0 @@ var contentType = headers['content-type']; |
@@ -11,4 +11,5 @@ import { IHttpRequest } from './IHttpRequest'; | ||
private DEFAULT_HEADERS; | ||
constructor({ disableSslVerification, proxy, logger, logLevel, headers }: ClientOptions); | ||
constructor({ proxy, logger, logLevel, headers }: ClientOptions); | ||
sendRequest(httpRequest: IHttpRequest): Promise<any>; | ||
transformOptions(data: any, headers: any): any; | ||
/** | ||
@@ -15,0 +16,0 @@ * Format error returned by axios |
@@ -28,3 +28,3 @@ "use strict"; | ||
var axios_1 = __importDefault(require("axios")); | ||
var querystring = require("querystring"); | ||
var querystring_1 = require("querystring"); | ||
var HttpsProxyAgent = require("https-proxy-agent"); | ||
@@ -35,10 +35,12 @@ var logger_1 = require("../logger"); | ||
var _this = this; | ||
var _b = _a.disableSslVerification, disableSslVerification = _b === void 0 ? true : _b, _c = _a.proxy, proxy = _c === void 0 ? undefined : _c, _d = _a.logger, logger = _d === void 0 ? undefined : _d, _e = _a.logLevel, logLevel = _e === void 0 ? logger_1.LogLevel.INFO : _e, _f = _a.headers, headers = _f === void 0 ? {} : _f; | ||
var _b = _a.proxy, proxy = _b === void 0 ? '' : _b, _c = _a.logger, logger = _c === void 0 ? undefined : _c, _d = _a.logLevel, logLevel = _d === void 0 ? logger_1.LogLevel.INFO : _d, _e = _a.headers, headers = _e === void 0 ? {} : _e; | ||
// A request header consists of its case-insensitive name followed by a colon ':' | ||
// from: https://developer.mozilla.org/zh-TW/docs/Web/HTTP/Headers | ||
this.DEFAULT_HEADERS = { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
'content-type': 'application/json' | ||
}; | ||
// proxy | ||
var proxyAgent = undefined; | ||
if (proxy) { | ||
var proxyAgent; | ||
if (proxy && proxy !== '') { | ||
proxyAgent = HttpsProxyAgent(proxy); | ||
@@ -56,6 +58,2 @@ } | ||
} | ||
// override several axios defaults | ||
// axios sets the default Content-Type for `post`, `put`, and `patch` operations | ||
// to 'application/x-www-form-urlencoded'. This causes problems, so overriding the | ||
// defaults here | ||
this.axiosInstance = axios_1.default.create({ | ||
@@ -68,18 +66,26 @@ maxContentLength: Infinity, | ||
}); | ||
this.axiosInstance.interceptors.request.use(function (config) { | ||
_this.logger.debug('Request:', config); | ||
return config; | ||
}, function (error) { | ||
_this.logger.error('Error: ', error); | ||
// @ts-ignore | ||
return Promise.reject(error); | ||
this.axiosInstance.interceptors.request.use(function (request) { | ||
var url = request.url, method = request.method, data = request.data, headers = request.headers; | ||
_this.logger.debug("Request: " + method.toUpperCase() + " " + url + " " + JSON.stringify(headers) + " " + JSON.stringify(data)); | ||
return request; | ||
}); | ||
this.axiosInstance.interceptors.response.use(function (response) { | ||
_this.logger.debug('Response:', response); | ||
var _a = response.config, url = _a.url, method = _a.method, status = response.status, statusText = response.statusText, data = response.data, headers = response.headers; | ||
var statusStr = ''; | ||
if (status && statusText) { | ||
statusStr += status + ":" + statusText + " "; | ||
} | ||
else if (status) { | ||
statusStr += status + " "; | ||
} | ||
else if (statusText) { | ||
statusStr += statusText + " "; | ||
} | ||
var requestId = response.headers ? response.headers['x-request-id'] : undefined; | ||
var reponseLength = response.result ? JSON.stringify(response.result).length : 1; | ||
_this.logger.debug("Response: " + method.toUpperCase() + " " + statusStr + " " + url + " " + JSON.stringify(headers) + " " + JSON.stringify(data) + " " + reponseLength + " " + requestId); | ||
return response; | ||
}, function (error) { | ||
_this.logger.error('Error: ', error); | ||
// @ts-ignore | ||
return Promise.reject(error); | ||
}); | ||
delete this.axiosInstance.defaults.headers.post['Content-Type']; | ||
delete this.axiosInstance.defaults.headers.put['Content-Type']; | ||
this.logger.debug('initialized'); | ||
@@ -90,2 +96,3 @@ } | ||
var endpoint = httpRequest.endpoint, queryParams = httpRequest.queryParams, method = httpRequest.method, data = httpRequest.data, headers = httpRequest.headers; | ||
headers = headers || {}; | ||
this.logger.debug("send request start: " + endpoint + " "); | ||
@@ -103,8 +110,13 @@ // Path params | ||
paramsSerializer: function (params) { | ||
return querystring.stringify(params); | ||
return querystring_1.stringify(params); | ||
}, | ||
}; | ||
var methods = ['PUT', 'POST', 'PATCH', 'DELETE']; | ||
if (method && methods.indexOf(method.toUpperCase()) !== -1) { | ||
requestParams = Object.assign(requestParams, { | ||
transformRequest: [this.transformOptions.bind(this)] | ||
}); | ||
} | ||
DefaultHttpClient.httpReqParam = requestParams; | ||
return this.axiosInstance(requestParams).then(function (res) { | ||
// sometimes error responses will still trigger the `then` block - escape that behavior here | ||
DefaultHttpClient.httpResponse = res; | ||
@@ -115,7 +127,4 @@ if (!res) { | ||
; | ||
// these objects contain circular json structures and are not always relevant to the user | ||
// if the user wants them, they can be accessed through the debug properties | ||
delete res.config; | ||
delete res.request; | ||
// the other sdks use the interface `result` for the body | ||
res.result = res.data; | ||
@@ -133,25 +142,20 @@ delete res.data; | ||
} | ||
var requestId = res.headers ? res.headers['x-request-id'] : undefined; | ||
var reponseLength = res.result ? JSON.stringify(res.result).length : 1; | ||
_this.logger.info('"' + requestParams.method + ' ' + requestParams.url + '" ' + res.status + ' ' + reponseLength + ' ' + requestId); | ||
_this.logger.debug('request: ' + JSON.stringify(requestParams) + ". response: " + JSON.stringify(res)); | ||
return res; | ||
}, function (err) { | ||
_this.logger.error('http reqeust failed', err.message); | ||
var response = err.response; | ||
DefaultHttpClient.httpResponse = err; | ||
var requestId; | ||
var reponseLength; | ||
var status; | ||
if (response) { | ||
requestId = response.headers ? response.headers['x-request-id'] : undefined; | ||
reponseLength = response.data ? JSON.stringify(response.data).length : 1; | ||
status = response.status; | ||
} | ||
_this.logger.info('"' + requestParams.method + ' ' + requestParams.url + '" ' + status + ' ' + reponseLength + ' ' + requestId); | ||
_this.logger.debug('request: ' + JSON.stringify(requestParams) + ". response: " + JSON.stringify(err)); | ||
// return another promise that rejects with 'err' to be handled in generated code | ||
throw _this.formatError(err); | ||
}); | ||
}; | ||
DefaultHttpClient.prototype.transformOptions = function (data, headers) { | ||
if (headers['content-type'] === 'multipart/form-data') { | ||
// data is form-data object | ||
for (var _i = 0, _a = Object.entries(data.getHeaders()); _i < _a.length; _i++) { | ||
var _b = _a[_i], header = _b[0], value = _b[1]; | ||
headers[header] = value; | ||
} | ||
return data; | ||
} | ||
headers['content-type'] = 'application/json'; | ||
return JSON.stringify(data); | ||
}; | ||
/** | ||
@@ -219,2 +223,3 @@ * Format error returned by axios | ||
} | ||
this.logger.error("some error found:", error); | ||
return error; | ||
@@ -226,17 +231,2 @@ }; | ||
exports.DefaultHttpClient = DefaultHttpClient; | ||
/** | ||
* @private | ||
* @param {string} path | ||
* @param {Object} params | ||
* @returns {string} | ||
*/ | ||
function parsePath(path, params) { | ||
if (!path || !params) { | ||
return path; | ||
} | ||
return Object.keys(params).reduce(function (parsedPath, param) { | ||
var value = encodeURIComponent(params[param]); | ||
return parsedPath.replace(new RegExp("{" + param + "}"), value); | ||
}, path); | ||
} | ||
function stripTrailingSlash(url) { | ||
@@ -288,3 +278,2 @@ // Match a forward slash / at the end of the string ($) | ||
} | ||
this.logger.info("Parsing service error message: " + message); | ||
return message; | ||
@@ -291,0 +280,0 @@ } |
@@ -11,2 +11,3 @@ export interface IHttpRequest { | ||
getPathParams: () => any; | ||
responseHeaders: any; | ||
} | ||
@@ -22,2 +23,3 @@ export declare class HttpRequestImpl implements IHttpRequest { | ||
data: any; | ||
responseHeaders: any; | ||
getPathParams(): any; | ||
@@ -24,0 +26,0 @@ getQueryParams(): any; |
{ | ||
"name": "@huaweicloud/huaweicloud-sdk-core", | ||
"version": "3.0.8-beta", | ||
"version": "3.0.9-beta", | ||
"description": "Core code for Huaweicloud SDK for Node.js", | ||
@@ -11,3 +11,3 @@ "main": "huaweicloud-sdk-core.js", | ||
"lint": "tslint --project .", | ||
"test": "npm run build && nyc mocha --config .mocharc.json logger/*.spec.js" | ||
"test": "npm run build && nyc mocha --config .mocharc.json tests/**/*.spec.js" | ||
}, | ||
@@ -25,3 +25,5 @@ "repository": { | ||
"extend": "^3.0.2", | ||
"form-data": "^4.0.0", | ||
"https-proxy-agent": "^5.0.0", | ||
"is-stream": "^2.0.0", | ||
"lodash": "^4.17.15", | ||
@@ -35,4 +37,6 @@ "log4js": "^6.3.0", | ||
"@types/mocha": "^8.2.2", | ||
"busboy": "^0.3.1", | ||
"chai": "^4.3.4", | ||
"mocha": "^8.3.2", | ||
"nock": "^13.1.0", | ||
"nyc": "^15.1.0", | ||
@@ -39,0 +43,0 @@ "shx": "^0.3.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110290
11
11
2061
+ Addedform-data@^4.0.0
+ Addedis-stream@^2.0.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)