@azure-rest/core-client 2.5.2-alpha.20260310.2 → 2.6.0

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.
Files changed (44) hide show
  1. package/dist/browser/common.d.ts +6 -0
  2. package/dist/browser/common.js.map +1 -1
  3. package/dist/browser/getClient.js +1 -1
  4. package/dist/browser/getClient.js.map +1 -1
  5. package/dist/commonjs/apiVersionPolicy.js +1 -0
  6. package/dist/commonjs/apiVersionPolicy.js.map +1 -1
  7. package/dist/commonjs/clientHelpers.js +1 -0
  8. package/dist/commonjs/clientHelpers.js.map +1 -1
  9. package/dist/commonjs/common.d.ts +6 -0
  10. package/dist/commonjs/common.js +1 -0
  11. package/dist/commonjs/common.js.map +2 -2
  12. package/dist/commonjs/getClient.js +2 -1
  13. package/dist/commonjs/getClient.js.map +3 -3
  14. package/dist/commonjs/index.js +1 -0
  15. package/dist/commonjs/index.js.map +1 -1
  16. package/dist/commonjs/keyCredentialAuthenticationPolicy.js +1 -0
  17. package/dist/commonjs/keyCredentialAuthenticationPolicy.js.map +1 -1
  18. package/dist/commonjs/operationOptionHelpers.js +1 -0
  19. package/dist/commonjs/operationOptionHelpers.js.map +1 -1
  20. package/dist/commonjs/restError.js +1 -0
  21. package/dist/commonjs/restError.js.map +1 -1
  22. package/dist/commonjs/tsdoc-metadata.json +1 -1
  23. package/dist/esm/apiVersionPolicy.js +22 -16
  24. package/dist/esm/apiVersionPolicy.js.map +1 -7
  25. package/dist/esm/clientHelpers.js +39 -41
  26. package/dist/esm/clientHelpers.js.map +1 -7
  27. package/dist/esm/common.d.ts +6 -0
  28. package/dist/esm/common.js +4 -0
  29. package/dist/esm/common.js.map +1 -7
  30. package/dist/esm/getClient.js +62 -60
  31. package/dist/esm/getClient.js.map +1 -7
  32. package/dist/esm/index.js +10 -10
  33. package/dist/esm/index.js.map +1 -7
  34. package/dist/esm/keyCredentialAuthenticationPolicy.js +15 -13
  35. package/dist/esm/keyCredentialAuthenticationPolicy.js.map +1 -7
  36. package/dist/esm/operationOptionHelpers.js +11 -10
  37. package/dist/esm/operationOptionHelpers.js.map +1 -7
  38. package/dist/esm/restError.js +11 -12
  39. package/dist/esm/restError.js.map +1 -7
  40. package/dist/react-native/common.d.ts +6 -0
  41. package/dist/react-native/common.js.map +1 -1
  42. package/dist/react-native/getClient.js +1 -1
  43. package/dist/react-native/getClient.js.map +1 -1
  44. package/package.json +11 -11
@@ -325,6 +325,12 @@ export type ClientOptions = PipelineOptions & {
325
325
  * Options to configure request/response logging.
326
326
  */
327
327
  loggingOptions?: LogPolicyOptions;
328
+ /**
329
+ * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.
330
+ * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline
331
+ * will be ignored.
332
+ */
333
+ pipeline?: Pipeline;
328
334
  };
329
335
  /**
330
336
  * Represents the shape of an HttpResponse
@@ -1 +1 @@
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 type {\n HttpClient,\n LogPolicyOptions,\n Pipeline,\n PipelineOptions,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n} from \"@azure/core-rest-pipeline\";\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationTracingOptions } from \"@azure/core-tracing\";\n\n/**\n * Shape of the default request parameters, this may be overridden 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 * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n *\n * This callback will be called with two parameters: the raw response, including headers and response body; and an error\n * object which will be provided if an error was thrown while processing the request.\n * The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.\n */\nexport type RawResponseCallback = (\n rawResponse: FullOperationResponse,\n error?: unknown,\n __legacyError?: unknown,\n) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\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 overridden with the generated\n * types. For example:\n * ```typescript snippet:PathExample\n * import { Client } from \"@azure-rest/core-client\";\n *\n * type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * A Node.js Readable stream that also has a `destroy` method.\n */\nexport interface NodeJSReadableStream extends NodeJS.ReadableStream {\n /**\n * Destroy the stream. Optionally emit an 'error' event, and emit a\n * 'close' event (unless emitClose is set to false). After this call,\n * internal resources will be released.\n */\n destroy(error?: Error): void;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJSReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n /**\n * Returns the response body as a NodeJS stream. Only available in Node-like environments.\n */\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n /**\n * Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the\n * `Readable.toWeb` Node API on the result of `asNodeStream`.\n */\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\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<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\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 * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: 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 * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\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 [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\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\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\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 type {\n HttpClient,\n LogPolicyOptions,\n Pipeline,\n PipelineOptions,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n} from \"@azure/core-rest-pipeline\";\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationTracingOptions } from \"@azure/core-tracing\";\n\n/**\n * Shape of the default request parameters, this may be overridden 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 * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n *\n * This callback will be called with two parameters: the raw response, including headers and response body; and an error\n * object which will be provided if an error was thrown while processing the request.\n * The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.\n */\nexport type RawResponseCallback = (\n rawResponse: FullOperationResponse,\n error?: unknown,\n __legacyError?: unknown,\n) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\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 overridden with the generated\n * types. For example:\n * ```typescript snippet:PathExample\n * import { Client } from \"@azure-rest/core-client\";\n *\n * type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * A Node.js Readable stream that also has a `destroy` method.\n */\nexport interface NodeJSReadableStream extends NodeJS.ReadableStream {\n /**\n * Destroy the stream. Optionally emit an 'error' event, and emit a\n * 'close' event (unless emitClose is set to false). After this call,\n * internal resources will be released.\n */\n destroy(error?: Error): void;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJSReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n /**\n * Returns the response body as a NodeJS stream. Only available in Node-like environments.\n */\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n /**\n * Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the\n * `Readable.toWeb` Node API on the result of `asNodeStream`.\n */\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\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<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\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 * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: 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 * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n\n /**\n * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.\n * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline\n * will be ignored.\n */\n pipeline?: Pipeline;\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 [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\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\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"]}
@@ -27,7 +27,7 @@ export function getClient(endpoint, credentialsOrPipelineOptions, clientOptions
27
27
  clientOptions = credentialsOrPipelineOptions ?? {};
28
28
  }
29
29
  }
30
- const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);
30
+ const pipeline = clientOptions.pipeline ?? createDefaultPipeline(endpoint, credentials, clientOptions);
31
31
  const tspClient = tspGetClient(endpoint, {
32
32
  ...clientOptions,
33
33
  pipeline,
@@ -1 +1 @@
1
- {"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../src/getClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isKeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { type PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport type { Client, ClientOptions, RequestParameters, StreamableMethod } from \"./common.js\";\nimport {\n getClient as tspGetClient,\n type ClientOptions as TspClientOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest\n */\nfunction wrapRequestParameters(parameters: RequestParameters): RequestParameters {\n if (parameters.onResponse) {\n return {\n ...parameters,\n onResponse(rawResponse, error) {\n parameters.onResponse?.(rawResponse, error, error);\n },\n };\n }\n\n return parameters;\n}\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: 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(endpoint, credentials, clientOptions);\n const tspClient = tspGetClient(endpoint, {\n ...clientOptions,\n pipeline,\n } as TspClientOptions) as Client;\n\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline: tspClient.pipeline,\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"]}
1
+ {"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../src/getClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isKeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport type { PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport type { Client, ClientOptions, RequestParameters, StreamableMethod } from \"./common.js\";\nimport {\n getClient as tspGetClient,\n type ClientOptions as TspClientOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest\n */\nfunction wrapRequestParameters(parameters: RequestParameters): RequestParameters {\n if (parameters.onResponse) {\n return {\n ...parameters,\n onResponse(rawResponse, error) {\n parameters.onResponse?.(rawResponse, error, error);\n },\n };\n }\n\n return parameters;\n}\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: 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 const pipeline =\n clientOptions.pipeline ?? createDefaultPipeline(endpoint, credentials, clientOptions);\n\n const tspClient = tspGetClient(endpoint, {\n ...clientOptions,\n pipeline,\n } as TspClientOptions) as Client;\n\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline: tspClient.pipeline,\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"]}
@@ -39,3 +39,4 @@ function apiVersionPolicy(options) {
39
39
  apiVersionPolicy,
40
40
  apiVersionPolicyName
41
41
  });
42
+ //# sourceMappingURL=apiVersionPolicy.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/apiVersionPolicy.ts"],
3
+ "sources": ["../../src/apiVersionPolicy.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\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 // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,uBAAuB;AAO7B,SAAS,iBAAiB,SAAwC;AACvE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa,CAAC,KAAK,SAAS;AAG1B,YAAM,MAAM,IAAI,IAAI,IAAI,GAAG;AAC3B,UAAI,CAAC,IAAI,aAAa,IAAI,aAAa,KAAK,QAAQ,YAAY;AAC9D,YAAI,MAAM,GAAG,IAAI,GAAG,GAClB,MAAM,KAAK,IAAI,aAAa,KAAK,CAAC,EAAE,SAAS,IAAI,MAAM,GACzD,eAAe,QAAQ,UAAU;AAAA,MACnC;AAEA,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AACF;",
6
6
  "names": []
@@ -70,3 +70,4 @@ function getCachedDefaultHttpsClient() {
70
70
  createDefaultPipeline,
71
71
  getCachedDefaultHttpsClient
72
72
  });
73
+ //# sourceMappingURL=clientHelpers.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/clientHelpers.ts"],
3
+ "sources": ["../../src/clientHelpers.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\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"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,gCAIO;AAEP,uBAAkC;AAGlC,8BAAiC;AACjC,+CAAkD;AAElD,IAAI;AAmBG,SAAS,4BACd,UACA,UACA,UAA8C,CAAC,GACzC;AACN,QAAM,EAAE,YAAY,cAAc,IAAI;AACtC,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,UAAI,oCAAkB,UAAU,GAAG;AACjC,UAAM,kBAAc,2DAAgC;AAAA,MAClD;AAAA,MACA,QAAQ,eAAe,aAAa,UAAU,GAAG,QAAQ;AAAA,IAC3D,CAAC;AACD,aAAS,UAAU,WAAW;AAAA,EAChC,WAAW,gBAAgB,UAAU,GAAG;AACtC,QAAI,CAAC,eAAe,aAAa,kBAAkB;AACjD,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC/C;AACA,UAAM,gBAAY;AAAA,MAChB;AAAA,MACA,eAAe,aAAa;AAAA,IAC9B;AACA,aAAS,UAAU,SAAS;AAAA,EAC9B;AACF;AAKO,SAAS,sBACd,UACA,YACA,UAAyB,CAAC,GAChB;AACV,QAAM,eAAW,qDAA0B,OAAO;AAElD,WAAS,cAAU,0CAAiB,OAAO,CAAC;AAE5C,8BAA4B,UAAU,UAAU,EAAE,YAAY,eAAe,QAAQ,CAAC;AACtF,SAAO;AACT;AAEA,SAAS,gBAAgB,YAA8C;AACrE,SAAQ,WAA6B,QAAQ;AAC/C;AAEO,SAAS,8BAA0C;AACxD,MAAI,CAAC,kBAAkB;AACrB,2BAAmB,mDAAwB;AAAA,EAC7C;AAEA,SAAO;AACT;",
6
6
  "names": []
@@ -325,6 +325,12 @@ export type ClientOptions = PipelineOptions & {
325
325
  * Options to configure request/response logging.
326
326
  */
327
327
  loggingOptions?: LogPolicyOptions;
328
+ /**
329
+ * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.
330
+ * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline
331
+ * will be ignored.
332
+ */
333
+ pipeline?: Pipeline;
328
334
  };
329
335
  /**
330
336
  * Represents the shape of an HttpResponse
@@ -13,3 +13,4 @@ var __copyProps = (to, from, except, desc) => {
13
13
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
14
  var common_exports = {};
15
15
  module.exports = __toCommonJS(common_exports);
16
+ //# sourceMappingURL=common.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/common.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpClient,\n LogPolicyOptions,\n Pipeline,\n PipelineOptions,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n} from \"@azure/core-rest-pipeline\";\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationTracingOptions } from \"@azure/core-tracing\";\n\n/**\n * Shape of the default request parameters, this may be overridden 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 * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n *\n * This callback will be called with two parameters: the raw response, including headers and response body; and an error\n * object which will be provided if an error was thrown while processing the request.\n * The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.\n */\nexport type RawResponseCallback = (\n rawResponse: FullOperationResponse,\n error?: unknown,\n __legacyError?: unknown,\n) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\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 overridden with the generated\n * types. For example:\n * ```typescript snippet:PathExample\n * import { Client } from \"@azure-rest/core-client\";\n *\n * type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * A Node.js Readable stream that also has a `destroy` method.\n */\nexport interface NodeJSReadableStream extends NodeJS.ReadableStream {\n /**\n * Destroy the stream. Optionally emit an 'error' event, and emit a\n * 'close' event (unless emitClose is set to false). After this call,\n * internal resources will be released.\n */\n destroy(error?: Error): void;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJSReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n /**\n * Returns the response body as a NodeJS stream. Only available in Node-like environments.\n */\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n /**\n * Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the\n * `Readable.toWeb` Node API on the result of `asNodeStream`.\n */\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\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<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\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 * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: 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 * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\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 [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\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\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"],
3
+ "sources": ["../../src/common.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpClient,\n LogPolicyOptions,\n Pipeline,\n PipelineOptions,\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n} from \"@azure/core-rest-pipeline\";\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { OperationTracingOptions } from \"@azure/core-tracing\";\n\n/**\n * Shape of the default request parameters, this may be overridden 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 * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n *\n * This callback will be called with two parameters: the raw response, including headers and response body; and an error\n * object which will be provided if an error was thrown while processing the request.\n * The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.\n */\nexport type RawResponseCallback = (\n rawResponse: FullOperationResponse,\n error?: unknown,\n __legacyError?: unknown,\n) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\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 overridden with the generated\n * types. For example:\n * ```typescript snippet:PathExample\n * import { Client } from \"@azure-rest/core-client\";\n *\n * type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * A Node.js Readable stream that also has a `destroy` method.\n */\nexport interface NodeJSReadableStream extends NodeJS.ReadableStream {\n /**\n * Destroy the stream. Optionally emit an 'error' event, and emit a\n * 'close' event (unless emitClose is set to false). After this call,\n * internal resources will be released.\n */\n destroy(error?: Error): void;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJSReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n /**\n * Returns the response body as a NodeJS stream. Only available in Node-like environments.\n */\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n /**\n * Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the\n * `Readable.toWeb` Node API on the result of `asNodeStream`.\n */\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\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<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\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 * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: 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 * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n\n /**\n * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.\n * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline\n * will be ignored.\n */\n pipeline?: Pipeline;\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 [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\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\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -43,7 +43,7 @@ function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
43
43
  clientOptions = credentialsOrPipelineOptions ?? {};
44
44
  }
45
45
  }
46
- const pipeline = (0, import_clientHelpers.createDefaultPipeline)(endpoint, credentials, clientOptions);
46
+ const pipeline = clientOptions.pipeline ?? (0, import_clientHelpers.createDefaultPipeline)(endpoint, credentials, clientOptions);
47
47
  const tspClient = (0, import_ts_http_runtime.getClient)(endpoint, {
48
48
  ...clientOptions,
49
49
  pipeline
@@ -89,3 +89,4 @@ function isCredential(param) {
89
89
  0 && (module.exports = {
90
90
  getClient
91
91
  });
92
+ //# sourceMappingURL=getClient.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/getClient.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isKeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { type PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport type { Client, ClientOptions, RequestParameters, StreamableMethod } from \"./common.js\";\nimport {\n getClient as tspGetClient,\n type ClientOptions as TspClientOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest\n */\nfunction wrapRequestParameters(parameters: RequestParameters): RequestParameters {\n if (parameters.onResponse) {\n return {\n ...parameters,\n onResponse(rawResponse, error) {\n parameters.onResponse?.(rawResponse, error, error);\n },\n };\n }\n\n return parameters;\n}\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: 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(endpoint, credentials, clientOptions);\n const tspClient = tspGetClient(endpoint, {\n ...clientOptions,\n pipeline,\n } as TspClientOptions) as Client;\n\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline: tspClient.pipeline,\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAmD;AAEnD,2BAAsC;AAEtC,6BAGO;AAKP,SAAS,sBAAsB,YAAkD;AAC/E,MAAI,WAAW,YAAY;AACzB,WAAO;AAAA,MACL,GAAG;AAAA,MACH,WAAW,aAAa,OAAO;AAC7B,mBAAW,aAAa,aAAa,OAAO,KAAK;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAmBO,SAAS,UACd,UACA,8BACA,gBAA+B,CAAC,GACxB;AACR,MAAI;AACJ,MAAI,8BAA8B;AAChC,QAAI,aAAa,4BAA4B,GAAG;AAC9C,oBAAc;AAAA,IAChB,OAAO;AACL,sBAAgB,gCAAgC,CAAC;AAAA,IACnD;AAAA,EACF;AAEA,QAAM,eAAW,4CAAsB,UAAU,aAAa,aAAa;AAC3E,QAAM,gBAAY,uBAAAA,WAAa,UAAU;AAAA,IACvC,GAAG;AAAA,IACH;AAAA,EACF,CAAqB;AAErB,QAAM,SAAS,CAAC,SAAiB,SAAqB;AACpD,WAAO;AAAA,MACL,KAAK,CAAC,iBAAoC,CAAC,MAAwB;AACjE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,IAAI,sBAAsB,cAAc,CAAC;AAAA,MAChF;AAAA,MACA,MAAM,CAAC,iBAAoC,CAAC,MAAwB;AAClE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,KAAK,sBAAsB,cAAc,CAAC;AAAA,MACjF;AAAA,MACA,KAAK,CAAC,iBAAoC,CAAC,MAAwB;AACjE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,IAAI,sBAAsB,cAAc,CAAC;AAAA,MAChF;AAAA,MACA,OAAO,CAAC,iBAAoC,CAAC,MAAwB;AACnE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,MAAM,sBAAsB,cAAc,CAAC;AAAA,MAClF;AAAA,MACA,QAAQ,CAAC,iBAAoC,CAAC,MAAwB;AACpE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,OAAO,sBAAsB,cAAc,CAAC;AAAA,MACnF;AAAA,MACA,MAAM,CAAC,iBAAoC,CAAC,MAAwB;AAClE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,KAAK,sBAAsB,cAAc,CAAC;AAAA,MACjF;AAAA,MACA,SAAS,CAAC,iBAAoC,CAAC,MAAwB;AACrE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,QAAQ,sBAAsB,cAAc,CAAC;AAAA,MACpF;AAAA,MACA,OAAO,CAAC,iBAAoC,CAAC,MAAwB;AACnE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,MAAM,sBAAsB,cAAc,CAAC;AAAA,MAClF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,eAAe;AAAA,IACf,UAAU,UAAU;AAAA,EACtB;AACF;AAEA,SAAS,aACP,OAC0C;AAC1C,aAAO,kCAAgB,KAAK,SAAK,oCAAkB,KAAK;AAC1D;",
3
+ "sources": ["../../src/getClient.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isKeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport type { PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport type { Client, ClientOptions, RequestParameters, StreamableMethod } from \"./common.js\";\nimport {\n getClient as tspGetClient,\n type ClientOptions as TspClientOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest\n */\nfunction wrapRequestParameters(parameters: RequestParameters): RequestParameters {\n if (parameters.onResponse) {\n return {\n ...parameters,\n onResponse(rawResponse, error) {\n parameters.onResponse?.(rawResponse, error, error);\n },\n };\n }\n\n return parameters;\n}\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: 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 const pipeline =\n clientOptions.pipeline ?? createDefaultPipeline(endpoint, credentials, clientOptions);\n\n const tspClient = tspGetClient(endpoint, {\n ...clientOptions,\n pipeline,\n } as TspClientOptions) as Client;\n\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline: tspClient.pipeline,\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAmD;AAEnD,2BAAsC;AAEtC,6BAGO;AAKP,SAAS,sBAAsB,YAAkD;AAC/E,MAAI,WAAW,YAAY;AACzB,WAAO;AAAA,MACL,GAAG;AAAA,MACH,WAAW,aAAa,OAAO;AAC7B,mBAAW,aAAa,aAAa,OAAO,KAAK;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAmBO,SAAS,UACd,UACA,8BACA,gBAA+B,CAAC,GACxB;AACR,MAAI;AACJ,MAAI,8BAA8B;AAChC,QAAI,aAAa,4BAA4B,GAAG;AAC9C,oBAAc;AAAA,IAChB,OAAO;AACL,sBAAgB,gCAAgC,CAAC;AAAA,IACnD;AAAA,EACF;AACA,QAAM,WACJ,cAAc,gBAAY,4CAAsB,UAAU,aAAa,aAAa;AAEtF,QAAM,gBAAY,uBAAAA,WAAa,UAAU;AAAA,IACvC,GAAG;AAAA,IACH;AAAA,EACF,CAAqB;AAErB,QAAM,SAAS,CAAC,SAAiB,SAAqB;AACpD,WAAO;AAAA,MACL,KAAK,CAAC,iBAAoC,CAAC,MAAwB;AACjE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,IAAI,sBAAsB,cAAc,CAAC;AAAA,MAChF;AAAA,MACA,MAAM,CAAC,iBAAoC,CAAC,MAAwB;AAClE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,KAAK,sBAAsB,cAAc,CAAC;AAAA,MACjF;AAAA,MACA,KAAK,CAAC,iBAAoC,CAAC,MAAwB;AACjE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,IAAI,sBAAsB,cAAc,CAAC;AAAA,MAChF;AAAA,MACA,OAAO,CAAC,iBAAoC,CAAC,MAAwB;AACnE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,MAAM,sBAAsB,cAAc,CAAC;AAAA,MAClF;AAAA,MACA,QAAQ,CAAC,iBAAoC,CAAC,MAAwB;AACpE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,OAAO,sBAAsB,cAAc,CAAC;AAAA,MACnF;AAAA,MACA,MAAM,CAAC,iBAAoC,CAAC,MAAwB;AAClE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,KAAK,sBAAsB,cAAc,CAAC;AAAA,MACjF;AAAA,MACA,SAAS,CAAC,iBAAoC,CAAC,MAAwB;AACrE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,QAAQ,sBAAsB,cAAc,CAAC;AAAA,MACpF;AAAA,MACA,OAAO,CAAC,iBAAoC,CAAC,MAAwB;AACnE,eAAO,UAAU,KAAK,MAAM,GAAG,IAAI,EAAE,MAAM,sBAAsB,cAAc,CAAC;AAAA,MAClF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,eAAe;AAAA,IACf,UAAU,UAAU;AAAA,EACtB;AACF;AAEA,SAAS,aACP,OAC0C;AAC1C,aAAO,kCAAgB,KAAK,SAAK,oCAAkB,KAAK;AAC1D;",
6
6
  "names": ["tspGetClient"]
7
7
  }
@@ -34,3 +34,4 @@ __reExport(src_exports, require("./getClient.js"), module.exports);
34
34
  operationOptionsToRequestParameters,
35
35
  ...require("./getClient.js")
36
36
  });
37
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/index.ts"],
3
+ "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Azure Rest Core Client library for JavaScript\n * @packageDocumentation\n */\n\nexport { createRestError } from \"./restError.js\";\nexport {\n addCredentialPipelinePolicy,\n type AddCredentialPipelinePolicyOptions,\n} from \"./clientHelpers.js\";\nexport { operationOptionsToRequestParameters } from \"./operationOptionHelpers.js\";\nexport * from \"./getClient.js\";\nexport type * from \"./common.js\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,uBAAgC;AAChC,2BAGO;AACP,oCAAoD;AACpD,wBAAc,2BAdd;",
6
6
  "names": []
@@ -36,3 +36,4 @@ function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
36
36
  keyCredentialAuthenticationPolicy,
37
37
  keyCredentialAuthenticationPolicyName
38
38
  });
39
+ //# sourceMappingURL=keyCredentialAuthenticationPolicy.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/keyCredentialAuthenticationPolicy.ts"],
3
+ "sources": ["../../src/keyCredentialAuthenticationPolicy.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\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"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,MAAM,wCAAwC;AAE9C,SAAS,kCACd,YACA,kBACgB;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,SAA0B,MAA8C;AACxF,cAAQ,QAAQ,IAAI,kBAAkB,WAAW,GAAG;AACpD,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EACF;AACF;",
6
6
  "names": []
@@ -30,3 +30,4 @@ function operationOptionsToRequestParameters(options) {
30
30
  0 && (module.exports = {
31
31
  operationOptionsToRequestParameters
32
32
  });
33
+ //# sourceMappingURL=operationOptionHelpers.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/operationOptionHelpers.ts"],
3
+ "sources": ["../../src/operationOptionHelpers.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions, RequestParameters } from \"./common.js\";\n\nimport {\n operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters,\n type OperationOptions as TspOperationOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Helper function to convert OperationOptions to RequestParameters\n * @param options - the options that are used by Modular layer to send the request\n * @returns the result of the conversion in RequestParameters of RLC layer\n */\nexport function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters {\n return tspOperationOptionsToRequestParameters(\n options as TspOperationOptions,\n ) as RequestParameters;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,6BAGO;AAOA,SAAS,oCAAoC,SAA8C;AAChG,aAAO,uBAAAA;AAAA,IACL;AAAA,EACF;AACF;",
6
6
  "names": ["tspOperationOptionsToRequestParameters"]
@@ -32,3 +32,4 @@ function createRestError(messageOrResponse, response) {
32
32
  0 && (module.exports = {
33
33
  createRestError
34
34
  });
35
+ //# sourceMappingURL=restError.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/restError.ts"],
3
+ "sources": ["../../src/restError.ts"],
4
4
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport type { PathUncheckedResponse } from \"./common.js\";\n\nimport {\n createRestError as tspCreateRestError,\n type PathUncheckedResponse as TspPathUncheckedResponse,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(response: PathUncheckedResponse): RestError;\n/**\n * Creates a rest error from an error message and a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError;\nexport function createRestError(\n messageOrResponse: string | PathUncheckedResponse,\n response?: PathUncheckedResponse,\n): RestError {\n if (typeof messageOrResponse === \"string\") {\n return tspCreateRestError(messageOrResponse, response! as TspPathUncheckedResponse);\n } else {\n return tspCreateRestError(messageOrResponse as TspPathUncheckedResponse);\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,6BAGO;AAUA,SAAS,gBACd,mBACA,UACW;AACX,MAAI,OAAO,sBAAsB,UAAU;AACzC,eAAO,uBAAAA,iBAAmB,mBAAmB,QAAqC;AAAA,EACpF,OAAO;AACL,eAAO,uBAAAA,iBAAmB,iBAA6C;AAAA,EACzE;AACF;",
6
6
  "names": ["tspCreateRestError"]
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.57.6"
8
+ "packageVersion": "7.58.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,17 +1,23 @@
1
- const apiVersionPolicyName = "ApiVersionPolicy";
2
- function apiVersionPolicy(options) {
3
- return {
4
- name: apiVersionPolicyName,
5
- sendRequest: (req, next) => {
6
- const url = new URL(req.url);
7
- if (!url.searchParams.get("api-version") && options.apiVersion) {
8
- req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
9
- }
10
- return next(req);
11
- }
12
- };
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export const apiVersionPolicyName = "ApiVersionPolicy";
4
+ /**
5
+ * Creates a policy that sets the apiVersion as a query parameter on every request
6
+ * @param options - Client options
7
+ * @returns Pipeline policy that sets the apiVersion as a query parameter on every request
8
+ */
9
+ export function apiVersionPolicy(options) {
10
+ return {
11
+ name: apiVersionPolicyName,
12
+ sendRequest: (req, next) => {
13
+ // Use the apiVesion defined in request url directly
14
+ // Append one if there is no apiVesion and we have one at client options
15
+ const url = new URL(req.url);
16
+ if (!url.searchParams.get("api-version") && options.apiVersion) {
17
+ req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
18
+ }
19
+ return next(req);
20
+ },
21
+ };
13
22
  }
14
- export {
15
- apiVersionPolicy,
16
- apiVersionPolicyName
17
- };
23
+ //# sourceMappingURL=apiVersionPolicy.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/apiVersionPolicy.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\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 // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"],
5
- "mappings": "AAMO,MAAM,uBAAuB;AAO7B,SAAS,iBAAiB,SAAwC;AACvE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa,CAAC,KAAK,SAAS;AAG1B,YAAM,MAAM,IAAI,IAAI,IAAI,GAAG;AAC3B,UAAI,CAAC,IAAI,aAAa,IAAI,aAAa,KAAK,QAAQ,YAAY;AAC9D,YAAI,MAAM,GAAG,IAAI,GAAG,GAClB,MAAM,KAAK,IAAI,aAAa,KAAK,CAAC,EAAE,SAAS,IAAI,MAAM,GACzD,eAAe,QAAQ,UAAU;AAAA,MACnC;AAEA,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AACF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,oDAAoD;YACpD,wEAAwE;YACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC/D,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\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 // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"]}
@@ -1,51 +1,49 @@
1
- import {
2
- bearerTokenAuthenticationPolicy,
3
- createDefaultHttpClient,
4
- createPipelineFromOptions
5
- } from "@azure/core-rest-pipeline";
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { bearerTokenAuthenticationPolicy, createDefaultHttpClient, createPipelineFromOptions, } from "@azure/core-rest-pipeline";
6
4
  import { isTokenCredential } from "@azure/core-auth";
7
5
  import { apiVersionPolicy } from "./apiVersionPolicy.js";
8
6
  import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy.js";
9
7
  let cachedHttpClient;
10
- function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
11
- const { credential, clientOptions } = options;
12
- if (!credential) {
13
- return;
14
- }
15
- if (isTokenCredential(credential)) {
16
- const tokenPolicy = bearerTokenAuthenticationPolicy({
17
- credential,
18
- scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`
19
- });
20
- pipeline.addPolicy(tokenPolicy);
21
- } else if (isKeyCredential(credential)) {
22
- if (!clientOptions?.credentials?.apiKeyHeaderName) {
23
- throw new Error(`Missing API Key Header Name`);
8
+ /**
9
+ * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
10
+ */
11
+ export function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
12
+ const { credential, clientOptions } = options;
13
+ if (!credential) {
14
+ return;
15
+ }
16
+ if (isTokenCredential(credential)) {
17
+ const tokenPolicy = bearerTokenAuthenticationPolicy({
18
+ credential,
19
+ scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,
20
+ });
21
+ pipeline.addPolicy(tokenPolicy);
22
+ }
23
+ else if (isKeyCredential(credential)) {
24
+ if (!clientOptions?.credentials?.apiKeyHeaderName) {
25
+ throw new Error(`Missing API Key Header Name`);
26
+ }
27
+ const keyPolicy = keyCredentialAuthenticationPolicy(credential, clientOptions?.credentials?.apiKeyHeaderName);
28
+ pipeline.addPolicy(keyPolicy);
24
29
  }
25
- const keyPolicy = keyCredentialAuthenticationPolicy(
26
- credential,
27
- clientOptions?.credentials?.apiKeyHeaderName
28
- );
29
- pipeline.addPolicy(keyPolicy);
30
- }
31
30
  }
32
- function createDefaultPipeline(endpoint, credential, options = {}) {
33
- const pipeline = createPipelineFromOptions(options);
34
- pipeline.addPolicy(apiVersionPolicy(options));
35
- addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
36
- return pipeline;
31
+ /**
32
+ * Creates a default rest pipeline to re-use accross Rest Level Clients
33
+ */
34
+ export function createDefaultPipeline(endpoint, credential, options = {}) {
35
+ const pipeline = createPipelineFromOptions(options);
36
+ pipeline.addPolicy(apiVersionPolicy(options));
37
+ addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
38
+ return pipeline;
37
39
  }
38
40
  function isKeyCredential(credential) {
39
- return credential.key !== void 0;
41
+ return credential.key !== undefined;
40
42
  }
41
- function getCachedDefaultHttpsClient() {
42
- if (!cachedHttpClient) {
43
- cachedHttpClient = createDefaultHttpClient();
44
- }
45
- return cachedHttpClient;
43
+ export function getCachedDefaultHttpsClient() {
44
+ if (!cachedHttpClient) {
45
+ cachedHttpClient = createDefaultHttpClient();
46
+ }
47
+ return cachedHttpClient;
46
48
  }
47
- export {
48
- addCredentialPipelinePolicy,
49
- createDefaultPipeline,
50
- getCachedDefaultHttpsClient
51
- };
49
+ //# sourceMappingURL=clientHelpers.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["/mnt/vss/_work/1/s/sdk/core/core-client-rest/src/clientHelpers.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\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"],
5
- "mappings": "AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAGlC,SAAS,wBAAwB;AACjC,SAAS,yCAAyC;AAElD,IAAI;AAmBG,SAAS,4BACd,UACA,UACA,UAA8C,CAAC,GACzC;AACN,QAAM,EAAE,YAAY,cAAc,IAAI;AACtC,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,MAAI,kBAAkB,UAAU,GAAG;AACjC,UAAM,cAAc,gCAAgC;AAAA,MAClD;AAAA,MACA,QAAQ,eAAe,aAAa,UAAU,GAAG,QAAQ;AAAA,IAC3D,CAAC;AACD,aAAS,UAAU,WAAW;AAAA,EAChC,WAAW,gBAAgB,UAAU,GAAG;AACtC,QAAI,CAAC,eAAe,aAAa,kBAAkB;AACjD,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC/C;AACA,UAAM,YAAY;AAAA,MAChB;AAAA,MACA,eAAe,aAAa;AAAA,IAC9B;AACA,aAAS,UAAU,SAAS;AAAA,EAC9B;AACF;AAKO,SAAS,sBACd,UACA,YACA,UAAyB,CAAC,GAChB;AACV,QAAM,WAAW,0BAA0B,OAAO;AAElD,WAAS,UAAU,iBAAiB,OAAO,CAAC;AAE5C,8BAA4B,UAAU,UAAU,EAAE,YAAY,eAAe,QAAQ,CAAC;AACtF,SAAO;AACT;AAEA,SAAS,gBAAgB,YAA8C;AACrE,SAAQ,WAA6B,QAAQ;AAC/C;AAEO,SAAS,8BAA0C;AACxD,MAAI,CAAC,kBAAkB;AACrB,uBAAmB,wBAAwB;AAAA,EAC7C;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F,IAAI,gBAAwC,CAAC;AAgB7C;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAkB,EAClB,QAAgB,EAChB,UAA8C,EAAE;IAEhD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,+BAA+B,CAAC;YAClD,UAAU;YACV,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,QAAQ,WAAW;SACrE,CAAC,CAAC;QACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,SAAS,GAAG,iCAAiC,CACjD,UAAU,EACV,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAC7C,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,UAA4C,EAC5C,UAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,CAAC,GAAG,KAAK,SAAS,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\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"]}
@@ -325,6 +325,12 @@ export type ClientOptions = PipelineOptions & {
325
325
  * Options to configure request/response logging.
326
326
  */
327
327
  loggingOptions?: LogPolicyOptions;
328
+ /**
329
+ * Pipeline to use for the client. If not provided, a default pipeline will be created using the options provided.
330
+ * Use with caution -- when setting this option, all client options that are used in the creation of the default pipeline
331
+ * will be ignored.
332
+ */
333
+ pipeline?: Pipeline;
328
334
  };
329
335
  /**
330
336
  * Represents the shape of an HttpResponse