Skip to content

Commit

Permalink
fix(general): tslint being applied in all sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Mar 8, 2019
1 parent 5d08457 commit cd5189d
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 58 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"ban": "ban",
"issues": "git-issues",
"license": "license-checker --production --onlyunknown --csv",
"pretslint": "npm run pretty",
"pretty": "prettier-standard 'src/*.ts' 'packages/**/*.ts'",
"secure": "nsp check",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
Expand Down
3 changes: 2 additions & 1 deletion packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const UrlJoin = require('url-join');
import { BotAdapter } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs';
import { GBMinInstance, IGBDialog } from 'botlib';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
import { GBAdminService } from '../services/GBAdminService';
import { Messages } from '../strings';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';

/**
* Dialogs for administration tasks.
Expand Down Expand Up @@ -157,6 +157,7 @@ export class AdminDialog extends IGBDialog {
return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'addConnection') {
await AdminDialog.addConnectionCommand(min, text);

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'undeployPackage') {
await AdminDialog.undeployPackageCommand(text, min);
Expand Down
4 changes: 2 additions & 2 deletions packages/admin.gbapp/models/AdminModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import {
Column,
CreatedAt,
DataType,
Model,
Table,
UpdatedAt,
DataType
UpdatedAt
} from 'sequelize-typescript';

@Table
Expand Down
4 changes: 3 additions & 1 deletion packages/admin.gbapp/services/GBAdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'use strict';

import { AuthenticationContext, TokenResponse } from 'adal-node';
import { IGBCoreService, IGBAdminService } from 'botlib';
import { IGBAdminService, IGBCoreService } from 'botlib';
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
import { GuaribasAdmin } from '../models/AdminModel';
const UrlJoin = require('url-join');
Expand Down Expand Up @@ -88,6 +88,7 @@ export class GBAdminService implements IGBAdminService {
};
let password = passwordGenerator.generatePassword(options);
password = password.replace(/[\@\[\=\:\;\?]/g, '#');

return password;
}

Expand All @@ -102,6 +103,7 @@ export class GBAdminService implements IGBAdminService {
maximumLength: 14
};
const name = passwordGenerator.generatePassword(options);

return name;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/azuredeployer.gbapp/dialogs/BotFarmDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import { BotAdapter } from 'botbuilder';
import { GBMinInstance } from 'botlib';
import { IGBDialog } from 'botlib';
import { Messages } from '../strings';
import { WaterfallDialog } from 'botlib/node_modules/botbuilder-dialogs';
import { Messages } from '../strings';

export class BotFarmDialog extends IGBDialog {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/azuredeployer.gbapp/dialogs/StartDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class StartDialog {
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`);
password = scanf('%s').replace(/(\n|\r)+$/, '');
}

return password;
}

Expand Down
33 changes: 18 additions & 15 deletions packages/azuredeployer.gbapp/services/AzureDeployerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { SearchManagementClient } from 'azure-arm-search';
import { SqlManagementClient } from 'azure-arm-sql';
import { WebSiteManagementClient } from 'azure-arm-website';
import { AppServicePlan } from 'azure-arm-website/lib/models';
import { IGBInstance, IGBInstallationDeployer } from 'botlib';
import { IGBInstallationDeployer, IGBInstance } from 'botlib';
import { HttpMethods, ServiceClient, WebResource } from 'ms-rest-js';
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
import { GBCorePackage } from '../../../packages/core.gbapp';
Expand Down Expand Up @@ -77,6 +77,19 @@ export class AzureDeployerService implements IGBInstallationDeployer {
this.deployer = deployer;
}

private static createRequestObject(url: string, accessToken: string, verb: HttpMethods, body: string) {
const req = new WebResource();
req.method = verb;
req.url = url;
req.headers = {};
req.headers['Content-Type'] = 'application/json';
req.headers['accept-language'] = '*';
req.headers.Authorization = 'Bearer ' + accessToken;
req.body = body;

return req;
}

public async getSubscriptions(credentials) {
const subscriptionClient = new SubscriptionClient.default(credentials);

Expand Down Expand Up @@ -228,19 +241,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
await storageClient.firewallRules.createOrUpdate(groupName, serverName, 'gb', params);
}

private static createRequestObject(url: string, accessToken: string, verb: HttpMethods, body: string) {
const req = new WebResource();
req.method = verb;
req.url = url;
req.headers = {};
req.headers['Content-Type'] = 'application/json';
req.headers['accept-language'] = '*';
req.headers.Authorization = 'Bearer ' + accessToken;
req.body = body;

return req;
}

public async deployFarm(
proxyAddress: string,
instance: IGBInstance,
Expand Down Expand Up @@ -344,6 +344,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
);

spinner.stop();

return instance;
}

Expand Down Expand Up @@ -385,7 +386,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
this.accessToken = credentials.tokenCache._entries[0].accessToken;
}


private async createStorageServer(group, name, administratorLogin, administratorPassword, serverName, location) {
const params = {
location: location,
Expand Down Expand Up @@ -471,6 +471,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const res = await httpClient.sendRequest(req);
if (!(res.bodyAsJson as any).id) {
reject(res.bodyAsText);

return;
}

Expand Down Expand Up @@ -588,6 +589,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {

private async createDeployGroup(name, location) {
const params = { location: location };

return this.resourceClient.resourceGroups.createOrUpdate(name, params);
}

Expand All @@ -610,6 +612,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
location: location,
serverFarmId: farmId
};

return this.webSiteClient.webApps.createOrUpdate(group, name, parameters);
}
}
2 changes: 1 addition & 1 deletion packages/console.gblib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { Sequelize } from 'sequelize-typescript';
import { ConsoleDirectLine } from './services/ConsoleDirectLine';

export class GBConsolePackage implements IGBPackage {

public sysPackages: IGBPackage[] = undefined;
public channel: ConsoleDirectLine;
public getDialogs(min: GBMinInstance) {}
Expand Down
3 changes: 2 additions & 1 deletion packages/console.gblib/services/ConsoleDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class ConsoleDirectLine extends GBService {
.then(function (client) {
client.clientAuthorizations.add('AuthorizationBotConnector',
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header'));

return client;
})
.catch(function (err) {
Expand Down Expand Up @@ -129,7 +130,7 @@ export class ConsoleDirectLine extends GBService {
setInterval(function () {
client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark })
.then(function (response) {
watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages
watermark = response.obj.watermark;
return response.obj.activities;
})
.then(_this_.printMessages, _this_.directLineClientName);
Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/models/GBModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { IGBInstance } from 'botlib';
@Table
export class GuaribasInstance extends Model<GuaribasInstance>
implements IGBInstance {

@PrimaryKey
@AutoIncrement
@Column
Expand Down
2 changes: 2 additions & 0 deletions packages/core.gbapp/services/GBConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class GBConfigService {
break;
}
}

return value;
}

Expand All @@ -120,6 +121,7 @@ export class GBConfigService {
if (!value) {
value = process.env[key];
}

return value;
}
}
4 changes: 4 additions & 0 deletions packages/core.gbapp/services/GBCoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,12 @@ STORAGE_SYNC=true
fkname += '_' + matches[1];
matches = re4.exec(fkcols);
}

return 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
}
);
}

return sql;
}

Expand Down Expand Up @@ -453,10 +455,12 @@ STORAGE_SYNC=true
fkname += '_' + matches[1];
matches = re3.exec(fkcols);
}

return (args[0] ? args[0] : '') + 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
}
);
}

return sql;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ export class GBDeployer {
// PACKAGE: Put in package logic.
case '.gbkb':
const service = new KBService(this.core.sequelize);

return service.deployKb(this.core, this, localPath);

case '.gbui':
break;

case '.gbdialog':
const vm = new GBVMService();

return vm.loadDialogPackage(localPath, min, this.core, this);

default:
Expand All @@ -257,6 +259,7 @@ export class GBDeployer {

case '.gbkb':
const service = new KBService(this.core.sequelize);

return service.undeployKbFromStorage(instance, this, p.packageId);

case '.gbui':
Expand Down Expand Up @@ -307,6 +310,7 @@ export class GBDeployer {

public async getPackageByName(instanceId: number, packageName: string): Promise<GuaribasPackage> {
const where = { packageName: packageName, instanceId: instanceId };

return GuaribasPackage.findOne({
where: where
});
Expand Down Expand Up @@ -436,6 +440,7 @@ export class GBDeployer {
appPackagesProcessed++;
}
});

return appPackagesProcessed;
}
}
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBImporterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class GBImporter {

packageJson = { ...packageJson, ...settings, ...servicesJson };

if (botId){
if (botId) {
packageJson.botId = botId;
}

Expand Down
17 changes: 10 additions & 7 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const AuthenticationContext = require('adal-node').AuthenticationContext;
import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder';

import { ConfirmPrompt, WaterfallDialog } from 'botbuilder-dialogs';
import { GBMinInstance, IGBAdminService, IGBConversationalService, IGBCoreService, IGBPackage, IGBInstance } from 'botlib';
import { GBMinInstance, IGBAdminService, IGBConversationalService, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
import { GBAnalyticsPackage } from '../../analytics.gblib';
import { GBCorePackage } from '../../core.gbapp';
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp';
Expand Down Expand Up @@ -266,11 +266,13 @@ export class GBMinService {

try {
const json = await request(options);

return Promise.resolve(JSON.parse(json));
} catch (error) {
const msg = `[botId:${
instance.botId
}] Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`;

return Promise.reject(new Error(msg));
}
}
Expand All @@ -296,6 +298,7 @@ export class GBMinService {
return await request(options);
} catch (error) {
const msg = `Error calling Speech to Text client. Error is: ${error}.`;

return Promise.reject(new Error(msg));
}
}
Expand Down Expand Up @@ -351,21 +354,21 @@ export class GBMinService {
if (sysPackage.name === 'GBWhatsappPackage') {
const url = '/instances/:botId/whatsapp';
server.post(url, (req, res) => {
p['channel'].received(req, res);
p.channel.received(req, res);
});
}
}, this);
}, this);

appPackages.forEach(p => {
p.sysPackages = sysPackages;
p.loadBot(min);
if (p.getDialogs !== undefined) {
let dialogs = p.getDialogs(min);
const dialogs = p.getDialogs(min);
dialogs.forEach(dialog => {
min.dialogs.add(new WaterfallDialog(dialog.name, dialog.waterfall));
});
}
}, this);
}, this);
}

/**
Expand Down Expand Up @@ -476,10 +479,10 @@ export class GBMinService {
private async processMessageActivity(context, min: GBMinInstance, step: any) {
// Direct script invoking by itent name.

let isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;
const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;

if (isVMCall) {
let mainMethod = context.activity.text;
const mainMethod = context.activity.text;

min.sandBoxMap[mainMethod].context = context;
min.sandBoxMap[mainMethod].step = step;
Expand Down

0 comments on commit cd5189d

Please sign in to comment.