Skip to content

Introduced support to download content as a binary. Minor bug fixes for function signatures #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
780 changes: 409 additions & 371 deletions lib/graph-js-sdk-web.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/spec/core/responseHandling.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions lib/spec/core/urlGeneration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
2 changes: 1 addition & 1 deletion lib/spec/core/urlGeneration.js.map

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

1 change: 1 addition & 0 deletions lib/spec/core/urlParsing.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
2 changes: 1 addition & 1 deletion lib/spec/core/urlParsing.js.map

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

7 changes: 4 additions & 3 deletions lib/src/GraphRequest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export declare class GraphRequest {
private urlJoin(urlSegments);
buildFullUrl(): string;
version(v: string): GraphRequest;
select(properties: string | [string]): GraphRequest;
expand(properties: string | [string]): GraphRequest;
orderby(properties: string | [string]): GraphRequest;
select(properties: string | string[]): GraphRequest;
expand(properties: string | string[]): GraphRequest;
orderby(properties: string | string[]): GraphRequest;
filter(filterStr: string): GraphRequest;
top(n: number): GraphRequest;
skip(n: number): GraphRequest;
Expand All @@ -37,6 +37,7 @@ export declare class GraphRequest {
private routeResponseToPromise(requestBuilder);
private routeResponseToCallback(requestBuilder, callback);
private sendRequestAndRouteResponse(requestBuilder, callback?);
getBinary(callback: GraphRequestCallback): void;
getStream(callback: GraphRequestCallback): void;
putStream(stream: any, callback: Function): void;
private configureRequest(requestBuilder, accessToken);
Expand Down
12 changes: 12 additions & 0 deletions lib/src/GraphRequest.js

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

2 changes: 1 addition & 1 deletion lib/src/GraphRequest.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/src/ResponseHandler.js.map

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

2 changes: 1 addition & 1 deletion lib/src/index.js.map

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

21 changes: 16 additions & 5 deletions src/GraphRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class GraphRequest {
}


private urlJoin(urlSegments:[string]):String {
private urlJoin(urlSegments:string[]):String {
const tr = (s) => s.replace(/\/+$/, '');
const tl = (s) => s.replace(/^\/+/, '');
const joiner = (pre, cur) => [tr(pre), tl(cur)].join('/');
Expand Down Expand Up @@ -127,17 +127,17 @@ export class GraphRequest {
* and .select("displayName", "birthday")
*
*/
select(properties:string|[string]):GraphRequest {
select(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$select", properties, arguments);
return this;
}

expand(properties:string|[string]):GraphRequest {
expand(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$expand", properties, arguments);
return this;
}

orderby(properties:string|[string]):GraphRequest {
orderby(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$orderby", properties, arguments);
return this;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ export class GraphRequest {
}

// helper for $select, $expand and $orderby (must be comma separated)
private addCsvQueryParamater(propertyName:string, propertyValue:string|[string], additionalProperties:IArguments) {
private addCsvQueryParamater(propertyName:string, propertyValue:string|string[], additionalProperties:IArguments) {
// if there are already $propertyName value there, append a ","
this.urlComponents.oDataQueryParams[propertyName] = this.urlComponents.oDataQueryParams[propertyName] ? this.urlComponents.oDataQueryParams[propertyName] + "," : "";

Expand Down Expand Up @@ -297,6 +297,17 @@ export class GraphRequest {
}
}

getBinary(callback: GraphRequestCallback) {
this.config.authProvider((err, accessToken) => {
if (err === null && accessToken !== null) {
let url = this.buildFullUrl();
callback(null, this.configureRequest(request.get(url).responseType('blob'), accessToken));
} else {
callback(err, null);
}
});
}

getStream(callback:GraphRequestCallback) {
this.config.authProvider((err, accessToken) => {
if (err === null && accessToken !== null) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"sourceMap": true,
"target": "es5",
"declaration": true,
"outDir": "lib/"
"outDir": "lib/",
"lib": ["es6","dom"]
},
"exclude": [
"node_modules",
Expand Down