@microsoft/microsoft-graph-client
Advanced tools
Comparing version 1.6.0 to 1.7.0-Preview.1
@@ -13,5 +13,7 @@ /** | ||
export * from "../middleware/RetryHandler"; | ||
export * from "../middleware/TelemetryHandler"; | ||
export * from "../middleware/options/AuthenticationHandlerOptions"; | ||
export * from "../middleware/options/IMiddlewareOptions"; | ||
export * from "../middleware/options/RetryHandlerOptions"; | ||
export * from "../middleware/options/TelemetryHandlerOptions"; | ||
export * from "../tasks/OneDriveLargeFileUploadTask"; | ||
@@ -18,0 +20,0 @@ export * from "../tasks/PageIterator"; |
@@ -12,4 +12,6 @@ /** | ||
export * from "../middleware/RetryHandler"; | ||
export * from "../middleware/TelemetryHandler"; | ||
export * from "../middleware/options/AuthenticationHandlerOptions"; | ||
export * from "../middleware/options/RetryHandlerOptions"; | ||
export * from "../middleware/options/TelemetryHandlerOptions"; | ||
export * from "../tasks/OneDriveLargeFileUploadTask"; | ||
@@ -16,0 +18,0 @@ export * from "../tasks/PageIterator"; |
@@ -26,2 +26,2 @@ /** | ||
*/ | ||
export declare const PACKAGE_VERSION = "1.6.0"; | ||
export declare const PACKAGE_VERSION = "1.7.0-Preview.1"; |
@@ -26,3 +26,3 @@ /** | ||
*/ | ||
export const PACKAGE_VERSION = "1.6.0"; | ||
export const PACKAGE_VERSION = "1.7.0-Preview.1"; | ||
//# sourceMappingURL=Constants.js.map |
@@ -15,6 +15,2 @@ /** | ||
}; | ||
/** | ||
* @module GraphRequest | ||
*/ | ||
import { PACKAGE_VERSION } from "./Constants"; | ||
import { GraphErrorHandler } from "./GraphErrorHandler"; | ||
@@ -174,5 +170,2 @@ import { oDataQueryNames, serializeContent, urlJoin } from "./GraphRequestUtil"; | ||
updateRequestOptions(options) { | ||
const defaultHeaders = { | ||
SdkVersion: `graph-js-${PACKAGE_VERSION}`, | ||
}; | ||
const optionsHeaders = Object.assign({}, options.headers); | ||
@@ -187,3 +180,2 @@ if (this.config.fetchOptions !== undefined) { | ||
Object.assign(options, this._options); | ||
Object.assign(optionsHeaders, defaultHeaders); | ||
if (options.headers !== undefined) { | ||
@@ -190,0 +182,0 @@ Object.assign(optionsHeaders, options.headers); |
@@ -24,2 +24,8 @@ /** | ||
* @returns A HTTPClient instance | ||
* | ||
* NOTE: These are the things that we need to remember while doing modifications in the below default pipeline. | ||
* * HTTPMessageHander should be the last one in the middleware pipeline, because this makes the actual network call of the request | ||
* * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag. | ||
* * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for | ||
* them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same. | ||
*/ | ||
@@ -26,0 +32,0 @@ static createWithAuthenticationProvider(authProvider: AuthenticationProvider): HTTPClient; |
@@ -17,2 +17,3 @@ /** | ||
import { RetryHandler } from "./middleware/RetryHandler"; | ||
import { TelemetryHandler } from "./middleware/TelemetryHandler"; | ||
/** | ||
@@ -37,2 +38,8 @@ * @private | ||
* @returns A HTTPClient instance | ||
* | ||
* NOTE: These are the things that we need to remember while doing modifications in the below default pipeline. | ||
* * HTTPMessageHander should be the last one in the middleware pipeline, because this makes the actual network call of the request | ||
* * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag. | ||
* * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for | ||
* them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same. | ||
*/ | ||
@@ -42,2 +49,3 @@ static createWithAuthenticationProvider(authProvider) { | ||
const retryHandler = new RetryHandler(new RetryHandlerOptions()); | ||
const telemetryHandler = new TelemetryHandler(); | ||
const httpMessageHandler = new HTTPMessageHandler(); | ||
@@ -48,7 +56,8 @@ authenticationHandler.setNext(retryHandler); | ||
retryHandler.setNext(redirectHandler); | ||
redirectHandler.setNext(httpMessageHandler); | ||
redirectHandler.setNext(telemetryHandler); | ||
} | ||
else { | ||
retryHandler.setNext(httpMessageHandler); | ||
retryHandler.setNext(telemetryHandler); | ||
} | ||
telemetryHandler.setNext(httpMessageHandler); | ||
return HTTPClientFactory.createWithMiddleware(authenticationHandler); | ||
@@ -55,0 +64,0 @@ } |
@@ -14,5 +14,9 @@ /** | ||
export * from "./middleware/RetryHandler"; | ||
export * from "./middleware/RedirectHandler"; | ||
export * from "./middleware/TelemetryHandler"; | ||
export * from "./middleware/options/AuthenticationHandlerOptions"; | ||
export * from "./middleware/options/IMiddlewareOptions"; | ||
export * from "./middleware/options/RetryHandlerOptions"; | ||
export * from "./middleware/options/RedirectHandlerOptions"; | ||
export * from "./middleware/options/TelemetryHandlerOptions"; | ||
export * from "./tasks/OneDriveLargeFileUploadTask"; | ||
@@ -19,0 +23,0 @@ export * from "./tasks/PageIterator"; |
@@ -13,4 +13,8 @@ /** | ||
export * from "./middleware/RetryHandler"; | ||
export * from "./middleware/RedirectHandler"; | ||
export * from "./middleware/TelemetryHandler"; | ||
export * from "./middleware/options/AuthenticationHandlerOptions"; | ||
export * from "./middleware/options/RetryHandlerOptions"; | ||
export * from "./middleware/options/RedirectHandlerOptions"; | ||
export * from "./middleware/options/TelemetryHandlerOptions"; | ||
export * from "./tasks/OneDriveLargeFileUploadTask"; | ||
@@ -17,0 +21,0 @@ export * from "./tasks/PageIterator"; |
@@ -18,2 +18,3 @@ /** | ||
import { AuthenticationHandlerOptions } from "./options/AuthenticationHandlerOptions"; | ||
import { FeatureUsageFlag, TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions"; | ||
/** | ||
@@ -60,2 +61,3 @@ * @class | ||
setRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey); | ||
TelemetryHandlerOptions.updateFeatureUsageFlag(context, FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED); | ||
return yield this.nextMiddleware.execute(context); | ||
@@ -62,0 +64,0 @@ } |
@@ -25,13 +25,21 @@ /** | ||
* Creates an instance of MiddlewareControl | ||
* @param {MiddlewareOptions[]} middlewareOptions - The array of middlewareOptions | ||
* @param {MiddlewareOptions[]} [middlewareOptions = []] - The array of middlewareOptions | ||
* @returns The instance of MiddlewareControl | ||
*/ | ||
constructor(middlewareOptions: MiddlewareOptions[]); | ||
constructor(middlewareOptions?: MiddlewareOptions[]); | ||
/** | ||
* @public | ||
* To get the middleware option using the class name of the option | ||
* @param {string} name - The class name of the strongly types option class | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @returns The middleware option | ||
*/ | ||
getMiddlewareOptions(name: string): MiddlewareOptions; | ||
/** | ||
* @public | ||
* To set the middleware options using the class name of the option | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @param {MiddlewareOptions} option - The strongly typed middleware option | ||
* @returns nothing | ||
*/ | ||
setMiddlewareOptions(name: string, option: MiddlewareOptions): void; | ||
} |
@@ -16,6 +16,6 @@ /** | ||
* Creates an instance of MiddlewareControl | ||
* @param {MiddlewareOptions[]} middlewareOptions - The array of middlewareOptions | ||
* @param {MiddlewareOptions[]} [middlewareOptions = []] - The array of middlewareOptions | ||
* @returns The instance of MiddlewareControl | ||
*/ | ||
constructor(middlewareOptions) { | ||
constructor(middlewareOptions = []) { | ||
this.middlewareOptions = new Map(); | ||
@@ -30,3 +30,3 @@ for (const option of middlewareOptions) { | ||
* To get the middleware option using the class name of the option | ||
* @param {string} name - The class name of the strongly types option class | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @returns The middleware option | ||
@@ -37,3 +37,13 @@ */ | ||
} | ||
/** | ||
* @public | ||
* To set the middleware options using the class name of the option | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @param {MiddlewareOptions} option - The strongly typed middleware option | ||
* @returns nothing | ||
*/ | ||
setMiddlewareOptions(name, option) { | ||
this.middlewareOptions.set(name, option); | ||
} | ||
} | ||
//# sourceMappingURL=MiddlewareControl.js.map |
@@ -13,2 +13,8 @@ /** | ||
* @constant | ||
* To generate the UUID | ||
* @returns The UUID string | ||
*/ | ||
export declare const generateUUID: () => string; | ||
/** | ||
* @constant | ||
* To get the request header from the request | ||
@@ -15,0 +21,0 @@ * @param {RequestInfo} request - The request object or the url string |
@@ -17,2 +17,17 @@ /** | ||
* @constant | ||
* To generate the UUID | ||
* @returns The UUID string | ||
*/ | ||
export const generateUUID = () => { | ||
let uuid = ""; | ||
for (let j = 0; j < 32; j++) { | ||
if (j === 8 || j === 12 || j === 16 || j === 20) { | ||
uuid += "-"; | ||
} | ||
uuid += Math.floor(Math.random() * 16).toString(16); | ||
} | ||
return uuid; | ||
}; | ||
/** | ||
* @constant | ||
* To get the request header from the request | ||
@@ -19,0 +34,0 @@ * @param {RequestInfo} request - The request object or the url string |
@@ -19,2 +19,3 @@ /** | ||
import { RedirectHandlerOptions } from "./options/RedirectHandlerOptions"; | ||
import { FeatureUsageFlag, TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions"; | ||
/** | ||
@@ -174,2 +175,3 @@ * @class | ||
context.options.redirect = RedirectHandler.MANUAL_REDIRECT; | ||
TelemetryHandlerOptions.updateFeatureUsageFlag(context, FeatureUsageFlag.REDIRECT_HANDLER_ENABLED); | ||
return yield this.executeWithRedirect(context, redirectCount, options); | ||
@@ -176,0 +178,0 @@ } |
@@ -39,14 +39,2 @@ /** | ||
* @private | ||
* @static | ||
* A member holding the name of transfer encoding header | ||
*/ | ||
private static TRANSFER_ENCODING_HEADER; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the value of transfer encoding chunked | ||
*/ | ||
private static TRANSFER_ENCODING_CHUNKED; | ||
/** | ||
* @private | ||
* A member to hold next middleware in the middleware chain | ||
@@ -53,0 +41,0 @@ */ |
@@ -19,2 +19,3 @@ /** | ||
import { RetryHandlerOptions } from "./options/RetryHandlerOptions"; | ||
import { FeatureUsageFlag, TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions"; | ||
/** | ||
@@ -165,2 +166,3 @@ * @class | ||
const options = this.getOptions(context); | ||
TelemetryHandlerOptions.updateFeatureUsageFlag(context, FeatureUsageFlag.RETRY_HANDLER_ENABLED); | ||
return yield this.executeWithRetry(context, retryAttempts, options); | ||
@@ -205,14 +207,2 @@ } | ||
RetryHandler.RETRY_AFTER_HEADER = "Retry-After"; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the name of transfer encoding header | ||
*/ | ||
RetryHandler.TRANSFER_ENCODING_HEADER = "Transfer-Encoding"; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the value of transfer encoding chunked | ||
*/ | ||
RetryHandler.TRANSFER_ENCODING_CHUNKED = "chunked"; | ||
//# sourceMappingURL=RetryHandler.js.map |
@@ -1,1 +0,1 @@ | ||
var e;!function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(e||(e={}));var t=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class n{constructor(e){if(this.requests=new Map,void 0!==e){const t=n.requestLimit;if(e.length>t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}for(const t of e)this.addRequest(t)}}static validateDependencies(e){if(0===e.size){const e=new Error("Empty requests map, Please provide at least one request.");throw e.name="Empty Requests Error",e}return(e=>{const t=e.entries();let n=t.next();for(;!n.done;){const e=n.value[1];if(void 0!==e.dependsOn&&e.dependsOn.length>0)return!1;n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];if(void 0!==r.dependsOn&&r.dependsOn.length>0)return!1;let i=n;for(n=t.next();!n.done;){const e=n.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==i.value[1].id)return!1;i=n,n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];let i;if(void 0===r.dependsOn||0===r.dependsOn.length)i=r.id;else{if(1!==r.dependsOn.length)return!1;{const t=r.dependsOn[0];if(t===r.id||!e.has(t))return!1;i=t}}for(n=t.next();!n.done;){const e=n.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&i!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===i||e.dependsOn[0]!==i))return!1;if(e.dependsOn.length>1)return!1}n=t.next()}return!0})(e)}static getRequestData(r){return t(this,void 0,void 0,function*(){const t={url:""},i=new RegExp("^https?://");t.url=i.test(r.url)?"/"+r.url.split(/.*?\/\/.*?\//)[1]:r.url,t.method=r.method;const o={};return r.headers.forEach((e,t)=>{o[t]=e}),Object.keys(o).length&&(t.headers=o),r.method!==e.PATCH&&r.method!==e.POST&&r.method!==e.PUT||(t.body=yield n.getRequestBody(r)),t})}static getRequestBody(e){return t(this,void 0,void 0,function*(){let t,n=!1;try{const r=e.clone();t=yield r.json(),n=!0}catch(e){}if(!n)try{if("undefined"!=typeof Blob){const n=yield e.blob(),r=new FileReader;t=yield new Promise(e=>{r.addEventListener("load",()=>{const t=r.result,n=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(n[4])},!1),r.readAsDataURL(n)})}else if("undefined"!=typeof Buffer){t=(yield e.buffer()).toString("base64")}n=!0}catch(e){}return t})}addRequest(e){const t=n.requestLimit;if(""===e.id){const e=new Error("Id for a request is empty, Please provide an unique id");throw e.name="Empty Id For Request",e}if(this.requests.size===t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}if(this.requests.has(e.id)){const t=new Error(`Adding request with duplicate id ${e.id}, Make the id of the requests unique`);throw t.name="Duplicate RequestId Error",t}return this.requests.set(e.id,e),e.id}removeRequest(e){const t=this.requests.delete(e),n=this.requests.entries();let r=n.next();for(;!r.done;){const t=r.value[1].dependsOn;if(void 0!==t){const n=t.indexOf(e);-1!==n&&t.splice(n,1),0===t.length&&delete r.value[1].dependsOn}r=n.next()}return t}getContent(){return t(this,void 0,void 0,function*(){const e=[],t={requests:e},r=this.requests.entries();let i=r.next();if(i.done){const e=new Error("No requests added yet, Please add at least one request.");throw e.name="Empty Payload",e}if(!n.validateDependencies(this.requests)){const e=new Error("Invalid dependency found, Dependency should be:\n1. Parallel - no individual request states a dependency in the dependsOn property.\n2. Serial - all individual requests depend on the previous individual request.\n3. Same - all individual requests that state a dependency in the dependsOn property, state the same dependency.");throw e.name="Invalid Dependency",e}for(;!i.done;){const t=i.value[1],o=yield n.getRequestData(t.request);if(void 0!==o.body&&(void 0===o.headers||void 0===o.headers["content-type"])){const e=new Error(`Content-type header is not mentioned for request #${t.id}, For request having body, Content-type header should be mentioned`);throw e.name="Invalid Content-type header",e}o.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(o.dependsOn=t.dependsOn),e.push(o),i=r.next()}return t.requests=e,t})}addDependency(e,t){if(!this.requests.has(e)){const t=new Error(`Dependent ${e} does not exists, Please check the id`);throw t.name="Invalid Dependent",t}if(void 0!==t&&!this.requests.has(t)){const e=new Error(`Dependency ${t} does not exists, Please check the id`);throw e.name="Invalid Dependency",e}if(void 0!==t){const n=this.requests.get(e);if(void 0===n.dependsOn&&(n.dependsOn=[]),-1!==n.dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}n.dependsOn.push(t)}else{const n=this.requests.entries();let r,i=n.next();for(;!i.done&&i.value[1].id!==e;)r=i,i=n.next();if(void 0===r){const e=new Error(`Can't add dependency ${t}, There is only a dependent request in the batch`);throw e.name="Invalid Dependency Addition",e}{const t=r.value[0];if(void 0===i.value[1].dependsOn&&(i.value[1].dependsOn=[]),-1!==i.value[1].dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}i.value[1].dependsOn.push(t)}}}removeDependency(e,t){const n=this.requests.get(e);if(void 0===n||void 0===n.dependsOn||0===n.dependsOn.length)return!1;if(void 0!==t){const e=n.dependsOn.indexOf(t);return-1!==e&&(n.dependsOn.splice(e,1),!0)}return delete n.dependsOn,!0}}n.requestLimit=20;class r{constructor(e){this.responses=new Map,this.update(e)}createResponseObject(e){const t=e.body,n={};return n.status=e.status,void 0!==e.statusText&&(n.statusText=e.statusText),n.headers=e.headers,new Response(t,n)}update(e){this.nextLink=e["@nextLink"];const t=e.responses;for(let e=0,n=t.length;e<n;e++)this.responses.set(t[e].id,this.createResponseObject(t[e]))}getResponseById(e){return this.responses.get(e)}getResponses(){return this.responses}*getResponsesIterator(){const e=this.responses.entries();let t=e.next();for(;!t.done;)yield t.value,t=e.next()}}class i{constructor(e){this.middlewareOptions=new Map;for(const t of e){const e=t.constructor.name;this.middlewareOptions.set(e,t)}}getMiddlewareOptions(e){return this.middlewareOptions.get(e)}}var o=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};const s=(e,t,n)=>{let r=null;if(e instanceof Request)r=e.headers.get(n);else if(void 0!==t&&void 0!==t.headers)if(t.headers instanceof Headers)r=t.headers.get(n);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,i=e.length;t<i;t++)if(e[t][0]===n){r=e[t][1];break}}else void 0!==t.headers[n]&&(r=t.headers[n]);return r},a=(e,t,n,r)=>{e instanceof Request?e.headers.set(n,r):void 0!==t&&(void 0===t.headers?t.headers={[n]:r}:t.headers instanceof Headers?t.headers.set(n,r):t.headers instanceof Array?t.headers.push([n,r]):Object.assign(t.headers,{[n]:r}))},c=(e,t)=>o(void 0,void 0,void 0,function*(){const n=t.headers.get("Content-Type")?yield t.blob():yield Promise.resolve(void 0),{method:r,headers:i,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p}=t;return new Request(e,{method:r,headers:i,body:n,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p})});class d{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var u=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class h{constructor(e){this.authenticationProvider=e}execute(e){return u(this,void 0,void 0,function*(){try{let t,n,r;e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(d.name)),void 0!==t&&(n=t.authenticationProvider,r=t.authenticationProviderOptions),void 0===n&&(n=this.authenticationProvider);const o=`Bearer ${yield n.getAccessToken(r)}`;return a(e.request,e.options,h.AUTHORIZATION_HEADER,o),yield this.nextMiddleware.execute(e)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}h.AUTHORIZATION_HEADER="Authorization";var l=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class p{execute(e){return l(this,void 0,void 0,function*(){try{return void(e.response=yield fetch(e.request,e.options))}catch(e){throw e}})}}class f{constructor(e=f.DEFAULT_DELAY,t=f.DEFAULT_MAX_RETRIES,n=f.DEFAULT_SHOULD_RETRY){if(e>f.MAX_DELAY&&t>f.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${f.MAX_DELAY} and ${f.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>f.MAX_DELAY){const e=new Error(`Delay should not be more than ${f.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>f.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${f.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}this.delay=Math.min(e,f.MAX_DELAY),this.maxRetries=Math.min(t,f.MAX_MAX_RETRIES),this.shouldRetry=n}getMaxDelay(){return f.MAX_DELAY}}f.DEFAULT_DELAY=3,f.DEFAULT_MAX_RETRIES=3,f.MAX_DELAY=180,f.MAX_MAX_RETRIES=10,f.DEFAULT_SHOULD_RETRY=(()=>!0);var y=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class m{constructor(e=new f){this.options=e}isRetry(e){return-1!==m.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(t,n){const r=t instanceof Request?t.method:n.method;if(r===e.PUT||r===e.PATCH||r===e.POST){if("application/octet-stream"===s(t,n,"Content-Type"))return!1}return!0}getDelay(e,t,n){const r=()=>Number(Math.random().toFixed(3)),i=void 0!==e.headers?e.headers.get(m.RETRY_AFTER_HEADER):null;let o;return o=null!==i?Number.isNaN(Number(i))?Math.round((new Date(i).getTime()-Date.now())/1e3):Number(i):t>=2?this.getExponentialBackOffTime(t)+n+r():n+r(),Math.min(o,this.options.getMaxDelay()+r())}getExponentialBackOffTime(e){return Math.round(.5*(Math.pow(2,e)-1))}sleep(e){return y(this,void 0,void 0,function*(){const t=1e3*e;return new Promise(e=>setTimeout(e,t))})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new f,this.options)),t}executeWithRetry(e,t,n){return y(this,void 0,void 0,function*(){try{if(yield this.nextMiddleware.execute(e),t<n.maxRetries&&this.isRetry(e.response)&&this.isBuffered(e.request,e.options)&&n.shouldRetry(n.delay,t,e.request,e.options,e.response)){++t,a(e.request,e.options,m.RETRY_ATTEMPT_HEADER,t.toString());const r=this.getDelay(e.response,t,n.delay);return yield this.sleep(r),yield this.executeWithRetry(e,t,n)}return}catch(e){throw e}})}execute(e){return y(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return yield this.executeWithRetry(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}m.RETRY_STATUS_CODES=[429,503,504],m.RETRY_ATTEMPT_HEADER="Retry-Attempt",m.RETRY_AFTER_HEADER="Retry-After",m.TRANSFER_ENCODING_HEADER="Transfer-Encoding",m.TRANSFER_ENCODING_CHUNKED="chunked";class v{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}var w=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class E{constructor(e,t,n,r){this.DEFAULT_FILE_SIZE=5242880,this.client=e,this.file=t,void 0===r.rangeSize&&(r.rangeSize=this.DEFAULT_FILE_SIZE),this.options=r,this.uploadSession=n,this.nextRange=new v(0,this.options.rangeSize-1)}parseRange(e){const t=e[0];if(void 0===t||""===t)return new v;const n=t.split("-"),r=parseInt(n[0],10);let i=parseInt(n[1],10);return Number.isNaN(i)&&(i=this.file.size-1),new v(r,i)}updateTaskStatus(e){this.uploadSession.expiry=new Date(e.expirationDateTime),this.nextRange=this.parseRange(e.nextExpectedRanges)}getNextRange(){if(-1===this.nextRange.minValue)return this.nextRange;const e=this.nextRange.minValue;let t=e+this.options.rangeSize-1;return t>=this.file.size&&(t=this.file.size-1),new v(e,t)}sliceFile(e){return this.file.content.slice(e.minValue,e.maxValue+1)}upload(){return w(this,void 0,void 0,function*(){try{for(;;){const e=this.getNextRange();if(-1===e.maxValue){const e=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");throw e.name="Invalid Session",e}const t=this.sliceFile(e),n=yield this.uploadSlice(t,e,this.file.size);if(void 0!==n.id)return n;this.updateTaskStatus(n)}}catch(e){throw e}})}uploadSlice(e,t,n){return w(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${t.maxValue-t.minValue+1}`,"Content-Range":`bytes ${t.minValue}-${t.maxValue}/${n}`}).put(e)}catch(e){throw e}})}cancel(){return w(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).delete()}catch(e){throw e}})}getStatus(){return w(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.uploadSession.url).get();return this.updateTaskStatus(e),e}catch(e){throw e}})}resume(){return w(this,void 0,void 0,function*(){try{return yield this.getStatus(),yield this.upload()}catch(e){throw e}})}}const g=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};var R=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class x extends E{constructor(e,t,n,r){super(e,t,n,r)}static create(e,t,n){return R(this,void 0,void 0,function*(){const r=n.fileName;let i,o;switch(t.constructor.name){case"Blob":o=(i=new File([t],r)).size;break;case"File":o=(i=t).size;break;case"Buffer":const e=t;o=e.byteLength-e.byteOffset,i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const t=x.constructCreateSessionUrl(n.fileName,n.path),s=yield x.createUploadSession(e,t,n.fileName),a=g(n.rangeSize);return new x(e,{name:r,content:i,size:o},s,{rangeSize:a})}catch(e){throw e}})}static constructCreateSessionUrl(e,t=x.DEFAULT_UPLOAD_PATH){return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t=`/${t}`),"/"!==t[t.length-1]&&(t=`${t}/`),encodeURI(`/me/drive/root:${t}${e}:/createUploadSession`)}static createUploadSession(e,t,n){return R(this,void 0,void 0,function*(){const r={item:{"@microsoft.graph.conflictBehavior":"rename",name:n}};try{const n=yield e.api(t).post(r);return{url:n.uploadUrl,expiry:new Date(n.expirationDateTime)}}catch(e){throw e}})}commit(e){return R(this,void 0,void 0,function*(){try{const t={name:this.file.name,"@microsoft.graph.conflictBehavior":"rename","@microsoft.graph.sourceUrl":this.uploadSession.url};return yield this.client.api(e).put(t)}catch(e){throw e}})}}x.DEFAULT_UPLOAD_PATH="/";var A=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class T{constructor(e,t,n){this.client=e,this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"],this.callback=n,this.complete=!1}iterationHelper(){if(void 0===this.collection)return!1;let e=!0;for(;e&&0!==this.collection.length;){const t=this.collection.shift();e=this.callback(t)}return e}fetchAndUpdateNextPageData(){return A(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.nextLink).get();this.collection=e.value,this.nextLink=e["@odata.nextLink"],this.deltaLink=e["@odata.deltaLink"]}catch(e){throw e}})}getDeltaLink(){return this.deltaLink}iterate(){return A(this,void 0,void 0,function*(){try{let e=this.iterationHelper();for(;e;)void 0!==this.nextLink?(yield this.fetchAndUpdateNextPageData(),e=this.iterationHelper()):e=!1;void 0===this.nextLink&&0===this.collection.length&&(this.complete=!0)}catch(e){throw e}})}resume(){return A(this,void 0,void 0,function*(){try{return this.iterate()}catch(e){throw e}})}isComplete(){return this.complete}}const O="v1.0",P="https://graph.microsoft.com/",D="1.6.0";var b=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class _{constructor(e){this.provider=e}getAccessToken(){return b(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.provider((n,r)=>{r?e(r):t(n)})})})}}class S{constructor(e=-1){this.statusCode=e,this.code=null,this.message=null,this.requestId=null,this.date=new Date,this.body=null}}var L=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class C{static constructError(e,t){const n=new S(t);return void 0!==e.name&&(n.code=e.name),n.body=e.toString(),n.message=e.message,n.date=new Date,n}static constructErrorFromRawResponse(e,t){return L(this,void 0,void 0,function*(){const n=new S(t);try{n.body=yield e.text()}catch(e){}return n})}static constructErrorFromResponse(e,t){e=e.error;const n=new S(t);n.code=e.code,n.message=e.message,void 0!==e.innerError&&(n.requestId=e.innerError["request-id"],n.date=new Date(e.innerError.date));try{n.body=JSON.stringify(e)}catch(e){}return n}static getError(e=null,t=-1,n){return L(this,void 0,void 0,function*(){let r;if(r=!e||"Response"!==e.constructor.name&&"Body"!==e.constructor.name?e&&e.error?C.constructErrorFromResponse(e,t):e&&"Error"===e.constructor.name?C.constructError(e,t):new S(t):yield C.constructErrorFromRawResponse(e,t),"function"!=typeof n)return r;n(r,null)})}}const M=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],U=e=>{const t=e=>e.replace(/\/+$/,""),n=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,r)=>[t(e),n(r)].join("/"))},q=e=>{const t=e.constructor.name;if("Buffer"===t||"Blob"===t||"File"===t||"FormData"===t||"string"==typeof e)return e;if("ArrayBuffer"===t)e=Buffer.from(e);else if("Int8Array"===t||"Int16Array"===t||"Int32Array"===t||"Uint8Array"===t||"Uint16Array"===t||"Uint32Array"===t||"Uint8ClampedArray"===t||"Float32Array"===t||"Float64Array"===t||"DataView"===t)e=Buffer.from(e.buffer);else try{e=JSON.stringify(e)}catch(e){throw new Error("Unable to stringify the content")}return e};var I;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}(I||(I={}));var k,N,F,$=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};!function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(k||(k={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(N||(N={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(F||(F={}));class H{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((n,r)=>{e.text().then(e=>{try{const i=(new DOMParser).parseFromString(e,t);n(i)}catch(e){r(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(e,t){return $(this,void 0,void 0,function*(){const n=e.clone();if(204===n.status)return Promise.resolve();let r;try{switch(t){case I.ARRAYBUFFER:r=yield n.arrayBuffer();break;case I.BLOB:r=yield n.blob();break;case I.DOCUMENT:r=yield H.parseDocumentResponse(n,k.TEXT_XML);break;case I.JSON:r=yield n.json();break;case I.STREAM:r=yield Promise.resolve(n.body);break;case I.TEXT:r=yield n.text();break;default:const e=n.headers.get("Content-type");if(null!==e){const t=e.split(";")[0];r=new RegExp(F.DOCUMENT).test(t)?yield H.parseDocumentResponse(n,t):new RegExp(F.IMAGE).test(t)?n.blob():t===N.TEXT_PLAIN?yield n.text():t===N.APPLICATION_JSON?yield n.json():Promise.resolve(n.body)}else r=Promise.resolve(n.body)}}catch(e){throw e}return r})}static getResponse(e,t,n){return $(this,void 0,void 0,function*(){try{if(t===I.RAW)return Promise.resolve(e);{const r=yield H.convertResponse(e,t);if(!e.ok)throw r;if("function"!=typeof n)return r;n(null,r,e)}}catch(t){throw e.ok?t:e}})}}var X=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class Q{constructor(e,t,n){this.parsePath=(e=>{if(-1!==e.indexOf("https://")){const t=(e=e.replace("https://","")).indexOf("/");-1!==t&&(this.urlComponents.host="https://"+e.substring(0,t),e=e.substring(t+1,e.length));const n=e.indexOf("/");-1!==n&&(this.urlComponents.version=e.substring(0,n),e=e.substring(n+1,e.length))}"/"===e.charAt(0)&&(e=e.substr(1));const t=e.indexOf("?");if(-1===t)this.urlComponents.path=e;else{this.urlComponents.path=e.substr(0,t);const n=e.substring(t+1,e.length).split("&");for(const e of n){const t=e.split("="),n=t[0],r=t[1];-1!==M.indexOf(n)?this.urlComponents.oDataQueryParams[n]=r:this.urlComponents.otherURLQueryParams[n]=r}}}),this.httpClient=e,this.config=t,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{}},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(n)}addCsvQueryParameter(e,t,n){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";let r=[];n.length>1&&"string"==typeof t?r=Array.prototype.slice.call(n):"string"==typeof t?r.push(t):r=r.concat(t),this.urlComponents.oDataQueryParams[e]+=r.join(",")}buildFullUrl(){const e=U([this.urlComponents.host,this.urlComponents.version,this.urlComponents.path])+this.createQueryString();return this.config.debugLogging&&console.log(e),e}createQueryString(){const e=this.urlComponents,t=[];if(0!==Object.keys(e.oDataQueryParams).length)for(const n in e.oDataQueryParams)e.oDataQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.oDataQueryParams[n]);if(0!==Object.keys(e.otherURLQueryParams).length)for(const n in e.otherURLQueryParams)e.otherURLQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.otherURLQueryParams[n]);return t.length>0?"?"+t.join("&"):""}updateRequestOptions(e){const t={SdkVersion:`graph-js-${D}`},n=Object.assign({},e.headers);if(void 0!==this.config.fetchOptions){const t=Object.assign({},this.config.fetchOptions);Object.assign(e,t),void 0!==typeof this.config.fetchOptions.headers&&(e.headers=Object.assign({},this.config.fetchOptions.headers))}Object.assign(e,this._options),Object.assign(n,t),void 0!==e.headers&&Object.assign(n,e.headers),Object.assign(n,this._headers),e.headers=n}send(e,t,n){return X(this,void 0,void 0,function*(){let r;const o=new i(this._middlewareOptions);this.updateRequestOptions(t);try{return r=(yield this.httpClient.sendRequest({request:e,options:t,middlewareControl:o})).response,yield H.getResponse(r,this._responseType,n)}catch(e){let t;throw void 0!==r&&(t=r.status),yield C.getError(e,t,n)}})}header(e,t){return this._headers[e]=t,this}headers(e){for(const t in e)e.hasOwnProperty(t)&&(this._headers[t]=e[t]);return this}option(e,t){return this._options[e]=t,this}options(e){for(const t in e)e.hasOwnProperty(t)&&(this._options[t]=e[t]);return this}middlewareOptions(e){return this._middlewareOptions=e,this}version(e){return this.urlComponents.version=e,this}responseType(e){return this._responseType=e,this}select(e){return this.addCsvQueryParameter("$select",e,arguments),this}expand(e){return this.addCsvQueryParameter("$expand",e,arguments),this}orderby(e){return this.addCsvQueryParameter("$orderby",e,arguments),this}filter(e){return this.urlComponents.oDataQueryParams.$filter=e,this}search(e){return this.urlComponents.oDataQueryParams.$search=e,this}top(e){return this.urlComponents.oDataQueryParams.$top=e,this}skip(e){return this.urlComponents.oDataQueryParams.$skip=e,this}skipToken(e){return this.urlComponents.oDataQueryParams.$skipToken=e,this}count(e){return this.urlComponents.oDataQueryParams.$count=e.toString(),this}query(e){const t=this.urlComponents.otherURLQueryParams;if("string"==typeof e){const n=e.split("="),r=n[0],i=n[1];t[r]=i}else for(const n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return this}get(t){return X(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};try{return yield this.send(n,r,t)}catch(e){throw e}})}post(t,n){return X(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.POST,body:q(t),headers:void 0!==t.constructor&&"FormData"===t.constructor.name?{}:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}create(e,t){return X(this,void 0,void 0,function*(){try{return yield this.post(e,t)}catch(e){throw e}})}put(t,n){return X(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,body:q(t),headers:{"Content-Type":"application/octet-stream"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}patch(t,n){return X(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PATCH,body:q(t),headers:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}update(e,t){return X(this,void 0,void 0,function*(){try{return yield this.patch(e,t)}catch(e){throw e}})}delete(t){return X(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.DELETE};try{return yield this.send(n,r,t)}catch(e){throw e}})}del(e){return X(this,void 0,void 0,function*(){try{return yield this.delete(e)}catch(e){throw e}})}getStream(t){return X(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};this.responseType(I.STREAM);try{return yield this.send(n,r,t)}catch(e){throw e}})}putStream(t,n){return X(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,headers:{"Content-Type":"application/octet-stream"},body:t};try{return yield this.send(r,i,n)}catch(e){throw e}})}}var j=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class B{constructor(e){this.middleware=e}sendRequest(e){return j(this,void 0,void 0,function*(){try{if(!(e.request instanceof Request)&&void 0===e.options){const e=new Error;throw e.name="InvalidRequestOptions",e.message="Unable to execute the middleware, Please provide valid options for a request",e}return yield this.middleware.execute(e),e}catch(e){throw e}})}}class z{constructor(e=z.DEFAULT_MAX_REDIRECTS,t=z.DEFAULT_SHOULD_RETRY){if(e>z.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${z.MAX_MAX_REDIRECTS}`);throw e.name="MaxLimitExceeded",e}this.maxRedirects=e,this.shouldRedirect=t}}z.DEFAULT_MAX_REDIRECTS=5,z.MAX_MAX_REDIRECTS=20,z.DEFAULT_SHOULD_RETRY=(()=>!0);var Y=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class V{constructor(e=new z){this.options=e}isRedirect(e){return-1!==V.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(V.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(V.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const n=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,r=n.exec(e);let i,o;null!==r&&(i=r[0]);const s=n.exec(t);return null!==s&&(o=s[0]),void 0!==i&&void 0!==o&&i!==o}updateRequestUrl(e,t){return Y(this,void 0,void 0,function*(){t.request=t.request instanceof Request?yield c(e,t.request):e})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new z,this.options)),t}executeWithRedirect(t,n,r){return Y(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(t);const i=t.response;if(!(n<r.maxRedirects&&this.isRedirect(i)&&this.hasLocationHeader(i)&&r.shouldRedirect(i)))return;if(++n,i.status===V.STATUS_CODE_SEE_OTHER)t.options.method=e.GET,delete t.options.body;else{const e=this.getLocationHeader(i);!this.isRelativeURL(e)&&this.shouldDropAuthorizationHeader(i.url,e)&&a(t.request,t.options,V.AUTHORIZATION_HEADER,void 0),yield this.updateRequestUrl(e,t)}yield this.executeWithRedirect(t,n,r)}catch(e){throw e}})}execute(e){return Y(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return e.options.redirect=V.MANUAL_REDIRECT,yield this.executeWithRedirect(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}V.REDIRECT_STATUS_CODES=[301,302,303,307,308],V.STATUS_CODE_SEE_OTHER=303,V.LOCATION_HEADER="Location",V.AUTHORIZATION_HEADER="Authorization",V.MANUAL_REDIRECT="manual";const W=()=>new Function("try {return this === global;}catch(e){return false;}")();class G{static createWithAuthenticationProvider(e){const t=new h(e),n=new m(new f),r=new p;if(t.setNext(n),W()){const e=new V(new z);n.setNext(e),e.setNext(r)}else n.setNext(r);return G.createWithMiddleware(t)}static createWithMiddleware(e){return new B(e)}}const Z=()=>{if("undefined"==typeof Promise&&"undefined"==typeof fetch){const e=new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof Promise){const e=new Error("Library cannot function without Promise. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof fetch){const e=new Error("Library cannot function without fetch. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}return!0};class J{constructor(e){this.config={baseUrl:P,debugLogging:!1,defaultVersion:O};try{Z()}catch(e){throw e}for(const t in e)e.hasOwnProperty(t)&&(this.config[t]=e[t]);let t;if(void 0!==e.authProvider&&void 0!==e.middleware){const e=new Error;throw e.name="AmbiguityInInitialization",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both",e}if(void 0!==e.authProvider)t=G.createWithAuthenticationProvider(e.authProvider);else{if(void 0===e.middleware){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain",e}t=new B(e.middleware)}this.httpClient=t}static init(e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]="authProvider"===n?new _(e[n]):e[n]);return J.initWithMiddleware(t)}static initWithMiddleware(e){try{return new J(e)}catch(e){throw e}}api(e){return new Q(this.httpClient,this.config,e)}}var K=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class ee{constructor(e,t,n){this.scopes=t,this.userAgentApplication="string"==typeof e?new Msal.UserAgentApplication(e,void 0,(e,t,n,r)=>{},n):e}getAccessToken(e){return K(this,void 0,void 0,function*(){let t;if(void 0!==e&&(t=e.scopes),void 0!==t&&0!==t.length||(t=this.scopes),0===t.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes cannot be empty, Please provide a scope",e}try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){try{yield this.userAgentApplication.loginPopup(t);try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){return yield this.userAgentApplication.acquireTokenPopup(t)}}catch(e){throw new Error(e)}}})}addScopes(e){if(0===e.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes array cannot be empty",e}this.scopes=Array.from(new Set(this.scopes.concat(e)))}clearScopes(){this.scopes=[]}}class te{constructor(e){this.scopes=e}}export{h as AuthenticationHandler,d as AuthenticationHandlerOptions,n as BatchRequestContent,r as BatchResponseContent,J as Client,S as GraphError,Q as GraphRequest,p as HTTPMessageHandler,ee as MSALAuthenticationProvider,te as MSALAuthenticationProviderOptions,x as OneDriveLargeFileUploadTask,T as PageIterator,I as ResponseType,m as RetryHandler,f as RetryHandlerOptions}; | ||
var e;!function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(e||(e={}));var t=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class n{constructor(e){if(this.requests=new Map,void 0!==e){const t=n.requestLimit;if(e.length>t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}for(const t of e)this.addRequest(t)}}static validateDependencies(e){if(0===e.size){const e=new Error("Empty requests map, Please provide at least one request.");throw e.name="Empty Requests Error",e}return(e=>{const t=e.entries();let n=t.next();for(;!n.done;){const e=n.value[1];if(void 0!==e.dependsOn&&e.dependsOn.length>0)return!1;n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];if(void 0!==r.dependsOn&&r.dependsOn.length>0)return!1;let i=n;for(n=t.next();!n.done;){const e=n.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==i.value[1].id)return!1;i=n,n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];let i;if(void 0===r.dependsOn||0===r.dependsOn.length)i=r.id;else{if(1!==r.dependsOn.length)return!1;{const t=r.dependsOn[0];if(t===r.id||!e.has(t))return!1;i=t}}for(n=t.next();!n.done;){const e=n.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&i!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===i||e.dependsOn[0]!==i))return!1;if(e.dependsOn.length>1)return!1}n=t.next()}return!0})(e)}static getRequestData(r){return t(this,void 0,void 0,function*(){const t={url:""},i=new RegExp("^https?://");t.url=i.test(r.url)?"/"+r.url.split(/.*?\/\/.*?\//)[1]:r.url,t.method=r.method;const o={};return r.headers.forEach((e,t)=>{o[t]=e}),Object.keys(o).length&&(t.headers=o),r.method!==e.PATCH&&r.method!==e.POST&&r.method!==e.PUT||(t.body=yield n.getRequestBody(r)),t})}static getRequestBody(e){return t(this,void 0,void 0,function*(){let t,n=!1;try{const r=e.clone();t=yield r.json(),n=!0}catch(e){}if(!n)try{if("undefined"!=typeof Blob){const n=yield e.blob(),r=new FileReader;t=yield new Promise(e=>{r.addEventListener("load",()=>{const t=r.result,n=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(n[4])},!1),r.readAsDataURL(n)})}else if("undefined"!=typeof Buffer){t=(yield e.buffer()).toString("base64")}n=!0}catch(e){}return t})}addRequest(e){const t=n.requestLimit;if(""===e.id){const e=new Error("Id for a request is empty, Please provide an unique id");throw e.name="Empty Id For Request",e}if(this.requests.size===t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}if(this.requests.has(e.id)){const t=new Error(`Adding request with duplicate id ${e.id}, Make the id of the requests unique`);throw t.name="Duplicate RequestId Error",t}return this.requests.set(e.id,e),e.id}removeRequest(e){const t=this.requests.delete(e),n=this.requests.entries();let r=n.next();for(;!r.done;){const t=r.value[1].dependsOn;if(void 0!==t){const n=t.indexOf(e);-1!==n&&t.splice(n,1),0===t.length&&delete r.value[1].dependsOn}r=n.next()}return t}getContent(){return t(this,void 0,void 0,function*(){const e=[],t={requests:e},r=this.requests.entries();let i=r.next();if(i.done){const e=new Error("No requests added yet, Please add at least one request.");throw e.name="Empty Payload",e}if(!n.validateDependencies(this.requests)){const e=new Error("Invalid dependency found, Dependency should be:\n1. Parallel - no individual request states a dependency in the dependsOn property.\n2. Serial - all individual requests depend on the previous individual request.\n3. Same - all individual requests that state a dependency in the dependsOn property, state the same dependency.");throw e.name="Invalid Dependency",e}for(;!i.done;){const t=i.value[1],o=yield n.getRequestData(t.request);if(void 0!==o.body&&(void 0===o.headers||void 0===o.headers["content-type"])){const e=new Error(`Content-type header is not mentioned for request #${t.id}, For request having body, Content-type header should be mentioned`);throw e.name="Invalid Content-type header",e}o.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(o.dependsOn=t.dependsOn),e.push(o),i=r.next()}return t.requests=e,t})}addDependency(e,t){if(!this.requests.has(e)){const t=new Error(`Dependent ${e} does not exists, Please check the id`);throw t.name="Invalid Dependent",t}if(void 0!==t&&!this.requests.has(t)){const e=new Error(`Dependency ${t} does not exists, Please check the id`);throw e.name="Invalid Dependency",e}if(void 0!==t){const n=this.requests.get(e);if(void 0===n.dependsOn&&(n.dependsOn=[]),-1!==n.dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}n.dependsOn.push(t)}else{const n=this.requests.entries();let r,i=n.next();for(;!i.done&&i.value[1].id!==e;)r=i,i=n.next();if(void 0===r){const e=new Error(`Can't add dependency ${t}, There is only a dependent request in the batch`);throw e.name="Invalid Dependency Addition",e}{const t=r.value[0];if(void 0===i.value[1].dependsOn&&(i.value[1].dependsOn=[]),-1!==i.value[1].dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}i.value[1].dependsOn.push(t)}}}removeDependency(e,t){const n=this.requests.get(e);if(void 0===n||void 0===n.dependsOn||0===n.dependsOn.length)return!1;if(void 0!==t){const e=n.dependsOn.indexOf(t);return-1!==e&&(n.dependsOn.splice(e,1),!0)}return delete n.dependsOn,!0}}n.requestLimit=20;class r{constructor(e){this.responses=new Map,this.update(e)}createResponseObject(e){const t=e.body,n={};return n.status=e.status,void 0!==e.statusText&&(n.statusText=e.statusText),n.headers=e.headers,new Response(t,n)}update(e){this.nextLink=e["@nextLink"];const t=e.responses;for(let e=0,n=t.length;e<n;e++)this.responses.set(t[e].id,this.createResponseObject(t[e]))}getResponseById(e){return this.responses.get(e)}getResponses(){return this.responses}*getResponsesIterator(){const e=this.responses.entries();let t=e.next();for(;!t.done;)yield t.value,t=e.next()}}class i{constructor(e=[]){this.middlewareOptions=new Map;for(const t of e){const e=t.constructor.name;this.middlewareOptions.set(e,t)}}getMiddlewareOptions(e){return this.middlewareOptions.get(e)}setMiddlewareOptions(e,t){this.middlewareOptions.set(e,t)}}var o=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};const s=()=>{let e="";for(let t=0;t<32;t++)8!==t&&12!==t&&16!==t&&20!==t||(e+="-"),e+=Math.floor(16*Math.random()).toString(16);return e},a=(e,t,n)=>{let r=null;if(e instanceof Request)r=e.headers.get(n);else if(void 0!==t&&void 0!==t.headers)if(t.headers instanceof Headers)r=t.headers.get(n);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,i=e.length;t<i;t++)if(e[t][0]===n){r=e[t][1];break}}else void 0!==t.headers[n]&&(r=t.headers[n]);return r},c=(e,t,n,r)=>{e instanceof Request?e.headers.set(n,r):void 0!==t&&(void 0===t.headers?t.headers={[n]:r}:t.headers instanceof Headers?t.headers.set(n,r):t.headers instanceof Array?t.headers.push([n,r]):Object.assign(t.headers,{[n]:r}))},d=(e,t)=>o(void 0,void 0,void 0,function*(){const n=t.headers.get("Content-Type")?yield t.blob():yield Promise.resolve(void 0),{method:r,headers:i,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p}=t;return new Request(e,{method:r,headers:i,body:n,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p})});class u{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var h;!function(e){e[e.NONE=0]="NONE",e[e.REDIRECT_HANDLER_ENABLED=1]="REDIRECT_HANDLER_ENABLED",e[e.RETRY_HANDLER_ENABLED=2]="RETRY_HANDLER_ENABLED",e[e.AUTHENTICATION_HANDLER_ENABLED=4]="AUTHENTICATION_HANDLER_ENABLED"}(h||(h={}));class l{constructor(){this.featureUsage=h.NONE}static updateFeatureUsageFlag(e,t){let n;e.middlewareControl instanceof i?n=e.middlewareControl.getMiddlewareOptions(l.name):e.middlewareControl=new i,void 0===n&&(n=new l,e.middlewareControl.setMiddlewareOptions(l.name,n)),n.setFeatureUsage(t)}setFeatureUsage(e){this.featureUsage=this.featureUsage|e}getFeatureUsage(){return this.featureUsage.toString(16)}}var p=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class f{constructor(e){this.authenticationProvider=e}execute(e){return p(this,void 0,void 0,function*(){try{let t,n,r;e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(u.name)),void 0!==t&&(n=t.authenticationProvider,r=t.authenticationProviderOptions),void 0===n&&(n=this.authenticationProvider);const o=`Bearer ${yield n.getAccessToken(r)}`;return c(e.request,e.options,f.AUTHORIZATION_HEADER,o),l.updateFeatureUsageFlag(e,h.AUTHENTICATION_HANDLER_ENABLED),yield this.nextMiddleware.execute(e)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}f.AUTHORIZATION_HEADER="Authorization";var y=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class m{execute(e){return y(this,void 0,void 0,function*(){try{return void(e.response=yield fetch(e.request,e.options))}catch(e){throw e}})}}class v{constructor(e=v.DEFAULT_DELAY,t=v.DEFAULT_MAX_RETRIES,n=v.DEFAULT_SHOULD_RETRY){if(e>v.MAX_DELAY&&t>v.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${v.MAX_DELAY} and ${v.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>v.MAX_DELAY){const e=new Error(`Delay should not be more than ${v.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>v.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${v.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}this.delay=Math.min(e,v.MAX_DELAY),this.maxRetries=Math.min(t,v.MAX_MAX_RETRIES),this.shouldRetry=n}getMaxDelay(){return v.MAX_DELAY}}v.DEFAULT_DELAY=3,v.DEFAULT_MAX_RETRIES=3,v.MAX_DELAY=180,v.MAX_MAX_RETRIES=10,v.DEFAULT_SHOULD_RETRY=(()=>!0);var E=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class w{constructor(e=new v){this.options=e}isRetry(e){return-1!==w.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(t,n){const r=t instanceof Request?t.method:n.method;if(r===e.PUT||r===e.PATCH||r===e.POST){if("application/octet-stream"===a(t,n,"Content-Type"))return!1}return!0}getDelay(e,t,n){const r=()=>Number(Math.random().toFixed(3)),i=void 0!==e.headers?e.headers.get(w.RETRY_AFTER_HEADER):null;let o;return o=null!==i?Number.isNaN(Number(i))?Math.round((new Date(i).getTime()-Date.now())/1e3):Number(i):t>=2?this.getExponentialBackOffTime(t)+n+r():n+r(),Math.min(o,this.options.getMaxDelay()+r())}getExponentialBackOffTime(e){return Math.round(.5*(Math.pow(2,e)-1))}sleep(e){return E(this,void 0,void 0,function*(){const t=1e3*e;return new Promise(e=>setTimeout(e,t))})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new v,this.options)),t}executeWithRetry(e,t,n){return E(this,void 0,void 0,function*(){try{if(yield this.nextMiddleware.execute(e),t<n.maxRetries&&this.isRetry(e.response)&&this.isBuffered(e.request,e.options)&&n.shouldRetry(n.delay,t,e.request,e.options,e.response)){++t,c(e.request,e.options,w.RETRY_ATTEMPT_HEADER,t.toString());const r=this.getDelay(e.response,t,n.delay);return yield this.sleep(r),yield this.executeWithRetry(e,t,n)}return}catch(e){throw e}})}execute(e){return E(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return l.updateFeatureUsageFlag(e,h.RETRY_HANDLER_ENABLED),yield this.executeWithRetry(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}w.RETRY_STATUS_CODES=[429,503,504],w.RETRY_ATTEMPT_HEADER="Retry-Attempt",w.RETRY_AFTER_HEADER="Retry-After";const R="v1.0",g="https://graph.microsoft.com/",A="1.7.0-Preview.1";var T=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class x{execute(e){return T(this,void 0,void 0,function*(){try{let t=a(e.request,e.options,x.CLIENT_REQUEST_ID_HEADER);null===t&&(t=s(),c(e.request,e.options,x.CLIENT_REQUEST_ID_HEADER,t));let n,r=`${x.PRODUCT_NAME}/${A}`;if(e.middlewareControl instanceof i&&(n=e.middlewareControl.getMiddlewareOptions(l.name)),void 0!==n){const e=n.getFeatureUsage();r+=` (${x.FEATURE_USAGE_STRING}=${e})`}return c(e.request,e.options,x.SDK_VERSION_HEADER,r),yield this.nextMiddleware.execute(e)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}x.CLIENT_REQUEST_ID_HEADER="client-request-id",x.SDK_VERSION_HEADER="SdkVersion",x.PRODUCT_NAME="graph-js",x.FEATURE_USAGE_STRING="featureUsage";class O{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}var D=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class _{constructor(e,t,n,r){this.DEFAULT_FILE_SIZE=5242880,this.client=e,this.file=t,void 0===r.rangeSize&&(r.rangeSize=this.DEFAULT_FILE_SIZE),this.options=r,this.uploadSession=n,this.nextRange=new O(0,this.options.rangeSize-1)}parseRange(e){const t=e[0];if(void 0===t||""===t)return new O;const n=t.split("-"),r=parseInt(n[0],10);let i=parseInt(n[1],10);return Number.isNaN(i)&&(i=this.file.size-1),new O(r,i)}updateTaskStatus(e){this.uploadSession.expiry=new Date(e.expirationDateTime),this.nextRange=this.parseRange(e.nextExpectedRanges)}getNextRange(){if(-1===this.nextRange.minValue)return this.nextRange;const e=this.nextRange.minValue;let t=e+this.options.rangeSize-1;return t>=this.file.size&&(t=this.file.size-1),new O(e,t)}sliceFile(e){return this.file.content.slice(e.minValue,e.maxValue+1)}upload(){return D(this,void 0,void 0,function*(){try{for(;;){const e=this.getNextRange();if(-1===e.maxValue){const e=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");throw e.name="Invalid Session",e}const t=this.sliceFile(e),n=yield this.uploadSlice(t,e,this.file.size);if(void 0!==n.id)return n;this.updateTaskStatus(n)}}catch(e){throw e}})}uploadSlice(e,t,n){return D(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${t.maxValue-t.minValue+1}`,"Content-Range":`bytes ${t.minValue}-${t.maxValue}/${n}`}).put(e)}catch(e){throw e}})}cancel(){return D(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).delete()}catch(e){throw e}})}getStatus(){return D(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.uploadSession.url).get();return this.updateTaskStatus(e),e}catch(e){throw e}})}resume(){return D(this,void 0,void 0,function*(){try{return yield this.getStatus(),yield this.upload()}catch(e){throw e}})}}const P=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};var L=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class b extends _{constructor(e,t,n,r){super(e,t,n,r)}static create(e,t,n){return L(this,void 0,void 0,function*(){const r=n.fileName;let i,o;switch(t.constructor.name){case"Blob":o=(i=new File([t],r)).size;break;case"File":o=(i=t).size;break;case"Buffer":const e=t;o=e.byteLength-e.byteOffset,i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const t=b.constructCreateSessionUrl(n.fileName,n.path),s=yield b.createUploadSession(e,t,n.fileName),a=P(n.rangeSize);return new b(e,{name:r,content:i,size:o},s,{rangeSize:a})}catch(e){throw e}})}static constructCreateSessionUrl(e,t=b.DEFAULT_UPLOAD_PATH){return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t=`/${t}`),"/"!==t[t.length-1]&&(t=`${t}/`),encodeURI(`/me/drive/root:${t}${e}:/createUploadSession`)}static createUploadSession(e,t,n){return L(this,void 0,void 0,function*(){const r={item:{"@microsoft.graph.conflictBehavior":"rename",name:n}};try{const n=yield e.api(t).post(r);return{url:n.uploadUrl,expiry:new Date(n.expirationDateTime)}}catch(e){throw e}})}commit(e){return L(this,void 0,void 0,function*(){try{const t={name:this.file.name,"@microsoft.graph.conflictBehavior":"rename","@microsoft.graph.sourceUrl":this.uploadSession.url};return yield this.client.api(e).put(t)}catch(e){throw e}})}}b.DEFAULT_UPLOAD_PATH="/";var S=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class C{constructor(e,t,n){this.client=e,this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"],this.callback=n,this.complete=!1}iterationHelper(){if(void 0===this.collection)return!1;let e=!0;for(;e&&0!==this.collection.length;){const t=this.collection.shift();e=this.callback(t)}return e}fetchAndUpdateNextPageData(){return S(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.nextLink).get();this.collection=e.value,this.nextLink=e["@odata.nextLink"],this.deltaLink=e["@odata.deltaLink"]}catch(e){throw e}})}getDeltaLink(){return this.deltaLink}iterate(){return S(this,void 0,void 0,function*(){try{let e=this.iterationHelper();for(;e;)void 0!==this.nextLink?(yield this.fetchAndUpdateNextPageData(),e=this.iterationHelper()):e=!1;void 0===this.nextLink&&0===this.collection.length&&(this.complete=!0)}catch(e){throw e}})}resume(){return S(this,void 0,void 0,function*(){try{return this.iterate()}catch(e){throw e}})}isComplete(){return this.complete}}var U=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class M{constructor(e){this.provider=e}getAccessToken(){return U(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.provider((n,r)=>{r?e(r):t(n)})})})}}class N{constructor(e=-1){this.statusCode=e,this.code=null,this.message=null,this.requestId=null,this.date=new Date,this.body=null}}var q=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class I{static constructError(e,t){const n=new N(t);return void 0!==e.name&&(n.code=e.name),n.body=e.toString(),n.message=e.message,n.date=new Date,n}static constructErrorFromRawResponse(e,t){return q(this,void 0,void 0,function*(){const n=new N(t);try{n.body=yield e.text()}catch(e){}return n})}static constructErrorFromResponse(e,t){e=e.error;const n=new N(t);n.code=e.code,n.message=e.message,void 0!==e.innerError&&(n.requestId=e.innerError["request-id"],n.date=new Date(e.innerError.date));try{n.body=JSON.stringify(e)}catch(e){}return n}static getError(e=null,t=-1,n){return q(this,void 0,void 0,function*(){let r;if(r=!e||"Response"!==e.constructor.name&&"Body"!==e.constructor.name?e&&e.error?I.constructErrorFromResponse(e,t):e&&"Error"===e.constructor.name?I.constructError(e,t):new N(t):yield I.constructErrorFromRawResponse(e,t),"function"!=typeof n)return r;n(r,null)})}}const F=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],k=e=>{const t=e=>e.replace(/\/+$/,""),n=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,r)=>[t(e),n(r)].join("/"))},H=e=>{const t=e.constructor.name;if("Buffer"===t||"Blob"===t||"File"===t||"FormData"===t||"string"==typeof e)return e;if("ArrayBuffer"===t)e=Buffer.from(e);else if("Int8Array"===t||"Int16Array"===t||"Int32Array"===t||"Uint8Array"===t||"Uint16Array"===t||"Uint32Array"===t||"Uint8ClampedArray"===t||"Float32Array"===t||"Float64Array"===t||"DataView"===t)e=Buffer.from(e.buffer);else try{e=JSON.stringify(e)}catch(e){throw new Error("Unable to stringify the content")}return e};var $;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}($||($={}));var X,B,Q,j=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};!function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(X||(X={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(B||(B={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(Q||(Q={}));class Y{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((n,r)=>{e.text().then(e=>{try{const i=(new DOMParser).parseFromString(e,t);n(i)}catch(e){r(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(e,t){return j(this,void 0,void 0,function*(){const n=e.clone();if(204===n.status)return Promise.resolve();let r;try{switch(t){case $.ARRAYBUFFER:r=yield n.arrayBuffer();break;case $.BLOB:r=yield n.blob();break;case $.DOCUMENT:r=yield Y.parseDocumentResponse(n,X.TEXT_XML);break;case $.JSON:r=yield n.json();break;case $.STREAM:r=yield Promise.resolve(n.body);break;case $.TEXT:r=yield n.text();break;default:const e=n.headers.get("Content-type");if(null!==e){const t=e.split(";")[0];r=new RegExp(Q.DOCUMENT).test(t)?yield Y.parseDocumentResponse(n,t):new RegExp(Q.IMAGE).test(t)?n.blob():t===B.TEXT_PLAIN?yield n.text():t===B.APPLICATION_JSON?yield n.json():Promise.resolve(n.body)}else r=Promise.resolve(n.body)}}catch(e){throw e}return r})}static getResponse(e,t,n){return j(this,void 0,void 0,function*(){try{if(t===$.RAW)return Promise.resolve(e);{const r=yield Y.convertResponse(e,t);if(!e.ok)throw r;if("function"!=typeof n)return r;n(null,r,e)}}catch(t){throw e.ok?t:e}})}}var z=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class V{constructor(e,t,n){this.parsePath=(e=>{if(-1!==e.indexOf("https://")){const t=(e=e.replace("https://","")).indexOf("/");-1!==t&&(this.urlComponents.host="https://"+e.substring(0,t),e=e.substring(t+1,e.length));const n=e.indexOf("/");-1!==n&&(this.urlComponents.version=e.substring(0,n),e=e.substring(n+1,e.length))}"/"===e.charAt(0)&&(e=e.substr(1));const t=e.indexOf("?");if(-1===t)this.urlComponents.path=e;else{this.urlComponents.path=e.substr(0,t);const n=e.substring(t+1,e.length).split("&");for(const e of n){const t=e.split("="),n=t[0],r=t[1];-1!==F.indexOf(n)?this.urlComponents.oDataQueryParams[n]=r:this.urlComponents.otherURLQueryParams[n]=r}}}),this.httpClient=e,this.config=t,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{}},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(n)}addCsvQueryParameter(e,t,n){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";let r=[];n.length>1&&"string"==typeof t?r=Array.prototype.slice.call(n):"string"==typeof t?r.push(t):r=r.concat(t),this.urlComponents.oDataQueryParams[e]+=r.join(",")}buildFullUrl(){const e=k([this.urlComponents.host,this.urlComponents.version,this.urlComponents.path])+this.createQueryString();return this.config.debugLogging&&console.log(e),e}createQueryString(){const e=this.urlComponents,t=[];if(0!==Object.keys(e.oDataQueryParams).length)for(const n in e.oDataQueryParams)e.oDataQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.oDataQueryParams[n]);if(0!==Object.keys(e.otherURLQueryParams).length)for(const n in e.otherURLQueryParams)e.otherURLQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.otherURLQueryParams[n]);return t.length>0?"?"+t.join("&"):""}updateRequestOptions(e){const t=Object.assign({},e.headers);if(void 0!==this.config.fetchOptions){const t=Object.assign({},this.config.fetchOptions);Object.assign(e,t),void 0!==typeof this.config.fetchOptions.headers&&(e.headers=Object.assign({},this.config.fetchOptions.headers))}Object.assign(e,this._options),void 0!==e.headers&&Object.assign(t,e.headers),Object.assign(t,this._headers),e.headers=t}send(e,t,n){return z(this,void 0,void 0,function*(){let r;const o=new i(this._middlewareOptions);this.updateRequestOptions(t);try{return r=(yield this.httpClient.sendRequest({request:e,options:t,middlewareControl:o})).response,yield Y.getResponse(r,this._responseType,n)}catch(e){let t;throw void 0!==r&&(t=r.status),yield I.getError(e,t,n)}})}header(e,t){return this._headers[e]=t,this}headers(e){for(const t in e)e.hasOwnProperty(t)&&(this._headers[t]=e[t]);return this}option(e,t){return this._options[e]=t,this}options(e){for(const t in e)e.hasOwnProperty(t)&&(this._options[t]=e[t]);return this}middlewareOptions(e){return this._middlewareOptions=e,this}version(e){return this.urlComponents.version=e,this}responseType(e){return this._responseType=e,this}select(e){return this.addCsvQueryParameter("$select",e,arguments),this}expand(e){return this.addCsvQueryParameter("$expand",e,arguments),this}orderby(e){return this.addCsvQueryParameter("$orderby",e,arguments),this}filter(e){return this.urlComponents.oDataQueryParams.$filter=e,this}search(e){return this.urlComponents.oDataQueryParams.$search=e,this}top(e){return this.urlComponents.oDataQueryParams.$top=e,this}skip(e){return this.urlComponents.oDataQueryParams.$skip=e,this}skipToken(e){return this.urlComponents.oDataQueryParams.$skipToken=e,this}count(e){return this.urlComponents.oDataQueryParams.$count=e.toString(),this}query(e){const t=this.urlComponents.otherURLQueryParams;if("string"==typeof e){const n=e.split("="),r=n[0],i=n[1];t[r]=i}else for(const n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return this}get(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};try{return yield this.send(n,r,t)}catch(e){throw e}})}post(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.POST,body:H(t),headers:void 0!==t.constructor&&"FormData"===t.constructor.name?{}:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}create(e,t){return z(this,void 0,void 0,function*(){try{return yield this.post(e,t)}catch(e){throw e}})}put(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,body:H(t),headers:{"Content-Type":"application/octet-stream"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}patch(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PATCH,body:H(t),headers:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}update(e,t){return z(this,void 0,void 0,function*(){try{return yield this.patch(e,t)}catch(e){throw e}})}delete(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.DELETE};try{return yield this.send(n,r,t)}catch(e){throw e}})}del(e){return z(this,void 0,void 0,function*(){try{return yield this.delete(e)}catch(e){throw e}})}getStream(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};this.responseType($.STREAM);try{return yield this.send(n,r,t)}catch(e){throw e}})}putStream(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,headers:{"Content-Type":"application/octet-stream"},body:t};try{return yield this.send(r,i,n)}catch(e){throw e}})}}var W=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class G{constructor(e){this.middleware=e}sendRequest(e){return W(this,void 0,void 0,function*(){try{if(!(e.request instanceof Request)&&void 0===e.options){const e=new Error;throw e.name="InvalidRequestOptions",e.message="Unable to execute the middleware, Please provide valid options for a request",e}return yield this.middleware.execute(e),e}catch(e){throw e}})}}class Z{constructor(e=Z.DEFAULT_MAX_REDIRECTS,t=Z.DEFAULT_SHOULD_RETRY){if(e>Z.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${Z.MAX_MAX_REDIRECTS}`);throw e.name="MaxLimitExceeded",e}this.maxRedirects=e,this.shouldRedirect=t}}Z.DEFAULT_MAX_REDIRECTS=5,Z.MAX_MAX_REDIRECTS=20,Z.DEFAULT_SHOULD_RETRY=(()=>!0);var J=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class K{constructor(e=new Z){this.options=e}isRedirect(e){return-1!==K.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(K.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(K.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const n=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,r=n.exec(e);let i,o;null!==r&&(i=r[0]);const s=n.exec(t);return null!==s&&(o=s[0]),void 0!==i&&void 0!==o&&i!==o}updateRequestUrl(e,t){return J(this,void 0,void 0,function*(){t.request=t.request instanceof Request?yield d(e,t.request):e})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new Z,this.options)),t}executeWithRedirect(t,n,r){return J(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(t);const i=t.response;if(!(n<r.maxRedirects&&this.isRedirect(i)&&this.hasLocationHeader(i)&&r.shouldRedirect(i)))return;if(++n,i.status===K.STATUS_CODE_SEE_OTHER)t.options.method=e.GET,delete t.options.body;else{const e=this.getLocationHeader(i);!this.isRelativeURL(e)&&this.shouldDropAuthorizationHeader(i.url,e)&&c(t.request,t.options,K.AUTHORIZATION_HEADER,void 0),yield this.updateRequestUrl(e,t)}yield this.executeWithRedirect(t,n,r)}catch(e){throw e}})}execute(e){return J(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return e.options.redirect=K.MANUAL_REDIRECT,l.updateFeatureUsageFlag(e,h.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}K.REDIRECT_STATUS_CODES=[301,302,303,307,308],K.STATUS_CODE_SEE_OTHER=303,K.LOCATION_HEADER="Location",K.AUTHORIZATION_HEADER="Authorization",K.MANUAL_REDIRECT="manual";const ee=()=>new Function("try {return this === global;}catch(e){return false;}")();class te{static createWithAuthenticationProvider(e){const t=new f(e),n=new w(new v),r=new x,i=new m;if(t.setNext(n),ee()){const e=new K(new Z);n.setNext(e),e.setNext(r)}else n.setNext(r);return r.setNext(i),te.createWithMiddleware(t)}static createWithMiddleware(e){return new G(e)}}const ne=()=>{if("undefined"==typeof Promise&&"undefined"==typeof fetch){const e=new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof Promise){const e=new Error("Library cannot function without Promise. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof fetch){const e=new Error("Library cannot function without fetch. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}return!0};class re{constructor(e){this.config={baseUrl:g,debugLogging:!1,defaultVersion:R};try{ne()}catch(e){throw e}for(const t in e)e.hasOwnProperty(t)&&(this.config[t]=e[t]);let t;if(void 0!==e.authProvider&&void 0!==e.middleware){const e=new Error;throw e.name="AmbiguityInInitialization",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both",e}if(void 0!==e.authProvider)t=te.createWithAuthenticationProvider(e.authProvider);else{if(void 0===e.middleware){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain",e}t=new G(e.middleware)}this.httpClient=t}static init(e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]="authProvider"===n?new M(e[n]):e[n]);return re.initWithMiddleware(t)}static initWithMiddleware(e){try{return new re(e)}catch(e){throw e}}api(e){return new V(this.httpClient,this.config,e)}}var ie=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class oe{constructor(e,t,n){this.scopes=t,this.userAgentApplication="string"==typeof e?new Msal.UserAgentApplication(e,void 0,(e,t,n,r)=>{},n):e}getAccessToken(e){return ie(this,void 0,void 0,function*(){let t;if(void 0!==e&&(t=e.scopes),void 0!==t&&0!==t.length||(t=this.scopes),0===t.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes cannot be empty, Please provide a scope",e}try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){try{yield this.userAgentApplication.loginPopup(t);try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){return yield this.userAgentApplication.acquireTokenPopup(t)}}catch(e){throw new Error(e)}}})}addScopes(e){if(0===e.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes array cannot be empty",e}this.scopes=Array.from(new Set(this.scopes.concat(e)))}clearScopes(){this.scopes=[]}}class se{constructor(e){this.scopes=e}}export{f as AuthenticationHandler,u as AuthenticationHandlerOptions,n as BatchRequestContent,r as BatchResponseContent,re as Client,h as FeatureUsageFlag,N as GraphError,V as GraphRequest,m as HTTPMessageHandler,oe as MSALAuthenticationProvider,se as MSALAuthenticationProviderOptions,b as OneDriveLargeFileUploadTask,C as PageIterator,$ as ResponseType,w as RetryHandler,v as RetryHandlerOptions,x as TelemetryHandler,l as TelemetryHandlerOptions}; |
@@ -13,5 +13,7 @@ /** | ||
export * from "../middleware/RetryHandler"; | ||
export * from "../middleware/TelemetryHandler"; | ||
export * from "../middleware/options/AuthenticationHandlerOptions"; | ||
export * from "../middleware/options/IMiddlewareOptions"; | ||
export * from "../middleware/options/RetryHandlerOptions"; | ||
export * from "../middleware/options/TelemetryHandlerOptions"; | ||
export * from "../tasks/OneDriveLargeFileUploadTask"; | ||
@@ -18,0 +20,0 @@ export * from "../tasks/PageIterator"; |
@@ -15,4 +15,6 @@ "use strict"; | ||
tslib_1.__exportStar(require("../middleware/RetryHandler"), exports); | ||
tslib_1.__exportStar(require("../middleware/TelemetryHandler"), exports); | ||
tslib_1.__exportStar(require("../middleware/options/AuthenticationHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("../middleware/options/RetryHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("../middleware/options/TelemetryHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("../tasks/OneDriveLargeFileUploadTask"), exports); | ||
@@ -19,0 +21,0 @@ tslib_1.__exportStar(require("../tasks/PageIterator"), exports); |
@@ -26,2 +26,2 @@ /** | ||
*/ | ||
export declare const PACKAGE_VERSION = "1.6.0"; | ||
export declare const PACKAGE_VERSION = "1.7.0-Preview.1"; |
@@ -28,3 +28,3 @@ "use strict"; | ||
*/ | ||
exports.PACKAGE_VERSION = "1.6.0"; | ||
exports.PACKAGE_VERSION = "1.7.0-Preview.1"; | ||
//# sourceMappingURL=Constants.js.map |
@@ -10,6 +10,2 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
/** | ||
* @module GraphRequest | ||
*/ | ||
var Constants_1 = require("./Constants"); | ||
var GraphErrorHandler_1 = require("./GraphErrorHandler"); | ||
@@ -171,5 +167,2 @@ var GraphRequestUtil_1 = require("./GraphRequestUtil"); | ||
GraphRequest.prototype.updateRequestOptions = function (options) { | ||
var defaultHeaders = { | ||
SdkVersion: "graph-js-" + Constants_1.PACKAGE_VERSION, | ||
}; | ||
var optionsHeaders = tslib_1.__assign({}, options.headers); | ||
@@ -184,3 +177,2 @@ if (this.config.fetchOptions !== undefined) { | ||
Object.assign(options, this._options); | ||
Object.assign(optionsHeaders, defaultHeaders); | ||
if (options.headers !== undefined) { | ||
@@ -187,0 +179,0 @@ Object.assign(optionsHeaders, options.headers); |
@@ -24,2 +24,8 @@ /** | ||
* @returns A HTTPClient instance | ||
* | ||
* NOTE: These are the things that we need to remember while doing modifications in the below default pipeline. | ||
* * HTTPMessageHander should be the last one in the middleware pipeline, because this makes the actual network call of the request | ||
* * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag. | ||
* * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for | ||
* them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same. | ||
*/ | ||
@@ -26,0 +32,0 @@ static createWithAuthenticationProvider(authProvider: AuthenticationProvider): HTTPClient; |
@@ -19,2 +19,3 @@ "use strict"; | ||
var RetryHandler_1 = require("./middleware/RetryHandler"); | ||
var TelemetryHandler_1 = require("./middleware/TelemetryHandler"); | ||
/** | ||
@@ -41,2 +42,8 @@ * @private | ||
* @returns A HTTPClient instance | ||
* | ||
* NOTE: These are the things that we need to remember while doing modifications in the below default pipeline. | ||
* * HTTPMessageHander should be the last one in the middleware pipeline, because this makes the actual network call of the request | ||
* * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag. | ||
* * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for | ||
* them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same. | ||
*/ | ||
@@ -46,2 +53,3 @@ HTTPClientFactory.createWithAuthenticationProvider = function (authProvider) { | ||
var retryHandler = new RetryHandler_1.RetryHandler(new RetryHandlerOptions_1.RetryHandlerOptions()); | ||
var telemetryHandler = new TelemetryHandler_1.TelemetryHandler(); | ||
var httpMessageHandler = new HTTPMessageHandler_1.HTTPMessageHandler(); | ||
@@ -52,7 +60,8 @@ authenticationHandler.setNext(retryHandler); | ||
retryHandler.setNext(redirectHandler); | ||
redirectHandler.setNext(httpMessageHandler); | ||
redirectHandler.setNext(telemetryHandler); | ||
} | ||
else { | ||
retryHandler.setNext(httpMessageHandler); | ||
retryHandler.setNext(telemetryHandler); | ||
} | ||
telemetryHandler.setNext(httpMessageHandler); | ||
return HTTPClientFactory.createWithMiddleware(authenticationHandler); | ||
@@ -59,0 +68,0 @@ }; |
@@ -14,5 +14,9 @@ /** | ||
export * from "./middleware/RetryHandler"; | ||
export * from "./middleware/RedirectHandler"; | ||
export * from "./middleware/TelemetryHandler"; | ||
export * from "./middleware/options/AuthenticationHandlerOptions"; | ||
export * from "./middleware/options/IMiddlewareOptions"; | ||
export * from "./middleware/options/RetryHandlerOptions"; | ||
export * from "./middleware/options/RedirectHandlerOptions"; | ||
export * from "./middleware/options/TelemetryHandlerOptions"; | ||
export * from "./tasks/OneDriveLargeFileUploadTask"; | ||
@@ -19,0 +23,0 @@ export * from "./tasks/PageIterator"; |
@@ -16,4 +16,8 @@ "use strict"; | ||
tslib_1.__exportStar(require("./middleware/RetryHandler"), exports); | ||
tslib_1.__exportStar(require("./middleware/RedirectHandler"), exports); | ||
tslib_1.__exportStar(require("./middleware/TelemetryHandler"), exports); | ||
tslib_1.__exportStar(require("./middleware/options/AuthenticationHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("./middleware/options/RetryHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("./middleware/options/RedirectHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("./middleware/options/TelemetryHandlerOptions"), exports); | ||
tslib_1.__exportStar(require("./tasks/OneDriveLargeFileUploadTask"), exports); | ||
@@ -20,0 +24,0 @@ tslib_1.__exportStar(require("./tasks/PageIterator"), exports); |
@@ -13,2 +13,3 @@ "use strict"; | ||
var AuthenticationHandlerOptions_1 = require("./options/AuthenticationHandlerOptions"); | ||
var TelemetryHandlerOptions_1 = require("./options/TelemetryHandlerOptions"); | ||
/** | ||
@@ -61,2 +62,3 @@ * @class | ||
MiddlewareUtil_1.setRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey); | ||
TelemetryHandlerOptions_1.TelemetryHandlerOptions.updateFeatureUsageFlag(context, TelemetryHandlerOptions_1.FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED); | ||
return [4 /*yield*/, this.nextMiddleware.execute(context)]; | ||
@@ -63,0 +65,0 @@ case 2: return [2 /*return*/, _a.sent()]; |
@@ -25,13 +25,21 @@ /** | ||
* Creates an instance of MiddlewareControl | ||
* @param {MiddlewareOptions[]} middlewareOptions - The array of middlewareOptions | ||
* @param {MiddlewareOptions[]} [middlewareOptions = []] - The array of middlewareOptions | ||
* @returns The instance of MiddlewareControl | ||
*/ | ||
constructor(middlewareOptions: MiddlewareOptions[]); | ||
constructor(middlewareOptions?: MiddlewareOptions[]); | ||
/** | ||
* @public | ||
* To get the middleware option using the class name of the option | ||
* @param {string} name - The class name of the strongly types option class | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @returns The middleware option | ||
*/ | ||
getMiddlewareOptions(name: string): MiddlewareOptions; | ||
/** | ||
* @public | ||
* To set the middleware options using the class name of the option | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @param {MiddlewareOptions} option - The strongly typed middleware option | ||
* @returns nothing | ||
*/ | ||
setMiddlewareOptions(name: string, option: MiddlewareOptions): void; | ||
} |
@@ -18,6 +18,7 @@ "use strict"; | ||
* Creates an instance of MiddlewareControl | ||
* @param {MiddlewareOptions[]} middlewareOptions - The array of middlewareOptions | ||
* @param {MiddlewareOptions[]} [middlewareOptions = []] - The array of middlewareOptions | ||
* @returns The instance of MiddlewareControl | ||
*/ | ||
function MiddlewareControl(middlewareOptions) { | ||
if (middlewareOptions === void 0) { middlewareOptions = []; } | ||
this.middlewareOptions = new Map(); | ||
@@ -33,3 +34,3 @@ for (var _i = 0, middlewareOptions_1 = middlewareOptions; _i < middlewareOptions_1.length; _i++) { | ||
* To get the middleware option using the class name of the option | ||
* @param {string} name - The class name of the strongly types option class | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @returns The middleware option | ||
@@ -40,2 +41,12 @@ */ | ||
}; | ||
/** | ||
* @public | ||
* To set the middleware options using the class name of the option | ||
* @param {string} name - The class name of the strongly typed option class | ||
* @param {MiddlewareOptions} option - The strongly typed middleware option | ||
* @returns nothing | ||
*/ | ||
MiddlewareControl.prototype.setMiddlewareOptions = function (name, option) { | ||
this.middlewareOptions.set(name, option); | ||
}; | ||
return MiddlewareControl; | ||
@@ -42,0 +53,0 @@ }()); |
@@ -13,2 +13,8 @@ /** | ||
* @constant | ||
* To generate the UUID | ||
* @returns The UUID string | ||
*/ | ||
export declare const generateUUID: () => string; | ||
/** | ||
* @constant | ||
* To get the request header from the request | ||
@@ -15,0 +21,0 @@ * @param {RequestInfo} request - The request object or the url string |
@@ -13,2 +13,17 @@ "use strict"; | ||
* @constant | ||
* To generate the UUID | ||
* @returns The UUID string | ||
*/ | ||
exports.generateUUID = function () { | ||
var uuid = ""; | ||
for (var j = 0; j < 32; j++) { | ||
if (j === 8 || j === 12 || j === 16 || j === 20) { | ||
uuid += "-"; | ||
} | ||
uuid += Math.floor(Math.random() * 16).toString(16); | ||
} | ||
return uuid; | ||
}; | ||
/** | ||
* @constant | ||
* To get the request header from the request | ||
@@ -15,0 +30,0 @@ * @param {RequestInfo} request - The request object or the url string |
@@ -14,2 +14,3 @@ "use strict"; | ||
var RedirectHandlerOptions_1 = require("./options/RedirectHandlerOptions"); | ||
var TelemetryHandlerOptions_1 = require("./options/TelemetryHandlerOptions"); | ||
/** | ||
@@ -202,2 +203,3 @@ * @class | ||
context.options.redirect = RedirectHandler.MANUAL_REDIRECT; | ||
TelemetryHandlerOptions_1.TelemetryHandlerOptions.updateFeatureUsageFlag(context, TelemetryHandlerOptions_1.FeatureUsageFlag.REDIRECT_HANDLER_ENABLED); | ||
return [4 /*yield*/, this.executeWithRedirect(context, redirectCount, options)]; | ||
@@ -204,0 +206,0 @@ case 1: return [2 /*return*/, _a.sent()]; |
@@ -39,14 +39,2 @@ /** | ||
* @private | ||
* @static | ||
* A member holding the name of transfer encoding header | ||
*/ | ||
private static TRANSFER_ENCODING_HEADER; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the value of transfer encoding chunked | ||
*/ | ||
private static TRANSFER_ENCODING_CHUNKED; | ||
/** | ||
* @private | ||
* A member to hold next middleware in the middleware chain | ||
@@ -53,0 +41,0 @@ */ |
@@ -14,2 +14,3 @@ "use strict"; | ||
var RetryHandlerOptions_1 = require("./options/RetryHandlerOptions"); | ||
var TelemetryHandlerOptions_1 = require("./options/TelemetryHandlerOptions"); | ||
/** | ||
@@ -177,2 +178,3 @@ * @class | ||
options = this.getOptions(context); | ||
TelemetryHandlerOptions_1.TelemetryHandlerOptions.updateFeatureUsageFlag(context, TelemetryHandlerOptions_1.FeatureUsageFlag.RETRY_HANDLER_ENABLED); | ||
return [4 /*yield*/, this.executeWithRetry(context, retryAttempts, options)]; | ||
@@ -219,14 +221,2 @@ case 1: return [2 /*return*/, _a.sent()]; | ||
RetryHandler.RETRY_AFTER_HEADER = "Retry-After"; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the name of transfer encoding header | ||
*/ | ||
RetryHandler.TRANSFER_ENCODING_HEADER = "Transfer-Encoding"; | ||
/** | ||
* @private | ||
* @static | ||
* A member holding the value of transfer encoding chunked | ||
*/ | ||
RetryHandler.TRANSFER_ENCODING_CHUNKED = "chunked"; | ||
return RetryHandler; | ||
@@ -233,0 +223,0 @@ }()); |
{ | ||
"name": "@microsoft/microsoft-graph-client", | ||
"//": "NOTE: The version here should match exactly the exported const PACKAGE_VERSION in Constants.ts. If you change it here, also change it there.", | ||
"version": "1.6.0", | ||
"version": "1.7.0-Preview.1", | ||
"description": "Microsoft Graph Client Library", | ||
@@ -6,0 +6,0 @@ "main": "lib/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1030911
295
13714
4