Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions design/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

##### Current set up -

1. TypeScript Source Code
1. TypeScript Source Code
/ \
Transpiles into JavaScript
'lib' folder
Expand All @@ -40,7 +40,7 @@
1. `src/browser/index.js` does not export `RedirectHandler` and `RedirectHandlerOptions`. Redirection is handled by the browser.
2. `src/browser/index.js` exports `src/browser/ImplicitMsalProvider`.
3. `src/browser/ImplicitMsalProvider` does not import or require 'msal' dependency. While, `src/ImplicitMsalProvider` imports or requires 'msal' in the implementation.
4. My assumtion is that `src/browser/ImplicitMsalProvider` is implemented specifically for the rollup process and to skip the rollup external dependency while using `graph-js-sdk.js` in the browser.
4. My assumption is that `src/browser/ImplicitMsalProvider` is implemented specifically for the rollup process and to skip the rollup external dependency while using `graph-js-sdk.js` in the browser.

Note - Browser applications using the ES modules from the npm package of the JS SDK refer to the `module` entry point - `lib/es/src/index.js`(not the browser entry point). Example - Graph Explorer.

Expand Down
2 changes: 1 addition & 1 deletion docs/ChaosHandlerSamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

**A request Passes through to the Graph, if there is no entry for the request**

**Note - Always add ChaosHandler before HttpMessageHandler in the midllewareChain**
**Note - Always add ChaosHandler before HttpMessageHandler in the middlewareChain**

### Samples

Expand Down
2 changes: 1 addition & 1 deletion docs/CustomMiddlewareChain.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class MyHttpMessageHandler implements Middleware {

### Create Middleware Chain

Can use own middlewares and the ones shipped with the library [[Here](../src/middleware) are the set of Middlwares shipped with the library] to create the middleware chain. Create a chain out of these one has to link them in sequentially manner in own preferred order using `.setNext()` method.
Can use own middlewares and the ones shipped with the library [[Here](../src/middleware) are the set of Middlewares shipped with the library] to create the middleware chain. Create a chain out of these one has to link them in sequentially manner in own preferred order using `.setNext()` method.

Using AuthenticationHandler [one shipped with the library] and MyLoggingHandler, and MyHttpMessageHandler [custom ones] to create a middleware chain here.

Expand Down
2 changes: 1 addition & 1 deletion docs/tasks/LargeFileUploadTask.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface FileObject<T> {
}
```

The Microsoft Graph JavaScript Client SDK provides two implementions -
The Microsoft Graph JavaScript Client SDK provides two implementations -

1. StreamUpload - Supports Node.js stream upload

Expand Down
16 changes: 8 additions & 8 deletions samples/javascript/tasks/LargeFileUploadTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function upload() {
const file = fs.createReadStream(`./${fileName}`);

const stats = fs.statSync(`./${fileName}`);
const totalsize = stats.size;
const totalSize = stats.size;

const progress = (range, extraCallbackParam) => {
// Implement the progress callback here
Expand All @@ -31,7 +31,7 @@ async function upload() {

const uploadEventHandlers = {
progress,
extraCallbackParam: "Any paramater needed by the callback implementation",
extraCallbackParam: "Any parameter needed by the callback implementation",
};

const options = {
Expand All @@ -55,18 +55,18 @@ async function upload() {
// AttachmentItem: {
// attachmentType: 'file',
// name: "FILE_NAME",
// size: totalsize,
// size: totalSize,
// }
// }

const fileObject = new StreamUpload(file, fileName, totalsize);
const fileObject = new StreamUpload(file, fileName, totalSize);

//OR
// OR
// You can also use a FileUpload instance
//const file = fs.readFileSync();
//const fileObject = new FileUpload(file, fileName, totalsize);
// const file = fs.readFileSync();
// const fileObject = new FileUpload(file, fileName, totalSize);

//OR
// OR
// You can also create an object from a custom implementation of the FileObject interface
const task = new MicrosoftGraph.LargeFileUploadTask(client, fileObject, uploadSession, options);
const uploadResult = await task.upload();
Expand Down
2 changes: 1 addition & 1 deletion samples/javascript/tasks/OneDriveLargeFileUploadTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function upload() {

const uploadEventHandlers = {
progress,
extraCallbackParam: "any paramater needed by the callback implementation",
extraCallbackParam: "any parameter needed by the callback implementation",
};

const options = {
Expand Down
20 changes: 10 additions & 10 deletions samples/typescript/tasks/LargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

// First, create an instance of the Microsoft Graph JS SDK Client class

import { LargeFileUploadSession, LargeFileUploadTask, LargeFileUploadTaskOptions, Range, StreamUpload, UploadEventHandlers, UploadResult } from "@microsoft/microsoft-graph-client";
import * as fs from "fs";
import { client } from "../clientInitialization/ClientWithOptions";
/**
* OR
* import { client } from ("../clientInitialization/TokenCredentialAuthenticationProvider");
* OR
* require or import client created using an custom authentication provider
*/
import * as fs from "fs";
import { LargeFileUploadTaskOptions, LargeFileUploadSession, LargeFileUploadTask, StreamUpload, UploadEventHandlers, UploadResult, Range, FileUpload } from "@microsoft/microsoft-graph-client";

async function upload(): Promise<UploadResult> {
const file = fs.createReadStream("./test.pdf");

const stats = fs.statSync(`./test.pdf`);
const totalsize = stats.size;
const totalSize = stats.size;

const progress = (range?: Range, extraCallbackParam?: unknown) => {
// Implement the progress callback here
Expand All @@ -34,7 +34,7 @@ async function upload(): Promise<UploadResult> {

const uploadEventHandlers: UploadEventHandlers = {
progress,
extraCallbackParam: "any paramater needed by the callback implementation",
extraCallbackParam: "any parameter needed by the callback implementation",
};

const options: LargeFileUploadTaskOptions = {
Expand All @@ -58,18 +58,18 @@ async function upload(): Promise<UploadResult> {
// AttachmentItem: {
// attachmentType: 'file',
// name: "FILE_NAME",
// size: totalsize,
// size: totalSize,
// }
// }

const fileObject = new StreamUpload(file, "test.pdf", totalsize);
const fileObject = new StreamUpload(file, "test.pdf", totalSize);

//OR
// OR
// You can also use a FileUpload instance
//const file = fs.readFileSync();
//const fileObject = new FileUpload(file, 'test.pdf', totalsize);
// const file = fs.readFileSync();
// const fileObject = new FileUpload(file, 'test.pdf', totalSize);

//OR
// OR
// You can also create an object from a custom implementation of FileObject
const task = new LargeFileUploadTask(client, fileObject, uploadSession, options);
const uploadResult = await task.upload();
Expand Down
12 changes: 6 additions & 6 deletions samples/typescript/tasks/OneDriveLargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
// First, create an instance of the Microsoft Graph JS SDK Client class
/* eslint-disable simple-import-sort/imports*/

import { OneDriveLargeFileUploadOptions, OneDriveLargeFileUploadTask, Range, StreamUpload, UploadEventHandlers, UploadResult } from "@microsoft/microsoft-graph-client";
import * as fs from "fs";
import { Readable } from "stream";
import { client } from "../clientInitialization/ClientWithOptions";
/**
* OR
* import { client } from ("../clientInitialization/TokenCredentialAuthenticationProvider");
* OR
* require or import client created using an custom authentication provider
*/
import { OneDriveLargeFileUploadOptions, OneDriveLargeFileUploadTask, Range, StreamUpload, UploadEventHandlers, UploadResult } from "@microsoft/microsoft-graph-client";
import * as fs from "fs";
import { Readable } from "stream";

async function upload() {
const file = fs.createReadStream("./test.pdf");
const fileName = "FILENAME";
const stats = fs.statSync(`./test.pdf`);
const totalsize = stats.size;
const totalSize = stats.size;

const progress = (range?: Range, extraCallBackParam?: unknown) => {
console.log("uploading range: ", range);
Expand All @@ -33,7 +33,7 @@ async function upload() {

const uploadEventHandlers: UploadEventHandlers = {
progress,
extraCallbackParam: "any paramater needed by the callback implementation",
extraCallbackParam: "any parameter needed by the callback implementation",
};

const options: OneDriveLargeFileUploadOptions = {
Expand All @@ -43,7 +43,7 @@ async function upload() {
uploadEventHandlers,
};

const stream = new StreamUpload(file, "test.pdf", totalsize);
const stream = new StreamUpload(file, "test.pdf", totalSize);
const task = await OneDriveLargeFileUploadTask.createTaskWithFileObject<Readable>(client, stream, options);
const uploadResult: UploadResult = await task.upload();
return uploadResult;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphClientError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GraphClientError extends Error {
* @static
* @async
* To set the GraphClientError object
* @param {any} - The error returned encountered by the Graph JavaScript Client SDK while processing request
* @param {any} error - The error returned encountered by the Graph JavaScript Client SDK while processing request
* @returns GraphClientError object set to the error passed
*/
public static setGraphClientError(error: any): GraphClientError {
Expand Down
2 changes: 2 additions & 0 deletions src/GraphError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class GraphError extends Error {
* @constructor
* Creates an instance of GraphError
* @param {number} [statusCode = -1] - The status code of the error
* @param {string} [message] - The message of the error
* @param {Error} [baseError] - The base error
* @returns An instance of GraphError
*/
public constructor(statusCode = -1, message?: string, baseError?: Error) {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphRequestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const isValidEndpoint = (url: string, allowedHosts: Set<string> = GRAPH_URLS): b

/**
* Throws error if the string is not a valid host/hostname and contains other url parts.
* @param {string} url - The host to be verified
* @param {string} host - The host to be verified
*/
const isCustomHostValid = (host: string) => {
if (host.indexOf("/") !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/HTTPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class HTTPClient {
/**
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* and sets this.middleware property to the first middleware handler of the array
* The calling function should validate if middleware is not undefined or not empty
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
Expand Down
2 changes: 1 addition & 1 deletion src/HTTPClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class HTTPClientFactory {
* @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
* * HTTPMessageHandler 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.
Expand Down
6 changes: 3 additions & 3 deletions src/middleware/ChaosHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ChaosHandler implements Middleware {
/**
* Generates responseBody
* @private
* @param {ChaosHandlerOptions} options - The ChaosHandlerOptions object
* @param {ChaosHandlerOptions} chaosHandlerOptions - The ChaosHandlerOptions object
* @param {string} requestID - request id
* @param {string} requestDate - date of the request
* * @returns response body
Expand Down Expand Up @@ -119,7 +119,7 @@ export class ChaosHandler implements Middleware {
/**
* creates a response
* @private
* @param {ChaosHandlerOptions} ChaosHandlerOptions - The ChaosHandlerOptions object
* @param {ChaosHandlerOptions} chaosHandlerOptions - The ChaosHandlerOptions object
* @param {Context} context - Contains the context of the request
*/
private createResponse(chaosHandlerOptions: ChaosHandlerOptions, context: Context) {
Expand Down Expand Up @@ -177,7 +177,7 @@ export class ChaosHandler implements Middleware {
/**
* To fetch the status code from the map(if needed), then returns response by calling createResponse
* @private
* @param {ChaosHandlerOptions} ChaosHandlerOptions - The ChaosHandlerOptions object
* @param {ChaosHandlerOptions} chaosHandlerOptions - The ChaosHandlerOptions object
* @param {string} requestURL - the URL for the request
* @param {string} requestMethod - the API method for the request
*/
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/options/ChaosHandlerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ChaosHandlerOptions implements MiddlewareOptions {
* @public
* @constructor
* To create an instance of Testing Handler Options
* @param {ChaosStrategy} ChaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
* @param {ChaosStrategy} chaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
* @param {string} statusMessage - The Message to be returned in the response
* @param {number?} statusCode - The statusCode to be returned in the response
* @param {number?} chaosPercentage - The percentage of randomness/chaos in the handler
Expand Down