@azure-rest/core-client 1.0.0-alpha.20220131.3 → 1.0.0-alpha.20220204.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist-esm/src/common.js.map +1 -1
- package/dist-esm/src/getClient.js +11 -0
- package/dist-esm/src/getClient.js.map +1 -1
- package/package.json +2 -2
- package/types/latest/core-client-rest.d.ts +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- Handle Binary and FormData content. [#18753](https://github.com/Azure/azure-sdk-for-js/pull/18753)
|
|
8
8
|
- Support custom base url with path parameters. [#19463](https://github.com/Azure/azure-sdk-for-js/pull/19463)
|
|
9
|
+
- Added new `ClientOptions` member `additionalPolicies` to allow passing custom pipeline policies to client constructors. [#20175](https://github.com/Azure/azure-sdk-for-js/pull/20175)
|
|
9
10
|
|
|
10
11
|
### Breaking Changes
|
|
11
12
|
|
package/dist/index.js
CHANGED
|
@@ -430,6 +430,7 @@ function replaceAll(value, searchValue, replaceValue) {
|
|
|
430
430
|
|
|
431
431
|
// Copyright (c) Microsoft Corporation.
|
|
432
432
|
function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
|
|
433
|
+
var _a;
|
|
433
434
|
let credentials;
|
|
434
435
|
if (credentialsOrPipelineOptions) {
|
|
435
436
|
if (isCredential(credentialsOrPipelineOptions)) {
|
|
@@ -440,6 +441,16 @@ function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
|
|
|
440
441
|
}
|
|
441
442
|
}
|
|
442
443
|
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);
|
|
444
|
+
if ((_a = clientOptions.additionalPolicies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
445
|
+
for (const { policy, position } of clientOptions.additionalPolicies) {
|
|
446
|
+
// Sign happens after Retry and is commonly needed to occur
|
|
447
|
+
// before policies that intercept post-retry.
|
|
448
|
+
const afterPhase = position === "perRetry" ? "Sign" : undefined;
|
|
449
|
+
pipeline.addPolicy(policy, {
|
|
450
|
+
afterPhase,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
443
454
|
const { allowInsecureConnection } = clientOptions;
|
|
444
455
|
const client = (path, ...args) => {
|
|
445
456
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/typeGuards.ts","../src/certificateCredential.ts","../src/restError.ts","../src/keyCredentialAuthenticationPolicy.ts","../src/apiVersionPolicy.ts","../src/clientHelpers.ts","../src/helpers/getBinaryBody.ts","../src/sendRequest.ts","../src/urlHelpers.ts","../src/getClient.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n * @internal\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n * @internal\n */\nexport function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[]\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n * @internal\n */\nfunction objectHasProperty<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n property: PropertyName\n): thing is Thing & Record<PropertyName, unknown> {\n return typeof thing === \"object\" && property in (thing as Record<string, unknown>);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isObjectWithProperties } from \"./typeGuards\";\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Certificate used to authenticate\n */\n cert: string;\n /**\n * Certificate key\n */\n certKey: string;\n}\n\n/**\n * Tests an object to determine whether it implements CertificateCredential.\n *\n * @param credential - The assumed CertificateCredential to be tested.\n */\nexport function isCertificateCredential(credential: unknown): credential is CertificateCredential {\n return (\n isObjectWithProperties(credential, [\"certKey\", \"cert\"]) &&\n typeof credential.cert === \"string\" &&\n typeof credential.certKey === \"string\"\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError, PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { PathUncheckedResponse } from \"./common\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError {\n return new RestError(message, {\n statusCode: statusCodeToNumber(response.status),\n request: response.request,\n response: toPipelineResponse(response),\n });\n}\n\nfunction toPipelineResponse(response: PathUncheckedResponse): PipelineResponse {\n return {\n headers: createHttpHeaders(response.headers),\n request: response.request,\n status: statusCodeToNumber(response.status) ?? -1,\n };\n}\n\nfunction statusCodeToNumber(statusCode: string): number | undefined {\n const status = Number.parseInt(statusCode);\n\n return Number.isNaN(status) ? undefined : status;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { ClientOptions } from \"./common\";\nimport { URL } from \"./url\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n if (options.apiVersion) {\n const url = new URL(req.url);\n url.searchParams.append(\"api-version\", options.apiVersion);\n req.url = url.toString();\n }\n\n return next(req);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts a string representing binary content into a Uint8Array\n */\nexport function stringToBinaryArray(content: string): Uint8Array {\n const arr = new Uint8Array(content.length);\n for (let i = 0; i < content.length; i++) {\n arr[i] = content.charCodeAt(i);\n }\n\n return arr;\n}\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\nimport { binaryArrayToString, stringToBinaryArray } from \"./helpers/getBinaryBody\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response, options);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (!contentType && typeof body === \"string\") {\n return { body };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n if (firstType === \"application/json\") {\n return { body: JSON.stringify(body) };\n }\n\n if (ArrayBuffer.isView(body)) {\n if (body instanceof Uint8Array) {\n return { body: binaryArrayToString(body) };\n } else {\n return { body: JSON.stringify(body) };\n }\n }\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body)\n ? { formData: processFormData(body) }\n : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Checks if binary data is in Uint8Array format, if so decode it to a binary string\n * to send over the wire\n */\nfunction processFormData(formData?: FormDataMap) {\n if (!formData) {\n return formData;\n }\n\n const processedFormData: FormDataMap = {};\n\n for (const element in formData) {\n const item = formData[element];\n if (item instanceof Uint8Array) {\n processedFormData[element] = binaryArrayToString(item);\n } else {\n processedFormData[element] = item;\n }\n }\n\n return processedFormData;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(\n response: PipelineResponse,\n requestOptions: RequestParameters\n): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n /**\n * If we know from options or from the content type that we are receiving binary content,\n * encode it into a UInt8Array\n */\n if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {\n return stringToBinaryArray(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n\nfunction isBinaryContentType(contentType: string) {\n return [\n \"application/octet-stream\",\n \"application/x-rdp\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"application/pdf\",\n \"application/zip\",\n ].includes(contentType);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"./common\";\nimport { URL } from \"./url\";\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param baseUrl - base url which can be a template url\n * @param routePath - path to append to the baseUrl\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n baseUrl: string,\n routePath: string,\n pathParameters: string[],\n options: RequestParameters = {}\n): string {\n let path = routePath;\n\n if (path.startsWith(\"https://\") || path.startsWith(\"http://\")) {\n return path;\n }\n\n baseUrl = buildBaseUrl(baseUrl, options);\n\n for (const pathParam of pathParameters) {\n let value = pathParam;\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(pathParam);\n }\n\n path = path.replace(/{([^/]+)}/, value);\n }\n\n const url = new URL(`${baseUrl}/${path}`);\n\n if (options.queryParameters) {\n const queryParams = options.queryParameters;\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n const value = param.toISOString !== undefined ? param.toISOString() : param.toString();\n url.searchParams.append(key, value);\n }\n }\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n\nexport function buildBaseUrl(baseUrl: string, options: RequestParameters): string {\n if (!options.pathParameters) {\n return baseUrl;\n }\n const pathParams = options.pathParameters;\n for (const [key, param] of Object.entries(pathParams)) {\n if (param === undefined || param === null) {\n throw new Error(`Path parameters ${key} must not be undefined or null`);\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);\n }\n let value = param.toISOString !== undefined ? param.toISOString() : String(param);\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(param);\n }\n baseUrl = replaceAll(baseUrl, `{${key}}`, value) ?? \"\";\n }\n return baseUrl;\n}\n\n/**\n * Replace all of the instances of searchValue in value with the provided replaceValue.\n * @param value - The value to search and replace in.\n * @param searchValue - The value to search for in the value argument.\n * @param replaceValue - The value to replace searchValue with in the value argument.\n * @returns The value where each instance of searchValue was replaced with replacedValue.\n */\nexport function replaceAll(\n value: string | undefined,\n searchValue: string,\n replaceValue: string\n): string | undefined {\n return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || \"\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"],"names":["RestError","createHttpHeaders","url","URL","createEmptyPipeline","isNode","proxyPolicy","decompressResponsePolicy","formDataPolicy","userAgentPolicy","setClientRequestIdPolicy","throttlingRetryPolicy","systemErrorRetryPolicy","exponentialRetryPolicy","redirectPolicy","logPolicy","isTokenCredential","bearerTokenAuthenticationPolicy","createDefaultHttpClient","createPipelineRequest"],"mappings":";;;;;;;;;AAAA;AACA;AAEA;;;;;SAKgB,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAED;;;;;;SAMgB,sBAAsB,CACpC,KAAY,EACZ,UAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAClD,OAAO,KAAK,CAAC;KACd;IAED,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;QACjC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE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AAS,gBAAgB,CACvB,MAAmB,EACnB,OAAe,EACf,IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;;IAGnB,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1Cc,0BAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/typeGuards.ts","../src/certificateCredential.ts","../src/restError.ts","../src/keyCredentialAuthenticationPolicy.ts","../src/apiVersionPolicy.ts","../src/clientHelpers.ts","../src/helpers/getBinaryBody.ts","../src/sendRequest.ts","../src/urlHelpers.ts","../src/getClient.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n * @internal\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n * @internal\n */\nexport function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[]\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n * @internal\n */\nfunction objectHasProperty<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n property: PropertyName\n): thing is Thing & Record<PropertyName, unknown> {\n return typeof thing === \"object\" && property in (thing as Record<string, unknown>);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isObjectWithProperties } from \"./typeGuards\";\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Certificate used to authenticate\n */\n cert: string;\n /**\n * Certificate key\n */\n certKey: string;\n}\n\n/**\n * Tests an object to determine whether it implements CertificateCredential.\n *\n * @param credential - The assumed CertificateCredential to be tested.\n */\nexport function isCertificateCredential(credential: unknown): credential is CertificateCredential {\n return (\n isObjectWithProperties(credential, [\"certKey\", \"cert\"]) &&\n typeof credential.cert === \"string\" &&\n typeof credential.certKey === \"string\"\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError, PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { PathUncheckedResponse } from \"./common\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError {\n return new RestError(message, {\n statusCode: statusCodeToNumber(response.status),\n request: response.request,\n response: toPipelineResponse(response),\n });\n}\n\nfunction toPipelineResponse(response: PathUncheckedResponse): PipelineResponse {\n return {\n headers: createHttpHeaders(response.headers),\n request: response.request,\n status: statusCodeToNumber(response.status) ?? -1,\n };\n}\n\nfunction statusCodeToNumber(statusCode: string): number | undefined {\n const status = Number.parseInt(statusCode);\n\n return Number.isNaN(status) ? undefined : status;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { ClientOptions } from \"./common\";\nimport { URL } from \"./url\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n if (options.apiVersion) {\n const url = new URL(req.url);\n url.searchParams.append(\"api-version\", options.apiVersion);\n req.url = url.toString();\n }\n\n return next(req);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts a string representing binary content into a Uint8Array\n */\nexport function stringToBinaryArray(content: string): Uint8Array {\n const arr = new Uint8Array(content.length);\n for (let i = 0; i < content.length; i++) {\n arr[i] = content.charCodeAt(i);\n }\n\n return arr;\n}\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\nimport { binaryArrayToString, stringToBinaryArray } from \"./helpers/getBinaryBody\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response, options);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (!contentType && typeof body === \"string\") {\n return { body };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n if (firstType === \"application/json\") {\n return { body: JSON.stringify(body) };\n }\n\n if (ArrayBuffer.isView(body)) {\n if (body instanceof Uint8Array) {\n return { body: binaryArrayToString(body) };\n } else {\n return { body: JSON.stringify(body) };\n }\n }\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body)\n ? { formData: processFormData(body) }\n : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Checks if binary data is in Uint8Array format, if so decode it to a binary string\n * to send over the wire\n */\nfunction processFormData(formData?: FormDataMap) {\n if (!formData) {\n return formData;\n }\n\n const processedFormData: FormDataMap = {};\n\n for (const element in formData) {\n const item = formData[element];\n if (item instanceof Uint8Array) {\n processedFormData[element] = binaryArrayToString(item);\n } else {\n processedFormData[element] = item;\n }\n }\n\n return processedFormData;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(\n response: PipelineResponse,\n requestOptions: RequestParameters\n): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n /**\n * If we know from options or from the content type that we are receiving binary content,\n * encode it into a UInt8Array\n */\n if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {\n return stringToBinaryArray(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n\nfunction isBinaryContentType(contentType: string) {\n return [\n \"application/octet-stream\",\n \"application/x-rdp\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"application/pdf\",\n \"application/zip\",\n ].includes(contentType);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"./common\";\nimport { URL } from \"./url\";\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param baseUrl - base url which can be a template url\n * @param routePath - path to append to the baseUrl\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n baseUrl: string,\n routePath: string,\n pathParameters: string[],\n options: RequestParameters = {}\n): string {\n let path = routePath;\n\n if (path.startsWith(\"https://\") || path.startsWith(\"http://\")) {\n return path;\n }\n\n baseUrl = buildBaseUrl(baseUrl, options);\n\n for (const pathParam of pathParameters) {\n let value = pathParam;\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(pathParam);\n }\n\n path = path.replace(/{([^/]+)}/, value);\n }\n\n const url = new URL(`${baseUrl}/${path}`);\n\n if (options.queryParameters) {\n const queryParams = options.queryParameters;\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n const value = param.toISOString !== undefined ? param.toISOString() : param.toString();\n url.searchParams.append(key, value);\n }\n }\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n\nexport function buildBaseUrl(baseUrl: string, options: RequestParameters): string {\n if (!options.pathParameters) {\n return baseUrl;\n }\n const pathParams = options.pathParameters;\n for (const [key, param] of Object.entries(pathParams)) {\n if (param === undefined || param === null) {\n throw new Error(`Path parameters ${key} must not be undefined or null`);\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);\n }\n let value = param.toISOString !== undefined ? param.toISOString() : String(param);\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(param);\n }\n baseUrl = replaceAll(baseUrl, `{${key}}`, value) ?? \"\";\n }\n return baseUrl;\n}\n\n/**\n * Replace all of the instances of searchValue in value with the provided replaceValue.\n * @param value - The value to search and replace in.\n * @param searchValue - The value to search for in the value argument.\n * @param replaceValue - The value to replace searchValue with in the value argument.\n * @returns The value where each instance of searchValue was replaced with replacedValue.\n */\nexport function replaceAll(\n value: string | undefined,\n searchValue: string,\n replaceValue: string\n): string | undefined {\n return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || \"\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n if (clientOptions.additionalPolicies?.length) {\n for (const { policy, position } of clientOptions.additionalPolicies) {\n // Sign happens after Retry and is commonly needed to occur\n // before policies that intercept post-retry.\n const afterPhase = position === \"perRetry\" ? \"Sign\" : undefined;\n pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"],"names":["RestError","createHttpHeaders","url","URL","createEmptyPipeline","isNode","proxyPolicy","decompressResponsePolicy","formDataPolicy","userAgentPolicy","setClientRequestIdPolicy","throttlingRetryPolicy","systemErrorRetryPolicy","exponentialRetryPolicy","redirectPolicy","logPolicy","isTokenCredential","bearerTokenAuthenticationPolicy","createDefaultHttpClient","createPipelineRequest"],"mappings":";;;;;;;;;AAAA;AAC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"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelineOptions,\n PipelineRequest,\n RawHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * With this property set to true, the response body will be returned\n * as a binary array UInt8Array\n */\n binaryResponse?: boolean;\n\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n};\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript\n * export type MyClient = Client & {\n * path: Routes;\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n */\n baseUrl?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelineOptions,\n PipelinePolicy,\n PipelineRequest,\n RawHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * With this property set to true, the response body will be returned\n * as a binary array UInt8Array\n */\n binaryResponse?: boolean;\n\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n};\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript\n * export type MyClient = Client & {\n * path: Routes;\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n */\n baseUrl?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n"]}
|
|
@@ -6,6 +6,7 @@ import { createDefaultPipeline } from "./clientHelpers";
|
|
|
6
6
|
import { sendRequest } from "./sendRequest";
|
|
7
7
|
import { buildRequestUrl } from "./urlHelpers";
|
|
8
8
|
export function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
|
|
9
|
+
var _a;
|
|
9
10
|
let credentials;
|
|
10
11
|
if (credentialsOrPipelineOptions) {
|
|
11
12
|
if (isCredential(credentialsOrPipelineOptions)) {
|
|
@@ -16,6 +17,16 @@ export function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions =
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);
|
|
20
|
+
if ((_a = clientOptions.additionalPolicies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
21
|
+
for (const { policy, position } of clientOptions.additionalPolicies) {
|
|
22
|
+
// Sign happens after Retry and is commonly needed to occur
|
|
23
|
+
// before policies that intercept post-retry.
|
|
24
|
+
const afterPhase = position === "perRetry" ? "Sign" : undefined;
|
|
25
|
+
pipeline.addPolicy(policy, {
|
|
26
|
+
afterPhase,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
19
30
|
const { allowInsecureConnection } = clientOptions;
|
|
20
31
|
const client = (path, ...args) => {
|
|
21
32
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../src/getClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAkC,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EA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uBAAuB,IAAK,OAAO,GACrC,IAAI,CACL,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,CAAC,UAA6B,EAAE,EAAyB,EAAE;gBAClE,OAAO,gBAAgB,CACrB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,QAAQ,kBACN,uBAAuB,IAAK,OAAO,GACrC,IAAI,CACL,CAAC;YACJ,CAAC;YACD,KAAK,EAAE,CAAC,UAA6B,EAAE,EAAyB,EAAE;gBAChE,OAAO,gBAAgB,CACrB,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,kBACN,uBAAuB,IAAK,OAAO,GACrC,IAAI,CACL,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,MAAM;QACrB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAmB,EACnB,OAAe,EACf,IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;IAEnB,6GAA6G;IAC7G,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1C,iBAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n if (clientOptions.additionalPolicies?.length) {\n for (const { policy, position } of clientOptions.additionalPolicies) {\n // Sign happens after Retry and is commonly needed to occur\n // before policies that intercept post-retry.\n const afterPhase = position === \"perRetry\" ? \"Sign\" : undefined;\n pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-rest/core-client",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20220204.4",
|
|
4
4
|
"description": "Core library for interfacing with AutoRest rest level generated code",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@azure/core-auth": "^1.3.0",
|
|
60
|
-
"@azure/core-rest-pipeline": "^1.
|
|
60
|
+
"@azure/core-rest-pipeline": "^1.5.0",
|
|
61
61
|
"@azure/core-util": "^1.0.0-beta.1",
|
|
62
62
|
"tslib": "^2.2.0"
|
|
63
63
|
},
|
|
@@ -6,12 +6,30 @@
|
|
|
6
6
|
import { KeyCredential } from '@azure/core-auth';
|
|
7
7
|
import { Pipeline } from '@azure/core-rest-pipeline';
|
|
8
8
|
import { PipelineOptions } from '@azure/core-rest-pipeline';
|
|
9
|
+
import { PipelinePolicy } from '@azure/core-rest-pipeline';
|
|
9
10
|
import { PipelineRequest } from '@azure/core-rest-pipeline';
|
|
10
11
|
import { RawHttpHeaders } from '@azure/core-rest-pipeline';
|
|
11
12
|
import { RawHttpHeadersInput } from '@azure/core-rest-pipeline';
|
|
12
13
|
import { RestError } from '@azure/core-rest-pipeline';
|
|
13
14
|
import { TokenCredential } from '@azure/core-auth';
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Used to configure additional policies added to the pipeline at construction.
|
|
18
|
+
*/
|
|
19
|
+
export declare interface AdditionalPolicyConfig {
|
|
20
|
+
/**
|
|
21
|
+
* A policy to be added.
|
|
22
|
+
*/
|
|
23
|
+
policy: PipelinePolicy;
|
|
24
|
+
/**
|
|
25
|
+
* Determines if this policy be applied before or after retry logic.
|
|
26
|
+
* Only use `perRetry` if you need to modify the request again
|
|
27
|
+
* each time the operation is retried due to retryable service
|
|
28
|
+
* issues.
|
|
29
|
+
*/
|
|
30
|
+
position: "perCall" | "perRetry";
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
/**
|
|
16
34
|
* Represents a certificate credential for authentication.
|
|
17
35
|
*/
|
|
@@ -80,6 +98,10 @@ export declare type ClientOptions = PipelineOptions & {
|
|
|
80
98
|
* Option to allow calling http (insecure) endpoints
|
|
81
99
|
*/
|
|
82
100
|
allowInsecureConnection?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Additional policies to include in the HTTP pipeline.
|
|
103
|
+
*/
|
|
104
|
+
additionalPolicies?: AdditionalPolicyConfig[];
|
|
83
105
|
};
|
|
84
106
|
|
|
85
107
|
/**
|