From 0d3bea80e0b9cd6877599b008430f859d751d3e1 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Thu, 11 Jun 2020 09:47:59 -0300 Subject: [PATCH] fix(core.gbapp): Check of previous bot name before creation. --- .gitignore | 1 + package-lock.json | 25 +++++++++++-------- package.json | 2 +- .../services/AzureDeployerService.ts | 3 ++- packages/core.gbapp/services/GBDeployer.ts | 10 ++++---- packages/core.gbapp/services/GBMinService.ts | 23 +++++++++-------- packages/core.gbapp/services/GBVMService.ts | 2 +- .../services/WhatsappDirectLine.ts | 2 +- 8 files changed, 39 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index cc7b6d0f..d8db0220 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ .env teste.sql poc/ +*.env \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d467a2f4..2770b961 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,9 +53,9 @@ } }, "@azure/cosmos": { - "version": "3.6.3", - "resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.6.3.tgz", - "integrity": "sha512-JoCDxl0TnL6EHL4xD3KC9r2bMivK13q1jl7h69wd/YFLlt3aBTTCehtAX+y4alNSENpL53XdRdw/cna0mI2XDw==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-3.7.0.tgz", + "integrity": "sha512-3SRxnmy6NncdX5eYqGuRTack52hloS9YhQ0aOKwWJ8Z4dDSrVH3XB2Mcp/WokoIpVm0Bq5nUC8FsvLBZKfRkyg==", "requires": { "@types/debug": "^4.1.4", "debug": "^4.1.1", @@ -66,13 +66,18 @@ "priorityqueuejs": "^1.0.0", "semaphore": "^1.0.5", "tslib": "^1.10.0", - "uuid": "^3.3.2" + "uuid": "^8.1.0" }, "dependencies": { "tslib": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", "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": { "@types/node": { - "version": "10.17.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.24.tgz", - "integrity": "sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA==" + "version": "10.17.26", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.26.tgz", + "integrity": "sha512-myMwkO2Cr82kirHY8uknNRHEVtn0wV3DTQfkrjx17jmkstDRZ24gNUdl8AHXVyVclTYI/bNjgTPTAWvWLqXqkw==" } } }, @@ -3273,9 +3278,9 @@ } }, "botlib": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.5.tgz", - "integrity": "sha512-fugvHvp0XDqAflOFxbLknC49ijDL0P0c8DDztLSj2sUfwoJ6J2YqVIU8kkVW1OdjNGvXCNUjiZS6ZHEuHaGdMQ==", + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.6.tgz", + "integrity": "sha512-wcTe6xoJ+NK5RUE6CoEMnnrKs/09IdCmRNRJmeiDPWU/bmL2JgMoeY4/owDFstEflV+uffZmNliT6cMvnAqWeA==", "requires": { "async": "3.1.0", "botbuilder": "4.7.0", diff --git a/package.json b/package.json index 6e010b7d..065d0c88 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "botbuilder-ai": "4.7.0", "botbuilder-dialogs": "4.7.0", "botframework-connector": "4.7.0", - "botlib": "1.5.6", + "botlib": "1.5.7", "cli-spinner": "0.2.10", "dotenv-extended": "2.7.1", "exceljs": "3.5.0", diff --git a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts index f51b6485..df3729f0 100644 --- a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts +++ b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts @@ -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 username = GBConfigService.get('CLOUD_USERNAME'); const password = GBConfigService.get('CLOUD_PASSWORD'); diff --git a/packages/core.gbapp/services/GBDeployer.ts b/packages/core.gbapp/services/GBDeployer.ts index fbbff17c..af09eb3e 100644 --- a/packages/core.gbapp/services/GBDeployer.ts +++ b/packages/core.gbapp/services/GBDeployer.ts @@ -174,9 +174,9 @@ export class GBDeployer implements IGBDeployer { return await this.deployBotFull(instance, GBServer.globals.publicAddress); } - public async botExists(instance: IGBInstance, group, publicAddress: string): Promise { + public async botExists(botId: string): Promise { const service = new AzureDeployerService(this); - return await service.botExists(instance.botId, group); + return await service.botExists(botId); } /** * Deploys a bot to the storage. @@ -191,7 +191,7 @@ export class GBDeployer implements IGBDeployer { const group = GBConfigService.get('CLOUD_GROUP'); const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID'); - if (await service.botExists(instance.botId, group)) { + if (await service.botExists(instance.botId)) { await service.updateBot( instance.botId, group, @@ -312,7 +312,7 @@ export class GBDeployer implements IGBDeployer { const group = GBConfigService.get('CLOUD_GROUP'); - if (await service.botExists(botId, group)) { + if (await service.botExists(botId)) { await service.deleteBot( botId, group @@ -408,7 +408,7 @@ export class GBDeployer implements IGBDeployer { return await service.undeployKbFromStorage(instance, this, p.packageId); case '.gbui': - + break; case '.gbtheme': diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index 2f882502..f7b3abe8 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -480,16 +480,19 @@ export class GBMinService { } else { const minBoot = GBServer.globals.minBoot as any; - min.whatsAppDirectLine = - new WhatsappDirectLine( - min, - min.botId, - min.instance.webchatKey, - minBoot.instance.whatsappServiceKey, - minBoot.instance.whatsappServiceNumber, - minBoot.instance.whatsappServiceUrl - ); - await min.whatsAppDirectLine.setup(false); + if (minBoot.instance.whatsappServiceKey) { + + min.whatsAppDirectLine = + new WhatsappDirectLine( + min, + min.botId, + min.instance.webchatKey, + minBoot.instance.whatsappServiceKey, + minBoot.instance.whatsappServiceNumber, + minBoot.instance.whatsappServiceUrl + ); + await min.whatsAppDirectLine.setup(false); + } } min.userProfile = conversationState.createProperty('userProfile'); diff --git a/packages/core.gbapp/services/GBVMService.ts b/packages/core.gbapp/services/GBVMService.ts index c8cedaf0..1a67916c 100644 --- a/packages/core.gbapp/services/GBVMService.ts +++ b/packages/core.gbapp/services/GBVMService.ts @@ -218,7 +218,7 @@ export class GBVMService extends GBService { // Convert TS into JS. const tsfile: string = `${filename}.ts`; 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); const tsc = new TSCompiler(); diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 140153bb..4665aea6 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -244,7 +244,7 @@ export class WhatsappDirectLine extends GBService { } else { 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); } }