Bump artifact dependencies if CODEQL_ACTION_ARTIFACT_V2_UPGRADE enabled (#2482)

Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
Co-authored-by: Henry Mercer <henrymercer@github.com>
This commit is contained in:
Angela P Wen 2024-10-01 09:59:05 -07:00 committed by GitHub
parent cf5b0a9041
commit a196a714b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5388 changed files with 2176737 additions and 71701 deletions

View file

@ -0,0 +1,39 @@
import { KeepAliveOptions } from "./policies/keepAliveOptions.js";
import { RedirectOptions } from "./policies/redirectOptions.js";
import { CommonClientOptions, OperationArguments, OperationSpec, ServiceClient, ServiceClientOptions } from "@azure/core-client";
/**
* Options specific to Shim Clients.
*/
export interface ExtendedClientOptions {
/**
* Options to disable keep alive.
*/
keepAliveOptions?: KeepAliveOptions;
/**
* Options to redirect requests.
*/
redirectOptions?: RedirectOptions;
}
/**
* Options that shim clients are expected to expose.
*/
export type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;
/**
* The common set of options that custom shim clients are expected to expose.
*/
export type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;
/**
* Client to provide compatability between core V1 & V2.
*/
export declare class ExtendedServiceClient extends ServiceClient {
constructor(options: ExtendedServiceClientOptions);
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
sendOperationRequest<T>(operationArguments: OperationArguments, operationSpec: OperationSpec): Promise<T>;
}
//# sourceMappingURL=extendedClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.d.ts","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,EAEb,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAEtF;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,4BAA4B;IAiBjD;;;;;;OAMG;IACG,oBAAoB,CAAC,CAAC,EAC1B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,CAAC;CAgCd"}

View file

@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createDisableKeepAlivePolicy, pipelineContainsDisableKeepAlivePolicy, } from "./policies/disableKeepAlivePolicy.js";
import { redirectPolicyName } from "@azure/core-rest-pipeline";
import { ServiceClient, } from "@azure/core-client";
import { toCompatResponse } from "./response.js";
/**
* Client to provide compatability between core V1 & V2.
*/
export class ExtendedServiceClient extends ServiceClient {
constructor(options) {
var _a, _b;
super(options);
if (((_a = options.keepAliveOptions) === null || _a === void 0 ? void 0 : _a.enable) === false &&
!pipelineContainsDisableKeepAlivePolicy(this.pipeline)) {
this.pipeline.addPolicy(createDisableKeepAlivePolicy());
}
if (((_b = options.redirectOptions) === null || _b === void 0 ? void 0 : _b.handleRedirects) === false) {
this.pipeline.removePolicy({
name: redirectPolicyName,
});
}
}
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
async sendOperationRequest(operationArguments, operationSpec) {
var _a;
const userProvidedCallBack = (_a = operationArguments === null || operationArguments === void 0 ? void 0 : operationArguments.options) === null || _a === void 0 ? void 0 : _a.onResponse;
let lastResponse;
function onResponse(rawResponse, flatResponse, error) {
lastResponse = rawResponse;
if (userProvidedCallBack) {
userProvidedCallBack(rawResponse, flatResponse, error);
}
}
operationArguments.options = Object.assign(Object.assign({}, operationArguments.options), { onResponse });
const result = await super.sendOperationRequest(operationArguments, operationSpec);
if (lastResponse) {
Object.defineProperty(result, "_response", {
value: toCompatResponse(lastResponse),
});
}
return result;
}
}
//# sourceMappingURL=extendedClient.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.js","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAML,aAAa,GAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AA0BjD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,OAAqC;;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IACE,CAAA,MAAA,OAAO,CAAC,gBAAgB,0CAAE,MAAM,MAAK,KAAK;YAC1C,CAAC,sCAAsC,CAAC,IAAI,CAAC,QAAQ,CAAC,EACtD,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,4BAA4B,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAA,MAAA,OAAO,CAAC,eAAe,0CAAE,eAAe,MAAK,KAAK,EAAE,CAAC;YACvD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBACzB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,oBAAoB,CACxB,kBAAsC,EACtC,aAA4B;;QAE5B,MAAM,oBAAoB,GACxB,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,0CAAE,UAAU,CAAC;QAE1C,IAAI,YAA+C,CAAC;QAEpD,SAAS,UAAU,CACjB,WAAkC,EAClC,YAAqB,EACrB,KAAe;YAEf,YAAY,GAAG,WAAW,CAAC;YAC3B,IAAI,oBAAoB,EAAE,CAAC;gBACzB,oBAAoB,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,kBAAkB,CAAC,OAAO,mCACrB,kBAAkB,CAAC,OAAO,KAC7B,UAAU,GACX,CAAC;QAEF,MAAM,MAAM,GAAM,MAAM,KAAK,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QAEtF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;gBACzC,KAAK,EAAE,gBAAgB,CAAC,YAAY,CAAC;aACtC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nimport {\n createDisableKeepAlivePolicy,\n pipelineContainsDisableKeepAlivePolicy,\n} from \"./policies/disableKeepAlivePolicy.js\";\nimport { RedirectOptions } from \"./policies/redirectOptions.js\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport {\n CommonClientOptions,\n FullOperationResponse,\n OperationArguments,\n OperationSpec,\n RawResponseCallback,\n ServiceClient,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport { toCompatResponse } from \"./response.js\";\n\n/**\n * Options specific to Shim Clients.\n */\nexport interface ExtendedClientOptions {\n /**\n * Options to disable keep alive.\n */\n keepAliveOptions?: KeepAliveOptions;\n /**\n * Options to redirect requests.\n */\n redirectOptions?: RedirectOptions;\n}\n\n/**\n * Options that shim clients are expected to expose.\n */\nexport type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;\n\n/**\n * The common set of options that custom shim clients are expected to expose.\n */\nexport type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;\n\n/**\n * Client to provide compatability between core V1 & V2.\n */\nexport class ExtendedServiceClient extends ServiceClient {\n constructor(options: ExtendedServiceClientOptions) {\n super(options);\n\n if (\n options.keepAliveOptions?.enable === false &&\n !pipelineContainsDisableKeepAlivePolicy(this.pipeline)\n ) {\n this.pipeline.addPolicy(createDisableKeepAlivePolicy());\n }\n\n if (options.redirectOptions?.handleRedirects === false) {\n this.pipeline.removePolicy({\n name: redirectPolicyName,\n });\n }\n }\n\n /**\n * Compatible send operation request function.\n *\n * @param operationArguments - Operation arguments\n * @param operationSpec - Operation Spec\n * @returns\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const userProvidedCallBack: RawResponseCallback | undefined =\n operationArguments?.options?.onResponse;\n\n let lastResponse: FullOperationResponse | undefined;\n\n function onResponse(\n rawResponse: FullOperationResponse,\n flatResponse: unknown,\n error?: unknown,\n ): void {\n lastResponse = rawResponse;\n if (userProvidedCallBack) {\n userProvidedCallBack(rawResponse, flatResponse, error);\n }\n }\n\n operationArguments.options = {\n ...operationArguments.options,\n onResponse,\n };\n\n const result: T = await super.sendOperationRequest(operationArguments, operationSpec);\n\n if (lastResponse) {\n Object.defineProperty(result, \"_response\", {\n value: toCompatResponse(lastResponse),\n });\n }\n\n return result;\n }\n}\n"]}

View file

@ -0,0 +1,9 @@
import { HttpClient } from "@azure/core-rest-pipeline";
import { RequestPolicy } from "./policies/requestPolicyFactoryPolicy.js";
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export declare function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient;
//# sourceMappingURL=httpClientAdapter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.d.ts","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAqC,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAIzE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,mBAAmB,EAAE,aAAa,GAAG,UAAU,CAShF"}

View file

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { toPipelineResponse } from "./response.js";
import { toWebResourceLike } from "./util.js";
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export function convertHttpClient(requestPolicyClient) {
return {
sendRequest: async (request) => {
const response = await requestPolicyClient.sendRequest(toWebResourceLike(request, { createProxy: true }));
return toPipelineResponse(response);
},
};
}
//# sourceMappingURL=httpClientAdapter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.js","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,mBAAkC;IAClE,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,OAAwB,EAA6B,EAAE;YACzE,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,WAAW,CACpD,iBAAiB,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAClD,CAAC;YACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpClient, PipelineRequest, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { RequestPolicy } from \"./policies/requestPolicyFactoryPolicy.js\";\nimport { toPipelineResponse } from \"./response.js\";\nimport { toWebResourceLike } from \"./util.js\";\n\n/**\n * Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.\n * @param requestPolicyClient - A HttpClient compatible with core-http\n * @returns A HttpClient compatible with core-rest-pipeline\n */\nexport function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient {\n return {\n sendRequest: async (request: PipelineRequest): Promise<PipelineResponse> => {\n const response = await requestPolicyClient.sendRequest(\n toWebResourceLike(request, { createProxy: true }),\n );\n return toPipelineResponse(response);\n },\n };\n}\n"]}

View file

@ -0,0 +1,14 @@
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
export { ExtendedServiceClient, ExtendedServiceClientOptions, ExtendedCommonClientOptions, ExtendedClientOptions, } from "./extendedClient.js";
export { CompatResponse } from "./response.js";
export { requestPolicyFactoryPolicyName, createRequestPolicyFactoryPolicy, RequestPolicyFactory, RequestPolicy, RequestPolicyOptionsLike, HttpPipelineLogLevel, } from "./policies/requestPolicyFactoryPolicy.js";
export { KeepAliveOptions } from "./policies/keepAliveOptions.js";
export { RedirectOptions } from "./policies/redirectOptions.js";
export { disableKeepAlivePolicyName } from "./policies/disableKeepAlivePolicy.js";
export { convertHttpClient } from "./httpClientAdapter.js";
export { WebResourceLike, HttpHeadersLike, RawHttpHeaders, HttpHeader, TransferProgressEvent, toHttpHeadersLike, } from "./util.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC"}

View file

@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
export { ExtendedServiceClient, } from "./extendedClient.js";
export { requestPolicyFactoryPolicyName, createRequestPolicyFactoryPolicy, HttpPipelineLogLevel, } from "./policies/requestPolicyFactoryPolicy.js";
export { disableKeepAlivePolicyName } from "./policies/disableKeepAlivePolicy.js";
export { convertHttpClient } from "./httpClientAdapter.js";
export { toHttpHeadersLike, } from "./util.js";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,OAAO,EACL,qBAAqB,GAItB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAIhC,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAML,iBAAiB,GAClB,MAAM,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A Shim Library that provides compatibility between Core V1 & V2 Packages.\n *\n * @packageDocumentation\n */\nexport {\n ExtendedServiceClient,\n ExtendedServiceClientOptions,\n ExtendedCommonClientOptions,\n ExtendedClientOptions,\n} from \"./extendedClient.js\";\nexport { CompatResponse } from \"./response.js\";\nexport {\n requestPolicyFactoryPolicyName,\n createRequestPolicyFactoryPolicy,\n RequestPolicyFactory,\n RequestPolicy,\n RequestPolicyOptionsLike,\n HttpPipelineLogLevel,\n} from \"./policies/requestPolicyFactoryPolicy.js\";\nexport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nexport { RedirectOptions } from \"./policies/redirectOptions.js\";\nexport { disableKeepAlivePolicyName } from \"./policies/disableKeepAlivePolicy.js\";\nexport { convertHttpClient } from \"./httpClientAdapter.js\";\nexport {\n WebResourceLike,\n HttpHeadersLike,\n RawHttpHeaders,\n HttpHeader,\n TransferProgressEvent,\n toHttpHeadersLike,\n} from \"./util.js\";\n"]}

View file

@ -0,0 +1,3 @@
{
"type": "module"
}

View file

@ -0,0 +1,8 @@
import { Pipeline, PipelinePolicy } from "@azure/core-rest-pipeline";
export declare const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
export declare function createDisableKeepAlivePolicy(): PipelinePolicy;
/**
* @internal
*/
export declare function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean;
//# sourceMappingURL=disableKeepAlivePolicy.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,cAAc,EAIf,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAEnE,wBAAgB,4BAA4B,IAAI,cAAc,CAQ7D;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElF"}

View file

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
export function createDisableKeepAlivePolicy() {
return {
name: disableKeepAlivePolicyName,
async sendRequest(request, next) {
request.disableKeepAlive = true;
return next(request);
},
};
}
/**
* @internal
*/
export function pipelineContainsDisableKeepAlivePolicy(pipeline) {
return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);
}
//# sourceMappingURL=disableKeepAlivePolicy.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.js","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAChC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sCAAsC,CAAC,QAAkB;IACvE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,0BAA0B,CAAC,CAAC;AACpG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nexport const disableKeepAlivePolicyName = \"DisableKeepAlivePolicy\";\n\nexport function createDisableKeepAlivePolicy(): PipelinePolicy {\n return {\n name: disableKeepAlivePolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.disableKeepAlive = true;\n return next(request);\n },\n };\n}\n\n/**\n * @internal\n */\nexport function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean {\n return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);\n}\n"]}

View file

@ -0,0 +1,11 @@
/**
* Keep Alive Options for how HTTP connections.
*/
export interface KeepAliveOptions {
/**
* When true, connections will be kept alive for multiple requests.
* Defaults to true.
*/
enable?: boolean;
}
//# sourceMappingURL=keepAliveOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=keepAliveOptions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.js","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Keep Alive Options for how HTTP connections.\n */\nexport interface KeepAliveOptions {\n /**\n * When true, connections will be kept alive for multiple requests.\n * Defaults to true.\n */\n enable?: boolean;\n}\n"]}

View file

@ -0,0 +1,15 @@
/**
* Options for how redirect responses are handled.
*/
export interface RedirectOptions {
/**
* When true, redirect responses are followed. Defaults to true.
*/
handleRedirects?: boolean;
/**
* The maximum number of times the redirect URL will be tried before
* failing. Defaults to 20.
*/
maxRetries?: number;
}
//# sourceMappingURL=redirectOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"redirectOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/redirectOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=redirectOptions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"redirectOptions.js","sourceRoot":"","sources":["../../../src/policies/redirectOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Options for how redirect responses are handled.\n */\nexport interface RedirectOptions {\n /**\n * When true, redirect responses are followed. Defaults to true.\n */\n handleRedirects?: boolean;\n\n /**\n * The maximum number of times the redirect URL will be tried before\n * failing. Defaults to 20.\n */\n maxRetries?: number;\n}\n"]}

View file

@ -0,0 +1,41 @@
import { PipelinePolicy } from "@azure/core-rest-pipeline";
import { WebResourceLike } from "../util.js";
import { CompatResponse } from "../response.js";
/**
* A compatible interface for core-http request policies
*/
export interface RequestPolicy {
sendRequest(httpRequest: WebResourceLike): Promise<CompatResponse>;
}
/**
* An enum for compatibility with RequestPolicy
*/
export declare enum HttpPipelineLogLevel {
ERROR = 1,
INFO = 3,
OFF = 0,
WARNING = 2
}
/**
* An interface for compatibility with RequestPolicy
*/
export interface RequestPolicyOptionsLike {
log(logLevel: HttpPipelineLogLevel, message: string): void;
shouldLog(logLevel: HttpPipelineLogLevel): boolean;
}
/**
* An interface for compatibility with core-http's RequestPolicyFactory
*/
export interface RequestPolicyFactory {
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;
}
/**
* The name of the RequestPolicyFactoryPolicy
*/
export declare const requestPolicyFactoryPolicyName = "RequestPolicyFactoryPolicy";
/**
* A policy that wraps policies written for core-http.
* @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline
*/
export declare function createRequestPolicyFactoryPolicy(factories: RequestPolicyFactory[]): PipelinePolicy;
//# sourceMappingURL=requestPolicyFactoryPolicy.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"requestPolicyFactoryPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/requestPolicyFactoryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EAIf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAwC,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,cAAc,EAAwC,MAAM,gBAAgB,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,KAAK,IAAI;IACT,IAAI,IAAI;IACR,GAAG,IAAI;IACP,OAAO,IAAI;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC;CACpD;AAWD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC;CACrF;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,+BAA+B,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,oBAAoB,EAAE,GAChC,cAAc,CAqBhB"}

View file

@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { toPipelineRequest, toWebResourceLike } from "../util.js";
import { toCompatResponse, toPipelineResponse } from "../response.js";
/**
* An enum for compatibility with RequestPolicy
*/
export var HttpPipelineLogLevel;
(function (HttpPipelineLogLevel) {
HttpPipelineLogLevel[HttpPipelineLogLevel["ERROR"] = 1] = "ERROR";
HttpPipelineLogLevel[HttpPipelineLogLevel["INFO"] = 3] = "INFO";
HttpPipelineLogLevel[HttpPipelineLogLevel["OFF"] = 0] = "OFF";
HttpPipelineLogLevel[HttpPipelineLogLevel["WARNING"] = 2] = "WARNING";
})(HttpPipelineLogLevel || (HttpPipelineLogLevel = {}));
const mockRequestPolicyOptions = {
log(_logLevel, _message) {
/* do nothing */
},
shouldLog(_logLevel) {
return false;
},
};
/**
* The name of the RequestPolicyFactoryPolicy
*/
export const requestPolicyFactoryPolicyName = "RequestPolicyFactoryPolicy";
/**
* A policy that wraps policies written for core-http.
* @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline
*/
export function createRequestPolicyFactoryPolicy(factories) {
const orderedFactories = factories.slice().reverse();
return {
name: requestPolicyFactoryPolicyName,
async sendRequest(request, next) {
let httpPipeline = {
async sendRequest(httpRequest) {
const response = await next(toPipelineRequest(httpRequest));
return toCompatResponse(response, { createProxy: true });
},
};
for (const factory of orderedFactories) {
httpPipeline = factory.create(httpPipeline, mockRequestPolicyOptions);
}
const webResourceLike = toWebResourceLike(request, { createProxy: true });
const response = await httpPipeline.sendRequest(webResourceLike);
return toPipelineResponse(response);
},
};
}
//# sourceMappingURL=requestPolicyFactoryPolicy.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"requestPolicyFactoryPolicy.js","sourceRoot":"","sources":["../../../src/policies/requestPolicyFactoryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAmB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAkB,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAStF;;GAEG;AACH,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,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(c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { WebResourceLike, toPipelineRequest, toWebResourceLike } from \"../util.js\";\nimport { CompatResponse, toCompatResponse, toPipelineResponse } from \"../response.js\";\n\n/**\n * A compatible interface for core-http request policies\n */\nexport interface RequestPolicy {\n sendRequest(httpRequest: WebResourceLike): Promise<CompatResponse>;\n}\n\n/**\n * An enum for compatibility with RequestPolicy\n */\nexport enum HttpPipelineLogLevel {\n ERROR = 1,\n INFO = 3,\n OFF = 0,\n WARNING = 2,\n}\n\n/**\n * An interface for compatibility with RequestPolicy\n */\nexport interface RequestPolicyOptionsLike {\n log(logLevel: HttpPipelineLogLevel, message: string): void;\n shouldLog(logLevel: HttpPipelineLogLevel): boolean;\n}\n\nconst mockRequestPolicyOptions: RequestPolicyOptionsLike = {\n log(_logLevel: HttpPipelineLogLevel, _message: string): void {\n /* do nothing */\n },\n shouldLog(_logLevel: HttpPipelineLogLevel): boolean {\n return false;\n },\n};\n\n/**\n * An interface for compatibility with core-http's RequestPolicyFactory\n */\nexport interface RequestPolicyFactory {\n create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;\n}\n\n/**\n * The name of the RequestPolicyFactoryPolicy\n */\nexport const requestPolicyFactoryPolicyName = \"RequestPolicyFactoryPolicy\";\n\n/**\n * A policy that wraps policies written for core-http.\n * @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline\n */\nexport function createRequestPolicyFactoryPolicy(\n factories: RequestPolicyFactory[],\n): PipelinePolicy {\n const orderedFactories = factories.slice().reverse();\n\n return {\n name: requestPolicyFactoryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n let httpPipeline: RequestPolicy = {\n async sendRequest(httpRequest) {\n const response = await next(toPipelineRequest(httpRequest));\n return toCompatResponse(response, { createProxy: true });\n },\n };\n for (const factory of orderedFactories) {\n httpPipeline = factory.create(httpPipeline, mockRequestPolicyOptions);\n }\n\n const webResourceLike = toWebResourceLike(request, { createProxy: true });\n const response = await httpPipeline.sendRequest(webResourceLike);\n return toPipelineResponse(response);\n },\n };\n}\n"]}

View file

@ -0,0 +1,30 @@
import { FullOperationResponse } from "@azure/core-client";
import { PipelineResponse } from "@azure/core-rest-pipeline";
import { HttpHeadersLike, WebResourceLike } from "./util.js";
/**
* Http Response that is compatible with the core-v1(core-http).
*/
export interface CompatResponse extends Omit<FullOperationResponse, "request" | "headers"> {
/**
* A description of a HTTP request to be made to a remote server.
*/
request: WebResourceLike;
/**
* A collection of HTTP header key/value pairs.
*/
headers: HttpHeadersLike;
}
/**
* A helper to convert response objects from the new pipeline back to the old one.
* @param response - A response object from core-client.
* @returns A response compatible with `HttpOperationResponse` from core-http.
*/
export declare function toCompatResponse(response: FullOperationResponse, options?: {
createProxy?: boolean;
}): CompatResponse;
/**
* A helper to convert back to a PipelineResponse
* @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.
*/
export declare function toPipelineResponse(compatResponse: CompatResponse): PipelineResponse;
//# sourceMappingURL=response.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAqB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,eAAe,EACf,eAAe,EAIhB,MAAM,WAAW,CAAC;AACnB;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,SAAS,CAAC;IACxF;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;CAC1B;AAKD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAClC,cAAc,CA+BhB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,gBAAgB,CAcnF"}

View file

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createHttpHeaders } from "@azure/core-rest-pipeline";
import { toHttpHeadersLike, toPipelineRequest, toWebResourceLike, } from "./util.js";
const originalResponse = Symbol("Original FullOperationResponse");
/**
* A helper to convert response objects from the new pipeline back to the old one.
* @param response - A response object from core-client.
* @returns A response compatible with `HttpOperationResponse` from core-http.
*/
export function toCompatResponse(response, options) {
let request = toWebResourceLike(response.request);
let headers = toHttpHeadersLike(response.headers);
if (options === null || options === void 0 ? void 0 : options.createProxy) {
return new Proxy(response, {
get(target, prop, receiver) {
if (prop === "headers") {
return headers;
}
else if (prop === "request") {
return request;
}
else if (prop === originalResponse) {
return response;
}
return Reflect.get(target, prop, receiver);
},
set(target, prop, value, receiver) {
if (prop === "headers") {
headers = value;
}
else if (prop === "request") {
request = value;
}
return Reflect.set(target, prop, value, receiver);
},
});
}
else {
return Object.assign(Object.assign({}, response), { request,
headers });
}
}
/**
* A helper to convert back to a PipelineResponse
* @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.
*/
export function toPipelineResponse(compatResponse) {
const extendedCompatResponse = compatResponse;
const response = extendedCompatResponse[originalResponse];
const headers = createHttpHeaders(compatResponse.headers.toJson({ preserveCase: true }));
if (response) {
response.headers = headers;
return response;
}
else {
return Object.assign(Object.assign({}, compatResponse), { headers, request: toPipelineRequest(compatResponse.request) });
}
}
//# sourceMappingURL=response.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAGL,i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Q,KACX,OAAO;YACP,OAAO,IACP;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,cAA8B;IAC/D,MAAM,sBAAsB,GAAG,cAAwC,CAAC;IACxE,MAAM,QAAQ,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzF,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,uCACK,cAAc,KACjB,OAAO,EACP,OAAO,EAAE,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC,IAClD;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n HttpHeadersLike,\n WebResourceLike,\n toHttpHeadersLike,\n toPipelineRequest,\n toWebResourceLike,\n} from \"./util.js\";\n/**\n * Http Response that is compatible with the core-v1(core-http).\n */\nexport interface CompatResponse extends Omit<FullOperationResponse, \"request\" | \"headers\"> {\n /**\n * A description of a HTTP request to be made to a remote server.\n */\n request: WebResourceLike;\n /**\n * A collection of HTTP header key/value pairs.\n */\n headers: HttpHeadersLike;\n}\n\nconst originalResponse = Symbol(\"Original FullOperationResponse\");\ntype ExtendedCompatResponse = CompatResponse & { [originalResponse]?: FullOperationResponse };\n\n/**\n * A helper to convert response objects from the new pipeline back to the old one.\n * @param response - A response object from core-client.\n * @returns A response compatible with `HttpOperationResponse` from core-http.\n */\nexport function toCompatResponse(\n response: FullOperationResponse,\n options?: { createProxy?: boolean },\n): CompatResponse {\n let request = toWebResourceLike(response.request);\n let headers = toHttpHeadersLike(response.headers);\n if (options?.createProxy) {\n return new Proxy(response, {\n get(target, prop, receiver) {\n if (prop === \"headers\") {\n return headers;\n } else if (prop === \"request\") {\n return request;\n } else if (prop === originalResponse) {\n return response;\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, value, receiver) {\n if (prop === \"headers\") {\n headers = value;\n } else if (prop === \"request\") {\n request = value;\n }\n return Reflect.set(target, prop, value, receiver);\n },\n }) as unknown as CompatResponse;\n } else {\n return {\n ...response,\n request,\n headers,\n };\n }\n}\n\n/**\n * A helper to convert back to a PipelineResponse\n * @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.\n */\nexport function toPipelineResponse(compatResponse: CompatResponse): PipelineResponse {\n const extendedCompatResponse = compatResponse as ExtendedCompatResponse;\n const response = extendedCompatResponse[originalResponse];\n const headers = createHttpHeaders(compatResponse.headers.toJson({ preserveCase: true }));\n if (response) {\n response.headers = headers;\n return response;\n } else {\n return {\n ...compatResponse,\n headers,\n request: toPipelineRequest(compatResponse.request),\n };\n }\n}\n"]}

View file

@ -0,0 +1,251 @@
import { HttpMethods, ProxySettings } from "@azure/core-rest-pipeline";
import { AbortSignalLike } from "@azure/abort-controller";
import { HttpHeaders as HttpHeadersV2, PipelineRequest } from "@azure/core-rest-pipeline";
export declare function toPipelineRequest(webResource: WebResourceLike, options?: {
originalRequest?: PipelineRequest;
}): PipelineRequest;
export declare function toWebResourceLike(request: PipelineRequest, options?: {
createProxy?: boolean;
originalRequest?: PipelineRequest;
}): WebResourceLike;
/**
* Converts HttpHeaders from core-rest-pipeline to look like
* HttpHeaders from core-http.
* @param headers - HttpHeaders from core-rest-pipeline
* @returns HttpHeaders as they looked in core-http
*/
export declare function toHttpHeadersLike(headers: HttpHeadersV2): HttpHeadersLike;
/**
* An individual header within a HttpHeaders collection.
*/
export interface HttpHeader {
/**
* The name of the header.
*/
name: string;
/**
* The value of the header.
*/
value: string;
}
/**
* A HttpHeaders collection represented as a simple JSON object.
*/
export type RawHttpHeaders = {
[headerName: string]: string;
};
/**
* A collection of HTTP header key/value pairs.
*/
export interface HttpHeadersLike {
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName: string, headerValue: string | number): void;
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName: string): string | undefined;
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName: string): boolean;
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName: string): boolean;
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders(): RawHttpHeaders;
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray(): HttpHeader[];
/**
* Get the header names that are contained in this collection.
*/
headerNames(): string[];
/**
* Get the header values that are contained in this collection.
*/
headerValues(): string[];
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone(): HttpHeadersLike;
/**
* Get the JSON object representation of this HTTP header collection.
* The result is the same as `rawHeaders()`.
*/
toJson(options?: {
preserveCase?: boolean;
}): RawHttpHeaders;
}
/**
* A collection of HTTP header key/value pairs.
*/
export declare class HttpHeaders implements HttpHeadersLike {
private readonly _headersMap;
constructor(rawHeaders?: RawHttpHeaders);
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName: string, headerValue: string | number): void;
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName: string): string | undefined;
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName: string): boolean;
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName: string): boolean;
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders(): RawHttpHeaders;
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray(): HttpHeader[];
/**
* Get the header names that are contained in this collection.
*/
headerNames(): string[];
/**
* Get the header values that are contained in this collection.
*/
headerValues(): string[];
/**
* Get the JSON object representation of this HTTP header collection.
*/
toJson(options?: {
preserveCase?: boolean;
}): RawHttpHeaders;
/**
* Get the string representation of this HTTP header collection.
*/
toString(): string;
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone(): HttpHeaders;
}
/**
* A description of a HTTP request to be made to a remote server.
*/
export interface WebResourceLike {
/**
* The URL being accessed by the request.
*/
url: string;
/**
* The HTTP method to use when making the request.
*/
method: HttpMethods;
/**
* The HTTP body contents of the request.
*/
body?: any;
/**
* The HTTP headers to use when making the request.
*/
headers: HttpHeadersLike;
/**
* Whether or not the body of the HttpOperationResponse should be treated as a stream.
* @deprecated Use streamResponseStatusCodes property instead.
*/
streamResponseBody?: boolean;
/**
* A list of response status codes whose corresponding HttpOperationResponse body should be treated as a stream.
*/
streamResponseStatusCodes?: Set<number>;
/**
* Form data, used to build the request body.
*/
formData?: any;
/**
* A query string represented as an object.
*/
query?: {
[key: string]: any;
};
/**
* If credentials (cookies) should be sent along during an XHR.
*/
withCredentials: boolean;
/**
* The number of milliseconds a request can take before automatically being terminated.
* If the request is terminated, an `AbortError` is thrown.
*/
timeout: number;
/**
* Proxy configuration.
*/
proxySettings?: ProxySettings;
/**
* If the connection should be reused.
*/
keepAlive?: boolean;
/**
* Whether or not to decompress response according to Accept-Encoding header (node-fetch only)
*/
decompressResponse?: boolean;
/**
* A unique identifier for the request. Used for logging and tracing.
*/
requestId: string;
/**
* Signal of an abort controller. Can be used to abort both sending a network request and waiting for a response.
*/
abortSignal?: AbortSignalLike;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/** Callback which fires upon download progress. */
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Clone this request object.
*/
clone(): WebResourceLike;
/**
* Validates that the required properties such as method, url, headers["Content-Type"],
* headers["accept-language"] are defined. It will throw an error if one of the above
* mentioned properties are not defined.
* Note: this a no-op for compat purposes.
*/
validateRequestProperties(): void;
/**
* This is a no-op for compat purposes and will throw if called.
*/
prepare(options: unknown): WebResourceLike;
}
/**
* Fired in response to upload or download progress.
*/
export type TransferProgressEvent = {
/**
* The number of bytes loaded so far.
*/
loadedBytes: number;
};
//# sourceMappingURL=util.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,aAAa,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,IAAI,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAe1F,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,eAAe,CAAC;CAC9B,GACL,eAAe,CA8BjB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,eAAe,CAAA;CAAE,GACrE,eAAe,CAwEjB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,eAAe,CAEzE;AASD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,MA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ElC;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}

View file

@ -0,0 +1,256 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createHttpHeaders, createPipelineRequest, } from "@azure/core-rest-pipeline";
// We use a custom symbol to cache a reference to the original request without
// exposing it on the public interface.
const originalRequestSymbol = Symbol("Original PipelineRequest");
// Symbol.for() will return the same symbol if it's already been created
// This particular one is used in core-client to handle the case of when a request is
// cloned but we need to retrieve the OperationSpec and OperationArguments from the
// original request.
const originalClientRequestSymbol = Symbol.for("@azure/core-client original request");
export function toPipelineRequest(webResource, options = {}) {
const compatWebResource = webResource;
const request = compatWebResource[originalRequestSymbol];
const headers = createHttpHeaders(webResource.headers.toJson({ preserveCase: true }));
if (request) {
request.headers = headers;
return request;
}
else {
const newRequest = createPipelineRequest({
url: webResource.url,
method: webResource.method,
headers,
withCredentials: webResource.withCredentials,
timeout: webResource.timeout,
requestId: webResource.requestId,
abortSignal: webResource.abortSignal,
body: webResource.body,
formData: webResource.formData,
disableKeepAlive: !!webResource.keepAlive,
onDownloadProgress: webResource.onDownloadProgress,
onUploadProgress: webResource.onUploadProgress,
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
options.originalRequest;
}
return newRequest;
}
}
export function toWebResourceLike(request, options) {
var _a;
const originalRequest = (_a = options === null || options === void 0 ? void 0 : options.originalRequest) !== null && _a !== void 0 ? _a : request;
const webResource = {
url: request.url,
method: request.method,
headers: toHttpHeadersLike(request.headers),
withCredentials: request.withCredentials,
timeout: request.timeout,
requestId: request.headers.get("x-ms-client-request-id") || request.requestId,
abortSignal: request.abortSignal,
body: request.body,
formData: request.formData,
keepAlive: !!request.disableKeepAlive,
onDownloadProgress: request.onDownloadProgress,
onUploadProgress: request.onUploadProgress,
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
prepare() {
throw new Error("WebResourceLike.prepare() is not supported by @azure/core-http-compat");
},
validateRequestProperties() {
/** do nothing */
},
};
if (options === null || options === void 0 ? void 0 : options.createProxy) {
return new Proxy(webResource, {
get(target, prop, receiver) {
if (prop === originalRequestSymbol) {
return request;
}
else if (prop === "clone") {
return () => {
return toWebResourceLike(toPipelineRequest(webResource, { originalRequest }), {
createProxy: true,
originalRequest,
});
};
}
return Reflect.get(target, prop, receiver);
},
set(target, prop, value, receiver) {
if (prop === "keepAlive") {
request.disableKeepAlive = !value;
}
const passThroughProps = [
"url",
"method",
"withCredentials",
"timeout",
"requestId",
"abortSignal",
"body",
"formData",
"onDownloadProgress",
"onUploadProgress",
"proxySettings",
"streamResponseStatusCodes",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
}
return Reflect.set(target, prop, value, receiver);
},
});
}
else {
return webResource;
}
}
/**
* Converts HttpHeaders from core-rest-pipeline to look like
* HttpHeaders from core-http.
* @param headers - HttpHeaders from core-rest-pipeline
* @returns HttpHeaders as they looked in core-http
*/
export function toHttpHeadersLike(headers) {
return new HttpHeaders(headers.toJSON({ preserveCase: true }));
}
/**
* A collection of HttpHeaders that can be sent with a HTTP request.
*/
function getHeaderKey(headerName) {
return headerName.toLowerCase();
}
/**
* A collection of HTTP header key/value pairs.
*/
export class HttpHeaders {
constructor(rawHeaders) {
this._headersMap = {};
if (rawHeaders) {
for (const headerName in rawHeaders) {
this.set(headerName, rawHeaders[headerName]);
}
}
}
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName, headerValue) {
this._headersMap[getHeaderKey(headerName)] = {
name: headerName,
value: headerValue.toString(),
};
}
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName) {
const header = this._headersMap[getHeaderKey(headerName)];
return !header ? undefined : header.value;
}
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName) {
return !!this._headersMap[getHeaderKey(headerName)];
}
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName) {
const result = this.contains(headerName);
delete this._headersMap[getHeaderKey(headerName)];
return result;
}
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders() {
return this.toJson({ preserveCase: true });
}
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray() {
const headers = [];
for (const headerKey in this._headersMap) {
headers.push(this._headersMap[headerKey]);
}
return headers;
}
/**
* Get the header names that are contained in this collection.
*/
headerNames() {
const headerNames = [];
const headers = this.headersArray();
for (let i = 0; i < headers.length; ++i) {
headerNames.push(headers[i].name);
}
return headerNames;
}
/**
* Get the header values that are contained in this collection.
*/
headerValues() {
const headerValues = [];
const headers = this.headersArray();
for (let i = 0; i < headers.length; ++i) {
headerValues.push(headers[i].value);
}
return headerValues;
}
/**
* Get the JSON object representation of this HTTP header collection.
*/
toJson(options = {}) {
const result = {};
if (options.preserveCase) {
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
result[header.name] = header.value;
}
}
else {
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
result[getHeaderKey(header.name)] = header.value;
}
}
return result;
}
/**
* Get the string representation of this HTTP header collection.
*/
toString() {
return JSON.stringify(this.toJson({ preserveCase: true }));
}
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone() {
const resultPreservingCasing = {};
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
resultPreservingCasing[header.name] = header.value;
}
return new HttpHeaders(resultPreservingCasing);
}
}
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,39 @@
import { KeepAliveOptions } from "./policies/keepAliveOptions.js";
import { RedirectOptions } from "./policies/redirectOptions.js";
import { CommonClientOptions, OperationArguments, OperationSpec, ServiceClient, ServiceClientOptions } from "@azure/core-client";
/**
* Options specific to Shim Clients.
*/
export interface ExtendedClientOptions {
/**
* Options to disable keep alive.
*/
keepAliveOptions?: KeepAliveOptions;
/**
* Options to redirect requests.
*/
redirectOptions?: RedirectOptions;
}
/**
* Options that shim clients are expected to expose.
*/
export type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;
/**
* The common set of options that custom shim clients are expected to expose.
*/
export type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;
/**
* Client to provide compatability between core V1 & V2.
*/
export declare class ExtendedServiceClient extends ServiceClient {
constructor(options: ExtendedServiceClientOptions);
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
sendOperationRequest<T>(operationArguments: OperationArguments, operationSpec: OperationSpec): Promise<T>;
}
//# sourceMappingURL=extendedClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.d.ts","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,EAEb,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAEtF;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,4BAA4B;IAiBjD;;;;;;OAMG;IACG,oBAAoB,CAAC,CAAC,EAC1B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,CAAC;CAgCd"}

View file

@ -0,0 +1,55 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtendedServiceClient = void 0;
const disableKeepAlivePolicy_js_1 = require("./policies/disableKeepAlivePolicy.js");
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
const core_client_1 = require("@azure/core-client");
const response_js_1 = require("./response.js");
/**
* Client to provide compatability between core V1 & V2.
*/
class ExtendedServiceClient extends core_client_1.ServiceClient {
constructor(options) {
var _a, _b;
super(options);
if (((_a = options.keepAliveOptions) === null || _a === void 0 ? void 0 : _a.enable) === false &&
!(0, disableKeepAlivePolicy_js_1.pipelineContainsDisableKeepAlivePolicy)(this.pipeline)) {
this.pipeline.addPolicy((0, disableKeepAlivePolicy_js_1.createDisableKeepAlivePolicy)());
}
if (((_b = options.redirectOptions) === null || _b === void 0 ? void 0 : _b.handleRedirects) === false) {
this.pipeline.removePolicy({
name: core_rest_pipeline_1.redirectPolicyName,
});
}
}
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
async sendOperationRequest(operationArguments, operationSpec) {
var _a;
const userProvidedCallBack = (_a = operationArguments === null || operationArguments === void 0 ? void 0 : operationArguments.options) === null || _a === void 0 ? void 0 : _a.onResponse;
let lastResponse;
function onResponse(rawResponse, flatResponse, error) {
lastResponse = rawResponse;
if (userProvidedCallBack) {
userProvidedCallBack(rawResponse, flatResponse, error);
}
}
operationArguments.options = Object.assign(Object.assign({}, operationArguments.options), { onResponse });
const result = await super.sendOperationRequest(operationArguments, operationSpec);
if (lastResponse) {
Object.defineProperty(result, "_response", {
value: (0, response_js_1.toCompatResponse)(lastResponse),
});
}
return result;
}
}
exports.ExtendedServiceClient = ExtendedServiceClient;
//# sourceMappingURL=extendedClient.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.js","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,oFAG8C;AAE9C,kEAA+D;AAC/D,oDAQ4B;AAC5B,+CAAiD;AA0BjD;;GAEG;AACH,MAAa,qBAAsB,SAAQ,2BAAa;IACtD,YAAY,OAAqC;;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IACE,CAAA,MAAA,OAAO,CAAC,gBAAgB,0CAAE,MAAM,MAAK,KAAK;YAC1C,CAAC,IAAA,kEAAsC,EAAC,IAAI,CAAC,QAAQ,CAAC,EACtD,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAA,wDAA4B,GAAE,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAA,MAAA,OAAO,CAAC,eAAe,0CAAE,eAAe,MAAK,KAAK,EAAE,CAAC;YACvD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBACzB,IAAI,EAAE,uCAAkB;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,oBAAoB,CACxB,kBAAsC,EACtC,aAA4B;;QAE5B,MAAM,oBAAoB,GACxB,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,0CAAE,UAAU,CAAC;QAE1C,IAAI,YAA+C,CAAC;QAEpD,SAAS,UAAU,CACjB,WAAkC,EAClC,YAAqB,EACrB,KAAe;YAEf,YAAY,GAAG,WAAW,CAAC;YAC3B,IAAI,oBAAoB,EAAE,CAAC;gBACzB,oBAAoB,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,kBAAkB,CAAC,OAAO,mCACrB,kBAAkB,CAAC,OAAO,KAC7B,UAAU,GACX,CAAC;QAEF,MAAM,MAAM,GAAM,MAAM,KAAK,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QAEtF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;gBACzC,KAAK,EAAE,IAAA,8BAAgB,EAAC,YAAY,CAAC;aACtC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5DD,sDA4DC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nimport {\n createDisableKeepAlivePolicy,\n pipelineContainsDisableKeepAlivePolicy,\n} from \"./policies/disableKeepAlivePolicy.js\";\nimport { RedirectOptions } from \"./policies/redirectOptions.js\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport {\n CommonClientOptions,\n FullOperationResponse,\n OperationArguments,\n OperationSpec,\n RawResponseCallback,\n ServiceClient,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport { toCompatResponse } from \"./response.js\";\n\n/**\n * Options specific to Shim Clients.\n */\nexport interface ExtendedClientOptions {\n /**\n * Options to disable keep alive.\n */\n keepAliveOptions?: KeepAliveOptions;\n /**\n * Options to redirect requests.\n */\n redirectOptions?: RedirectOptions;\n}\n\n/**\n * Options that shim clients are expected to expose.\n */\nexport type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;\n\n/**\n * The common set of options that custom shim clients are expected to expose.\n */\nexport type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;\n\n/**\n * Client to provide compatability between core V1 & V2.\n */\nexport class ExtendedServiceClient extends ServiceClient {\n constructor(options: ExtendedServiceClientOptions) {\n super(options);\n\n if (\n options.keepAliveOptions?.enable === false &&\n !pipelineContainsDisableKeepAlivePolicy(this.pipeline)\n ) {\n this.pipeline.addPolicy(createDisableKeepAlivePolicy());\n }\n\n if (options.redirectOptions?.handleRedirects === false) {\n this.pipeline.removePolicy({\n name: redirectPolicyName,\n });\n }\n }\n\n /**\n * Compatible send operation request function.\n *\n * @param operationArguments - Operation arguments\n * @param operationSpec - Operation Spec\n * @returns\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const userProvidedCallBack: RawResponseCallback | undefined =\n operationArguments?.options?.onResponse;\n\n let lastResponse: FullOperationResponse | undefined;\n\n function onResponse(\n rawResponse: FullOperationResponse,\n flatResponse: unknown,\n error?: unknown,\n ): void {\n lastResponse = rawResponse;\n if (userProvidedCallBack) {\n userProvidedCallBack(rawResponse, flatResponse, error);\n }\n }\n\n operationArguments.options = {\n ...operationArguments.options,\n onResponse,\n };\n\n const result: T = await super.sendOperationRequest(operationArguments, operationSpec);\n\n if (lastResponse) {\n Object.defineProperty(result, \"_response\", {\n value: toCompatResponse(lastResponse),\n });\n }\n\n return result;\n }\n}\n"]}

View file

@ -0,0 +1,9 @@
import { HttpClient } from "@azure/core-rest-pipeline";
import { RequestPolicy } from "./policies/requestPolicyFactoryPolicy.js";
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export declare function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient;
//# sourceMappingURL=httpClientAdapter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.d.ts","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAqC,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAIzE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,mBAAmB,EAAE,aAAa,GAAG,UAAU,CAShF"}

View file

@ -0,0 +1,22 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertHttpClient = void 0;
const response_js_1 = require("./response.js");
const util_js_1 = require("./util.js");
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
function convertHttpClient(requestPolicyClient) {
return {
sendRequest: async (request) => {
const response = await requestPolicyClient.sendRequest((0, util_js_1.toWebResourceLike)(request, { createProxy: true }));
return (0, response_js_1.toPipelineResponse)(response);
},
};
}
exports.convertHttpClient = convertHttpClient;
//# sourceMappingURL=httpClientAdapter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.js","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmD;AACnD,uCAA8C;AAE9C;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,mBAAkC;IAClE,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,OAAwB,EAA6B,EAAE;YACzE,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,WAAW,CACpD,IAAA,2BAAiB,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAClD,CAAC;YACF,OAAO,IAAA,gCAAkB,EAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC;AATD,8CASC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpClient, PipelineRequest, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { RequestPolicy } from \"./policies/requestPolicyFactoryPolicy.js\";\nimport { toPipelineResponse } from \"./response.js\";\nimport { toWebResourceLike } from \"./util.js\";\n\n/**\n * Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.\n * @param requestPolicyClient - A HttpClient compatible with core-http\n * @returns A HttpClient compatible with core-rest-pipeline\n */\nexport function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient {\n return {\n sendRequest: async (request: PipelineRequest): Promise<PipelineResponse> => {\n const response = await requestPolicyClient.sendRequest(\n toWebResourceLike(request, { createProxy: true }),\n );\n return toPipelineResponse(response);\n },\n };\n}\n"]}

View file

@ -0,0 +1,14 @@
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
export { ExtendedServiceClient, ExtendedServiceClientOptions, ExtendedCommonClientOptions, ExtendedClientOptions, } from "./extendedClient.js";
export { CompatResponse } from "./response.js";
export { requestPolicyFactoryPolicyName, createRequestPolicyFactoryPolicy, RequestPolicyFactory, RequestPolicy, RequestPolicyOptionsLike, HttpPipelineLogLevel, } from "./policies/requestPolicyFactoryPolicy.js";
export { KeepAliveOptions } from "./policies/keepAliveOptions.js";
export { RedirectOptions } from "./policies/redirectOptions.js";
export { disableKeepAlivePolicyName } from "./policies/disableKeepAlivePolicy.js";
export { convertHttpClient } from "./httpClientAdapter.js";
export { WebResourceLike, HttpHeadersLike, RawHttpHeaders, HttpHeader, TransferProgressEvent, toHttpHeadersLike, } from "./util.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC"}

View file

@ -0,0 +1,23 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHttpHeadersLike = exports.convertHttpClient = exports.disableKeepAlivePolicyName = exports.HttpPipelineLogLevel = exports.createRequestPolicyFactoryPolicy = exports.requestPolicyFactoryPolicyName = exports.ExtendedServiceClient = void 0;
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
var extendedClient_js_1 = require("./extendedClient.js");
Object.defineProperty(exports, "ExtendedServiceClient", { enumerable: true, get: function () { return extendedClient_js_1.ExtendedServiceClient; } });
var requestPolicyFactoryPolicy_js_1 = require("./policies/requestPolicyFactoryPolicy.js");
Object.defineProperty(exports, "requestPolicyFactoryPolicyName", { enumerable: true, get: function () { return requestPolicyFactoryPolicy_js_1.requestPolicyFactoryPolicyName; } });
Object.defineProperty(exports, "createRequestPolicyFactoryPolicy", { enumerable: true, get: function () { return requestPolicyFactoryPolicy_js_1.createRequestPolicyFactoryPolicy; } });
Object.defineProperty(exports, "HttpPipelineLogLevel", { enumerable: true, get: function () { return requestPolicyFactoryPolicy_js_1.HttpPipelineLogLevel; } });
var disableKeepAlivePolicy_js_1 = require("./policies/disableKeepAlivePolicy.js");
Object.defineProperty(exports, "disableKeepAlivePolicyName", { enumerable: true, get: function () { return disableKeepAlivePolicy_js_1.disableKeepAlivePolicyName; } });
var httpClientAdapter_js_1 = require("./httpClientAdapter.js");
Object.defineProperty(exports, "convertHttpClient", { enumerable: true, get: function () { return httpClientAdapter_js_1.convertHttpClient; } });
var util_js_1 = require("./util.js");
Object.defineProperty(exports, "toHttpHeadersLike", { enumerable: true, get: function () { return util_js_1.toHttpHeadersLike; } });
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;GAIG;AACH,yDAK6B;AAJ3B,0HAAA,qBAAqB,OAAA;AAMvB,0FAOkD;AANhD,+IAAA,8BAA8B,OAAA;AAC9B,iJAAA,gCAAgC,OAAA;AAIhC,qIAAA,oBAAoB,OAAA;AAItB,kFAAkF;AAAzE,uIAAA,0BAA0B,OAAA;AACnC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,qCAOmB;AADjB,4GAAA,iBAAiB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A Shim Library that provides compatibility between Core V1 & V2 Packages.\n *\n * @packageDocumentation\n */\nexport {\n ExtendedServiceClient,\n ExtendedServiceClientOptions,\n ExtendedCommonClientOptions,\n ExtendedClientOptions,\n} from \"./extendedClient.js\";\nexport { CompatResponse } from \"./response.js\";\nexport {\n requestPolicyFactoryPolicyName,\n createRequestPolicyFactoryPolicy,\n RequestPolicyFactory,\n RequestPolicy,\n RequestPolicyOptionsLike,\n HttpPipelineLogLevel,\n} from \"./policies/requestPolicyFactoryPolicy.js\";\nexport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nexport { RedirectOptions } from \"./policies/redirectOptions.js\";\nexport { disableKeepAlivePolicyName } from \"./policies/disableKeepAlivePolicy.js\";\nexport { convertHttpClient } from \"./httpClientAdapter.js\";\nexport {\n WebResourceLike,\n HttpHeadersLike,\n RawHttpHeaders,\n HttpHeader,\n TransferProgressEvent,\n toHttpHeadersLike,\n} from \"./util.js\";\n"]}

View file

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View file

@ -0,0 +1,8 @@
import { Pipeline, PipelinePolicy } from "@azure/core-rest-pipeline";
export declare const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
export declare function createDisableKeepAlivePolicy(): PipelinePolicy;
/**
* @internal
*/
export declare function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean;
//# sourceMappingURL=disableKeepAlivePolicy.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,cAAc,EAIf,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAEnE,wBAAgB,4BAA4B,IAAI,cAAc,CAQ7D;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElF"}

View file

@ -0,0 +1,24 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.pipelineContainsDisableKeepAlivePolicy = exports.createDisableKeepAlivePolicy = exports.disableKeepAlivePolicyName = void 0;
exports.disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
function createDisableKeepAlivePolicy() {
return {
name: exports.disableKeepAlivePolicyName,
async sendRequest(request, next) {
request.disableKeepAlive = true;
return next(request);
},
};
}
exports.createDisableKeepAlivePolicy = createDisableKeepAlivePolicy;
/**
* @internal
*/
function pipelineContainsDisableKeepAlivePolicy(pipeline) {
return pipeline.getOrderedPolicies().some((policy) => policy.name === exports.disableKeepAlivePolicyName);
}
exports.pipelineContainsDisableKeepAlivePolicy = pipelineContainsDisableKeepAlivePolicy;
//# sourceMappingURL=disableKeepAlivePolicy.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.js","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAUrB,QAAA,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,SAAgB,4BAA4B;IAC1C,OAAO;QACL,IAAI,EAAE,kCAA0B;QAChC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAChC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AARD,oEAQC;AAED;;GAEG;AACH,SAAgB,sCAAsC,CAAC,QAAkB;IACvE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,kCAA0B,CAAC,CAAC;AACpG,CAAC;AAFD,wFAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nexport const disableKeepAlivePolicyName = \"DisableKeepAlivePolicy\";\n\nexport function createDisableKeepAlivePolicy(): PipelinePolicy {\n return {\n name: disableKeepAlivePolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.disableKeepAlive = true;\n return next(request);\n },\n };\n}\n\n/**\n * @internal\n */\nexport function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean {\n return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);\n}\n"]}

View file

@ -0,0 +1,11 @@
/**
* Keep Alive Options for how HTTP connections.
*/
export interface KeepAliveOptions {
/**
* When true, connections will be kept alive for multiple requests.
* Defaults to true.
*/
enable?: boolean;
}
//# sourceMappingURL=keepAliveOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}

View file

@ -0,0 +1,5 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=keepAliveOptions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.js","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Keep Alive Options for how HTTP connections.\n */\nexport interface KeepAliveOptions {\n /**\n * When true, connections will be kept alive for multiple requests.\n * Defaults to true.\n */\n enable?: boolean;\n}\n"]}

View file

@ -0,0 +1,15 @@
/**
* Options for how redirect responses are handled.
*/
export interface RedirectOptions {
/**
* When true, redirect responses are followed. Defaults to true.
*/
handleRedirects?: boolean;
/**
* The maximum number of times the redirect URL will be tried before
* failing. Defaults to 20.
*/
maxRetries?: number;
}
//# sourceMappingURL=redirectOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"redirectOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/redirectOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}

View file

@ -0,0 +1,5 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=redirectOptions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"redirectOptions.js","sourceRoot":"","sources":["../../../src/policies/redirectOptions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Options for how redirect responses are handled.\n */\nexport interface RedirectOptions {\n /**\n * When true, redirect responses are followed. Defaults to true.\n */\n handleRedirects?: boolean;\n\n /**\n * The maximum number of times the redirect URL will be tried before\n * failing. Defaults to 20.\n */\n maxRetries?: number;\n}\n"]}

View file

@ -0,0 +1,41 @@
import { PipelinePolicy } from "@azure/core-rest-pipeline";
import { WebResourceLike } from "../util.js";
import { CompatResponse } from "../response.js";
/**
* A compatible interface for core-http request policies
*/
export interface RequestPolicy {
sendRequest(httpRequest: WebResourceLike): Promise<CompatResponse>;
}
/**
* An enum for compatibility with RequestPolicy
*/
export declare enum HttpPipelineLogLevel {
ERROR = 1,
INFO = 3,
OFF = 0,
WARNING = 2
}
/**
* An interface for compatibility with RequestPolicy
*/
export interface RequestPolicyOptionsLike {
log(logLevel: HttpPipelineLogLevel, message: string): void;
shouldLog(logLevel: HttpPipelineLogLevel): boolean;
}
/**
* An interface for compatibility with core-http's RequestPolicyFactory
*/
export interface RequestPolicyFactory {
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;
}
/**
* The name of the RequestPolicyFactoryPolicy
*/
export declare const requestPolicyFactoryPolicyName = "RequestPolicyFactoryPolicy";
/**
* A policy that wraps policies written for core-http.
* @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline
*/
export declare function createRequestPolicyFactoryPolicy(factories: RequestPolicyFactory[]): PipelinePolicy;
//# sourceMappingURL=requestPolicyFactoryPolicy.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"requestPolicyFactoryPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/requestPolicyFactoryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EAIf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAwC,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,cAAc,EAAwC,MAAM,gBAAgB,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,KAAK,IAAI;IACT,IAAI,IAAI;IACR,GAAG,IAAI;IACP,OAAO,IAAI;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC;CACpD;AAWD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC;CACrF;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,+BAA+B,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,oBAAoB,EAAE,GAChC,cAAc,CAqBhB"}

View file

@ -0,0 +1,55 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRequestPolicyFactoryPolicy = exports.requestPolicyFactoryPolicyName = exports.HttpPipelineLogLevel = void 0;
const util_js_1 = require("../util.js");
const response_js_1 = require("../response.js");
/**
* An enum for compatibility with RequestPolicy
*/
var HttpPipelineLogLevel;
(function (HttpPipelineLogLevel) {
HttpPipelineLogLevel[HttpPipelineLogLevel["ERROR"] = 1] = "ERROR";
HttpPipelineLogLevel[HttpPipelineLogLevel["INFO"] = 3] = "INFO";
HttpPipelineLogLevel[HttpPipelineLogLevel["OFF"] = 0] = "OFF";
HttpPipelineLogLevel[HttpPipelineLogLevel["WARNING"] = 2] = "WARNING";
})(HttpPipelineLogLevel || (exports.HttpPipelineLogLevel = HttpPipelineLogLevel = {}));
const mockRequestPolicyOptions = {
log(_logLevel, _message) {
/* do nothing */
},
shouldLog(_logLevel) {
return false;
},
};
/**
* The name of the RequestPolicyFactoryPolicy
*/
exports.requestPolicyFactoryPolicyName = "RequestPolicyFactoryPolicy";
/**
* A policy that wraps policies written for core-http.
* @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline
*/
function createRequestPolicyFactoryPolicy(factories) {
const orderedFactories = factories.slice().reverse();
return {
name: exports.requestPolicyFactoryPolicyName,
async sendRequest(request, next) {
let httpPipeline = {
async sendRequest(httpRequest) {
const response = await next((0, util_js_1.toPipelineRequest)(httpRequest));
return (0, response_js_1.toCompatResponse)(response, { createProxy: true });
},
};
for (const factory of orderedFactories) {
httpPipeline = factory.create(httpPipeline, mockRequestPolicyOptions);
}
const webResourceLike = (0, util_js_1.toWebResourceLike)(request, { createProxy: true });
const response = await httpPipeline.sendRequest(webResourceLike);
return (0, response_js_1.toPipelineResponse)(response);
},
};
}
exports.createRequestPolicyFactoryPolicy = createRequestPolicyFactoryPolicy;
//# sourceMappingURL=requestPolicyFactoryPolicy.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"requestPolicyFactoryPolicy.js","sourceRoot":"","sources":["../../../src/policies/requestPolicyFactoryPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,wCAAmF;AACnF,gDAAsF;AAStF;;GAEG;AACH,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,iEAAS,CAAA;IACT,+DAAQ,CAAA;IACR,6DAAO,CAAA;IACP,qEAAW,CAAA;AACb,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B;AAUD,MAAM,wBAAwB,GAA6B;IACzD,GAAG,CAAC,SAA+B,EAAE,QAAgB;QACnD,gBAAgB;IAClB,CAAC;IACD,SAAS,CAAC,SAA+B;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AASF;;GAEG;AACU,QAAA,8BAA8B,GAAG,4BAA4B,CAAC;AAE3E;;;GAGG;AACH,SAAgB,gCAAgC,CAC9C,SAAiC;IAEjC,MAAM,gBAAgB,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC;IAErD,OAAO;QACL,IAAI,EAAE,sCAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,YAAY,GAAkB;gBAChC,KAAK,CAAC,WAAW,CAAC,WAAW;oBAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAA,2BAAiB,EAAC,WAAW,CAAC,CAAC,CAAC;oBAC5D,OAAO,IAAA,8BAAgB,EAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC3D,CAAC;aACF,CAAC;YACF,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;gBACvC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;YACxE,CAAC;YAED,MAAM,eAAe,GAAG,IAAA,2BAAiB,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACjE,OAAO,IAAA,gCAAkB,EAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,4EAuBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { WebResourceLike, toPipelineRequest, toWebResourceLike } from \"../util.js\";\nimport { CompatResponse, toCompatResponse, toPipelineResponse } from \"../response.js\";\n\n/**\n * A compatible interface for core-http request policies\n */\nexport interface RequestPolicy {\n sendRequest(httpRequest: WebResourceLike): Promise<CompatResponse>;\n}\n\n/**\n * An enum for compatibility with RequestPolicy\n */\nexport enum HttpPipelineLogLevel {\n ERROR = 1,\n INFO = 3,\n OFF = 0,\n WARNING = 2,\n}\n\n/**\n * An interface for compatibility with RequestPolicy\n */\nexport interface RequestPolicyOptionsLike {\n log(logLevel: HttpPipelineLogLevel, message: string): void;\n shouldLog(logLevel: HttpPipelineLogLevel): boolean;\n}\n\nconst mockRequestPolicyOptions: RequestPolicyOptionsLike = {\n log(_logLevel: HttpPipelineLogLevel, _message: string): void {\n /* do nothing */\n },\n shouldLog(_logLevel: HttpPipelineLogLevel): boolean {\n return false;\n },\n};\n\n/**\n * An interface for compatibility with core-http's RequestPolicyFactory\n */\nexport interface RequestPolicyFactory {\n create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;\n}\n\n/**\n * The name of the RequestPolicyFactoryPolicy\n */\nexport const requestPolicyFactoryPolicyName = \"RequestPolicyFactoryPolicy\";\n\n/**\n * A policy that wraps policies written for core-http.\n * @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline\n */\nexport function createRequestPolicyFactoryPolicy(\n factories: RequestPolicyFactory[],\n): PipelinePolicy {\n const orderedFactories = factories.slice().reverse();\n\n return {\n name: requestPolicyFactoryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n let httpPipeline: RequestPolicy = {\n async sendRequest(httpRequest) {\n const response = await next(toPipelineRequest(httpRequest));\n return toCompatResponse(response, { createProxy: true });\n },\n };\n for (const factory of orderedFactories) {\n httpPipeline = factory.create(httpPipeline, mockRequestPolicyOptions);\n }\n\n const webResourceLike = toWebResourceLike(request, { createProxy: true });\n const response = await httpPipeline.sendRequest(webResourceLike);\n return toPipelineResponse(response);\n },\n };\n}\n"]}

View file

@ -0,0 +1,30 @@
import { FullOperationResponse } from "@azure/core-client";
import { PipelineResponse } from "@azure/core-rest-pipeline";
import { HttpHeadersLike, WebResourceLike } from "./util.js";
/**
* Http Response that is compatible with the core-v1(core-http).
*/
export interface CompatResponse extends Omit<FullOperationResponse, "request" | "headers"> {
/**
* A description of a HTTP request to be made to a remote server.
*/
request: WebResourceLike;
/**
* A collection of HTTP header key/value pairs.
*/
headers: HttpHeadersLike;
}
/**
* A helper to convert response objects from the new pipeline back to the old one.
* @param response - A response object from core-client.
* @returns A response compatible with `HttpOperationResponse` from core-http.
*/
export declare function toCompatResponse(response: FullOperationResponse, options?: {
createProxy?: boolean;
}): CompatResponse;
/**
* A helper to convert back to a PipelineResponse
* @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.
*/
export declare function toPipelineResponse(compatResponse: CompatResponse): PipelineResponse;
//# sourceMappingURL=response.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAqB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EACL,eAAe,EACf,eAAe,EAIhB,MAAM,WAAW,CAAC;AACnB;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,SAAS,CAAC;IACxF;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;CAC1B;AAKD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAClC,cAAc,CA+BhB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,gBAAgB,CAcnF"}

View file

@ -0,0 +1,65 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.toPipelineResponse = exports.toCompatResponse = void 0;
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
const util_js_1 = require("./util.js");
const originalResponse = Symbol("Original FullOperationResponse");
/**
* A helper to convert response objects from the new pipeline back to the old one.
* @param response - A response object from core-client.
* @returns A response compatible with `HttpOperationResponse` from core-http.
*/
function toCompatResponse(response, options) {
let request = (0, util_js_1.toWebResourceLike)(response.request);
let headers = (0, util_js_1.toHttpHeadersLike)(response.headers);
if (options === null || options === void 0 ? void 0 : options.createProxy) {
return new Proxy(response, {
get(target, prop, receiver) {
if (prop === "headers") {
return headers;
}
else if (prop === "request") {
return request;
}
else if (prop === originalResponse) {
return response;
}
return Reflect.get(target, prop, receiver);
},
set(target, prop, value, receiver) {
if (prop === "headers") {
headers = value;
}
else if (prop === "request") {
request = value;
}
return Reflect.set(target, prop, value, receiver);
},
});
}
else {
return Object.assign(Object.assign({}, response), { request,
headers });
}
}
exports.toCompatResponse = toCompatResponse;
/**
* A helper to convert back to a PipelineResponse
* @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.
*/
function toPipelineResponse(compatResponse) {
const extendedCompatResponse = compatResponse;
const response = extendedCompatResponse[originalResponse];
const headers = (0, core_rest_pipeline_1.createHttpHeaders)(compatResponse.headers.toJson({ preserveCase: true }));
if (response) {
response.headers = headers;
return response;
}
else {
return Object.assign(Object.assign({}, compatResponse), { headers, request: (0, util_js_1.toPipelineRequest)(compatResponse.request) });
}
}
exports.toPipelineResponse = toPipelineResponse;
//# sourceMappingURL=response.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,kEAAgF;AAChF,uCAMmB;AAenB,MAAM,gBAAgB,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAGlE;;;;GAIG;AACH,SAAgB,gBAAgB,CAC9B,QAA+B,EAC/B,OAAmC;IAEnC,IAAI,OAAO,GAAG,IAAA,2BAAiB,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,OAAO,GAAG,IAAA,2BAAiB,EAAC,QAAQ,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AY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzF,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,uCACK,cAAc,KACjB,OAAO,EACP,OAAO,EAAE,IAAA,2BAAiB,EAAC,cAAc,CAAC,OAAO,CAAC,IAClD;IACJ,CAAC;AACH,CAAC;AAdD,gDAcC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n HttpHeadersLike,\n WebResourceLike,\n toHttpHeadersLike,\n toPipelineRequest,\n toWebResourceLike,\n} from \"./util.js\";\n/**\n * Http Response that is compatible with the core-v1(core-http).\n */\nexport interface CompatResponse extends Omit<FullOperationResponse, \"request\" | \"headers\"> {\n /**\n * A description of a HTTP request to be made to a remote server.\n */\n request: WebResourceLike;\n /**\n * A collection of HTTP header key/value pairs.\n */\n headers: HttpHeadersLike;\n}\n\nconst originalResponse = Symbol(\"Original FullOperationResponse\");\ntype ExtendedCompatResponse = CompatResponse & { [originalResponse]?: FullOperationResponse };\n\n/**\n * A helper to convert response objects from the new pipeline back to the old one.\n * @param response - A response object from core-client.\n * @returns A response compatible with `HttpOperationResponse` from core-http.\n */\nexport function toCompatResponse(\n response: FullOperationResponse,\n options?: { createProxy?: boolean },\n): CompatResponse {\n let request = toWebResourceLike(response.request);\n let headers = toHttpHeadersLike(response.headers);\n if (options?.createProxy) {\n return new Proxy(response, {\n get(target, prop, receiver) {\n if (prop === \"headers\") {\n return headers;\n } else if (prop === \"request\") {\n return request;\n } else if (prop === originalResponse) {\n return response;\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, value, receiver) {\n if (prop === \"headers\") {\n headers = value;\n } else if (prop === \"request\") {\n request = value;\n }\n return Reflect.set(target, prop, value, receiver);\n },\n }) as unknown as CompatResponse;\n } else {\n return {\n ...response,\n request,\n headers,\n };\n }\n}\n\n/**\n * A helper to convert back to a PipelineResponse\n * @param compatResponse - A response compatible with `HttpOperationResponse` from core-http.\n */\nexport function toPipelineResponse(compatResponse: CompatResponse): PipelineResponse {\n const extendedCompatResponse = compatResponse as ExtendedCompatResponse;\n const response = extendedCompatResponse[originalResponse];\n const headers = createHttpHeaders(compatResponse.headers.toJson({ preserveCase: true }));\n if (response) {\n response.headers = headers;\n return response;\n } else {\n return {\n ...compatResponse,\n headers,\n request: toPipelineRequest(compatResponse.request),\n };\n }\n}\n"]}

View file

@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.43.1"
}
]
}

View file

@ -0,0 +1,251 @@
import { HttpMethods, ProxySettings } from "@azure/core-rest-pipeline";
import { AbortSignalLike } from "@azure/abort-controller";
import { HttpHeaders as HttpHeadersV2, PipelineRequest } from "@azure/core-rest-pipeline";
export declare function toPipelineRequest(webResource: WebResourceLike, options?: {
originalRequest?: PipelineRequest;
}): PipelineRequest;
export declare function toWebResourceLike(request: PipelineRequest, options?: {
createProxy?: boolean;
originalRequest?: PipelineRequest;
}): WebResourceLike;
/**
* Converts HttpHeaders from core-rest-pipeline to look like
* HttpHeaders from core-http.
* @param headers - HttpHeaders from core-rest-pipeline
* @returns HttpHeaders as they looked in core-http
*/
export declare function toHttpHeadersLike(headers: HttpHeadersV2): HttpHeadersLike;
/**
* An individual header within a HttpHeaders collection.
*/
export interface HttpHeader {
/**
* The name of the header.
*/
name: string;
/**
* The value of the header.
*/
value: string;
}
/**
* A HttpHeaders collection represented as a simple JSON object.
*/
export type RawHttpHeaders = {
[headerName: string]: string;
};
/**
* A collection of HTTP header key/value pairs.
*/
export interface HttpHeadersLike {
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName: string, headerValue: string | number): void;
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName: string): string | undefined;
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName: string): boolean;
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName: string): boolean;
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders(): RawHttpHeaders;
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray(): HttpHeader[];
/**
* Get the header names that are contained in this collection.
*/
headerNames(): string[];
/**
* Get the header values that are contained in this collection.
*/
headerValues(): string[];
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone(): HttpHeadersLike;
/**
* Get the JSON object representation of this HTTP header collection.
* The result is the same as `rawHeaders()`.
*/
toJson(options?: {
preserveCase?: boolean;
}): RawHttpHeaders;
}
/**
* A collection of HTTP header key/value pairs.
*/
export declare class HttpHeaders implements HttpHeadersLike {
private readonly _headersMap;
constructor(rawHeaders?: RawHttpHeaders);
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName: string, headerValue: string | number): void;
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName: string): string | undefined;
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName: string): boolean;
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName: string): boolean;
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders(): RawHttpHeaders;
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray(): HttpHeader[];
/**
* Get the header names that are contained in this collection.
*/
headerNames(): string[];
/**
* Get the header values that are contained in this collection.
*/
headerValues(): string[];
/**
* Get the JSON object representation of this HTTP header collection.
*/
toJson(options?: {
preserveCase?: boolean;
}): RawHttpHeaders;
/**
* Get the string representation of this HTTP header collection.
*/
toString(): string;
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone(): HttpHeaders;
}
/**
* A description of a HTTP request to be made to a remote server.
*/
export interface WebResourceLike {
/**
* The URL being accessed by the request.
*/
url: string;
/**
* The HTTP method to use when making the request.
*/
method: HttpMethods;
/**
* The HTTP body contents of the request.
*/
body?: any;
/**
* The HTTP headers to use when making the request.
*/
headers: HttpHeadersLike;
/**
* Whether or not the body of the HttpOperationResponse should be treated as a stream.
* @deprecated Use streamResponseStatusCodes property instead.
*/
streamResponseBody?: boolean;
/**
* A list of response status codes whose corresponding HttpOperationResponse body should be treated as a stream.
*/
streamResponseStatusCodes?: Set<number>;
/**
* Form data, used to build the request body.
*/
formData?: any;
/**
* A query string represented as an object.
*/
query?: {
[key: string]: any;
};
/**
* If credentials (cookies) should be sent along during an XHR.
*/
withCredentials: boolean;
/**
* The number of milliseconds a request can take before automatically being terminated.
* If the request is terminated, an `AbortError` is thrown.
*/
timeout: number;
/**
* Proxy configuration.
*/
proxySettings?: ProxySettings;
/**
* If the connection should be reused.
*/
keepAlive?: boolean;
/**
* Whether or not to decompress response according to Accept-Encoding header (node-fetch only)
*/
decompressResponse?: boolean;
/**
* A unique identifier for the request. Used for logging and tracing.
*/
requestId: string;
/**
* Signal of an abort controller. Can be used to abort both sending a network request and waiting for a response.
*/
abortSignal?: AbortSignalLike;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/** Callback which fires upon download progress. */
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Clone this request object.
*/
clone(): WebResourceLike;
/**
* Validates that the required properties such as method, url, headers["Content-Type"],
* headers["accept-language"] are defined. It will throw an error if one of the above
* mentioned properties are not defined.
* Note: this a no-op for compat purposes.
*/
validateRequestProperties(): void;
/**
* This is a no-op for compat purposes and will throw if called.
*/
prepare(options: unknown): WebResourceLike;
}
/**
* Fired in response to upload or download progress.
*/
export type TransferProgressEvent = {
/**
* The number of bytes loaded so far.
*/
loadedBytes: number;
};
//# sourceMappingURL=util.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,aAAa,EAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,IAAI,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAe1F,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,eAAe,CAAC;CAC9B,GACL,eAAe,CA8BjB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,eAAe,CAAA;CAAE,GACrE,eAAe,CAwEjB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,eAAe,CAEzE;AASD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5D;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE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AAqB,GAAG;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}

View file

@ -0,0 +1,263 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpHeaders = exports.toHttpHeadersLike = exports.toWebResourceLike = exports.toPipelineRequest = void 0;
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
// We use a custom symbol to cache a reference to the original request without
// exposing it on the public interface.
const originalRequestSymbol = Symbol("Original PipelineRequest");
// Symbol.for() will return the same symbol if it's already been created
// This particular one is used in core-client to handle the case of when a request is
// cloned but we need to retrieve the OperationSpec and OperationArguments from the
// original request.
const originalClientRequestSymbol = Symbol.for("@azure/core-client original request");
function toPipelineRequest(webResource, options = {}) {
const compatWebResource = webResource;
const request = compatWebResource[originalRequestSymbol];
const headers = (0, core_rest_pipeline_1.createHttpHeaders)(webResource.headers.toJson({ preserveCase: true }));
if (request) {
request.headers = headers;
return request;
}
else {
const newRequest = (0, core_rest_pipeline_1.createPipelineRequest)({
url: webResource.url,
method: webResource.method,
headers,
withCredentials: webResource.withCredentials,
timeout: webResource.timeout,
requestId: webResource.requestId,
abortSignal: webResource.abortSignal,
body: webResource.body,
formData: webResource.formData,
disableKeepAlive: !!webResource.keepAlive,
onDownloadProgress: webResource.onDownloadProgress,
onUploadProgress: webResource.onUploadProgress,
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
options.originalRequest;
}
return newRequest;
}
}
exports.toPipelineRequest = toPipelineRequest;
function toWebResourceLike(request, options) {
var _a;
const originalRequest = (_a = options === null || options === void 0 ? void 0 : options.originalRequest) !== null && _a !== void 0 ? _a : request;
const webResource = {
url: request.url,
method: request.method,
headers: toHttpHeadersLike(request.headers),
withCredentials: request.withCredentials,
timeout: request.timeout,
requestId: request.headers.get("x-ms-client-request-id") || request.requestId,
abortSignal: request.abortSignal,
body: request.body,
formData: request.formData,
keepAlive: !!request.disableKeepAlive,
onDownloadProgress: request.onDownloadProgress,
onUploadProgress: request.onUploadProgress,
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
prepare() {
throw new Error("WebResourceLike.prepare() is not supported by @azure/core-http-compat");
},
validateRequestProperties() {
/** do nothing */
},
};
if (options === null || options === void 0 ? void 0 : options.createProxy) {
return new Proxy(webResource, {
get(target, prop, receiver) {
if (prop === originalRequestSymbol) {
return request;
}
else if (prop === "clone") {
return () => {
return toWebResourceLike(toPipelineRequest(webResource, { originalRequest }), {
createProxy: true,
originalRequest,
});
};
}
return Reflect.get(target, prop, receiver);
},
set(target, prop, value, receiver) {
if (prop === "keepAlive") {
request.disableKeepAlive = !value;
}
const passThroughProps = [
"url",
"method",
"withCredentials",
"timeout",
"requestId",
"abortSignal",
"body",
"formData",
"onDownloadProgress",
"onUploadProgress",
"proxySettings",
"streamResponseStatusCodes",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
}
return Reflect.set(target, prop, value, receiver);
},
});
}
else {
return webResource;
}
}
exports.toWebResourceLike = toWebResourceLike;
/**
* Converts HttpHeaders from core-rest-pipeline to look like
* HttpHeaders from core-http.
* @param headers - HttpHeaders from core-rest-pipeline
* @returns HttpHeaders as they looked in core-http
*/
function toHttpHeadersLike(headers) {
return new HttpHeaders(headers.toJSON({ preserveCase: true }));
}
exports.toHttpHeadersLike = toHttpHeadersLike;
/**
* A collection of HttpHeaders that can be sent with a HTTP request.
*/
function getHeaderKey(headerName) {
return headerName.toLowerCase();
}
/**
* A collection of HTTP header key/value pairs.
*/
class HttpHeaders {
constructor(rawHeaders) {
this._headersMap = {};
if (rawHeaders) {
for (const headerName in rawHeaders) {
this.set(headerName, rawHeaders[headerName]);
}
}
}
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName, headerValue) {
this._headersMap[getHeaderKey(headerName)] = {
name: headerName,
value: headerValue.toString(),
};
}
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName) {
const header = this._headersMap[getHeaderKey(headerName)];
return !header ? undefined : header.value;
}
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName) {
return !!this._headersMap[getHeaderKey(headerName)];
}
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName) {
const result = this.contains(headerName);
delete this._headersMap[getHeaderKey(headerName)];
return result;
}
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders() {
return this.toJson({ preserveCase: true });
}
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray() {
const headers = [];
for (const headerKey in this._headersMap) {
headers.push(this._headersMap[headerKey]);
}
return headers;
}
/**
* Get the header names that are contained in this collection.
*/
headerNames() {
const headerNames = [];
const headers = this.headersArray();
for (let i = 0; i < headers.length; ++i) {
headerNames.push(headers[i].name);
}
return headerNames;
}
/**
* Get the header values that are contained in this collection.
*/
headerValues() {
const headerValues = [];
const headers = this.headersArray();
for (let i = 0; i < headers.length; ++i) {
headerValues.push(headers[i].value);
}
return headerValues;
}
/**
* Get the JSON object representation of this HTTP header collection.
*/
toJson(options = {}) {
const result = {};
if (options.preserveCase) {
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
result[header.name] = header.value;
}
}
else {
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
result[getHeaderKey(header.name)] = header.value;
}
}
return result;
}
/**
* Get the string representation of this HTTP header collection.
*/
toString() {
return JSON.stringify(this.toJson({ preserveCase: true }));
}
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone() {
const resultPreservingCasing = {};
for (const headerKey in this._headersMap) {
const header = this._headersMap[headerKey];
resultPreservingCasing[header.name] = header.value;
}
return new HttpHeaders(resultPreservingCasing);
}
}
exports.HttpHeaders = HttpHeaders;
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,337 @@
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
import { AbortSignalLike } from '@azure/abort-controller';
import { CommonClientOptions } from '@azure/core-client';
import { FullOperationResponse } from '@azure/core-client';
import { HttpClient } from '@azure/core-rest-pipeline';
import { HttpHeaders } from '@azure/core-rest-pipeline';
import { HttpMethods } from '@azure/core-rest-pipeline';
import { OperationArguments } from '@azure/core-client';
import { OperationSpec } from '@azure/core-client';
import { PipelinePolicy } from '@azure/core-rest-pipeline';
import { ProxySettings } from '@azure/core-rest-pipeline';
import { ServiceClient } from '@azure/core-client';
import { ServiceClientOptions } from '@azure/core-client';
/**
* Http Response that is compatible with the core-v1(core-http).
*/
export declare interface CompatResponse extends Omit<FullOperationResponse, "request" | "headers"> {
/**
* A description of a HTTP request to be made to a remote server.
*/
request: WebResourceLike;
/**
* A collection of HTTP header key/value pairs.
*/
headers: HttpHeadersLike;
}
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export declare function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient;
/**
* A policy that wraps policies written for core-http.
* @param factories - An array of `RequestPolicyFactory` objects from a core-http pipeline
*/
export declare function createRequestPolicyFactoryPolicy(factories: RequestPolicyFactory[]): PipelinePolicy;
export declare const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
/**
* Options specific to Shim Clients.
*/
export declare interface ExtendedClientOptions {
/**
* Options to disable keep alive.
*/
keepAliveOptions?: KeepAliveOptions;
/**
* Options to redirect requests.
*/
redirectOptions?: RedirectOptions;
}
/**
* The common set of options that custom shim clients are expected to expose.
*/
export declare type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;
/**
* Client to provide compatability between core V1 & V2.
*/
export declare class ExtendedServiceClient extends ServiceClient {
constructor(options: ExtendedServiceClientOptions);
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
sendOperationRequest<T>(operationArguments: OperationArguments, operationSpec: OperationSpec): Promise<T>;
}
/**
* Options that shim clients are expected to expose.
*/
export declare type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;
/**
* An individual header within a HttpHeaders collection.
*/
export declare interface HttpHeader {
/**
* The name of the header.
*/
name: string;
/**
* The value of the header.
*/
value: string;
}
/**
* A collection of HTTP header key/value pairs.
*/
export declare interface HttpHeadersLike {
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param headerName - The name of the header to set. This value is case-insensitive.
* @param headerValue - The value of the header to set.
*/
set(headerName: string, headerValue: string | number): void;
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param headerName - The name of the header.
*/
get(headerName: string): string | undefined;
/**
* Get whether or not this header collection contains a header entry for the provided header name.
*/
contains(headerName: string): boolean;
/**
* Remove the header with the provided headerName. Return whether or not the header existed and
* was removed.
* @param headerName - The name of the header to remove.
*/
remove(headerName: string): boolean;
/**
* Get the headers that are contained this collection as an object.
*/
rawHeaders(): RawHttpHeaders;
/**
* Get the headers that are contained in this collection as an array.
*/
headersArray(): HttpHeader[];
/**
* Get the header names that are contained in this collection.
*/
headerNames(): string[];
/**
* Get the header values that are contained in this collection.
*/
headerValues(): string[];
/**
* Create a deep clone/copy of this HttpHeaders collection.
*/
clone(): HttpHeadersLike;
/**
* Get the JSON object representation of this HTTP header collection.
* The result is the same as `rawHeaders()`.
*/
toJson(options?: {
preserveCase?: boolean;
}): RawHttpHeaders;
}
/**
* An enum for compatibility with RequestPolicy
*/
export declare enum HttpPipelineLogLevel {
ERROR = 1,
INFO = 3,
OFF = 0,
WARNING = 2
}
/**
* Keep Alive Options for how HTTP connections.
*/
export declare interface KeepAliveOptions {
/**
* When true, connections will be kept alive for multiple requests.
* Defaults to true.
*/
enable?: boolean;
}
/**
* A HttpHeaders collection represented as a simple JSON object.
*/
export declare type RawHttpHeaders = {
[headerName: string]: string;
};
/**
* Options for how redirect responses are handled.
*/
export declare interface RedirectOptions {
/**
* When true, redirect responses are followed. Defaults to true.
*/
handleRedirects?: boolean;
/**
* The maximum number of times the redirect URL will be tried before
* failing. Defaults to 20.
*/
maxRetries?: number;
}
/**
* A compatible interface for core-http request policies
*/
export declare interface RequestPolicy {
sendRequest(httpRequest: WebResourceLike): Promise<CompatResponse>;
}
/**
* An interface for compatibility with core-http's RequestPolicyFactory
*/
export declare interface RequestPolicyFactory {
create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;
}
/**
* The name of the RequestPolicyFactoryPolicy
*/
export declare const requestPolicyFactoryPolicyName = "RequestPolicyFactoryPolicy";
/**
* An interface for compatibility with RequestPolicy
*/
export declare interface RequestPolicyOptionsLike {
log(logLevel: HttpPipelineLogLevel, message: string): void;
shouldLog(logLevel: HttpPipelineLogLevel): boolean;
}
/**
* Converts HttpHeaders from core-rest-pipeline to look like
* HttpHeaders from core-http.
* @param headers - HttpHeaders from core-rest-pipeline
* @returns HttpHeaders as they looked in core-http
*/
export declare function toHttpHeadersLike(headers: HttpHeaders): HttpHeadersLike;
/**
* Fired in response to upload or download progress.
*/
export declare type TransferProgressEvent = {
/**
* The number of bytes loaded so far.
*/
loadedBytes: number;
};
/**
* A description of a HTTP request to be made to a remote server.
*/
export declare interface WebResourceLike {
/**
* The URL being accessed by the request.
*/
url: string;
/**
* The HTTP method to use when making the request.
*/
method: HttpMethods;
/**
* The HTTP body contents of the request.
*/
body?: any;
/**
* The HTTP headers to use when making the request.
*/
headers: HttpHeadersLike;
/**
* Whether or not the body of the HttpOperationResponse should be treated as a stream.
* @deprecated Use streamResponseStatusCodes property instead.
*/
streamResponseBody?: boolean;
/**
* A list of response status codes whose corresponding HttpOperationResponse body should be treated as a stream.
*/
streamResponseStatusCodes?: Set<number>;
/**
* Form data, used to build the request body.
*/
formData?: any;
/**
* A query string represented as an object.
*/
query?: {
[key: string]: any;
};
/**
* If credentials (cookies) should be sent along during an XHR.
*/
withCredentials: boolean;
/**
* The number of milliseconds a request can take before automatically being terminated.
* If the request is terminated, an `AbortError` is thrown.
*/
timeout: number;
/**
* Proxy configuration.
*/
proxySettings?: ProxySettings;
/**
* If the connection should be reused.
*/
keepAlive?: boolean;
/**
* Whether or not to decompress response according to Accept-Encoding header (node-fetch only)
*/
decompressResponse?: boolean;
/**
* A unique identifier for the request. Used for logging and tracing.
*/
requestId: string;
/**
* Signal of an abort controller. Can be used to abort both sending a network request and waiting for a response.
*/
abortSignal?: AbortSignalLike;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/** Callback which fires upon download progress. */
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Clone this request object.
*/
clone(): WebResourceLike;
/**
* Validates that the required properties such as method, url, headers["Content-Type"],
* headers["accept-language"] are defined. It will throw an error if one of the above
* mentioned properties are not defined.
* Note: this a no-op for compat purposes.
*/
validateRequestProperties(): void;
/**
* This is a no-op for compat purposes and will throw if called.
*/
prepare(options: unknown): WebResourceLike;
}
export { }

View file

@ -0,0 +1,39 @@
import { KeepAliveOptions } from "./policies/keepAliveOptions.js";
import { RedirectOptions } from "./policies/redirectOptions.js";
import { CommonClientOptions, OperationArguments, OperationSpec, ServiceClient, ServiceClientOptions } from "@azure/core-client";
/**
* Options specific to Shim Clients.
*/
export interface ExtendedClientOptions {
/**
* Options to disable keep alive.
*/
keepAliveOptions?: KeepAliveOptions;
/**
* Options to redirect requests.
*/
redirectOptions?: RedirectOptions;
}
/**
* Options that shim clients are expected to expose.
*/
export type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;
/**
* The common set of options that custom shim clients are expected to expose.
*/
export type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;
/**
* Client to provide compatability between core V1 & V2.
*/
export declare class ExtendedServiceClient extends ServiceClient {
constructor(options: ExtendedServiceClientOptions);
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
sendOperationRequest<T>(operationArguments: OperationArguments, operationSpec: OperationSpec): Promise<T>;
}
//# sourceMappingURL=extendedClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.d.ts","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,EAEb,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAEtF;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,4BAA4B;IAiBjD;;;;;;OAMG;IACG,oBAAoB,CAAC,CAAC,EAC1B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,CAAC;CAgCd"}

View file

@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createDisableKeepAlivePolicy, pipelineContainsDisableKeepAlivePolicy, } from "./policies/disableKeepAlivePolicy.js";
import { redirectPolicyName } from "@azure/core-rest-pipeline";
import { ServiceClient, } from "@azure/core-client";
import { toCompatResponse } from "./response.js";
/**
* Client to provide compatability between core V1 & V2.
*/
export class ExtendedServiceClient extends ServiceClient {
constructor(options) {
var _a, _b;
super(options);
if (((_a = options.keepAliveOptions) === null || _a === void 0 ? void 0 : _a.enable) === false &&
!pipelineContainsDisableKeepAlivePolicy(this.pipeline)) {
this.pipeline.addPolicy(createDisableKeepAlivePolicy());
}
if (((_b = options.redirectOptions) === null || _b === void 0 ? void 0 : _b.handleRedirects) === false) {
this.pipeline.removePolicy({
name: redirectPolicyName,
});
}
}
/**
* Compatible send operation request function.
*
* @param operationArguments - Operation arguments
* @param operationSpec - Operation Spec
* @returns
*/
async sendOperationRequest(operationArguments, operationSpec) {
var _a;
const userProvidedCallBack = (_a = operationArguments === null || operationArguments === void 0 ? void 0 : operationArguments.options) === null || _a === void 0 ? void 0 : _a.onResponse;
let lastResponse;
function onResponse(rawResponse, flatResponse, error) {
lastResponse = rawResponse;
if (userProvidedCallBack) {
userProvidedCallBack(rawResponse, flatResponse, error);
}
}
operationArguments.options = Object.assign(Object.assign({}, operationArguments.options), { onResponse });
const result = await super.sendOperationRequest(operationArguments, operationSpec);
if (lastResponse) {
Object.defineProperty(result, "_response", {
value: toCompatResponse(lastResponse),
});
}
return result;
}
}
//# sourceMappingURL=extendedClient.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"extendedClient.js","sourceRoot":"","sources":["../../src/extendedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,sCAAsC,GACvC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAML,aAAa,GAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AA0BjD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,OAAqC;;QAC/C,KAAK,CAAC,OAAO,CAAC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IT license.\n\nimport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nimport {\n createDisableKeepAlivePolicy,\n pipelineContainsDisableKeepAlivePolicy,\n} from \"./policies/disableKeepAlivePolicy.js\";\nimport { RedirectOptions } from \"./policies/redirectOptions.js\";\nimport { redirectPolicyName } from \"@azure/core-rest-pipeline\";\nimport {\n CommonClientOptions,\n FullOperationResponse,\n OperationArguments,\n OperationSpec,\n RawResponseCallback,\n ServiceClient,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport { toCompatResponse } from \"./response.js\";\n\n/**\n * Options specific to Shim Clients.\n */\nexport interface ExtendedClientOptions {\n /**\n * Options to disable keep alive.\n */\n keepAliveOptions?: KeepAliveOptions;\n /**\n * Options to redirect requests.\n */\n redirectOptions?: RedirectOptions;\n}\n\n/**\n * Options that shim clients are expected to expose.\n */\nexport type ExtendedServiceClientOptions = ServiceClientOptions & ExtendedClientOptions;\n\n/**\n * The common set of options that custom shim clients are expected to expose.\n */\nexport type ExtendedCommonClientOptions = CommonClientOptions & ExtendedClientOptions;\n\n/**\n * Client to provide compatability between core V1 & V2.\n */\nexport class ExtendedServiceClient extends ServiceClient {\n constructor(options: ExtendedServiceClientOptions) {\n super(options);\n\n if (\n options.keepAliveOptions?.enable === false &&\n !pipelineContainsDisableKeepAlivePolicy(this.pipeline)\n ) {\n this.pipeline.addPolicy(createDisableKeepAlivePolicy());\n }\n\n if (options.redirectOptions?.handleRedirects === false) {\n this.pipeline.removePolicy({\n name: redirectPolicyName,\n });\n }\n }\n\n /**\n * Compatible send operation request function.\n *\n * @param operationArguments - Operation arguments\n * @param operationSpec - Operation Spec\n * @returns\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const userProvidedCallBack: RawResponseCallback | undefined =\n operationArguments?.options?.onResponse;\n\n let lastResponse: FullOperationResponse | undefined;\n\n function onResponse(\n rawResponse: FullOperationResponse,\n flatResponse: unknown,\n error?: unknown,\n ): void {\n lastResponse = rawResponse;\n if (userProvidedCallBack) {\n userProvidedCallBack(rawResponse, flatResponse, error);\n }\n }\n\n operationArguments.options = {\n ...operationArguments.options,\n onResponse,\n };\n\n const result: T = await super.sendOperationRequest(operationArguments, operationSpec);\n\n if (lastResponse) {\n Object.defineProperty(result, \"_response\", {\n value: toCompatResponse(lastResponse),\n });\n }\n\n return result;\n }\n}\n"]}

View file

@ -0,0 +1,9 @@
import { HttpClient } from "@azure/core-rest-pipeline";
import { RequestPolicy } from "./policies/requestPolicyFactoryPolicy.js";
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export declare function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient;
//# sourceMappingURL=httpClientAdapter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.d.ts","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAqC,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAIzE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,mBAAmB,EAAE,aAAa,GAAG,UAAU,CAShF"}

View file

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { toPipelineResponse } from "./response.js";
import { toWebResourceLike } from "./util.js";
/**
* Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.
* @param requestPolicyClient - A HttpClient compatible with core-http
* @returns A HttpClient compatible with core-rest-pipeline
*/
export function convertHttpClient(requestPolicyClient) {
return {
sendRequest: async (request) => {
const response = await requestPolicyClient.sendRequest(toWebResourceLike(request, { createProxy: true }));
return toPipelineResponse(response);
},
};
}
//# sourceMappingURL=httpClientAdapter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"httpClientAdapter.js","sourceRoot":"","sources":["../../src/httpClientAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,mBAAkC;IAClE,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,OAAwB,EAA6B,EAAE;YACzE,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,WAAW,CACpD,iBAAiB,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAClD,CAAC;YACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpClient, PipelineRequest, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { RequestPolicy } from \"./policies/requestPolicyFactoryPolicy.js\";\nimport { toPipelineResponse } from \"./response.js\";\nimport { toWebResourceLike } from \"./util.js\";\n\n/**\n * Converts a RequestPolicy based HttpClient to a PipelineRequest based HttpClient.\n * @param requestPolicyClient - A HttpClient compatible with core-http\n * @returns A HttpClient compatible with core-rest-pipeline\n */\nexport function convertHttpClient(requestPolicyClient: RequestPolicy): HttpClient {\n return {\n sendRequest: async (request: PipelineRequest): Promise<PipelineResponse> => {\n const response = await requestPolicyClient.sendRequest(\n toWebResourceLike(request, { createProxy: true }),\n );\n return toPipelineResponse(response);\n },\n };\n}\n"]}

View file

@ -0,0 +1,14 @@
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
export { ExtendedServiceClient, ExtendedServiceClientOptions, ExtendedCommonClientOptions, ExtendedClientOptions, } from "./extendedClient.js";
export { CompatResponse } from "./response.js";
export { requestPolicyFactoryPolicyName, createRequestPolicyFactoryPolicy, RequestPolicyFactory, RequestPolicy, RequestPolicyOptionsLike, HttpPipelineLogLevel, } from "./policies/requestPolicyFactoryPolicy.js";
export { KeepAliveOptions } from "./policies/keepAliveOptions.js";
export { RedirectOptions } from "./policies/redirectOptions.js";
export { disableKeepAlivePolicyName } from "./policies/disableKeepAlivePolicy.js";
export { convertHttpClient } from "./httpClientAdapter.js";
export { WebResourceLike, HttpHeadersLike, RawHttpHeaders, HttpHeader, TransferProgressEvent, toHttpHeadersLike, } from "./util.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC"}

13
node_modules/@azure/core-http-compat/dist/esm/index.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* A Shim Library that provides compatibility between Core V1 & V2 Packages.
*
* @packageDocumentation
*/
export { ExtendedServiceClient, } from "./extendedClient.js";
export { requestPolicyFactoryPolicyName, createRequestPolicyFactoryPolicy, HttpPipelineLogLevel, } from "./policies/requestPolicyFactoryPolicy.js";
export { disableKeepAlivePolicyName } from "./policies/disableKeepAlivePolicy.js";
export { convertHttpClient } from "./httpClientAdapter.js";
export { toHttpHeadersLike, } from "./util.js";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,OAAO,EACL,qBAAqB,GAItB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAIhC,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAML,iBAAiB,GAClB,MAAM,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A Shim Library that provides compatibility between Core V1 & V2 Packages.\n *\n * @packageDocumentation\n */\nexport {\n ExtendedServiceClient,\n ExtendedServiceClientOptions,\n ExtendedCommonClientOptions,\n ExtendedClientOptions,\n} from \"./extendedClient.js\";\nexport { CompatResponse } from \"./response.js\";\nexport {\n requestPolicyFactoryPolicyName,\n createRequestPolicyFactoryPolicy,\n RequestPolicyFactory,\n RequestPolicy,\n RequestPolicyOptionsLike,\n HttpPipelineLogLevel,\n} from \"./policies/requestPolicyFactoryPolicy.js\";\nexport { KeepAliveOptions } from \"./policies/keepAliveOptions.js\";\nexport { RedirectOptions } from \"./policies/redirectOptions.js\";\nexport { disableKeepAlivePolicyName } from \"./policies/disableKeepAlivePolicy.js\";\nexport { convertHttpClient } from \"./httpClientAdapter.js\";\nexport {\n WebResourceLike,\n HttpHeadersLike,\n RawHttpHeaders,\n HttpHeader,\n TransferProgressEvent,\n toHttpHeadersLike,\n} from \"./util.js\";\n"]}

View file

@ -0,0 +1,3 @@
{
"type": "module"
}

View file

@ -0,0 +1,8 @@
import { Pipeline, PipelinePolicy } from "@azure/core-rest-pipeline";
export declare const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
export declare function createDisableKeepAlivePolicy(): PipelinePolicy;
/**
* @internal
*/
export declare function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean;
//# sourceMappingURL=disableKeepAlivePolicy.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,cAAc,EAIf,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAEnE,wBAAgB,4BAA4B,IAAI,cAAc,CAQ7D;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElF"}

View file

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export const disableKeepAlivePolicyName = "DisableKeepAlivePolicy";
export function createDisableKeepAlivePolicy() {
return {
name: disableKeepAlivePolicyName,
async sendRequest(request, next) {
request.disableKeepAlive = true;
return next(request);
},
};
}
/**
* @internal
*/
export function pipelineContainsDisableKeepAlivePolicy(pipeline) {
return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);
}
//# sourceMappingURL=disableKeepAlivePolicy.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"disableKeepAlivePolicy.js","sourceRoot":"","sources":["../../../src/policies/disableKeepAlivePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAChC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sCAAsC,CAAC,QAAkB;IACvE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,0BAA0B,CAAC,CAAC;AACpG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nexport const disableKeepAlivePolicyName = \"DisableKeepAlivePolicy\";\n\nexport function createDisableKeepAlivePolicy(): PipelinePolicy {\n return {\n name: disableKeepAlivePolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.disableKeepAlive = true;\n return next(request);\n },\n };\n}\n\n/**\n * @internal\n */\nexport function pipelineContainsDisableKeepAlivePolicy(pipeline: Pipeline): boolean {\n return pipeline.getOrderedPolicies().some((policy) => policy.name === disableKeepAlivePolicyName);\n}\n"]}

View file

@ -0,0 +1,11 @@
/**
* Keep Alive Options for how HTTP connections.
*/
export interface KeepAliveOptions {
/**
* When true, connections will be kept alive for multiple requests.
* Defaults to true.
*/
enable?: boolean;
}
//# sourceMappingURL=keepAliveOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=keepAliveOptions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"keepAliveOptions.js","sourceRoot":"","sources":["../../../src/policies/keepAliveOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Keep Alive Options for how HTTP connections.\n */\nexport interface KeepAliveOptions {\n /**\n * When true, connections will be kept alive for multiple requests.\n * Defaults to true.\n */\n enable?: boolean;\n}\n"]}

View file

@ -0,0 +1,15 @@
/**
* Options for how redirect responses are handled.
*/
export interface RedirectOptions {
/**
* When true, redirect responses are followed. Defaults to true.
*/
handleRedirects?: boolean;
/**
* The maximum number of times the redirect URL will be tried before
* failing. Defaults to 20.
*/
maxRetries?: number;
}
//# sourceMappingURL=redirectOptions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"redirectOptions.d.ts","sourceRoot":"","sources":["../../../src/policies/redirectOptions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=redirectOptions.js.map

Some files were not shown because too many files have changed in this diff Show more