From dcafb7acf96559d0333b450e1270429a57c72dd1 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (pragmatismo.io)" Date: Thu, 6 Dec 2018 10:32:31 -0200 Subject: [PATCH 1/2] fix(gbdialog): Updating packages to latest versions and sync *-lock file. --- package-lock.json | 84 +++++++++++++++++------------------------------ package.json | 4 +-- 2 files changed, 31 insertions(+), 57 deletions(-) diff --git a/package-lock.json b/package-lock.json index bba196aa..4d26d5c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3299,9 +3299,9 @@ } }, "@types/node": { - "version": "9.6.36", - "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.36.tgz", - "integrity": "sha512-Fbw+AdRLL01vv7Rk7bYaNPecqmKoinJHGbpKnDpbUZmUj/0vj3nLqPQ4CNBzr3q2zso6Cq/4jHoCAdH78fvJrw==" + "version": "9.6.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.40.tgz", + "integrity": "sha512-M3HHoXXndsho/sTbQML2BJr7/uwNhMg8P0D4lb+UsM65JQZx268faiz9hKpY4FpocWqpwlLwa8vevw8hLtKjOw==" }, "async": { "version": "1.5.2", @@ -3548,9 +3548,9 @@ } }, "botlib": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/botlib/-/botlib-0.1.6.tgz", - "integrity": "sha512-NG/F7Yxhx/duehDzjI78mYMonZ03d+Gx+WtRmqj7TimGcc4xK1y4m7s+n9jt0XR+GYhj0jcA5uKA2LqDRtq22A==", + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/botlib/-/botlib-0.1.8.tgz", + "integrity": "sha512-66v6koaZnEZBMtnFlMs6wGyD6lu+CUg0YXuPPhTEMROrJtWu25aTlCXgkxlhhuGjQvxRpkqwvP8Ta5fsAGqvPg==", "requires": { "async": "2.6.1", "botbuilder": "4.1.3", @@ -3607,9 +3607,9 @@ } }, "@types/node": { - "version": "9.6.36", - "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.36.tgz", - "integrity": "sha512-Fbw+AdRLL01vv7Rk7bYaNPecqmKoinJHGbpKnDpbUZmUj/0vj3nLqPQ4CNBzr3q2zso6Cq/4jHoCAdH78fvJrw==" + "version": "9.6.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.40.tgz", + "integrity": "sha512-M3HHoXXndsho/sTbQML2BJr7/uwNhMg8P0D4lb+UsM65JQZx268faiz9hKpY4FpocWqpwlLwa8vevw8hLtKjOw==" }, "botbuilder": { "version": "4.1.3", @@ -5024,9 +5024,9 @@ } }, "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.4.tgz", + "integrity": "sha512-8I1sgZHfVwcSOY6mSGpVU3lw/GSIZvusg8dD2+OGehCJpOhQRLNcH0qb9upQnOH4XhgxxFJSg6E2kx95deb1Tw==", "requires": { "boom": "5.x.x" }, @@ -5034,7 +5034,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "requires": { "hoek": "4.x.x" } @@ -7098,8 +7098,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -7117,13 +7116,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7136,18 +7133,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -7250,8 +7244,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -7261,7 +7254,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7274,20 +7266,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7304,7 +7293,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7377,8 +7365,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -7388,7 +7375,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7464,8 +7450,7 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -7495,7 +7480,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7513,7 +7497,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7552,13 +7535,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.2", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -13925,7 +13906,6 @@ "align-text": { "version": "0.1.4", "bundled": true, - "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -14205,8 +14185,7 @@ }, "is-buffer": { "version": "1.1.6", - "bundled": true, - "optional": true + "bundled": true }, "is-builtin-module": { "version": "1.0.0", @@ -14278,7 +14257,6 @@ "kind-of": { "version": "3.2.2", "bundled": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -14319,8 +14297,7 @@ }, "longest": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "lru-cache": { "version": "4.1.3", @@ -14549,8 +14526,7 @@ }, "repeat-string": { "version": "1.6.1", - "bundled": true, - "optional": true + "bundled": true }, "require-directory": { "version": "2.1.1", @@ -18673,9 +18649,9 @@ } }, "tslint-microsoft-contrib": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.2.1.tgz", - "integrity": "sha512-PDYjvpo0gN9IfMULwKk0KpVOPMhU6cNoT9VwCOLeDl/QS8v8W2yspRpFFuUS7/c5EIH/n8ApMi8TxJAz1tfFUA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-6.0.0.tgz", + "integrity": "sha512-R//efwn+34IUjTJeYgNDAJdzG0jyLWIehygPt/PHuZAieTolFVS56FgeFW7DOLap9ghXzMiFPTmDgm54qaL7QA==", "dev": true, "requires": { "tsutils": "^2.27.2 <2.29.0" diff --git a/package.json b/package.json index 1af0b732..07434066 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "botbuilder-choices": "^4.0.0-preview1.2", "botbuilder-dialogs": "^4.1.5", "botbuilder-prompts": "^4.0.0-preview1.2", - "botlib": "0.1.7", + "botlib": "^0.1.8", "chai": "4.2.0", "child_process": "^1.0.2", "chokidar": "2.0.4", @@ -124,7 +124,6 @@ "@types/url-join": "0.8.2", "@types/winston": "2.4.4", "ban-sensitive-files": "1.9.2", - "chai": "^4.2.0", "commitizen": "^3.0.4", "coveralls": "^3.0.2", "cz-conventional-changelog": "^2.1.0", @@ -132,7 +131,6 @@ "deps-ok": "1.4.1", "git-issues": "1.3.1", "license-checker": "24.0.1", - "mocha": "^5.2.0", "nsp": "3.2.1", "pre-git": "3.17.1", "prettier-standard": "8.0.1", From 02ed08508d339d65936fe910223366f99c019021 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (pragmatismo.io)" Date: Thu, 6 Dec 2018 10:45:16 -0200 Subject: [PATCH 2/2] fix(default.gbui): Removing warnings. --- packages/admin.gbapp/dialogs/AdminDialog.ts | 93 ++++++++++--------- packages/default.gbui/src/GBUIApp.js | 21 ++--- .../default.gbui/src/players/GBLoginPlayer.js | 8 -- .../src/players/GBMarkdownPlayer.js | 4 +- 4 files changed, 59 insertions(+), 67 deletions(-) diff --git a/packages/admin.gbapp/dialogs/AdminDialog.ts b/packages/admin.gbapp/dialogs/AdminDialog.ts index 8b9cd419..eb81edef 100644 --- a/packages/admin.gbapp/dialogs/AdminDialog.ts +++ b/packages/admin.gbapp/dialogs/AdminDialog.ts @@ -43,7 +43,7 @@ import { GBMinInstance } from 'botlib'; import { IGBDialog } from 'botlib'; import { GBConfigService } from '../../core.gbapp/services/GBConfigService'; import { GBDeployer } from '../../core.gbapp/services/GBDeployer'; -import { GBImporter } from '../../core.gbapp/services/GBImporter'; +import { GBImporter } from '../../core.gbapp/services/GBImporterService'; import { GBAdminService } from '../services/GBAdminService'; import { Messages } from '../strings'; @@ -57,19 +57,27 @@ export class AdminDialog extends IGBDialog { const packageName = text.split(' ')[1]; const importer = new GBImporter(min.core); const deployer = new GBDeployer(min.core, importer); - await deployer.undeployPackageFromLocalPath( - min.instance, - UrlJoin('packages', packageName) - ); + await deployer.undeployPackageFromLocalPath(min.instance, UrlJoin('packages', packageName)); } - public static async deployPackageCommand(text: string, deployer: GBDeployer) { + public static async deployPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) { const packageName = text.split(' ')[1]; const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH'); - await deployer.deployPackageFromLocalPath( - UrlJoin(additionalPath, packageName) - ); + await deployer.deployPackageFromLocalPath(min, UrlJoin(additionalPath, packageName)); } + + public static async rebuildIndexPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) { + await deployer.rebuildIndex(min.instance); + } + + public static async addConnectionCommand(min: GBMinInstance, text: any) { + const packageName = text.split(' ')[1]; + const importer = new GBImporter(min.core); + const admin = new GBAdminService(min.core); + // TODO: await admin.addConnection + } + + /** * Setup dialogs flows and define services call. * @@ -87,23 +95,22 @@ export class AdminDialog extends IGBDialog { async step => { const locale = step.context.activity.locale; const prompt = Messages[locale].authenticate; - await step.prompt('textPrompt', prompt); - return await step.next(); + + return await step.prompt('textPrompt', prompt); }, async step => { const locale = step.context.activity.locale; const password = step.result; - if ( - password === GBConfigService.get('ADMIN_PASS') && - GBAdminService.StrongRegex.test(password) - ) { + + if (password === GBConfigService.get('ADMIN_PASS')) { await step.context.sendActivity(Messages[locale].welcome); - await step.prompt('textPrompt', Messages[locale].which_task); + + return await step.prompt('textPrompt', Messages[locale].which_task); } else { - await step.prompt('textPrompt', Messages[locale].wrong_password); - await step.endDialog(); + await step.context.sendActivity(Messages[locale].wrong_password); + + return await step.endDialog(); } - return await step.next(); }, async step => { const locale = step.context.activity.locale; @@ -114,20 +121,32 @@ export class AdminDialog extends IGBDialog { let unknownCommand = false; if (text === 'quit') { - await step.replaceDialog('/'); + return await step.replaceDialog('/'); } else if (cmdName === 'createFarm') { await AdminDialog.createFarmCommand(text, deployer); - await step.replaceDialog('/admin', { firstRun: false }); + + return await step.replaceDialog('/admin', { firstRun: false }); } else if (cmdName === 'deployPackage') { - await AdminDialog.deployPackageCommand(text, deployer); - await step.replaceDialog('/admin', { firstRun: false }); + await AdminDialog.deployPackageCommand(min, text, deployer); + + return await step.replaceDialog('/admin', { firstRun: false }); } else if (cmdName === 'redeployPackage') { await AdminDialog.undeployPackageCommand(text, min); - await AdminDialog.deployPackageCommand(text, deployer); - await step.replaceDialog('/admin', { firstRun: false }); + await AdminDialog.deployPackageCommand(min, text, deployer); + + return await step.replaceDialog('/admin', { firstRun: false }); + } else if (cmdName === 'rebuildIndex') { + await AdminDialog.rebuildIndexPackageCommand(min, text, deployer); + + 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); - await step.replaceDialog('/admin', { firstRun: false }); + + return await step.replaceDialog('/admin', { firstRun: false }); } else if (cmdName === 'setupSecurity') { await AdminDialog.setupSecurity(min, step); } else { @@ -137,13 +156,11 @@ export class AdminDialog extends IGBDialog { if (unknownCommand) { await step.context.sendActivity(Messages[locale].unknown_command); } else { - await step.context.sendActivity( - Messages[locale].finshed_working(cmdName) - ); + await step.context.sendActivity(Messages[locale].finshed_working(cmdName)); } await step.endDialog(); - await step.replaceDialog('/answer', { query: text }); - return await step.next(); + + return await step.replaceDialog('/answer', { query: text }); } ]) ); @@ -151,17 +168,9 @@ export class AdminDialog extends IGBDialog { private static async setupSecurity(min: any, step: any) { const locale = step.activity.locale; - const state = `${min.instance.instanceId}${Math.floor( - Math.random() * 1000000000 - )}`; - await min.adminService.setValue( - min.instance.instanceId, - 'AntiCSRFAttackState', - state - ); - const url = `https://login.microsoftonline.com/${ - min.instance.authenticatorTenant - }/oauth2/authorize?client_id=${ + const state = `${min.instance.instanceId}${Math.floor(Math.random() * 1000000000)}`; + await min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state); + const url = `https://login.microsoftonline.com/${min.instance.authenticatorTenant}/oauth2/authorize?client_id=${ min.instance.authenticatorClientId }&response_type=code&redirect_uri=${min.instance.botEndpoint}/${ min.instance.botId diff --git a/packages/default.gbui/src/GBUIApp.js b/packages/default.gbui/src/GBUIApp.js index 191989c7..0a82ff67 100644 --- a/packages/default.gbui/src/GBUIApp.js +++ b/packages/default.gbui/src/GBUIApp.js @@ -40,13 +40,9 @@ import SidebarMenu from "./components/SidebarMenu.js"; import GBCss from "./components/GBCss.js"; import { DirectLine } from "botframework-directlinejs"; import { ConnectionStatus } from "botframework-directlinejs"; -import { SpeechRecognizer } from "botframework-webchat"; -import { SpeechSynthesizer } from "botframework-webchat"; -import { SynthesisGender } from "botframework-webchat"; import { Chat } from "botframework-webchat"; import GBPowerBIPlayer from "./players/GBPowerBIPlayer.js"; -import { UserAgentApplication } from "msal"; -import { Observable } from 'rxjs' + class GBUIApp extends React.Component { constructor() { @@ -117,11 +113,11 @@ class GBUIApp extends React.Component { configureChat() { var botId = window.location.href.split("/")[3]; - if (botId.indexOf('#') != -1) { + if (botId.indexOf('#') !== -1) { botId = botId.split("#")[0]; } - if (!botId || botId == "") { + if (!botId || botId === "") { botId = "[default]"; } @@ -302,7 +298,7 @@ class GBUIApp extends React.Component { } - let speechOptions; + let chat =
; let gbCss =
; @@ -314,15 +310,10 @@ class GBUIApp extends React.Component { ); if (this.state.line && this.state.instance) { - let token = this.state.instanceClient.speechToken; gbCss = ; - function getToken() { - return new Promise((resolve: any, reject: any): any => { - resolve(token); - }); - } - + // let speechOptions; + // let token = this.state.instanceClient.speechToken; // speechOptions = { // speechRecognizer: new SpeechRecognizer({ // locale: "pt-br", diff --git a/packages/default.gbui/src/players/GBLoginPlayer.js b/packages/default.gbui/src/players/GBLoginPlayer.js index b9ec66f2..cb078916 100644 --- a/packages/default.gbui/src/players/GBLoginPlayer.js +++ b/packages/default.gbui/src/players/GBLoginPlayer.js @@ -43,14 +43,6 @@ class GBLoginPlayer extends React.Component { } doLogin(info) { - let logger = new Logger( - (logLevel, message, piiEnabled) => { - console.log(message); - }, - { level: LogLevel.Verbose } - ); - - let authority = "https://login.microsoftonline.com/" + this.state.login.authenticatorTenant; diff --git a/packages/default.gbui/src/players/GBMarkdownPlayer.js b/packages/default.gbui/src/players/GBMarkdownPlayer.js index a4a60ff0..2919ae6a 100644 --- a/packages/default.gbui/src/players/GBMarkdownPlayer.js +++ b/packages/default.gbui/src/players/GBMarkdownPlayer.js @@ -119,13 +119,13 @@ class GBMarkdownPlayer extends Component { } if (this.state.prevId) { - prev = this.sendAnswer(this.state.prevId)}> Back } if (this.state.nextId) { - next = this.sendAnswer(this.state.nextId)}> Next