@microsoft/microsoft-graph-client
- Version 3.0.7
- Published
- 1.25 MB
- 2 dependencies
- MIT license
Install
npm i @microsoft/microsoft-graph-client
yarn add @microsoft/microsoft-graph-client
pnpm add @microsoft/microsoft-graph-client
Overview
Microsoft Graph Client Library
Index
Functions
Classes
Interfaces
Enums
Type Aliases
Functions
function getValidRangeSize
getValidRangeSize: (rangeSize?: number) => number;
Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session)
Parameter rangeSize
The rangeSize value.
Returns
The valid rangeSize
Classes
class AuthenticationHandler
class AuthenticationHandler implements Middleware {}
Middleware Class representing AuthenticationHandler
constructor
constructor(authenticationProvider: AuthenticationProvider);
Creates an instance of AuthenticationHandler
Parameter authenticationProvider
The authentication provider for the authentication handler
Modifiers
@public
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The context object of the request
Returns
A Promise that resolves to nothing
Modifiers
@public
method setNext
setNext: (next: Middleware) => void;
To set the next middleware in the chain
Parameter next
The middleware instance
Returns
Nothing
Modifiers
@public
class AuthenticationHandlerOptions
class AuthenticationHandlerOptions implements MiddlewareOptions {}
MiddlewareOptions Class representing AuthenticationHandlerOptions
constructor
constructor( authenticationProvider?: AuthenticationProvider, authenticationProviderOptions?: AuthenticationProviderOptions);
To create an instance of AuthenticationHandlerOptions
Parameter authenticationProvider
The authentication provider instance
Parameter authenticationProviderOptions
The authentication provider options instance
Returns
An instance of AuthenticationHandlerOptions
Modifiers
@public
property authenticationProvider
authenticationProvider: AuthenticationProvider;
A member holding an instance of an authentication provider
Modifiers
@public
property authenticationProviderOptions
authenticationProviderOptions: AuthenticationProviderOptions;
A member holding an instance of authentication provider options
Modifiers
@public
class BatchRequestContent
class BatchRequestContent {}
Class for handling BatchRequestContent
constructor
constructor(requests?: BatchRequestStep[]);
Constructs a BatchRequestContent instance
Parameter requests
Array of requests value
Returns
An instance of a BatchRequestContent
Modifiers
@public
property requests
requests: Map<string, BatchRequestStep>;
To keep track of requests, key will be id of the request and value will be the request json
Modifiers
@public
method addDependency
addDependency: (dependentId: string, dependencyId?: string) => void;
Adds a dependency for a given dependent request
Parameter dependentId
The id of the dependent request
Parameter dependencyId
The id of the dependency request, if not specified the preceding request will be considered as a dependency
Returns
Nothing
Modifiers
@public
method addRequest
addRequest: (request: BatchRequestStep) => string;
Adds a request to the batch request content
Parameter request
The request value
Returns
The id of the added request
Modifiers
@public
method getContent
getContent: () => Promise<BatchRequestBody>;
Serialize content from BatchRequestContent instance
Returns
The body content to make batch request
Modifiers
@public
method removeDependency
removeDependency: (dependentId: string, dependencyId?: string) => boolean;
Removes a dependency for a given dependent request id
Parameter dependentId
The id of the dependent request
Parameter dependencyId
The id of the dependency request, if not specified will remove all the dependencies of that request
Returns
The boolean indicating removed status
Modifiers
@public
method removeRequest
removeRequest: (requestId: string) => boolean;
Removes request from the batch payload and its dependencies from all dependents
Parameter requestId
The id of a request that needs to be removed
Returns
The boolean indicating removed status
Modifiers
@public
class BatchResponseContent
class BatchResponseContent {}
Class that handles BatchResponseContent
constructor
constructor(response: BatchResponseBody);
Creates the BatchResponseContent instance
Parameter response
The response body returned for batch request from server
Returns
An instance of a BatchResponseContent
Modifiers
@public
method getResponseById
getResponseById: (requestId: string) => Response;
To get the response of a request for a given request id
Parameter requestId
The request id value
Returns
The Response object instance for the particular request
Modifiers
@public
method getResponses
getResponses: () => Map<string, Response>;
To get all the responses of the batch request
Returns
The Map of id and Response objects
Modifiers
@public
method getResponsesIterator
getResponsesIterator: () => IterableIterator<[string, Response]>;
To get the iterator for the responses
Returns
The Iterable generator for the response objects
Modifiers
@public
method update
update: (response: BatchResponseBody) => void;
Updates the Batch response content instance with given responses.
Parameter response
The response json representing batch response message
Returns
Nothing
Modifiers
@public
class ChaosHandler
class ChaosHandler implements Middleware {}
Class representing ChaosHandler Class Middleware
constructor
constructor( options?: ChaosHandlerOptions, manualMap?: Map<string, Map<string, number>>);
To create an instance of Testing Handler
Parameter options
The testing handler options instance
Parameter manualMap
The Map passed by user containing url-statusCode info
Returns
An instance of Testing Handler
Modifiers
@public
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The context object of the request
Returns
A Promise that resolves to nothing
Modifiers
@public
method setNext
setNext: (next: Middleware) => void;
To set the next middleware in the chain
Parameter next
The middleware instance
Returns
Nothing
Modifiers
@public
class ChaosHandlerOptions
class ChaosHandlerOptions implements MiddlewareOptions {}
Class representing ChaosHandlerOptions Class MiddlewareOptions
constructor
constructor( chaosStrategy?: ChaosStrategy, statusMessage?: string, statusCode?: number, chaosPercentage?: number, responseBody?: any, headers?: Headers);
To create an instance of Testing Handler Options
Parameter chaosStrategy
Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
Parameter statusMessage
The Message to be returned in the response
Parameter statusCode
The statusCode to be returned in the response
Parameter chaosPercentage
The percentage of randomness/chaos in the handler
Parameter responseBody
The response body to be returned in the response
Returns
An instance of ChaosHandlerOptions
Modifiers
@public
property chaosPercentage
chaosPercentage: number;
The percentage of randomness/chaos in the handler
Setting the default value as 10%
Modifiers
@public
property chaosStrategy
chaosStrategy: ChaosStrategy;
Specifies the startegy used for the Testing Handler -> RANDOM/MANUAL
Modifiers
@public
property headers
headers: Headers;
The response headers to be returned in the response
Modifiers
@public
property responseBody
responseBody: any;
The response body to be returned in the response
Modifiers
@public
property statusCode
statusCode: number;
Status code to be returned in the response
Modifiers
@public
property statusMessage
statusMessage: string;
The Message to be returned in the response
Modifiers
@public
class Client
class Client {}
method api
api: (path: string) => GraphRequest;
Entry point to make requests
Parameter path
The path string value
Returns
The graph request instance
Modifiers
@public
method init
static init: (options: Options) => Client;
To create a client instance with options and initializes the default middleware chain
Parameter options
The options for client instance
Returns
The Client instance
Modifiers
@public
method initWithMiddleware
static initWithMiddleware: (clientOptions: ClientOptions) => Client;
To create a client instance with the Client Options
Parameter clientOptions
The options object for initializing the client
Returns
The Client instance
Modifiers
@public
class CustomAuthenticationProvider
class CustomAuthenticationProvider implements AuthenticationProvider {}
Class representing CustomAuthenticationProvider AuthenticationProvider
constructor
constructor(provider: AuthProvider);
Creates an instance of CustomAuthenticationProvider
Parameter provider
An authProvider function
Returns
An instance of CustomAuthenticationProvider
Modifiers
@public
method getAccessToken
getAccessToken: () => Promise<any>;
To get the access token
Returns
The promise that resolves to an access token
Modifiers
@public
class FileUpload
class FileUpload implements FileObject<SliceType> {}
Class used for creating LargeFileUploadTask fileobject. This class accepts files of type ArrayBuffer, Blob, Uint8Array.
constructor
constructor( content: ArrayBuffer | Blob | Uint8Array, name: string, size: number);
Parameter content
The file to be uploaded
Parameter name
The name of the file to be uploaded
Parameter size
The total size of the file to be uploaded
Returns
An instance of the FileUpload class
Modifiers
@public
property content
content: ArrayBuffer | Blob | Uint8Array;
property name
name: string;
property size
size: number;
method sliceFile
sliceFile: (range: Range) => ArrayBuffer | Blob | Uint8Array;
Slices the file content to the given range
Parameter range
The range value
Returns
The sliced file part
Modifiers
@public
class GraphClientError
class GraphClientError extends Error {}
Create GraphClientError object to handle client-side errors encountered within the JavaScript Client SDK. Whereas GraphError Class should be used to handle errors in the response from the Graph API.
constructor
constructor(message?: string);
Creates an instance of GraphClientError
Parameter message
? - Error message
Returns
An instance of GraphClientError
Modifiers
@public
property customError
customError?: any;
A custom error. This property should set be when the error is not of instanceOf Error/GraphClientError. Example = const client = MicrosoftGraph.Client.init({ defaultVersion: "v1.0", authProvider: (done) => { done({TokenError:"AccessToken cannot be null"}, "<ACCESS_TOKEN>"); });
Modifiers
@public
method setGraphClientError
static setGraphClientError: (error: any) => GraphClientError;
To set the GraphClientError object
Parameter error
The error returned encountered by the Graph JavaScript Client SDK while processing request
Returns
GraphClientError object set to the error passed
Modifiers
@public
class GraphError
class GraphError extends Error {}
Class for GraphError @NOTE: This is NOT what is returned from the Graph GraphError is created from parsing JSON errors returned from the graph Some fields are renamed ie, "request-id" => requestId so you can use dot notation
constructor
constructor(statusCode?: number, message?: string, baseError?: Error);
Creates an instance of GraphError
Parameter statusCode
The status code of the error
Parameter message
The message of the error
Parameter baseError
The base error
Returns
An instance of GraphError
Modifiers
@public
property body
body: any;
A member holding original error response by the graph service
Modifiers
@public
property code
code: string;
A member holding code i.e name of the error
Modifiers
@public
property date
date: Date;
A member holding processed date and time of the request
Modifiers
@public
property headers
headers?: Headers;
property requestId
requestId: string;
A member holding request-id i.e identifier of the request
Modifiers
@public
property statusCode
statusCode: number;
A member holding status code of the error
Modifiers
@public
class GraphRequest
class GraphRequest {}
A Class representing GraphRequest
constructor
constructor(httpClient: HTTPClient, config: ClientOptions, path: string);
Creates an instance of GraphRequest
Parameter httpClient
The HTTPClient instance
Parameter config
The options for making request
Parameter path
A path string
Modifiers
@public
method count
count: (isCount?: boolean) => GraphRequest;
To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
Parameter isCount
The count boolean
Returns
The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
Modifiers
@public
method create
create: (content: any, callback?: GraphRequestCallback) => Promise<any>;
Alias for Post request call
Parameter content
The content that needs to be sent with the request
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the post response
Modifiers
@public
method del
del: (callback?: GraphRequestCallback) => Promise<any>;
Alias for delete request call
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the delete response
Modifiers
@public
method delete
delete: (callback?: GraphRequestCallback) => Promise<any>;
Makes http request with DELETE method
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the delete response
Modifiers
@public
method expand
expand: (properties: string | string[]) => GraphRequest;
To add properties for expand OData Query param
Parameter properties
The Properties value
Returns
The same GraphRequest instance that is being called with, after adding the properties for $expand query
Modifiers
@public
method filter
filter: (filterStr: string) => GraphRequest;
To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
Parameter filterStr
The filter query string
Returns
The same GraphRequest instance that is being called with, after adding the $filter query
Modifiers
@public
method get
get: (callback?: GraphRequestCallback) => Promise<any>;
Makes a http request with GET method
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the get response
Modifiers
@public
method getStream
getStream: (callback?: GraphRequestCallback) => Promise<any>;
Makes a http request with GET method to read response as a stream.
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the getStream response
Modifiers
@public
method header
header: (headerKey: string, headerValue: string) => GraphRequest;
Sets the custom header for a request
Parameter headerKey
A header key
Parameter headerValue
A header value
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method headers
headers: (headers: KeyValuePairObjectStringNumber | HeadersInit) => GraphRequest;
Sets the custom headers for a request
Parameter headers
The request headers
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method middlewareOptions
middlewareOptions: (options: MiddlewareOptions[]) => GraphRequest;
Sets the middleware options for a request
Parameter options
The array of middleware options
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method option
option: (key: string, value: any) => GraphRequest;
Sets the option for making a request
Parameter key
The key value
Parameter value
The value
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method options
options: (options: { [key: string]: any }) => GraphRequest;
Sets the options for making a request
Parameter options
The options key value pair
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method orderby
orderby: (properties: string | string[]) => GraphRequest;
To add properties for orderby OData Query param
Parameter properties
The Properties value
Returns
The same GraphRequest instance that is being called with, after adding the properties for $orderby query
Modifiers
@public
method patch
patch: (content: any, callback?: GraphRequestCallback) => Promise<any>;
Makes http request with PATCH method
Parameter content
The content that needs to be sent with the request
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the patch response
Modifiers
@public
method post
post: (content: any, callback?: GraphRequestCallback) => Promise<any>;
Makes a http request with POST method
Parameter content
The content that needs to be sent with the request
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the post response
Modifiers
@public
method put
put: (content: any, callback?: GraphRequestCallback) => Promise<any>;
Makes http request with PUT method
Parameter content
The content that needs to be sent with the request
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the put response
Modifiers
@public
method putStream
putStream: (stream: any, callback?: GraphRequestCallback) => Promise<any>;
Makes a http request with GET method to read response as a stream.
Parameter stream
The stream instance
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the putStream response
Modifiers
@public
method query
query: ( queryDictionaryOrString: string | KeyValuePairObjectStringNumber) => GraphRequest;
Appends query string to the urlComponent
Parameter queryDictionaryOrString
The query value
Returns
The same GraphRequest instance that is being called with, after appending the query string to the url component
Modifiers
@public
method responseType
responseType: (responseType: ResponseType) => GraphRequest;
Sets the api endpoint version for a request
Parameter responseType
The response type value
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
method search
search: (searchStr: string) => GraphRequest;
To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
Parameter searchStr
The search criterion string
Returns
The same GraphRequest instance that is being called with, after adding the $search query criteria
Modifiers
@public
method select
select: (properties: string | string[]) => GraphRequest;
To add properties for select OData Query param
Parameter properties
The Properties value
Returns
The same GraphRequest instance that is being called with, after adding the properties for $select query
Modifiers
@public
method skip
skip: (n: number) => GraphRequest;
To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
Parameter n
The number value
Returns
The same GraphRequest instance that is being called with, after adding the number for the $skip query
Modifiers
@public
method skipToken
skipToken: (token: string) => GraphRequest;
To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
Parameter token
The token value
Returns
The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
Modifiers
@public
method top
top: (n: number) => GraphRequest;
To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
Parameter n
The number value
Returns
The same GraphRequest instance that is being called with, after adding the number for $top query
Modifiers
@public
method update
update: (content: any, callback?: GraphRequestCallback) => Promise<any>;
Alias for PATCH request
Parameter content
The content that needs to be sent with the request
Parameter callback
The callback function to be called in response with async call
Returns
A promise that resolves to the patch response
Modifiers
@public
method version
version: (version: string) => GraphRequest;
Sets the api endpoint version for a request
Parameter version
The version value
Returns
The same GraphRequest instance that is being called with
Modifiers
@public
class HTTPMessageHandler
class HTTPMessageHandler implements Middleware {}
Middleware Class for HTTPMessageHandler
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The request context object
Returns
A promise that resolves to nothing
Modifiers
@public
class LargeFileUploadTask
class LargeFileUploadTask<T> {}
Class representing LargeFileUploadTask
constructor
constructor( client: Client, file: FileObject<T>, uploadSession: LargeFileUploadSession, options?: LargeFileUploadTaskOptions);
Constructs a LargeFileUploadTask
Parameter client
The GraphClient instance
Parameter file
The FileObject holding details of a file that needs to be uploaded
Parameter uploadSession
The upload session to which the upload has to be done
Parameter options
The upload task options
Returns
An instance of LargeFileUploadTask
Modifiers
@public
property client
protected client: Client;
The GraphClient instance
property file
protected file: FileObject<T>;
The object holding file details
property nextRange
protected nextRange: Range;
The next range needs to be uploaded
property options
protected options: LargeFileUploadTaskOptions;
The object holding options for the task
property uploadSession
protected uploadSession: LargeFileUploadSession;
The object for upload session
method cancel
cancel: () => Promise<unknown>;
Deletes upload session in the server
Returns
The promise resolves to cancelled response
Modifiers
@public
method createUploadSession
static createUploadSession: ( client: Client, requestUrl: string, payload: any, headers?: KeyValuePairObjectStringNumber) => Promise<LargeFileUploadSession>;
Makes request to the server to create an upload session
Parameter client
The GraphClient instance
Parameter requestUrl
The URL to create the upload session
Parameter payload
The payload that needs to be sent
Parameter headers
The headers that needs to be sent
Returns
The promise that resolves to LargeFileUploadSession
Modifiers
@public
method getNextRange
getNextRange: () => Range;
Gets next range that needs to be uploaded
Returns
The range instance
Modifiers
@public
method getStatus
getStatus: () => Promise<unknown>;
Gets status for the upload session
Returns
The promise resolves to the status enquiry response
Modifiers
@public
method getUploadSession
getUploadSession: () => LargeFileUploadSession;
Get the upload session information
Returns
The large file upload session
Modifiers
@public
method resume
resume: () => Promise<unknown>;
Resumes upload session and continue uploading the file from the last sent range
Returns
The promise resolves to the uploaded response
Modifiers
@public
method sliceFile
sliceFile: (range: Range) => ArrayBuffer | Blob;
Parameter range
The range value
Returns
The sliced ArrayBuffer or Blob
Modifiers
@public
Deprecated
This function has been moved into FileObject interface.
Slices the file content to the given range
method upload
upload: () => Promise<UploadResult>;
Uploads file to the server in a sequential order by slicing the file
Returns
The promise resolves to uploaded response
Modifiers
@public
method uploadSlice
uploadSlice: ( fileSlice: ArrayBuffer | Blob | File, range: Range, totalSize: number) => Promise<unknown>;
Uploads given slice to the server
Parameter fileSlice
The file slice
Parameter range
The range value
Parameter totalSize
The total size of a complete file
Returns
The response body of the upload slice result
Modifiers
@public
method uploadSliceGetRawResponse
uploadSliceGetRawResponse: ( fileSlice: unknown, range: Range, totalSize: number) => Promise<Response>;
Uploads given slice to the server
Parameter fileSlice
The file slice
Parameter range
The range value
Parameter totalSize
The total size of a complete file
Returns
The raw response of the upload slice result
Modifiers
@public
class MiddlewareFactory
class MiddlewareFactory {}
Class containing function(s) related to the middleware pipelines.
method getDefaultMiddlewareChain
static getDefaultMiddlewareChain: ( authProvider: AuthenticationProvider) => Middleware[];
Returns the default middleware chain an array with the middleware handlers
Parameter authProvider
The authentication provider instance
Returns
an array of the middleware handlers of the default middleware chain
Modifiers
@public
class OneDriveLargeFileUploadTask
class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {}
Class representing OneDriveLargeFileUploadTask
constructor
constructor( client: Client, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions);
Constructs a OneDriveLargeFileUploadTask
Parameter client
The GraphClient instance
Parameter file
The FileObject holding details of a file that needs to be uploaded
Parameter uploadSession
The upload session to which the upload has to be done
Parameter options
The upload task options
Returns
An instance of OneDriveLargeFileUploadTask
Modifiers
@public
method commit
commit: (requestUrl: string, conflictBehavior?: string) => Promise<unknown>;
Commits upload session to end uploading
Parameter requestUrl
The URL to commit the upload session
Parameter conflictBehavior
Conflict behaviour option. Default is 'rename'
Returns
The promise resolves to committed response
Modifiers
@public
method create
static create: ( client: Client, file: Blob | Uint8Array | File, options: OneDriveLargeFileUploadOptions) => Promise<OneDriveLargeFileUploadTask<Blob | ArrayBuffer | Uint8Array>>;
Creates a OneDriveLargeFileUploadTask
Parameter client
The GraphClient instance
Parameter file
File represented as Blob, Uint8Array or File
Parameter options
The options for upload task
Returns
The promise that will be resolves to OneDriveLargeFileUploadTask instance
Modifiers
@public
method createTaskWithFileObject
static createTaskWithFileObject: <T>( client: Client, fileObject: FileObject<T>, options: OneDriveLargeFileUploadOptions) => Promise<OneDriveLargeFileUploadTask<T>>;
Creates a OneDriveLargeFileUploadTask
Parameter client
The GraphClient instance
Parameter fileObject
FileObject instance
Parameter options
The options for upload task
Returns
The promise that will be resolves to OneDriveLargeFileUploadTask instance
Modifiers
@public
method createUploadSession
static createUploadSession: ( client: Client, requestUrl: string, payloadOptions: OneDriveFileUploadSessionPayLoad) => Promise<LargeFileUploadSession>;
Makes request to the server to create an upload session
Parameter client
The GraphClient instance
Parameter requestUrl
The URL to create the upload session
Parameter payloadOptions
The payload option. Default conflictBehavior is 'rename'
Returns
The promise that resolves to LargeFileUploadSession
Modifiers
@public
class PageIterator
class PageIterator {}
Class for PageIterator
constructor
constructor( client: Client, pageCollection: PageCollection, callback: PageIteratorCallback, requestOptions?: GraphRequestOptions);
Creates new instance for PageIterator
Parameter client
The graph client instance
Parameter pageCollection
The page collection object
Parameter callBack
The callback function
Parameter requestOptions
The request options
Returns
An instance of a PageIterator
Modifiers
@public
method getDeltaLink
getDeltaLink: () => string | undefined;
Getter to get the deltaLink in the current response
Returns
A deltaLink which is being used to make delta requests in future
Modifiers
@public
method isComplete
isComplete: () => boolean;
To get the completeness status of the iterator
Returns
Boolean indicating the completeness
Modifiers
@public
method iterate
iterate: () => Promise<any>;
Iterates over the collection and kicks callback for each item on iteration. Fetches next set of data through nextLink and iterates over again This happens until the nextLink is drained out or the user responds with a red flag to continue from callback
Returns
A Promise that resolves to nothing on completion and throws error incase of any discrepancy.
Modifiers
@public
method resume
resume: () => Promise<any>;
To resume the iteration Note: This internally calls the iterate method, It's just for more readability.
Returns
A Promise that resolves to nothing on completion and throws error incase of any discrepancy
Modifiers
@public
class Range
class Range {}
Class representing Range
constructor
constructor(minVal?: number, maxVal?: number);
Creates a range for given min and max values
Parameter minVal
The minimum value.
Parameter maxVal
The maximum value.
Returns
An instance of a Range
Modifiers
@public
property maxValue
maxValue: number;
The maximum value of the range
Modifiers
@public
property minValue
minValue: number;
The minimum value of the range
Modifiers
@public
class RedirectHandler
class RedirectHandler implements Middleware {}
Class Middleware Class representing RedirectHandler
constructor
constructor(options?: RedirectHandlerOptions);
To create an instance of RedirectHandler
Parameter options
The redirect handler options instance
Returns
An instance of RedirectHandler
Modifiers
@public
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The context object of the request
Returns
A Promise that resolves to nothing
Modifiers
@public
method setNext
setNext: (next: Middleware) => void;
To set the next middleware in the chain
Parameter next
The middleware instance
Returns
Nothing
Modifiers
@public
class RedirectHandlerOptions
class RedirectHandlerOptions implements MiddlewareOptions {}
MiddlewareOptions A class representing RedirectHandlerOptions
constructor
constructor(maxRedirects?: number, shouldRedirect?: ShouldRedirect);
To create an instance of RedirectHandlerOptions
Parameter maxRedirects
The max redirects value
Parameter shouldRedirect
The should redirect callback
Returns
An instance of RedirectHandlerOptions
Modifiers
@public
property maxRedirects
maxRedirects: number;
A member holding max redirects value
Modifiers
@public
property shouldRedirect
shouldRedirect: ShouldRedirect;
A member holding shouldRedirect callback
Modifiers
@public
class RetryHandler
class RetryHandler implements Middleware {}
Middleware Class for RetryHandler
constructor
constructor(options?: RetryHandlerOptions);
To create an instance of RetryHandler
Parameter options
The retry handler options value
Returns
An instance of RetryHandler
Modifiers
@public
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The context object of the request
Returns
A Promise that resolves to nothing
Modifiers
@public
method setNext
setNext: (next: Middleware) => void;
To set the next middleware in the chain
Parameter next
The middleware instance
Returns
Nothing
Modifiers
@public
class RetryHandlerOptions
class RetryHandlerOptions implements MiddlewareOptions {}
MiddlewareOptions Class for RetryHandlerOptions
constructor
constructor(delay?: number, maxRetries?: number, shouldRetry?: ShouldRetry);
To create an instance of RetryHandlerOptions
Parameter delay
The delay value in seconds
Parameter maxRetries
The maxRetries value
Parameter shouldRetry
The shouldRetry callback function
Returns
An instance of RetryHandlerOptions
Modifiers
@public
property delay
delay: number;
A member holding delay value in seconds
Modifiers
@public
property maxRetries
maxRetries: number;
A member holding maxRetries value
Modifiers
@public
property shouldRetry
shouldRetry: ShouldRetry;
A member holding shouldRetry callback
Modifiers
@public
method getMaxDelay
getMaxDelay: () => number;
To get the maximum delay
Returns
A maximum delay
Modifiers
@public
class StreamUpload
class StreamUpload implements FileObject<NodeStream> {}
FileObject class for Readable Stream upload
constructor
constructor(content: NodeStream, name: string, size: number);
property content
content: NodeStream;
property name
name: string;
property size
size: number;
method sliceFile
sliceFile: (range: Range) => Promise<SliceType>;
Slices the file content to the given range
Parameter range
The range value
Returns
The sliced file part
Modifiers
@public
class TelemetryHandler
class TelemetryHandler implements Middleware {}
Middleware Class for TelemetryHandler
method execute
execute: (context: Context) => Promise<void>;
To execute the current middleware
Parameter context
The context object of the request
Returns
A Promise that resolves to nothing
Modifiers
@public
method setNext
setNext: (next: Middleware) => void;
To set the next middleware in the chain
Parameter next
The middleware instance
Returns
Nothing
Modifiers
@public
class TelemetryHandlerOptions
class TelemetryHandlerOptions implements MiddlewareOptions {}
MiddlewareOptions Class for TelemetryHandlerOptions
method getFeatureUsage
getFeatureUsage: () => string;
To get the feature usage
Returns
A feature usage flag as hexadecimal string
Modifiers
@public
method updateFeatureUsageFlag
static updateFeatureUsageFlag: ( context: Context, flag: FeatureUsageFlag) => void;
To update the feature usage in the context object
Parameter context
The request context object containing middleware options
Parameter flag
The flag value
Returns
nothing
Modifiers
@public
class UploadResult
class UploadResult {}
Class representing a successful file upload result
constructor
constructor(responseBody: {}, location: string);
Parameter responsebody
The response body from the completed upload response
Parameter location
The location value from the headers from the completed upload response
Modifiers
@public
property location
location: string;
Get of the location value. Location value is looked up in the response header
Modifiers
@public
property responseBody
responseBody: {};
Get The response body from the completed upload response
Modifiers
@public
method CreateUploadResult
static CreateUploadResult: ( responseBody?: unknown, responseHeaders?: Headers) => UploadResult;
Parameter responseBody
The response body from the completed upload response
Parameter responseHeaders
The headers from the completed upload response
Modifiers
@public
Interfaces
interface AuthenticationProvider
interface AuthenticationProvider {}
A signature representing Authentication provider {Function} getAccessToken - The function to get the access token from the authentication provider
property getAccessToken
getAccessToken: ( authenticationProviderOptions?: AuthenticationProviderOptions) => Promise<string>;
To get access token from the authentication provider
Parameter authenticationProviderOptions
The authentication provider options instance
Returns
A promise that resolves to an access token
interface AuthenticationProviderOptions
interface AuthenticationProviderOptions {}
A signature represents the Authentication provider options {string[]} [scopes] - The array of scopes
property scopes
scopes?: string[];
interface BatchRequestBody
interface BatchRequestBody {}
Signature representing batch request body {BatchRequestData[]} requests - Array of request data, a json representation of requests for batch
property requests
requests: BatchRequestData[];
interface BatchRequestData
interface BatchRequestData extends RequestData {}
Signature representing batch request data {string} id - Unique identity for the request, Should not be an empty string {string[]} [dependsOn] - Array of dependencies
interface BatchRequestStep
interface BatchRequestStep {}
Signature representing BatchRequestStep data {string} id - Unique identity for the request, Should not be an empty string {string[]} [dependsOn] - Array of dependencies {Request} request - The Request object
interface BatchResponseBody
interface BatchResponseBody {}
Signature representing Batch response body {KeyValuePairObject[]} responses - An array of key value pair representing response object for every request {string} [@odata.nextLink] - The nextLink value to get next set of responses in case of asynchronous batch requests
property "@odata.nextLink"
'@odata.nextLink'?: string;
property responses
responses: KeyValuePairObject[];
interface ClientOptions
interface ClientOptions {}
Options for initializing the Graph Client {Function} [authProvider] - The authentication provider instance {string} [baseUrl] - Base url that needs to be appended to every request {boolean} [debugLogging] - The boolean to enable/disable debug logging {string} [defaultVersion] - The default version that needs to be used while making graph api request {FetchOptions} [fetchOptions] - The options for fetch request {Middleware| Middleware[]} [middleware] - The first middleware of the middleware chain or an array of the Middleware handlers {Set}[customHosts] - A set of custom host names. Should contain hostnames only.
property authProvider
authProvider?: AuthenticationProvider;
property baseUrl
baseUrl?: string;
property customHosts
customHosts?: Set<string>;
Example - If URL is "https://test_host/v1.0", then set property "customHosts" as "customHosts: Set(["test_host"])"
property debugLogging
debugLogging?: boolean;
property defaultVersion
defaultVersion?: string;
property fetchOptions
fetchOptions?: FetchOptions;
property middleware
middleware?: Middleware | Middleware[];
interface Context
interface Context {}
{RequestInfo} request - The request url string or the Request instance {FetchOptions} [options] - The options for the request {Response} [response] - The response content {MiddlewareControl} [middlewareControl] - The options for the middleware chain {Set}[customHosts] - A set of custom host names. Should contain hostnames only.
property customHosts
customHosts?: Set<string>;
Example - If URL is "https://test_host", then set property "customHosts" as "customHosts: Set(["test_host"])"
property middlewareControl
middlewareControl?: MiddlewareControl;
property options
options?: FetchOptions;
property request
request: RequestInfo;
property response
response?: Response;
interface FetchOptions
interface FetchOptions extends RequestInit, NodeFetchInit {}
Signature to define the fetch api options which includes both fetch standard options and also the extended node fetch options RequestInit
See Also
https://fetch.spec.whatwg.org/#requestinit NodeFetchInit
interface FileObject
interface FileObject<T> {}
Signature to define the properties and content of the file in upload task {ArrayBuffer | File} content - The actual file content {string} name - Specifies the file name with extension {number} size - Specifies size of the file
interface GraphRequestOptions
interface GraphRequestOptions {}
Signature to define the request options to be sent during request. The values of the GraphRequestOptions properties are passed to the Graph Request object. {HeadersInit} headers - the header options for the request {MiddlewareOptions[]} middlewareoptions - The middleware options for the request {FetchOptions} options - The fetch options for the request
property headers
headers?: HeadersInit;
property middlewareOptions
middlewareOptions?: MiddlewareOptions[];
property options
options?: FetchOptions;
interface LargeFileUploadSession
interface LargeFileUploadSession {}
Signature to represent upload session resulting from the session creation in the server {string} url - The URL to which the file upload is made {Date} expiry - The expiration of the time of the upload session
interface LargeFileUploadTaskOptions
interface LargeFileUploadTaskOptions {}
Signature to define options for upload task {number} [rangeSize = LargeFileUploadTask.DEFAULT_FILE_SIZE] - Specifies the range chunk size {UploadEventHandlers} uploadEventHandlers - UploadEventHandlers attached to an upload task
property rangeSize
rangeSize?: number;
property uploadEventHandlers
uploadEventHandlers?: UploadEventHandlers;
interface Middleware
interface Middleware {}
{Function} execute - The method to execute the middleware {Function} [setNext] - A method to set the next middleware in the chain
interface MiddlewareOptions
interface MiddlewareOptions {}
Signature representing the middleware options
interface NodeFetchInit
interface NodeFetchInit {}
https://github.com/bitinn/node-fetch/#options Signature to define the fetch request options for node environment {number} [follow] - node-fetch option: maximum redirect count. 0 to not follow redirect {number} [compress] - node-fetch option: support gzip/deflate content encoding. false to disable {number} [size] - node-fetch option: maximum response body size in bytes. 0 to disable {any} [agent] - node-fetch option: HTTP(S).Agent instance, allows custom proxy, certificate, lookup, family etc. {number} [highWaterMark] - node-fetch option: maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. {boolean} [insecureHTTPParser] - node-fetch option: use an insecure HTTP parser that accepts invalid HTTP headers when
true
.
property agent
agent?: any;
property compress
compress?: boolean;
property follow
follow?: number;
property highWaterMark
highWaterMark?: number;
property insecureHTTPParser
insecureHTTPParser?: boolean;
property size
size?: number;
interface OneDriveLargeFileUploadOptions
interface OneDriveLargeFileUploadOptions {}
Signature to define options when creating an upload task {string} fileName - Specifies the name of a file to be uploaded (with extension) {string} [fileDescription] - Specifies the description of the file to be uploaded {string} [path] - The path to which the file needs to be uploaded {number} [rangeSize] - Specifies the range chunk size {string} [conflictBehavior] - Conflict behaviour option {UploadEventHandlers} [uploadEventHandlers] - UploadEventHandlers attached to an upload task
property conflictBehavior
conflictBehavior?: string;
property fileDescription
fileDescription?: string;
property fileName
fileName: string;
property path
path?: string;
property rangeSize
rangeSize?: number;
property uploadEventHandlers
uploadEventHandlers?: UploadEventHandlers;
property uploadSessionURL
uploadSessionURL?: string;
interface Options
interface Options {}
Options for initializing the Graph Client {AuthProvider} authProvider - The function to get the authentication token {string} [baseUrl] - Base url that needs to be appended to every request {boolean} [debugLogging] - The boolean to enable/disable debug logging {string} [defaultVersion] - The default version that needs to be used while making graph api request {FetchOptions} [fetchOptions] - The options for fetch request {Set}[customHosts] - A set of custom host names. Should contain hostnames only.
property authProvider
authProvider: AuthProvider;
property baseUrl
baseUrl?: string;
property customHosts
customHosts?: Set<string>;
Example - If URL is "https://test_host/v1.0", then set property "customHosts" as "customHosts: Set(["test_host"])"
property debugLogging
debugLogging?: boolean;
property defaultVersion
defaultVersion?: string;
property fetchOptions
fetchOptions?: FetchOptions;
interface PageCollection
interface PageCollection {}
Signature representing PageCollection {any[]} value - The collection value {string} [@odata.nextLink] - The nextLink value {string} [@odata.deltaLink] - The deltaLink value {any} Additional - Any number of additional properties (This is to accept the any additional data returned by in the response to the nextLink request)
property "@odata.deltaLink"
'@odata.deltaLink'?: string;
property "@odata.nextLink"
'@odata.nextLink'?: string;
property value
value: any[];
index signature
[Key: string]: any;
interface RequestData
interface RequestData extends RequestInit {}
Signature representing single request in a Batching RequestInit
See Also
https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L1337 and https://fetch.spec.whatwg.org/#requestinit
{string} url - The url value of the request
property url
url: string;
interface UploadEventHandlers
interface UploadEventHandlers {}
Interface enabling progress handling with callbacks.
property extraCallbackParam
extraCallbackParam?: unknown;
Parameters that are passed into the progress, completed, failure callback options.
property progress
progress?: (range?: Range, extraCallbackParam?: unknown) => void;
Callback function called on each slice upload during the LargeFileUploadTask.upload() process
interface URLComponents
interface URLComponents {}
Signature to define URL components http://graph.microsoft.com/VERSION/PATH?QUERYSTRING&OTHER_QUERY_PARAMS
{string} host - The host to which the request needs to be made {string} version - Version of the graph endpoint {string} [path] - The path of the resource request {KeyValuePairObjectStringNumber} oDataQueryParams - The oData Query Params {KeyValuePairObjectStringNumber} otherURLQueryParams - The other query params for a request {string[]} otherURLQueryOptions - The non key-value query parameters. Example- '/me?$whatif'
property host
host: string;
property oDataQueryParams
oDataQueryParams: KeyValuePairObjectStringNumber;
property otherURLQueryOptions
otherURLQueryOptions?: string[];
property otherURLQueryParams
otherURLQueryParams: KeyValuePairObjectStringNumber;
property path
path?: string;
property version
version: string;
Enums
enum ChaosStrategy
enum ChaosStrategy { MANUAL = 0, RANDOM = 1,}
Strategy used for Testing Handler
enum FeatureUsageFlag
enum FeatureUsageFlag { NONE = 0, REDIRECT_HANDLER_ENABLED = 1, RETRY_HANDLER_ENABLED = 2, AUTHENTICATION_HANDLER_ENABLED = 4,}
{number} NONE - The hexadecimal flag value for nothing enabled {number} REDIRECT_HANDLER_ENABLED - The hexadecimal flag value for redirect handler enabled {number} RETRY_HANDLER_ENABLED - The hexadecimal flag value for retry handler enabled {number} AUTHENTICATION_HANDLER_ENABLED - The hexadecimal flag value for the authentication handler enabled
member AUTHENTICATION_HANDLER_ENABLED
AUTHENTICATION_HANDLER_ENABLED = 4
member NONE
NONE = 0
member REDIRECT_HANDLER_ENABLED
REDIRECT_HANDLER_ENABLED = 1
member RETRY_HANDLER_ENABLED
RETRY_HANDLER_ENABLED = 2
enum ResponseType
enum ResponseType { ARRAYBUFFER = 'arraybuffer', BLOB = 'blob', DOCUMENT = 'document', JSON = 'json', RAW = 'raw', STREAM = 'stream', TEXT = 'text',}
Enum for ResponseType values {string} ARRAYBUFFER - To download response content as an [ArrayBuffer]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer {string} BLOB - To download content as a [binary/blob] https://developer.mozilla.org/en-US/docs/Web/API/Blob {string} DOCUMENT - This downloads content as a document or stream {string} JSON - To download response content as a json {string} STREAM - To download response as a [stream]https://nodejs.org/api/stream.html {string} TEXT - For downloading response as a text
Type Aliases
type AuthProvider
type AuthProvider = (done: AuthProviderCallback) => void;
Signature that holds authProvider - The anonymous callback function which takes a single param
type AuthProviderCallback
type AuthProviderCallback = (error: any, accessToken: string | null) => void;
Signature that defines callback for an authentication provider - The anonymous callback function which takes two params
type GraphRequestCallback
type GraphRequestCallback = ( error: GraphError, response: any, rawResponse?: any) => void;
Signature to define the GraphRequest callback - The anonymous callback function
type PageIteratorCallback
type PageIteratorCallback = (data: any) => boolean;
Signature representing callback for page iterator {Function} callback - The callback function which should return boolean to continue the continue/stop the iteration.
type ShouldRedirect
type ShouldRedirect = (response: Response) => boolean;
A type declaration for shouldRetry callback
type ShouldRetry
type ShouldRetry = ( delay: number, attempt: number, request: RequestInfo, options: FetchOptions | undefined, response: Response) => boolean;
A type declaration for shouldRetry callback
type SliceType
type SliceType = ArrayBuffer | Blob | Uint8Array;
Representing the return type of the sliceFile function that is type of the slice of a given range.
Package Files (42)
- lib/src/Client.d.ts
- lib/src/CustomAuthenticationProvider.d.ts
- lib/src/GraphClientError.d.ts
- lib/src/GraphError.d.ts
- lib/src/GraphRequest.d.ts
- lib/src/IAuthProvider.d.ts
- lib/src/IAuthProviderCallback.d.ts
- lib/src/IAuthenticationProvider.d.ts
- lib/src/IAuthenticationProviderOptions.d.ts
- lib/src/IClientOptions.d.ts
- lib/src/IContext.d.ts
- lib/src/IFetchOptions.d.ts
- lib/src/IGraphRequestCallback.d.ts
- lib/src/IOptions.d.ts
- lib/src/ResponseType.d.ts
- lib/src/content/BatchRequestContent.d.ts
- lib/src/content/BatchResponseContent.d.ts
- lib/src/index.d.ts
- lib/src/middleware/AuthenticationHandler.d.ts
- lib/src/middleware/ChaosHandler.d.ts
- lib/src/middleware/HTTPMessageHandler.d.ts
- lib/src/middleware/IMiddleware.d.ts
- lib/src/middleware/MiddlewareFactory.d.ts
- lib/src/middleware/RedirectHandler.d.ts
- lib/src/middleware/RetryHandler.d.ts
- lib/src/middleware/TelemetryHandler.d.ts
- lib/src/middleware/options/AuthenticationHandlerOptions.d.ts
- lib/src/middleware/options/ChaosHandlerOptions.d.ts
- lib/src/middleware/options/ChaosStrategy.d.ts
- lib/src/middleware/options/IMiddlewareOptions.d.ts
- lib/src/middleware/options/RedirectHandlerOptions.d.ts
- lib/src/middleware/options/RetryHandlerOptions.d.ts
- lib/src/middleware/options/TelemetryHandlerOptions.d.ts
- lib/src/tasks/FileUploadTask/FileObjectClasses/FileUpload.d.ts
- lib/src/tasks/FileUploadTask/FileObjectClasses/StreamUpload.d.ts
- lib/src/tasks/FileUploadTask/Interfaces/IUploadEventHandlers.d.ts
- lib/src/tasks/FileUploadTask/Range.d.ts
- lib/src/tasks/FileUploadTask/UploadResult.d.ts
- lib/src/tasks/LargeFileUploadTask.d.ts
- lib/src/tasks/OneDriveLargeFileUploadTask.d.ts
- lib/src/tasks/OneDriveLargeFileUploadTaskUtil.d.ts
- lib/src/tasks/PageIterator.d.ts
Dependencies (2)
Dev Dependencies (44)
- @azure/identity
- @azure/msal-browser
- @babel/core
- @babel/plugin-transform-runtime
- @babel/preset-env
- @istanbuljs/nyc-config-typescript
- @microsoft/microsoft-graph-types
- @rollup/plugin-babel
- @rollup/plugin-commonjs
- @rollup/plugin-node-resolve
- @rollup/plugin-terser
- @types/chai
- @types/mocha
- @types/node
- @types/sinon
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- chai
- eslint
- eslint-config-prettier
- eslint-plugin-prettier
- eslint-plugin-simple-import-sort
- form-data
- gulp
- husky
- isomorphic-fetch
- karma
- karma-chai
- karma-chrome-launcher
- karma-firefox-launcher
- karma-mocha
- karma-typescript
- lint-staged
- mocha
- mocha-junit-reporter
- nyc
- prettier
- rollup
- sinon
- source-map-support
- stream-browserify
- ts-node
- typescript
- uglify-es
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@microsoft/microsoft-graph-client
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@microsoft/microsoft-graph-client)
- HTML<a href="https://www.jsdocs.io/package/@microsoft/microsoft-graph-client"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 8340 ms. - Missing or incorrect documentation? Open an issue for this package.