Skip to content

Commit b05fc9c

Browse files
nikithauckrototypemuthu-rathinambaywetwarreee
authored
Release - 2.1.0 (#338)
* updated broken link in README * Post request with empty body, now working fine. * updated the tests for this case * made change to use undefined instead of null as classname * added functionality to simplify building middleware chain * Updated GraphRequest.ts for .count() scenario Updated GraphRequest.ts to handle .count() when no parameter is specified * Bumped version to '2.1.0-Preview.1' * Adding the Modifying middleware chain samples * - fixes broken link to client instance * Updated the example to the correct return type * fix casing on filename * Update package.json * Designed ChaosHandler * Removing the set and get middleware chain method * Update README * Update README * Bump lodash from 4.17.15 to 4.17.19 in /samples/browser Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.15...4.17.19) Signed-off-by: dependabot[bot] <[email protected]> * Changed parsepath and query functions to split query params on first equals sign considering nested queries. Added comments to query functions * Correcting spelling in comments, setting the param key directlyand replacing ternary condition with if else * Adding a buildheaders function to conditionally set content type and checking if body is null when serializing content * Altering condition to be optimal Co-authored-by: Mustafa Zengin <[email protected]> * Adding formdata to the node project, setting the esModuleInterop config as true for allowing import of npm modules, adding unit test for application/xhtml+xml content type post * Adding a private query parsing function and more validations * Adding tests for url parsing and comments to the private url parsing functions * Adding more information in the return comments for functions returning the GraphRequest instance * Adding unit test for serializecontent testing if content is null, changed content type setting for put and patch * Changing the conditional expression to check for undefined or null headers Co-authored-by: Mustafa Zengin <[email protected]> * Adding the missing return Co-authored-by: Mustafa Zengin <[email protected]> * Removing the try catch block from the test case * Removing the try catch block from the test case * Returning if the content-type is present else setting content-type as default * Uninstalling formdata, restoring the tsconfigs and removing the condition to check if form-data is undefined in GraphRequest.ts * Restoring file * Reverting the package json changes * Bump yargs-parser from 13.1.1 to 13.1.2 in /samples/browser (#321) Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 13.1.1 to 13.1.2. - [Release notes](https://github.com/yargs/yargs-parser/releases) - [Changelog](https://github.com/yargs/yargs-parser/blob/master/docs/CHANGELOG-full.md) - [Commits](https://github.com/yargs/yargs-parser/commits) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump mixin-deep from 1.3.1 to 1.3.2 in /scripts (#301) Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases) - [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: nikithauc <[email protected]> * Bump http-proxy from 1.17.0 to 1.18.1 in /samples/browser (#319) Bumps [http-proxy](https://github.com/http-party/node-http-proxy) from 1.17.0 to 1.18.1. - [Release notes](https://github.com/http-party/node-http-proxy/releases) - [Changelog](https://github.com/http-party/node-http-proxy/blob/master/CHANGELOG.md) - [Commits](http-party/node-http-proxy@1.17.0...1.18.1) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update OneDriveLargeFileUploadTask.ts (#325) * Update OneDriveLargeFileUploadTask.ts Trying to upload files with the '#' or '%' character in the filename ends with network errors of the form - 400 status response "The parameter item does not exist in method getByPath" Encoding the entire URL does not encode URL components correctly. When the SDK's client tries to encode these URL components in the parameters on the call to OneDriveLargeFileUploadTask.create, then the resultant file in OneDrive has the URL encoded filename (as opposed to the user-friendly/decoded filename). Therefore, fix the encoding in the SDK's URL components itself, directly. * Update OneDriveLargeFileUploadTask.ts Fix typo * Update src/tasks/OneDriveLargeFileUploadTask.ts Updated comment Co-authored-by: Mustafa Zengin <[email protected]> * Update OneDriveLargeFileUploadTask.ts Updated comment Co-authored-by: Mustafa Zengin <[email protected]> * Use correct class name (#284) Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: nikithauc <[email protected]> * Typo in documentation example. (#270) Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: nikithauc <[email protected]> * Enhancement/#311 page iterator request options (#318) * Adding request options property to PageIterator * Adding tests for page iterator task to test passing along the headers * using headersinit type for headers * Specifying parameter definition * using constants * Updating function documentation * remove response type, test passing fetchoptions * testing requestOptions set in pageiterator * typos, optional parameters comments * Sorting parameter list - chaoshandleroptions (#334) * Client init with middleware array (#333) * Passing midddleware array in client options * Tests for middleware array * Removing try catch * ifnode condition,chain middleware test * Adding missing exports * Array initialization Co-authored-by: Vincent Biret <[email protected]> * merging with dev * Using spread operator * Checking if middleware is not empty Co-authored-by: Vincent Biret <[email protected]> * Make GraphError real Error (#335) Co-authored-by: nikithauc <[email protected]> * Using ternary shorthand, upgrade preview 2.1.0-2 (#337) * Bump version to 2.1.0 * changing.substring parameter, comments to check middleware * adding tests, urlotherqueryoptions type Co-authored-by: Abhinav Srivastava <[email protected]> Co-authored-by: muthurathinam <[email protected]> Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: warreee <[email protected]> Co-authored-by: Gideon Goldberg <[email protected]> Co-authored-by: Muthurathinam <[email protected]> Co-authored-by: Nikola Metulev <[email protected]> Co-authored-by: Behnam Mohammadi <[email protected]> Co-authored-by: DeVere Dyett <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mustafa Zengin <[email protected]> Co-authored-by: Michael Mainer <[email protected]> Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: Hari Sridharan <[email protected]> Co-authored-by: Mustafa Zengin <[email protected]> Co-authored-by: mattdenkers <[email protected]> Co-authored-by: lewgordon <[email protected]> Co-authored-by: Olivier Cuypers <[email protected]>
1 parent 248945c commit b05fc9c

39 files changed

+1517
-134
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ npm install msal@<version>
9595

9696
```typescript
9797
import { UserAgentApplication } from "msal";
98+
9899
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
99100
import { MSALAuthenticationProviderOptions } from '@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions';
100101

docs/Actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ client
2929
.then((stream) => {
3030
let writeStream = fs.createWriteStream(`../<DOWNLOAD_FILE_NAME>`); // Eg: test.pdf
3131
stream.pipe(writeStream).on("error", (err) => {
32-
throw error;
32+
throw err;
3333
});
3434
writeStream.on("finish", () => {
3535
console.log("Downloaded");
3636
});
3737
writeStream.on("error", (err) => {
38-
throw error;
38+
throw err;
3939
});
4040
})
4141
.catch((error) => {

docs/ChaosHandlerSamples.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Testing Handler
2+
3+
### How to include
4+
5+
> Uses [Custom Middleware Chain](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CustomMiddlewareChain.md), it's not included in default middleware chain
6+
7+
### Modes in Chaos Handler
8+
9+
- 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).
10+
- Random mode - We get a random Response code from a set of response code defined for each method.
11+
12+
**A request Passes through to the Graph, if there is no entry for the request**
13+
14+
**Note - Always add ChaosHandler before HttpMessageHandler in the midllewareChain**
15+
16+
### Samples
17+
18+
```js
19+
require("isomorphic-fetch");
20+
const MicrosoftGraph = require("../../lib/src/index.js");
21+
const secrets = require("./secrets");
22+
const fs = require("fs");
23+
// Initialising the client
24+
const client = MicrosoftGraph.Client.init({
25+
defaultVersion: "v1.0",
26+
debugLogging: true,
27+
authProvider: (done) => {
28+
done(null, secrets.accessToken);
29+
},
30+
});
31+
32+
/*
33+
Create a custom MiddlewareChain passing information in this way
34+
35+
const manualMap = new Map([["/me/messages/.*", new Map([["GET", 429], ["PATCH", 429]])], ["/me", new Map([["POST", 502]])]]);
36+
const chaosHandler = new MicrosoftGraph.ChaosHandler(new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.MANUAL), manualMap);
37+
*/
38+
39+
// This request would use the Map (Manual mode)
40+
const mail = {
41+
subject: "Chaos Handler Samples",
42+
toRecipients: [
43+
{
44+
emailAddress: {
45+
address: "[email protected]",
46+
},
47+
},
48+
],
49+
body: {
50+
content: "<h1>Testing Handler Samples Sample</h1><br>https://github.com/microsoftgraph/msgraph-sdk-javascript",
51+
contentType: "html",
52+
},
53+
};
54+
client
55+
.api("/users/me/sendMail")
56+
.post({
57+
message: mail,
58+
})
59+
.then((res) => {
60+
console.log(res, "This is for sendMail");
61+
})
62+
.catch((err) => {
63+
console.log(err, "This is for sendMail in error case");
64+
});
65+
66+
// OverRiding to Random mode, providing the chaos percentage as 60(percentage times the error would be generated from handler)
67+
client
68+
.api("/me")
69+
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, "I generated the error", undefined, 60)])
70+
.get()
71+
.then((res) => {
72+
console.log(res);
73+
})
74+
.catch((err) => {
75+
console.log(err);
76+
});
77+
78+
// This request is passed to the graph and gets a response from the graph, as no entry for /me GET request in the Map
79+
client
80+
.api("/me")
81+
.get()
82+
.then((res) => {
83+
console.log("Found", res, "users");
84+
})
85+
.catch((err) => {
86+
console.log(err, "!!!!!!!!!");
87+
});
88+
89+
// Using Manual Map with regex matching
90+
client
91+
.api("/me/messages/hjdlfslod-fdssdkjfs-6zdkmghs-sadhsu2")
92+
.header("content-type", "application/json")
93+
.update({
94+
birthday: "1908-12-22T00:00:00Z",
95+
})
96+
.then((res) => {
97+
console.log("This is regex matching... Updated Bday");
98+
})
99+
.catch((err) => {
100+
console.log(err, "matched");
101+
});
102+
```

docs/CustomAuthenticationProvider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MyAuthenticationProvider implements AuthenticationProvider {
1818
* This should return a Promise that resolves to an accessToken (in case of success) or rejects with error (in case of failure)
1919
* Basically this method will contain the implementation for getting and refreshing accessTokens
2020
*/
21-
public async getAccessToken(): Promise<any> {}
21+
public async getAccessToken(): Promise<string> {}
2222
}
2323
```
2424

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

3232
let clientOptions: ClientOptions = {
33-
authProvider: new MyCustomAuthenticationProvider(),
33+
authProvider: new MyAuthenticationProvider(),
3434
};
3535
const client = Client.initWithMiddleware(clientOptions);
3636
```

docs/CustomMiddlewareChain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ export class MyLoggingHandler implements Middleware {
144144
}
145145
```
146146

147-
Refer [MiddlewareOptions](../src/middleware/option/IMiddlewareOptions.ts) interface to know its structure.
147+
Refer [MiddlewareOptions](../src/middleware/options/IMiddlewareOptions.ts) interface to know its structure.

docs/GettingRawResponse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Steps for getting the raw response [i.e [Response Object](https://developer.mozi
44

55
## Initialize the Client
66

7-
Refer [this documentation](../CreatingClientInstance.md) for initializing the client.
7+
Refer [this documentation](./CreatingClientInstance.md) for initializing the client.
88

99
## Getting Raw Response by setting ResponseType
1010

docs/tasks/LargeFileUploadTask.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ _You can pass in the customized options using LargeFileUploadTask_
104104

105105
```typescript
106106
async function largeFileUpload(client, file) {
107-
const filename = file.name;
107+
const fileName = file.name;
108108
const driveId = "<YOUR_DRIVE_ID>";
109109
const path = "<LOCATION_TO_STORE_FILE>";
110110
try {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@microsoft/microsoft-graph-client",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Microsoft Graph Client Library",
5+
"license": "MIT",
56
"main": "lib/src/index.js",
67
"module": "lib/es/index.js",
78
"typings": "lib/src/index",

samples/browser/package-lock.json

Lines changed: 18 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)