@azure-rest/core-client 1.0.0-alpha.20211105.1 → 1.0.0-alpha.20220104.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ### Features Added
6
6
 
7
+ - Handle Binary and FormData content. [#18753](https://github.com/Azure/azure-sdk-for-js/pull/18753)
8
+
7
9
  ### Breaking Changes
8
10
 
9
11
  ### Bugs Fixed
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Azure Rest Core client library for JavaScript (Experimental)
1
+ # Azure Rest Core client library for JavaScript
2
2
 
3
3
  This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients
4
4
 
package/dist/index.js CHANGED
@@ -96,6 +96,27 @@ function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
96
96
  };
97
97
  }
98
98
 
99
+ // Copyright (c) Microsoft Corporation.
100
+ const apiVersionPolicyName = "ApiVersionPolicy";
101
+ /**
102
+ * Creates a policy that sets the apiVersion as a query parameter on every request
103
+ * @param options - Client options
104
+ * @returns Pipeline policy that sets the apiVersion as a query parameter on every request
105
+ */
106
+ function apiVersionPolicy(options) {
107
+ return {
108
+ name: apiVersionPolicyName,
109
+ sendRequest: (req, next) => {
110
+ if (options.apiVersion) {
111
+ const url$1 = new url.URL(req.url);
112
+ url$1.searchParams.append("api-version", options.apiVersion);
113
+ req.url = url$1.toString();
114
+ }
115
+ return next(req);
116
+ },
117
+ };
118
+ }
119
+
99
120
  // Copyright (c) Microsoft Corporation.
100
121
  let cachedHttpClient;
101
122
  /**
@@ -116,6 +137,7 @@ function createDefaultPipeline(baseUrl, credential, options = {}) {
116
137
  pipeline.addPolicy(coreRestPipeline.exponentialRetryPolicy(options.retryOptions), { phase: "Retry" });
117
138
  pipeline.addPolicy(coreRestPipeline.redirectPolicy(options.redirectOptions), { afterPhase: "Retry" });
118
139
  pipeline.addPolicy(coreRestPipeline.logPolicy(), { afterPhase: "Retry" });
140
+ pipeline.addPolicy(apiVersionPolicy(options));
119
141
  if (credential) {
120
142
  if (coreAuth.isTokenCredential(credential)) {
121
143
  const tokenPolicy = coreRestPipeline.bearerTokenAuthenticationPolicy({
@@ -144,6 +166,29 @@ function getCachedDefaultHttpsClient() {
144
166
  return cachedHttpClient;
145
167
  }
146
168
 
169
+ // Copyright (c) Microsoft Corporation.
170
+ // Licensed under the MIT license.
171
+ /**
172
+ * Converts a string representing binary content into a Uint8Array
173
+ */
174
+ function stringToBinaryArray(content) {
175
+ const arr = new Uint8Array(content.length);
176
+ for (let i = 0; i < content.length; i++) {
177
+ arr[i] = content.charCodeAt(i);
178
+ }
179
+ return arr;
180
+ }
181
+ /**
182
+ * Converts binary content to its string representation
183
+ */
184
+ function binaryArrayToString(content) {
185
+ let decodedBody = "";
186
+ for (const element of content) {
187
+ decodedBody += String.fromCharCode(element);
188
+ }
189
+ return decodedBody;
190
+ }
191
+
147
192
  // Copyright (c) Microsoft Corporation.
148
193
  /**
149
194
  * Helper function to send request used by the client
@@ -158,7 +203,7 @@ async function sendRequest(method, url, pipeline, options = {}) {
158
203
  const request = buildPipelineRequest(method, url, options);
159
204
  const response = await pipeline.sendRequest(httpClient, request);
160
205
  const rawHeaders = response.headers.toJSON();
161
- const parsedBody = getResponseBody(response);
206
+ const parsedBody = getResponseBody(response, options);
162
207
  return {
163
208
  request,
164
209
  headers: rawHeaders,
@@ -198,14 +243,30 @@ function buildPipelineRequest(method, url, options = {}) {
198
243
  /**
199
244
  * Prepares the body before sending the request
200
245
  */
201
- function getRequestBody(body, contentType = "application/json") {
246
+ function getRequestBody(body, contentType = "") {
202
247
  if (body === undefined) {
203
248
  return { body: undefined };
204
249
  }
250
+ if (!contentType && typeof body === "string") {
251
+ return { body };
252
+ }
205
253
  const firstType = contentType.split(";")[0];
254
+ if (firstType === "application/json") {
255
+ return { body: JSON.stringify(body) };
256
+ }
257
+ if (ArrayBuffer.isView(body)) {
258
+ if (body instanceof Uint8Array) {
259
+ return { body: binaryArrayToString(body) };
260
+ }
261
+ else {
262
+ return { body: JSON.stringify(body) };
263
+ }
264
+ }
206
265
  switch (firstType) {
207
266
  case "multipart/form-data":
208
- return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) };
267
+ return isFormData(body)
268
+ ? { formData: processFormData(body) }
269
+ : { body: JSON.stringify(body) };
209
270
  case "text/plain":
210
271
  return { body: String(body) };
211
272
  default:
@@ -215,10 +276,30 @@ function getRequestBody(body, contentType = "application/json") {
215
276
  function isFormData(body) {
216
277
  return body instanceof Object && Object.keys(body).length > 0;
217
278
  }
279
+ /**
280
+ * Checks if binary data is in Uint8Array format, if so decode it to a binary string
281
+ * to send over the wire
282
+ */
283
+ function processFormData(formData) {
284
+ if (!formData) {
285
+ return formData;
286
+ }
287
+ const processedFormData = {};
288
+ for (const element in formData) {
289
+ const item = formData[element];
290
+ if (item instanceof Uint8Array) {
291
+ processedFormData[element] = binaryArrayToString(item);
292
+ }
293
+ else {
294
+ processedFormData[element] = item;
295
+ }
296
+ }
297
+ return processedFormData;
298
+ }
218
299
  /**
219
300
  * Prepares the response body
220
301
  */
221
- function getResponseBody(response) {
302
+ function getResponseBody(response, requestOptions) {
222
303
  var _a, _b;
223
304
  // Set the default response type
224
305
  const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "";
@@ -227,6 +308,13 @@ function getResponseBody(response) {
227
308
  if (firstType === "text/plain") {
228
309
  return String(bodyToParse);
229
310
  }
311
+ /**
312
+ * If we know from options or from the content type that we are receiving binary content,
313
+ * encode it into a UInt8Array
314
+ */
315
+ if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {
316
+ return stringToBinaryArray(bodyToParse);
317
+ }
230
318
  // Default to "application/json" and fallback to string;
231
319
  try {
232
320
  return bodyToParse ? JSON.parse(bodyToParse) : undefined;
@@ -253,6 +341,18 @@ function createParseError(response, err) {
253
341
  response: response,
254
342
  });
255
343
  }
344
+ function isBinaryContentType(contentType) {
345
+ return [
346
+ "application/octet-stream",
347
+ "application/x-rdp",
348
+ "image/bmp",
349
+ "image/gif",
350
+ "image/jpeg",
351
+ "image/png",
352
+ "application/pdf",
353
+ "application/zip",
354
+ ].includes(contentType);
355
+ }
256
356
 
257
357
  // Copyright (c) Microsoft Corporation.
258
358
  /**
@@ -312,28 +412,28 @@ function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
312
412
  const client = (path, ...args) => {
313
413
  return {
314
414
  get: (options = {}) => {
315
- return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
415
+ return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
316
416
  },
317
417
  post: (options = {}) => {
318
- return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
418
+ return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
319
419
  },
320
420
  put: (options = {}) => {
321
- return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
421
+ return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
322
422
  },
323
423
  patch: (options = {}) => {
324
- return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
424
+ return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
325
425
  },
326
426
  delete: (options = {}) => {
327
- return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
427
+ return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
328
428
  },
329
429
  head: (options = {}) => {
330
- return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
430
+ return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
331
431
  },
332
432
  options: (options = {}) => {
333
- return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
433
+ return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
334
434
  },
335
435
  trace: (options = {}) => {
336
- return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
436
+ return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
337
437
  },
338
438
  };
339
439
  };
@@ -343,15 +443,8 @@ function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
343
443
  pipeline,
344
444
  };
345
445
  }
346
- function buildSendRequest(method, clientOptions, baseUrl, path, pipeline, requestOptions = {}, args = []) {
347
- var _a;
446
+ function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = []) {
348
447
  // If the client has an api-version and the request doesn't specify one, inject the one in the client options
349
- if (!((_a = requestOptions.queryParameters) === null || _a === void 0 ? void 0 : _a["api-version"]) && clientOptions.apiVersion) {
350
- if (!requestOptions.queryParameters) {
351
- requestOptions.queryParameters = {};
352
- }
353
- requestOptions.queryParameters["api-version"] = clientOptions.apiVersion;
354
- }
355
448
  const url = buildRequestUrl(baseUrl, path, args, requestOptions);
356
449
  return sendRequest(method, url, pipeline, requestOptions);
357
450
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/typeGuards.ts","../src/certificateCredential.ts","../src/restError.ts","../src/keyCredentialAuthenticationPolicy.ts","../src/clientHelpers.ts","../src/sendRequest.ts","../src/urlHelpers.ts","../src/getClient.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n * @internal\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n * @internal\n */\nexport function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[]\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n * @internal\n */\nfunction objectHasProperty<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n property: PropertyName\n): thing is Thing & Record<PropertyName, unknown> {\n return typeof thing === \"object\" && property in (thing as Record<string, unknown>);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isObjectWithProperties } from \"./typeGuards\";\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Certificate used to authenticate\n */\n cert: string;\n /**\n * Certificate key\n */\n certKey: string;\n}\n\n/**\n * Tests an object to determine whether it implements CertificateCredential.\n *\n * @param credential - The assumed CertificateCredential to be tested.\n */\nexport function isCertificateCredential(credential: unknown): credential is CertificateCredential {\n return (\n isObjectWithProperties(credential, [\"certKey\", \"cert\"]) &&\n typeof credential.cert === \"string\" &&\n typeof credential.certKey === \"string\"\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError, PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { PathUncheckedResponse } from \"./common\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError {\n return new RestError(message, {\n statusCode: statusCodeToNumber(response.status),\n request: response.request,\n response: toPipelineResponse(response),\n });\n}\n\nfunction toPipelineResponse(response: PathUncheckedResponse): PipelineResponse {\n return {\n headers: createHttpHeaders(response.headers),\n request: response.request,\n status: statusCodeToNumber(response.status) ?? -1,\n };\n}\n\nfunction statusCodeToNumber(statusCode: string): number | undefined {\n const status = Number.parseInt(statusCode);\n\n return Number.isNaN(status) ? undefined : status;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"application/json\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(response: PipelineResponse): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"./common\";\nimport { URL } from \"./url\";\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param baseUrl - base url which can be a template url\n * @param routePath - path to append to the baseUrl\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n baseUrl: string,\n routePath: string,\n pathParameters: string[],\n options: RequestParameters = {}\n): string {\n let path = routePath;\n\n if (path.startsWith(\"https://\") || path.startsWith(\"http://\")) {\n return path;\n }\n\n for (const pathParam of pathParameters) {\n let value = pathParam;\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(pathParam);\n }\n\n path = path.replace(/{([^/]+)}/, value);\n }\n\n const url = new URL(`${baseUrl}/${path}`);\n\n if (options.queryParameters) {\n const queryParams = options.queryParameters;\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n const value = param.toISOString !== undefined ? param.toISOString() : param.toString();\n url.searchParams.append(key, value);\n }\n }\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n clientOptions: ClientOptions,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n if (!requestOptions.queryParameters?.[\"api-version\"] && clientOptions.apiVersion) {\n if (!requestOptions.queryParameters) {\n requestOptions.queryParameters = {};\n }\n\n requestOptions.queryParameters[\"api-version\"] = clientOptions.apiVersion;\n }\n\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"],"names":["RestError","createHttpHeaders","createEmptyPipeline","isNode","proxyPolicy","decompressResponsePolicy","formDataPolicy","userAgentPolicy","setClientRequestIdPolicy","throttlingRetryPolicy","systemErrorRetryPolicy","exponentialRetryPolicy","redirectPolicy","logPolicy","isTokenCredential","bearerTokenAuthenticationPolicy","createDefaultHttpClient","createPipelineRequest","url","URL"],"mappings":";;;;;;;;;AAAA;AACA;AAEA;;;;;SAKgB,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAED;;;;;;SAMgB,sBAAsB,CACpC,KAAY,EACZ,UAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAClD,OAAO,KAAK,CAAC;KACd;IAED,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;QACjC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YACvC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;AAMA,SAAS,iBAAiB,CACxB,KAAY,EACZ,QAAsB;IAEtB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAK,KAAiC,CAAC;AACrF;;AC9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EAAE,MAAM;QACrB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAmB,EACnB,aAA4B,EAC5B,OAAe,EACf,IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;;;IAGnB,IAAI,EAAC,MAAA,cAAc,CAAC,eAAe,0CAAG,aAAa,CAAC,CAAA,IAAI,aAAa,CAAC,UAAU,EAAE;QAChF,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACnC,cAAc,CAAC,eAAe,GAAG,EAAE,CAAC;SACrC;QAED,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC;KAC1E;IAED,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1CJ,0BAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/typeGuards.ts","../src/certificateCredential.ts","../src/restError.ts","../src/keyCredentialAuthenticationPolicy.ts","../src/apiVersionPolicy.ts","../src/clientHelpers.ts","../src/helpers/getBinaryBody.ts","../src/sendRequest.ts","../src/urlHelpers.ts","../src/getClient.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helper TypeGuard that checks if something is defined or not.\n * @param thing - Anything\n * @internal\n */\nexport function isDefined<T>(thing: T | undefined | null): thing is T {\n return typeof thing !== \"undefined\" && thing !== null;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified properties.\n * @param thing - Anything.\n * @param properties - The name of the properties that should appear in the object.\n * @internal\n */\nexport function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n properties: PropertyName[]\n): thing is Thing & Record<PropertyName, unknown> {\n if (!isDefined(thing) || typeof thing !== \"object\") {\n return false;\n }\n\n for (const property of properties) {\n if (!objectHasProperty(thing, property)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Helper TypeGuard that checks if the input is an object with the specified property.\n * @param thing - Any object.\n * @param property - The name of the property that should appear in the object.\n * @internal\n */\nfunction objectHasProperty<Thing extends unknown, PropertyName extends string>(\n thing: Thing,\n property: PropertyName\n): thing is Thing & Record<PropertyName, unknown> {\n return typeof thing === \"object\" && property in (thing as Record<string, unknown>);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isObjectWithProperties } from \"./typeGuards\";\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Certificate used to authenticate\n */\n cert: string;\n /**\n * Certificate key\n */\n certKey: string;\n}\n\n/**\n * Tests an object to determine whether it implements CertificateCredential.\n *\n * @param credential - The assumed CertificateCredential to be tested.\n */\nexport function isCertificateCredential(credential: unknown): credential is CertificateCredential {\n return (\n isObjectWithProperties(credential, [\"certKey\", \"cert\"]) &&\n typeof credential.cert === \"string\" &&\n typeof credential.certKey === \"string\"\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RestError, PipelineResponse, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { PathUncheckedResponse } from \"./common\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError {\n return new RestError(message, {\n statusCode: statusCodeToNumber(response.status),\n request: response.request,\n response: toPipelineResponse(response),\n });\n}\n\nfunction toPipelineResponse(response: PathUncheckedResponse): PipelineResponse {\n return {\n headers: createHttpHeaders(response.headers),\n request: response.request,\n status: statusCodeToNumber(response.status) ?? -1,\n };\n}\n\nfunction statusCodeToNumber(statusCode: string): number | undefined {\n const status = Number.parseInt(statusCode);\n\n return Number.isNaN(status) ? undefined : status;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { ClientOptions } from \"./common\";\nimport { URL } from \"./url\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n if (options.apiVersion) {\n const url = new URL(req.url);\n url.searchParams.append(\"api-version\", options.apiVersion);\n req.url = url.toString();\n }\n\n return next(req);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts a string representing binary content into a Uint8Array\n */\nexport function stringToBinaryArray(content: string): Uint8Array {\n const arr = new Uint8Array(content.length);\n for (let i = 0; i < content.length; i++) {\n arr[i] = content.charCodeAt(i);\n }\n\n return arr;\n}\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\nimport { binaryArrayToString, stringToBinaryArray } from \"./helpers/getBinaryBody\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response, options);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (!contentType && typeof body === \"string\") {\n return { body };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n if (firstType === \"application/json\") {\n return { body: JSON.stringify(body) };\n }\n\n if (ArrayBuffer.isView(body)) {\n if (body instanceof Uint8Array) {\n return { body: binaryArrayToString(body) };\n } else {\n return { body: JSON.stringify(body) };\n }\n }\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body)\n ? { formData: processFormData(body) }\n : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Checks if binary data is in Uint8Array format, if so decode it to a binary string\n * to send over the wire\n */\nfunction processFormData(formData?: FormDataMap) {\n if (!formData) {\n return formData;\n }\n\n const processedFormData: FormDataMap = {};\n\n for (const element in formData) {\n const item = formData[element];\n if (item instanceof Uint8Array) {\n processedFormData[element] = binaryArrayToString(item);\n } else {\n processedFormData[element] = item;\n }\n }\n\n return processedFormData;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(\n response: PipelineResponse,\n requestOptions: RequestParameters\n): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n /**\n * If we know from options or from the content type that we are receiving binary content,\n * encode it into a UInt8Array\n */\n if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {\n return stringToBinaryArray(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n\nfunction isBinaryContentType(contentType: string) {\n return [\n \"application/octet-stream\",\n \"application/x-rdp\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"application/pdf\",\n \"application/zip\",\n ].includes(contentType);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"./common\";\nimport { URL } from \"./url\";\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param baseUrl - base url which can be a template url\n * @param routePath - path to append to the baseUrl\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n baseUrl: string,\n routePath: string,\n pathParameters: string[],\n options: RequestParameters = {}\n): string {\n let path = routePath;\n\n if (path.startsWith(\"https://\") || path.startsWith(\"http://\")) {\n return path;\n }\n\n for (const pathParam of pathParameters) {\n let value = pathParam;\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(pathParam);\n }\n\n path = path.replace(/{([^/]+)}/, value);\n }\n\n const url = new URL(`${baseUrl}/${path}`);\n\n if (options.queryParameters) {\n const queryParams = options.queryParameters;\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n const value = param.toISOString !== undefined ? param.toISOString() : param.toString();\n url.searchParams.append(key, value);\n }\n }\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"],"names":["RestError","createHttpHeaders","url","URL","createEmptyPipeline","isNode","proxyPolicy","decompressResponsePolicy","formDataPolicy","userAgentPolicy","setClientRequestIdPolicy","throttlingRetryPolicy","systemErrorRetryPolicy","exponentialRetryPolicy","redirectPolicy","logPolicy","isTokenCredential","bearerTokenAuthenticationPolicy","createDefaultHttpClient","createPipelineRequest"],"mappings":";;;;;;;;;AAAA;AACA;AAEA;;;;;SAKgB,SAAS,CAAI,KAA2B;IACtD,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAC;AACxD,CAAC;AAED;;;;;;SAMgB,sBAAsB,CACpC,KAAY,EACZ,UAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAClD,OAAO,KAAK,CAAC;KACd;IAED,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;QACjC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YACvC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;AAMA,SAAS,iBAAiB,CACxB,KAAY,EACZ,QAAsB;IAEtB,OAAO,OAAO,KAAK,KA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,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAmB,EACnB,OAAe,EACf,IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;;IAGnB,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1Cc,0BAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;;;;;;"}
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { URL } from "./url";
4
+ export const apiVersionPolicyName = "ApiVersionPolicy";
5
+ /**
6
+ * Creates a policy that sets the apiVersion as a query parameter on every request
7
+ * @param options - Client options
8
+ * @returns Pipeline policy that sets the apiVersion as a query parameter on every request
9
+ */
10
+ export function apiVersionPolicy(options) {
11
+ return {
12
+ name: apiVersionPolicyName,
13
+ sendRequest: (req, next) => {
14
+ if (options.apiVersion) {
15
+ const url = new URL(req.url);
16
+ url.searchParams.append("api-version", options.apiVersion);
17
+ req.url = url.toString();
18
+ }
19
+ return next(req);
20
+ },
21
+ };
22
+ }
23
+ //# sourceMappingURL=apiVersionPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,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,IAAI,OAAO,CAAC,UAAU,EAAE;gBACtB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC7B,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC3D,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;aAC1B;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 { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { ClientOptions } from \"./common\";\nimport { URL } from \"./url\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n if (options.apiVersion) {\n const url = new URL(req.url);\n url.searchParams.append(\"api-version\", options.apiVersion);\n req.url = url.toString();\n }\n\n return next(req);\n },\n };\n}\n"]}
@@ -4,6 +4,7 @@ import { createEmptyPipeline, bearerTokenAuthenticationPolicy, createDefaultHttp
4
4
  import { isNode } from "@azure/core-util";
5
5
  import { isTokenCredential } from "@azure/core-auth";
6
6
  import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy";
7
+ import { apiVersionPolicy } from "./apiVersionPolicy";
7
8
  let cachedHttpClient;
8
9
  /**
9
10
  * Creates a default rest pipeline to re-use accross Rest Level Clients
@@ -23,6 +24,7 @@ export function createDefaultPipeline(baseUrl, credential, options = {}) {
23
24
  pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: "Retry" });
24
25
  pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: "Retry" });
25
26
  pipeline.addPolicy(logPolicy(), { afterPhase: "Retry" });
27
+ pipeline.addPolicy(apiVersionPolicy(options));
26
28
  if (credential) {
27
29
  if (isTokenCredential(credential)) {
28
30
  const tokenPolicy = bearerTokenAuthenticationPolicy({
@@ -1 +1 @@
1
- {"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAE/B,uBAAuB,EAEvB,WAAW,EACX,wBAAwB,EACxB,cAAc,EACd,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,IAAI,gBAAwC,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,UAA4C,EAC5C,UAAyB,EAAE;;IAE3B,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IAEvC,IAAI,MAAM,EAAE;QACV,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;QACtD,QAAQ,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC,CAAC;KAChD;IAED,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC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AC,CAAC;SAC/B;KACF;IAED,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;QACrB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;KAC9C;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}
1
+ {"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAE/B,uBAAuB,EAEvB,WAAW,EACX,wBAAwB,EACxB,cAAc,EACd,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,IAAI,gBAAwC,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf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AAI,GAAG,OAAO,WAAW;aAC7D,CAAC,CAAC;YACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;SACjC;aAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;YACtC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,gBAAgB,CAAA,EAAE;gBAC1C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;aAChD;YACD,MAAM,SAAS,GAAG,iCAAiC,CACjD,UAAU,EACV,MAAA,OAAO,CAAC,WAAW,0CAAE,gBAAgB,CACtC,CAAC;YACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;SAC/B;KACF;IAED,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;QACrB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;KAC9C;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createEmptyPipeline,\n bearerTokenAuthenticationPolicy,\n Pipeline,\n createDefaultHttpClient,\n HttpClient,\n proxyPolicy,\n decompressResponsePolicy,\n formDataPolicy,\n userAgentPolicy,\n setClientRequestIdPolicy,\n throttlingRetryPolicy,\n systemErrorRetryPolicy,\n exponentialRetryPolicy,\n redirectPolicy,\n logPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { isNode } from \"@azure/core-util\";\nimport { TokenCredential, KeyCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { ClientOptions } from \"./common\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n baseUrl: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {}\n): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNode) {\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy());\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n pipeline.addPolicy(setClientRequestIdPolicy());\n pipeline.addPolicy(throttlingRetryPolicy(), { phase: \"Retry\" });\n pipeline.addPolicy(systemErrorRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(exponentialRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n pipeline.addPolicy(logPolicy(), { afterPhase: \"Retry\" });\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n if (credential) {\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: options.credentials?.scopes ?? `${baseUrl}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!options.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n options.credentials?.apiKeyHeaderName\n );\n pipeline.addPolicy(keyPolicy);\n }\n }\n\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}
@@ -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 {\n Pipeline,\n PipelineOptions,\n PipelineRequest,\n RawHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n};\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript\n * export type MyClient = Client & {\n * path: Routes;\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n */\n baseUrl?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Pipeline,\n PipelineOptions,\n PipelineRequest,\n RawHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * With this property set to true, the response body will be returned\n * as a binary array UInt8Array\n */\n binaryResponse?: boolean;\n};\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript\n * export type MyClient = Client & {\n * path: Routes;\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => Promise<PathUncheckedResponse>;\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n */\n baseUrl?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n"]}
@@ -20,28 +20,28 @@ export function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions =
20
20
  const client = (path, ...args) => {
21
21
  return {
22
22
  get: (options = {}) => {
23
- return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
23
+ return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
24
24
  },
25
25
  post: (options = {}) => {
26
- return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
26
+ return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
27
27
  },
28
28
  put: (options = {}) => {
29
- return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
29
+ return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
30
30
  },
31
31
  patch: (options = {}) => {
32
- return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
32
+ return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
33
33
  },
34
34
  delete: (options = {}) => {
35
- return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
35
+ return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
36
36
  },
37
37
  head: (options = {}) => {
38
- return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
38
+ return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
39
39
  },
40
40
  options: (options = {}) => {
41
- return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
41
+ return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
42
42
  },
43
43
  trace: (options = {}) => {
44
- return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
44
+ return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args);
45
45
  },
46
46
  };
47
47
  };
@@ -51,15 +51,8 @@ export function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions =
51
51
  pipeline,
52
52
  };
53
53
  }
54
- function buildSendRequest(method, clientOptions, baseUrl, path, pipeline, requestOptions = {}, args = []) {
55
- var _a;
54
+ function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = []) {
56
55
  // If the client has an api-version and the request doesn't specify one, inject the one in the client options
57
- if (!((_a = requestOptions.queryParameters) === null || _a === void 0 ? void 0 : _a["api-version"]) && clientOptions.apiVersion) {
58
- if (!requestOptions.queryParameters) {
59
- requestOptions.queryParameters = {};
60
- }
61
- requestOptions.queryParameters["api-version"] = clientOptions.apiVersion;
62
- }
63
56
  const url = buildRequestUrl(baseUrl, path, args, requestOptions);
64
57
  return sendRequest(method, url, pipeline, requestOptions);
65
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../src/getClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAkC,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAmB/C,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,4BAAgF,EAChF,gBAA+B,EAAE;IAEjC,IAAI,WAAwD,CAAC;IAC7D,IAAI,4BAA4B,EAAE;QAChC,IAAI,YAAY,CAAC,4BAA4B,CAAC,EAAE;YAC9C,WAAW,GAAG,4BAA4B,CAAC;SAC5C;aAAM;YACL,aAAa,GAAG,4BAA4B,aAA5B,4BAA4B,cAA5B,4BAA4B,GAAI,EAAE,CAAC;SACpD;KACF;IAED,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5E,MAAM,EAAE,uBAAuB,EAAE,GAAG,aAAa,CAAC;IAClD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,GAAG,IAAgB,EAAE,EAAE;QACnD,OAAO;YACL,GAAG,EAAE,CAAC,UAA6B,EAAE,EAAyB,EAAE;gBAC9D,OAAO,gBAA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,GACrC,IAAI,CACL,CAAC;YACJ,CAAC;YACD,KAAK,EAAE,CAAC,UAA6B,EAAE,EAAyB,EAAE;gBAChE,OAAO,gBAAgB,CACrB,OAAO,EACP,aAAa,EACb,OAAO,EACP,IAAI,EACJ,QAAQ,kBACN,uBAAuB,IAAK,OAAO,GACrC,IAAI,CACL,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,MAAM;QACrB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAmB,EACnB,aAA4B,EAC5B,OAAe,EACf,IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;;IAEnB,6GAA6G;IAC7G,IAAI,CAAC,CAAA,MAAA,cAAc,CAAC,eAAe,0CAAG,aAAa,CAAC,CAAA,IAAI,aAAa,CAAC,UAAU,EAAE;QAChF,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACnC,cAAc,CAAC,eAAe,GAAG,EAAE,CAAC;SACrC;QAED,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC;KAC1E;IAED,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1C,iBAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n clientOptions,\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n clientOptions: ClientOptions,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n if (!requestOptions.queryParameters?.[\"api-version\"] && clientOptions.apiVersion) {\n if (!requestOptions.queryParameters) {\n requestOptions.queryParameters = {};\n }\n\n requestOptions.queryParameters[\"api-version\"] = clientOptions.apiVersion;\n }\n\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"]}
1
+ {"version":3,"file":"get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IAAY,EACZ,QAAkB,EAClB,iBAAoC,EAAE,EACtC,OAAiB,EAAE;IAEnB,6GAA6G;IAC7G,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,IACG,KAAuB,CAAC,GAAG,KAAK,SAAS;QAC1C,iBAAiB,CAAC,KAAK,CAAC;QACxB,uBAAuB,CAAC,KAAK,CAAC,EAC9B;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isTokenCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isCertificateCredential } from \"./certificateCredential\";\nimport { HttpMethods, Pipeline, PipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { createDefaultPipeline } from \"./clientHelpers\";\nimport { Client, ClientOptions, HttpResponse, RequestParameters } from \"./common\";\nimport { sendRequest } from \"./sendRequest\";\nimport { buildRequestUrl } from \"./urlHelpers\";\n\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(baseUrl: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param baseUrl - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n baseUrl: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions\n): Client;\nexport function getClient(\n baseUrl: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {}\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);\n const { allowInsecureConnection } = clientOptions;\n const client = (path: string, ...args: Array<any>) => {\n return {\n get: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"GET\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n post: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"POST\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n put: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PUT\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n patch: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"PATCH\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n delete: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"DELETE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n head: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"HEAD\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n options: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"OPTIONS\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n trace: (options: RequestParameters = {}): Promise<HttpResponse> => {\n return buildSendRequest(\n \"TRACE\",\n baseUrl,\n path,\n pipeline,\n { allowInsecureConnection, ...options },\n args\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildSendRequest(\n method: HttpMethods,\n baseUrl: string,\n path: string,\n pipeline: Pipeline,\n requestOptions: RequestParameters = {},\n args: string[] = []\n): Promise<HttpResponse> {\n // If the client has an api-version and the request doesn't specify one, inject the one in the client options\n const url = buildRequestUrl(baseUrl, path, args, requestOptions);\n return sendRequest(method, url, pipeline, requestOptions);\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions\n): param is TokenCredential | KeyCredential {\n if (\n (param as KeyCredential).key !== undefined ||\n isTokenCredential(param) ||\n isCertificateCredential(param)\n ) {\n return true;\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ /**
4
+ * Converts a string representing binary content into a Uint8Array
5
+ */
6
+ export function stringToBinaryArray(content) {
7
+ const arr = new Uint8Array(content.length);
8
+ for (let i = 0; i < content.length; i++) {
9
+ arr[i] = content.charCodeAt(i);
10
+ }
11
+ return arr;
12
+ }
13
+ /**
14
+ * Converts binary content to its string representation
15
+ */
16
+ export function binaryArrayToString(content) {
17
+ let decodedBody = "";
18
+ for (const element of content) {
19
+ decodedBody += String.fromCharCode(element);
20
+ }
21
+ return decodedBody;
22
+ }
23
+ //# sourceMappingURL=getBinaryBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBinaryBody.js","sourceRoot":"","sources":["../../../src/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAChC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmB;IACrD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;QAC7B,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;KAC7C;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts a string representing binary content into a Uint8Array\n */\nexport function stringToBinaryArray(content: string): Uint8Array {\n const arr = new Uint8Array(content.length);\n for (let i = 0; i < content.length; i++) {\n arr[i] = content.charCodeAt(i);\n }\n\n return arr;\n}\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT license.
3
3
  import { createHttpHeaders, createPipelineRequest, RestError, } from "@azure/core-rest-pipeline";
4
4
  import { getCachedDefaultHttpsClient } from "./clientHelpers";
5
+ import { binaryArrayToString, stringToBinaryArray } from "./helpers/getBinaryBody";
5
6
  /**
6
7
  * Helper function to send request used by the client
7
8
  * @param method - method to use to send the request
@@ -15,7 +16,7 @@ export async function sendRequest(method, url, pipeline, options = {}) {
15
16
  const request = buildPipelineRequest(method, url, options);
16
17
  const response = await pipeline.sendRequest(httpClient, request);
17
18
  const rawHeaders = response.headers.toJSON();
18
- const parsedBody = getResponseBody(response);
19
+ const parsedBody = getResponseBody(response, options);
19
20
  return {
20
21
  request,
21
22
  headers: rawHeaders,
@@ -55,14 +56,30 @@ function buildPipelineRequest(method, url, options = {}) {
55
56
  /**
56
57
  * Prepares the body before sending the request
57
58
  */
58
- function getRequestBody(body, contentType = "application/json") {
59
+ function getRequestBody(body, contentType = "") {
59
60
  if (body === undefined) {
60
61
  return { body: undefined };
61
62
  }
63
+ if (!contentType && typeof body === "string") {
64
+ return { body };
65
+ }
62
66
  const firstType = contentType.split(";")[0];
67
+ if (firstType === "application/json") {
68
+ return { body: JSON.stringify(body) };
69
+ }
70
+ if (ArrayBuffer.isView(body)) {
71
+ if (body instanceof Uint8Array) {
72
+ return { body: binaryArrayToString(body) };
73
+ }
74
+ else {
75
+ return { body: JSON.stringify(body) };
76
+ }
77
+ }
63
78
  switch (firstType) {
64
79
  case "multipart/form-data":
65
- return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) };
80
+ return isFormData(body)
81
+ ? { formData: processFormData(body) }
82
+ : { body: JSON.stringify(body) };
66
83
  case "text/plain":
67
84
  return { body: String(body) };
68
85
  default:
@@ -72,10 +89,30 @@ function getRequestBody(body, contentType = "application/json") {
72
89
  function isFormData(body) {
73
90
  return body instanceof Object && Object.keys(body).length > 0;
74
91
  }
92
+ /**
93
+ * Checks if binary data is in Uint8Array format, if so decode it to a binary string
94
+ * to send over the wire
95
+ */
96
+ function processFormData(formData) {
97
+ if (!formData) {
98
+ return formData;
99
+ }
100
+ const processedFormData = {};
101
+ for (const element in formData) {
102
+ const item = formData[element];
103
+ if (item instanceof Uint8Array) {
104
+ processedFormData[element] = binaryArrayToString(item);
105
+ }
106
+ else {
107
+ processedFormData[element] = item;
108
+ }
109
+ }
110
+ return processedFormData;
111
+ }
75
112
  /**
76
113
  * Prepares the response body
77
114
  */
78
- function getResponseBody(response) {
115
+ function getResponseBody(response, requestOptions) {
79
116
  var _a, _b;
80
117
  // Set the default response type
81
118
  const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "";
@@ -84,6 +121,13 @@ function getResponseBody(response) {
84
121
  if (firstType === "text/plain") {
85
122
  return String(bodyToParse);
86
123
  }
124
+ /**
125
+ * If we know from options or from the content type that we are receiving binary content,
126
+ * encode it into a UInt8Array
127
+ */
128
+ if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {
129
+ return stringToBinaryArray(bodyToParse);
130
+ }
87
131
  // Default to "application/json" and fallback to string;
88
132
  try {
89
133
  return bodyToParse ? JSON.parse(bodyToParse) : undefined;
@@ -110,4 +154,16 @@ function createParseError(response, err) {
110
154
  response: response,
111
155
  });
112
156
  }
157
+ function isBinaryContentType(contentType) {
158
+ return [
159
+ "application/octet-stream",
160
+ "application/x-rdp",
161
+ "image/bmp",
162
+ "image/gif",
163
+ "image/jpeg",
164
+ "image/png",
165
+ "application/pdf",
166
+ "application/zip",
167
+ ].includes(contentType);
168
+ }
113
169
  //# sourceMappingURL=sendRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../src/sendRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAQrB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAG9D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAA6B,EAAE;IAE/B,MAAM,UAAU,GAAG,2BAA2B,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,UAAU,GAAmB,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAE7D,MAAM,UAAU,GAAgC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE1E,OAAO;QACL,OAAO;QACP,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,IAAS;IAC/B,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC5B,O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AQ,CAAC,UAAU,GAAG,CAAC;IAChG,MAAM,OAAO,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,SAAS,CAAC,WAAW,CAAC;IAClD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE;QACxB,IAAI,EAAE,OAAO;QACb,UAAU,EAAE,QAAQ,CAAC,MAAM;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"application/json\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body) ? { formData: body } : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(response: PipelineResponse): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n"]}
1
+ {"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../src/sendRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAQrB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAA6B,EAAE;IAE/B,MAAM,UAAU,GAAG,2BAA2B,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,UAAU,GAAmB,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAE7D,MAAM,UAAU,GAAgC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEnF,OAAO;QACL,OAAO;QACP,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,IAAS;IAC/B,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,0BAA0B,CAAC;KACnC;IAED,yBAAyB;IACzB,OAAO,iCAAiC,CAAC;AAC3C,CAAC;AAMD,SAAS,oBAAoB,CAC3B,MAAmB,EACnB,GAAW,EACX,UAAqC,EAAE;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Q,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,WAAmB;IAC9C,OAAO;QACL,0BAA0B;QAC1B,mBAAmB;QACnB,WAAW;QACX,WAAW;QACX,YAAY;QACZ,WAAW;QACX,iBAAiB;QACjB,iBAAiB;KAClB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n createHttpHeaders,\n createPipelineRequest,\n FormDataMap,\n HttpMethods,\n Pipeline,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers\";\nimport { HttpResponse, RequestParameters } from \"./common\";\nimport { binaryArrayToString, stringToBinaryArray } from \"./helpers/getBinaryBody\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters = {}\n): Promise<HttpResponse> {\n const httpClient = getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n const response = await pipeline.sendRequest(httpClient, request);\n const rawHeaders: RawHttpHeaders = response.headers.toJSON();\n\n const parsedBody: RequestBodyType | undefined = getResponseBody(response, options);\n\n return {\n request,\n headers: rawHeaders,\n status: `${response.status}`,\n body: parsedBody,\n };\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string {\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n // By default return json\n return \"application/json; charset=UTF-8\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {}\n): PipelineRequest {\n const { body, formData } = getRequestBody(options.body, options.contentType);\n const hasContent = body !== undefined || formData !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? \"application/json\",\n ...(hasContent && {\n \"content-type\": options.contentType ?? getContentType(options.body),\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n formData,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n formData?: FormDataMap;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (!contentType && typeof body === \"string\") {\n return { body };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n if (firstType === \"application/json\") {\n return { body: JSON.stringify(body) };\n }\n\n if (ArrayBuffer.isView(body)) {\n if (body instanceof Uint8Array) {\n return { body: binaryArrayToString(body) };\n } else {\n return { body: JSON.stringify(body) };\n }\n }\n\n switch (firstType) {\n case \"multipart/form-data\":\n return isFormData(body)\n ? { formData: processFormData(body) }\n : { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n return { body: JSON.stringify(body) };\n }\n}\n\nfunction isFormData(body: unknown): body is FormDataMap {\n return body instanceof Object && Object.keys(body).length > 0;\n}\n\n/**\n * Checks if binary data is in Uint8Array format, if so decode it to a binary string\n * to send over the wire\n */\nfunction processFormData(formData?: FormDataMap) {\n if (!formData) {\n return formData;\n }\n\n const processedFormData: FormDataMap = {};\n\n for (const element in formData) {\n const item = formData[element];\n if (item instanceof Uint8Array) {\n processedFormData[element] = binaryArrayToString(item);\n } else {\n processedFormData[element] = item;\n }\n }\n\n return processedFormData;\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(\n response: PipelineResponse,\n requestOptions: RequestParameters\n): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse: string = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n\n /**\n * If we know from options or from the content type that we are receiving binary content,\n * encode it into a UInt8Array\n */\n if (requestOptions.binaryResponse || isBinaryContentType(firstType)) {\n return stringToBinaryArray(bodyToParse);\n }\n\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n\nfunction isBinaryContentType(contentType: string) {\n return [\n \"application/octet-stream\",\n \"application/x-rdp\",\n \"image/bmp\",\n \"image/gif\",\n \"image/jpeg\",\n \"image/png\",\n \"application/pdf\",\n \"application/zip\",\n ].includes(contentType);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-rest/core-client",
3
- "version": "1.0.0-alpha.20211105.1",
3
+ "version": "1.0.0-alpha.20220104.5",
4
4
  "description": "Core library for interfacing with AutoRest rest level generated code",
5
5
  "sdk-type": "client",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,6 @@
16
16
  "build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
17
17
  "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
18
18
  "clean": "rimraf dist dist-* temp types *.tgz *.log",
19
- "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src",
20
19
  "execute:samples": "echo skipped",
21
20
  "extract-api": "tsc -p . && api-extractor run --local",
22
21
  "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
@@ -63,17 +62,17 @@
63
62
  "tslib": "^2.2.0"
64
63
  },
65
64
  "devDependencies": {
65
+ "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
66
+ "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
66
67
  "@microsoft/api-extractor": "^7.18.11",
67
68
  "@types/chai": "^4.1.6",
68
69
  "@types/mocha": "^7.0.2",
69
70
  "@types/node": "^12.0.0",
70
- "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
71
- "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
71
+ "@types/sinon": "^9.0.4",
72
72
  "chai": "^4.2.0",
73
73
  "cross-env": "^7.0.2",
74
74
  "eslint": "^7.15.0",
75
75
  "inherits": "^2.0.3",
76
- "karma": "^6.2.0",
77
76
  "karma-chrome-launcher": "^3.0.0",
78
77
  "karma-coverage": "^2.0.0",
79
78
  "karma-edge-launcher": "^0.4.2",
@@ -81,17 +80,17 @@
81
80
  "karma-firefox-launcher": "^1.1.0",
82
81
  "karma-ie-launcher": "^1.0.0",
83
82
  "karma-junit-reporter": "^2.0.1",
84
- "karma-mocha": "^2.0.1",
85
83
  "karma-mocha-reporter": "^2.2.5",
84
+ "karma-mocha": "^2.0.1",
86
85
  "karma-sourcemap-loader": "^0.3.8",
86
+ "karma": "^6.2.0",
87
+ "mocha-junit-reporter": "^2.0.0",
87
88
  "mocha": "^7.1.1",
88
- "mocha-junit-reporter": "^1.18.0",
89
- "prettier": "2.2.1",
89
+ "prettier": "^2.5.1",
90
90
  "rimraf": "^3.0.0",
91
91
  "rollup": "^1.16.3",
92
92
  "sinon": "^9.0.2",
93
93
  "typescript": "~4.2.0",
94
- "util": "^0.12.1",
95
- "typedoc": "0.15.2"
94
+ "util": "^0.12.1"
96
95
  }
97
96
  }
@@ -185,6 +185,11 @@ export declare type RequestParameters = {
185
185
  allowInsecureConnection?: boolean;
186
186
  /** Set to true if you want to skip encoding the path parameters */
187
187
  skipUrlEncoding?: boolean;
188
+ /**
189
+ * With this property set to true, the response body will be returned
190
+ * as a binary array UInt8Array
191
+ */
192
+ binaryResponse?: boolean;
188
193
  };
189
194
 
190
195
  /**