Skip to content

Commit 00bada8

Browse files
authored
Merge pull request #326 from gautamsi/fix/v0.10
released 0.10
2 parents 7e732c1 + 7b113df commit 00bada8

File tree

11 files changed

+89
-66
lines changed

11 files changed

+89
-66
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ews-javascript-api",
3-
"version": "0.9.6",
3+
"version": "0.10.0",
44
"description": "EWS Managed api in JavaScript",
55
"main": "js/ExchangeWebService.js",
66
"scripts": {

scripts/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function copyPackageJson() {
100100
const file = 'package.json'
101101
const obj = await readFile(file).catch(error => console.error(error));
102102
delete obj.devDependencies;
103+
delete obj.scripts;
103104
await writeFile(`${outputDir}/package.json`, obj, { spaces: 4, EOL: os.EOL }).catch(error => console.error(error));
104105
resolve();
105106
});

src/js/Autodiscover/Requests/AutodiscoverRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export abstract class AutodiscoverRequest {
155155
}
156156

157157
EwsLogging.DebugLog("sending ews request");
158-
EwsLogging.DebugLog(xhrOptions, true);
158+
EwsLogging.DebugLog({ ...xhrOptions, ...{ headers: { ...xhrOptions.headers, Authorization: "REDACTED" } }}, true);
159159
const xhrResponse = await this.service.XHRApi.xhr(xhrOptions)
160160
const ewsXmlReader = new EwsXmlReader(xhrResponse.responseText || xhrResponse.response);
161161
const responseObject = ewsXmlReader.JsObject;

src/js/Core/ExchangeServiceBase.ts

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export abstract class ExchangeServiceBase {
7272
private clientRequestId: string = null;
7373
private returnClientRequestId: boolean = false;
7474
// private cookieContainer: CookieContainer = new CookieContainer();
75-
protected timeZone: TimeZoneInfo = null;
75+
protected timeZone: TimeZoneInfo = TimeZoneInfo.Local;
7676
private timeZoneDefinition: TimeZoneDefinition = null;
7777
private serverInfo: ExchangeServerInfo = null;
7878
// private webProxy: IWebProxy = null;
@@ -371,24 +371,24 @@ export abstract class ExchangeServiceBase {
371371
//#region Constructor
372372

373373
/**
374-
* @internal Initializes a new instance of the **ExchangeServiceBase** class.
374+
* Initializes a new instance of the **ExchangeServiceBase** class.
375375
*
376376
*/
377377
constructor();
378378
/**
379-
* @internal Initializes a new instance of the **ExchangeServiceBase** class.
379+
* Initializes a new instance of the **ExchangeServiceBase** class.
380380
*
381381
* @param {TimeZoneInfo} timeZone The time zone to which the service is scoped.
382382
*/
383383
constructor(timeZone: TimeZoneInfo);
384384
/**
385-
* @internal Initializes a new instance of the **ExchangeServiceBase** class.
385+
* Initializes a new instance of the **ExchangeServiceBase** class.
386386
*
387387
* @param {ExchangeVersion} requestedServerVersion The requested server version.
388388
*/
389389
constructor(requestedServerVersion: ExchangeVersion);
390390
/**
391-
* @internal Initializes a new instance of the **ExchangeServiceBase** class.
391+
* Initializes a new instance of the **ExchangeServiceBase** class.
392392
*
393393
* @param {ExchangeVersion} requestedServerVersion The requested server version.
394394
* @param {TimeZoneInfo} timeZone The time zone to which the service is scoped.
@@ -445,10 +445,13 @@ export abstract class ExchangeServiceBase {
445445
}
446446
}
447447

448-
449-
450448
this.requestedServerVersion = requestedServerVersion;
451449

450+
if (hasValue(timeZone)) {
451+
this.timeZone = timeZone;
452+
//this.useDefaultCredentials = true; //ref: no default credential in node.js
453+
}
454+
452455
if (hasValue(service)) {
453456
// this.useDefaultCredentials = service.useDefaultCredentials;
454457
this.credentials = service.credentials;
@@ -467,11 +470,6 @@ export abstract class ExchangeServiceBase {
467470
// this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory;
468471
this.xhrApi = service.xhrApi;
469472
}
470-
471-
if (timeZone !== null && typeof timeZone !== 'undefined') {
472-
this.timeZone = timeZone;
473-
//this.useDefaultCredentials = true; //ref: no default credential in node.js
474-
}
475473
}
476474
//#endregion
477475

@@ -713,18 +711,18 @@ export abstract class ExchangeServiceBase {
713711
}
714712

715713
// REF: no default credential in NodeJs
716-
//request.UseDefaultCredentials = this.UseDefaultCredentials;
714+
// request.UseDefaultCredentials = this.UseDefaultCredentials;
717715
// if (!this.UseDefaultCredentials) {
718-
// var serviceCredentials = this.Credentials;
719-
// if (serviceCredentials === null) {
720-
// throw new ServiceLocalException(Strings.CredentialsRequired);
721-
// }
716+
var serviceCredentials = this.Credentials;
717+
if (serviceCredentials === null) {
718+
throw new ServiceLocalException(Strings.CredentialsRequired);
719+
}
722720

723-
// // Make sure that credentials have been authenticated if required
724-
// //serviceCredentials.PreAuthenticate(); //todo: fix preauthenticate if possible
721+
// Make sure that credentials have been authenticated if required
722+
//serviceCredentials.PreAuthenticate(); //todo: fix preauthenticate if possible
725723

726-
// // Apply credentials to the request
727-
// serviceCredentials.PrepareWebRequest(request);
724+
// Apply credentials to the request
725+
serviceCredentials.PrepareWebRequest(request);
728726
// }
729727
// else
730728
// debugger;
@@ -749,28 +747,27 @@ export abstract class ExchangeServiceBase {
749747
* @param {XMLHttpRequest} response The response.
750748
*/
751749
ProcessHttpResponseHeaders(traceType: TraceFlags, response: XMLHttpRequest): void {
752-
return;
753-
//todo: implement tracing
750+
//TODO: implement tracing properly
754751
this.TraceHttpResponseHeaders(traceType, response);
755752

756-
this.SaveHttpResponseHeaders(response.getAllResponseHeaders());
753+
this.SaveHttpResponseHeaders(response);
757754
}
758755

759756
/**
760757
* Save the HTTP response headers.
761758
*
762-
* @param {Object} headers The response headers
759+
* @param {Object} response The response headers
763760
*/
764-
private SaveHttpResponseHeaders(headers: any/* System.Net.WebHeaderCollection*/): any {
761+
private SaveHttpResponseHeaders(response: any/* System.Net.WebHeaderCollection*/): any {
765762
//debug:
766763
this.httpResponseHeaders.clear();
767764

768-
for (var key in headers.headers) {
769-
this.httpResponseHeaders.Add(key, headers.headers[key]);
765+
for (var key in response.headers || {}) {
766+
this.httpResponseHeaders.Add(key, response.headers[key]);
770767
}
771768

772769
if (this.OnResponseHeadersCaptured != null) {
773-
this.OnResponseHeadersCaptured(headers);
770+
this.OnResponseHeadersCaptured(this.httpResponseHeaders);
774771
}
775772
}
776773

src/js/Core/Requests/HangingServiceRequestBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export class HangingServiceRequestBase extends ServiceRequestBase {
368368
//var startTime = Date.now();// DateTime.UtcNow;
369369
//var response = XHR(request);
370370
EwsLogging.DebugLog("sending ews request");
371-
EwsLogging.DebugLog(request, true);
371+
EwsLogging.DebugLog({ ...request, ...{ headers: { ...request.headers, Authorization: "REDACTED" } }}, true);
372372

373373
return this.Service.XHRApi.xhrStream(request, progressDelegate);
374374
// return new Promise((successDelegate, errorDelegate) => {

src/js/Core/Requests/ServiceRequestBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ export abstract class ServiceRequestBase {
488488
//var startTime = Date.now();// DateTime.UtcNow;
489489
//var response = XHR(request);
490490
EwsLogging.DebugLog("sending ews request");
491-
EwsLogging.DebugLog(request, true);
491+
EwsLogging.DebugLog({ ...request, ...{ headers: { ...request.headers, Authorization: "REDACTED" } }}, true);
492492

493493
return this.service.XHRApi.xhr(request);
494494

src/js/Core/Requests/SimpleServiceRequestBase.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class SimpleServiceRequestBase extends ServiceRequestBase {
5050

5151
var ewsXmlReader: EwsServiceXmlReader = new EwsServiceXmlReader(xhrResponse.responseText || xhrResponse.response, this.Service);
5252
//EwsLogging.DebugLog(ewsXmlReader.JsObject, true);
53-
var serviceResponse = this.ReadResponsePrivate(ewsXmlReader.JsObject);
53+
var serviceResponse = this.ReadResponsePrivate(xhrResponse, ewsXmlReader.JsObject);
5454

5555
if (successDelegate)
5656
successDelegate(serviceResponse || xhrResponse.responseText || xhrResponse.response);
@@ -73,7 +73,7 @@ export class SimpleServiceRequestBase extends ServiceRequestBase {
7373
});
7474

7575
}
76-
private ReadResponsePrivate(response: any /*IEwsHttpWebResponse*/): any {
76+
private ReadResponsePrivate(response: any /*IEwsHttpWebResponse*/, jsObject: any): any {
7777
var serviceResponse: any;
7878

7979
try {
@@ -107,10 +107,10 @@ export class SimpleServiceRequestBase extends ServiceRequestBase {
107107

108108

109109
if (this.Service.RenderingMethod == RenderingMode.Xml) {
110-
serviceResponse = this.ReadResponseXmlJsObject(response);
110+
serviceResponse = this.ReadResponseXmlJsObject(jsObject);
111111
}
112112
else if (this.Service.RenderingMethod == RenderingMode.JSON) {
113-
serviceResponse = this.ReadResponseJson(response);
113+
serviceResponse = this.ReadResponseJson(jsObject);
114114
}
115115
else {
116116
throw new Error/*InvalidOperationException*/("Unknown RenderingMethod.");

src/js/Core/ServiceObjects/Items/Item.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AffectedTaskOccurrence } from "../../../Enumerations/AffectedTaskOccurrence";
22
import { ArchiveTag } from "../../../ComplexProperties/ArchiveTag";
3-
import { ArrayHelper, StringHelper } from "../../../ExtensionMethods";
3+
import { ArrayHelper, StringHelper, isNullOrUndefined } from "../../../ExtensionMethods";
44
import { Attachment } from "../../../ComplexProperties/Attachment";
55
import { AttachmentCollection } from "../../../ComplexProperties/AttachmentCollection";
66
import { ConflictResolutionMode } from "../../../Enumerations/ConflictResolutionMode";
@@ -670,7 +670,9 @@ export class Item extends ServiceObject {
670670
* @param {boolean} suppressReadReceipts Whether to suppress read receipts
671671
*/
672672
Delete(deleteMode: DeleteMode, suppressReadReceipts: boolean): Promise<void>
673-
Delete(deleteMode: DeleteMode, suppressReadReceipts: boolean = false): Promise<void> { return this.InternalDelete(deleteMode, null, null, suppressReadReceipts); }
673+
Delete(deleteMode: DeleteMode, suppressReadReceipts: boolean = false): Promise<void> {
674+
return this.InternalDelete(deleteMode, null, null, suppressReadReceipts);
675+
}
674676

675677
/**
676678
* @internal Gets a list of extended properties defined on this object.
@@ -785,16 +787,14 @@ export class Item extends ServiceObject {
785787
this.ThrowIfThisIsAttachment();
786788

787789
// If sendCancellationsMode is null, use the default value that's appropriate for item type.
788-
// if (!sendCancellationsMode)
789-
// {
790-
// sendCancellationsMode = this.DefaultSendCancellationsMode;
791-
// }
790+
if (isNullOrUndefined(sendCancellationsMode)) {
791+
sendCancellationsMode = this.DefaultSendCancellationsMode;
792+
}
792793

793794
// If affectedTaskOccurrences is null, use the default value that's appropriate for item type.
794-
// if (!affectedTaskOccurrences)
795-
// {
796-
// affectedTaskOccurrences = this.DefaultAffectedTaskOccurrences;
797-
// }
795+
if (isNullOrUndefined(affectedTaskOccurrences)) {
796+
affectedTaskOccurrences = this.DefaultAffectedTaskOccurrences;
797+
}
798798

799799
return this.Service.DeleteItem(
800800
this.Id,

src/js/Misc/DelegateTypes.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {ItemAttachment} from "../ComplexProperties/ItemAttachment";
2-
import {ExchangeVersion} from "../Enumerations/ExchangeVersion";
3-
import {PropertyDefinition} from "../PropertyDefinitions/PropertyDefinition";
4-
import {ComplexProperty} from "../ComplexProperties/ComplexProperty";
5-
import {ExchangeService} from "../Core/ExchangeService";
6-
import {ServiceObject} from "../Core/ServiceObjects/ServiceObject";
1+
import { ItemAttachment } from "../ComplexProperties/ItemAttachment";
2+
import { ExchangeVersion } from "../Enumerations/ExchangeVersion";
3+
import { PropertyDefinition } from "../PropertyDefinitions/PropertyDefinition";
4+
import { ComplexProperty } from "../ComplexProperties/ComplexProperty";
5+
import { ExchangeService } from "../Core/ExchangeService";
6+
import { ServiceObject } from "../Core/ServiceObjects/ServiceObject";
7+
import { Dictionary } from "../AltDictionary";
78

89

910
//no change needed
@@ -25,7 +26,7 @@ export interface CustomXmlSerializationDelegate {
2526
//}
2627

2728
export interface ResponseHeadersCapturedHandler {
28-
(responseHeaders: any /*System.Net.WebHeaderCollection*/): void;
29+
(responseHeaders: Dictionary<string, string>): void;
2930
}
3031
//class ResponseHeadersCapturedHandler extends System.MulticastDelegate {
3132
// //BeginInvoke(responseHeaders: System.Net.WebHeaderCollection, callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("DelegateTypes.ts - BeginInvoke : Not implemented.");}
@@ -66,17 +67,17 @@ export interface GetPropertyDefinitionCallback {
6667
export interface CreateComplexPropertyDelegate<TComplexProperty extends ComplexProperty> {
6768
(): TComplexProperty;
6869
}
69-
//class GetPropertyDefinitionCallback extends System.MulticastDelegate {
70-
// //BeginInvoke(version: ExchangeVersion, callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("DelegateTypes.ts - BeginInvoke : Not implemented.");}
71-
// //EndInvoke(result: System.IAsyncResult): PropertyDefinition{ throw new Error("DelegateTypes.ts - EndInvoke : Not implemented.");}
72-
// //Invoke(version: ExchangeVersion): PropertyDefinition{ throw new Error("DelegateTypes.ts - Invoke : Not implemented.");}
73-
//}
70+
//class GetPropertyDefinitionCallback extends System.MulticastDelegate {
71+
// //BeginInvoke(version: ExchangeVersion, callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("DelegateTypes.ts - BeginInvoke : Not implemented.");}
72+
// //EndInvoke(result: System.IAsyncResult): PropertyDefinition{ throw new Error("DelegateTypes.ts - EndInvoke : Not implemented.");}
73+
// //Invoke(version: ExchangeVersion): PropertyDefinition{ throw new Error("DelegateTypes.ts - Invoke : Not implemented.");}
74+
//}
7475

75-
//class CreateComplexPropertyDelegate<TComplexProperty> extends System.MulticastDelegate {
76-
// //BeginInvoke(callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("DelegateTypes.ts - BeginInvoke : Not implemented.");}
77-
// //EndInvoke(result: System.IAsyncResult): TComplexProperty{ throw new Error("DelegateTypes.ts - EndInvoke : Not implemented.");}
78-
// //Invoke(): TComplexProperty{ throw new Error("DelegateTypes.ts - Invoke : Not implemented.");}
79-
//}
76+
//class CreateComplexPropertyDelegate<TComplexProperty> extends System.MulticastDelegate {
77+
// //BeginInvoke(callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("DelegateTypes.ts - BeginInvoke : Not implemented.");}
78+
// //EndInvoke(result: System.IAsyncResult): TComplexProperty{ throw new Error("DelegateTypes.ts - EndInvoke : Not implemented.");}
79+
// //Invoke(): TComplexProperty{ throw new Error("DelegateTypes.ts - Invoke : Not implemented.");}
80+
//}
8081

8182

8283
export interface CreateServiceObjectWithServiceParam {

0 commit comments

Comments
 (0)