fix(general): tslint being applied in all sources.
This commit is contained in:
parent
5d08457bef
commit
cd5189d0c8
28 changed files with 90 additions and 58 deletions
|
@ -38,7 +38,6 @@
|
||||||
"ban": "ban",
|
"ban": "ban",
|
||||||
"issues": "git-issues",
|
"issues": "git-issues",
|
||||||
"license": "license-checker --production --onlyunknown --csv",
|
"license": "license-checker --production --onlyunknown --csv",
|
||||||
"pretslint": "npm run pretty",
|
|
||||||
"pretty": "prettier-standard 'src/*.ts' 'packages/**/*.ts'",
|
"pretty": "prettier-standard 'src/*.ts' 'packages/**/*.ts'",
|
||||||
"secure": "nsp check",
|
"secure": "nsp check",
|
||||||
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
|
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
|
||||||
|
|
|
@ -40,12 +40,12 @@ const UrlJoin = require('url-join');
|
||||||
import { BotAdapter } from 'botbuilder';
|
import { BotAdapter } from 'botbuilder';
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||||
|
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||||
import { GBAdminService } from '../services/GBAdminService';
|
import { GBAdminService } from '../services/GBAdminService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialogs for administration tasks.
|
* Dialogs for administration tasks.
|
||||||
|
@ -157,6 +157,7 @@ export class AdminDialog extends IGBDialog {
|
||||||
return await step.replaceDialog('/admin', { firstRun: false });
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'addConnection') {
|
} else if (cmdName === 'addConnection') {
|
||||||
await AdminDialog.addConnectionCommand(min, text);
|
await AdminDialog.addConnectionCommand(min, text);
|
||||||
|
|
||||||
return await step.replaceDialog('/admin', { firstRun: false });
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'undeployPackage') {
|
} else if (cmdName === 'undeployPackage') {
|
||||||
await AdminDialog.undeployPackageCommand(text, min);
|
await AdminDialog.undeployPackageCommand(text, min);
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
CreatedAt,
|
CreatedAt,
|
||||||
|
DataType,
|
||||||
Model,
|
Model,
|
||||||
Table,
|
Table,
|
||||||
UpdatedAt,
|
UpdatedAt
|
||||||
DataType
|
|
||||||
} from 'sequelize-typescript';
|
} from 'sequelize-typescript';
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { AuthenticationContext, TokenResponse } from 'adal-node';
|
import { AuthenticationContext, TokenResponse } from 'adal-node';
|
||||||
import { IGBCoreService, IGBAdminService } from 'botlib';
|
import { IGBAdminService, IGBCoreService } from 'botlib';
|
||||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||||
import { GuaribasAdmin } from '../models/AdminModel';
|
import { GuaribasAdmin } from '../models/AdminModel';
|
||||||
const UrlJoin = require('url-join');
|
const UrlJoin = require('url-join');
|
||||||
|
@ -88,6 +88,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
};
|
};
|
||||||
let password = passwordGenerator.generatePassword(options);
|
let password = passwordGenerator.generatePassword(options);
|
||||||
password = password.replace(/[\@\[\=\:\;\?]/g, '#');
|
password = password.replace(/[\@\[\=\:\;\?]/g, '#');
|
||||||
|
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +103,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
maximumLength: 14
|
maximumLength: 14
|
||||||
};
|
};
|
||||||
const name = passwordGenerator.generatePassword(options);
|
const name = passwordGenerator.generatePassword(options);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
import { BotAdapter } from 'botbuilder';
|
import { BotAdapter } from 'botbuilder';
|
||||||
import { GBMinInstance } from 'botlib';
|
import { GBMinInstance } from 'botlib';
|
||||||
import { IGBDialog } from 'botlib';
|
import { IGBDialog } from 'botlib';
|
||||||
import { Messages } from '../strings';
|
|
||||||
import { WaterfallDialog } from 'botlib/node_modules/botbuilder-dialogs';
|
import { WaterfallDialog } from 'botlib/node_modules/botbuilder-dialogs';
|
||||||
|
import { Messages } from '../strings';
|
||||||
|
|
||||||
export class BotFarmDialog extends IGBDialog {
|
export class BotFarmDialog extends IGBDialog {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -136,6 +136,7 @@ export class StartDialog {
|
||||||
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`);
|
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`);
|
||||||
password = scanf('%s').replace(/(\n|\r)+$/, '');
|
password = scanf('%s').replace(/(\n|\r)+$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import { SearchManagementClient } from 'azure-arm-search';
|
||||||
import { SqlManagementClient } from 'azure-arm-sql';
|
import { SqlManagementClient } from 'azure-arm-sql';
|
||||||
import { WebSiteManagementClient } from 'azure-arm-website';
|
import { WebSiteManagementClient } from 'azure-arm-website';
|
||||||
import { AppServicePlan } from 'azure-arm-website/lib/models';
|
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 { HttpMethods, ServiceClient, WebResource } from 'ms-rest-js';
|
||||||
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
|
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
|
||||||
import { GBCorePackage } from '../../../packages/core.gbapp';
|
import { GBCorePackage } from '../../../packages/core.gbapp';
|
||||||
|
@ -77,6 +77,19 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
this.deployer = deployer;
|
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) {
|
public async getSubscriptions(credentials) {
|
||||||
const subscriptionClient = new SubscriptionClient.default(credentials);
|
const subscriptionClient = new SubscriptionClient.default(credentials);
|
||||||
|
|
||||||
|
@ -228,19 +241,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
await storageClient.firewallRules.createOrUpdate(groupName, serverName, 'gb', params);
|
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(
|
public async deployFarm(
|
||||||
proxyAddress: string,
|
proxyAddress: string,
|
||||||
instance: IGBInstance,
|
instance: IGBInstance,
|
||||||
|
@ -344,6 +344,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
);
|
);
|
||||||
|
|
||||||
spinner.stop();
|
spinner.stop();
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +386,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
this.accessToken = credentials.tokenCache._entries[0].accessToken;
|
this.accessToken = credentials.tokenCache._entries[0].accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async createStorageServer(group, name, administratorLogin, administratorPassword, serverName, location) {
|
private async createStorageServer(group, name, administratorLogin, administratorPassword, serverName, location) {
|
||||||
const params = {
|
const params = {
|
||||||
location: location,
|
location: location,
|
||||||
|
@ -471,6 +471,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
const res = await httpClient.sendRequest(req);
|
const res = await httpClient.sendRequest(req);
|
||||||
if (!(res.bodyAsJson as any).id) {
|
if (!(res.bodyAsJson as any).id) {
|
||||||
reject(res.bodyAsText);
|
reject(res.bodyAsText);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,6 +589,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
|
|
||||||
private async createDeployGroup(name, location) {
|
private async createDeployGroup(name, location) {
|
||||||
const params = { location: location };
|
const params = { location: location };
|
||||||
|
|
||||||
return this.resourceClient.resourceGroups.createOrUpdate(name, params);
|
return this.resourceClient.resourceGroups.createOrUpdate(name, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,6 +612,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
location: location,
|
location: location,
|
||||||
serverFarmId: farmId
|
serverFarmId: farmId
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.webSiteClient.webApps.createOrUpdate(group, name, parameters);
|
return this.webSiteClient.webApps.createOrUpdate(group, name, parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import { Sequelize } from 'sequelize-typescript';
|
||||||
import { ConsoleDirectLine } from './services/ConsoleDirectLine';
|
import { ConsoleDirectLine } from './services/ConsoleDirectLine';
|
||||||
|
|
||||||
export class GBConsolePackage implements IGBPackage {
|
export class GBConsolePackage implements IGBPackage {
|
||||||
|
|
||||||
public sysPackages: IGBPackage[] = undefined;
|
public sysPackages: IGBPackage[] = undefined;
|
||||||
public channel: ConsoleDirectLine;
|
public channel: ConsoleDirectLine;
|
||||||
public getDialogs(min: GBMinInstance) {}
|
public getDialogs(min: GBMinInstance) {}
|
||||||
|
|
|
@ -64,6 +64,7 @@ export class ConsoleDirectLine extends GBService {
|
||||||
.then(function (client) {
|
.then(function (client) {
|
||||||
client.clientAuthorizations.add('AuthorizationBotConnector',
|
client.clientAuthorizations.add('AuthorizationBotConnector',
|
||||||
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header'));
|
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header'));
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
|
@ -129,7 +130,7 @@ export class ConsoleDirectLine extends GBService {
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark })
|
client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark })
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages
|
watermark = response.obj.watermark;
|
||||||
return response.obj.activities;
|
return response.obj.activities;
|
||||||
})
|
})
|
||||||
.then(_this_.printMessages, _this_.directLineClientName);
|
.then(_this_.printMessages, _this_.directLineClientName);
|
||||||
|
|
|
@ -54,7 +54,7 @@ import { IGBInstance } from 'botlib';
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasInstance extends Model<GuaribasInstance>
|
export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
implements IGBInstance {
|
implements IGBInstance {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
|
|
|
@ -112,6 +112,7 @@ export class GBConfigService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +121,7 @@ export class GBConfigService {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
value = process.env[key];
|
value = process.env[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,10 +420,12 @@ STORAGE_SYNC=true
|
||||||
fkname += '_' + matches[1];
|
fkname += '_' + matches[1];
|
||||||
matches = re4.exec(fkcols);
|
matches = re4.exec(fkcols);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
return 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,10 +455,12 @@ STORAGE_SYNC=true
|
||||||
fkname += '_' + matches[1];
|
fkname += '_' + matches[1];
|
||||||
matches = re3.exec(fkcols);
|
matches = re3.exec(fkcols);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (args[0] ? args[0] : '') + 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
return (args[0] ? args[0] : '') + 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ export class GBDeployer {
|
||||||
// PACKAGE: Put in package logic.
|
// PACKAGE: Put in package logic.
|
||||||
case '.gbkb':
|
case '.gbkb':
|
||||||
const service = new KBService(this.core.sequelize);
|
const service = new KBService(this.core.sequelize);
|
||||||
|
|
||||||
return service.deployKb(this.core, this, localPath);
|
return service.deployKb(this.core, this, localPath);
|
||||||
|
|
||||||
case '.gbui':
|
case '.gbui':
|
||||||
|
@ -231,6 +232,7 @@ export class GBDeployer {
|
||||||
|
|
||||||
case '.gbdialog':
|
case '.gbdialog':
|
||||||
const vm = new GBVMService();
|
const vm = new GBVMService();
|
||||||
|
|
||||||
return vm.loadDialogPackage(localPath, min, this.core, this);
|
return vm.loadDialogPackage(localPath, min, this.core, this);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -257,6 +259,7 @@ export class GBDeployer {
|
||||||
|
|
||||||
case '.gbkb':
|
case '.gbkb':
|
||||||
const service = new KBService(this.core.sequelize);
|
const service = new KBService(this.core.sequelize);
|
||||||
|
|
||||||
return service.undeployKbFromStorage(instance, this, p.packageId);
|
return service.undeployKbFromStorage(instance, this, p.packageId);
|
||||||
|
|
||||||
case '.gbui':
|
case '.gbui':
|
||||||
|
@ -307,6 +310,7 @@ export class GBDeployer {
|
||||||
|
|
||||||
public async getPackageByName(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
public async getPackageByName(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
||||||
const where = { packageName: packageName, instanceId: instanceId };
|
const where = { packageName: packageName, instanceId: instanceId };
|
||||||
|
|
||||||
return GuaribasPackage.findOne({
|
return GuaribasPackage.findOne({
|
||||||
where: where
|
where: where
|
||||||
});
|
});
|
||||||
|
@ -436,6 +440,7 @@ export class GBDeployer {
|
||||||
appPackagesProcessed++;
|
appPackagesProcessed++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return appPackagesProcessed;
|
return appPackagesProcessed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ export class GBImporter {
|
||||||
|
|
||||||
packageJson = { ...packageJson, ...settings, ...servicesJson };
|
packageJson = { ...packageJson, ...settings, ...servicesJson };
|
||||||
|
|
||||||
if (botId){
|
if (botId) {
|
||||||
packageJson.botId = botId;
|
packageJson.botId = botId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ const AuthenticationContext = require('adal-node').AuthenticationContext;
|
||||||
import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder';
|
import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder';
|
||||||
|
|
||||||
import { ConfirmPrompt, WaterfallDialog } from 'botbuilder-dialogs';
|
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 { GBAnalyticsPackage } from '../../analytics.gblib';
|
||||||
import { GBCorePackage } from '../../core.gbapp';
|
import { GBCorePackage } from '../../core.gbapp';
|
||||||
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp';
|
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp';
|
||||||
|
@ -266,11 +266,13 @@ export class GBMinService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const json = await request(options);
|
const json = await request(options);
|
||||||
|
|
||||||
return Promise.resolve(JSON.parse(json));
|
return Promise.resolve(JSON.parse(json));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg = `[botId:${
|
const msg = `[botId:${
|
||||||
instance.botId
|
instance.botId
|
||||||
}] Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`;
|
}] Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`;
|
||||||
|
|
||||||
return Promise.reject(new Error(msg));
|
return Promise.reject(new Error(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,6 +298,7 @@ export class GBMinService {
|
||||||
return await request(options);
|
return await request(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg = `Error calling Speech to Text client. Error is: ${error}.`;
|
const msg = `Error calling Speech to Text client. Error is: ${error}.`;
|
||||||
|
|
||||||
return Promise.reject(new Error(msg));
|
return Promise.reject(new Error(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,21 +354,21 @@ export class GBMinService {
|
||||||
if (sysPackage.name === 'GBWhatsappPackage') {
|
if (sysPackage.name === 'GBWhatsappPackage') {
|
||||||
const url = '/instances/:botId/whatsapp';
|
const url = '/instances/:botId/whatsapp';
|
||||||
server.post(url, (req, res) => {
|
server.post(url, (req, res) => {
|
||||||
p['channel'].received(req, res);
|
p.channel.received(req, res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
appPackages.forEach(p => {
|
appPackages.forEach(p => {
|
||||||
p.sysPackages = sysPackages;
|
p.sysPackages = sysPackages;
|
||||||
p.loadBot(min);
|
p.loadBot(min);
|
||||||
if (p.getDialogs !== undefined) {
|
if (p.getDialogs !== undefined) {
|
||||||
let dialogs = p.getDialogs(min);
|
const dialogs = p.getDialogs(min);
|
||||||
dialogs.forEach(dialog => {
|
dialogs.forEach(dialog => {
|
||||||
min.dialogs.add(new WaterfallDialog(dialog.name, dialog.waterfall));
|
min.dialogs.add(new WaterfallDialog(dialog.name, dialog.waterfall));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,10 +479,10 @@ export class GBMinService {
|
||||||
private async processMessageActivity(context, min: GBMinInstance, step: any) {
|
private async processMessageActivity(context, min: GBMinInstance, step: any) {
|
||||||
// Direct script invoking by itent name.
|
// 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) {
|
if (isVMCall) {
|
||||||
let mainMethod = context.activity.text;
|
const mainMethod = context.activity.text;
|
||||||
|
|
||||||
min.sandBoxMap[mainMethod].context = context;
|
min.sandBoxMap[mainMethod].context = context;
|
||||||
min.sandBoxMap[mainMethod].step = step;
|
min.sandBoxMap[mainMethod].step = step;
|
||||||
|
|
|
@ -33,19 +33,19 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { GBMinInstance, IGBCoreService, GBService } from 'botlib';
|
import { GBMinInstance, GBService, IGBCoreService } from 'botlib';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import GBAPIService from './GBAPIService';
|
||||||
|
import GBAPIService from './GBAPIService';
|
||||||
import { GBDeployer } from './GBDeployer';
|
import { GBDeployer } from './GBDeployer';
|
||||||
import { TSCompiler } from './TSCompiler';
|
import { TSCompiler } from './TSCompiler';
|
||||||
import GBAPIService from './GBAPIService';
|
|
||||||
import DialogClass from './GBAPIService';
|
|
||||||
|
|
||||||
const walkPromise = require('walk-promise');
|
const walkPromise = require('walk-promise');
|
||||||
const logger = require('../../../src/logger');
|
const logger = require('../../../src/logger');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
const UrlJoin = require('url-join');
|
const UrlJoin = require('url-join');
|
||||||
const vb2ts = require('vbscript-to-typescript/dist/converter');
|
const vb2ts = require('vbscript-to-typescript/dist/converter');
|
||||||
let beautify = require('js-beautify').js;
|
const beautify = require('js-beautify').js;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview Virtualization services for emulation of BASIC.
|
* @fileoverview Virtualization services for emulation of BASIC.
|
||||||
|
@ -250,7 +250,7 @@ export class GBVMService extends GBService {
|
||||||
min.dialogs.add(
|
min.dialogs.add(
|
||||||
new WaterfallDialog('/hear', [
|
new WaterfallDialog('/hear', [
|
||||||
async step => {
|
async step => {
|
||||||
step.activeDialog.state.cbId = step.options['id'];
|
step.activeDialog.state.cbId = step.options.id;
|
||||||
|
|
||||||
return await step.prompt('textPrompt', {});
|
return await step.prompt('textPrompt', {});
|
||||||
},
|
},
|
||||||
|
|
|
@ -41,7 +41,6 @@ const logger = require('../../../src/logger');
|
||||||
|
|
||||||
export class TSCompiler {
|
export class TSCompiler {
|
||||||
|
|
||||||
|
|
||||||
private static shouldIgnoreError(diagnostic) {
|
private static shouldIgnoreError(diagnostic) {
|
||||||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ describe('Load function', () => {
|
||||||
try {
|
try {
|
||||||
// const service = new GBVMService();
|
// const service = new GBVMService();
|
||||||
// TODO: service.loadJS('invalid.file', null, null, null, null);
|
// TODO: service.loadJS('invalid.file', null, null, null, null);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.equal(0);
|
expect(error).to.equal(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
new WaterfallDialog('/feedbackNumber', [
|
new WaterfallDialog('/feedbackNumber', [
|
||||||
async step => {
|
async step => {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
|
||||||
// TODO: Migrate to 4.*+ await step.prompt("choicePrompt", Messages[locale].what_about_me, [
|
// TODO: Migrate to 4.*+ await step.prompt("choicePrompt", Messages[locale].what_about_me, [
|
||||||
// "1",
|
// "1",
|
||||||
// "2",
|
// "2",
|
||||||
|
@ -73,6 +74,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
const user = await min.userProfile.get(context, {});
|
const user = await min.userProfile.get(context, {});
|
||||||
await service.updateConversationRate(user.conversation, rate);
|
await service.updateConversationRate(user.conversation, rate);
|
||||||
await step.context.sendActivity(Messages[locale].thanks);
|
await step.context.sendActivity(Messages[locale].thanks);
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
@ -84,7 +86,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
|
||||||
await step.context.sendActivity(Messages[locale].about_suggestions);
|
await step.context.sendActivity(Messages[locale].about_suggestions);
|
||||||
step.activeDialog.state.cbId = step.options['id'];
|
step.activeDialog.state.cbId = step.options.id;
|
||||||
|
|
||||||
return await step.prompt('textPrompt', Messages[locale].what_about_service);
|
return await step.prompt('textPrompt', Messages[locale].what_about_service);
|
||||||
},
|
},
|
||||||
|
@ -93,8 +95,8 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
const rate = await AzureText.getSentiment(
|
const rate = await AzureText.getSentiment(
|
||||||
min.instance.textAnalyticsKey,
|
min.instance.textAnalyticsKey,
|
||||||
min.instance.textAnalyticsEndpoint,
|
min.instance.textAnalyticsEndpoint,
|
||||||
min.conversationalService.getCurrentLanguage(step),
|
min.conversationalService.getCurrentLanguage(step),
|
||||||
step.result
|
step.result
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -105,6 +107,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
|
|
||||||
// TODO: Record.
|
// TODO: Record.
|
||||||
}
|
}
|
||||||
|
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ export class QualityDialog extends IGBDialog {
|
||||||
);
|
);
|
||||||
await step.replaceDialog('/ask', { isReturning: true });
|
await step.replaceDialog('/ask', { isReturning: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -62,6 +62,7 @@ export class CSService {
|
||||||
rate: number
|
rate: number
|
||||||
): Promise<GuaribasConversation> {
|
): Promise<GuaribasConversation> {
|
||||||
conversation.rate = rate;
|
conversation.rate = rate;
|
||||||
|
|
||||||
return conversation.save();
|
return conversation.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ export class AskDialog extends IGBDialog {
|
||||||
min.dialogs.add(
|
min.dialogs.add(
|
||||||
new WaterfallDialog('/answerEvent', [
|
new WaterfallDialog('/answerEvent', [
|
||||||
async step => {
|
async step => {
|
||||||
if (step.options && step.options['questionId']) {
|
if (step.options && step.options.questionId) {
|
||||||
const question = await service.getQuestionById(min.instance.instanceId, step.options['questionId']);
|
const question = await service.getQuestionById(min.instance.instanceId, step.options.questionId);
|
||||||
const answer = await service.getAnswerById(min.instance.instanceId, question.answerId);
|
const answer = await service.getAnswerById(min.instance.instanceId, question.answerId);
|
||||||
|
|
||||||
// Sends the answer to all outputs, including projector.
|
// Sends the answer to all outputs, including projector.
|
||||||
|
@ -69,6 +69,7 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
await step.replaceDialog('/ask', { isReturning: true });
|
await step.replaceDialog('/ask', { isReturning: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
@ -78,7 +79,7 @@ export class AskDialog extends IGBDialog {
|
||||||
new WaterfallDialog('/answer', [
|
new WaterfallDialog('/answer', [
|
||||||
async step => {
|
async step => {
|
||||||
const user = await min.userProfile.get(step.context, {});
|
const user = await min.userProfile.get(step.context, {});
|
||||||
let text = step.options['query'];
|
let text = step.options.query;
|
||||||
if (!text) {
|
if (!text) {
|
||||||
throw new Error(`/answer being called with no args query text.`);
|
throw new Error(`/answer being called with no args query text.`);
|
||||||
}
|
}
|
||||||
|
@ -91,9 +92,9 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// Handle extra text from FAQ.
|
// Handle extra text from FAQ.
|
||||||
|
|
||||||
if (step.options && step.options['query']) {
|
if (step.options && step.options.query) {
|
||||||
text = step.options['query'];
|
text = step.options.query;
|
||||||
} else if (step.options && step.options['fromFaq']) {
|
} else if (step.options && step.options.fromFaq) {
|
||||||
await step.context.sendActivity(Messages[locale].going_answer);
|
await step.context.sendActivity(Messages[locale].going_answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +156,12 @@ export class AskDialog extends IGBDialog {
|
||||||
// Sends the answer to all outputs, including projector.
|
// Sends the answer to all outputs, including projector.
|
||||||
|
|
||||||
await service.sendAnswer(min.conversationalService, step, resultsB.answer);
|
await service.sendAnswer(min.conversationalService, step, resultsB.answer);
|
||||||
|
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
} else {
|
} else {
|
||||||
if (!(await min.conversationalService.routeNLP(step, min, text))) {
|
if (!(await min.conversationalService.routeNLP(step, min, text))) {
|
||||||
await step.context.sendActivity(Messages[locale].did_not_find);
|
await step.context.sendActivity(Messages[locale].did_not_find);
|
||||||
|
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,9 +183,9 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// Three forms of asking.
|
// Three forms of asking.
|
||||||
|
|
||||||
if (step.options && step.options['firstTime']) {
|
if (step.options && step.options.firstTime) {
|
||||||
text = Messages[locale].ask_first_time;
|
text = Messages[locale].ask_first_time;
|
||||||
} else if (step.options && step.options['isReturning']) {
|
} else if (step.options && step.options.isReturning) {
|
||||||
text = Messages[locale].anything_else;
|
text = Messages[locale].anything_else;
|
||||||
} else if (user.subjects.length > 0) {
|
} else if (user.subjects.length > 0) {
|
||||||
text = Messages[locale].which_question;
|
text = Messages[locale].which_question;
|
||||||
|
@ -193,6 +196,7 @@ export class AskDialog extends IGBDialog {
|
||||||
if (text.length > 0) {
|
if (text.length > 0) {
|
||||||
return await step.prompt('textPrompt', text);
|
return await step.prompt('textPrompt', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
|
@ -205,6 +209,5 @@ export class AskDialog extends IGBDialog {
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ export class FaqDialog extends IGBDialog {
|
||||||
data: data.slice(0, 10)
|
data: data.slice(0, 10)
|
||||||
});
|
});
|
||||||
|
|
||||||
await step.context.sendActivity(Messages[locale].see_faq); // TODO: RND messages.
|
await step.context.sendActivity(Messages[locale].see_faq);
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ export class MenuDialog extends IGBDialog {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
let rootSubjectId = null;
|
let rootSubjectId = null;
|
||||||
|
|
||||||
if (step.options && step.options['data']) {
|
if (step.options && step.options.data) {
|
||||||
const subject = step.options['data'];
|
const subject = step.options.data;
|
||||||
|
|
||||||
// If there is a shortcut specified as subject destination, go there.
|
// If there is a shortcut specified as subject destination, go there.
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
const dialog = subject.to.split(':')[1];
|
const dialog = subject.to.split(':')[1];
|
||||||
await step.replaceDialog('/' + dialog);
|
await step.replaceDialog('/' + dialog);
|
||||||
await step.endDialog();
|
await step.endDialog();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +157,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
|
|
||||||
const user = await min.userProfile.get(step.context, {});
|
const user = await min.userProfile.get(step.context, {});
|
||||||
user.isAsking = true;
|
user.isAsking = true;
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -49,11 +49,11 @@ import { Messages } from '../strings';
|
||||||
import { IGBConversationalService, IGBCoreService, IGBInstance } from 'botlib';
|
import { IGBConversationalService, IGBCoreService, IGBInstance } from 'botlib';
|
||||||
import { AzureSearch } from 'pragmatismo-io-framework';
|
import { AzureSearch } from 'pragmatismo-io-framework';
|
||||||
import { Sequelize } from 'sequelize-typescript';
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||||
import { GuaribasPackage } from '../../core.gbapp/models/GBModel';
|
import { GuaribasPackage } from '../../core.gbapp/models/GBModel';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models';
|
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models';
|
||||||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
||||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
|
||||||
|
|
||||||
export class KBServiceSearchResults {
|
export class KBServiceSearchResults {
|
||||||
public answer: GuaribasAnswer;
|
public answer: GuaribasAnswer;
|
||||||
|
@ -433,6 +433,7 @@ export class KBService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return doIt(subjects.children, null);
|
return doIt(subjects.children, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,9 @@ import { WhatsappDirectLine } from './services/WhatsappDirectLine';
|
||||||
|
|
||||||
export class GBWhatsappPackage implements IGBPackage {
|
export class GBWhatsappPackage implements IGBPackage {
|
||||||
public sysPackages: IGBPackage[] = undefined;
|
public sysPackages: IGBPackage[] = undefined;
|
||||||
public getDialogs(min: GBMinInstance) {}
|
|
||||||
|
|
||||||
public channel: WhatsappDirectLine;
|
public channel: WhatsappDirectLine;
|
||||||
|
public getDialogs(min: GBMinInstance) {}
|
||||||
|
|
||||||
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
|
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
|
||||||
|
|
||||||
|
|
|
@ -142,12 +142,13 @@ export class WhatsappDirectLine extends GBService {
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.watermark = response.obj.watermark;
|
this.watermark = response.obj.watermark;
|
||||||
|
|
||||||
return response.obj.activities;
|
return response.obj.activities;
|
||||||
})
|
})
|
||||||
.then(activities => {
|
.then(activities => {
|
||||||
this.printMessages(activities, conversationId, from, fromName);
|
this.printMessages(activities, conversationId, from, fromName);
|
||||||
});
|
});
|
||||||
}, this.pollInterval);
|
}, this.pollInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public printMessages(activities, conversationId, from, fromName) {
|
public printMessages(activities, conversationId, from, fromName) {
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
const logger = require('./logger');
|
const logger = require('./logger');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
import { IGBInstance, IGBPackage, IGBCoreService } from 'botlib';
|
import { IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
|
||||||
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
|
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
|
||||||
import { AzureDeployerService } from '../packages/azuredeployer.gbapp/services/AzureDeployerService';
|
import { AzureDeployerService } from '../packages/azuredeployer.gbapp/services/AzureDeployerService';
|
||||||
import { GuaribasInstance } from '../packages/core.gbapp/models/GBModel';
|
import { GuaribasInstance } from '../packages/core.gbapp/models/GBModel';
|
||||||
|
|
Loading…
Add table
Reference in a new issue