diff --git a/DATABASE-CHANGES.md b/DATABASE-CHANGES.md index 7c6374f4..de73683b 100644 --- a/DATABASE-CHANGES.md +++ b/DATABASE-CHANGES.md @@ -17,4 +17,16 @@ GO ALTER TABLE [dbo].[GuaribasUser] DROP COLUMN [currentBotId] GO +``` + + +# 1.7.7 +``` SQL +ALTER TABLE [dbo].[GuaribasInstance] DROP COLUMN [authenticatorClientId] +GO + +ALTER TABLE [dbo].[GuaribasInstance] DROP COLUMN [authenticatorClientSecret] +GO + + ``` \ No newline at end of file diff --git a/package.json b/package.json index 2d1f0236..d7066397 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.0", + "botlib": "1.5.1", "chai": "4.2.0", "cli-spinner": "0.2.10", "csv-parse": "4.8.3", diff --git a/packages/admin.gbapp/dialogs/AdminDialog.ts b/packages/admin.gbapp/dialogs/AdminDialog.ts index f4c3bf5c..c6167343 100644 --- a/packages/admin.gbapp/dialogs/AdminDialog.ts +++ b/packages/admin.gbapp/dialogs/AdminDialog.ts @@ -222,27 +222,11 @@ export class AdminDialog extends IGBDialog { }, async step => { step.activeDialog.state.authenticatorAuthorityHostUrl = step.result; - const locale = step.context.activity.locale; - const prompt = Messages[locale].enter_authenticator_client_id; - - return await step.prompt('textPrompt', prompt); - }, - async step => { - step.activeDialog.state.authenticatorClientId = step.result; - const locale = step.context.activity.locale; - const prompt = Messages[locale].enter_authenticator_client_secret; - - return await step.prompt('textPrompt', prompt); - }, - async step => { - step.activeDialog.state.authenticatorClientSecret = step.result; await min.adminService.updateSecurityInfo( min.instance.instanceId, step.activeDialog.state.authenticatorTenant, - step.activeDialog.state.authenticatorAuthorityHostUrl, - step.activeDialog.state.authenticatorClientId, - step.activeDialog.state.authenticatorClientSecret + step.activeDialog.state.authenticatorAuthorityHostUrl ); const locale = step.context.activity.locale; @@ -253,7 +237,7 @@ export class AdminDialog extends IGBDialog { const url = `https://login.microsoftonline.com/${ min.instance.authenticatorTenant - }/oauth2/authorize?client_id=${min.instance.authenticatorClientId}&response_type=code&redirect_uri=${urlJoin( + }/oauth2/authorize?client_id=${min.instance.marketplaceId}&response_type=code&redirect_uri=${urlJoin( min.instance.botEndpoint, min.instance.botId, '/token' diff --git a/packages/admin.gbapp/services/GBAdminService.ts b/packages/admin.gbapp/services/GBAdminService.ts index e89c06c9..01f94704 100644 --- a/packages/admin.gbapp/services/GBAdminService.ts +++ b/packages/admin.gbapp/services/GBAdminService.ts @@ -133,17 +133,13 @@ export class GBAdminService implements IGBAdminService { public async updateSecurityInfo( instanceId: number, authenticatorTenant: string, - authenticatorAuthorityHostUrl: string, - authenticatorClientId: string, - authenticatorClientSecret: string + authenticatorAuthorityHostUrl: string ): Promise { const options = { where: {} }; options.where = { instanceId: instanceId }; const item = await GuaribasInstance.findOne(options); item.authenticatorTenant = authenticatorTenant; item.authenticatorAuthorityHostUrl = authenticatorAuthorityHostUrl; - item.authenticatorClientId = authenticatorClientId; - item.authenticatorClientSecret = authenticatorClientSecret; return item.save(); } @@ -182,8 +178,8 @@ export class GBAdminService implements IGBAdminService { const authenticationContext = new AuthenticationContext(authorizationUrl); authenticationContext.acquireTokenWithRefreshToken( refreshToken, - instance.authenticatorClientId, - instance.authenticatorClientSecret, + instance.marketplaceId, + instance.marketplacePassword, resource, async (err, res) => { if (err !== null) { diff --git a/packages/core.gbapp/models/GBModel.ts b/packages/core.gbapp/models/GBModel.ts index 3af4dec4..6b01f9ce 100644 --- a/packages/core.gbapp/models/GBModel.ts +++ b/packages/core.gbapp/models/GBModel.ts @@ -108,12 +108,6 @@ export class GuaribasInstance extends Model @Column public authenticatorAuthorityHostUrl: string; - @Column - public authenticatorClientId: string; - - @Column - public authenticatorClientSecret: string; - @Column public cloudSubscriptionId: string; diff --git a/packages/core.gbapp/services/GBAPIService.ts b/packages/core.gbapp/services/GBAPIService.ts index 3a35900e..48739859 100644 --- a/packages/core.gbapp/services/GBAPIService.ts +++ b/packages/core.gbapp/services/GBAPIService.ts @@ -157,7 +157,8 @@ class SysClass { } }); const botId = this.min.instance.botId; - const path = `/${botId}/${botId}.gbdata`; + + const path = `/${botId}.gbai/${botId}.gbdata`; let res = await client.api( `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:${path}:/children`) @@ -187,7 +188,7 @@ class SysClass { const session = await client.api( `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/items/${document[0].id}/workbook/createSession`) - .get(body); + .post(body); // Applies filtering. @@ -199,21 +200,29 @@ class SysClass { } }; - let filtered = await client.api( + await client.api( `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/items/${document[0].id}/workbook/worksheets('Sheet1')/tables(id='Table1')/columns('${columnName}')/filter/apply`) - .headers("workbook-session-id", session.session_Id) - .get(bodyFilter); - + .headers("workbook-session-id", session.id) + .post(bodyFilter); // Get the filtered values. let results = await client.api( `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/items/${document[0].id}/workbook/worksheets('Sheet1')/tables('Table1')/range/visibleView/rows?$select=values`) - .headers("workbook-session-id", session.session_Id) - .get(bodyFilter); + .headers("workbook-session-id", session.id) + .get(); - return results; + // Translate an array into a readable BASIC object. + + let output = {}; + results.value[1].values[0] + const firstRow = results.value[0]; + for (let index = 0; index < firstRow.values[0].length; index++) { + output[firstRow.values[0][index]] = results.value[1].values[0][index]; + } + + return output; } public generatePassword() { diff --git a/packages/core.gbapp/services/GBCoreService.ts b/packages/core.gbapp/services/GBCoreService.ts index 67fdae47..2dbc8bf3 100644 --- a/packages/core.gbapp/services/GBCoreService.ts +++ b/packages/core.gbapp/services/GBCoreService.ts @@ -433,7 +433,7 @@ STORAGE_SYNC=true ); } } - + public async createBootInstance( core: GBCoreService, installationDeployer: IGBInstallationDeployer, diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index ee08c477..b942dcbe 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -210,7 +210,6 @@ export class GBMinService { const { min, adapter, conversationState } = await this.buildBotAdapter(instance, GBServer.globals.sysPackages); GBServer.globals.minInstances.push(min); - this.deployer.deployPackage(min, 'packages/default.gbdialog'); // Install per bot deployed packages. @@ -299,8 +298,8 @@ export class GBMinService { req.query.code, urlJoin(instance.botEndpoint, min.instance.botId, '/token'), resource, - instance.authenticatorClientId, - instance.authenticatorClientSecret, + instance.marketplaceId, + instance.marketplacePassword, async (err, token) => { if (err) { const msg = `Error acquiring token: ${err}`; @@ -326,7 +325,7 @@ export class GBMinService { '/oauth2/authorize' ); authorizationUrl = `${authorizationUrl}?response_type=code&client_id=${ - min.instance.authenticatorClientId + min.instance.marketplaceId }&redirect_uri=${urlJoin(min.instance.botEndpoint, min.instance.botId, 'token')}`; res.redirect(authorizationUrl); }); @@ -357,7 +356,7 @@ export class GBMinService { speechToken: speechToken, conversationId: webchatTokenContainer.conversationId, authenticatorTenant: instance.authenticatorTenant, - authenticatorClientId: instance.authenticatorClientId + authenticatorClientId: instance.marketplaceId }) ); } else { diff --git a/packages/core.gbapp/services/GBVMService.ts b/packages/core.gbapp/services/GBVMService.ts index 3b702bca..ef83b433 100644 --- a/packages/core.gbapp/services/GBVMService.ts +++ b/packages/core.gbapp/services/GBVMService.ts @@ -262,9 +262,7 @@ export class GBVMService extends GBService { GBLog.info(`[GBVMService] Finished loading of ${filename}`); } catch (error) { GBLog.error(`[GBVMService] ERROR loading ${error}`); - } - } } diff --git a/packages/default.gbdialog/delivery.vbs.gbignore b/packages/default.gbdialog/delivery.vbs.gbignore index 946f3c98..e7bad148 100644 --- a/packages/default.gbdialog/delivery.vbs.gbignore +++ b/packages/default.gbdialog/delivery.vbs.gbignore @@ -18,4 +18,33 @@ else end if end if -talk "Valeu!" \ No newline at end of file +talk "Valeu!" + + + +Falar "Qual seu nome?" +Ouvir nome + +Falar "Informe seu CEP, por favor:" +Ouvir CEP + +Address = CEP + +Confira seu endereço: + +Address.Street +Address.Number + + +Falar "Manda sua localização para eu pedir a alguém para sair agora com o seu pedido" +Hear Location + +SAve "Pedidos.xlsx", Nome, From, Location.Street, Location.Number + + + +Falar "Manda sua localização que eu encontro o posto mais próximo" +Hear Location + +Find "Postos.xlsx", "Endereço=" + Location + \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 33c90dcf..f8b8647e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -51,7 +51,6 @@ import { GBCoreService } from '../packages/core.gbapp/services/GBCoreService'; import { GBDeployer } from '../packages/core.gbapp/services/GBDeployer'; import { GBImporter } from '../packages/core.gbapp/services/GBImporterService'; import { GBMinService } from '../packages/core.gbapp/services/GBMinService'; -import { GBWhatsappPackage } from '../packages/whatsapp.gblib'; /** * Global shared server data;