fix(core.gbapp): GB Apps can now publish bots and replace root web application.
This commit is contained in:
parent
675c8511cb
commit
eed995e460
8 changed files with 57 additions and 9 deletions
|
@ -49,6 +49,7 @@ import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminSe
|
||||||
import { GBCorePackage } from '../../../packages/core.gbapp';
|
import { GBCorePackage } from '../../../packages/core.gbapp';
|
||||||
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
|
||||||
import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer';
|
||||||
|
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
|
||||||
|
|
||||||
const Spinner = require('cli-spinner').Spinner;
|
const Spinner = require('cli-spinner').Spinner;
|
||||||
// tslint:disable-next-line: no-submodule-imports
|
// tslint:disable-next-line: no-submodule-imports
|
||||||
|
@ -581,6 +582,28 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
return await this.storageClient.servers.createOrUpdate(group, name, params);
|
return await this.storageClient.servers.createOrUpdate(group, name, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async createApplication(token: string, name: string) {
|
||||||
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
let client = MicrosoftGraph.Client.init({
|
||||||
|
authProvider: done => {
|
||||||
|
done(null, token);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const app = {
|
||||||
|
displayName: name
|
||||||
|
};
|
||||||
|
|
||||||
|
client.api(`/applications`).post(app, (err, res) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private async registerProviders(subscriptionId, baseUrl, accessToken) {
|
private async registerProviders(subscriptionId, baseUrl, accessToken) {
|
||||||
const query = `subscriptions/${subscriptionId}/providers/${this.provider}/register?api-version=2018-02-01`;
|
const query = `subscriptions/${subscriptionId}/providers/${this.provider}/register?api-version=2018-02-01`;
|
||||||
const requestUrl = urlJoin(baseUrl, query);
|
const requestUrl = urlJoin(baseUrl, query);
|
||||||
|
|
|
@ -40,6 +40,7 @@ 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 { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
|
import { GBServer } from '../../../src/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for Welcoming people.
|
* Dialog for Welcoming people.
|
||||||
|
@ -56,6 +57,12 @@ export class WelcomeDialog extends IGBDialog {
|
||||||
min.dialogs.add(new WaterfallDialog('/', [
|
min.dialogs.add(new WaterfallDialog('/', [
|
||||||
async step => {
|
async step => {
|
||||||
|
|
||||||
|
if (GBServer.globals.entryPointDialog !== undefined)
|
||||||
|
{
|
||||||
|
|
||||||
|
return step.replaceDialog(GBServer.globals.entryPointDialog);
|
||||||
|
}
|
||||||
|
|
||||||
const user = await min.userProfile.get(context, {});
|
const user = await min.userProfile.get(context, {});
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ export class GBConversationalService implements IGBConversationalService {
|
||||||
this.coreService = coreService;
|
this.coreService = coreService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getNewMobileCode() {
|
public getNewMobileCode() {
|
||||||
const passwordGenerator = new PasswordGenerator();
|
const passwordGenerator = new PasswordGenerator();
|
||||||
const options = {
|
const options = {
|
||||||
upperCaseAlpha: false,
|
upperCaseAlpha: false,
|
||||||
|
|
|
@ -288,6 +288,11 @@ STORAGE_SYNC=true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setEntryPointDialog(dialogName: string)
|
||||||
|
{
|
||||||
|
GBServer.globals.entryPointDialog = dialogName;
|
||||||
|
}
|
||||||
|
|
||||||
public setWWWRoot(localPath: string)
|
public setWWWRoot(localPath: string)
|
||||||
{
|
{
|
||||||
GBServer.globals.wwwroot = localPath;
|
GBServer.globals.wwwroot = localPath;
|
||||||
|
|
|
@ -163,11 +163,23 @@ export class GBDeployer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async deployBlankBot(botId: string){
|
public async deployBlankBot(botId: string){
|
||||||
let instance = await this.importer.createBotInstance(botId);
|
let instance = await this.importer.createBotInstance(botId);
|
||||||
return this.deployBotFull(instance, GBServer.globals.publicAddress);
|
|
||||||
|
|
||||||
|
const username = GBConfigService.get('CLOUD_USERNAME');
|
||||||
|
const password = GBConfigService.get('CLOUD_PASSWORD');
|
||||||
|
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
|
||||||
|
|
||||||
|
const service = new AzureDeployerService(this);
|
||||||
|
let application = service.createApplication(accessToken, botId);
|
||||||
|
|
||||||
|
instance.marketplaceId = (application as any).appId;
|
||||||
|
instance.marketplacePassword = (application as any).passwordCredentials[0];
|
||||||
|
instance.adminPass = GBAdminService.getRndPassword();
|
||||||
|
|
||||||
|
await this.core.saveInstance(instance);
|
||||||
|
|
||||||
|
return this.deployBotFull(instance, GBServer.globals.publicAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,9 +191,9 @@ export class GBDeployer {
|
||||||
const service = new AzureDeployerService(this);
|
const service = new AzureDeployerService(this);
|
||||||
const username = GBConfigService.get('CLOUD_USERNAME');
|
const username = GBConfigService.get('CLOUD_USERNAME');
|
||||||
const password = GBConfigService.get('CLOUD_PASSWORD');
|
const password = GBConfigService.get('CLOUD_PASSWORD');
|
||||||
|
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
|
||||||
const group = GBConfigService.get('CLOUD_GROUP');
|
const group = GBConfigService.get('CLOUD_GROUP');
|
||||||
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
|
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
|
||||||
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
|
|
||||||
|
|
||||||
if (await service.botExists(instance.botId, group)) {
|
if (await service.botExists(instance.botId, group)) {
|
||||||
await service.updateBot(
|
await service.updateBot(
|
||||||
|
|
|
@ -385,7 +385,7 @@ export class GBMinService {
|
||||||
min.core = this.core;
|
min.core = this.core;
|
||||||
min.conversationalService = this.conversationalService;
|
min.conversationalService = this.conversationalService;
|
||||||
min.adminService = this.adminService;
|
min.adminService = this.adminService;
|
||||||
min.deployer = this.deployer;
|
min.deployService = this.deployer;
|
||||||
min.instance = await this.core.loadInstance(min.botId);
|
min.instance = await this.core.loadInstance(min.botId);
|
||||||
min.cbMap = {};
|
min.cbMap = {};
|
||||||
min.scriptMap = {};
|
min.scriptMap = {};
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
import { GuaribasConversation } from '../../analytics.gblib/models';
|
import { GuaribasConversation } from '../../analytics.gblib/models';
|
||||||
import { GuaribasQuestionAlternate } from '../models';
|
import { GuaribasQuestionAlternate } from '../models';
|
||||||
import { GuaribasQuestion } from 'packages/kb.gbapp/models';
|
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customer Satisfaction Service Layer.
|
* Customer Satisfaction Service Layer.
|
||||||
|
@ -57,7 +57,7 @@ export class CSService {
|
||||||
question = await GuaribasQuestion.findOne({
|
question = await GuaribasQuestion.findOne({
|
||||||
where: {
|
where: {
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
questionId: questionAlternate.questionTyped;
|
questionId: questionAlternate.questionTyped
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ export class RootData {
|
||||||
public minInstances: any[]; //
|
public minInstances: any[]; //
|
||||||
public minBoot: GBMinInstance;
|
public minBoot: GBMinInstance;
|
||||||
public wwwroot: string; // .gbui or a static webapp.
|
public wwwroot: string; // .gbui or a static webapp.
|
||||||
|
public entryPointDialog: string; // To replace default welcome dialog.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue