Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/ms-rest-azure-js

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/ms-rest-azure-js - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

5

Changelog.md
# Changelog
## 2.1.0 - 2021-01-26
- Added support for @azure/identity's TokenCredential. For more information, see https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md#credentials
## 2.0.1 - 2019-07-30

@@ -88,2 +91,2 @@ - In `getOperationResponse()` if the `resource` is of type `string` and we get an error while performing `JSON.parse()` then instead of letting the error be thrown we set the `resource` as-is as the `response.parsedBody`

- Supports polling for long running operations
- Provides definition of CloudError
- Provides definition of CloudError

@@ -828,3 +828,3 @@ /** @license ms-rest-azure-js

*/
var msRestAzureVersion = "2.0.1";
var msRestAzureVersion = "2.1.0";

@@ -844,2 +844,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

function AzureServiceClient(credentials, options) {
var _a;
var _this = _super.call(this, credentials, options = updateOptionsWithDefaultValues(options)) || this;

@@ -849,3 +850,3 @@ _this.acceptLanguage = DEFAULT_LANGUAGE;

// automatically use the baseUri from that environment.
var env = credentials.environment;
var env = (_a = credentials) === null || _a === void 0 ? void 0 : _a.environment;
if (env && !_this.baseUri) {

@@ -852,0 +853,0 @@ _this.baseUri = env.resourceManagerEndpointUrl;

2

dist/msRestAzure.min.js

@@ -5,2 +5,2 @@ /** @license ms-rest-azure-js

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@azure/ms-rest-js")):"function"==typeof define&&define.amd?define(["exports","@azure/ms-rest-js"],t):t((e=e||self).msRestAzure={},e.msRest)}(this,function(e,a){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function t(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function r(e,i,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{s(u.next(e))}catch(e){t(e)}}function o(e){try{s(u.throw(e))}catch(e){t(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}s((u=u.apply(e,i||[])).next())})}function s(r,n){var o,s,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]<i[3])){a.label=t[1];break}if(6===t[0]&&a.label<i[1]){a.label=i[1],i=t;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(t);break}i[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],s=0}finally{o=i=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}var i=(u.prototype.getOperationStatus=function(){return this._pollState.state},u.prototype.isFinished=function(){return f(this._pollState.state)},u.prototype.pollUntilFinished=function(){return r(this,void 0,void 0,function(){var t;return s(this,function(e){switch(e.label){case 0:return this.isFinished()?[3,3]:(t=function(e,t){var r=30;null!=e.longRunningOperationRetryTimeout?r=e.longRunningOperationRetryTimeout:(t=t.headers.get("retry-after"))&&(t=parseInt(t),Number.isNaN(t)||(r=t));return r}(this._azureServiceClient,this._pollState.mostRecentResponse),[4,a.delay(1e3*t)]);case 1:return e.sent(),[4,this.sendPollRequest()];case 2:return e.sent(),[3,0];case 3:return[2,this.isFinalStatusAcceptable()]}})})},u.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState.initialResponse.request.method;return!this._pollState.resource&&("PUT"===e||"PATCH"===e||"POST"===e)},u.prototype.getMostRecentResponse=function(){return this._pollState.mostRecentResponse},u.prototype.getOperationResponse=function(){return r(this,void 0,void 0,function(){var t,r,n;return s(this,function(e){switch(e.label){case 0:return this.shouldDoFinalGetResourceRequest()?[4,this.doFinalGetResourceRequest()]:[3,2];case 1:e.sent(),e.label=2;case 2:if(t=this._pollState.mostRecentResponse,r=o(o({},t),{headers:t.headers.clone()}),n=this._pollState.resource)if("string"==typeof n.valueOf()){r.bodyAsText=n;try{r.parsedBody=JSON.parse(n)}catch(e){r.parsedBody=n}}else r.bodyAsText=JSON.stringify(n),r.parsedBody=n;else r.bodyAsText=t.bodyAsText,r.parsedBody=t.parsedBody;return[2,r]}})})},u.prototype.getRestError=function(){var e,t=new a.RestError("");return t.request=a.stripRequest(this._pollState.mostRecentRequest),t.response=this._pollState.mostRecentResponse,t.message='Long running operation failed with status: "'+this._pollState.state+'".',t.body=this._pollState.resource,!t.body||(e=t.body.error)&&(e.message&&(t.message='Long running operation failed with error: "'+e.message+'".'),e.code&&(t.code=e.code)),t},u.prototype.updateState=function(e,t){var r=this;return this.updateOperationStatus(e,t).then(function(e){r._pollState.state=p(e.parsedBody)||"Succeeded",r._pollState.mostRecentResponse=e,r._pollState.mostRecentRequest=e.request,r._pollState.resource=c(e)}).catch(function(e){var t;if(!e.response||!e.response.status)throw e;if(t=e.response.status,"DELETE"!==r._pollState.initialResponse.request.method||t<400||499<t)throw e})},u.prototype.updateOperationStatus=function(e,t){var e=e.replace(" ","%20"),r=new a.WebResource(e,"GET"),e=this._pollState;r.operationSpec=e.mostRecentRequest.operationSpec,r.shouldDeserialize=t,r.operationResponseGetter=l;e=e.options;if(e&&e.customHeaders)for(var n=e.customHeaders,o=0,s=Object.keys(n);o<s.length;o++){var i=s[o];r.headers.set(i,n[i])}return this._azureServiceClient.sendRequest(r)},u.prototype.getPollState=function(){return this._pollState},u);function u(e,t){this._azureServiceClient=e,this._pollState=t}function l(e,t){var r=t.status,t=e.responses,e=t[r];return e||(200===r?e=t[201]||t[202]:201<=r&&r<=299&&(e={})),e}function p(e){var t;return e&&(e.provisioningState?t=e.provisioningState:e.properties&&(t=e.properties.provisioningState)),t}function c(t){var e;try{t.parsedBody?e=t.parsedBody:t.bodyAsText&&0<t.bodyAsText.length&&(e=JSON.parse(t.bodyAsText))}catch(e){var r=new a.RestError('Error "'+e+'" occurred in parsing the responseBody " +\n "while creating the PollingState for Long Running Operation- "'+t.bodyAsText+'"');throw r.request=t.request,r.response=t,r}return e}function d(e,t){switch(null==t&&(t=c(e)),e.status){case 202:n="InProgress";break;case 204:n="Succeeded";break;case 201:n=p(t)||"InProgress";break;case 200:var r=p(t),n=r||(b(e)||g(e)?"InProgress":"Succeeded");break;default:n="Failed"}return n}var h=["Succeeded","Failed","Canceled","Cancelled"];function f(e){for(var t=!1,r=0,n=h;r<n.length;r++)if(y(e,n[r])){t=!0;break}return t}function y(e,t){return(e&&e.toLowerCase())===(t&&t.toLowerCase())}function R(e,t){var r;switch(t.pollStrategyType){case"AzureAsyncOperation":r=new P(e,t);break;case"Location":r=new m(e,t);break;case"GetResource":r=new O(e,t);break;default:throw new Error('Unrecognized LRO poll strategy type: "'+t.pollStrategyType+'"')}return r}function g(e){return e.headers.get("location")}var S,m=(t(v,S=i),v.prototype.locationStrategyShouldDeserialize=function(e){var t=!1,r=this._pollState.initialResponse.request.method,e=e.status;return 200!==e&&(201!==e||"PUT"!==r&&"PATCH"!==r)&&(204!==e||"DELETE"!==r&&"POST"!==r)||(t=!0),t},v.prototype.sendPollRequest=function(){var i=this._pollState;return this.updateOperationStatus(i.locationHeaderValue,this.locationStrategyShouldDeserialize.bind(this)).then(function(e){var t=g(e);t&&(i.locationHeaderValue=t),i.mostRecentResponse=e,i.mostRecentRequest=e.request;var r=i.initialResponse,n=r.request.method,t=r.status,r=e.status;if(202===r)i.state="InProgress";else if(200===r||201===r&&("PUT"===n||"PATCH"===n)||204===r&&("DELETE"===n||"POST"===n))i.state="Succeeded",i.resource=c(e);else{if(404!==r||"POST"!==n||200!==t&&201!==t&&202!==t){if(400<=r&&r<=499){var o=e.bodyAsText,s=o;try{s=JSON.parse(o).message}catch(e){}throw new a.RestError(s,void 0,r,a.stripRequest(e.request),e,o)}throw new Error("The response with status code "+r+' from polling for long running operation url "'+i.locationHeaderValue+'" is not valid.')}i.state="Failed",i.resource=c(e)}})},v.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return y(e.state,"Succeeded")||"POST"===t.request.method&&404===e.mostRecentResponse.status&&(200===r||201===r||202===r)},v.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,t=t.status,t=("POST"!==r||404!==e.mostRecentResponse.status||200!==t&&201!==t&&202!==t)&&(S.prototype.shouldDoFinalGetResourceRequest.call(this)||"POST"===r&&201===t);return t},v.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.status,t=t.request,e="POST"!==t.method||200!==r&&201!==r&&202!==r?t.url:e.locationHeaderValue;return this.updateState(e,!0)},v);function v(){return null!==S&&S.apply(this,arguments)||this}function b(e){return e.headers.get("azure-asyncoperation")}var q,P=(t(_,q=i),_.prototype.sendPollRequest=function(){var o=this._pollState;return this.updateOperationStatus(o.azureAsyncOperationHeaderValue,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new a.RestError("Invalid status code ("+t+') with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=a.stripRequest(e.request),n.response=e,n.body=r,n}if(!r)throw new Error("The response from long running operation does not contain a body.");if(!r.status)throw new Error('The response "'+e.bodyAsText+'" from long running operation does not contain the status property.');n=b(e);n&&(o.azureAsyncOperationHeaderValue=n),o.state=r.status,o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=c(e)})},_.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=!1;return"PUT"===r||"PATCH"===r?n=!0:e.locationHeaderValue&&(t=t.status,"POST"===r?n=200===t||201===t:"DELETE"===r&&(n=200===t||202===t)),n},_.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.locationHeaderValue,r=e.initialResponse,n=r.request,e=n.url;return t&&(n=n.method,r=r.status,("POST"!==n||200!==r&&201!==r&&202!==r)&&("DELETE"!==n||200!==r&&202!==r)||(e=t)),this.updateState(e,!0)},_.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return y(e.state,"Succeeded")||"POST"===t.request.method&&(200===r||201===r)},_);function _(){return null!==q&&q.apply(this,arguments)||this}var w,O=(t(T,w=i),T.prototype.sendPollRequest=function(){var o=this._pollState;return this.updateOperationStatus(o.initialResponse.request.url,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new a.RestError('Invalid status code with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=a.stripRequest(e.request),n.response=e,n.body=r,n}if(!e.parsedBody)throw new Error("The response from long running operation does not contain a body.");o.state=p(e.parsedBody)||"Succeeded",o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=c(e)})},T.prototype.isFinalStatusAcceptable=function(){return y(this._pollState.state,"Succeeded")},T.prototype.doFinalGetResourceRequest=function(){return this.sendPollRequest()},T);function T(){return null!==w&&w.apply(this,arguments)||this}var A=(E.prototype.getInitialResponse=function(){return this._initialResponse},E.prototype.getMostRecentResponse=function(){var e=this._lroPollStrategy;return e?e.getMostRecentResponse():this._initialResponse},E.prototype.isFinished=function(){var e=this._lroPollStrategy;return!e||e.isFinished()},E.prototype.isFinalStatusAcceptable=function(){var e,t=this._lroPollStrategy;return t?t.isFinished()&&(e=t.isFinalStatusAcceptable()):e=!0,e},E.prototype.getOperationStatus=function(){var e=this._lroPollStrategy;return e?e.getOperationStatus():"Succeeded"},E.prototype.getOperationResponse=function(){var e,t=this._lroPollStrategy;if(t)if(t.isFinished()){if(!t.isFinalStatusAcceptable())throw t.getRestError();e=t.getOperationResponse()}else e=Promise.resolve(void 0);else e=Promise.resolve(this._initialResponse);return e},E.prototype.poll=function(){var e=this._lroPollStrategy,t=e?e.sendPollRequest().then(function(){return e.getOperationStatus()}):Promise.resolve("Succeeded");return t},E.prototype.pollUntilFinished=function(){return r(this,void 0,void 0,function(){var t;return s(this,function(e){return t=this._lroPollStrategy,[2,t?t.pollUntilFinished().then(function(e){if(e)return t.getOperationResponse().then(z);throw t.getRestError()}):Promise.resolve(z(this._initialResponse))]})})},E.prototype.getPollState=function(){var e=this._lroPollStrategy;return e?e.getPollState():void 0},E);function E(e,t){this._lroPollStrategy=e,this._initialResponse=t}function C(e,t,r){r=function(e,t,r){var n,o=e.request.method,s=e.status;if(b(e))n="AzureAsyncOperation";else if(g(e))n="Location";else if("PUT"===o||"PATCH"===o)n="GetResource";else if(201!==s&&202!==s&&!f(d(e)))throw new Error("Can't determine long running operation polling strategy.");return n?(s=c(e),R(t,{pollStrategyType:n,options:r,initialResponse:e,mostRecentResponse:e,mostRecentRequest:e.request,azureAsyncOperationHeaderValue:b(e),locationHeaderValue:g(e),resource:s,state:d(e,s)})):void 0}(t,e,r);return new A(r,t)}function F(e,t){e=R(e,t);return new A(e,t.initialResponse)}function z(e){var t=e.request,r=t.operationResponseGetter,t=t.operationSpec;return a.flattenResponse(e,r&&t&&r(t,e))}var L,N="en-us",x="2.0.1",H=(t(D,L=a.ServiceClient),D.prototype.sendLRORequest=function(e,t,r){var n=this;return this.sendOperationRequest(e,t).then(function(e){return C(n,e._response,r)})},D.prototype.sendLongRunningRequest=function(e,t){return this.beginLongRunningRequest(e,t).then(function(e){return e.pollUntilFinished()}).then(function(e){return e._response})},D.prototype.beginLongRunningRequest=function(e,t){var r=this;return this.sendRequest(e).then(function(e){return C(r,e,t)})},D.prototype.restoreLROPoller=function(e){return F(this,e)},D);function D(e,t){var r=L.call(this,e,t=function(e){e=e||{};null==e.generateClientRequestIdHeader&&(e.generateClientRequestIdHeader=!0);e.userAgent||(e.userAgent=B());return e}(t))||this;r.acceptLanguage=N;e=e.environment;return e&&!r.baseUri&&(r.baseUri=e.resourceManagerEndpointUrl),null!=t.acceptLanguage&&(r.acceptLanguage=t.acceptLanguage),null!=t.longRunningOperationRetryTimeout&&(r.longRunningOperationRetryTimeout=t.longRunningOperationRetryTimeout),r}function B(){var e=a.getDefaultUserAgentValue();return"ms-rest-azure-js/"+x+" "+e}var G,i=(t(U,G=a.ApiKeyCredentials),U);function U(e){if(!e||e&&"string"!=typeof e.valueOf())throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");e={inHeader:{"Ocp-Apim-Subscription-Key":e,"X-BingApis-SDK-Client":"node-SDK"}};return G.call(this,e)||this}e.AzureServiceClient=H,e.BaseResourceMapper={serializedName:"BaseResource",type:{name:"Composite",className:"BaseResource",modelProperties:{}}},e.CloudErrorMapper={serializedName:"CloudError",type:{name:"Composite",className:"CloudError",modelProperties:{code:{required:!0,serializedName:"code",type:{name:"String"}},message:{required:!0,serializedName:"message",type:{name:"String"}},target:{serializedName:"target",type:{name:"String"}},details:{serializedName:"details",type:{name:"Sequence",element:{serializedName:"CloudErrorElementType",type:{name:"Composite",className:"CloudError"}}}},innerError:{required:!1,serializedName:"innererror",type:{name:"Object"}},additionalInfo:{required:!1,serializedName:"additionalInfo",type:{name:"Composite",className:"AdditionalInfoElement",modelProperties:{type:{required:!0,serializedName:"type",type:{name:"String"}},info:{required:!1,serializedName:"info",type:{name:"Object"}}}}}}}},e.CognitiveServicesCredentials=i,e.DEFAULT_LANGUAGE=N,e.LROPoller=A,e.createLROPollerFromInitialResponse=C,e.createLROPollerFromPollState=F,e.getDefaultUserAgentValue=B,e.msRestAzureVersion=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@azure/ms-rest-js")):"function"==typeof define&&define.amd?define(["exports","@azure/ms-rest-js"],t):t((e=e||self).msRestAzure={},e.msRest)}(this,function(e,a){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function t(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function r(e,i,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{s(u.next(e))}catch(e){t(e)}}function o(e){try{s(u.throw(e))}catch(e){t(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}s((u=u.apply(e,i||[])).next())})}function s(r,n){var o,s,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,(t=i?[2&t[0],i.value]:t)[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]<i[3])){a.label=t[1];break}if(6===t[0]&&a.label<i[1]){a.label=i[1],i=t;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(t);break}i[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],s=0}finally{o=i=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}var i=(u.prototype.getOperationStatus=function(){return this._pollState.state},u.prototype.isFinished=function(){return f(this._pollState.state)},u.prototype.pollUntilFinished=function(){return r(this,void 0,void 0,function(){var t;return s(this,function(e){switch(e.label){case 0:return this.isFinished()?[3,3]:(t=function(e,t){var r=30;null!=e.longRunningOperationRetryTimeout?r=e.longRunningOperationRetryTimeout:(t=t.headers.get("retry-after"))&&(t=parseInt(t),Number.isNaN(t)||(r=t));return r}(this._azureServiceClient,this._pollState.mostRecentResponse),[4,a.delay(1e3*t)]);case 1:return e.sent(),[4,this.sendPollRequest()];case 2:return e.sent(),[3,0];case 3:return[2,this.isFinalStatusAcceptable()]}})})},u.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState.initialResponse.request.method;return!this._pollState.resource&&("PUT"===e||"PATCH"===e||"POST"===e)},u.prototype.getMostRecentResponse=function(){return this._pollState.mostRecentResponse},u.prototype.getOperationResponse=function(){return r(this,void 0,void 0,function(){var t,r,n;return s(this,function(e){switch(e.label){case 0:return this.shouldDoFinalGetResourceRequest()?[4,this.doFinalGetResourceRequest()]:[3,2];case 1:e.sent(),e.label=2;case 2:if(t=this._pollState.mostRecentResponse,r=o(o({},t),{headers:t.headers.clone()}),n=this._pollState.resource)if("string"==typeof n.valueOf()){r.bodyAsText=n;try{r.parsedBody=JSON.parse(n)}catch(e){r.parsedBody=n}}else r.bodyAsText=JSON.stringify(n),r.parsedBody=n;else r.bodyAsText=t.bodyAsText,r.parsedBody=t.parsedBody;return[2,r]}})})},u.prototype.getRestError=function(){var e,t=new a.RestError("");return t.request=a.stripRequest(this._pollState.mostRecentRequest),t.response=this._pollState.mostRecentResponse,t.message='Long running operation failed with status: "'+this._pollState.state+'".',t.body=this._pollState.resource,!t.body||(e=t.body.error)&&(e.message&&(t.message='Long running operation failed with error: "'+e.message+'".'),e.code&&(t.code=e.code)),t},u.prototype.updateState=function(e,t){var r=this;return this.updateOperationStatus(e,t).then(function(e){r._pollState.state=p(e.parsedBody)||"Succeeded",r._pollState.mostRecentResponse=e,r._pollState.mostRecentRequest=e.request,r._pollState.resource=c(e)}).catch(function(e){var t;if(!e.response||!e.response.status)throw e;if(t=e.response.status,"DELETE"!==r._pollState.initialResponse.request.method||t<400||499<t)throw e})},u.prototype.updateOperationStatus=function(e,t){var e=e.replace(" ","%20"),r=new a.WebResource(e,"GET"),e=this._pollState;r.operationSpec=e.mostRecentRequest.operationSpec,r.shouldDeserialize=t,r.operationResponseGetter=l;e=e.options;if(e&&e.customHeaders)for(var n=e.customHeaders,o=0,s=Object.keys(n);o<s.length;o++){var i=s[o];r.headers.set(i,n[i])}return this._azureServiceClient.sendRequest(r)},u.prototype.getPollState=function(){return this._pollState},u);function u(e,t){this._azureServiceClient=e,this._pollState=t}function l(e,t){var r=t.status,t=e.responses,e=t[r];return e||(200===r?e=t[201]||t[202]:201<=r&&r<=299&&(e={})),e}function p(e){var t;return e&&(e.provisioningState?t=e.provisioningState:e.properties&&(t=e.properties.provisioningState)),t}function c(t){var e;try{t.parsedBody?e=t.parsedBody:t.bodyAsText&&0<t.bodyAsText.length&&(e=JSON.parse(t.bodyAsText))}catch(e){var r=new a.RestError('Error "'+e+'" occurred in parsing the responseBody " +\n "while creating the PollingState for Long Running Operation- "'+t.bodyAsText+'"');throw r.request=t.request,r.response=t,r}return e}function d(e,t){switch(null==t&&(t=c(e)),e.status){case 202:n="InProgress";break;case 204:n="Succeeded";break;case 201:n=p(t)||"InProgress";break;case 200:var r=p(t),n=r||(b(e)||g(e)?"InProgress":"Succeeded");break;default:n="Failed"}return n}var h=["Succeeded","Failed","Canceled","Cancelled"];function f(e){for(var t=!1,r=0,n=h;r<n.length;r++)if(y(e,n[r])){t=!0;break}return t}function y(e,t){return(e&&e.toLowerCase())===(t&&t.toLowerCase())}function R(e,t){var r;switch(t.pollStrategyType){case"AzureAsyncOperation":r=new P(e,t);break;case"Location":r=new m(e,t);break;case"GetResource":r=new O(e,t);break;default:throw new Error('Unrecognized LRO poll strategy type: "'+t.pollStrategyType+'"')}return r}function g(e){return e.headers.get("location")}var S,m=(t(v,S=i),v.prototype.locationStrategyShouldDeserialize=function(e){var t=!1,r=this._pollState.initialResponse.request.method,e=e.status;return t=200===e||201===e&&("PUT"===r||"PATCH"===r)||204===e&&("DELETE"===r||"POST"===r)?!0:t},v.prototype.sendPollRequest=function(){var i=this._pollState;return this.updateOperationStatus(i.locationHeaderValue,this.locationStrategyShouldDeserialize.bind(this)).then(function(e){var t=g(e);t&&(i.locationHeaderValue=t),i.mostRecentResponse=e,i.mostRecentRequest=e.request;var r=i.initialResponse,n=r.request.method,t=r.status,r=e.status;if(202===r)i.state="InProgress";else if(200===r||201===r&&("PUT"===n||"PATCH"===n)||204===r&&("DELETE"===n||"POST"===n))i.state="Succeeded",i.resource=c(e);else{if(404!==r||"POST"!==n||200!==t&&201!==t&&202!==t){if(400<=r&&r<=499){var o=e.bodyAsText,s=o;try{s=JSON.parse(o).message}catch(e){}throw new a.RestError(s,void 0,r,a.stripRequest(e.request),e,o)}throw new Error("The response with status code "+r+' from polling for long running operation url "'+i.locationHeaderValue+'" is not valid.')}i.state="Failed",i.resource=c(e)}})},v.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return y(e.state,"Succeeded")||"POST"===t.request.method&&404===e.mostRecentResponse.status&&(200===r||201===r||202===r)},v.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,t=t.status,t=("POST"!==r||404!==e.mostRecentResponse.status||200!==t&&201!==t&&202!==t)&&(S.prototype.shouldDoFinalGetResourceRequest.call(this)||"POST"===r&&201===t);return t},v.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.status,t=t.request,e="POST"!==t.method||200!==r&&201!==r&&202!==r?t.url:e.locationHeaderValue;return this.updateState(e,!0)},v);function v(){return null!==S&&S.apply(this,arguments)||this}function b(e){return e.headers.get("azure-asyncoperation")}var q,P=(t(_,q=i),_.prototype.sendPollRequest=function(){var o=this._pollState;return this.updateOperationStatus(o.azureAsyncOperationHeaderValue,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new a.RestError("Invalid status code ("+t+') with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=a.stripRequest(e.request),n.response=e,n.body=r,n}if(!r)throw new Error("The response from long running operation does not contain a body.");if(!r.status)throw new Error('The response "'+e.bodyAsText+'" from long running operation does not contain the status property.');n=b(e);n&&(o.azureAsyncOperationHeaderValue=n),o.state=r.status,o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=c(e)})},_.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=!1;return"PUT"===r||"PATCH"===r?n=!0:e.locationHeaderValue&&(t=t.status,"POST"===r?n=200===t||201===t:"DELETE"===r&&(n=200===t||202===t)),n},_.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.locationHeaderValue,r=e.initialResponse,n=r.request,e=n.url;return t&&(n=n.method,r=r.status,("POST"!==n||200!==r&&201!==r&&202!==r)&&("DELETE"!==n||200!==r&&202!==r)||(e=t)),this.updateState(e,!0)},_.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return y(e.state,"Succeeded")||"POST"===t.request.method&&(200===r||201===r)},_);function _(){return null!==q&&q.apply(this,arguments)||this}var w,O=(t(T,w=i),T.prototype.sendPollRequest=function(){var o=this._pollState;return this.updateOperationStatus(o.initialResponse.request.url,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new a.RestError('Invalid status code with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=a.stripRequest(e.request),n.response=e,n.body=r,n}if(!e.parsedBody)throw new Error("The response from long running operation does not contain a body.");o.state=p(e.parsedBody)||"Succeeded",o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=c(e)})},T.prototype.isFinalStatusAcceptable=function(){return y(this._pollState.state,"Succeeded")},T.prototype.doFinalGetResourceRequest=function(){return this.sendPollRequest()},T);function T(){return null!==w&&w.apply(this,arguments)||this}var A=(E.prototype.getInitialResponse=function(){return this._initialResponse},E.prototype.getMostRecentResponse=function(){var e=this._lroPollStrategy;return e?e.getMostRecentResponse():this._initialResponse},E.prototype.isFinished=function(){var e=this._lroPollStrategy;return!e||e.isFinished()},E.prototype.isFinalStatusAcceptable=function(){var e,t=this._lroPollStrategy;return t?t.isFinished()&&(e=t.isFinalStatusAcceptable()):e=!0,e},E.prototype.getOperationStatus=function(){var e=this._lroPollStrategy;return e?e.getOperationStatus():"Succeeded"},E.prototype.getOperationResponse=function(){var e,t=this._lroPollStrategy;if(t)if(t.isFinished()){if(!t.isFinalStatusAcceptable())throw t.getRestError();e=t.getOperationResponse()}else e=Promise.resolve(void 0);else e=Promise.resolve(this._initialResponse);return e},E.prototype.poll=function(){var e=this._lroPollStrategy,t=e?e.sendPollRequest().then(function(){return e.getOperationStatus()}):Promise.resolve("Succeeded");return t},E.prototype.pollUntilFinished=function(){return r(this,void 0,void 0,function(){var t;return s(this,function(e){return t=this._lroPollStrategy,[2,t?t.pollUntilFinished().then(function(e){if(e)return t.getOperationResponse().then(z);throw t.getRestError()}):Promise.resolve(z(this._initialResponse))]})})},E.prototype.getPollState=function(){var e=this._lroPollStrategy;return e?e.getPollState():void 0},E);function E(e,t){this._lroPollStrategy=e,this._initialResponse=t}function C(e,t,r){r=function(e,t,r){var n,o=e.request.method,s=e.status;if(b(e))n="AzureAsyncOperation";else if(g(e))n="Location";else if("PUT"===o||"PATCH"===o)n="GetResource";else if(201!==s&&202!==s&&!f(d(e)))throw new Error("Can't determine long running operation polling strategy.");return n?(s=c(e),R(t,{pollStrategyType:n,options:r,initialResponse:e,mostRecentResponse:e,mostRecentRequest:e.request,azureAsyncOperationHeaderValue:b(e),locationHeaderValue:g(e),resource:s,state:d(e,s)})):void 0}(t,e,r);return new A(r,t)}function F(e,t){e=R(e,t);return new A(e,t.initialResponse)}function z(e){var t=e.request,r=t.operationResponseGetter,t=t.operationSpec;return a.flattenResponse(e,r&&t&&r(t,e))}var L,N="en-us",x="2.1.0",H=(t(D,L=a.ServiceClient),D.prototype.sendLRORequest=function(e,t,r){var n=this;return this.sendOperationRequest(e,t).then(function(e){return C(n,e._response,r)})},D.prototype.sendLongRunningRequest=function(e,t){return this.beginLongRunningRequest(e,t).then(function(e){return e.pollUntilFinished()}).then(function(e){return e._response})},D.prototype.beginLongRunningRequest=function(e,t){var r=this;return this.sendRequest(e).then(function(e){return C(r,e,t)})},D.prototype.restoreLROPoller=function(e){return F(this,e)},D);function D(e,t){var r=L.call(this,e,t=function(e){e=e||{};null==e.generateClientRequestIdHeader&&(e.generateClientRequestIdHeader=!0);e.userAgent||(e.userAgent=B());return e}(t))||this;r.acceptLanguage=N;e=null===e||void 0===e?void 0:e.environment;return e&&!r.baseUri&&(r.baseUri=e.resourceManagerEndpointUrl),null!=t.acceptLanguage&&(r.acceptLanguage=t.acceptLanguage),null!=t.longRunningOperationRetryTimeout&&(r.longRunningOperationRetryTimeout=t.longRunningOperationRetryTimeout),r}function B(){var e=a.getDefaultUserAgentValue();return"ms-rest-azure-js/"+x+" "+e}var G,i=(t(U,G=a.ApiKeyCredentials),U);function U(e){if(!e||e&&"string"!=typeof e.valueOf())throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");e={inHeader:{"Ocp-Apim-Subscription-Key":e,"X-BingApis-SDK-Client":"node-SDK"}};return G.call(this,e)||this}e.AzureServiceClient=H,e.BaseResourceMapper={serializedName:"BaseResource",type:{name:"Composite",className:"BaseResource",modelProperties:{}}},e.CloudErrorMapper={serializedName:"CloudError",type:{name:"Composite",className:"CloudError",modelProperties:{code:{required:!0,serializedName:"code",type:{name:"String"}},message:{required:!0,serializedName:"message",type:{name:"String"}},target:{serializedName:"target",type:{name:"String"}},details:{serializedName:"details",type:{name:"Sequence",element:{serializedName:"CloudErrorElementType",type:{name:"Composite",className:"CloudError"}}}},innerError:{required:!1,serializedName:"innererror",type:{name:"Object"}},additionalInfo:{required:!1,serializedName:"additionalInfo",type:{name:"Composite",className:"AdditionalInfoElement",modelProperties:{type:{required:!0,serializedName:"type",type:{name:"String"}},info:{required:!1,serializedName:"info",type:{name:"Object"}}}}}}}},e.CognitiveServicesCredentials=i,e.DEFAULT_LANGUAGE=N,e.LROPoller=A,e.createLROPollerFromInitialResponse=C,e.createLROPollerFromPollState=F,e.getDefaultUserAgentValue=B,e.msRestAzureVersion=x,Object.defineProperty(e,"__esModule",{value:!0})});
import { HttpOperationResponse, OperationArguments, OperationSpec, RequestOptionsBase, RequestPrepareOptions, ServiceClient, ServiceClientCredentials, ServiceClientOptions, WebResource } from "@azure/ms-rest-js";
import { TokenCredential } from "@azure/core-auth";
import { LROPoller } from "./lroPoller";

@@ -33,3 +34,3 @@ import { LROPollState } from "./lroPollStrategy";

longRunningOperationRetryTimeout?: number;
constructor(credentials: ServiceClientCredentials, options?: AzureServiceClientOptions);
constructor(credentials: ServiceClientCredentials | TokenCredential, options?: AzureServiceClientOptions);
/**

@@ -36,0 +37,0 @@ * Send the initial request of a LRO (long running operation) and get back an

@@ -19,2 +19,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

function AzureServiceClient(credentials, options) {
var _a;
var _this = _super.call(this, credentials, options = updateOptionsWithDefaultValues(options)) || this;

@@ -24,3 +25,3 @@ _this.acceptLanguage = Constants.DEFAULT_LANGUAGE;

// automatically use the baseUri from that environment.
var env = credentials.environment;
var env = (_a = credentials) === null || _a === void 0 ? void 0 : _a.environment;
if (env && !_this.baseUri) {

@@ -27,0 +28,0 @@ _this.baseUri = env.resourceManagerEndpointUrl;

@@ -20,3 +20,3 @@ /**

*/
export declare const msRestAzureVersion = "2.0.1";
export declare const msRestAzureVersion = "2.1.0";
//# sourceMappingURL=constants.d.ts.map

@@ -15,3 +15,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

*/
export var msRestAzureVersion = "2.0.1";
export var msRestAzureVersion = "2.1.0";
//# sourceMappingURL=constants.js.map

@@ -5,2 +5,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

import { HttpOperationResponse, OperationArguments, OperationSpec, RequestOptionsBase, RequestPrepareOptions, ServiceClient, ServiceClientCredentials, ServiceClientOptions, WebResource, getDefaultUserAgentValue as getDefaultUserAgentValueFromMsRest } from "@azure/ms-rest-js";
import { TokenCredential } from "@azure/core-auth";
import { createLROPollerFromInitialResponse, createLROPollerFromPollState, LROPoller } from "./lroPoller";

@@ -42,3 +43,3 @@ import { LROPollState } from "./lroPollStrategy";

constructor(credentials: ServiceClientCredentials, options?: AzureServiceClientOptions) {
constructor(credentials: ServiceClientCredentials | TokenCredential, options?: AzureServiceClientOptions) {
super(credentials, options = updateOptionsWithDefaultValues(options));

@@ -48,3 +49,3 @@

// automatically use the baseUri from that environment.
const env = (credentials as any).environment;
const env = (credentials as any)?.environment;
if (env && !this.baseUri) {

@@ -51,0 +52,0 @@ this.baseUri = env.resourceManagerEndpointUrl;

@@ -30,2 +30,2 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

*/
export const msRestAzureVersion = "2.0.1";
export const msRestAzureVersion = "2.1.0";

@@ -8,3 +8,3 @@ {

},
"version": "2.0.2",
"version": "2.1.0",
"description": "Isomorphic Azure client runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",

@@ -45,3 +45,4 @@ "tags": [

"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"@azure/core-auth": "^1.1.4",
"@azure/ms-rest-js": "^2.2.0",
"tslib": "^1.10.0"

@@ -48,0 +49,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc