Skip to content

Commit 97cefe8

Browse files
Merge pull request #101 from microsoftgraph/dev
Sync up master with changes in dev
2 parents c91286e + 0f9ebec commit 97cefe8

File tree

92 files changed

+5183
-4852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+5183
-4852
lines changed

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
.vscode/
1+
/.vscode/*
2+
!/.vscode/launch.json
23
.DS_Store
34
.tmp
45
tmp
56
node_modules
67
typings
78
src/**/*.js
9+
src/**/*.js.map
10+
src/**/*.d.ts
811
coverage
912
**/*.tgz
1013
samples/node/secrets.json
@@ -16,7 +19,6 @@ samples/typescript/graph-typings.d.ts
1619
samples/typescript/sample.js.map
1720
src/index.d.ts
1821

19-
spec/types/secrets*
20-
spec/types/*.js
21-
spec/types/*.d.ts
22-
spec/types/*.js.map
22+
spec/**/*.js
23+
spec/**/*.d.ts
24+
spec/**/*.js.map

.jshintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"esnext": "true"
3+
}

.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Run node samples",
11+
"program": "${workspaceRoot}/samples/node/node-sample.js",
12+
"cwd": "${workspaceRoot}",
13+
"outFiles": [],
14+
"internalConsoleOptions": "openOnSessionStart"
15+
},
16+
{
17+
"type": "node",
18+
"request": "launch",
19+
"name": "Run core tests",
20+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
21+
"args": [
22+
"${workspaceRoot}/lib/spec/core/*.js"
23+
],
24+
"cwd": "${workspaceRoot}",
25+
"outFiles": [],
26+
"internalConsoleOptions": "openOnSessionStart"
27+
}
28+
]
29+
}

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Changelog
2+
3+
### 1.2.0
4+
Updates
5+
6+
* Two output js files, one with polyfills for Fetch-API and ES6-Promises ([lib/graph-js-sdk-web.js](./lib/graph-js-sdk-web.js)) and one without ([lib/graph-js-sdk-core.js](./lib/graph-js-sdk-core.js))
7+
[Refer [README.md](https://github.com/microsoftgraph/msgraph-sdk-javascript#browser) for usage]
8+
* Enum for ResponseType, which lists down the available ResponseType options in autocomplete
9+
10+
Bug Fix
11+
* Cannot access the property "request-id" of undefined in GraphError handling
12+
13+
### 1.1.0
14+
New Features
15+
* Support for Multipart POST request
16+
17+
Updates
18+
* Light weight FetchAPI dependency (in replacement for SuperAgent)
19+
20+
Bug Fixes
21+
* Updated putStream and getStream to work for all sized files
22+
* Added obfuscation for output js file (graph-js-sdk-web.js)
23+
* Updated versions of mocha and chai to 5.2.0 and 4.1.2 to fix security vulnerability in growl (which is a dependency of mocha)
24+
* Running unit test files under types directory
25+
* Compiling ts files
26+
27+
#### 1.0.0
28+
* Added tests for new Graph functionality - Delta query, Extensibility, OneNote, and more.
29+
30+
#### 0.4.0
31+
* Add support for ES5. Make sure to use `graph-js-sdk-web.js` for web apps
32+
* Removed iterator helper method.
33+
34+
#### 0.3.1
35+
* Support for Node.js versions 4 and 5
36+
37+
#### 0.3.0
38+
* Migrated away from typings in client library core and TypeScript sample
39+
40+
#### 0.2.2
41+
* Updated SuperAgent to version ``` 3.3.0 ```
42+
43+
#### 0.2.0
44+
* **Breaking change for existing apps** - Initialize the client library with `MicrosoftGraph.Client.init({...})`. See the updated usage section below for code samples.
45+
* Added response handling tests to simulate Graph calls
46+
* Added type declarations file for core client library, which adds intellisense for chained methods.

README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ The Microsoft Graph JavaScript client library is a lightweight wrapper around th
1818

1919
### Browser
2020

21-
Include [lib/graph-js-sdk-web.js](https://github.com/microsoftgraph/msgraph-sdk-javascript/raw/master/lib/graph-js-sdk-web.js) in your page.
21+
The library comes with two varieties of options, you can pick one based on your use case
22+
23+
1. If your application has polyfills for **Fetch-API** and **ES6-Promise**, then can just include [lib/graph-js-sdk-core.js](./lib/graph-js-sdk-core.js) in your page.
24+
```html
25+
<script type="text/javascript" src="graph-js-sdk-core.js"></script>
26+
```
27+
28+
2. If your application does not have polyfills for **Fetch-API** and **ES6-Promise**, then you have to include [lib/graph-js-sdk-web.js](./lib/graph-js-sdk-web.js) in your page.
2229
```html
2330
<script type="text/javascript" src="graph-js-sdk-web.js"></script>
2431
```
@@ -151,7 +158,7 @@ let fs = require('fs'); // requires filesystem module
151158
let stream = fs.createReadStream('./logo.png'); //path to local file
152159
client
153160
.api('/me/drive/root/children/logo.png/content') // path to the destination in OneDrive
154-
.put(stream, (err) => {
161+
.putStream(stream, (err) => {
155162
console.log(err);
156163
});
157164
````
@@ -241,7 +248,29 @@ You can pass in additional request headers, either individually or in a dictiona
241248
````
242249

243250
### .responseType()
244-
To set a custom response type, use the `.responseType(string)` method. To see an example, check the [browser sample](samples/browser/index.html) that downloads an image and displays it in an `<img>` element.
251+
To set a custom response type, use the `.responseType(<ResponseType>)` method. Refer [ResponseType.ts](./src/ResponseType.ts) for available options.
252+
````js
253+
client
254+
.api(`/me/drive/root/children/${fileName}/content`)
255+
.responseType(MicrosoftGraph.ResponseType.BLOB)
256+
.get()
257+
.then((res) => {
258+
console.log("Downloaded..!!");
259+
})
260+
.catch((err) => {
261+
throw err;
262+
});
263+
````
264+
265+
## Running node samples
266+
You can run and debug the node samples found under [./samples/node/node-sample.js](./samples/node/node-sample.js) by running the *Run node samples* configuration from the **Debug** (Ctrl + Shift + D) menu in Visual Studio Code. Alternately, you can run the node samples from the CLI by entering `node ./samples/node/node-sample.js` (assuming you are at the root of this repo). You'll need to rename the *secrets.example.json* file to *secrets.json* and add a valid access token to it. You can get an access token by doing the following:
267+
1. Go to [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer).
268+
2. Login with the account you want to use to run the node samples.
269+
3. Open the F12 dev tools.
270+
4. Type `tokenPlease()` into the console to get an access token.
271+
5. Copy the access token and put it into the *secrets.json* file and save the file.
272+
273+
We suggest that you become acquainted with these samples as they show some of the main use scenarios for this client library.
245274

246275
## Additional information
247276
### Options in `MicrosoftGraph.Client.init()`
@@ -287,7 +316,7 @@ These steps are not required to use this library.
287316

288317
```npm pack``` bundles the npm module.
289318

290-
```npm test``` runs tests of the core library (URL parsing, mock responses, etc)
319+
```npm test``` runs tests of the core library (URL parsing, mock responses, etc). You can also set breakpoints and run this from within Visual Studio Code by selecting the *Run core test* configuration from the Debug view.
291320

292321
```npm run test:types``` to run tests against the Graph API for users, groups, Excel, OneNote, etc.
293322

@@ -303,28 +332,6 @@ We'd love to get your feedback about the Microsoft Graph JavaScript client libra
303332

304333
## Contributing
305334
Please see the [contributing guidelines](CONTRIBUTING.md).
306-
## Changelog
307-
308-
#### 1.0.0
309-
* Added tests for new Graph functionality - Delta query, Extensibility, OneNote, and more.
310-
311-
#### 0.4.0
312-
* Add support for ES5. Make sure to use `graph-js-sdk-web.js` for web apps
313-
* Removed iterator helper method.
314-
315-
#### 0.3.1
316-
* Support for Node.js versions 4 and 5
317-
318-
#### 0.3.0
319-
* Migrated away from typings in client library core and TypeScript sample
320-
321-
#### 0.2.2
322-
* Updated SuperAgent to version ``` 3.3.0 ```
323-
324-
#### 0.2.0
325-
* **Breaking change for existing apps** - Initialize the client library with `MicrosoftGraph.Client.init({...})`. See the updated usage section below for code samples.
326-
* Added response handling tests to simulate Graph calls
327-
* Added type declarations file for core client library, which adds intellisense for chained methods.
328335

329336

330337
## Additional resources
@@ -339,3 +346,6 @@ Please see the [contributing guidelines](CONTRIBUTING.md).
339346
Copyright (c) Microsoft Corporation. All rights reserved.
340347

341348
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
349+
350+
## Third Party Notices
351+
See [Third Party Notices](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/master/THIRD%20PARTY%20NOTICES) for information on the packages that are included in the [package.json](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/master/package.json)

THIRD PARTY NOTICES

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This file is based on or incorporates material from the projects listed below (Third Party OSS). The original copyright notice and the license under which Microsoft received such Third Party OSS, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party OSS to you under the licensing terms for the Microsoft product or service. Microsoft
2+
reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
3+
4+
superagent - 3.5.2
5+
6+
es6-promise - 4.1.0
7+
8+
Provided for Informational Purposes Only
9+
10+
MIT License
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

browser-wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// make MicrosoftGraph globally accessible
22
// MicrosoftGraph.api() can be called directly
3-
window.MicrosoftGraph = require('./lib/src/index.js');
3+
window.MicrosoftGraph = require('./lib/src/index.js');

core-browserify.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var browserify = require('browserify');
2+
var b = browserify();
3+
b.add('./browser-wrapper.js');
4+
b.external("es6-promise");
5+
b.external("isomorphic-fetch");
6+
b.bundle().pipe(process.stdout);

lib/graph-js-sdk-core.js

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

0 commit comments

Comments
 (0)