@azure/core-client 1.9.3-alpha.20240704.2 → 1.9.3-alpha.20240705.2

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.
@@ -63,7 +63,6 @@ export declare class ServiceClient {
63
63
  readonly pipeline: Pipeline;
64
64
  /**
65
65
  * The ServiceClient constructor
66
- * @param credential - The credentials used for authentication with the service.
67
66
  * @param options - The service client options that govern the behavior of the client.
68
67
  */
69
68
  constructor(options?: ServiceClientOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAElB,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,QAAQ,EACR,eAAe,EACf,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IAEpC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAS;IAE9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAU;IAEpD;;OAEG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AAwB,CAAC,CAAU;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IAEzC;;OAEG;IACH,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC;;;OAGG;gBACS,OAAO,GAAE,oBAAyB;IAwB9C;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAItE;;;;;OAKG;IACG,oBAAoB,CAAC,CAAC,EAC1B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,CAAC;CA8Fd"}
@@ -14,7 +14,6 @@ import { logger } from "./log.js";
14
14
  export class ServiceClient {
15
15
  /**
16
16
  * The ServiceClient constructor
17
- * @param credential - The credentials used for authentication with the service.
18
17
  * @param options - The service client options that govern the behavior of the client.
19
18
  */
20
19
  constructor(options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAKL,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqClC;;GAEG;AACH,MAAM,OAAO,aAAa;IA4BxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACt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,UAAU,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAChF,CAAC;gBACF,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC;gBAC7B,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,EAAE,CAAC;oBACxB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,SAAS,qBAAqB,CAAC,OAA6B;IAC1D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,IAAI,gBAAgB;QACpC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;QACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,oBAAoB,iCACtB,OAAO,KACV,iBAAiB,IACjB,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param credential - The credentials used for authentication with the service.\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAKL,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqClC;;GAEG;AACH,MAAM,OAAO,aAAa;IA4BxB;;;OAGG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,CAAC;QACrD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CACZ,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CA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AAC,CAAC;gBACvD,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,SAAS,qBAAqB,CAAC,OAA6B;IAC1D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,IAAI,gBAAgB;QACpC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;QACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,oBAAoB,iCACtB,OAAO,KACV,iBAAiB,IACjB,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
@@ -63,7 +63,6 @@ export declare class ServiceClient {
63
63
  readonly pipeline: Pipeline;
64
64
  /**
65
65
  * The ServiceClient constructor
66
- * @param credential - The credentials used for authentication with the service.
67
66
  * @param options - The service client options that govern the behavior of the client.
68
67
  */
69
68
  constructor(options?: ServiceClientOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAElB,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,QAAQ,EACR,eAAe,EACf,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IAEpC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAS;IAE9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAU;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IAEzC;;OAEG;IACH,SAAg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,CAAa;IAEzC;;OAEG;IACH,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC;;;OAGG;gBACS,OAAO,GAAE,oBAAyB;IAwB9C;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAItE;;;;;OAKG;IACG,oBAAoB,CAAC,CAAC,EAC1B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,CAAC;CA8Fd"}
@@ -17,7 +17,6 @@ const log_js_1 = require("./log.js");
17
17
  class ServiceClient {
18
18
  /**
19
19
  * The ServiceClient constructor
20
- * @param credential - The credentials used for authentication with the service.
21
20
  * @param options - The service client options that govern the behavior of the client.
22
21
  */
23
22
  constructor(options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,kEAMmC;AAEnC,+CAAqD;AACrD,yCAA6C;AAC7C,6DAAkE;AAClE,+DAAgE;AAChE,mDAAgD;AAChD,+DAAwE;AACxE,qCAAkC;AAqClC;;GAEG;AACH,MAAa,aAAa;IA4BxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,CAAC;QACrD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,eAAM,CAAC,OAAO,CACZ,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,IAAA,+CAA0B,GAAE,CAAC;QAEtE,IAAI,CAAC,QAAQ,GAAG,OAA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AAC;CACF;AAvKD,sCAuKC;AAED,SAAS,qBAAqB,CAAC,OAA6B;IAC1D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,IAAI,gBAAgB;QACpC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;QACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,IAAA,kCAAoB,kCACtB,OAAO,KACV,iBAAiB,IACjB,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param credential - The credentials used for authentication with the service.\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,kEAMmC;AAEnC,+CAAqD;AACrD,yCAA6C;AAC7C,6DAAkE;AAClE,+DAAgE;AAChE,mDAAgD;AAChD,+DAAwE;AACxE,qCAAkC;AAqClC;;GAEG;AACH,MAAa,aAAa;IA4BxB;;;OAGG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,CAAC;QACrD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,eAAM,CAAC,OAAO,CACZ,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,IAAA,+CAA0B,GAAE,CAAC;QAEtE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,MAAA,OAAO,CAAC,kBAAkB,0CAAE,MAAM,EAAE,CAAC;YACvC,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;gBAC9D,2DAA2D;gBAC3D,6CAA6C;gBAC7C,MAAM,UAAU,GAAG,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;gBAChE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE;oBAC9B,UAAU;iBACX,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG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AC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
@@ -845,7 +845,6 @@ export declare class ServiceClient {
845
845
  readonly pipeline: Pipeline;
846
846
  /**
847
847
  * The ServiceClient constructor
848
- * @param credential - The credentials used for authentication with the service.
849
848
  * @param options - The service client options that govern the behavior of the client.
850
849
  */
851
850
  constructor(options?: ServiceClientOptions);
@@ -63,7 +63,6 @@ export declare class ServiceClient {
63
63
  readonly pipeline: Pipeline;
64
64
  /**
65
65
  * The ServiceClient constructor
66
- * @param credential - The credentials used for authentication with the service.
67
66
  * @param options - The service client options that govern the behavior of the client.
68
67
  */
69
68
  constructor(options?: ServiceClientOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAG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 import { logger } from "./log.js";
14
14
  export class ServiceClient {
15
15
  /**
16
16
  * The ServiceClient constructor
17
- * @param credential - The credentials used for authentication with the service.
18
17
  * @param options - The service client options that govern the behavior of the client.
19
18
  */
20
19
  constructor(options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAKL,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqClC;;GAEG;AACH,MAAM,OAAO,aAAa;IA4BxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,CAAC;QACrD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CACZ,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,0BAA0B,EAAE,CAAC;QAEtE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC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AC,CAAC;IACtD,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,IAAI,gBAAgB;QACpC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;QACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,oBAAoB,iCACtB,OAAO,KACV,iBAAiB,IACjB,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param credential - The credentials used for authentication with the service.\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAA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C;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
@@ -63,7 +63,6 @@ export declare class ServiceClient {
63
63
  readonly pipeline: Pipeline;
64
64
  /**
65
65
  * The ServiceClient constructor
66
- * @param credential - The credentials used for authentication with the service.
67
66
  * @param options - The service client options that govern the behavior of the client.
68
67
  */
69
68
  constructor(options?: ServiceClientOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAElB,aAAa,EACd,MAAM,iBAAiB,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- * @param credential - The credentials used for authentication with the service.
18
17
  * @param options - The service client options that govern the behavior of the client.
19
18
  */
20
19
  constructor(options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAKL,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAqClC;;GAEG;AACH,MAAM,OAAO,aAAa;IA4BxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;;QAC5C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,CAAC;QACrD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CACZ,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,0BAA0B,EAAE,CAAC;QAEtE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,MAAA,OAAO,CAAC,kBAAkB,0CAAE,MAAM,EAAE,CAAC;YAC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;QACpC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;QACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,oBAAoB,iCACtB,OAAO,KACV,iBAAiB,IACjB,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA6B;IACxD,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param credential - The credentials used for authentication with the service.\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../src/serviceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAKL,qBAAqB,GACtB,MAAM,2B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EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,CAAC,QAAQ,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,2JAA2J,CAC5J,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommonClientOptions,\n OperationArguments,\n OperationRequest,\n OperationSpec,\n} from \"./interfaces.js\";\nimport {\n HttpClient,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { createClientPipeline } from \"./pipeline.js\";\nimport { flattenResponse } from \"./utils.js\";\nimport { getCachedDefaultHttpClient } from \"./httpClientCache.js\";\nimport { getOperationRequestInfo } from \"./operationHelpers.js\";\nimport { getRequestUrl } from \"./urlHelpers.js\";\nimport { getStreamingResponseStatusCodes } from \"./interfaceHelpers.js\";\nimport { logger } from \"./log.js\";\n\n/**\n * Options to be provided while creating the client.\n */\nexport interface ServiceClientOptions extends CommonClientOptions {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUri?: string;\n /**\n * If specified, this is the endpoint that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n * to encourage customer to use endpoint, we mark the baseUri as deprecated.\n */\n endpoint?: string;\n /**\n * If specified, will be used to build the BearerTokenAuthenticationPolicy.\n */\n credentialScopes?: string | string[];\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n requestContentType?: string;\n /**\n * Credential used to authenticate the request.\n */\n credential?: TokenCredential;\n /**\n * A customized pipeline to use, otherwise a default one will be created.\n */\n pipeline?: Pipeline;\n}\n\n/**\n * Initializes a new instance of the ServiceClient.\n */\nexport class ServiceClient {\n /**\n * If specified, this is the base URI that requests will be made against for this ServiceClient.\n * If it is not specified, then all OperationSpecs must contain a baseUrl property.\n */\n private readonly _endpoint?: string;\n\n /**\n * The default request content type for the service.\n * Used if no requestContentType is present on an OperationSpec.\n */\n private readonly _requestContentType?: string;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n private readonly _allowInsecureConnection?: boolean;\n\n /**\n * The HTTP client that will be used to send requests.\n */\n private readonly _httpClient: HttpClient;\n\n /**\n * The pipeline used by this client to make requests\n */\n public readonly pipeline: Pipeline;\n\n /**\n * The ServiceClient constructor\n * @param options - The service client options that govern the behavior of the client.\n */\n constructor(options: ServiceClientOptions = {}) {\n this._requestContentType = options.requestContentType;\n this._endpoint = options.endpoint ?? options.baseUri;\n if (options.baseUri) {\n logger.warning(\n \"The baseUri option for SDK Clients has been deprecated, please use endpoint instead.\",\n );\n }\n this._allowInsecureConnection = options.allowInsecureConnection;\n this._httpClient = options.httpClient || getCachedDefaultHttpClient();\n\n this.pipeline = options.pipeline || createDefaultPipeline(options);\n if (options.additionalPolicies?.length) {\n for (const { policy, position } of options.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 this.pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n }\n\n /**\n * Send the provided httpRequest.\n */\n async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n return this.pipeline.sendRequest(this._httpClient, request);\n }\n\n /**\n * Send an HTTP request that is populated using the provided OperationSpec.\n * @typeParam T - The typed result of the request, based on the OperationSpec.\n * @param operationArguments - The arguments that the HTTP request's templated values will be populated from.\n * @param operationSpec - The OperationSpec to use to populate the httpRequest.\n */\n async sendOperationRequest<T>(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<T> {\n const endpoint: string | undefined = operationSpec.baseUrl || this._endpoint;\n if (!endpoint) {\n throw new Error(\n \"If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.\",\n );\n }\n\n // Templatized URLs sometimes reference properties on the ServiceClient child class,\n // so we have to pass `this` below in order to search these properties if they're\n // not part of OperationArguments\n const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);\n\n const request: OperationRequest = createPipelineRequest({\n url,\n });\n request.method = operationSpec.httpMethod;\n const operationInfo = getOperationRequestInfo(request);\n operationInfo.operationSpec = operationSpec;\n operationInfo.operationArguments = operationArguments;\n\n const contentType = operationSpec.contentType || this._requestContentType;\n if (contentType && operationSpec.requestBody) {\n request.headers.set(\"Content-Type\", contentType);\n }\n\n const options = operationArguments.options;\n if (options) {\n const requestOptions = options.requestOptions;\n\n if (requestOptions) {\n if (requestOptions.timeout) {\n request.timeout = requestOptions.timeout;\n }\n\n if (requestOptions.onUploadProgress) {\n request.onUploadProgress = requestOptions.onUploadProgress;\n }\n\n if (requestOptions.onDownloadProgress) {\n request.onDownloadProgress = requestOptions.onDownloadProgress;\n }\n\n if (requestOptions.shouldDeserialize !== undefined) {\n operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;\n }\n\n if (requestOptions.allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n }\n\n if (options.abortSignal) {\n request.abortSignal = options.abortSignal;\n }\n\n if (options.tracingOptions) {\n request.tracingOptions = options.tracingOptions;\n }\n }\n\n if (this._allowInsecureConnection) {\n request.allowInsecureConnection = true;\n }\n\n if (request.streamResponseStatusCodes === undefined) {\n request.streamResponseStatusCodes = getStreamingResponseStatusCodes(operationSpec);\n }\n\n try {\n const rawResponse = await this.sendRequest(request);\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[rawResponse.status],\n ) as T;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n return flatResponse;\n } catch (error: any) {\n if (typeof error === \"object\" && error?.response) {\n const rawResponse = error.response;\n const flatResponse = flattenResponse(\n rawResponse,\n operationSpec.responses[error.statusCode] || operationSpec.responses[\"default\"],\n );\n error.details = flatResponse;\n if (options?.onResponse) {\n options.onResponse(rawResponse, flatResponse, error);\n }\n }\n throw error;\n }\n }\n}\n\nfunction createDefaultPipeline(options: ServiceClientOptions): Pipeline {\n const credentialScopes = getCredentialScopes(options);\n const credentialOptions =\n options.credential && credentialScopes\n ? { credentialScopes, credential: options.credential }\n : undefined;\n\n return createClientPipeline({\n ...options,\n credentialOptions,\n });\n}\n\nfunction getCredentialScopes(options: ServiceClientOptions): string | string[] | undefined {\n if (options.credentialScopes) {\n return options.credentialScopes;\n }\n\n if (options.endpoint) {\n return `${options.endpoint}/.default`;\n }\n\n if (options.baseUri) {\n return `${options.baseUri}/.default`;\n }\n\n if (options.credential && !options.credentialScopes) {\n throw new Error(\n `When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`,\n );\n }\n\n return undefined;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/core-client",
3
- "version": "1.9.3-alpha.20240704.2",
3
+ "version": "1.9.3-alpha.20240705.2",
4
4
  "description": "Core library for interfacing with AutoRest generated code",
5
5
  "sdk-type": "client",
6
6
  "type": "module",