fix(all): TRUE multicloud.
This commit is contained in:
parent
1765e8f50e
commit
c2bdbbe140
7 changed files with 79 additions and 60 deletions
|
@ -285,7 +285,7 @@ export class GBVMService extends GBService {
|
|||
// Loads storage custom connections.
|
||||
const path = DialogKeywords.getGBAIPath(min.botId, null);
|
||||
const filePath = Path.join('work', path, 'connections.json');
|
||||
let connections = null;
|
||||
let connections = [];
|
||||
if (Fs.existsSync(filePath)) {
|
||||
connections = JSON.parse(Fs.readFileSync(filePath, 'utf8'));
|
||||
}
|
||||
|
|
|
@ -1745,24 +1745,27 @@ export class SystemKeywords {
|
|||
|
||||
private flattenJSON(obj, res = {}, separator = '_', parent = null) {
|
||||
for (let key in obj) {
|
||||
if (typeof obj[key] === 'function') {
|
||||
if (!obj.hasOwnProperty(key) || typeof obj[key] === 'function') {
|
||||
continue;
|
||||
}
|
||||
if (typeof obj[key] !== 'object' || obj[key] instanceof Date) {
|
||||
// If not defined already add the flattened field.
|
||||
|
||||
// If not defined already, add the flattened field.
|
||||
const newKey = `${parent ? parent + separator : ''}${key}`;
|
||||
if (!res[newKey]) {
|
||||
if (!res.hasOwnProperty(newKey)) {
|
||||
res[newKey] = obj[key];
|
||||
} else {
|
||||
GBLog.verbose(`Ignoring duplicated field in flatten operation to storage: ${key}.`);
|
||||
}
|
||||
} else {
|
||||
obj[key] = this.flattenJSON(obj[key], res, separator, `${parent ? parent + separator : ''}${key}`);
|
||||
// Create a temporary reference to the nested object to prevent memory leaks.
|
||||
const tempObj = obj[key];
|
||||
this.flattenJSON(tempObj, res, separator, `${parent ? parent + separator : ''}${key}`);
|
||||
// Clear the reference to avoid holding unnecessary objects in memory.
|
||||
obj[key] = null;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public async getCustomToken({ pid, tokenName }) {
|
||||
const { min } = await DialogKeywords.getProcessInfo(pid);
|
||||
|
|
|
@ -81,6 +81,9 @@ export class GBConfigService {
|
|||
|
||||
if (!value) {
|
||||
switch (key) {
|
||||
case 'PORT':
|
||||
value = this.getServerPort();
|
||||
break;
|
||||
case 'STORAGE_NAME':
|
||||
value = null;
|
||||
break;
|
||||
|
|
|
@ -872,7 +872,7 @@ ENDPOINT_UPDATE=true
|
|||
Fs.cpSync(Path.join(base, `default.gbdialog`), Path.join(gbaiPath, `default.gbdialog`), {
|
||||
errorOnExist: false,
|
||||
force: true,
|
||||
recursive: true
|
||||
recursive: true,
|
||||
});
|
||||
Fs.cpSync(Path.join(base, `default.gbdrive`), Path.join(gbaiPath, `default.gbdrive`), {
|
||||
errorOnExist: false,
|
||||
|
|
|
@ -422,40 +422,50 @@ export class GBDeployer implements IGBDeployer {
|
|||
/**
|
||||
* Loads all para from tabular file Config.xlsx.
|
||||
*/
|
||||
public async loadParamsFromTabular(min: GBMinInstance, path): Promise<any> {
|
||||
const workbook = new Excel.Workbook();
|
||||
const data = await workbook.xlsx.readFile(Path.join(path, 'Config.xlsx'));
|
||||
|
||||
public async loadParamsFromTabular(min: GBMinInstance, filePath: string): Promise<any> {
|
||||
if (!Fs.existsSync(filePath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const ext = Path.extname(filePath).toLowerCase();
|
||||
let rows: any[] = [];
|
||||
|
||||
const workbook = new Excel.Workbook();
|
||||
|
||||
if (ext === '.xlsx') {
|
||||
await workbook.xlsx.readFile(filePath);
|
||||
let worksheet: any;
|
||||
for (let t = 0; t < data.worksheets.length; t++) {
|
||||
worksheet = data.worksheets[t];
|
||||
for (let t = 0; t < workbook.worksheets.length; t++) {
|
||||
worksheet = workbook.worksheets[t];
|
||||
if (worksheet) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const rows = worksheet._rows;
|
||||
GBLogEx.info(min, `Processing ${rows.length} rows from Config file ${path}...`);
|
||||
let list = [];
|
||||
rows = worksheet.getSheetValues();
|
||||
} else if (ext === '.csv') {
|
||||
await workbook.csv.readFile(filePath);
|
||||
let worksheet = workbook.worksheets[0]; // Assuming the CSV file has only one sheet
|
||||
rows = worksheet.getSheetValues();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
GBLogEx.info(min, `Processing ${rows.length} rows from Config file ${filePath}...`);
|
||||
|
||||
// Skips the header lines.
|
||||
|
||||
for (let index = 0; index < 6; index++) {
|
||||
rows.shift();
|
||||
}
|
||||
|
||||
|
||||
let obj = {};
|
||||
await asyncPromise.eachSeries(rows, async line => {
|
||||
|
||||
let obj: any = {};
|
||||
await asyncPromise.eachSeries(rows, async (line: any) => {
|
||||
if (line && line._cells[0] && line._cells[1] && line._cells[0].text) {
|
||||
|
||||
// Extracts values from columns in the current line.
|
||||
|
||||
obj[line._cells[0].text] = line._cells[1].text;
|
||||
}
|
||||
});
|
||||
|
||||
GBLogEx.info(min, GBUtil.toYAML(list));
|
||||
GBLogEx.info(min, GBUtil.toYAML(obj));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -614,9 +624,12 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
switch (packageType) {
|
||||
case '.gbot':
|
||||
|
||||
|
||||
// Extracts configuration information from .gbot files.
|
||||
|
||||
min.instance.params = await this.loadParamsFromTabular(min, localPath);
|
||||
if (min.instance.params.length){
|
||||
|
||||
let connections = [];
|
||||
|
||||
|
@ -643,7 +656,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
// Updates instance object.
|
||||
|
||||
await this.core.saveInstance(min.instance);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case '.gbkb':
|
||||
|
|
|
@ -700,7 +700,7 @@ export class GBMinService {
|
|||
};
|
||||
|
||||
if (!GBConfigService.get('STORAGE_NAME')) {
|
||||
config['domain'] = `http://localhost:${process.env.PORT}/directline/${botId}`;
|
||||
config['domain'] = `http://localhost:${GBConfigService.get('PORT')}/directline/${botId}`;
|
||||
} else {
|
||||
const webchatTokenContainer = await this.getWebchatToken(instance);
|
||||
(config['conversationId'] = webchatTokenContainer.conversationId),
|
||||
|
@ -773,7 +773,7 @@ export class GBMinService {
|
|||
};
|
||||
if (!GBConfigService.get('STORAGE_NAME')) {
|
||||
startRouter(GBServer.globals.server, instance.botId);
|
||||
config['clientOptions'] = { baseUri: `http://localhost:${process.env.PORT}` };
|
||||
config['clientOptions'] = { baseUri: `http://localhost:${GBConfigService.get('PORT')}` };
|
||||
}
|
||||
|
||||
const adapter = new BotFrameworkAdapter(config);
|
||||
|
|
|
@ -492,7 +492,7 @@ export class ChatServices {
|
|||
});
|
||||
} else {
|
||||
dataSource = new DataSource({
|
||||
type: dialect === dialect as any,
|
||||
type: dialect as any,
|
||||
host: host,
|
||||
port: port,
|
||||
database: storageName,
|
||||
|
|
Loading…
Add table
Reference in a new issue