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