diff --git a/packages/basic.gblib/services/DebuggerService.ts b/packages/basic.gblib/services/DebuggerService.ts index 41eab551..73ae6e21 100644 --- a/packages/basic.gblib/services/DebuggerService.ts +++ b/packages/basic.gblib/services/DebuggerService.ts @@ -45,7 +45,7 @@ import { GBUtil } from '../../../src/util.js'; export class DebuggerService { public async setBreakpoint({ botId, line }) { - GBLogEx.info(botId, `BASIC: Enabled breakpoint for ${botId} on ${line}.`); + GBLogEx.info(botId, `Enabled breakpoint for ${botId} on ${line}.`); GBServer.globals.debuggers[botId].breaks.push(Number.parseInt(line)); } @@ -145,11 +145,11 @@ export class DebuggerService { error = `Cannot DEBUG an already running process. ${botId}`; return { error: error }; } else if (GBServer.globals.debuggers[botId].state === 2) { - GBLogEx.info(botId, `BASIC: Releasing execution ${botId} in DEBUG mode.`); + GBLogEx.info(botId, `Releasing execution ${botId} in DEBUG mode.`); await this.resume({ botId }); return { status: 'OK' }; } else { - GBLogEx.info(botId, `BASIC: Running ${botId} in DEBUG mode.`); + GBLogEx.info(botId, `Running ${botId} in DEBUG mode.`); GBServer.globals.debuggers[botId].state = 1; GBServer.globals.debuggers[botId].stateInfo = 'Running (Debug)'; diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 1350fca4..1ee49ea2 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -144,7 +144,7 @@ export class DialogKeywords { const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); - GBLogEx.info(min, `BASIC: Visualization: Chart generated at ${url}.`); + GBLogEx.info(min, `Visualization: Chart generated at ${url}.`); return url; } @@ -155,7 +155,7 @@ export class DialogKeywords { */ public async getOCR({ pid, localFile }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: OCR processing on ${localFile}.`); + GBLogEx.info(min, `OCR processing on ${localFile}.`); const config = { lang: 'eng', @@ -593,7 +593,7 @@ export class DialogKeywords { */ public async sendFileTo({ pid, mobile, filename, caption }) { const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: SEND FILE TO '${mobile}',filename '${filename}'.`); + GBLogEx.info(min, `SEND FILE TO '${mobile}',filename '${filename}'.`); return await this.internalSendFile({ pid, mobile, channel: proc.channel, filename, caption }); } @@ -605,7 +605,7 @@ export class DialogKeywords { */ public async sendTemplateTo({ pid, mobile, filename }) { const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: SEND TEMPLATE TO '${mobile}',filename '${filename}'.`); + GBLogEx.info(min, `SEND TEMPLATE TO '${mobile}',filename '${filename}'.`); const service = new GBConversationalService(min.core); let text; @@ -626,7 +626,7 @@ export class DialogKeywords { */ public async sendFile({ pid, filename, caption }) { const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: SEND FILE (to: ${user.userSystemId},filename '${filename}'.`); + GBLogEx.info(min, `SEND FILE (to: ${user.userSystemId},filename '${filename}'.`); const mobile = await this.userMobile({ pid }); return await this.internalSendFile({ pid, channel: proc.channel, mobile, filename, caption }); } @@ -708,7 +708,7 @@ export class DialogKeywords { // throw new Error(`Not possible to define ${name} as it is a reserved system param name.`); // } let { min, user, params } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: ${name} = ${value} (botId: ${min.botId})`); + GBLogEx.info(min, `${name} = ${value} (botId: ${min.botId})`); const sec = new SecService(); if (user) { await sec.setParam(user.userId, name, value); @@ -969,9 +969,9 @@ export class DialogKeywords { await this.talk({ pid: pid, text: button }); } - GBLogEx.info(min, `BASIC: HEAR with [${args.toString()}] (Asking for input).`); + GBLogEx.info(min, `HEAR with [${args.toString()}] (Asking for input).`); } else { - GBLogEx.info(min, 'BASIC: HEAR (Asking for input).'); + GBLogEx.info(min, 'HEAR (Asking for input).'); } // Wait for the user to answer. @@ -1377,7 +1377,7 @@ export class DialogKeywords { */ public async talk({ pid, text }) { const { min, user, step } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: TALK '${text} step:${step}'.`); + GBLogEx.info(min, `TALK '${text} step:${step}'.`); if (user) { // TODO: const translate = user ? user.basicOptions.translatorOn : false; @@ -1423,7 +1423,7 @@ export class DialogKeywords { url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); - GBLogEx.info(min, `BASIC: WebAutomation: Sending ${url} to ${mobile} (${channel}).`); + GBLogEx.info(min, `WebAutomation: Sending ${url} to ${mobile} (${channel}).`); } // GBFILE object. @@ -1431,15 +1431,15 @@ export class DialogKeywords { url = filename.url; nameOnly = Path.basename(filename.localName); - GBLogEx.info(min, `BASIC: Sending the GBFILE ${url} to ${mobile} (${channel}).`); + GBLogEx.info(min, `Sending the GBFILE ${url} to ${mobile} (${channel}).`); } // Handles Markdown. else if (filename.indexOf('.md') !== -1) { - GBLogEx.info(min, `BASIC: Sending the contents of ${filename} markdown to mobile ${mobile}.`); + GBLogEx.info(min, `Sending the contents of ${filename} markdown to mobile ${mobile}.`); const md = await min.kbService.getAnswerTextByMediaName(min.instance.instanceId, filename); if (!md) { - GBLogEx.info(min, `BASIC: Markdown file ${filename} not found on database for ${min.instance.botId}.`); + GBLogEx.info(min, `Markdown file ${filename} not found on database for ${min.instance.botId}.`); } await min.conversationalService['playMarkdown'](min, md, DialogKeywords.getChannel(), null, mobile); @@ -1453,7 +1453,7 @@ export class DialogKeywords { let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const fileUrl = urlJoin('/', gbaiName, `${min.botId}.gbdrive`, filename); - GBLogEx.info(min, `BASIC: Direct send from .gbdrive: ${fileUrl} to ${mobile}.`); + GBLogEx.info(min, `Direct send from .gbdrive: ${fileUrl} to ${mobile}.`); const sys = new SystemKeywords(); diff --git a/packages/basic.gblib/services/GBVMService.ts b/packages/basic.gblib/services/GBVMService.ts index 638f920f..16cd3aa4 100644 --- a/packages/basic.gblib/services/GBVMService.ts +++ b/packages/basic.gblib/services/GBVMService.ts @@ -215,7 +215,7 @@ export class GBVMService extends GBService { }`; Fs.writeFileSync(urlJoin(folder, 'package.json'), packageJson); - GBLogEx.info(min, `BASIC: Installing .gbdialog node_modules for ${min.botId}...`); + GBLogEx.info(min, `Installing .gbdialog node_modules for ${min.botId}...`); const npmPath = urlJoin(process.env.PWD, 'node_modules', '.bin', 'npm'); child_process.execSync(`${npmPath} install`, { cwd: folder }); } @@ -431,7 +431,7 @@ export class GBVMService extends GBService { to.hasMany(from); } catch (error) { throw new Error( - `BASIC: Invalid relationship in ${mainName}: from ${e.from} to ${e.to} (${min.botId})... ${error.message}` + `Invalid relationship in ${mainName}: from ${e.from} to ${e.to} (${min.botId})... ${error.message}` ); } }); @@ -439,14 +439,14 @@ export class GBVMService extends GBService { if (sync && shouldSync) { GBLogEx.info( min, - `BASIC: Syncing changes for TABLE ${connectionName} ${tableName} keyword (${min.botId})...` + `Syncing changes for TABLE ${connectionName} ${tableName} keyword (${min.botId})...` ); await seq.sync({ alter: true, force: false // Keep it false due to data loss danger. }); - GBLogEx.info(min, `BASIC: Done sync for ${min.botId} ${connectionName} ${tableName} storage table...`); + GBLogEx.info(min, `Done sync for ${min.botId} ${connectionName} ${tableName} storage table...`); } } }); diff --git a/packages/basic.gblib/services/ImageProcessingServices.ts b/packages/basic.gblib/services/ImageProcessingServices.ts index 7be7aea7..8a0a87a4 100644 --- a/packages/basic.gblib/services/ImageProcessingServices.ts +++ b/packages/basic.gblib/services/ImageProcessingServices.ts @@ -51,7 +51,7 @@ export class ImageProcessingServices { */ public async sharpen({ pid, file: file }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Image Processing SHARPEN ${file}.`); + GBLogEx.info(min, `Image Processing SHARPEN ${file}.`); const gbfile = DialogKeywords.getFileByHandle(file); @@ -92,7 +92,7 @@ export class ImageProcessingServices { */ public async blur({ pid, file: file }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Image Processing SHARPEN ${file}.`); + GBLogEx.info(min, `Image Processing SHARPEN ${file}.`); const gbfile = DialogKeywords.getFileByHandle(file); const data = await sharp(gbfile.data) diff --git a/packages/basic.gblib/services/ScheduleServices.ts b/packages/basic.gblib/services/ScheduleServices.ts index de19c832..dc0ed0e7 100644 --- a/packages/basic.gblib/services/ScheduleServices.ts +++ b/packages/basic.gblib/services/ScheduleServices.ts @@ -66,7 +66,7 @@ export class ScheduleServices extends GBService { }); if (count > 0) { - GBLogEx.info(min, `BASIC: Removed ${name} SET SCHEDULE and ${count} rows from storage on: ${min.botId}...`); + GBLogEx.info(min, `Removed ${name} SET SCHEDULE and ${count} rows from storage on: ${min.botId}...`); } i++; diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index d9a016cc..d6c9f2c1 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -322,7 +322,7 @@ export class SystemKeywords { localName = Path.join('work', gbaiName, 'cache', `img${GBAdminService.getRndReadableIdentifier()}.png`); await page.screenshot({ path: localName, fullPage: true }); url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); - GBLogEx.info(min, `BASIC: Table image generated at ${url} .`); + GBLogEx.info(min, `Table image generated at ${url} .`); } // Handles PDF generation. @@ -331,7 +331,7 @@ export class SystemKeywords { localName = Path.join('work', gbaiName, 'cache', `img${GBAdminService.getRndReadableIdentifier()}.pdf`); url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); let pdf = await page.pdf({ format: 'A4' }); - GBLogEx.info(min, `BASIC: Table PDF generated at ${url} .`); + GBLogEx.info(min, `Table PDF generated at ${url} .`); } await browser.close(); @@ -469,7 +469,7 @@ export class SystemKeywords { public async wait({ pid, seconds }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); // tslint:disable-next-line no-string-based-set-timeout - GBLogEx.info(min, `BASIC: WAIT for ${seconds} second(s).`); + GBLogEx.info(min, `WAIT for ${seconds} second(s).`); const timeout = async (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); await timeout(seconds * 1000); } @@ -482,7 +482,7 @@ export class SystemKeywords { */ public async talkTo({ pid, mobile, message }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Talking '${message}' to a specific user (${mobile}) (TALK TO). `); + GBLogEx.info(min, `Talking '${message}' to a specific user (${mobile}) (TALK TO). `); await min.conversationalService.sendMarkdownToMobile(min, null, mobile, message); } @@ -508,7 +508,7 @@ export class SystemKeywords { */ public async sendSmsTo({ pid, mobile, message }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: SEND SMS TO '${mobile}', message '${message}'.`); + GBLogEx.info(min, `SEND SMS TO '${mobile}', message '${message}'.`); await min.conversationalService.sendSms(min, mobile, message); } @@ -527,7 +527,7 @@ export class SystemKeywords { // Handles calls for HTML stuff if (handle && WebAutomationServices.isSelector(file)) { - GBLogEx.info(min, `BASIC: Web automation SET ${file}' to '${address}' . `); + GBLogEx.info(min, `Web automation SET ${file}' to '${address}' . `); await new WebAutomationServices().setElementText({ pid, handle, selector: file, text: address }); return; @@ -545,7 +545,7 @@ export class SystemKeywords { // Handles calls for BASIC persistence on sheet files. - GBLogEx.info(min, `BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `); + GBLogEx.info(min, `Defining '${address}' in '${file}' to '${value}' (SET). `); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); @@ -632,7 +632,7 @@ export class SystemKeywords { */ public async saveFile({ pid, file, data }): Promise { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Saving '${file}' (SAVE file).`); + GBLogEx.info(min, `Saving '${file}' (SAVE file).`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const botId = min.instance.botId; const path = DialogKeywords.getGBAIPath(min.botId, `gbdrive`); @@ -648,9 +648,9 @@ export class SystemKeywords { await client.api(`${baseUrl}/drive/root:/${path}/${file}:/content`).put(data); } catch (error) { if (error.code === 'itemNotFound') { - GBLogEx.info(min, `BASIC: BASIC source file not found: ${file}.`); + GBLogEx.info(min, `BASIC source file not found: ${file}.`); } else if (error.code === 'nameAlreadyExists') { - GBLogEx.info(min, `BASIC: BASIC destination file already exists: ${file}.`); + GBLogEx.info(min, `BASIC destination file already exists: ${file}.`); } throw error; } @@ -666,7 +666,7 @@ export class SystemKeywords { */ public async uploadFile({ pid, file }): Promise { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: UPLOAD '${file.name}' ${file.size} bytes.`); + GBLogEx.info(min, `UPLOAD '${file.name}' ${file.size} bytes.`); // Checks if it is a GB FILE object. @@ -710,7 +710,7 @@ export class SystemKeywords { return file; } else { - GBLog.error(`BASIC: BLOB HTTP ${res.errorCode} ${res._response.status} .`); + GBLog.error(`BLOB HTTP ${res.errorCode} ${res._response.status} .`); } } @@ -730,17 +730,17 @@ export class SystemKeywords { */ public async saveToStorageBatch({ pid, table, rows }): Promise { const { min } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Saving batch to storage '${table}' (SAVE).`); + GBLogEx.info(min, `SAVE '${table}' ${rows.length} row(s).`); if (rows.length === 0) { return; } const definition = this.getTableFromName(table, min); - const rowsDest = []; + let rowsDest = []; rows.forEach(row => { - const dst = {}; + let dst = {}; let i = 0; Object.keys(row).forEach(column => { const field = column.charAt(0).toUpperCase() + column.slice(1); @@ -748,16 +748,18 @@ export class SystemKeywords { i++; }); rowsDest.push(dst); + dst = null; }); await retry( async bail => { await definition.bulkCreate(GBUtil.caseInsensitive(rowsDest)); + rowsDest = []; }, { retries: 5, onRetry: err => { - GBLog.error(`Retrying SaveToStorageBatch due to: ${JSON.stringify(err)}.`); + GBLog.error(`SAVE (retry): ${GBUtil.toYAML(err)}.`); } } ); @@ -775,7 +777,7 @@ export class SystemKeywords { } const { min } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Saving to storage '${table}' (SAVE).`); + GBLogEx.info(min, `Saving to storage '${table}' (SAVE).`); const definition = this.getTableFromName(table, min); @@ -807,7 +809,7 @@ export class SystemKeywords { public async saveToStorageWithJSON({ pid, table, fieldsValues, fieldsNames }): Promise { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Saving to storage '${table}' (SAVE).`); + GBLogEx.info(min, `Saving to storage '${table}' (SAVE).`); const minBoot = GBServer.globals.minBoot as any; const definition = minBoot.core.sequelize.models[table]; @@ -841,7 +843,7 @@ export class SystemKeywords { } const { min } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Saving '${file}' (SAVE). Args: ${args.join(',')}.`); + GBLogEx.info(min, `Saving '${file}' (SAVE). Args: ${args.join(',')}.`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const botId = min.instance.botId; const path = DialogKeywords.getGBAIPath(botId, 'gbdata'); @@ -929,7 +931,7 @@ export class SystemKeywords { if (result.status != 200) { GBLogEx.info(min, `Waiting 5 secs. before retrying HTTP ${result.status} GET: ${result.url}`); await GBUtil.sleep(5 * 1000); - throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`); + throw new Error(`HTTP:${result.status} retry: ${result.statusText}.`); } }, { @@ -959,7 +961,7 @@ export class SystemKeywords { qs }); } else { - GBLogEx.info(min, `BASIC: GET '${addressOrHeaders}' in '${file}'.`); + GBLogEx.info(min, `GET '${addressOrHeaders}' in '${file}'.`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const botId = min.instance.botId; (''); @@ -978,7 +980,7 @@ export class SystemKeywords { .get(); let val = results.text[0][0]; - GBLogEx.info(min, `BASIC: Getting '${file}' (GET). Value= ${val}.`); + GBLogEx.info(min, `Getting '${file}' (GET). Value= ${val}.`); return val; } } @@ -1073,7 +1075,7 @@ export class SystemKeywords { } else { maxLines = maxLines; } - GBLogEx.info(min, `BASIC: FIND running on ${file} (maxLines: ${maxLines}) and args: ${JSON.stringify(args)}...`); + GBLogEx.info(min, `FIND running on ${file} (maxLines: ${maxLines}) and args: ${JSON.stringify(args)}...`); // Choose data sources based on file type (HTML Table, data variable or sheet file) @@ -1090,7 +1092,7 @@ export class SystemKeywords { // Transforms table - const resultH = await container.evaluate(originalSelector => { + let resultH = await container.evaluate(originalSelector => { const rows = document.querySelectorAll(`${originalSelector} tr`); return Array.from(rows, row => { const columns = row.querySelectorAll('th'); @@ -1098,7 +1100,7 @@ export class SystemKeywords { }); }, originalSelector); - const result = await container.evaluate(originalSelector => { + let result = await container.evaluate(originalSelector => { const rows = document.querySelectorAll(`${originalSelector} tr`); return Array.from(rows, row => { const columns = row.querySelectorAll('td'); @@ -1110,12 +1112,15 @@ export class SystemKeywords { for (let i = 0; i < resultH[0].length; i++) { header[i] = resultH[0][i]; } + resultH = null; + rows = []; rows[0] = header; for (let i = 1; i < result.length; i++) { rows[i] = result[i]; } + result = null; } else if (file['cTag']) { const gbaiName = DialogKeywords.getGBAIPath(min.botId); const localName = Path.join('work', gbaiName, 'cache', `csv${GBAdminService.getRndReadableIdentifier()}.csv`); @@ -1124,7 +1129,7 @@ export class SystemKeywords { Fs.writeFileSync(localName, Buffer.from(await response.arrayBuffer()), { encoding: null }); var workbook = new Excel.Workbook(); - const worksheet = await workbook.csv.readFile(localName); + let worksheet = await workbook.csv.readFile(localName); header = []; rows = []; @@ -1146,6 +1151,7 @@ export class SystemKeywords { rows.push(outRow); } } + worksheet = null; } else if (file.indexOf('.xlsx') !== -1) { let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); @@ -1191,7 +1197,7 @@ export class SystemKeywords { // Increments columnIndex by looping until find a column match. - const filters = []; + let filters = []; let predefinedFilterTypes; if (params.filterTypes) { predefinedFilterTypes = params.filterTypes.split(','); @@ -1201,7 +1207,7 @@ export class SystemKeywords { await CollectionUtil.asyncForEach(args, async arg => { const filter = await SystemKeywords.getFilter(arg); if (!filter) { - throw new Error(`BASIC: FIND filter has an error: ${arg} check this and publish .gbdialog again.`); + throw new Error(`FIND filter has an error: ${arg} check this and publish .gbdialog again.`); } let columnIndex = 0; @@ -1380,15 +1386,18 @@ export class SystemKeywords { } const outputArray = await DialogKeywords.getOption({ pid, name: 'output' }); + filters = null; + header = null; + rows = null; if (table.length === 1) { - GBLogEx.info(min, `BASIC: FIND returned no results (zero rows).`); + GBLogEx.info(min, `FIND returned no results (zero rows).`); return null; } else if (table.length === 2 && !outputArray) { - GBLogEx.info(min, `BASIC: FIND returned single result: ${table[0]}.`); + GBLogEx.info(min, `FIND returned single result: ${table[0]}.`); return table[1]; } else { - GBLogEx.info(min, `BASIC: FIND returned multiple results (Count): ${table.length - 1}.`); + GBLogEx.info(min, `FIND returned multiple results (Count): ${table.length - 1}.`); return table; } } @@ -1547,7 +1556,7 @@ export class SystemKeywords { } public async internalCreateDocument(min, path, content) { - GBLogEx.info(min, `BASIC: CREATE DOCUMENT '${path}...'`); + GBLogEx.info(min, `CREATE DOCUMENT '${path}...'`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const gbaiName = DialogKeywords.getGBAIPath(min.botId); const tmpDocx = urlJoin(gbaiName, path); @@ -1583,7 +1592,7 @@ export class SystemKeywords { */ public async copyFile({ pid, src, dest }) { const { min, user, params } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: BEGINING COPY '${src}' to '${dest}'`); + GBLogEx.info(min, `BEGINING COPY '${src}' to '${dest}'`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const botId = min.instance.botId; @@ -1619,13 +1628,13 @@ export class SystemKeywords { name: `${Path.basename(dest)}` }; const file = await client.api(`${baseUrl}/drive/items/${srcFile.id}/copy`).post(destFile); - GBLogEx.info(min, `BASIC: FINISHED COPY '${src}' to '${dest}'`); + GBLogEx.info(min, `FINISHED COPY '${src}' to '${dest}'`); return file; } catch (error) { if (error.code === 'itemNotFound') { - GBLogEx.info(min, `BASIC: COPY source file not found: ${srcPath}.`); + GBLogEx.info(min, `COPY source file not found: ${srcPath}.`); } else if (error.code === 'nameAlreadyExists') { - GBLogEx.info(min, `BASIC: COPY destination file already exists: ${dstPath}.`); + GBLogEx.info(min, `COPY destination file already exists: ${dstPath}.`); } throw error; } @@ -1644,7 +1653,7 @@ export class SystemKeywords { */ public async convert({ pid, src, dest }) { const { min, user, params } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: CONVERT '${src}' to '${dest}'`); + GBLogEx.info(min, `CONVERT '${src}' to '${dest}'`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const botId = min.instance.botId; @@ -1690,9 +1699,9 @@ export class SystemKeywords { await client.api(`${baseUrl}/drive/root:/${dstPath}:/content`).put(result); } catch (error) { if (error.code === 'itemNotFound') { - GBLogEx.info(min, `BASIC: CONVERT source file not found: ${srcPath}.`); + GBLogEx.info(min, `CONVERT source file not found: ${srcPath}.`); } else if (error.code === 'nameAlreadyExists') { - GBLogEx.info(min, `BASIC: CONVERT destination file already exists: ${dstPath}.`); + GBLogEx.info(min, `CONVERT destination file already exists: ${dstPath}.`); } throw error; } @@ -1789,17 +1798,17 @@ export class SystemKeywords { if (result.status === 401) { GBLogEx.info(min, `Waiting 5 secs. before retrying HTTP 401 GET: ${url}`); await GBUtil.sleep(5 * 1000); - throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`); + throw new Error(`HTTP:${result.status} retry: ${result.statusText}.`); } if (result.status === 429) { GBLogEx.info(min, `Waiting 1min. before retrying HTTP 429 GET: ${url}`); await GBUtil.sleep(60 * 1000); - throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`); + throw new Error(`HTTP:${result.status} retry: ${result.statusText}.`); } if (result.status === 503) { GBLogEx.info(min, `Waiting 1h before retrying GET 503: ${url}`); await GBUtil.sleep(60 * 60 * 1000); - throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`); + throw new Error(`HTTP:${result.status} retry: ${result.statusText}.`); } if (result.status === 2000) { @@ -1809,7 +1818,7 @@ export class SystemKeywords { bail(new Error(`Expired Token for ${url}.`)); } if (result.status != 200) { - throw new Error(`BASIC: GET ${result.status}: ${result.statusText}.`); + throw new Error(`GET ${result.status}: ${result.statusText}.`); } }, { @@ -1852,7 +1861,7 @@ export class SystemKeywords { if (res) { res['pageMode'] = pageMode; } - + result = null; return res; } @@ -1882,10 +1891,10 @@ export class SystemKeywords { let result = await fetch(url, options); const text = await result.text(); - GBLogEx.info(min, `BASIC: PUT ${url} (${data}): ${text}`); + GBLogEx.info(min, `PUT ${url} (${data}): ${text}`); if (result.status != 200 && result.status != 201) { - throw new Error(`BASIC: PUT ${result.status}: ${result.statusText}.`); + throw new Error(`PUT ${result.status}: ${result.statusText}.`); } let res = JSON.parse(text); @@ -1917,10 +1926,10 @@ export class SystemKeywords { let result = await fetch(url, options); const text = await result.text(); - GBLogEx.info(min, `BASIC: POST ${url} (${data}): ${text}`); + GBLogEx.info(min, `POST ${url} (${data}): ${text}`); if (result.status != 200 && result.status != 201) { - throw new Error(`BASIC: POST ${result.status}: ${result.statusText}.`); + throw new Error(`POST ${result.status}: ${result.statusText}.`); } let res = JSON.parse(text); @@ -2113,11 +2122,11 @@ export class SystemKeywords { public async merge({ pid, file, data, key1, key2 }): Promise { const { min, user, params } = await DialogKeywords.getProcessInfo(pid); if (!data || data.length === 0) { - GBLog.verbose(`BASIC: MERGE running on ${file}: NO DATA.`); + GBLog.verbose(`MERGE running on ${file}: NO DATA.`); return data; } - GBLogEx.info(min, `BASIC: MERGE running on ${file} and key1: ${key1}, key2: ${key2}...`); + GBLogEx.info(min, `MERGE running on ${file} and key1: ${key1}, key2: ${key2}...`); if (!this.cachedMerge[pid]) { this.cachedMerge[pid] = { file: {} }; } @@ -2185,7 +2194,7 @@ export class SystemKeywords { page++; count = paged.length; - GBLogEx.info(min, `BASIC: MERGE cached: ${rows.length} from page: ${page}.`); + GBLogEx.info(min, `MERGE cached: ${rows.length} from page: ${page}.`); } }, { @@ -2404,7 +2413,14 @@ export class SystemKeywords { await this.saveToStorageBatch({ pid, table: file, rows: fieldsValuesList }); } - GBLogEx.info(min, `BASIC: MERGE results: adds:${adds}, updates:${updates} , skipped: ${skipped}.`); + table = null; + fieldsValuesList = null; + rows = null; + header = null; + results = null; + t = null; + + GBLogEx.info(min, `MERGE results: adds:${adds}, updates:${updates} , skipped: ${skipped}.`); return { title: file, adds, updates, skipped }; } @@ -2445,7 +2461,7 @@ export class SystemKeywords { const { min, user } = await DialogKeywords.getProcessInfo(pid); const prompt = `rewrite this sentence in a better way: ${text}`; const answer = await ChatServices.continue(min, prompt, 0); - GBLogEx.info(min, `BASIC: REWRITE ${text} TO ${answer}`); + GBLogEx.info(min, `REWRITE ${text} TO ${answer}`); return answer; } @@ -2532,7 +2548,7 @@ export class SystemKeywords { private async internalAutoSave({ min, handle }) { const file = GBServer.globals.files[handle]; - GBLogEx.info(min, `BASIC: Auto saving '${file.filename}' (SAVE file).`); + GBLogEx.info(min, `Auto saving '${file.filename}' (SAVE file).`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const path = DialogKeywords.getGBAIPath(min.botId, `gbdrive`); @@ -2556,7 +2572,7 @@ export class SystemKeywords { public async deleteFromStorage({ pid, table, criteria }) { const { min } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: DELETE (storage) '${table}' where ${criteria}.`); + GBLogEx.info(min, `DELETE '${table}' where ${criteria}.`); const definition = this.getTableFromName(table, min); const filter = await SystemKeywords.getFilter(criteria); @@ -2580,7 +2596,7 @@ export class SystemKeywords { public async deleteFile({ pid, file }) { const { min } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: DELETE '${file.name}'.`); + GBLogEx.info(min, `DELETE '${file.name}'.`); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min); const gbaiPath = DialogKeywords.getGBAIPath(min.botId); diff --git a/packages/basic.gblib/services/WebAutomationServices.ts b/packages/basic.gblib/services/WebAutomationServices.ts index 4214ac1e..e985adbd 100644 --- a/packages/basic.gblib/services/WebAutomationServices.ts +++ b/packages/basic.gblib/services/WebAutomationServices.ts @@ -93,7 +93,7 @@ export class WebAutomationServices { public async openPage({ pid, handle, sessionKind, sessionName, url, username, password }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Web Automation OPEN ${sessionName ? sessionName : ''} ${url}.`); + GBLogEx.info(min, `Web Automation OPEN ${sessionName ? sessionName : ''} ${url}.`); // Try to find an existing handle. @@ -192,7 +192,7 @@ export class WebAutomationServices { public async getBySelector({ handle, selector, pid }) { const page = WebAutomationServices.getPageByHandle(handle); const { min, user } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: Web Automation GET element: ${selector}.`); + GBLogEx.info(min, `Web Automation GET element: ${selector}.`); await page.waitForSelector(selector); let elements = await page.$$(selector); if (elements && elements.length > 1) { @@ -217,7 +217,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation GET element by frame: ${selector}.`); + GBLogEx.info(min, `Web Automation GET element by frame: ${selector}.`); await page.waitForSelector(frame); let frameHandle = await page.$(frame); const f = await frameHandle.contentFrame(); @@ -239,7 +239,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation HOVER element: ${selector}.`); + GBLogEx.info(min, `Web Automation HOVER element: ${selector}.`); await this.getBySelector({ handle, selector: selector, pid }); await page.hover(selector); await this.debugStepWeb(pid, page); @@ -254,7 +254,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation CLICK element: ${frameOrSelector}.`); + GBLogEx.info(min, `Web Automation CLICK element: ${frameOrSelector}.`); if (selector) { await page.waitForSelector(frameOrSelector); let frameHandle = await page.$(frameOrSelector); @@ -297,7 +297,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation PRESS ${char} ON element: ${frame}.`); + GBLogEx.info(min, `Web Automation PRESS ${char} ON element: ${frame}.`); if (char.toLowerCase() === 'enter') { char = '\n'; } @@ -315,7 +315,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation CLICK LINK TEXT: ${text} ${index}.`); + GBLogEx.info(min, `Web Automation CLICK LINK TEXT: ${text} ${index}.`); if (!index) { index = 1; } @@ -328,7 +328,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation CLICK BUTTON: ${text} ${index}.`); + GBLogEx.info(min, `Web Automation CLICK BUTTON: ${text} ${index}.`); if (!index) { index = 1; } @@ -346,7 +346,7 @@ export class WebAutomationServices { public async screenshot({ pid, handle, selector }) { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation SCREENSHOT ${selector}.`); + GBLogEx.info(min, `Web Automation SCREENSHOT ${selector}.`); const gbaiName = DialogKeywords.getGBAIPath(min.botId); const localName = Path.join('work', gbaiName, 'cache', `screen-${GBAdminService.getRndReadableIdentifier()}.jpg`); @@ -354,7 +354,7 @@ export class WebAutomationServices { await page.screenshot({ path: localName }); const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName)); - GBLogEx.info(min, `BASIC: WebAutomation: Screenshot captured at ${url}.`); + GBLogEx.info(min, `WebAutomation: Screenshot captured at ${url}.`); return { data: null, localName: localName, url: url }; } @@ -369,7 +369,7 @@ export class WebAutomationServices { text = `${text}`; const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation TYPE on ${selector}: ${text}.`); + GBLogEx.info(min, `Web Automation TYPE on ${selector}: ${text}.`); const e = await this.getBySelector({ handle, selector, pid }); await e.click({ clickCount: 3 }); await page.keyboard.press('Backspace'); @@ -409,7 +409,7 @@ export class WebAutomationServices { const cookies = await page.cookies(); options.headers.Cookie = cookies.map(ck => ck.name + '=' + ck.value).join(';'); - GBLogEx.info(min, `BASIC: DOWNLOADING '${options.uri}...'`); + GBLogEx.info(min, `DOWNLOADING '${options.uri}...'`); let local; let filename; @@ -455,7 +455,7 @@ export class WebAutomationServices { file = await client.api(`${baseUrl}/drive/root:/${dstPath}:/content`).put(result); } catch (error) { if (error.code === 'nameAlreadyExists') { - GBLogEx.info(min, `BASIC: DOWNLOAD destination file already exists: ${dstPath}.`); + GBLogEx.info(min, `DOWNLOAD destination file already exists: ${dstPath}.`); } throw error; } @@ -484,7 +484,7 @@ export class WebAutomationServices { const { min, user } = await DialogKeywords.getProcessInfo(pid); const page = WebAutomationServices.getPageByHandle(handle); - GBLogEx.info(min, `BASIC: Web Automation CLICK element: ${frameOrSelector}.`); + GBLogEx.info(min, `Web Automation CLICK element: ${frameOrSelector}.`); if (frameOrSelector) { const result = await page.$eval( frameOrSelector, diff --git a/packages/basic.gblib/services/vm2-process/index.ts b/packages/basic.gblib/services/vm2-process/index.ts index aa36f47a..ae24cbdd 100644 --- a/packages/basic.gblib/services/vm2-process/index.ts +++ b/packages/basic.gblib/services/vm2-process/index.ts @@ -175,7 +175,7 @@ export const createVm2Pool = ({ min, max, ...limits }) => { GBServer.globals.debuggers[limits.botId].state = 0; GBServer.globals.debuggers[limits.botId].stateInfo = 'Fail'; } else if (stderrCache.includes('Debugger attached.')) { - GBLogEx.info(min, `BASIC: General Bots Debugger attached to Node .gbdialog process for ${limits.botId}.`); + GBLogEx.info(min, `General Bots Debugger attached to Node .gbdialog process for ${limits.botId}.`); } }); @@ -212,16 +212,16 @@ export const createVm2Pool = ({ min, max, ...limits }) => { }); } GBServer.globals.debuggers[limits.botId].scope = variablesText; - GBLogEx.info(min,`BASIC: Breakpoint variables: ${variablesText}`); // (zero-based) + GBLogEx.info(min,`Breakpoint variables: ${variablesText}`); // (zero-based) // Processes breakpoint hits. if (hitBreakpoints.length >= 1) { - GBLogEx.info(min, `BASIC: Break at line ${frame.location.lineNumber + 1}`); // (zero-based) + GBLogEx.info(min, `Break at line ${frame.location.lineNumber + 1}`); // (zero-based) GBServer.globals.debuggers[limits.botId].state = 2; GBServer.globals.debuggers[limits.botId].stateInfo = 'Break'; } else { - GBLog.verbose(`BASIC: Configuring breakpoints if any for ${limits.botId}...`); + GBLog.verbose(`Configuring breakpoints if any for ${limits.botId}...`); // Waits for debugger and setup breakpoints. await CollectionUtil.asyncForEach(GBServer.globals.debuggers[limits.botId].breaks, async brk => { diff --git a/packages/basic.gblib/services/vm2-process/vm2ProcessRunner.ts b/packages/basic.gblib/services/vm2-process/vm2ProcessRunner.ts index adb14526..dee088a3 100644 --- a/packages/basic.gblib/services/vm2-process/vm2ProcessRunner.ts +++ b/packages/basic.gblib/services/vm2-process/vm2ProcessRunner.ts @@ -39,7 +39,7 @@ const server = net1.createServer(socket => { socket.write(JSON.stringify({ result }) + '\n'); socket.end(); } catch (error) { - console.log(`BASIC: RUNTIME: ${error.message}, ${error.stack}`); + console.log(`RUNTIME: ${error.message}, ${error.stack}`); socket.write(JSON.stringify({ error: error.message }) + '\n'); socket.end(); } diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index 53765ac6..c2e5d75d 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -412,7 +412,7 @@ export class GBConversationalService { nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, {}, (err, data) => { const message = data.messages ? data.messages[0] : {}; if (err || message['error-text']) { - GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`); + GBLog.error(`error sending SMS to ${mobile}: ${message['error-text']}`); reject(message['error-text']); } else { resolve(data); diff --git a/packages/llm.gblib/services/ImageServices.ts b/packages/llm.gblib/services/ImageServices.ts index 180bfe87..04a3f82a 100644 --- a/packages/llm.gblib/services/ImageServices.ts +++ b/packages/llm.gblib/services/ImageServices.ts @@ -74,7 +74,7 @@ export class ImageServices { let buf: any = Buffer.from(await res.arrayBuffer()); Fs.writeFileSync(localName, buf, { encoding: null }); - GBLogEx.info(min, `BASIC: DALL-E image generated at ${url}.`); + GBLogEx.info(min, `DALL-E image generated at ${url}.`); return { localName, url }; } diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 8eb45a10..99fd44c3 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -410,7 +410,7 @@ export class WhatsappDirectLine extends GBService { const botId = this.min.instance.botId; const state = WhatsappDirectLine.state[botId + from]; if (state) { - GBLog.verbose(`BASIC: Continuing HEAR from WhatsApp...`); + GBLog.verbose(`Continuing HEAR from WhatsApp...`); WhatsappDirectLine.state[botId + from] = null; await state.promise(null, text);