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 { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
|
||||
import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer';
|
||||
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
|
||||
|
||||
const Spinner = require('cli-spinner').Spinner;
|
||||
// tslint:disable-next-line: no-submodule-imports
|
||||
|
@ -337,7 +338,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
endIpAddress: ip
|
||||
};
|
||||
await storageClient.firewallRules.createOrUpdate(groupName, serverName, 'gb', params);
|
||||
|
||||
|
||||
// AllowAllWindowsAzureIps must be created that way, so the Azure Search can
|
||||
// access SQL Database to index its contents.
|
||||
|
||||
|
@ -372,7 +373,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
|
||||
const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey);
|
||||
|
||||
instance.nlpEndpoint = urlJoin(nlp.endpoint, 'apps');
|
||||
instance.nlpEndpoint = urlJoin(nlp.endpoint, 'apps');
|
||||
instance.nlpKey = keys.key1;
|
||||
instance.nlpAppId = nlpAppId;
|
||||
|
||||
|
@ -581,6 +582,28 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
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) {
|
||||
const query = `subscriptions/${subscriptionId}/providers/${this.provider}/register?api-version=2018-02-01`;
|
||||
const requestUrl = urlJoin(baseUrl, query);
|
||||
|
|
|
@ -40,6 +40,7 @@ import { BotAdapter } from 'botbuilder';
|
|||
import {WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { Messages } from '../strings';
|
||||
import { GBServer } from '../../../src/app';
|
||||
|
||||
/**
|
||||
* Dialog for Welcoming people.
|
||||
|
@ -56,6 +57,12 @@ export class WelcomeDialog extends IGBDialog {
|
|||
min.dialogs.add(new WaterfallDialog('/', [
|
||||
async step => {
|
||||
|
||||
if (GBServer.globals.entryPointDialog !== undefined)
|
||||
{
|
||||
|
||||
return step.replaceDialog(GBServer.globals.entryPointDialog);
|
||||
}
|
||||
|
||||
const user = await min.userProfile.get(context, {});
|
||||
const locale = step.context.activity.locale;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ export class GBConversationalService implements IGBConversationalService {
|
|||
this.coreService = coreService;
|
||||
}
|
||||
|
||||
public static getNewMobileCode() {
|
||||
public getNewMobileCode() {
|
||||
const passwordGenerator = new PasswordGenerator();
|
||||
const options = {
|
||||
upperCaseAlpha: false,
|
||||
|
|
|
@ -288,6 +288,11 @@ STORAGE_SYNC=true
|
|||
}
|
||||
}
|
||||
|
||||
public setEntryPointDialog(dialogName: string)
|
||||
{
|
||||
GBServer.globals.entryPointDialog = dialogName;
|
||||
}
|
||||
|
||||
public setWWWRoot(localPath: string)
|
||||
{
|
||||
GBServer.globals.wwwroot = localPath;
|
||||
|
|
|
@ -163,11 +163,23 @@ export class GBDeployer {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
public async deployBlankBot(botId: string){
|
||||
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 username = GBConfigService.get('CLOUD_USERNAME');
|
||||
const password = GBConfigService.get('CLOUD_PASSWORD');
|
||||
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
|
||||
const group = GBConfigService.get('CLOUD_GROUP');
|
||||
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
|
||||
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
|
||||
|
||||
if (await service.botExists(instance.botId, group)) {
|
||||
await service.updateBot(
|
||||
|
|
|
@ -385,7 +385,7 @@ export class GBMinService {
|
|||
min.core = this.core;
|
||||
min.conversationalService = this.conversationalService;
|
||||
min.adminService = this.adminService;
|
||||
min.deployer = this.deployer;
|
||||
min.deployService = this.deployer;
|
||||
min.instance = await this.core.loadInstance(min.botId);
|
||||
min.cbMap = {};
|
||||
min.scriptMap = {};
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
import { GuaribasConversation } from '../../analytics.gblib/models';
|
||||
import { GuaribasQuestionAlternate } from '../models';
|
||||
import { GuaribasQuestion } from 'packages/kb.gbapp/models';
|
||||
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models';
|
||||
|
||||
/**
|
||||
* Customer Satisfaction Service Layer.
|
||||
|
@ -57,7 +57,7 @@ export class CSService {
|
|||
question = await GuaribasQuestion.findOne({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
questionId: questionAlternate.questionTyped;
|
||||
questionId: questionAlternate.questionTyped
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ export class RootData {
|
|||
public minInstances: any[]; //
|
||||
public minBoot: GBMinInstance;
|
||||
public wwwroot: string; // .gbui or a static webapp.
|
||||
public entryPointDialog: string; // To replace default welcome dialog.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue