@azure/core-rest-pipeline
Advanced tools
Comparing version 1.0.0-alpha.20210303.2 to 1.0.0-beta.2
# Release History | ||
## 1.0.0-beta.2 (Unreleased) | ||
## 1.0.0-beta.2 (2021-03-10) | ||
- Renamed interfaces with `HTTPS` in the name to have `HTTP` instead. | ||
- Changed from exposing `DefaultHttpsClient` as a class directly, to providing `createDefaultHttpsClient()` to instantiate the appropriate runtime class. | ||
@@ -6,0 +7,0 @@ - Fix an issue when passing in proxy hosts. [PR 13911](https://github.com/Azure/azure-sdk-for-js/pull/13911) |
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
export { createEmptyPipeline, createPipelineFromOptions } from "./pipeline"; | ||
export { createDefaultHttpsClient } from "./defaultHttpsClient"; | ||
export { createDefaultHttpClient } from "./defaultHttpClient"; | ||
export { createHttpHeaders } from "./httpHeaders"; | ||
@@ -6,0 +6,0 @@ export { createPipelineRequest } from "./pipelineRequest"; |
@@ -21,3 +21,3 @@ // Copyright (c) Microsoft Corporation. | ||
*/ | ||
class HttpsPipeline { | ||
class HttpPipeline { | ||
constructor(policies = []) { | ||
@@ -59,3 +59,3 @@ this._policies = []; | ||
} | ||
sendRequest(httpsClient, request) { | ||
sendRequest(httpClient, request) { | ||
const policies = this.getOrderedPolicies(); | ||
@@ -66,3 +66,3 @@ const pipeline = policies.reduceRight((next, policy) => { | ||
}; | ||
}, (req) => httpsClient.sendRequest(req)); | ||
}, (req) => httpClient.sendRequest(req)); | ||
return pipeline(request); | ||
@@ -77,6 +77,6 @@ } | ||
clone() { | ||
return new HttpsPipeline(this._policies); | ||
return new HttpPipeline(this._policies); | ||
} | ||
static create() { | ||
return new HttpsPipeline(); | ||
return new HttpPipeline(); | ||
} | ||
@@ -255,3 +255,3 @@ orderPolicies() { | ||
export function createEmptyPipeline() { | ||
return HttpsPipeline.create(); | ||
return HttpPipeline.create(); | ||
} | ||
@@ -263,3 +263,3 @@ /** | ||
export function createPipelineFromOptions(options) { | ||
const pipeline = HttpsPipeline.create(); | ||
const pipeline = HttpPipeline.create(); | ||
if (isNode) { | ||
@@ -266,0 +266,0 @@ pipeline.addPolicy(proxyPolicy(options.proxyOptions)); |
@@ -14,3 +14,3 @@ // Copyright (c) Microsoft Corporation. | ||
this.formData = options.formData; | ||
this.keepAlive = (_d = options.keepAlive) !== null && _d !== void 0 ? _d : true; | ||
this.disableKeepAlive = (_d = options.disableKeepAlive) !== null && _d !== void 0 ? _d : false; | ||
this.proxySettings = options.proxySettings; | ||
@@ -20,3 +20,3 @@ this.streamResponseStatusCodes = options.streamResponseStatusCodes; | ||
this.abortSignal = options.abortSignal; | ||
this.spanOptions = options.spanOptions; | ||
this.tracingOptions = options.tracingOptions; | ||
this.onUploadProgress = options.onUploadProgress; | ||
@@ -23,0 +23,0 @@ this.onDownloadProgress = options.onDownloadProgress; |
@@ -32,5 +32,3 @@ // Copyright (c) Microsoft Corporation. | ||
abortSignal: request.abortSignal, | ||
tracingOptions: { | ||
spanOptions: request.spanOptions | ||
} | ||
tracingOptions: request.tracingOptions | ||
}); | ||
@@ -37,0 +35,0 @@ request.headers.set("Authorization", `Bearer ${token}`); |
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { __awaiter } from "tslib"; | ||
import { getTracer, getTraceParentHeader } from "@azure/core-tracing"; | ||
import { getTraceParentHeader, createSpanFunction } from "@azure/core-tracing"; | ||
import { SpanKind } from "@opentelemetry/api"; | ||
import { URL } from "../util/url"; | ||
import { getUserAgentValue } from "../util/userAgent"; | ||
const createSpan = createSpanFunction({ | ||
packagePrefix: "", | ||
namespace: "" | ||
}); | ||
/** | ||
@@ -23,12 +27,12 @@ * The programmatic identifier of the tracingPolicy. | ||
sendRequest(request, next) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!request.spanOptions || !request.spanOptions.parent) { | ||
if (!((_a = request.tracingOptions) === null || _a === void 0 ? void 0 : _a.spanOptions) || !((_b = request.tracingOptions.spanOptions) === null || _b === void 0 ? void 0 : _b.parent)) { | ||
return next(request); | ||
} | ||
// create a new span | ||
const tracer = getTracer(); | ||
const spanOptions = Object.assign(Object.assign({}, request.spanOptions), { kind: SpanKind.CLIENT }); | ||
const tracingOptions = Object.assign(Object.assign({}, request.tracingOptions), { spanOptions: Object.assign(Object.assign({}, request.tracingOptions.spanOptions), { kind: SpanKind.CLIENT }) }); | ||
const url = new URL(request.url); | ||
const path = url.pathname || "/"; | ||
const span = tracer.startSpan(path, spanOptions); | ||
const { span } = createSpan(path, { tracingOptions }); | ||
span.setAttributes({ | ||
@@ -35,0 +39,0 @@ "http.method": request.method, |
{ | ||
"name": "@azure/core-rest-pipeline", | ||
"version": "1.0.0-alpha.20210303.2", | ||
"description": "Isomorphic client library for making HTTPS requests in node.js and browser.", | ||
"version": "1.0.0-beta.2", | ||
"description": "Isomorphic client library for making HTTP requests in node.js and browser.", | ||
"sdk-type": "client", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"browser": { | ||
"./dist-esm/src/defaultHttpsClient.js": "./dist-esm/src/defaultHttpsClient.browser.js", | ||
"./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.browser.js", | ||
"./dist-esm/src/policies/decompressResponsePolicy.js": "./dist-esm/src/policies/decompressResponsePolicy.browser.js", | ||
@@ -18,7 +18,7 @@ "./dist-esm/src/policies/formDataPolicy.js": "./dist-esm/src/policies/formDataPolicy.browser.js", | ||
}, | ||
"types": "types/latest/core-rest-pipeline.d.ts", | ||
"types": "core-rest-pipeline.shims.d.ts", | ||
"typesVersions": { | ||
"<3.6": { | ||
"types/latest/src/*": [ | ||
"types/3.1/src/*" | ||
"core-rest-pipeline.shims.d.ts": [ | ||
"core-rest-pipeline.shims-3_1.d.ts" | ||
] | ||
@@ -64,5 +64,8 @@ } | ||
"dist-esm/src/", | ||
"types/", | ||
"README.md", | ||
"LICENSE" | ||
"types/3.1/core-rest-pipeline.d.ts", | ||
"types/latest/core-rest-pipeline.d.ts", | ||
"core-rest-pipeline.shims.d.ts", | ||
"core-rest-pipeline.shims-3_1.d.ts", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
@@ -96,3 +99,3 @@ "repository": "github:Azure/azure-sdk-for-js", | ||
"@azure/core-auth": "^1.2.0", | ||
"@azure/core-tracing": "^1.0.0-alpha", | ||
"@azure/core-tracing": "1.0.0-preview.10", | ||
"@azure/logger": "^1.0.0", | ||
@@ -117,3 +120,3 @@ "@opentelemetry/api": "^0.10.2", | ||
"@types/uuid": "^8.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0-alpha", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0", | ||
"chai": "^4.2.0", | ||
@@ -120,0 +123,0 @@ "downlevel-dts": "~0.4.0", |
@@ -33,8 +33,8 @@ # Azure Core HTTP client library for JavaScript (Experimental) | ||
### HttpsClient | ||
### HttpClient | ||
An `HttpsClient` is any object that satisfies the following interface to implement a `SendRequest` method: | ||
An `HttpClient` is any object that satisfies the following interface to implement a `SendRequest` method: | ||
```ts | ||
export interface HttpsClient { | ||
export interface HttpClient { | ||
/** | ||
@@ -47,3 +47,3 @@ * The method that makes the request and returns a response. | ||
`HttpsClient`s are expected to actually make the HTTP request to a server endpoint, using some platform-specific mechanism for doing so. | ||
`HttpClient`s are expected to actually make the HTTP request to a server endpoint, using some platform-specific mechanism for doing so. | ||
@@ -69,3 +69,3 @@ ### Pipeline Policies | ||
It is similar in shape to `HttpsClient`, but includes a policy name as well as a slightly modified `SendRequest` signature that allows it to conditionally call the next policy in the pipeline. | ||
It is similar in shape to `HttpClient`, but includes a policy name as well as a slightly modified `SendRequest` signature that allows it to conditionally call the next policy in the pipeline. | ||
@@ -105,3 +105,3 @@ One can view the role of policies as that of `middleware`, a concept that is familiar to NodeJS developers who have worked with frameworks such as [Express](https://expressjs.com/). | ||
removePolicy(options: { name?: string; phase?: PipelinePhase }): PipelinePolicy[]; | ||
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
getOrderedPolicies(): PipelinePolicy[]; | ||
@@ -112,3 +112,3 @@ clone(): Pipeline; | ||
As you can see it allows for policies to be added or removed and it is loosely coupled with `HttpsClient` to perform the real request to the server endpoint. | ||
As you can see it allows for policies to be added or removed and it is loosely coupled with `HttpClient` to perform the real request to the server endpoint. | ||
@@ -115,0 +115,0 @@ One important concept for `Pipeline`s is that they group policies into ordered phases: |
/// <reference types="node" /> | ||
import { AbortSignalLike } from '@azure/abort-controller'; | ||
import { Debugger } from '@azure/logger'; | ||
import { SpanOptions } from '@azure/core-tracing'; | ||
import { OperationTracingOptions } from '@azure/core-tracing'; | ||
import { TokenCredential } from '@azure/core-auth'; | ||
@@ -51,5 +51,5 @@ /** | ||
/** | ||
* Create the correct HttpsClient for the current environment. | ||
* Create the correct HttpClient for the current environment. | ||
*/ | ||
export declare function createDefaultHttpsClient(): HttpsClient; | ||
export declare function createDefaultHttpClient(): HttpClient; | ||
/** | ||
@@ -140,2 +140,12 @@ * Creates a totally empty pipeline. | ||
/** | ||
* The required interface for a client that makes HTTP requests | ||
* on behalf of a pipeline. | ||
*/ | ||
export declare interface HttpClient { | ||
/** | ||
* The method that makes the request and returns a response. | ||
*/ | ||
sendRequest: SendRequest; | ||
} | ||
/** | ||
* Represents a set of HTTP headers on a request/response. | ||
@@ -177,12 +187,2 @@ * Header names are treated as case insensitive. | ||
/** | ||
* The required interface for a client that makes HTTPS requests | ||
* on behalf of a pipeline. | ||
*/ | ||
export declare interface HttpsClient { | ||
/** | ||
* The method that makes the request and returns a response. | ||
*/ | ||
sendRequest: SendRequest; | ||
} | ||
/** | ||
* Defines options that are used to configure internal options of | ||
@@ -238,3 +238,3 @@ * the HTTP pipeline for an SDK client. | ||
/** | ||
* Represents a pipeline for making a HTTPS request to a URL. | ||
* Represents a pipeline for making a HTTP request to a URL. | ||
* Pipelines can have multiple policies to manage manipulating each request | ||
@@ -259,7 +259,7 @@ * before and after it is made to the server. | ||
/** | ||
* Uses the pipeline to make a HTTPS request. | ||
* @param httpsClient - The HttpsClient that actually performs the request. | ||
* Uses the pipeline to make a HTTP request. | ||
* @param httpClient - The HttpClient that actually performs the request. | ||
* @param request - The request to be made. | ||
*/ | ||
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
/** | ||
@@ -372,5 +372,5 @@ * Returns the current set of policies in the pipeline in the order in which | ||
/** | ||
* If the connection should be reused. | ||
* If the connection should not be reused. | ||
*/ | ||
keepAlive?: boolean; | ||
disableKeepAlive?: boolean; | ||
/** | ||
@@ -381,5 +381,5 @@ * Used to abort the request later. | ||
/** | ||
* Options used to create a span when tracing is enabled. | ||
* Tracing options to use for any created Spans. | ||
*/ | ||
spanOptions?: SpanOptions; | ||
tracingOptions?: OperationTracingOptions; | ||
/** | ||
@@ -441,5 +441,5 @@ * Callback which fires upon upload progress. | ||
/** | ||
* If the connection should be reused. Defaults to true. | ||
* If the connection should not be reused. | ||
*/ | ||
keepAlive?: boolean; | ||
disableKeepAlive?: boolean; | ||
/** | ||
@@ -452,3 +452,3 @@ * Used to abort the request later. | ||
*/ | ||
spanOptions?: SpanOptions; | ||
tracingOptions?: OperationTracingOptions; | ||
/** | ||
@@ -455,0 +455,0 @@ * Callback which fires upon upload progress. |
/// <reference types="node" /> | ||
import { AbortSignalLike } from '@azure/abort-controller'; | ||
import { Debugger } from '@azure/logger'; | ||
import { SpanOptions } from '@azure/core-tracing'; | ||
import { OperationTracingOptions } from '@azure/core-tracing'; | ||
import { TokenCredential } from '@azure/core-auth'; | ||
@@ -56,5 +56,5 @@ | ||
/** | ||
* Create the correct HttpsClient for the current environment. | ||
* Create the correct HttpClient for the current environment. | ||
*/ | ||
export declare function createDefaultHttpsClient(): HttpsClient; | ||
export declare function createDefaultHttpClient(): HttpClient; | ||
@@ -160,2 +160,13 @@ /** | ||
/** | ||
* The required interface for a client that makes HTTP requests | ||
* on behalf of a pipeline. | ||
*/ | ||
export declare interface HttpClient { | ||
/** | ||
* The method that makes the request and returns a response. | ||
*/ | ||
sendRequest: SendRequest; | ||
} | ||
/** | ||
* Represents a set of HTTP headers on a request/response. | ||
@@ -199,13 +210,2 @@ * Header names are treated as case insensitive. | ||
/** | ||
* The required interface for a client that makes HTTPS requests | ||
* on behalf of a pipeline. | ||
*/ | ||
export declare interface HttpsClient { | ||
/** | ||
* The method that makes the request and returns a response. | ||
*/ | ||
sendRequest: SendRequest; | ||
} | ||
/** | ||
* Defines options that are used to configure internal options of | ||
@@ -267,3 +267,3 @@ * the HTTP pipeline for an SDK client. | ||
/** | ||
* Represents a pipeline for making a HTTPS request to a URL. | ||
* Represents a pipeline for making a HTTP request to a URL. | ||
* Pipelines can have multiple policies to manage manipulating each request | ||
@@ -288,7 +288,7 @@ * before and after it is made to the server. | ||
/** | ||
* Uses the pipeline to make a HTTPS request. | ||
* @param httpsClient - The HttpsClient that actually performs the request. | ||
* Uses the pipeline to make a HTTP request. | ||
* @param httpClient - The HttpClient that actually performs the request. | ||
* @param request - The request to be made. | ||
*/ | ||
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>; | ||
/** | ||
@@ -405,5 +405,5 @@ * Returns the current set of policies in the pipeline in the order in which | ||
/** | ||
* If the connection should be reused. | ||
* If the connection should not be reused. | ||
*/ | ||
keepAlive?: boolean; | ||
disableKeepAlive?: boolean; | ||
/** | ||
@@ -414,5 +414,5 @@ * Used to abort the request later. | ||
/** | ||
* Options used to create a span when tracing is enabled. | ||
* Tracing options to use for any created Spans. | ||
*/ | ||
spanOptions?: SpanOptions; | ||
tracingOptions?: OperationTracingOptions; | ||
/** | ||
@@ -475,5 +475,5 @@ * Callback which fires upon upload progress. | ||
/** | ||
* If the connection should be reused. Defaults to true. | ||
* If the connection should not be reused. | ||
*/ | ||
keepAlive?: boolean; | ||
disableKeepAlive?: boolean; | ||
/** | ||
@@ -486,3 +486,3 @@ * Used to abort the request later. | ||
*/ | ||
spanOptions?: SpanOptions; | ||
tracingOptions?: OperationTracingOptions; | ||
/** | ||
@@ -489,0 +489,0 @@ * Callback which fires upon upload progress. |
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
Sorry, the diff of this file is too big to display
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
482857
88
5225
+ Added@azure/core-tracing@1.0.0-preview.10(transitive)
+ Added@opencensus/web-types@0.0.7(transitive)
- Removed@azure/core-tracing@1.2.0(transitive)