@azure-rest/arm-compute 1.0.0-alpha.20240111.1 → 1.0.0-alpha.20240115.1

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/dist/index.js CHANGED
@@ -13,18 +13,23 @@ var coreLro = require('@azure/core-lro');
13
13
  * @param credentials type: TokenCredential
14
14
  */
15
15
  function createClient(credentials, options = {}) {
16
- var _a;
17
- const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `https://management.azure.com`;
18
- options = Object.assign(Object.assign({}, options), { credentials: {
16
+ const baseUrl = options.baseUrl ?? `https://management.azure.com`;
17
+ options = {
18
+ ...options,
19
+ credentials: {
19
20
  scopes: ["https://management.azure.com/.default"],
20
- } });
21
+ },
22
+ };
21
23
  const userAgentInfo = `azsdk-js-arm-compute-rest/1.0.0-beta.1`;
22
24
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
23
25
  ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
24
26
  : `${userAgentInfo}`;
25
- options = Object.assign(Object.assign({}, options), { userAgentOptions: {
27
+ options = {
28
+ ...options,
29
+ userAgentOptions: {
26
30
  userAgentPrefix,
27
- } });
31
+ },
32
+ };
28
33
  const client = coreClient.getClient(baseUrl, credentials, options);
29
34
  return client;
30
35
  }
@@ -381,7 +386,7 @@ const responseMap = {
381
386
  };
382
387
  function isUnexpected(response) {
383
388
  const lroOriginal = response.headers["x-ms-original-url"];
384
- const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
389
+ const url = new URL(lroOriginal ?? response.request.url);
385
390
  const method = response.request.method;
386
391
  let pathDetails = responseMap[`${method} ${url.pathname}`];
387
392
  if (!pathDetails) {
@@ -390,7 +395,6 @@ function isUnexpected(response) {
390
395
  return !pathDetails.includes(response.status);
391
396
  }
392
397
  function geParametrizedPathSuccess(path) {
393
- var _a, _b;
394
398
  const pathParts = path.split("/");
395
399
  // Iterate the responseMap to find a match
396
400
  for (const [key, value] of Object.entries(responseMap)) {
@@ -405,7 +409,7 @@ function geParametrizedPathSuccess(path) {
405
409
  // track if we have found a match to return the values found.
406
410
  let found = true;
407
411
  for (let i = 0; i < candidateParts.length; i++) {
408
- if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.endsWith("}"))) {
412
+ if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.endsWith("}")) {
409
413
  // If the current part of the candidate is a "template" part
410
414
  // it is a match with the actual path part on hand
411
415
  // skip as the parameterized part can match anything
@@ -494,7 +498,7 @@ function getElements(body, itemName) {
494
498
  if (!Array.isArray(value)) {
495
499
  throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
496
500
  }
497
- return value !== null && value !== void 0 ? value : [];
501
+ return value ?? [];
498
502
  }
499
503
  /**
500
504
  * Checks if a request failed
@@ -530,7 +534,7 @@ function getLongRunningPoller(client, initialResponse, options = {}) {
530
534
  // to get the latest status. We use the client provided and the polling path
531
535
  // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
532
536
  // depending on the lro pattern that the service implements. If non is provided we default to the initial path.
533
- const pollPath = path !== null && path !== void 0 ? path : initialResponse.request.url;
537
+ const pollPath = path ?? initialResponse.request.url;
534
538
  const response = await client.pathUnchecked(pollPath).get();
535
539
  const lroResponse = getLroResponse(response);
536
540
  lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
@@ -550,7 +554,11 @@ function getLroResponse(response) {
550
554
  }
551
555
  return {
552
556
  flatResponse: response,
553
- rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
557
+ rawResponse: {
558
+ ...response,
559
+ statusCode: Number.parseInt(response.status),
560
+ body: response.body,
561
+ },
554
562
  };
555
563
  }
556
564