Skip to content

Commit e748623

Browse files
committed
1 parent c3499fe commit e748623

File tree

9 files changed

+84
-37
lines changed

9 files changed

+84
-37
lines changed

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ews-javascript-api",
3-
"version": "0.9.0-dev.1",
3+
"version": "0.9.0-dev.6",
44
"description": "EWS Managed api in JavaScript",
55
"main": "js/ExchangeWebService.js",
66
"scripts": {
@@ -26,14 +26,12 @@
2626
"homepage": "https://github.com/gautamsi/ews-javascript-api",
2727
"dependencies": {
2828
"@types/moment-timezone": "^0.2.34",
29-
"@types/node": "^6.0.46",
30-
"@types/node-uuid": "0.0.28",
31-
"@types/q": "0.0.32",
29+
"@types/node": "^7.0.18",
30+
"@types/uuid": "^2.0.29",
3231
"base64-js": "^1.2.0",
3332
"moment": "^2.17.1",
3433
"moment-timezone": "^0.5.11",
35-
"node-uuid": "^1.4.7",
36-
"reflect-metadata": "^0.1.8",
34+
"uuid": "^3.0.1",
3735
"xmldom": "^0.1.22"
3836
},
3937
"optionalDependencies": {
@@ -43,7 +41,7 @@
4341
"devDependencies": {
4442
"@types/chai": "^3.4.34",
4543
"@types/chai-as-promised": "0.0.29",
46-
"@types/gulp": "^3.8.32",
44+
"@types/gulp": "^4.0.3",
4745
"@types/mocha": "^2.2.32",
4846
"almond": "^0.3.3",
4947
"chai": "^3.5.0",

src/js/Core/Requests/HangingServiceRequestBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class HangingServiceRequestBase extends ServiceRequestBase {
152152
}
153153
}).then((xhrResponse: any) => { //<any> used for progress delegate, not in standard promise
154154
//console.log(xhrResponse);
155-
successDelegate(void 0);
155+
//successDelegate(void 0);
156156
}, (resperr: XMLHttpRequest) => {
157157
if (resperr.status && resperr.getAllResponseHeaders) {
158158
EwsLogging.Log("Error in calling service, error code: " + resperr.status + "\r\n " + resperr.getAllResponseHeaders());

src/js/Core/ServiceObjects/Folders/Folder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class Folder extends ServiceObject {
270270
}
271271

272272
if (viewOrSearchFilter instanceof FolderView) {
273-
return this.Service.FindFolders(this.Id, view);
273+
return this.Service.FindFolders(this.Id, viewOrSearchFilter);
274274
}
275275
else if (viewOrSearchFilter instanceof SearchFilter) {
276276
if (typeof view === 'undefined' || !(view instanceof FolderView)) {

src/js/ExchangeWebService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ export { SortDirection } from "./Enumerations/SortDirection";
826826
export { StandardUser } from "./Enumerations/StandardUser";
827827
export { StartTimeZonePropertyDefinition } from "./PropertyDefinitions/StartTimeZonePropertyDefinition";
828828
export { StreamingSubscription } from "./Notifications/StreamingSubscription";
829-
export { StreamingSubscriptionConnection } from "./Notifications/StreamingSubscriptionConnection";
829+
export { StreamingSubscriptionConnection, ResponseHeaderDelegate } from "./Notifications/StreamingSubscriptionConnection";
830830
export { StringList } from "./ComplexProperties/StringList";
831831
export { StringPropertyDefinition } from "./PropertyDefinitions/StringPropertyDefinition";
832832
export { Strings } from "./Strings";

src/js/ExtensionMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export class xml2JsObject {
312312
else
313313
obj[attr.name] = attr.value;
314314
else if (attr.localName === 'xmlns') {
315-
if (xmlNode.namespaceURI !== attr.value && typeof obj[TYPE_STR] === 'undefiend') {
315+
if (xmlNode.namespaceURI !== attr.value && typeof obj[TYPE_STR] === 'undefined') {
316316
obj[TYPE_STR] = attr.value;
317317
}
318318
nonGenericAttributeCount--;

src/js/Guid.ts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
import {StringHelper} from "./ExtensionMethods";
2-
import * as uuid from 'node-uuid';
1+
import { StringHelper } from "./ExtensionMethods";
2+
import * as uuid from 'uuid';
33
/** Guid proxy class */
44
export class Guid {
5-
static Empty: Guid = new Guid('00000000-0000-0000-0000-000000000000');
6-
private guid: string = null;
7-
constructor(str: string) {
8-
if (StringHelper.IsNullOrEmpty(str) || str === null) {
9-
throw new TypeError("Guid.ctor - invalid input");
10-
}
11-
str = str.replace("-", "").replace("{", "").replace("}", "").toLowerCase();
12-
var parsed = uuid.parse(str);
13-
if (parsed) {
14-
this.guid = uuid.unparse(parsed);
15-
// if (this.guid.replace("-", "") !== str.toString()) {
16-
// throw new TypeError("Guid.ctor - malformed string")
17-
// }
5+
static Empty: Guid = new Guid();
6+
private guid: string = '00000000-0000-0000-0000-000000000000';
7+
//private regx = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
8+
//private regx_withoutdash = /^[0-9a-f]{8}[0-9a-f]{4}[1-5][0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/i;
9+
10+
constructor();
11+
constructor(str: string);
12+
constructor(str?: string) {
13+
let regx = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
14+
if (arguments.length > 0) {
15+
if (StringHelper.IsNullOrEmpty(str) || str === null) {
16+
throw new TypeError("Guid.ctor - invalid input");
17+
}
18+
//str = str.replace("-", "").replace("{", "").replace("}", "").toLowerCase();
19+
str = str.replace("{", "").replace("}", "").toLowerCase();
20+
if (regx.test(str)) {
21+
this.guid = str;
22+
} else {
23+
throw new TypeError("Guid.ctor - invalid input");
24+
}
1825
}
1926
}
2027
ToString() {
2128
return this.guid;
2229
}
30+
toString(){
31+
return this.guid;
32+
}
2333

34+
static NewGuid(): Guid {
35+
return new Guid(uuid.v4());
36+
}
2437
static Parse(str: string): Guid {
25-
var parsed = uuid.parse(str);
26-
if (parsed) {
27-
return new Guid(str);
38+
return new Guid(str);
39+
}
40+
41+
static TryParse(str, _parsed_output: { guid: Guid } = { guid: null }) {
42+
try {
43+
_parsed_output.guid = new Guid(str);
44+
return true;
45+
} catch (error) {
46+
return false;
2847
}
2948
}
3049
}

src/js/Notifications/StreamingSubscriptionConnection.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export class StreamingSubscriptionConnection {
7070
*/
7171
OnDisconnect: SubscriptionErrorDelegate[] = [];
7272

73+
/**
74+
* Occurs when a streaming subscription connection gets headers from the server.
75+
*/
76+
OnResponseHeader: ResponseHeaderDelegate[] = [];
77+
7378
/**
7479
* Getting the current subscriptions in this connection.
7580
*/
@@ -269,6 +274,20 @@ export class StreamingSubscriptionConnection {
269274
}
270275
}
271276

277+
/**
278+
* Internal helper method called when the request receives headers.
279+
*
280+
* @param {any} headers The headerf from server.
281+
*/
282+
private InternalOnResponseHeader(headers: any): void {
283+
if (this.OnResponseHeader && ArrayHelper.isArray(this.OnResponseHeader)) {
284+
try {
285+
this.OnResponseHeader.forEach((onHeader) => { onHeader(headers) });
286+
}
287+
catch (e) { }
288+
}
289+
}
290+
272291
/**
273292
* Issues the general failure.
274293
*
@@ -399,6 +418,7 @@ export class StreamingSubscriptionConnection {
399418
this.connectionTimeout);
400419

401420
this.currentHangingRequest.OnDisconnect.push(this.OnRequestDisconnect.bind(this)); //todo: fix if needed multiple instance new HangingServiceRequestBase.HangingRequestDisconnectHandler(this.OnRequestDisconnect)
421+
this.currentHangingRequest.OnResponseHeader = this.InternalOnResponseHeader.bind(this); //todo: fix if needed multiple instance new HangingServiceRequestBase.HangingRequestDisconnectHandler(this.OnRequestDisconnect)
402422

403423
return this.currentHangingRequest.InternalExecute();
404424
//}
@@ -469,4 +489,14 @@ export interface NotificationEventDelegate {
469489
*/
470490
export interface SubscriptionErrorDelegate {
471491
(sender: any, args: SubscriptionErrorEventArgs): void;
492+
}
493+
494+
/**
495+
* Represents a delegate that is invoked when an error occurs within a streaming subscription connection.
496+
*
497+
* @param {any} sender The StreamingSubscriptionConnection instance within which the error occurred.
498+
* @param {SubscriptionErrorEventArgs} args The event data.
499+
*/
500+
export interface ResponseHeaderDelegate {
501+
(header: any): void;
472502
}

src/js/Promise.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,6 @@ export interface PromiseConstructor {
299299

300300
export var Promise: PromiseConstructor;
301301

302-
try {
303-
var promise = require('bluebird');
304-
Promise = promise;
305-
} catch (e) {
306-
Promise = <any>PromiseType;
307-
}
308-
309302
class PromiseType<T> {
310303
constructor() {
311304
throw new NotSupportedException("Promise implementation missing.\nPlease use ConfigurePromise function to assign Promise Object\n" +
@@ -315,6 +308,13 @@ class PromiseType<T> {
315308
}
316309
}
317310

311+
try {
312+
var promise = require('bluebird');
313+
Promise = promise;
314+
} catch (e) {
315+
Promise = <any>PromiseType;
316+
}
317+
318318
export function ConfigurePromise(promise: PromiseConstructor) {
319319
Promise = promise;
320320
}

src/js/PropertyDefinitions/ExtendedPropertyDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class ExtendedPropertyDefinition extends PropertyDefinitionBase {
226226
(extPropDef1.Tag === extPropDef2.Tag) &&
227227
(extPropDef1.Name === extPropDef2.Name) &&
228228
(extPropDef1.PropertySet === extPropDef2.PropertySet) &&
229-
(extPropDef1.propertySetId === extPropDef2.propertySetId));
229+
(String(extPropDef1.propertySetId) === String(extPropDef2.propertySetId)));
230230
}
231231

232232
/**

0 commit comments

Comments
 (0)