fix(core.gbapp): Check of previous bot name before creation.

This commit is contained in:
Rodrigo Rodriguez 2020-06-11 09:47:59 -03:00
parent 6306274db9
commit 0d3bea80e0
8 changed files with 39 additions and 29 deletions

1
.gitignore vendored
View file

@ -21,3 +21,4 @@
.env .env
teste.sql teste.sql
poc/ poc/
*.env

25
package-lock.json generated
View file

@ -53,9 +53,9 @@
} }
}, },
"@azure/cosmos": { "@azure/cosmos": {
"version": "3.6.3", "version": "3.7.0",
"resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.6.3.tgz", "resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.7.0.tgz",
"integrity": "sha512-JoCDxl0TnL6EHL4xD3KC9r2bMivK13q1jl7h69wd/YFLlt3aBTTCehtAX+y4alNSENpL53XdRdw/cna0mI2XDw==", "integrity": "sha512-3SRxnmy6NncdX5eYqGuRTack52hloS9YhQ0aOKwWJ8Z4dDSrVH3XB2Mcp/WokoIpVm0Bq5nUC8FsvLBZKfRkyg==",
"requires": { "requires": {
"@types/debug": "^4.1.4", "@types/debug": "^4.1.4",
"debug": "^4.1.1", "debug": "^4.1.1",
@ -66,13 +66,18 @@
"priorityqueuejs": "^1.0.0", "priorityqueuejs": "^1.0.0",
"semaphore": "^1.0.5", "semaphore": "^1.0.5",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"uuid": "^3.3.2" "uuid": "^8.1.0"
}, },
"dependencies": { "dependencies": {
"tslib": { "tslib": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
},
"uuid": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",
"integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg=="
} }
} }
}, },
@ -3141,9 +3146,9 @@
}, },
"dependencies": { "dependencies": {
"@types/node": { "@types/node": {
"version": "10.17.24", "version": "10.17.26",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.24.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.26.tgz",
"integrity": "sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA==" "integrity": "sha512-myMwkO2Cr82kirHY8uknNRHEVtn0wV3DTQfkrjx17jmkstDRZ24gNUdl8AHXVyVclTYI/bNjgTPTAWvWLqXqkw=="
} }
} }
}, },
@ -3273,9 +3278,9 @@
} }
}, },
"botlib": { "botlib": {
"version": "1.5.5", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.5.tgz", "resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.6.tgz",
"integrity": "sha512-fugvHvp0XDqAflOFxbLknC49ijDL0P0c8DDztLSj2sUfwoJ6J2YqVIU8kkVW1OdjNGvXCNUjiZS6ZHEuHaGdMQ==", "integrity": "sha512-wcTe6xoJ+NK5RUE6CoEMnnrKs/09IdCmRNRJmeiDPWU/bmL2JgMoeY4/owDFstEflV+uffZmNliT6cMvnAqWeA==",
"requires": { "requires": {
"async": "3.1.0", "async": "3.1.0",
"botbuilder": "4.7.0", "botbuilder": "4.7.0",

View file

@ -66,7 +66,7 @@
"botbuilder-ai": "4.7.0", "botbuilder-ai": "4.7.0",
"botbuilder-dialogs": "4.7.0", "botbuilder-dialogs": "4.7.0",
"botframework-connector": "4.7.0", "botframework-connector": "4.7.0",
"botlib": "1.5.6", "botlib": "1.5.7",
"cli-spinner": "0.2.10", "cli-spinner": "0.2.10",
"dotenv-extended": "2.7.1", "dotenv-extended": "2.7.1",
"exceljs": "3.5.0", "exceljs": "3.5.0",

View file

@ -219,7 +219,8 @@ export class AzureDeployerService implements IGBInstallationDeployer {
}; };
} }
public async botExists(botId, group) { public async botExists(botId) {
const group = GBConfigService.get('CLOUD_GROUP');
const baseUrl = `https://management.azure.com/`; const baseUrl = `https://management.azure.com/`;
const username = GBConfigService.get('CLOUD_USERNAME'); const username = GBConfigService.get('CLOUD_USERNAME');
const password = GBConfigService.get('CLOUD_PASSWORD'); const password = GBConfigService.get('CLOUD_PASSWORD');

View file

@ -174,9 +174,9 @@ export class GBDeployer implements IGBDeployer {
return await this.deployBotFull(instance, GBServer.globals.publicAddress); return await this.deployBotFull(instance, GBServer.globals.publicAddress);
} }
public async botExists(instance: IGBInstance, group, publicAddress: string): Promise<boolean> { public async botExists(botId: string): Promise<boolean> {
const service = new AzureDeployerService(this); const service = new AzureDeployerService(this);
return await service.botExists(instance.botId, group); return await service.botExists(botId);
} }
/** /**
* Deploys a bot to the storage. * Deploys a bot to the storage.
@ -191,7 +191,7 @@ export class GBDeployer implements IGBDeployer {
const group = GBConfigService.get('CLOUD_GROUP'); const group = GBConfigService.get('CLOUD_GROUP');
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID'); const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
if (await service.botExists(instance.botId, group)) { if (await service.botExists(instance.botId)) {
await service.updateBot( await service.updateBot(
instance.botId, instance.botId,
group, group,
@ -312,7 +312,7 @@ export class GBDeployer implements IGBDeployer {
const group = GBConfigService.get('CLOUD_GROUP'); const group = GBConfigService.get('CLOUD_GROUP');
if (await service.botExists(botId, group)) { if (await service.botExists(botId)) {
await service.deleteBot( await service.deleteBot(
botId, group botId, group
@ -408,7 +408,7 @@ export class GBDeployer implements IGBDeployer {
return await service.undeployKbFromStorage(instance, this, p.packageId); return await service.undeployKbFromStorage(instance, this, p.packageId);
case '.gbui': case '.gbui':
break; break;
case '.gbtheme': case '.gbtheme':

View file

@ -480,16 +480,19 @@ export class GBMinService {
} }
else { else {
const minBoot = GBServer.globals.minBoot as any; const minBoot = GBServer.globals.minBoot as any;
min.whatsAppDirectLine = if (minBoot.instance.whatsappServiceKey) {
new WhatsappDirectLine(
min, min.whatsAppDirectLine =
min.botId, new WhatsappDirectLine(
min.instance.webchatKey, min,
minBoot.instance.whatsappServiceKey, min.botId,
minBoot.instance.whatsappServiceNumber, min.instance.webchatKey,
minBoot.instance.whatsappServiceUrl minBoot.instance.whatsappServiceKey,
); minBoot.instance.whatsappServiceNumber,
await min.whatsAppDirectLine.setup(false); minBoot.instance.whatsappServiceUrl
);
await min.whatsAppDirectLine.setup(false);
}
} }
min.userProfile = conversationState.createProperty('userProfile'); min.userProfile = conversationState.createProperty('userProfile');

View file

@ -218,7 +218,7 @@ export class GBVMService extends GBService {
// Convert TS into JS. // Convert TS into JS.
const tsfile: string = `${filename}.ts`; const tsfile: string = `${filename}.ts`;
let tsCode: string = fs.readFileSync(tsfile, 'utf8'); let tsCode: string = fs.readFileSync(tsfile, 'utf8');
tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve = undefined;`); tsCode = tsCode.replace(/export.*\n/gi, `export function ${mainName}(step:any) { let resolve;`);
fs.writeFileSync(tsfile, tsCode); fs.writeFileSync(tsfile, tsCode);
const tsc = new TSCompiler(); const tsc = new TSCompiler();

View file

@ -244,7 +244,7 @@ export class WhatsappDirectLine extends GBService {
} }
else { else {
GBLog.info(`USER (${id}) TO AGENT ${user.userSystemId}: ${text}`); GBLog.info(`USER (${id}) TO AGENT ${user.userSystemId}: ${text}`);
this.sendToDeviceEx(user.agentSystemId, `${id}: ${text}`, locale); this.sendToDeviceEx(user.agentSystemId, `Bot: ${this.min.instance.botId}\n${id}: ${text}`, locale);
} }
} }