@azure/ms-rest-azure-js
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -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.msRestAzure={},e.msRest)}(this,function(e,p){"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 s(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 t(s,i,a,u){return new(a||(a=Promise))(function(e,t){function r(e){try{o(u.next(e))}catch(e){t(e)}}function n(e){try{o(u.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(r,n)}o((u=u.apply(s,i||[])).next())})}function i(r,n){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"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 r=function(){function e(e,t){this._azureServiceClient=e,this._pollState=t}return e.prototype.getOperationStatus=function(){return this._pollState.state},e.prototype.isFinished=function(){return h(this._pollState.state)},e.prototype.pollUntilFinished=function(){return t(this,void 0,void 0,function(){var t;return i(this,function(e){switch(e.label){case 0:return this.isFinished()?[3,3]:(t=function(e,t){var r=30;if(null!=e.longRunningOperationRetryTimeout)r=e.longRunningOperationRetryTimeout;else{var n=t.headers.get("retry-after");if(n){var o=parseInt(n);Number.isNaN(o)||(r=o)}}return r}(this._azureServiceClient,this._pollState.mostRecentResponse),[4,p.delay(1e3*t)]);case 1:return e.sent(),[4,this.sendPollRequest()];case 2:return e.sent(),[3,0];case 3:return[2,this.isFinalStatusAcceptable()]}})})},e.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState.initialResponse.request.method;return!this._pollState.resource&&("PUT"===e||"PATCH"===e||"POST"===e)},e.prototype.getMostRecentResponse=function(){return this._pollState.mostRecentResponse},e.prototype.getOperationResponse=function(){return t(this,void 0,void 0,function(){var t,r,n;return i(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:return t=this._pollState.mostRecentResponse,r=o({},t,{headers:t.headers.clone()}),(n=this._pollState.resource)?"string"==typeof n.valueOf()?(r.bodyAsText=n,r.parsedBody=JSON.parse(n)):(r.bodyAsText=JSON.stringify(n),r.parsedBody=n):(r.bodyAsText=t.bodyAsText,r.parsedBody=t.parsedBody),[2,r]}})})},e.prototype.getRestError=function(){var e=new p.RestError("");if(e.request=p.stripRequest(this._pollState.mostRecentRequest),e.response=this._pollState.mostRecentResponse,e.message='Long running operation failed with status: "'+this._pollState.state+'".',e.body=this._pollState.resource,e.body){var t=e.body.error;t&&(t.message&&(e.message='Long running operation failed with error: "'+t.message+'".'),t.code&&(e.code=t.code))}return e},e.prototype.updateState=function(e,t){var n=this;return this.updateOperationStatus(e,t).then(function(t){n._pollState.state=a(t.parsedBody)||"Succeeded",n._pollState.mostRecentResponse=t,n._pollState.mostRecentRequest=t.request;try{n._pollState.resource=l(t)}catch(e){n._pollState.resource=void 0;var r=t.status;if("DELETE"!==n._pollState.initialResponse.request.method||r<400||499<r)throw e}})},e.prototype.updateOperationStatus=function(e,t){var r=e.replace(" ","%20"),n=new p.WebResource(r,"GET"),o=this._pollState;n.operationSpec=o.mostRecentRequest.operationSpec,n.shouldDeserialize=t,n.operationResponseGetter=c;var s=o.options;if(s&&s.customHeaders)for(var i=s.customHeaders,a=0,u=Object.keys(i);a<u.length;a++){var l=u[a];n.headers.set(l,i[l])}return this._azureServiceClient.sendRequest(n)},e.prototype.getPollState=function(){return this._pollState},e}();function c(e,t){var r=t.status,n=e.responses,o=n[r];return o||(200===r?o=n[201]||n[202]:201<=r&&r<=299&&(o={})),o}function a(e){var t;return e&&(e.provisioningState?t=e.provisioningState:e.properties&&(t=e.properties.provisioningState)),t}function l(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 p.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 u(e,t){var r;switch(null==t&&(t=l(e)),e.status){case 202:r="InProgress";break;case 204:r="Succeeded";break;case 201:r=a(t)||"InProgress";break;case 200:var n=a(t);r=n||(S(e)||R(e)?"InProgress":"Succeeded");break;default:r="Failed"}return r}var d=["Succeeded","Failed","Canceled","Cancelled"];function h(e){for(var t=!1,r=0,n=d;r<n.length;r++){if(f(e,n[r])){t=!0;break}}return t}function f(e,t){return(e&&e.toLowerCase())===(t&&t.toLowerCase())}function y(e,t){var r;switch(t.pollStrategyType){case"AzureAsyncOperation":r=new v(e,t);break;case"Location":r=new g(e,t);break;case"GetResource":r=new m(e,t);break;default:throw new Error('Unrecognized LRO poll strategy type: "'+t.pollStrategyType+'"')}return r}function R(e){return e.headers.get("location")}var g=function(o){function e(){return null!==o&&o.apply(this,arguments)||this}return s(e,o),e.prototype.locationStrategyShouldDeserialize=function(e){var t=!1,r=this._pollState.initialResponse.request.method,n=e.status;return 200!==n&&(201!==n||"PUT"!==r&&"PATCH"!==r)&&(204!==n||"DELETE"!==r&&"POST"!==r)||(t=!0),t},e.prototype.sendPollRequest=function(){var u=this._pollState;return this.updateOperationStatus(u.locationHeaderValue,this.locationStrategyShouldDeserialize.bind(this)).then(function(e){var t=R(e);t&&(u.locationHeaderValue=t),u.mostRecentResponse=e,u.mostRecentRequest=e.request;var r=u.initialResponse,n=r.request.method,o=r.status,s=e.status;if(202===s)u.state="InProgress";else if(200===s||201===s&&("PUT"===n||"PATCH"===n)||204===s&&("DELETE"===n||"POST"===n))u.state="Succeeded",u.resource=l(e);else{if(404!==s||"POST"!==n||200!==o&&201!==o&&202!==o){if(400<=s&&s<=499){var i=e.bodyAsText,a=i;try{a=JSON.parse(i).message}catch(e){}throw new p.RestError(a,void 0,s,p.stripRequest(e.request),e,i)}throw new Error("The response with status code "+s+' from polling for long running operation url "'+u.locationHeaderValue+'" is not valid.')}u.state="Failed",u.resource=l(e)}})},e.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return f(e.state,"Succeeded")||"POST"===t.request.method&&404===e.mostRecentResponse.status&&(200===r||201===r||202===r)},e.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=t.status;return("POST"!==r||404!==e.mostRecentResponse.status||200!==n&&201!==n&&202!==n)&&(o.prototype.shouldDoFinalGetResourceRequest.call(this)||"POST"===r&&201===n)},e.prototype.doFinalGetResourceRequest=function(){var e,t=this._pollState,r=t.initialResponse,n=r.status,o=r.request;return e="POST"!==o.method||200!==n&&201!==n&&202!==n?o.url:t.locationHeaderValue,this.updateState(e,!0)},e}(r);function S(e){return e.headers.get("azure-asyncoperation")}var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.sendPollRequest=function(){var s=this._pollState;return this.updateOperationStatus(s.azureAsyncOperationHeaderValue,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new p.RestError("Invalid status code ("+t+') with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=p.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.');var o=S(e);o&&(s.azureAsyncOperationHeaderValue=o),s.state=r.status,s.mostRecentResponse=e,s.mostRecentRequest=e.request,s.resource=l(e)})},t.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=!1;if("PUT"===r||"PATCH"===r)n=!0;else if(e.locationHeaderValue){var o=t.status;"POST"===r?n=200===o||201===o:"DELETE"===r&&(n=200===o||202===o)}return n},t.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.locationHeaderValue,r=e.initialResponse,n=r.request,o=n.url;if(t){var s=n.method,i=r.status;("POST"!==s||200!==i&&201!==i&&202!==i)&&("DELETE"!==s||200!==i&&202!==i)||(o=t)}return this.updateState(o,!0)},t.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return f(e.state,"Succeeded")||"POST"===t.request.method&&(200===r||201===r)},t}(r),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),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 p.RestError('Invalid status code with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=p.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=a(e.parsedBody)||"Succeeded",o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=l(e)})},t.prototype.isFinalStatusAcceptable=function(){return f(this._pollState.state,"Succeeded")},t.prototype.doFinalGetResourceRequest=function(){return this.sendPollRequest()},t}(r),b=function(){function e(e,t){this._lroPollStrategy=e,this._initialResponse=t}return 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;return e?e.sendPollRequest().then(function(){return e.getOperationStatus()}):Promise.resolve("Succeeded")},e.prototype.pollUntilFinished=function(){return t(this,void 0,void 0,function(){var t;return i(this,function(e){return t=this._lroPollStrategy,[2,t?t.pollUntilFinished().then(function(e){if(e)return t.getOperationResponse().then(_);throw t.getRestError()}):Promise.resolve(_(this._initialResponse))]})})},e.prototype.getPollState=function(){var e=this._lroPollStrategy;return e?e.getPollState():void 0},e}();function q(e,t,r){var n=function(e,t,r){var n,o,s=e.request.method,i=e.status;if(S(e))n="AzureAsyncOperation";else if(R(e))n="Location";else if("PUT"===s||"PATCH"===s)n="GetResource";else if(201!==i&&202!==i&&!h(u(e)))throw new Error("Can't determine long running operation polling strategy.");if(n){var a=l(e);o=y(t,{pollStrategyType:n,options:r,initialResponse:e,mostRecentResponse:e,mostRecentRequest:e.request,azureAsyncOperationHeaderValue:S(e),locationHeaderValue:R(e),resource:a,state:u(e,a)})}else o=void 0;return o}(t,e,r);return new b(n,t)}function _(e){var t=e.request,r=t.operationResponseGetter,n=t.operationSpec;return p.flattenResponse(e,r&&n&&r(n,e))}var w="en-us",O="0.1.0",P=function(o){function e(e,t){var r=o.call(this,e,t=function(e){e||(e={});null==e.generateClientRequestIdHeader&&(e.generateClientRequestIdHeader=!0);e.userAgent||(e.userAgent=T());return e}(t))||this;r.acceptLanguage=w;var n=e.environment;return n&&!r.baseUri&&(r.baseUri=n.resourceManagerEndpointUrl),null!=t.acceptLanguage&&(r.acceptLanguage=t.acceptLanguage),null!=t.longRunningOperationRetryTimeout&&(r.longRunningOperationRetryTimeout=t.longRunningOperationRetryTimeout),r}return s(e,o),e.prototype.sendLRORequest=function(e,t,r){var n=this;return this.sendOperationRequest(e,t).then(function(e){return q(n,e._response,r)})},e.prototype.sendLongRunningRequest=function(e,t){return this.beginLongRunningRequest(e,t).then(function(e){return e.pollUntilFinished()}).then(function(e){return e._response})},e.prototype.beginLongRunningRequest=function(e,t){var r=this;return this.sendRequest(e).then(function(e){return q(r,e,t)})},e.prototype.restoreLROPoller=function(e){return r=y(this,t=e),new b(r,t.initialResponse);var t,r},e}(p.ServiceClient);function T(){var e=p.getDefaultUserAgentValue();return"ms-rest-azure-js/"+O+" "+e}var A=function(r){function e(e){if(!e||e&&"string"!=typeof e.valueOf())throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");var t={inHeader:{"Ocp-Apim-Subscription-Key":e,"X-BingApis-SDK-Client":"node-SDK"}};return r.call(this,t)||this}return s(e,r),e}(p.ApiKeyCredentials);e.AzureServiceClient=P,e.getDefaultUserAgentValue=T,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=A,e.LROPoller=b,e.DEFAULT_LANGUAGE=w,e.msRestAzureVersion=O,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.msRestAzure={},e.msRest)}(this,function(e,p){"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 s(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 t(s,i,a,u){return new(a||(a=Promise))(function(e,t){function r(e){try{o(u.next(e))}catch(e){t(e)}}function n(e){try{o(u.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(r,n)}o((u=u.apply(s,i||[])).next())})}function i(r,n){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"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 r=function(){function e(e,t){this._azureServiceClient=e,this._pollState=t}return e.prototype.getOperationStatus=function(){return this._pollState.state},e.prototype.isFinished=function(){return f(this._pollState.state)},e.prototype.pollUntilFinished=function(){return t(this,void 0,void 0,function(){var t;return i(this,function(e){switch(e.label){case 0:return this.isFinished()?[3,3]:(t=function(e,t){var r=30;if(null!=e.longRunningOperationRetryTimeout)r=e.longRunningOperationRetryTimeout;else{var n=t.headers.get("retry-after");if(n){var o=parseInt(n);Number.isNaN(o)||(r=o)}}return r}(this._azureServiceClient,this._pollState.mostRecentResponse),[4,p.delay(1e3*t)]);case 1:return e.sent(),[4,this.sendPollRequest()];case 2:return e.sent(),[3,0];case 3:return[2,this.isFinalStatusAcceptable()]}})})},e.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState.initialResponse.request.method;return!this._pollState.resource&&("PUT"===e||"PATCH"===e||"POST"===e)},e.prototype.getMostRecentResponse=function(){return this._pollState.mostRecentResponse},e.prototype.getOperationResponse=function(){return t(this,void 0,void 0,function(){var t,r,n;return i(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:return t=this._pollState.mostRecentResponse,r=o({},t,{headers:t.headers.clone()}),(n=this._pollState.resource)?"string"==typeof n.valueOf()?(r.bodyAsText=n,r.parsedBody=JSON.parse(n)):(r.bodyAsText=JSON.stringify(n),r.parsedBody=n):(r.bodyAsText=t.bodyAsText,r.parsedBody=t.parsedBody),[2,r]}})})},e.prototype.getRestError=function(){var e=new p.RestError("");if(e.request=p.stripRequest(this._pollState.mostRecentRequest),e.response=this._pollState.mostRecentResponse,e.message='Long running operation failed with status: "'+this._pollState.state+'".',e.body=this._pollState.resource,e.body){var t=e.body.error;t&&(t.message&&(e.message='Long running operation failed with error: "'+t.message+'".'),t.code&&(e.code=t.code))}return e},e.prototype.updateState=function(e,t){var n=this;return this.updateOperationStatus(e,t).then(function(t){n._pollState.state=a(t.parsedBody)||"Succeeded",n._pollState.mostRecentResponse=t,n._pollState.mostRecentRequest=t.request;try{n._pollState.resource=l(t)}catch(e){n._pollState.resource=void 0;var r=t.status;if("DELETE"!==n._pollState.initialResponse.request.method||r<400||499<r)throw e}})},e.prototype.updateOperationStatus=function(e,t){var r=e.replace(" ","%20"),n=new p.WebResource(r,"GET"),o=this._pollState;n.operationSpec=o.mostRecentRequest.operationSpec,n.shouldDeserialize=t,n.operationResponseGetter=c;var s=o.options;if(s&&s.customHeaders)for(var i=s.customHeaders,a=0,u=Object.keys(i);a<u.length;a++){var l=u[a];n.headers.set(l,i[l])}return this._azureServiceClient.sendRequest(n)},e.prototype.getPollState=function(){return this._pollState},e}();function c(e,t){var r=t.status,n=e.responses,o=n[r];return o||(200===r?o=n[201]||n[202]:201<=r&&r<=299&&(o={})),o}function a(e){var t;return e&&(e.provisioningState?t=e.provisioningState:e.properties&&(t=e.properties.provisioningState)),t}function l(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 p.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 u(e,t){var r;switch(null==t&&(t=l(e)),e.status){case 202:r="InProgress";break;case 204:r="Succeeded";break;case 201:r=a(t)||"InProgress";break;case 200:var n=a(t);r=n||(S(e)||R(e)?"InProgress":"Succeeded");break;default:r="Failed"}return r}var d=["Succeeded","Failed","Canceled","Cancelled"];function f(e){for(var t=!1,r=0,n=d;r<n.length;r++){if(h(e,n[r])){t=!0;break}}return t}function h(e,t){return(e&&e.toLowerCase())===(t&&t.toLowerCase())}function y(e,t){var r;switch(t.pollStrategyType){case"AzureAsyncOperation":r=new v(e,t);break;case"Location":r=new g(e,t);break;case"GetResource":r=new m(e,t);break;default:throw new Error('Unrecognized LRO poll strategy type: "'+t.pollStrategyType+'"')}return r}function R(e){return e.headers.get("location")}var g=function(o){function e(){return null!==o&&o.apply(this,arguments)||this}return s(e,o),e.prototype.locationStrategyShouldDeserialize=function(e){var t=!1,r=this._pollState.initialResponse.request.method,n=e.status;return 200!==n&&(201!==n||"PUT"!==r&&"PATCH"!==r)&&(204!==n||"DELETE"!==r&&"POST"!==r)||(t=!0),t},e.prototype.sendPollRequest=function(){var u=this._pollState;return this.updateOperationStatus(u.locationHeaderValue,this.locationStrategyShouldDeserialize.bind(this)).then(function(e){var t=R(e);t&&(u.locationHeaderValue=t),u.mostRecentResponse=e,u.mostRecentRequest=e.request;var r=u.initialResponse,n=r.request.method,o=r.status,s=e.status;if(202===s)u.state="InProgress";else if(200===s||201===s&&("PUT"===n||"PATCH"===n)||204===s&&("DELETE"===n||"POST"===n))u.state="Succeeded",u.resource=l(e);else{if(404!==s||"POST"!==n||200!==o&&201!==o&&202!==o){if(400<=s&&s<=499){var i=e.bodyAsText,a=i;try{a=JSON.parse(i).message}catch(e){}throw new p.RestError(a,void 0,s,p.stripRequest(e.request),e,i)}throw new Error("The response with status code "+s+' from polling for long running operation url "'+u.locationHeaderValue+'" is not valid.')}u.state="Failed",u.resource=l(e)}})},e.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return h(e.state,"Succeeded")||"POST"===t.request.method&&404===e.mostRecentResponse.status&&(200===r||201===r||202===r)},e.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=t.status;return("POST"!==r||404!==e.mostRecentResponse.status||200!==n&&201!==n&&202!==n)&&(o.prototype.shouldDoFinalGetResourceRequest.call(this)||"POST"===r&&201===n)},e.prototype.doFinalGetResourceRequest=function(){var e,t=this._pollState,r=t.initialResponse,n=r.status,o=r.request;return e="POST"!==o.method||200!==n&&201!==n&&202!==n?o.url:t.locationHeaderValue,this.updateState(e,!0)},e}(r);function S(e){return e.headers.get("azure-asyncoperation")}var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.sendPollRequest=function(){var s=this._pollState;return this.updateOperationStatus(s.azureAsyncOperationHeaderValue,!1).then(function(e){var t=e.status,r=e.parsedBody;if(200!==t&&201!==t&&202!==t&&204!==t){var n=new p.RestError("Invalid status code ("+t+') with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=p.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.');var o=S(e);o&&(s.azureAsyncOperationHeaderValue=o),s.state=r.status,s.mostRecentResponse=e,s.mostRecentRequest=e.request,s.resource=l(e)})},t.prototype.shouldDoFinalGetResourceRequest=function(){var e=this._pollState,t=e.initialResponse,r=t.request.method,n=!1;if("PUT"===r||"PATCH"===r)n=!0;else if(e.locationHeaderValue){var o=t.status;"POST"===r?n=200===o||201===o:"DELETE"===r&&(n=200===o||202===o)}return n},t.prototype.doFinalGetResourceRequest=function(){var e=this._pollState,t=e.locationHeaderValue,r=e.initialResponse,n=r.request,o=n.url;if(t){var s=n.method,i=r.status;("POST"!==s||200!==i&&201!==i&&202!==i)&&("DELETE"!==s||200!==i&&202!==i)||(o=t)}return this.updateState(o,!0)},t.prototype.isFinalStatusAcceptable=function(){var e=this._pollState,t=e.initialResponse,r=t.status;return h(e.state,"Succeeded")||"POST"===t.request.method&&(200===r||201===r)},t}(r),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),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 p.RestError('Invalid status code with response body "'+e.bodyAsText+'" occurred when polling for operation status.');throw n.statusCode=t,n.request=p.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=a(e.parsedBody)||"Succeeded",o.mostRecentResponse=e,o.mostRecentRequest=e.request,o.resource=l(e)})},t.prototype.isFinalStatusAcceptable=function(){return h(this._pollState.state,"Succeeded")},t.prototype.doFinalGetResourceRequest=function(){return this.sendPollRequest()},t}(r),b=function(){function e(e,t){this._lroPollStrategy=e,this._initialResponse=t}return 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;return e?e.sendPollRequest().then(function(){return e.getOperationStatus()}):Promise.resolve("Succeeded")},e.prototype.pollUntilFinished=function(){return t(this,void 0,void 0,function(){var t;return i(this,function(e){return t=this._lroPollStrategy,[2,t?t.pollUntilFinished().then(function(e){if(e)return t.getOperationResponse().then(_);throw t.getRestError()}):Promise.resolve(_(this._initialResponse))]})})},e.prototype.getPollState=function(){var e=this._lroPollStrategy;return e?e.getPollState():void 0},e}();function q(e,t,r){var n=function(e,t,r){var n,o,s=e.request.method,i=e.status;if(S(e))n="AzureAsyncOperation";else if(R(e))n="Location";else if("PUT"===s||"PATCH"===s)n="GetResource";else if(201!==i&&202!==i&&!f(u(e)))throw new Error("Can't determine long running operation polling strategy.");if(n){var a=l(e);o=y(t,{pollStrategyType:n,options:r,initialResponse:e,mostRecentResponse:e,mostRecentRequest:e.request,azureAsyncOperationHeaderValue:S(e),locationHeaderValue:R(e),resource:a,state:u(e,a)})}else o=void 0;return o}(t,e,r);return new b(n,t)}function _(e){var t=e.request,r=t.operationResponseGetter,n=t.operationSpec;return p.flattenResponse(e,r&&n&&r(n,e))}var w="en-us",O="0.1.0",P=function(o){function e(e,t){var r=o.call(this,e,t=function(e){e||(e={});null==e.generateClientRequestIdHeader&&(e.generateClientRequestIdHeader=!0);e.userAgent||(e.userAgent=T());return e}(t))||this;r.acceptLanguage=w;var n=e.environment;return n&&!r.baseUri&&(r.baseUri=n.resourceManagerEndpointUrl),null!=t.acceptLanguage&&(r.acceptLanguage=t.acceptLanguage),null!=t.longRunningOperationRetryTimeout&&(r.longRunningOperationRetryTimeout=t.longRunningOperationRetryTimeout),r}return s(e,o),e.prototype.sendLRORequest=function(e,t,r){var n=this;return this.sendOperationRequest(e,t).then(function(e){return q(n,e._response,r)})},e.prototype.sendLongRunningRequest=function(e,t){return this.beginLongRunningRequest(e,t).then(function(e){return e.pollUntilFinished()}).then(function(e){return e._response})},e.prototype.beginLongRunningRequest=function(e,t){var r=this;return this.sendRequest(e).then(function(e){return q(r,e,t)})},e.prototype.restoreLROPoller=function(e){return function(e,t){var r=y(e,t);return new b(r,t.initialResponse)}(this,e)},e}(p.ServiceClient);function T(){var e=p.getDefaultUserAgentValue();return"ms-rest-azure-js/"+O+" "+e}var A=function(r){function e(e){if(!e||e&&"string"!=typeof e.valueOf())throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");var t={inHeader:{"Ocp-Apim-Subscription-Key":e,"X-BingApis-SDK-Client":"node-SDK"}};return r.call(this,t)||this}return s(e,r),e}(p.ApiKeyCredentials);e.AzureServiceClient=P,e.getDefaultUserAgentValue=T,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=A,e.LROPoller=b,e.DEFAULT_LANGUAGE=w,e.msRestAzureVersion=O,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Isomorphic Azure client runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest", | ||
@@ -45,3 +45,3 @@ "tags": [ | ||
"dependencies": { | ||
"@azure/ms-rest-js": "^1.2.5", | ||
"@azure/ms-rest-js": "^1.8.1", | ||
"tslib": "^1.9.2" | ||
@@ -48,0 +48,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
304721
1
Updated@azure/ms-rest-js@^1.8.1