diff --git a/.gitignore b/.gitignore index 4fb02ad91..d976e8c53 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ tmp node_modules typings src/**/*.js +src/**/*.js.map +src/**/*.d.ts coverage **/*.tgz samples/node/secrets.json @@ -17,7 +19,6 @@ samples/typescript/graph-typings.d.ts samples/typescript/sample.js.map src/index.d.ts -spec/types/secrets* -spec/types/*.js -spec/types/*.d.ts -spec/types/*.js.map \ No newline at end of file +spec/**/*.js +spec/**/*.d.ts +spec/**/*.js.map diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..73067b3e9 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,3 @@ +{ + "esnext": "true" +} \ No newline at end of file diff --git a/browser-wrapper.js b/browser-wrapper.js index b7b5c5e58..8ec5c12e1 100644 --- a/browser-wrapper.js +++ b/browser-wrapper.js @@ -1,3 +1,3 @@ // make MicrosoftGraph globally accessible // MicrosoftGraph.api() can be called directly -window.MicrosoftGraph = require('./lib/src/index.js'); \ No newline at end of file +window.MicrosoftGraph = require('./lib/src/index.js'); diff --git a/lib/graph-js-sdk-core.js b/lib/graph-js-sdk-core.js index 104fd9b0a..635241ae9 100644 --- a/lib/graph-js-sdk-core.js +++ b/lib/graph-js-sdk-core.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i1&&typeof propertyValue==="string"){allValues=Array.prototype.slice.call(additionalProperties)}this.urlComponents.oDataQueryParams[propertyName]+=allValues.join(",")};GraphRequest.prototype.delete=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.DELETE,headers:new Headers}),callback)};GraphRequest.prototype.patch=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PATCH,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.post=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.POST,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers(content.constructor!==undefined&&content.constructor.name==="FormData"?{}:{"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.put=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PUT,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/octet-stream"})}),callback)};GraphRequest.prototype.create=function(content,callback){return this.post(content,callback)};GraphRequest.prototype.update=function(content,callback){return this.patch(content,callback)};GraphRequest.prototype.del=function(callback){return this.delete(callback)};GraphRequest.prototype.get=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.GET,headers:new Headers}),callback)};GraphRequest.prototype.routeResponseToPromise=function(request){var _this=this;return new es6_promise_1.Promise(function(resolve,reject){_this.routeResponseToCallback(request,function(err,body){if(err!=null){reject(err)}else{resolve(body)}})})};GraphRequest.prototype.handleFetch=function(request,callback,options){var _this=this;(request.constructor.name==="Request"?fetch(request):fetch(request,options)).then(function(response){_this.convertResponseType(response).then(function(responseValue){ResponseHandler_1.ResponseHandler.init(response,undefined,responseValue,callback)}).catch(function(error){ResponseHandler_1.ResponseHandler.init(response,error,undefined,callback)})}).catch(function(error){ResponseHandler_1.ResponseHandler.init(undefined,error,undefined,callback)})};GraphRequest.prototype.routeResponseToCallback=function(request,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err==null&&accessToken!=null){request=self.configureRequest(request,accessToken);self.handleFetch(request,callback)}else{callback(err,null,null)}})};GraphRequest.prototype.sendRequestAndRouteResponse=function(request,callback){if(callback==null&&typeof es6_promise_1.Promise!=="undefined"){return this.routeResponseToPromise(request)}else{this.routeResponseToCallback(request,callback||function(){})}};GraphRequest.prototype.getStream=function(callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_1={method:RequestMethod_1.RequestMethod.GET,headers:self.getDefaultRequestHeaders(accessToken)};self.responseType(ResponseType_1.ResponseType.STREAM);Object.keys(self._headers).forEach(function(key){return options_1.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_1)}else{callback(err,null)}})};GraphRequest.prototype.putStream=function(stream,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_2={method:RequestMethod_1.RequestMethod.PUT,headers:{"Content-Type":"application/octet-stream"},body:stream};var defaultHeaders_1=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders_1).forEach(function(key){return options_2.headers[key]=defaultHeaders_1[key]});Object.keys(self._headers).forEach(function(key){return options_2.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_2)}})};GraphRequest.prototype.getDefaultRequestHeaders=function(accessToken){return{Authorization:"Bearer "+accessToken,SdkVersion:"graph-js-"+common_1.PACKAGE_VERSION}};GraphRequest.prototype.configureRequest=function(request,accessToken){var self=this,defaultHeaders=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders).forEach(function(key){return request.headers.set(key,defaultHeaders[key])});Object.keys(self._headers).forEach(function(key){return request.headers.set(key,self._headers[key])});return request};GraphRequest.prototype.query=function(queryDictionaryOrString){if(typeof queryDictionaryOrString==="string"){var queryStr=queryDictionaryOrString;var queryKey=queryStr.split("=")[0];var queryValue=queryStr.split("=")[1];this.urlComponents.otherURLQueryParams[queryKey]=queryValue}else{for(var key in queryDictionaryOrString){this.urlComponents.otherURLQueryParams[key]=queryDictionaryOrString[key]}}return this};GraphRequest.prototype.createQueryString=function(){var q=[];if(Object.keys(this.urlComponents.oDataQueryParams).length!=0){for(var property in this.urlComponents.oDataQueryParams){q.push(property+"="+this.urlComponents.oDataQueryParams[property])}}if(Object.keys(this.urlComponents.otherURLQueryParams).length!=0){for(var property in this.urlComponents.otherURLQueryParams){q.push(property+"="+this.urlComponents.otherURLQueryParams[property])}}if(q.length>0){return"?"+q.join("&")}return""};GraphRequest.prototype.convertResponseType=function(response){var responseValue;if(!this._responseType){this._responseType=""}switch(this._responseType.toLowerCase()){case ResponseType_1.ResponseType.ARRAYBUFFER:responseValue=response.arrayBuffer();break;case ResponseType_1.ResponseType.BLOB:responseValue=response.blob();break;case ResponseType_1.ResponseType.DOCUMENT:responseValue=response.json();break;case ResponseType_1.ResponseType.JSON:responseValue=response.json();break;case ResponseType_1.ResponseType.STREAM:responseValue=es6_promise_1.Promise.resolve(response.body);break;case ResponseType_1.ResponseType.TEXT:responseValue=response.text();break;default:responseValue=response.json();break}return responseValue};return GraphRequest}();exports.GraphRequest=GraphRequest},{"./GraphHelper":2,"./RequestMethod":4,"./ResponseHandler":5,"./ResponseType":6,"./common":7,"es6-promise":"es6-promise","isomorphic-fetch":"isomorphic-fetch"}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var RequestMethod;(function(RequestMethod){RequestMethod["GET"]="GET";RequestMethod["PATCH"]="PATCH";RequestMethod["POST"]="POST";RequestMethod["PUT"]="PUT";RequestMethod["DELETE"]="DELETE"})(RequestMethod=exports.RequestMethod||(exports.RequestMethod={}))},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseHandler=function(){function ResponseHandler(){}ResponseHandler.init=function(res,err,resContents,callback){if(res&&res.ok){callback(null,resContents,res)}else{if(err==null&&res!=null)if(resContents!=null&&resContents.error!=null)callback(ResponseHandler.buildGraphErrorFromResponseObject(resContents.error,res.status),null,res);else callback(ResponseHandler.defaultGraphError(res.status),null,res);else callback(ResponseHandler.ParseError(err),null,res)}};ResponseHandler.ParseError=function(rawErr){if(!rawErr){return ResponseHandler.defaultGraphError(-1)}return ResponseHandler.buildGraphErrorFromErrorObject(rawErr)};ResponseHandler.defaultGraphError=function(statusCode){return{statusCode:statusCode,code:null,message:null,requestId:null,date:new Date,body:null}};ResponseHandler.buildGraphErrorFromErrorObject=function(errObj){var error=ResponseHandler.defaultGraphError(-1);error.body=errObj.toString();error.message=errObj.message;error.date=new Date;return error};ResponseHandler.buildGraphErrorFromResponseObject=function(errObj,statusCode){return{statusCode:statusCode,code:errObj.code,message:errObj.message,requestId:errObj.innerError!==undefined?errObj.innerError["request-id"]:"",date:errObj.innerError!==undefined?new Date(errObj.innerError.date):new Date,body:errObj}};return ResponseHandler}();exports.ResponseHandler=ResponseHandler},{}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseType;(function(ResponseType){ResponseType["ARRAYBUFFER"]="arraybuffer";ResponseType["BLOB"]="blob";ResponseType["DOCUMENT"]="document";ResponseType["JSON"]="json";ResponseType["STREAM"]="stream";ResponseType["TEXT"]="text"})(ResponseType=exports.ResponseType||(exports.ResponseType={}))},{}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.oDataQueryNames=["select","expand","orderby","filter","top","skip","skipToken","count"];exports.DEFAULT_VERSION="v1.0";exports.GRAPH_BASE_URL="https://graph.microsoft.com/";exports.PACKAGE_VERSION="1.2.0";exports.oDataQueryNames=exports.oDataQueryNames.concat(exports.oDataQueryNames.map(function(s){return"$"+s}))},{}],8:[function(require,module,exports){"use strict";function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});var common_1=require("./common");var GraphRequest_1=require("./GraphRequest");var Client=function(){function Client(){this.config={debugLogging:false,defaultVersion:common_1.DEFAULT_VERSION,baseUrl:common_1.GRAPH_BASE_URL}}Client.init=function(clientOptions){var graphClient=new Client;for(var key in clientOptions){graphClient.config[key]=clientOptions[key]}return graphClient};Client.prototype.api=function(path){return new GraphRequest_1.GraphRequest(this.config,path)};return Client}();exports.Client=Client;__export(require("./GraphRequest"));__export(require("./common"));__export(require("./ResponseHandler"));__export(require("./ResponseType"))},{"./GraphRequest":3,"./ResponseHandler":5,"./ResponseType":6,"./common":7}],9:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],10:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":9,ieee754:11,isarray:12}],11:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],12:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}]},{},[1]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i1&&typeof propertyValue==="string"){allValues=Array.prototype.slice.call(additionalProperties)}this.urlComponents.oDataQueryParams[propertyName]+=allValues.join(",")};GraphRequest.prototype.delete=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.DELETE,headers:new Headers}),callback)};GraphRequest.prototype.patch=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PATCH,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.post=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.POST,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers(content.constructor!==undefined&&content.constructor.name==="FormData"?{}:{"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.put=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PUT,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/octet-stream"})}),callback)};GraphRequest.prototype.create=function(content,callback){return this.post(content,callback)};GraphRequest.prototype.update=function(content,callback){return this.patch(content,callback)};GraphRequest.prototype.del=function(callback){return this.delete(callback)};GraphRequest.prototype.get=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.GET,headers:new Headers}),callback)};GraphRequest.prototype.routeResponseToPromise=function(request){var _this=this;return new es6_promise_1.Promise(function(resolve,reject){_this.routeResponseToCallback(request,function(err,body){if(err!=null){reject(err)}else{resolve(body)}})})};GraphRequest.prototype.handleFetch=function(request,callback,options){var _this=this;(request.constructor.name==="Request"?fetch(request):fetch(request,options)).then(function(response){_this.convertResponseType(response).then(function(responseValue){ResponseHandler_1.ResponseHandler.init(response,undefined,responseValue,callback)}).catch(function(error){ResponseHandler_1.ResponseHandler.init(response,error,undefined,callback)})}).catch(function(error){ResponseHandler_1.ResponseHandler.init(undefined,error,undefined,callback)})};GraphRequest.prototype.routeResponseToCallback=function(request,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err==null&&accessToken!=null){request=self.configureRequest(request,accessToken);self.handleFetch(request,callback)}else{callback(err,null,null)}})};GraphRequest.prototype.sendRequestAndRouteResponse=function(request,callback){if(callback==null&&typeof es6_promise_1.Promise!=="undefined"){return this.routeResponseToPromise(request)}else{this.routeResponseToCallback(request,callback||function(){})}};GraphRequest.prototype.getStream=function(callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_1={method:RequestMethod_1.RequestMethod.GET,headers:self.getDefaultRequestHeaders(accessToken)};self.responseType(ResponseType_1.ResponseType.STREAM);Object.keys(self._headers).forEach(function(key){return options_1.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_1)}else{callback(err,null)}})};GraphRequest.prototype.putStream=function(stream,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_2={method:RequestMethod_1.RequestMethod.PUT,headers:{"Content-Type":"application/octet-stream"},body:stream};var defaultHeaders_1=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders_1).forEach(function(key){return options_2.headers[key]=defaultHeaders_1[key]});Object.keys(self._headers).forEach(function(key){return options_2.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_2)}})};GraphRequest.prototype.getDefaultRequestHeaders=function(accessToken){return{Authorization:"Bearer "+accessToken,SdkVersion:"graph-js-"+common_1.PACKAGE_VERSION}};GraphRequest.prototype.configureRequest=function(request,accessToken){var self=this,defaultHeaders=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders).forEach(function(key){return request.headers.set(key,defaultHeaders[key])});Object.keys(self._headers).forEach(function(key){return request.headers.set(key,self._headers[key])});return request};GraphRequest.prototype.query=function(queryDictionaryOrString){if(typeof queryDictionaryOrString==="string"){var queryStr=queryDictionaryOrString;var queryKey=queryStr.split("=")[0];var queryValue=queryStr.split("=")[1];this.urlComponents.otherURLQueryParams[queryKey]=queryValue}else{for(var key in queryDictionaryOrString){this.urlComponents.otherURLQueryParams[key]=queryDictionaryOrString[key]}}return this};GraphRequest.prototype.createQueryString=function(){var q=[];if(Object.keys(this.urlComponents.oDataQueryParams).length!=0){for(var property in this.urlComponents.oDataQueryParams){q.push(property+"="+this.urlComponents.oDataQueryParams[property])}}if(Object.keys(this.urlComponents.otherURLQueryParams).length!=0){for(var property in this.urlComponents.otherURLQueryParams){q.push(property+"="+this.urlComponents.otherURLQueryParams[property])}}if(q.length>0){return"?"+q.join("&")}return""};GraphRequest.prototype.convertResponseType=function(response){var responseValue;if(!this._responseType){this._responseType=""}switch(this._responseType.toLowerCase()){case ResponseType_1.ResponseType.ARRAYBUFFER:responseValue=response.arrayBuffer();break;case ResponseType_1.ResponseType.BLOB:responseValue=response.blob();break;case ResponseType_1.ResponseType.DOCUMENT:responseValue=response.json();break;case ResponseType_1.ResponseType.JSON:responseValue=response.json();break;case ResponseType_1.ResponseType.STREAM:responseValue=es6_promise_1.Promise.resolve(response.body);break;case ResponseType_1.ResponseType.TEXT:responseValue=response.text();break;default:responseValue=response.json();break}return responseValue};return GraphRequest}();exports.GraphRequest=GraphRequest},{"./GraphHelper":2,"./RequestMethod":8,"./ResponseHandler":9,"./ResponseType":10,"./common":11,"es6-promise":"es6-promise","isomorphic-fetch":"isomorphic-fetch"}],4:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]=self.file.size){maxValue=self.file.size-1}return new Range_1.Range(minVal,maxValue)};LargeFileUploadTask.prototype.sliceFile=function(range){var blob=this.file.content.slice(range.minValue,range.maxValue+1);return blob};LargeFileUploadTask.prototype.upload=function(){return __awaiter(this,void 0,void 0,function(){var self,nextRange,err,fileSlice,response,err_1;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,5,,6]);_a.label=2;case 2:if(!true)return[3,4];nextRange=self.getNextRange();if(nextRange.maxValue===-1){err=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");err.name="Invalid Session";throw err}fileSlice=self.sliceFile(nextRange);return[4,self.uploadSlice(fileSlice,nextRange,self.file.size)];case 3:response=_a.sent();if(response.id!==undefined){return[2,response]}else{self.updateTaskStatus(response)}return[3,2];case 4:return[3,6];case 5:err_1=_a.sent();throw err_1;case 6:return[2]}})})};LargeFileUploadTask.prototype.uploadSlice=function(fileSlice,range,totalSize){return __awaiter(this,void 0,void 0,function(){var self,err_2;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).headers({"Content-Length":""+(range.maxValue-range.minValue+1),"Content-Range":"bytes "+range.minValue+"-"+range.maxValue+"/"+totalSize}).put(fileSlice)];case 2:return[2,_a.sent()];case 3:err_2=_a.sent();throw err_2;case 4:return[2]}})})};LargeFileUploadTask.prototype.cancel=function(){return __awaiter(this,void 0,void 0,function(){var self,err_3;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).delete()];case 2:return[2,_a.sent()];case 3:err_3=_a.sent();throw err_3;case 4:return[2]}})})};LargeFileUploadTask.prototype.getStatus=function(){return __awaiter(this,void 0,void 0,function(){var self,response,err_4;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).get()];case 2:response=_a.sent();self.updateTaskStatus(response);return[2,response];case 3:err_4=_a.sent();throw err_4;case 4:return[2]}})})};LargeFileUploadTask.prototype.resume=function(){return __awaiter(this,void 0,void 0,function(){var self,err_5;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,4,,5]);return[4,self.getStatus()];case 2:_a.sent();return[4,self.upload()];case 3:return[2,_a.sent()];case 4:err_5=_a.sent();throw err_5;case 5:return[2]}})})};return LargeFileUploadTask}();exports.LargeFileUploadTask=LargeFileUploadTask},{"./Range":7}],5:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]320*1024){value=Math.floor(value/(320*1024))*320*1024}return value};exports.getValidRangeSize=function(rangeSize){if(rangeSize===void 0){rangeSize=DEFAULT_FILE_SIZE}var sixtyMB=60*1024*1024;if(rangeSize>sixtyMB){rangeSize=sixtyMB}return roundTo320KB(rangeSize)}},{}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Range=function(){function Range(minVal,maxVal){if(minVal===void 0){minVal=-1}if(maxVal===void 0){maxVal=-1}var self=this;self.minValue=minVal;self.maxValue=maxVal}return Range}();exports.Range=Range},{}],8:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var RequestMethod;(function(RequestMethod){RequestMethod["GET"]="GET";RequestMethod["PATCH"]="PATCH";RequestMethod["POST"]="POST";RequestMethod["PUT"]="PUT";RequestMethod["DELETE"]="DELETE"})(RequestMethod=exports.RequestMethod||(exports.RequestMethod={}))},{}],9:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseHandler=function(){function ResponseHandler(){}ResponseHandler.init=function(res,err,resContents,callback){if(res&&res.ok){callback(null,resContents,res)}else{if(err==null&&res!=null)if(resContents!=null&&resContents.error!=null)callback(ResponseHandler.buildGraphErrorFromResponseObject(resContents.error,res.status),null,res);else callback(ResponseHandler.defaultGraphError(res.status),null,res);else callback(ResponseHandler.ParseError(err),null,res)}};ResponseHandler.ParseError=function(rawErr){if(!rawErr){return ResponseHandler.defaultGraphError(-1)}return ResponseHandler.buildGraphErrorFromErrorObject(rawErr)};ResponseHandler.defaultGraphError=function(statusCode){return{statusCode:statusCode,code:null,message:null,requestId:null,date:new Date,body:null}};ResponseHandler.buildGraphErrorFromErrorObject=function(errObj){var error=ResponseHandler.defaultGraphError(-1);error.body=errObj.toString();error.message=errObj.message;error.date=new Date;return error};ResponseHandler.buildGraphErrorFromResponseObject=function(errObj,statusCode){return{statusCode:statusCode,code:errObj.code,message:errObj.message,requestId:errObj.innerError!==undefined?errObj.innerError["request-id"]:"",date:errObj.innerError!==undefined?new Date(errObj.innerError.date):new Date,body:errObj}};return ResponseHandler}();exports.ResponseHandler=ResponseHandler},{}],10:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseType;(function(ResponseType){ResponseType["ARRAYBUFFER"]="arraybuffer";ResponseType["BLOB"]="blob";ResponseType["DOCUMENT"]="document";ResponseType["JSON"]="json";ResponseType["STREAM"]="stream";ResponseType["TEXT"]="text"})(ResponseType=exports.ResponseType||(exports.ResponseType={}))},{}],11:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.oDataQueryNames=["select","expand","orderby","filter","top","skip","skipToken","count"];exports.DEFAULT_VERSION="v1.0";exports.GRAPH_BASE_URL="https://graph.microsoft.com/";exports.PACKAGE_VERSION="1.2.0";exports.oDataQueryNames=exports.oDataQueryNames.concat(exports.oDataQueryNames.map(function(s){return"$"+s}))},{}],12:[function(require,module,exports){"use strict";function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});var common_1=require("./common");var GraphRequest_1=require("./GraphRequest");var Client=function(){function Client(){this.config={debugLogging:false,defaultVersion:common_1.DEFAULT_VERSION,baseUrl:common_1.GRAPH_BASE_URL}}Client.init=function(clientOptions){var graphClient=new Client;for(var key in clientOptions){graphClient.config[key]=clientOptions[key]}return graphClient};Client.prototype.api=function(path){return new GraphRequest_1.GraphRequest(this.config,path)};return Client}();exports.Client=Client;__export(require("./GraphRequest"));__export(require("./common"));__export(require("./ResponseHandler"));__export(require("./OneDriveLargeFileUploadTask"));__export(require("./ResponseType"))},{"./GraphRequest":3,"./OneDriveLargeFileUploadTask":5,"./ResponseHandler":9,"./ResponseType":10,"./common":11}],13:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],14:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":13,ieee754:15,isarray:16}],15:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],16:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}]},{},[1]); \ No newline at end of file diff --git a/lib/graph-js-sdk-web.js b/lib/graph-js-sdk-web.js index 283f599c4..b9127c2c0 100644 --- a/lib/graph-js-sdk-web.js +++ b/lib/graph-js-sdk-web.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i1&&typeof propertyValue==="string"){allValues=Array.prototype.slice.call(additionalProperties)}this.urlComponents.oDataQueryParams[propertyName]+=allValues.join(",")};GraphRequest.prototype.delete=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.DELETE,headers:new Headers}),callback)};GraphRequest.prototype.patch=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PATCH,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.post=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.POST,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers(content.constructor!==undefined&&content.constructor.name==="FormData"?{}:{"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.put=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PUT,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/octet-stream"})}),callback)};GraphRequest.prototype.create=function(content,callback){return this.post(content,callback)};GraphRequest.prototype.update=function(content,callback){return this.patch(content,callback)};GraphRequest.prototype.del=function(callback){return this.delete(callback)};GraphRequest.prototype.get=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.GET,headers:new Headers}),callback)};GraphRequest.prototype.routeResponseToPromise=function(request){var _this=this;return new es6_promise_1.Promise(function(resolve,reject){_this.routeResponseToCallback(request,function(err,body){if(err!=null){reject(err)}else{resolve(body)}})})};GraphRequest.prototype.handleFetch=function(request,callback,options){var _this=this;(request.constructor.name==="Request"?fetch(request):fetch(request,options)).then(function(response){_this.convertResponseType(response).then(function(responseValue){ResponseHandler_1.ResponseHandler.init(response,undefined,responseValue,callback)}).catch(function(error){ResponseHandler_1.ResponseHandler.init(response,error,undefined,callback)})}).catch(function(error){ResponseHandler_1.ResponseHandler.init(undefined,error,undefined,callback)})};GraphRequest.prototype.routeResponseToCallback=function(request,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err==null&&accessToken!=null){request=self.configureRequest(request,accessToken);self.handleFetch(request,callback)}else{callback(err,null,null)}})};GraphRequest.prototype.sendRequestAndRouteResponse=function(request,callback){if(callback==null&&typeof es6_promise_1.Promise!=="undefined"){return this.routeResponseToPromise(request)}else{this.routeResponseToCallback(request,callback||function(){})}};GraphRequest.prototype.getStream=function(callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_1={method:RequestMethod_1.RequestMethod.GET,headers:self.getDefaultRequestHeaders(accessToken)};self.responseType(ResponseType_1.ResponseType.STREAM);Object.keys(self._headers).forEach(function(key){return options_1.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_1)}else{callback(err,null)}})};GraphRequest.prototype.putStream=function(stream,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_2={method:RequestMethod_1.RequestMethod.PUT,headers:{"Content-Type":"application/octet-stream"},body:stream};var defaultHeaders_1=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders_1).forEach(function(key){return options_2.headers[key]=defaultHeaders_1[key]});Object.keys(self._headers).forEach(function(key){return options_2.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_2)}})};GraphRequest.prototype.getDefaultRequestHeaders=function(accessToken){return{Authorization:"Bearer "+accessToken,SdkVersion:"graph-js-"+common_1.PACKAGE_VERSION}};GraphRequest.prototype.configureRequest=function(request,accessToken){var self=this,defaultHeaders=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders).forEach(function(key){return request.headers.set(key,defaultHeaders[key])});Object.keys(self._headers).forEach(function(key){return request.headers.set(key,self._headers[key])});return request};GraphRequest.prototype.query=function(queryDictionaryOrString){if(typeof queryDictionaryOrString==="string"){var queryStr=queryDictionaryOrString;var queryKey=queryStr.split("=")[0];var queryValue=queryStr.split("=")[1];this.urlComponents.otherURLQueryParams[queryKey]=queryValue}else{for(var key in queryDictionaryOrString){this.urlComponents.otherURLQueryParams[key]=queryDictionaryOrString[key]}}return this};GraphRequest.prototype.createQueryString=function(){var q=[];if(Object.keys(this.urlComponents.oDataQueryParams).length!=0){for(var property in this.urlComponents.oDataQueryParams){q.push(property+"="+this.urlComponents.oDataQueryParams[property])}}if(Object.keys(this.urlComponents.otherURLQueryParams).length!=0){for(var property in this.urlComponents.otherURLQueryParams){q.push(property+"="+this.urlComponents.otherURLQueryParams[property])}}if(q.length>0){return"?"+q.join("&")}return""};GraphRequest.prototype.convertResponseType=function(response){var responseValue;if(!this._responseType){this._responseType=""}switch(this._responseType.toLowerCase()){case ResponseType_1.ResponseType.ARRAYBUFFER:responseValue=response.arrayBuffer();break;case ResponseType_1.ResponseType.BLOB:responseValue=response.blob();break;case ResponseType_1.ResponseType.DOCUMENT:responseValue=response.json();break;case ResponseType_1.ResponseType.JSON:responseValue=response.json();break;case ResponseType_1.ResponseType.STREAM:responseValue=es6_promise_1.Promise.resolve(response.body);break;case ResponseType_1.ResponseType.TEXT:responseValue=response.text();break;default:responseValue=response.json();break}return responseValue};return GraphRequest}();exports.GraphRequest=GraphRequest},{"./GraphHelper":2,"./RequestMethod":4,"./ResponseHandler":5,"./ResponseType":6,"./common":7,"es6-promise":11,"isomorphic-fetch":14}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var RequestMethod;(function(RequestMethod){RequestMethod["GET"]="GET";RequestMethod["PATCH"]="PATCH";RequestMethod["POST"]="POST";RequestMethod["PUT"]="PUT";RequestMethod["DELETE"]="DELETE"})(RequestMethod=exports.RequestMethod||(exports.RequestMethod={}))},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseHandler=function(){function ResponseHandler(){}ResponseHandler.init=function(res,err,resContents,callback){if(res&&res.ok){callback(null,resContents,res)}else{if(err==null&&res!=null)if(resContents!=null&&resContents.error!=null)callback(ResponseHandler.buildGraphErrorFromResponseObject(resContents.error,res.status),null,res);else callback(ResponseHandler.defaultGraphError(res.status),null,res);else callback(ResponseHandler.ParseError(err),null,res)}};ResponseHandler.ParseError=function(rawErr){if(!rawErr){return ResponseHandler.defaultGraphError(-1)}return ResponseHandler.buildGraphErrorFromErrorObject(rawErr)};ResponseHandler.defaultGraphError=function(statusCode){return{statusCode:statusCode,code:null,message:null,requestId:null,date:new Date,body:null}};ResponseHandler.buildGraphErrorFromErrorObject=function(errObj){var error=ResponseHandler.defaultGraphError(-1);error.body=errObj.toString();error.message=errObj.message;error.date=new Date;return error};ResponseHandler.buildGraphErrorFromResponseObject=function(errObj,statusCode){return{statusCode:statusCode,code:errObj.code,message:errObj.message,requestId:errObj.innerError!==undefined?errObj.innerError["request-id"]:"",date:errObj.innerError!==undefined?new Date(errObj.innerError.date):new Date,body:errObj}};return ResponseHandler}();exports.ResponseHandler=ResponseHandler},{}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseType;(function(ResponseType){ResponseType["ARRAYBUFFER"]="arraybuffer";ResponseType["BLOB"]="blob";ResponseType["DOCUMENT"]="document";ResponseType["JSON"]="json";ResponseType["STREAM"]="stream";ResponseType["TEXT"]="text"})(ResponseType=exports.ResponseType||(exports.ResponseType={}))},{}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.oDataQueryNames=["select","expand","orderby","filter","top","skip","skipToken","count"];exports.DEFAULT_VERSION="v1.0";exports.GRAPH_BASE_URL="https://graph.microsoft.com/";exports.PACKAGE_VERSION="1.2.0";exports.oDataQueryNames=exports.oDataQueryNames.concat(exports.oDataQueryNames.map(function(s){return"$"+s}))},{}],8:[function(require,module,exports){"use strict";function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});var common_1=require("./common");var GraphRequest_1=require("./GraphRequest");var Client=function(){function Client(){this.config={debugLogging:false,defaultVersion:common_1.DEFAULT_VERSION,baseUrl:common_1.GRAPH_BASE_URL}}Client.init=function(clientOptions){var graphClient=new Client;for(var key in clientOptions){graphClient.config[key]=clientOptions[key]}return graphClient};Client.prototype.api=function(path){return new GraphRequest_1.GraphRequest(this.config,path)};return Client}();exports.Client=Client;__export(require("./GraphRequest"));__export(require("./common"));__export(require("./ResponseHandler"));__export(require("./ResponseType"))},{"./GraphRequest":3,"./ResponseHandler":5,"./ResponseType":6,"./common":7}],9:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],10:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":9,ieee754:12,isarray:13}],11:[function(require,module,exports){(function(process,global){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.ES6Promise=factory()})(this,function(){"use strict";function objectOrFunction(x){var type=typeof x;return x!==null&&(type==="object"||type==="function")}function isFunction(x){return typeof x==="function"}var _isArray=void 0;if(Array.isArray){_isArray=Array.isArray}else{_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}var isArray=_isArray;var len=0;var vertxNext=void 0;var customSchedulerFn=void 0;var asap=function asap(callback,arg){queue[len]=callback;queue[len+1]=arg;len+=2;if(len===2){if(customSchedulerFn){customSchedulerFn(flush)}else{scheduleFlush()}}};function setScheduler(scheduleFn){customSchedulerFn=scheduleFn}function setAsap(asapFn){asap=asapFn}var browserWindow=typeof window!=="undefined"?window:undefined;var browserGlobal=browserWindow||{};var BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver;var isNode=typeof self==="undefined"&&typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function useNextTick(){return function(){return process.nextTick(flush)}}function useVertxTimer(){if(typeof vertxNext!=="undefined"){return function(){vertxNext(flush)}}return useSetTimeout()}function useMutationObserver(){var iterations=0;var observer=new BrowserMutationObserver(flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=flush;return function(){return channel.port2.postMessage(0)}}function useSetTimeout(){var globalSetTimeout=setTimeout;return function(){return globalSetTimeout(flush,1)}}var queue=new Array(1e3);function flush(){for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],13:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],14:[function(require,module,exports){require("whatwg-fetch");module.exports=self.fetch.bind(self)},{"whatwg-fetch":16}],15:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex1){for(var i=1;i-1}}function normalizeName(name){if(typeof name!=="string"){name=String(name)}if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)){throw new TypeError("Invalid character in header field name")}return name.toLowerCase()}function normalizeValue(value){if(typeof value!=="string"){value=String(value)}return value}function iteratorFor(items){var iterator={next:function(){var value=items.shift();return{done:value===undefined,value:value}}};if(support.iterable){iterator[Symbol.iterator]=function(){return iterator}}return iterator}function Headers(headers){this.map={};if(headers instanceof Headers){headers.forEach(function(value,name){this.append(name,value)},this)}else if(Array.isArray(headers)){headers.forEach(function(header){this.append(header[0],header[1])},this)}else if(headers){Object.getOwnPropertyNames(headers).forEach(function(name){this.append(name,headers[name])},this)}}Headers.prototype.append=function(name,value){name=normalizeName(name);value=normalizeValue(value);var oldValue=this.map[name];this.map[name]=oldValue?oldValue+","+value:value};Headers.prototype["delete"]=function(name){delete this.map[normalizeName(name)]};Headers.prototype.get=function(name){name=normalizeName(name);return this.has(name)?this.map[name]:null};Headers.prototype.has=function(name){return this.map.hasOwnProperty(normalizeName(name))};Headers.prototype.set=function(name,value){this.map[normalizeName(name)]=normalizeValue(value)};Headers.prototype.forEach=function(callback,thisArg){for(var name in this.map){if(this.map.hasOwnProperty(name)){callback.call(thisArg,this.map[name],name,this)}}};Headers.prototype.keys=function(){var items=[];this.forEach(function(value,name){items.push(name)});return iteratorFor(items)};Headers.prototype.values=function(){var items=[];this.forEach(function(value){items.push(value)});return iteratorFor(items)};Headers.prototype.entries=function(){var items=[];this.forEach(function(value,name){items.push([name,value])});return iteratorFor(items)};if(support.iterable){Headers.prototype[Symbol.iterator]=Headers.prototype.entries}function consumed(body){if(body.bodyUsed){return Promise.reject(new TypeError("Already read"))}body.bodyUsed=true}function fileReaderReady(reader){return new Promise(function(resolve,reject){reader.onload=function(){resolve(reader.result)};reader.onerror=function(){reject(reader.error)}})}function readBlobAsArrayBuffer(blob){var reader=new FileReader;var promise=fileReaderReady(reader);reader.readAsArrayBuffer(blob);return promise}function readBlobAsText(blob){var reader=new FileReader;var promise=fileReaderReady(reader);reader.readAsText(blob);return promise}function readArrayBufferAsText(buf){var view=new Uint8Array(buf);var chars=new Array(view.length);for(var i=0;i-1?upcased:method}function Request(input,options){options=options||{};var body=options.body;if(input instanceof Request){if(input.bodyUsed){throw new TypeError("Already read")}this.url=input.url;this.credentials=input.credentials;if(!options.headers){this.headers=new Headers(input.headers)}this.method=input.method;this.mode=input.mode;if(!body&&input._bodyInit!=null){body=input._bodyInit;input.bodyUsed=true}}else{this.url=String(input)}this.credentials=options.credentials||this.credentials||"omit";if(options.headers||!this.headers){this.headers=new Headers(options.headers)}this.method=normalizeMethod(options.method||this.method||"GET");this.mode=options.mode||this.mode||null;this.referrer=null;if((this.method==="GET"||this.method==="HEAD")&&body){throw new TypeError("Body not allowed for GET or HEAD requests")}this._initBody(body)}Request.prototype.clone=function(){return new Request(this,{body:this._bodyInit})};function decode(body){var form=new FormData;body.trim().split("&").forEach(function(bytes){if(bytes){var split=bytes.split("=");var name=split.shift().replace(/\+/g," ");var value=split.join("=").replace(/\+/g," ");form.append(decodeURIComponent(name),decodeURIComponent(value))}});return form}function parseHeaders(rawHeaders){var headers=new Headers;var preProcessedHeaders=rawHeaders.replace(/\r?\n[\t ]+/g," ");preProcessedHeaders.split(/\r?\n/).forEach(function(line){var parts=line.split(":");var key=parts.shift().trim();if(key){var value=parts.join(":").trim();headers.append(key,value)}});return headers}Body.call(Request.prototype);function Response(bodyInit,options){if(!options){options={}}this.type="default";this.status=options.status===undefined?200:options.status;this.ok=this.status>=200&&this.status<300;this.statusText="statusText"in options?options.statusText:"OK";this.headers=new Headers(options.headers);this.url=options.url||"";this._initBody(bodyInit)}Body.call(Response.prototype);Response.prototype.clone=function(){return new Response(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Headers(this.headers),url:this.url})};Response.error=function(){var response=new Response(null,{status:0,statusText:""});response.type="error";return response};var redirectStatuses=[301,302,303,307,308];Response.redirect=function(url,status){if(redirectStatuses.indexOf(status)===-1){throw new RangeError("Invalid status code")}return new Response(null,{status:status,headers:{location:url}})};self.Headers=Headers;self.Request=Request;self.Response=Response;self.fetch=function(input,init){return new Promise(function(resolve,reject){var request=new Request(input,init);var xhr=new XMLHttpRequest;xhr.onload=function(){var options={status:xhr.status,statusText:xhr.statusText,headers:parseHeaders(xhr.getAllResponseHeaders()||"")};options.url="responseURL"in xhr?xhr.responseURL:options.headers.get("X-Request-URL");var body="response"in xhr?xhr.response:xhr.responseText;resolve(new Response(body,options))};xhr.onerror=function(){reject(new TypeError("Network request failed"))};xhr.ontimeout=function(){reject(new TypeError("Network request failed"))};xhr.open(request.method,request.url,true);if(request.credentials==="include"){xhr.withCredentials=true}else if(request.credentials==="omit"){xhr.withCredentials=false}if("responseType"in xhr&&support.blob){xhr.responseType="blob"}request.headers.forEach(function(value,name){xhr.setRequestHeader(name,value)});xhr.send(typeof request._bodyInit==="undefined"?null:request._bodyInit)})};self.fetch.polyfill=true})(typeof self!=="undefined"?self:this)},{}]},{},[1]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i1&&typeof propertyValue==="string"){allValues=Array.prototype.slice.call(additionalProperties)}this.urlComponents.oDataQueryParams[propertyName]+=allValues.join(",")};GraphRequest.prototype.delete=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.DELETE,headers:new Headers}),callback)};GraphRequest.prototype.patch=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PATCH,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.post=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.POST,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers(content.constructor!==undefined&&content.constructor.name==="FormData"?{}:{"Content-Type":"application/json"})}),callback)};GraphRequest.prototype.put=function(content,callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.PUT,body:GraphHelper_1.GraphHelper.serializeContent(content),headers:new Headers({"Content-Type":"application/octet-stream"})}),callback)};GraphRequest.prototype.create=function(content,callback){return this.post(content,callback)};GraphRequest.prototype.update=function(content,callback){return this.patch(content,callback)};GraphRequest.prototype.del=function(callback){return this.delete(callback)};GraphRequest.prototype.get=function(callback){var url=this.buildFullUrl();return this.sendRequestAndRouteResponse(new Request(url,{method:RequestMethod_1.RequestMethod.GET,headers:new Headers}),callback)};GraphRequest.prototype.routeResponseToPromise=function(request){var _this=this;return new es6_promise_1.Promise(function(resolve,reject){_this.routeResponseToCallback(request,function(err,body){if(err!=null){reject(err)}else{resolve(body)}})})};GraphRequest.prototype.handleFetch=function(request,callback,options){var _this=this;(request.constructor.name==="Request"?fetch(request):fetch(request,options)).then(function(response){_this.convertResponseType(response).then(function(responseValue){ResponseHandler_1.ResponseHandler.init(response,undefined,responseValue,callback)}).catch(function(error){ResponseHandler_1.ResponseHandler.init(response,error,undefined,callback)})}).catch(function(error){ResponseHandler_1.ResponseHandler.init(undefined,error,undefined,callback)})};GraphRequest.prototype.routeResponseToCallback=function(request,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err==null&&accessToken!=null){request=self.configureRequest(request,accessToken);self.handleFetch(request,callback)}else{callback(err,null,null)}})};GraphRequest.prototype.sendRequestAndRouteResponse=function(request,callback){if(callback==null&&typeof es6_promise_1.Promise!=="undefined"){return this.routeResponseToPromise(request)}else{this.routeResponseToCallback(request,callback||function(){})}};GraphRequest.prototype.getStream=function(callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_1={method:RequestMethod_1.RequestMethod.GET,headers:self.getDefaultRequestHeaders(accessToken)};self.responseType(ResponseType_1.ResponseType.STREAM);Object.keys(self._headers).forEach(function(key){return options_1.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_1)}else{callback(err,null)}})};GraphRequest.prototype.putStream=function(stream,callback){var self=this;self.config.authProvider(function(err,accessToken){if(err===null&&accessToken!==null){var url=self.buildFullUrl();var options_2={method:RequestMethod_1.RequestMethod.PUT,headers:{"Content-Type":"application/octet-stream"},body:stream};var defaultHeaders_1=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders_1).forEach(function(key){return options_2.headers[key]=defaultHeaders_1[key]});Object.keys(self._headers).forEach(function(key){return options_2.headers[key]=self._headers[key]});self.handleFetch(url,callback,options_2)}})};GraphRequest.prototype.getDefaultRequestHeaders=function(accessToken){return{Authorization:"Bearer "+accessToken,SdkVersion:"graph-js-"+common_1.PACKAGE_VERSION}};GraphRequest.prototype.configureRequest=function(request,accessToken){var self=this,defaultHeaders=self.getDefaultRequestHeaders(accessToken);Object.keys(defaultHeaders).forEach(function(key){return request.headers.set(key,defaultHeaders[key])});Object.keys(self._headers).forEach(function(key){return request.headers.set(key,self._headers[key])});return request};GraphRequest.prototype.query=function(queryDictionaryOrString){if(typeof queryDictionaryOrString==="string"){var queryStr=queryDictionaryOrString;var queryKey=queryStr.split("=")[0];var queryValue=queryStr.split("=")[1];this.urlComponents.otherURLQueryParams[queryKey]=queryValue}else{for(var key in queryDictionaryOrString){this.urlComponents.otherURLQueryParams[key]=queryDictionaryOrString[key]}}return this};GraphRequest.prototype.createQueryString=function(){var q=[];if(Object.keys(this.urlComponents.oDataQueryParams).length!=0){for(var property in this.urlComponents.oDataQueryParams){q.push(property+"="+this.urlComponents.oDataQueryParams[property])}}if(Object.keys(this.urlComponents.otherURLQueryParams).length!=0){for(var property in this.urlComponents.otherURLQueryParams){q.push(property+"="+this.urlComponents.otherURLQueryParams[property])}}if(q.length>0){return"?"+q.join("&")}return""};GraphRequest.prototype.convertResponseType=function(response){var responseValue;if(!this._responseType){this._responseType=""}switch(this._responseType.toLowerCase()){case ResponseType_1.ResponseType.ARRAYBUFFER:responseValue=response.arrayBuffer();break;case ResponseType_1.ResponseType.BLOB:responseValue=response.blob();break;case ResponseType_1.ResponseType.DOCUMENT:responseValue=response.json();break;case ResponseType_1.ResponseType.JSON:responseValue=response.json();break;case ResponseType_1.ResponseType.STREAM:responseValue=es6_promise_1.Promise.resolve(response.body);break;case ResponseType_1.ResponseType.TEXT:responseValue=response.text();break;default:responseValue=response.json();break}return responseValue};return GraphRequest}();exports.GraphRequest=GraphRequest},{"./GraphHelper":2,"./RequestMethod":8,"./ResponseHandler":9,"./ResponseType":10,"./common":11,"es6-promise":15,"isomorphic-fetch":18}],4:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]=self.file.size){maxValue=self.file.size-1}return new Range_1.Range(minVal,maxValue)};LargeFileUploadTask.prototype.sliceFile=function(range){var blob=this.file.content.slice(range.minValue,range.maxValue+1);return blob};LargeFileUploadTask.prototype.upload=function(){return __awaiter(this,void 0,void 0,function(){var self,nextRange,err,fileSlice,response,err_1;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,5,,6]);_a.label=2;case 2:if(!true)return[3,4];nextRange=self.getNextRange();if(nextRange.maxValue===-1){err=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");err.name="Invalid Session";throw err}fileSlice=self.sliceFile(nextRange);return[4,self.uploadSlice(fileSlice,nextRange,self.file.size)];case 3:response=_a.sent();if(response.id!==undefined){return[2,response]}else{self.updateTaskStatus(response)}return[3,2];case 4:return[3,6];case 5:err_1=_a.sent();throw err_1;case 6:return[2]}})})};LargeFileUploadTask.prototype.uploadSlice=function(fileSlice,range,totalSize){return __awaiter(this,void 0,void 0,function(){var self,err_2;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).headers({"Content-Length":""+(range.maxValue-range.minValue+1),"Content-Range":"bytes "+range.minValue+"-"+range.maxValue+"/"+totalSize}).put(fileSlice)];case 2:return[2,_a.sent()];case 3:err_2=_a.sent();throw err_2;case 4:return[2]}})})};LargeFileUploadTask.prototype.cancel=function(){return __awaiter(this,void 0,void 0,function(){var self,err_3;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).delete()];case 2:return[2,_a.sent()];case 3:err_3=_a.sent();throw err_3;case 4:return[2]}})})};LargeFileUploadTask.prototype.getStatus=function(){return __awaiter(this,void 0,void 0,function(){var self,response,err_4;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,self.client.api(self.uploadSession.url).get()];case 2:response=_a.sent();self.updateTaskStatus(response);return[2,response];case 3:err_4=_a.sent();throw err_4;case 4:return[2]}})})};LargeFileUploadTask.prototype.resume=function(){return __awaiter(this,void 0,void 0,function(){var self,err_5;return __generator(this,function(_a){switch(_a.label){case 0:self=this;_a.label=1;case 1:_a.trys.push([1,4,,5]);return[4,self.getStatus()];case 2:_a.sent();return[4,self.upload()];case 3:return[2,_a.sent()];case 4:err_5=_a.sent();throw err_5;case 5:return[2]}})})};return LargeFileUploadTask}();exports.LargeFileUploadTask=LargeFileUploadTask},{"./Range":7}],5:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]320*1024){value=Math.floor(value/(320*1024))*320*1024}return value};exports.getValidRangeSize=function(rangeSize){if(rangeSize===void 0){rangeSize=DEFAULT_FILE_SIZE}var sixtyMB=60*1024*1024;if(rangeSize>sixtyMB){rangeSize=sixtyMB}return roundTo320KB(rangeSize)}},{}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var Range=function(){function Range(minVal,maxVal){if(minVal===void 0){minVal=-1}if(maxVal===void 0){maxVal=-1}var self=this;self.minValue=minVal;self.maxValue=maxVal}return Range}();exports.Range=Range},{}],8:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var RequestMethod;(function(RequestMethod){RequestMethod["GET"]="GET";RequestMethod["PATCH"]="PATCH";RequestMethod["POST"]="POST";RequestMethod["PUT"]="PUT";RequestMethod["DELETE"]="DELETE"})(RequestMethod=exports.RequestMethod||(exports.RequestMethod={}))},{}],9:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseHandler=function(){function ResponseHandler(){}ResponseHandler.init=function(res,err,resContents,callback){if(res&&res.ok){callback(null,resContents,res)}else{if(err==null&&res!=null)if(resContents!=null&&resContents.error!=null)callback(ResponseHandler.buildGraphErrorFromResponseObject(resContents.error,res.status),null,res);else callback(ResponseHandler.defaultGraphError(res.status),null,res);else callback(ResponseHandler.ParseError(err),null,res)}};ResponseHandler.ParseError=function(rawErr){if(!rawErr){return ResponseHandler.defaultGraphError(-1)}return ResponseHandler.buildGraphErrorFromErrorObject(rawErr)};ResponseHandler.defaultGraphError=function(statusCode){return{statusCode:statusCode,code:null,message:null,requestId:null,date:new Date,body:null}};ResponseHandler.buildGraphErrorFromErrorObject=function(errObj){var error=ResponseHandler.defaultGraphError(-1);error.body=errObj.toString();error.message=errObj.message;error.date=new Date;return error};ResponseHandler.buildGraphErrorFromResponseObject=function(errObj,statusCode){return{statusCode:statusCode,code:errObj.code,message:errObj.message,requestId:errObj.innerError!==undefined?errObj.innerError["request-id"]:"",date:errObj.innerError!==undefined?new Date(errObj.innerError.date):new Date,body:errObj}};return ResponseHandler}();exports.ResponseHandler=ResponseHandler},{}],10:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var ResponseType;(function(ResponseType){ResponseType["ARRAYBUFFER"]="arraybuffer";ResponseType["BLOB"]="blob";ResponseType["DOCUMENT"]="document";ResponseType["JSON"]="json";ResponseType["STREAM"]="stream";ResponseType["TEXT"]="text"})(ResponseType=exports.ResponseType||(exports.ResponseType={}))},{}],11:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.oDataQueryNames=["select","expand","orderby","filter","top","skip","skipToken","count"];exports.DEFAULT_VERSION="v1.0";exports.GRAPH_BASE_URL="https://graph.microsoft.com/";exports.PACKAGE_VERSION="1.2.0";exports.oDataQueryNames=exports.oDataQueryNames.concat(exports.oDataQueryNames.map(function(s){return"$"+s}))},{}],12:[function(require,module,exports){"use strict";function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});var common_1=require("./common");var GraphRequest_1=require("./GraphRequest");var Client=function(){function Client(){this.config={debugLogging:false,defaultVersion:common_1.DEFAULT_VERSION,baseUrl:common_1.GRAPH_BASE_URL}}Client.init=function(clientOptions){var graphClient=new Client;for(var key in clientOptions){graphClient.config[key]=clientOptions[key]}return graphClient};Client.prototype.api=function(path){return new GraphRequest_1.GraphRequest(this.config,path)};return Client}();exports.Client=Client;__export(require("./GraphRequest"));__export(require("./common"));__export(require("./ResponseHandler"));__export(require("./OneDriveLargeFileUploadTask"));__export(require("./ResponseType"))},{"./GraphRequest":3,"./OneDriveLargeFileUploadTask":5,"./ResponseHandler":9,"./ResponseType":10,"./common":11}],13:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],14:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":13,ieee754:16,isarray:17}],15:[function(require,module,exports){(function(process,global){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.ES6Promise=factory()})(this,function(){"use strict";function objectOrFunction(x){var type=typeof x;return x!==null&&(type==="object"||type==="function")}function isFunction(x){return typeof x==="function"}var _isArray=void 0;if(Array.isArray){_isArray=Array.isArray}else{_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}var isArray=_isArray;var len=0;var vertxNext=void 0;var customSchedulerFn=void 0;var asap=function asap(callback,arg){queue[len]=callback;queue[len+1]=arg;len+=2;if(len===2){if(customSchedulerFn){customSchedulerFn(flush)}else{scheduleFlush()}}};function setScheduler(scheduleFn){customSchedulerFn=scheduleFn}function setAsap(asapFn){asap=asapFn}var browserWindow=typeof window!=="undefined"?window:undefined;var browserGlobal=browserWindow||{};var BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver;var isNode=typeof self==="undefined"&&typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function useNextTick(){return function(){return process.nextTick(flush)}}function useVertxTimer(){if(typeof vertxNext!=="undefined"){return function(){vertxNext(flush)}}return useSetTimeout()}function useMutationObserver(){var iterations=0;var observer=new BrowserMutationObserver(flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=flush;return function(){return channel.port2.postMessage(0)}}function useSetTimeout(){var globalSetTimeout=setTimeout;return function(){return globalSetTimeout(flush,1)}}var queue=new Array(1e3);function flush(){for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],17:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],18:[function(require,module,exports){require("whatwg-fetch");module.exports=self.fetch.bind(self)},{"whatwg-fetch":20}],19:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex1){for(var i=1;i-1}}function normalizeName(name){if(typeof name!=="string"){name=String(name)}if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)){throw new TypeError("Invalid character in header field name")}return name.toLowerCase()}function normalizeValue(value){if(typeof value!=="string"){value=String(value)}return value}function iteratorFor(items){var iterator={next:function(){var value=items.shift();return{done:value===undefined,value:value}}};if(support.iterable){iterator[Symbol.iterator]=function(){return iterator}}return iterator}function Headers(headers){this.map={};if(headers instanceof Headers){headers.forEach(function(value,name){this.append(name,value)},this)}else if(Array.isArray(headers)){headers.forEach(function(header){this.append(header[0],header[1])},this)}else if(headers){Object.getOwnPropertyNames(headers).forEach(function(name){this.append(name,headers[name])},this)}}Headers.prototype.append=function(name,value){name=normalizeName(name);value=normalizeValue(value);var oldValue=this.map[name];this.map[name]=oldValue?oldValue+","+value:value};Headers.prototype["delete"]=function(name){delete this.map[normalizeName(name)]};Headers.prototype.get=function(name){name=normalizeName(name);return this.has(name)?this.map[name]:null};Headers.prototype.has=function(name){return this.map.hasOwnProperty(normalizeName(name))};Headers.prototype.set=function(name,value){this.map[normalizeName(name)]=normalizeValue(value)};Headers.prototype.forEach=function(callback,thisArg){for(var name in this.map){if(this.map.hasOwnProperty(name)){callback.call(thisArg,this.map[name],name,this)}}};Headers.prototype.keys=function(){var items=[];this.forEach(function(value,name){items.push(name)});return iteratorFor(items)};Headers.prototype.values=function(){var items=[];this.forEach(function(value){items.push(value)});return iteratorFor(items)};Headers.prototype.entries=function(){var items=[];this.forEach(function(value,name){items.push([name,value])});return iteratorFor(items)};if(support.iterable){Headers.prototype[Symbol.iterator]=Headers.prototype.entries}function consumed(body){if(body.bodyUsed){return Promise.reject(new TypeError("Already read"))}body.bodyUsed=true}function fileReaderReady(reader){return new Promise(function(resolve,reject){reader.onload=function(){resolve(reader.result)};reader.onerror=function(){reject(reader.error)}})}function readBlobAsArrayBuffer(blob){var reader=new FileReader;var promise=fileReaderReady(reader);reader.readAsArrayBuffer(blob);return promise}function readBlobAsText(blob){var reader=new FileReader;var promise=fileReaderReady(reader);reader.readAsText(blob);return promise}function readArrayBufferAsText(buf){var view=new Uint8Array(buf);var chars=new Array(view.length);for(var i=0;i-1?upcased:method}function Request(input,options){options=options||{};var body=options.body;if(input instanceof Request){if(input.bodyUsed){throw new TypeError("Already read")}this.url=input.url;this.credentials=input.credentials;if(!options.headers){this.headers=new Headers(input.headers)}this.method=input.method;this.mode=input.mode;if(!body&&input._bodyInit!=null){body=input._bodyInit;input.bodyUsed=true}}else{this.url=String(input)}this.credentials=options.credentials||this.credentials||"omit";if(options.headers||!this.headers){this.headers=new Headers(options.headers)}this.method=normalizeMethod(options.method||this.method||"GET");this.mode=options.mode||this.mode||null;this.referrer=null;if((this.method==="GET"||this.method==="HEAD")&&body){throw new TypeError("Body not allowed for GET or HEAD requests")}this._initBody(body)}Request.prototype.clone=function(){return new Request(this,{body:this._bodyInit})};function decode(body){var form=new FormData;body.trim().split("&").forEach(function(bytes){if(bytes){var split=bytes.split("=");var name=split.shift().replace(/\+/g," ");var value=split.join("=").replace(/\+/g," ");form.append(decodeURIComponent(name),decodeURIComponent(value))}});return form}function parseHeaders(rawHeaders){var headers=new Headers;var preProcessedHeaders=rawHeaders.replace(/\r?\n[\t ]+/g," ");preProcessedHeaders.split(/\r?\n/).forEach(function(line){var parts=line.split(":");var key=parts.shift().trim();if(key){var value=parts.join(":").trim();headers.append(key,value)}});return headers}Body.call(Request.prototype);function Response(bodyInit,options){if(!options){options={}}this.type="default";this.status=options.status===undefined?200:options.status;this.ok=this.status>=200&&this.status<300;this.statusText="statusText"in options?options.statusText:"OK";this.headers=new Headers(options.headers);this.url=options.url||"";this._initBody(bodyInit)}Body.call(Response.prototype);Response.prototype.clone=function(){return new Response(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Headers(this.headers),url:this.url})};Response.error=function(){var response=new Response(null,{status:0,statusText:""});response.type="error";return response};var redirectStatuses=[301,302,303,307,308];Response.redirect=function(url,status){if(redirectStatuses.indexOf(status)===-1){throw new RangeError("Invalid status code")}return new Response(null,{status:status,headers:{location:url}})};self.Headers=Headers;self.Request=Request;self.Response=Response;self.fetch=function(input,init){return new Promise(function(resolve,reject){var request=new Request(input,init);var xhr=new XMLHttpRequest;xhr.onload=function(){var options={status:xhr.status,statusText:xhr.statusText,headers:parseHeaders(xhr.getAllResponseHeaders()||"")};options.url="responseURL"in xhr?xhr.responseURL:options.headers.get("X-Request-URL");var body="response"in xhr?xhr.response:xhr.responseText;resolve(new Response(body,options))};xhr.onerror=function(){reject(new TypeError("Network request failed"))};xhr.ontimeout=function(){reject(new TypeError("Network request failed"))};xhr.open(request.method,request.url,true);if(request.credentials==="include"){xhr.withCredentials=true}else if(request.credentials==="omit"){xhr.withCredentials=false}if("responseType"in xhr&&support.blob){xhr.responseType="blob"}request.headers.forEach(function(value,name){xhr.setRequestHeader(name,value)});xhr.send(typeof request._bodyInit==="undefined"?null:request._bodyInit)})};self.fetch.polyfill=true})(typeof self!=="undefined"?self:this)},{}]},{},[1]); \ No newline at end of file diff --git a/lib/spec/core/responseHandling.js.map b/lib/spec/core/responseHandling.js.map index 2fc4ec5e8..71949af22 100644 --- a/lib/spec/core/responseHandling.js.map +++ b/lib/spec/core/responseHandling.js.map @@ -1 +1 @@ -{"version":3,"file":"responseHandling.js","sourceRoot":"","sources":["../../../spec/core/responseHandling.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,6DAAyD;AAKzD,+BAAiC;AAEjC,IAAM,aAAa,GAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpC,IAAM,aAAa,GAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACpD,IAAM,QAAQ,GACV,IAAI,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE/C,IAAM,aAAa,GAAQ;IACvB,KAAK,EAAE;QACH,MAAM,EAAE,cAAc;QACtB,SAAS,EA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,CAAC,eAAe,EAAE;IACtB,EAAE,CAAC,+BAA+B,EAAE;QAChC,iCAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAC,GAAc,EAAE,GAAG;YACvD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"responseHandling.js","sourceRoot":"","sources":["../../../spec/core/responseHandling.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,6DAAyD;AAKzD,+BAAiC;AAIjC,IAAM,aAAa,GAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpC,IAAM,aAAa,GAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACpD,IAAM,QAAQ,GACV,IAAI,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE/C,IAAM,aAAa,GAAQ;IACvB,KAAK,EAAE;QACH,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,0EAA0E;QACrF,YAAY,EAAE;YACV,YAAY,EAAE,sCAAsC;YACpD,MAAM,EAAE,qBAAqB;SAChC;KACJ;CACJ,CAAC;AAEF,IAAM,aAAa,GAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACpD,IAAM,QAAQ,GACV,IAAI,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE/C,QAAQ,CAAC,mBAAmB,EAAE;IAC1B,EAAE,CAAC,qCAAqC,EAAE;QACtC,iCAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,UAAC,GAAc,EAAE,GAAG;YACpE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE;QAC9B,iCAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,UAAC,GAAc,EAAE,GAAG;YACpE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,kBAAkB,EAAE;IACzB,EAAE,CAAC,+DAA+D,EAAE;QAChE,iCAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,UAAC,GAAc,EAAE,GAAG;YACpE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE;IACtB,EAAE,CAAC,+BAA+B,EAAE;QAChC,iCAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAC,GAAc,EAAE,GAAG;YACvD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/spec/core/urlGeneration.js b/lib/spec/core/urlGeneration.js index 222bdd208..a51e3da9b 100644 --- a/lib/spec/core/urlGeneration.js +++ b/lib/spec/core/urlGeneration.js @@ -39,6 +39,13 @@ cases.push({ .select(["displayName"]) .select("jobTitle") }); +// Need to figure out type signature of select() to allow string, array of strings, and unlimited string parameters +// cases.push({ +// url: "https://graph.microsoft.com/beta/me?$select=displayName,jobTitle,mailNickname", +// request: client.api("/me") +// .version("beta") +// .select("displayName", "jobTitle", "mailNickname") +// }) cases.push({ url: "https://graph.microsoft.com/beta/me/people?$select=displayName,title&$count=true", request: client.api("/me/people") diff --git a/lib/spec/core/urlGeneration.js.map b/lib/spec/core/urlGeneration.js.map index daf6920fe..8a813a72d 100644 --- a/lib/spec/core/urlGeneration.js.map +++ b/lib/spec/core/urlGeneration.js.map @@ -1 +1 @@ -{"version":3,"file":"urlGeneration.js","sourceRoot":"","sources":["../../../spec/core/urlGeneration.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AAEjC,yCAAuD;AAEvD,IAAM,MAAM,GAAG,cAAW,CAAC,IAAI,EAAE,CAAC;AAElC,IAAI,KAAK,GAAG,EAAE,CAAC;AAEf,KAAK,CAAC,IAAI,CAAC;IACP,GAAG,EAAE,yDAAyD;IAC9D,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;SACb,MAAM,CAAC,aAAa,CAAC;CACrC,CAAC,CAAC;AAEH,KAAK,CAAC,IAAI,CAAC;IACP,GAAG,EAAC,yDAAyD;IAC7D,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;SACb,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;CACvC,CAAC,CAAC;AAEH,KAAK,CAAC,IAAI,CAAC;IACP,GAAG,EAAE,kEAAkE;IACvE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;SACZ,MAAM,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,KAAK,CAAC,IAAI,CAAC;IACP,GAAG,EAAE,kEAAkE;IACvE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,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 No newline at end of file diff --git a/lib/spec/core/urlParsing.js b/lib/spec/core/urlParsing.js index 421a8b867..38d4932ec 100644 --- a/lib/spec/core/urlParsing.js +++ b/lib/spec/core/urlParsing.js @@ -15,6 +15,7 @@ var testCases = { "/me?a=b": "https://graph.microsoft.com/v1.0/me?a=b", "/me?$filter=b&c=d": "https://graph.microsoft.com/v1.0/me?$filter=b&c=d", "me?$filter=b&c=d": "https://graph.microsoft.com/v1.0/me?$filter=b&c=d", + // oData params should work with and without $ "me?$select=displayName": "https://graph.microsoft.com/v1.0/me?$select=displayName", "me?select=displayName": "https://graph.microsoft.com/v1.0/me?select=displayName", "https://graph.microsoft.com/beta/me?select=displayName": "https://graph.microsoft.com/beta/me?select=displayName" diff --git a/lib/spec/core/urlParsing.js.map b/lib/spec/core/urlParsing.js.map index 48e735db8..358618d60 100644 --- a/lib/spec/core/urlParsing.js.map +++ b/lib/spec/core/urlParsing.js.map @@ -1 +1 @@ -{"version":3,"file":"urlParsing.js","sourceRoot":"","sources":["../../../spec/core/urlParsing.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AAEjC,yCAAqD;AAErD,IAAM,MAAM,GAAG,cAAW,CAAC,IAAI,EAAE,CAAC;AAGlC,IAAI,SAAS,GAAG;IACZ,KAAK,EAAE,qCAAqC;IAC5C,MAAM,EAAE,sCAAsC;IAC9C,IAAI,EAAE,qCAAqC;IAC3C,WAAW,EAAE,4CAA4C;IACzD,YAAY,EAAE,4CAA4C;IAC1D,4CAA4C,EAAE,4CAA4C;IAC1F,kFAAkF,EAAE,kFAAkF;IACtK,iDAAiD,EAAE,kFAAkF;IACrI,SAAS,EAAE,yCAAyC;IACpD,mBAAmB,EAAE,mDAAmD;IACxE,kBAAkB,EAAE,mDAAmD;IAGvE,wBAAwB,EAAE,yDAAyD;IACnF,uBAAuB,EAAE,wDAAwD;IACjF,wDAAwD,EAAE,wDAAwD;CACrH,CAAA;AAED,QAAQ,CAAC,cAAc,EAAE;4BACZ,IAAI;QACT,EA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,IAAI,IAAI,IAAI,SAAS;gBAAjB,IAAI;KAKZ;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/src/GraphHelper.js b/lib/src/GraphHelper.js index 858034b9b..b2df931ae 100644 --- a/lib/src/GraphHelper.js +++ b/lib/src/GraphHelper.js @@ -1,8 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var GraphHelper = (function () { +var GraphHelper = /** @class */ (function () { function GraphHelper() { } + /* + This conversion is required due to the following reasons: + 1. Body parameter of Request method of isomorphic-fetch only accepts Blob, ArrayBuffer, FormData, TypedArrays, string. + 2. Node.js platform does not suppport Blob, FormData. Javascript File object inherits from Blob so it is also + not supported in node. Therefore content of type Blob, File, FormData will only come from browsers. + 3. Parallel to Javascript's arrayBuffer, node provides Buffer interface. Node's Buffer is able to send the arbitary + binary data to the server successfully for both Browser and Node platform. Whereas sending binary data via + ArrayBuffer or TypedArrays was only possible using Browser. To support both Node and Browser, `serializeContent` + converts TypedArrays or ArrayBuffer to `Node Buffer`. + 4. If the data received is in JSON format, `serializeContent` converts the JSON to string. + */ GraphHelper.serializeContent = function (content) { var className = content.constructor.name; if (className === 'Buffer' diff --git a/lib/src/GraphHelper.js.map b/lib/src/GraphHelper.js.map index 15712a755..d28b18310 100644 --- a/lib/src/GraphHelper.js.map +++ b/lib/src/GraphHelper.js.map @@ -1 +1 @@ -{"version":3,"file":"GraphHelper.js","sourceRoot":"","sources":["../../src/GraphHelper.ts"],"names":[],"mappings":";;AAAA;IAAA;IA+CA,CAAC;IAlCe,4BAAgB,GAA9B,UAA+B,OAAY;QACvC,IAAI,SAAS,GAAW,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;QAEjD,IAAI,SAAS,KAAK,QAAQ;eACnB,SAAS,KAAK,MAAM;eACpB,SAAS,KAAK,MAAM;eACpB,SAAS,KAAK,UAAU;eACxB,OAAO,OAAO,KAAK,QAAQ,EAAE;YAChC,OAAO,OAAO,CAAC;SAClB;QAED,IAA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AAC,CAAC;SAClC;aAAM,IAAI,SAAS,KAAK,WAAW;eAC7B,SAAS,KAAK,YAAY;eAC1B,SAAS,KAAK,YAAY;eAC1B,SAAS,KAAK,YAAY;eAC1B,SAAS,KAAK,aAAa;eAC3B,SAAS,KAAK,aAAa;eAC3B,SAAS,KAAK,mBAAmB;eACjC,SAAS,KAAK,cAAc;eAC5B,SAAS,KAAK,cAAc;eAC5B,SAAS,KAAK,UAAU,EAAE;YAC7B,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SACzC;aAAM;YACH,IAAI;gBACA,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACrC;YAAC,OAAO,KAAK,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;aAC3C;SACJ;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IACH,kBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,kCAAW"} \ No newline at end of file diff --git a/lib/src/GraphRequest.js b/lib/src/GraphRequest.js index b83124f05..acfaabe89 100644 --- a/lib/src/GraphRequest.js +++ b/lib/src/GraphRequest.js @@ -7,7 +7,7 @@ var ResponseHandler_1 = require("./ResponseHandler"); var RequestMethod_1 = require("./RequestMethod"); var ResponseType_1 = require("./ResponseType"); var GraphHelper_1 = require("./GraphHelper"); -var GraphRequest = (function () { +var GraphRequest = /** @class */ (function () { function GraphRequest(config, path) { this.config = config; this._headers = {}; @@ -30,27 +30,42 @@ var GraphRequest = (function () { return this; }; GraphRequest.prototype.parsePath = function (rawPath) { + // break rawPath into this.urlComponents + // strip out the base url if they passed it in if (rawPath.indexOf("https://") != -1) { rawPath = rawPath.replace("https://", ""); + // find where the host ends var endOfHostStrPos = rawPath.indexOf("/"); - this.urlComponents.host = "https://" + rawPath.substring(0, endOfHostStrPos); + this.urlComponents.host = "https://" + rawPath.substring(0, endOfHostStrPos); // parse out the host + // strip the host from rawPath rawPath = rawPath.substring(endOfHostStrPos + 1, rawPath.length); + // then remove the following version var endOfVersionStrPos = rawPath.indexOf("/"); + // parse out the version this.urlComponents.version = rawPath.substring(0, endOfVersionStrPos); + // strip version from rawPath rawPath = rawPath.substring(endOfVersionStrPos + 1, rawPath.length); } + // strip out any leading "/" if (rawPath.charAt(0) == "/") { rawPath = rawPath.substr(1); } var queryStrPos = rawPath.indexOf("?"); + // let afterPath = if (queryStrPos == -1) { + // no query string this.urlComponents.path = rawPath; } else { this.urlComponents.path = rawPath.substr(0, queryStrPos); + // capture query string into + // this.urlComponents.oDataQueryParams + // and + // this.urlComponents.otherURLQueryParams var queryParams = rawPath.substring(queryStrPos + 1, rawPath.length).split("&"); for (var _i = 0, queryParams_1 = queryParams; _i < queryParams_1.length; _i++) { var queryParam = queryParams_1[_i]; + //queryParam: a=b var queryParams_2 = queryParam.split("="); var key = queryParams_2[0]; var value = queryParams_2[1]; @@ -84,6 +99,12 @@ var GraphRequest = (function () { this.urlComponents.version = v; return this; }; + /* + * Accepts .select("displayName,birthday") + * and .select(["displayName", "birthday"]) + * and .select("displayName", "birthday") + * + */ GraphRequest.prototype.select = function (properties) { this.addCsvQueryParamater("$select", properties, arguments); return this; @@ -120,15 +141,18 @@ var GraphRequest = (function () { this._responseType = responseType; return this; }; + // helper for $select, $expand and $orderby (must be comma separated) GraphRequest.prototype.addCsvQueryParamater = function (propertyName, propertyValue, additionalProperties) { + // if there are already $propertyName value there, append a "," this.urlComponents.oDataQueryParams[propertyName] = this.urlComponents.oDataQueryParams[propertyName] ? this.urlComponents.oDataQueryParams[propertyName] + "," : ""; var allValues = []; if (typeof propertyValue === "string") { allValues.push(propertyValue); } - else { + else { // propertyValue passed in as array allValues = allValues.concat(propertyValue); } + // merge in additionalProperties if (additionalProperties.length > 1 && typeof propertyValue === "string") { allValues = Array.prototype.slice.call(additionalProperties); } @@ -162,9 +186,12 @@ var GraphRequest = (function () { headers: new Headers({ 'Content-Type': 'application/octet-stream' }) }), callback); }; + // request aliases + // alias for post GraphRequest.prototype.create = function (content, callback) { return this.post(content, callback); }; + // alias for patch GraphRequest.prototype.update = function (content, callback) { return this.patch(content, callback); }; @@ -188,6 +215,7 @@ var GraphRequest = (function () { }); }); }; + // Given the Request object, make the request and invoke callback GraphRequest.prototype.handleFetch = function (request, callback, options) { var _this = this; ((request.constructor.name === "Request") ? fetch(request) : fetch(request, options)).then(function (response) { @@ -200,6 +228,7 @@ var GraphRequest = (function () { ResponseHandler_1.ResponseHandler.init(undefined, error, undefined, callback); }); }; + // Given the Request object, get an auth token from the authProvider, make the fetch call GraphRequest.prototype.routeResponseToCallback = function (request, callback) { var self = this; self.config.authProvider(function (err, accessToken) { @@ -212,7 +241,12 @@ var GraphRequest = (function () { } }); }; + /* + * Help method that's called from the final actions( .get(), .post(), etc.) that after making the request either invokes + * routeResponseToCallback() or routeResponseToPromise() + */ GraphRequest.prototype.sendRequestAndRouteResponse = function (request, callback) { + // return a promise when Promises are supported and no callback was provided if (callback == null && typeof es6_promise_1.Promise !== "undefined") { return this.routeResponseToPromise(request); } @@ -269,21 +303,25 @@ var GraphRequest = (function () { Object.keys(self._headers).forEach(function (key) { return request.headers.set(key, self._headers[key]); }); return request; }; + // append query strings to the url, accepts either a string like $select=displayName or a dictionary {"$select": "displayName"} GraphRequest.prototype.query = function (queryDictionaryOrString) { - if (typeof queryDictionaryOrString === "string") { + if (typeof queryDictionaryOrString === "string") { // is string var queryStr = queryDictionaryOrString; var queryKey = queryStr.split("=")[0]; var queryValue = queryStr.split("=")[1]; this.urlComponents.otherURLQueryParams[queryKey] = queryValue; } - else { + else { // is dictionary for (var key in queryDictionaryOrString) { this.urlComponents.otherURLQueryParams[key] = queryDictionaryOrString[key]; } } return this; }; + // ex: ?$select=displayName&$filter=startsWith(displayName, 'A') + // does not include starting ? GraphRequest.prototype.createQueryString = function () { + // need to combine first this.urlComponents.oDataQueryParams and this.urlComponents.otherURLQueryParams var q = []; if (Object.keys(this.urlComponents.oDataQueryParams).length != 0) { for (var property in this.urlComponents.oDataQueryParams) { @@ -313,6 +351,7 @@ var GraphRequest = (function () { responseValue = response.blob(); break; case ResponseType_1.ResponseType.DOCUMENT: + // XMLHTTPRequest only :( responseValue = response.json(); break; case ResponseType_1.ResponseType.JSON: diff --git a/lib/src/GraphRequest.js.map b/lib/src/GraphRequest.js.map index d64385d2e..4445fbe84 100644 --- a/lib/src/GraphRequest.js.map +++ b/lib/src/GraphRequest.js.map @@ -1 +1 @@ -{"version":3,"file":"GraphRequest.js","sourceRoot":"","sources":["../../src/GraphRequest.ts"],"names":[],"mappings":";;AAAA,2CAAqC;AACrC,4BAA0B;AAE1B,mCAAgI;AAChI,qDAAmD;AACnD,iDAAgD;AAChD,+CAA8C;AAC9C,6CAA4C;AAE5C;IAOI,sBAAY,MAAe,EAAE,IAAY;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QAEnB,IAAI,CAAC,aAAa,GAAG;YACjB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YACzB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;YACnC,gBAAgB,EAAE,EAAE;YACpB,mBAAmB,EAAE,EAAE;SAC1B,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEM,6BAAM,GAAb,UAAc,SAAiB,EAAE,WAAmB;QAChD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;QACvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,8BAAO,GAAd,UAAe,OAA2C;QACtD,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IAChB,CA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pB,aAAa,GAAG,qBAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC/C,MAAM;YACV,KAAK,2BAAY,CAAC,IAAI;gBAClB,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;YACV;gBACI,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;SACb;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;IACL,mBAAC;AAAD,CAAC,AAvbD,IAubC;AAvbY,oCAAY"} \ No newline at end of file +{"version":3,"file":"GraphRequest.js","sourceRoot":"","sources":["../../src/GraphRequest.ts"],"names":[],"mappings":";;AAAA,2CAAqC;AACrC,4BAA0B;AAE1B,mCAAgI;AAChI,qDAAmD;AACnD,iDAAgD;AAChD,+CAA8C;AAC9C,6CAA4C;AAE5C;IAOI,sBAAY,MAAe,EAAE,IAAY;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QAEnB,IAAI,CAAC,aAAa,GAAG;YACjB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YACzB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;YACnC,gBAAgB,EAAE,EAAE;YACpB,mBAAmB,EAAE,EAAE;SAC1B,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEM,6BAAM,GAAb,UAAc,SAAiB,EAAE,WAAmB;QAChD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;QACvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,8BAAO,GAAd,UAAe,OAA2C;QACtD,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;I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,EAAE,CAAC;SAC3B;QACD,QAAQ,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE;YACtC,KAAK,2BAAY,CAAC,WAAW;gBACzB,aAAa,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACvC,MAAM;YACV,KAAK,2BAAY,CAAC,IAAI;gBAClB,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;YACV,KAAK,2BAAY,CAAC,QAAQ;gBACtB,yBAAyB;gBACzB,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;YACV,KAAK,2BAAY,CAAC,IAAI;gBAClB,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;YACV,KAAK,2BAAY,CAAC,MAAM;gBACpB,aAAa,GAAG,qBAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC/C,MAAM;YACV,KAAK,2BAAY,CAAC,IAAI;gBAClB,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;YACV;gBACI,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM;SACb;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;IACL,mBAAC;AAAD,CAAC,AAvbD,IAubC;AAvbY,oCAAY"} \ No newline at end of file diff --git a/lib/src/LargeFileUploadTask.d.ts b/lib/src/LargeFileUploadTask.d.ts new file mode 100644 index 000000000..b2d402976 --- /dev/null +++ b/lib/src/LargeFileUploadTask.d.ts @@ -0,0 +1,127 @@ +/** + * @module LargeFileUploadTask + */ +import { Client } from "./index"; +import { Range } from "./Range"; +/** + * @interface + * Signature to represent the resulting response in the status enquiry request + * @property {string} expirationDateTime - The expiration of the time of the upload session + * @property {string[]} nextExpectedRanges - The ranges expected in next consecutive request in the upload + */ +interface UploadStatusResponse { + expirationDateTime: string; + nextExpectedRanges: string[]; +} +/** + * @interface + * Signature to define options for upload task + * @property {number} [rangeSize = LargeFileUploadTask.DEFAULT_FILE_SIZE] - Specifies the range chunk size + */ +export interface LargeFileUploadTaskOptions { + rangeSize?: number; +} +/** + * @interface + * Signature to represent upload session resulting from the session creation in the server + * @property {string} url - The URL to which the file upload is made + * @property {Date} expiry - The expiration of the time of the upload session + */ +export interface LargeFileUploadSession { + url: string; + expiry: Date; +} +/** + * @interface + * Signature to define the properties and content of the file in upload task + * @property {ArrayBuffer | File} content - The actual file content + * @property {string} name - Specifies the file name with extension + * @property {number} size - Specifies size of the file + */ +export interface FileObject { + content: ArrayBuffer | File; + name: string; + size: number; +} +/** + * Class representing LargeFileUploadTask + */ +export declare class LargeFileUploadTask { + /** The GraphClient instance */ + client: Client; + /** The object holding file details */ + file: FileObject; + /** The object holding options for the task */ + options: LargeFileUploadTaskOptions; + /** The object for upload session */ + uploadSession: LargeFileUploadSession; + /** The next range needs to be uploaded */ + nextRange: Range; + /** + * Default value for the rangeSize + */ + private DEFAULT_FILE_SIZE; + /** + * Constructs a LargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions); + /** + * Parses given range string to the Range instance + * @param {string[]} ranges - The ranges value + * @return The range instance + */ + parseRange(ranges: string[]): Range; + /** + * Updates the expiration date and the next range + * @param {UploadStatusResponse} response - The response of the upload status + */ + updateTaskStatus(response: UploadStatusResponse): void; + /** + * Gets next range that needs to be uploaded + * @return The range instance + */ + getNextRange(): Range; + /** + * Slices the file content to the given range + * @param {Range} range - The range value + * @return The sliced ArrayBuffer or Blob + */ + sliceFile(range: Range): ArrayBuffer | Blob; + /** + * @async + * Uploads file to the server in a sequential order by slicing the file + * @return The promise resolves to uploaded response + */ + upload(): Promise; + /** + * @async + * Uploads given slice to the server + * @param {ArrayBuffer | Blob | File} fileSlice - The file slice + * @param {Range} range - The range value + * @param {number} totalSize - The total size of a complete file + */ + uploadSlice(fileSlice: ArrayBuffer | Blob | File, range: Range, totalSize: number): Promise; + /** + * @async + * Deletes upload session in the server + * @return The promise resolves to cancelled response + */ + cancel(): Promise; + /** + * @async + * Gets status for the upload session + * @return The promise resolves to the status enquiry response + */ + getStatus(): Promise; + /** + * @async + * Resumes upload session and continue uploading the file from the last sent range + * @return The promise resolves to the uploaded response + */ + resume(): Promise; +} +export {}; diff --git a/lib/src/LargeFileUploadTask.js b/lib/src/LargeFileUploadTask.js new file mode 100644 index 000000000..ee8cd01a0 --- /dev/null +++ b/lib/src/LargeFileUploadTask.js @@ -0,0 +1,284 @@ +"use strict"; +/** + * @module LargeFileUploadTask + */ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Range_1 = require("./Range"); +; +/** + * Class representing LargeFileUploadTask + */ +var LargeFileUploadTask = /** @class */ (function () { + /** + * Constructs a LargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + function LargeFileUploadTask(client, file, uploadSession, options) { + /** + * Default value for the rangeSize + */ + this.DEFAULT_FILE_SIZE = 5 * 1024 * 1024; + var self = this; + self.client = client; + self.file = file; + if (options.rangeSize === undefined) { + options.rangeSize = self.DEFAULT_FILE_SIZE; + } + self.options = options; + self.uploadSession = uploadSession; + self.nextRange = new Range_1.Range(0, self.options.rangeSize - 1); + } + /** + * Parses given range string to the Range instance + * @param {string[]} ranges - The ranges value + * @return The range instance + */ + LargeFileUploadTask.prototype.parseRange = function (ranges) { + var rangeStr = ranges[0]; + if (typeof rangeStr === "undefined" || rangeStr === "") { + return new Range_1.Range(); + } + var firstRange = rangeStr.split("-"), minVal = parseInt(firstRange[0]), maxVal = parseInt(firstRange[1]); + if (Number.isNaN(maxVal)) { + maxVal = this.file.size - 1; + } + return new Range_1.Range(minVal, maxVal); + }; + /** + * Updates the expiration date and the next range + * @param {UploadStatusResponse} response - The response of the upload status + */ + LargeFileUploadTask.prototype.updateTaskStatus = function (response) { + var self = this; + self.uploadSession.expiry = new Date(response.expirationDateTime); + self.nextRange = self.parseRange(response.nextExpectedRanges); + }; + /** + * Gets next range that needs to be uploaded + * @return The range instance + */ + LargeFileUploadTask.prototype.getNextRange = function () { + var self = this; + if (self.nextRange.minValue === -1) { + return self.nextRange; + } + var minVal = self.nextRange.minValue, maxValue = minVal + self.options.rangeSize - 1; + if (maxValue >= self.file.size) { + maxValue = self.file.size - 1; + } + return new Range_1.Range(minVal, maxValue); + }; + /** + * Slices the file content to the given range + * @param {Range} range - The range value + * @return The sliced ArrayBuffer or Blob + */ + LargeFileUploadTask.prototype.sliceFile = function (range) { + var blob = this.file.content.slice(range.minValue, range.maxValue + 1); + return blob; + }; + /** + * @async + * Uploads file to the server in a sequential order by slicing the file + * @return The promise resolves to uploaded response + */ + LargeFileUploadTask.prototype.upload = function () { + return __awaiter(this, void 0, void 0, function () { + var self, nextRange, err, fileSlice, response, err_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 5, , 6]); + _a.label = 2; + case 2: + if (!true) return [3 /*break*/, 4]; + nextRange = self.getNextRange(); + if (nextRange.maxValue === -1) { + err = new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file"); + err.name = "Invalid Session"; + throw err; + } + fileSlice = self.sliceFile(nextRange); + return [4 /*yield*/, self.uploadSlice(fileSlice, nextRange, self.file.size)]; + case 3: + response = _a.sent(); + // Upon completion of upload process incase of onedrive, driveItem is returned, which contains id + if (response.id !== undefined) { + return [2 /*return*/, response]; + } + else { + self.updateTaskStatus(response); + } + return [3 /*break*/, 2]; + case 4: return [3 /*break*/, 6]; + case 5: + err_1 = _a.sent(); + throw err_1; + case 6: return [2 /*return*/]; + } + }); + }); + }; + /** + * @async + * Uploads given slice to the server + * @param {ArrayBuffer | Blob | File} fileSlice - The file slice + * @param {Range} range - The range value + * @param {number} totalSize - The total size of a complete file + */ + LargeFileUploadTask.prototype.uploadSlice = function (fileSlice, range, totalSize) { + return __awaiter(this, void 0, void 0, function () { + var self, err_2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, self.client + .api(self.uploadSession.url) + .headers({ + "Content-Length": "" + (range.maxValue - range.minValue + 1), + "Content-Range": "bytes " + range.minValue + "-" + range.maxValue + "/" + totalSize + }) + .put(fileSlice)]; + case 2: return [2 /*return*/, _a.sent()]; + case 3: + err_2 = _a.sent(); + throw err_2; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * @async + * Deletes upload session in the server + * @return The promise resolves to cancelled response + */ + LargeFileUploadTask.prototype.cancel = function () { + return __awaiter(this, void 0, void 0, function () { + var self, err_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, self.client + .api(self.uploadSession.url) + .delete()]; + case 2: return [2 /*return*/, _a.sent()]; + case 3: + err_3 = _a.sent(); + throw err_3; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * @async + * Gets status for the upload session + * @return The promise resolves to the status enquiry response + */ + LargeFileUploadTask.prototype.getStatus = function () { + return __awaiter(this, void 0, void 0, function () { + var self, response, err_4; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, self.client + .api(self.uploadSession.url) + .get()]; + case 2: + response = _a.sent(); + self.updateTaskStatus(response); + return [2 /*return*/, response]; + case 3: + err_4 = _a.sent(); + throw err_4; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * @async + * Resumes upload session and continue uploading the file from the last sent range + * @return The promise resolves to the uploaded response + */ + LargeFileUploadTask.prototype.resume = function () { + return __awaiter(this, void 0, void 0, function () { + var self, err_5; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 4, , 5]); + return [4 /*yield*/, self.getStatus()]; + case 2: + _a.sent(); + return [4 /*yield*/, self.upload()]; + case 3: return [2 /*return*/, _a.sent()]; + case 4: + err_5 = _a.sent(); + throw err_5; + case 5: return [2 /*return*/]; + } + }); + }); + }; + return LargeFileUploadTask; +}()); +exports.LargeFileUploadTask = LargeFileUploadTask; +//# sourceMappingURL=LargeFileUploadTask.js.map \ No newline at end of file diff --git a/lib/src/LargeFileUploadTask.js.map b/lib/src/LargeFileUploadTask.js.map new file mode 100644 index 000000000..147212eed --- /dev/null +++ b/lib/src/LargeFileUploadTask.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LargeFileUploadTask.js","sourceRoot":"","sources":["../../src/LargeFileUploadTask.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,iCAAgC;AAoB/B,CAAC;AA0BF;;GAEG;AACH;IAqBI;;;;;;OAMG;IACH,6BAAY,MAAc,EAAE,IAAgB,EAAE,aAAqC,EAAE,OAAmC;QAZxH;;UAEE;QACM,sBAAiB,GAAW,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QAUhD,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACjC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC;SAC9C;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,aAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAC9D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AAM,KAAG,CAAC;;;;;KAEjB;IACL,0BAAC;AAAD,CAAC,AAnMD,IAmMC;AAnMY,kDAAmB"} \ No newline at end of file diff --git a/lib/src/OneDriveLargeFileUploadTask.d.ts b/lib/src/OneDriveLargeFileUploadTask.d.ts new file mode 100644 index 000000000..79748dfbb --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTask.d.ts @@ -0,0 +1,70 @@ +/** + * @module OneDriveLargeFileUploadTask + */ +/// +import { Client } from "./index"; +import { FileObject, LargeFileUploadSession, LargeFileUploadTask, LargeFileUploadTaskOptions } from "./LargeFileUploadTask"; +/** + * @interface + * Signature to define options when creating an upload task + * @property {string} fileName - Specifies the name of a file to be uploaded (with extension) + * @property {string} [path] - The path to which the file needs to be uploaded + * @property {number} [rangeSize] - Specifies the range chunk size + */ +interface OneDriveLargeFileUploadOptions { + fileName: string; + path?: string; + rangeSize?: number; +} +/** + * Class representing OneDriveLargeFileUploadTask + */ +export declare class OneDriveLargeFileUploadTask extends LargeFileUploadTask { + /** + * Default path for the file being uploaded + */ + static DEFAULT_UPLOAD_PATH: string; + /** + * Constructs a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions); + /** + * @static + * @async + * Creates a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {Blob | Buffer | File} file - File represented as Blob, Buffer or File + * @param {OneDriveLargeFileUploadOptions} options - The options for upload task + * @return The promise that will be resolves to OneDriveLargeFileUploadTask instance + */ + static create(client: Client, file: Blob | Buffer | File, options: OneDriveLargeFileUploadOptions): Promise; + /** + * @static + * Constructs the create session url for Onedrive + * @param {string} fileName - The name of the file + * @param {path} [path = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH] - The path for the upload + * @return The constructed create session url + */ + static constructCreateSessionUrl(fileName: string, path?: string): string; + /** + * @static + * @async + * Makes request to the server to create an upload session + * @param {Client} client - The GraphClient instance + * @param {string} requestUrl - The URL to create the upload session + * @param {string} fileName - The name of a file to upload, (with extension) + * @return The promise that resolves to LargeFileUploadSession + */ + static createUploadSession(client: Client, requestUrl: string, fileName: string): Promise; + /** + * Commits upload session to end uploading + * @param {string} requestUrl - The URL to commit the upload session + * @return The promise resolves to committed response + */ + commit(requestUrl: string): Promise; +} +export {}; diff --git a/lib/src/OneDriveLargeFileUploadTask.js b/lib/src/OneDriveLargeFileUploadTask.js new file mode 100644 index 000000000..6cf6be92c --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTask.js @@ -0,0 +1,219 @@ +"use strict"; +/** + * @module OneDriveLargeFileUploadTask + */ +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var LargeFileUploadTask_1 = require("./LargeFileUploadTask"); +var OneDriveLargeFileUploadTaskUtil_1 = require("./OneDriveLargeFileUploadTaskUtil"); +; +/** + * Class representing OneDriveLargeFileUploadTask + */ +var OneDriveLargeFileUploadTask = /** @class */ (function (_super) { + __extends(OneDriveLargeFileUploadTask, _super); + /** + * Constructs a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + function OneDriveLargeFileUploadTask(client, file, uploadSession, options) { + return _super.call(this, client, file, uploadSession, options) || this; + } + /** + * @static + * @async + * Creates a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {Blob | Buffer | File} file - File represented as Blob, Buffer or File + * @param {OneDriveLargeFileUploadOptions} options - The options for upload task + * @return The promise that will be resolves to OneDriveLargeFileUploadTask instance + */ + OneDriveLargeFileUploadTask.create = function (client, file, options) { + return __awaiter(this, void 0, void 0, function () { + var fileObj, _file, b, requestUrl, session, rangeSize, err_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + fileObj = {}; + fileObj.name = options.fileName; + switch (file.constructor.name) { + case "Blob": + fileObj.content = new File([file], fileObj.name); + fileObj.size = fileObj.content.size; + break; + case "File": + _file = file; + fileObj.content = _file; + fileObj.size = _file.size; + break; + case "Buffer": + b = file; + fileObj.size = b.byteLength - b.byteOffset; + fileObj.content = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); + break; + } + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + requestUrl = OneDriveLargeFileUploadTask.constructCreateSessionUrl(options.fileName, options.path); + return [4 /*yield*/, OneDriveLargeFileUploadTask.createUploadSession(client, requestUrl, options.fileName)]; + case 2: + session = _a.sent(); + rangeSize = OneDriveLargeFileUploadTaskUtil_1.getValidRangeSize(options.rangeSize); + return [2 /*return*/, new OneDriveLargeFileUploadTask(client, fileObj, session, { rangeSize: rangeSize })]; + case 3: + err_1 = _a.sent(); + throw err_1; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * @static + * Constructs the create session url for Onedrive + * @param {string} fileName - The name of the file + * @param {path} [path = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH] - The path for the upload + * @return The constructed create session url + */ + OneDriveLargeFileUploadTask.constructCreateSessionUrl = function (fileName, path) { + if (path === void 0) { path = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH; } + fileName = fileName.trim(); + path = path.trim(); + if (path === "") { + path = "/"; + } + if (path[0] !== "/") { + path = "/" + path; + } + if (path[path.length - 1] !== "/") { + path = path + "/"; + } + return encodeURI("/me/drive/root:" + path + fileName + ":/createUploadSession"); + }; + /** + * @static + * @async + * Makes request to the server to create an upload session + * @param {Client} client - The GraphClient instance + * @param {string} requestUrl - The URL to create the upload session + * @param {string} fileName - The name of a file to upload, (with extension) + * @return The promise that resolves to LargeFileUploadSession + */ + OneDriveLargeFileUploadTask.createUploadSession = function (client, requestUrl, fileName) { + return __awaiter(this, void 0, void 0, function () { + var payload, session, err_2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + payload = { + item: { + "@microsoft.graph.conflictBehavior": "rename", + name: fileName + } + }; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, client.api(requestUrl).post(payload)]; + case 2: + session = _a.sent(); + return [2 /*return*/, { + url: session.uploadUrl, + expiry: new Date(session.expirationDateTime) + }]; + case 3: + err_2 = _a.sent(); + throw err_2; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * Commits upload session to end uploading + * @param {string} requestUrl - The URL to commit the upload session + * @return The promise resolves to committed response + */ + OneDriveLargeFileUploadTask.prototype.commit = function (requestUrl) { + return __awaiter(this, void 0, void 0, function () { + var self, payload, err_3; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + self = this; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + payload = { + name: self.file.name, + "@microsoft.graph.conflictBehavior": "rename", + "@microsoft.graph.sourceUrl": self.uploadSession.url + }; + return [4 /*yield*/, self.client + .api(requestUrl) + .put(payload)]; + case 2: return [2 /*return*/, _a.sent()]; + case 3: + err_3 = _a.sent(); + throw err_3; + case 4: return [2 /*return*/]; + } + }); + }); + }; + /** + * Default path for the file being uploaded + */ + OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH = "/"; + return OneDriveLargeFileUploadTask; +}(LargeFileUploadTask_1.LargeFileUploadTask)); +exports.OneDriveLargeFileUploadTask = OneDriveLargeFileUploadTask; +//# sourceMappingURL=OneDriveLargeFileUploadTask.js.map \ No newline at end of file diff --git a/lib/src/OneDriveLargeFileUploadTask.js.map b/lib/src/OneDriveLargeFileUploadTask.js.map new file mode 100644 index 000000000..d47c4eb61 --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTask.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OneDriveLargeFileUploadTask.js","sourceRoot":"","sources":["../../src/OneDriveLargeFileUploadTask.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,6DAA4H;AAC5H,qFAAsE;AAarE,CAAC;AAEF;;GAEG;AACH;IAAiD,+CAAmB;IAOhE;;;;;;OAMG;IACH,qCAAY,MAAc,EAAE,IAAgB,EAAE,aAAqC,EAAE,OAAmC;eACpH,kBAAM,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACU,kCAAM,GAAnB,UAAoB,MAAc,EAAE,IAA0B,EAAE,OAAuC;;;;;;wBAC/F,OAAO,GAA2B,EAAE,CAAC;wBACzC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC;wBAChC,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;4BAC3B,KAAK,MAAM;gCACP,OAAO,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,CAAO,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gCACvD,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gCACpC,MAAM;4BACV,KAAK,MAAM;gCACH,KAAK,GAAS,IAAI,CAAC;gCACvB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;gCACxB,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gCAC1B,MAAM;4BACV,KAAK,QAAQ;gCACL,CAAC,GAAW,IAAI,CAAC;gCACrB,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;gCAC3C,OAAO,CAAC,OAAO,GAAG,CAAC,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AAgB;;;;;;wBAC7E,OAAO,GAAG;4BACV,IAAI,EAAE;gCACF,mCAAmC,EAAE,QAAQ;gCAC7C,IAAI,EAAE,QAAQ;6BACjB;yBACJ,CAAC;;;;wBAEgB,qBAAM,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAA;;wBAApD,OAAO,GAAG,SAA0C;wBACxD,sBAA+B;gCAC3B,GAAG,EAAE,OAAO,CAAC,SAAS;gCACtB,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;6BAC/C,EAAC;;;wBAEF,MAAM,KAAG,CAAC;;;;;KAEjB;IAED;;;;OAIG;IACG,4CAAM,GAAZ,UAAa,UAAkB;;;;;;wBACvB,IAAI,GAAG,IAAI,CAAC;;;;wBAER,OAAO,GAAG;4BACV,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;4BACpB,mCAAmC,EAAE,QAAQ;4BAC7C,4BAA4B,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG;yBACvD,CAAA;wBACM,qBAAM,IAAI,CAAC,MAAM;iCACnB,GAAG,CAAC,UAAU,CAAC;iCACf,GAAG,CAAC,OAAO,CAAC,EAAA;4BAFjB,sBAAO,SAEU,EAAA;;;wBAEjB,MAAM,KAAG,CAAC;;;;;KAEjB;IA1HD;;OAEG;IACI,+CAAmB,GAAW,GAAG,CAAC;IAwH7C,kCAAC;CAAA,AA7HD,CAAiD,yCAAmB,GA6HnE;AA7HY,kEAA2B"} \ No newline at end of file diff --git a/lib/src/OneDriveLargeFileUploadTaskUtil.d.ts b/lib/src/OneDriveLargeFileUploadTaskUtil.d.ts new file mode 100644 index 000000000..95dd1d7eb --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTaskUtil.d.ts @@ -0,0 +1,10 @@ +/** + * @module OneDriveLargeFileUploadTaskUtil + */ +/** + * Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session}) + * + * @param {number} [rangeSize = DEFAULT_FILE_SIZE] - The rangeSize value. + * @return The valid rangeSize + */ +export declare const getValidRangeSize: (rangeSize?: number) => number; diff --git a/lib/src/OneDriveLargeFileUploadTaskUtil.js b/lib/src/OneDriveLargeFileUploadTaskUtil.js new file mode 100644 index 000000000..cca092c9d --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTaskUtil.js @@ -0,0 +1,36 @@ +"use strict"; +/** + * @module OneDriveLargeFileUploadTaskUtil + */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Default value for the rangeSize + * Recommended size is between 5 - 10 MB {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#best-practices} + */ +var DEFAULT_FILE_SIZE = 5 * 1024 * 1024; +/** + * Rounds off the given value to a multiple of 320 KB + * @param {number} value - The value + * @return The rounded off value + */ +var roundTo320KB = function (value) { + if (value > (320 * 1024)) { + value = Math.floor(value / (320 * 1024)) * 320 * 1024; + } + return value; +}; +/** + * Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session}) + * + * @param {number} [rangeSize = DEFAULT_FILE_SIZE] - The rangeSize value. + * @return The valid rangeSize + */ +exports.getValidRangeSize = function (rangeSize) { + if (rangeSize === void 0) { rangeSize = DEFAULT_FILE_SIZE; } + var sixtyMB = 60 * 1024 * 1024; + if (rangeSize > sixtyMB) { + rangeSize = sixtyMB; + } + return roundTo320KB(rangeSize); +}; +//# sourceMappingURL=OneDriveLargeFileUploadTaskUtil.js.map \ No newline at end of file diff --git a/lib/src/OneDriveLargeFileUploadTaskUtil.js.map b/lib/src/OneDriveLargeFileUploadTaskUtil.js.map new file mode 100644 index 000000000..6fe31ce8e --- /dev/null +++ b/lib/src/OneDriveLargeFileUploadTaskUtil.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OneDriveLargeFileUploadTaskUtil.js","sourceRoot":"","sources":["../../src/OneDriveLargeFileUploadTaskUtil.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEF;;;GAGG;AACJ,IAAM,iBAAiB,GAAW,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD;;;;GAIG;AACH,IAAM,YAAY,GAAG,UAAC,KAAa;IAC/B,IAAI,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE;QACtB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;KACzD;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAA;AAED;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,UAAC,SAAqC;IAArC,0BAAA,EAAA,6BAAqC;IACnE,IAAM,OAAO,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,IAAI,SAAS,GAAG,OAAO,EAAE;QACrB,SAAS,GAAG,OAAO,CAAC;KACvB;IACD,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/src/Range.d.ts b/lib/src/Range.d.ts new file mode 100644 index 000000000..f851878bf --- /dev/null +++ b/lib/src/Range.d.ts @@ -0,0 +1,18 @@ +/** + * @module Range + */ +/** +* Class representing Range +*/ +export declare class Range { + /** The minimum value of the range */ + minValue: number; + /** The maximum value of the range */ + maxValue: number; + /** + * Creates a range for given min and max values + * @param {number} [minVal = -1] - The minimum value. + * @param {number} [maxVal = -1] - The maximum value. + */ + constructor(minVal?: number, maxVal?: number); +} diff --git a/lib/src/Range.js b/lib/src/Range.js new file mode 100644 index 000000000..cf5b2ac1d --- /dev/null +++ b/lib/src/Range.js @@ -0,0 +1,25 @@ +"use strict"; +/** + * @module Range + */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** +* Class representing Range +*/ +var Range = /** @class */ (function () { + /** + * Creates a range for given min and max values + * @param {number} [minVal = -1] - The minimum value. + * @param {number} [maxVal = -1] - The maximum value. + */ + function Range(minVal, maxVal) { + if (minVal === void 0) { minVal = -1; } + if (maxVal === void 0) { maxVal = -1; } + var self = this; + self.minValue = minVal; + self.maxValue = maxVal; + } + return Range; +}()); +exports.Range = Range; +//# sourceMappingURL=Range.js.map \ No newline at end of file diff --git a/lib/src/Range.js.map b/lib/src/Range.js.map new file mode 100644 index 000000000..1ad7a384b --- /dev/null +++ b/lib/src/Range.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Range.js","sourceRoot":"","sources":["../../src/Range.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEF;;EAEE;AACH;IAMI;;;;OAIG;IACH,eAAY,MAAmB,EAAE,MAAmB;QAAxC,uBAAA,EAAA,UAAkB,CAAC;QAAE,uBAAA,EAAA,UAAkB,CAAC;QAChD,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;IAC3B,CAAC;IACL,YAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,sBAAK"} \ No newline at end of file diff --git a/lib/src/ResponseHandler.js b/lib/src/ResponseHandler.js index bb67a702e..4acb72864 100644 --- a/lib/src/ResponseHandler.js +++ b/lib/src/ResponseHandler.js @@ -1,23 +1,37 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ResponseHandler = (function () { +var ResponseHandler = /** @class */ (function () { function ResponseHandler() { } ResponseHandler.init = function (res, err, resContents, callback) { - if (res && res.ok) { + if (res && res.ok) { // 2xx callback(null, resContents, res); } - else { + else { // not OK response if (err == null && res != null) - if (resContents != null && resContents.error != null) + if (resContents != null && resContents.error != null) // if error was passed to body callback(ResponseHandler.buildGraphErrorFromResponseObject(resContents.error, res.status), null, res); else callback(ResponseHandler.defaultGraphError(res.status), null, res); - else + else // pass back error as first param callback(ResponseHandler.ParseError(err), null, res); } }; + /* + Example error for https://graph.microsoft.com/v1.0/me/events?$top=3&$search=foo + { + "error": { + "code": "SearchEvents", + "message": "The parameter $search is not currently supported on the Events resource.", + "innerError": { + "request-id": "b31c83fd-944c-4663-aa50-5d9ceb367e19", + "date": "2016-11-17T18:37:45" + } + } + } + */ ResponseHandler.ParseError = function (rawErr) { + // if we couldn't find an error obj to parse, just return an object with a status code and date if (!rawErr) { return ResponseHandler.defaultGraphError(-1); } diff --git a/lib/src/ResponseHandler.js.map b/lib/src/ResponseHandler.js.map index 0c7a1d010..f45d75d53 100644 --- a/lib/src/ResponseHandler.js.map +++ b/lib/src/ResponseHandler.js.map @@ -1 +1 @@ -{"version":3,"file":"ResponseHandler.js","sourceRoot":"","sources":["../../src/ResponseHandler.ts"],"names":[],"mappings":";;AAEA;IAAA;IAiEA,CAAC;IAhEU,oBAAI,GAAX,UAAY,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,QAA6B;QAC5D,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE;YACf,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAA;SACnC;aAAM;YACH,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI;gBAC1B,IAAI,WAAW,IAAI,IAAI,IAAI,WAAW,CAAC,KAAK,IAAI,IAAI;oBAChD,QAAQ,CAAC,eAAe,CAAC,iCAAiC,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;;oBAEtG,QAAQ,CAAC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;;gBAEtE,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;SAC3D;IACL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AAE,IAAI;YACb,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,IAAI,EAAE,IAAI;SACb,CAAA;IACL,CAAC;IAEM,8CAA8B,GAArC,UAAsC,MAAa;QAC/C,IAAM,KAAK,GAAe,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC/B,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,KAAK,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,iDAAiC,GAAxC,UAAyC,MAAW,EAAE,UAAkB;QACpE,OAAO;YACH,UAAU,YAAA;YACV,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;YACnF,IAAI,EAAE,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC,IAAI,IAAI,EAAE;YACtF,IAAI,EAAE,MAAM;SACf,CAAC;IACN,CAAC;IACL,sBAAC;AAAD,CAAC,AAjED,IAiEC;AAjEY,0CAAe"} \ No newline at end of file diff --git a/lib/src/ResponseType.d.ts b/lib/src/ResponseType.d.ts index 302d3b4c0..acd2b6aa9 100644 --- a/lib/src/ResponseType.d.ts +++ b/lib/src/ResponseType.d.ts @@ -1,3 +1,13 @@ +/** + * @enum + * Enum for ResponseType values + * @property {string} ARRAYBUFFER - To download response content as an [ArrayBuffer]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer} + * @property {string} BLOB - To download content as a [binary/blob] {@link https://developer.mozilla.org/en-US/docs/Web/API/Blob} + * @property {string} DOCUMENT - This downloads content as a json, See [this for more info]{@link https://github.com/microsoftgraph/msgraph-sdk-javascript/pull/63} + * @property {string} JSON - To download response content as a json + * @property {string} STREAM - To download response as a [stream]{@link https://nodejs.org/api/stream.html} + * @property {string} TEXT - For downloading response as a text + */ export declare enum ResponseType { ARRAYBUFFER = "arraybuffer", BLOB = "blob", diff --git a/lib/src/ResponseType.js b/lib/src/ResponseType.js index f69df9b68..c24ca73bd 100644 --- a/lib/src/ResponseType.js +++ b/lib/src/ResponseType.js @@ -1,4 +1,14 @@ "use strict"; +/** + * @enum + * Enum for ResponseType values + * @property {string} ARRAYBUFFER - To download response content as an [ArrayBuffer]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer} + * @property {string} BLOB - To download content as a [binary/blob] {@link https://developer.mozilla.org/en-US/docs/Web/API/Blob} + * @property {string} DOCUMENT - This downloads content as a json, See [this for more info]{@link https://github.com/microsoftgraph/msgraph-sdk-javascript/pull/63} + * @property {string} JSON - To download response content as a json + * @property {string} STREAM - To download response as a [stream]{@link https://nodejs.org/api/stream.html} + * @property {string} TEXT - For downloading response as a text + */ Object.defineProperty(exports, "__esModule", { value: true }); var ResponseType; (function (ResponseType) { diff --git a/lib/src/ResponseType.js.map b/lib/src/ResponseType.js.map index 71cd956b7..32a5b23f9 100644 --- a/lib/src/ResponseType.js.map +++ b/lib/src/ResponseType.js.map @@ -1 +1 @@ -{"version":3,"file":"ResponseType.js","sourceRoot":"","sources":["../../src/ResponseType.ts"],"names":[],"mappings":";;AAWA,IAAY,YAOX;AAPD,WAAY,YAAY;IACpB,2CAA2B,CAAA;IAC3B,6BAAa,CAAA;IACb,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,6BAAa,CAAA;AACjB,CAAC,EAPW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAOvB"} \ No newline at end of file +{"version":3,"file":"ResponseType.js","sourceRoot":"","sources":["../../src/ResponseType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAEH,IAAY,YAOX;AAPD,WAAY,YAAY;IACpB,2CAA2B,CAAA;IAC3B,6BAAa,CAAA;IACb,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,iCAAiB,CAAA;IACjB,6BAAa,CAAA;AACjB,CAAC,EAPW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAOvB"} \ No newline at end of file diff --git a/lib/src/common.js b/lib/src/common.js index 7a337a482..29bcdf06b 100644 --- a/lib/src/common.js +++ b/lib/src/common.js @@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.oDataQueryNames = ["select", "expand", "orderby", "filter", "top", "skip", "skipToken", "count"]; exports.DEFAULT_VERSION = "v1.0"; exports.GRAPH_BASE_URL = "https://graph.microsoft.com/"; +// NOTE: This should be kept up to date with the version used in package.json. +// If you are changing this please ensure you are also changing it in package.json. exports.PACKAGE_VERSION = "1.2.0"; +// support oData params with and without $ prefix exports.oDataQueryNames = exports.oDataQueryNames.concat(exports.oDataQueryNames.map(function (s) { return "$" + s; })); //# sourceMappingURL=common.js.map \ No newline at end of file diff --git a/lib/src/common.js.map b/lib/src/common.js.map index 6b545bb12..aee23de74 100644 --- a/lib/src/common.js.map +++ b/lib/src/common.js.map @@ -1 +1 @@ -{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;AAAW,QAAA,eAAe,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9F,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,cAAc,GAAG,8BAA8B,CAAC;AAIhD,QAAA,eAAe,GAAG,OAAO,CAAC;AAGvC,uBAAe,GAAG,uBAAe,CAAC,MAAM,CAAC,uBAAe,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,GAAG,GAAC,CAAC,EAAL,CAAK,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;AAAW,QAAA,eAAe,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9F,QAAA,eAAe,GAAG,MAAM,CAAC;AACzB,QAAA,cAAc,GAAG,8BAA8B,CAAC;AAE7D,8EAA8E;AAC9E,mFAAmF;AACtE,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,iDAAiD;AACjD,uBAAe,GAAG,uBAAe,CAAC,MAAM,CAAC,uBAAe,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,GAAG,GAAC,CAAC,EAAL,CAAK,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/src/index.d.ts b/lib/src/index.d.ts index cff2306fe..ebb7dd033 100644 --- a/lib/src/index.d.ts +++ b/lib/src/index.d.ts @@ -8,4 +8,5 @@ export declare class Client { export * from "./GraphRequest"; export * from "./common"; export * from "./ResponseHandler"; +export * from "./OneDriveLargeFileUploadTask"; export * from "./ResponseType"; diff --git a/lib/src/index.js b/lib/src/index.js index 134c98ffc..c1f25d022 100644 --- a/lib/src/index.js +++ b/lib/src/index.js @@ -5,8 +5,9 @@ function __export(m) { Object.defineProperty(exports, "__esModule", { value: true }); var common_1 = require("./common"); var GraphRequest_1 = require("./GraphRequest"); -var Client = (function () { +var Client = /** @class */ (function () { function Client() { + // specify client defaults this.config = { debugLogging: false, defaultVersion: common_1.DEFAULT_VERSION, @@ -20,6 +21,9 @@ var Client = (function () { } return graphClient; }; + /* + * Entry point for calling api + */ Client.prototype.api = function (path) { return new GraphRequest_1.GraphRequest(this.config, path); }; @@ -29,5 +33,6 @@ exports.Client = Client; __export(require("./GraphRequest")); __export(require("./common")); __export(require("./ResponseHandler")); +__export(require("./OneDriveLargeFileUploadTask")); __export(require("./ResponseType")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/src/index.js.map b/lib/src/index.js.map index 9d64ddab4..284a448f1 100644 --- a/lib/src/index.js.map +++ b/lib/src/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,mCAAiE;AACjE,+CAA2C;AAE3C;IAAA;QAEI,WAAM,GAAW;YACb,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,wBAAe;YAC/B,OAAO,EAAE,uBAAc;SAC1B,CAAC;IAiBN,CAAC;IAfU,WAAI,GAAX,UAAY,aAAsB;QAC9B,IAAI,WAAW,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,KAAK,IAAI,GAAG,IAAI,aAAa,EAAE;YAC3B,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;SAChD;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAKD,oBAAG,GAAH,UAAI,IAAW;QACX,OAAO,IAAI,2BAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEL,aAAC;AAAD,CAAC,AAvBD,IAuBC;AAvBY,wBAAM;AAyBnB,oCAA+B;AAC/B,8BAAyB;AACzB,uCAAkC;AAClC,oCAA+B"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,mCAAiE;AACjE,+CAA2C;AAE3C;IAAA;QACI,0BAA0B;QAC1B,WAAM,GAAW;YACb,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,wBAAe;YAC/B,OAAO,EAAE,uBAAc;SAC1B,CAAC;IAiBN,CAAC;IAfU,WAAI,GAAX,UAAY,aAAsB;QAC9B,IAAI,WAAW,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,KAAK,IAAI,GAAG,IAAI,aAAa,EAAE;YAC3B,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;SAChD;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,oBAAG,GAAH,UAAI,IAAW;QACX,OAAO,IAAI,2BAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEL,aAAC;AAAD,CAAC,AAvBD,IAuBC;AAvBY,wBAAM;AAyBnB,oCAA+B;AAC/B,8BAAyB;AACzB,uCAAkC;AAClC,mDAA8C;AAC9C,oCAA+B"} \ No newline at end of file diff --git a/package.json b/package.json index 518d519b8..6f76004dc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "build-with-vendor": "npm run compile && npm run rollup-with-vendor", "build": "npm run compile && npm run rollup-core && npm run rollup-with-vendor", "test": "mocha lib/spec/core", - "test:types": "tsc --p spec/types && mocha spec/types" + "test:types": "tsc -p spec && mocha spec/types", + "test:tasks": "tsc -p spec && mocha spec/tasks" }, "dependencies": { "es6-promise": "^4.1.0", diff --git a/samples/browser/index.html b/samples/browser/index.html index 9b3554b77..3bc6cc31b 100644 --- a/samples/browser/index.html +++ b/samples/browser/index.html @@ -1,5 +1,6 @@ + Browser test @@ -7,7 +8,7 @@ + -

Please check the Node.js sample for more examples on calling the Graph.

+

Please check the Node.js sample for more examples on calling the Graph.

-

-By loading this page, we called /me endpoint on the Microsoft Graph. Open your browser's' JavaScript console to see the result! -

-
-

Your user photo from /me/photo/$value:

- -

-Also, you can update your profile picture: -
-

-
+

+ By loading this page, we called /me endpoint on the Microsoft Graph. Open your browser's' JavaScript console to see the result! +

+
+

Your user photo from /me/photo/$value:

+ +

+ Also, you can update your profile picture: + +
+

+
+ diff --git a/spec/core/responseHandling.ts b/spec/core/responseHandling.ts index 815089505..b41b3bd8c 100644 --- a/spec/core/responseHandling.ts +++ b/spec/core/responseHandling.ts @@ -6,6 +6,8 @@ import * as mocha from 'mocha' import * as assert from 'assert'; +declare const describe, it; + const _200_RES_BODY: any = { a: 1 }; const _200_RES_INIT: ResponseInit = { status: 200 }; const _200_RES: Response = diff --git a/spec/core/urlGeneration.ts b/spec/core/urlGeneration.ts index d66ff0783..fcafd6d23 100644 --- a/spec/core/urlGeneration.ts +++ b/spec/core/urlGeneration.ts @@ -4,6 +4,8 @@ import { Client as GraphClient } from "../../src/index" const client = GraphClient.init(); +declare const describe, it; + let cases = []; cases.push({ diff --git a/spec/core/urlParsing.ts b/spec/core/urlParsing.ts index 673cc52c1..0a6c61a24 100644 --- a/spec/core/urlParsing.ts +++ b/spec/core/urlParsing.ts @@ -4,6 +4,8 @@ import {Client as GraphClient} from "../../src/index" const client = GraphClient.init(); +declare const describe, it; + let testCases = { "/me": "https://graph.microsoft.com/v1.0/me", diff --git a/spec/types/package-lock.json b/spec/package-lock.json similarity index 100% rename from spec/types/package-lock.json rename to spec/package-lock.json diff --git a/spec/types/package.json b/spec/package.json similarity index 100% rename from spec/types/package.json rename to spec/package.json diff --git a/spec/types/empty-spreadsheet.xlsx b/spec/sample_files/empty-spreadsheet.xlsx similarity index 100% rename from spec/types/empty-spreadsheet.xlsx rename to spec/sample_files/empty-spreadsheet.xlsx diff --git a/spec/types/onenotepage.html b/spec/sample_files/onenotepage.html similarity index 100% rename from spec/types/onenotepage.html rename to spec/sample_files/onenotepage.html diff --git a/spec/types/onenotepage_fileattachment.html b/spec/sample_files/onenotepage_fileattachment.html similarity index 100% rename from spec/types/onenotepage_fileattachment.html rename to spec/sample_files/onenotepage_fileattachment.html diff --git a/spec/sample_files/sample_image.jpg b/spec/sample_files/sample_image.jpg new file mode 100644 index 000000000..3ed850c3d Binary files /dev/null and b/spec/sample_files/sample_image.jpg differ diff --git a/spec/secrets.sample.ts b/spec/secrets.sample.ts new file mode 100644 index 000000000..f4c5dbebb --- /dev/null +++ b/spec/secrets.sample.ts @@ -0,0 +1,7 @@ +/** + * @file + * Defines access token exporting structure + * + * To use authentication based(making real requests to the graph service) testing populate this access token's value and rename this fil as secrets.ts + */ +export const AccessToken = ""; \ No newline at end of file diff --git a/spec/tasks/LargeFileUploadTask.ts b/spec/tasks/LargeFileUploadTask.ts new file mode 100644 index 000000000..94cab8542 --- /dev/null +++ b/spec/tasks/LargeFileUploadTask.ts @@ -0,0 +1,171 @@ +import { assert } from "chai"; +import { getClient } from "../test-helper"; +import { LargeFileUploadTask } from "../../lib/src/LargeFileUploadTask"; + +declare const describe, it; + +describe('Parsing Range', () => { + let name = "sample_image.jpg", + arrayBuffer = new ArrayBuffer(80000), + size = 100000; + let fileObj = { + content: arrayBuffer, + name, + size + }; + let uploadSession = { + url: "test url", + expiry: new Date() + }; + let options = {}; + let uploadTask = new LargeFileUploadTask(getClient(), fileObj, uploadSession, options); + it('Should return default range for given undefined range', (done) => { + let range = uploadTask.parseRange([]); + assert.equal(range.minValue, -1); + assert.equal(range.maxValue, -1); + done(); + }); + + it('Should return default range for given empty range', (done) => { + let range = uploadTask.parseRange([""]); + assert.equal(range.minValue, -1); + assert.equal(range.maxValue, -1); + done(); + }); + + it('Should return valid range for given range with from and to values', (done) => { + let range = uploadTask.parseRange(["100-200"]); + assert.equal(range.minValue, 100); + assert.equal(range.maxValue, 200); + done(); + }); + + it('Should return valid range for given range without to value', (done) => { + let range = uploadTask.parseRange(["0-"]); + assert.equal(range.minValue, 0); + assert.equal(range.maxValue, 99999); + done(); + }); +}); + +describe('Update Task Status', () => { + let name = "sample_image.jpg", + arrayBuffer = new ArrayBuffer(80000), + size = 100000; + let fileObj = { + content: arrayBuffer, + name, + size + }; + let uploadSession = { + url: "test url", + expiry: new Date() + }; + let options = {}; + let uploadTask = new LargeFileUploadTask(getClient(), fileObj, uploadSession, options); + it('Should update status with expiration date and next expected ranges as given', (done) => { + let statusResponse = { + expirationDateTime: "2018-08-06T09:05:45.195Z", + nextExpectedRanges: ["100-2000"] + } + uploadTask.updateTaskStatus(statusResponse); + assert.equal(uploadTask.nextRange.minValue, 100); + assert.equal(uploadTask.nextRange.maxValue, 2000); + done(); + }); + it('Should update status with given expiration date and (fileSize - 1) for next expected range maxValue', (done) => { + let statusResponse = { + expirationDateTime: "2018-08-06T09:05:45.195Z", + nextExpectedRanges: ["100-"] + } + uploadTask.updateTaskStatus(statusResponse); + assert.equal(uploadTask.nextRange.minValue, 100); + assert.equal(uploadTask.nextRange.maxValue, 99999); + done(); + }); +}); + +describe('GetNextRange', () => { + let name = "sample_image.jpg", + arrayBuffer = new ArrayBuffer(80000), + size = 328680; + let fileObj = { + content: arrayBuffer, + name, + size + }; + let uploadSession = { + url: "test url", + expiry: new Date() + }; + let options = { + rangeSize: 327680 + }; + let uploadTask = new LargeFileUploadTask(getClient(), fileObj, uploadSession, options); + + it('Should return proper next range well within the file size', (done) => { + let nextRange = uploadTask.getNextRange(); + assert.equal(nextRange.minValue, 0); + assert.equal(nextRange.maxValue, 327679); + done(); + }); + + it('Should return next range maxValue equal to the file size', (done) => { + let statusResponse = { + expirationDateTime: "2018-08-06T09:05:45.195Z", + nextExpectedRanges: ["327680-"] + }; + uploadTask.updateTaskStatus(statusResponse); + let nextRange = uploadTask.getNextRange(); + assert.equal(nextRange.minValue, 327680); + assert.equal(nextRange.maxValue, 328679); + done(); + }); + + it('Should return next range as default(empty) range, this is for the upload task completed', (done) => { + let statusResponse = { + expirationDateTime: "2018-08-06T09:05:45.195Z", + nextExpectedRanges: [] + }; + uploadTask.updateTaskStatus(statusResponse); + let nextRange = uploadTask.getNextRange(); + assert.equal(nextRange.minValue, -1); + assert.equal(nextRange.maxValue, -1); + done(); + }); +}); + +describe('Upload File', () => { + let name = "sample_image.jpg", + arrayBuffer = new ArrayBuffer(80000), + size = 328680; + let fileObj = { + content: arrayBuffer, + name, + size + }; + let uploadSession = { + url: "test url", + expiry: new Date() + }; + let options = { + rangeSize: 327680 + }; + let uploadTask = new LargeFileUploadTask(getClient(), fileObj, uploadSession, options); + it('Should return an exception while trying to upload the file upload completed task', (done) => { + let statusResponse = { + expirationDateTime: "2018-08-06T09:05:45.195Z", + nextExpectedRanges: [] + }; + uploadTask.updateTaskStatus(statusResponse); + uploadTask.upload() + .then((res) => { + throw new Error("Upload is working for upload completed task"); + }) + .catch((err) => { + assert.equal(err.name, "Invalid Session"); + assert.equal(err.message, "Task with which you are trying to upload is already completed, Please check for your uploaded file"); + done(); + }); + }); +}); diff --git a/spec/tasks/OneDriveLargeFileUploadTask.ts b/spec/tasks/OneDriveLargeFileUploadTask.ts new file mode 100644 index 000000000..31d51768d --- /dev/null +++ b/spec/tasks/OneDriveLargeFileUploadTask.ts @@ -0,0 +1,39 @@ +import { assert } from "chai"; +import { OneDriveLargeFileUploadTask } from "../../lib/src/OneDriveLargeFileUploadTask"; + +declare const describe, it; + +describe('constructCreateSessionUrl', () => { + let spaceFileName = " test.png "; + let fileName = "test.png"; + let specialFileName = "test file.png"; + let encodedFileName = "test%20file.png"; + + it('Should trim the extra spaces in the filename', () => { + assert.equal(`/me/drive/root:/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(spaceFileName)); + }); + + it('Should encode space in the filename', () => { + assert.equal(`/me/drive/root:/${encodedFileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(specialFileName)); + }); + + it('Should return url with default root value', () => { + assert.equal(`/me/drive/root:/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(fileName)); + }); + + it('Should return url with default root value for an empty path string', () => { + assert.equal(`/me/drive/root:/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(fileName, "")); + }); + + it('Should add / in front of the path', () => { + assert.equal(`/me/drive/root:/Documents/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(fileName, "Documents/")); + }); + + it('Should add / in back of the path', () => { + assert.equal(`/me/drive/root:/Documents/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(fileName, "/Documents")); + }); + + it('Should trim the extra spaces in the path', () => { + assert.equal(`/me/drive/root:/Documents/${fileName}:/createUploadSession`, OneDriveLargeFileUploadTask.constructCreateSessionUrl(fileName, " /Documents/ ")); + }); +}); \ No newline at end of file diff --git a/spec/tasks/OneDriveLargeFileUploadTaskUtil.ts b/spec/tasks/OneDriveLargeFileUploadTaskUtil.ts new file mode 100644 index 000000000..d90986931 --- /dev/null +++ b/spec/tasks/OneDriveLargeFileUploadTaskUtil.ts @@ -0,0 +1,23 @@ +import { assert } from "chai"; +import * as OneDriveLargeFileUploadTaskUtil from "../../lib/src/OneDriveLargeFileUploadTaskUtil"; + +declare const describe, it; + +describe('getValidRangeSize', () => { + it('Should return size in multiple of 320KB for the size not a multiple of 320KB', (done) => { + assert.equal(327680, OneDriveLargeFileUploadTaskUtil.getValidRangeSize(327685)); + done(); + }); + it('Should return same size for the size less than 320 KB', (done) => { + assert.equal(100, OneDriveLargeFileUploadTaskUtil.getValidRangeSize(100)); + done(); + }); + it('Should return size in multiple of 320KB with max range of 60 MB for file size more than 60 MB', (done) => { + assert.equal(62914560, OneDriveLargeFileUploadTaskUtil.getValidRangeSize(104857600)); + done(); + }); + it('Should return size in multiple of 320KB for the size multiple of 320 KB', (done) => { + assert.equal(1638400, OneDriveLargeFileUploadTaskUtil.getValidRangeSize(1638400)); + done(); + }) +}); diff --git a/spec/types/test-helper.ts b/spec/test-helper.ts similarity index 86% rename from spec/types/test-helper.ts rename to spec/test-helper.ts index 3a9886fdd..9761d7650 100644 --- a/spec/types/test-helper.ts +++ b/spec/test-helper.ts @@ -1,5 +1,5 @@ import { AccessToken } from "./secrets" -import { Client } from "../../lib/src/index" +import { Client } from "../lib/src/index" export function getClient(): Client { return Client.init({ diff --git a/spec/types/tsconfig.json b/spec/tsconfig.json similarity index 100% rename from spec/types/tsconfig.json rename to spec/tsconfig.json diff --git a/spec/types/OneNote.ts b/spec/types/OneNote.ts index d941a74aa..fda394242 100644 --- a/spec/types/OneNote.ts +++ b/spec/types/OneNote.ts @@ -1,7 +1,7 @@ import { assert } from 'chai' -import { getClient, randomString } from "./test-helper" -import { Notebook, OnenoteSection, OnenotePage } from '@microsoft/microsoft-graph-types-beta' +import { getClient, randomString } from "../test-helper" +import { Notebook, OnenoteSection, OnenotePage } from '@microsoft/microsoft-graph-types' import * as fs from "fs"; import * as FormData from "form-data"; @@ -9,11 +9,11 @@ declare const describe, it; describe('OneNote', function () { this.timeout(20 * 1000); - let notebook: Notebook = { + let notebook = { displayName: "Sample notebook - " + randomString() }; - let section: OnenoteSection = { + let section = { displayName: "Sample section - " + randomString() } @@ -63,7 +63,7 @@ describe('OneNote', function () { }); it("Create a OneNote page with html page content", () => { let formData = new FormData(); - formData.append('Presentation', fs.createReadStream('./spec/types/onenotepage.html')); + formData.append('Presentation', fs.createReadStream('./spec/sample_files/onenotepage.html')); return getClient() .api(`/me/onenote/sections/${section.id}/pages`) .post(formData) @@ -79,7 +79,7 @@ describe('OneNote', function () { it("create a OneNote page with html page content and file attachment", () => { let formData = new FormData(); - formData.append('Presentation', fs.createReadStream('./spec/types/onenotepage_fileattachment.html')); + formData.append('Presentation', fs.createReadStream('./spec/sample_files/onenotepage_fileattachment.html')); formData.append("fileBlock1", fs.createReadStream("./sample.png")); return getClient() .api(`/me/onenote/sections/${section.id}/pages`) diff --git a/spec/types/delta-query.ts b/spec/types/delta-query.ts index b35066cc1..e8768b7b7 100644 --- a/spec/types/delta-query.ts +++ b/spec/types/delta-query.ts @@ -2,7 +2,7 @@ import { assert } from 'chai' import { Event } from '@microsoft/microsoft-graph-types' -import { getClient, randomString } from "./test-helper" +import { getClient, randomString } from "../test-helper" declare const describe, it; @@ -61,4 +61,4 @@ describe('Delta Query', function () { throw "Didn't find created event when using delta token"; }) }); -}); \ No newline at end of file +}); diff --git a/spec/types/excel.ts b/spec/types/excel.ts index 2c2aeb154..85fad7144 100644 --- a/spec/types/excel.ts +++ b/spec/types/excel.ts @@ -1,7 +1,7 @@ import { assert } from 'chai' import * as fs from 'fs'; -import { getClient, randomString } from "./test-helper" +import { getClient, randomString } from "../test-helper" import { WorkbookWorksheet, WorkbookRange } from '@microsoft/microsoft-graph-types' declare const describe, it; @@ -17,7 +17,7 @@ describe('Excel', function () { }); it('Uploads an Excel file to OneDrive', function () { - let file = fs.readFileSync('./spec/types/empty-spreadsheet.xlsx'); + let file = fs.readFileSync('./spec/sample_files/empty-spreadsheet.xlsx'); return getClient() .api(`/me/drive/root/children/${ExcelFilename}/content`) .put(file); @@ -61,4 +61,4 @@ describe('Excel', function () { assert.isUndefined(res['other prop']) }) }) -}); \ No newline at end of file +}); diff --git a/spec/types/groups.ts b/spec/types/groups.ts index b0e44b322..152f21edf 100644 --- a/spec/types/groups.ts +++ b/spec/types/groups.ts @@ -1,6 +1,6 @@ import { assert } from 'chai' -import { getClient, randomString } from "./test-helper" +import { getClient, randomString } from "../test-helper" import { Group } from '@microsoft/microsoft-graph-types' declare const describe, it; @@ -40,4 +40,4 @@ describe('Groups', function () { return Promise.resolve(); }); }); -}); \ No newline at end of file +}); diff --git a/spec/types/insights.ts b/spec/types/insights.ts index 752cb4767..afbd3506b 100644 --- a/spec/types/insights.ts +++ b/spec/types/insights.ts @@ -1,7 +1,7 @@ import { assert } from 'chai' -import { getClient, randomString } from "./test-helper" -import { Person } from '@microsoft/microsoft-graph-types-beta' +import { getClient } from "../test-helper" +import { Person } from '@microsoft/microsoft-graph-types' declare const describe, it; @@ -41,4 +41,4 @@ describe('Social and Insights', function () { .get() }); -}); \ No newline at end of file +}); diff --git a/spec/types/miscellaneous.ts b/spec/types/miscellaneous.ts index afdc34e4c..9dd3a9da7 100644 --- a/spec/types/miscellaneous.ts +++ b/spec/types/miscellaneous.ts @@ -14,10 +14,9 @@ */ import { assert } from 'chai' -import { getClient, randomString } from "./test-helper" +import { getClient, randomString } from "../test-helper" import * as fs from "fs"; - declare const describe, it; describe('Fetch messages', function () { diff --git a/spec/types/open-extensions.ts b/spec/types/open-extensions.ts index 3aeb41059..488fa789a 100644 --- a/spec/types/open-extensions.ts +++ b/spec/types/open-extensions.ts @@ -1,7 +1,7 @@ import { assert } from 'chai' -import { getClient, randomString } from "./test-helper" -import { OpenTypeExtension, User } from '@microsoft/microsoft-graph-types-beta' +import { getClient, randomString } from "../test-helper" +import { OpenTypeExtension } from '@microsoft/microsoft-graph-types' declare const describe, it; @@ -9,7 +9,7 @@ interface ColorOpenExtension extends OpenTypeExtension { color: string } -let extension:ColorOpenExtension = { +let extension = { extensionName: `com.javascript.extension-${randomString()}`, color: randomString() } @@ -32,19 +32,7 @@ describe('Open Extensions', function() { }); }); -// it('Queries open extension values on a user', function() { -// return getClient().api("https://graph.microsoft.com/beta/me?$select=id&$expand=extensions").get().then((json) => { -// let user = json as User; -// for (let userExtension of user.extensions) { -// if (userExtension.id == extension.id) { -// return Promise.resolve(); -// } -// } -// return Promise.reject("Created extension not found when iterating user extensions"); -// }); -// }); - it('Deletes the created open extension', function() { return getClient().api(`https://graph.microsoft.com/beta/me/extensions/${extension.id}`).delete() }); -}); \ No newline at end of file +}); diff --git a/spec/types/users.ts b/spec/types/users.ts index 13b94d95a..2f93dbccb 100644 --- a/spec/types/users.ts +++ b/spec/types/users.ts @@ -2,7 +2,7 @@ import { assert } from 'chai' import { User } from '@microsoft/microsoft-graph-types' -import { getClient, randomString } from "./test-helper" +import { getClient, randomString } from "../test-helper" declare const describe, it; diff --git a/src/LargeFileUploadTask.ts b/src/LargeFileUploadTask.ts new file mode 100644 index 000000000..4252d9223 --- /dev/null +++ b/src/LargeFileUploadTask.ts @@ -0,0 +1,250 @@ +/** + * @module LargeFileUploadTask + */ + +import { Client } from "./index"; +import { Range } from "./Range"; + +/** + * @interface + * Signature to represent the resulting response in the status enquiry request + * @property {string} expirationDateTime - The expiration of the time of the upload session + * @property {string[]} nextExpectedRanges - The ranges expected in next consecutive request in the upload + */ +interface UploadStatusResponse { + expirationDateTime: string; + nextExpectedRanges: string[]; +} + +/** + * @interface + * Signature to define options for upload task + * @property {number} [rangeSize = LargeFileUploadTask.DEFAULT_FILE_SIZE] - Specifies the range chunk size + */ +export interface LargeFileUploadTaskOptions { + rangeSize?: number; +}; + +/** + * @interface + * Signature to represent upload session resulting from the session creation in the server + * @property {string} url - The URL to which the file upload is made + * @property {Date} expiry - The expiration of the time of the upload session + */ +export interface LargeFileUploadSession { + url: string; + expiry: Date; +} + +/** + * @interface + * Signature to define the properties and content of the file in upload task + * @property {ArrayBuffer | File} content - The actual file content + * @property {string} name - Specifies the file name with extension + * @property {number} size - Specifies size of the file + */ +export interface FileObject { + content: ArrayBuffer | File; + name: string; + size: number; +} + +/** + * Class representing LargeFileUploadTask + */ +export class LargeFileUploadTask { + /** The GraphClient instance */ + client: Client + + /** The object holding file details */ + file: FileObject + + /** The object holding options for the task */ + options: LargeFileUploadTaskOptions + + /** The object for upload session */ + uploadSession: LargeFileUploadSession + + /** The next range needs to be uploaded */ + nextRange: Range + + /** + * Default value for the rangeSize + */ + private DEFAULT_FILE_SIZE: number = 5 * 1024 * 1024; + + /** + * Constructs a LargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) { + let self = this; + self.client = client; + self.file = file; + if (options.rangeSize === undefined) { + options.rangeSize = self.DEFAULT_FILE_SIZE; + } + self.options = options; + self.uploadSession = uploadSession; + self.nextRange = new Range(0, self.options.rangeSize - 1); + } + + /** + * Parses given range string to the Range instance + * @param {string[]} ranges - The ranges value + * @return The range instance + */ + parseRange (ranges: string[]): Range { + let rangeStr = ranges[0]; + if (typeof rangeStr === "undefined" || rangeStr === "") { + return new Range(); + } + let firstRange = rangeStr.split("-"), + minVal = parseInt(firstRange[0]), + maxVal = parseInt(firstRange[1]); + if (Number.isNaN(maxVal)) { + maxVal = this.file.size - 1; + } + return new Range(minVal, maxVal); + } + + /** + * Updates the expiration date and the next range + * @param {UploadStatusResponse} response - The response of the upload status + */ + updateTaskStatus(response: UploadStatusResponse): void { + let self = this; + self.uploadSession.expiry = new Date(response.expirationDateTime); + self.nextRange = self.parseRange(response.nextExpectedRanges); + } + + /** + * Gets next range that needs to be uploaded + * @return The range instance + */ + getNextRange(): Range { + let self = this; + if (self.nextRange.minValue === -1) { + return self.nextRange; + } + let minVal = self.nextRange.minValue, + maxValue = minVal + self.options.rangeSize - 1; + if (maxValue >= self.file.size) { + maxValue = self.file.size - 1; + } + return new Range(minVal, maxValue); + } + + /** + * Slices the file content to the given range + * @param {Range} range - The range value + * @return The sliced ArrayBuffer or Blob + */ + sliceFile(range: Range): ArrayBuffer | Blob { + let blob = this.file.content.slice(range.minValue, range.maxValue + 1); + return blob; + } + + /** + * @async + * Uploads file to the server in a sequential order by slicing the file + * @return The promise resolves to uploaded response + */ + async upload(): Promise { + let self = this; + try { + while (true) { + let nextRange = self.getNextRange(); + if (nextRange.maxValue === -1) { + let err = new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file"); + err.name = "Invalid Session"; + throw err; + } + let fileSlice = self.sliceFile(nextRange), + response = await self.uploadSlice(fileSlice, nextRange, self.file.size); + // Upon completion of upload process incase of onedrive, driveItem is returned, which contains id + if (response.id !== undefined) { + return response; + } else { + self.updateTaskStatus(response); + } + } + } catch(err) { + throw err; + } + } + + /** + * @async + * Uploads given slice to the server + * @param {ArrayBuffer | Blob | File} fileSlice - The file slice + * @param {Range} range - The range value + * @param {number} totalSize - The total size of a complete file + */ + async uploadSlice(fileSlice: ArrayBuffer | Blob | File, range: Range, totalSize: number): Promise { + let self = this; + try { + return await self.client + .api(self.uploadSession.url) + .headers({ + "Content-Length": `${range.maxValue - range.minValue + 1}`, + "Content-Range": `bytes ${range.minValue}-${range.maxValue}/${totalSize}` + }) + .put(fileSlice); + } catch(err) { + throw err; + } + } + + /** + * @async + * Deletes upload session in the server + * @return The promise resolves to cancelled response + */ + async cancel (): Promise { + let self = this; + try { + return await self.client + .api(self.uploadSession.url) + .delete(); + } catch (err) { + throw err; + } + } + + /** + * @async + * Gets status for the upload session + * @return The promise resolves to the status enquiry response + */ + async getStatus(): Promise { + let self = this; + try { + let response = await self.client + .api(self.uploadSession.url) + .get(); + self.updateTaskStatus(response); + return response; + } catch (err) { + throw err; + } + } + + /** + * @async + * Resumes upload session and continue uploading the file from the last sent range + * @return The promise resolves to the uploaded response + */ + async resume(): Promise { + let self = this; + try { + await self.getStatus(); + return await self.upload(); + } catch (err) { + throw err; + } + } +} diff --git a/src/OneDriveLargeFileUploadTask.ts b/src/OneDriveLargeFileUploadTask.ts new file mode 100644 index 000000000..0251c9948 --- /dev/null +++ b/src/OneDriveLargeFileUploadTask.ts @@ -0,0 +1,150 @@ +/** + * @module OneDriveLargeFileUploadTask + */ + +import { Client } from "./index"; +import { FileObject, LargeFileUploadSession, LargeFileUploadTask, LargeFileUploadTaskOptions } from "./LargeFileUploadTask"; +import { getValidRangeSize } from "./OneDriveLargeFileUploadTaskUtil"; + +/** + * @interface + * Signature to define options when creating an upload task + * @property {string} fileName - Specifies the name of a file to be uploaded (with extension) + * @property {string} [path] - The path to which the file needs to be uploaded + * @property {number} [rangeSize] - Specifies the range chunk size + */ +interface OneDriveLargeFileUploadOptions { + fileName: string; + path?: string; + rangeSize?: number; +}; + +/** + * Class representing OneDriveLargeFileUploadTask + */ +export class OneDriveLargeFileUploadTask extends LargeFileUploadTask { + + /** + * Default path for the file being uploaded + */ + static DEFAULT_UPLOAD_PATH: string = "/"; + + /** + * Constructs a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded + * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done + * @param {LargeFileUploadTaskOptions} options - The upload task options + */ + constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) { + super(client, file, uploadSession, options); + } + + /** + * @static + * @async + * Creates a OneDriveLargeFileUploadTask + * @param {Client} client - The GraphClient instance + * @param {Blob | Buffer | File} file - File represented as Blob, Buffer or File + * @param {OneDriveLargeFileUploadOptions} options - The options for upload task + * @return The promise that will be resolves to OneDriveLargeFileUploadTask instance + */ + static async create(client: Client, file: Blob | Buffer | File, options: OneDriveLargeFileUploadOptions): Promise { + let fileObj: FileObject = {}; + fileObj.name = options.fileName; + switch (file.constructor.name) { + case "Blob": + fileObj.content = new File([file], fileObj.name); + fileObj.size = fileObj.content.size; + break; + case "File": + let _file = file; + fileObj.content = _file; + fileObj.size = _file.size; + break; + case "Buffer": + let b = file; + fileObj.size = b.byteLength - b.byteOffset; + fileObj.content = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); + break; + } + try { + let requestUrl = OneDriveLargeFileUploadTask.constructCreateSessionUrl(options.fileName, options.path); + let session = await OneDriveLargeFileUploadTask.createUploadSession(client, requestUrl, options.fileName); + let rangeSize = getValidRangeSize(options.rangeSize); + return new OneDriveLargeFileUploadTask(client, fileObj, session, {rangeSize}); + } catch (err) { + throw err; + } + } + + /** + * @static + * Constructs the create session url for Onedrive + * @param {string} fileName - The name of the file + * @param {path} [path = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH] - The path for the upload + * @return The constructed create session url + */ + static constructCreateSessionUrl(fileName: string, path: string = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH): string { + fileName = fileName.trim(); + path = path.trim(); + if (path === "") { + path = "/"; + } + if (path[0] !== "/") { + path = `/${path}`; + } + if (path[path.length - 1] !== "/") { + path = `${path}/`; + } + return encodeURI(`/me/drive/root:${path}${fileName}:/createUploadSession`); + } + + /** + * @static + * @async + * Makes request to the server to create an upload session + * @param {Client} client - The GraphClient instance + * @param {string} requestUrl - The URL to create the upload session + * @param {string} fileName - The name of a file to upload, (with extension) + * @return The promise that resolves to LargeFileUploadSession + */ + static async createUploadSession(client: Client, requestUrl: string, fileName: string): Promise { + let payload = { + item: { + "@microsoft.graph.conflictBehavior": "rename", + name: fileName + } + }; + try { + let session = await client.api(requestUrl).post(payload); + return { + url: session.uploadUrl, + expiry: new Date(session.expirationDateTime) + }; + } catch (err) { + throw err; + } + } + + /** + * Commits upload session to end uploading + * @param {string} requestUrl - The URL to commit the upload session + * @return The promise resolves to committed response + */ + async commit(requestUrl: string): Promise { + let self = this; + try { + let payload = { + name: self.file.name, + "@microsoft.graph.conflictBehavior": "rename", + "@microsoft.graph.sourceUrl": self.uploadSession.url + } + return await self.client + .api(requestUrl) + .put(payload) + } catch (err) { + throw err; + } + } +} diff --git a/src/OneDriveLargeFileUploadTaskUtil.ts b/src/OneDriveLargeFileUploadTaskUtil.ts new file mode 100644 index 000000000..ceac3fd2e --- /dev/null +++ b/src/OneDriveLargeFileUploadTaskUtil.ts @@ -0,0 +1,35 @@ +/** + * @module OneDriveLargeFileUploadTaskUtil + */ + + /** + * Default value for the rangeSize + * Recommended size is between 5 - 10 MB {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#best-practices} + */ +const DEFAULT_FILE_SIZE: number = 5 * 1024 * 1024; + +/** + * Rounds off the given value to a multiple of 320 KB + * @param {number} value - The value + * @return The rounded off value + */ +const roundTo320KB = (value: number): number => { + if (value > (320 * 1024)) { + value = Math.floor(value / (320 * 1024)) * 320 * 1024; + } + return value; +} + +/** + * Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session}) + * + * @param {number} [rangeSize = DEFAULT_FILE_SIZE] - The rangeSize value. + * @return The valid rangeSize + */ +export const getValidRangeSize = (rangeSize: number = DEFAULT_FILE_SIZE): number => { + const sixtyMB = 60 * 1024 * 1024; + if (rangeSize > sixtyMB) { + rangeSize = sixtyMB; + } + return roundTo320KB(rangeSize); +} diff --git a/src/Range.ts b/src/Range.ts new file mode 100644 index 000000000..ecb8747fc --- /dev/null +++ b/src/Range.ts @@ -0,0 +1,24 @@ +/** + * @module Range + */ + + /** + * Class representing Range + */ +export class Range { + /** The minimum value of the range */ + minValue: number + /** The maximum value of the range */ + maxValue: number + + /** + * Creates a range for given min and max values + * @param {number} [minVal = -1] - The minimum value. + * @param {number} [maxVal = -1] - The maximum value. + */ + constructor(minVal: number = -1, maxVal: number = -1) { + let self = this; + self.minValue = minVal; + self.maxValue = maxVal; + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 9cc6bc9b2..25c21de69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,4 +29,5 @@ export class Client { export * from "./GraphRequest"; export * from "./common"; export * from "./ResponseHandler"; +export * from "./OneDriveLargeFileUploadTask"; export * from "./ResponseType"; diff --git a/tsconfig.json b/tsconfig.json index 6e73f65d9..ea2538c49 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "noEmitOnError": true, "noImplicitAny": false, "moduleResolution": "node", - "removeComments": true, + "removeComments": false, "sourceMap": true, "target": "es5", "lib": ["es6", "dom"], @@ -15,10 +15,12 @@ "node_modules", "lib", "samples", + "spec/tasks", "spec/types" ], "include": [ "./src/index.ts", + "./src/LargeFileUploadTask.ts", "./spec/core" ] }