@azure-rest/core-client
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
# Release History | ||
## 1.0.0-beta.9 (2022-04-07) | ||
### Features Added | ||
- Handle Binary and FormData content. [#18753](https://github.com/Azure/azure-sdk-for-js/pull/18753) | ||
- Support custom base url with path parameters. [#19463](https://github.com/Azure/azure-sdk-for-js/pull/19463) | ||
- Added new `ClientOptions` member `additionalPolicies` to allow passing custom pipeline policies to client constructors. [#20175](https://github.com/Azure/azure-sdk-for-js/pull/20175) | ||
## 1.0.0-beta.8 (2021-11-04) | ||
@@ -4,0 +12,0 @@ |
@@ -7,2 +7,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy"; | ||
import { apiVersionPolicy } from "./apiVersionPolicy"; | ||
let cachedHttpClient; | ||
@@ -27,2 +28,3 @@ /** | ||
pipeline.addPolicy(logPolicy(), { afterPhase: "Retry" }); | ||
pipeline.addPolicy(apiVersionPolicy(options)); | ||
if (credential) { | ||
@@ -29,0 +31,0 @@ if (isTokenCredential(credential)) { |
@@ -9,2 +9,3 @@ // Copyright (c) Microsoft Corporation. | ||
export function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) { | ||
var _a; | ||
let credentials; | ||
@@ -20,28 +21,38 @@ if (credentialsOrPipelineOptions) { | ||
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions); | ||
const { allowInsecureConnection } = clientOptions; | ||
if ((_a = clientOptions.additionalPolicies) === null || _a === void 0 ? void 0 : _a.length) { | ||
for (const { policy, position } of clientOptions.additionalPolicies) { | ||
// Sign happens after Retry and is commonly needed to occur | ||
// before policies that intercept post-retry. | ||
const afterPhase = position === "perRetry" ? "Sign" : undefined; | ||
pipeline.addPolicy(policy, { | ||
afterPhase, | ||
}); | ||
} | ||
} | ||
const { allowInsecureConnection, httpClient } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
@@ -56,13 +67,6 @@ }; | ||
} | ||
function buildSendRequest(method, clientOptions, baseUrl, path, pipeline, requestOptions = {}, args = []) { | ||
var _a; | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = [], httpClient) { | ||
// If the client has an api-version and the request doesn't specify one, inject the one in the client options | ||
if (!((_a = requestOptions.queryParameters) === null || _a === void 0 ? void 0 : _a["api-version"]) && clientOptions.apiVersion) { | ||
if (!requestOptions.queryParameters) { | ||
requestOptions.queryParameters = {}; | ||
} | ||
requestOptions.queryParameters["api-version"] = clientOptions.apiVersion; | ||
} | ||
const url = buildRequestUrl(baseUrl, path, args, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions, httpClient); | ||
} | ||
@@ -69,0 +73,0 @@ function isCredential(param) { |
@@ -5,2 +5,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { getCachedDefaultHttpsClient } from "./clientHelpers"; | ||
import { binaryArrayToString, stringToBinaryArray } from "./helpers/getBinaryBody"; | ||
/** | ||
@@ -12,10 +13,11 @@ * Helper function to send request used by the client | ||
* @param options - request options | ||
* @param customHttpClient - a custom HttpClient to use when making the request | ||
* @returns returns and HttpResponse | ||
*/ | ||
export async function sendRequest(method, url, pipeline, options = {}) { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
export async function sendRequest(method, url, pipeline, options = {}, customHttpClient) { | ||
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient(); | ||
const request = buildPipelineRequest(method, url, options); | ||
const response = await pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = response.headers.toJSON(); | ||
const parsedBody = getResponseBody(response); | ||
const parsedBody = getResponseBody(response, options); | ||
return { | ||
@@ -60,10 +62,26 @@ request, | ||
*/ | ||
function getRequestBody(body, contentType = "application/json") { | ||
function getRequestBody(body, contentType = "") { | ||
if (body === undefined) { | ||
return { body: undefined }; | ||
} | ||
if (!contentType && typeof body === "string") { | ||
return { body }; | ||
} | ||
const firstType = contentType.split(";")[0]; | ||
if (firstType === "application/json") { | ||
return { body: JSON.stringify(body) }; | ||
} | ||
if (ArrayBuffer.isView(body)) { | ||
if (body instanceof Uint8Array) { | ||
return { body: binaryArrayToString(body) }; | ||
} | ||
else { | ||
return { body: JSON.stringify(body) }; | ||
} | ||
} | ||
switch (firstType) { | ||
case "multipart/form-data": | ||
return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) }; | ||
return isFormData(body) | ||
? { formData: processFormData(body) } | ||
: { body: JSON.stringify(body) }; | ||
case "text/plain": | ||
@@ -79,5 +97,25 @@ return { body: String(body) }; | ||
/** | ||
* Checks if binary data is in Uint8Array format, if so decode it to a binary string | ||
* to send over the wire | ||
*/ | ||
function processFormData(formData) { | ||
if (!formData) { | ||
return formData; | ||
} | ||
const processedFormData = {}; | ||
for (const element in formData) { | ||
const item = formData[element]; | ||
if (item instanceof Uint8Array) { | ||
processedFormData[element] = binaryArrayToString(item); | ||
} | ||
else { | ||
processedFormData[element] = item; | ||
} | ||
} | ||
return processedFormData; | ||
} | ||
/** | ||
* Prepares the response body | ||
*/ | ||
function getResponseBody(response) { | ||
function getResponseBody(response, requestOptions) { | ||
var _a, _b; | ||
@@ -91,2 +129,9 @@ // Set the default response type | ||
} | ||
/** | ||
* If we know from options or from the content type that we are receiving binary content, | ||
* encode it into a UInt8Array | ||
*/ | ||
if (requestOptions.binaryResponse || isBinaryContentType(firstType)) { | ||
return stringToBinaryArray(bodyToParse); | ||
} | ||
// Default to "application/json" and fallback to string; | ||
@@ -118,2 +163,14 @@ try { | ||
} | ||
function isBinaryContentType(contentType) { | ||
return [ | ||
"application/octet-stream", | ||
"application/x-rdp", | ||
"image/bmp", | ||
"image/gif", | ||
"image/jpeg", | ||
"image/png", | ||
"application/pdf", | ||
"application/zip", | ||
].includes(contentType); | ||
} | ||
//# sourceMappingURL=sendRequest.js.map |
@@ -17,2 +17,3 @@ // Copyright (c) Microsoft Corporation. | ||
} | ||
baseUrl = buildBaseUrl(baseUrl, options); | ||
for (const pathParam of pathParameters) { | ||
@@ -45,2 +46,33 @@ let value = pathParam; | ||
} | ||
export function buildBaseUrl(baseUrl, options) { | ||
var _a; | ||
if (!options.pathParameters) { | ||
return baseUrl; | ||
} | ||
const pathParams = options.pathParameters; | ||
for (const [key, param] of Object.entries(pathParams)) { | ||
if (param === undefined || param === null) { | ||
throw new Error(`Path parameters ${key} must not be undefined or null`); | ||
} | ||
if (!param.toString || typeof param.toString !== "function") { | ||
throw new Error(`Path parameters must be able to be represented as string, ${key} can't`); | ||
} | ||
let value = param.toISOString !== undefined ? param.toISOString() : String(param); | ||
if (!options.skipUrlEncoding) { | ||
value = encodeURIComponent(param); | ||
} | ||
baseUrl = (_a = replaceAll(baseUrl, `{${key}}`, value)) !== null && _a !== void 0 ? _a : ""; | ||
} | ||
return baseUrl; | ||
} | ||
/** | ||
* Replace all of the instances of searchValue in value with the provided replaceValue. | ||
* @param value - The value to search and replace in. | ||
* @param searchValue - The value to search for in the value argument. | ||
* @param replaceValue - The value to replace searchValue with in the value argument. | ||
* @returns The value where each instance of searchValue was replaced with replacedValue. | ||
*/ | ||
export function replaceAll(value, searchValue, replaceValue) { | ||
return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || ""); | ||
} | ||
//# sourceMappingURL=urlHelpers.js.map |
@@ -100,2 +100,23 @@ 'use strict'; | ||
// Copyright (c) Microsoft Corporation. | ||
const apiVersionPolicyName = "ApiVersionPolicy"; | ||
/** | ||
* Creates a policy that sets the apiVersion as a query parameter on every request | ||
* @param options - Client options | ||
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request | ||
*/ | ||
function apiVersionPolicy(options) { | ||
return { | ||
name: apiVersionPolicyName, | ||
sendRequest: (req, next) => { | ||
if (options.apiVersion) { | ||
const url$1 = new url.URL(req.url); | ||
url$1.searchParams.append("api-version", options.apiVersion); | ||
req.url = url$1.toString(); | ||
} | ||
return next(req); | ||
}, | ||
}; | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
let cachedHttpClient; | ||
@@ -120,2 +141,3 @@ /** | ||
pipeline.addPolicy(coreRestPipeline.logPolicy(), { afterPhase: "Retry" }); | ||
pipeline.addPolicy(apiVersionPolicy(options)); | ||
if (credential) { | ||
@@ -150,3 +172,26 @@ if (coreAuth.isTokenCredential(credential)) { | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
/** | ||
* Converts a string representing binary content into a Uint8Array | ||
*/ | ||
function stringToBinaryArray(content) { | ||
const arr = new Uint8Array(content.length); | ||
for (let i = 0; i < content.length; i++) { | ||
arr[i] = content.charCodeAt(i); | ||
} | ||
return arr; | ||
} | ||
/** | ||
* Converts binary content to its string representation | ||
*/ | ||
function binaryArrayToString(content) { | ||
let decodedBody = ""; | ||
for (const element of content) { | ||
decodedBody += String.fromCharCode(element); | ||
} | ||
return decodedBody; | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
/** | ||
* Helper function to send request used by the client | ||
@@ -157,10 +202,11 @@ * @param method - method to use to send the request | ||
* @param options - request options | ||
* @param customHttpClient - a custom HttpClient to use when making the request | ||
* @returns returns and HttpResponse | ||
*/ | ||
async function sendRequest(method, url, pipeline, options = {}) { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
async function sendRequest(method, url, pipeline, options = {}, customHttpClient) { | ||
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient(); | ||
const request = buildPipelineRequest(method, url, options); | ||
const response = await pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = response.headers.toJSON(); | ||
const parsedBody = getResponseBody(response); | ||
const parsedBody = getResponseBody(response, options); | ||
return { | ||
@@ -205,10 +251,26 @@ request, | ||
*/ | ||
function getRequestBody(body, contentType = "application/json") { | ||
function getRequestBody(body, contentType = "") { | ||
if (body === undefined) { | ||
return { body: undefined }; | ||
} | ||
if (!contentType && typeof body === "string") { | ||
return { body }; | ||
} | ||
const firstType = contentType.split(";")[0]; | ||
if (firstType === "application/json") { | ||
return { body: JSON.stringify(body) }; | ||
} | ||
if (ArrayBuffer.isView(body)) { | ||
if (body instanceof Uint8Array) { | ||
return { body: binaryArrayToString(body) }; | ||
} | ||
else { | ||
return { body: JSON.stringify(body) }; | ||
} | ||
} | ||
switch (firstType) { | ||
case "multipart/form-data": | ||
return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) }; | ||
return isFormData(body) | ||
? { formData: processFormData(body) } | ||
: { body: JSON.stringify(body) }; | ||
case "text/plain": | ||
@@ -224,5 +286,25 @@ return { body: String(body) }; | ||
/** | ||
* Checks if binary data is in Uint8Array format, if so decode it to a binary string | ||
* to send over the wire | ||
*/ | ||
function processFormData(formData) { | ||
if (!formData) { | ||
return formData; | ||
} | ||
const processedFormData = {}; | ||
for (const element in formData) { | ||
const item = formData[element]; | ||
if (item instanceof Uint8Array) { | ||
processedFormData[element] = binaryArrayToString(item); | ||
} | ||
else { | ||
processedFormData[element] = item; | ||
} | ||
} | ||
return processedFormData; | ||
} | ||
/** | ||
* Prepares the response body | ||
*/ | ||
function getResponseBody(response) { | ||
function getResponseBody(response, requestOptions) { | ||
var _a, _b; | ||
@@ -236,2 +318,9 @@ // Set the default response type | ||
} | ||
/** | ||
* If we know from options or from the content type that we are receiving binary content, | ||
* encode it into a UInt8Array | ||
*/ | ||
if (requestOptions.binaryResponse || isBinaryContentType(firstType)) { | ||
return stringToBinaryArray(bodyToParse); | ||
} | ||
// Default to "application/json" and fallback to string; | ||
@@ -263,2 +352,14 @@ try { | ||
} | ||
function isBinaryContentType(contentType) { | ||
return [ | ||
"application/octet-stream", | ||
"application/x-rdp", | ||
"image/bmp", | ||
"image/gif", | ||
"image/jpeg", | ||
"image/png", | ||
"application/pdf", | ||
"application/zip", | ||
].includes(contentType); | ||
} | ||
@@ -279,2 +380,3 @@ // Copyright (c) Microsoft Corporation. | ||
} | ||
baseUrl = buildBaseUrl(baseUrl, options); | ||
for (const pathParam of pathParameters) { | ||
@@ -307,5 +409,37 @@ let value = pathParam; | ||
} | ||
function buildBaseUrl(baseUrl, options) { | ||
var _a; | ||
if (!options.pathParameters) { | ||
return baseUrl; | ||
} | ||
const pathParams = options.pathParameters; | ||
for (const [key, param] of Object.entries(pathParams)) { | ||
if (param === undefined || param === null) { | ||
throw new Error(`Path parameters ${key} must not be undefined or null`); | ||
} | ||
if (!param.toString || typeof param.toString !== "function") { | ||
throw new Error(`Path parameters must be able to be represented as string, ${key} can't`); | ||
} | ||
let value = param.toISOString !== undefined ? param.toISOString() : String(param); | ||
if (!options.skipUrlEncoding) { | ||
value = encodeURIComponent(param); | ||
} | ||
baseUrl = (_a = replaceAll(baseUrl, `{${key}}`, value)) !== null && _a !== void 0 ? _a : ""; | ||
} | ||
return baseUrl; | ||
} | ||
/** | ||
* Replace all of the instances of searchValue in value with the provided replaceValue. | ||
* @param value - The value to search and replace in. | ||
* @param searchValue - The value to search for in the value argument. | ||
* @param replaceValue - The value to replace searchValue with in the value argument. | ||
* @returns The value where each instance of searchValue was replaced with replacedValue. | ||
*/ | ||
function replaceAll(value, searchValue, replaceValue) { | ||
return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || ""); | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) { | ||
var _a; | ||
let credentials; | ||
@@ -321,28 +455,38 @@ if (credentialsOrPipelineOptions) { | ||
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions); | ||
const { allowInsecureConnection } = clientOptions; | ||
if ((_a = clientOptions.additionalPolicies) === null || _a === void 0 ? void 0 : _a.length) { | ||
for (const { policy, position } of clientOptions.additionalPolicies) { | ||
// Sign happens after Retry and is commonly needed to occur | ||
// before policies that intercept post-retry. | ||
const afterPhase = position === "perRetry" ? "Sign" : undefined; | ||
pipeline.addPolicy(policy, { | ||
afterPhase, | ||
}); | ||
} | ||
} | ||
const { allowInsecureConnection, httpClient } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
@@ -357,13 +501,6 @@ }; | ||
} | ||
function buildSendRequest(method, clientOptions, baseUrl, path, pipeline, requestOptions = {}, args = []) { | ||
var _a; | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = [], httpClient) { | ||
// If the client has an api-version and the request doesn't specify one, inject the one in the client options | ||
if (!((_a = requestOptions.queryParameters) === null || _a === void 0 ? void 0 : _a["api-version"]) && clientOptions.apiVersion) { | ||
if (!requestOptions.queryParameters) { | ||
requestOptions.queryParameters = {}; | ||
} | ||
requestOptions.queryParameters["api-version"] = clientOptions.apiVersion; | ||
} | ||
const url = buildRequestUrl(baseUrl, path, args, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions, httpClient); | ||
} | ||
@@ -370,0 +507,0 @@ function isCredential(param) { |
{ | ||
"name": "@azure-rest/core-client", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"description": "Core library for interfacing with AutoRest rest level generated code", | ||
@@ -15,7 +15,6 @@ "sdk-type": "client", | ||
"build:samples": "echo Obsolete", | ||
"build:test": "tsc -p . && rollup -c 2>&1", | ||
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local", | ||
"build:test": "tsc -p . && dev-tool run bundle", | ||
"build": "npm run clean && tsc -p . && dev-tool run bundle && api-extractor run --local", | ||
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", | ||
"clean": "rimraf dist dist-* temp types *.tgz *.log", | ||
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src", | ||
"execute:samples": "echo skipped", | ||
@@ -32,3 +31,3 @@ "extract-api": "tsc -p . && api-extractor run --local", | ||
"test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node", | ||
"test": "npm run clean && tsc -p . && npm run unit-test:node && rollup -c 2>&1 && npm run unit-test:browser && npm run integration-test", | ||
"test": "npm run clean && tsc -p . && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", | ||
"unit-test:browser": "karma start --single-run", | ||
@@ -63,3 +62,3 @@ "unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"", | ||
"@azure/core-auth": "^1.3.0", | ||
"@azure/core-rest-pipeline": "^1.1.0", | ||
"@azure/core-rest-pipeline": "^1.5.0", | ||
"@azure/core-util": "^1.0.0-beta.1", | ||
@@ -69,2 +68,4 @@ "tslib": "^2.2.0" | ||
"devDependencies": { | ||
"@azure/dev-tool": "^1.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0", | ||
"@microsoft/api-extractor": "^7.18.11", | ||
@@ -74,4 +75,3 @@ "@types/chai": "^4.1.6", | ||
"@types/node": "^12.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0", | ||
"@azure/dev-tool": "^1.0.0", | ||
"@types/sinon": "^9.0.4", | ||
"chai": "^4.2.0", | ||
@@ -81,3 +81,2 @@ "cross-env": "^7.0.2", | ||
"inherits": "^2.0.3", | ||
"karma": "^6.2.0", | ||
"karma-chrome-launcher": "^3.0.0", | ||
@@ -90,15 +89,13 @@ "karma-coverage": "^2.0.0", | ||
"karma-junit-reporter": "^2.0.1", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-mocha": "^2.0.1", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"karma": "^6.2.0", | ||
"mocha-junit-reporter": "^2.0.0", | ||
"mocha": "^7.1.1", | ||
"mocha-junit-reporter": "^1.18.0", | ||
"prettier": "2.2.1", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.16.3", | ||
"sinon": "^9.0.2", | ||
"typescript": "~4.2.0", | ||
"util": "^0.12.1", | ||
"typedoc": "0.15.2" | ||
"typescript": "~4.2.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# Azure Rest Core client library for JavaScript (Experimental) | ||
# Azure Rest Core client library for JavaScript | ||
@@ -3,0 +3,0 @@ This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients |
@@ -6,5 +6,7 @@ /** | ||
import { HttpClient } from '@azure/core-rest-pipeline'; | ||
import { KeyCredential } from '@azure/core-auth'; | ||
import { Pipeline } from '@azure/core-rest-pipeline'; | ||
import { PipelineOptions } from '@azure/core-rest-pipeline'; | ||
import { PipelinePolicy } from '@azure/core-rest-pipeline'; | ||
import { PipelineRequest } from '@azure/core-rest-pipeline'; | ||
@@ -17,2 +19,19 @@ import { RawHttpHeaders } from '@azure/core-rest-pipeline'; | ||
/** | ||
* Used to configure additional policies added to the pipeline at construction. | ||
*/ | ||
export declare interface AdditionalPolicyConfig { | ||
/** | ||
* A policy to be added. | ||
*/ | ||
policy: PipelinePolicy; | ||
/** | ||
* Determines if this policy be applied before or after retry logic. | ||
* Only use `perRetry` if you need to modify the request again | ||
* each time the operation is retried due to retryable service | ||
* issues. | ||
*/ | ||
position: "perCall" | "perRetry"; | ||
} | ||
/** | ||
* Represents a certificate credential for authentication. | ||
@@ -85,2 +104,10 @@ */ | ||
allowInsecureConnection?: boolean; | ||
/** | ||
* Additional policies to include in the HTTP pipeline. | ||
*/ | ||
additionalPolicies?: AdditionalPolicyConfig[]; | ||
/** | ||
* Specify a custom HttpClient when making requests. | ||
*/ | ||
httpClient?: HttpClient; | ||
}; | ||
@@ -191,2 +218,11 @@ | ||
skipUrlEncoding?: boolean; | ||
/** | ||
* With this property set to true, the response body will be returned | ||
* as a binary array UInt8Array | ||
*/ | ||
binaryResponse?: boolean; | ||
/** | ||
* Path parameters for custom the base url | ||
*/ | ||
pathParameters?: Record<string, any>; | ||
}; | ||
@@ -193,0 +229,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
Sorry, the diff of this file is not supported yet
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
146007
28
35
1272