@azure-rest/core-client
Advanced tools
Comparing version 1.0.0-alpha.20210623.4 to 1.0.0-alpha.20210701.2
@@ -1,3 +0,10 @@ | ||
# Release History | ||
# Release History\ | ||
## 1.0.0-beta.5 (2021-06-24) | ||
### Features Added | ||
- Expose client option to set `allowInsecureConnection` to support http. [#15831](https://github.com/Azure/azure-sdk-for-js/pull/15831) | ||
- Add new createRestError which takes a response to create a RestError. [#15831](https://github.com/Azure/azure-sdk-for-js/pull/15831) | ||
## 1.0.0-beta.4 (2021-05-27) | ||
@@ -4,0 +11,0 @@ |
@@ -19,27 +19,28 @@ // Copyright (c) Microsoft Corporation. | ||
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions); | ||
const { allowInsecureConnection } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
@@ -46,0 +47,0 @@ }; |
@@ -9,2 +9,3 @@ // Copyright (c) Microsoft Corporation. | ||
export { isCertificateCredential } from "./certificateCredential"; | ||
export { createRestError } from "./restError"; | ||
export * from "./common"; | ||
@@ -11,0 +12,0 @@ export * from "./getClient"; |
@@ -113,2 +113,26 @@ 'use strict'; | ||
/** | ||
* Creates a rest error from a PathUnchecked response | ||
*/ | ||
function createRestError(message, response) { | ||
return new coreRestPipeline.RestError(message, { | ||
statusCode: statusCodeToNumber(response.status), | ||
request: response.request, | ||
response: toPipelineResponse(response), | ||
}); | ||
} | ||
function toPipelineResponse(response) { | ||
var _a; | ||
return { | ||
headers: coreRestPipeline.createHttpHeaders(response.headers), | ||
request: response.request, | ||
status: (_a = statusCodeToNumber(response.status)) !== null && _a !== void 0 ? _a : -1, | ||
}; | ||
} | ||
function statusCodeToNumber(statusCode) { | ||
const status = Number.parseInt(statusCode); | ||
return Number.isNaN(status) ? undefined : status; | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
/** | ||
* Helper function to send request used by the client | ||
@@ -212,27 +236,28 @@ * @param method - method to use to send the request | ||
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions); | ||
const { allowInsecureConnection } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, options, args); | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
}, | ||
@@ -269,4 +294,5 @@ }; | ||
exports.createDefaultPipeline = createDefaultPipeline; | ||
exports.createRestError = createRestError; | ||
exports.getClient = getClient; | ||
exports.isCertificateCredential = isCertificateCredential; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@azure-rest/core-client", | ||
"version": "1.0.0-alpha.20210623.4", | ||
"version": "1.0.0-alpha.20210701.2", | ||
"description": "Core library for interfacing with AutoRest rest level generated code", | ||
@@ -11,3 +11,3 @@ "sdk-type": "client", | ||
}, | ||
"types": "types/src/latest/core-client-rest.d.ts", | ||
"types": "types/latest/core-client-rest.d.ts", | ||
"scripts": { | ||
@@ -59,3 +59,3 @@ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=12.0.0" | ||
}, | ||
@@ -67,3 +67,3 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client-rest/", | ||
"@azure/core-auth": "^1.3.0", | ||
"@azure/core-rest-pipeline": "^1.0.3", | ||
"@azure/core-rest-pipeline": "^1.1.0", | ||
"tslib": "^2.2.0" | ||
@@ -75,3 +75,3 @@ }, | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^8.0.0", | ||
"@types/node": "^12.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0-alpha", | ||
@@ -78,0 +78,0 @@ "@azure/dev-tool": "^1.0.0-alpha", |
@@ -9,4 +9,9 @@ # Azure Rest Core client library for JavaScript (Experimental) | ||
- [Node.js](https://nodejs.org) version > 8.x | ||
### Currently supported environments | ||
- [LTS versions of Node.js](https://nodejs.org/about/releases/) | ||
- Latest versions of Safari, Chrome, Edge, and Firefox. | ||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. | ||
### Installation | ||
@@ -13,0 +18,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
88545
32
41
603