Skip to content

Commit

Permalink
fix(core.gbapp): .gbot download from tabular is now OK.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Oct 24, 2020
1 parent 201b8c7 commit a7fce94
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 48 deletions.
39 changes: 15 additions & 24 deletions packages/admin.gbapp/services/GBAdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class GBAdminService implements IGBAdminService {
public static async getADALCredentialsFromUsername(username: string, password: string) {
return await msRestAzure.loginWithUsernamePassword(username, password);
}

public static getMobileCode() {
const passwordGenerator = new PasswordGenerator();
const options = {
Expand All @@ -101,7 +101,6 @@ export class GBAdminService implements IGBAdminService {
return passwordGenerator.generatePassword(options);
}


public static getRndPassword(): string {
const passwordGenerator = new PasswordGenerator();
const options = {
Expand Down Expand Up @@ -168,7 +167,6 @@ export class GBAdminService implements IGBAdminService {
}

public async acquireElevatedToken(instanceId: number): Promise<string> {

// TODO: Use boot bot as base for authentication.

let botId = GBConfigService.get('BOT_ID');
Expand Down Expand Up @@ -227,9 +225,7 @@ export class GBAdminService implements IGBAdminService {
return path.indexOf('sharepoint.com') > 0;
}

public async publish(min: GBMinInstance, packageName: string, republish: boolean): Promise<void> {

}
public async publish(min: GBMinInstance, packageName: string, republish: boolean): Promise<void> {}
public static async deployPackageCommand(min: GBMinInstance, text: string, deployer: IGBDeployer) {
const packageName = text.split(' ')[1];

Expand All @@ -239,24 +235,22 @@ export class GBAdminService implements IGBAdminService {
throw new Error('ADDITIONAL_DEPLOY_PATH is not set and deployPackage was called.');
}
await deployer.deployPackage(min, urlJoin(additionalPath, packageName));
}
else {
} else {
let siteName = text.split(' ')[1];
let folderName = text.split(' ')[2];

let packageType = Path.extname(folderName);
if (packageType !== '.gbot') {
let s = new GBSharePointService();

let localFolder = Path.join('work', `${min.instance.botId}.gbai`, Path.basename(folderName));
GBLog.warn(`${GBConfigService.get('CLOUD_USERNAME')} must be authorized on SharePoint related site`);
await s.downloadFolder(localFolder, siteName, folderName,
GBConfigService.get('CLOUD_USERNAME'), GBConfigService.get('CLOUD_PASSWORD'))
await deployer.deployPackage(min, localFolder);
}
else {
await deployer.deployPackage(min, folderName);
}
let s = new GBSharePointService();

let localFolder = Path.join('work', `${min.instance.botId}.gbai`, Path.basename(folderName));
GBLog.warn(`${GBConfigService.get('CLOUD_USERNAME')} must be authorized on SharePoint related site`);
await s.downloadFolder(
localFolder,
siteName,
folderName,
GBConfigService.get('CLOUD_USERNAME'),
GBConfigService.get('CLOUD_PASSWORD')
);
await deployer.deployPackage(min, localFolder);
}
}
public static async rebuildIndexPackageCommand(min: GBMinInstance, deployer: IGBDeployer) {
Expand All @@ -271,7 +265,4 @@ export class GBAdminService implements IGBAdminService {
const service = await AzureDeployerService.createInstance(deployer);
service.syncBotServerRepository(min.instance.botId, serverName);
}



}
3 changes: 3 additions & 0 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ export class GBConversationalService {

let nlp: RecognizerResult;
try {
const saved = step.context.activity.text
step.context.activity.text = text;
nlp = await model.recognize(step.context);
step.context.activity.text = saved;
} catch (error) {
// tslint:disable:no-unsafe-any
if (error.statusCode === 404) {
Expand Down
35 changes: 13 additions & 22 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,14 @@ export class GBDeployer implements IGBDeployer {

public async publishNLP(instance: IGBInstance): Promise<void> {
const service = new AzureDeployerService(this);
const res = await service.publishNLP(
instance.cloudLocation,
instance.nlpAppId,
instance.nlpAuthoringKey,
);
if(res.status !== 200 && res.status !== 201) throw res.bodyAsText;

const res = await service.publishNLP(instance.cloudLocation, instance.nlpAppId, instance.nlpAuthoringKey);
if (res.status !== 200 && res.status !== 201) throw res.bodyAsText;
}

public async trainNLP(instance: IGBInstance): Promise<void> {
const service = new AzureDeployerService(this);
const res = await service.trainNLP(
instance.cloudLocation,
instance.nlpAppId,
instance.nlpAuthoringKey,
);
if(res.status !== 200 && res.status !== 202) throw res.bodyAsText;
const res = await service.trainNLP(instance.cloudLocation, instance.nlpAppId, instance.nlpAuthoringKey);
if (res.status !== 200 && res.status !== 202) throw res.bodyAsText;
let sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
Expand All @@ -274,15 +265,14 @@ export class GBDeployer implements IGBDeployer {

public async refreshNLPEntity(instance: IGBInstance, listName, listData): Promise<void> {
const service = new AzureDeployerService(this);
const res = await service.refreshEntityList(
const res = await service.refreshEntityList(
instance.cloudLocation,
instance.nlpAppId,
listName,
instance.nlpAuthoringKey,
listData
);
if(res.status !== 200) throw res.bodyAsText;

if (res.status !== 200) throw res.bodyAsText;
}

/**
Expand All @@ -295,7 +285,7 @@ export class GBDeployer implements IGBDeployer {
await this.deployBotFull(instance, publicAddress);
}

public async loadParamsFromExcel(min: GBMinInstance): Promise<any> {
public async loadParamsFromTabular(min: GBMinInstance): Promise<any> {
let token = await min.adminService.acquireElevatedToken(min.instance.instanceId);

let siteId = process.env.STORAGE_SITE_ID;
Expand Down Expand Up @@ -417,11 +407,12 @@ export class GBDeployer implements IGBDeployer {

switch (packageType) {
case '.gbot':
if (Fs.existsSync(localPath)) {
await this.deployBotFromLocalPath(localPath, GBServer.globals.publicAddress);
}
if (process.env.ENABLE_PARAMS_ONLINE === 'true') {
min.instance.params = await this.loadParamsFromExcel(min);
if (process.env.ENABLE_PARAMS_ONLINE === 'false') {
if (Fs.existsSync(localPath)) {
await this.deployBotFromLocalPath(localPath, GBServer.globals.publicAddress);
}
} else {
min.instance.params = await this.loadParamsFromTabular(min);
}
await this.core.saveInstance(min.instance);

Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ export class GBMinService {
min.instance.translatorKey ? min.instance.translatorKey : minBoot.instance.translatorKey,
min.instance.translatorEndpoint ? min.instance.translatorEndpoint : minBoot.instance.translatorEndpoint,
query,
'pt'
'en'
);
GBLog.info(`Translated text: ${query}.`);

Expand Down
2 changes: 1 addition & 1 deletion packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class AskDialog extends IGBDialog {
min.instance.translatorKey ? min.instance.translatorKey : minBoot.instance.translatorKey,
min.instance.translatorEndpoint ? min.instance.translatorEndpoint : minBoot.instance.translatorEndpoint,
query,
'pt'
'en'
);
GBLog.info(`Translated text: ${query}.`);

Expand Down

0 comments on commit a7fce94

Please sign in to comment.