fix(all): #123 done.
This commit is contained in:
parent
7e3ee7dc52
commit
2d1efeb0cc
3 changed files with 26 additions and 6 deletions
|
@ -43,7 +43,7 @@ import { LanguageDialog } from './dialogs/LanguageDialog.js';
|
||||||
import { SwitchBotDialog } from './dialogs/SwitchBot.js';
|
import { SwitchBotDialog } from './dialogs/SwitchBot.js';
|
||||||
import { WelcomeDialog } from './dialogs/WelcomeDialog.js';
|
import { WelcomeDialog } from './dialogs/WelcomeDialog.js';
|
||||||
import { WhoAmIDialog } from './dialogs/WhoAmIDialog.js';
|
import { WhoAmIDialog } from './dialogs/WhoAmIDialog.js';
|
||||||
import { GuaribasChannel, GuaribasInstance, GuaribasLog, GuaribasPackage } from './models/GBModel.js';
|
import { GuaribasApplications, GuaribasChannel, GuaribasInstance, GuaribasLog, GuaribasPackage } from './models/GBModel.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package for core.gbapp.
|
* Package for core.gbapp.
|
||||||
|
@ -53,7 +53,7 @@ export class GBCorePackage implements IGBPackage {
|
||||||
public CurrentEngineName = 'guaribas-1.0.0';
|
public CurrentEngineName = 'guaribas-1.0.0';
|
||||||
|
|
||||||
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
public async loadPackage (core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||||
core.sequelize.addModels([GuaribasInstance, GuaribasPackage, GuaribasChannel, GuaribasLog]);
|
core.sequelize.addModels([GuaribasInstance, GuaribasPackage, GuaribasChannel, GuaribasLog, GuaribasApplications]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDialogs (min: GBMinInstance) {
|
public async getDialogs (min: GBMinInstance) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp
|
||||||
import { GBKBPackage } from '../../kb.gbapp/index.js';
|
import { GBKBPackage } from '../../kb.gbapp/index.js';
|
||||||
import { GBSecurityPackage } from '../../security.gbapp/index.js';
|
import { GBSecurityPackage } from '../../security.gbapp/index.js';
|
||||||
import { GBWhatsappPackage } from '../../whatsapp.gblib/index.js';
|
import { GBWhatsappPackage } from '../../whatsapp.gblib/index.js';
|
||||||
import { GuaribasInstance, GuaribasLog } from '../models/GBModel.js';
|
import { GuaribasApplications, GuaribasInstance, GuaribasLog } from '../models/GBModel.js';
|
||||||
import { GBConfigService } from './GBConfigService.js';
|
import { GBConfigService } from './GBConfigService.js';
|
||||||
import { GBAzureDeployerPackage } from '../../azuredeployer.gbapp/index.js';
|
import { GBAzureDeployerPackage } from '../../azuredeployer.gbapp/index.js';
|
||||||
import { GBSharePointPackage } from '../../sharepoint.gblib/index.js';
|
import { GBSharePointPackage } from '../../sharepoint.gblib/index.js';
|
||||||
|
@ -60,6 +60,8 @@ import { GBGoogleChatPackage } from '../../google-chat.gblib/index.js';
|
||||||
import { GBHubSpotPackage } from '../../hubspot.gblib/index.js';
|
import { GBHubSpotPackage } from '../../hubspot.gblib/index.js';
|
||||||
import open from 'open';
|
import open from 'open';
|
||||||
import ngrok from 'ngrok';
|
import ngrok from 'ngrok';
|
||||||
|
import Path from 'path';
|
||||||
|
import { file } from 'googleapis/build/src/apis/file/index.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GBCoreService contains main logic for handling storage services related
|
* GBCoreService contains main logic for handling storage services related
|
||||||
|
@ -396,6 +398,25 @@ ENDPOINT_UPDATE=true
|
||||||
return await instance.save();
|
return await instance.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all bot instances from object storage, if it's formatted.
|
||||||
|
*/
|
||||||
|
public async getApplicationsByInstanceId(appPackages, instanceId: number) {
|
||||||
|
const options = { where: { instanceId: instanceId } };
|
||||||
|
const apps = await GuaribasApplications.findAll(options);
|
||||||
|
|
||||||
|
let matchingAppPackages = [];
|
||||||
|
await CollectionUtil.asyncForEach(appPackages, async appPackage => {
|
||||||
|
const filenameOnly = Path.basename(appPackage.name);
|
||||||
|
const matchedApp = apps.find(app => app.name === filenameOnly || app.name === filenameOnly);
|
||||||
|
if (matchedApp) {
|
||||||
|
matchingAppPackages.push(appPackage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return matchingAppPackages;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all bot instances from object storage, if it's formatted.
|
* Loads all bot instances from object storage, if it's formatted.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -707,7 +707,6 @@ export class GBMinService {
|
||||||
min['scheduleMap'] = {};
|
min['scheduleMap'] = {};
|
||||||
min['conversationWelcomed'] = {};
|
min['conversationWelcomed'] = {};
|
||||||
min.packages = sysPackages;
|
min.packages = sysPackages;
|
||||||
min.appPackages = appPackages;
|
|
||||||
|
|
||||||
// NLP Manager.
|
// NLP Manager.
|
||||||
|
|
||||||
|
@ -726,7 +725,7 @@ export class GBMinService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// https://github.com/GeneralBots/BotServer/issues/123
|
// https://github.com/GeneralBots/BotServer/issues/123
|
||||||
// min.appPackages = core.getPackagesByInstanceId(min.instance.instanceId);
|
min.appPackages = await this.core['getApplicationsByInstanceId'] (appPackages, min.instance.instanceId);
|
||||||
|
|
||||||
// Creates a hub of services available in .gbapps.
|
// Creates a hub of services available in .gbapps.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue