Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
f48ed18
updated broken link in README
krototype Aug 16, 2019
8178222
Merge pull request #218 from microsoftgraph/abhsriva/updateREADME
krototype Aug 22, 2019
2ec9a2f
Merge branch 'master' into dev
muthu-rathinam Aug 27, 2019
32daeb8
Post request with empty body, now working fine.
krototype Sep 16, 2019
eed1515
Merge branch 'dev' into abhsriva/emptyPostRequest
krototype Sep 16, 2019
6850658
updated the tests for this case
krototype Sep 16, 2019
f7c333b
Merge branch 'abhsriva/emptyPostRequest' of https://github.com/micros…
krototype Sep 17, 2019
2ebf666
made change to use undefined instead of null as classname
krototype Sep 17, 2019
7baaf98
Merge pull request #229 from microsoftgraph/abhsriva/emptyPostRequest
krototype Oct 3, 2019
834fcf3
added functionality to simplify building middleware chain
krototype Oct 15, 2019
b2f7d3b
Merge branch 'dev' into build_middleware_chain
krototype Oct 15, 2019
de8a55b
Merge pull request #239 from microsoftgraph/build_middleware_chain
krototype Oct 18, 2019
072bed1
Updated GraphRequest.ts for .count() scenario
krototype Oct 22, 2019
b9a66b4
Merge pull request #243 from microsoftgraph/abhsriva/update-count
krototype Oct 25, 2019
c3e0ef3
Bumped version to '2.1.0-Preview.1'
muthu-rathinam Oct 25, 2019
0374959
Adding the Modifying middleware chain samples
krototype Nov 12, 2019
f825b1b
- fixes broken link to client instance
baywet Nov 18, 2019
c4e43a8
Updated the example to the correct return type
Nov 19, 2019
f2b418e
Merge pull request #247 from microsoftgraph/abhsriva/customMiddleware…
krototype Nov 26, 2019
42cf768
Merge branch 'dev' into patch-1
krototype Nov 26, 2019
704d5e3
Merge pull request #250 from baywet/patch-1
krototype Nov 26, 2019
b9a3225
Merge branch 'dev' into patch-1
Nov 27, 2019
73e0b1e
fix casing on filename
gidsg Nov 29, 2019
ea88e47
Merge branch 'dev' into fix-case
muthurathinam Dec 9, 2019
da8d0f3
Merge pull request #251 from warreee/patch-1
muthurathinam Dec 9, 2019
e920fad
Merge branch 'dev' into fix-case
muthurathinam Dec 9, 2019
4a70b05
Merge pull request #255 from gidsg/fix-case
muthurathinam Dec 9, 2019
db7403d
Update package.json
nmetulev Dec 11, 2019
ea5f4ab
Merge pull request #257 from nmetulev/patch-2
muthurathinam Dec 12, 2019
9da92e1
Designed ChaosHandler
krototype Dec 12, 2019
f37b583
Merge pull request #258 from microsoftgraph/abhsriva/ChaosHandler
krototype Dec 12, 2019
aa17391
Removing the set and get middleware chain method
krototype Dec 12, 2019
3b95f44
Merge pull request #259 from microsoftgraph/removeSetMiddleware
krototype Dec 12, 2019
183cf62
Update README
behnammodi Jun 9, 2020
4d59843
Update README
behnammodi Jun 9, 2020
a4d34d6
Merge pull request #290 from behnammodi/dev
ddyett Jun 9, 2020
42ee7aa
Bump lodash from 4.17.15 to 4.17.19 in /samples/browser
dependabot[bot] Jul 16, 2020
870477b
Merge pull request #299 from microsoftgraph/dependabot/npm_and_yarn/s…
ddyett Jul 16, 2020
6e890cc
Changed parsepath and query functions to split query params on first …
nikithauc Jul 28, 2020
6813139
Correcting spelling in comments, setting the param key directlyand re…
nikithauc Jul 29, 2020
72adfd0
Adding a buildheaders function to conditionally set content type and …
nikithauc Jul 29, 2020
b946955
Altering condition to be optimal
nikithauc Jul 29, 2020
d5bb8c4
Adding formdata to the node project, setting the esModuleInterop conf…
nikithauc Aug 4, 2020
6c68a75
Adding a private query parsing function and more validations
nikithauc Aug 4, 2020
4a63220
Adding tests for url parsing and comments to the private url parsing …
nikithauc Aug 5, 2020
35c804d
Adding more information in the return comments for functions returnin…
nikithauc Aug 5, 2020
099fa02
Adding unit test for serializecontent testing if content is null, cha…
nikithauc Aug 5, 2020
1f342bf
Changing the conditional expression to check for undefined or null he…
nikithauc Aug 5, 2020
36b0cc9
Adding the missing return
nikithauc Aug 5, 2020
d8a1ff9
Removing the try catch block from the test case
nikithauc Aug 5, 2020
2b0d381
Removing the try catch block from the test case
nikithauc Aug 5, 2020
ed902ec
Merge pull request #306 from microsoftgraph/JS_Issue_291_URLParsingCo…
MIchaelMainer Aug 7, 2020
45727eb
Returning if the content-type is present else setting content-type as…
nikithauc Aug 7, 2020
cff1a71
Merge branch 'dev' into JS-Issue-293-298-Emptybody-Content-type
nikithauc Aug 7, 2020
3f9412d
Uninstalling formdata, restoring the tsconfigs and removing the condi…
nikithauc Aug 12, 2020
354b215
Merge branch 'JS-Issue-293-298-Emptybody-Content-type' of https://git…
nikithauc Aug 12, 2020
5dd2a1d
Restoring file
nikithauc Aug 12, 2020
62b5f8c
Reverting the package json changes
nikithauc Aug 12, 2020
1ee7bd8
Merge pull request #309 from microsoftgraph/JS-Issue-293-298-Emptybod…
MIchaelMainer Aug 14, 2020
3138966
Bump yargs-parser from 13.1.1 to 13.1.2 in /samples/browser (#321)
dependabot[bot] Sep 9, 2020
9e25f05
Bump mixin-deep from 1.3.1 to 1.3.2 in /scripts (#301)
dependabot[bot] Sep 9, 2020
ab824f7
Bump http-proxy from 1.17.0 to 1.18.1 in /samples/browser (#319)
dependabot[bot] Sep 9, 2020
aaf142e
Update OneDriveLargeFileUploadTask.ts (#325)
hasridha Sep 17, 2020
a2742b3
Use correct class name (#284)
mattdenkers Sep 24, 2020
8089cd0
Typo in documentation example. (#270)
lewgordon Sep 24, 2020
130f3c0
Enhancement/#311 page iterator request options (#318)
nikithauc Sep 25, 2020
bdaf597
Sorting parameter list - chaoshandleroptions (#334)
nikithauc Oct 1, 2020
f99d0ff
Client init with middleware array (#333)
nikithauc Oct 5, 2020
ad4399b
Make GraphError real Error (#335)
OlivierCuyp Oct 5, 2020
a95a762
Using ternary shorthand, upgrade preview 2.1.0-2 (#337)
nikithauc Oct 6, 2020
412b6bf
Bump version to 2.1.0
nikithauc Oct 8, 2020
054db46
merging with master
nikithauc Oct 8, 2020
cd5a6d8
changing.substring parameter, comments to check middleware
nikithauc Oct 8, 2020
3f85c02
adding tests, urlotherqueryoptions type
nikithauc Oct 8, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ npm install msal@<version>

```typescript
import { UserAgentApplication } from "msal";

import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
import { MSALAuthenticationProviderOptions } from '@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions';

Expand Down
4 changes: 2 additions & 2 deletions docs/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ client
.then((stream) => {
let writeStream = fs.createWriteStream(`../<DOWNLOAD_FILE_NAME>`); // Eg: test.pdf
stream.pipe(writeStream).on("error", (err) => {
throw error;
throw err;
});
writeStream.on("finish", () => {
console.log("Downloaded");
});
writeStream.on("error", (err) => {
throw error;
throw err;
});
})
.catch((error) => {
Expand Down
102 changes: 102 additions & 0 deletions docs/ChaosHandlerSamples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Testing Handler

### How to include

> Uses [Custom Middleware Chain](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CustomMiddlewareChain.md), it's not included in default middleware chain

### Modes in Chaos Handler

- Manual mode - Setting the Response code manually. - Global/Client Level - Provide a map declared manually containing response code for the requests. - Request Level - Providing response code per request. This would be overriding the Global level response code (if any).
- Random mode - We get a random Response code from a set of response code defined for each method.

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

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

### Samples

```js
require("isomorphic-fetch");
const MicrosoftGraph = require("../../lib/src/index.js");
const secrets = require("./secrets");
const fs = require("fs");
// Initialising the client
const client = MicrosoftGraph.Client.init({
defaultVersion: "v1.0",
debugLogging: true,
authProvider: (done) => {
done(null, secrets.accessToken);
},
});

/*
Create a custom MiddlewareChain passing information in this way

const manualMap = new Map([["/me/messages/.*", new Map([["GET", 429], ["PATCH", 429]])], ["/me", new Map([["POST", 502]])]]);
const chaosHandler = new MicrosoftGraph.ChaosHandler(new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.MANUAL), manualMap);
*/

// This request would use the Map (Manual mode)
const mail = {
subject: "Chaos Handler Samples",
toRecipients: [
{
emailAddress: {
address: "admin@M365x003297.OnMicrosoft.com",
},
},
],
body: {
content: "<h1>Testing Handler Samples Sample</h1><br>https://github.com/microsoftgraph/msgraph-sdk-javascript",
contentType: "html",
},
};
client
.api("/users/me/sendMail")
.post({
message: mail,
})
.then((res) => {
console.log(res, "This is for sendMail");
})
.catch((err) => {
console.log(err, "This is for sendMail in error case");
});

// OverRiding to Random mode, providing the chaos percentage as 60(percentage times the error would be generated from handler)
client
.api("/me")
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, "I generated the error", undefined, 60)])
.get()
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});

// This request is passed to the graph and gets a response from the graph, as no entry for /me GET request in the Map
client
.api("/me")
.get()
.then((res) => {
console.log("Found", res, "users");
})
.catch((err) => {
console.log(err, "!!!!!!!!!");
});

// Using Manual Map with regex matching
client
.api("/me/messages/hjdlfslod-fdssdkjfs-6zdkmghs-sadhsu2")
.header("content-type", "application/json")
.update({
birthday: "1908-12-22T00:00:00Z",
})
.then((res) => {
console.log("This is regex matching... Updated Bday");
})
.catch((err) => {
console.log(err, "matched");
});
```
4 changes: 2 additions & 2 deletions docs/CustomAuthenticationProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MyAuthenticationProvider implements AuthenticationProvider {
* This should return a Promise that resolves to an accessToken (in case of success) or rejects with error (in case of failure)
* Basically this method will contain the implementation for getting and refreshing accessTokens
*/
public async getAccessToken(): Promise<any> {}
public async getAccessToken(): Promise<string> {}
}
```

Expand All @@ -30,7 +30,7 @@ Pass instance of MyAuthenticationProvider while initializing.
import { MyAuthenticationProvider } from "./MyAuthenticationProvider";

let clientOptions: ClientOptions = {
authProvider: new MyCustomAuthenticationProvider(),
authProvider: new MyAuthenticationProvider(),
};
const client = Client.initWithMiddleware(clientOptions);
```
2 changes: 1 addition & 1 deletion docs/CustomMiddlewareChain.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ export class MyLoggingHandler implements Middleware {
}
```

Refer [MiddlewareOptions](../src/middleware/option/IMiddlewareOptions.ts) interface to know its structure.
Refer [MiddlewareOptions](../src/middleware/options/IMiddlewareOptions.ts) interface to know its structure.
2 changes: 1 addition & 1 deletion docs/GettingRawResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Steps for getting the raw response [i.e [Response Object](https://developer.mozi

## Initialize the Client

Refer [this documentation](../CreatingClientInstance.md) for initializing the client.
Refer [this documentation](./CreatingClientInstance.md) for initializing the client.

## Getting Raw Response by setting ResponseType

Expand Down
2 changes: 1 addition & 1 deletion docs/tasks/LargeFileUploadTask.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ _You can pass in the customized options using LargeFileUploadTask_

```typescript
async function largeFileUpload(client, file) {
const filename = file.name;
const fileName = file.name;
const driveId = "<YOUR_DRIVE_ID>";
const path = "<LOCATION_TO_STORE_FILE>";
try {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@microsoft/microsoft-graph-client",
"version": "2.0.0",
"version": "2.1.0",
"description": "Microsoft Graph Client Library",
"license": "MIT",
"main": "lib/src/index.js",
"module": "lib/es/index.js",
"typings": "lib/src/index",
Expand Down
34 changes: 18 additions & 16 deletions samples/browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions scripts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions spec/core/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
import { assert } from "chai";
import "isomorphic-fetch";

import { CustomAuthenticationProvider, TelemetryHandler } from "../../src";
import { Client } from "../../src/Client";
import { AuthProvider } from "../../src/IAuthProvider";
import { ClientOptions } from "../../src/IClientOptions";
import { Options } from "../../src/IOptions";
import { AuthenticationHandler } from "../../src/middleware/AuthenticationHandler";
import { ChaosHandler } from "../../src/middleware/ChaosHandler";
import { ChaosHandlerOptions } from "../../src/middleware/options/ChaosHandlerOptions";
import { ChaosStrategy } from "../../src/middleware/options/ChaosStrategy";
import { DummyAuthenticationProvider } from "../DummyAuthenticationProvider";
import { DummyHTTPMessageHandler } from "../DummyHTTPMessageHandler";

Expand Down Expand Up @@ -61,6 +66,41 @@ describe("Client.ts", () => {
assert.equal(error.name, "InvalidMiddlewareChain");
}
});

it("Init middleware using a middleware array", async () => {
const provider: AuthProvider = (done) => {
done(null, "dummy_token");
};
const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider));
const responseBody = "Test response body";
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing middleware array", 200, 0, responseBody);
const middlewareArray = [authHandler, new ChaosHandler(options)];
const client = Client.initWithMiddleware({ middleware: middlewareArray });

const response = await client.api("me").get();
assert.equal(response, responseBody);
});

it("Init middleware using a chained middleware array", async () => {
const provider: AuthProvider = (done) => {
done(null, "dummy_token");
};
const authHandler = new AuthenticationHandler(new CustomAuthenticationProvider(provider));

const responseBody = "Test response body";
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Testing chained middleware array", 200, 0, responseBody);
const chaosHandler = new ChaosHandler(options);
const telemetryHandler = new TelemetryHandler();

authHandler.setNext(telemetryHandler);
telemetryHandler.setNext(chaosHandler);

const middlewareArray = [authHandler];
const client = Client.initWithMiddleware({ middleware: middlewareArray });

const response = await client.api("me").get();
assert.equal(response, responseBody);
});
});

describe("init", () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/core/GraphErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ describe("GraphErrorHandler.ts", () => {

it("Should construct some default error", async () => {
const gError = await GraphErrorHandler.getError();
assert.equal(gError.message, "");
assert.equal(gError.statusCode, -1);
assert.equal(gError.code, null);
assert.equal(gError.message, null);
assert.equal(gError.body, null);
assert.equal(gError.requestId, null);
});
Expand Down
Loading