Skip to content

Commit

Permalink
+semver: minor
Browse files Browse the repository at this point in the history
Updated Package Versions (#5)

* updated task.json
* Updated SOAP package version
* Updated versions of npm packages
* Removed TYPINGS for TS
* Updated versions
* Fixed TS build errors
* Fixed typo in casing of file
  • Loading branch information
knom authored and knom committed Apr 14, 2021
1 parent 3139b1d commit bd12b38
Show file tree
Hide file tree
Showing 14 changed files with 12,466 additions and 143 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package/
*.vsix
typings/
.taskkey

**/exchangeClient.js
Expand Down
4 changes: 2 additions & 2 deletions InstallMailApp/InstallMailApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
// https://github.com/Microsoft/vsts-task-lib/blob/be60205671545ebef47d3a40569519da9b4d34b0/node/docs/vsts-task-lib.md

import q = require('q');
import tl = require('vsts-task-lib/task');
import trm = require('vsts-task-lib/toolrunner');
import tl = require('azure-pipelines-task-lib/task');
import trm = require('azure-pipelines-task-lib/toolrunner');
import path = require('path');
import fs = require('fs');
import ews = require('./lib/ews-soap/exchangeClient');
Expand Down
113 changes: 57 additions & 56 deletions InstallMailApp/lib/ews-soap/exchangeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ let path = require("path");
let xml2js = require("xml2js");
let soap = require("soap");
let enumerable = require("linq");
import tl = require('vsts-task-lib/task');
import tl = require('azure-pipelines-task-lib/task');

export class EWSClient {
private client: any = null;

public initialize(settings, callback) {
public initialize(settings: any, callback: any) {
let endpoint = settings.url + "/EWS/Exchange.asmx";
let url = path.join(__dirname, "Services.wsdl");

let options = {
escapeXML: false
};
soap.createClient(url, options, (err, client) => {
let options = {
escapeXML: false
};

soap.createClient(url, options, (err: any, client: any) => {
if (err) {
return callback(err);
}
Expand All @@ -24,22 +24,22 @@ export class EWSClient {
}

this.client = client;
this.client.addListener('request', function(xml){
tl.debug("---REQUEST---");
tl.debug(xml);
tl.debug("---END of REQUEST---");
});
this.client.addListener('response', function(a,b){
tl.debug("---RESPONSE---");
tl.debug("body: " + a);
tl.debug("response: " + JSON.stringify(b));
tl.debug("---END of RESPONSE---");
});
this.client.addListener('soapError', function(){
tl.warning("---SOAP ERROR---");
tl.warning("---END of SOAP ERROR---");
});

this.client.addListener('request', function (xml: string) {
tl.debug("---REQUEST---");
tl.debug(xml);
tl.debug("---END of REQUEST---");
});
this.client.addListener('response', function (a: string, b: string) {
tl.debug("---RESPONSE---");
tl.debug("body: " + a);
tl.debug("response: " + JSON.stringify(b));
tl.debug("---END of RESPONSE---");
});
this.client.addListener('soapError', function () {
tl.warning("---SOAP ERROR---");
tl.warning("---END of SOAP ERROR---");
});

if (settings.token) {
this.client.setSecurity(new soap.BearerSecurity(settings.token));
Expand All @@ -52,20 +52,19 @@ export class EWSClient {
}, endpoint);
}

public installApp(manifest, callback) {
public installApp(manifest: string, callback: any) {
if (!this.client) {
return callback(new Error("Call initialize()"));
}

let soapRequest =
//"<tns:InstallApp xmlns:tns='http://schemas.microsoft.com/exchange/services/2006/messages'>" +
"<Manifest>" + manifest + "</Manifest>"; //+
//"</tns:InstallApp>";
//"</tns:InstallApp>";

this.client.InstallApp(soapRequest, (httpError, result, rawBody) => {
this.client.InstallApp(soapRequest, (httpError: any, result: any, rawBody: any) => {
if (httpError) {
if (httpError.response.statusCode && (httpError.response.statusCode == 401 || httpError.response.statusCode == 403))
{
if (httpError.response.statusCode && (httpError.response.statusCode == 401 || httpError.response.statusCode == 403)) {
return callback(new Error(httpError.response.statusCode + ": Unauthorized!"));
}
return callback(new Error(httpError));
Expand All @@ -78,41 +77,41 @@ export class EWSClient {
"attrkey": "@"
});

parser.parseString(rawBody, (err, result) => {
parser.parseString(rawBody, (err: any, result: any) => {
let message = "";
let responseCode = result["s:Body"]["InstallAppResponse"]["ResponseCode"];

if (responseCode !== "NoError") {
try{
let message = enumerable.from(result["s:Body"]["InstallAppResponse"]["MessageXml"]["t:Value"])
.where(function(i){return i["@"]["Name"] === "InnerErrorMessageText";})
.select(function(i){return i["_"];}).first();
}catch(e){
let message = "";
}
finally{
return callback(new Error(responseCode + ": " + JSON.stringify(message)));
}
try {
message = enumerable.from(result["s:Body"]["InstallAppResponse"]["MessageXml"]["t:Value"])
.where(function (i: any) { return i["@"]["Name"] === "InnerErrorMessageText"; })
.select(function (i: any) { return i["_"]; }).first();
} catch (e) {
message = "";
}
finally {
return callback(new Error(responseCode + ": " + JSON.stringify(message)));
}
}

callback(null);
});
});
};

public uninstallApp(id, callback) {
public uninstallApp(id: string, callback: any) {
if (!this.client) {
return callback(new Error("Call initialize()"));
}

let soapRequest =
//"<m:UninstallApp xmlns:m='http://schemas.microsoft.com/exchange/services/2006/messages'>" +
"<ID>" + id + "</ID>"; // +
//"</m:UninstallApp>";
//"</m:UninstallApp>";

this.client.UninstallApp(soapRequest, (httpError, result, rawBody) => {
this.client.UninstallApp(soapRequest, (httpError: any, result: any, rawBody: any) => {
if (httpError) {
if (httpError.response.statusCode && (httpError.response.statusCode == 401 || httpError.response.statusCode == 403))
{
if (httpError.response.statusCode && (httpError.response.statusCode == 401 || httpError.response.statusCode == 403)) {
return callback(new Error(httpError.response.statusCode + ": Unauthorized!"));
}
return callback(new Error(httpError));
Expand All @@ -125,24 +124,26 @@ export class EWSClient {
"attrkey": "@"
});

parser.parseString(rawBody, (err, result) => {
parser.parseString(rawBody, (err: any, result: any) => {
let message = "";

let responseCode = result["s:Body"]["UninstallAppResponse"]["ResponseCode"];

if (responseCode !== "NoError") {
try{
let message = enumerable.from(result["s:Body"]["UninstallAppResponse"]["MessageXml"]["t:Value"])
.where(function(i){return i["@"]["Name"] === "InnerErrorMessageText";})
.select(function(i){return i["_"];}).first();
}catch(e){
let message = "";
}
finally{
return callback(new Error(responseCode + ": " + JSON.stringify(message)));
}
try {
message = enumerable.from(result["s:Body"]["UninstallAppResponse"]["MessageXml"]["t:Value"])
.where(function (i: any) { return i["@"]["Name"] === "InnerErrorMessageText"; })
.select(function (i: any) { return i["_"]; }).first();
} catch (e) {
message = "";
}
finally {
return callback(new Error(responseCode + ": " + JSON.stringify(message)));
}
}

callback(null);
});
});
};
}
}
Loading

0 comments on commit bd12b38

Please sign in to comment.